OSDN Git Service

move the test application to tests sub-directory
[kde/libdbusmenu-qt.git] / src / dbusmenuexporterprivate_p.h
1 /* This file is part of the dbusmenu-qt library
2    Copyright 2010 Canonical
3    Author: Aurelien Gateau <aurelien.gateau@canonical.com>
4
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
9    version.
10
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.
15
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.
20 */
21 #ifndef DBUSMENUEXPORTERPRIVATE_P_H
22 #define DBUSMENUEXPORTERPRIVATE_P_H
23
24 // Local
25 #include "dbusmenuexporter.h"
26 #include "dbusmenutypes_p.h"
27
28 // Qt
29 #include <QtCore/QHash>
30 #include <QtCore/QMap>
31 #include <QtCore/QSet>
32 #include <QtCore/QVariant>
33 #include <QtCore/QTimer>
34 #include <QMenu>
35
36 class DBusMenuExporterDBus;
37
38 class DBusMenuExporterPrivate
39 {
40 public:
41     DBusMenuExporter *q;
42
43     QString m_objectPath;
44
45     DBusMenuExporterDBus *m_dbusObject;
46
47     QMenu *m_rootMenu;
48     QHash<QAction *, QVariantMap> m_actionProperties;
49     QMap<int, QAction *> m_actionForId;
50     QMap<QAction *, int> m_idForAction;
51     int m_nextId;
52     uint m_revision;
53     bool m_emittedLayoutUpdatedOnce;
54
55     QSet<int> m_itemUpdatedIds;
56     QTimer *m_itemUpdatedTimer;
57
58     QSet<int> m_layoutUpdatedIds;
59     QTimer *m_layoutUpdatedTimer;
60
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);
69
70     void addAction(QAction *action, int parentId);
71     void updateAction(QAction *action);
72     void removeAction(QAction *action, int parentId);
73     /**
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)
80      */
81     void removeActionInternal(QObject *action);
82
83     void emitLayoutUpdated(int id);
84
85     void insertIconProperty(QVariantMap* map, QAction *action) const;
86
87     void collapseSeparators(QMenu*);
88 };
89
90
91 #endif /* DBUSMENUEXPORTERPRIVATE_P_H */