Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/shell/sourceformattercontroller.h
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #ifndef KDEVPLATFORM_SOURCEFORMATTERCONTROLLER_H | 21 | #ifndef KDEVPLATFORM_SOURCEFORMATTERCONTROLLER_H | ||
22 | #define KDEVPLATFORM_SOURCEFORMATTERCONTROLLER_H | 22 | #define KDEVPLATFORM_SOURCEFORMATTERCONTROLLER_H | ||
23 | 23 | | |||
24 | #include <interfaces/isourceformattercontroller.h> | 24 | #include <interfaces/isourceformattercontroller.h> | ||
25 | #include <interfaces/isourceformatter.h> | 25 | #include <interfaces/isourceformatter.h> | ||
26 | 26 | | |||
27 | #include <QSet> | 27 | #include <QSet> | ||
28 | #include <QVector> | ||||
28 | #include <QMimeType> | 29 | #include <QMimeType> | ||
29 | 30 | | |||
30 | #include <kxmlguiclient.h> | 31 | #include <kxmlguiclient.h> | ||
31 | #include <KConfigGroup> | 32 | #include <KConfigGroup> | ||
32 | 33 | | |||
33 | #include "shellexport.h" | 34 | #include "shellexport.h" | ||
34 | 35 | | |||
35 | class QUrl; | 36 | class QUrl; | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 84 | public: | |||
97 | * of the document corresponding to the \arg url. | 98 | * of the document corresponding to the \arg url. | ||
98 | */ | 99 | */ | ||
99 | ISourceFormatter* formatterForUrl(const QUrl &url) override; | 100 | ISourceFormatter* formatterForUrl(const QUrl &url) override; | ||
100 | /** Loads and returns a source formatter for this mime type. | 101 | /** Loads and returns a source formatter for this mime type. | ||
101 | * The language is then activated and the style is loaded. | 102 | * The language is then activated and the style is loaded. | ||
102 | * The source formatter is then ready to use on a file. | 103 | * The source formatter is then ready to use on a file. | ||
103 | */ | 104 | */ | ||
104 | ISourceFormatter* formatterForUrl(const QUrl& url, const QMimeType& mime) override; | 105 | ISourceFormatter* formatterForUrl(const QUrl& url, const QMimeType& mime) override; | ||
106 | bool hasFormatters() const override; | ||||
105 | /** \return Whether this mime type is supported by any plugin. | 107 | /** \return Whether this mime type is supported by any plugin. | ||
106 | */ | 108 | */ | ||
107 | bool isMimeTypeSupported(const QMimeType& mime) override; | 109 | bool isMimeTypeSupported(const QMimeType& mime) override; | ||
108 | 110 | | |||
109 | /** | 111 | /** | ||
110 | * @brief Instantiate a Formatter for the given plugin and load its configuration. | 112 | * @brief Instantiate a Formatter for the given plugin and load its configuration. | ||
111 | * | 113 | * | ||
112 | * @param ifmt The ISourceFormatter interface of the plugin | 114 | * @param ifmt The ISourceFormatter interface of the plugin | ||
Show All 14 Lines | |||||
127 | KConfigGroup sessionConfig() const; | 129 | KConfigGroup sessionConfig() const; | ||
128 | KConfigGroup globalConfig() const; | 130 | KConfigGroup globalConfig() const; | ||
129 | 131 | | |||
130 | void settingsChanged(); | 132 | void settingsChanged(); | ||
131 | 133 | | |||
132 | void disableSourceFormatting(bool disable) override; | 134 | void disableSourceFormatting(bool disable) override; | ||
133 | bool sourceFormattingEnabled() override; | 135 | bool sourceFormattingEnabled() override; | ||
134 | 136 | | |||
137 | QVector<KDevelop::ISourceFormatter*> formatters() const; | ||||
138 | | ||||
139 | Q_SIGNALS: | ||||
140 | void formatterLoaded(KDevelop::ISourceFormatter* ifmt); | ||||
141 | void formatterUnloading(KDevelop::ISourceFormatter* ifmt); | ||||
142 | | ||||
135 | private Q_SLOTS: | 143 | private Q_SLOTS: | ||
136 | void updateFormatTextAction(); | 144 | void updateFormatTextAction(); | ||
137 | void beautifySource(); | 145 | void beautifySource(); | ||
138 | void beautifyLine(); | 146 | void beautifyLine(); | ||
139 | void formatFiles(); | 147 | void formatFiles(); | ||
140 | void documentLoaded( KDevelop::IDocument* ); | 148 | void documentLoaded( KDevelop::IDocument* ); | ||
149 | void pluginLoaded(KDevelop::IPlugin* plugin); | ||||
150 | void unloadingPlugin(KDevelop::IPlugin* plugin); | ||||
151 | | ||||
141 | private: | 152 | private: | ||
142 | /** \return A modeline string (to add at the end or the beginning of a file) | 153 | /** \return A modeline string (to add at the end or the beginning of a file) | ||
143 | * corresponding to the settings of the active language. | 154 | * corresponding to the settings of the active language. | ||
144 | */ | 155 | */ | ||
145 | QString addModelineForCurrentLang(QString input, const QUrl& url, const QMimeType&); | 156 | QString addModelineForCurrentLang(QString input, const QUrl& url, const QMimeType&); | ||
146 | /** \return The name of kate indentation mode for the mime type. | 157 | /** \return The name of kate indentation mode for the mime type. | ||
147 | * examples are cstyle, python, etc. | 158 | * examples are cstyle, python, etc. | ||
148 | */ | 159 | */ | ||
149 | QString indentationMode(const QMimeType& mime); | 160 | QString indentationMode(const QMimeType& mime); | ||
150 | void formatDocument(KDevelop::IDocument* doc, ISourceFormatter* formatter, const QMimeType& mime); | 161 | void formatDocument(KDevelop::IDocument* doc, ISourceFormatter* formatter, const QMimeType& mime); | ||
151 | // Adapts the mode of the editor regarding indentation-style | 162 | // Adapts the mode of the editor regarding indentation-style | ||
152 | void adaptEditorIndentationMode(KTextEditor::Document* doc, KDevelop::ISourceFormatter* formatter, | 163 | void adaptEditorIndentationMode(KTextEditor::Document* doc, KDevelop::ISourceFormatter* formatter, | ||
153 | const QUrl& url, bool ignoreModeline = false); | 164 | const QUrl& url, bool ignoreModeline = false); | ||
154 | 165 | | |||
166 | void resetUi(); | ||||
167 | | ||||
155 | private: | 168 | private: | ||
156 | const QScopedPointer<class SourceFormatterControllerPrivate> d; | 169 | const QScopedPointer<class SourceFormatterControllerPrivate> d; | ||
157 | }; | 170 | }; | ||
158 | 171 | | |||
159 | } | 172 | } | ||
160 | 173 | | |||
161 | #endif // KDEVPLATFORM_SOURCEFORMATTERMANAGER_H | 174 | #endif // KDEVPLATFORM_SOURCEFORMATTERMANAGER_H |