All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataSetTableView.h
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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 DataSetTableView.h
22 
23  \brief A table view for a dataset.
24 */
25 
26 
27 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_DATASETTABLEVIEW_H
28 #define __TERRALIB_QT_WIDGETS_INTERNAL_DATASETTABLEVIEW_H
29 
30 #include "../Config.h"
31 
32 // Qt
33 #include <QtGui/QTableView>
34 
35 // Forward declaration
36 class TablePopupFilter;
37 
38 namespace te
39 {
40  // Forward declarations
41  namespace da
42  {
43  class DataSet;
44  class DataSetType;
45  class ObjectIdSet;
46  class DataSourceCapabilities;
47  }
48 
49  namespace map
50  {
51  class AbstractLayer;
52  }
53 
54  namespace qt
55  {
56  namespace widgets
57  {
58  // Forward declaration
59  class DataSetTableModel;
60  class HighlightDelegate;
61 
62  /*!
63  \class DataSetTableView
64 
65  \brief A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as its model.
66 
67  \note We assume that the layer can return ALWAYS return a te::da::DataSet object with random access of it's values.
68 
69  \ingroup widgets
70  */
71  class TEQTWIDGETSEXPORT DataSetTableView : public QTableView
72  {
73  Q_OBJECT
74 
75  public:
76  /*!
77  \brief Constructor.
78 
79  \param parent Qt widget parent.
80  */
81  DataSetTableView(QWidget* parent=0);
82 
83  /*!
84  \brief Virtual destructor.
85  */
86  virtual ~DataSetTableView();
87 
88  /*!
89  \brief Sets the layer to be presented.
90 
91  \param layer Pointer to the layer to be presented.
92  */
93  void setLayer(const te::map::AbstractLayer* layer);
94 
95  /*!
96  \brief Updates the data set being visualized.
97 
98  Note that this DataSet MUST HAVE random access. The view DOES TAKE the ownership of the pointer.
99 
100  \param dset The new data set to be visualized.
101  */
102  void setDataSet(te::da::DataSet* dset);
103 
104  /*!
105  \brief Sets the schema of the data set. It is used to define the primary keys and create the ObjectIdSet.
106 
107  \param schema The DataSetType to extract keys.
108  */
109  virtual void setLayerSchema(const te::da::DataSetType* schema);
110 
111 
112  /*!
113  \brief Highlights the objects identified by \a oids
114 
115  \param oids The identifiers of rows to be highlighted.
116  */
117  void highlightOIds(const te::da::ObjectIdSet* oids);
118 
119  public slots:
120 
121  /*!
122  \name Table slot methods.
123 
124  \brief Methods to handle user interaction with table.
125  */
126 
127  //@{
128  /*!
129  \brief Hides the column at position \a column
130 
131  \param column Column to be hidden.
132  */
133  void hideColumn(const int& column);
134 
135  /*!
136  \brief Shows the hidden column.
137 
138  \param column Column to be presented.
139  */
140  void showColumn(const int& column);
141 
142  /*!
143  \brief Shows all hidden columns.
144  */
145  void showAllColumns();
146 
147  /*!
148  \brief Shows columns in the original order.
149  */
150  void resetColumnsOrder();
151 
152  /*!
153  \brief Used to highlight the data when the mouse is clicked over a row in the table.
154 
155  \param row Row to be highlighted.
156 
157  \param add True to add to selection, false to new selection.
158  */
159  void highlightRow(const int& row, const bool& add);
160 
161  /*!
162  \brief Select all rows from \a initRow to \a finalRow.
163 
164  \param initRow the begin row.
165 
166  \param finalRow the final row.
167 
168  \note It does not matter if \a initRow is less than \a finalRow.
169  */
170  void highlightRows(const int& initRow, const int& finalRow);
171 
172  /*!
173  \brief Promotes the highlighted rows.
174 
175  The rows highlighted are presented in the begining of the table.
176  */
177  void promote();
178 
179  /*!
180  \brief Sort by the selected columns.
181  */
182 // void sortByColumns();
183 
184  /*!
185  \brief Sort by the selected columns.
186 
187  \param asc True for ascendent order, false for descendent.
188  */
189  void sortByColumns(const bool& asc);
190 
191  //@}
192 
193  /*!
194  \brief Shows or hides the icon sinalizing the columns that identify each row.
195 
196  \param visible True for icon visible, false otherwise.
197  */
198  void setOIdsColumnsVisible(const bool& visible);
199 
200  /*!
201  \brief Add column to the table.
202  */
203  void addColumn();
204 
205  /*
206  \brief Removes a column from the table.
207 
208  \param column Position of the column to be removed.
209  */
210  void removeColumn(const int& column);
211 
212  /*!
213  \brief Enable / disable auto-scroll.
214 
215  \param enable True for enable auto-scroll, false for disable it.
216  */
217  void setAutoScrollEnabled(const bool& enable);
218 
219  signals:
220 
221  /*!
222  \brief Emmite when objects was selected.
223  */
224  void selectOIds(te::da::ObjectIdSet*, const bool&);
225 
226  void deselectOIds(te::da::ObjectIdSet*);
227 
228  protected:
229 
230  void removeSelection(const int& initRow, const int& finalRow);
231 
232  DataSetTableModel* m_model; //!< The model to be used.
233  TablePopupFilter* m_popupFilter; //!< The menus popup filter.
234  HighlightDelegate* m_delegate; //!< Delegate used for rendering selected rows.
235  const te::map::AbstractLayer* m_layer; //!< Pointer to the layer being presented.
236  bool m_autoScrollEnabled; //! Auto scroll enabling.
237  bool m_isSorted; //! Previously sorted.
238  bool m_isPromoted; //! Previously promoted.
239  te::da::DataSet* m_dset; //! Data set being used.
240  };
241  }
242  }
243 }
244 
245 #endif //__TERRALIB_QT_WIDGETS_INTERNAL_DATASETTABLEVIEW_H
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:101
te::da::DataSet * m_dset
Previously promoted.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:53
DataSetTableModel * m_model
The model to be used.
This is the base class for layers.
Definition: AbstractLayer.h:76
A table model representing a te::da::DataSet.
const te::map::AbstractLayer * m_layer
Pointer to the layer being presented.
bool m_isPromoted
Previously sorted.
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...
A class that models the description of a dataset.
Definition: DataSetType.h:72
An specialization of QItemDelegate to be used with te::map::AbstractTable objects.
TablePopupFilter * m_popupFilter
The menus popup filter.
bool m_isSorted
Auto scroll enabling.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:111
HighlightDelegate * m_delegate
Delegate used for rendering selected rows.