QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgsquerybuilder.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsquerybuilder.h - query builder
3 --------------------------------------
4 Date : 2004-11-19
5 Copyright : (C) 2004 by Gary E.Sherman
6 Email : sherman at mrcc.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#ifndef QGSQUERYBUILDER_H
16#define QGSQUERYBUILDER_H
17#include <map>
18#include "qgis_sip.h"
19#include <vector>
20#include <QStandardItemModel>
21#include <QSortFilterProxyModel>
22#include <QStandardItem>
23#include <QModelIndex>
24#include "ui_qgsquerybuilderbase.h"
25#include "qgsguiutils.h"
26#include "qgis_gui.h"
28
29class QgsVectorLayer;
30class QgsCodeEditor;
32
45class GUI_EXPORT QgsQueryBuilder : public QgsSubsetStringEditorInterface, private Ui::QgsQueryBuilderBase
46{
47 Q_OBJECT
48 public:
49
57 QgsQueryBuilder( QgsVectorLayer *layer, QWidget *parent SIP_TRANSFERTHIS = nullptr,
58 Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
59
60 void showEvent( QShowEvent *event ) override;
61
63 QString sql() const;
64
66 void setSql( const QString &sqlStatement );
67
68 QString subsetString() const override { return sql(); }
69 void setSubsetString( const QString &subsetString ) override { setSql( subsetString ); }
70
71#ifdef SIP_RUN
72 SIP_IF_FEATURE( HAVE_QSCI_SIP )
73
74
78 QgsCodeEditor *codeEditorWidget() const;
80 SIP_IF_FEATURE( !HAVE_QSCI_SIP )
81
82
86 QWidget *codeEditorWidget() const;
88#else
89
94 QgsCodeEditor *codeEditorWidget() const { return mTxtSql; }
95#endif
96
101 static bool saveQueryToFile( const QString &subset );
102
107 static bool loadQueryFromFile( QString &subset );
108
109 public slots:
110 void accept() override;
111 void reject() override;
112 void clear();
113
121 virtual void test();
122
127 void saveQuery();
128
133 void loadQuery();
134
135 void setDatasourceDescription( const QString &uri );
136
137 private slots:
138 void btnEqual_clicked();
139 void btnLessThan_clicked();
140 void btnGreaterThan_clicked();
141 void btnPct_clicked();
142 void btnIn_clicked();
143 void btnNotIn_clicked();
144 void btnLike_clicked();
145 void btnILike_clicked();
146 void lstFields_clicked( const QModelIndex &index );
147 void lstFields_doubleClicked( const QModelIndex &index );
148 void lstValues_doubleClicked( const QModelIndex &index );
149 void btnLessEqual_clicked();
150 void btnGreaterEqual_clicked();
151 void btnNotEqual_clicked();
152 void btnAnd_clicked();
153 void btnNot_clicked();
154 void btnOr_clicked();
155 void onTextChanged( const QString &text );
156 void layerSubsetStringChanged();
157
162 void btnGetAllValues_clicked();
163
169 void btnSampleValues_clicked();
170
171 private:
172
173 void showHelp();
174
178 void setupGuiViews();
179 void fillValues( const QString &field, int limit );
180
181 // private members
183 QgsFieldProxyModel *mModelFields = nullptr;
185 QStandardItemModel *mModelValues = nullptr;
187 QSortFilterProxyModel *mProxyValues = nullptr;
189 int mPreviousFieldRow;
190
192 QgsVectorLayer *mLayer = nullptr;
193
195 QString mOrigSubsetString;
196
198 bool mIgnoreLayerSubsetStringChangedSignal = false;
199
200 friend class TestQgsQueryBuilder;
201};
202#endif //QGSQUERYBUILDER_H
A text editor based on QScintilla2.
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer.
Query Builder for layers.
QString subsetString() const override
Returns the subset string entered in the dialog.
void setSubsetString(const QString &subsetString) override
Sets a subset string into the dialog.
QgsCodeEditor * codeEditorWidget() const
Returns the code editor widget for the SQL.
Interface for a dialog that can edit subset strings.
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_IF_FEATURE(feature)
Definition qgis_sip.h:181
#define SIP_END
Definition qgis_sip.h:208