mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Start on history item
This commit is contained in:
parent
6275960df8
commit
69ab3c9e0c
@ -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>
|
||||
|
Before Width: | Height: | Size: 515 B After Width: | Height: | Size: 515 B |
3
python/gui/auto_additions/qgsprocessingtoolboxmodel.py
Normal file
3
python/gui/auto_additions/qgsprocessingtoolboxmodel.py
Normal file
@ -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 @@ class ProcessingPlugin:
|
||||
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,6 +640,8 @@ 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();
|
||||
@ -637,7 +649,7 @@ bool QgsProcessingToolboxProxyModel::filterAcceptsRow( int sourceRow, const QMod
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user