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 %Docstring
Sets the processing ``registry`` associated with the view. 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. level group containing recently used algorithms.
%End %End

View File

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

View File

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

View File

@ -56,7 +56,7 @@ class GUI_EXPORT QgsProcessingToolboxTreeView : public QTreeView
/** /**
* Sets the processing \a registry associated with the view. * 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. * level group containing recently used algorithms.
*/ */
void setRegistry( void setRegistry(