Skip to content

Commit

Permalink
Move QgsHistoryEntry to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 22, 2023
1 parent d5cd4c9 commit e84ce19
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 142 deletions.
69 changes: 69 additions & 0 deletions python/gui/auto_generated/history/qgshistoryentry.sip.in
@@ -0,0 +1,69 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/history/qgshistoryentry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsHistoryEntry
{
%Docstring(signature="appended")
Encapsulates a history entry.

.. versionadded:: 3.24
%End

%TypeHeaderCode
#include "qgshistoryentry.h"
%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``.
%End

QgsHistoryEntry( const QVariantMap &entry );
%Docstring
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;

QString providerId;

QVariantMap entry;

SIP_PYOBJECT __repr__();
%MethodCode
const QString str = QStringLiteral( "<QgsHistoryEntry: %1 %2>" ).arg( sipCpp->providerId, sipCpp->timestamp.toString( Qt::ISODate ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/history/qgshistoryentry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
Expand Up @@ -10,58 +10,6 @@



class QgsHistoryEntry
{
%Docstring(signature="appended")
Encapsulates a history entry.

.. versionadded:: 3.24
%End

%TypeHeaderCode
#include "qgshistoryproviderregistry.h"
%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``.
%End

QgsHistoryEntry( const QVariantMap &entry );
%Docstring
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;

QString providerId;

QVariantMap entry;

SIP_PYOBJECT __repr__();
%MethodCode
const QString str = QStringLiteral( "<QgsHistoryEntry: %1 %2>" ).arg( sipCpp->providerId, sipCpp->timestamp.toString( Qt::ISODate ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};


class QgsHistoryProviderRegistry : QObject
{
%Docstring(signature="appended")
Expand Down
1 change: 1 addition & 0 deletions python/gui/gui_auto.sip
Expand Up @@ -341,6 +341,7 @@
%Include auto_generated/effects/qgspainteffectpropertieswidget.sip
%Include auto_generated/effects/qgspainteffectwidget.sip
%Include auto_generated/elevation/qgselevationprofilecanvas.sip
%Include auto_generated/history/qgshistoryentry.sip
%Include auto_generated/history/qgshistoryprovider.sip
%Include auto_generated/history/qgshistoryproviderregistry.sip
%Include auto_generated/labeling/qgslabellineanchorwidget.sip
Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -236,6 +236,7 @@ set(QGIS_GUI_SRCS
elevation/qgselevationprofilecanvas.cpp
elevation/qgselevationprofilelayertreeview.cpp

history/qgshistoryentry.cpp
history/qgshistoryprovider.cpp
history/qgshistoryproviderregistry.cpp

Expand Down Expand Up @@ -1142,6 +1143,7 @@ set(QGIS_GUI_HDRS
elevation/qgselevationprofilecanvas.h
elevation/qgselevationprofilelayertreeview.h

history/qgshistoryentry.h
history/qgshistoryprovider.h
history/qgshistoryproviderregistry.h

Expand Down
37 changes: 37 additions & 0 deletions src/gui/history/qgshistoryentry.cpp
@@ -0,0 +1,37 @@
/***************************************************************************
qgshistoryentry.cpp
-------------------------
begin : April 2019
copyright : (C) 2019 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgshistoryentry.h"

QgsHistoryEntry::QgsHistoryEntry( const QString &providerId, const QDateTime &timestamp, const QVariantMap &entry )
: timestamp( timestamp )
, providerId( providerId )
, entry( entry )
{

}

QgsHistoryEntry::QgsHistoryEntry( const QVariantMap &entry )
: timestamp( QDateTime::currentDateTime() )
, entry( entry )
{

}

bool QgsHistoryEntry::isValid() const
{
return !providerId.isEmpty();
}
88 changes: 88 additions & 0 deletions src/gui/history/qgshistoryentry.h
@@ -0,0 +1,88 @@
/***************************************************************************
qgshistoryentry.h
--------------------------
begin : April 2019
copyright : (C) 2019 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSHISTORYENTRY_H
#define QGSHISTORYENTRY_H

#include "qgis_gui.h"
#include "qgis_sip.h"
#include "qgis.h"

#include <QMap>
#include <QString>
#include <QDateTime>
#include <QVariant>

/**
* Encapsulates a history entry.
*
* \ingroup gui
* \since QGIS 3.24
*/
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.
*/
QgsHistoryEntry( const QString &providerId, const QDateTime &timestamp, const QVariantMap &entry );

/**
* Constructor for QgsHistoryEntry \a entry.
*
* The entry timestamp will be automatically set to the current date/time.
*/
QgsHistoryEntry( const QVariantMap &entry );

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

//! Entry timestamp
QDateTime timestamp;

//! Associated history provider ID
QString providerId;

/**
* Entry details.
*
* Entries details are stored as a free-form map. Interpretation of this map is the responsibility of the
* associated history provider.
*/
QVariantMap entry;

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
const QString str = QStringLiteral( "<QgsHistoryEntry: %1 %2>" ).arg( sipCpp->providerId, sipCpp->timestamp.toString( Qt::ISODate ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

};

Q_DECLARE_METATYPE( QgsHistoryEntry );

#endif // QGSHISTORYENTRY
31 changes: 2 additions & 29 deletions src/gui/history/qgshistoryproviderregistry.cpp
Expand Up @@ -15,44 +15,17 @@
***************************************************************************/

#include "qgshistoryproviderregistry.h"
#include "history/qgshistoryprovider.h"
#include "qgshistoryprovider.h"
#include "qgsapplication.h"
#include "qgsruntimeprofiler.h"
#include "qgslogger.h"
#include "qgsxmlutils.h"
#include "qgsprocessinghistoryprovider.h"
#include "qgshistoryentry.h"

#include <QFile>
#include <sqlite3.h>

//
// QgsHistoryEntry
//

QgsHistoryEntry::QgsHistoryEntry( const QString &providerId, const QDateTime &timestamp, const QVariantMap &entry )
: timestamp( timestamp )
, providerId( providerId )
, entry( entry )
{

}

QgsHistoryEntry::QgsHistoryEntry( const QVariantMap &entry )
: timestamp( QDateTime::currentDateTime() )
, entry( entry )
{

}

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

//
// QgsHistoryProviderRegistry
//

QgsHistoryProviderRegistry::QgsHistoryProviderRegistry( QObject *parent, bool useMemoryDatabase )
: QObject( parent )
{
Expand Down
61 changes: 1 addition & 60 deletions src/gui/history/qgshistoryproviderregistry.h
Expand Up @@ -30,66 +30,7 @@
#include "qgssqliteutils.h"

class QgsAbstractHistoryProvider;

/**
* Encapsulates a history entry.
*
* \ingroup gui
* \since QGIS 3.24
*/
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.
*/
QgsHistoryEntry( const QString &providerId, const QDateTime &timestamp, const QVariantMap &entry );

/**
* Constructor for QgsHistoryEntry \a entry.
*
* The entry timestamp will be automatically set to the current date/time.
*/
QgsHistoryEntry( const QVariantMap &entry );

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

//! Entry timestamp
QDateTime timestamp;

//! Associated history provider ID
QString providerId;

/**
* Entry details.
*
* Entries details are stored as a free-form map. Interpretation of this map is the responsibility of the
* associated history provider.
*/
QVariantMap entry;

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
const QString str = QStringLiteral( "<QgsHistoryEntry: %1 %2>" ).arg( sipCpp->providerId, sipCpp->timestamp.toString( Qt::ISODate ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

};

Q_DECLARE_METATYPE( QgsHistoryEntry );
class QgsHistoryEntry;

/**
* The QgsHistoryProviderRegistry is a registry for objects which track user history (i.e. operations performed through the GUI).
Expand Down

0 comments on commit e84ce19

Please sign in to comment.