aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/texteditor/texteditor.pro1
-rw-r--r--src/plugins/texteditor/texteditor.qbs1
-rw-r--r--src/plugins/texteditor/texteditorplugin.cpp8
-rw-r--r--src/plugins/texteditor/texteditorplugin.h3
-rw-r--r--src/plugins/texteditor/textmark.cpp70
-rw-r--r--src/plugins/texteditor/textmark.h3
-rw-r--r--src/plugins/texteditor/textmarkregistry.h71
7 files changed, 52 insertions, 105 deletions
diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro
index a7635edae20..1ef00e05174 100644
--- a/src/plugins/texteditor/texteditor.pro
+++ b/src/plugins/texteditor/texteditor.pro
@@ -214,7 +214,6 @@ HEADERS += texteditorplugin.h \
circularclipboardassist.h \
textmark.h \
codeassist/keywordscompletionassist.h \
- textmarkregistry.h \
marginsettings.h \
blockrange.h \
completionsettingspage.h \
diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs
index a79f3368790..2b5f43e2478 100644
--- a/src/plugins/texteditor/texteditor.qbs
+++ b/src/plugins/texteditor/texteditor.qbs
@@ -143,7 +143,6 @@ Project {
"texteditorsettings.h",
"textmark.cpp",
"textmark.h",
- "textmarkregistry.h",
"textstyles.h",
"typingsettings.cpp",
"typingsettings.h",
diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp
index 6cf66f39646..4d5c4170a50 100644
--- a/src/plugins/texteditor/texteditorplugin.cpp
+++ b/src/plugins/texteditor/texteditorplugin.cpp
@@ -37,7 +37,6 @@
#include "snippets/snippetprovider.h"
#include "texteditoractionhandler.h"
#include "texteditorsettings.h"
-#include "textmarkregistry.h"
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
@@ -130,8 +129,6 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
m_outlineFactory = new OutlineFactory;
addAutoReleasedObject(m_outlineFactory);
- m_baseTextMarkRegistry = new TextMarkRegistry(this);
-
addAutoReleasedObject(new FindInFiles);
addAutoReleasedObject(new FindInCurrentFile);
addAutoReleasedObject(new FindInOpenFiles);
@@ -211,11 +208,6 @@ LineNumberFilter *TextEditorPlugin::lineNumberFilter()
return m_instance->m_lineNumberFilter;
}
-TextMarkRegistry *TextEditorPlugin::baseTextMarkRegistry()
-{
- return m_instance->m_baseTextMarkRegistry;
-}
-
void TextEditorPlugin::updateSearchResultsFont(const FontSettings &settings)
{
if (auto window = SearchResultWindow::instance()) {
diff --git a/src/plugins/texteditor/texteditorplugin.h b/src/plugins/texteditor/texteditorplugin.h
index 2109e23d27c..f3875afa40b 100644
--- a/src/plugins/texteditor/texteditorplugin.h
+++ b/src/plugins/texteditor/texteditorplugin.h
@@ -37,7 +37,6 @@ namespace Internal {
class LineNumberFilter;
class OutlineFactory;
-class TextMarkRegistry;
class TextEditorPlugin : public ExtensionSystem::IPlugin
{
@@ -55,7 +54,6 @@ public:
void extensionsInitialized();
static LineNumberFilter *lineNumberFilter();
- static TextMarkRegistry *baseTextMarkRegistry();
private:
void updateSearchResultsFont(const TextEditor::FontSettings &);
@@ -65,7 +63,6 @@ private:
TextEditorSettings *m_settings = nullptr;
LineNumberFilter *m_lineNumberFilter = nullptr;
OutlineFactory *m_outlineFactory = nullptr;
- TextMarkRegistry *m_baseTextMarkRegistry = nullptr;
#ifdef WITH_TESTS
private slots:
diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp
index 286cd2af41d..9b633823289 100644
--- a/src/plugins/texteditor/textmark.cpp
+++ b/src/plugins/texteditor/textmark.cpp
@@ -25,7 +25,6 @@
#include "textmark.h"
#include "textdocument.h"
-#include "textmarkregistry.h"
#include "texteditor.h"
#include "texteditorplugin.h"
@@ -41,6 +40,32 @@ using namespace TextEditor::Internal;
namespace TextEditor {
+class TextMarkRegistry : public QObject
+{
+ Q_OBJECT
+public:
+ static void add(TextMark *mark);
+ static bool remove(TextMark *mark);
+ static Utils::Theme::Color categoryColor(Core::Id category);
+ static bool categoryHasColor(Core::Id category);
+ static void setCategoryColor(Core::Id category, Utils::Theme::Color color);
+ static QString defaultToolTip(Core::Id category);
+ static void setDefaultToolTip(Core::Id category, const QString &toolTip);
+
+private:
+ TextMarkRegistry(QObject *parent);
+ static TextMarkRegistry* instance();
+ void editorOpened(Core::IEditor *editor);
+ void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName);
+ void allDocumentsRenamed(const QString &oldName, const QString &newName);
+
+ QHash<Utils::FileName, QSet<TextMark *> > m_marks;
+ QHash<Core::Id, Utils::Theme::Color> m_colors;
+ QHash<Core::Id, QString> m_defaultToolTips;
+};
+
+TextMarkRegistry *m_instance = nullptr;
+
TextMark::TextMark(const QString &fileName, int lineNumber, Id category, double widthFactor)
: m_baseTextDocument(0),
m_fileName(fileName),
@@ -51,12 +76,12 @@ TextMark::TextMark(const QString &fileName, int lineNumber, Id category, double
m_widthFactor(widthFactor)
{
if (!m_fileName.isEmpty())
- TextEditorPlugin::baseTextMarkRegistry()->add(this);
+ TextMarkRegistry::add(this);
}
TextMark::~TextMark()
{
- TextEditorPlugin::baseTextMarkRegistry()->remove(this);
+ TextMarkRegistry::remove(this);
if (m_baseTextDocument)
m_baseTextDocument->removeMark(this);
m_baseTextDocument = 0;
@@ -72,10 +97,10 @@ void TextMark::updateFileName(const QString &fileName)
if (fileName == m_fileName)
return;
if (!m_fileName.isEmpty())
- TextEditorPlugin::baseTextMarkRegistry()->remove(this);
+ TextMarkRegistry::remove(this);
m_fileName = fileName;
if (!m_fileName.isEmpty())
- TextEditorPlugin::baseTextMarkRegistry()->add(this);
+ TextMarkRegistry::add(this);
}
int TextMark::lineNumber() const
@@ -121,22 +146,22 @@ const QIcon &TextMark::icon() const
Theme::Color TextMark::categoryColor(Id category)
{
- return TextEditorPlugin::baseTextMarkRegistry()->categoryColor(category);
+ return TextMarkRegistry::categoryColor(category);
}
bool TextMark::categoryHasColor(Id category)
{
- return TextEditorPlugin::baseTextMarkRegistry()->categoryHasColor(category);
+ return TextMarkRegistry::categoryHasColor(category);
}
void TextMark::setCategoryColor(Id category, Theme::Color color)
{
- TextEditorPlugin::baseTextMarkRegistry()->setCategoryColor(category, color);
+ TextMarkRegistry::setCategoryColor(category, color);
}
void TextMark::setDefaultToolTip(Id category, const QString &toolTip)
{
- TextEditorPlugin::baseTextMarkRegistry()->setDefaultToolTip(category, toolTip);
+ TextMarkRegistry::setDefaultToolTip(category, toolTip);
}
void TextMark::updateMarker()
@@ -219,7 +244,7 @@ bool TextMark::addToolTipContent(QLayout *target)
{
QString text = m_toolTip;
if (text.isEmpty()) {
- text = TextEditorPlugin::baseTextMarkRegistry()->defaultToolTip(m_category);
+ text = TextMarkRegistry::defaultToolTip(m_category);
if (text.isEmpty())
return false;
}
@@ -267,7 +292,7 @@ TextMarkRegistry::TextMarkRegistry(QObject *parent)
void TextMarkRegistry::add(TextMark *mark)
{
- m_marks[FileName::fromString(mark->fileName())].insert(mark);
+ instance()->m_marks[FileName::fromString(mark->fileName())].insert(mark);
auto document = qobject_cast<TextDocument*>(DocumentModel::documentForFilePath(mark->fileName()));
if (!document)
return;
@@ -276,40 +301,47 @@ void TextMarkRegistry::add(TextMark *mark)
bool TextMarkRegistry::remove(TextMark *mark)
{
- return m_marks[FileName::fromString(mark->fileName())].remove(mark);
+ return instance()->m_marks[FileName::fromString(mark->fileName())].remove(mark);
}
Theme::Color TextMarkRegistry::categoryColor(Id category)
{
- return m_colors.value(category, Theme::ProjectExplorer_TaskWarn_TextMarkColor);
+ return instance()->m_colors.value(category, Theme::ProjectExplorer_TaskWarn_TextMarkColor);
}
bool TextMarkRegistry::categoryHasColor(Id category)
{
- return m_colors.contains(category);
+ return instance()->m_colors.contains(category);
}
void TextMarkRegistry::setCategoryColor(Id category, Theme::Color newColor)
{
- Theme::Color &color = m_colors[category];
+ Theme::Color &color = instance()->m_colors[category];
if (color == newColor)
return;
color = newColor;
}
-QString TextMarkRegistry::defaultToolTip(Id category) const
+QString TextMarkRegistry::defaultToolTip(Id category)
{
- return m_defaultToolTips[category];
+ return instance()->m_defaultToolTips[category];
}
void TextMarkRegistry::setDefaultToolTip(Id category, const QString &toolTip)
{
- QString &defaultToolTip = m_defaultToolTips[category];
+ QString &defaultToolTip = instance()->m_defaultToolTips[category];
if (defaultToolTip == toolTip)
return;
defaultToolTip = toolTip;
}
+TextMarkRegistry *TextMarkRegistry::instance()
+{
+ if (!m_instance)
+ m_instance = new TextMarkRegistry(TextEditorPlugin::instance());
+ return m_instance;
+}
+
void TextMarkRegistry::editorOpened(IEditor *editor)
{
auto document = qobject_cast<TextDocument *>(editor ? editor->document() : 0);
@@ -361,3 +393,5 @@ void TextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QString
}
} // namespace TextEditor
+
+#include "textmark.moc"
diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h
index 1eec26d17ac..ca6f3310647 100644
--- a/src/plugins/texteditor/textmark.h
+++ b/src/plugins/texteditor/textmark.h
@@ -45,8 +45,6 @@ namespace TextEditor {
class BaseTextEditor;
class TextDocument;
-namespace Internal { class TextMarkRegistry; }
-
class TEXTEDITOR_EXPORT TextMark
{
public:
@@ -102,7 +100,6 @@ public:
private:
Q_DISABLE_COPY(TextMark)
- friend class Internal::TextMarkRegistry;
TextDocument *m_baseTextDocument;
QString m_fileName;
diff --git a/src/plugins/texteditor/textmarkregistry.h b/src/plugins/texteditor/textmarkregistry.h
deleted file mode 100644
index a7e28f9c722..00000000000
--- a/src/plugins/texteditor/textmarkregistry.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <utils/fileutils.h>
-
-#include <QColor>
-#include <QHash>
-#include <QObject>
-#include <QSet>
-
-#include <coreplugin/id.h>
-#include <utils/theme/theme.h>
-
-namespace Core {
-class IEditor;
-class IDocument;
-}
-
-namespace TextEditor {
-class TextMark;
-namespace Internal {
-
-class TextMarkRegistry : public QObject
-{
- Q_OBJECT
-public:
- TextMarkRegistry(QObject *parent);
-
- void add(TextMark *mark);
- bool remove(TextMark *mark);
- Utils::Theme::Color categoryColor(Core::Id category);
- bool categoryHasColor(Core::Id category);
- void setCategoryColor(Core::Id category, Utils::Theme::Color color);
- QString defaultToolTip(Core::Id category) const;
- void setDefaultToolTip(Core::Id category, const QString &toolTip);
-private:
- void editorOpened(Core::IEditor *editor);
- void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName);
- void allDocumentsRenamed(const QString &oldName, const QString &newName);
-
- QHash<Utils::FileName, QSet<TextMark *> > m_marks;
- QHash<Core::Id, Utils::Theme::Color> m_colors;
- QHash<Core::Id, QString> m_defaultToolTips;
-};
-
-} // namespace Internal
-} // namespace TextEditor