FolderItem.cpp
Go to the documentation of this file.
1 #include "FolderItem.h"
2 #include "LayerItem.h"
3 
5 {
6  size_t c = item->getChildrenCount("");
7  size_t nv = 0;
8 
9  if(c == 0)
10  return te::qt::widgets::NONE;
11 
12  for(size_t i = 0; i < c; i++)
13  {
14  if(item->getChild(i)->isVisible() == te::qt::widgets::NONE)
15  nv++;
16  }
17 
18  if(nv == c)
19  return te::qt::widgets::NONE;
20 
21  if(nv == 0)
23 
25 }
26 
28  TreeItem("FOLDER"),
29  m_layer(layer)
30 {
31 
32 }
33 
35 
37 {
38  return m_layer->getTitle();
39 }
40 
42 {
43  return GetVisibility(this);
44 }
45 
46 void te::qt::widgets::FolderItem::setVisible(const VISIBLE& visible, const bool& updateAncestors, const bool& updateDescendents)
47 {
48  if(m_parent == nullptr)
49  return;
50 
51  if(updateDescendents)
52  {
53  unsigned int c = (unsigned int)getChildrenCount("");
54 
55  for(unsigned int i = 0; i < c; i++)
56  getChild(i)->setVisible(visible, false, true);
57  }
58 
60 
61  if(updateAncestors)
62  m_parent->setVisible(v, true);
63 }
64 
66 {
67  return TreeItem::flags() | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable;
68 }
69 
70 void te::qt::widgets::FolderItem::setTitle(const std::string& title)
71 {
72  m_layer->setTitle(title);
73 }
74 
76 {
78 
79  te::qt::widgets::LayerItem* layerItem = dynamic_cast<te::qt::widgets::LayerItem*>(item);
80 
81  if (layerItem)
82  {
83  te::map::AbstractLayerPtr child = layerItem->getLayer();
84 
85  if(child)
86  m_layer->add(child);
87  }
88 }
Defines a folder item, just containing LayerItem.
TreeItem * m_parent
Pointer to the parent.
void insertChild(TreeItem *item, const size_t &pos)
Inserts a child item at the desired position.
Definition: FolderItem.cpp:75
An item that contains a te::map::AbstractLayerPtr.
Definition: LayerItem.h:51
te::map::AbstractLayerPtr getLayer() const
Returns the layer contained in the item.
Definition: LayerItem.cpp:140
TreeItem * getChild(const size_t &pos) const
Returns the child located at pos.
FolderItem(te::map::AbstractLayerPtr layer)
Constructor.
Definition: FolderItem.cpp:27
Defines a hierarchical structure.
std::string getAsString() const
Returns the label of the item to be presented in a Qt view.
Definition: FolderItem.cpp:36
te::map::AbstractLayerPtr m_layer
The asbtract layer.
Definition: FolderItem.h:96
void setTitle(const std::string &title)
Updates the title of the folder.
Definition: FolderItem.cpp:70
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Qt::ItemFlags flags()
Returns the flags to be used by the model.
Definition: FolderItem.cpp:65
VISIBLE
Defines the visibility of an item.
VISIBLE isVisible() const
Returns the visibilty state of the item.
Definition: FolderItem.cpp:41
Defines a layer item.
te::qt::widgets::VISIBLE GetVisibility(const te::qt::widgets::TreeItem *item)
Definition: FolderItem.cpp:4
virtual void insertChild(TreeItem *item, const size_t &pos)
Inserts a child item at the desired position.
size_t getChildrenCount(const std::string &type) const
Returns the number of children.
void setVisible(const VISIBLE &visible, const bool &updateAncestors=false, const bool &updateDescendents=false)
Updates the visibilty state of the item.
Definition: FolderItem.cpp:46
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
virtual void setVisible(const VISIBLE &visible, const bool &updateAncestors=false, const bool &updateDescendents=false)
Updates the visibilty state of the item.
virtual VISIBLE isVisible() const
Returns the visibilty state of the item.
virtual Qt::ItemFlags flags()
Returns the flags to be used by the model.