QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 "qgshelp.h"
27 #include "qgis_gui.h"
28 
29 class QgsVectorLayer;
30 
43 class GUI_EXPORT QgsQueryBuilder : public QDialog, private Ui::QgsQueryBuilderBase
44 {
45  Q_OBJECT
46  public:
47 
55  QgsQueryBuilder( QgsVectorLayer *layer, QWidget *parent SIP_TRANSFERTHIS = nullptr,
56  Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
57 
58  ~QgsQueryBuilder() override;
59 
60  void showEvent( QShowEvent *event ) override;
61 
62  QString sql();
63  void setSql( const QString &sqlStatement );
64 
65  public slots:
66  void accept() override;
67  void reject() override;
68  void clear();
69 
76  void test();
77 
78  void setDatasourceDescription( const QString &uri );
79 
80  private slots:
81  void btnEqual_clicked();
82  void btnLessThan_clicked();
83  void btnGreaterThan_clicked();
84  void btnPct_clicked();
85  void btnIn_clicked();
86  void btnNotIn_clicked();
87  void btnLike_clicked();
88  void btnILike_clicked();
89  void lstFields_clicked( const QModelIndex &index );
90  void lstFields_doubleClicked( const QModelIndex &index );
91  void lstValues_doubleClicked( const QModelIndex &index );
92  void btnLessEqual_clicked();
93  void btnGreaterEqual_clicked();
94  void btnNotEqual_clicked();
95  void btnAnd_clicked();
96  void btnNot_clicked();
97  void btnOr_clicked();
98  void onTextChanged( const QString &text );
99 
104  void btnGetAllValues_clicked();
105 
111  void btnSampleValues_clicked();
112 
113  private:
114 
118  void populateFields();
119 
120  void showHelp();
121 
125  void setupGuiViews();
126  void setupLstFieldsModel();
127  void fillValues( int idx, int limit );
128 
129  // private members
131  QStandardItemModel *mModelFields = nullptr;
133  QStandardItemModel *mModelValues = nullptr;
135  QSortFilterProxyModel *mProxyValues = nullptr;
137  int mPreviousFieldRow;
138 
140  QgsVectorLayer *mLayer = nullptr;
141 
143  QString mOrigSubsetString;
144 };
145 #endif //QGSQUERYBUILDER_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Query Builder for layers.
Represents a vector layer which manages a vector based data sets.