QueryBuilderWidget.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/query/QueryBuilderWidget.h
22 
23  \brief This file has the QueryBuilderWidget class.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_QUERY_INTERNAL_QUERYBUILDERWIDGET_H
27 #define __TERRALIB_QT_WIDGETS_QUERY_INTERNAL_QUERYBUILDERWIDGET_H
28 
29 // TerraLib
30 #ifndef Q_MOC_RUN
31 #include "../../../dataaccess/dataset/DataSetType.h"
32 #include "../../../dataaccess/datasource/DataSource.h"
33 #include "../../../dataaccess/query/Expression.h"
34 #include "../../../dataaccess/query/Where.h"
35 #include "../Config.h"
36 #endif
37 
38 // STL
39 #include <memory>
40 #include <map>
41 
42 // Qt
43 #include <QWidget>
44 #include <QTreeWidgetItem>
45 
46 
47 namespace Ui { class QueryBuilderWidgetForm; }
48 
49 namespace te
50 {
51  namespace qt
52  {
53  namespace widgets
54  {
55  class QueryBuilderTreeWidget;
56  class QueryConnectorWidget;
57  class QueryConditionWidget;
58 
59  /*!
60  \class QueryBuilderWidget
61 
62  \brief This class is used to define the Where Clause object of select operation.
63  */
64  class TEQTWIDGETSEXPORT QueryBuilderWidget : public QWidget
65  {
66  Q_OBJECT
67 
68  public:
69 
70  QueryBuilderWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
71 
73 
74  void setInputParameters(te::da::DataSourcePtr dataSource, std::string dataSetName, std::unique_ptr<te::da::DataSetType> dsType);
75 
76  void startWhereClause();
77 
78  void setWhereClause(te::da::Where* where);
79 
80  te::da::Where* getWhereClause();
81 
82  std::string getWhereString();
83 
84  protected:
85 
86  QWidget * createCondition(bool startCondition, QWidget* parent, bool right);
87 
88  QWidget* createConnector(bool startCondition, QWidget* owner, QWidget* parent, bool autoCreateCondition);
89 
90  void removeCondition(te::qt::widgets::QueryConditionWidget* condition);
91 
92  void removeConnector(te::qt::widgets::QueryConnectorWidget* connector);
93 
94  void rebuildTree(QTreeWidgetItem* item);
95 
96  void buildTree(te::da::Expression* exp, QWidget* parent, bool right);
97 
98  bool functionsIsAConnector(te::da::Function* func);
99 
100  bool functionsIsACondition(te::da::Function* func);
101 
102  protected slots:
103 
104  void onAddConnectorClicked(QWidget* owner, QWidget* parent);
105 
106  void onRemoveConnectorClicked(QWidget* owner, QWidget* parent);
107 
108  protected:
109 
110  std::unique_ptr<Ui::QueryBuilderWidgetForm> m_ui;
111 
113 
114  QWidget* m_starterWidget;
115 
117 
118  std::string m_dataSetName;
119 
120  std::unique_ptr<te::da::DataSetType> m_dsType;
121 
122  std::map<QTreeWidgetItem*, QWidget*> m_widgetMap;
123 
124  };
125 
126  } // end namespace widgets
127  } // end namespace qt
128 } // end namespace te
129 
130 #endif // __TERRALIB_QT_WIDGETS_QUERY_INTERNAL_QUERYBUILDERWIDGET_H
#define slots
std::unique_ptr< Ui::QueryBuilderWidgetForm > m_ui
std::map< QTreeWidgetItem *, QWidget * > m_widgetMap
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1449
std::unique_ptr< te::da::DataSetType > m_dsType
This class is used to define the Query Connector for a where clause.
This class is used to define the Query Builder Tree Widget.
This class is used to define the Where Clause object of select operation.
This is an abstract class that models a query expression.
Definition: Expression.h:47
TerraLib.
A class that can be used to model a filter expression that can be applied to a query.
Definition: Where.h:47
A class that models a Function expression.
Definition: Function.h:47
This class is used to define the Query Condition for a where clause.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
QueryBuilderTreeWidget * m_treeWidget