diff --git a/python/core/qgstaskmanager.sip b/python/core/qgstaskmanager.sip index 3a3c6167d18..d5cfa46e332 100644 --- a/python/core/qgstaskmanager.sip +++ b/python/core/qgstaskmanager.sip @@ -49,7 +49,7 @@ class QgsTask : QObject }; typedef QFlags Flags; - /** + /** * Constructor for QgsTask. * @param description text description of task * @param flags task flags @@ -135,7 +135,7 @@ class QgsTask : QObject * Will be emitted by task when its status changes. * @param status new task status * @note derived classes should not emit this signal directly, instead they should call - * completed() or stopped() + * completed() or terminated() */ void statusChanged( int status ); @@ -158,9 +158,9 @@ class QgsTask : QObject * other then completion (eg when a task has been cancelled or encountered * an internal error). * @note derived classes should not emit this signal directly, instead they should call - * stopped() + * terminated() */ - void taskStopped(); + void taskTerminated(); protected: @@ -175,13 +175,13 @@ class QgsTask : QObject * * Alternatively, tasks can also return the ResultPending value * to indicate that the task is still operating and will manually report its - * completion by calling completed() or stopped(). This may be useful for + * completion by calling completed() or terminated(). This may be useful for * tasks which rely on external events for completion, eg downloading a * file. In this case Qt slots could be created which are connected to the - * download completion or termination and which call completed() or stopped() + * download completion or termination and which call completed() or terminated() * to indicate the task has finished operations. * @see completed() - * @see stopped() + * @see terminated() */ virtual TaskResult run() = 0; @@ -201,13 +201,13 @@ class QgsTask : QObject void completed(); /** - * Sets the task as stopped. Calling this is only required for tasks which + * Sets the task as terminated. Calling this is only required for tasks which * returned the ResultPending value as a result of run(). * Should be called whenever the task ends for any reason other than successful - * completion. Calling will automatically emit the statusChanged and taskStopped + * completion. Calling will automatically emit the statusChanged and taskTerminated * signals. */ - void stopped(); + void terminated(); protected slots: diff --git a/src/core/qgstaskmanager.cpp b/src/core/qgstaskmanager.cpp index a3b87c38f2c..b9fe34f275f 100644 --- a/src/core/qgstaskmanager.cpp +++ b/src/core/qgstaskmanager.cpp @@ -46,7 +46,7 @@ void QgsTask::start() break; case ResultFail: - stopped(); + terminated(); break; case ResultPending: @@ -63,7 +63,7 @@ void QgsTask::cancel() if ( mStatus == Queued || mStatus == OnHold ) { // immediately terminate unstarted jobs - stopped(); + terminated(); } } @@ -98,11 +98,11 @@ void QgsTask::completed() emit taskCompleted(); } -void QgsTask::stopped() +void QgsTask::terminated() { mStatus = Terminated; emit statusChanged( Terminated ); - emit taskStopped(); + emit taskTerminated(); } @@ -413,7 +413,7 @@ bool QgsTaskManager::cleanupAndDeleteTask( QgsTask *task ) task->cancel(); // delete task when it's terminated connect( task, &QgsTask::taskCompleted, task, &QgsTask::deleteLater ); - connect( task, &QgsTask::taskStopped, task, &QgsTask::deleteLater ); + connect( task, &QgsTask::taskTerminated, task, &QgsTask::deleteLater ); } else { diff --git a/src/core/qgstaskmanager.h b/src/core/qgstaskmanager.h index 2a6e744abac..f53a4a848ae 100644 --- a/src/core/qgstaskmanager.h +++ b/src/core/qgstaskmanager.h @@ -157,7 +157,7 @@ class CORE_EXPORT QgsTask : public QObject * Will be emitted by task when its status changes. * @param status new task status * @note derived classes should not emit this signal directly, instead they should call - * completed() or stopped() + * completed() or terminated() */ void statusChanged( int status ); @@ -180,9 +180,9 @@ class CORE_EXPORT QgsTask : public QObject * other then completion (eg when a task has been cancelled or encountered * an internal error). * @note derived classes should not emit this signal directly, instead they should call - * stopped() + * terminated() */ - void taskStopped(); + void taskTerminated(); protected: @@ -197,13 +197,13 @@ class CORE_EXPORT QgsTask : public QObject * * Alternatively, tasks can also return the ResultPending value * to indicate that the task is still operating and will manually report its - * completion by calling completed() or stopped(). This may be useful for + * completion by calling completed() or terminated(). This may be useful for * tasks which rely on external events for completion, eg downloading a * file. In this case Qt slots could be created which are connected to the - * download completion or termination and which call completed() or stopped() + * download completion or termination and which call completed() or terminated() * to indicate the task has finished operations. * @see completed() - * @see stopped() + * @see terminated() */ virtual TaskResult run() = 0; @@ -223,13 +223,13 @@ class CORE_EXPORT QgsTask : public QObject void completed(); /** - * Sets the task as stopped. Calling this is only required for tasks which + * Sets the task as terminated. Calling this is only required for tasks which * returned the ResultPending value as a result of run(). * Should be called whenever the task ends for any reason other than successful - * completion. Calling will automatically emit the statusChanged and taskStopped + * completion. Calling will automatically emit the statusChanged and taskTerminated * signals. */ - void stopped(); + void terminated(); protected slots: diff --git a/tests/src/core/testqgstaskmanager.cpp b/tests/src/core/testqgstaskmanager.cpp index 29bf8159129..583769a6384 100644 --- a/tests/src/core/testqgstaskmanager.cpp +++ b/tests/src/core/testqgstaskmanager.cpp @@ -33,7 +33,7 @@ class TestTask : public QgsTask TestTask( const QString& desc, const QgsTask::Flags& flags ) : QgsTask( desc, flags ), runCalled( false ) {} void emitProgressChanged( double progress ) { setProgress( progress ); } - void emitTaskStopped() { stopped(); } + void emitTaskStopped() { terminated(); } void emitTaskCompleted() { completed(); } bool runCalled; @@ -153,8 +153,8 @@ void TestQgsTaskManager::task() QVERIFY( task->canCancel() ); QVERIFY( task->flags() & QgsTask::CanReportProgress ); - QSignalSpy startedSpy( task.data(), SIGNAL( begun() ) ); - QSignalSpy statusSpy( task.data(), SIGNAL( statusChanged( int ) ) ); + QSignalSpy startedSpy( task.data(), &QgsTask::begun ); + QSignalSpy statusSpy( task.data(), &QgsTask::statusChanged ); task->start(); QCOMPARE( task->status(), QgsTask::Running ); @@ -165,7 +165,7 @@ void TestQgsTaskManager::task() QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy.last().at( 0 ).toInt() ), QgsTask::Running ); //test that calling stopped sets correct state - QSignalSpy stoppedSpy( task.data(), SIGNAL( taskStopped() ) ); + QSignalSpy stoppedSpy( task.data(), &QgsTask::taskTerminated ); task->emitTaskStopped(); QCOMPARE( task->status(), QgsTask::Terminated ); QVERIFY( !task->isActive() ); @@ -175,8 +175,8 @@ void TestQgsTaskManager::task() //test that calling completed sets correct state task.reset( new TestTask() ); - QSignalSpy completeSpy( task.data(), SIGNAL( taskCompleted() ) ); - QSignalSpy statusSpy2( task.data(), SIGNAL( statusChanged( int ) ) ); + QSignalSpy completeSpy( task.data(), &QgsTask::taskCompleted ); + QSignalSpy statusSpy2( task.data(), &QgsTask::statusChanged ); task->emitTaskCompleted(); QCOMPARE( task->status(), QgsTask::Complete ); QVERIFY( !task->isActive() ); @@ -208,7 +208,7 @@ void TestQgsTaskManager::taskResult() { QScopedPointer< TestTask > task( new SuccessTask() ); QCOMPARE( task->status(), QgsTask::Queued ); - QSignalSpy statusSpy( task.data(), SIGNAL( statusChanged( int ) ) ); + QSignalSpy statusSpy( task.data(), &QgsTask::statusChanged ); task->start(); QCOMPARE( statusSpy.count(), 2 ); @@ -218,7 +218,7 @@ void TestQgsTaskManager::taskResult() task.reset( new FailTask() ); QCOMPARE( task->status(), QgsTask::Queued ); - QSignalSpy statusSpy2( task.data(), SIGNAL( statusChanged( int ) ) ); + QSignalSpy statusSpy2( task.data(), &QgsTask::statusChanged ); task->start(); QCOMPARE( statusSpy2.count(), 2 ); @@ -243,7 +243,7 @@ void TestQgsTaskManager::addTask() QCOMPARE( manager.count(), 0 ); QVERIFY( !manager.task( 0L ) ); - QSignalSpy spy( &manager, SIGNAL( taskAdded( long ) ) ); + QSignalSpy spy( &manager, &QgsTaskManager::taskAdded ); //add a task TestTask* task = new TestTask(); @@ -284,7 +284,7 @@ void TestQgsTaskManager::deleteTask() manager.addTask( task2 ); manager.addTask( task3 ); - QSignalSpy spy( &manager, SIGNAL( taskAboutToBeDeleted( long ) ) ); + QSignalSpy spy( &manager, &QgsTaskManager::taskAboutToBeDeleted ); //try deleting a non-existant task QVERIFY( !manager.deleteTask( 56 ) ); @@ -407,7 +407,7 @@ void TestQgsTaskManager::statusChanged() manager.addTask( task ); manager.addTask( task2 ); - QSignalSpy spy( &manager, SIGNAL( statusChanged( long, int ) ) ); + QSignalSpy spy( &manager, &QgsTaskManager::statusChanged ); task->start(); QCOMPARE( spy.count(), 1 ); @@ -435,7 +435,7 @@ void TestQgsTaskManager::allTasksFinished() manager.addTask( task2 ); while ( task2->status() != QgsTask::Running ) { } - QSignalSpy spy( &manager, SIGNAL( allTasksFinished() ) ); + QSignalSpy spy( &manager, &QgsTaskManager::allTasksFinished ); task->emitTaskStopped(); while ( task->status() == QgsTask::Running ) { } @@ -470,7 +470,7 @@ void TestQgsTaskManager::activeTasks() QgsTaskManager manager; TestTask* task = new TestTask(); TestTask* task2 = new TestTask(); - QSignalSpy spy( &manager, SIGNAL( countActiveTasksChanged( int ) ) ); + QSignalSpy spy( &manager, &QgsTaskManager::countActiveTasksChanged ); manager.addTask( task ); QCOMPARE( manager.activeTasks().toSet(), ( QList< QgsTask* >() << task ).toSet() ); QCOMPARE( manager.countActiveTasks(), 1 );