QGIS API Documentation 3.99.0-Master (d270888f95f)
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
23#include <QString>
24
25using namespace Qt::StringLiterals;
26
36class GUI_EXPORT QgsStoredQueryManager : public QObject
37{
38 Q_OBJECT
39
40 public:
41#ifndef SIP_RUN
43 static inline QgsSettingsTreeNamedListNode *sTreeStoredQueries = QgsSettingsTree::sTreeDatabase->createNamedListNode( u"stored-queries"_s );
44 static const QgsSettingsEntryString *settingQueryName;
45 static const QgsSettingsEntryString *settingQueryDefinition;
47#endif
48
53 QgsStoredQueryManager( QObject *parent = nullptr );
54
67 void storeQuery( const QString &name, const QString &query, Qgis::QueryStorageBackend backend = Qgis::QueryStorageBackend::LocalProfile );
68
78
83
87 QString query( const QString &name, Qgis::QueryStorageBackend backend = Qgis::QueryStorageBackend::LocalProfile ) const;
88
113
119 QList< QgsStoredQueryManager::QueryDetails > allQueries() const;
120
121 signals:
122
126 void queryAdded( const QString &name, Qgis::QueryStorageBackend backend );
127
131 void queryChanged( const QString &name, Qgis::QueryStorageBackend backend );
132
136 void queryRemoved( const QString &name, Qgis::QueryStorageBackend backend );
137
138 private:
139 static QString getQueryHash( const QString &name );
140};
141
142
143#endif // QGSSTOREDQUERYMANAGER_H
QueryStorageBackend
Stored query storage backends.
Definition qgis.h:3576
@ LocalProfile
Local user profile.
Definition qgis.h:3577
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.