StyleItem.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 layer/explorer/StyleItem.cpp
22 */
23 #include "StyleItem.h"
24 
25 // TerraLib
26 #include "../../../../color/RGBAColor.h"
27 #include "../../../../maptools/AbstractLayer.h"
28 #include "../../../../se/Description.h"
29 #include "../../../../se/Rule.h"
30 #include "../../../../se/Symbolizer.h"
31 #include "../../../../se/Style.h"
32 
33 #include "LayerItem.h"
34 #include "RuleItem.h"
35 
36 // Qt
37 #include <QObject>
38 
40 {
41  std::vector<te::se::Rule*> rules = style->getRules();
42 
43  for (std::size_t i = 0; i != rules.size(); ++i)
44  {
45  te::qt::widgets::RuleItem* ruleItem = new te::qt::widgets::RuleItem(rules[i]);
46 
47  item->addChild(ruleItem);
48  }
49 }
50 
52  TreeItem("STYLE"),
53  m_style(style)
54 {
55  m_label = (QObject::tr("Style")).toUtf8().data();
56 
57  if (m_style->getName())
58  m_label = *m_style->getName();
59  else
60  m_label = QObject::tr("Default Style").toUtf8().data();
61 
62  AddRuleItems(this, m_style);
63 }
64 
66 
68 {
69  return m_label;
70 }
71 
73 {
74  return TreeItem::flags();
75 }
76 
78 {
79  std::string toolTip;
80 
81  if (m_style && m_style->getDescription())
82  toolTip = m_style->getDescription()->getTitle();
83 
84  return toolTip;
85 }
86 
88 {
90 
91  AddRuleItems(this, m_style);
92 }
te::se::Style * m_style
Grouping being used.
Definition: StyleItem.h:95
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
A class that represents a style of a layer in a LayerTreeModel.
const std::string & getTitle() const
Definition: Description.cpp:38
void removeAllChilds()
Removes all children.
std::string m_label
Label to be presented on the Qt view.
Definition: StyleItem.h:94
Defines a hierarchical structure.
const std::vector< Rule * > & getRules() const
Definition: Style.cpp:94
StyleItem(te::se::Style *style)
Constructor.
Definition: StyleItem.cpp:51
void addChild(TreeItem *item)
Adds a child to the item. The child is added to the end of the list.
Represents a lengend in the tree structure.
Definition: RuleItem.h:53
void AddRuleItems(te::qt::widgets::StyleItem *item, const te::se::Style *style)
Definition: StyleItem.cpp:39
std::string getAsString() const
Returns the label of the item to be presented in a Qt view.
Definition: StyleItem.cpp:67
Defines a rule item.
const std::string * getName() const
Definition: Style.cpp:59
Defines a layer item.
std::string getToolTip() const
Returns the item tooltip (for information purposes).
Definition: StyleItem.cpp:77
void updateStyle(const te::se::Style *style)
updateStyle
Definition: StyleItem.cpp:87
A class that represents a style of a layer in a LayerTreeModel.
Definition: StyleItem.h:50
const Description * getDescription() const
Definition: Style.cpp:70
Qt::ItemFlags flags()
Returns the flags to be used by the model.
Definition: StyleItem.cpp:72
virtual Qt::ItemFlags flags()
Returns the flags to be used by the model.