diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp index 692606b539..0f65adcaad 100644 --- a/src/dbus/qdbusdemarshaller.cpp +++ b/src/dbus/qdbusdemarshaller.cpp @@ -287,7 +287,7 @@ QVariant QDBusDemarshaller::toVariantInternal() case DBUS_TYPE_UNIX_FD: if (capabilities & QDBusConnection::UnixFileDescriptorPassing) - return qVariantFromValue(toUnixFileDescriptor()); + return QVariant::fromValue(toUnixFileDescriptor()); // fall through default: diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index fd01934eae..a06818bcd3 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -544,7 +544,7 @@ QSize ValueExtractor::sizeValue(const Declaration &decl) else x[1] = x[0]; QList v; - v << QVariant::fromValue(x[0]) << qVariantFromValue(x[1]); + v << QVariant::fromValue(x[0]) << QVariant::fromValue(x[1]); decl.d->parsed = v; return QSize(lengthValueFromData(x[0], f), lengthValueFromData(x[1], f)); } diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 4796e4bb86..e2d75c06f8 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1068,7 +1068,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData downloadZerocopyBuffer = downloadBufferPointer.data(); downloadBufferCurrentSize = 0; downloadBufferMaximumSize = contentLength; - q->setAttribute(QNetworkRequest::DownloadBufferAttribute, qVariantFromValue > (downloadBufferPointer)); + q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue > (downloadBufferPointer)); } q->setAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, pu); diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index d535cbda65..c5f26df4b8 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -698,7 +698,7 @@ char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size) downloadBuffer = new char[downloadBufferMaximumSize]; // throws if allocation fails downloadBufferPointer = QSharedPointer(downloadBuffer, downloadBufferDeleter); - q->setAttribute(QNetworkRequest::DownloadBufferAttribute, qVariantFromValue > (downloadBufferPointer)); + q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue > (downloadBufferPointer)); } } @@ -713,7 +713,7 @@ void QNetworkReplyImplPrivate::setDownloadBuffer(QSharedPointer sp, qint64 downloadBuffer = downloadBufferPointer.data(); downloadBufferCurrentSize = 0; downloadBufferMaximumSize = size; - q->setAttribute(QNetworkRequest::DownloadBufferAttribute, qVariantFromValue > (downloadBufferPointer)); + q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue > (downloadBufferPointer)); } diff --git a/src/plugins/bearer/connman/qofonoservice_linux.cpp b/src/plugins/bearer/connman/qofonoservice_linux.cpp index 94c8b83e4e..6e01029d13 100644 --- a/src/plugins/bearer/connman/qofonoservice_linux.cpp +++ b/src/plugins/bearer/connman/qofonoservice_linux.cpp @@ -786,7 +786,7 @@ bool QOfonoPrimaryDataContextInterface::setActive(bool on) { // this->setProperty("Active", QVariant(on)); - return setProp("Active", qVariantFromValue(on)); + return setProp("Active", QVariant::fromValue(on)); } bool QOfonoPrimaryDataContextInterface::setApn(const QString &name) @@ -855,7 +855,7 @@ QVariantMap QOfonoPrimaryDataContextInterface::getProperties() bool QOfonoPrimaryDataContextInterface::setProp(const QString &property, const QVariant &var) { QList args; - args << qVariantFromValue(property) << qVariantFromValue(QDBusVariant(var)); + args << QVariant::fromValue(property) << QVariant::fromValue(QDBusVariant(var)); QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect, QLatin1String("SetProperty"), diff --git a/src/plugins/platforms/qnx/qqnxclipboard.cpp b/src/plugins/platforms/qnx/qqnxclipboard.cpp index 8931a15139..38dac0c5ab 100644 --- a/src/plugins/platforms/qnx/qqnxclipboard.cpp +++ b/src/plugins/platforms/qnx/qqnxclipboard.cpp @@ -153,7 +153,7 @@ protected: return QMimeData::retrieveData(mimetype, preferredType); const QByteArray data = readClipboardBuff(mimetype.toUtf8().constData()); - return qVariantFromValue(data); + return QVariant::fromValue(data); } private Q_SLOTS: diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index 8a5e0bb34b..9bd1de1851 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -420,7 +420,7 @@ QVariant QMYSQLResult::handle() const { #if MYSQL_VERSION_ID >= 40108 if(d->preparedQuery) - return d->meta ? QVariant::fromValue(d->meta) : qVariantFromValue(d->stmt); + return d->meta ? QVariant::fromValue(d->meta) : QVariant::fromValue(d->stmt); else #endif return QVariant::fromValue(d->result); diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index 3abd851c89..db7f067680 100644 --- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp @@ -145,9 +145,9 @@ void tst_QAnimationGroup::emptyGroup() QCOMPARE(groupStateChangedSpy.count(), 2); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast(groupStateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Stopped); @@ -160,9 +160,9 @@ void tst_QAnimationGroup::emptyGroup() group.start(); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(2).first()), + QCOMPARE(qvariant_cast(groupStateChangedSpy.at(2).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(3).first()), + QCOMPARE(qvariant_cast(groupStateChangedSpy.at(3).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Stopped); diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 2fdf1de9c8..b7464c8467 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -270,18 +270,18 @@ void tst_QParallelAnimationGroup::stateChanged() group.start(); //all the animations should be started QCOMPARE(spy1.count(), 1); - QCOMPARE(qVariantValue(spy1.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast(spy1.last().first()), TestAnimation::Running); QCOMPARE(spy2.count(), 1); - QCOMPARE(qVariantValue(spy2.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast(spy2.last().first()), TestAnimation::Running); QCOMPARE(spy3.count(), 1); - QCOMPARE(qVariantValue(spy3.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast(spy3.last().first()), TestAnimation::Running); QCOMPARE(spy4.count(), 1); - QCOMPARE(qVariantValue(spy4.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim1 should be finished QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 2); - QCOMPARE(qVariantValue(spy1.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast(spy1.last().first()), TestAnimation::Stopped); QCOMPARE(spy2.count(), 1); //no change QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change @@ -290,7 +290,7 @@ void tst_QParallelAnimationGroup::stateChanged() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 2); //no change QCOMPARE(spy2.count(), 2); - QCOMPARE(qVariantValue(spy2.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast(spy2.last().first()), TestAnimation::Stopped); QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change @@ -299,9 +299,9 @@ void tst_QParallelAnimationGroup::stateChanged() QCOMPARE(spy1.count(), 2); //no change QCOMPARE(spy2.count(), 2); //no change QCOMPARE(spy3.count(), 2); - QCOMPARE(qVariantValue(spy3.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast(spy3.last().first()), TestAnimation::Stopped); QCOMPARE(spy4.count(), 2); - QCOMPARE(qVariantValue(spy4.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast(spy4.last().first()), TestAnimation::Stopped); //cleanup spy1.clear(); @@ -318,22 +318,22 @@ void tst_QParallelAnimationGroup::stateChanged() QCOMPARE(spy1.count(), 0); QCOMPARE(spy2.count(), 0); QCOMPARE(spy3.count(), 1); - QCOMPARE(qVariantValue(spy3.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast(spy3.last().first()), TestAnimation::Running); QCOMPARE(spy4.count(), 1); - QCOMPARE(qVariantValue(spy4.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim2 should be started QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 0); //no change QCOMPARE(spy2.count(), 1); - QCOMPARE(qVariantValue(spy2.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast(spy2.last().first()), TestAnimation::Running); QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change group.setCurrentTime(500); //anim1 is finally also started QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 1); - QCOMPARE(qVariantValue(spy1.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast(spy1.last().first()), TestAnimation::Running); QCOMPARE(spy2.count(), 1); //no change QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change @@ -341,13 +341,13 @@ void tst_QParallelAnimationGroup::stateChanged() group.setCurrentTime(0); //everything should be stopped QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(spy1.count(), 2); - QCOMPARE(qVariantValue(spy1.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast(spy1.last().first()), TestAnimation::Stopped); QCOMPARE(spy2.count(), 2); - QCOMPARE(qVariantValue(spy2.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast(spy2.last().first()), TestAnimation::Stopped); QCOMPARE(spy3.count(), 2); - QCOMPARE(qVariantValue(spy3.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast(spy3.last().first()), TestAnimation::Stopped); QCOMPARE(spy4.count(), 2); - QCOMPARE(qVariantValue(spy4.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast(spy4.last().first()), TestAnimation::Stopped); } void tst_QParallelAnimationGroup::clearGroup() @@ -455,9 +455,9 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(groupStateChangedSpy.count(), 1); QCOMPARE(childStateChangedSpy.count(), 1); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(childStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(childStateChangedSpy.at(0).first()), QAnimationGroup::Running); // starting directly a running child will not have any effect @@ -620,11 +620,11 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() anim2.start(); anim2.pause(); - QCOMPARE(qVariantValue(stateChangedSpy1.at(0).first()), + QCOMPARE(qvariant_cast(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy2.at(0).first()), + QCOMPARE(qvariant_cast(stateChangedSpy2.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy2.at(1).first()), + QCOMPARE(qvariant_cast(stateChangedSpy2.at(1).first()), QAnimationGroup::Paused); QCOMPARE(group.state(), QAnimationGroup::Stopped); @@ -634,15 +634,15 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() group.start(); QCOMPARE(stateChangedSpy1.count(), 3); - QCOMPARE(qVariantValue(stateChangedSpy1.at(1).first()), + QCOMPARE(qvariant_cast(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(stateChangedSpy1.at(2).first()), + QCOMPARE(qvariant_cast(stateChangedSpy1.at(2).first()), QAnimationGroup::Running); QCOMPARE(stateChangedSpy2.count(), 4); - QCOMPARE(qVariantValue(stateChangedSpy2.at(2).first()), + QCOMPARE(qvariant_cast(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(stateChangedSpy2.at(3).first()), + QCOMPARE(qvariant_cast(stateChangedSpy2.at(3).first()), QAnimationGroup::Running); QCOMPARE(group.state(), QAnimationGroup::Running); @@ -694,19 +694,19 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() group.start(); QCOMPARE(stateChangedSpy1.count(), 2); QCOMPARE(finishedSpy1.count(), 1); - QCOMPARE(qVariantValue(stateChangedSpy1.at(0).first()), + QCOMPARE(qvariant_cast(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy1.at(1).first()), + QCOMPARE(qvariant_cast(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(stateChangedSpy2.count(), 1); QCOMPARE(finishedSpy2.count(), 0); - QCOMPARE(qVariantValue(stateChangedSpy1.at(0).first()), + QCOMPARE(qvariant_cast(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); QCOMPARE(stateChangedSpy3.count(), 1); QCOMPARE(finishedSpy3.count(), 0); - QCOMPARE(qVariantValue(stateChangedSpy3.at(0).first()), + QCOMPARE(qvariant_cast(stateChangedSpy3.at(0).first()), QAnimationGroup::Running); @@ -770,9 +770,9 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations() group.start(); QCOMPARE(stateChangedSpy.count(), 2); - QCOMPARE(qVariantValue(stateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(stateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast(stateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Running); @@ -1000,10 +1000,10 @@ void tst_QParallelAnimationGroup::pauseResume() new TestAnimation2(500, &group); group.start(); QCOMPARE(spy.count(), 1); //the animation should have been started - QCOMPARE(qVariantValue(spy.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast(spy.last().first()), TestAnimation::Running); group.setCurrentTime(250); //end of first animation QCOMPARE(spy.count(), 2); //the animation should have been stopped - QCOMPARE(qVariantValue(spy.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast(spy.last().first()), TestAnimation::Stopped); group.pause(); QCOMPARE(spy.count(), 2); //this shouldn't have changed group.resume(); diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index 05d1569988..11b95d82d8 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -702,7 +702,7 @@ Q_DECLARE_METATYPE(QAbstractAnimation::State) QVariant numberInterpolator(const Number &f, const Number &t, qreal progress) { - return qVariantFromValue(Number(f.n + (t.n - f.n)*progress)); + return QVariant::fromValue(Number(f.n + (t.n - f.n)*progress)); } QVariant xaxisQPointInterpolator(const QPointF &f, const QPointF &t, qreal progress) @@ -714,21 +714,21 @@ void tst_QPropertyAnimation::interpolated() { QObject o; o.setProperty("point", QPointF()); //this will avoid warnings - o.setProperty("number", qVariantFromValue(Number(42))); - QCOMPARE(qVariantValue(o.property("number")), Number(42)); + o.setProperty("number", QVariant::fromValue(Number(42))); + QCOMPARE(qvariant_cast(o.property("number")), Number(42)); { qRegisterAnimationInterpolator(numberInterpolator); QPropertyAnimation anim(&o, "number"); - anim.setStartValue(qVariantFromValue(Number(0))); - anim.setEndValue(qVariantFromValue(Number(100))); + anim.setStartValue(QVariant::fromValue(Number(0))); + anim.setEndValue(QVariant::fromValue(Number(100))); anim.setDuration(1000); anim.start(); anim.pause(); anim.setCurrentTime(100); - Number t(qVariantValue(o.property("number"))); + Number t(qvariant_cast(o.property("number"))); QCOMPARE(t, Number(10)); anim.setCurrentTime(500); - QCOMPARE(qVariantValue(o.property("number")), Number(50)); + QCOMPARE(qvariant_cast(o.property("number")), Number(50)); } { qRegisterAnimationInterpolator(xaxisQPointInterpolator); @@ -861,16 +861,16 @@ void tst_QPropertyAnimation::zeroDurationStart() //let's check the first state change const QVariantList firstChange = spy.first(); //old state - QCOMPARE(qVariantValue(firstChange.last()), QAbstractAnimation::Stopped); + QCOMPARE(qvariant_cast(firstChange.last()), QAbstractAnimation::Stopped); //new state - QCOMPARE(qVariantValue(firstChange.first()), QAbstractAnimation::Running); + QCOMPARE(qvariant_cast(firstChange.first()), QAbstractAnimation::Running); //let's check the first state change const QVariantList secondChange = spy.last(); //old state - QCOMPARE(qVariantValue(secondChange.last()), QAbstractAnimation::Running); + QCOMPARE(qvariant_cast(secondChange.last()), QAbstractAnimation::Running); //new state - QCOMPARE(qVariantValue(secondChange.first()), QAbstractAnimation::Stopped); + QCOMPARE(qvariant_cast(secondChange.first()), QAbstractAnimation::Stopped); } #define Pause 1 diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 63a4de5ac9..0ceeb6ce86 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -590,7 +590,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates } QList args = spy.at(i); QAbstractAnimation::State st = expectedStates.at(i); - QAbstractAnimation::State actual = qVariantValue(args.first()); + QAbstractAnimation::State actual = qvariant_cast(args.first()); if (equals && actual != st) { equals = false; break; @@ -608,7 +608,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates } if (i < spy.count()) { QList args = spy.at(i); - QAbstractAnimation::State actual = qVariantValue(args.value(1)); + QAbstractAnimation::State actual = qvariant_cast(args.value(1)); if (!a.isEmpty()) a += QLatin1String(", "); if (int(actual) >= 0 && int(actual) <= 2) { @@ -677,20 +677,20 @@ void tst_QSequentialAnimationGroup::pauseAndResume() << QAbstractAnimation::Running << QAbstractAnimation::Stopped))); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(a1StateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast(a1StateChangedSpy.at(1).first()), QAnimationGroup::Paused); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(2).first()), + QCOMPARE(qvariant_cast(a1StateChangedSpy.at(2).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(3).first()), + QCOMPARE(qvariant_cast(a1StateChangedSpy.at(3).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(4).first()), + QCOMPARE(qvariant_cast(a1StateChangedSpy.at(4).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(seqStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(seqStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(seqStateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast(seqStateChangedSpy.at(1).first()), QAnimationGroup::Paused); group.resume(); @@ -711,7 +711,7 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QVERIFY(a3_s_o1->currentLoopTime() >= 1); QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running - QCOMPARE(qVariantValue(seqStateChangedSpy.at(2).first()), + QCOMPARE(qvariant_cast(seqStateChangedSpy.at(2).first()), QAnimationGroup::Running); group.pause(); @@ -732,13 +732,13 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QVERIFY(a3_s_o1->currentLoopTime() >= 1); QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused - QCOMPARE(qVariantValue(seqStateChangedSpy.at(3).first()), + QCOMPARE(qvariant_cast(seqStateChangedSpy.at(3).first()), QAnimationGroup::Paused); group.stop(); QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped - QCOMPARE(qVariantValue(seqStateChangedSpy.at(4).first()), + QCOMPARE(qvariant_cast(seqStateChangedSpy.at(4).first()), QAnimationGroup::Stopped); } @@ -782,25 +782,25 @@ void tst_QSequentialAnimationGroup::restart() for (int i = 0; i < 3; i++) { QCOMPARE(animsStateChanged[i]->count(), 4); - QCOMPARE(qVariantValue(animsStateChanged[i]->at(0).first()), + QCOMPARE(qvariant_cast(animsStateChanged[i]->at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(animsStateChanged[i]->at(1).first()), + QCOMPARE(qvariant_cast(animsStateChanged[i]->at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(animsStateChanged[i]->at(2).first()), + QCOMPARE(qvariant_cast(animsStateChanged[i]->at(2).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(animsStateChanged[i]->at(3).first()), + QCOMPARE(qvariant_cast(animsStateChanged[i]->at(3).first()), QAnimationGroup::Stopped); } QCOMPARE(seqStateChangedSpy.count(), 2); - QCOMPARE(qVariantValue(seqStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(seqStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(seqStateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast(seqStateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(seqCurrentAnimChangedSpy.count(), 6); for(int i=0; i(anims[i%3]), qVariantValue(seqCurrentAnimChangedSpy.at(i).at(0))); + QCOMPARE(static_cast(anims[i%3]), qvariant_cast(seqCurrentAnimChangedSpy.at(i).at(0))); group.start(); @@ -1124,9 +1124,9 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(groupStateChangedSpy.count(), 1); QCOMPARE(childStateChangedSpy.count(), 1); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(childStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(childStateChangedSpy.at(0).first()), QAnimationGroup::Running); // starting directly a running child will not have any effect @@ -1317,9 +1317,9 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild() QCOMPARE(anim2->state(), QAnimationGroup::Running); QCOMPARE(stateChangedSpy2.count(), 4); - QCOMPARE(qVariantValue(stateChangedSpy2.at(2).first()), + QCOMPARE(qvariant_cast(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(stateChangedSpy2.at(3).first()), + QCOMPARE(qvariant_cast(stateChangedSpy2.at(3).first()), QAnimationGroup::Running); group.stop(); @@ -1357,9 +1357,9 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation() group.start(); QCOMPARE(stateChangedSpy.count(), 2); - QCOMPARE(qVariantValue(stateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast(stateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast(stateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(anim1->state(), QAnimationGroup::Stopped); diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index c3c4607119..3ca9521d8b 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -264,9 +264,9 @@ void tst_QProcess::simpleStart() process = 0; QCOMPARE(spy.count(), 3); - QCOMPARE(qVariantValue(spy.at(0).at(0)), QProcess::Starting); - QCOMPARE(qVariantValue(spy.at(1).at(0)), QProcess::Running); - QCOMPARE(qVariantValue(spy.at(2).at(0)), QProcess::NotRunning); + QCOMPARE(qvariant_cast(spy.at(0).at(0)), QProcess::Starting); + QCOMPARE(qvariant_cast(spy.at(1).at(0)), QProcess::Running); + QCOMPARE(qvariant_cast(spy.at(2).at(0)), QProcess::NotRunning); } //----------------------------------------------------------------------------- void tst_QProcess::execute() @@ -331,9 +331,9 @@ void tst_QProcess::crashTest() process = 0; QCOMPARE(stateSpy.count(), 3); - QCOMPARE(qVariantValue(stateSpy.at(0).at(0)), QProcess::Starting); - QCOMPARE(qVariantValue(stateSpy.at(1).at(0)), QProcess::Running); - QCOMPARE(qVariantValue(stateSpy.at(2).at(0)), QProcess::NotRunning); + QCOMPARE(qvariant_cast(stateSpy.at(0).at(0)), QProcess::Starting); + QCOMPARE(qvariant_cast(stateSpy.at(1).at(0)), QProcess::Running); + QCOMPARE(qvariant_cast(stateSpy.at(2).at(0)), QProcess::NotRunning); } //----------------------------------------------------------------------------- @@ -1571,8 +1571,8 @@ void tst_QProcess::failToStart() int it = j * attempts + i + 1; QCOMPARE(stateSpy.count(), it * 2); - QCOMPARE(qVariantValue(stateSpy.at(it * 2 - 2).at(0)), QProcess::Starting); - QCOMPARE(qVariantValue(stateSpy.at(it * 2 - 1).at(0)), QProcess::NotRunning); + QCOMPARE(qvariant_cast(stateSpy.at(it * 2 - 2).at(0)), QProcess::Starting); + QCOMPARE(qvariant_cast(stateSpy.at(it * 2 - 1).at(0)), QProcess::NotRunning); } } } diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 5063fbb9b0..65ab63510c 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -1023,7 +1023,7 @@ void tst_QSettings::testVariantTypes() #define testVal(key, val, tp, rtype) \ { \ QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP"); \ - settings1.setValue(key, qVariantFromValue(val)); \ + settings1.setValue(key, QVariant::fromValue(val)); \ } \ QConfFile::clearCache(); \ { \ @@ -1055,7 +1055,7 @@ void tst_QSettings::testVariantTypes() QList l3; QDate date = QDate::currentDate(); QTime time = QTime::currentTime(); - l3 << QString("ene") << 10 << qVariantFromValue(QColor(1, 2, 3)) << QVariant(QRect(1, 2, 3, 4)) + l3 << QString("ene") << 10 << QVariant::fromValue(QColor(1, 2, 3)) << QVariant(QRect(1, 2, 3, 4)) << QVariant(QSize(4, 56)) << QVariant(QPoint(4, 2)) << true << false << date << time; testVal("key3", l3, QVariantList, List); diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index d27d685f37..6a15133b27 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -535,27 +535,27 @@ void tst_QItemModel::data() // General Purpose roles QVariant variant = currentModel->data(currentModel->index(0,0), Qt::ToolTipRole); if (variant.isValid()) { - QVERIFY(qVariantCanConvert(variant)); + QVERIFY(variant.canConvert()); } variant = currentModel->data(currentModel->index(0,0), Qt::StatusTipRole); if (variant.isValid()) { - QVERIFY(qVariantCanConvert(variant)); + QVERIFY(variant.canConvert()); } variant = currentModel->data(currentModel->index(0,0), Qt::WhatsThisRole); if (variant.isValid()) { - QVERIFY(qVariantCanConvert(variant)); + QVERIFY(variant.canConvert()); } variant = currentModel->data(currentModel->index(0,0), Qt::SizeHintRole); if (variant.isValid()) { - QVERIFY(qVariantCanConvert(variant)); + QVERIFY(variant.canConvert()); } // Appearance roles QVariant fontVariant = currentModel->data(currentModel->index(0,0), Qt::FontRole); if (fontVariant.isValid()) { - QVERIFY(qVariantCanConvert(fontVariant)); + QVERIFY(fontVariant.canConvert()); } QVariant textAlignmentVariant = currentModel->data(currentModel->index(0,0), Qt::TextAlignmentRole); @@ -569,12 +569,12 @@ void tst_QItemModel::data() QVariant colorVariant = currentModel->data(currentModel->index(0,0), Qt::BackgroundColorRole); if (colorVariant.isValid()) { - QVERIFY(qVariantCanConvert(colorVariant)); + QVERIFY(colorVariant.canConvert()); } colorVariant = currentModel->data(currentModel->index(0,0), Qt::TextColorRole); if (colorVariant.isValid()) { - QVERIFY(qVariantCanConvert(colorVariant)); + QVERIFY(colorVariant.canConvert()); } QVariant checkStateVariant = currentModel->data(currentModel->index(0,0), Qt::CheckStateRole); diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 4eb26928ac..e9de52b821 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -260,7 +260,7 @@ Q_DECLARE_METATYPE(TestSpace::Foo) void tst_QMetaType::namespaces() { TestSpace::Foo nf = { 11.12 }; - QVariant v = qVariantFromValue(nf); + QVariant v = QVariant::fromValue(nf); QCOMPARE(qvariant_cast(v).d, 11.12); } diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 60b92fc27d..54704bf5d9 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -2051,12 +2051,12 @@ void tst_QObject::property() CustomType *customPointer = 0; QVariant customVariant = object.property("custom"); - customPointer = qVariantValue(customVariant); + customPointer = qvariant_cast(customVariant); QCOMPARE(customPointer, object.custom()); CustomType custom; customPointer = &custom; - qVariantSetValue(customVariant, customPointer); + customVariant.setValue(customPointer); property = mo->property(mo->indexOfProperty("custom")); QVERIFY(property.isWritable()); @@ -2068,7 +2068,7 @@ void tst_QObject::property() QCOMPARE(object.custom(), customPointer); customVariant = object.property("custom"); - customPointer = qVariantValue(customVariant); + customPointer = qvariant_cast(customVariant); QCOMPARE(object.custom(), customPointer); // this enum property has a meta type, but it's not yet registered, so we know this fails @@ -2101,22 +2101,22 @@ void tst_QObject::property() var = object.property("priority"); QVERIFY(!var.isNull()); - QVERIFY(qVariantCanConvert(var)); - QCOMPARE(qVariantValue(var), PropertyObject::High); + QVERIFY(var.canConvert()); + QCOMPARE(qvariant_cast(var), PropertyObject::High); object.setPriority(PropertyObject::Low); - QCOMPARE(qVariantValue(object.property("priority")), PropertyObject::Low); + QCOMPARE(qvariant_cast(object.property("priority")), PropertyObject::Low); QVERIFY(object.setProperty("priority", PropertyObject::VeryHigh)); - QCOMPARE(qVariantValue(object.property("priority")), PropertyObject::VeryHigh); + QCOMPARE(qvariant_cast(object.property("priority")), PropertyObject::VeryHigh); QVERIFY(object.setProperty("priority", "High")); - QCOMPARE(qVariantValue(object.property("priority")), PropertyObject::High); + QCOMPARE(qvariant_cast(object.property("priority")), PropertyObject::High); QVERIFY(!object.setProperty("priority", QVariant())); var = object.property("priority"); - QCOMPARE(qVariantValue(var), PropertyObject::High); + QCOMPARE(qvariant_cast(var), PropertyObject::High); object.setPriority(PropertyObject::Low); - QCOMPARE(qVariantValue(object.property("priority")), PropertyObject::Low); + QCOMPARE(qvariant_cast(object.property("priority")), PropertyObject::Low); object.setProperty("priority", var); - QCOMPARE(qVariantValue(object.property("priority")), PropertyObject::High); + QCOMPARE(qvariant_cast(object.property("priority")), PropertyObject::High); qRegisterMetaType("CustomString"); QVERIFY(mo->indexOfProperty("customString") != -1); @@ -3002,10 +3002,10 @@ void tst_QObject::floatProperty() QVERIFY(prop.isValid()); QVERIFY(prop.type() == uint(QMetaType::type("float"))); QVERIFY(!prop.write(&obj, QVariant("Hello"))); - QVERIFY(prop.write(&obj, qVariantFromValue(128.0f))); + QVERIFY(prop.write(&obj, QVariant::fromValue(128.0f))); QVariant v = prop.read(&obj); QVERIFY(int(v.userType()) == QMetaType::Float); - QVERIFY(qVariantValue(v) == 128.0f); + QVERIFY(qvariant_cast(v) == 128.0f); } void tst_QObject::qrealProperty() @@ -3018,15 +3018,15 @@ void tst_QObject::qrealProperty() QVERIFY(prop.type() == uint(QMetaType::type("qreal"))); QVERIFY(!prop.write(&obj, QVariant("Hello"))); - QVERIFY(prop.write(&obj, qVariantFromValue(128.0f))); + QVERIFY(prop.write(&obj, QVariant::fromValue(128.0f))); QVariant v = prop.read(&obj); QCOMPARE(v.userType(), qMetaTypeId()); - QVERIFY(qVariantValue(v) == 128.0); + QVERIFY(qvariant_cast(v) == 128.0); - QVERIFY(prop.write(&obj, qVariantFromValue(double(127)))); + QVERIFY(prop.write(&obj, QVariant::fromValue(double(127)))); v = prop.read(&obj); QCOMPARE(v.userType(), qMetaTypeId()); - QVERIFY(qVariantValue(v) == 127.0); + QVERIFY(qvariant_cast(v) == 127.0); } class DynamicPropertyObject : public PropertyObject diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 3824b5cc25..869eaf45b7 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -512,20 +512,20 @@ void tst_QVariant::canConvert_data() QVariant var(QBitArray(0)); QTest::newRow("BitArray") << var << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QBitmap()); + var = QVariant::fromValue(QBitmap()); QTest::newRow("Bitmap") << var << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QBrush()); + var = QVariant::fromValue(QBrush()); QTest::newRow("Brush") << var << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; var = QVariant(QByteArray()); QTest::newRow("ByteArray") << var << N << N << Y << N << Y << Y << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; - var = qVariantFromValue(QColor()); + var = QVariant::fromValue(QColor()); QTest::newRow("Color") << var << N << N << N << Y << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; #ifndef QT_NO_CURSOR - var = qVariantFromValue(QCursor()); + var = QVariant::fromValue(QCursor()); QTest::newRow("Cursor") << var << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; #endif @@ -541,13 +541,13 @@ void tst_QVariant::canConvert_data() var = QVariant(0.1f); QTest::newRow("Float") << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; - var = qVariantFromValue(QFont()); + var = QVariant::fromValue(QFont()); QTest::newRow("Font") << var << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; - var = qVariantFromValue(QIcon()); + var = QVariant::fromValue(QIcon()); QTest::newRow("Icon") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QImage()); + var = QVariant::fromValue(QImage()); QTest::newRow("Image") << var << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; var = QVariant((int)1); @@ -556,7 +556,7 @@ void tst_QVariant::canConvert_data() var = QVariant(); QTest::newRow("Invalid") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QKeySequence()); + var = QVariant::fromValue(QKeySequence()); QTest::newRow("KeySequence") << var << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; var = QVariant(QList()); @@ -568,16 +568,16 @@ void tst_QVariant::canConvert_data() var = QVariant(QMap()); QTest::newRow("Map") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QPalette()); + var = QVariant::fromValue(QPalette()); QTest::newRow("Palette") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QPen()); + var = QVariant::fromValue(QPen()); QTest::newRow("Pen") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QPixmap()); + var = QVariant::fromValue(QPixmap()); QTest::newRow("Pixmap") << var << N << Y << N << Y << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QPolygon()); + var = QVariant::fromValue(QPolygon()); QTest::newRow("PointArray") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; var = QVariant(QPoint()); @@ -586,13 +586,13 @@ void tst_QVariant::canConvert_data() var = QVariant(QRect()); QTest::newRow("Rect") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QRegion()); + var = QVariant::fromValue(QRegion()); QTest::newRow("Region") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N; var = QVariant(QSize()); QTest::newRow("Size") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N; - var = qVariantFromValue(QSizePolicy()); + var = QVariant::fromValue(QSizePolicy()); QTest::newRow("SizePolicy") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N; var = QVariant(QString()); @@ -713,7 +713,7 @@ void tst_QVariant::toInt_data() QTest::newRow( "signedint-string" ) << QVariant( QString("-123") ) << -123 << true; QTest::newRow( "signedlonglong0" ) << QVariant( (qlonglong)-34 ) << -34 << true; QTest::newRow( "QChar" ) << QVariant(QChar('a')) << int('a') << true; - QTest::newRow( "keysequence" ) << qVariantFromValue( QKeySequence( Qt::Key_A ) ) << 65 << true; + QTest::newRow( "keysequence" ) << QVariant::fromValue( QKeySequence( Qt::Key_A ) ) << 65 << true; QByteArray bytearray(4, ' '); bytearray[0] = 'T'; bytearray[1] = 'e'; @@ -1020,7 +1020,7 @@ void tst_QVariant::toColor() QFETCH( QColor, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Color ) ); - QColor d = qVariantValue(value); + QColor d = qvariant_cast(value); QCOMPARE( d, result ); } @@ -1044,7 +1044,7 @@ void tst_QVariant::toPixmap() QFETCH( QPixmap, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Pixmap ) ); - QPixmap d = qVariantValue(value); + QPixmap d = qvariant_cast(value); QCOMPARE( d, result ); } @@ -1064,7 +1064,7 @@ void tst_QVariant::toImage() QFETCH( QImage, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Image ) ); - QImage d = qVariantValue(value); + QImage d = qvariant_cast(value); QCOMPARE( d, result ); } @@ -1086,7 +1086,7 @@ void tst_QVariant::toBrush() QFETCH( QBrush, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Brush ) ); - QBrush d = qVariantValue(value); + QBrush d = qvariant_cast(value); QCOMPARE( d, result ); } @@ -1105,7 +1105,7 @@ void tst_QVariant::toFont() QFETCH( QFont, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Font ) ); - QFont d = qVariantValue(value); + QFont d = qvariant_cast(value); QCOMPARE( d, result ); } @@ -1129,7 +1129,7 @@ void tst_QVariant::toKeySequence() QFETCH( QKeySequence, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::KeySequence ) ); - QKeySequence d = qVariantValue(value); + QKeySequence d = qvariant_cast(value); QCOMPARE( d, result ); } @@ -1291,7 +1291,7 @@ void tst_QVariant::toString_data() QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" ); QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" ); QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" ); - QTest::newRow( "qkeysequence" ) << qVariantFromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) + QTest::newRow( "qkeysequence" ) << QVariant::fromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) #ifndef Q_OS_MAC << QString( "Ctrl+A" ); #else @@ -1299,8 +1299,8 @@ void tst_QVariant::toString_data() #endif QFont font( "times", 12 ); - QTest::newRow( "qfont" ) << qVariantFromValue( font ) << QString("times,12,-1,5,50,0,0,0,0,0"); - QTest::newRow( "qcolor" ) << qVariantFromValue( QColor( 10, 10, 10 ) ) << QString( "#0a0a0a" ); + QTest::newRow( "qfont" ) << QVariant::fromValue( font ) << QString("times,12,-1,5,50,0,0,0,0,0"); + QTest::newRow( "qcolor" ) << QVariant::fromValue( QColor( 10, 10, 10 ) ) << QString( "#0a0a0a" ); QTest::newRow( "llong" ) << QVariant( (qlonglong)Q_INT64_C(123456789012) ) << QString( "123456789012" ); } @@ -1407,10 +1407,10 @@ void tst_QVariant::toRegularExpression() void tst_QVariant::matrix() { QVariant variant; - QMatrix matrix = qVariantValue(variant); + QMatrix matrix = qvariant_cast(variant); QVERIFY(matrix.isIdentity()); - qVariantSetValue(variant, QMatrix().rotate(90)); - QCOMPARE(QMatrix().rotate(90), qVariantValue(variant)); + variant.setValue(QMatrix().rotate(90)); + QCOMPARE(QMatrix().rotate(90), qvariant_cast(variant)); void *mmatrix = QMetaType::create(QVariant::Matrix, 0); QVERIFY(mmatrix); @@ -1420,12 +1420,12 @@ void tst_QVariant::matrix() void tst_QVariant::matrix4x4() { QVariant variant; - QMatrix4x4 matrix = qVariantValue(variant); + QMatrix4x4 matrix = qvariant_cast(variant); QVERIFY(matrix.isIdentity()); QMatrix4x4 m; m.scale(2.0f); - qVariantSetValue(variant, m); - QCOMPARE(m, qVariantValue(variant)); + variant.setValue(m); + QCOMPARE(m, qvariant_cast(variant)); void *mmatrix = QMetaType::create(QVariant::Matrix4x4, 0); QVERIFY(mmatrix); @@ -1435,10 +1435,10 @@ void tst_QVariant::matrix4x4() void tst_QVariant::transform() { QVariant variant; - QTransform matrix = qVariantValue(variant); + QTransform matrix = qvariant_cast(variant); QVERIFY(matrix.isIdentity()); - qVariantSetValue(variant, QTransform().rotate(90)); - QCOMPARE(QTransform().rotate(90), qVariantValue(variant)); + variant.setValue(QTransform().rotate(90)); + QCOMPARE(QTransform().rotate(90), qvariant_cast(variant)); void *mmatrix = QMetaType::create(QVariant::Transform, 0); QVERIFY(mmatrix); @@ -1449,10 +1449,10 @@ void tst_QVariant::transform() void tst_QVariant::vector2D() { QVariant variant; - QVector2D vector = qVariantValue(variant); + QVector2D vector = qvariant_cast(variant); QVERIFY(vector.isNull()); - qVariantSetValue(variant, QVector2D(0.1, 0.2)); - QCOMPARE(QVector2D(0.1, 0.2), qVariantValue(variant)); + variant.setValue(QVector2D(0.1, 0.2)); + QCOMPARE(QVector2D(0.1, 0.2), qvariant_cast(variant)); void *pvector = QMetaType::create(QVariant::Vector2D, 0); QVERIFY(pvector); @@ -1462,10 +1462,10 @@ void tst_QVariant::vector2D() void tst_QVariant::vector3D() { QVariant variant; - QVector3D vector = qVariantValue(variant); + QVector3D vector = qvariant_cast(variant); QVERIFY(vector.isNull()); - qVariantSetValue(variant, QVector3D(0.1, 0.2, 0.3)); - QCOMPARE(QVector3D(0.1, 0.2, 0.3), qVariantValue(variant)); + variant.setValue(QVector3D(0.1, 0.2, 0.3)); + QCOMPARE(QVector3D(0.1, 0.2, 0.3), qvariant_cast(variant)); void *pvector = QMetaType::create(QVariant::Vector3D, 0); QVERIFY(pvector); @@ -1475,10 +1475,10 @@ void tst_QVariant::vector3D() void tst_QVariant::vector4D() { QVariant variant; - QVector4D vector = qVariantValue(variant); + QVector4D vector = qvariant_cast(variant); QVERIFY(vector.isNull()); - qVariantSetValue(variant, QVector4D(0.1, 0.2, 0.3, 0.4)); - QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qVariantValue(variant)); + variant.setValue(QVector4D(0.1, 0.2, 0.3, 0.4)); + QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qvariant_cast(variant)); void *pvector = QMetaType::create(QVariant::Vector4D, 0); QVERIFY(pvector); @@ -1488,10 +1488,10 @@ void tst_QVariant::vector4D() void tst_QVariant::quaternion() { QVariant variant; - QQuaternion quaternion = qVariantValue(variant); + QQuaternion quaternion = qvariant_cast(variant); QVERIFY(quaternion.isIdentity()); - qVariantSetValue(variant, QQuaternion(0.1, 0.2, 0.3, 0.4)); - QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qVariantValue(variant)); + variant.setValue(QQuaternion(0.1, 0.2, 0.3, 0.4)); + QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qvariant_cast(variant)); void *pquaternion = QMetaType::create(QVariant::Quaternion, 0); QVERIFY(pquaternion); @@ -1548,14 +1548,14 @@ void tst_QVariant::writeToReadFromDataStream_data() bytearray[3] = 't'; bytearray[4] = '\0'; QTest::newRow( "bytearray_valid" ) << QVariant( bytearray ) << false; - QTest::newRow( "bitmap_invalid" ) << qVariantFromValue( QBitmap() ) << true; + QTest::newRow( "bitmap_invalid" ) << QVariant::fromValue( QBitmap() ) << true; QBitmap bitmap( 10, 10 ); bitmap.fill( Qt::red ); - QTest::newRow( "bitmap_valid" ) << qVariantFromValue( bitmap ) << false; - QTest::newRow( "brush_valid" ) << qVariantFromValue( QBrush( Qt::red ) ) << false; - QTest::newRow( "color_valid" ) << qVariantFromValue( QColor( Qt::red ) ) << false; + QTest::newRow( "bitmap_valid" ) << QVariant::fromValue( bitmap ) << false; + QTest::newRow( "brush_valid" ) << QVariant::fromValue( QBrush( Qt::red ) ) << false; + QTest::newRow( "color_valid" ) << QVariant::fromValue( QColor( Qt::red ) ) << false; #ifndef QT_NO_CURSOR - QTest::newRow( "cursor_valid" ) << qVariantFromValue( QCursor( Qt::PointingHandCursor ) ) << false; + QTest::newRow( "cursor_valid" ) << QVariant::fromValue( QCursor( Qt::PointingHandCursor ) ) << false; #endif QTest::newRow( "date_invalid" ) << QVariant( QDate() ) << true; QTest::newRow( "date_valid" ) << QVariant( QDate( 2002, 07, 06 ) ) << false; @@ -1563,14 +1563,14 @@ void tst_QVariant::writeToReadFromDataStream_data() QTest::newRow( "datetime_valid" ) << QVariant( QDateTime( QDate( 2002, 07, 06 ), QTime( 14, 0, 0 ) ) ) << false; QTest::newRow( "double_valid" ) << QVariant( 123.456 ) << false; QTest::newRow( "float_valid" ) << QVariant( 123.456f ) << false; - QTest::newRow( "font_valid" ) << qVariantFromValue( QFont( "times", 12 ) ) << false; - QTest::newRow( "pixmap_invalid" ) << qVariantFromValue( QPixmap() ) << true; + QTest::newRow( "font_valid" ) << QVariant::fromValue( QFont( "times", 12 ) ) << false; + QTest::newRow( "pixmap_invalid" ) << QVariant::fromValue( QPixmap() ) << true; QPixmap pixmap( 10, 10 ); pixmap.fill( Qt::red ); - QTest::newRow( "pixmap_valid" ) << qVariantFromValue( pixmap ) << false; + QTest::newRow( "pixmap_valid" ) << QVariant::fromValue( pixmap ) << false; // QTest::newRow( "iconset_valid" ) << QVariant( QIcon( pixmap ) ) << false; - QTest::newRow( "image_invalid" ) << qVariantFromValue( QImage() ) << true; - QTest::newRow( "keysequence_valid" ) << qVariantFromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) << false; + QTest::newRow( "image_invalid" ) << QVariant::fromValue( QImage() ) << true; + QTest::newRow( "keysequence_valid" ) << QVariant::fromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) << false; QTest::newRow( "int_valid" ) << QVariant( -123 ) << false; typedef QMap variantsMap; variantsMap vMap; @@ -1579,15 +1579,15 @@ void tst_QVariant::writeToReadFromDataStream_data() vMap.insert( "double", QVariant( 3.45 ) ); vMap.insert( "float", QVariant( 3.45f ) ); QTest::newRow( "map_valid" ) << QVariant( vMap ) << false; - QTest::newRow( "palette_valid" ) << qVariantFromValue(QPalette(QColor("turquoise"))) << false; - QTest::newRow( "pen_valid" ) << qVariantFromValue( QPen( Qt::red ) ) << false; - QTest::newRow( "pointarray_invalid" ) << qVariantFromValue( QPolygon() ) << true; - QTest::newRow( "pointarray_valid" ) << qVariantFromValue( QPolygon( QRect( 10, 10, 20, 20 ) ) ) << false; - QTest::newRow( "region_invalid" ) << qVariantFromValue( QRegion() ) << true; - QTest::newRow( "region_valid" ) << qVariantFromValue( QRegion( 10, 10, 20, 20 ) ) << false; - QTest::newRow( "sizepolicy_valid" ) << qVariantFromValue( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ) << false; - QTest::newRow( "point_invalid" ) << qVariantFromValue( QPoint() ) << true; - QTest::newRow( "point_valid" ) << qVariantFromValue( QPoint( 10, 10 ) ) << false; + QTest::newRow( "palette_valid" ) << QVariant::fromValue(QPalette(QColor("turquoise"))) << false; + QTest::newRow( "pen_valid" ) << QVariant::fromValue( QPen( Qt::red ) ) << false; + QTest::newRow( "pointarray_invalid" ) << QVariant::fromValue( QPolygon() ) << true; + QTest::newRow( "pointarray_valid" ) << QVariant::fromValue( QPolygon( QRect( 10, 10, 20, 20 ) ) ) << false; + QTest::newRow( "region_invalid" ) << QVariant::fromValue( QRegion() ) << true; + QTest::newRow( "region_valid" ) << QVariant::fromValue( QRegion( 10, 10, 20, 20 ) ) << false; + QTest::newRow( "sizepolicy_valid" ) << QVariant::fromValue( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ) << false; + QTest::newRow( "point_invalid" ) << QVariant::fromValue( QPoint() ) << true; + QTest::newRow( "point_valid" ) << QVariant::fromValue( QPoint( 10, 10 ) ) << false; QTest::newRow( "rect_invalid" ) << QVariant( QRect() ) << true; QTest::newRow( "rect_valid" ) << QVariant( QRect( 10, 10, 20, 20 ) ) << false; QTest::newRow( "size_invalid" ) << QVariant( QSize( 0, 0 ) ) << true; @@ -2132,7 +2132,7 @@ void tst_QVariant::userType() { QVariant userVar; - qVariantSetValue(userVar, data); + userVar.setValue(data); QCOMPARE(userVar.type(), QVariant::UserType); QCOMPARE(userVar.userType(), qMetaTypeId()); @@ -2143,7 +2143,7 @@ void tst_QVariant::userType() QVariant userVar2(userVar); QVERIFY(userVar == userVar2); - qVariantSetValue(userVar2, data2); + userVar2.setValue(data2); QVERIFY(userVar != userVar2); const MyType *varData = static_cast(userVar.constData()); @@ -2152,7 +2152,7 @@ void tst_QVariant::userType() QCOMPARE(varData->text, data.text); QVariant userVar3; - qVariantSetValue(userVar3, data2); + userVar3.setValue(data2); userVar3 = userVar2; QVERIFY(userVar2 == userVar3); @@ -2161,7 +2161,7 @@ void tst_QVariant::userType() QCOMPARE(instanceCount, 2); { QVariant userVar; - qVariantSetValue(userVar, &data); + userVar.setValue(&data); QCOMPARE(userVar.type(), QVariant::UserType); QCOMPARE(userVar.userType(), qMetaTypeId()); @@ -2172,7 +2172,7 @@ void tst_QVariant::userType() QVariant userVar2(userVar); QVERIFY(userVar == userVar2); - qVariantSetValue(userVar2, &data2); + userVar2.setValue(&data2); QVERIFY(userVar != userVar2); MyType * const*varData = reinterpret_cast(userVar.constData()); @@ -2180,7 +2180,7 @@ void tst_QVariant::userType() QCOMPARE(*varData, &data); QVariant userVar3; - qVariantSetValue(userVar3, &data2); + userVar3.setValue(&data2); /* This check is correct now. userVar2 contains a pointer to data2 and so * does userVar3. */ @@ -2192,7 +2192,7 @@ void tst_QVariant::userType() QCOMPARE(instanceCount, 2); QVariant myCarrier; - qVariantSetValue(myCarrier, data); + myCarrier.setValue(data); QCOMPARE(instanceCount, 3); { QVariant second = myCarrier; @@ -2203,7 +2203,7 @@ void tst_QVariant::userType() QCOMPARE(instanceCount, 3); MyType data3(0, "null"); - data3 = qVariantValue(myCarrier); + data3 = qvariant_cast(myCarrier); QCOMPARE(data3.number, 1); QCOMPARE(data3.text, (const char *)"eins"); #ifndef Q_CC_SUN @@ -2216,7 +2216,7 @@ void tst_QVariant::userType() const MyType data(3, "drei"); QVariant myCarrier; - qVariantSetValue(myCarrier, data); + myCarrier.setValue(data); QCOMPARE(myCarrier.typeName(), "MyType"); const MyType data2 = qvariant_cast(myCarrier); @@ -2228,7 +2228,7 @@ void tst_QVariant::userType() short s = 42; QVariant myCarrier; - qVariantSetValue(myCarrier, s); + myCarrier.setValue(s); QCOMPARE((int)qvariant_cast(myCarrier), 42); } @@ -2236,7 +2236,7 @@ void tst_QVariant::userType() qlonglong ll = Q_INT64_C(42); QVariant myCarrier; - qVariantSetValue(myCarrier, ll); + myCarrier.setValue(ll); QCOMPARE(qvariant_cast(myCarrier), 42); } @@ -2257,14 +2257,14 @@ void tst_QVariant::podUserType() pod.a = 10; pod.b = 20; - QVariant pod_as_variant = qVariantFromValue(pod); + QVariant pod_as_variant = QVariant::fromValue(pod); MyTypePOD pod2 = qvariant_cast(pod_as_variant); QCOMPARE(pod.a, pod2.a); QCOMPARE(pod.b, pod2.b); - qVariantSetValue(pod_as_variant, pod); - pod2 = qVariantValue(pod_as_variant); + pod_as_variant.setValue(pod); + pod2 = qvariant_cast(pod_as_variant); QCOMPARE(pod.a, pod2.a); QCOMPARE(pod.b, pod2.b); @@ -2331,7 +2331,7 @@ void tst_QVariant::data() v = f; QVERIFY(v.data()); - QCOMPARE(*static_cast(v.data()), qVariantValue(v)); + QCOMPARE(*static_cast(v.data()), qvariant_cast(v)); v = ll; QVERIFY(v.data()); @@ -2410,12 +2410,12 @@ void tst_QVariant::variant_to() QStringList sl; sl << QLatin1String("blah"); - qVariantSetValue(v3, sl); + v3.setValue(sl); Foo foo; foo.i = 42; - qVariantSetValue(v4, foo); + v4.setValue(foo); QCOMPARE(qvariant_cast(v1), 4.2); QCOMPARE(qvariant_cast(v1), 4.2f); @@ -2430,7 +2430,7 @@ void tst_QVariant::variant_to() QCOMPARE(qvariant_cast(v1), 4); - QVariant n = qVariantFromValue(42); + QVariant n = QVariant::fromValue(42); QCOMPARE(qvariant_cast(n), 42); QCOMPARE(qvariant_cast(n), 42u); QCOMPARE(qvariant_cast(n), 42.0); @@ -2438,7 +2438,7 @@ void tst_QVariant::variant_to() QCOMPARE(qvariant_cast(n), short(42)); QCOMPARE(qvariant_cast(n), ushort(42)); - n = qVariantFromValue(43l); + n = QVariant::fromValue(43l); QCOMPARE(qvariant_cast(n), 43); QCOMPARE(qvariant_cast(n), 43u); QCOMPARE(qvariant_cast(n), 43.0); @@ -2450,7 +2450,7 @@ void tst_QVariant::variant_to() QCOMPARE(qvariant_cast(n), 44ul); QCOMPARE(qvariant_cast(n), 44.0f); - QCOMPARE(qVariantFromValue(0.25f).toDouble(), 0.25); + QCOMPARE(QVariant::fromValue(0.25f).toDouble(), 0.25); } struct Blah { int i; }; @@ -2502,10 +2502,10 @@ void tst_QVariant::url() QVariant v3(str); //built with a QString QCOMPARE(v2.toUrl(), url); - QVERIFY(qVariantCanConvert(v3)); + QVERIFY(v3.canConvert()); QCOMPARE(v2.toUrl(), v3.toUrl()); - QVERIFY(qVariantCanConvert(v2)); + QVERIFY(v2.canConvert()); QCOMPARE(v2.toString(), str); QCOMPARE(v3.toString(), str); } @@ -2514,7 +2514,7 @@ void tst_QVariant::globalColor() { QVariant variant(Qt::blue); QVERIFY(variant.type() == QVariant::Color); - QVERIFY(qVariantValue(variant) == QColor(Qt::blue)); + QVERIFY(qvariant_cast(variant) == QColor(Qt::blue)); } void tst_QVariant::variantMap() @@ -2687,7 +2687,7 @@ void tst_QVariant::convertToQUint8() const * It's of type QVariant::Int. */ const QVariant v0 = anInt; - QVERIFY(qVariantCanConvert(v0)); + QVERIFY(v0.canConvert()); QCOMPARE(int(qvariant_cast(v0)), 32); QCOMPARE(int(v0.toInt()), 32); QCOMPARE(v0.toString(), QString("32")); @@ -2705,7 +2705,7 @@ void tst_QVariant::convertToQUint8() const const quint8 anInt = 32; const QVariant v0 = anInt; - QVERIFY(qVariantCanConvert(v0)); + QVERIFY(v0.canConvert()); QCOMPARE(int(qvariant_cast(v0)), 32); QCOMPARE(int(v0.toUInt()), 32); QCOMPARE(v0.toString(), QString("32")); @@ -2716,7 +2716,7 @@ void tst_QVariant::convertToQUint8() const const qint16 anInt = 32; const QVariant v0 = anInt; - QVERIFY(qVariantCanConvert(v0)); + QVERIFY(v0.canConvert()); QCOMPARE(int(qvariant_cast(v0)), 32); QCOMPARE(int(v0.toInt()), 32); QCOMPARE(v0.toString(), QString("32")); @@ -2727,7 +2727,7 @@ void tst_QVariant::convertToQUint8() const const quint16 anInt = 32; const QVariant v0 = anInt; - QVERIFY(qVariantCanConvert(v0)); + QVERIFY(v0.canConvert()); QCOMPARE(int(qvariant_cast(v0)), 32); QCOMPARE(int(v0.toUInt()), 32); QCOMPARE(v0.toString(), QString("32")); @@ -2742,8 +2742,8 @@ void tst_QVariant::comparePointers() const MyClass myClass; - QVariant v = qVariantFromValue(&myClass); - QVariant v2 = qVariantFromValue(&myClass); + QVariant v = QVariant::fromValue(&myClass); + QVariant v2 = QVariant::fromValue(&myClass); QCOMPARE(v, v2); } @@ -2758,15 +2758,15 @@ void tst_QVariant::voidStar() const void *p2 = p1; QVariant v1, v2; - v1 = qVariantFromValue(p1); + v1 = QVariant::fromValue(p1); v2 = v1; QVERIFY(v1 == v2); - v2 = qVariantFromValue(p2); + v2 = QVariant::fromValue(p2); QVERIFY(v1 == v2); p2 = 0; - v2 = qVariantFromValue(p2); + v2 = QVariant::fromValue(p2); QVERIFY(v1 != v2); } @@ -2775,14 +2775,14 @@ void tst_QVariant::dataStar() const qRegisterMetaType(); Data *p1 = new Data; - QVariant v1 = qVariantFromValue(p1); + QVariant v1 = QVariant::fromValue(p1); QCOMPARE(v1.userType(), qMetaTypeId()); QCOMPARE(qvariant_cast(v1), p1); QVariant v2 = v1; QVERIFY(v1 == v2); - v2 = qVariantFromValue(p1); + v2 = QVariant::fromValue(p1); QVERIFY(v1 == v2); delete p1; } @@ -2820,10 +2820,10 @@ void tst_QVariant::canConvertQStringList_data() const template void convertMetaType() { - QVERIFY(qVariantFromValue(10).isValid()); - QVERIFY(qVariantFromValue(10).canConvert(QVariant::Int)); - QCOMPARE(qVariantFromValue(10).toInt(), 10); - QCOMPARE(qVariantFromValue(10), qVariantFromValue(10)); + QVERIFY(QVariant::fromValue(10).isValid()); + QVERIFY(QVariant::fromValue(10).canConvert(QVariant::Int)); + QCOMPARE(QVariant::fromValue(10).toInt(), 10); + QCOMPARE(QVariant::fromValue(10), QVariant::fromValue(10)); } #define CONVERT_META_TYPE(Type) \ @@ -2947,11 +2947,11 @@ void tst_QVariant::compareCustomTypes() const WontCompare f1; f1.x = 0; - const QVariant variant1(qVariantFromValue(f1)); + const QVariant variant1(QVariant::fromValue(f1)); WontCompare f2; f2.x = 0; - const QVariant variant2(qVariantFromValue(f2)); + const QVariant variant2(QVariant::fromValue(f2)); /* We compare pointers. */ QVERIFY(variant1 != variant2); @@ -2973,10 +2973,10 @@ void tst_QVariant::copyingUserTypes() const QVariant var; QVariant var3; const QHostAddress ha("127.0.0.1"); - qVariantSetValue(var, ha); + var.setValue(ha); var3 = var; - QCOMPARE(qVariantValue(var3), ha); + QCOMPARE(qvariant_cast(var3), ha); } void tst_QVariant::convertBoolToByteArray() const @@ -2987,7 +2987,7 @@ void tst_QVariant::convertBoolToByteArray() const const QVariant variant(input); - QCOMPARE(qVariantCanConvert(variant), canConvert); + QCOMPARE(variant.canConvert(), canConvert); if(canConvert) { /* Just call this function so we run the code path. */ @@ -3055,7 +3055,7 @@ void tst_QVariant::convertByteArrayToBool() const const QVariant variant(input); QCOMPARE(variant.type(), QVariant::Bool); QCOMPARE(variant.toBool(), input); - QVERIFY(qVariantCanConvert(variant)); + QVERIFY(variant.canConvert()); QCOMPARE(variant.toByteArray(), output); } @@ -3130,7 +3130,7 @@ void tst_QVariant::setValue() QVERIFY( !v1.isDetached() ); QVERIFY( !v2.isDetached() ); - qVariantSetValue(v2, 3); //set an integer value + v2.setValue(3); //set an integer value QVERIFY( v1.isDetached() ); QVERIFY( v2.isDetached() ); @@ -3209,7 +3209,7 @@ template void playWithVariant(const T &orig, bool isNull, const QString } QCOMPARE(qvariant_cast(v2), qvariant_cast(v)); QCOMPARE(v2.toString(), toString); - v3 = qVariantFromValue(orig); + v3 = QVariant::fromValue(orig); QVERIFY(v3.isValid()); QCOMPARE(v3.isNull(), isNull); diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 40e3cd08b6..487007e4cf 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -526,7 +526,7 @@ void tst_QEasingCurve::properties() obj.setEasing(inOutBack); - QEasingCurve easing = qVariantValue(obj.property("easing")); + QEasingCurve easing = qvariant_cast(obj.property("easing")); QCOMPARE(easing.type(), QEasingCurve::InOutBack); QCOMPARE(easing.overshoot(), overshoot); QCOMPARE(easing.amplitude(), amplitude); @@ -538,9 +538,9 @@ void tst_QEasingCurve::properties() period = linear.period(); obj.setProperty("easing", - qVariantFromValue(QEasingCurve(QEasingCurve::Linear))); + QVariant::fromValue(QEasingCurve(QEasingCurve::Linear))); - easing = qVariantValue(obj.property("easing")); + easing = qvariant_cast(obj.property("easing")); QCOMPARE(easing.type(), QEasingCurve::Linear); QCOMPARE(easing.overshoot(), overshoot); QCOMPARE(easing.amplitude(), amplitude); diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index 30571fadd6..7e31f6091c 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -1064,11 +1064,11 @@ void tst_QDBusAbstractAdaptor::writeProperties() valueSpy.clear(); properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop1"), - qVariantFromValue(QDBusVariant(name))); + QVariant::fromValue(QDBusVariant(name))); QVERIFY(valueSpy.isEmpty()); // call mustn't have succeeded properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop2"), - qVariantFromValue(QDBusVariant(name))); + QVariant::fromValue(QDBusVariant(name))); QCOMPARE(valueSpy, name); QCOMPARE(QString(slotSpy), QString("void %1::setProp2(const QString &)").arg(name)); } @@ -1570,11 +1570,11 @@ void tst_QDBusAbstractAdaptor::writePropertiesPeer() clearValueSpyPeer(); properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop1"), - qVariantFromValue(QDBusVariant(name))); + QVariant::fromValue(QDBusVariant(name))); QVERIFY(valueSpyPeer().isEmpty()); // call mustn't have succeeded properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop2"), - qVariantFromValue(QDBusVariant(name))); + QVariant::fromValue(QDBusVariant(name))); QCOMPARE(valueSpyPeer(), name); QCOMPARE(QString(slotSpyPeer()), QString("void %1::setProp2(const QString &)").arg(name)); } @@ -1774,9 +1774,9 @@ void tst_QDBusAbstractAdaptor::typeMatching_data() QTest::addColumn("value"); QTest::newRow("bool") << "Bool" << "b" << QVariant(true); - QTest::newRow("byte") << "UChar" << "y" << qVariantFromValue(uchar(42)); - QTest::newRow("short") << "Short" << "n" << qVariantFromValue(short(-43)); - QTest::newRow("ushort") << "UShort" << "q" << qVariantFromValue(ushort(44)); + QTest::newRow("byte") << "UChar" << "y" << QVariant::fromValue(uchar(42)); + QTest::newRow("short") << "Short" << "n" << QVariant::fromValue(short(-43)); + QTest::newRow("ushort") << "UShort" << "q" << QVariant::fromValue(ushort(44)); QTest::newRow("int") << "Int" << "i" << QVariant(42); QTest::newRow("uint") << "UInt" << "u" << QVariant(42U); QTest::newRow("qlonglong") << "LongLong" << "x" << QVariant(Q_INT64_C(42)); @@ -1784,12 +1784,12 @@ void tst_QDBusAbstractAdaptor::typeMatching_data() QTest::newRow("double") << "Double" << "d" << QVariant(2.5); QTest::newRow("string") << "String" << "s" << QVariant("Hello, World!"); - QTest::newRow("variant") << "Variant" << "v" << qVariantFromValue(QDBusVariant("Hello again!")); + QTest::newRow("variant") << "Variant" << "v" << QVariant::fromValue(QDBusVariant("Hello again!")); QTest::newRow("list") << "List" << "av" << QVariant(QVariantList() << 42 << QString("foo") << QByteArray("bar") - << qVariantFromValue(QDBusVariant(QString("baz")))); + << QVariant::fromValue(QDBusVariant(QString("baz")))); QTest::newRow("stringlist") << "StringList" << "as" << QVariant(QStringList() << "Hello" << "world"); QTest::newRow("bytearray") << "ByteArray" << "ay" << QVariant(QByteArray("foo")); @@ -1798,24 +1798,24 @@ void tst_QDBusAbstractAdaptor::typeMatching_data() map["The answer to life, the Universe and everything"] = 42u; // uint map["In the beginning..."] = QString("There was nothing"); // string map["but Unix came and said"] = QByteArray("\"Hello, World\""); // bytearray - map["two"] = qVariantFromValue(short(2)); // short + map["two"] = QVariant::fromValue(short(2)); // short QTest::newRow("map") << "Map" << "a{sv}" << QVariant(map); StringStringMap ssmap; ssmap["a"] = "A"; ssmap["A"] = "a"; - QTest::newRow("ssmap") << "SSMap" << "a{ss}" << qVariantFromValue(ssmap); + QTest::newRow("ssmap") << "SSMap" << "a{ss}" << QVariant::fromValue(ssmap); LLDateTimeMap lldtmap; lldtmap[-1] = QDateTime(); QDateTime now = QDateTime::currentDateTime(); lldtmap[now.toTime_t()] = now; // array of struct of int64 and struct of 3 ints and struct of 4 ints and int - QTest::newRow("lldtmap") << "LLDateTimeMap" << "a{x((iii)(iiii)i)}" << qVariantFromValue(lldtmap); + QTest::newRow("lldtmap") << "LLDateTimeMap" << "a{x((iii)(iiii)i)}" << QVariant::fromValue(lldtmap); MyStruct s; s.i = 42; s.s = "A value"; - QTest::newRow("struct") << "Struct" << "(is)" << qVariantFromValue(s); + QTest::newRow("struct") << "Struct" << "(is)" << QVariant::fromValue(s); } void tst_QDBusAbstractAdaptor::typeMatching() diff --git a/tests/auto/dbus/qdbusabstractinterface/pinger.h b/tests/auto/dbus/qdbusabstractinterface/pinger.h index 7fc6e640fe..0b6e8343bb 100644 --- a/tests/auto/dbus/qdbusabstractinterface/pinger.h +++ b/tests/auto/dbus/qdbusabstractinterface/pinger.h @@ -81,19 +81,19 @@ public: inline RegisteredType complexProp() const { return qvariant_cast< RegisteredType >(property("complexProp")); } inline void setComplexProp(RegisteredType value) - { setProperty("complexProp", qVariantFromValue(value)); } + { setProperty("complexProp", QVariant::fromValue(value)); } Q_PROPERTY(QString stringProp READ stringProp WRITE setStringProp) inline QString stringProp() const { return qvariant_cast< QString >(property("stringProp")); } inline void setStringProp(const QString &value) - { setProperty("stringProp", qVariantFromValue(value)); } + { setProperty("stringProp", QVariant::fromValue(value)); } Q_PROPERTY(QDBusVariant variantProp READ variantProp WRITE setVariantProp) inline QDBusVariant variantProp() const { return qvariant_cast< QDBusVariant >(property("variantProp")); } inline void setVariantProp(const QDBusVariant &value) - { setProperty("variantProp", qVariantFromValue(value)); } + { setProperty("variantProp", QVariant::fromValue(value)); } public Q_SLOTS: // METHODS inline QDBusPendingReply complexMethod() @@ -120,7 +120,7 @@ public Q_SLOTS: // METHODS inline QDBusPendingReply sleepMethod(int in0) { QList argumentList; - argumentList << qVariantFromValue(in0); + argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QLatin1String("sleepMethod"), argumentList); } diff --git a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index 59ec2955e4..48ea1e45af 100644 --- a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -582,7 +582,7 @@ void tst_QDBusAbstractInterface::variantPropWrite() QVERIFY2(p, "Not connected to D-Bus"); QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47)); - QVERIFY(p->setProperty("variantProp", qVariantFromValue(expectedValue))); + QVERIFY(p->setProperty("variantProp", QVariant::fromValue(expectedValue))); QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant()); } @@ -603,7 +603,7 @@ void tst_QDBusAbstractInterface::complexPropWrite() QVERIFY2(p, "Not connected to D-Bus"); RegisteredType expectedValue = RegisteredType("This is a value"); - QVERIFY(p->setProperty("complexProp", qVariantFromValue(expectedValue))); + QVERIFY(p->setProperty("complexProp", QVariant::fromValue(expectedValue))); QCOMPARE(targetObj.m_complexProp, expectedValue); } @@ -652,7 +652,7 @@ void tst_QDBusAbstractInterface::variantPropWritePeer() resetServer(); QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47)); - QVERIFY(p->setProperty("variantProp", qVariantFromValue(expectedValue))); + QVERIFY(p->setProperty("variantProp", QVariant::fromValue(expectedValue))); QEXPECT_FAIL("", "QTBUG-24262 peer tests are broken", Abort); QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant()); } @@ -676,7 +676,7 @@ void tst_QDBusAbstractInterface::complexPropWritePeer() resetServer(); RegisteredType expectedValue = RegisteredType("This is a value"); - QVERIFY(p->setProperty("complexProp", qVariantFromValue(expectedValue))); + QVERIFY(p->setProperty("complexProp", QVariant::fromValue(expectedValue))); QEXPECT_FAIL("", "QTBUG-24262 peer tests are broken", Abort); QCOMPARE(targetObj.m_complexProp, expectedValue); } diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index af2355aa5d..f6520ce946 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -161,7 +161,7 @@ int prop1Peer() void setComplexPropPeer(QList val) { QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "setComplexProp"); - req << qVariantFromValue(val); + req << QVariant::fromValue(val); QDBusMessage reply = QDBusConnection::sessionBus().call(req); } @@ -474,7 +474,7 @@ void tst_QDBusInterface::callMethod() MyObject::callCount = 0; // call a SLOT method - QDBusMessage reply = iface.call("ping", qVariantFromValue(QDBusVariant("foo"))); + QDBusMessage reply = iface.call("ping", QVariant::fromValue(QDBusVariant("foo"))); QCOMPARE(MyObject::callCount, 1); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -493,7 +493,7 @@ void tst_QDBusInterface::callMethod() QCOMPARE(dv.variant().toString(), QString("foo")); // call an INVOKABLE method - reply = iface.call("ping_invokable", qVariantFromValue(QDBusVariant("bar"))); + reply = iface.call("ping_invokable", QVariant::fromValue(QDBusVariant("bar"))); QCOMPARE(MyObject::callCount, 2); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -708,7 +708,7 @@ void tst_QDBusInterface::callMethodPeer() resetPeer(); // call a SLOT method - QDBusMessage reply = iface.call("ping", qVariantFromValue(QDBusVariant("foo"))); + QDBusMessage reply = iface.call("ping", QVariant::fromValue(QDBusVariant("foo"))); QCOMPARE(callCountPeer(), 1); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -728,7 +728,7 @@ void tst_QDBusInterface::callMethodPeer() QCOMPARE(dv.variant().toString(), QString("foo")); // call an INVOKABLE method - reply = iface.call("ping_invokable", qVariantFromValue(QDBusVariant("bar"))); + reply = iface.call("ping_invokable", QVariant::fromValue(QDBusVariant("bar"))); QCOMPARE(callCountPeer(), 2); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -1066,7 +1066,7 @@ void tst_QDBusInterface::complexPropertyWrite() obj.m_complexProp.clear(); MyObject::callCount = 0; - QVERIFY(iface.setProperty("complexProp", qVariantFromValue(arg))); + QVERIFY(iface.setProperty("complexProp", QVariant::fromValue(arg))); QCOMPARE(MyObject::callCount, 1); QCOMPARE(obj.m_complexProp, arg); } @@ -1129,7 +1129,7 @@ void tst_QDBusInterface::complexPropertyWritePeer() resetPeer(); QList arg = QList() << -47 << 42; - QVERIFY(iface.setProperty("complexProp", qVariantFromValue(arg))); + QVERIFY(iface.setProperty("complexProp", QVariant::fromValue(arg))); QCOMPARE(callCountPeer(), 1); QCOMPARE(complexPropPeer(), arg); } diff --git a/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp b/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp index 871ae6948d..340455c2bd 100644 --- a/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp +++ b/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp @@ -185,7 +185,7 @@ void tst_QDBusLocalCalls::makeCallsVariant() QFETCH(QVariant, value); QDBusMessage callMsg = QDBusMessage::createMethodCall(conn.baseService(), "/", QString(), "echo"); - callMsg << qVariantFromValue(QDBusVariant(value)); + callMsg << QVariant::fromValue(QDBusVariant(value)); QDBusMessage replyMsg = doCall(callMsg); QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage)); @@ -222,7 +222,7 @@ void tst_QDBusLocalCalls::makeCallsComplex() value << 1 << -42 << 47; QDBusMessage callMsg = QDBusMessage::createMethodCall(conn.baseService(), "/", QString(), "echo"); - callMsg << qVariantFromValue(value); + callMsg << QVariant::fromValue(value); QDBusMessage replyMsg = doCall(callMsg); QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage)); diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 8412fb85be..8a7e809b15 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -182,9 +182,9 @@ void basicNumericTypes_data() { QTest::newRow("bool") << QVariant(false) << "b" << "false"; QTest::newRow("bool2") << QVariant(true) << "b" << "true"; - QTest::newRow("byte") << qVariantFromValue(uchar(1)) << "y" << "1"; - QTest::newRow("int16") << qVariantFromValue(short(2)) << "n" << "2"; - QTest::newRow("uint16") << qVariantFromValue(ushort(3)) << "q" << "3"; + QTest::newRow("byte") << QVariant::fromValue(uchar(1)) << "y" << "1"; + QTest::newRow("int16") << QVariant::fromValue(short(2)) << "n" << "2"; + QTest::newRow("uint16") << QVariant::fromValue(ushort(3)) << "q" << "3"; QTest::newRow("int") << QVariant(1) << "i" << "1"; QTest::newRow("uint") << QVariant(2U) << "u" << "2"; QTest::newRow("int64") << QVariant(Q_INT64_C(3)) << "x" << "3"; @@ -195,8 +195,8 @@ void basicNumericTypes_data() void basicStringTypes_data() { QTest::newRow("string") << QVariant("ping") << "s" << "\"ping\""; - QTest::newRow("objectpath") << qVariantFromValue(QDBusObjectPath("/org/kde")) << "o" << "[ObjectPath: /org/kde]"; - QTest::newRow("signature") << qVariantFromValue(QDBusSignature("g")) << "g" << "[Signature: g]"; + QTest::newRow("objectpath") << QVariant::fromValue(QDBusObjectPath("/org/kde")) << "o" << "[ObjectPath: /org/kde]"; + QTest::newRow("signature") << QVariant::fromValue(QDBusSignature("g")) << "g" << "[Signature: g]"; QTest::newRow("emptystring") << QVariant("") << "s" << "\"\""; QTest::newRow("nullstring") << QVariant(QString()) << "s" << "\"\""; } @@ -210,17 +210,17 @@ void tst_QDBusMarshall::sendBasic_data() basicStringTypes_data(); if (fileDescriptorPassing) - QTest::newRow("file-descriptor") << qVariantFromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())) << "h" << "[Unix FD: valid]"; + QTest::newRow("file-descriptor") << QVariant::fromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())) << "h" << "[Unix FD: valid]"; } void tst_QDBusMarshall::sendVariant_data() { sendBasic_data(); - QTest::newRow("variant") << qVariantFromValue(QDBusVariant(1)) << "v" << "[Variant(int): 1]"; + QTest::newRow("variant") << QVariant::fromValue(QDBusVariant(1)) << "v" << "[Variant(int): 1]"; QDBusVariant nested(1); - QTest::newRow("variant-variant") << qVariantFromValue(QDBusVariant(qVariantFromValue(nested))) << "v" + QTest::newRow("variant-variant") << QVariant::fromValue(QDBusVariant(QVariant::fromValue(nested))) << "v" << "[Variant(QDBusVariant): [Variant(int): 1]]"; } @@ -252,70 +252,70 @@ void tst_QDBusMarshall::sendArrays_data() QTest::newRow("bytearray") << QVariant(bytearray) << "ay" << "{102, 111, 111}"; QList bools; - QTest::newRow("emptyboollist") << qVariantFromValue(bools) << "ab" << "[Argument: ab {}]"; + QTest::newRow("emptyboollist") << QVariant::fromValue(bools) << "ab" << "[Argument: ab {}]"; bools << false << true << false; - QTest::newRow("boollist") << qVariantFromValue(bools) << "ab" << "[Argument: ab {false, true, false}]"; + QTest::newRow("boollist") << QVariant::fromValue(bools) << "ab" << "[Argument: ab {false, true, false}]"; QList shorts; - QTest::newRow("emptyshortlist") << qVariantFromValue(shorts) << "an" << "[Argument: an {}]"; + QTest::newRow("emptyshortlist") << QVariant::fromValue(shorts) << "an" << "[Argument: an {}]"; shorts << 42 << -43 << 44 << 45 << -32768 << 32767; - QTest::newRow("shortlist") << qVariantFromValue(shorts) << "an" + QTest::newRow("shortlist") << QVariant::fromValue(shorts) << "an" << "[Argument: an {42, -43, 44, 45, -32768, 32767}]"; QList ushorts; - QTest::newRow("emptyushortlist") << qVariantFromValue(ushorts) << "aq" << "[Argument: aq {}]"; + QTest::newRow("emptyushortlist") << QVariant::fromValue(ushorts) << "aq" << "[Argument: aq {}]"; ushorts << 12u << 13u << 14u << 15 << 65535; - QTest::newRow("ushortlist") << qVariantFromValue(ushorts) << "aq" << "[Argument: aq {12, 13, 14, 15, 65535}]"; + QTest::newRow("ushortlist") << QVariant::fromValue(ushorts) << "aq" << "[Argument: aq {12, 13, 14, 15, 65535}]"; QList ints; - QTest::newRow("emptyintlist") << qVariantFromValue(ints) << "ai" << "[Argument: ai {}]"; + QTest::newRow("emptyintlist") << QVariant::fromValue(ints) << "ai" << "[Argument: ai {}]"; ints << 42 << -43 << 44 << 45 << 2147483647 << -2147483647-1; - QTest::newRow("intlist") << qVariantFromValue(ints) << "ai" << "[Argument: ai {42, -43, 44, 45, 2147483647, -2147483648}]"; + QTest::newRow("intlist") << QVariant::fromValue(ints) << "ai" << "[Argument: ai {42, -43, 44, 45, 2147483647, -2147483648}]"; QList uints; - QTest::newRow("emptyuintlist") << qVariantFromValue(uints) << "au" << "[Argument: au {}]"; + QTest::newRow("emptyuintlist") << QVariant::fromValue(uints) << "au" << "[Argument: au {}]"; uints << uint(12) << uint(13) << uint(14) << 4294967295U; - QTest::newRow("uintlist") << qVariantFromValue(uints) << "au" << "[Argument: au {12, 13, 14, 4294967295}]"; + QTest::newRow("uintlist") << QVariant::fromValue(uints) << "au" << "[Argument: au {12, 13, 14, 4294967295}]"; QList llints; - QTest::newRow("emptyllintlist") << qVariantFromValue(llints) << "ax" << "[Argument: ax {}]"; + QTest::newRow("emptyllintlist") << QVariant::fromValue(llints) << "ax" << "[Argument: ax {}]"; llints << Q_INT64_C(99) << Q_INT64_C(-100) << Q_INT64_C(-9223372036854775807)-1 << Q_INT64_C(9223372036854775807); - QTest::newRow("llintlist") << qVariantFromValue(llints) << "ax" + QTest::newRow("llintlist") << QVariant::fromValue(llints) << "ax" << "[Argument: ax {99, -100, -9223372036854775808, 9223372036854775807}]"; QList ullints; - QTest::newRow("emptyullintlist") << qVariantFromValue(ullints) << "at" << "[Argument: at {}]"; + QTest::newRow("emptyullintlist") << QVariant::fromValue(ullints) << "at" << "[Argument: at {}]"; ullints << Q_UINT64_C(66) << Q_UINT64_C(67) << Q_UINT64_C(18446744073709551615); - QTest::newRow("ullintlist") << qVariantFromValue(ullints) << "at" << "[Argument: at {66, 67, 18446744073709551615}]"; + QTest::newRow("ullintlist") << QVariant::fromValue(ullints) << "at" << "[Argument: at {66, 67, 18446744073709551615}]"; QList doubles; - QTest::newRow("emptydoublelist") << qVariantFromValue(doubles) << "ad" << "[Argument: ad {}]"; + QTest::newRow("emptydoublelist") << QVariant::fromValue(doubles) << "ad" << "[Argument: ad {}]"; doubles << 1.2 << 2.2 << 4.4 << -std::numeric_limits::infinity() << std::numeric_limits::infinity() << std::numeric_limits::quiet_NaN(); - QTest::newRow("doublelist") << qVariantFromValue(doubles) << "ad" << "[Argument: ad {1.2, 2.2, 4.4, -inf, inf, nan}]"; + QTest::newRow("doublelist") << QVariant::fromValue(doubles) << "ad" << "[Argument: ad {1.2, 2.2, 4.4, -inf, inf, nan}]"; QList objectPaths; - QTest::newRow("emptyobjectpathlist") << qVariantFromValue(objectPaths) << "ao" << "[Argument: ao {}]"; + QTest::newRow("emptyobjectpathlist") << QVariant::fromValue(objectPaths) << "ao" << "[Argument: ao {}]"; objectPaths << QDBusObjectPath("/") << QDBusObjectPath("/foo"); - QTest::newRow("objectpathlist") << qVariantFromValue(objectPaths) << "ao" << "[Argument: ao {[ObjectPath: /], [ObjectPath: /foo]}]"; + QTest::newRow("objectpathlist") << QVariant::fromValue(objectPaths) << "ao" << "[Argument: ao {[ObjectPath: /], [ObjectPath: /foo]}]"; if (fileDescriptorPassing) { QList fileDescriptors; - QTest::newRow("emptyfiledescriptorlist") << qVariantFromValue(fileDescriptors) << "ah" << "[Argument: ah {}]"; + QTest::newRow("emptyfiledescriptorlist") << QVariant::fromValue(fileDescriptors) << "ah" << "[Argument: ah {}]"; fileDescriptors << QDBusUnixFileDescriptor(fileDescriptorForTest()) << QDBusUnixFileDescriptor(1); - QTest::newRow("filedescriptorlist") << qVariantFromValue(fileDescriptors) << "ah" << "[Argument: ah {[Unix FD: valid], [Unix FD: valid]}]"; + QTest::newRow("filedescriptorlist") << QVariant::fromValue(fileDescriptors) << "ah" << "[Argument: ah {[Unix FD: valid], [Unix FD: valid]}]"; } QVariantList variants; QTest::newRow("emptyvariantlist") << QVariant(variants) << "av" << "[Argument: av {}]"; variants << QString("Hello") << QByteArray("World") << 42 << -43.0 << 44U << Q_INT64_C(-45) - << Q_UINT64_C(46) << true << qVariantFromValue(short(-47)) - << qVariantFromValue(QDBusSignature("av")) - << qVariantFromValue(QDBusVariant(qVariantFromValue(QDBusObjectPath("/")))); + << Q_UINT64_C(46) << true << QVariant::fromValue(short(-47)) + << QVariant::fromValue(QDBusSignature("av")) + << QVariant::fromValue(QDBusVariant(QVariant::fromValue(QDBusObjectPath("/")))); QTest::newRow("variantlist") << QVariant(variants) << "av" << "[Argument: av {[Variant(QString): \"Hello\"], [Variant(QByteArray): {87, 111, 114, 108, 100}], [Variant(int): 42], [Variant(double): -43], [Variant(uint): 44], [Variant(qlonglong): -45], [Variant(qulonglong): 46], [Variant(bool): true], [Variant(short): -47], [Variant: [Signature: av]], [Variant: [Variant: [ObjectPath: /]]]}]"; } @@ -328,132 +328,132 @@ void tst_QDBusMarshall::sendArrayOfArrays_data() // arrays: QList strings; - QTest::newRow("empty-list-of-stringlist") << qVariantFromValue(strings) << "aas" + QTest::newRow("empty-list-of-stringlist") << QVariant::fromValue(strings) << "aas" << "[Argument: aas {}]"; strings << QStringList(); - QTest::newRow("list-of-emptystringlist") << qVariantFromValue(strings) << "aas" + QTest::newRow("list-of-emptystringlist") << QVariant::fromValue(strings) << "aas" << "[Argument: aas {{}}]"; strings << (QStringList() << "hello" << "world") << (QStringList() << "hi" << "there") << (QStringList() << QString()); - QTest::newRow("stringlist") << qVariantFromValue(strings) << "aas" + QTest::newRow("stringlist") << QVariant::fromValue(strings) << "aas" << "[Argument: aas {{}, {\"hello\", \"world\"}, {\"hi\", \"there\"}, {\"\"}}]"; QList bytearray; - QTest::newRow("empty-list-of-bytearray") << qVariantFromValue(bytearray) << "aay" + QTest::newRow("empty-list-of-bytearray") << QVariant::fromValue(bytearray) << "aay" << "[Argument: aay {}]"; bytearray << QByteArray(); - QTest::newRow("list-of-emptybytearray") << qVariantFromValue(bytearray) << "aay" + QTest::newRow("list-of-emptybytearray") << QVariant::fromValue(bytearray) << "aay" << "[Argument: aay {{}}]"; bytearray << "foo" << "bar" << "baz" << "" << QByteArray(); - QTest::newRow("bytearray") << qVariantFromValue(bytearray) << "aay" + QTest::newRow("bytearray") << QVariant::fromValue(bytearray) << "aay" << "[Argument: aay {{}, {102, 111, 111}, {98, 97, 114}, {98, 97, 122}, {}, {}}]"; QList > bools; - QTest::newRow("empty-list-of-boollist") << qVariantFromValue(bools) << "aab" + QTest::newRow("empty-list-of-boollist") << QVariant::fromValue(bools) << "aab" << "[Argument: aab {}]"; bools << QList(); - QTest::newRow("list-of-emptyboollist") << qVariantFromValue(bools) << "aab" + QTest::newRow("list-of-emptyboollist") << QVariant::fromValue(bools) << "aab" << "[Argument: aab {[Argument: ab {}]}]"; bools << (QList() << false << true) << (QList() << false) << (QList()); - QTest::newRow("boollist") << qVariantFromValue(bools) << "aab" + QTest::newRow("boollist") << QVariant::fromValue(bools) << "aab" << "[Argument: aab {[Argument: ab {}], [Argument: ab {false, true}], [Argument: ab {false}], [Argument: ab {}]}]"; QList > shorts; - QTest::newRow("empty-list-of-shortlist") << qVariantFromValue(shorts) << "aan" + QTest::newRow("empty-list-of-shortlist") << QVariant::fromValue(shorts) << "aan" << "[Argument: aan {}]"; shorts << QList(); - QTest::newRow("list-of-emptyshortlist") << qVariantFromValue(shorts) << "aan" + QTest::newRow("list-of-emptyshortlist") << QVariant::fromValue(shorts) << "aan" << "[Argument: aan {[Argument: an {}]}]"; shorts << (QList() << 42 << -43 << 44 << 45) << (QList() << -32768 << 32767) << (QList()); - QTest::newRow("shortlist") << qVariantFromValue(shorts) << "aan" + QTest::newRow("shortlist") << QVariant::fromValue(shorts) << "aan" << "[Argument: aan {[Argument: an {}], [Argument: an {42, -43, 44, 45}], [Argument: an {-32768, 32767}], [Argument: an {}]}]"; QList > ushorts; - QTest::newRow("empty-list-of-ushortlist") << qVariantFromValue(ushorts) << "aaq" + QTest::newRow("empty-list-of-ushortlist") << QVariant::fromValue(ushorts) << "aaq" << "[Argument: aaq {}]"; ushorts << QList(); - QTest::newRow("list-of-emptyushortlist") << qVariantFromValue(ushorts) << "aaq" + QTest::newRow("list-of-emptyushortlist") << QVariant::fromValue(ushorts) << "aaq" << "[Argument: aaq {[Argument: aq {}]}]"; ushorts << (QList() << 12u << 13u << 14u << 15) << (QList() << 65535) << (QList()); - QTest::newRow("ushortlist") << qVariantFromValue(ushorts) << "aaq" + QTest::newRow("ushortlist") << QVariant::fromValue(ushorts) << "aaq" << "[Argument: aaq {[Argument: aq {}], [Argument: aq {12, 13, 14, 15}], [Argument: aq {65535}], [Argument: aq {}]}]"; QList > ints; - QTest::newRow("empty-list-of-intlist") << qVariantFromValue(ints) << "aai" + QTest::newRow("empty-list-of-intlist") << QVariant::fromValue(ints) << "aai" << "[Argument: aai {}]"; ints << QList(); - QTest::newRow("list-of-emptyintlist") << qVariantFromValue(ints) << "aai" + QTest::newRow("list-of-emptyintlist") << QVariant::fromValue(ints) << "aai" << "[Argument: aai {[Argument: ai {}]}]"; ints << (QList() << 42 << -43 << 44 << 45) << (QList() << 2147483647 << -2147483647-1) << (QList()); - QTest::newRow("intlist") << qVariantFromValue(ints) << "aai" + QTest::newRow("intlist") << QVariant::fromValue(ints) << "aai" << "[Argument: aai {[Argument: ai {}], [Argument: ai {42, -43, 44, 45}], [Argument: ai {2147483647, -2147483648}], [Argument: ai {}]}]"; QList > uints; - QTest::newRow("empty-list-of-uintlist") << qVariantFromValue(uints) << "aau" + QTest::newRow("empty-list-of-uintlist") << QVariant::fromValue(uints) << "aau" << "[Argument: aau {}]"; uints << QList(); - QTest::newRow("list-of-emptyuintlist") << qVariantFromValue(uints) << "aau" + QTest::newRow("list-of-emptyuintlist") << QVariant::fromValue(uints) << "aau" << "[Argument: aau {[Argument: au {}]}]"; uints << (QList() << uint(12) << uint(13) << uint(14)) << (QList() << 4294967295U) << (QList()); - QTest::newRow("uintlist") << qVariantFromValue(uints) << "aau" + QTest::newRow("uintlist") << QVariant::fromValue(uints) << "aau" << "[Argument: aau {[Argument: au {}], [Argument: au {12, 13, 14}], [Argument: au {4294967295}], [Argument: au {}]}]"; QList > llints; - QTest::newRow("empty-list-of-llintlist") << qVariantFromValue(llints) << "aax" + QTest::newRow("empty-list-of-llintlist") << QVariant::fromValue(llints) << "aax" << "[Argument: aax {}]"; llints << QList(); - QTest::newRow("list-of-emptyllintlist") << qVariantFromValue(llints) << "aax" + QTest::newRow("list-of-emptyllintlist") << QVariant::fromValue(llints) << "aax" << "[Argument: aax {[Argument: ax {}]}]"; llints << (QList() << Q_INT64_C(99) << Q_INT64_C(-100)) << (QList() << Q_INT64_C(-9223372036854775807)-1 << Q_INT64_C(9223372036854775807)) << (QList()); - QTest::newRow("llintlist") << qVariantFromValue(llints) << "aax" + QTest::newRow("llintlist") << QVariant::fromValue(llints) << "aax" << "[Argument: aax {[Argument: ax {}], [Argument: ax {99, -100}], [Argument: ax {-9223372036854775808, 9223372036854775807}], [Argument: ax {}]}]"; QList > ullints; - QTest::newRow("empty-list-of-ullintlist") << qVariantFromValue(ullints) << "aat" + QTest::newRow("empty-list-of-ullintlist") << QVariant::fromValue(ullints) << "aat" << "[Argument: aat {}]"; ullints << QList(); - QTest::newRow("list-of-emptyullintlist") << qVariantFromValue(ullints) << "aat" + QTest::newRow("list-of-emptyullintlist") << QVariant::fromValue(ullints) << "aat" << "[Argument: aat {[Argument: at {}]}]"; ullints << (QList() << Q_UINT64_C(66) << Q_UINT64_C(67)) << (QList() << Q_UINT64_C(18446744073709551615)) << (QList()); - QTest::newRow("ullintlist") << qVariantFromValue(ullints) << "aat" + QTest::newRow("ullintlist") << QVariant::fromValue(ullints) << "aat" << "[Argument: aat {[Argument: at {}], [Argument: at {66, 67}], [Argument: at {18446744073709551615}], [Argument: at {}]}]"; QList > doubles; - QTest::newRow("empty-list-ofdoublelist") << qVariantFromValue(doubles) << "aad" + QTest::newRow("empty-list-ofdoublelist") << QVariant::fromValue(doubles) << "aad" << "[Argument: aad {}]"; doubles << QList(); - QTest::newRow("list-of-emptydoublelist") << qVariantFromValue(doubles) << "aad" + QTest::newRow("list-of-emptydoublelist") << QVariant::fromValue(doubles) << "aad" << "[Argument: aad {[Argument: ad {}]}]"; doubles << (QList() << 1.2 << 2.2 << 4.4) << (QList() << -std::numeric_limits::infinity() << std::numeric_limits::infinity() << std::numeric_limits::quiet_NaN()) << (QList()); - QTest::newRow("doublelist") << qVariantFromValue(doubles) << "aad" + QTest::newRow("doublelist") << QVariant::fromValue(doubles) << "aad" << "[Argument: aad {[Argument: ad {}], [Argument: ad {1.2, 2.2, 4.4}], [Argument: ad {-inf, inf, nan}], [Argument: ad {}]}]"; QList variants; - QTest::newRow("emptyvariantlist") << qVariantFromValue(variants) << "aav" + QTest::newRow("emptyvariantlist") << QVariant::fromValue(variants) << "aav" << "[Argument: aav {}]"; variants << QVariantList(); - QTest::newRow("emptyvariantlist") << qVariantFromValue(variants) << "aav" + QTest::newRow("emptyvariantlist") << QVariant::fromValue(variants) << "aav" << "[Argument: aav {[Argument: av {}]}]"; variants << (QVariantList() << QString("Hello") << QByteArray("World")) << (QVariantList() << 42 << -43.0 << 44U << Q_INT64_C(-45)) - << (QVariantList() << Q_UINT64_C(46) << true << qVariantFromValue(short(-47))); - QTest::newRow("variantlist") << qVariantFromValue(variants) << "aav" + << (QVariantList() << Q_UINT64_C(46) << true << QVariant::fromValue(short(-47))); + QTest::newRow("variantlist") << QVariant::fromValue(variants) << "aav" << "[Argument: aav {[Argument: av {}], [Argument: av {[Variant(QString): \"Hello\"], [Variant(QByteArray): {87, 111, 114, 108, 100}]}], [Argument: av {[Variant(int): 42], [Variant(double): -43], [Variant(uint): 44], [Variant(qlonglong): -45]}], [Argument: av {[Variant(qulonglong): 46], [Variant(bool): true], [Variant(short): -47]}]}]"; } @@ -464,65 +464,65 @@ void tst_QDBusMarshall::sendMaps_data() QTest::addColumn("stringResult"); QMap ismap; - QTest::newRow("empty-is-map") << qVariantFromValue(ismap) << "a{is}" + QTest::newRow("empty-is-map") << QVariant::fromValue(ismap) << "a{is}" << "[Argument: a{is} {}]"; ismap[1] = "a"; ismap[2000] = "b"; ismap[-47] = "c"; - QTest::newRow("is-map") << qVariantFromValue(ismap) << "a{is}" + QTest::newRow("is-map") << QVariant::fromValue(ismap) << "a{is}" << "[Argument: a{is} {-47 = \"c\", 1 = \"a\", 2000 = \"b\"}]"; QMap ssmap; - QTest::newRow("empty-ss-map") << qVariantFromValue(ssmap) << "a{ss}" + QTest::newRow("empty-ss-map") << QVariant::fromValue(ssmap) << "a{ss}" << "[Argument: a{ss} {}]"; ssmap["a"] = "a"; ssmap["c"] = "b"; ssmap["b"] = "c"; - QTest::newRow("ss-map") << qVariantFromValue(ssmap) << "a{ss}" + QTest::newRow("ss-map") << QVariant::fromValue(ssmap) << "a{ss}" << "[Argument: a{ss} {\"a\" = \"a\", \"b\" = \"c\", \"c\" = \"b\"}]"; QVariantMap svmap; - QTest::newRow("empty-sv-map") << qVariantFromValue(svmap) << "a{sv}" + QTest::newRow("empty-sv-map") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {}]"; svmap["a"] = 1; svmap["c"] = "b"; svmap["b"] = QByteArray("c"); svmap["d"] = 42U; - svmap["e"] = qVariantFromValue(short(-47)); - svmap["f"] = qVariantFromValue(QDBusVariant(0)); - QTest::newRow("sv-map1") << qVariantFromValue(svmap) << "a{sv}" + svmap["e"] = QVariant::fromValue(short(-47)); + svmap["f"] = QVariant::fromValue(QDBusVariant(0)); + QTest::newRow("sv-map1") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {\"a\" = [Variant(int): 1], \"b\" = [Variant(QByteArray): {99}], \"c\" = [Variant(QString): \"b\"], \"d\" = [Variant(uint): 42], \"e\" = [Variant(short): -47], \"f\" = [Variant: [Variant(int): 0]]}]"; QMap osmap; - QTest::newRow("empty-os-map") << qVariantFromValue(osmap) << "a{os}" + QTest::newRow("empty-os-map") << QVariant::fromValue(osmap) << "a{os}" << "[Argument: a{os} {}]"; osmap[QDBusObjectPath("/")] = "root"; osmap[QDBusObjectPath("/foo")] = "foo"; osmap[QDBusObjectPath("/bar/baz")] = "bar and baz"; - QTest::newRow("os-map") << qVariantFromValue(osmap) << "a{os}" + QTest::newRow("os-map") << QVariant::fromValue(osmap) << "a{os}" << "[Argument: a{os} {[ObjectPath: /] = \"root\", [ObjectPath: /bar/baz] = \"bar and baz\", [ObjectPath: /foo] = \"foo\"}]"; QMap gsmap; - QTest::newRow("empty-gs-map") << qVariantFromValue(gsmap) << "a{gs}" + QTest::newRow("empty-gs-map") << QVariant::fromValue(gsmap) << "a{gs}" << "[Argument: a{gs} {}]"; gsmap[QDBusSignature("i")] = "int32"; gsmap[QDBusSignature("s")] = "string"; gsmap[QDBusSignature("a{gs}")] = "array of dict_entry of (signature, string)"; - QTest::newRow("gs-map") << qVariantFromValue(gsmap) << "a{gs}" + QTest::newRow("gs-map") << QVariant::fromValue(gsmap) << "a{gs}" << "[Argument: a{gs} {[Signature: a{gs}] = \"array of dict_entry of (signature, string)\", [Signature: i] = \"int32\", [Signature: s] = \"string\"}]"; if (fileDescriptorPassing) { - svmap["zzfiledescriptor"] = qVariantFromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())); - QTest::newRow("sv-map1-fd") << qVariantFromValue(svmap) << "a{sv}" + svmap["zzfiledescriptor"] = QVariant::fromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())); + QTest::newRow("sv-map1-fd") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {\"a\" = [Variant(int): 1], \"b\" = [Variant(QByteArray): {99}], \"c\" = [Variant(QString): \"b\"], \"d\" = [Variant(uint): 42], \"e\" = [Variant(short): -47], \"f\" = [Variant: [Variant(int): 0]], \"zzfiledescriptor\" = [Variant(QDBusUnixFileDescriptor): [Unix FD: valid]]}]"; } svmap.clear(); - svmap["ismap"] = qVariantFromValue(ismap); - svmap["ssmap"] = qVariantFromValue(ssmap); - svmap["osmap"] = qVariantFromValue(osmap); - svmap["gsmap"] = qVariantFromValue(gsmap); - QTest::newRow("sv-map2") << qVariantFromValue(svmap) << "a{sv}" + svmap["ismap"] = QVariant::fromValue(ismap); + svmap["ssmap"] = QVariant::fromValue(ssmap); + svmap["osmap"] = QVariant::fromValue(osmap); + svmap["gsmap"] = QVariant::fromValue(gsmap); + QTest::newRow("sv-map2") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {\"gsmap\" = [Variant: [Argument: a{gs} {[Signature: a{gs}] = \"array of dict_entry of (signature, string)\", [Signature: i] = \"int32\", [Signature: s] = \"string\"}]], \"ismap\" = [Variant: [Argument: a{is} {-47 = \"c\", 1 = \"a\", 2000 = \"b\"}]], \"osmap\" = [Variant: [Argument: a{os} {[ObjectPath: /] = \"root\", [ObjectPath: /bar/baz] = \"bar and baz\", [ObjectPath: /foo] = \"foo\"}]], \"ssmap\" = [Variant: [Argument: a{ss} {\"a\" = \"a\", \"b\" = \"c\", \"c\" = \"b\"}]]}]"; } @@ -554,33 +554,33 @@ void tst_QDBusMarshall::sendStructs_data() << "[Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 12, 25, 0, 0], 0]"; MyStruct ms = { 1, "Hello, World" }; - QTest::newRow("int-string") << qVariantFromValue(ms) << "(is)" << "[Argument: (is) 1, \"Hello, World\"]"; + QTest::newRow("int-string") << QVariant::fromValue(ms) << "(is)" << "[Argument: (is) 1, \"Hello, World\"]"; MyVariantMapStruct mvms = { "Hello, World", QVariantMap() }; - QTest::newRow("string-variantmap") << qVariantFromValue(mvms) << "(sa{sv})" << "[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {}]]"; + QTest::newRow("string-variantmap") << QVariant::fromValue(mvms) << "(sa{sv})" << "[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {}]]"; // use only basic types, otherwise comparison will fail mvms.map["int"] = 42; mvms.map["uint"] = 42u; - mvms.map["short"] = qVariantFromValue(-47); + mvms.map["short"] = QVariant::fromValue(-47); mvms.map["bytearray"] = QByteArray("Hello, world"); - QTest::newRow("string-variantmap2") << qVariantFromValue(mvms) << "(sa{sv})" << "[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]"; + QTest::newRow("string-variantmap2") << QVariant::fromValue(mvms) << "(sa{sv})" << "[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]"; QList list; - QTest::newRow("empty-list-of-string-variantmap") << qVariantFromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {}]"; + QTest::newRow("empty-list-of-string-variantmap") << QVariant::fromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {}]"; list << mvms; - QTest::newRow("list-of-string-variantmap") << qVariantFromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]}]"; + QTest::newRow("list-of-string-variantmap") << QVariant::fromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]}]"; if (fileDescriptorPassing) { MyFileDescriptorStruct fds; fds.fd = QDBusUnixFileDescriptor(fileDescriptorForTest()); - QTest::newRow("fdstruct") << qVariantFromValue(fds) << "(h)" << "[Argument: (h) [Unix FD: valid]]"; + QTest::newRow("fdstruct") << QVariant::fromValue(fds) << "(h)" << "[Argument: (h) [Unix FD: valid]]"; QList fdlist; - QTest::newRow("empty-list-of-fdstruct") << qVariantFromValue(fdlist) << "a(h)" << "[Argument: a(h) {}]"; + QTest::newRow("empty-list-of-fdstruct") << QVariant::fromValue(fdlist) << "a(h)" << "[Argument: a(h) {}]"; fdlist << fds; - QTest::newRow("list-of-fdstruct") << qVariantFromValue(fdlist) << "a(h)" << "[Argument: a(h) {[Argument: (h) [Unix FD: valid]]}]"; + QTest::newRow("list-of-fdstruct") << QVariant::fromValue(fdlist) << "a(h)" << "[Argument: a(h) {[Argument: (h) [Unix FD: valid]]}]"; } } @@ -591,23 +591,23 @@ void tst_QDBusMarshall::sendComplex_data() QTest::addColumn("stringResult"); QList dtlist; - QTest::newRow("empty-datetimelist") << qVariantFromValue(dtlist) << "a((iii)(iiii)i)" + QTest::newRow("empty-datetimelist") << QVariant::fromValue(dtlist) << "a((iii)(iiii)i)" << "[Argument: a((iii)(iiii)i) {}]"; dtlist << QDateTime(); - QTest::newRow("list-of-emptydatetime") << qVariantFromValue(dtlist) << "a((iii)(iiii)i)" + QTest::newRow("list-of-emptydatetime") << QVariant::fromValue(dtlist) << "a((iii)(iiii)i)" << "[Argument: a((iii)(iiii)i) {[Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0]}]"; dtlist << QDateTime(QDate(1977, 9, 13), QTime(0, 0, 0)) << QDateTime(QDate(2006, 6, 18), QTime(13, 14, 0)); - QTest::newRow("datetimelist") << qVariantFromValue(dtlist) << "a((iii)(iiii)i)" + QTest::newRow("datetimelist") << QVariant::fromValue(dtlist) << "a((iii)(iiii)i)" << "[Argument: a((iii)(iiii)i) {[Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0], [Argument: ((iii)(iiii)i) [Argument: (iii) 1977, 9, 13], [Argument: (iiii) 0, 0, 0, 0], 0], [Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 13, 14, 0, 0], 0]}]"; QMap lldtmap; - QTest::newRow("empty-lldtmap") << qVariantFromValue(lldtmap) << "a{x((iii)(iiii)i)}" + QTest::newRow("empty-lldtmap") << QVariant::fromValue(lldtmap) << "a{x((iii)(iiii)i)}" << "[Argument: a{x((iii)(iiii)i)} {}]"; lldtmap[0] = QDateTime(); lldtmap[1] = QDateTime(QDate(1970, 1, 1), QTime(0, 0, 1), Qt::UTC); lldtmap[1150629776] = QDateTime(QDate(2006, 6, 18), QTime(11, 22, 56), Qt::UTC); - QTest::newRow("lldtmap") << qVariantFromValue(lldtmap) << "a{x((iii)(iiii)i)}" + QTest::newRow("lldtmap") << QVariant::fromValue(lldtmap) << "a{x((iii)(iiii)i)}" << "[Argument: a{x((iii)(iiii)i)} {0 = [Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0], 1 = [Argument: ((iii)(iiii)i) [Argument: (iii) 1970, 1, 1], [Argument: (iiii) 0, 0, 1, 0], 1], 1150629776 = [Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 11, 22, 56, 0], 1]}]"; @@ -631,18 +631,18 @@ void tst_QDBusMarshall::sendComplex_data() svmap["c"] = "b"; svmap["b"] = QByteArray("c"); svmap["d"] = 42U; - svmap["e"] = qVariantFromValue(short(-47)); - svmap["f"] = qVariantFromValue(QDBusVariant(0)); + svmap["e"] = QVariant::fromValue(short(-47)); + svmap["f"] = QVariant::fromValue(QDBusVariant(0)); svmap["date"] = QDate(1977, 1, 1); svmap["time"] = QTime(8, 58, 0); svmap["datetime"] = QDateTime(QDate(13, 9, 2008), QTime(8, 59, 31)); svmap["pointf"] = QPointF(0.5, -0.5); - svmap["ismap"] = qVariantFromValue(ismap); - svmap["ssmap"] = qVariantFromValue(ssmap); - svmap["gsmap"] = qVariantFromValue(gsmap); - svmap["dtlist"] = qVariantFromValue(dtlist); - svmap["lldtmap"] = qVariantFromValue(lldtmap); - QTest::newRow("sv-map") << qVariantFromValue(svmap) << "a{sv}" + svmap["ismap"] = QVariant::fromValue(ismap); + svmap["ssmap"] = QVariant::fromValue(ssmap); + svmap["gsmap"] = QVariant::fromValue(gsmap); + svmap["dtlist"] = QVariant::fromValue(dtlist); + svmap["lldtmap"] = QVariant::fromValue(lldtmap); + QTest::newRow("sv-map") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {\"a\" = [Variant(int): 1], \"b\" = [Variant(QByteArray): {99}], \"c\" = [Variant(QString): \"b\"], \"d\" = [Variant(uint): 42], \"date\" = [Variant: [Argument: (iii) 1977, 1, 1]], \"datetime\" = [Variant: [Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) 8, 59, 31, 0], 0]], \"dtlist\" = [Variant: [Argument: a((iii)(iiii)i) {[Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0], [Argument: ((iii)(iiii)i) [Argument: (iii) 1977, 9, 13], [Argument: (iiii) 0, 0, 0, 0], 0], [Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 13, 14, 0, 0], 0]}]], \"e\" = [Variant(short): -47], \"f\" = [Variant: [Variant(int): 0]], \"gsmap\" = [Variant: [Argument: a{gs} {[Signature: a{gs}] = \"array of dict_entry of (signature, string)\", [Signature: i] = \"int32\", [Signature: s] = \"string\"}]], \"ismap\" = [Variant: [Argument: a{is} {-47 = \"c\", 1 = \"a\", 2000 = \"b\"}]], \"lldtmap\" = [Variant: [Argument: a{x((iii)(iiii)i)} {0 = [Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0], 1 = [Argument: ((iii)(iiii)i) [Argument: (iii) 1970, 1, 1], [Argument: (iiii) 0, 0, 1, 0], 1], 1150629776 = [Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 11, 22, 56, 0], 1]}]], \"pointf\" = [Variant: [Argument: (dd) 0.5, -0.5]], \"ssmap\" = [Variant: [Argument: a{ss} {\"a\" = \"a\", \"b\" = \"c\", \"c\" = \"b\"}]], \"time\" = [Variant: [Argument: (iiii) 8, 58, 0, 0]]}]"; } @@ -657,83 +657,83 @@ void tst_QDBusMarshall::sendArgument_data() arg = QDBusArgument(); arg << true; - QTest::newRow("bool") << qVariantFromValue(arg) << "b" << int(QDBusArgument::BasicType);; + QTest::newRow("bool") << QVariant::fromValue(arg) << "b" << int(QDBusArgument::BasicType);; arg = QDBusArgument(); arg << false; - QTest::newRow("bool2") << qVariantFromValue(arg) << "b" << int(QDBusArgument::BasicType); + QTest::newRow("bool2") << QVariant::fromValue(arg) << "b" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << uchar(1); - QTest::newRow("byte") << qVariantFromValue(arg) << "y" << int(QDBusArgument::BasicType); + QTest::newRow("byte") << QVariant::fromValue(arg) << "y" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << short(2); - QTest::newRow("int16") << qVariantFromValue(arg) << "n" << int(QDBusArgument::BasicType); + QTest::newRow("int16") << QVariant::fromValue(arg) << "n" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << ushort(3); - QTest::newRow("uint16") << qVariantFromValue(arg) << "q" << int(QDBusArgument::BasicType); + QTest::newRow("uint16") << QVariant::fromValue(arg) << "q" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << 1; - QTest::newRow("int32") << qVariantFromValue(arg) << "i" << int(QDBusArgument::BasicType); + QTest::newRow("int32") << QVariant::fromValue(arg) << "i" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << 2U; - QTest::newRow("uint32") << qVariantFromValue(arg) << "u" << int(QDBusArgument::BasicType); + QTest::newRow("uint32") << QVariant::fromValue(arg) << "u" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << Q_INT64_C(3); - QTest::newRow("int64") << qVariantFromValue(arg) << "x" << int(QDBusArgument::BasicType); + QTest::newRow("int64") << QVariant::fromValue(arg) << "x" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << Q_UINT64_C(4); - QTest::newRow("uint64") << qVariantFromValue(arg) << "t" << int(QDBusArgument::BasicType); + QTest::newRow("uint64") << QVariant::fromValue(arg) << "t" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << 42.5; - QTest::newRow("double") << qVariantFromValue(arg) << "d" << int(QDBusArgument::BasicType); + QTest::newRow("double") << QVariant::fromValue(arg) << "d" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QLatin1String("ping"); - QTest::newRow("string") << qVariantFromValue(arg) << "s" << int(QDBusArgument::BasicType); + QTest::newRow("string") << QVariant::fromValue(arg) << "s" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QDBusObjectPath("/org/kde"); - QTest::newRow("objectpath") << qVariantFromValue(arg) << "o" << int(QDBusArgument::BasicType); + QTest::newRow("objectpath") << QVariant::fromValue(arg) << "o" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QDBusSignature("g"); - QTest::newRow("signature") << qVariantFromValue(arg) << "g" << int(QDBusArgument::BasicType); + QTest::newRow("signature") << QVariant::fromValue(arg) << "g" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QLatin1String(""); - QTest::newRow("emptystring") << qVariantFromValue(arg) << "s" << int(QDBusArgument::BasicType); + QTest::newRow("emptystring") << QVariant::fromValue(arg) << "s" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QString(); - QTest::newRow("nullstring") << qVariantFromValue(arg) << "s" << int(QDBusArgument::BasicType); + QTest::newRow("nullstring") << QVariant::fromValue(arg) << "s" << int(QDBusArgument::BasicType); if (fileDescriptorPassing) { arg = QDBusArgument(); arg << QDBusUnixFileDescriptor(fileDescriptorForTest()); - QTest::newRow("filedescriptor") << qVariantFromValue(arg) << "h" << int(QDBusArgument::BasicType); + QTest::newRow("filedescriptor") << QVariant::fromValue(arg) << "h" << int(QDBusArgument::BasicType); } arg = QDBusArgument(); arg << QDBusVariant(1); - QTest::newRow("variant") << qVariantFromValue(arg) << "v" << int(QDBusArgument::VariantType); + QTest::newRow("variant") << QVariant::fromValue(arg) << "v" << int(QDBusArgument::VariantType); arg = QDBusArgument(); - arg << QDBusVariant(qVariantFromValue(QDBusVariant(1))); - QTest::newRow("variant-variant") << qVariantFromValue(arg) << "v" << int(QDBusArgument::VariantType); + arg << QDBusVariant(QVariant::fromValue(QDBusVariant(1))); + QTest::newRow("variant-variant") << QVariant::fromValue(arg) << "v" << int(QDBusArgument::VariantType); arg = QDBusArgument(); arg.beginArray(QVariant::Int); arg << 1 << 2 << 3 << -4; arg.endArray(); - QTest::newRow("array-of-int") << qVariantFromValue(arg) << "ai" << int(QDBusArgument::ArrayType); + QTest::newRow("array-of-int") << QVariant::fromValue(arg) << "ai" << int(QDBusArgument::ArrayType); arg = QDBusArgument(); arg.beginMap(QVariant::Int, QVariant::UInt); @@ -744,13 +744,13 @@ void tst_QDBusMarshall::sendArgument_data() arg << 3 << 4U; arg.endMapEntry(); arg.endMap(); - QTest::newRow("map") << qVariantFromValue(arg) << "a{iu}" << int(QDBusArgument::MapType); + QTest::newRow("map") << QVariant::fromValue(arg) << "a{iu}" << int(QDBusArgument::MapType); arg = QDBusArgument(); arg.beginStructure(); arg << 1 << 2U << short(-3) << ushort(4) << 5.0 << false; arg.endStructure(); - QTest::newRow("structure") << qVariantFromValue(arg) << "(iunqdb)" << int(QDBusArgument::StructureType); + QTest::newRow("structure") << QVariant::fromValue(arg) << "(iunqdb)" << int(QDBusArgument::StructureType); } void tst_QDBusMarshall::sendBasic() @@ -790,7 +790,7 @@ void tst_QDBusMarshall::sendVariant() QDBusMessage msg = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "ping"); - msg << qVariantFromValue(QDBusVariant(value)); + msg << QVariant::fromValue(QDBusVariant(value)); QDBusMessage reply = con.call(msg); // qDebug() << reply; @@ -851,7 +851,7 @@ void tst_QDBusMarshall::sendArgument() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); reply = con.call(msg); QCOMPARE(reply.signature(), QString("(%1)").arg(sig)); @@ -883,7 +883,7 @@ void tst_QDBusMarshall::sendSignalErrors() QVERIFY(con.isConnected()); QDBusMessage msg = QDBusMessage::createSignal("/foo", "local.interfaceName", "signalName"); - msg << qVariantFromValue(QDBusObjectPath()); + msg << QVariant::fromValue(QDBusObjectPath()); QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); QVERIFY(!con.send(msg)); @@ -893,20 +893,20 @@ void tst_QDBusMarshall::sendSignalErrors() QTest::ignoreMessage(QtWarningMsg, "QDBusObjectPath: invalid path \"abc\""); path.setPath("abc"); - msg << qVariantFromValue(path); + msg << QVariant::fromValue(path); QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); QVERIFY(!con.send(msg)); QDBusSignature sig; - msg.setArguments(QVariantList() << qVariantFromValue(sig)); + msg.setArguments(QVariantList() << QVariant::fromValue(sig)); QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); QVERIFY(!con.send(msg)); QTest::ignoreMessage(QtWarningMsg, "QDBusSignature: invalid signature \"a\""); sig.setSignature("a"); msg.setArguments(QVariantList()); - msg << qVariantFromValue(sig); + msg << QVariant::fromValue(sig); QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); QVERIFY(!con.send(msg)); } @@ -956,7 +956,7 @@ void tst_QDBusMarshall::sendCallErrors_data() << "Marshalling failed: Variant containing QVariant::Invalid passed in arguments" << "QDBusMarshaller: cannot add an invalid QVariant"; QTest::newRow("invalid-variant1") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(QDBusVariant())) + << (QVariantList() << QVariant::fromValue(QDBusVariant())) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Variant containing QVariant::Invalid passed in arguments" << "QDBusMarshaller: cannot add a null QDBusVariant"; @@ -970,20 +970,20 @@ void tst_QDBusMarshall::sendCallErrors_data() // this type is known to the meta type system, but not registered with D-Bus qRegisterMetaType(); QTest::newRow("extra-unregistered") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(UnregisteredType())) + << (QVariantList() << QVariant::fromValue(UnregisteredType())) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Unregistered type UnregisteredType passed in arguments" << QString("QDBusMarshaller: type `UnregisteredType' (%1) is not registered with D-BUS. Use qDBusRegisterMetaType to register it") .arg(qMetaTypeId()); QTest::newRow("invalid-object-path-arg") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(QDBusObjectPath())) + << (QVariantList() << QVariant::fromValue(QDBusObjectPath())) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Invalid object path passed in arguments" << ""; QTest::newRow("invalid-signature-arg") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(QDBusSignature())) + << (QVariantList() << QVariant::fromValue(QDBusSignature())) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Invalid signature passed in arguments" << ""; @@ -991,7 +991,7 @@ void tst_QDBusMarshall::sendCallErrors_data() // invalid file descriptor if (fileDescriptorPassing) { QTest::newRow("invalid-file-descriptor") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(QDBusUnixFileDescriptor(-1))) + << (QVariantList() << QVariant::fromValue(QDBusUnixFileDescriptor(-1))) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Invalid file descriptor passed in arguments" << ""; @@ -1200,7 +1200,7 @@ QVariant demarshallPrimitiveAs(const QDBusArgument& dbusArg) { T val; dbusArg >> val; - return qVariantFromValue(val); + return QVariant::fromValue(val); } QVariant demarshallPrimitiveAs(int typeIndex, const QDBusArgument& dbusArg) @@ -1247,7 +1247,7 @@ void tst_QDBusMarshall::demarshallPrimitives() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); QDBusMessage reply = con.call(msg); const QDBusArgument receiveArg = qvariant_cast(reply.arguments().at(0)); @@ -1279,15 +1279,15 @@ void tst_QDBusMarshall::demarshallStrings_data() typedef QPair ValSigPair; const QList nullStringTypes = QList() - << ValSigPair(qVariantFromValue(QString()), 's') - << ValSigPair(qVariantFromValue(QDBusObjectPath()), 'o') - << ValSigPair(qVariantFromValue(QDBusSignature()), 'g'); + << ValSigPair(QVariant::fromValue(QString()), 's') + << ValSigPair(QVariant::fromValue(QDBusObjectPath()), 'o') + << ValSigPair(QVariant::fromValue(QDBusSignature()), 'g'); foreach (ValSigPair valSigPair, nullStringTypes) { QTest::newRow("bool(false)") << QVariant(false) << valSigPair.second << valSigPair.first; QTest::newRow("bool(true)") << QVariant(true) << valSigPair.second << valSigPair.first; - QTest::newRow("byte") << qVariantFromValue(uchar(1)) << valSigPair.second << valSigPair.first; - QTest::newRow("int16") << qVariantFromValue(short(2)) << valSigPair.second << valSigPair.first; - QTest::newRow("uint16") << qVariantFromValue(ushort(3)) << valSigPair.second << valSigPair.first; + QTest::newRow("byte") << QVariant::fromValue(uchar(1)) << valSigPair.second << valSigPair.first; + QTest::newRow("int16") << QVariant::fromValue(short(2)) << valSigPair.second << valSigPair.first; + QTest::newRow("uint16") << QVariant::fromValue(ushort(3)) << valSigPair.second << valSigPair.first; QTest::newRow("int") << QVariant(1) << valSigPair.second << valSigPair.first; QTest::newRow("uint") << QVariant(2U) << valSigPair.second << valSigPair.first; QTest::newRow("int64") << QVariant(Q_INT64_C(3)) << valSigPair.second << valSigPair.first; @@ -1299,32 +1299,32 @@ void tst_QDBusMarshall::demarshallStrings_data() // to check released functionality is maintained even after checks have // been added to string demarshalling QTest::newRow("empty string->invalid objectpath") << QVariant("") - << 'o' << qVariantFromValue(QDBusObjectPath()); + << 'o' << QVariant::fromValue(QDBusObjectPath()); QTest::newRow("null string->invalid objectpath") << QVariant(QString()) - << 'o' << qVariantFromValue(QDBusObjectPath()); + << 'o' << QVariant::fromValue(QDBusObjectPath()); QTest::newRow("string->invalid objectpath") << QVariant("invalid objectpath") - << 'o' << qVariantFromValue(QDBusObjectPath()); + << 'o' << QVariant::fromValue(QDBusObjectPath()); QTest::newRow("string->valid objectpath") << QVariant("/org/kde") - << 'o' << qVariantFromValue(QDBusObjectPath("/org/kde")); + << 'o' << QVariant::fromValue(QDBusObjectPath("/org/kde")); QTest::newRow("empty string->invalid signature") << QVariant("") - << 'g' << qVariantFromValue(QDBusSignature()); + << 'g' << QVariant::fromValue(QDBusSignature()); QTest::newRow("null string->invalid signature") << QVariant(QString()) - << 'g' << qVariantFromValue(QDBusSignature()); + << 'g' << QVariant::fromValue(QDBusSignature()); QTest::newRow("string->invalid signature") << QVariant("_invalid signature") - << 'g' << qVariantFromValue(QDBusSignature()); + << 'g' << QVariant::fromValue(QDBusSignature()); QTest::newRow("string->valid signature") << QVariant("s") - << 'g' << qVariantFromValue(QDBusSignature("s")); + << 'g' << QVariant::fromValue(QDBusSignature("s")); - QTest::newRow("objectpath->string") << qVariantFromValue(QDBusObjectPath("/org/kde")) - << 's' << qVariantFromValue(QString("/org/kde")); - QTest::newRow("objectpath->invalid signature") << qVariantFromValue(QDBusObjectPath("/org/kde")) - << 'g' << qVariantFromValue(QDBusSignature()); + QTest::newRow("objectpath->string") << QVariant::fromValue(QDBusObjectPath("/org/kde")) + << 's' << QVariant::fromValue(QString("/org/kde")); + QTest::newRow("objectpath->invalid signature") << QVariant::fromValue(QDBusObjectPath("/org/kde")) + << 'g' << QVariant::fromValue(QDBusSignature()); - QTest::newRow("signature->string") << qVariantFromValue(QDBusSignature("s")) - << 's' << qVariantFromValue(QString("s")); - QTest::newRow("signature->invalid objectpath") << qVariantFromValue(QDBusSignature("s")) - << 'o' << qVariantFromValue(QDBusObjectPath()); + QTest::newRow("signature->string") << QVariant::fromValue(QDBusSignature("s")) + << 's' << QVariant::fromValue(QString("s")); + QTest::newRow("signature->invalid objectpath") << QVariant::fromValue(QDBusSignature("s")) + << 'o' << QVariant::fromValue(QDBusObjectPath()); } QVariant demarshallAsString(const QDBusArgument& dbusArg, char targetSig) @@ -1338,12 +1338,12 @@ QVariant demarshallAsString(const QDBusArgument& dbusArg, char targetSig) case 'o': { QDBusObjectPath op; dbusArg >> op; - return qVariantFromValue(op); + return QVariant::fromValue(op); } case 'g' : { QDBusSignature sig; dbusArg >> sig; - return qVariantFromValue(sig); + return QVariant::fromValue(sig); } default: { return QVariant(); @@ -1367,7 +1367,7 @@ void tst_QDBusMarshall::demarshallStrings() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); QDBusMessage reply = con.call(msg); const QDBusArgument receiveArg = qvariant_cast(reply.arguments().at(0)); @@ -1391,15 +1391,15 @@ void tst_QDBusMarshall::demarshallInvalidStringList_data() // Arrays of non-string type should not demarshall to a string list QList bools; - QTest::newRow("emptyboollist") << qVariantFromValue(bools); + QTest::newRow("emptyboollist") << QVariant::fromValue(bools); bools << false << true << false; - QTest::newRow("boollist") << qVariantFromValue(bools); + QTest::newRow("boollist") << QVariant::fromValue(bools); // Structures should not demarshall to a QByteArray QTest::newRow("struct of strings") - << qVariantFromValue(QVariantList() << QString("foo") << QString("bar")); + << QVariant::fromValue(QVariantList() << QString("foo") << QString("bar")); QTest::newRow("struct of mixed types") - << qVariantFromValue(QVariantList() << QString("foo") << int(42) << double(3.14)); + << QVariant::fromValue(QVariantList() << QString("foo") << int(42) << double(3.14)); } void tst_QDBusMarshall::demarshallInvalidStringList() @@ -1416,7 +1416,7 @@ void tst_QDBusMarshall::demarshallInvalidStringList() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); QDBusMessage reply = con.call(msg); const QDBusArgument receiveArg = qvariant_cast(reply.arguments().at(0)); @@ -1440,16 +1440,16 @@ void tst_QDBusMarshall::demarshallInvalidByteArray_data() // Arrays of other types than byte should not demarshall to a QByteArray QList bools; - QTest::newRow("empty array of bool") << qVariantFromValue(bools); + QTest::newRow("empty array of bool") << QVariant::fromValue(bools); bools << true << false << true; - QTest::newRow("non-empty array of bool") << qVariantFromValue(bools); + QTest::newRow("non-empty array of bool") << QVariant::fromValue(bools); // Structures should not demarshall to a QByteArray QTest::newRow("struct of bytes") - << qVariantFromValue(QVariantList() << uchar(1) << uchar(2)); + << QVariant::fromValue(QVariantList() << uchar(1) << uchar(2)); QTest::newRow("struct of mixed types") - << qVariantFromValue(QVariantList() << int(42) << QString("foo") << double(3.14)); + << QVariant::fromValue(QVariantList() << int(42) << QString("foo") << double(3.14)); } void tst_QDBusMarshall::demarshallInvalidByteArray() @@ -1466,7 +1466,7 @@ void tst_QDBusMarshall::demarshallInvalidByteArray() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); QDBusMessage reply = con.call(msg); const QDBusArgument receiveArg = qvariant_cast(reply.arguments().at(0)); diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 7f41f0651e..466764f81e 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -158,7 +158,7 @@ void tst_QClipboard::testSignals() QCOMPARE(selectionChangedSpy.count(), 0); QCOMPARE(changedSpy.count(), 1); QCOMPARE(changedSpy.at(0).count(), 1); - QCOMPARE(qVariantValue(changedSpy.at(0).at(0)), QClipboard::Clipboard); + QCOMPARE(qvariant_cast(changedSpy.at(0).at(0)), QClipboard::Clipboard); changedSpy.clear(); @@ -168,7 +168,7 @@ void tst_QClipboard::testSignals() QCOMPARE(selectionChangedSpy.count(), 1); QCOMPARE(changedSpy.count(), 1); QCOMPARE(changedSpy.at(0).count(), 1); - QCOMPARE(qVariantValue(changedSpy.at(0).at(0)), QClipboard::Selection); + QCOMPARE(qvariant_cast(changedSpy.at(0).at(0)), QClipboard::Selection); } else { QCOMPARE(selectionChangedSpy.count(), 0); } @@ -183,7 +183,7 @@ void tst_QClipboard::testSignals() QCOMPARE(searchChangedSpy.count(), 1); QCOMPARE(changedSpy.count(), 1); QCOMPARE(changedSpy.at(0).count(), 1); - QCOMPARE(qVariantValue(changedSpy.at(0).at(0)), QClipboard::FindBuffer); + QCOMPARE(qvariant_cast(changedSpy.at(0).at(0)), QClipboard::FindBuffer); } else { QCOMPARE(searchChangedSpy.count(), 0); } diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 698470ac60..c89d10a543 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -3358,13 +3358,13 @@ void tst_QMatrixNxN::properties() QMatrix4x4 m1(uniqueValues4); obj.setMatrix(m1); - QMatrix4x4 m2 = qVariantValue(obj.property("matrix")); + QMatrix4x4 m2 = qvariant_cast(obj.property("matrix")); QVERIFY(isSame(m2, uniqueValues4)); QMatrix4x4 m3(transposedValues4); - obj.setProperty("matrix", qVariantFromValue(m3)); + obj.setProperty("matrix", QVariant::fromValue(m3)); - m2 = qVariantValue(obj.property("matrix")); + m2 = qvariant_cast(obj.property("matrix")); QVERIFY(isSame(m2, transposedValues4)); } diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp index 1690afcac4..a4e1f940fc 100644 --- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp @@ -855,16 +855,16 @@ void tst_QQuaternion::properties() obj.setQuaternion(QQuaternion(6.0f, 7.0f, 8.0f, 9.0f)); - QQuaternion q = qVariantValue(obj.property("quaternion")); + QQuaternion q = qvariant_cast(obj.property("quaternion")); QCOMPARE(q.scalar(), (qreal)6.0f); QCOMPARE(q.x(), (qreal)7.0f); QCOMPARE(q.y(), (qreal)8.0f); QCOMPARE(q.z(), (qreal)9.0f); obj.setProperty("quaternion", - qVariantFromValue(QQuaternion(-6.0f, -7.0f, -8.0f, -9.0f))); + QVariant::fromValue(QQuaternion(-6.0f, -7.0f, -8.0f, -9.0f))); - q = qVariantValue(obj.property("quaternion")); + q = qvariant_cast(obj.property("quaternion")); QCOMPARE(q.scalar(), (qreal)-6.0f); QCOMPARE(q.x(), (qreal)-7.0f); QCOMPARE(q.y(), (qreal)-8.0f); diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp index 067773074e..72a4ecef97 100644 --- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp @@ -2077,38 +2077,38 @@ void tst_QVectorND::properties() obj.setVector3D(QVector3D(3.0f, 4.0f, 5.0f)); obj.setVector4D(QVector4D(6.0f, 7.0f, 8.0f, 9.0f)); - QVector2D v2 = qVariantValue(obj.property("vector2D")); + QVector2D v2 = qvariant_cast(obj.property("vector2D")); QCOMPARE(v2.x(), (qreal)1.0f); QCOMPARE(v2.y(), (qreal)2.0f); - QVector3D v3 = qVariantValue(obj.property("vector3D")); + QVector3D v3 = qvariant_cast(obj.property("vector3D")); QCOMPARE(v3.x(), (qreal)3.0f); QCOMPARE(v3.y(), (qreal)4.0f); QCOMPARE(v3.z(), (qreal)5.0f); - QVector4D v4 = qVariantValue(obj.property("vector4D")); + QVector4D v4 = qvariant_cast(obj.property("vector4D")); QCOMPARE(v4.x(), (qreal)6.0f); QCOMPARE(v4.y(), (qreal)7.0f); QCOMPARE(v4.z(), (qreal)8.0f); QCOMPARE(v4.w(), (qreal)9.0f); obj.setProperty("vector2D", - qVariantFromValue(QVector2D(-1.0f, -2.0f))); + QVariant::fromValue(QVector2D(-1.0f, -2.0f))); obj.setProperty("vector3D", - qVariantFromValue(QVector3D(-3.0f, -4.0f, -5.0f))); + QVariant::fromValue(QVector3D(-3.0f, -4.0f, -5.0f))); obj.setProperty("vector4D", - qVariantFromValue(QVector4D(-6.0f, -7.0f, -8.0f, -9.0f))); + QVariant::fromValue(QVector4D(-6.0f, -7.0f, -8.0f, -9.0f))); - v2 = qVariantValue(obj.property("vector2D")); + v2 = qvariant_cast(obj.property("vector2D")); QCOMPARE(v2.x(), (qreal)-1.0f); QCOMPARE(v2.y(), (qreal)-2.0f); - v3 = qVariantValue(obj.property("vector3D")); + v3 = qvariant_cast(obj.property("vector3D")); QCOMPARE(v3.x(), (qreal)-3.0f); QCOMPARE(v3.y(), (qreal)-4.0f); QCOMPARE(v3.z(), (qreal)-5.0f); - v4 = qVariantValue(obj.property("vector4D")); + v4 = qvariant_cast(obj.property("vector4D")); QCOMPARE(v4.x(), (qreal)-6.0f); QCOMPARE(v4.y(), (qreal)-7.0f); QCOMPARE(v4.z(), (qreal)-8.0f); diff --git a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp index 928dc48125..25764aacce 100644 --- a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp +++ b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp @@ -282,21 +282,21 @@ void tst_QNetworkRequest::setHeader_data() cookie.setName("a"); cookie.setValue("b"); QTest::newRow("Cookie-1") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList() << cookie) + << QVariant::fromValue(QList() << cookie) << true << "Cookie" << "a=b"; QTest::newRow("SetCookie-1") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList() << cookie) + << QVariant::fromValue(QList() << cookie) << true << "Set-Cookie" << "a=b"; cookie.setPath("/"); QTest::newRow("Cookie-2") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList() << cookie) + << QVariant::fromValue(QList() << cookie) << true << "Cookie" << "a=b"; QTest::newRow("SetCookie-2") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList() << cookie) + << QVariant::fromValue(QList() << cookie) << true << "Set-Cookie" << "a=b; path=/"; @@ -304,11 +304,11 @@ void tst_QNetworkRequest::setHeader_data() cookie2.setName("c"); cookie2.setValue("d"); QTest::newRow("Cookie-3") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList() << cookie << cookie2) + << QVariant::fromValue(QList() << cookie << cookie2) << true << "Cookie" << "a=b; c=d"; QTest::newRow("SetCookie-3") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList() << cookie << cookie2) + << QVariant::fromValue(QList() << cookie << cookie2) << true << "Set-Cookie" << "a=b; path=/, c=d"; } @@ -388,17 +388,17 @@ void tst_QNetworkRequest::rawHeaderParsing_data() cookie.setName("a"); cookie.setValue("b"); QTest::newRow("Cookie-1") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList() << cookie) + << QVariant::fromValue(QList() << cookie) << true << "Cookie" << "a=b"; QTest::newRow("SetCookie-1") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList() << cookie) + << QVariant::fromValue(QList() << cookie) << true << "Set-Cookie" << "a=b"; cookie.setPath("/"); QTest::newRow("SetCookie-2") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList() << cookie) + << QVariant::fromValue(QList() << cookie) << true << "Set-Cookie" << "a=b; path=/"; @@ -407,12 +407,12 @@ void tst_QNetworkRequest::rawHeaderParsing_data() cookie2.setName("c"); cookie2.setValue("d"); QTest::newRow("Cookie-3") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList() << cookie << cookie2) + << QVariant::fromValue(QList() << cookie << cookie2) << true << "Cookie" << "a=b; c=d"; cookie.setPath("/"); QTest::newRow("SetCookie-3") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList() << cookie << cookie2) + << QVariant::fromValue(QList() << cookie << cookie2) << true << "Set-Cookie" << "a=b; path=/, c=d"; } diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 1f531f387c..eeda46dfdc 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -383,7 +383,7 @@ void tst_QLocalSocket::listenAndConnect() QVERIFY(socket->error() != QLocalSocket::UnknownSocketError); QCOMPARE(socket->state(), QLocalSocket::UnconnectedState); //QVERIFY(socket->socketDescriptor() == -1); - QCOMPARE(qVariantValue(spyError.first()[0]), + QCOMPARE(qvariant_cast(spyError.first()[0]), QLocalSocket::ServerNotFoundError); } @@ -403,19 +403,19 @@ void tst_QLocalSocket::listenAndConnect() QVERIFY(spyError.count() >= 0); if (canListen) { if (spyError.count() > 0) - QCOMPARE(qVariantValue(spyError.first()[0]), + QCOMPARE(qvariant_cast(spyError.first()[0]), QLocalSocket::SocketTimeoutError); } else { - QCOMPARE(qVariantValue(spyError.first()[0]), + QCOMPARE(qvariant_cast(spyError.first()[0]), QLocalSocket::ServerNotFoundError); } // Check first and last state - QCOMPARE(qVariantValue(spyStateChanged.first()[0]), + QCOMPARE(qvariant_cast(spyStateChanged.first()[0]), QLocalSocket::ConnectingState); if (canListen) - QCOMPARE(qVariantValue(spyStateChanged.last()[0]), + QCOMPARE(qvariant_cast(spyStateChanged.last()[0]), QLocalSocket::ConnectedState); QCOMPARE(spyStateChanged.count(), 2); QCOMPARE(spyReadyRead.count(), 0); diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index a3e5366e41..3cc1f32622 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -130,7 +130,7 @@ private slots: { QTcpSocket *client = nextPendingConnection(); connect(client, SIGNAL(readyRead()), SLOT(handleClientCommand())); - client->setProperty("pendingResponses", qVariantFromValue(responses)); + client->setProperty("pendingResponses", QVariant::fromValue(responses)); } void handleClientCommand() @@ -145,7 +145,7 @@ private slots: client->disconnectFromHost(); else client->write(pendingResponses.dequeue()); - client->setProperty("pendingResponses", qVariantFromValue(pendingResponses)); + client->setProperty("pendingResponses", QVariant::fromValue(pendingResponses)); } }; diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 3c7c3a3da0..13c5d961d7 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -2212,9 +2212,9 @@ void tst_QTcpSocket::connectionRefused() QCOMPARE(socket->error(), QAbstractSocket::ConnectionRefusedError); QCOMPARE(stateSpy.count(), 3); - QCOMPARE(qVariantValue(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState); - QCOMPARE(qVariantValue(stateSpy.at(1).at(0)), QAbstractSocket::ConnectingState); - QCOMPARE(qVariantValue(stateSpy.at(2).at(0)), QAbstractSocket::UnconnectedState); + QCOMPARE(qvariant_cast(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState); + QCOMPARE(qvariant_cast(stateSpy.at(1).at(0)), QAbstractSocket::ConnectingState); + QCOMPARE(qvariant_cast(stateSpy.at(2).at(0)), QAbstractSocket::UnconnectedState); QCOMPARE(errorSpy.count(), 1); delete socket; diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 6f81829e25..34bc361e4b 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1793,8 +1793,8 @@ void tst_QSslSocket::peerVerifyError() QVERIFY(!socket->waitForEncrypted(10000)); QVERIFY(!peerVerifyErrorSpy.isEmpty()); QVERIFY(!sslErrorsSpy.isEmpty()); - QCOMPARE(qVariantValue(peerVerifyErrorSpy.last().at(0)).error(), QSslError::HostNameMismatch); - QCOMPARE(qVariantValue >(sslErrorsSpy.at(0).at(0)).size(), peerVerifyErrorSpy.size()); + QCOMPARE(qvariant_cast(peerVerifyErrorSpy.last().at(0)).error(), QSslError::HostNameMismatch); + QCOMPARE(qvariant_cast >(sslErrorsSpy.at(0).at(0)).size(), peerVerifyErrorSpy.size()); } void tst_QSslSocket::disconnectFromHostWhenConnecting() diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp index 876b6a1365..98f66000f6 100644 --- a/tests/auto/other/modeltest/modeltest.cpp +++ b/tests/auto/other/modeltest/modeltest.cpp @@ -414,27 +414,27 @@ void ModelTest::data() // General Purpose roles that should return a QString QVariant variant = model->data ( model->index ( 0, 0 ), Qt::ToolTipRole ); if ( variant.isValid() ) { - QVERIFY( qVariantCanConvert ( variant ) ); + QVERIFY( variant.canConvert() ); } variant = model->data ( model->index ( 0, 0 ), Qt::StatusTipRole ); if ( variant.isValid() ) { - QVERIFY( qVariantCanConvert ( variant ) ); + QVERIFY( variant.canConvert() ); } variant = model->data ( model->index ( 0, 0 ), Qt::WhatsThisRole ); if ( variant.isValid() ) { - QVERIFY( qVariantCanConvert ( variant ) ); + QVERIFY( variant.canConvert() ); } // General Purpose roles that should return a QSize variant = model->data ( model->index ( 0, 0 ), Qt::SizeHintRole ); if ( variant.isValid() ) { - QVERIFY( qVariantCanConvert ( variant ) ); + QVERIFY( variant.canConvert() ); } // General Purpose roles that should return a QFont QVariant fontVariant = model->data ( model->index ( 0, 0 ), Qt::FontRole ); if ( fontVariant.isValid() ) { - QVERIFY( qVariantCanConvert ( fontVariant ) ); + QVERIFY( fontVariant.canConvert() ); } // Check that the alignment is one we know about @@ -447,12 +447,12 @@ void ModelTest::data() // General Purpose roles that should return a QColor QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole ); if ( colorVariant.isValid() ) { - QVERIFY( qVariantCanConvert ( colorVariant ) ); + QVERIFY( colorVariant.canConvert() ); } colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole ); if ( colorVariant.isValid() ) { - QVERIFY( qVariantCanConvert ( colorVariant ) ); + QVERIFY( colorVariant.canConvert() ); } // Check that the "check state" is one we know about. diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 626c5049f0..fb2db21743 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -2078,7 +2078,7 @@ void tst_QSqlDatabase::eventNotificationPSQL() QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toString(), procedureName); - QCOMPARE(qVariantValue(arguments.at(1)), QSqlDriver::SelfSource); + QCOMPARE(qvariant_cast(arguments.at(1)), QSqlDriver::SelfSource); QCOMPARE(qvariant_cast(arguments.at(2)).toString(), payload); QVERIFY_SQL(driver, unsubscribeFromNotification(procedureName)); } diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 36ac9de02d..4a0eab0f83 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -3001,7 +3001,7 @@ void tst_QSqlQuery::QTBUG_551() q.bindValue(":outp", outLst, QSql::Out); QVERIFY_SQL(q, execBatch(QSqlQuery::ValuesAsColumns) ); - res_outLst = qVariantValue(q.boundValues()[":outp"]); + res_outLst = qvariant_cast(q.boundValues()[":outp"]); QCOMPARE(res_outLst[0].toString(), QLatin1String("1. Value is 0")); QCOMPARE(res_outLst[1].toString(), QLatin1String("2. Value is 1")); QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2")); diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index b354e0a82a..1bf016d6f5 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -860,13 +860,13 @@ void tst_Moc::namespaceTypeProperty() QByteArray ba = QByteArray("points"); QVariant v = tst.property(ba); QVERIFY(v.isValid()); - myNS::Points p = qVariantValue(v); + myNS::Points p = qvariant_cast(v); QCOMPARE(p.p1, 0xBEEF); QCOMPARE(p.p2, 0xBABE); p.p1 = 0xCAFE; p.p2 = 0x1EE7; - QVERIFY(tst.setProperty(ba, qVariantFromValue(p))); - myNS::Points pp = qVariantValue(tst.property(ba)); + QVERIFY(tst.setProperty(ba, QVariant::fromValue(p))); + myNS::Points pp = qvariant_cast(tst.property(ba)); QCOMPARE(p.p1, pp.p1); QCOMPARE(p.p2, pp.p2); } @@ -1181,16 +1181,16 @@ void tst_Moc::qprivateproperties() PrivatePropertyTest test; test.setProperty("foo", 1); - QCOMPARE(test.property("foo"), qVariantFromValue(1)); + QCOMPARE(test.property("foo"), QVariant::fromValue(1)); test.setProperty("bar", 2); - QCOMPARE(test.property("bar"), qVariantFromValue(2)); + QCOMPARE(test.property("bar"), QVariant::fromValue(2)); test.setProperty("plop", 3); - QCOMPARE(test.property("plop"), qVariantFromValue(3)); + QCOMPARE(test.property("plop"), QVariant::fromValue(3)); test.setProperty("baz", 4); - QCOMPARE(test.property("baz"), qVariantFromValue(4)); + QCOMPARE(test.property("baz"), QVariant::fromValue(4)); } diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 14c2be5bd8..e8fc5ad603 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -1061,11 +1061,11 @@ void tst_QFiledialog::historyBack() QCOMPARE(backButton->isEnabled(), true); QCOMPARE(forwardButton->isEnabled(), true); QCOMPARE(spy.count(), 3); - QString currentPath = qVariantValue(spy.last().first()); + QString currentPath = qvariant_cast(spy.last().first()); QCOMPARE(model->index(currentPath), model->index(temp)); backButton->click(); - currentPath = qVariantValue(spy.last().first()); + currentPath = qvariant_cast(spy.last().first()); QCOMPARE(currentPath, home); QCOMPARE(backButton->isEnabled(), false); QCOMPARE(forwardButton->isEnabled(), true); @@ -1101,39 +1101,39 @@ void tst_QFiledialog::historyForward() backButton->click(); QCOMPARE(forwardButton->isEnabled(), true); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(temp)); forwardButton->click(); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(desktop)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(desktop)); QCOMPARE(backButton->isEnabled(), true); QCOMPARE(forwardButton->isEnabled(), false); QCOMPARE(spy.count(), 4); backButton->click(); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(temp)); QCOMPARE(backButton->isEnabled(), true); backButton->click(); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(home)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(home)); QCOMPARE(backButton->isEnabled(), false); QCOMPARE(forwardButton->isEnabled(), true); QCOMPARE(spy.count(), 6); forwardButton->click(); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(temp)); backButton->click(); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(home)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(home)); QCOMPARE(spy.count(), 8); forwardButton->click(); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(temp)); forwardButton->click(); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(desktop)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(desktop)); backButton->click(); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(temp)); backButton->click(); - QCOMPARE(model->index(qVariantValue(spy.last().first())), model->index(home)); + QCOMPARE(model->index(qvariant_cast(spy.last().first())), model->index(home)); fd.setDirectory(desktop); QCOMPARE(forwardButton->isEnabled(), false); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 639a1f61a9..a6f846045f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -2219,7 +2219,7 @@ void tst_QGraphicsItem::setMatrix() QApplication::instance()->processEvents(); QCOMPARE(spy.count(), 3); - QList rlist = qVariantValue >(spy.last().at(0)); + QList rlist = qvariant_cast >(spy.last().at(0)); QCOMPARE(rlist.size(), 3); QCOMPARE(rlist.at(0), rotatedRect); // From item.setMatrix() (clearing rotated rect) @@ -4450,13 +4450,13 @@ protected: break; case QGraphicsItem::ItemMatrixChange: { QVariant variant; - qVariantSetValue(variant, matrix()); + variant.setValue(matrix()); oldValues << variant; } break; case QGraphicsItem::ItemTransformChange: { QVariant variant; - qVariantSetValue(variant, transform()); + variant.setValue(transform()); oldValues << variant; } break; @@ -4478,7 +4478,7 @@ protected: case QGraphicsItem::ItemSelectedHasChanged: break; case QGraphicsItem::ItemParentChange: - oldValues << qVariantFromValue(parentItem()); + oldValues << QVariant::fromValue(parentItem()); break; case QGraphicsItem::ItemParentHasChanged: break; @@ -4489,11 +4489,11 @@ protected: oldValues << children().size(); break; case QGraphicsItem::ItemSceneChange: - oldValues << qVariantFromValue(scene()); + oldValues << QVariant::fromValue(scene()); if (itemSceneChangeTargetScene - && qVariantValue(value) - && itemSceneChangeTargetScene != qVariantValue(value)) { - return qVariantFromValue(itemSceneChangeTargetScene); + && qvariant_cast(value) + && itemSceneChangeTargetScene != qvariant_cast(value)) { + return QVariant::fromValue(itemSceneChangeTargetScene); } return value; case QGraphicsItem::ItemSceneHasChanged: @@ -4573,17 +4573,17 @@ void tst_QGraphicsItem::itemChange() } { // ItemMatrixChange / ItemTransformHasChanged - qVariantSetValue(tester.itemChangeReturnValue, QMatrix().rotate(90)); + tester.itemChangeReturnValue.setValue(QMatrix().rotate(90)); tester.setMatrix(QMatrix().translate(50, 0), true); ++changeCount; // notification sent too QCOMPARE(tester.changes.size(), ++changeCount); QCOMPARE(int(tester.changes.at(tester.changes.size() - 2)), int(QGraphicsItem::ItemMatrixChange)); QCOMPARE(int(tester.changes.last()), int(QGraphicsItem::ItemTransformHasChanged)); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 2)), + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 2)), QMatrix().translate(50, 0)); QCOMPARE(tester.values.last(), QVariant(QTransform(QMatrix().rotate(90)))); QVariant variant; - qVariantSetValue(variant, QMatrix()); + variant.setValue(QMatrix()); QCOMPARE(tester.oldValues.last(), variant); QCOMPARE(tester.matrix(), QMatrix().rotate(90)); } @@ -4593,19 +4593,19 @@ void tst_QGraphicsItem::itemChange() ++changeCount; // notification sent too // ItemTransformChange / ItemTransformHasChanged - qVariantSetValue(tester.itemChangeReturnValue, QTransform().rotate(90)); + tester.itemChangeReturnValue.setValue(QTransform().rotate(90)); tester.translate(50, 0); ++changeCount; // notification sent too ++changeCount; QCOMPARE(tester.changes.size(), changeCount); QCOMPARE(tester.changes.at(tester.changes.size() - 2), QGraphicsItem::ItemTransformChange); QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemTransformHasChanged); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 2)), + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 2)), QTransform().translate(50, 0)); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 1)), + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 1)), QTransform().rotate(90)); QVariant variant; - qVariantSetValue(variant, QTransform()); + variant.setValue(QTransform()); QCOMPARE(tester.oldValues.last(), variant); QCOMPARE(tester.transform(), QTransform().rotate(90)); } @@ -4690,9 +4690,9 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.changes.size(), changeCount); QCOMPARE(tester.changes.at(tester.changes.size() - 2), QGraphicsItem::ItemFlagsChange); QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemFlagsHaveChanged); - QVariant expectedFlags = qVariantFromValue(QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges)); + QVariant expectedFlags = QVariant::fromValue(QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges)); QCOMPARE(tester.values.at(tester.values.size() - 2), expectedFlags); - QCOMPARE(tester.values.at(tester.values.size() - 1), qVariantFromValue((quint32)QGraphicsItem::ItemIsSelectable)); + QCOMPARE(tester.values.at(tester.values.size() - 1), QVariant::fromValue((quint32)QGraphicsItem::ItemIsSelectable)); } { // ItemSelectedChange @@ -4739,12 +4739,12 @@ void tst_QGraphicsItem::itemChange() } { // ItemParentChange - qVariantSetValue(tester.itemChangeReturnValue, 0); + tester.itemChangeReturnValue.setValue(0); tester.setParentItem(&testerHelper); QCOMPARE(tester.changes.size(), ++changeCount); QCOMPARE(tester.changes.last(), QGraphicsItem::ItemParentChange); - QCOMPARE(qVariantValue(tester.values.last()), (QGraphicsItem *)&testerHelper); - QCOMPARE(qVariantValue(tester.oldValues.last()), (QGraphicsItem *)0); + QCOMPARE(qvariant_cast(tester.values.last()), (QGraphicsItem *)&testerHelper); + QCOMPARE(qvariant_cast(tester.oldValues.last()), (QGraphicsItem *)0); QCOMPARE(tester.parentItem(), (QGraphicsItem *)0); } { @@ -4771,14 +4771,14 @@ void tst_QGraphicsItem::itemChange() testerHelper.setParentItem(&tester); QCOMPARE(tester.changes.size(), ++changeCount); QCOMPARE(tester.changes.last(), QGraphicsItem::ItemChildAddedChange); - QCOMPARE(qVariantValue(tester.values.last()), (QGraphicsItem *)&testerHelper); + QCOMPARE(qvariant_cast(tester.values.last()), (QGraphicsItem *)&testerHelper); } { // ItemChildRemovedChange 1 testerHelper.setParentItem(0); QCOMPARE(tester.changes.size(), ++changeCount); QCOMPARE(tester.changes.last(), QGraphicsItem::ItemChildRemovedChange); - QCOMPARE(qVariantValue(tester.values.last()), (QGraphicsItem *)&testerHelper); + QCOMPARE(qvariant_cast(tester.values.last()), (QGraphicsItem *)&testerHelper); // ItemChildRemovedChange 1 ItemChangeTester *test = new ItemChangeTester; @@ -4819,10 +4819,10 @@ void tst_QGraphicsItem::itemChange() ItemChangeTester *child = new ItemChangeTester; child->setParentItem(&parent); QCOMPARE(parent.changes.last(), QGraphicsItem::ItemChildAddedChange); - QCOMPARE(qVariantValue(parent.values.last()), (QGraphicsItem *)child); + QCOMPARE(qvariant_cast(parent.values.last()), (QGraphicsItem *)child); delete child; QCOMPARE(parent.changes.last(), QGraphicsItem::ItemChildRemovedChange); - QCOMPARE(qVariantValue(parent.values.last()), (QGraphicsItem *)child); + QCOMPARE(qvariant_cast(parent.values.last()), (QGraphicsItem *)child); } { // !!! Note: If this test crashes because of double-deletion, there's @@ -4841,8 +4841,8 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemSceneHasChanged); // Item's old value was 0 // Item's current value is scene - QCOMPARE(qVariantValue(tester.oldValues.last()), (QGraphicsScene *)0); - QCOMPARE(qVariantValue(tester.values.last()), (QGraphicsScene *)&scene); + QCOMPARE(qvariant_cast(tester.oldValues.last()), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast(tester.values.last()), (QGraphicsScene *)&scene); scene2.addItem(&tester); ++changeCount; // ItemSceneChange (0) was: (scene) ++changeCount; // ItemSceneHasChanged (0) @@ -4858,16 +4858,16 @@ void tst_QGraphicsItem::itemChange() // Item's last old value was scene // Item's last current value is 0 - QCOMPARE(qVariantValue(tester.oldValues.at(tester.oldValues.size() - 2)), (QGraphicsScene *)&scene); - QCOMPARE(qVariantValue(tester.oldValues.at(tester.oldValues.size() - 1)), (QGraphicsScene *)0); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 4)), (QGraphicsScene *)0); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 3)), (QGraphicsScene *)0); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)&scene2); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast(tester.oldValues.at(tester.oldValues.size() - 2)), (QGraphicsScene *)&scene); + QCOMPARE(qvariant_cast(tester.oldValues.at(tester.oldValues.size() - 1)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 4)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 3)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)&scene2); // Item's last old value was 0 // Item's last current value is scene2 - QCOMPARE(qVariantValue(tester.oldValues.last()), (QGraphicsScene *)0); - QCOMPARE(qVariantValue(tester.values.last()), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast(tester.oldValues.last()), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast(tester.values.last()), (QGraphicsScene *)&scene2); scene2.removeItem(&tester); ++changeCount; // ItemSceneChange (0) was: (scene2) @@ -4879,9 +4879,9 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemSceneHasChanged); // Item's last old value was scene2 // Item's last current value is 0 - QCOMPARE(qVariantValue(tester.oldValues.last()), (QGraphicsScene *)&scene2); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)0); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast(tester.oldValues.last()), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)0); tester.itemSceneChangeTargetScene = &scene; scene2.addItem(&tester); @@ -4890,9 +4890,9 @@ void tst_QGraphicsItem::itemChange() ++changeCount; // ItemSceneHasChanged (scene) QCOMPARE(tester.values.size(), changeCount); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 3)), (QGraphicsScene *)&scene2); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)&scene); - QCOMPARE(qVariantValue(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)&scene); + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 3)), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)&scene); + QCOMPARE(qvariant_cast(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)&scene); QCOMPARE(tester.scene(), &scene); tester.itemSceneChangeTargetScene = 0; diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index df529c6095..3686619fea 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -2830,7 +2830,7 @@ void tst_QGraphicsScene::update() // Check that the update region is correct QCOMPARE(spy.count(), 1); QRectF region; - foreach (QRectF rectF, qVariantValue >(spy.at(0).at(0))) + foreach (QRectF rectF, qvariant_cast >(spy.at(0).at(0))) region |= rectF; QCOMPARE(region, QRectF(-100, -100, 200, 200)); } diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 99353c6edf..4015cd7b6d 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -3211,11 +3211,11 @@ void tst_QGraphicsWidget::itemChangeEvents() break; } case QEvent::ParentAboutToChange: { - valueDuringEvents.insert(QEvent::ParentAboutToChange, qVariantFromValue(parentItem())); + valueDuringEvents.insert(QEvent::ParentAboutToChange, QVariant::fromValue(parentItem())); break; } case QEvent::ParentChange: { - valueDuringEvents.insert(QEvent::ParentChange, qVariantFromValue(parentItem())); + valueDuringEvents.insert(QEvent::ParentChange, QVariant::fromValue(parentItem())); break; } case QEvent::CursorChange: { @@ -3252,10 +3252,10 @@ void tst_QGraphicsWidget::itemChangeEvents() TestGraphicsWidget *item = new TestGraphicsWidget; item->setParentItem(parent); // ParentAboutToChange should be triggered before the parent has changed - QTRY_COMPARE(qVariantValue(item->valueDuringEvents.value(QEvent::ParentAboutToChange)), + QTRY_COMPARE(qvariant_cast(item->valueDuringEvents.value(QEvent::ParentAboutToChange)), static_cast(0)); // ParentChange should be triggered after the parent has changed - QTRY_COMPARE(qVariantValue(item->valueDuringEvents.value(QEvent::ParentChange)), + QTRY_COMPARE(qvariant_cast(item->valueDuringEvents.value(QEvent::ParentChange)), static_cast(parent)); // ShowEvent should be triggered before the item is shown diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 90fa2ad716..288e41c6ef 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1466,8 +1466,8 @@ void tst_QApplication::focusChanged() QApplication::setActiveWindow(&parent1); // needs this on twm (focus follows mouse) QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).count(), 2); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == &le1); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == 0); @@ -1476,8 +1476,8 @@ void tst_QApplication::focusChanged() pb1.setFocus(); QCOMPARE(spy.count(), 1); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == &pb1); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le1); @@ -1485,8 +1485,8 @@ void tst_QApplication::focusChanged() lb1.setFocus(); QCOMPARE(spy.count(), 1); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == &lb1); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &pb1); @@ -1494,8 +1494,8 @@ void tst_QApplication::focusChanged() lb1.clearFocus(); QCOMPARE(spy.count(), 1); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == 0); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &lb1); @@ -1513,8 +1513,8 @@ void tst_QApplication::focusChanged() parent2.show(); QApplication::setActiveWindow(&parent2); // needs this on twm (focus follows mouse) QVERIFY(spy.count() > 0); // one for deactivation, one for activation on Windows - old = qVariantValue(spy.at(spy.count()-1).at(0)); - now = qVariantValue(spy.at(spy.count()-1).at(1)); + old = qvariant_cast(spy.at(spy.count()-1).at(0)); + now = qvariant_cast(spy.at(spy.count()-1).at(1)); QVERIFY(now == &le2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == 0); @@ -1547,8 +1547,8 @@ void tst_QApplication::focusChanged() QVERIFY(now == QApplication::focusWidget()); } else { QVERIFY(spy.count() > 0); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == &pb2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le2); @@ -1561,8 +1561,8 @@ void tst_QApplication::focusChanged() } else { tab.simulate(now); QVERIFY(spy.count() > 0); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == &le2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &pb2); @@ -1575,8 +1575,8 @@ void tst_QApplication::focusChanged() } else { backtab.simulate(now); QVERIFY(spy.count() > 0); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == &pb2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le2); @@ -1591,8 +1591,8 @@ void tst_QApplication::focusChanged() } else { backtab.simulate(now); QVERIFY(spy.count() > 0); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == &le2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &pb2); @@ -1605,8 +1605,8 @@ void tst_QApplication::focusChanged() QVERIFY(now == QApplication::focusWidget()); } else { QVERIFY(spy.count() > 0); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == &pb2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le2); @@ -1614,8 +1614,8 @@ void tst_QApplication::focusChanged() click.simulate(old); QVERIFY(spy.count() > 0); - old = qVariantValue(spy.at(0).at(0)); - now = qVariantValue(spy.at(0).at(1)); + old = qvariant_cast(spy.at(0).at(0)); + now = qvariant_cast(spy.at(0).at(1)); QVERIFY(now == &le2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &pb2); @@ -1629,10 +1629,10 @@ void tst_QApplication::focusChanged() //on windows, the change of focus is made in 2 steps //(the focusChanged SIGNAL is emitted twice) if (spy.count()==1) - old = qVariantValue(spy.at(spy.count()-1).at(0)); + old = qvariant_cast(spy.at(spy.count()-1).at(0)); else - old = qVariantValue(spy.at(spy.count()-2).at(0)); - now = qVariantValue(spy.at(spy.count()-1).at(1)); + old = qvariant_cast(spy.at(spy.count()-2).at(0)); + now = qvariant_cast(spy.at(spy.count()-1).at(1)); QVERIFY(now == &le1); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le2); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 5c6ea19c50..a6f344c4bc 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -2049,7 +2049,7 @@ void tst_QDateTimeEdit::dateSignalChecking() if (timesEmitted > 0) { QList list = dateSpy.takeFirst(); QDate d; - d = qVariantValue(list.at(0)); + d = qvariant_cast(list.at(0)); QCOMPARE(d, newDate); } QCOMPARE(dateTimeSpy.count(), timesEmitted); @@ -2085,7 +2085,7 @@ void tst_QDateTimeEdit::timeSignalChecking() if (timesEmitted > 0) { QList list = timeSpy.takeFirst(); QTime t; - t = qVariantValue(list.at(0)); + t = qvariant_cast(list.at(0)); QCOMPARE(t, newTime); } QCOMPARE(dateTimeSpy.count(), timesEmitted); @@ -2135,21 +2135,21 @@ void tst_QDateTimeEdit::dateTimeSignalChecking() QCOMPARE(timesDateEmitted, 1); QList list = dateSpy.takeFirst(); QDate d; - d = qVariantValue(list.at(0)); + d = qvariant_cast(list.at(0)); QCOMPARE(d, newDateTime.date()); } QCOMPARE(timeSpy.count(), timesTimeEmitted); if (timesTimeEmitted > 0) { QList list = timeSpy.takeFirst(); QTime t; - t = qVariantValue(list.at(0)); + t = qvariant_cast(list.at(0)); QCOMPARE(t, newDateTime.time()); } QCOMPARE(dateTimeSpy.count(), timesDateTimeEmitted); if (timesDateTimeEmitted > 0) { QList list = dateTimeSpy.takeFirst(); QDateTime dt; - dt = qVariantValue(list.at(0)); + dt = qvariant_cast(list.at(0)); QCOMPARE(dt, newDateTime); } } diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp index f6b4d88311..ca8dba4b88 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp @@ -188,7 +188,7 @@ static void variantSetValue(T d) QVariant v; QBENCHMARK { for(int i = 0; i < ITERATION_COUNT; ++i) { - qVariantSetValue(v, d); + v.setValue(d); } } } diff --git a/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp b/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp index e93a1013e7..fe9e37c5d5 100644 --- a/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp +++ b/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp @@ -168,13 +168,13 @@ void tst_QDBusPerformance::oneWay_data() QByteArray ba(256, 'a'); while (ba.size() < 8193) { - QTest::newRow(QString("%1-byteArray").arg(ba.size()).toAscii()) << qVariantFromValue(ba) << ba.size(); + QTest::newRow(QString("%1-byteArray").arg(ba.size()).toAscii()) << QVariant::fromValue(ba) << ba.size(); ba += ba; } QString s(256, QLatin1Char('a')); while (s.size() < 8193) { - QTest::newRow(QString("%1-string").arg(s.size()).toAscii()) << qVariantFromValue(s) << s.size(); + QTest::newRow(QString("%1-string").arg(s.size()).toAscii()) << QVariant::fromValue(s) << s.size(); s += s; } } @@ -197,7 +197,7 @@ void tst_QDBusPerformance::oneWayVariant() QFETCH(QVariant, data); QFETCH(int, size); - QVERIFY(executeTest("size", size, qVariantFromValue(QDBusVariant(data)))); + QVERIFY(executeTest("size", size, QVariant::fromValue(QDBusVariant(data)))); } void tst_QDBusPerformance::roundTrip_data() @@ -223,7 +223,7 @@ void tst_QDBusPerformance::roundTripVariant() QFETCH(QVariant, data); QFETCH(int, size); - QVERIFY(executeTest("echo", size, qVariantFromValue(QDBusVariant(data)))); + QVERIFY(executeTest("echo", size, QVariant::fromValue(QDBusVariant(data)))); } QTEST_MAIN(tst_QDBusPerformance) diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index 6826312880..c85fc439e9 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -90,7 +90,7 @@ void BearerEx::showConfigurations() font.setUnderline(true); listItem->setFont(font); listItem->setText(" UserChoice"); - listItem->setData(Qt::UserRole, qVariantFromValue(defaultConfig)); + listItem->setData(Qt::UserRole, QVariant::fromValue(defaultConfig)); listWidget->addItem(listItem); } @@ -121,7 +121,7 @@ void BearerEx::showConfigurations() listItem->setFont(font); } listItem->setText(text); - listItem->setData(Qt::UserRole, qVariantFromValue(configurations[i])); + listItem->setData(Qt::UserRole, QVariant::fromValue(configurations[i])); listWidget->addItem(listItem); } } @@ -143,7 +143,7 @@ void BearerEx::on_showDetailsButton_clicked() return; } - QNetworkConfiguration networkConfiguration = qVariantValue(item->data(Qt::UserRole)); + QNetworkConfiguration networkConfiguration = qvariant_cast(item->data(Qt::UserRole)); DetailedInfoDialog infoDialog(&networkConfiguration,this); infoDialog.exec(); } @@ -154,7 +154,7 @@ void BearerEx::on_createSessionButton_clicked() if (!item) { return; } - QNetworkConfiguration networkConfiguration = qVariantValue(item->data(Qt::UserRole)); + QNetworkConfiguration networkConfiguration = qvariant_cast(item->data(Qt::UserRole)); int newTabIndex = mainTabWidget->count(); SessionTab* newTab = new SessionTab(&networkConfiguration,&m_NetworkConfigurationManager,eventListWidget,newTabIndex-1); QString label = QString("S")+QString::number(newTabIndex-1);