DataSetTreeModel.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/dataset/explorer/DataSetTreeModel.h
22 
23  \brief A simple model for datasets belonging to a data source.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_DATASET_EXPLORER_INTERNAL_DATASETTREEMODEL_H
27 #define __TERRALIB_QT_WIDGETS_DATASET_EXPLORER_INTERNAL_DATASETTREEMODEL_H
28 
29 // TerraLib
30 #include "../../../../dataaccess/datasource/DataSourceInfo.h"
31 #include "../../Config.h"
32 
33 // Qt
34 #include <QtCore/QAbstractItemModel>
35 
36 class QWidget;
37 
38 namespace te
39 {
40  namespace qt
41  {
42  namespace widgets
43  {
44  class DataSetGroupItem;
45 
46  class TEQTWIDGETSEXPORT DataSetTreeModel : public QAbstractItemModel
47  {
48  Q_OBJECT
49 
50  public:
51 
52  DataSetTreeModel(const te::da::DataSourceInfoPtr& datasource, QWidget* parent = 0);
53 
55 
56  bool canFetchMore(const QModelIndex& parent) const;
57 
58  int columnCount(const QModelIndex& parent = QModelIndex()) const;
59 
60  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
61 
62  void fetchMore(const QModelIndex& parent);
63 
64  Qt::ItemFlags flags(const QModelIndex& index) const;
65 
66  bool hasChildren(const QModelIndex& parent = QModelIndex()) const;
67 
68  QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
69 
70  QModelIndex parent(const QModelIndex & index) const;
71 
72  int rowCount(const QModelIndex & parent = QModelIndex()) const;
73 
74  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
75 
76  void setCheckable(const bool checkable);
77 
78  bool isCheckable() const;
79 
80  void setForceCatalogCache(const bool force);
81 
82  bool forceCatalogCache() const;
83 
84  protected:
85 
86  /*!
87  \brief It emits the dataChanged signal for the descendants indexes of the given index.
88 
89  \param parent The item index whose descendants will have the dataChanged signal emitted.
90  */
91  void emitDataChangedForDescendants(const QModelIndex& parent);
92 
93  /*!
94  \brief It emits the dataChanged signal for the indexes that are ancestors of the given index.
95 
96  \param index The item index whose ancestors will have the dataChanged signal emitted.
97  */
98  void emitDataChangedForAncestors(const QModelIndex& index);
99 
100 
101  private:
102 
103  DataSetGroupItem* m_datasets; //!< A container for the datasets of the input data source.
104  bool m_checkable; //!< If true the model allows for checkable items.
105  bool m_forceCatalogCache; //!< If true every information looked in the data source catalog is also cahed in the data source catalog.
106  };
107 
108  } // end namespace widgets
109  } // end namespace qt
110 } // end namespace te
111 
112 #endif // __TERRALIB_QT_WIDGETS_DATASET_EXPLORER_INTERNAL_DATASETTREEMODEL_H
DataSetGroupItem * m_datasets
A container for the datasets of the input data source.
URI C++ Library.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
bool m_forceCatalogCache
If true every information looked in the data source catalog is also cahed in the data source catalog...
bool m_checkable
If true the model allows for checkable items.
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr