Loading...
Searching...
No Matches
MenuBarModel.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 MenuBarModel.h
22
23 \brief Contains a definition for a model over the QMenuBar.
24*/
25#ifndef __TERRALIB_QT_WIDGETS_INTERNAL_MENUBARMODEL_H
26#define __TERRALIB_QT_WIDGETS_INTERNAL_MENUBARMODEL_H
27
28#include <QtCore/QAbstractTableModel>
29
30//Forward declaration
31class QMenuBar;
32class QToolBar;
33class QAction;
34
35//STL
36#include <vector>
37
38namespace te
39{
40 namespace qt
41 {
42 namespace af
43 {
44
45 /*!
46 \class MenuBarModel
47
48 \brief Defines a model, based on a QMenuBar, to present all system buttons as a table.
49 */
50 class MenuBarModel : public QAbstractTableModel
51 {
52 Q_OBJECT
53
54 public:
55
56 /*!
57 \brief Constructor.
58
59 \param mnuBar The menu bar to be used.
60
61 \param parent Parent object.
62 */
63 MenuBarModel(QMenuBar* mnuBar, QObject* parent=0);
64
65 /*!
66 \brief Destructor.
67 */
69
70 virtual Qt::ItemFlags flags (const QModelIndex & index) const;
71
72 QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const;
73
74 QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
75
76 int columnCount (const QModelIndex & parent = QModelIndex()) const;
77
78 int rowCount (const QModelIndex & parent = QModelIndex()) const;
79
80 bool setData (const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
81
82 /*!
83 \brief Check the actions contained in \a acts.
84
85 \param acts List of the actions.
86 */
87 void updateActionsState(const QList<QAction*>& acts);
88
89 /*!
90 \brief Sets the menu bar to be used in the model.
91 */
92 void setMenuBar(QMenuBar* mnuBar);
93
94 signals:
95
96 void updateAction(QAction*, const bool&);
97
98 protected:
99
100 std::vector<QAction*> m_actions; //!< System buttons.
101 std::vector<bool> m_actionsActivation; //!< State of each system button. (True insert, False do nothing).
102 };
103 }
104 }
105}
106
107#endif //__TERRALIB_QT_WIDGETS_INTERNAL_MENUBARMODEL_H
Defines a model, based on a QMenuBar, to present all system buttons as a table.
int rowCount(const QModelIndex &parent=QModelIndex()) const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
void setMenuBar(QMenuBar *mnuBar)
Sets the menu bar to be used in the model.
void updateActionsState(const QList< QAction * > &acts)
Check the actions contained in acts.
~MenuBarModel()
Destructor.
void updateAction(QAction *, const bool &)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
MenuBarModel(QMenuBar *mnuBar, QObject *parent=0)
Constructor.
std::vector< QAction * > m_actions
System buttons.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
std::vector< bool > m_actionsActivation
State of each system button. (True insert, False do nothing).
TerraLib.