All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LegendGroupItem.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/vp/qt/LegendGroupItem.cpp
22 
23  \brief A class that represents a group of legends in a LayerTreeModel.
24 */
25 
26 // TerraLib
27 #include "../../common/Translator.h"
28 #include "../../datatype/Property.h"
29 #include "../../qt/widgets/layer/explorer/LegendItem.h"
30 #include "../../se/Rule.h"
31 #include "../Exception.h"
32 #include "LegendGroupItem.h"
33 
34 // Qt
35 #include <QWidget>
36 
37 te::vp::LegendGroupItem::LegendGroupItem(std::vector<te::se::Rule*> rules, AbstractTreeItem* parent)
38  : AbstractTreeItem(parent)
39 {
40  if(rules.empty())
41  return;
42 
43  for(size_t i = 0; i < rules.size(); ++i)
44  {
45  te::se::Rule* rule = rules[i];
46 
47 
49  item->setCheckable(true);
50 
51  m_items.push_back(item);
52  }
53 }
54 
56 {
57 }
58 
60 {
61  return 2;
62 }
63 
64 QVariant te::vp::LegendGroupItem::data(int column, int role) const
65 {
66  if(role == Qt::DisplayRole && column == 0)
67  return QVariant(TE_TR("Legends"));
68 
69  return QVariant();
70 }
71 
72 QMenu* te::vp::LegendGroupItem::getMenu(QWidget* parent) const
73 {
74  return 0;
75 }
76 
78 {
79  if(!children().empty ())
80  return false;
81 
82  return hasChildren();
83 }
84 
85 Qt::ItemFlags te::vp::LegendGroupItem::flags() const
86 {
87  return Qt::ItemIsUserCheckable;
88 }
89 
91 {
92 }
93 
95 {
96  return m_items.size() > 0 ? true : false;
97 }
98 
99 bool te::vp::LegendGroupItem::setData(int column, const QVariant& value, int role)
100 {
101  return true;
102 }
103 
105 {
106  return 0;
107 }
108 
109 std::vector<te::qt::widgets::AbstractTreeItem*> te::vp::LegendGroupItem::getItems() const
110 {
111  return m_items;
112 }
113 
114 const std::string te::vp::LegendGroupItem::getItemType() const
115 {
116  return "LEGEND_ITEM";
117 }
const std::string getItemType() const
It returns the item type.
std::vector< te::qt::widgets::AbstractTreeItem * > getItems() const
te::map::AbstractLayerPtr getLayer() const
A class that represents a group of legends in a LayerTreeModel.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
QMenu * getMenu(QWidget *parent=0) const
Qt::ItemFlags flags() const
QVariant data(int column, int role) const
LegendGroupItem(std::vector< te::se::Rule * > rules, AbstractTreeItem *parent)
void setCheckable(bool checkable)
Definition: LegendItem.cpp:156
std::vector< te::qt::widgets::AbstractTreeItem * > m_items
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
Definition: Rule.h:78
bool setData(int column, const QVariant &value, int role=Qt::EditRole)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr