All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataSetTableModel.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 terralib/qt/widgets/table/DataSetTableModel.h
22 
23  \brief A model based on te::da::DataSet.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_TABLE_INTERNAL_DATASETTABLEMODEL_H
27 #define __TERRALIB_QT_WIDGETS_TABLE_INTERNAL_DATASETTABLEMODEL_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // Qt
33 #include <QtCore/QAbstractTableModel>
34 
35 // STL
36 #include <vector>
37 
38 namespace te
39 {
40  // Forward declarations
41  namespace da
42  {
43  class DataSet;
44  class ObjectId;
45  class ObjectIdSet;
46  }
47 
48  namespace qt
49  {
50  namespace widgets
51  {
52  // Forward declaration
53  class Promoter;
54 
55  /*!
56  \class DataSetTableModel
57 
58  \brief A table model representing a te::da::DataSet.
59 
60  \ingroup widgets
61  */
62  class TEQTWIDGETSEXPORT DataSetTableModel : public QAbstractTableModel
63  {
64  public:
65 
66  /*!
67  \brief Constructor.
68  */
69  DataSetTableModel(QObject* parent = 0);
70 
71  /*!
72  \brief Virtual destructor.
73  */
74  virtual ~DataSetTableModel();
75 
76  /*!
77  \brief Updates the data being used.
78 
79  \param dset The new data set to be used.
80 
81  \note This method DOES TAKE the ownership of \a dset.
82  */
83  void setDataSet(te::da::DataSet* dset);
84 
85  /*!
86  \brief Sets the columns used as pkeys, for presentation purposes.
87 
88  \param pkeys Positions of the columns that form the primary key.
89  */
90  void setPkeysColumns(const std::vector<size_t>& pkeys);
91 
92  /*!
93  \brief Promotes the rows identified by \a oids.
94 
95  \parama oids The identifiers of the rows to be promoted.
96  */
97  void promote(const te::da::ObjectIdSet* oids);
98 
99  /*!
100  \brief Returns the pointer to the promoter being used.
101 
102  \return Pointer of the promoter being used.
103 
104  \note The caller of this method DOES NOT take the ownership of the pointer.
105  */
106  Promoter* getPromoter();
107 
108  /*!
109  \brief Shows an icon for indentify the columns that are used for identify objects.
110  */
111  void showOIdsVisible(const bool& visible);
112 
113  /*!
114  \brief Returns the ObjectIdSet begining with row \a initRow and ending in \a finalRow.
115 
116  \param initRow Initial row.
117 
118  \param endRow Final row.
119 
120  \note The caller WILL TAKE the ownership of the ObjectIdSet returned.
121  */
122  te::da::ObjectIdSet* getObjectIdSet (const int& initRow, const int& finalRow);
123 
124  /*!
125  \brief Enable or disable the dataset presentation.
126 
127  \param enabled True for show dataSet on table, false to hide it.
128  */
129  void setEnabled(const bool& enabled);
130 
131  /*!
132  \name QAbstractTableModel re-implementation methods.
133 
134  \brief Re-implementation of QAbstractTableModel methods.
135  */
136  //@{
137 
138  int rowCount(const QModelIndex & parent) const;
139 
140  int columnCount(const QModelIndex & parent) const;
141 
142  QVariant data(const QModelIndex & index, int role) const;
143 
144  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
145 
146  Qt::ItemFlags flags(const QModelIndex & index) const;
147 
148  bool setData (const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
149 
150  bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex());
151 
152  bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex());
153  //@}
154 
155  protected:
156 
157  te::da::DataSet* m_dataset; //!< The dataset being used.
158 
159  mutable int m_currentRow; //!< An internal row pointer.
160 
161  std::vector<size_t> m_pkeysColumns; //!< Primary key columns.
162 
163  Promoter* m_promoter; //!< Promoter to be used.
164 
165  bool m_OIdsVisible; //!< Oids icon visibility.
166 
167  bool m_enabled;
168  };
169  }
170  }
171 }
172 
173 #endif //__TERRALIB_QT_WIDGETS_TABLE_INTERNAL_DATASETTABLEMODEL_H
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:101
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:53
A table model representing a te::da::DataSet.
Promoter * m_promoter
Promoter to be used.
te::da::DataSet * m_dataset
The dataset being used.
int m_currentRow
An internal row pointer.
std::vector< size_t > m_pkeysColumns
Primary key columns.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:111
A class used for logical ordering of rows.
Definition: Promoter.h:69
bool m_OIdsVisible
Oids icon visibility.