QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsstoredquerymanager.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsstoredquerymanager.h
3 ----------------------------------
4 Date : February 2025
5 Copyright : (C) 2025 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSSTOREDQUERYMANAGER_H
17#define QGSSTOREDQUERYMANAGER_H
18
19#include "qgis.h"
20#include "qgis_gui.h"
21#include "qgssettingstree.h"
22
32class GUI_EXPORT QgsStoredQueryManager : public QObject
33{
34 Q_OBJECT
35
36 public:
37#ifndef SIP_RUN
39 static inline QgsSettingsTreeNamedListNode *sTreeStoredQueries = QgsSettingsTree::sTreeDatabase->createNamedListNode( QStringLiteral( "stored-queries" ) );
40 static const QgsSettingsEntryString *settingQueryName;
41 static const QgsSettingsEntryString *settingQueryDefinition;
43#endif
44
49 QgsStoredQueryManager( QObject *parent = nullptr );
50
63 void storeQuery( const QString &name, const QString &query, Qgis::QueryStorageBackend backend = Qgis::QueryStorageBackend::LocalProfile );
64
74
79
83 QString query( const QString &name, Qgis::QueryStorageBackend backend = Qgis::QueryStorageBackend::LocalProfile ) const;
84
110
116 QList< QgsStoredQueryManager::QueryDetails > allQueries() const;
117
118 signals:
119
123 void queryAdded( const QString &name, Qgis::QueryStorageBackend backend );
124
128 void queryChanged( const QString &name, Qgis::QueryStorageBackend backend );
129
133 void queryRemoved( const QString &name, Qgis::QueryStorageBackend backend );
134
135 private:
136 static QString getQueryHash( const QString &name );
137};
138
139
140#endif // QGSSTOREDQUERYMANAGER_H
QueryStorageBackend
Stored query storage backends.
Definition qgis.h:3517
@ LocalProfile
Local user profile.
Definition qgis.h:3518
A string settings entry.
A named list tree node for the settings tree to help organizing and introspecting the tree.
static QgsSettingsTreeNode * sTreeDatabase
Contains details about a stored query.
Qgis::QueryStorageBackend backend
Storage backend.
QList< QgsStoredQueryManager::QueryDetails > allQueries() const
Returns details of all queries stored in the manager.
QStringList allQueryNames(Qgis::QueryStorageBackend backend=Qgis::QueryStorageBackend::LocalProfile) const
Returns a list of the names of all stored queries for the specified backend.
void queryRemoved(const QString &name, Qgis::QueryStorageBackend backend)
Emitted when a query is removed from the manager.
void queryChanged(const QString &name, Qgis::QueryStorageBackend backend)
Emitted when an existing query is changed in the manager.
void queryAdded(const QString &name, Qgis::QueryStorageBackend backend)
Emitted when a query is added to the manager.
QgsStoredQueryManager(QObject *parent=nullptr)
Constructor for QgsStoredQueryManager, with the specified parent object.
QString query(const QString &name, Qgis::QueryStorageBackend backend=Qgis::QueryStorageBackend::LocalProfile) const
Returns the query definition with matching name, from the specified backend.
void removeQuery(const QString &name, Qgis::QueryStorageBackend backend=Qgis::QueryStorageBackend::LocalProfile)
Removes the stored query with matching name.
void storeQuery(const QString &name, const QString &query, Qgis::QueryStorageBackend backend=Qgis::QueryStorageBackend::LocalProfile)
Saves a query to the manager.