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  Ui::WhereClauseWidgetForm* getForm() const;
110 
111  te::da::Where* getWhere();
112 
113  std::string getWhereString();
114 
115 
116  public:
117 
118  void setDataSource(const te::da::DataSourcePtr& ds);
119 
120  void setLayerList(std::list<te::map::AbstractLayerPtr>& layerList);
121 
122  void setFromItems(std::vector<std::pair<std::string, std::string> > vec);
123 
124  void setAttributeList(const std::vector<std::string>& vec);
125 
126  void setGeomAttributeList(const std::vector<std::string>& vec, int srid);
127 
128  void setOperatorsList(const std::vector<std::string>& vec);
129 
130  void setSpatialOperatorsList(const std::vector<std::string>& vec);
131 
132  void setConnectorsList(const std::vector<std::string>& vec);
133 
134  void setCriteriaTabEnabled(int index, bool enable);
135 
136  void clear();
137 
138  void resetInterface();
139 
140  public slots:
141 
142  void onAddWhereClausePushButtonClicked();
143 
144  void onRemoveWhereClausePushButtonClicked();
145 
146  void onValuePropertyRadioButtonClicked();
147 
148  void onClearAllPushButtonClicked();
149 
150  void onRestrictValueComboBoxActivated(QString value);
151 
152  void onComboBoxActivated(QString value);
153 
154  protected:
155 
156  te::da::Expression* getExpression(const QString& value, const std::string& propName);
157 
158  void copyCombo(QComboBox* input, QComboBox* output, std::string curValue = "");
159 
160  QStringList getPropertyValues(std::string propertyName);
161 
162 
163  private:
164 
165  std::auto_ptr<Ui::WhereClauseWidgetForm> m_ui;
166 
168 
169  std::vector<std::pair<std::string, std::string> > m_fromItems;
170 
171  std::map<int, ExpressionProperty*> m_mapExp;
172 
173  std::map< QComboBox*, std::pair<int, int> > m_comboMap;
174 
175  QStringList m_connectorsList;
176 
177  int m_count;
178  int m_srid;
179  };
180 
181  } // end namespace widgets
182  } // end namespace qt
183 } // end namespace te
184 
185 #endif // __TERRALIB_QT_WIDGETS_QUERY_INTERNAL_WHERECLAUSEWIDGET_H
std::auto_ptr< Ui::WhereClauseWidgetForm > m_ui
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
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