QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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 "ui_qgsquerybuilderbase.h"
18
19#include <map>
20#include <vector>
21
22#include "qgis_gui.h"
23#include "qgis_sip.h"
24#include "qgsguiutils.h"
26
27#include <QModelIndex>
28#include <QSortFilterProxyModel>
29#include <QStandardItem>
30#include <QStandardItemModel>
31
32class QgsVectorLayer;
33class QgsCodeEditor;
35
48class GUI_EXPORT QgsQueryBuilder : public QgsSubsetStringEditorInterface, private Ui::QgsQueryBuilderBase
49{
50 Q_OBJECT
51 public:
59 QgsQueryBuilder( QgsVectorLayer *layer, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
60
61 void showEvent( QShowEvent *event ) override;
62
64 QString sql() const;
65
67 void setSql( const QString &sqlStatement );
68
69 QString subsetString() const override { return sql(); }
70 void setSubsetString( const QString &subsetString ) override { setSql( subsetString ); }
71
72#ifdef SIP_RUN
73 SIP_IF_FEATURE( HAVE_QSCI_SIP )
74
75
79 QgsCodeEditor *codeEditorWidget() const;
81
82 SIP_IF_FEATURE( !HAVE_QSCI_SIP )
83
84
88 QWidget *
89 codeEditorWidget() const;
91#else
92
97 QgsCodeEditor *codeEditorWidget() const { return mTxtSql; }
98#endif
99
104 static bool saveQueryToFile( const QString &subset );
105
110 static bool loadQueryFromFile( QString &subset );
111
112 public slots:
113 void accept() override;
114 void reject() override;
115 void clear();
116
124 virtual void test();
125
130 void saveQuery();
131
136 void loadQuery();
137
138 void setDatasourceDescription( const QString &uri );
139
140 private slots:
141 void btnEqual_clicked();
142 void btnLessThan_clicked();
143 void btnGreaterThan_clicked();
144 void btnPct_clicked();
145 void btnIn_clicked();
146 void btnNotIn_clicked();
147 void btnLike_clicked();
148 void btnILike_clicked();
149 void lstFields_clicked( const QModelIndex &index );
150 void lstFields_doubleClicked( const QModelIndex &index );
151 void lstValues_doubleClicked( const QModelIndex &index );
152 void btnLessEqual_clicked();
153 void btnGreaterEqual_clicked();
154 void btnNotEqual_clicked();
155 void btnAnd_clicked();
156 void btnNot_clicked();
157 void btnOr_clicked();
158 void onTextChanged( const QString &text );
159 void layerSubsetStringChanged();
160
165 void btnGetAllValues_clicked();
166
172 void btnSampleValues_clicked();
173
174 private:
175 void showHelp();
176
180 void setupGuiViews();
181 void fillValues( const QString &field, int limit );
182
183 // private members
185 QgsFieldProxyModel *mModelFields = nullptr;
187 QStandardItemModel *mModelValues = nullptr;
189 QSortFilterProxyModel *mProxyValues = nullptr;
191 int mPreviousFieldRow = -1;
192
194 QgsVectorLayer *mLayer = nullptr;
195
197 QString mOrigSubsetString;
198
200 bool mIgnoreLayerSubsetStringChangedSignal = false;
201
203};
204#endif //QGSQUERYBUILDER_H
A text editor based on QScintilla2.
A proxy model to filter the list of fields of a layer.
friend class TestQgsQueryBuilder
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.
void setSql(const QString &sqlStatement)
Set the sql statement to display in the dialog.
void showEvent(QShowEvent *event) override
QgsQueryBuilder(QgsVectorLayer *layer, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
This constructor is used when the query builder is called from the vector layer properties dialog.
QString sql() const
Returns the sql statement entered in the dialog.
QgsCodeEditor * codeEditorWidget() const
Returns the code editor widget for the SQL.
QgsSubsetStringEditorInterface(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
Constructor.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_IF_FEATURE(feature)
Definition qgis_sip.h:188
#define SIP_END
Definition qgis_sip.h:215