QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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:
55 QgsHistoryProviderRegistry( QObject *parent = nullptr, bool useMemoryDatabase = false );
56
58
63 void addDefaultProviders() SIP_SKIP;
64
71 bool addProvider( QgsAbstractHistoryProvider *provider SIP_TRANSFER );
72
77 QgsAbstractHistoryProvider *providerById( const QString &id );
78
86 bool removeProvider( const QString &id );
87
91 QStringList providerIds() const;
92
110
126 long long addEntry( const QString &providerId, const QVariantMap &entry, bool &ok SIP_OUT, QgsHistoryProviderRegistry::HistoryEntryOptions options = QgsHistoryProviderRegistry::HistoryEntryOptions() );
127
140
147 bool addEntries( const QList<QgsHistoryEntry> &entries, QgsHistoryProviderRegistry::HistoryEntryOptions options = QgsHistoryProviderRegistry::HistoryEntryOptions() );
148
158 QgsHistoryEntry entry( long long id, bool &ok, Qgis::HistoryProviderBackend backend = Qgis::HistoryProviderBackend::LocalProfile ) const;
159
166 bool updateEntry( long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend = Qgis::HistoryProviderBackend::LocalProfile );
167
173 QList<QgsHistoryEntry> queryEntries( const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime(), const QString &providerId = QString(), Qgis::HistoryProviderBackends backends = Qgis::HistoryProviderBackend::LocalProfile ) const;
174
178 static QString userHistoryDbPath();
179
185 bool clearHistory( Qgis::HistoryProviderBackend backend, const QString &providerId = QString() );
186
187 signals:
188
194 void entryAdded( long long id, const QgsHistoryEntry &entry, Qgis::HistoryProviderBackend backend );
195
201 void entryUpdated( long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend );
202
211 void historyCleared( Qgis::HistoryProviderBackend backend, const QString &providerId );
212
213 private:
217 bool createDatabase( const QString &filename, QString &error );
218
220 bool openDatabase( const QString &filename, QString &error );
221
225 void createTables();
226
233 bool runEmptyQuery( const QString &query );
234
235 QMap<QString, QgsAbstractHistoryProvider *> mProviders;
236
238};
239
240#endif //QGSHISTORYPROVIDERREGISTRY_H
HistoryProviderBackend
History provider backends.
Definition qgis.h:3299
@ LocalProfile
Local profile.
QFlags< HistoryProviderBackend > HistoryProviderBackends
Definition qgis.h:3304
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