From 6f4aa0458c991e3f81154469265899e30fe8121e Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 29 Aug 2019 14:41:14 +0200 Subject: [PATCH] Remove usages of deprecated APIs (part 2) Replace the uses of deprecated APIs listed below, while keeping in mind that compatibility with Qt 5.12 (the latest LTS) must be kept. This means that the new alternatives must be used only when compiling with Qt versions where the replacement is available. Replaced: QLineF::intersect() -> QLine::intersects() (since 5.14) QComboBox::activated() -> QComboBox::textActivated() (since 5.14) QWheelEvent::pos() -> QWheelEvent::position() (since 5.14) QList::swap() -> QList::swapItemsAt() (since 5.13) Task-number: QTBUG-76491 Change-Id: I62adc4f0826607b0156bf4bc5648ffb0e41cd895 Reviewed-by: Eike Ziller --- .../qmt/infrastructure/geometryutilities.cpp | 4 ++++ .../model_widgets_ui/propertiesviewmview.cpp | 5 +++++ src/libs/tracing/timelinerenderer.cpp | 5 +++++ src/plugins/modeleditor/editordiagramview.cpp | 9 +++++++-- .../componentcore/changestyleaction.cpp | 4 ++++ .../common/navigatorgraphicsview.cpp | 4 ++++ .../plugin_interface/sceneutils.cpp | 4 ++++ .../plugin_interface/transitionitem.cpp | 20 +++++++++++++++++++ 8 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/libs/modelinglib/qmt/infrastructure/geometryutilities.cpp b/src/libs/modelinglib/qmt/infrastructure/geometryutilities.cpp index 9968fbf0b89..5a42bf1f33d 100644 --- a/src/libs/modelinglib/qmt/infrastructure/geometryutilities.cpp +++ b/src/libs/modelinglib/qmt/infrastructure/geometryutilities.cpp @@ -58,7 +58,11 @@ bool GeometryUtilities::intersect(const QPolygonF &polygon, const QLineF &line, { for (int i = 0; i <= polygon.size() - 2; ++i) { QLineF polygonLine(polygon.at(i), polygon.at(i+1)); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectType intersectionType = polygonLine.intersect(line, intersectionPoint); +#else + QLineF::IntersectType intersectionType = polygonLine.intersects(line, intersectionPoint); +#endif if (intersectionType == QLineF::BoundedIntersection) { if (intersectionLine) *intersectionLine = polygonLine; diff --git a/src/libs/modelinglib/qmt/model_widgets_ui/propertiesviewmview.cpp b/src/libs/modelinglib/qmt/model_widgets_ui/propertiesviewmview.cpp index 81c71501c23..31c764c5ada 100644 --- a/src/libs/modelinglib/qmt/model_widgets_ui/propertiesviewmview.cpp +++ b/src/libs/modelinglib/qmt/model_widgets_ui/propertiesviewmview.cpp @@ -352,8 +352,13 @@ void PropertiesView::MView::visitMElement(const MElement *element) m_stereotypeComboBox->addItems(m_propertiesView->stereotypeController()->knownStereotypes(m_stereotypeElement)); connect(m_stereotypeComboBox->lineEdit(), &QLineEdit::textEdited, this, &PropertiesView::MView::onStereotypesChanged); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) connect(m_stereotypeComboBox, QOverload::of(&QComboBox::activated), this, &PropertiesView::MView::onStereotypesChanged); +#else + connect(m_stereotypeComboBox, &QComboBox::textActivated, + this, &PropertiesView::MView::onStereotypesChanged); +#endif } if (!m_stereotypeComboBox->hasFocus()) { QList stereotypeList; diff --git a/src/libs/tracing/timelinerenderer.cpp b/src/libs/tracing/timelinerenderer.cpp index a93444570a0..2abd234e01a 100644 --- a/src/libs/tracing/timelinerenderer.cpp +++ b/src/libs/tracing/timelinerenderer.cpp @@ -209,8 +209,13 @@ void TimelineRenderer::wheelEvent(QWheelEvent *event) int degrees = (event->angleDelta().x() + event->angleDelta().y()) / 8; const qint64 circle = 360; +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) qint64 mouseTime = event->pos().x() * zoom->windowDuration() / width() + zoom->windowStart(); +#else + qint64 mouseTime = event->position().toPoint().x() * zoom->windowDuration() / width() + + zoom->windowStart(); +#endif qint64 beforeMouse = (mouseTime - zoom->rangeStart()) * (circle - degrees) / circle; qint64 afterMouse = (zoom->rangeEnd() - mouseTime) * (circle - degrees) / circle; diff --git a/src/plugins/modeleditor/editordiagramview.cpp b/src/plugins/modeleditor/editordiagramview.cpp index bf15165c80f..c7c93db493b 100644 --- a/src/plugins/modeleditor/editordiagramview.cpp +++ b/src/plugins/modeleditor/editordiagramview.cpp @@ -71,10 +71,15 @@ void EditorDiagramView::wheelEvent(QWheelEvent *wheelEvent) { if (wheelEvent->modifiers() == Qt::ControlModifier) { int degree = wheelEvent->angleDelta().y() / 8; +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + QPoint zoomOrigin = wheelEvent->pos(); +#else + QPoint zoomOrigin = wheelEvent->position().toPoint(); +#endif if (degree > 0) - emit zoomIn(wheelEvent->pos()); + emit zoomIn(zoomOrigin); else if (degree < 0) - emit zoomOut(wheelEvent->pos()); + emit zoomOut(zoomOrigin); } } diff --git a/src/plugins/qmldesigner/components/componentcore/changestyleaction.cpp b/src/plugins/qmldesigner/components/componentcore/changestyleaction.cpp index c2a17cd7b12..b7e10a6da70 100644 --- a/src/plugins/qmldesigner/components/componentcore/changestyleaction.cpp +++ b/src/plugins/qmldesigner/components/componentcore/changestyleaction.cpp @@ -90,7 +90,11 @@ QWidget *ChangeStyleWidgetAction::createWidget(QWidget *parent) }); connect(comboBox, + #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QOverload::of(&QComboBox::activated), + #else + &QComboBox::textActivated, + #endif this, [this](const QString &style) { diff --git a/src/plugins/scxmleditor/common/navigatorgraphicsview.cpp b/src/plugins/scxmleditor/common/navigatorgraphicsview.cpp index c1c81736383..e49aaaefca6 100644 --- a/src/plugins/scxmleditor/common/navigatorgraphicsview.cpp +++ b/src/plugins/scxmleditor/common/navigatorgraphicsview.cpp @@ -80,7 +80,11 @@ void NavigatorGraphicsView::wheelEvent(QWheelEvent *event) else emit zoomOut(); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) emit moveMainViewTo(mapToScene(event->pos())); +#else + emit moveMainViewTo(mapToScene(event->position().toPoint())); +#endif } else QGraphicsView::wheelEvent(event); } diff --git a/src/plugins/scxmleditor/plugin_interface/sceneutils.cpp b/src/plugins/scxmleditor/plugin_interface/sceneutils.cpp index 016749d221a..04456168d66 100644 --- a/src/plugins/scxmleditor/plugin_interface/sceneutils.cpp +++ b/src/plugins/scxmleditor/plugin_interface/sceneutils.cpp @@ -224,7 +224,11 @@ void layout(const QList &items) firstItem = initialItem->outputTransitions().constFirst()->connectedItem(initialItem); int index = childItems.indexOf(firstItem); if (index > 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) childItems.swap(index, 0); +#else + childItems.swapItemsAt(index, 0); +#endif } // Search final-item diff --git a/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp b/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp index eb05ca403f0..fefa5c3e565 100644 --- a/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp +++ b/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp @@ -306,11 +306,19 @@ void TransitionItem::mousePressEvent(QGraphicsSceneMouseEvent *event) QPointF intersPoint; QLineF line2(p, p + QPointF(SELECTION_DISTANCE, SELECTION_DISTANCE)); line2.setAngle(line.angle() + 90); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) if (line.intersect(line2, &intersPoint) == QLineF::BoundedIntersection) +#else + if (line.intersects(line2, &intersPoint) == QLineF::BoundedIntersection) +#endif sel = true; else { line2.setAngle(line.angle() - 90); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) sel = line.intersect(line2, &intersPoint) == QLineF::BoundedIntersection; +#else + sel = line.intersects(line2, &intersPoint) == QLineF::BoundedIntersection; +#endif } if (sel) @@ -797,7 +805,11 @@ QPointF TransitionItem::findIntersectionPoint(ConnectableItem *item, const QLine for (int i = 1; i < itemPolygon.count(); ++i) { p2 = itemPolygon.at(i) + item->scenePos(); checkLine = QLineF(p1, p2); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) if (checkLine.intersect(line, &intersectPoint) == QLineF::BoundedIntersection) +#else + if (checkLine.intersects(line, &intersectPoint) == QLineF::BoundedIntersection) +#endif return intersectPoint; p1 = p2; } @@ -1083,11 +1095,19 @@ bool TransitionItem::containsScenePoint(const QPointF &p) const QPointF intersPoint; QLineF line2(pp, pp + QPointF(SELECTION_DISTANCE, SELECTION_DISTANCE)); line2.setAngle(line.angle() + 90); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) if (line.intersect(line2, &intersPoint) == QLineF::BoundedIntersection) { +#else + if (line.intersects(line2, &intersPoint) == QLineF::BoundedIntersection) { +#endif return true; } else { line2.setAngle(line.angle() - 90); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) if (line.intersect(line2, &intersPoint) == QLineF::BoundedIntersection) +#else + if (line.intersects(line2, &intersPoint) == QLineF::BoundedIntersection) +#endif return true; } }