WhereClauseWidget.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/WhereClauseWidget.h
22 
23  \brief This file has the DataSetWidget class.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_QUERY_INTERNAL_WHERECLAUSEWIDGET_H
27 #define __TERRALIB_QT_WIDGETS_QUERY_INTERNAL_WHERECLAUSEWIDGET_H
28 
29 // TerraLib
30 #include "../Config.h"
31 #ifndef Q_MOC_RUN
32 #include "../../../dataaccess/datasource/DataSource.h"
33 #include "../../../dataaccess/query/Expression.h"
34 #include "../../../dataaccess/query/Where.h"
35 #include "../../../maptools/AbstractLayer.h"
36 #endif
37 
38 // STL
39 #include <memory>
40 #include <map>
41 #include <set>
42 
43 // Qt
44 #include <QComboBox>
45 #include <QWidget>
46 
47 
48 namespace Ui { class WhereClauseWidgetForm; }
49 
50 namespace te
51 {
52  namespace qt
53  {
54  namespace widgets
55  {
57  {
58  /*! \brief Default constructor. */
60  {
61  m_isAttributeCriteria = false;
62  m_isSpatialCriteria = false;
63  m_isPropertyValue = false;
64  m_isValueValue = false;
65 
66  m_property = "";
67  m_operator = "";
68  m_value = "";
69 
70  m_expression = 0;
71  m_valuesComboBox = 0;
72  }
73 
75  {
76  delete m_expression;
77  }
78 
81 
84 
85  std::string m_property;
86  std::string m_operator;
87  std::string m_value;
88 
90 
91  QComboBox* m_valuesComboBox;
92  };
93 
94  /*!
95  \class WhereClauseWidget
96 
97  \brief This class is used to define the WHERE object of select operation.
98  */
99  class TEQTWIDGETSEXPORT WhereClauseWidget : public QWidget
100  {
101  Q_OBJECT
102 
103  public:
104 
105  WhereClauseWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
106 
108 
109  te::da::Where* getWhere();
110 
111  std::string getWhereString();
112 
113  public:
114 
115  void addLayer(te::map::AbstractLayerPtr layer);
116 
117  void removeLayer(te::map::AbstractLayerPtr layer);
118 
119  void setDataSource(const te::da::DataSourcePtr& ds);
120 
121  void setLayerList(std::list<te::map::AbstractLayerPtr>& layerList);
122 
123  void setFromItems(std::vector<std::pair<std::string, std::string> > vec);
124 
125  void setAttributeList(const std::vector<std::string>& vec);
126 
127  void setGeomAttributeList(const std::vector<std::string>& vec, int srid);
128 
129  void setOperatorsList(const std::vector<std::string>& vec);
130 
131  void setSpatialOperatorsList(const std::vector<std::string>& vec);
132 
133  void setConnectorsList(const std::vector<std::string>& vec);
134 
135  void setCriteriaTabEnabled(int index, bool enable);
136 
137  void clear();
138 
139  void resetInterface();
140 
141  public slots:
142 
143  void onAddWhereClausePushButtonClicked();
144 
145  void onRemoveWhereClausePushButtonClicked();
146 
147  void onValuePropertyRadioButtonClicked();
148 
149  void onClearAllPushButtonClicked();
150 
151  void onRestrictValueComboBoxActivated(QString value);
152 
153  void onComboBoxActivated(QString value);
154 
155  protected:
156 
157  te::da::Expression* getExpression(const QString& value, const std::string& propName);
158 
159  void copyCombo(QComboBox* input, QComboBox* output, std::string curValue = "");
160 
161  QStringList getPropertyValues(std::string propertyName);
162 
163 
164  private:
165 
166  std::auto_ptr<Ui::WhereClauseWidgetForm> m_ui;
167 
169 
170  std::vector<std::pair<std::string, std::string> > m_fromItems;
171 
172  std::map<int, ExpressionProperty*> m_mapExp;
173 
174  std::map< QComboBox*, std::pair<int, int> > m_comboMap;
175 
176  QStringList m_connectorsList;
177 
178  int m_count;
179  int m_srid;
180  };
181 
182  } // end namespace widgets
183  } // end namespace qt
184 } // end namespace te
185 
186 #endif // __TERRALIB_QT_WIDGETS_QUERY_INTERNAL_WHERECLAUSEWIDGET_H
std::auto_ptr< Ui::WhereClauseWidgetForm > m_ui
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1438
ExpressionProperty()
Default constructor.
std::vector< std::pair< std::string, std::string > > m_fromItems
This is an abstract class that models a query expression.
Definition: Expression.h:47
URI C++ Library.
A class that can be used to model a filter expression that can be applied to a query.
Definition: Where.h:47
std::map< QComboBox *, std::pair< int, int > > m_comboMap
This class is used to define the WHERE object of select operation.
std::map< int, ExpressionProperty * > m_mapExp
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr