Skip to content
Permalink
Browse files

Work on recent item - todo sort by use, test filter, update on change

  • Loading branch information
nyalldawson committed Jul 7, 2018
1 parent 3e9648f commit 670f408807fa8a153a5777c626edc30f48759889
@@ -358,6 +358,9 @@ A sort/filter proxy model for providers and algorithms shown within the Processi
which automatically sorts the toolbox in a logical fashion and supports filtering
the results.

If \recentLog is specified then it will be used to create a "Recently used" top
level group containing recently used algorithms.

.. versionadded:: 3.2
%End

@@ -374,7 +377,9 @@ the results.
typedef QFlags<QgsProcessingToolboxProxyModel::Filter> Filters;


explicit QgsProcessingToolboxProxyModel( QObject *parent /TransferThis/ = 0, QgsProcessingRegistry *registry = 0 );
explicit QgsProcessingToolboxProxyModel( QObject *parent /TransferThis/ = 0,
QgsProcessingRegistry *registry = 0,
QgsProcessingRecentAlgorithmLog *recentLog = 0 );
%Docstring
Constructor for QgsProcessingToolboxProxyModel, with the given ``parent`` object.

@@ -16,6 +16,7 @@
#include "qgsprocessingtoolboxmodel.h"
#include "qgsapplication.h"
#include "qgsprocessingregistry.h"
#include "qgsprocessingrecentalgorithmlog.h"
#include <functional>

#ifdef ENABLE_MODELTEST
@@ -128,7 +129,19 @@ void QgsProcessingToolboxModel::rebuild()

if ( mRecentLog )
{
mRootNode->addChildNode( new QgsProcessingToolboxModelRecentNode() );
std::unique_ptr< QgsProcessingToolboxModelRecentNode > recentNode = qgis::make_unique< QgsProcessingToolboxModelRecentNode >();
QgsProcessingToolboxModelRecentNode *parentNode = recentNode.get();
mRootNode->addChildNode( recentNode.release() );
const QStringList recentAlgIds = mRecentLog->recentAlgorithmIds();
for ( const QString &id : recentAlgIds )
{
const QgsProcessingAlgorithm *algorithm = mRegistry->algorithmById( id );
if ( algorithm )
{
std::unique_ptr< QgsProcessingToolboxModelAlgorithmNode > algorithmNode = qgis::make_unique< QgsProcessingToolboxModelAlgorithmNode >( algorithm, mRegistry );
parentNode->addChildNode( algorithmNode.release() );
}
}
}

const QList< QgsProcessingProvider * > providers = mRegistry->providers();
@@ -551,9 +564,10 @@ QModelIndex QgsProcessingToolboxModel::indexOfParentTreeNode( QgsProcessingToolb
// QgsProcessingToolboxProxyModel
//

QgsProcessingToolboxProxyModel::QgsProcessingToolboxProxyModel( QObject *parent, QgsProcessingRegistry *registry )
QgsProcessingToolboxProxyModel::QgsProcessingToolboxProxyModel( QObject *parent, QgsProcessingRegistry *registry,
QgsProcessingRecentAlgorithmLog *recentLog )
: QSortFilterProxyModel( parent )
, mModel( new QgsProcessingToolboxModel( parent, registry ) )
, mModel( new QgsProcessingToolboxModel( parent, registry, recentLog ) )
{
setSourceModel( mModel );
setDynamicSortFilter( true );
@@ -393,6 +393,9 @@ class GUI_EXPORT QgsProcessingToolboxModel : public QAbstractItemModel
* which automatically sorts the toolbox in a logical fashion and supports filtering
* the results.
*
* If \recentLog is specified then it will be used to create a "Recently used" top
* level group containing recently used algorithms.
*
* \ingroup gui
* \since QGIS 3.2
*/
@@ -418,7 +421,9 @@ class GUI_EXPORT QgsProcessingToolboxProxyModel: public QSortFilterProxyModel
* registry attached to QgsApplication::processingRegistry() will be used
* by the model.
*/
explicit QgsProcessingToolboxProxyModel( QObject *parent SIP_TRANSFERTHIS = nullptr, QgsProcessingRegistry *registry = nullptr );
explicit QgsProcessingToolboxProxyModel( QObject *parent SIP_TRANSFERTHIS = nullptr,
QgsProcessingRegistry *registry = nullptr,
QgsProcessingRecentAlgorithmLog *recentLog = nullptr );

/**
* Set \a filters that affect how toolbox content is filtered.

0 comments on commit 670f408

Please sign in to comment.
You can’t perform that action at this time.