summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-07-25 14:10:41 +0200
committerhjk <hjk121@nokiamail.com>2014-07-25 14:53:11 +0200
commit96d3449acdd22acb6991aa843fc4dd6c6ebaa7a6 (patch)
treea28a842b77705af182816b28cfd4b5c6a7b9cdd4
parent71c6d4d771d0e118bd715acc4433c98d8a7be3c8 (diff)
downloadqt-creator-96d3449acdd22acb6991aa843fc4dd6c6ebaa7a6.tar.gz
TextEditor: Remove itexteditor.{h,cpp}
Move the remaining contents to more appropriate places. Change-Id: I55eed5c572bd33dafe2187523d9aa381c211fdd6 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
-rw-r--r--src/plugins/clangcodemodel/semanticmarker.h2
-rw-r--r--src/plugins/texteditor/basetextdocument.cpp35
-rw-r--r--src/plugins/texteditor/basetextdocument.h22
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp14
-rw-r--r--src/plugins/texteditor/basetexteditor.h32
-rw-r--r--src/plugins/texteditor/findinopenfiles.cpp3
-rw-r--r--src/plugins/texteditor/itexteditor.cpp96
-rw-r--r--src/plugins/texteditor/itexteditor.h91
-rw-r--r--src/plugins/texteditor/linenumberfilter.cpp2
-rw-r--r--src/plugins/texteditor/texteditor.pro2
-rw-r--r--src/plugins/texteditor/texteditor.qbs2
-rw-r--r--src/plugins/texteditor/textmark.cpp3
12 files changed, 104 insertions, 200 deletions
diff --git a/src/plugins/clangcodemodel/semanticmarker.h b/src/plugins/clangcodemodel/semanticmarker.h
index 43959b4e27..744aece1c6 100644
--- a/src/plugins/clangcodemodel/semanticmarker.h
+++ b/src/plugins/clangcodemodel/semanticmarker.h
@@ -36,7 +36,7 @@
#include "sourcemarker.h"
#include "utils.h"
-#include <texteditor/itexteditor.h>
+#include <texteditor/basetexteditor.h>
#include <QMutex>
#include <QScopedPointer>
diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp
index 7e58efbff9..0d51aaa16b 100644
--- a/src/plugins/texteditor/basetextdocument.cpp
+++ b/src/plugins/texteditor/basetextdocument.cpp
@@ -59,11 +59,15 @@ using namespace Core;
\class TextEditor::BaseTextDocument
\brief The BaseTextDocument class is the base class for QTextDocument based documents.
+ It is the base class for documents used by implementations of the BaseTextEditor class,
+ and contains basic functions for retrieving text content and markers (like bookmarks).
+
Subclasses of BaseTextEditor can either use BaseTextDocument as is (and this is the default),
or created subclasses of BaseTextDocument if they have special requirements.
*/
namespace TextEditor {
+
class BaseTextDocumentPrivate : public QObject
{
Q_OBJECT
@@ -193,6 +197,37 @@ void BaseTextDocumentPrivate::onModificationChanged(bool modified)
updateRevisions();
}
+BaseTextEditorDocument::BaseTextEditorDocument(QObject *parent)
+ : Core::TextDocument(parent)
+{
+}
+
+QMap<QString, QString> BaseTextEditorDocument::openedTextDocumentContents()
+{
+ QMap<QString, QString> workingCopy;
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
+ BaseTextEditorDocument *textEditorDocument = qobject_cast<BaseTextEditorDocument *>(document);
+ if (!textEditorDocument)
+ continue;
+ QString fileName = textEditorDocument->filePath();
+ workingCopy[fileName] = textEditorDocument->plainText();
+ }
+ return workingCopy;
+}
+
+QMap<QString, QTextCodec *> BaseTextEditorDocument::openedTextDocumentEncodings()
+{
+ QMap<QString, QTextCodec *> workingCopy;
+ foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
+ BaseTextEditorDocument *textEditorDocument = qobject_cast<BaseTextEditorDocument *>(document);
+ if (!textEditorDocument)
+ continue;
+ QString fileName = textEditorDocument->filePath();
+ workingCopy[fileName] = const_cast<QTextCodec *>(textEditorDocument->codec());
+ }
+ return workingCopy;
+}
+
BaseTextDocument::BaseTextDocument() : d(new BaseTextDocumentPrivate(this))
{
connect(d->m_document, SIGNAL(modificationChanged(bool)), d, SLOT(onModificationChanged(bool)));
diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h
index 370a24ba9a..9b3f868dfb 100644
--- a/src/plugins/texteditor/basetextdocument.h
+++ b/src/plugins/texteditor/basetextdocument.h
@@ -32,9 +32,12 @@
#include "texteditor_global.h"
-#include "itexteditor.h"
+#include <coreplugin/textdocument.h>
+#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/editormanager/ieditor.h>
#include <QList>
+#include <QMap>
QT_BEGIN_NAMESPACE
class QTextCursor;
@@ -55,6 +58,23 @@ class TypingSettings;
typedef QList<TextMark *> TextMarks;
+class TEXTEDITOR_EXPORT BaseTextEditorDocument : public Core::TextDocument
+{
+ Q_OBJECT
+public:
+ explicit BaseTextEditorDocument(QObject *parent = 0);
+
+ virtual QString plainText() const = 0;
+ virtual QString textAt(int pos, int length) const = 0;
+ virtual QChar characterAt(int pos) const = 0;
+
+ static QMap<QString, QString> openedTextDocumentContents();
+ static QMap<QString, QTextCodec *> openedTextDocumentEncodings();
+
+signals:
+ void contentsChanged();
+};
+
class TEXTEDITOR_EXPORT BaseTextDocument : public BaseTextEditorDocument
{
Q_OBJECT
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 01a917b4f1..4fd46e17b4 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -113,6 +113,7 @@
is BaseTextEditorWidget.
*/
+
using namespace Core;
using namespace Utils;
@@ -6829,7 +6830,7 @@ IAssistInterface *BaseTextEditorWidget::createAssistInterface(AssistKind kind,
return new DefaultAssistInterface(document(), position(), d->m_document->filePath(), reason);
}
-QString TextEditor::BaseTextEditorWidget::foldReplacementText(const QTextBlock &) const
+QString BaseTextEditorWidget::foldReplacementText(const QTextBlock &) const
{
return QLatin1String("...");
}
@@ -6849,6 +6850,17 @@ bool BaseTextEditor::restoreState(const QByteArray &state)
return m_editorWidget->restoreState(state);
}
+BaseTextEditorDocument *BaseTextEditor::textDocument()
+{
+ return qobject_cast<BaseTextEditorDocument *>(document());
+}
+
+
+BaseTextEditor *BaseTextEditor::currentTextEditor()
+{
+ return qobject_cast<BaseTextEditor *>(Core::EditorManager::currentEditor());
+}
+
} // namespace TextEditor
#include "basetexteditor.moc"
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index 38595d56b8..c3371c490e 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -31,10 +31,12 @@
#define BASETEXTEDITOR_H
#include "basetextdocument.h"
-#include "itexteditor.h"
#include "codeassist/assistenums.h"
+#include "texteditor_global.h"
+#include <coreplugin/textdocument.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/find/ifindsupport.h>
#include <QPlainTextEdit>
@@ -43,9 +45,17 @@
QT_BEGIN_NAMESPACE
class QToolBar;
class QPrinter;
+class QMenu;
+class QPainter;
+class QPoint;
+class QRect;
+class QTextBlock;
QT_END_NAMESPACE
-namespace Utils { class LineColumnLabel; }
+namespace Utils {
+class CommentDefinition;
+class LineColumnLabel;
+}
namespace TextEditor {
@@ -77,6 +87,24 @@ class Indenter;
class AutoCompleter;
class ExtraEncodingSettings;
+class TEXTEDITOR_EXPORT BlockRange
+{
+public:
+ BlockRange() : _first(0), _last(-1) {}
+ BlockRange(int firstPosition, int lastPosition)
+ : _first(firstPosition), _last(lastPosition)
+ {}
+
+ inline bool isNull() const { return _last < _first; }
+
+ int first() const { return _first; }
+ int last() const { return _last; }
+
+private:
+ int _first;
+ int _last;
+};
+
class TEXTEDITOR_EXPORT BaseTextEditor : public Core::IEditor
{
Q_OBJECT
diff --git a/src/plugins/texteditor/findinopenfiles.cpp b/src/plugins/texteditor/findinopenfiles.cpp
index 9d15c02a7c..a46eb50acb 100644
--- a/src/plugins/texteditor/findinopenfiles.cpp
+++ b/src/plugins/texteditor/findinopenfiles.cpp
@@ -28,7 +28,8 @@
****************************************************************************/
#include "findinopenfiles.h"
-#include "itexteditor.h"
+#include "basetextdocument.h"
+#include "basetexteditor.h"
#include <utils/filesearch.h>
#include <coreplugin/icore.h>
diff --git a/src/plugins/texteditor/itexteditor.cpp b/src/plugins/texteditor/itexteditor.cpp
deleted file mode 100644
index 2da0838c59..0000000000
--- a/src/plugins/texteditor/itexteditor.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "basetexteditor.h"
-#include <coreplugin/editormanager/editormanager.h>
-
-#include <QTextCodec>
-
-namespace TextEditor {
-
-/*!
- \class TextEditor::BaseTextEditorDocument
- \brief The BaseTextEditorDocument class is an abstract base for documents of text editors.
-
- It is the base class for documents used by implementations of the BaseTextEditor class,
- and contains basic functions for retrieving text content and markers (like bookmarks).
-*/
-
-/*!
- \class TextEditor::BaseTextEditor
- \brief The BaseTextEditor class is an abstract base class for text editors.
-
- It contains the basic functions for retrieving and setting cursor position and selections,
- and operations on them, like removing or inserting. It uses implementations of
- BaseTextEditorDocument as the underlying document.
-*/
-
-BaseTextEditorDocument::BaseTextEditorDocument(QObject *parent)
- : Core::TextDocument(parent)
-{
-}
-
-QMap<QString, QString> BaseTextEditorDocument::openedTextDocumentContents()
-{
- QMap<QString, QString> workingCopy;
- foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
- BaseTextEditorDocument *textEditorDocument = qobject_cast<BaseTextEditorDocument *>(document);
- if (!textEditorDocument)
- continue;
- QString fileName = textEditorDocument->filePath();
- workingCopy[fileName] = textEditorDocument->plainText();
- }
- return workingCopy;
-}
-
-QMap<QString, QTextCodec *> BaseTextEditorDocument::openedTextDocumentEncodings()
-{
- QMap<QString, QTextCodec *> workingCopy;
- foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
- BaseTextEditorDocument *textEditorDocument = qobject_cast<BaseTextEditorDocument *>(document);
- if (!textEditorDocument)
- continue;
- QString fileName = textEditorDocument->filePath();
- workingCopy[fileName] = const_cast<QTextCodec *>(textEditorDocument->codec());
- }
- return workingCopy;
-}
-
-BaseTextEditorDocument *BaseTextEditor::textDocument()
-{
- return qobject_cast<BaseTextEditorDocument *>(document());
-}
-
-
-BaseTextEditor *BaseTextEditor::currentTextEditor()
-{
- return qobject_cast<BaseTextEditor *>(Core::EditorManager::currentEditor());
-}
-
-} // namespace TextEditor
diff --git a/src/plugins/texteditor/itexteditor.h b/src/plugins/texteditor/itexteditor.h
deleted file mode 100644
index 52b23f79ff..0000000000
--- a/src/plugins/texteditor/itexteditor.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef ITEXTEDITOR_H
-#define ITEXTEDITOR_H
-
-#include "texteditor_global.h"
-
-#include <coreplugin/textdocument.h>
-#include <coreplugin/editormanager/editormanager.h>
-#include <coreplugin/editormanager/ieditor.h>
-
-#include <QMap>
-
-QT_BEGIN_NAMESPACE
-class QMenu;
-class QPainter;
-class QPoint;
-class QRect;
-class QTextBlock;
-QT_END_NAMESPACE
-
-namespace Utils { class CommentDefinition; }
-
-namespace TextEditor {
-
-class TEXTEDITOR_EXPORT BlockRange
-{
-public:
- BlockRange() : _first(0), _last(-1) {}
- BlockRange(int firstPosition, int lastPosition)
- : _first(firstPosition), _last(lastPosition)
- {}
-
- inline bool isNull() const { return _last < _first; }
-
- int first() const { return _first; }
- int last() const { return _last; }
-
-private:
- int _first;
- int _last;
-};
-
-
-class TEXTEDITOR_EXPORT BaseTextEditorDocument : public Core::TextDocument
-{
- Q_OBJECT
-public:
- explicit BaseTextEditorDocument(QObject *parent = 0);
-
- virtual QString plainText() const = 0;
- virtual QString textAt(int pos, int length) const = 0;
- virtual QChar characterAt(int pos) const = 0;
-
- static QMap<QString, QString> openedTextDocumentContents();
- static QMap<QString, QTextCodec *> openedTextDocumentEncodings();
-
-signals:
- void contentsChanged();
-};
-
-} // namespace TextEditor
-
-#endif // ITEXTEDITOR_H
diff --git a/src/plugins/texteditor/linenumberfilter.cpp b/src/plugins/texteditor/linenumberfilter.cpp
index 3764bbedc7..4be1ef5efd 100644
--- a/src/plugins/texteditor/linenumberfilter.cpp
+++ b/src/plugins/texteditor/linenumberfilter.cpp
@@ -28,7 +28,7 @@
****************************************************************************/
#include "linenumberfilter.h"
-#include "itexteditor.h"
+#include "basetexteditor.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro
index 3c6c9f0b80..35589cad41 100644
--- a/src/plugins/texteditor/texteditor.pro
+++ b/src/plugins/texteditor/texteditor.pro
@@ -29,7 +29,6 @@ SOURCES += texteditorplugin.cpp \
findinopenfiles.cpp \
colorscheme.cpp \
colorschemeedit.cpp \
- itexteditor.cpp \
texteditoroverlay.cpp \
texteditoroptionspage.cpp \
basetextdocumentlayout.cpp \
@@ -126,7 +125,6 @@ HEADERS += texteditorplugin.h \
displaysettings.h \
displaysettingspage.h \
fontsettings.h \
- itexteditor.h \
linenumberfilter.h \
texteditor_global.h \
findinfiles.h \
diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs
index 800d632bc5..56037b203e 100644
--- a/src/plugins/texteditor/texteditor.qbs
+++ b/src/plugins/texteditor/texteditor.qbs
@@ -88,8 +88,6 @@ QtcPlugin {
"indenter.cpp",
"indenter.h",
"ioutlinewidget.h",
- "itexteditor.cpp",
- "itexteditor.h",
"linenumberfilter.cpp",
"linenumberfilter.h",
"marginsettings.cpp",
diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp
index e46dea0bd8..033b88b3fa 100644
--- a/src/plugins/texteditor/textmark.cpp
+++ b/src/plugins/texteditor/textmark.cpp
@@ -30,8 +30,7 @@
#include "textmark.h"
#include "basetextdocument.h"
#include "textmarkregistry.h"
-#include "itexteditor.h"
-#include "basetextdocument.h"
+#include "basetexteditor.h"
#include "texteditorplugin.h"
#include <coreplugin/editormanager/editormanager.h>