actionmanager_p.h 3.3 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

30
31
#ifndef ACTIONMANAGERPRIVATE_H
#define ACTIONMANAGERPRIVATE_H
con's avatar
con committed
32

33
#include <coreplugin/actionmanager/actionmanager.h>
con's avatar
con committed
34
35
36
37
38
39
40
41
42

#include <QtCore/QMap>
#include <QtCore/QHash>
#include <QtCore/QMultiHash>

QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE

hjk's avatar
hjk committed
43
44
struct CommandLocation
{
con's avatar
con committed
45
46
47
48
49
50
51
52
53
54
    int m_container;
    int m_position;
};

namespace Core {

class UniqueIDManager;

namespace Internal {

55
class ActionContainerPrivate;
con's avatar
con committed
56
class MainWindow;
con's avatar
con committed
57
class CommandPrivate;
con's avatar
con committed
58

hjk's avatar
hjk committed
59
class ActionManagerPrivate : public Core::ActionManager
con's avatar
con committed
60
61
62
63
{
    Q_OBJECT

public:
64
    explicit ActionManagerPrivate(MainWindow *mainWnd);
65
    ~ActionManagerPrivate();
con's avatar
con committed
66
67

    void setContext(const QList<int> &context);
68
    static ActionManagerPrivate *instance();
con's avatar
con committed
69
70
71
72

    void saveSettings(QSettings *settings);
    QList<int> defaultGroups() const;

73
    QList<Command *> commands() const;
74
    QList<ActionContainerPrivate *> containers() const;
con's avatar
con committed
75
76
77

    bool hasContext(int context) const;

con's avatar
con committed
78
    Command *command(int uid) const;
79
    ActionContainer *actionContainer(int uid) const;
con's avatar
con committed
80
81
82
83

    void initialize();

    //ActionManager Interface
84
85
    ActionContainer *createMenu(const QString &id);
    ActionContainer *createMenuBar(const QString &id);
con's avatar
con committed
86

con's avatar
con committed
87
    Command *registerAction(QAction *action, const QString &id,
con's avatar
con committed
88
        const QList<int> &context);
con's avatar
con committed
89
    Command *registerShortcut(QShortcut *shortcut, const QString &id,
con's avatar
con committed
90
91
        const QList<int> &context);

con's avatar
con committed
92
    Core::Command *command(const QString &id) const;
93
    Core::ActionContainer *actionContainer(const QString &id) const;
con's avatar
con committed
94
95
96

private:
    bool hasContext(QList<int> context) const;
con's avatar
con committed
97
    Command *registerOverridableAction(QAction *action, const QString &id,
con's avatar
con committed
98
99
        bool checkUnique);

100
    static ActionManagerPrivate* m_instance;
con's avatar
con committed
101
102
    QList<int> m_defaultGroups;

con's avatar
con committed
103
    typedef QHash<int, CommandPrivate *> IdCmdMap;
con's avatar
con committed
104
105
    IdCmdMap m_idCmdMap;

106
    typedef QHash<int, ActionContainerPrivate *> IdContainerMap;
con's avatar
con committed
107
108
    IdContainerMap m_idContainerMap;

109
110
111
//    typedef QMap<int, int> GlobalGroupMap;
//    GlobalGroupMap m_globalgroups;
//
con's avatar
con committed
112
113
114
115
116
117
118
119
    QList<int> m_context;

    MainWindow *m_mainWnd;
};

} // namespace Internal
} // namespace Core

120
#endif // ACTIONMANAGERPRIVATE_H