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