Add capacity for history providers to create/update nodes

This commit is contained in:
Nyall Dawson 2023-04-19 11:02:19 +10:00
parent dd25f39479
commit 0774c80f3e
3 changed files with 35 additions and 4 deletions

View File

@ -36,6 +36,20 @@ Abstract base class for objects which track user history (i.e. operations perfor
virtual QString id() const = 0;
%Docstring
Returns the provider's unique id, which is used to associate existing history entries with the provider.
%End
virtual QgsHistoryEntryNode *createNodeForEntry( const QVariantMap &entry ) /Factory/;
%Docstring
Creates a new history node for the given ``entry``.
.. versionadded:: 3.32
%End
virtual void updateNodeForEntry( QgsHistoryEntryNode *node, const QVariantMap &entry );
%Docstring
Updates an existing history ``node`` for the given ``entry``.
.. versionadded:: 3.32
%End
};

View File

@ -17,3 +17,13 @@
#include "qgshistoryprovider.h"
QgsAbstractHistoryProvider::~QgsAbstractHistoryProvider() = default;
QgsHistoryEntryNode *QgsAbstractHistoryProvider::createNodeForEntry( const QVariantMap & )
{
return nullptr;
}
void QgsAbstractHistoryProvider::updateNodeForEntry( QgsHistoryEntryNode *, const QVariantMap & )
{
}

View File

@ -52,13 +52,20 @@ class GUI_EXPORT QgsAbstractHistoryProvider
*/
virtual QString id() const = 0;
#if 0
/**
* Creates a new history node for the given \a entry.
*
* \since QGIS 3.32
*/
virtual QgsHistoryEntryNode *createNodeForEntry( const QVariantMap &entry ) = 0 SIP_FACTORY;
#endif
virtual QgsHistoryEntryNode *createNodeForEntry( const QVariantMap &entry ) SIP_FACTORY;
/**
* Updates an existing history \a node for the given \a entry.
*
* \since QGIS 3.32
*/
virtual void updateNodeForEntry( QgsHistoryEntryNode *node, const QVariantMap &entry );
};
#endif //QGSHISTORYPROVIDER_H