LayerViewDelegate.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 LayerViewDelegate.h
22  *
23  * \brief A class for rendering icons for layer and folder itens.
24  */
25 #ifndef __TERRALIB_QT_WIDGETS_LAYER_INTERNAL_LAYERVIEWDELEGATE_H
26 #define __TERRALIB_QT_WIDGETS_LAYER_INTERNAL_LAYERVIEWDELEGATE_H
27 
28 #include "../../Config.h"
29 
30 // TerraLib
31 #include "../../../../common/Decorator.h"
32 
33 // Qt
34 #include <QIcon>
35 #include <QStyledItemDelegate>
36 
37 namespace te
38 {
39  namespace qt
40  {
41  namespace widgets
42  {
43  /*!
44  * \class LayerViewDelegate
45  *
46  * \brief A class for rendering icons for layer and folder itens.
47  *
48  * This is the default delegate for LayerItemView. It's used for present icons for the known kind of items.
49  * For unknown items, or if you want to change the known ones, you can create your own delegate and install
50  * it on the LayerItemView. Note that we use a decorator instead the QStyledItemDelegate. This is useful for
51  * making the inheritance dynamic.
52  *
53  * \ingroup widgets
54  *
55  * \sa te::common::Decorator
56  */
57  class TEQTWIDGETSEXPORT LayerViewDelegate: public te::common::Decorator<QStyledItemDelegate>
58  {
59  Q_OBJECT
60 
61  public:
62 
63  /*!
64  * \name Instantiation Methods
65  *
66  * Methods related to creation and destruction of the object.
67  */
68  //@{
69 
70  /*!
71  * \brief Constructor.
72  *
73  * \param decorated The delegate to be decorated.
74  *
75  * \param parent Used by Qt5.
76  */
77  LayerViewDelegate(QStyledItemDelegate* decorated, QObject* parent = 0);
78 
79  /*!
80  * \brief Destructor.
81  */
83 
84  /*!
85  * \name Reimplementation of QStyledItemDelegate.
86  *
87  * Methods reimplemented of the QStyledItemDelegate class.
88  */
89  //@{
90  void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
91  //@}
92 
93  protected:
94 
95  /*!
96  * \brief Returns the icon for a given index.
97  *
98  * \param index Index of the object being rendered.
99  *
100  * \return The icon for the \a index.
101  */
102  QIcon getIcon(const QModelIndex & index) const;
103 
104  QIcon m_layer; //!< Icon for a layer not invalid.
105  QIcon m_folder; //!< Icon for a folder.
106  QIcon m_colorMap; //!< Icon for a ColorMap.
107  QIcon m_chart; //!< Icon for a chart.
108  QIcon m_queryLayer; //!< Icon for a query layer.
109  QIcon m_tabularLayer; //!< Icon for a tabular layer.
110  QIcon m_invalidLayer; //!< Icon for an invalid layers.
111  };
112  }
113  }
114 }
115 
116 #endif //__TERRALIB_QT_WIDGETS_LAYER_INTERNAL_LAYERVIEWDELEGATE_H
A class for rendering icons for layer and folder itens.
QIcon m_invalidLayer
Icon for an invalid layers.
QIcon m_layer
Icon for a layer not invalid.
QIcon m_queryLayer
Icon for a query layer.
URI C++ Library.
QIcon m_folder
Icon for a folder.
QIcon m_colorMap
Icon for a ColorMap.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
QIcon m_tabularLayer
Icon for a tabular layer.