QGIS API Documentation 3.43.0-Master (ebb4087afc0)
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
73 void removeQuery( const QString &name, Qgis::QueryStorageBackend backend = Qgis::QueryStorageBackend::LocalProfile );
74
78 QStringList allQueryNames( Qgis::QueryStorageBackend backend = Qgis::QueryStorageBackend::LocalProfile ) const;
79
83 QString query( const QString &name, Qgis::QueryStorageBackend backend = Qgis::QueryStorageBackend::LocalProfile ) const;
84
92 {
93 public:
97 QString name;
98
102 QString definition;
103
108 };
109
115 QList< QgsStoredQueryManager::QueryDetails > allQueries() const;
116
117 signals:
118
122 void queryAdded( const QString &name, Qgis::QueryStorageBackend backend );
123
127 void queryChanged( const QString &name, Qgis::QueryStorageBackend backend );
128
132 void queryRemoved( const QString &name, Qgis::QueryStorageBackend backend );
133
134 private:
135 static QString getQueryHash( const QString &name );
136};
137
138
139#endif // QGSSTOREDQUERYMANAGER_H
QueryStorageBackend
Stored query storage backends.
Definition qgis.h:3381
@ LocalProfile
Local user profile.
A string settings entry.
QgsSettingsTreeNamedListNode is a named list tree node for the settings tree to help organizing and i...
QgsSettingsTreeNamedListNode * createNamedListNode(const QString &key, const Qgis::SettingsTreeNodeOptions &options=Qgis::SettingsTreeNodeOptions())
Creates a named list tree node.
static QgsSettingsTreeNode * sTreeDatabase
Contains details about a stored query.
A manager for stored SQL queries.
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.