QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
56 QgsQueryBuilder( QgsVectorLayer *layer, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
57
58 void showEvent( QShowEvent *event ) override;
59
61 QString sql() const;
62
64 void setSql( const QString &sqlStatement );
65
66 QString subsetString() const override { return sql(); }
67 void setSubsetString( const QString &subsetString ) override { setSql( subsetString ); }
68
69#ifdef SIP_RUN
70 SIP_IF_FEATURE( HAVE_QSCI_SIP )
71
72
76 QgsCodeEditor *codeEditorWidget() const;
78 SIP_IF_FEATURE( !HAVE_QSCI_SIP )
79
80
84 QWidget *codeEditorWidget() const;
86#else
87
92 QgsCodeEditor *codeEditorWidget() const { return mTxtSql; }
93#endif
94
99 static bool saveQueryToFile( const QString &subset );
100
105 static bool loadQueryFromFile( QString &subset );
106
107 public slots:
108 void accept() override;
109 void reject() override;
110 void clear();
111
119 virtual void test();
120
125 void saveQuery();
126
131 void loadQuery();
132
133 void setDatasourceDescription( const QString &uri );
134
135 private slots:
136 void btnEqual_clicked();
137 void btnLessThan_clicked();
138 void btnGreaterThan_clicked();
139 void btnPct_clicked();
140 void btnIn_clicked();
141 void btnNotIn_clicked();
142 void btnLike_clicked();
143 void btnILike_clicked();
144 void lstFields_clicked( const QModelIndex &index );
145 void lstFields_doubleClicked( const QModelIndex &index );
146 void lstValues_doubleClicked( const QModelIndex &index );
147 void btnLessEqual_clicked();
148 void btnGreaterEqual_clicked();
149 void btnNotEqual_clicked();
150 void btnAnd_clicked();
151 void btnNot_clicked();
152 void btnOr_clicked();
153 void onTextChanged( const QString &text );
154 void layerSubsetStringChanged();
155
160 void btnGetAllValues_clicked();
161
167 void btnSampleValues_clicked();
168
169 private:
170 void showHelp();
171
175 void setupGuiViews();
176 void fillValues( const QString &field, int limit );
177
178 // private members
180 QgsFieldProxyModel *mModelFields = nullptr;
182 QStandardItemModel *mModelValues = nullptr;
184 QSortFilterProxyModel *mProxyValues = nullptr;
186 int mPreviousFieldRow;
187
189 QgsVectorLayer *mLayer = nullptr;
190
192 QString mOrigSubsetString;
193
195 bool mIgnoreLayerSubsetStringChangedSignal = false;
196
197 friend class TestQgsQueryBuilder;
198};
199#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