1 /* This file is part of the dbusmenu-qt library
2 Copyright 2010 Canonical
3 Author: Aurelien Gateau <aurelien.gateau@canonical.com>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
21 #ifndef DBUSMENUEXPORTERPRIVATE_P_H
22 #define DBUSMENUEXPORTERPRIVATE_P_H
25 #include "dbusmenuexporter.h"
26 #include "dbusmenutypes_p.h"
29 #include <QtCore/QHash>
30 #include <QtCore/QMap>
31 #include <QtCore/QSet>
32 #include <QtCore/QVariant>
33 #include <QtCore/QTimer>
36 class DBusMenuExporterDBus;
38 class DBusMenuExporterPrivate
45 DBusMenuExporterDBus *m_dbusObject;
48 QHash<QAction *, QVariantMap> m_actionProperties;
49 QMap<int, QAction *> m_actionForId;
50 QMap<QAction *, int> m_idForAction;
53 bool m_emittedLayoutUpdatedOnce;
55 QSet<int> m_itemUpdatedIds;
56 QTimer *m_itemUpdatedTimer;
58 QSet<int> m_layoutUpdatedIds;
59 QTimer *m_layoutUpdatedTimer;
61 int idForAction(QAction *action) const;
62 void addMenu(QMenu *menu, int parentId);
63 QVariantMap propertiesForAction(QAction *action) const;
64 QVariantMap propertiesForKMenuTitleAction(QAction *action_) const;
65 QVariantMap propertiesForSeparatorAction(QAction *action) const;
66 QVariantMap propertiesForStandardAction(QAction *action) const;
67 QMenu *menuForId(int id) const;
68 void fillLayoutItem(DBusMenuLayoutItem *item, QMenu *menu, int id, int depth, const QStringList &propertyNames);
70 void addAction(QAction *action, int parentId);
71 void updateAction(QAction *action);
72 void removeAction(QAction *action, int parentId);
74 * Removes any reference from action in the exporter, but do not notify the
75 * change outside. This is useful when a submenu is destroyed because we do
76 * not receive QEvent::ActionRemoved events for its actions.
77 * IMPORTANT: action might have already been destroyed when this method is
78 * called, so don't dereference the pointer (it is a QObject to avoid being
79 * tempted to dereference)
81 void removeActionInternal(QObject *action);
83 void emitLayoutUpdated(int id);
85 void insertIconProperty(QVariantMap* map, QAction *action) const;
87 void collapseSeparators(QMenu*);
91 #endif /* DBUSMENUEXPORTERPRIVATE_P_H */