All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #include "../../../dataaccess/datasource/DataSource.h"
32 #include "../../../dataaccess/query/Expression.h"
33 #include "../../../dataaccess/query/Where.h"
34 #include "../../../maptools/AbstractLayer.h"
35 
36 // STL
37 #include <memory>
38 #include <map>
39 #include <set>
40 
41 // Qt
42 #include <QComboBox>
43 #include <QWidget>
44 
45 
46 namespace Ui { class WhereClauseWidgetForm; }
47 
48 namespace te
49 {
50  namespace qt
51  {
52  namespace widgets
53  {
55  {
56  /*! \brief Default constructor. */
58  {
59  m_isAttributeCriteria = false;
60  m_isSpatialCriteria = false;
61  m_isPropertyValue = false;
62  m_isValueValue = false;
63 
64  m_property = "";
65  m_operator = "";
66  m_value = "";
67 
68  m_expression = 0;
69  m_valuesComboBox = 0;
70  }
71 
73  {
74  delete m_expression;
75  }
76 
79 
82 
83  std::string m_property;
84  std::string m_operator;
85  std::string m_value;
86 
88 
89  QComboBox* m_valuesComboBox;
90  };
91 
92  /*!
93  \class WhereClauseWidget
94 
95  \brief This class is used to define the WHERE object of select operation.
96  */
97  class TEQTWIDGETSEXPORT WhereClauseWidget : public QWidget
98  {
99  Q_OBJECT
100 
101  public:
102 
103  WhereClauseWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
104 
106 
107  Ui::WhereClauseWidgetForm* getForm() const;
108 
109  te::da::Where* getWhere();
110 
111  std::string getWhereString();
112 
113 
114  public:
115 
116  void setDataSource(const te::da::DataSourcePtr& ds);
117 
118  void setLayerList(std::list<te::map::AbstractLayerPtr>& layerList);
119 
120  void setFromItems(std::vector<std::pair<std::string, std::string> > vec);
121 
122  void setAttributeList(const std::vector<std::string>& vec);
123 
124  void setGeomAttributeList(const std::vector<std::string>& vec, int srid);
125 
126  void setOperatorsList(const std::vector<std::string>& vec);
127 
128  void setSpatialOperatorsList(const std::vector<std::string>& vec);
129 
130  void setConnectorsList(const std::vector<std::string>& vec);
131 
132  void clear();
133 
134  void resetInterface();
135 
136 
137  public slots:
138 
139  void onAddWhereClausePushButtonClicked();
140 
141  void onRemoveWhereClausePushButtonClicked();
142 
143  void onValuePropertyRadioButtonClicked();
144 
145  void onClearAllPushButtonClicked();
146 
147  void onRestrictValueComboBoxActivated(QString value);
148 
149  void onComboBoxActivated(QString value);
150 
151  protected:
152 
153  te::da::Expression* getExpression(const QString& value, const std::string& propName);
154 
155  void copyCombo(QComboBox* input, QComboBox* output, std::string curValue = "");
156 
157  QStringList getPropertyValues(std::string propertyName);
158 
159 
160  private:
161 
162  std::auto_ptr<Ui::WhereClauseWidgetForm> m_ui;
163 
165 
166  std::vector<std::pair<std::string, std::string> > m_fromItems;
167 
168  std::map<int, ExpressionProperty*> m_mapExp;
169 
170  std::map< QComboBox*, std::pair<int, int> > m_comboMap;
171 
172  QStringList m_connectorsList;
173 
174  int m_count;
175  int m_srid;
176  };
177 
178  } // end namespace widgets
179  } // end namespace qt
180 } // end namespace te
181 
182 #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
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:66