Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Metatype QgsHistoryEntry
  • Loading branch information
nyalldawson committed Apr 22, 2023
1 parent ae5808f commit d5cd4c9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
Expand Up @@ -23,6 +23,11 @@ Encapsulates a history entry.
%End
public:

QgsHistoryEntry();
%Docstring
Constructor for an invalid entry.
%End

QgsHistoryEntry( const QString &providerId, const QDateTime &timestamp, const QVariantMap &entry );
%Docstring
Constructor for QgsHistoryEntry ``entry``, with the specified ``providerId`` and ``timestamp``.
Expand All @@ -33,6 +38,13 @@ Constructor for QgsHistoryEntry ``entry``, with the specified ``providerId`` and
Constructor for QgsHistoryEntry ``entry``.

The entry timestamp will be automatically set to the current date/time.
%End

bool isValid() const;
%Docstring
Returns ``True`` if the entry is valid.

.. versionadded:: 3.32
%End

QDateTime timestamp;
Expand All @@ -49,6 +61,7 @@ The entry timestamp will be automatically set to the current date/time.

};


class QgsHistoryProviderRegistry : QObject
{
%Docstring(signature="appended")
Expand Down
5 changes: 5 additions & 0 deletions src/gui/history/qgshistoryproviderregistry.cpp
Expand Up @@ -44,6 +44,11 @@ QgsHistoryEntry::QgsHistoryEntry( const QVariantMap &entry )

}

bool QgsHistoryEntry::isValid() const
{
return !providerId.isEmpty();
}

//
// QgsHistoryProviderRegistry
//
Expand Down
14 changes: 14 additions & 0 deletions src/gui/history/qgshistoryproviderregistry.h
Expand Up @@ -41,6 +41,11 @@ class GUI_EXPORT QgsHistoryEntry
{
public:

/**
* Constructor for an invalid entry.
*/
QgsHistoryEntry() = default;

/**
* Constructor for QgsHistoryEntry \a entry, with the specified \a providerId and \a timestamp.
*/
Expand All @@ -53,6 +58,13 @@ class GUI_EXPORT QgsHistoryEntry
*/
QgsHistoryEntry( const QVariantMap &entry );

/**
* Returns TRUE if the entry is valid.
*
* \since QGIS 3.32
*/
bool isValid() const;

//! Entry timestamp
QDateTime timestamp;

Expand All @@ -77,6 +89,8 @@ class GUI_EXPORT QgsHistoryEntry

};

Q_DECLARE_METATYPE( QgsHistoryEntry );

/**
* The QgsHistoryProviderRegistry is a registry for objects which track user history (i.e. operations performed through the GUI).
*
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsgui.cpp
Expand Up @@ -325,6 +325,8 @@ QgsGui::QgsGui()
mWidgetStateHelper = new QgsWidgetStateHelper();
mProcessingRecentAlgorithmLog = new QgsProcessingRecentAlgorithmLog();
mProcessingGuiRegistry = new QgsProcessingGuiRegistry();

qRegisterMetaType< QgsHistoryEntry >( "QgsHistoryEntry" );
}

bool QgsGui::pythonMacroAllowed( void ( *lambda )(), QgsMessageBar *messageBar )
Expand Down

0 comments on commit d5cd4c9

Please sign in to comment.