OSDN Git Service

4fe3881bd1c3a87645a19523a8de84913ceadd30
[qt-creator-jp/qt-creator-jp.git] / src / plugins / bineditor / bineditorplugin.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef BINEDITORPLUGIN_H
35 #define BINEDITORPLUGIN_H
36
37 #include <extensionsystem/iplugin.h>
38 #include <coreplugin/editormanager/ieditorfactory.h>
39 #include <coreplugin/icontext.h>
40
41 #include <QtCore/QtPlugin>
42 #include <QtCore/QPointer>
43 #include <QtCore/QStringList>
44 #include <QtGui/QAction>
45
46 namespace BINEditor {
47 class BinEditor;
48 namespace Internal {
49 class BinEditorFactory;
50
51
52 class BinEditorPlugin : public ExtensionSystem::IPlugin
53 {
54     Q_OBJECT
55
56 public:
57     BinEditorPlugin();
58     ~BinEditorPlugin();
59
60     bool initialize(const QStringList &arguments, QString *error_message = 0);
61     void extensionsInitialized();
62
63     // Connect editor to settings changed signals.
64     void initializeEditor(BinEditor *editor);
65
66 private slots:
67     void undoAction();
68     void redoAction();
69     void copyAction();
70     void selectAllAction();
71     void updateActions();
72
73     void updateCurrentEditor(Core::IContext *object);
74
75 private:
76     Core::Context m_context;
77     QAction *registerNewAction(const QString &id, const QString &title = QString());
78     QAction *registerNewAction(const QString &id, QObject *receiver, const char *slot,
79                                const QString &title = QString());
80     QAction *m_undoAction;
81     QAction *m_redoAction;
82     QAction *m_copyAction;
83     QAction *m_selectAllAction;
84
85     friend class BinEditorFactory;
86     Core::IEditor *createEditor(QWidget *parent);
87
88     BinEditorFactory *m_factory;
89     QPointer<BinEditor> m_currentEditor;
90 };
91
92 class BinEditorFactory : public Core::IEditorFactory
93 {
94     Q_OBJECT
95
96 public:
97     explicit BinEditorFactory(BinEditorPlugin *owner);
98
99     virtual QStringList mimeTypes() const;
100
101     Core::IEditor *createEditor(QWidget *parent);
102     QString id() const;
103     QString displayName() const;
104     Core::IFile *open(const QString &fileName);
105
106 private:
107     const QStringList m_mimeTypes;
108     BinEditorPlugin *m_owner;
109 };
110
111 } // namespace Internal
112 } // namespace BINEditor
113
114 #endif // BINEDITORPLUGIN_H