Skip to content

Commit 0506b50

Browse files
authored
OMPlot/OMEdit: QMouseEvent::globalPos, x, y are deprecated (#13020)
* OMPlot: QMouseEvent::globalPos is deprecated * OMEdit: globalPos is deprecated * OMEdit: QMouseEvent::x(), y() is deprecated * OMNotebook: Use QT_VERSION_CHECK
1 parent 242d200 commit 0506b50

File tree

8 files changed

+37
-5
lines changed

8 files changed

+37
-5
lines changed

OMEdit/OMEditLIB/Animation/ViewerWidget.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ void ViewerWidget::keyReleaseEvent(QKeyEvent *event)
210210
void ViewerWidget::mouseMoveEvent(QMouseEvent *event)
211211
{
212212
int pixelRatio = qCeil(qApp->devicePixelRatio());
213+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
214+
getEventQueue()->mouseMotion(static_cast<float>(event->position().x() * pixelRatio), static_cast<float>(event->position().y() * pixelRatio));
215+
#else
213216
getEventQueue()->mouseMotion(static_cast<float>(event->x() * pixelRatio), static_cast<float>(event->y() * pixelRatio));
217+
#endif
214218
}
215219

216220
/*!
@@ -240,15 +244,23 @@ void ViewerWidget::mousePressEvent(QMouseEvent *event)
240244
mMouseButton = 3;
241245
if (event->modifiers() == Qt::ShiftModifier) {
242246
//qt counts pixels from upper left corner and osg from bottom left corner
247+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
248+
pickVisualizer(event->position().x() * pixelRatio, (this->height() - event->position().y()) * pixelRatio);
249+
#else
243250
pickVisualizer(event->x() * pixelRatio, (this->height() - event->y()) * pixelRatio);
251+
#endif
244252
showVisualizerPickContextMenu(event->pos());
245253
return;
246254
}
247255
break;
248256
default:
249257
break;
250258
}
259+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
260+
getEventQueue()->mouseButtonPress(static_cast<float>(event->position().x() * pixelRatio), static_cast<float>(event->position().y() * pixelRatio), mMouseButton);
261+
#else
251262
getEventQueue()->mouseButtonPress(static_cast<float>(event->x() * pixelRatio), static_cast<float>(event->y() * pixelRatio), mMouseButton);
263+
#endif
252264
}
253265

254266
/*!
@@ -499,7 +511,11 @@ void ViewerWidget::mouseReleaseEvent(QMouseEvent *event)
499511
break;
500512
}
501513
int pixelRatio = qCeil(qApp->devicePixelRatio());
514+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
515+
getEventQueue()->mouseButtonRelease(static_cast<float>(event->position().x() * pixelRatio), static_cast<float>(event->position().y() * pixelRatio), mMouseButton);
516+
#else
502517
getEventQueue()->mouseButtonRelease(static_cast<float>(event->x() * pixelRatio), static_cast<float>(event->y() * pixelRatio), mMouseButton);
518+
#endif
503519
}
504520

505521
/*!

OMEdit/OMEditLIB/Editors/BaseEditor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,11 @@ void PlainTextEdit::lineNumberAreaMouseEvent(QMouseEvent *event)
10611061
QMenu menu(this);
10621062
mpBaseEditor->getToggleBreakpointAction()->setData(QStringList() << fileName << QString::number(lineNumber));
10631063
menu.addAction(mpBaseEditor->getToggleBreakpointAction());
1064+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
1065+
menu.exec(event->globalPosition().toPoint());
1066+
#else
10641067
menu.exec(event->globalPos());
1068+
#endif
10651069
}
10661070
}
10671071
}

OMEdit/OMEditLIB/Modeling/ItemDelegate.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ ItemDelegate::ItemDelegate(QObject *pParent, bool drawRichText, bool drawGrid)
5252
QString ItemDelegate::formatDisplayText(QVariant variant) const
5353
{
5454
QString text;
55+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
56+
if (variant.typeId() == QMetaType::Double) {
57+
#else
5558
if (variant.type() == QVariant::Double) {
59+
#endif
5660
text = QLocale().toString(variant.toDouble());
5761
} else {
5862
text = variant.toString();
@@ -88,7 +92,11 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
8892
QRect decorationRect;
8993
value = index.data(Qt::DecorationRole);
9094
if (value.isValid()) {
95+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
96+
if (value.typeId() == QMetaType::QIcon) {
97+
#else
9198
if (value.type() == QVariant::Icon) {
99+
#endif
92100
icon = qvariant_cast<QIcon>(value);
93101
decorationRect = QRect(QPoint(0, 0), icon.actualSize(opt.decorationSize, iconMode, iconState));
94102
} else {

OMNotebook/OMNotebook/OMNotebookGUI/cell.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ namespace IAEX
383383
}
384384
else if( (*current)->attribute() == "FontFamily" )
385385
{
386-
#if QT_VERSION >= 0x060000
386+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
387387
style_.textCharFormat()->setFontFamilies({(*current)->value()});
388388
#else
389389
style_.textCharFormat()->setFontFamily( (*current)->value() );

OMNotebook/OMNotebook/OMNotebookGUI/cellstyle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace IAEX
6969
public:
7070
CellStyle()
7171
{
72-
#if QT_VERSION >= 0x060000
72+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
7373
textFormat_.setFontFamilies({"Times New Roman"});
7474
#else
7575
textFormat_.setFontFamily( "Times New Roman" );

OMNotebook/OMNotebook/OMNotebookGUI/stylesheet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ namespace IAEX
363363
// FAMILY
364364
if( fontElement.tagName() == "family" )
365365
{
366-
#if QT_VERSION >= 0x060000
366+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
367367
item->textCharFormat()->setFontFamilies({fontElement.text()});
368368
#else
369369
item->textCharFormat()->setFontFamily( fontElement.text() );

OMPlot/OMPlot/OMPlotGUI/Legend.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ bool Legend::eventFilter(QObject *object, QEvent *event)
9292
#endif
9393
if (pPlotCurve) {
9494
QString toolTip = tr("Name: <b>%1</b><br />Filename: <b>%2</b>").arg(pPlotCurve->title().text()).arg(pPlotCurve->getFileName());
95+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
96+
QToolTip::showText(pMouseEvent->globalPosition().toPoint(), toolTip, this);
97+
#else
9598
QToolTip::showText(pMouseEvent->globalPos(), toolTip, this);
99+
#endif
96100
} else {
97101
QToolTip::hideText();
98102
}

OMShell/OMShell/OMShellGUI/oms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ OMS::OMS( QWidget* parent )
280280
}
281281

282282
// command stuff
283-
#if QT_VERSION >= 0x060000
283+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
284284
commandSignFormat_.setFontFamilies({"Arial"});
285285
#else
286286
commandSignFormat_.setFontFamily( "Arial" );
@@ -449,7 +449,7 @@ void OMS::addCommandLine()
449449

450450
// set original text settings
451451
moshEdit_->document()->setDefaultFont(QFont("Courier New", fontSize_, QFont::Normal));
452-
#if QT_VERSION >= 0x060000
452+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
453453
textFormat_.setFontFamilies({"Courier New"});
454454
#else
455455
textFormat_.setFontFamily( "Courier New" );

0 commit comments

Comments
 (0)