forked from qt-creator/qt-creator
TextEditors: Move indenter to document.
Change-Id: I8bdf7134562d007aa16cc63a34f5a15a708577ae Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -32,12 +32,13 @@
|
||||
#include "basetextdocumentlayout.h"
|
||||
#include "basetexteditor.h"
|
||||
#include "convenience.h"
|
||||
#include "typingsettings.h"
|
||||
#include "storagesettings.h"
|
||||
#include "tabsettings.h"
|
||||
#include "extraencodingsettings.h"
|
||||
#include "indenter.h"
|
||||
#include "storagesettings.h"
|
||||
#include "syntaxhighlighter.h"
|
||||
#include "tabsettings.h"
|
||||
#include "texteditorconstants.h"
|
||||
#include "typingsettings.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
@@ -68,6 +69,7 @@ public:
|
||||
ExtraEncodingSettings m_extraEncodingSettings;
|
||||
QTextDocument *m_document;
|
||||
SyntaxHighlighter *m_highlighter;
|
||||
QScopedPointer<Indenter> m_indenter;
|
||||
|
||||
bool m_fileIsReadOnly;
|
||||
int m_autoSaveRevision;
|
||||
@@ -76,6 +78,7 @@ public:
|
||||
BaseTextDocumentPrivate::BaseTextDocumentPrivate(BaseTextDocument *q) :
|
||||
m_document(new QTextDocument(q)),
|
||||
m_highlighter(0),
|
||||
m_indenter(new Indenter),
|
||||
m_fileIsReadOnly(false),
|
||||
m_autoSaveRevision(-1)
|
||||
{
|
||||
@@ -172,6 +175,22 @@ const ExtraEncodingSettings &BaseTextDocument::extraEncodingSettings() const
|
||||
return d->m_extraEncodingSettings;
|
||||
}
|
||||
|
||||
void BaseTextDocument::setIndenter(Indenter *indenter)
|
||||
{
|
||||
// clear out existing code formatter data
|
||||
for (QTextBlock it = document()->begin(); it.isValid(); it = it.next()) {
|
||||
TextEditor::TextBlockUserData *userData = BaseTextDocumentLayout::testUserData(it);
|
||||
if (userData)
|
||||
userData->setCodeFormatterData(0);
|
||||
}
|
||||
d->m_indenter.reset(indenter);
|
||||
}
|
||||
|
||||
Indenter *BaseTextDocument::indenter() const
|
||||
{
|
||||
return d->m_indenter.data();
|
||||
}
|
||||
|
||||
bool BaseTextDocument::isSaveAsAllowed() const
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user