All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PluginsModel.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 PluginsModel.h
22 
23  \brief
24 */
25 
26 #ifndef __TERRALIB_QT_WDIGETS_PLUGIN_MANAGER_INTERNAL_PLUGINSMODEL_H
27 #define __TERRALIB_QT_WDIGETS_PLUGIN_MANAGER_INTERNAL_PLUGINSMODEL_H
28 
29 //Qt
30 #include <QtCore/QAbstractTableModel>
31 #include <QtCore/QFlags>
32 
33 //STL
34 #include <vector>
35 
36 namespace te
37 {
38  // Forward declarations
39  namespace plugin
40  {
41  struct PluginInfo;
42  }
43 
44  namespace qt
45  {
46  namespace widgets
47  {
48  class PluginsModel : public QAbstractTableModel
49  {
50  public:
51 
52  /*!
53  \enum PluginStatus
54 
55  \brief Define possible states for the plugin.
56  */
58  {
59  No_operation = 0, //!< No operation.
60  To_add = 1, //!< Plugin to be added.
61  To_remove = 2, //!< Plugin to be removed.
62  To_enable = 4, //!< Plugin to be loaded.
63  To_disable = 8, //!< Plugin to be unloaded.
64  Loaded = 16, //!< Plugin is loaded.
65  Unloaded = 32, //!< Plugin is unloaded.
66  Broked = 64 //!< Plugin haas missed dependencies.
67  };
68 
69  Q_DECLARE_FLAGS( PluginsStatus, PluginStatus )
70 
71  /*!
72  \name Constructor and destructor.
73  \brief Methods used to construct and destruct the object.
74  */
75  //@{
76 
77  /*!
78  \brief Constructor.
79 
80  \param parent Qt object parent.
81  */
82  PluginsModel(QObject* parent=0);
83 
84  /*!
85  \brief Destructor.
86  */
87  virtual ~PluginsModel();
88  //@}
89 
90  /*!
91  \name QAbstractTableModel re-implementation methods.
92  \brief Re-implementation of QAbstractTableModel methods.
93  */
94  //@{
95 
96  /*!
97  \brief Returns the number of plugins regitered in plugins manager.
98  \param parent Parent. (This is not used for this model).
99  \return 8.
100  */
101  int rowCount(const QModelIndex & parent) const;
102 
103  /*!
104  \brief Returns the number of columns.
105  \param parent Parent index. (For this model it is not used)
106  \return 8.
107  */
108  int columnCount(const QModelIndex & parent) const;
109 
110  /*!
111  \brief Returns data identified by \a index.
112  \param index Data index.
113  \param role Data role.
114  \return Data as QVariant object.
115  */
116  QVariant data(const QModelIndex & index, int role) const;
117 
118  /*!
119  \brief Returns the data to be presented as header.
120  \param section Column / Row number.
121  \param orientation Horizontal / Vertical orientation options.
122  \param role Data role.
123  \return Data to be presented as header.
124  */
125  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
126 
127  /*!
128  \brief Returns the flags associated with a given item.
129  \param index Index of the cell.
130  \return Flags related to the item.
131  */
132  Qt::ItemFlags flags(const QModelIndex & index) const;
133 
134  bool setData (const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
135  //@}
136 
137  /*!
138  \brief Adds information about plugin.
139 
140  \param info Information of the plugin.
141 
142  \param status Status of plugin.
143 
144  \sa PluginStatus
145  */
146  void addPlugin(const te::plugin::PluginInfo* info, const PluginsStatus& status);
147 
148  /*!
149  \brief Remove the selected plugins.
150 
151  \param plgs Indexes of the plugins to be removed.
152  */
153  void removePlugins(const QModelIndexList& plgs);
154 
155  /*!
156  \brief Returns plugins informations.
157 
158  \param[out] plgs List of plugins.
159 
160  \param[out] status List of the status of the plugins.
161  */
162  void getPluginsInfo(std::vector<te::plugin::PluginInfo*>& plgs, std::vector<PluginsStatus>& status);
163 
164  /*!
165  \brief Clear the list of plugins and status.
166  */
167  void clear();
168 
169  protected:
170 
171  std::vector<te::plugin::PluginInfo*> m_plugins; //!< List of informations about plugins.
172  std::vector<PluginsStatus> m_pluginsStatus; //!< List of status of each plugin.
173  };
174 
175  Q_DECLARE_OPERATORS_FOR_FLAGS( te::qt::widgets::PluginsModel::PluginsStatus )
176  }
177  }
178 }
179 
180 
181 
182 #endif //__TERRALIB_QT_WDIGETS_PLUGIN_MANAGER_INTERNAL_PLUGINSMODEL_H
void removePlugins(const QModelIndexList &plgs)
Remove the selected plugins.
Qt::ItemFlags flags(const QModelIndex &index) const
Returns the flags associated with a given item.
int rowCount(const QModelIndex &parent) const
Returns the number of plugins regitered in plugins manager.
void addPlugin(const te::plugin::PluginInfo *info, const PluginsStatus &status)
Adds information about plugin.
void clear()
Clear the list of plugins and status.
void getPluginsInfo(std::vector< te::plugin::PluginInfo * > &plgs, std::vector< PluginsStatus > &status)
Returns plugins informations.
Plugin haas missed dependencies.
Definition: PluginsModel.h:66
PluginStatus
Define possible states for the plugin.
Definition: PluginsModel.h:57
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Returns the data to be presented as header.
QVariant data(const QModelIndex &index, int role) const
Returns data identified by index.
std::vector< PluginsStatus > m_pluginsStatus
List of status of each plugin.
Definition: PluginsModel.h:172
int columnCount(const QModelIndex &parent) const
Returns the number of columns.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
std::vector< te::plugin::PluginInfo * > m_plugins
List of informations about plugins.
Definition: PluginsModel.h:171