QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgshistoryproviderregistry.h
Go to the documentation of this file.
1/***************************************************************************
2 qgshistoryproviderregistry.h
3 --------------------------
4 begin : April 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSHISTORYPROVIDERREGISTRY_H
17#define QGSHISTORYPROVIDERREGISTRY_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21#include "qgis.h"
22
23#include <QObject>
24#include <QMap>
25#include <QString>
26#include <QDateTime>
27#include <QVariant>
28#include <QVector>
29
30#include "qgssqliteutils.h"
31
33class QgsHistoryEntry;
34
44class GUI_EXPORT QgsHistoryProviderRegistry : public QObject
45{
46 Q_OBJECT
47
48 public:
49
56 QgsHistoryProviderRegistry( QObject *parent = nullptr, bool useMemoryDatabase = false );
57
59
64 void addDefaultProviders() SIP_SKIP;
65
72 bool addProvider( QgsAbstractHistoryProvider *provider SIP_TRANSFER );
73
78 QgsAbstractHistoryProvider *providerById( const QString &id );
79
87 bool removeProvider( const QString &id );
88
92 QStringList providerIds() const;
93
101 {
102 public:
103
108
111 };
112
128 long long addEntry( const QString &providerId, const QVariantMap &entry, bool &ok SIP_OUT, QgsHistoryProviderRegistry::HistoryEntryOptions options = QgsHistoryProviderRegistry::HistoryEntryOptions() );
129
142
149 bool addEntries( const QList< QgsHistoryEntry > &entries, QgsHistoryProviderRegistry::HistoryEntryOptions options = QgsHistoryProviderRegistry::HistoryEntryOptions() );
150
160 QgsHistoryEntry entry( long long id, bool &ok, Qgis::HistoryProviderBackend backend = Qgis::HistoryProviderBackend::LocalProfile ) const;
161
168 bool updateEntry( long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend = Qgis::HistoryProviderBackend::LocalProfile );
169
175 QList< QgsHistoryEntry > queryEntries( const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime(),
176 const QString &providerId = QString(), Qgis::HistoryProviderBackends backends = Qgis::HistoryProviderBackend::LocalProfile ) const;
177
181 static QString userHistoryDbPath();
182
188 bool clearHistory( Qgis::HistoryProviderBackend backend, const QString &providerId = QString() );
189
190 signals:
191
197 void entryAdded( long long id, const QgsHistoryEntry &entry, Qgis::HistoryProviderBackend backend );
198
204 void entryUpdated( long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend );
205
214 void historyCleared( Qgis::HistoryProviderBackend backend, const QString &providerId );
215
216 private:
217
221 bool createDatabase( const QString &filename, QString &error );
222
224 bool openDatabase( const QString &filename, QString &error );
225
229 void createTables();
230
237 bool runEmptyQuery( const QString &query );
238
239 QMap< QString, QgsAbstractHistoryProvider * > mProviders;
240
242
243};
244
245#endif //QGSHISTORYPROVIDERREGISTRY_H
HistoryProviderBackend
History provider backends.
Definition: qgis.h:2842
@ LocalProfile
Local profile.
QFlags< HistoryProviderBackend > HistoryProviderBackends
Definition: qgis.h:2847
Abstract base class for objects which track user history (i.e.
Encapsulates a history entry.
Contains options for storing history entries.
HistoryEntryOptions()
Constructor for HistoryEntryOptions.
The QgsHistoryProviderRegistry is a registry for objects which track user history (i....
void entryAdded(long long id, const QgsHistoryEntry &entry, Qgis::HistoryProviderBackend backend)
Emitted when an entry is added.
void entryUpdated(long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend)
Emitted when an entry is updated.
void historyCleared(Qgis::HistoryProviderBackend backend, const QString &providerId)
Emitted when the history is cleared for a backend.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_OUT
Definition: qgis_sip.h:58