diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-02-25 14:40:51 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-03-03 12:53:04 +0100 |
commit | 42ef6bf079bc5247e72f88dd61d24d9e11c9940e (patch) | |
tree | 0d1b886997eb7327a1852abac12793a99d75bdfb | |
parent | 35cb65b657890717e33430cb3c12c6138c669fb2 (diff) |
Migrate from old signal/slot connection syntax (part 2)
Change the syntax also for the connections that involve types that
are defined in the repc-generated files.
Change-Id: I222a59c8fae438c5f0026e66a75d0fa905e49ccf
Reviewed-by: Michael Brasser <michael.brasser@live.com>
(cherry picked from commit 32b60c566f74c86ac51cd96ede41d85a0c95a298)
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | examples/remoteobjects/plugins/plugin.cpp | 10 | ||||
-rw-r--r-- | examples/remoteobjects/simpleswitch/directconnectclient/client.cpp | 10 | ||||
-rw-r--r-- | src/remoteobjects/doc/snippets/doc_src_simpleswitch.cpp | 10 | ||||
-rw-r--r-- | tests/auto/integration/tst_integration.cpp | 18 | ||||
-rw-r--r-- | tests/auto/integration_external/client/main.cpp | 4 | ||||
-rw-r--r-- | tests/auto/integration_external/server/main.cpp | 2 | ||||
-rw-r--r-- | tests/auto/integration_multiprocess/client/main.cpp | 4 | ||||
-rw-r--r-- | tests/auto/integration_multiprocess/server/main.cpp | 2 | ||||
-rw-r--r-- | tests/auto/proxy/tst_proxy.cpp | 8 | ||||
-rw-r--r-- | tests/auto/proxy_multiprocess/client/main.cpp | 2 | ||||
-rw-r--r-- | tests/auto/proxy_multiprocess/server/main.cpp | 2 | ||||
-rw-r--r-- | tests/auto/restart/server/main.cpp | 2 |
12 files changed, 37 insertions, 37 deletions
diff --git a/examples/remoteobjects/plugins/plugin.cpp b/examples/remoteobjects/plugins/plugin.cpp index 9590d26..bf84e7d 100644 --- a/examples/remoteobjects/plugins/plugin.cpp +++ b/examples/remoteobjects/plugins/plugin.cpp @@ -76,11 +76,11 @@ public: TimeModel(QObject *parent = nullptr) : QObject(parent), d_ptr(nullptr) { d_ptr.reset(m_client.acquire< MinuteTimerReplica >()); - connect(d_ptr.data(), SIGNAL(hourChanged()), this, SIGNAL(timeChanged())); - connect(d_ptr.data(), SIGNAL(minuteChanged()), this, SIGNAL(timeChanged())); - connect(d_ptr.data(), SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); - connect(d_ptr.data(), SIGNAL(timeChanged2(QTime)), this, SLOT(test(QTime))); - connect(d_ptr.data(), SIGNAL(sendCustom(PresetInfo)), this, SLOT(testCustom(PresetInfo))); + connect(d_ptr.data(), &MinuteTimerReplica::hourChanged, this, &TimeModel::timeChanged); + connect(d_ptr.data(), &MinuteTimerReplica::minuteChanged, this, &TimeModel::timeChanged); + connect(d_ptr.data(), &MinuteTimerReplica::timeChanged, this, &TimeModel::timeChanged); + connect(d_ptr.data(), &MinuteTimerReplica::timeChanged2, this, &TimeModel::test); + connect(d_ptr.data(), &MinuteTimerReplica::sendCustom, this, &TimeModel::testCustom); } ~TimeModel() override diff --git a/examples/remoteobjects/simpleswitch/directconnectclient/client.cpp b/examples/remoteobjects/simpleswitch/directconnectclient/client.cpp index 81cbf0e..a8e3133 100644 --- a/examples/remoteobjects/simpleswitch/directconnectclient/client.cpp +++ b/examples/remoteobjects/simpleswitch/directconnectclient/client.cpp @@ -69,12 +69,12 @@ Client::~Client() void Client::initConnections(void) { - // initialize connections between signals and slots + // initialize connections between signals and slots - // connect source replica signal currStateChanged() with client's recSwitchState() slot to receive source's current state - QObject::connect(reptr.data(), SIGNAL(currStateChanged(bool)), this, SLOT(recSwitchState_slot(bool))); - // connect client's echoSwitchState(..) signal with replica's server_slot(..) to echo back received state - QObject::connect(this, SIGNAL(echoSwitchState(bool)),reptr.data(), SLOT(server_slot(bool))); + // connect source replica signal currStateChanged() with client's recSwitchState() slot to receive source's current state + QObject::connect(reptr.data(), &SimpleSwitchReplica::currStateChanged, this, &Client::recSwitchState_slot); + // connect client's echoSwitchState(..) signal with replica's server_slot(..) to echo back received state + QObject::connect(this, &Client::echoSwitchState, reptr.data(), &SimpleSwitchReplica::server_slot); } void Client::recSwitchState_slot(bool value) diff --git a/src/remoteobjects/doc/snippets/doc_src_simpleswitch.cpp b/src/remoteobjects/doc/snippets/doc_src_simpleswitch.cpp index 5578511..ec97fdb 100644 --- a/src/remoteobjects/doc/snippets/doc_src_simpleswitch.cpp +++ b/src/remoteobjects/doc/snippets/doc_src_simpleswitch.cpp @@ -200,12 +200,12 @@ Client::~Client() void Client::initConnections() { - // initialize connections between signals and slots + // initialize connections between signals and slots - // connect source replica signal currStateChanged() with client's recSwitchState() slot to receive source's current state - QObject::connect(reptr.data(), SIGNAL(currStateChanged()), this, SLOT(recSwitchState_slot())); - // connect client's echoSwitchState(..) signal with replica's server_slot(..) to echo back received state - QObject::connect(this, SIGNAL(echoSwitchState(bool)),reptr.data(), SLOT(server_slot(bool))); + // connect source replica signal currStateChanged() with client's recSwitchState() slot to receive source's current state + QObject::connect(reptr.data(), &SimpleSwitchReplica::currStateChanged, this, &Client::recSwitchState_slot); + // connect client's echoSwitchState(..) signal with replica's server_slot(..) to echo back received state + QObject::connect(this, &Client::echoSwitchState, reptr.data(), &SimpleSwitchReplica::server_slot); } void Client::recSwitchState_slot() diff --git a/tests/auto/integration/tst_integration.cpp b/tests/auto/integration/tst_integration.cpp index 0718219..ba52bbd 100644 --- a/tests/auto/integration/tst_integration.cpp +++ b/tests/auto/integration/tst_integration.cpp @@ -342,7 +342,7 @@ private slots: // set property on the replica (test property change packet) { - QSignalSpy spy(tc_rep.data(), SIGNAL(classEnumChanged(TestClassReplica::ClassEnum))); + QSignalSpy spy(tc_rep.data(), &TestClassReplica::classEnumChanged); QVERIFY(spy.isValid()); tc_rep->pushClassEnum(TestClassReplica::Two); QVERIFY(spy.count() || spy.wait()); @@ -352,7 +352,7 @@ private slots: // set property on the source (test property change packet) { - QSignalSpy spy(tc_rep.data(), SIGNAL(classEnumChanged(TestClassReplica::ClassEnum))); + QSignalSpy spy(tc_rep.data(), &TestClassReplica::classEnumChanged); tc.setClassEnum(TestClassSimpleSource::One); QVERIFY(spy.wait()); @@ -380,7 +380,7 @@ private slots: // write enum on the dynamic replica { - QSignalSpy spy(tc_rep.data(), SIGNAL(classEnumRWChanged(TestClassReplica::ClassEnum))); + QSignalSpy spy(tc_rep.data(), &TestClassReplica::classEnumRWChanged); property.write(tc_repDynamic.data(), TestClassReplica::Two); QVERIFY(spy.wait()); @@ -401,7 +401,7 @@ private slots: // ensure write enum fails on ReadPush { - QSignalSpy spy(tc_rep.data(), SIGNAL(classEnumChanged(TestClassReplica::ClassEnum))); + QSignalSpy spy(tc_rep.data(), &TestClassReplica::classEnumChanged); bool res = property.write(tc_repDynamic.data(), TestClassReplica::Two); QVERIFY(!res); int methodIndex = metaObject->indexOfMethod("pushClassEnum(TestClassReplica::ClassEnum)"); @@ -696,7 +696,7 @@ private slots: setupClient(); const QScopedPointer<EngineReplica> engine_r(client->acquire<EngineReplica>()); - QSignalSpy spy(engine_r.data(), SIGNAL(rpmChanged(int))); + QSignalSpy spy(engine_r.data(), &EngineReplica::rpmChanged); e.setRpm(2345); spy.wait(); @@ -939,7 +939,7 @@ private slots: QCOMPARE(engine_r->cylinders(), 4); // Default value engine_r->waitForSource(); QCOMPARE(engine_r->cylinders(), 6); - QSignalSpy spy(engine_r.data(), SIGNAL(rpmChanged(int))); + QSignalSpy spy(engine_r.data(), &EngineReplica::rpmChanged); engine_r->setRpm(42); spy.wait(); QCOMPARE(spy.count(), 1); @@ -957,7 +957,7 @@ private slots: const QScopedPointer<EngineReplica> engine_r(client->acquire<EngineReplica>()); engine_r->waitForSource(); QCOMPARE(engine_r->started(), false); - QSignalSpy spy(engine_r.data(), SIGNAL(startedChanged(bool))); + QSignalSpy spy(engine_r.data(), &EngineReplica::startedChanged); engine_r->pushStarted(true); spy.wait(); QCOMPARE(spy.count(), 1); @@ -1000,7 +1000,7 @@ private slots: engine_r->waitForSource(); QCOMPARE(engine_r->rpm(), 0); - QSignalSpy spy(engine_r.data(), SIGNAL(rpmChanged(int))); + QSignalSpy spy(engine_r.data(), &EngineReplica::rpmChanged); engine_r->increaseRpm(1000); spy.wait(); QCOMPARE(spy.count(), 1); @@ -1232,7 +1232,7 @@ private slots: setupHost(); Engine e; host->enableRemoting<EngineSourceAPI>(&e); - QSignalSpy spy(engine_d.data(), SIGNAL(rpmChanged(int))); + QSignalSpy spy(engine_d.data(), &EngineReplica::rpmChanged); e.setRpm(50); spy.wait(); diff --git a/tests/auto/integration_external/client/main.cpp b/tests/auto/integration_external/client/main.cpp index bc53333..1b09481 100644 --- a/tests/auto/integration_external/client/main.cpp +++ b/tests/auto/integration_external/client/main.cpp @@ -68,9 +68,9 @@ private Q_SLOTS: QVERIFY(reply.waitForFinished()); // BEGIN: Testing - QSignalSpy advanceSpy(m_rep.data(), SIGNAL(advance())); + QSignalSpy advanceSpy(m_rep.data(), &MyInterfaceReplica::advance); - QSignalSpy spy(m_rep.data(), SIGNAL(enum1Changed(MyInterfaceReplica::Enum1))); + QSignalSpy spy(m_rep.data(), &MyInterfaceReplica::enum1Changed); QVERIFY(advanceSpy.wait()); QCOMPARE(spy.count(), 2); diff --git a/tests/auto/integration_external/server/main.cpp b/tests/auto/integration_external/server/main.cpp index e97408b..6c41031 100644 --- a/tests/auto/integration_external/server/main.cpp +++ b/tests/auto/integration_external/server/main.cpp @@ -70,7 +70,7 @@ private Q_SLOTS: qDebug() << "Waiting for incoming connections"; - QSignalSpy waitForStartedSpy(&myTestServer, SIGNAL(startedChanged(bool))); + QSignalSpy waitForStartedSpy(&myTestServer, &MyTestServer::startedChanged); QVERIFY(waitForStartedSpy.isValid()); QVERIFY(waitForStartedSpy.wait()); QCOMPARE(waitForStartedSpy.value(0).value(0).toBool(), true); diff --git a/tests/auto/integration_multiprocess/client/main.cpp b/tests/auto/integration_multiprocess/client/main.cpp index 87f2ad8..cfb0ff3 100644 --- a/tests/auto/integration_multiprocess/client/main.cpp +++ b/tests/auto/integration_multiprocess/client/main.cpp @@ -51,9 +51,9 @@ private Q_SLOTS: QVERIFY(reply.waitForFinished()); // BEGIN: Testing - QSignalSpy advanceSpy(m_rep.data(), SIGNAL(advance())); + QSignalSpy advanceSpy(m_rep.data(), &MyInterfaceReplica::advance); - QSignalSpy spy(m_rep.data(), SIGNAL(enum1Changed(MyInterfaceReplica::Enum1))); + QSignalSpy spy(m_rep.data(), &MyInterfaceReplica::enum1Changed); QVERIFY(advanceSpy.wait()); QCOMPARE(spy.count(), 2); diff --git a/tests/auto/integration_multiprocess/server/main.cpp b/tests/auto/integration_multiprocess/server/main.cpp index 3dfd0bd..c4e40e8 100644 --- a/tests/auto/integration_multiprocess/server/main.cpp +++ b/tests/auto/integration_multiprocess/server/main.cpp @@ -56,7 +56,7 @@ private Q_SLOTS: qDebug() << "Waiting for incoming connections"; - QSignalSpy waitForStartedSpy(&myTestServer, SIGNAL(startedChanged(bool))); + QSignalSpy waitForStartedSpy(&myTestServer, &MyTestServer::startedChanged); QVERIFY(waitForStartedSpy.isValid()); QVERIFY(waitForStartedSpy.wait()); QCOMPARE(waitForStartedSpy.value(0).value(0).toBool(), true); diff --git a/tests/auto/proxy/tst_proxy.cpp b/tests/auto/proxy/tst_proxy.cpp index 3fc49d9..d1601ce 100644 --- a/tests/auto/proxy/tst_proxy.cpp +++ b/tests/auto/proxy/tst_proxy.cpp @@ -137,8 +137,8 @@ void ProxyTest::testProxy() QCOMPARE((EngineReplica::EngineType)rep->type(), EngineReplica::Gas); //Change Replica and make sure change propagates to source - QSignalSpy sourceSpy(&engine, SIGNAL(rpmChanged(int))); - QSignalSpy replicaSpy(rep, SIGNAL(rpmChanged(int))); + QSignalSpy sourceSpy(&engine, &EngineSimpleSource::rpmChanged); + QSignalSpy replicaSpy(rep, &EngineReplica::rpmChanged); rep->pushRpm(42); sourceSpy.wait(); QCOMPARE(sourceSpy.count(), 1); @@ -164,7 +164,7 @@ void ProxyTest::testProxy() QCOMPARE(typeMeta.read(replica.data()).value<EngineReplica::EngineType>(), EngineReplica::Gas); //Change Replica and make sure change propagates to source - QSignalSpy sourceSpy(&engine, SIGNAL(rpmChanged(int))); + QSignalSpy sourceSpy(&engine, &EngineSimpleSource::rpmChanged); QSignalSpy replicaSpy(replica.data(), QByteArray(QByteArrayLiteral("2")+rpmMeta.notifySignal().methodSignature().constData())); const int rpmPushIndex = metaObject->indexOfMethod("pushRpm(int)"); @@ -249,7 +249,7 @@ void ProxyTest::testProxy() SubClassSimpleSource updatedSubclass; const MyPOD updatedValue(-1, 123.456, QStringLiteral("Updated")); updatedSubclass.setMyPOD(updatedValue); - QSignalSpy replicaSpy(rep, SIGNAL(subClassChanged(SubClassReplica*))); + QSignalSpy replicaSpy(rep, &ParentClassReplica::subClassChanged); parent.setSubClass(&updatedSubclass); replicaSpy.wait(); QCOMPARE(replicaSpy.count(), 1); diff --git a/tests/auto/proxy_multiprocess/client/main.cpp b/tests/auto/proxy_multiprocess/client/main.cpp index 19ba46f..c90754a 100644 --- a/tests/auto/proxy_multiprocess/client/main.cpp +++ b/tests/auto/proxy_multiprocess/client/main.cpp @@ -83,7 +83,7 @@ private Q_SLOTS: qDebug() << "Verified expected initial states, sending start."; QSignalSpy enumSpy(m_rep.data(), &ParentClassReplica::enum2); - QSignalSpy advanceSpy(m_rep.data(), SIGNAL(advance())); + QSignalSpy advanceSpy(m_rep.data(), &ParentClassReplica::advance); auto reply = m_rep->start(); QVERIFY(reply.waitForFinished()); QVERIFY(reply.error() == QRemoteObjectPendingCall::NoError); diff --git a/tests/auto/proxy_multiprocess/server/main.cpp b/tests/auto/proxy_multiprocess/server/main.cpp index 1cd005d..17ded5d 100644 --- a/tests/auto/proxy_multiprocess/server/main.cpp +++ b/tests/auto/proxy_multiprocess/server/main.cpp @@ -69,7 +69,7 @@ private Q_SLOTS: qDebug() << "Waiting for incoming connections"; - QSignalSpy waitForStartedSpy(&parent, SIGNAL(startedChanged(bool))); + QSignalSpy waitForStartedSpy(&parent, &MyTestServer::startedChanged); QVERIFY(waitForStartedSpy.isValid()); QVERIFY(waitForStartedSpy.wait()); QCOMPARE(waitForStartedSpy.value(0).value(0).toBool(), true); diff --git a/tests/auto/restart/server/main.cpp b/tests/auto/restart/server/main.cpp index b65dc17..7ef2cca 100644 --- a/tests/auto/restart/server/main.cpp +++ b/tests/auto/restart/server/main.cpp @@ -57,7 +57,7 @@ private Q_SLOTS: qDebug() << "Waiting for incoming connections"; - QSignalSpy waitForStartedSpy(&myTestServer, SIGNAL(startedChanged(bool))); + QSignalSpy waitForStartedSpy(&myTestServer, &MyTestServer::startedChanged); QVERIFY(waitForStartedSpy.isValid()); QVERIFY(waitForStartedSpy.wait()); QCOMPARE(waitForStartedSpy.value(0).value(0).toBool(), true); |