Loading...
Searching...
No Matches
DataSetTableView.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 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// TerraLib
31#include "../../../core/encoding/CharEncoding.h"
32#include "../Config.h"
33
34// Qt
35#include <QTableView>
36
37// STL
38#include <memory>
39
40// Forward declaration
41class TablePopupFilter;
42
43namespace te
44{
45 // Forward declarations
46
47 namespace da
48 {
49 class DataSet;
50 class DataSetType;
51 class DataSourceTransactor;
52 class ObjectIdSet;
53 class DataSourceCapabilities;
54 }
55
56 namespace gm
57 {
58 class Envelope;
59 }
60
61 namespace map
62 {
63 class AbstractLayer;
64 }
65
66 namespace qt
67 {
68 namespace widgets
69 {
70 // Forward declaration
71 class DataSetTableModel;
72 class HighlightDelegate;
73 class ChartDisplayWidget;
74
75 /*!
76 \class DataSetTableView
77
78 \brief A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as its model.
79
80 \note We assume that the layer can return ALWAYS return a te::da::DataSet object with random access of it's values.
81
82 \ingroup widgets
83 */
84 class TEQTWIDGETSEXPORT DataSetTableView : public QTableView
85 {
86 Q_OBJECT
87
88 public:
89 /*!
90 \brief Constructor.
91
92 \param parent Qt widget parent.
93 */
94 DataSetTableView(QWidget* parent=0);
95
96 /*!
97 \brief Virtual destructor.
98 */
100
101 /*!
102 \brief Sets the drag drop on the horizontal header.
103 When the drag drop is enabled, you lose the ability to swap columns
104
105 \param b True: does the drag drop. False: do not drag drop.
106 */
107 void setDragDrop(bool b);
108
109 /*!
110 \brief Gets the drag drop flag.
111
112 \return True: is drag drop. False: not is drag drop.
113 */
115
116 /*!
117 \brief Sets the drop on the horizontal header.
118
119 \param b True: accept drop. False: do not accept drop.
120 */
121 void setAcceptDrop(bool b);
122
123 /*!
124 \brief Gets accept drop flag.
125
126 \return True: accept drop. False: not accept drop.
127 */
129
130 /*!
131 \brief Sets the layer to be presented.
132
133 \param layer Pointer to the layer to be presented.
134
135 \param clearEditor True for reset editions, false to maintain it.
136
137 \param editable True to allow layer editions.
138 */
139 void setLayer(te::map::AbstractLayer* layer, const bool& clearEditor = true, const bool& editable = true);
140
141 /*!
142 \brief Gets selected layer.
143
144 \return The selecte layer.
145 */
147
148 /*!
149 \brief Updates the data set being visualized.
150
151 Note that this DataSet MUST HAVE random access. The view DOES TAKE the ownership of the pointer.
152
153 \param dset The new data set to be visualized.
154
155 \param clearEditor True for reset editions, false to maintain it.
156 */
157 void setDataSet(te::da::DataSet* dset, const bool& clearEditor = true);
158
159 /*!
160 \brief Sets the schema of the data set. It is used to define the primary keys and create the ObjectIdSet.
161
162 \param schema The DataSetType to extract keys.
163 */
164 virtual void setLayerSchema(const te::da::DataSetType* schema);
165
166
167 /*!
168 \brief Highlights the objects identified by \a oids
169
170 \param oids The identifiers of rows to be highlighted.
171 */
173
174 /*!
175 \brief Update the color to be used.
176
177 \param color The new color;
178 */
179 void setHighlightColor(const QColor& color);
180
181 /*!
182 \brief Returns \a true if there are unsaved editions e \a false if there is not.
183 */
184 bool hasEditions() const;
185
186 public slots:
187
188 /*!
189 \name Table slot methods.
190
191 \brief Methods to handle user interaction with table.
192 */
193
194 //@{
195
196 /*!
197 \brief Creates a new histogram based on the data at position \a column
198
199 \param column Column that provides the data for the histogram.
200 */
201 void createHistogram(const int& column);
202
203 /*!
204 \brief Creates a new chart that displays the normal distribution based on the data at position \a column
205
206 \param column Column that provides the data used to calculate the normal distribution.
207 */
208 void createNormalDistribution(const int& column);
209
210 /*!
211 \brief Hides the column at position \a column
212
213 \param column Column to be hidden.
214 */
215 void hideColumn(const int& column);
216
217 /*!
218 \brief Shows the hidden column.
219
220 \param column Column to be presented.
221 */
222 void showColumn(const int& column);
223
224 /*!
225 \brief Rename a column of the table.
226 \param column Index of the column to be renamed.
227 */
228 void renameColumn(const int& column);
229
230 /*!
231 \brief Changes teh type of a column in the table.
232 \param column Index of the column to be changed.
233 */
234 void retypeColumn(const int& column);
235
236 /*!
237 \brief Shows the change column data dialog.
238 \param column Index of the column to be updated.
239 */
240 void changeColumnData(const int& column);
241
242 /*!
243 \brief Shows all hidden columns.
244 */
246
247 /*!
248 \brief Shows columns in the original order.
249 */
251
252 /*!
253 \brief Used to highlight the data when the mouse is clicked over a row in the table.
254
255 \param row Row to be highlighted.
256
257 \param add True to add to selection, false to new selection.
258 */
259 void highlightRow(const int& row, const bool& add);
260
261 /*!
262 \brief Select all rows from \a initRow to \a finalRow.
263
264 \param initRow the begin row.
265
266 \param finalRow the final row.
267
268 \note It does not matter if \a initRow is less than \a finalRow.
269 */
270 void highlightRows(const int& initRow, const int& finalRow);
271
272 /*!
273 \brief Promotes the highlighted rows.
274
275 The rows highlighted are presented in the begining of the table.
276
277 \param If \a true, scrolls to the top of the table.
278 */
279 void promote(const bool& scroll=false);
280
281 /*!
282 \brief Sort by the selected columns.
283
284 \param asc True for ascendent order, false for descendent.
285
286 \param col Index of the column to used by sorting.
287 */
288 void sortByColumns(const bool& asc, const int& col);
289
290 //@}
291
292 /*!
293 \brief Shows or hides the icon sinalizing the columns that identify each row.
294
295 \param visible True for icon visible, false otherwise.
296 */
297 void setOIdsColumnsVisible(const bool& visible);
298
299 /*!
300 \brief Add column to the table.
301 */
302 void addColumn();
303
304 /*
305 \brief Removes a column from the table.
306
307 \param column Position of the column to be removed.
308 */
309 void removeColumn(const int& column);
310
311 /*
312 \brief Enable or disable auto pan.
313
314 \param enable Define auto pan status.
315 */
316 void setAutoPanEnabled(const bool& enable);
317
318 /*!
319 \brief Enable / disable auto-scroll.
320
321 \param enable True for enable auto-scroll, false for disable it.
322 */
323 void setAutoScrollEnabled(const bool& enable);
324
325 /*!
326 \brief Enable / disable promotion.
327
328 If enabled all selected rows will be moved to te top of the table.
329
330 \param enable \a True to enable promotion, \a false to disable it
331 */
332 void setPromotionEnabled(const bool& enable);
333
334 /*!
335 \brief Saves all editions to the dataset.
336 */
338
339 signals:
340
341 /*!
342 \brief Emmite when objects was selected.
343 */
345
347
349
350 void enableAutoPan(const bool&);
351
352 protected:
353
354 void removeSelection(const int& initRow, const int& finalRow);
355
356 DataSetTableModel* m_model; //!< The model to be used.
357 TablePopupFilter* m_popupFilter; //!< The menus popup filter.
358 HighlightDelegate* m_delegate; //!< Delegate used for rendering selected rows.
359 te::map::AbstractLayer* m_layer; //!< Pointer to the layer being presented.
360 std::unique_ptr<te::da::DataSourceTransactor> m_transactor; //!< Pointer to the transactor, to keep data while table is open.
361 bool m_autoPanEnabled; //!< Auto pan enabling.
362 bool m_autoScrollEnabled; //!< Auto scroll enabling.
363 bool m_doScroll; //!< Flag to force or not scrolling.
364 bool m_promotionEnabled; //!< Promotion enabled.
365 te::da::DataSet* m_dset; //!< Data set being used.
366 std::vector<std::string> m_orderby; //!< Order by columns.
367 bool m_orderAsc; //!< Flag that sinalizes if the it is sorted in ascending sorting.
368 bool m_resetOrder; //!< Flag that sinalizes if there's is no sort.
369 };
370 }
371 }
372}
373
374#endif //__TERRALIB_QT_WIDGETS_INTERNAL_DATASETTABLEVIEW_H
A class that models the description of a dataset.
Definition: DataSetType.h:73
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
This class represents a set of unique ids created in the same context. i.e. from the same data set.
Definition: ObjectIdSet.h:56
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
This is the base class for layers.
Definition: AbstractLayer.h:78
A wdiget used to display a chart.
A table model representing a te::da::DataSet.
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...
void setAutoScrollEnabled(const bool &enable)
Enable / disable auto-scroll.
void showAllColumns()
Shows all hidden columns.
void enableAutoPan(const bool &)
bool m_promotionEnabled
Promotion enabled.
TablePopupFilter * m_popupFilter
The menus popup filter.
void deselectOIds(te::da::ObjectIdSet *)
te::map::AbstractLayer * m_layer
Pointer to the layer being presented.
void removeSelection(const int &initRow, const int &finalRow)
void selectOIds(te::da::ObjectIdSet *, const bool &, te::gm::Envelope *)
Emmite when objects was selected.
bool getDragDrop()
Gets the drag drop flag.
bool hasEditions() const
Returns true if there are unsaved editions e false if there is not.
std::vector< std::string > m_orderby
Order by columns.
void setOIdsColumnsVisible(const bool &visible)
Shows or hides the icon sinalizing the columns that identify each row.
te::map::AbstractLayer * getLayer()
Gets selected layer.
void setAcceptDrop(bool b)
Sets the drop on the horizontal header.
void setLayer(te::map::AbstractLayer *layer, const bool &clearEditor=true, const bool &editable=true)
Sets the layer to be presented.
void highlightRow(const int &row, const bool &add)
Used to highlight the data when the mouse is clicked over a row in the table.
void createNormalDistribution(const int &column)
Creates a new chart that displays the normal distribution based on the data at position column.
void highlightRows(const int &initRow, const int &finalRow)
Select all rows from initRow to finalRow.
virtual ~DataSetTableView()
Virtual destructor.
void setPromotionEnabled(const bool &enable)
Enable / disable promotion.
void renameColumn(const int &column)
Rename a column of the table.
virtual void setLayerSchema(const te::da::DataSetType *schema)
Sets the schema of the data set. It is used to define the primary keys and create the ObjectIdSet.
void resetColumnsOrder()
Shows columns in the original order.
te::da::DataSet * m_dset
Data set being used.
void promote(const bool &scroll=false)
Promotes the highlighted rows.
std::unique_ptr< te::da::DataSourceTransactor > m_transactor
Pointer to the transactor, to keep data while table is open.
void createHistogram(const int &column)
Creates a new histogram based on the data at position column.
void changeColumnData(const int &column)
Shows the change column data dialog.
DataSetTableView(QWidget *parent=0)
Constructor.
bool m_resetOrder
Flag that sinalizes if there's is no sort.
bool m_doScroll
Flag to force or not scrolling.
void retypeColumn(const int &column)
Changes teh type of a column in the table.
void hideColumn(const int &column)
Hides the column at position column.
bool m_autoScrollEnabled
Auto scroll enabling.
bool m_autoPanEnabled
Auto pan enabling.
void addColumn()
Add column to the table.
void setAutoPanEnabled(const bool &enable)
void highlightOIds(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.
void saveEditions()
Saves all editions to the dataset.
void sortByColumns(const bool &asc, const int &col)
Sort by the selected columns.
DataSetTableModel * m_model
The model to be used.
bool getAcceptDrop()
Gets accept drop flag.
void setHighlightColor(const QColor &color)
Update the color to be used.
HighlightDelegate * m_delegate
Delegate used for rendering selected rows.
void createChartDisplay(te::qt::widgets::ChartDisplayWidget *)
void showColumn(const int &column)
Shows the hidden column.
void removeColumn(const int &column)
void setDragDrop(bool b)
Sets the drag drop on the horizontal header. When the drag drop is enabled, you lose the ability to s...
void setDataSet(te::da::DataSet *dset, const bool &clearEditor=true)
Updates the data set being visualized.
bool m_orderAsc
Flag that sinalizes if the it is sorted in ascending sorting.
An specialization of QItemDelegate to be used with te::map::AbstractTable objects.
TerraLib.
#define slots
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63