Skip to content

Commit

Permalink
Rename overloaded signal, flip remaining connects to new style
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 5, 2016
1 parent f71c78e commit 252f2e1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions python/core/qgstaskmanager.sip
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ class QgsTaskManager : QObject
//! @param progress percent of progress, from 0.0 - 100.0
void progressChanged( long taskId, double progress );

//! Will be emitted when only a single task remains to complete
//! and that task has reported a progress change
//! @param progress percent of progress, from 0.0 - 100.0
void finalTaskProgressChanged( double progress );

//! Will be emitted when a task reports a status change
//! @param taskId ID of task
//! @param status new task status
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgstaskmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void QgsTaskManager::taskProgressChanged( double progress )
emit progressChanged( id, progress );
if ( mActiveTasks.count() == 1 )
{
emit progressChanged( progress );
emit finalTaskProgressChanged( progress );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgstaskmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class CORE_EXPORT QgsTaskManager : public QObject
//! Will be emitted when only a single task remains to complete
//! and that task has reported a progress change
//! @param progress percent of progress, from 0.0 - 100.0
void progressChanged( double progress );
void finalTaskProgressChanged( double progress );

//! Will be emitted when a task reports a status change
//! @param taskId ID of task
Expand Down
18 changes: 9 additions & 9 deletions src/gui/qgstaskmanagerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ QgsTaskManagerModel::QgsTaskManagerModel( QgsTaskManager *manager, QObject *pare
mRowToTaskIdMap.insert( i, mManager->taskId( task ) );
}

connect( mManager, SIGNAL( taskAdded( long ) ), this, SLOT( taskAdded( long ) ) );
connect( mManager, SIGNAL( taskAboutToBeDeleted( long ) ), this, SLOT( taskDeleted( long ) ) );
connect( mManager, SIGNAL( progressChanged( long, double ) ), this, SLOT( progressChanged( long, double ) ) );
connect( mManager, SIGNAL( statusChanged( long, int ) ), this, SLOT( statusChanged( long, int ) ) );
connect( mManager, &QgsTaskManager::taskAdded, this, &QgsTaskManagerModel::taskAdded );
connect( mManager, &QgsTaskManager::taskAboutToBeDeleted, this, &QgsTaskManagerModel::taskDeleted );
connect( mManager, &QgsTaskManager::progressChanged, this, &QgsTaskManagerModel::progressChanged );
connect( mManager, &QgsTaskManager::statusChanged, this, &QgsTaskManagerModel::statusChanged );
}

QModelIndex QgsTaskManagerModel::index( int row, int column, const QModelIndex &parent ) const
Expand Down Expand Up @@ -412,13 +412,13 @@ QgsTaskManagerStatusBarWidget::QgsTaskManagerStatusBarWidget( QgsTaskManager *ma
mFloatingWidget->setAnchorPoint( QgsFloatingWidget::BottomMiddle );
mFloatingWidget->setAnchorWidgetPoint( QgsFloatingWidget::TopMiddle );
mFloatingWidget->hide();
connect( this, SIGNAL( clicked( bool ) ), this, SLOT( toggleDisplay() ) );
connect( this, &QgsTaskManagerStatusBarWidget::clicked, this, &QgsTaskManagerStatusBarWidget::toggleDisplay );
hide();

connect( manager, SIGNAL( taskAdded( long ) ), this, SLOT( showButton() ) );
connect( manager, SIGNAL( allTasksFinished() ), this, SLOT( allFinished() ) );
connect( manager, SIGNAL( progressChanged( double ) ), this, SLOT( overallProgressChanged( double ) ) );
connect( manager, SIGNAL( countActiveTasksChanged( int ) ), this, SLOT( countActiveTasksChanged( int ) ) );
connect( manager, &QgsTaskManager::taskAdded, this, &QgsTaskManagerStatusBarWidget::showButton );
connect( manager, &QgsTaskManager::allTasksFinished, this, &QgsTaskManagerStatusBarWidget::allFinished );
connect( manager, &QgsTaskManager::finalTaskProgressChanged, this, &QgsTaskManagerStatusBarWidget::overallProgressChanged );
connect( manager, &QgsTaskManager::countActiveTasksChanged, this, &QgsTaskManagerStatusBarWidget::countActiveTasksChanged );
}

QSize QgsTaskManagerStatusBarWidget::sizeHint() const
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgstaskmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ void TestQgsTaskManager::progressChanged()
manager.addTask( task );
manager.addTask( task2 );

QSignalSpy spy( &manager, SIGNAL( progressChanged( long, double ) ) );
QSignalSpy spy2( &manager, SIGNAL( progressChanged( double ) ) );
QSignalSpy spy( &manager, &QgsTaskManager::progressChanged );
QSignalSpy spy2( &manager, &QgsTaskManager::finalTaskProgressChanged );

task->emitProgressChanged( 50.0 );
QCOMPARE( task->progress(), 50.0 );
Expand Down

0 comments on commit 252f2e1

Please sign in to comment.