All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GroupingSliceItem.cpp
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 terralib/qt/widgets/layer/explorer/GroupingSliceItem.cpp
22 
23  \brief A class that represents a grouping item of a grouping in a LayerTreeModel.
24 */
25 
26 // TerraLib
27 #include "../../../../maptools/GroupingItem.h"
28 #include "../../se/SymbologyPreview.h"
29 #include "GroupingSliceItem.h"
30 
31 // Qt
32 #include <QMenu>
33 #include <QWidget>
34 
36  : AbstractTreeItem(parent),
37  m_item(item),
38  m_isCheckable(false),
39  m_isChecked(false)
40 {
41 }
42 
44 {
45 }
46 
48 {
49  return 1;
50 }
51 
52 QVariant te::qt::widgets::GroupingSliceItem::data(int /*column*/, int role) const
53 {
54  if(role == Qt::DecorationRole)
55  return QVariant(QIcon(SymbologyPreview::build(m_item->getSymbolizers(), QSize(16, 16))));
56 
57  if(role == Qt::DisplayRole)
58  return QVariant(m_item->getTitle().c_str());
59 
60  if(role == Qt::CheckStateRole && m_isCheckable)
61  return QVariant(m_isChecked ? Qt::Checked : Qt::Unchecked);
62 
63  return QVariant();
64 }
65 
66 QMenu* te::qt::widgets::GroupingSliceItem::getMenu(QWidget* /*parent*/) const
67 {
68  return 0;
69 }
70 
72 {
73  return false;
74 }
75 
77 {
78  return (m_isCheckable ? (Qt::ItemIsEnabled | Qt::ItemIsUserCheckable) : Qt::ItemIsEnabled);
79 }
80 
82 {
83 }
84 
86 {
87  return false;
88 }
89 
90 bool te::qt::widgets::GroupingSliceItem::setData(int /*column*/, const QVariant& value, int role)
91 {
92  if(role == Qt::CheckStateRole && m_isCheckable)
93  {
94  bool ok = false;
95  Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt(&ok));
96 
97  if(!ok)
98  return false;
99 
100  m_isChecked = (checkState == Qt::Checked ? true : false);
101  }
102 
103  return false;
104 }
105 
107 {
108  return te::map::AbstractLayerPtr(0);
109 }
110 
112 {
113  return "GROUPING_SLICE_ITEM";
114 }
115 
117 {
118  m_isCheckable = checkable;
119 }
120 
122 {
123  return m_isCheckable;
124 }
const std::string getItemType() const
It returns the item type: "GROUPING_SLICE_ITEM".
QMenu * getMenu(QWidget *parent=0) const
The class that represents an item in a LayerTreeModel.
te::map::AbstractLayerPtr getLayer() const
bool setData(int column, const QVariant &value, int role=Qt::EditRole)
A GroupingItem contains information about a grouping item associated to a layer.
Definition: GroupingItem.h:48
GroupingSliceItem(te::map::GroupingItem *item, QObject *parent=0)
QVariant data(int column, int role) const
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
static QPixmap build(const te::se::Symbolizer *symb, const QSize &size)
Generates the preview of given symbolizer element.
A class that represents a grouping item of a grouping in a LayerTreeModel.