diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index c33fc18a01b9b6dd444ad6ffabbb58eb9a363e55..f1f277e8eabff64f057bf22e8f557bd92163bc77 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -1868,7 +1868,8 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs) << QLatin1String(TextEditor::Constants::C_LABEL) << QLatin1String(TextEditor::Constants::C_COMMENT) << QLatin1String(TextEditor::Constants::C_DOXYGEN_COMMENT) - << QLatin1String(TextEditor::Constants::C_DOXYGEN_TAG); + << QLatin1String(TextEditor::Constants::C_DOXYGEN_TAG) + << QLatin1String(TextEditor::Constants::C_VISUAL_WHITESPACE); } const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories); diff --git a/src/plugins/cppeditor/cppeditorenums.h b/src/plugins/cppeditor/cppeditorenums.h index 72020fd0135c9792a7b1c1f0a1e17e013603f593..b11466b945a243d752be149d99a4ada9223b1d49 100644 --- a/src/plugins/cppeditor/cppeditorenums.h +++ b/src/plugins/cppeditor/cppeditorenums.h @@ -49,6 +49,7 @@ enum CppFormats { CppCommentFormat, CppDoxygenCommentFormat, CppDoxygenTagFormat, + CppVisualWhitespace, NumCppFormats }; diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index 1e1a200b8c82d4841982b9e389b65420cb75ea48..5a8de5500c2e4c068e9ebf8c9fe6f99ac1a17bea 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -44,7 +44,6 @@ using namespace CPlusPlus; CppHighlighter::CppHighlighter(QTextDocument *document) : QSyntaxHighlighter(document) { - visualSpaceFormat.setForeground(Qt::lightGray); } void CppHighlighter::highlightBlock(const QString &text) @@ -75,7 +74,7 @@ void CppHighlighter::highlightBlock(const QString &text) } TextEditDocumentLayout::clearParentheses(currentBlock()); if (text.length()) // the empty line can still contain whitespace - setFormat(0, text.length(), visualSpaceFormat); + setFormat(0, text.length(), m_formats[CppVisualWhitespace]); return; } @@ -98,7 +97,7 @@ void CppHighlighter::highlightBlock(const QString &text) if (previousTokenEnd != tk.position()) { setFormat(previousTokenEnd, tk.position() - previousTokenEnd, - visualSpaceFormat); + m_formats[CppVisualWhitespace]); } if (tk.is(T_LPAREN) || tk.is(T_LBRACE) || tk.is(T_LBRACKET)) { @@ -176,7 +175,7 @@ void CppHighlighter::highlightBlock(const QString &text) const SimpleToken tk = tokens.last(); const int lastTokenEnd = tk.position() + tk.length(); if (text.length() > lastTokenEnd) - setFormat(lastTokenEnd, text.length() - lastTokenEnd, visualSpaceFormat); + setFormat(lastTokenEnd, text.length() - lastTokenEnd, m_formats[CppVisualWhitespace]); } if (TextBlockUserData *userData = TextEditDocumentLayout::testUserData(currentBlock())) { diff --git a/src/plugins/cppeditor/cpphighlighter.h b/src/plugins/cppeditor/cpphighlighter.h index 8a777c6da5bb914d40ebdef5d32a504dd07a631a..291f213c558ed20d8f042181a5f9727c2ca9d3dc 100644 --- a/src/plugins/cppeditor/cpphighlighter.h +++ b/src/plugins/cppeditor/cpphighlighter.h @@ -65,7 +65,6 @@ private: bool isQtKeyword(const QStringRef &text) const; QTextCharFormat m_formats[NumCppFormats]; - QTextCharFormat visualSpaceFormat; }; } // namespace Internal diff --git a/src/plugins/qmleditor/qmleditor.cpp b/src/plugins/qmleditor/qmleditor.cpp index 18c69ca7d20929d2b735e6e1c6d3a1bef8b1cd77..2d68189a7a3022ed65366481215ed12250daddb4 100644 --- a/src/plugins/qmleditor/qmleditor.cpp +++ b/src/plugins/qmleditor/qmleditor.cpp @@ -46,6 +46,7 @@ #include <coreplugin/icore.h> #include <coreplugin/actionmanager/actionmanager.h> +#include <coreplugin/uniqueidmanager.h> #include <extensionsystem/pluginmanager.h> #include <texteditor/basetextdocument.h> #include <texteditor/fontsettings.h> @@ -364,14 +365,17 @@ protected: #endif }; -ScriptEditorEditable::ScriptEditorEditable(ScriptEditor *editor, const QList<int> &context) - : BaseTextEditorEditable(editor), m_context(context) +ScriptEditorEditable::ScriptEditorEditable(ScriptEditor *editor) + : BaseTextEditorEditable(editor) { + + Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance(); + m_context << uidm->uniqueIdentifier(QmlEditor::Constants::C_QMLEDITOR); + m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); } -ScriptEditor::ScriptEditor(const Context &context, QWidget *parent) : +ScriptEditor::ScriptEditor(QWidget *parent) : TextEditor::BaseTextEditor(parent), - m_context(context), m_methodCombo(0), m_modelManager(0) { @@ -411,7 +415,7 @@ QStringList ScriptEditor::words() const Core::IEditor *ScriptEditorEditable::duplicate(QWidget *parent) { - ScriptEditor *newEditor = new ScriptEditor(m_context, parent); + ScriptEditor *newEditor = new ScriptEditor(parent); newEditor->duplicateFrom(editor()); QmlEditorPlugin::instance()->initializeEditor(newEditor); return newEditor->editableInterface(); @@ -605,7 +609,8 @@ void ScriptEditor::setFontSettings(const TextEditor::FontSettings &fs) << QLatin1String(TextEditor::Constants::C_KEYWORD) << QLatin1String(TextEditor::Constants::C_PREPROCESSOR) << QLatin1String(TextEditor::Constants::C_LABEL) - << QLatin1String(TextEditor::Constants::C_COMMENT); + << QLatin1String(TextEditor::Constants::C_COMMENT) + << QLatin1String(TextEditor::Constants::C_VISUAL_WHITESPACE); } highlighter->setFormats(fs.toTextCharFormats(categories)); @@ -674,7 +679,7 @@ void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar typedCha TextEditor::BaseTextEditorEditable *ScriptEditor::createEditableInterface() { - ScriptEditorEditable *editable = new ScriptEditorEditable(this, m_context); + ScriptEditorEditable *editable = new ScriptEditorEditable(this); createToolBar(editable); return editable; } diff --git a/src/plugins/qmleditor/qmleditor.h b/src/plugins/qmleditor/qmleditor.h index 0e78bdbd2e7bcd846d521e048788247c9ad9f934..d6a1026e71aad4e115d5665273f8e9c42d33831e 100644 --- a/src/plugins/qmleditor/qmleditor.h +++ b/src/plugins/qmleditor/qmleditor.h @@ -59,7 +59,7 @@ class ScriptEditorEditable : public TextEditor::BaseTextEditorEditable Q_OBJECT public: - ScriptEditorEditable(ScriptEditor *, const QList<int> &); + ScriptEditorEditable(ScriptEditor *); QList<int> context() const; bool duplicateSupported() const { return true; } @@ -95,8 +95,7 @@ class ScriptEditor : public TextEditor::BaseTextEditor public: typedef QList<int> Context; - ScriptEditor(const Context &context, - QWidget *parent = 0); + ScriptEditor(QWidget *parent = 0); ~ScriptEditor(); QList<Declaration> declarations() const; diff --git a/src/plugins/qmleditor/qmleditorfactory.cpp b/src/plugins/qmleditor/qmleditorfactory.cpp index 2b8173404d475ae754e8e39d8aa13dc43f673bde..f89c93e2f67d9905353a989e1d4068767c04b81b 100644 --- a/src/plugins/qmleditor/qmleditorfactory.cpp +++ b/src/plugins/qmleditor/qmleditorfactory.cpp @@ -41,18 +41,15 @@ using namespace QmlEditor::Internal; using namespace QmlEditor::Constants; -QmlEditorFactory::QmlEditorFactory(const Context &context, QObject *parent) +QmlEditorFactory::QmlEditorFactory(QObject *parent) : Core::IEditorFactory(parent), m_kind(QLatin1String(C_QMLEDITOR)), - m_mimeTypes(QLatin1String(QmlEditor::Constants::QMLEDITOR_MIMETYPE)), - m_context(context), - m_actionHandler(new QmlEditorActionHandler) + m_mimeTypes(QLatin1String(QmlEditor::Constants::QMLEDITOR_MIMETYPE)) { } QmlEditorFactory::~QmlEditorFactory() { - delete m_actionHandler; } QString QmlEditorFactory::kind() const @@ -72,7 +69,7 @@ Core::IFile *QmlEditorFactory::open(const QString &fileName) Core::IEditor *QmlEditorFactory::createEditor(QWidget *parent) { - ScriptEditor *rc = new ScriptEditor(m_context, parent); + ScriptEditor *rc = new ScriptEditor(parent); QmlEditorPlugin::instance()->initializeEditor(rc); return rc->editableInterface(); } diff --git a/src/plugins/qmleditor/qmleditorfactory.h b/src/plugins/qmleditor/qmleditorfactory.h index af178e68c91e28000847a65f05cc84c7c4a97095..a3a3588953f5b17334b20876a87f0952549c1d90 100644 --- a/src/plugins/qmleditor/qmleditorfactory.h +++ b/src/plugins/qmleditor/qmleditorfactory.h @@ -48,9 +48,7 @@ class QmlEditorFactory : public Core::IEditorFactory Q_OBJECT public: - typedef QList<int> Context; - - QmlEditorFactory(const Context &context, QObject *parent); + QmlEditorFactory(QObject *parent); ~QmlEditorFactory(); virtual QStringList mimeTypes() const; @@ -62,9 +60,6 @@ public: private: const QString m_kind; const QStringList m_mimeTypes; - const Context m_context; - - TextEditor::TextEditorActionHandler *m_actionHandler; }; } // namespace Internal diff --git a/src/plugins/qmleditor/qmleditorplugin.cpp b/src/plugins/qmleditor/qmleditorplugin.cpp index c2cfc50db3fdf64e16325054565035fe5da58019..474268a69466f7b6eec8f203e955f2e542ba0196 100644 --- a/src/plugins/qmleditor/qmleditorplugin.cpp +++ b/src/plugins/qmleditor/qmleditorplugin.cpp @@ -92,13 +92,10 @@ bool QmlEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err m_modelManager = new QmlModelManager(this); addAutoReleasedObject(m_modelManager); - m_scriptcontext << core->uniqueIDManager()->uniqueIdentifier(QmlEditor::Constants::C_QMLEDITOR); - m_context = m_scriptcontext; - m_context << core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR); + QList<int> context; + context<< core->uniqueIDManager()->uniqueIdentifier(QmlEditor::Constants::C_QMLEDITOR); - registerActions(); - - m_editor = new QmlEditorFactory(m_context, this); + m_editor = new QmlEditorFactory(this); addObject(m_editor); Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); @@ -150,8 +147,4 @@ void QmlEditorPlugin::initializeEditor(QmlEditor::Internal::ScriptEditor *editor TextEditor::Internal::CompletionSupport::instance(), SLOT(autoComplete(ITextEditable*, bool))); } -void QmlEditorPlugin::registerActions() -{ -} - Q_EXPORT_PLUGIN(QmlEditorPlugin) diff --git a/src/plugins/qmleditor/qmleditorplugin.h b/src/plugins/qmleditor/qmleditorplugin.h index 85a15e22fa183083ef7e0ce835e93bf622d8650a..b28818c2e2af3d8f42c465729993afe871ed17cf 100644 --- a/src/plugins/qmleditor/qmleditorplugin.h +++ b/src/plugins/qmleditor/qmleditorplugin.h @@ -65,14 +65,8 @@ public: void initializeEditor(ScriptEditor *editor); private: - void registerActions(); - static QmlEditorPlugin *m_instance; - typedef QList<int> Context; - Context m_context; - Context m_scriptcontext; - QmlModelManagerInterface *m_modelManager; QmlFileWizard *m_wizard; QmlEditorFactory *m_editor; diff --git a/src/plugins/qtscripteditor/qtscripteditor.cpp b/src/plugins/qtscripteditor/qtscripteditor.cpp index 1d0481857fa99119747cc776b695ee9e5b5c212e..403571b14ccf36467f277c596ca42bfdaf912bf3 100644 --- a/src/plugins/qtscripteditor/qtscripteditor.cpp +++ b/src/plugins/qtscripteditor/qtscripteditor.cpp @@ -322,7 +322,8 @@ void ScriptEditor::setFontSettings(const TextEditor::FontSettings &fs) << QLatin1String(TextEditor::Constants::C_KEYWORD) << QLatin1String(TextEditor::Constants::C_PREPROCESSOR) << QLatin1String(TextEditor::Constants::C_LABEL) - << QLatin1String(TextEditor::Constants::C_COMMENT); + << QLatin1String(TextEditor::Constants::C_COMMENT) + << QLatin1String(TextEditor::Constants::C_VISUAL_WHITESPACE); } highlighter->setFormats(fs.toTextCharFormats(categories)); diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 721d8e330bd18613424ab638fcd4f5bcd58e5d2f..14e30ded054a3c5edbba5d2609d6e946158ef516 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -93,6 +93,7 @@ const char * const C_LABEL = "Label"; const char * const C_COMMENT = "Comment"; const char * const C_DOXYGEN_COMMENT = "Doxygen.Comment"; const char * const C_DOXYGEN_TAG = "Doxygen.Tag"; +const char * const C_VISUAL_WHITESPACE = "VisualWhitespace"; const char * const C_DISABLED_CODE = "DisabledCode"; @@ -101,6 +102,7 @@ const char * const C_REMOVED_LINE = "RemovedLine"; const char * const C_DIFF_FILE = "DiffFile"; const char * const C_DIFF_LOCATION = "DiffLocation"; + } // namespace Constants } // namespace TextEditor diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 7b0b8a4e330313134a99b880bb786d3ff02a1fe7..4b590093dd40074473429851b1537e35adf1cc79 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -92,6 +92,7 @@ TextEditorSettings::TextEditorSettings(QObject *parent) formatDescriptions.append(FormatDescription(QLatin1String(C_COMMENT), tr("Comment"), Qt::darkGreen)); formatDescriptions.append(FormatDescription(QLatin1String(C_DOXYGEN_COMMENT), tr("Doxygen Comment"), Qt::darkBlue)); formatDescriptions.append(FormatDescription(QLatin1String(C_DOXYGEN_TAG), tr("Doxygen Tag"), Qt::blue)); + formatDescriptions.append(FormatDescription(QLatin1String(C_VISUAL_WHITESPACE), tr("Visual Whitespace"), Qt::lightGray)); formatDescriptions.append(FormatDescription(QLatin1String(C_DISABLED_CODE), tr("Disabled Code"), Qt::gray)); // Diff categories diff --git a/src/shared/qscripthighlighter/qscripthighlighter.cpp b/src/shared/qscripthighlighter/qscripthighlighter.cpp index 5630d52921da5a3a8afdf093eeaada0f86bc0f9e..e96dd4146ce58077528ba3f79ff22cc651a0d28d 100644 --- a/src/shared/qscripthighlighter/qscripthighlighter.cpp +++ b/src/shared/qscripthighlighter/qscripthighlighter.cpp @@ -203,6 +203,7 @@ const QVector<QTextCharFormat> &QScriptHighlighter::defaultFormats() rc[CommentFormat].setForeground(Qt::red); rc[CommentFormat].setFontItalic(true); rc[PreProcessorFormat].setForeground(Qt::darkBlue); + rc[VisualWhitespace].setForeground(Qt::lightGray); } return rc; } diff --git a/src/shared/qscripthighlighter/qscripthighlighter.h b/src/shared/qscripthighlighter/qscripthighlighter.h index 61f5d4a32dbec16a68e7c971ada809fbbbd76f05..c9a66faeb59ed1004ab30b40c98815674c3863fc 100644 --- a/src/shared/qscripthighlighter/qscripthighlighter.h +++ b/src/shared/qscripthighlighter/qscripthighlighter.h @@ -47,6 +47,7 @@ public: enum { NumberFormat, StringFormat, TypeFormat, KeywordFormat, PreProcessorFormat, LabelFormat, CommentFormat, + VisualWhitespace, NumFormats }; bool isDuiEnabled() const;