All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LayerTreeView.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/LayerTreeView.h
22 
23  \brief A tree view for the layers of an application.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_LAYER_EXPLORER_INTERNAL_LAYERTREEVIEW_H
27 #define __TERRALIB_QT_WIDGETS_LAYER_EXPLORER_INTERNAL_LAYERTREEVIEW_H
28 
29 // TerraLib
30 #include "../../../../maptools/AbstractLayer.h"
31 #include "../../Config.h"
32 
33 // STL
34 #include <list>
35 
36 // Boost
37 #include <boost/noncopyable.hpp>
38 
39 // Qt
40 #include <QTreeView>
41 
42 // Forward declaration
43 class QAction;
44 class QString;
45 
46 namespace te
47 {
48  namespace qt
49  {
50  namespace widgets
51  {
52  class AbstractTreeItem;
53 
54  /*!
55  \class LayerTreeView
56 
57  \brief A tree view for the layers of an application.
58 
59  \ingroup widgets
60 
61  \sa LayerExplorer, LayerTreeModel
62  */
63  class TEQTWIDGETSEXPORT LayerTreeView : public QTreeView, public boost::noncopyable
64  {
65  Q_OBJECT
66 
67  public:
68 
70  {
73  MULTIPLE_ITEMS_SELECTED
74  };
75 
76  /*! \brief Constructor */
77  LayerTreeView(QWidget* parent = 0);
78 
79  /*! \brief Destructor */
80  ~LayerTreeView();
81 
82  /*!
83  \brief It gets the items that are selected in the tree view.
84 
85  \return The list of items that are selected in the tree view.
86  */
87  std::list<AbstractTreeItem*> getSelectedItems() const;
88 
89  /*!
90  \brief It gets the single and folder layer items that are selected in the tree view.
91 
92  \return The list of single and folder layer items that are selected in the tree view.
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 in the view.
105 
106  \return The list of single layers that are selected in the view.
107  */
108  std::list<te::map::AbstractLayerPtr> getSelectedSingleLayers() const;
109 
110  /*!
111  \brief It gets the single layers that are selected and visible in the tree view.
112 
113  \return The list of single layers that are selected and visible in the tree view.
114  */
115  std::list<te::map::AbstractLayerPtr> getSelectedAndVisibleSingleLayers() const;
116 
117  /*!
118  \brief It adds the action to a specified menu of a given item type when a context menu is displayed.
119 
120  \param action The action to be associated to the context menu.
121  \param menu The name of a submenu, using a dot separator notation. If omitted, the action will be set on a top menu item.
122  \param itemType If omitted the action will be set to all item types.
123  \param menuSelectionType The selection type of the context menu.
124 
125  \note LayerTreeView will not take the ownership of the action.
126  */
127  void add(QAction* action,
128  const std::string& menu = "",
129  const std::string& itemType = "",
130  ContextMenuSelectionType menuSelectionType = te::qt::widgets::LayerTreeView::UNIQUE_ITEM_SELECTED);
131 
132  /*!
133  \brief It removes the action from the list of context menu.
134 
135  \param action The action to be removed from the context menu.
136 
137  \note The LayerTreeView will not destroy the action, it will only detach it from the widget.
138  */
139  void remove(QAction* action);
140 
141  public slots:
142 
143  void onSelectedLayersChanged(const QItemSelection& selected, const QItemSelection& deselected);
144 
145  signals:
146 
147  void activated(te::qt::widgets::AbstractTreeItem* item);
148 
149  void clicked(te::qt::widgets::AbstractTreeItem* item);
150 
151  void doubleClicked(te::qt::widgets::AbstractTreeItem* item);
152 
153  void entered(te::qt::widgets::AbstractTreeItem* item);
154 
155  void pressed(te::qt::widgets::AbstractTreeItem* item);
156 
157  void visibilityChanged(const te::map::AbstractLayerPtr& layer);
158 
159  void selectedLayersChanged(const std::list<te::map::AbstractLayerPtr>& selectedLayers);
160 
161  protected:
162 
163  void dragEnterEvent(QDragEnterEvent* e);
164 
165  void dragMoveEvent(QDragMoveEvent* e);
166 
167  void dragLeaveEvent(QDragLeaveEvent* e);
168 
169  void dropEvent(QDropEvent* e);
170 
171  void contextMenuEvent(QContextMenuEvent* e);
172 
173  protected slots:
174 
175  void onItemActivated(const QModelIndex& index);
176 
177  void onItemClicked(const QModelIndex& index);
178 
179  void onItemDoubleClicked(const QModelIndex& index);
180 
181  void onItemEntered(const QModelIndex& index);
182 
183  void onItemPressed(const QModelIndex& index);
184 
185  private:
186 
187  class Impl;
188 
189  Impl* m_pImpl; //!< The tree view implementation.
190  };
191 
192  } // end namespace widgets
193  } // end namespace qt
194 } // end namespace te
195 
196 #endif // __TERRALIB_QT_WIDGETS_LAYER_EXPLORER_INTERNAL_LAYERTREEVIEW_H
A tree view for the layers of an application.
Definition: LayerTreeView.h:63
The class that represents an item in a LayerTreeModel.
LayerTreeView implementation.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:66
Impl * m_pImpl
The tree view implementation.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr