diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-09-10 17:05:10 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-10-23 09:58:57 +0200 |
commit | 11bad6109606794091adc3b8a14070ac09707f45 (patch) | |
tree | 603d07bada752a534a8549c6d008b9b8a4aa832a /tests/auto/widgets/itemviews | |
parent | a618c260ed0d1de711a5bc20337f9b8c3835c407 (diff) |
Deprecate QVariant::Type
It's been obsolete for a long time already. Make sure
the compiler now warns about it and remove all remaining
uses in qtbase.
Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews')
3 files changed, 25 insertions, 25 deletions
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index a8a39b7113..7493daa432 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -881,7 +881,7 @@ void tst_QItemDelegate::dateAndTimeEditorTest2() QCOMPARE(w.fastEdit(i1), timeEdit.data()); timeEdit->setTime(time1); d->setModelData(timeEdit, &s, i1); - QCOMPARE(s.data(i1).type(), QVariant::Time); // ensure that we wrote a time variant. + QCOMPARE(s.data(i1).metaType().id(), QMetaType::QTime); // ensure that we wrote a time variant. QCOMPARE(s.data(i1).toTime(), time1); // ensure that it is the correct time. w.doCloseEditor(timeEdit); QVERIFY(d->currentEditor() == 0); // should happen at doCloseEditor. We only test this once. @@ -910,7 +910,7 @@ void tst_QItemDelegate::dateAndTimeEditorTest2() QCOMPARE(dateTimeEdit->dateTime(), datetime2); dateTimeEdit->setDateTime(datetime1); d->setModelData(dateTimeEdit, &s, i1); - QCOMPARE(s.data(i1).type(), QVariant::DateTime); // ensure that we wrote a datetime variant. + QCOMPARE(s.data(i1).metaType().id(), QMetaType::QDateTime); // ensure that we wrote a datetime variant. QCOMPARE(s.data(i1).toDateTime(), datetime1); w.doCloseEditor(dateTimeEdit); @@ -921,7 +921,7 @@ void tst_QItemDelegate::dateAndTimeEditorTest2() QCOMPARE(w.fastEdit(i2), dateEdit.data()); dateEdit->setDate(date1); d->setModelData(dateEdit, &s, i2); - QCOMPARE(s.data(i2).type(), QVariant::Date); // ensure that we wrote a time variant. + QCOMPARE(s.data(i2).metaType().id(), QMetaType::QDate); // ensure that we wrote a time variant. QCOMPARE(s.data(i2).toDate(), date1); // ensure that it is the correct date. w.doCloseEditor(dateEdit); @@ -1002,30 +1002,30 @@ void tst_QItemDelegate::decoration_data() int pm = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); QTest::newRow("pixmap 30x30") - << (int)QVariant::Pixmap + << (int)QMetaType::QPixmap << QSize(30, 30) << QSize(30, 30); QTest::newRow("image 30x30") - << (int)QVariant::Image + << (int)QMetaType::QImage << QSize(30, 30) << QSize(30, 30); //The default engine scales pixmaps down if required, but never up. For WinCE we need bigger IconSize than 30 QTest::newRow("icon 30x30") - << (int)QVariant::Icon + << (int)QMetaType::QIcon << QSize(60, 60) << QSize(pm, pm); QTest::newRow("color 30x30") - << (int)QVariant::Color + << (int)QMetaType::QColor << QSize(30, 30) << QSize(pm, pm); // This demands too much memory and potentially hangs. Feel free to uncomment // for your own testing. // QTest::newRow("pixmap 30x30 big") -// << (int)QVariant::Pixmap +// << (int)QMetaType::QPixmap // << QSize(1024, 1024) // Over 1M // << QSize(1024, 1024); } @@ -1049,26 +1049,26 @@ void tst_QItemDelegate::decoration() QVERIFY(QTest::qWaitForWindowActive(&table)); QVariant value; - switch ((QVariant::Type)type) { - case QVariant::Pixmap: { + switch (type) { + case QMetaType::QPixmap: { QPixmap pm(size); pm.fill(Qt::black); value = pm; break; } - case QVariant::Image: { + case QMetaType::QImage: { QImage img(size, QImage::Format_Mono); memset(img.bits(), 0, img.sizeInBytes()); value = img; break; } - case QVariant::Icon: { + case QMetaType::QIcon: { QPixmap pm(size); pm.fill(Qt::black); value = QIcon(pm); break; } - case QVariant::Color: + case QMetaType::QColor: value = QColor(Qt::green); break; default: diff --git a/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp b/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp index ed4c543d0a..6f176c4ba5 100644 --- a/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp +++ b/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp @@ -46,7 +46,7 @@ void tst_QItemEditorFactory::createEditor() QWidget parent; - QWidget *w = factory->createEditor(QVariant::String, &parent); + QWidget *w = factory->createEditor(QMetaType::QString, &parent); QCOMPARE(w->metaObject()->className(), "QExpandingLineEdit"); } @@ -63,23 +63,23 @@ void tst_QItemEditorFactory::createCustomEditor() { QItemEditorFactory editorFactory; - editorFactory.registerEditor(QVariant::Rect, creator); - editorFactory.registerEditor(QVariant::RectF, creator); + editorFactory.registerEditor(QMetaType::QRect, creator); + editorFactory.registerEditor(QMetaType::QRectF, creator); //creator should not be deleted as a result of calling the next line - editorFactory.registerEditor(QVariant::Rect, creator2); + editorFactory.registerEditor(QMetaType::QRect, creator2); QVERIFY(creator); //this should erase creator2 - editorFactory.registerEditor(QVariant::Rect, creator); + editorFactory.registerEditor(QMetaType::QRect, creator); QVERIFY(creator2.isNull()); QWidget parent; - QWidget *w = editorFactory.createEditor(QVariant::Rect, &parent); + QWidget *w = editorFactory.createEditor(QMetaType::QRect, &parent); QCOMPARE(w->metaObject()->className(), "QDoubleSpinBox"); - QCOMPARE(w->metaObject()->userProperty().type(), QVariant::Double); + QCOMPARE(w->metaObject()->userProperty().userType(), QMetaType::Double); } //editorFactory has been deleted, so should be creator @@ -99,12 +99,12 @@ void tst_QItemEditorFactory::uintValues() { QWidget *editor = editorFactory.createEditor(QMetaType::UInt, &parent); QCOMPARE(editor->metaObject()->className(), "QUIntSpinBox"); - QCOMPARE(editor->metaObject()->userProperty().type(), QVariant::UInt); + QCOMPARE(editor->metaObject()->userProperty().userType(), QMetaType::UInt); } { QWidget *editor = editorFactory.createEditor(QMetaType::Int, &parent); QCOMPARE(editor->metaObject()->className(), "QSpinBox"); - QCOMPARE(editor->metaObject()->userProperty().type(), QVariant::Int); + QCOMPARE(editor->metaObject()->userProperty().userType(), QMetaType::Int); } } diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 25a7989c95..2a02afb36b 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -1938,13 +1938,13 @@ void tst_QTreeWidget::setData() // ### add more data types here item->setData(0, Qt::DisplayRole, 5); - QCOMPARE(item->data(0, Qt::DisplayRole).type(), QVariant::Int); + QCOMPARE(item->data(0, Qt::DisplayRole).userType(), QMetaType::Int); item->setData(0, Qt::DisplayRole, "test"); - QCOMPARE(item->data(0, Qt::DisplayRole).type(), QVariant::String); + QCOMPARE(item->data(0, Qt::DisplayRole).userType(), QMetaType::QString); item->setData(0, Qt::DisplayRole, 0.4); - QCOMPARE(item->data(0, Qt::DisplayRole).type(), QVariant::Double); + QCOMPARE(item->data(0, Qt::DisplayRole).userType(), QMetaType::Double); delete item; } |