All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LayerExplorer.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 terralib/qt/widgets/layer/explorer/LayerExplorer.h
22 
23  \brief A widget designed to explore the layers of an application.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_LAYER_EXPLORER_INTERNAL_LAYEREXPLORER_H
27 #define __TERRALIB_QT_WIDGETS_LAYER_EXPLORER_INTERNAL_LAYEREXPLORER_H
28 
29 // TerraLib
30 #include "../../../../maptools/AbstractLayer.h"
31 #include "../../Config.h"
32 #include "LayerTreeView.h"
33 
34 // STL
35 #include <list>
36 
37 // Qt
38 #include <QDockWidget>
39 #include <QModelIndex>
40 
41 namespace te
42 {
43  namespace qt
44  {
45  namespace widgets
46  {
47  class AbstractTreeItem;
48  class LayerTreeModel;
49 
50  /*!
51  \class LayerExplorer
52 
53  \brief A widget designed to explore the layers of an application.
54 
55  \ingroup widgets
56 
57  \sa LayerTreeView, LayerTreeModel
58  */
59  class TEQTWIDGETSEXPORT LayerExplorer : public QDockWidget
60  {
61  Q_OBJECT
62 
63  public:
64 
65  LayerExplorer(QWidget* parent = 0, Qt::WindowFlags flags = 0);
66 
67  ~LayerExplorer();
68 
69  LayerTreeView* getTreeView() const;
70 
71  LayerTreeModel* getTreeModel() const;
72 
73  void set(const std::list<te::map::AbstractLayerPtr>& layers);
74 
75  /*!
76  \brief It gets the top level layers in the tree model associated to the layer explorer.
77 
78  \return The list of the top level layers in the tree model associated to the layer explorer.
79  */
80  std::list<te::map::AbstractLayerPtr> getTopLayers() const;
81 
82  /*!
83  \brief It gets all the selected items in the layer explorer.
84 
85  \return The list of selected items in the layer explorer.
86  */
87  std::list<AbstractTreeItem*> getSelectedItems() const;
88 
89  /*!
90  \brief It gets all the selected layers(single and folders) in the layer explorer.
91 
92  \return The list of all the selected layers(single and folders) in the layer explorer.
93  */
94  std::list<AbstractTreeItem*> getSelectedLayerItems() const;
95 
96  /*!
97  \brief It gets the single layer items that are selected in the tree view.
98 
99  \return The list of single layer items that are selected in the tree view.
100  */
101  std::list<AbstractTreeItem*> getSelectedSingleLayerItems() const;
102 
103  /*!
104  \brief It gets the single layers that are selected.
105 
106  \return The list of single layers that are selected.
107  */
108  std::list<te::map::AbstractLayerPtr> getSelectedSingleLayers() const;
109 
110  /*!
111  \brief It gets the single layers that are selected and visible.
112 
113  \return The list of single layers that are selected and visible.
114  */
115  std::list<te::map::AbstractLayerPtr> getSelectedAndVisibleSingleLayers() const;
116 
117  /*!
118  \brief It gets the layer item that is associated to the given layer.
119 
120  \param layer The layer whose the corresponding layer item will be returned.
121 
122  \return The layer item associated to the layer.
123  */
125 
126  /*!
127  \brief It adds a item layer to the list of item layers of the parent layer item.
128  If the parent layer is not specified, the item layer is added as a top layer item.
129 
130  \param layer The layer that will be associated to the item layer to be added.
131  \param parentItem The parent item where the layer item will be added.
132  */
133  void add(const te::map::AbstractLayerPtr& layer, AbstractTreeItem* parentItem = 0);
134 
135  /*!
136  \brief It removes the given item from the layer explorer.
137 
138  \param item The item to be removed from the layer explorer.
139 
140  \return True, if the item was successfully removed; otherwise, it returns false.
141  */
142  bool remove(AbstractTreeItem* item);
143 
144  /*!
145  \brief It gets the context menu selection type associated to the menu selection type.
146 
147  \param menuSelectionType The menu selection type.
148 
149  \return The context menu selection type.
150  */
151  te::qt::widgets::LayerTreeView::ContextMenuSelectionType getMenuSelectionType(int menuSelectionType) const;
152 
153  /*!
154  \brief It calls the action to a specified menu of a given layer type when a context menu is displayed.
155 
156  \param action The action to be associated to the context menu.
157  \param menu The name of a submenu, using a dot separator notation. If omitted, the action will be set on a top menu item.
158  \param itemType If omitted the action will be set to all item types.
159  \param menuSelectionType The selection type of the context menu.
160 
161  \note The LayerTreeView will not take the ownership of the action.
162  */
163  void add(QAction* action,
164  const std::string& menu = "",
165  const std::string& itemType = "",
167 
168  signals:
169 
170  void selectedLayersChanged(const std::list<te::map::AbstractLayerPtr>& selectedLayers);
171 
172  void visibilityChanged(const te::map::AbstractLayerPtr& layer);
173 
174  void layerOrderChanged();
175 
176  void doubleClicked(te::qt::widgets::AbstractTreeItem* item);
177 
178  public slots:
179 
180  /*!
181  \brief It sends out a signal indicating that there were changes in the selection of layers in the tree view.
182 
183  \param selectedLayers The new list of selected layers.
184  */
185  void onSelectedLayersChanged(const std::list<te::map::AbstractLayerPtr>& selectedLayers);
186 
187  /*!
188  \brief It sends out a signal indicating that the visibility of the given single layer was changed in the tree view.
189  */
190  void onVisibilityChanged(const te::map::AbstractLayerPtr& layer);
191 
192  /*!
193  \brief It sends out a signal indicating that there was a drag and operation on the tree view.
194  */
195  void onLayerOrderChanged();
196 
197  /*!
198  \brief It sends out a signal indicating that the given item was double clicked.
199 
200  \param item The tree item that was double clicked.
201  */
202  void onItemDoubleClicked(te::qt::widgets::AbstractTreeItem* item);
203 
204  /*!
205  \brief It expands the specified model item.
206 
207  \param item The model item to be expanded.
208  */
209  void expand(te::qt::widgets::AbstractTreeItem* item);
210 
211  /*!
212  \brief It collapses the specified model item.
213 
214  \param item The model item to be collapsed.
215  */
216  void collapse(te::qt::widgets::AbstractTreeItem* item);
217 
218  private:
219 
220  LayerTreeView* m_treeView; //!< The tree view for the layers
221  LayerTreeModel* m_treeModel; //!< the tree model for the layers
222  };
223  } // end namespace widgets
224  } // end namespace qt
225 } // end namespace te
226 
227 #endif // __TERRALIB_QT_WIDGETS_LAYER_EXPLORER_INTERNAL_LAYEREXPLORER_H
A tree view for the layers of an application.
Definition: LayerTreeView.h:63
The class that represents an item in a LayerTreeModel.
LayerTreeView * m_treeView
The tree view for the layers.
A widget designed to explore the layers of an application.
Definition: LayerExplorer.h:59
LayerTreeModel * m_treeModel
the tree model for the layers
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:66
A tree view for the layers of an application.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr