Skip to content
Permalink
Browse files

Start on history item

  • Loading branch information
nyalldawson committed Jul 7, 2018
1 parent 6275960 commit 69ab3c9e0c62f7146eb558cea38699ce02b05e78
@@ -695,6 +695,7 @@
<file>themes/default/mActionIdentifyByRadius.svg</file>
<file>themes/default/mActionIdentifyByRectangle.svg</file>
<file>themes/default/mIndicatorEmbedded.svg</file>
<file>themes/default/mIconHistory.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
File renamed without changes.
@@ -0,0 +1,3 @@
# The following has been generated automatically from src/gui/processing/qgsprocessingtoolboxmodel.h
QgsProcessingToolboxProxyModel.Filters.baseClass = QgsProcessingToolboxProxyModel
Filters = QgsProcessingToolboxProxyModel # dirty hack since SIP seems to introduce the flags in module
@@ -36,6 +36,8 @@ Abstract base class for nodes contained within a QgsProcessingToolboxModel.
sipType = sipType_QgsProcessingToolboxModelGroupNode;
else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeAlgorithm )
sipType = sipType_QgsProcessingToolboxModelAlgorithmNode;
else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeRecent )
sipType = sipType_QgsProcessingToolboxModelRecentNode;
}
else
sipType = 0;
@@ -47,6 +49,7 @@ Abstract base class for nodes contained within a QgsProcessingToolboxModel.
NodeProvider,
NodeGroup,
NodeAlgorithm,
NodeRecent,
};

~QgsProcessingToolboxModelNode();
@@ -93,6 +96,32 @@ Deletes all child nodes from this node.

};

class QgsProcessingToolboxModelRecentNode : QgsProcessingToolboxModelNode
{
%Docstring
Processing toolbox model node corresponding to the recent algorithms group

.. versionadded:: 3.2

.. warning::

Not part of stable API and may change in future QGIS releases.
%End

%TypeHeaderCode
#include "qgsprocessingtoolboxmodel.h"
%End
public:

QgsProcessingToolboxModelRecentNode();
%Docstring
Constructor for QgsProcessingToolboxModelRecentNode.
%End

virtual NodeType nodeType() const;

};

class QgsProcessingToolboxModelProviderNode : QgsProcessingToolboxModelNode
{
%Docstring
@@ -205,7 +205,7 @@ def initGui(self):
self.menu.addAction(self.modelerAction)

self.historyAction = QAction(
QIcon(os.path.join(pluginPath, 'images', 'history.svg')),
QgsApplication.getThemeIcon("/mIconHistory.svg"),
QCoreApplication.translate('ProcessingPlugin', '&History…'), self.iface.mainWindow())
self.historyAction.setObjectName('historyAction')
self.historyAction.triggered.connect(self.openHistory)
@@ -124,6 +124,8 @@ void QgsProcessingToolboxModel::rebuild()

mRootNode->deleteChildren();

mRootNode->addChildNode( new QgsProcessingToolboxModelRecentNode() );

const QList< QgsProcessingProvider * > providers = mRegistry->providers();
for ( QgsProcessingProvider *provider : providers )
{
@@ -276,6 +278,10 @@ QVariant QgsProcessingToolboxModel::data( const QModelIndex &index, int role ) c
return QVariant();
}

bool isRecentNode = false;
if ( QgsProcessingToolboxModelNode *node = index2node( index ) )
isRecentNode = node->nodeType() == QgsProcessingToolboxModelNode::NodeRecent;

QgsProcessingProvider *provider = providerForIndex( index );
QgsProcessingToolboxModelGroupNode *groupNode = qobject_cast< QgsProcessingToolboxModelGroupNode * >( index2node( index ) );
const QgsProcessingAlgorithm *algorithm = algorithmForIndex( index );
@@ -293,6 +299,8 @@ QVariant QgsProcessingToolboxModel::data( const QModelIndex &index, int role ) c
return algorithm->displayName();
else if ( groupNode )
return groupNode->name();
else if ( isRecentNode )
return tr( "Recently used" );
else
return QVariant();

@@ -323,6 +331,8 @@ QVariant QgsProcessingToolboxModel::data( const QModelIndex &index, int role ) c
return provider->icon();
else if ( algorithm )
return algorithm->icon();
else if ( isRecentNode )
return QgsApplication::getThemeIcon( QStringLiteral( "/mIconHistory.svg" ) );
else if ( !index.parent().isValid() )
// top level groups get the QGIS icon
return QgsApplication::getThemeIcon( QStringLiteral( "/providerQgis.svg" ) );
@@ -630,14 +640,16 @@ bool QgsProcessingToolboxProxyModel::filterAcceptsRow( int sourceRow, const QMod
}
}

bool isRecentNode = mModel->data( sourceIndex, QgsProcessingToolboxModel::RoleNodeType ).toInt() == QgsProcessingToolboxModelNode::NodeRecent;

if ( QgsProcessingProvider *provider = mModel->providerForIndex( sourceIndex ) )
{
return hasChildren && provider->isActive();
}
else
{
// group
return hasChildren;
return hasChildren || isRecentNode;
}
}

@@ -50,6 +50,8 @@ class GUI_EXPORT QgsProcessingToolboxModelNode : public QObject
sipType = sipType_QgsProcessingToolboxModelGroupNode;
else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeAlgorithm )
sipType = sipType_QgsProcessingToolboxModelAlgorithmNode;
else if ( node->nodeType() == QgsProcessingToolboxModelNode::NodeRecent )
sipType = sipType_QgsProcessingToolboxModelRecentNode;
}
else
sipType = 0;
@@ -64,6 +66,7 @@ class GUI_EXPORT QgsProcessingToolboxModelNode : public QObject
NodeProvider = 0, //!< Provider node
NodeGroup, //!< Group node
NodeAlgorithm, //!< Algorithm node
NodeRecent, //!< Recent algorithms node
};

~QgsProcessingToolboxModelNode() override;
@@ -121,6 +124,27 @@ class GUI_EXPORT QgsProcessingToolboxModelNode : public QObject

};

/**
* Processing toolbox model node corresponding to the recent algorithms group
* \ingroup gui
* \since QGIS 3.2
* \warning Not part of stable API and may change in future QGIS releases.
*/
class GUI_EXPORT QgsProcessingToolboxModelRecentNode : public QgsProcessingToolboxModelNode
{
Q_OBJECT

public:

/**
* Constructor for QgsProcessingToolboxModelRecentNode.
*/
QgsProcessingToolboxModelRecentNode() = default;

NodeType nodeType() const override { return NodeRecent; }

};

/**
* Processing toolbox model node corresponding to a Processing provider.
* \ingroup gui

0 comments on commit 69ab3c9

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