This commit is contained in:
Nyall Dawson 2018-07-08 17:27:53 +10:00
parent 8caecbb85c
commit 45d856e903
4 changed files with 20 additions and 7 deletions

View File

@ -47,7 +47,7 @@ level group containing recently used algorithms.
%Docstring
Sets the processing ``registry`` associated with the view.
If \recentLog is specified then it will be used to create a "Recently used" top
If ``recentLog`` is specified then it will be used to create a "Recently used" top
level group containing recently used algorithms.
%End

View File

@ -138,10 +138,13 @@ void QgsProcessingToolboxModel::rebuild()
repopulateRecentAlgorithms( true );
}
const QList< QgsProcessingProvider * > providers = mRegistry->providers();
for ( QgsProcessingProvider *provider : providers )
if ( mRegistry )
{
addProvider( provider );
const QList< QgsProcessingProvider * > providers = mRegistry->providers();
for ( QgsProcessingProvider *provider : providers )
{
addProvider( provider );
}
}
endResetModel();
}
@ -160,6 +163,12 @@ void QgsProcessingToolboxModel::repopulateRecentAlgorithms( bool resetting )
endRemoveRows();
}
if ( !mRegistry )
{
emit recentAlgorithmAdded();
return;
}
const QStringList recentAlgIds = mRecentLog->recentAlgorithmIds();
QList< const QgsProcessingAlgorithm * > recentAlgorithms;
recentAlgorithms.reserve( recentAlgIds.count() );
@ -196,6 +205,9 @@ void QgsProcessingToolboxModel::repopulateRecentAlgorithms( bool resetting )
void QgsProcessingToolboxModel::providerAdded( const QString &id )
{
if ( !mRegistry )
return;
QgsProcessingProvider *provider = mRegistry->providerById( id );
if ( !provider )
return;

View File

@ -20,6 +20,7 @@
#include "qgis_gui.h"
#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include <QPointer>
class QgsProcessingRegistry;
class QgsProcessingProvider;
@ -375,8 +376,8 @@ class GUI_EXPORT QgsProcessingToolboxModel : public QAbstractItemModel
private:
QgsProcessingRegistry *mRegistry = nullptr;
QgsProcessingRecentAlgorithmLog *mRecentLog = nullptr;
QPointer< QgsProcessingRegistry > mRegistry;
QPointer< QgsProcessingRecentAlgorithmLog > mRecentLog;
std::unique_ptr< QgsProcessingToolboxModelGroupNode > mRootNode;
QgsProcessingToolboxModelRecentNode *mRecentNode = nullptr;

View File

@ -56,7 +56,7 @@ class GUI_EXPORT QgsProcessingToolboxTreeView : public QTreeView
/**
* Sets the processing \a registry associated with the view.
*
* If \recentLog is specified then it will be used to create a "Recently used" top
* If \a recentLog is specified then it will be used to create a "Recently used" top
* level group containing recently used algorithms.
*/
void setRegistry(