2
* Copyright (C) 2013 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Author: Marcus Tomlinson <marcus.tomlinson@canonical.com>
19
#ifndef QTGMENUMODEL_H
20
#define QTGMENUMODEL_H
35
class QtGMenuModel : public QObject
42
Root, Section, SubMenu
45
explicit QtGMenuModel( GMenuModel* model );
46
QtGMenuModel( GMenuModel* model, const QString& bus_name, const QString& menu_path,
47
const QString& actions_path );
48
virtual ~QtGMenuModel();
50
GMenuModel* Model() const;
51
LinkType Type() const;
55
QtGMenuModel* Parent() const;
56
QtGMenuModel* Child( int index ) const;
58
std::shared_ptr< QMenu > GetQMenu();
60
constexpr static const char* c_property_actionName = "actionName";
61
constexpr static const char* c_property_isParameterized = "isParameterized";
62
constexpr static const char* c_property_busName = "busName";
63
constexpr static const char* c_property_menuPath = "menuPath";
64
constexpr static const char* c_property_actionsPath = "actionsPath";
65
constexpr static const char* c_property_keywords = "keywords";
66
constexpr static const char* c_property_hud_toolbar_item = "hud-toolbar-item";
69
void MenuItemsChanged( QtGMenuModel* model, int index, int removed, int added );
70
void ActionTriggered( QString action_name, bool checked );
73
void ActionEnabled( QString action_name, bool enabled );
74
void ActionParameterized( QString action_name, bool parameterized );
77
void ActionTriggered( bool );
80
QtGMenuModel( GMenuModel* model, LinkType link_type, QtGMenuModel* parent, int index );
82
static QtGMenuModel* CreateChild( QtGMenuModel* parent, GMenuModel* model, int index );
84
static void MenuItemsChangedCallback( GMenuModel* model, gint index, gint removed, gint added,
87
void ChangeMenuItems( int index, int added, int removed );
89
void ConnectCallback();
90
void DisconnectCallback();
92
void InsertChild( QtGMenuModel* child, int index );
93
int ChildIndex( QtGMenuModel* child );
95
QAction* CreateAction( int index );
96
QAction* FindAction( QString name );
98
void AppendQMenu( std::shared_ptr< QMenu > top_menu );
99
void UpdateExtQMenu();
102
QtGMenuModel* m_parent = nullptr;
103
QMap< int, QtGMenuModel* > m_children;
105
GMenuModel* m_model = nullptr;
106
gulong m_items_changed_handler = 0;
108
LinkType m_link_type;
111
QMenu* m_menu = new QMenu();
112
QMenu* m_ext_menu = new QMenu();
116
QString m_actions_path;
119
} // namespace qtgmenu
121
#endif // QTGMENUMODEL_H