QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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"
27 
28 class QgsVectorLayer;
29 
42 class GUI_EXPORT QgsQueryBuilder : public QDialog, private Ui::QgsQueryBuilderBase
43 {
44  Q_OBJECT
45  public:
46 
54  QgsQueryBuilder( QgsVectorLayer *layer, QWidget *parent SIP_TRANSFERTHIS = nullptr,
55  Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
56 
57  void showEvent( QShowEvent *event ) override;
58 
59  QString sql();
60  void setSql( const QString &sqlStatement );
61 
62  public slots:
63  void accept() override;
64  void reject() override;
65  void clear();
66 
73  void test();
74 
79  void saveQuery();
80 
85  void loadQuery();
86 
87  void setDatasourceDescription( const QString &uri );
88 
89  private slots:
90  void btnEqual_clicked();
91  void btnLessThan_clicked();
92  void btnGreaterThan_clicked();
93  void btnPct_clicked();
94  void btnIn_clicked();
95  void btnNotIn_clicked();
96  void btnLike_clicked();
97  void btnILike_clicked();
98  void lstFields_clicked( const QModelIndex &index );
99  void lstFields_doubleClicked( const QModelIndex &index );
100  void lstValues_doubleClicked( const QModelIndex &index );
101  void btnLessEqual_clicked();
102  void btnGreaterEqual_clicked();
103  void btnNotEqual_clicked();
104  void btnAnd_clicked();
105  void btnNot_clicked();
106  void btnOr_clicked();
107  void onTextChanged( const QString &text );
108 
113  void btnGetAllValues_clicked();
114 
120  void btnSampleValues_clicked();
121 
122  private:
123 
127  void populateFields();
128 
129  void showHelp();
130 
134  void setupGuiViews();
135  void setupLstFieldsModel();
136  void fillValues( int idx, int limit );
137 
138  // private members
140  QStandardItemModel *mModelFields = nullptr;
142  QStandardItemModel *mModelValues = nullptr;
144  QSortFilterProxyModel *mProxyValues = nullptr;
146  int mPreviousFieldRow;
147 
149  QgsVectorLayer *mLayer = nullptr;
150 
152  QString mOrigSubsetString;
153 };
154 #endif //QGSQUERYBUILDER_H
qgis_sip.h
QgsQueryBuilder
Query Builder for layers.
Definition: qgsquerybuilder.h:43
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
qgsguiutils.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53