HighlightDelegate.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 HighlightDelegate.h
22 
23  \brief A delegate for highlight the selected object ids.
24 */
25 
26 
27 #ifndef __TERRALIB_QT_WIDGETS_TABLE_INTERNAL_DATASETTABLEVIEW_H
28 #define __TERRALIB_QT_WIDGETS_TABLE_INTERNAL_DATASETTABLEVIEW_H
29 
30 #include "../Config.h"
31 
32 // Qt
33 #include <QItemDelegate>
34 
35 // STL
36 #include <set>
37 
38 namespace te
39 {
40  namespace da
41  {
42  class ObjectIdSet;
43  class ObjectId;
44  class DataSet;
45  }
46 
47  namespace qt
48  {
49  namespace widgets
50  {
51  // Forward declaration
52  class Promoter;
53 
54  /*!
55  \class HighlightDelegate
56 
57  \brief An specialization of QItemDelegate to be used with te::map::AbstractTable objects.
58 
59  This class is used on QAbstractItemView that has a te::qt::widgets::DatSetModel as model to highlight some objects.
60  Each identifier in the set of ids are rendering with a predefined color.
61 
62  \sa QItemDelegate, te::qt::widgets::DataSetTableModel
63  */
64  class TEQTWIDGETSEXPORT HighlightDelegate : public QItemDelegate
65  {
66  public:
67 
68  /*!
69  \brief Constructor.
70 
71  \param parent QObject parent.
72  */
73  HighlightDelegate(QObject* parent=0);
74 
75  /*!
76  \brief Destructor
77  */
78  virtual ~HighlightDelegate();
79 
80 
81  virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
82 
83  /*!
84  \brief Update the color group.
85 
86  \param c New color of the group.
87  */
88  virtual void setColor(const QColor& c);
89 
90  /*!
91  \brief Returns the color.
92 
93  \return Current color.
94  */
95  QColor getColor();
96 
97  /*!
98  \brief Sets the current data set being used. This method DOES NOT take the ownership of the \a dset.
99 
100  \param dset The DataSet to be used.
101  */
102  virtual void setDataSet(te::da::DataSet* dset);
103 
104  /*!
105  \brief Sets the object id set. It WILL NOT TAKE the ownership of the \a objs.
106  */
107  virtual void setObjectIdSet(const te::da::ObjectIdSet* objs);
108 
109  /*!
110  \brief Returns the identifiers of the rows highlighted.
111 
112  \return The identifiers of the highlighted rows;
113  */
114  virtual const te::da::ObjectIdSet* getSelected() const;
115 
116  /*!
117  \brief Sets the promoter being used.
118 
119  \param promoter Pointer of the promoter.
120 
121  \note It DOES NOT take the ownership of \a promoter.
122  */
123  void setPromoter(Promoter* promoter);
124 
125  protected:
126 
127  QColor m_color; //!< Highlight color.
128 
129  const te::da::ObjectIdSet* m_objs; //!< Identifiers of the highlight object.
130 
131  te::da::DataSet* m_dset; //!< Pointer to the DataSet being used.
132 
133  Promoter* m_promoter; //!< Pointer to the promoter being used.
134 
135  std::set<std::string> m_oids;
136  };
137  }
138  }
139 }
140 
141 #endif //__TERRALIB_QT_WIDGETS_TABLE_INTERNAL_DATASETTABLEVIEW_H
An specialization of QItemDelegate to be used with te::map::AbstractTable objects.
const te::da::ObjectIdSet * m_objs
Identifiers of the highlight object.
Promoter * m_promoter
Pointer to the promoter being used.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
URI C++ Library.
A class used for logical ordering of rows.
Definition: Promoter.h:69
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
te::da::DataSet * m_dset
Pointer to the DataSet being used.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63