actionmanager_p.h 3.41 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 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
**
con's avatar
con committed
9
** No Commercial Usage
10
**
con's avatar
con committed
11 12 13 14
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
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
**
con's avatar
con committed
25 26 27 28 29 30
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
con's avatar
con committed
31
**
32
**************************************************************************/
hjk's avatar
hjk committed
33

34 35
#ifndef ACTIONMANAGERPRIVATE_H
#define ACTIONMANAGERPRIVATE_H
con's avatar
con committed
36

37
#include <coreplugin/actionmanager/actionmanager.h>
38 39
#include "command_p.h"

40
#include <coreplugin/icontext.h>
con's avatar
con committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

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

QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE

namespace Core {

class UniqueIDManager;

namespace Internal {

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

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

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

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

    void saveSettings(QSettings *settings);

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

    bool hasContext(int context) const;

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

    void initialize();

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

hjk's avatar
hjk committed
86
    Command *registerAction(QAction *action, const Id &id,
87
        const Context &context, bool scriptable=false);
hjk's avatar
hjk committed
88
    Command *registerShortcut(QShortcut *shortcut, const Id &id,
89
        const Context &context, bool scriptable=false);
con's avatar
con committed
90

hjk's avatar
hjk committed
91 92
    Core::Command *command(const Id &id) const;
    Core::ActionContainer *actionContainer(const Id &id) const;
93
    void unregisterAction(QAction *action, const Id &id);
94
    void unregisterShortcut(const Id &id);
con's avatar
con committed
95

96 97
private slots:
    void containerDestroyed();
con's avatar
con committed
98
private:
99
    bool hasContext(const Context &context) const;
100
    Action *overridableAction(const Id &id);
con's avatar
con committed
101

102
    static ActionManagerPrivate *m_instance;
con's avatar
con committed
103

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

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

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

    MainWindow *m_mainWnd;
};

} // namespace Internal
} // namespace Core

121
#endif // ACTIONMANAGERPRIVATE_H