cppplugin.h 3.57 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
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

con's avatar
con committed
33 34 35 36 37 38
#ifndef CPPPLUGIN_H
#define CPPPLUGIN_H

#include <extensionsystem/iplugin.h>
#include <coreplugin/editormanager/ieditorfactory.h>

39 40 41 42
#include <QtCore/QtPlugin>
#include <QtCore/QStringList>
#include <QtGui/QAction>

con's avatar
con committed
43 44
namespace TextEditor {
class TextEditorActionHandler;
45
class ITextEditor;
con's avatar
con committed
46 47 48 49 50
} // namespace TextEditor

namespace CppEditor {
namespace Internal {

51
class CPPEditorWidget;
52
class CppQuickFixCollector;
Leandro Melo's avatar
Leandro Melo committed
53
class CppQuickFixAssistProvider;
con's avatar
con committed
54 55 56 57 58 59 60 61 62 63 64 65 66

class CppPlugin : public ExtensionSystem::IPlugin
{
    Q_OBJECT

public:
    CppPlugin();
    ~CppPlugin();

    static CppPlugin *instance();

    bool initialize(const QStringList &arguments, QString *error_message = 0);
    void extensionsInitialized();
67
    ShutdownFlag aboutToShutdown();
con's avatar
con committed
68 69

    // Connect editor to settings changed signals.
70
    void initializeEditor(CPPEditorWidget *editor);
con's avatar
con committed
71

Kai Koehne's avatar
Kai Koehne committed
72
    bool sortedOutline() const;
73

Leandro Melo's avatar
Leandro Melo committed
74
    CppQuickFixAssistProvider *quickFixProvider() const;
75

76
signals:
Kai Koehne's avatar
Kai Koehne committed
77
    void outlineSortingChanged(bool sort);
78
    void typeHierarchyRequested();
79 80

public slots:
Kai Koehne's avatar
Kai Koehne committed
81
    void setSortedOutline(bool sorted);
82

con's avatar
con committed
83 84 85
private slots:
    void switchDeclarationDefinition();
    void jumpToDefinition();
86
    void renameSymbolUnderCursor();
87 88
    void onTaskStarted(const QString &type);
    void onAllTasksFinished(const QString &type);
89
    void findUsages();
90
    void currentEditorChanged(Core::IEditor *editor);
91
    void openTypeHierarchy();
con's avatar
con committed
92 93 94

private:
    Core::IEditor *createEditor(QWidget *parent);
95 96
    void writeSettings();
    void readSettings();
con's avatar
con committed
97 98 99

    static CppPlugin *m_instance;

100
    TextEditor::TextEditorActionHandler *m_actionHandler;
Kai Koehne's avatar
Kai Koehne committed
101
    bool m_sortedOutline;
102 103
    QAction *m_renameSymbolUnderCursorAction;
    QAction *m_findUsagesAction;
104
    QAction *m_updateCodeModelAction;
105
    QAction *m_openTypeHierarchyAction;
106

Leandro Melo's avatar
Leandro Melo committed
107
    CppQuickFixAssistProvider *m_quickFixProvider;
108

109
    QPointer<TextEditor::ITextEditor> m_currentEditor;
con's avatar
con committed
110 111
};

112
class CppEditorFactory : public Core::IEditorFactory
con's avatar
con committed
113 114 115 116
{
    Q_OBJECT

public:
117
    CppEditorFactory(CppPlugin *owner);
con's avatar
con committed
118

hjk's avatar
hjk committed
119 120
    // IEditorFactory
    QStringList mimeTypes() const;
con's avatar
con committed
121
    Core::IEditor *createEditor(QWidget *parent);
hjk's avatar
hjk committed
122 123
    Core::Id id() const;
    QString displayName() const;
con's avatar
con committed
124 125 126 127 128 129 130 131 132 133 134
    Core::IFile *open(const QString &fileName);

private:
    CppPlugin *m_owner;
    QStringList m_mimeTypes;
};

} // namespace Internal
} // namespace CppEditor

#endif // CPPPLUGIN_H