QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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.h"
20#include "qgis_gui.h"
21#include "qgis_sip.h"
22#include "qgssqliteutils.h"
23
24#include <QDateTime>
25#include <QMap>
26#include <QObject>
27#include <QString>
28#include <QVariant>
29#include <QVector>
30
32class QgsHistoryEntry;
33
43class GUI_EXPORT QgsHistoryProviderRegistry : public QObject
44{
45 Q_OBJECT
46
47 public:
54 QgsHistoryProviderRegistry( QObject *parent = nullptr, bool useMemoryDatabase = false );
55
57
63
71
76 QgsAbstractHistoryProvider *providerById( const QString &id );
77
85 bool removeProvider( const QString &id );
86
90 QStringList providerIds() const;
91
109
125 long long addEntry( const QString &providerId, const QVariantMap &entry, bool &ok SIP_OUT, QgsHistoryProviderRegistry::HistoryEntryOptions options = QgsHistoryProviderRegistry::HistoryEntryOptions() );
126
139
147
158
165 bool updateEntry( long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend = Qgis::HistoryProviderBackend::LocalProfile );
166
172 QList<QgsHistoryEntry> queryEntries( const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime(), const QString &providerId = QString(), Qgis::HistoryProviderBackends backends = Qgis::HistoryProviderBackend::LocalProfile ) const;
173
177 static QString userHistoryDbPath();
178
184 bool clearHistory( Qgis::HistoryProviderBackend backend, const QString &providerId = QString() );
185
186 signals:
187
193 void entryAdded( long long id, const QgsHistoryEntry &entry, Qgis::HistoryProviderBackend backend );
194
200 void entryUpdated( long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend );
201
210 void historyCleared( Qgis::HistoryProviderBackend backend, const QString &providerId );
211
212 private:
216 bool createDatabase( const QString &filename, QString &error );
217
219 bool openDatabase( const QString &filename, QString &error );
220
224 void createTables();
225
232 bool runEmptyQuery( const QString &query );
233
234 QMap<QString, QgsAbstractHistoryProvider *> mProviders;
235
237};
238
239#endif //QGSHISTORYPROVIDERREGISTRY_H
HistoryProviderBackend
History provider backends.
Definition qgis.h:3503
@ LocalProfile
Local profile.
Definition qgis.h:3504
QFlags< HistoryProviderBackend > HistoryProviderBackends
Definition qgis.h:3508
Abstract base class for objects which track user history (i.e.
Encapsulates a history entry.
Contains options for storing history entries.
Qgis::HistoryProviderBackends storageBackends
Target storage backends.
HistoryEntryOptions()
Constructor for HistoryEntryOptions.
QgsAbstractHistoryProvider * providerById(const QString &id)
Returns the provider with matching id, or nullptr if no matching provider is registered.
bool updateEntry(long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend=Qgis::HistoryProviderBackend::LocalProfile)
Updates the existing entry with matching id.
static QString userHistoryDbPath()
Returns the path to user's local history database.
bool clearHistory(Qgis::HistoryProviderBackend backend, const QString &providerId=QString())
Clears the history for the specified backend.
void entryAdded(long long id, const QgsHistoryEntry &entry, Qgis::HistoryProviderBackend backend)
Emitted when an entry is added.
bool addProvider(QgsAbstractHistoryProvider *provider)
Adds a provider to the registry.
bool addEntries(const QList< QgsHistoryEntry > &entries, QgsHistoryProviderRegistry::HistoryEntryOptions options=QgsHistoryProviderRegistry::HistoryEntryOptions())
Adds a list of entries to the history logs.
QgsHistoryProviderRegistry(QObject *parent=nullptr, bool useMemoryDatabase=false)
Creates a new empty history provider registry.
bool removeProvider(const QString &id)
Removes the provider with matching id.
long long addEntry(const QString &providerId, const QVariantMap &entry, bool &ok, QgsHistoryProviderRegistry::HistoryEntryOptions options=QgsHistoryProviderRegistry::HistoryEntryOptions())
Adds an entry to the history logs.
QgsHistoryEntry entry(long long id, bool &ok, Qgis::HistoryProviderBackend backend=Qgis::HistoryProviderBackend::LocalProfile) const
Returns the entry with matching ID, from the specified backend.
QList< QgsHistoryEntry > queryEntries(const QDateTime &start=QDateTime(), const QDateTime &end=QDateTime(), const QString &providerId=QString(), Qgis::HistoryProviderBackends backends=Qgis::HistoryProviderBackend::LocalProfile) const
Queries history entries which occurred between the specified start and end times.
void entryUpdated(long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend)
Emitted when an entry is updated.
void addDefaultProviders()
Adds the default history providers to the registry.
QStringList providerIds() const
Returns a list of the registered provider IDs.
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:134
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_OUT
Definition qgis_sip.h:58