QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 
75  void setDatasourceDescription( const QString &uri );
76 
77  private slots:
78  void btnEqual_clicked();
79  void btnLessThan_clicked();
80  void btnGreaterThan_clicked();
81  void btnPct_clicked();
82  void btnIn_clicked();
83  void btnNotIn_clicked();
84  void btnLike_clicked();
85  void btnILike_clicked();
86  void lstFields_clicked( const QModelIndex &index );
87  void lstFields_doubleClicked( const QModelIndex &index );
88  void lstValues_doubleClicked( const QModelIndex &index );
89  void btnLessEqual_clicked();
90  void btnGreaterEqual_clicked();
91  void btnNotEqual_clicked();
92  void btnAnd_clicked();
93  void btnNot_clicked();
94  void btnOr_clicked();
95  void onTextChanged( const QString &text );
96 
101  void btnGetAllValues_clicked();
102 
108  void btnSampleValues_clicked();
109 
110  private:
111 
115  void populateFields();
116 
117  void showHelp();
118 
122  void setupGuiViews();
123  void setupLstFieldsModel();
124  void fillValues( int idx, int limit );
125 
126  // private members
128  QStandardItemModel *mModelFields = nullptr;
130  QStandardItemModel *mModelValues = nullptr;
132  QSortFilterProxyModel *mProxyValues = nullptr;
134  int mPreviousFieldRow;
135 
137  QgsVectorLayer *mLayer = nullptr;
138 
140  QString mOrigSubsetString;
141 };
142 #endif //QGSQUERYBUILDER_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Query Builder for layers.
Represents a vector layer which manages a vector based data sets.