forked from qt-creator/qt-creator
Rename {Core,TextEditor},{Base,}TextDocument classes
First step of some more 'Base' removal in TextEditor. s/Core::TextDocument/Core::BaseTextDocument/ s/TextEditor::BaseTextDocument/TextEditor::TextDocument/ Change-Id: I71ba325a2f0ad72ec9dae0d96846cbae72d326f7 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -50,7 +50,7 @@ AndroidManifestDocument::AndroidManifestDocument(AndroidManifestEditorWidget *ed
|
|||||||
bool AndroidManifestDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
bool AndroidManifestDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||||
{
|
{
|
||||||
m_editorWidget->preSave();
|
m_editorWidget->preSave();
|
||||||
return BaseTextDocument::save(errorString, fileName, autoSave);
|
return TextDocument::save(errorString, fileName, autoSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AndroidManifestDocument::defaultPath() const
|
QString AndroidManifestDocument::defaultPath() const
|
||||||
@@ -67,7 +67,7 @@ QString AndroidManifestDocument::suggestedFileName() const
|
|||||||
|
|
||||||
bool AndroidManifestDocument::isModified() const
|
bool AndroidManifestDocument::isModified() const
|
||||||
{
|
{
|
||||||
return BaseTextDocument::isModified() || m_editorWidget->isModified();
|
return TextDocument::isModified() || m_editorWidget->isModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManifestDocument::isSaveAsAllowed() const
|
bool AndroidManifestDocument::isSaveAsAllowed() const
|
||||||
|
@@ -37,7 +37,7 @@ namespace Internal {
|
|||||||
|
|
||||||
class AndroidManifestEditorWidget;
|
class AndroidManifestEditorWidget;
|
||||||
|
|
||||||
class AndroidManifestDocument : public TextEditor::BaseTextDocument
|
class AndroidManifestDocument : public TextEditor::TextDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit AndroidManifestDocument(AndroidManifestEditorWidget *editorWidget);
|
explicit AndroidManifestDocument(AndroidManifestEditorWidget *editorWidget);
|
||||||
|
@@ -66,7 +66,7 @@ public:
|
|||||||
// JavaDocument
|
// JavaDocument
|
||||||
//
|
//
|
||||||
|
|
||||||
class JavaDocument : public TextEditor::BaseTextDocument
|
class JavaDocument : public TextEditor::TextDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JavaDocument();
|
JavaDocument();
|
||||||
|
@@ -90,7 +90,7 @@ QList<TextEditor::BlockRange> toTextEditorBlocks(
|
|||||||
|
|
||||||
namespace ClangCodeModel {
|
namespace ClangCodeModel {
|
||||||
|
|
||||||
ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::BaseTextDocument *document)
|
ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::TextDocument *document)
|
||||||
: BaseEditorDocumentProcessor(document)
|
: BaseEditorDocumentProcessor(document)
|
||||||
, m_parser(document->filePath())
|
, m_parser(document->filePath())
|
||||||
, m_parserRevision(0)
|
, m_parserRevision(0)
|
||||||
|
@@ -46,7 +46,7 @@ class ClangEditorDocumentProcessor : public CppTools::BaseEditorDocumentProcesso
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClangEditorDocumentProcessor(TextEditor::BaseTextDocument *document);
|
ClangEditorDocumentProcessor(TextEditor::TextDocument *document);
|
||||||
~ClangEditorDocumentProcessor();
|
~ClangEditorDocumentProcessor();
|
||||||
|
|
||||||
// BaseEditorDocumentProcessor interface
|
// BaseEditorDocumentProcessor interface
|
||||||
|
@@ -63,7 +63,7 @@ CppTools::CppCompletionAssistProvider *ModelManagerSupport::completionAssistProv
|
|||||||
}
|
}
|
||||||
|
|
||||||
CppTools::BaseEditorDocumentProcessor *ModelManagerSupport::editorDocumentProcessor(
|
CppTools::BaseEditorDocumentProcessor *ModelManagerSupport::editorDocumentProcessor(
|
||||||
TextEditor::BaseTextDocument *baseTextDocument)
|
TextEditor::TextDocument *baseTextDocument)
|
||||||
{
|
{
|
||||||
return new ClangCodeModel::ClangEditorDocumentProcessor(baseTextDocument);
|
return new ClangCodeModel::ClangEditorDocumentProcessor(baseTextDocument);
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ public:
|
|||||||
|
|
||||||
virtual CppTools::CppCompletionAssistProvider *completionAssistProvider();
|
virtual CppTools::CppCompletionAssistProvider *completionAssistProvider();
|
||||||
virtual CppTools::BaseEditorDocumentProcessor *editorDocumentProcessor(
|
virtual CppTools::BaseEditorDocumentProcessor *editorDocumentProcessor(
|
||||||
TextEditor::BaseTextDocument *baseTextDocument);
|
TextEditor::TextDocument *baseTextDocument);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<CppTools::CppCompletionAssistProvider> m_completionAssistProvider;
|
QScopedPointer<CppTools::CppCompletionAssistProvider> m_completionAssistProvider;
|
||||||
|
@@ -71,7 +71,7 @@ CMakeEditor::CMakeEditor()
|
|||||||
void CMakeEditor::finalizeInitialization()
|
void CMakeEditor::finalizeInitialization()
|
||||||
{
|
{
|
||||||
connect(document(), &IDocument::changed, [this]() {
|
connect(document(), &IDocument::changed, [this]() {
|
||||||
BaseTextDocument *document = textDocument();
|
TextDocument *document = textDocument();
|
||||||
if (!document->isModified())
|
if (!document->isModified())
|
||||||
return;
|
return;
|
||||||
InfoBar *infoBar = document->infoBar();
|
InfoBar *infoBar = document->infoBar();
|
||||||
@@ -240,7 +240,7 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
// CMakeDocument
|
// CMakeDocument
|
||||||
//
|
//
|
||||||
|
|
||||||
class CMakeDocument : public BaseTextDocument
|
class CMakeDocument : public TextDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMakeDocument();
|
CMakeDocument();
|
||||||
|
@@ -48,10 +48,10 @@ enum { debug = 0 };
|
|||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class TextDocumentPrivate
|
class BaseTextDocumentPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextDocumentPrivate() : m_readResult(Utils::TextFileFormat::ReadSuccess) {}
|
BaseTextDocumentPrivate() : m_readResult(Utils::TextFileFormat::ReadSuccess) {}
|
||||||
|
|
||||||
Utils::TextFileFormat m_format;
|
Utils::TextFileFormat m_format;
|
||||||
Utils::TextFileFormat::ReadResult m_readResult;
|
Utils::TextFileFormat::ReadResult m_readResult;
|
||||||
@@ -60,23 +60,23 @@ public:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
TextDocument::TextDocument(QObject *parent) :
|
BaseTextDocument::BaseTextDocument(QObject *parent) :
|
||||||
IDocument(parent), d(new Internal::TextDocumentPrivate)
|
IDocument(parent), d(new Internal::BaseTextDocumentPrivate)
|
||||||
{
|
{
|
||||||
setCodec(Core::EditorManager::defaultTextCodec());
|
setCodec(Core::EditorManager::defaultTextCodec());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextDocument::~TextDocument()
|
BaseTextDocument::~BaseTextDocument()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextDocument::hasDecodingError() const
|
bool BaseTextDocument::hasDecodingError() const
|
||||||
{
|
{
|
||||||
return d->m_readResult == Utils::TextFileFormat::ReadEncodingError;
|
return d->m_readResult == Utils::TextFileFormat::ReadEncodingError;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray TextDocument::decodingErrorSample() const
|
QByteArray BaseTextDocument::decodingErrorSample() const
|
||||||
{
|
{
|
||||||
return d->m_decodingErrorSample;
|
return d->m_decodingErrorSample;
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ QByteArray TextDocument::decodingErrorSample() const
|
|||||||
Writes out text using the format obtained from the last read.
|
Writes out text using the format obtained from the last read.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool TextDocument::write(const QString &fileName, const QString &data, QString *errorMessage) const
|
bool BaseTextDocument::write(const QString &fileName, const QString &data, QString *errorMessage) const
|
||||||
{
|
{
|
||||||
return write(fileName, format(), data, errorMessage);
|
return write(fileName, format(), data, errorMessage);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ bool TextDocument::write(const QString &fileName, const QString &data, QString *
|
|||||||
Writes out text using a custom \a format.
|
Writes out text using a custom \a format.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool TextDocument::write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const
|
bool BaseTextDocument::write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << Q_FUNC_INFO << this << fileName;
|
qDebug() << Q_FUNC_INFO << this << fileName;
|
||||||
@@ -105,7 +105,7 @@ bool TextDocument::write(const QString &fileName, const Utils::TextFileFormat &f
|
|||||||
Autodetects format and reads in the text file specified by \a fileName.
|
Autodetects format and reads in the text file specified by \a fileName.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TextDocument::ReadResult TextDocument::read(const QString &fileName, QStringList *plainTextList, QString *errorString)
|
BaseTextDocument::ReadResult BaseTextDocument::read(const QString &fileName, QStringList *plainTextList, QString *errorString)
|
||||||
{
|
{
|
||||||
d->m_readResult =
|
d->m_readResult =
|
||||||
Utils::TextFileFormat::readFile(fileName, codec(),
|
Utils::TextFileFormat::readFile(fileName, codec(),
|
||||||
@@ -117,7 +117,7 @@ TextDocument::ReadResult TextDocument::read(const QString &fileName, QStringList
|
|||||||
Autodetects format and reads in the text file specified by \a fileName.
|
Autodetects format and reads in the text file specified by \a fileName.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TextDocument::ReadResult TextDocument::read(const QString &fileName, QString *plainText, QString *errorString)
|
BaseTextDocument::ReadResult BaseTextDocument::read(const QString &fileName, QString *plainText, QString *errorString)
|
||||||
{
|
{
|
||||||
d->m_readResult =
|
d->m_readResult =
|
||||||
Utils::TextFileFormat::readFile(fileName, codec(),
|
Utils::TextFileFormat::readFile(fileName, codec(),
|
||||||
@@ -125,19 +125,19 @@ TextDocument::ReadResult TextDocument::read(const QString &fileName, QString *pl
|
|||||||
return d->m_readResult;
|
return d->m_readResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QTextCodec *TextDocument::codec() const
|
const QTextCodec *BaseTextDocument::codec() const
|
||||||
{
|
{
|
||||||
return d->m_format.codec;
|
return d->m_format.codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextDocument::setCodec(const QTextCodec *codec)
|
void BaseTextDocument::setCodec(const QTextCodec *codec)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << Q_FUNC_INFO << this << (codec ? codec->name() : QByteArray());
|
qDebug() << Q_FUNC_INFO << this << (codec ? codec->name() : QByteArray());
|
||||||
d->m_format.codec = codec;
|
d->m_format.codec = codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextDocument::switchUtf8Bom()
|
void BaseTextDocument::switchUtf8Bom()
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << Q_FUNC_INFO << this << "UTF-8 BOM: " << !d->m_format.hasUtf8Bom;
|
qDebug() << Q_FUNC_INFO << this << "UTF-8 BOM: " << !d->m_format.hasUtf8Bom;
|
||||||
@@ -148,7 +148,7 @@ void TextDocument::switchUtf8Bom()
|
|||||||
Returns the format obtained from the last call to \c read().
|
Returns the format obtained from the last call to \c read().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Utils::TextFileFormat TextDocument::format() const
|
Utils::TextFileFormat BaseTextDocument::format() const
|
||||||
{
|
{
|
||||||
return d->m_format;
|
return d->m_format;
|
||||||
}
|
}
|
||||||
|
@@ -36,16 +36,17 @@
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
namespace Internal { class TextDocumentPrivate; }
|
namespace Internal { class BaseTextDocumentPrivate; }
|
||||||
|
|
||||||
class CORE_EXPORT TextDocument : public IDocument
|
class CORE_EXPORT BaseTextDocument : public IDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Utils::TextFileFormat::ReadResult ReadResult;
|
typedef Utils::TextFileFormat::ReadResult ReadResult;
|
||||||
|
|
||||||
explicit TextDocument(QObject *parent = 0);
|
explicit BaseTextDocument(QObject *parent = 0);
|
||||||
virtual ~TextDocument();
|
virtual ~BaseTextDocument();
|
||||||
|
|
||||||
Utils::TextFileFormat format() const;
|
Utils::TextFileFormat format() const;
|
||||||
const QTextCodec *codec() const;
|
const QTextCodec *codec() const;
|
||||||
@@ -63,7 +64,7 @@ public:
|
|||||||
bool write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const;
|
bool write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Internal::TextDocumentPrivate *d;
|
Internal::BaseTextDocumentPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -214,7 +214,7 @@ void CodepasterPlugin::postEditor()
|
|||||||
if (const BaseTextEditor *textEditor = qobject_cast<const BaseTextEditor *>(editor))
|
if (const BaseTextEditor *textEditor = qobject_cast<const BaseTextEditor *>(editor))
|
||||||
data = textEditor->selectedText();
|
data = textEditor->selectedText();
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
if (auto textDocument = qobject_cast<const BaseTextDocument *>(document))
|
if (auto textDocument = qobject_cast<const TextDocument *>(document))
|
||||||
data = textDocument->plainText();
|
data = textDocument->plainText();
|
||||||
}
|
}
|
||||||
post(data, mimeType);
|
post(data, mimeType);
|
||||||
|
@@ -706,7 +706,7 @@ void CppEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefL
|
|||||||
d->m_declDefLink = link;
|
d->m_declDefLink = link;
|
||||||
IDocument *targetDocument = DocumentModel::documentForFilePath( d->m_declDefLink->targetFile->fileName());
|
IDocument *targetDocument = DocumentModel::documentForFilePath( d->m_declDefLink->targetFile->fileName());
|
||||||
if (textDocument() != targetDocument) {
|
if (textDocument() != targetDocument) {
|
||||||
if (auto textDocument = qobject_cast<BaseTextDocument *>(targetDocument))
|
if (auto textDocument = qobject_cast<TextDocument *>(targetDocument))
|
||||||
connect(textDocument, SIGNAL(contentsChanged()),
|
connect(textDocument, SIGNAL(contentsChanged()),
|
||||||
this, SLOT(abortDeclDefLink()));
|
this, SLOT(abortDeclDefLink()));
|
||||||
}
|
}
|
||||||
@@ -741,7 +741,7 @@ void CppEditorWidget::abortDeclDefLink()
|
|||||||
|
|
||||||
IDocument *targetDocument = DocumentModel::documentForFilePath(d->m_declDefLink->targetFile->fileName());
|
IDocument *targetDocument = DocumentModel::documentForFilePath(d->m_declDefLink->targetFile->fileName());
|
||||||
if (textDocument() != targetDocument) {
|
if (textDocument() != targetDocument) {
|
||||||
if (auto textDocument = qobject_cast<BaseTextDocument *>(targetDocument))
|
if (auto textDocument = qobject_cast<TextDocument *>(targetDocument))
|
||||||
disconnect(textDocument, SIGNAL(contentsChanged()),
|
disconnect(textDocument, SIGNAL(contentsChanged()),
|
||||||
this, SLOT(abortDeclDefLink()));
|
this, SLOT(abortDeclDefLink()));
|
||||||
}
|
}
|
||||||
|
@@ -166,7 +166,7 @@ void CppEditorDocument::applyFontSettings()
|
|||||||
b = b.next();
|
b = b.next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BaseTextDocument::applyFontSettings(); // rehighlights and updates additional formats
|
TextDocument::applyFontSettings(); // rehighlights and updates additional formats
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorDocument::invalidateFormatterCache()
|
void CppEditorDocument::invalidateFormatterCache()
|
||||||
|
@@ -44,7 +44,7 @@
|
|||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class CppEditorDocument : public TextEditor::BaseTextDocument
|
class CppEditorDocument : public TextEditor::TextDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@@ -104,7 +104,7 @@ public:
|
|||||||
static void escape();
|
static void escape();
|
||||||
|
|
||||||
/// Undoing changes
|
/// Undoing changes
|
||||||
static void undoChangesInDocument(BaseTextDocument *editorDocument);
|
static void undoChangesInDocument(TextDocument *editorDocument);
|
||||||
static void undoChangesInAllEditorWidgets();
|
static void undoChangesInAllEditorWidgets();
|
||||||
|
|
||||||
/// Execute actions for the current cursor position of editorWidget.
|
/// Execute actions for the current cursor position of editorWidget.
|
||||||
@@ -255,7 +255,7 @@ void TestActionsTestCase::escape()
|
|||||||
QTest::keyClick(w, Qt::Key_Escape);
|
QTest::keyClick(w, Qt::Key_Escape);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestActionsTestCase::undoChangesInDocument(BaseTextDocument *editorDocument)
|
void TestActionsTestCase::undoChangesInDocument(TextDocument *editorDocument)
|
||||||
{
|
{
|
||||||
QTextDocument * const document = editorDocument->document();
|
QTextDocument * const document = editorDocument->document();
|
||||||
QVERIFY(document);
|
QVERIFY(document);
|
||||||
@@ -266,7 +266,7 @@ void TestActionsTestCase::undoChangesInDocument(BaseTextDocument *editorDocument
|
|||||||
void TestActionsTestCase::undoChangesInAllEditorWidgets()
|
void TestActionsTestCase::undoChangesInAllEditorWidgets()
|
||||||
{
|
{
|
||||||
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
||||||
BaseTextDocument *baseTextDocument = qobject_cast<BaseTextDocument *>(document);
|
TextDocument *baseTextDocument = qobject_cast<TextDocument *>(document);
|
||||||
undoChangesInDocument(baseTextDocument);
|
undoChangesInDocument(baseTextDocument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ namespace CppTools {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
BaseEditorDocumentProcessor::BaseEditorDocumentProcessor(
|
BaseEditorDocumentProcessor::BaseEditorDocumentProcessor(
|
||||||
TextEditor::BaseTextDocument *document)
|
TextEditor::TextDocument *document)
|
||||||
: m_baseTextDocument(document)
|
: m_baseTextDocument(document)
|
||||||
{
|
{
|
||||||
QTC_CHECK(document);
|
QTC_CHECK(document);
|
||||||
@@ -57,7 +57,7 @@ BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditor::BaseTextDocument *BaseEditorDocumentProcessor::baseTextDocument() const
|
TextEditor::TextDocument *BaseEditorDocumentProcessor::baseTextDocument() const
|
||||||
{
|
{
|
||||||
return m_baseTextDocument;
|
return m_baseTextDocument;
|
||||||
}
|
}
|
||||||
|
@@ -49,10 +49,10 @@ class CPPTOOLS_EXPORT BaseEditorDocumentProcessor : public QObject
|
|||||||
BaseEditorDocumentProcessor();
|
BaseEditorDocumentProcessor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BaseEditorDocumentProcessor(TextEditor::BaseTextDocument *document);
|
BaseEditorDocumentProcessor(TextEditor::TextDocument *document);
|
||||||
virtual ~BaseEditorDocumentProcessor();
|
virtual ~BaseEditorDocumentProcessor();
|
||||||
|
|
||||||
TextEditor::BaseTextDocument *baseTextDocument() const;
|
TextEditor::TextDocument *baseTextDocument() const;
|
||||||
|
|
||||||
// Function interface to implement
|
// Function interface to implement
|
||||||
virtual void run() = 0;
|
virtual void run() = 0;
|
||||||
@@ -90,7 +90,7 @@ protected:
|
|||||||
QTextDocument *textDocument() const { return m_baseTextDocument->document(); }
|
QTextDocument *textDocument() const { return m_baseTextDocument->document(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextEditor::BaseTextDocument *m_baseTextDocument;
|
TextEditor::TextDocument *m_baseTextDocument;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
@@ -123,7 +123,7 @@ QList<TextEditor::BlockRange> toTextEditorBlocks(
|
|||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
||||||
TextEditor::BaseTextDocument *document,
|
TextEditor::TextDocument *document,
|
||||||
bool enableSemanticHighlighter)
|
bool enableSemanticHighlighter)
|
||||||
: BaseEditorDocumentProcessor(document)
|
: BaseEditorDocumentProcessor(document)
|
||||||
, m_parser(document->filePath())
|
, m_parser(document->filePath())
|
||||||
|
@@ -45,7 +45,7 @@ class CPPTOOLS_EXPORT BuiltinEditorDocumentProcessor : public BaseEditorDocument
|
|||||||
BuiltinEditorDocumentProcessor();
|
BuiltinEditorDocumentProcessor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BuiltinEditorDocumentProcessor(TextEditor::BaseTextDocument *document,
|
BuiltinEditorDocumentProcessor(TextEditor::TextDocument *document,
|
||||||
bool enableSemanticHighlighter = true);
|
bool enableSemanticHighlighter = true);
|
||||||
~BuiltinEditorDocumentProcessor();
|
~BuiltinEditorDocumentProcessor();
|
||||||
|
|
||||||
|
@@ -952,7 +952,7 @@ CppCompletionAssistProvider *CppModelManager::completionAssistProvider(const QSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseEditorDocumentProcessor *CppModelManager::editorDocumentProcessor(
|
BaseEditorDocumentProcessor *CppModelManager::editorDocumentProcessor(
|
||||||
TextEditor::BaseTextDocument *baseTextDocument) const
|
TextEditor::TextDocument *baseTextDocument) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(baseTextDocument, return 0);
|
QTC_ASSERT(baseTextDocument, return 0);
|
||||||
ModelManagerSupport *cms = modelManagerSupportForMimeType(baseTextDocument->mimeType());
|
ModelManagerSupport *cms = modelManagerSupportForMimeType(baseTextDocument->mimeType());
|
||||||
|
@@ -47,7 +47,7 @@
|
|||||||
namespace Core { class IEditor; }
|
namespace Core { class IEditor; }
|
||||||
namespace CPlusPlus { class LookupContext; }
|
namespace CPlusPlus { class LookupContext; }
|
||||||
namespace ProjectExplorer { class Project; }
|
namespace ProjectExplorer { class Project; }
|
||||||
namespace TextEditor { class BaseTextDocument; }
|
namespace TextEditor { class TextDocument; }
|
||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ public:
|
|||||||
ModelManagerSupport *modelManagerSupportForMimeType(const QString &mimeType) const;
|
ModelManagerSupport *modelManagerSupportForMimeType(const QString &mimeType) const;
|
||||||
CppCompletionAssistProvider *completionAssistProvider(const QString &mimeType) const;
|
CppCompletionAssistProvider *completionAssistProvider(const QString &mimeType) const;
|
||||||
BaseEditorDocumentProcessor *editorDocumentProcessor(
|
BaseEditorDocumentProcessor *editorDocumentProcessor(
|
||||||
TextEditor::BaseTextDocument *baseTextDocument) const;
|
TextEditor::TextDocument *baseTextDocument) const;
|
||||||
|
|
||||||
void setIndexingSupport(CppIndexingSupport *indexingSupport);
|
void setIndexingSupport(CppIndexingSupport *indexingSupport);
|
||||||
CppIndexingSupport *indexingSupport();
|
CppIndexingSupport *indexingSupport();
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace TextEditor { class BaseTextDocument; }
|
namespace TextEditor { class TextDocument; }
|
||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
virtual CppCompletionAssistProvider *completionAssistProvider() = 0;
|
virtual CppCompletionAssistProvider *completionAssistProvider() = 0;
|
||||||
virtual BaseEditorDocumentProcessor *editorDocumentProcessor(
|
virtual BaseEditorDocumentProcessor *editorDocumentProcessor(
|
||||||
TextEditor::BaseTextDocument *baseTextDocument) = 0;
|
TextEditor::TextDocument *baseTextDocument) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // CppTools namespace
|
} // CppTools namespace
|
||||||
|
@@ -57,7 +57,7 @@ QString ModelManagerSupportInternal::displayName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseEditorDocumentProcessor *ModelManagerSupportInternal::editorDocumentProcessor(
|
BaseEditorDocumentProcessor *ModelManagerSupportInternal::editorDocumentProcessor(
|
||||||
TextEditor::BaseTextDocument *baseTextDocument)
|
TextEditor::TextDocument *baseTextDocument)
|
||||||
{
|
{
|
||||||
return new BuiltinEditorDocumentProcessor(baseTextDocument);
|
return new BuiltinEditorDocumentProcessor(baseTextDocument);
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ public:
|
|||||||
|
|
||||||
virtual CppCompletionAssistProvider *completionAssistProvider();
|
virtual CppCompletionAssistProvider *completionAssistProvider();
|
||||||
virtual BaseEditorDocumentProcessor *editorDocumentProcessor(
|
virtual BaseEditorDocumentProcessor *editorDocumentProcessor(
|
||||||
TextEditor::BaseTextDocument *baseTextDocument);
|
TextEditor::TextDocument *baseTextDocument);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<CppCompletionAssistProvider> m_completionAssistProvider;
|
QScopedPointer<CppCompletionAssistProvider> m_completionAssistProvider;
|
||||||
|
@@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
virtual void indentSelection(const QTextCursor &selection,
|
virtual void indentSelection(const QTextCursor &selection,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const TextEditor::BaseTextDocument *textDocument) const
|
const TextEditor::TextDocument *textDocument) const
|
||||||
{
|
{
|
||||||
const TextEditor::TabSettings &tabSettings =
|
const TextEditor::TabSettings &tabSettings =
|
||||||
ProjectExplorer::actualTabSettings(fileName, textDocument);
|
ProjectExplorer::actualTabSettings(fileName, textDocument);
|
||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
virtual void reindentSelection(const QTextCursor &selection,
|
virtual void reindentSelection(const QTextCursor &selection,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const TextEditor::BaseTextDocument *textDocument) const
|
const TextEditor::TextDocument *textDocument) const
|
||||||
{
|
{
|
||||||
const TextEditor::TabSettings &tabSettings =
|
const TextEditor::TabSettings &tabSettings =
|
||||||
ProjectExplorer::actualTabSettings(fileName, textDocument);
|
ProjectExplorer::actualTabSettings(fileName, textDocument);
|
||||||
|
@@ -42,14 +42,14 @@ using TextEditor::SemanticHighlighter::clearExtraAdditionalFormatsUntilEnd;
|
|||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
SemanticHighlighter::SemanticHighlighter(TextEditor::BaseTextDocument *baseTextDocument)
|
SemanticHighlighter::SemanticHighlighter(TextEditor::TextDocument *baseTextDocument)
|
||||||
: QObject(baseTextDocument)
|
: QObject(baseTextDocument)
|
||||||
, m_baseTextDocument(baseTextDocument)
|
, m_baseTextDocument(baseTextDocument)
|
||||||
, m_revision(0)
|
, m_revision(0)
|
||||||
{
|
{
|
||||||
QTC_CHECK(m_baseTextDocument);
|
QTC_CHECK(m_baseTextDocument);
|
||||||
|
|
||||||
connect(baseTextDocument, &TextEditor::BaseTextDocument::fontSettingsChanged,
|
connect(baseTextDocument, &TextEditor::TextDocument::fontSettingsChanged,
|
||||||
this, &SemanticHighlighter::onDocumentFontSettingsChanged);
|
this, &SemanticHighlighter::onDocumentFontSettingsChanged);
|
||||||
|
|
||||||
updateFormatMapFromFontSettings();
|
updateFormatMapFromFontSettings();
|
||||||
|
@@ -67,7 +67,7 @@ public:
|
|||||||
typedef std::function<QFuture<TextEditor::HighlightingResult> ()> HighlightingRunner;
|
typedef std::function<QFuture<TextEditor::HighlightingResult> ()> HighlightingRunner;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SemanticHighlighter(TextEditor::BaseTextDocument *baseTextDocument);
|
explicit SemanticHighlighter(TextEditor::TextDocument *baseTextDocument);
|
||||||
~SemanticHighlighter();
|
~SemanticHighlighter();
|
||||||
|
|
||||||
void setHighlightingRunner(HighlightingRunner highlightingRunner);
|
void setHighlightingRunner(HighlightingRunner highlightingRunner);
|
||||||
@@ -88,7 +88,7 @@ private:
|
|||||||
void updateFormatMapFromFontSettings();
|
void updateFormatMapFromFontSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextEditor::BaseTextDocument *m_baseTextDocument;
|
TextEditor::TextDocument *m_baseTextDocument;
|
||||||
|
|
||||||
unsigned m_revision;
|
unsigned m_revision;
|
||||||
QScopedPointer<QFutureWatcher<TextEditor::HighlightingResult>> m_watcher;
|
QScopedPointer<QFutureWatcher<TextEditor::HighlightingResult>> m_watcher;
|
||||||
|
@@ -1879,7 +1879,7 @@ void DebuggerPluginPrivate::requestContextMenu(BaseTextEditor *editor,
|
|||||||
bool contextUsable = true;
|
bool contextUsable = true;
|
||||||
|
|
||||||
BreakpointModelId id = BreakpointModelId();
|
BreakpointModelId id = BreakpointModelId();
|
||||||
BaseTextDocument *document = editor->textDocument();
|
TextDocument *document = editor->textDocument();
|
||||||
args.fileName = document->filePath();
|
args.fileName = document->filePath();
|
||||||
if (document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool()) {
|
if (document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool()) {
|
||||||
QString line = document->plainText()
|
QString line = document->plainText()
|
||||||
|
@@ -100,7 +100,7 @@ public:
|
|||||||
DisassemblerLines contentsAtCurrentLocation() const;
|
DisassemblerLines contentsAtCurrentLocation() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QPointer<BaseTextDocument> document;
|
QPointer<TextDocument> document;
|
||||||
Location location;
|
Location location;
|
||||||
QPointer<DebuggerEngine> engine;
|
QPointer<DebuggerEngine> engine;
|
||||||
TextMark locationMark;
|
TextMark locationMark;
|
||||||
@@ -291,7 +291,7 @@ void DisassemblerAgent::setContentsToDocument(const DisassemblerLines &contents)
|
|||||||
widget->setReadOnly(true);
|
widget->setReadOnly(true);
|
||||||
widget->setRequestMarkEnabled(true);
|
widget->setRequestMarkEnabled(true);
|
||||||
}
|
}
|
||||||
d->document = qobject_cast<BaseTextDocument *>(editor->document());
|
d->document = qobject_cast<TextDocument *>(editor->document());
|
||||||
QTC_ASSERT(d->document, return);
|
QTC_ASSERT(d->document, return);
|
||||||
d->document->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
|
d->document->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
|
||||||
d->document->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
|
d->document->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
|
||||||
|
@@ -1325,8 +1325,8 @@ void QmlEngine::updateScriptSource(const QString &fileName, int lineOffset, int
|
|||||||
|
|
||||||
void QmlEngine::updateDocument(Core::IDocument *document, const QTextDocument *textDocument)
|
void QmlEngine::updateDocument(Core::IDocument *document, const QTextDocument *textDocument)
|
||||||
{
|
{
|
||||||
TextEditor::BaseTextDocument *baseTextDocument
|
TextEditor::TextDocument *baseTextDocument
|
||||||
= qobject_cast<TextEditor::BaseTextDocument *>(document);
|
= qobject_cast<TextEditor::TextDocument *>(document);
|
||||||
if (!baseTextDocument)
|
if (!baseTextDocument)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -262,7 +262,7 @@ bool getUninitializedVariables(const Snapshot &snapshot,
|
|||||||
// Editor tooltip support
|
// Editor tooltip support
|
||||||
bool isCppEditor(BaseTextEditorWidget *editorWidget)
|
bool isCppEditor(BaseTextEditorWidget *editorWidget)
|
||||||
{
|
{
|
||||||
const BaseTextDocument *document = editorWidget->textDocument();
|
const TextDocument *document = editorWidget->textDocument();
|
||||||
return ProjectFile::classify(document->filePath()) != ProjectFile::Unclassified;
|
return ProjectFile::classify(document->filePath()) != ProjectFile::Unclassified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ namespace Internal {
|
|||||||
|
|
||||||
class ResourceHandler;
|
class ResourceHandler;
|
||||||
|
|
||||||
class FormWindowFile : public TextEditor::BaseTextDocument
|
class FormWindowFile : public TextEditor::TextDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
namespace DiffEditor {
|
namespace DiffEditor {
|
||||||
|
|
||||||
DiffEditorDocument::DiffEditorDocument() :
|
DiffEditorDocument::DiffEditorDocument() :
|
||||||
Core::TextDocument(),
|
Core::BaseTextDocument(),
|
||||||
m_controller(new DiffEditorController(this))
|
m_controller(new DiffEditorController(this))
|
||||||
{
|
{
|
||||||
setId(Constants::DIFF_EDITOR_ID);
|
setId(Constants::DIFF_EDITOR_ID);
|
||||||
|
@@ -38,7 +38,7 @@ namespace DiffEditor {
|
|||||||
|
|
||||||
class DiffEditorController;
|
class DiffEditorController;
|
||||||
|
|
||||||
class DIFFEDITOR_EXPORT DiffEditorDocument : public Core::TextDocument
|
class DIFFEDITOR_EXPORT DiffEditorDocument : public Core::BaseTextDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@@ -1876,8 +1876,8 @@ void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
|
|||||||
// Context(FAKEVIM_CONTEXT));
|
// Context(FAKEVIM_CONTEXT));
|
||||||
resetCommandBuffer();
|
resetCommandBuffer();
|
||||||
foreach (IEditor *editor, m_editorToHandler.keys()) {
|
foreach (IEditor *editor, m_editorToHandler.keys()) {
|
||||||
if (BaseTextDocument *textDocument =
|
if (TextDocument *textDocument =
|
||||||
qobject_cast<BaseTextDocument *>(editor->document())) {
|
qobject_cast<TextDocument *>(editor->document())) {
|
||||||
m_editorToHandler[editor]->restoreWidget(textDocument->tabSettings().m_tabSize);
|
m_editorToHandler[editor]->restoreWidget(textDocument->tabSettings().m_tabSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,7 @@ ProjectFilesFactory::ProjectFilesFactory()
|
|||||||
addMimeType(Constants::INCLUDES_MIMETYPE);
|
addMimeType(Constants::INCLUDES_MIMETYPE);
|
||||||
addMimeType(Constants::CONFIG_MIMETYPE);
|
addMimeType(Constants::CONFIG_MIMETYPE);
|
||||||
|
|
||||||
setDocumentCreator([]() { return new BaseTextDocument(Constants::FILES_EDITOR_ID); });
|
setDocumentCreator([]() { return new TextDocument(Constants::FILES_EDITOR_ID); });
|
||||||
setEditorActionHandlers(TextEditorActionHandler::None);
|
setEditorActionHandlers(TextEditorActionHandler::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -337,7 +337,7 @@ GlslEditorFactory::GlslEditorFactory()
|
|||||||
addMimeType(Constants::GLSL_MIMETYPE_VERT_ES);
|
addMimeType(Constants::GLSL_MIMETYPE_VERT_ES);
|
||||||
addMimeType(Constants::GLSL_MIMETYPE_FRAG_ES);
|
addMimeType(Constants::GLSL_MIMETYPE_FRAG_ES);
|
||||||
|
|
||||||
setDocumentCreator([]() { return new BaseTextDocument(Constants::C_GLSLEDITOR_ID); });
|
setDocumentCreator([]() { return new TextDocument(Constants::C_GLSLEDITOR_ID); });
|
||||||
setEditorWidgetCreator([]() { return new GlslEditorWidget; });
|
setEditorWidgetCreator([]() { return new GlslEditorWidget; });
|
||||||
setIndenterCreator([]() { return new GlslIndenter; });
|
setIndenterCreator([]() { return new GlslIndenter; });
|
||||||
setSyntaxHighlighterCreator([]() { return new GlslHighlighter; });
|
setSyntaxHighlighterCreator([]() { return new GlslHighlighter; });
|
||||||
|
@@ -77,7 +77,7 @@ void GlslHighlighter::highlightBlock(const QString &text)
|
|||||||
lex.setScanKeywords(false);
|
lex.setScanKeywords(false);
|
||||||
lex.setScanComments(true);
|
lex.setScanComments(true);
|
||||||
const int variant = languageVariant(parent()
|
const int variant = languageVariant(parent()
|
||||||
? static_cast<BaseTextDocument*>(parent())->mimeType()
|
? static_cast<TextDocument*>(parent())->mimeType()
|
||||||
: QString());
|
: QString());
|
||||||
lex.setVariant(variant);
|
lex.setVariant(variant);
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ Utils::FileIterator *AllProjectsFind::filesForProjects(const QStringList &nameFi
|
|||||||
foreach (const QString &filter, nameFilters) {
|
foreach (const QString &filter, nameFilters) {
|
||||||
filterRegs << QRegExp(filter, Qt::CaseInsensitive, QRegExp::Wildcard);
|
filterRegs << QRegExp(filter, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||||
}
|
}
|
||||||
QMap<QString, QTextCodec *> openEditorEncodings = BaseTextDocument::openedTextDocumentEncodings();
|
QMap<QString, QTextCodec *> openEditorEncodings = TextDocument::openedTextDocumentEncodings();
|
||||||
QMap<QString, QTextCodec *> encodings;
|
QMap<QString, QTextCodec *> encodings;
|
||||||
foreach (const Project *project, projects) {
|
foreach (const Project *project, projects) {
|
||||||
QStringList projectFiles = project->files(Project::AllFiles);
|
QStringList projectFiles = project->files(Project::AllFiles);
|
||||||
|
@@ -405,7 +405,7 @@ void EditorConfiguration::editorsClosed(const QList<Core::IEditor*> &closedEdito
|
|||||||
}
|
}
|
||||||
|
|
||||||
TabSettings actualTabSettings(const QString &fileName,
|
TabSettings actualTabSettings(const QString &fileName,
|
||||||
const BaseTextDocument *baseTextdocument)
|
const TextDocument *baseTextdocument)
|
||||||
{
|
{
|
||||||
if (baseTextdocument)
|
if (baseTextdocument)
|
||||||
return baseTextdocument->tabSettings();
|
return baseTextdocument->tabSettings();
|
||||||
|
@@ -43,7 +43,7 @@ class Id;
|
|||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
class BaseTextEditor;
|
class BaseTextEditor;
|
||||||
class BaseTextEditorWidget;
|
class BaseTextEditorWidget;
|
||||||
class BaseTextDocument;
|
class TextDocument;
|
||||||
class TabSettings;
|
class TabSettings;
|
||||||
class ICodeStylePreferences;
|
class ICodeStylePreferences;
|
||||||
class TypingSettings;
|
class TypingSettings;
|
||||||
@@ -121,7 +121,7 @@ private:
|
|||||||
// the file belongs to and return the project settings. If the file doesn't belong to any
|
// the file belongs to and return the project settings. If the file doesn't belong to any
|
||||||
// project return the global settings.
|
// project return the global settings.
|
||||||
PROJECTEXPLORER_EXPORT TextEditor::TabSettings actualTabSettings(
|
PROJECTEXPLORER_EXPORT TextEditor::TabSettings actualTabSettings(
|
||||||
const QString &fileName, const TextEditor::BaseTextDocument *baseTextDocument);
|
const QString &fileName, const TextEditor::TextDocument *baseTextDocument);
|
||||||
|
|
||||||
} // ProjectExplorer
|
} // ProjectExplorer
|
||||||
|
|
||||||
|
@@ -74,7 +74,7 @@ PythonEditorFactory::PythonEditorFactory()
|
|||||||
| TextEditorActionHandler::UnCommentSelection
|
| TextEditorActionHandler::UnCommentSelection
|
||||||
| TextEditorActionHandler::UnCollapseAll);
|
| TextEditorActionHandler::UnCollapseAll);
|
||||||
|
|
||||||
setDocumentCreator([]() { return new BaseTextDocument(Constants::C_PYTHONEDITOR_ID); });
|
setDocumentCreator([]() { return new TextDocument(Constants::C_PYTHONEDITOR_ID); });
|
||||||
setEditorWidgetCreator([]() { return new PythonEditorWidget; });
|
setEditorWidgetCreator([]() { return new PythonEditorWidget; });
|
||||||
setIndenterCreator([]() { return new PythonIndenter; });
|
setIndenterCreator([]() { return new PythonIndenter; });
|
||||||
setSyntaxHighlighterCreator([]() { return new PythonHighlighter; });
|
setSyntaxHighlighterCreator([]() { return new PythonHighlighter; });
|
||||||
|
@@ -162,7 +162,7 @@ void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
|||||||
// ProFileDocument
|
// ProFileDocument
|
||||||
//
|
//
|
||||||
|
|
||||||
class ProFileDocument : public BaseTextDocument
|
class ProFileDocument : public TextDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProFileDocument();
|
ProFileDocument();
|
||||||
|
@@ -49,7 +49,7 @@ void BaseTextEditModifier::indent(int offset, int length)
|
|||||||
|
|
||||||
if (TextEditor::BaseTextEditorWidget *baseTextEditorWidget = qobject_cast<TextEditor::BaseTextEditorWidget*>(plainTextEdit())) {
|
if (TextEditor::BaseTextEditorWidget *baseTextEditorWidget = qobject_cast<TextEditor::BaseTextEditorWidget*>(plainTextEdit())) {
|
||||||
|
|
||||||
TextEditor::BaseTextDocument *baseTextEditorDocument = baseTextEditorWidget->textDocument();
|
TextEditor::TextDocument *baseTextEditorDocument = baseTextEditorWidget->textDocument();
|
||||||
QTextDocument *textDocument = baseTextEditorWidget->document();
|
QTextDocument *textDocument = baseTextEditorWidget->document();
|
||||||
|
|
||||||
int startLine = -1;
|
int startLine = -1;
|
||||||
|
@@ -574,7 +574,7 @@ void QmlJSEditorDocument::setDiagnosticRanges(const QVector<QTextLayout::FormatR
|
|||||||
|
|
||||||
void QmlJSEditorDocument::applyFontSettings()
|
void QmlJSEditorDocument::applyFontSettings()
|
||||||
{
|
{
|
||||||
BaseTextDocument::applyFontSettings();
|
TextDocument::applyFontSettings();
|
||||||
d->m_semanticHighlighter->updateFontSettings(fontSettings());
|
d->m_semanticHighlighter->updateFontSettings(fontSettings());
|
||||||
if (!isSemanticInfoOutdated()) {
|
if (!isSemanticInfoOutdated()) {
|
||||||
d->m_semanticHighlightingNecessary = false;
|
d->m_semanticHighlightingNecessary = false;
|
||||||
@@ -584,7 +584,7 @@ void QmlJSEditorDocument::applyFontSettings()
|
|||||||
|
|
||||||
void QmlJSEditorDocument::triggerPendingUpdates()
|
void QmlJSEditorDocument::triggerPendingUpdates()
|
||||||
{
|
{
|
||||||
BaseTextDocument::triggerPendingUpdates(); // calls applyFontSettings if necessary
|
TextDocument::triggerPendingUpdates(); // calls applyFontSettings if necessary
|
||||||
// might still need to rehighlight if font settings did not change
|
// might still need to rehighlight if font settings did not change
|
||||||
if (d->m_semanticHighlightingNecessary && !isSemanticInfoOutdated()) {
|
if (d->m_semanticHighlightingNecessary && !isSemanticInfoOutdated()) {
|
||||||
d->m_semanticHighlightingNecessary = false;
|
d->m_semanticHighlightingNecessary = false;
|
||||||
|
@@ -45,7 +45,7 @@ class QmlJSEditorDocumentPrivate;
|
|||||||
class QmlOutlineModel;
|
class QmlOutlineModel;
|
||||||
} // Internal
|
} // Internal
|
||||||
|
|
||||||
class QMLJSEDITOR_EXPORT QmlJSEditorDocument : public TextEditor::BaseTextDocument
|
class QMLJSEDITOR_EXPORT QmlJSEditorDocument : public TextEditor::TextDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@@ -247,7 +247,7 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const
|
|||||||
WorkingCopy workingCopy;
|
WorkingCopy workingCopy;
|
||||||
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
||||||
const QString key = document->filePath();
|
const QString key = document->filePath();
|
||||||
if (TextEditor::BaseTextDocument *textDocument = qobject_cast<TextEditor::BaseTextDocument *>(document)) {
|
if (TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(document)) {
|
||||||
// TODO the language should be a property on the document, not the editor
|
// TODO the language should be a property on the document, not the editor
|
||||||
if (DocumentModel::editorsForDocument(document).first()->context().contains(ProjectExplorer::Constants::LANG_QMLJS))
|
if (DocumentModel::editorsForDocument(document).first()->context().contains(ProjectExplorer::Constants::LANG_QMLJS))
|
||||||
workingCopy.insert(key, textDocument->plainText(), textDocument->document()->revision());
|
workingCopy.insert(key, textDocument->plainText(), textDocument->document()->revision());
|
||||||
|
@@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
virtual void indentSelection(const QTextCursor &selection,
|
virtual void indentSelection(const QTextCursor &selection,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const TextEditor::BaseTextDocument *textDocument) const
|
const TextEditor::TextDocument *textDocument) const
|
||||||
{
|
{
|
||||||
// ### shares code with QmlJSTextEditor::indent
|
// ### shares code with QmlJSTextEditor::indent
|
||||||
QTextDocument *doc = selection.document();
|
QTextDocument *doc = selection.document();
|
||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
|
|
||||||
virtual void reindentSelection(const QTextCursor &selection,
|
virtual void reindentSelection(const QTextCursor &selection,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const TextEditor::BaseTextDocument *textDocument) const
|
const TextEditor::TextDocument *textDocument) const
|
||||||
{
|
{
|
||||||
const TextEditor::TabSettings &tabSettings =
|
const TextEditor::TabSettings &tabSettings =
|
||||||
ProjectExplorer::actualTabSettings(fileName, textDocument);
|
ProjectExplorer::actualTabSettings(fileName, textDocument);
|
||||||
|
@@ -46,7 +46,7 @@ using namespace Qnx;
|
|||||||
using namespace Qnx::Internal;
|
using namespace Qnx::Internal;
|
||||||
|
|
||||||
BarDescriptorDocument::BarDescriptorDocument(QObject *parent)
|
BarDescriptorDocument::BarDescriptorDocument(QObject *parent)
|
||||||
: Core::TextDocument(parent)
|
: Core::BaseTextDocument(parent)
|
||||||
{
|
{
|
||||||
setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID);
|
setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID);
|
||||||
setMimeType(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE));
|
setMimeType(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE));
|
||||||
|
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
typedef QList<BarDescriptorAsset> BarDescriptorAssetList;
|
typedef QList<BarDescriptorAsset> BarDescriptorAssetList;
|
||||||
|
|
||||||
class BarDescriptorDocument : public Core::TextDocument
|
class BarDescriptorDocument : public Core::BaseTextDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@@ -168,7 +168,7 @@ void BarDescriptorEditorWidget::initAssetsPage()
|
|||||||
|
|
||||||
void BarDescriptorEditorWidget::initSourcePage()
|
void BarDescriptorEditorWidget::initSourcePage()
|
||||||
{
|
{
|
||||||
BaseTextDocumentPtr doc(new BaseTextDocument);
|
BaseTextDocumentPtr doc(new TextDocument);
|
||||||
doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); // FIXME: This looks odd.
|
doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); // FIXME: This looks odd.
|
||||||
doc->setIndenter(new TextEditor::NormalIndenter);
|
doc->setIndenter(new TextEditor::NormalIndenter);
|
||||||
|
|
||||||
|
@@ -174,12 +174,12 @@ void BaseFileFind::runSearch(Core::SearchResult *search)
|
|||||||
watcher->setFuture(Utils::findInFilesRegExp(parameters.text,
|
watcher->setFuture(Utils::findInFilesRegExp(parameters.text,
|
||||||
files(parameters.nameFilters, parameters.additionalParameters),
|
files(parameters.nameFilters, parameters.additionalParameters),
|
||||||
textDocumentFlagsForFindFlags(parameters.flags),
|
textDocumentFlagsForFindFlags(parameters.flags),
|
||||||
BaseTextDocument::openedTextDocumentContents()));
|
TextDocument::openedTextDocumentContents()));
|
||||||
} else {
|
} else {
|
||||||
watcher->setFuture(Utils::findInFiles(parameters.text,
|
watcher->setFuture(Utils::findInFiles(parameters.text,
|
||||||
files(parameters.nameFilters, parameters.additionalParameters),
|
files(parameters.nameFilters, parameters.additionalParameters),
|
||||||
textDocumentFlagsForFindFlags(parameters.flags),
|
textDocumentFlagsForFindFlags(parameters.flags),
|
||||||
BaseTextDocument::openedTextDocumentContents()));
|
TextDocument::openedTextDocumentContents()));
|
||||||
}
|
}
|
||||||
FutureProgress *progress =
|
FutureProgress *progress =
|
||||||
ProgressManager::addTask(watcher->future(), tr("Searching"), Constants::TASK_SEARCH);
|
ProgressManager::addTask(watcher->future(), tr("Searching"), Constants::TASK_SEARCH);
|
||||||
|
@@ -70,10 +70,10 @@ using namespace Core;
|
|||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
class BaseTextDocumentPrivate
|
class TextDocumentPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BaseTextDocumentPrivate() :
|
TextDocumentPrivate() :
|
||||||
m_fontSettingsNeedsApply(false),
|
m_fontSettingsNeedsApply(false),
|
||||||
m_highlighter(0),
|
m_highlighter(0),
|
||||||
m_indenter(new Indenter),
|
m_indenter(new Indenter),
|
||||||
@@ -105,7 +105,7 @@ public:
|
|||||||
TextMarks m_marksCache; // Marks not owned
|
TextMarks m_marksCache; // Marks not owned
|
||||||
};
|
};
|
||||||
|
|
||||||
QTextCursor BaseTextDocumentPrivate::indentOrUnindent(const QTextCursor &textCursor, bool doIndent)
|
QTextCursor TextDocumentPrivate::indentOrUnindent(const QTextCursor &textCursor, bool doIndent)
|
||||||
{
|
{
|
||||||
QTextCursor cursor = textCursor;
|
QTextCursor cursor = textCursor;
|
||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
@@ -157,7 +157,7 @@ QTextCursor BaseTextDocumentPrivate::indentOrUnindent(const QTextCursor &textCur
|
|||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocumentPrivate::resetRevisions()
|
void TextDocumentPrivate::resetRevisions()
|
||||||
{
|
{
|
||||||
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(m_document.documentLayout());
|
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(m_document.documentLayout());
|
||||||
QTC_ASSERT(documentLayout, return);
|
QTC_ASSERT(documentLayout, return);
|
||||||
@@ -167,7 +167,7 @@ void BaseTextDocumentPrivate::resetRevisions()
|
|||||||
block.setRevision(documentLayout->lastSaveRevision);
|
block.setRevision(documentLayout->lastSaveRevision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocumentPrivate::updateRevisions()
|
void TextDocumentPrivate::updateRevisions()
|
||||||
{
|
{
|
||||||
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(m_document.documentLayout());
|
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(m_document.documentLayout());
|
||||||
QTC_ASSERT(documentLayout, return);
|
QTC_ASSERT(documentLayout, return);
|
||||||
@@ -190,8 +190,8 @@ void BaseTextDocumentPrivate::updateRevisions()
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BaseTextDocument::BaseTextDocument(Id id)
|
TextDocument::TextDocument(Id id)
|
||||||
: d(new BaseTextDocumentPrivate)
|
: d(new TextDocumentPrivate)
|
||||||
{
|
{
|
||||||
QObject::connect(&d->m_document, &QTextDocument::modificationChanged, [this](bool modified) {
|
QObject::connect(&d->m_document, &QTextDocument::modificationChanged, [this](bool modified) {
|
||||||
// we only want to update the block revisions when going back to the saved version,
|
// we only want to update the block revisions when going back to the saved version,
|
||||||
@@ -201,7 +201,7 @@ BaseTextDocument::BaseTextDocument(Id id)
|
|||||||
emit changed();
|
emit changed();
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(&d->m_document, &QTextDocument::contentsChanged, this, &BaseTextDocument::contentsChanged);
|
QObject::connect(&d->m_document, &QTextDocument::contentsChanged, this, &TextDocument::contentsChanged);
|
||||||
|
|
||||||
// set new document layout
|
// set new document layout
|
||||||
QTextOption opt = d->m_document.defaultTextOption();
|
QTextOption opt = d->m_document.defaultTextOption();
|
||||||
@@ -216,16 +216,16 @@ BaseTextDocument::BaseTextDocument(Id id)
|
|||||||
setId(id);
|
setId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextDocument::~BaseTextDocument()
|
TextDocument::~TextDocument()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QString> BaseTextDocument::openedTextDocumentContents()
|
QMap<QString, QString> TextDocument::openedTextDocumentContents()
|
||||||
{
|
{
|
||||||
QMap<QString, QString> workingCopy;
|
QMap<QString, QString> workingCopy;
|
||||||
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
||||||
BaseTextDocument *textEditorDocument = qobject_cast<BaseTextDocument *>(document);
|
TextDocument *textEditorDocument = qobject_cast<TextDocument *>(document);
|
||||||
if (!textEditorDocument)
|
if (!textEditorDocument)
|
||||||
continue;
|
continue;
|
||||||
QString fileName = textEditorDocument->filePath();
|
QString fileName = textEditorDocument->filePath();
|
||||||
@@ -234,11 +234,11 @@ QMap<QString, QString> BaseTextDocument::openedTextDocumentContents()
|
|||||||
return workingCopy;
|
return workingCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QTextCodec *> BaseTextDocument::openedTextDocumentEncodings()
|
QMap<QString, QTextCodec *> TextDocument::openedTextDocumentEncodings()
|
||||||
{
|
{
|
||||||
QMap<QString, QTextCodec *> workingCopy;
|
QMap<QString, QTextCodec *> workingCopy;
|
||||||
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
||||||
BaseTextDocument *textEditorDocument = qobject_cast<BaseTextDocument *>(document);
|
TextDocument *textEditorDocument = qobject_cast<TextDocument *>(document);
|
||||||
if (!textEditorDocument)
|
if (!textEditorDocument)
|
||||||
continue;
|
continue;
|
||||||
QString fileName = textEditorDocument->filePath();
|
QString fileName = textEditorDocument->filePath();
|
||||||
@@ -247,42 +247,42 @@ QMap<QString, QTextCodec *> BaseTextDocument::openedTextDocumentEncodings()
|
|||||||
return workingCopy;
|
return workingCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BaseTextDocument::plainText() const
|
QString TextDocument::plainText() const
|
||||||
{
|
{
|
||||||
return document()->toPlainText();
|
return document()->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BaseTextDocument::textAt(int pos, int length) const
|
QString TextDocument::textAt(int pos, int length) const
|
||||||
{
|
{
|
||||||
return Convenience::textAt(QTextCursor(document()), pos, length);
|
return Convenience::textAt(QTextCursor(document()), pos, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
QChar BaseTextDocument::characterAt(int pos) const
|
QChar TextDocument::characterAt(int pos) const
|
||||||
{
|
{
|
||||||
return document()->characterAt(pos);
|
return document()->characterAt(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setTypingSettings(const TypingSettings &typingSettings)
|
void TextDocument::setTypingSettings(const TypingSettings &typingSettings)
|
||||||
{
|
{
|
||||||
d->m_typingSettings = typingSettings;
|
d->m_typingSettings = typingSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setStorageSettings(const StorageSettings &storageSettings)
|
void TextDocument::setStorageSettings(const StorageSettings &storageSettings)
|
||||||
{
|
{
|
||||||
d->m_storageSettings = storageSettings;
|
d->m_storageSettings = storageSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TypingSettings &BaseTextDocument::typingSettings() const
|
const TypingSettings &TextDocument::typingSettings() const
|
||||||
{
|
{
|
||||||
return d->m_typingSettings;
|
return d->m_typingSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StorageSettings &BaseTextDocument::storageSettings() const
|
const StorageSettings &TextDocument::storageSettings() const
|
||||||
{
|
{
|
||||||
return d->m_storageSettings;
|
return d->m_storageSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setTabSettings(const TabSettings &tabSettings)
|
void TextDocument::setTabSettings(const TabSettings &tabSettings)
|
||||||
{
|
{
|
||||||
if (tabSettings == d->m_tabSettings)
|
if (tabSettings == d->m_tabSettings)
|
||||||
return;
|
return;
|
||||||
@@ -294,12 +294,12 @@ void BaseTextDocument::setTabSettings(const TabSettings &tabSettings)
|
|||||||
emit tabSettingsChanged();
|
emit tabSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
const TabSettings &BaseTextDocument::tabSettings() const
|
const TabSettings &TextDocument::tabSettings() const
|
||||||
{
|
{
|
||||||
return d->m_tabSettings;
|
return d->m_tabSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setFontSettings(const FontSettings &fontSettings)
|
void TextDocument::setFontSettings(const FontSettings &fontSettings)
|
||||||
{
|
{
|
||||||
if (fontSettings == d->m_fontSettings)
|
if (fontSettings == d->m_fontSettings)
|
||||||
return;
|
return;
|
||||||
@@ -308,13 +308,13 @@ void BaseTextDocument::setFontSettings(const FontSettings &fontSettings)
|
|||||||
emit fontSettingsChanged();
|
emit fontSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::triggerPendingUpdates()
|
void TextDocument::triggerPendingUpdates()
|
||||||
{
|
{
|
||||||
if (d->m_fontSettingsNeedsApply)
|
if (d->m_fontSettingsNeedsApply)
|
||||||
applyFontSettings();
|
applyFontSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::applyFontSettings()
|
void TextDocument::applyFontSettings()
|
||||||
{
|
{
|
||||||
d->m_fontSettingsNeedsApply = false;
|
d->m_fontSettingsNeedsApply = false;
|
||||||
if (d->m_highlighter) {
|
if (d->m_highlighter) {
|
||||||
@@ -323,42 +323,42 @@ void BaseTextDocument::applyFontSettings()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const FontSettings &BaseTextDocument::fontSettings() const
|
const FontSettings &TextDocument::fontSettings() const
|
||||||
{
|
{
|
||||||
return d->m_fontSettings;
|
return d->m_fontSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings)
|
void TextDocument::setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings)
|
||||||
{
|
{
|
||||||
d->m_extraEncodingSettings = extraEncodingSettings;
|
d->m_extraEncodingSettings = extraEncodingSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::autoIndent(const QTextCursor &cursor, QChar typedChar)
|
void TextDocument::autoIndent(const QTextCursor &cursor, QChar typedChar)
|
||||||
{
|
{
|
||||||
d->m_indenter->indent(&d->m_document, cursor, typedChar, d->m_tabSettings);
|
d->m_indenter->indent(&d->m_document, cursor, typedChar, d->m_tabSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::autoReindent(const QTextCursor &cursor)
|
void TextDocument::autoReindent(const QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
d->m_indenter->reindent(&d->m_document, cursor, d->m_tabSettings);
|
d->m_indenter->reindent(&d->m_document, cursor, d->m_tabSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextCursor BaseTextDocument::indent(const QTextCursor &cursor)
|
QTextCursor TextDocument::indent(const QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
return d->indentOrUnindent(cursor, true);
|
return d->indentOrUnindent(cursor, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextCursor BaseTextDocument::unindent(const QTextCursor &cursor)
|
QTextCursor TextDocument::unindent(const QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
return d->indentOrUnindent(cursor, false);
|
return d->indentOrUnindent(cursor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExtraEncodingSettings &BaseTextDocument::extraEncodingSettings() const
|
const ExtraEncodingSettings &TextDocument::extraEncodingSettings() const
|
||||||
{
|
{
|
||||||
return d->m_extraEncodingSettings;
|
return d->m_extraEncodingSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setIndenter(Indenter *indenter)
|
void TextDocument::setIndenter(Indenter *indenter)
|
||||||
{
|
{
|
||||||
// clear out existing code formatter data
|
// clear out existing code formatter data
|
||||||
for (QTextBlock it = document()->begin(); it.isValid(); it = it.next()) {
|
for (QTextBlock it = document()->begin(); it.isValid(); it = it.next()) {
|
||||||
@@ -369,42 +369,42 @@ void BaseTextDocument::setIndenter(Indenter *indenter)
|
|||||||
d->m_indenter.reset(indenter);
|
d->m_indenter.reset(indenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
Indenter *BaseTextDocument::indenter() const
|
Indenter *TextDocument::indenter() const
|
||||||
{
|
{
|
||||||
return d->m_indenter.data();
|
return d->m_indenter.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::isSaveAsAllowed() const
|
bool TextDocument::isSaveAsAllowed() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BaseTextDocument::defaultPath() const
|
QString TextDocument::defaultPath() const
|
||||||
{
|
{
|
||||||
return d->m_defaultPath;
|
return d->m_defaultPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BaseTextDocument::suggestedFileName() const
|
QString TextDocument::suggestedFileName() const
|
||||||
{
|
{
|
||||||
return d->m_suggestedFileName;
|
return d->m_suggestedFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setDefaultPath(const QString &defaultPath)
|
void TextDocument::setDefaultPath(const QString &defaultPath)
|
||||||
{
|
{
|
||||||
d->m_defaultPath = defaultPath;
|
d->m_defaultPath = defaultPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setSuggestedFileName(const QString &suggestedFileName)
|
void TextDocument::setSuggestedFileName(const QString &suggestedFileName)
|
||||||
{
|
{
|
||||||
d->m_suggestedFileName = suggestedFileName;
|
d->m_suggestedFileName = suggestedFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextDocument *BaseTextDocument::document() const
|
QTextDocument *TextDocument::document() const
|
||||||
{
|
{
|
||||||
return &d->m_document;
|
return &d->m_document;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyntaxHighlighter *BaseTextDocument::syntaxHighlighter() const
|
SyntaxHighlighter *TextDocument::syntaxHighlighter() const
|
||||||
{
|
{
|
||||||
return d->m_highlighter;
|
return d->m_highlighter;
|
||||||
}
|
}
|
||||||
@@ -416,7 +416,7 @@ SyntaxHighlighter *BaseTextDocument::syntaxHighlighter() const
|
|||||||
* If \a autoSave is true, the cursor will be restored and some signals suppressed
|
* If \a autoSave is true, the cursor will be restored and some signals suppressed
|
||||||
* and we do not clean up the text file (cleanWhitespace(), ensureFinalNewLine()).
|
* and we do not clean up the text file (cleanWhitespace(), ensureFinalNewLine()).
|
||||||
*/
|
*/
|
||||||
bool BaseTextDocument::save(QString *errorString, const QString &saveFileName, bool autoSave)
|
bool TextDocument::save(QString *errorString, const QString &saveFileName, bool autoSave)
|
||||||
{
|
{
|
||||||
QTextCursor cursor(&d->m_document);
|
QTextCursor cursor(&d->m_document);
|
||||||
|
|
||||||
@@ -501,17 +501,17 @@ bool BaseTextDocument::save(QString *errorString, const QString &saveFileName, b
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::setContents(const QByteArray &contents)
|
bool TextDocument::setContents(const QByteArray &contents)
|
||||||
{
|
{
|
||||||
return setPlainText(QString::fromUtf8(contents));
|
return setPlainText(QString::fromUtf8(contents));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::shouldAutoSave() const
|
bool TextDocument::shouldAutoSave() const
|
||||||
{
|
{
|
||||||
return d->m_autoSaveRevision != d->m_document.revision();
|
return d->m_autoSaveRevision != d->m_document.revision();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setFilePath(const QString &newName)
|
void TextDocument::setFilePath(const QString &newName)
|
||||||
{
|
{
|
||||||
if (newName == filePath())
|
if (newName == filePath())
|
||||||
return;
|
return;
|
||||||
@@ -519,19 +519,19 @@ void BaseTextDocument::setFilePath(const QString &newName)
|
|||||||
IDocument::setFilePath(QDir::cleanPath(fi.absoluteFilePath()));
|
IDocument::setFilePath(QDir::cleanPath(fi.absoluteFilePath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::isFileReadOnly() const
|
bool TextDocument::isFileReadOnly() const
|
||||||
{
|
{
|
||||||
if (filePath().isEmpty()) //have no corresponding file, so editing is ok
|
if (filePath().isEmpty()) //have no corresponding file, so editing is ok
|
||||||
return false;
|
return false;
|
||||||
return d->m_fileIsReadOnly;
|
return d->m_fileIsReadOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::isModified() const
|
bool TextDocument::isModified() const
|
||||||
{
|
{
|
||||||
return d->m_document.isModified();
|
return d->m_document.isModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::checkPermissions()
|
void TextDocument::checkPermissions()
|
||||||
{
|
{
|
||||||
bool previousReadOnly = d->m_fileIsReadOnly;
|
bool previousReadOnly = d->m_fileIsReadOnly;
|
||||||
if (!filePath().isEmpty()) {
|
if (!filePath().isEmpty()) {
|
||||||
@@ -544,7 +544,7 @@ void BaseTextDocument::checkPermissions()
|
|||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
bool TextDocument::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||||
{
|
{
|
||||||
QStringList content;
|
QStringList content;
|
||||||
|
|
||||||
@@ -591,14 +591,14 @@ bool BaseTextDocument::open(QString *errorString, const QString &fileName, const
|
|||||||
|| readResult == Utils::TextFileFormat::ReadEncodingError;
|
|| readResult == Utils::TextFileFormat::ReadEncodingError;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::reload(QString *errorString, QTextCodec *codec)
|
bool TextDocument::reload(QString *errorString, QTextCodec *codec)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(codec, return false);
|
QTC_ASSERT(codec, return false);
|
||||||
setCodec(codec);
|
setCodec(codec);
|
||||||
return reload(errorString);
|
return reload(errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::reload(QString *errorString)
|
bool TextDocument::reload(QString *errorString)
|
||||||
{
|
{
|
||||||
emit aboutToReload();
|
emit aboutToReload();
|
||||||
BaseTextDocumentLayout *documentLayout =
|
BaseTextDocumentLayout *documentLayout =
|
||||||
@@ -615,7 +615,7 @@ bool BaseTextDocument::reload(QString *errorString)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::setPlainText(const QString &text)
|
bool TextDocument::setPlainText(const QString &text)
|
||||||
{
|
{
|
||||||
if (text.size() > EditorManager::maxTextFileSize()) {
|
if (text.size() > EditorManager::maxTextFileSize()) {
|
||||||
document()->setPlainText(BaseTextEditorWidget::msgTextTooLarge(text.size()));
|
document()->setPlainText(BaseTextEditorWidget::msgTextTooLarge(text.size()));
|
||||||
@@ -629,7 +629,7 @@ bool BaseTextDocument::setPlainText(const QString &text)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
bool TextDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
||||||
{
|
{
|
||||||
if (flag == FlagIgnore)
|
if (flag == FlagIgnore)
|
||||||
return true;
|
return true;
|
||||||
@@ -641,7 +641,7 @@ bool BaseTextDocument::reload(QString *errorString, ReloadFlag flag, ChangeType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::setSyntaxHighlighter(SyntaxHighlighter *highlighter)
|
void TextDocument::setSyntaxHighlighter(SyntaxHighlighter *highlighter)
|
||||||
{
|
{
|
||||||
if (d->m_highlighter)
|
if (d->m_highlighter)
|
||||||
delete d->m_highlighter;
|
delete d->m_highlighter;
|
||||||
@@ -650,7 +650,7 @@ void BaseTextDocument::setSyntaxHighlighter(SyntaxHighlighter *highlighter)
|
|||||||
d->m_highlighter->setDocument(&d->m_document);
|
d->m_highlighter->setDocument(&d->m_document);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::cleanWhitespace(const QTextCursor &cursor)
|
void TextDocument::cleanWhitespace(const QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
bool hasSelection = cursor.hasSelection();
|
bool hasSelection = cursor.hasSelection();
|
||||||
QTextCursor copyCursor = cursor;
|
QTextCursor copyCursor = cursor;
|
||||||
@@ -662,7 +662,7 @@ void BaseTextDocument::cleanWhitespace(const QTextCursor &cursor)
|
|||||||
copyCursor.endEditBlock();
|
copyCursor.endEditBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument)
|
void TextDocument::cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument)
|
||||||
{
|
{
|
||||||
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document.documentLayout());
|
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document.documentLayout());
|
||||||
Q_ASSERT(cursor.visualNavigation() == false);
|
Q_ASSERT(cursor.visualNavigation() == false);
|
||||||
@@ -697,7 +697,7 @@ void BaseTextDocument::cleanWhitespace(QTextCursor &cursor, bool cleanIndentatio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::ensureFinalNewLine(QTextCursor& cursor)
|
void TextDocument::ensureFinalNewLine(QTextCursor& cursor)
|
||||||
{
|
{
|
||||||
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
|
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||||
bool emptyFile = !cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
|
bool emptyFile = !cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
|
||||||
@@ -709,12 +709,12 @@ void BaseTextDocument::ensureFinalNewLine(QTextCursor& cursor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextMarks BaseTextDocument::marks() const
|
TextMarks TextDocument::marks() const
|
||||||
{
|
{
|
||||||
return d->m_marksCache;
|
return d->m_marksCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::addMark(TextMark *mark)
|
bool TextDocument::addMark(TextMark *mark)
|
||||||
{
|
{
|
||||||
if (mark->baseTextDocument())
|
if (mark->baseTextDocument())
|
||||||
return false;
|
return false;
|
||||||
@@ -748,7 +748,7 @@ bool BaseTextDocument::addMark(TextMark *mark)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextMarks BaseTextDocument::marksAt(int line) const
|
TextMarks TextDocument::marksAt(int line) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(line >= 1, return TextMarks());
|
QTC_ASSERT(line >= 1, return TextMarks());
|
||||||
int blockNumber = line - 1;
|
int blockNumber = line - 1;
|
||||||
@@ -761,7 +761,7 @@ TextMarks BaseTextDocument::marksAt(int line) const
|
|||||||
return TextMarks();
|
return TextMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::removeMarkFromMarksCache(TextMark *mark)
|
void TextDocument::removeMarkFromMarksCache(TextMark *mark)
|
||||||
{
|
{
|
||||||
auto documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document.documentLayout());
|
auto documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document.documentLayout());
|
||||||
QTC_ASSERT(documentLayout, return);
|
QTC_ASSERT(documentLayout, return);
|
||||||
@@ -801,7 +801,7 @@ void BaseTextDocument::removeMarkFromMarksCache(TextMark *mark)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::removeMark(TextMark *mark)
|
void TextDocument::removeMark(TextMark *mark)
|
||||||
{
|
{
|
||||||
QTextBlock block = d->m_document.findBlockByNumber(mark->lineNumber() - 1);
|
QTextBlock block = d->m_document.findBlockByNumber(mark->lineNumber() - 1);
|
||||||
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
|
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
|
||||||
@@ -813,7 +813,7 @@ void BaseTextDocument::removeMark(TextMark *mark)
|
|||||||
mark->setBaseTextDocument(0);
|
mark->setBaseTextDocument(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::updateMark(TextMark *mark)
|
void TextDocument::updateMark(TextMark *mark)
|
||||||
{
|
{
|
||||||
Q_UNUSED(mark)
|
Q_UNUSED(mark)
|
||||||
auto documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document.documentLayout());
|
auto documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document.documentLayout());
|
||||||
@@ -821,7 +821,7 @@ void BaseTextDocument::updateMark(TextMark *mark)
|
|||||||
documentLayout->requestUpdate();
|
documentLayout->requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::moveMark(TextMark *mark, int previousLine)
|
void TextDocument::moveMark(TextMark *mark, int previousLine)
|
||||||
{
|
{
|
||||||
QTextBlock block = d->m_document.findBlockByNumber(previousLine - 1);
|
QTextBlock block = d->m_document.findBlockByNumber(previousLine - 1);
|
||||||
if (TextBlockUserData *data = BaseTextDocumentLayout::testUserData(block)) {
|
if (TextBlockUserData *data = BaseTextDocumentLayout::testUserData(block)) {
|
||||||
|
@@ -48,25 +48,25 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
class BaseTextDocumentPrivate;
|
|
||||||
class ExtraEncodingSettings;
|
class ExtraEncodingSettings;
|
||||||
class FontSettings;
|
class FontSettings;
|
||||||
class Indenter;
|
class Indenter;
|
||||||
class StorageSettings;
|
class StorageSettings;
|
||||||
class SyntaxHighlighter;
|
class SyntaxHighlighter;
|
||||||
class TabSettings;
|
class TabSettings;
|
||||||
|
class TextDocumentPrivate;
|
||||||
class TextMark;
|
class TextMark;
|
||||||
class TypingSettings;
|
class TypingSettings;
|
||||||
|
|
||||||
typedef QList<TextMark *> TextMarks;
|
typedef QList<TextMark *> TextMarks;
|
||||||
|
|
||||||
class TEXTEDITOR_EXPORT BaseTextDocument : public Core::TextDocument
|
class TEXTEDITOR_EXPORT TextDocument : public Core::BaseTextDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseTextDocument(Core::Id id = Core::Id());
|
explicit TextDocument(Core::Id id = Core::Id());
|
||||||
virtual ~BaseTextDocument();
|
virtual ~TextDocument();
|
||||||
|
|
||||||
static QMap<QString, QString> openedTextDocumentContents();
|
static QMap<QString, QString> openedTextDocumentContents();
|
||||||
static QMap<QString, QTextCodec *> openedTextDocumentEncodings();
|
static QMap<QString, QTextCodec *> openedTextDocumentEncodings();
|
||||||
@@ -98,7 +98,7 @@ public:
|
|||||||
void removeMark(TextMark *mark);
|
void removeMark(TextMark *mark);
|
||||||
void updateMark(TextMark *mark);
|
void updateMark(TextMark *mark);
|
||||||
void moveMark(TextMark *mark, int previousLine);
|
void moveMark(TextMark *mark, int previousLine);
|
||||||
void removeMarkFromMarksCache(TextEditor::TextMark *mark);
|
void removeMarkFromMarksCache(TextMark *mark);
|
||||||
|
|
||||||
// IDocument implementation.
|
// IDocument implementation.
|
||||||
bool save(QString *errorString, const QString &fileName, bool autoSave);
|
bool save(QString *errorString, const QString &fileName, bool autoSave);
|
||||||
@@ -146,10 +146,10 @@ private:
|
|||||||
void cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument);
|
void cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument);
|
||||||
void ensureFinalNewLine(QTextCursor &cursor);
|
void ensureFinalNewLine(QTextCursor &cursor);
|
||||||
|
|
||||||
BaseTextDocumentPrivate *d;
|
TextDocumentPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<BaseTextDocument> BaseTextDocumentPtr;
|
typedef QSharedPointer<TextDocument> BaseTextDocumentPtr;
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|
||||||
|
@@ -591,7 +591,7 @@ TextMarks BaseTextDocumentLayout::documentClosing()
|
|||||||
return marks;
|
return marks;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocumentLayout::documentReloaded(TextMarks marks, BaseTextDocument *baseTextDocument)
|
void BaseTextDocumentLayout::documentReloaded(TextMarks marks, TextDocument *baseTextDocument)
|
||||||
{
|
{
|
||||||
foreach (TextMark *mark, marks) {
|
foreach (TextMark *mark, marks) {
|
||||||
int blockNumber = mark->lineNumber() - 1;
|
int blockNumber = mark->lineNumber() - 1;
|
||||||
|
@@ -218,7 +218,7 @@ public:
|
|||||||
QSizeF documentSize() const;
|
QSizeF documentSize() const;
|
||||||
|
|
||||||
TextMarks documentClosing();
|
TextMarks documentClosing();
|
||||||
void documentReloaded(TextMarks marks, BaseTextDocument *baseextDocument);
|
void documentReloaded(TextMarks marks, TextDocument *baseextDocument);
|
||||||
void updateMarksLineNumber();
|
void updateMarksLineNumber();
|
||||||
void updateMarksBlock(const QTextBlock &block);
|
void updateMarksBlock(const QTextBlock &block);
|
||||||
|
|
||||||
|
@@ -251,7 +251,7 @@ public:
|
|||||||
void updateCannotDecodeInfo();
|
void updateCannotDecodeInfo();
|
||||||
void collectToCircularClipboard();
|
void collectToCircularClipboard();
|
||||||
|
|
||||||
void ctor(const QSharedPointer<BaseTextDocument> &doc);
|
void ctor(const QSharedPointer<TextDocument> &doc);
|
||||||
void handleHomeKey(bool anchor);
|
void handleHomeKey(bool anchor);
|
||||||
void handleBackspaceKey();
|
void handleBackspaceKey();
|
||||||
void moveLineUpDown(bool up);
|
void moveLineUpDown(bool up);
|
||||||
@@ -324,7 +324,7 @@ public:
|
|||||||
bool m_contentsChanged;
|
bool m_contentsChanged;
|
||||||
bool m_lastCursorChangeWasInteresting;
|
bool m_lastCursorChangeWasInteresting;
|
||||||
|
|
||||||
QSharedPointer<BaseTextDocument> m_document;
|
QSharedPointer<TextDocument> m_document;
|
||||||
QByteArray m_tempState;
|
QByteArray m_tempState;
|
||||||
QByteArray m_tempNavigationState;
|
QByteArray m_tempNavigationState;
|
||||||
|
|
||||||
@@ -590,12 +590,12 @@ BaseTextEditorWidget::BaseTextEditorWidget(QWidget *parent)
|
|||||||
d = new BaseTextEditorWidgetPrivate(this);
|
d = new BaseTextEditorWidgetPrivate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextEditorWidget::setTextDocument(const QSharedPointer<BaseTextDocument> &doc)
|
void BaseTextEditorWidget::setTextDocument(const QSharedPointer<TextDocument> &doc)
|
||||||
{
|
{
|
||||||
d->ctor(doc);
|
d->ctor(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextEditorWidgetPrivate::ctor(const QSharedPointer<BaseTextDocument> &doc)
|
void BaseTextEditorWidgetPrivate::ctor(const QSharedPointer<TextDocument> &doc)
|
||||||
{
|
{
|
||||||
q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
|
|
||||||
@@ -889,7 +889,7 @@ int BaseTextEditorWidgetPrivate::visualIndent(const QTextBlock &block) const
|
|||||||
|
|
||||||
void BaseTextEditorWidget::selectEncoding()
|
void BaseTextEditorWidget::selectEncoding()
|
||||||
{
|
{
|
||||||
BaseTextDocument *doc = d->m_document.data();
|
TextDocument *doc = d->m_document.data();
|
||||||
CodecSelector codecSelector(this, doc);
|
CodecSelector codecSelector(this, doc);
|
||||||
|
|
||||||
switch (codecSelector.exec()) {
|
switch (codecSelector.exec()) {
|
||||||
@@ -999,7 +999,7 @@ void BaseTextEditorWidgetPrivate::foldLicenseHeader()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextDocument *BaseTextEditorWidget::textDocument() const
|
TextDocument *BaseTextEditorWidget::textDocument() const
|
||||||
{
|
{
|
||||||
return d->m_document.data();
|
return d->m_document.data();
|
||||||
}
|
}
|
||||||
@@ -2844,16 +2844,16 @@ void BaseTextEditorWidgetPrivate::setupDocumentSignals()
|
|||||||
QObject::connect(doc, &QTextDocument::contentsChange,
|
QObject::connect(doc, &QTextDocument::contentsChange,
|
||||||
this, &BaseTextEditorWidgetPrivate::editorContentsChange);
|
this, &BaseTextEditorWidgetPrivate::editorContentsChange);
|
||||||
|
|
||||||
QObject::connect(m_document.data(), &BaseTextDocument::aboutToReload,
|
QObject::connect(m_document.data(), &TextDocument::aboutToReload,
|
||||||
this, &BaseTextEditorWidgetPrivate::documentAboutToBeReloaded);
|
this, &BaseTextEditorWidgetPrivate::documentAboutToBeReloaded);
|
||||||
|
|
||||||
QObject::connect(m_document.data(), &BaseTextDocument::reloadFinished,
|
QObject::connect(m_document.data(), &TextDocument::reloadFinished,
|
||||||
this, &BaseTextEditorWidgetPrivate::documentReloadFinished);
|
this, &BaseTextEditorWidgetPrivate::documentReloadFinished);
|
||||||
|
|
||||||
QObject::connect(m_document.data(), &BaseTextDocument::tabSettingsChanged,
|
QObject::connect(m_document.data(), &TextDocument::tabSettingsChanged,
|
||||||
this, &BaseTextEditorWidgetPrivate::updateTabStops);
|
this, &BaseTextEditorWidgetPrivate::updateTabStops);
|
||||||
|
|
||||||
QObject::connect(m_document.data(), &BaseTextDocument::fontSettingsChanged,
|
QObject::connect(m_document.data(), &TextDocument::fontSettingsChanged,
|
||||||
this, &BaseTextEditorWidgetPrivate::applyFontSettingsDelayed);
|
this, &BaseTextEditorWidgetPrivate::applyFontSettingsDelayed);
|
||||||
|
|
||||||
slotUpdateExtraAreaWidth();
|
slotUpdateExtraAreaWidth();
|
||||||
@@ -2862,7 +2862,7 @@ void BaseTextEditorWidgetPrivate::setupDocumentSignals()
|
|||||||
|
|
||||||
// Connect to settings change signals
|
// Connect to settings change signals
|
||||||
connect(settings, &TextEditorSettings::fontSettingsChanged,
|
connect(settings, &TextEditorSettings::fontSettingsChanged,
|
||||||
m_document.data(), &BaseTextDocument::setFontSettings);
|
m_document.data(), &TextDocument::setFontSettings);
|
||||||
connect(settings, &TextEditorSettings::typingSettingsChanged,
|
connect(settings, &TextEditorSettings::typingSettingsChanged,
|
||||||
q, &BaseTextEditorWidget::setTypingSettings);
|
q, &BaseTextEditorWidget::setTypingSettings);
|
||||||
connect(settings, &TextEditorSettings::storageSettingsChanged,
|
connect(settings, &TextEditorSettings::storageSettingsChanged,
|
||||||
@@ -6531,7 +6531,7 @@ QColor BaseTextEditorWidget::replacementPenColor(int blockNumber) const
|
|||||||
|
|
||||||
void BaseTextEditorWidget::setupFallBackEditor(Id id)
|
void BaseTextEditorWidget::setupFallBackEditor(Id id)
|
||||||
{
|
{
|
||||||
BaseTextDocumentPtr doc(new BaseTextDocument(id));
|
BaseTextDocumentPtr doc(new TextDocument(id));
|
||||||
doc->setFontSettings(TextEditorSettings::fontSettings());
|
doc->setFontSettings(TextEditorSettings::fontSettings());
|
||||||
setTextDocument(doc);
|
setTextDocument(doc);
|
||||||
}
|
}
|
||||||
@@ -6553,7 +6553,7 @@ void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
|
|||||||
if (a && a->isEnabled())
|
if (a && a->isEnabled())
|
||||||
menu->addAction(a);
|
menu->addAction(a);
|
||||||
|
|
||||||
BaseTextDocument *doc = textDocument();
|
TextDocument *doc = textDocument();
|
||||||
if (doc->codec()->name() == QByteArray("UTF-8") && doc->supportsUtf8Bom()) {
|
if (doc->codec()->name() == QByteArray("UTF-8") && doc->supportsUtf8Bom()) {
|
||||||
a = ActionManager::command(Constants::SWITCH_UTF8BOM)->action();
|
a = ActionManager::command(Constants::SWITCH_UTF8BOM)->action();
|
||||||
if (a && a->isEnabled()) {
|
if (a && a->isEnabled()) {
|
||||||
@@ -6578,7 +6578,7 @@ BaseTextEditor::~BaseTextEditor()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextDocument *BaseTextEditor::textDocument() const
|
TextDocument *BaseTextEditor::textDocument() const
|
||||||
{
|
{
|
||||||
BaseTextEditorWidget *widget = editorWidget();
|
BaseTextEditorWidget *widget = editorWidget();
|
||||||
QTC_CHECK(!widget->d->m_document.isNull());
|
QTC_CHECK(!widget->d->m_document.isNull());
|
||||||
@@ -6782,18 +6782,18 @@ void BaseTextBlockSelection::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns a cursor which always has the complete selection
|
// returns a cursor which always has the complete selection
|
||||||
QTextCursor BaseTextBlockSelection::selection(const BaseTextDocument *baseTextDocument) const
|
QTextCursor BaseTextBlockSelection::selection(const TextDocument *baseTextDocument) const
|
||||||
{
|
{
|
||||||
return cursor(baseTextDocument, true);
|
return cursor(baseTextDocument, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns a cursor which always has the correct position and anchor
|
// returns a cursor which always has the correct position and anchor
|
||||||
QTextCursor BaseTextBlockSelection::cursor(const BaseTextDocument *baseTextDocument) const
|
QTextCursor BaseTextBlockSelection::cursor(const TextDocument *baseTextDocument) const
|
||||||
{
|
{
|
||||||
return cursor(baseTextDocument, false);
|
return cursor(baseTextDocument, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextCursor BaseTextBlockSelection::cursor(const BaseTextDocument *baseTextDocument,
|
QTextCursor BaseTextBlockSelection::cursor(const TextDocument *baseTextDocument,
|
||||||
bool fullSelection) const
|
bool fullSelection) const
|
||||||
{
|
{
|
||||||
if (!baseTextDocument)
|
if (!baseTextDocument)
|
||||||
|
@@ -138,7 +138,7 @@ public:
|
|||||||
static BaseTextEditor *currentTextEditor();
|
static BaseTextEditor *currentTextEditor();
|
||||||
|
|
||||||
BaseTextEditorWidget *editorWidget() const;
|
BaseTextEditorWidget *editorWidget() const;
|
||||||
BaseTextDocument *textDocument() const;
|
TextDocument *textDocument() const;
|
||||||
|
|
||||||
// Some convenience text access
|
// Some convenience text access
|
||||||
QTextDocument *qdocument() const;
|
QTextDocument *qdocument() const;
|
||||||
@@ -217,7 +217,7 @@ public:
|
|||||||
~BaseTextEditorWidget();
|
~BaseTextEditorWidget();
|
||||||
|
|
||||||
void setTextDocument(const BaseTextDocumentPtr &doc);
|
void setTextDocument(const BaseTextDocumentPtr &doc);
|
||||||
BaseTextDocument *textDocument() const;
|
TextDocument *textDocument() const;
|
||||||
BaseTextDocumentPtr textDocumentPtr() const;
|
BaseTextDocumentPtr textDocumentPtr() const;
|
||||||
|
|
||||||
// IEditor
|
// IEditor
|
||||||
@@ -625,7 +625,7 @@ public:
|
|||||||
BaseTextEditorFactory(QObject *parent = 0);
|
BaseTextEditorFactory(QObject *parent = 0);
|
||||||
|
|
||||||
typedef std::function<BaseTextEditor *()> EditorCreator;
|
typedef std::function<BaseTextEditor *()> EditorCreator;
|
||||||
typedef std::function<BaseTextDocument *()> DocumentCreator;
|
typedef std::function<TextDocument *()> DocumentCreator;
|
||||||
typedef std::function<BaseTextEditorWidget *()> EditorWidgetCreator;
|
typedef std::function<BaseTextEditorWidget *()> EditorWidgetCreator;
|
||||||
typedef std::function<SyntaxHighlighter *()> SyntaxHighLighterCreator;
|
typedef std::function<SyntaxHighlighter *()> SyntaxHighLighterCreator;
|
||||||
typedef std::function<Indenter *()> IndenterCreator;
|
typedef std::function<Indenter *()> IndenterCreator;
|
||||||
|
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
class BaseTextDocument;
|
class TextDocument;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class TextEditorOverlay;
|
class TextEditorOverlay;
|
||||||
@@ -64,8 +64,8 @@ public:
|
|||||||
BaseTextBlockSelection(const BaseTextBlockSelection &other);
|
BaseTextBlockSelection(const BaseTextBlockSelection &other);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
QTextCursor selection(const BaseTextDocument *baseTextDocument) const;
|
QTextCursor selection(const TextDocument *baseTextDocument) const;
|
||||||
QTextCursor cursor(const BaseTextDocument *baseTextDocument) const;
|
QTextCursor cursor(const TextDocument *baseTextDocument) const;
|
||||||
void fromPostition(int positionBlock, int positionColumn, int anchorBlock, int anchorColumn);
|
void fromPostition(int positionBlock, int positionColumn, int anchorBlock, int anchorColumn);
|
||||||
bool hasSelection() { return !(positionBlock == anchorBlock && positionColumn == anchorColumn); }
|
bool hasSelection() { return !(positionBlock == anchorBlock && positionColumn == anchorColumn); }
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
int anchorColumn;
|
int anchorColumn;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTextCursor cursor(const BaseTextDocument *baseTextDocument, bool fullSelection) const;
|
QTextCursor cursor(const TextDocument *baseTextDocument, bool fullSelection) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//================BaseTextEditorPrivate==============
|
//================BaseTextEditorPrivate==============
|
||||||
|
@@ -62,7 +62,7 @@ public:
|
|||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|
||||||
|
|
||||||
CodecSelector::CodecSelector(QWidget *parent, BaseTextDocument *doc)
|
CodecSelector::CodecSelector(QWidget *parent, TextDocument *doc)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
m_hasDecodingError = doc->hasDecodingError();
|
m_hasDecodingError = doc->hasDecodingError();
|
||||||
|
@@ -39,7 +39,7 @@ namespace Utils { class ListWidget; }
|
|||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
class BaseTextDocument;
|
class TextDocument;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ class CodecSelector : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CodecSelector(QWidget *parent, BaseTextDocument *doc);
|
CodecSelector(QWidget *parent, TextDocument *doc);
|
||||||
~CodecSelector();
|
~CodecSelector();
|
||||||
|
|
||||||
QTextCodec *selectedCodec() const;
|
QTextCodec *selectedCodec() const;
|
||||||
|
@@ -63,7 +63,7 @@ Utils::FileIterator *FindInCurrentFile::files(const QStringList &nameFilters,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(nameFilters)
|
Q_UNUSED(nameFilters)
|
||||||
QString fileName = additionalParameters.toString();
|
QString fileName = additionalParameters.toString();
|
||||||
QMap<QString, QTextCodec *> openEditorEncodings = BaseTextDocument::openedTextDocumentEncodings();
|
QMap<QString, QTextCodec *> openEditorEncodings = TextDocument::openedTextDocumentEncodings();
|
||||||
QTextCodec *codec = openEditorEncodings.value(fileName);
|
QTextCodec *codec = openEditorEncodings.value(fileName);
|
||||||
if (!codec)
|
if (!codec)
|
||||||
codec = Core::EditorManager::defaultTextCodec();
|
codec = Core::EditorManager::defaultTextCodec();
|
||||||
|
@@ -65,7 +65,7 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters,
|
|||||||
Q_UNUSED(nameFilters)
|
Q_UNUSED(nameFilters)
|
||||||
Q_UNUSED(additionalParameters)
|
Q_UNUSED(additionalParameters)
|
||||||
QMap<QString, QTextCodec *> openEditorEncodings
|
QMap<QString, QTextCodec *> openEditorEncodings
|
||||||
= BaseTextDocument::openedTextDocumentEncodings();
|
= TextDocument::openedTextDocumentEncodings();
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
QList<QTextCodec *> codecs;
|
QList<QTextCodec *> codecs;
|
||||||
foreach (Core::DocumentModel::Entry *entry,
|
foreach (Core::DocumentModel::Entry *entry,
|
||||||
|
@@ -61,7 +61,7 @@ PlainTextEditorFactory::PlainTextEditorFactory()
|
|||||||
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
|
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
|
||||||
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
|
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
|
||||||
|
|
||||||
setDocumentCreator([]() { return new BaseTextDocument(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); });
|
setDocumentCreator([]() { return new TextDocument(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); });
|
||||||
setEditorWidgetCreator([]() { return new PlainTextEditorWidget; });
|
setEditorWidgetCreator([]() { return new PlainTextEditorWidget; });
|
||||||
setIndenterCreator([]() { return new NormalIndenter; });
|
setIndenterCreator([]() { return new NormalIndenter; });
|
||||||
|
|
||||||
|
@@ -384,7 +384,7 @@ void RefactoringFile::apply()
|
|||||||
|
|
||||||
void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &,
|
void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &,
|
||||||
const QString &,
|
const QString &,
|
||||||
const BaseTextDocument *) const,
|
const TextDocument *) const,
|
||||||
const RefactoringSelections &ranges)
|
const RefactoringSelections &ranges)
|
||||||
{
|
{
|
||||||
typedef QPair<QTextCursor, QTextCursor> CursorPair;
|
typedef QPair<QTextCursor, QTextCursor> CursorPair;
|
||||||
@@ -406,12 +406,12 @@ void RefactoringFile::fileChanged()
|
|||||||
RefactoringChangesData::~RefactoringChangesData()
|
RefactoringChangesData::~RefactoringChangesData()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void RefactoringChangesData::indentSelection(const QTextCursor &, const QString &, const BaseTextDocument *) const
|
void RefactoringChangesData::indentSelection(const QTextCursor &, const QString &, const TextDocument *) const
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "not implemented";
|
qWarning() << Q_FUNC_INFO << "not implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefactoringChangesData::reindentSelection(const QTextCursor &, const QString &, const BaseTextDocument *) const
|
void RefactoringChangesData::reindentSelection(const QTextCursor &, const QString &, const TextDocument *) const
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "not implemented";
|
qWarning() << Q_FUNC_INFO << "not implemented";
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ class QTextDocument;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
class BaseTextDocument;
|
class TextDocument;
|
||||||
class BaseTextEditorWidget;
|
class BaseTextEditorWidget;
|
||||||
class RefactoringChanges;
|
class RefactoringChanges;
|
||||||
class RefactoringFile;
|
class RefactoringFile;
|
||||||
@@ -99,7 +99,7 @@ protected:
|
|||||||
|
|
||||||
void indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &,
|
void indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &,
|
||||||
const QString &,
|
const QString &,
|
||||||
const BaseTextDocument *) const,
|
const TextDocument *) const,
|
||||||
const RefactoringSelections &ranges);
|
const RefactoringSelections &ranges);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -159,10 +159,10 @@ public:
|
|||||||
|
|
||||||
virtual void indentSelection(const QTextCursor &selection,
|
virtual void indentSelection(const QTextCursor &selection,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const BaseTextDocument *textEditor) const;
|
const TextDocument *textEditor) const;
|
||||||
virtual void reindentSelection(const QTextCursor &selection,
|
virtual void reindentSelection(const QTextCursor &selection,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const BaseTextDocument *textEditor) const;
|
const TextDocument *textEditor) const;
|
||||||
virtual void fileChanged(const QString &fileName);
|
virtual void fileChanged(const QString &fileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -171,12 +171,12 @@ void TextMark::dragToLine(int lineNumber)
|
|||||||
Q_UNUSED(lineNumber);
|
Q_UNUSED(lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextDocument *TextMark::baseTextDocument() const
|
TextDocument *TextMark::baseTextDocument() const
|
||||||
{
|
{
|
||||||
return m_baseTextDocument;
|
return m_baseTextDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextMark::setBaseTextDocument(BaseTextDocument *baseTextDocument)
|
void TextMark::setBaseTextDocument(TextDocument *baseTextDocument)
|
||||||
{
|
{
|
||||||
m_baseTextDocument = baseTextDocument;
|
m_baseTextDocument = baseTextDocument;
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ TextMarkRegistry::TextMarkRegistry(QObject *parent)
|
|||||||
void TextMarkRegistry::add(TextMark *mark)
|
void TextMarkRegistry::add(TextMark *mark)
|
||||||
{
|
{
|
||||||
m_marks[FileName::fromString(mark->fileName())].insert(mark);
|
m_marks[FileName::fromString(mark->fileName())].insert(mark);
|
||||||
auto document = qobject_cast<BaseTextDocument*>(DocumentModel::documentForFilePath(mark->fileName()));
|
auto document = qobject_cast<TextDocument*>(DocumentModel::documentForFilePath(mark->fileName()));
|
||||||
if (!document)
|
if (!document)
|
||||||
return;
|
return;
|
||||||
document->addMark(mark);
|
document->addMark(mark);
|
||||||
@@ -210,7 +210,7 @@ bool TextMarkRegistry::remove(TextMark *mark)
|
|||||||
|
|
||||||
void TextMarkRegistry::editorOpened(Core::IEditor *editor)
|
void TextMarkRegistry::editorOpened(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
auto document = qobject_cast<BaseTextDocument *>(editor ? editor->document() : 0);
|
auto document = qobject_cast<TextDocument *>(editor ? editor->document() : 0);
|
||||||
if (!document)
|
if (!document)
|
||||||
return;
|
return;
|
||||||
if (!m_marks.contains(FileName::fromString(document->filePath())))
|
if (!m_marks.contains(FileName::fromString(document->filePath())))
|
||||||
@@ -223,7 +223,7 @@ void TextMarkRegistry::editorOpened(Core::IEditor *editor)
|
|||||||
void TextMarkRegistry::documentRenamed(IDocument *document, const
|
void TextMarkRegistry::documentRenamed(IDocument *document, const
|
||||||
QString &oldName, const QString &newName)
|
QString &oldName, const QString &newName)
|
||||||
{
|
{
|
||||||
BaseTextDocument *baseTextDocument = qobject_cast<BaseTextDocument *>(document);
|
TextDocument *baseTextDocument = qobject_cast<TextDocument *>(document);
|
||||||
if (!document)
|
if (!document)
|
||||||
return;
|
return;
|
||||||
FileName oldFileName = FileName::fromString(oldName);
|
FileName oldFileName = FileName::fromString(oldName);
|
||||||
|
@@ -44,7 +44,7 @@ QT_END_NAMESPACE
|
|||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
class BaseTextEditor;
|
class BaseTextEditor;
|
||||||
class BaseTextDocument;
|
class TextDocument;
|
||||||
|
|
||||||
namespace Internal { class TextMarkRegistry; }
|
namespace Internal { class TextMarkRegistry; }
|
||||||
|
|
||||||
@@ -87,14 +87,14 @@ public:
|
|||||||
double widthFactor() const;
|
double widthFactor() const;
|
||||||
void setWidthFactor(double factor);
|
void setWidthFactor(double factor);
|
||||||
|
|
||||||
BaseTextDocument *baseTextDocument() const;
|
TextDocument *baseTextDocument() const;
|
||||||
void setBaseTextDocument(BaseTextDocument *baseTextDocument);
|
void setBaseTextDocument(TextDocument *baseTextDocument);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(TextMark)
|
Q_DISABLE_COPY(TextMark)
|
||||||
friend class Internal::TextMarkRegistry;
|
friend class Internal::TextMarkRegistry;
|
||||||
|
|
||||||
BaseTextDocument *m_baseTextDocument;
|
TextDocument *m_baseTextDocument;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
int m_lineNumber;
|
int m_lineNumber;
|
||||||
Priority m_priority;
|
Priority m_priority;
|
||||||
|
@@ -65,8 +65,8 @@ VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters,
|
|||||||
setEditorActionHandlers(TextEditorActionHandler::None);
|
setEditorActionHandlers(TextEditorActionHandler::None);
|
||||||
setDuplicatedSupported(false);
|
setDuplicatedSupported(false);
|
||||||
|
|
||||||
setDocumentCreator([=]() -> BaseTextDocument* {
|
setDocumentCreator([=]() -> TextDocument* {
|
||||||
auto document = new BaseTextDocument(parameters->id);
|
auto document = new TextDocument(parameters->id);
|
||||||
// if (QLatin1String(parameters->mimeType) != QLatin1String(DiffEditor::Constants::DIFF_EDITOR_MIMETYPE))
|
// if (QLatin1String(parameters->mimeType) != QLatin1String(DiffEditor::Constants::DIFF_EDITOR_MIMETYPE))
|
||||||
document->setMimeType(QLatin1String(parameters->mimeType));
|
document->setMimeType(QLatin1String(parameters->mimeType));
|
||||||
return document;
|
return document;
|
||||||
|
@@ -1205,7 +1205,7 @@ const VcsBaseEditorParameters *VcsBaseEditor::findType(const VcsBaseEditorParame
|
|||||||
static QTextCodec *findFileCodec(const QString &source)
|
static QTextCodec *findFileCodec(const QString &source)
|
||||||
{
|
{
|
||||||
Core::IDocument *document = Core::DocumentModel::documentForFilePath(source);
|
Core::IDocument *document = Core::DocumentModel::documentForFilePath(source);
|
||||||
if (Core::TextDocument *textDocument = qobject_cast<Core::TextDocument *>(document))
|
if (Core::BaseTextDocument *textDocument = qobject_cast<Core::BaseTextDocument *>(document))
|
||||||
return const_cast<QTextCodec *>(textDocument->codec());
|
return const_cast<QTextCodec *>(textDocument->codec());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user