forked from qt-creator/qt-creator
TextEditor: Remove itexteditor.{h,cpp}
Move the remaining contents to more appropriate places. Change-Id: I55eed5c572bd33dafe2187523d9aa381c211fdd6 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
#include "sourcemarker.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
|
||||
#include <QMutex>
|
||||
#include <QScopedPointer>
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "findinopenfiles.h"
|
||||
#include "itexteditor.h"
|
||||
#include "basetextdocument.h"
|
||||
#include "basetexteditor.h"
|
||||
|
||||
#include <utils/filesearch.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -28,7 +28,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "linenumberfilter.h"
|
||||
#include "itexteditor.h"
|
||||
#include "basetexteditor.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -88,8 +88,6 @@ QtcPlugin {
|
||||
"indenter.cpp",
|
||||
"indenter.h",
|
||||
"ioutlinewidget.h",
|
||||
"itexteditor.cpp",
|
||||
"itexteditor.h",
|
||||
"linenumberfilter.cpp",
|
||||
"linenumberfilter.h",
|
||||
"marginsettings.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>
|
||||
|
||||
Reference in New Issue
Block a user