summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp18
-rw-r--r--src/plugins/texteditor/basetexteditor.h17
-rw-r--r--src/plugins/texteditor/generichighlighter/manager.cpp3
-rw-r--r--src/plugins/texteditor/plaintexteditorfactory.cpp17
-rw-r--r--src/plugins/texteditor/plaintexteditorfactory.h6
-rw-r--r--src/plugins/texteditor/texteditorplugin.cpp9
-rw-r--r--src/plugins/texteditor/texteditorplugin.h3
7 files changed, 37 insertions, 36 deletions
diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
index 8877b1c41f..767192982b 100644
--- a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
+++ b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
@@ -35,6 +35,7 @@
#include <coreplugin/coreconstants.h>
#include <texteditor/basetexteditor.h>
+#include <texteditor/plaintexteditorfactory.h>
#include <utils/fileutils.h>
@@ -102,23 +103,20 @@ public:
QVERIFY(ast);
// Open file
- TextEditor::BaseTextDocumentPtr textDocument(new TextEditor::BaseTextDocument);
- textDocument->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
- TextEditor::BaseTextEditorWidget editorWidget(0);
- editorWidget.setTextDocument(textDocument);
- editorWidget.setupAsPlainEditor();
+ TextEditor::BaseTextEditor *editor = TextEditor::PlainTextEditorFactory::createPlainTextEditor();
+ TextEditor::BaseTextEditorWidget *editorWidget = editor->editorWidget();
QString error;
- editorWidget.open(&error, document->fileName(), document->fileName());
+ editor->open(&error, document->fileName(), document->fileName());
QVERIFY(error.isEmpty());
// Set cursor position
- QTextCursor cursor = editorWidget.textCursor();
+ QTextCursor cursor = editorWidget->textCursor();
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
- editorWidget.setTextCursor(cursor);
+ editorWidget->setTextCursor(cursor);
- QTextDocument *qtextDocument = editorWidget.document();
+ QTextDocument *qtextDocument = editorWidget->document();
CppRefactoringFilePtr cppRefactoringFile
- = CppRefactoringChanges::file(&editorWidget, document);
+ = CppRefactoringChanges::file(editorWidget, document);
// Prepare for formatting
Overview overview;
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index 96bac2379b..ed002ad325 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -77,19 +77,21 @@ namespace Internal {
class TextEditorOverlay;
}
-class BaseTextEditorWidget;
+class AutoCompleter;
+class BaseTextEditor;
class BaseTextEditorFactory;
-class FontSettings;
+class BaseTextEditorWidget;
+class PlainTextEditorFactory;
+
class BehaviorSettings;
class CompletionSettings;
class DisplaySettings;
+class ExtraEncodingSettings;
+class FontSettings;
+class Indenter;
class MarginSettings;
-class TypingSettings;
class StorageSettings;
-class Indenter;
-class AutoCompleter;
-class ExtraEncodingSettings;
-class BaseTextEditor;
+class TypingSettings;
class TEXTEDITOR_EXPORT BlockRange
{
@@ -640,6 +642,7 @@ public:
private:
friend class BaseTextEditor;
+ friend class PlainTextEditorFactory;
Core::IEditor *createEditor();
BaseTextEditor *createEditorHelper(const BaseTextDocumentPtr &doc);
diff --git a/src/plugins/texteditor/generichighlighter/manager.cpp b/src/plugins/texteditor/generichighlighter/manager.cpp
index 657d0521ca..08ffab425e 100644
--- a/src/plugins/texteditor/generichighlighter/manager.cpp
+++ b/src/plugins/texteditor/generichighlighter/manager.cpp
@@ -35,7 +35,6 @@
#include "highlightersettings.h"
#include <texteditor/plaintexteditorfactory.h>
#include <texteditor/texteditorconstants.h>
-#include <texteditor/texteditorplugin.h>
#include <texteditor/texteditorsettings.h>
#include <coreplugin/icore.h>
@@ -359,7 +358,7 @@ void Manager::registerMimeTypesFinished()
const QPair<RegisterData, QList<MimeType> > &result = m_registeringWatcher.result();
m_register = result.first;
- PlainTextEditorFactory *factory = TextEditorPlugin::editorFactory();
+ PlainTextEditorFactory *factory = PlainTextEditorFactory::instance();
const QSet<QString> &inFactory = factory->mimeTypes().toSet();
foreach (const MimeType &mimeType, result.second) {
MimeDatabase::addMimeType(mimeType);
diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp
index 33e8de572e..dbe83566e4 100644
--- a/src/plugins/texteditor/plaintexteditorfactory.cpp
+++ b/src/plugins/texteditor/plaintexteditorfactory.cpp
@@ -41,10 +41,10 @@
#include <utils/qtcassert.h>
#include <QCoreApplication>
-#include <QDebug>
namespace TextEditor {
-namespace Internal {
+
+static PlainTextEditorFactory *m_instance = 0;
class PlainTextEditorWidget : public BaseTextEditorWidget
{
@@ -55,6 +55,8 @@ public:
PlainTextEditorFactory::PlainTextEditorFactory()
{
+ QTC_CHECK(!m_instance);
+ m_instance = this;
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
@@ -69,5 +71,14 @@ PlainTextEditorFactory::PlainTextEditorFactory()
TextEditorActionHandler::UnCollapseAll);
}
-} // namespace Internal
+PlainTextEditorFactory *PlainTextEditorFactory::instance()
+{
+ return m_instance;
+}
+
+BaseTextEditor *PlainTextEditorFactory::createPlainTextEditor()
+{
+ return qobject_cast<BaseTextEditor *>(m_instance->createEditor());
+}
+
} // namespace TextEditor
diff --git a/src/plugins/texteditor/plaintexteditorfactory.h b/src/plugins/texteditor/plaintexteditorfactory.h
index 3ade4c07d5..8a90f1fc81 100644
--- a/src/plugins/texteditor/plaintexteditorfactory.h
+++ b/src/plugins/texteditor/plaintexteditorfactory.h
@@ -33,17 +33,17 @@
#include <texteditor/basetexteditor.h>
namespace TextEditor {
-namespace Internal {
-class PlainTextEditorFactory : public TextEditor::BaseTextEditorFactory
+class TEXTEDITOR_EXPORT PlainTextEditorFactory : public TextEditor::BaseTextEditorFactory
{
Q_OBJECT
public:
PlainTextEditorFactory();
+ static PlainTextEditorFactory *instance();
+ static BaseTextEditor *createPlainTextEditor();
};
-} // namespace Internal
} // namespace TextEditor
#endif // PLAINTEXTEDITORFACTORY_H
diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp
index f03dfac192..2548fde439 100644
--- a/src/plugins/texteditor/texteditorplugin.cpp
+++ b/src/plugins/texteditor/texteditorplugin.cpp
@@ -70,7 +70,6 @@ static TextEditorPlugin *m_instance = 0;
TextEditorPlugin::TextEditorPlugin()
: m_settings(0),
- m_editorFactory(0),
m_lineNumberFilter(0),
m_searchResultWindow(0)
{
@@ -154,8 +153,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
m_settings = new TextEditorSettings(this);
// Add plain text editor factory
- m_editorFactory = new PlainTextEditorFactory;
- addAutoReleasedObject(m_editorFactory);
+ addAutoReleasedObject(new PlainTextEditorFactory);
// Goto line functionality for quick open
m_lineNumberFilter = new LineNumberFilter;
@@ -261,11 +259,6 @@ void TextEditorPlugin::extensionsInitialized()
this, SLOT(updateCurrentSelection(QString)));
}
-PlainTextEditorFactory *TextEditorPlugin::editorFactory()
-{
- return m_instance->m_editorFactory;
-}
-
LineNumberFilter *TextEditorPlugin::lineNumberFilter()
{
return m_instance->m_lineNumberFilter;
diff --git a/src/plugins/texteditor/texteditorplugin.h b/src/plugins/texteditor/texteditorplugin.h
index 853b8d8b07..6b0b99c285 100644
--- a/src/plugins/texteditor/texteditorplugin.h
+++ b/src/plugins/texteditor/texteditorplugin.h
@@ -42,7 +42,6 @@ class TextEditorSettings;
namespace Internal {
class LineNumberFilter;
-class PlainTextEditorFactory;
class OutlineFactory;
class TextMarkRegistry;
@@ -59,7 +58,6 @@ public:
bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
- static PlainTextEditorFactory *editorFactory();
static LineNumberFilter *lineNumberFilter();
static TextMarkRegistry *baseTextMarkRegistry();
@@ -71,7 +69,6 @@ private slots:
private:
TextEditorSettings *m_settings;
- PlainTextEditorFactory *m_editorFactory;
LineNumberFilter *m_lineNumberFilter;
Core::SearchResultWindow *m_searchResultWindow;
OutlineFactory *m_outlineFactory;