TextEditor: modernize TextDocument

Change-Id: I9ea17165ba4eade89a6119135378793256e13358
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2018-02-15 08:34:26 +01:00
parent 6e236d04a6
commit e10b220189
2 changed files with 16 additions and 20 deletions

View File

@@ -77,18 +77,14 @@ namespace TextEditor {
class TextDocumentPrivate
{
public:
TextDocumentPrivate() :
m_fontSettingsNeedsApply(false),
m_highlighter(0),
m_completionAssistProvider(0),
m_indenter(new Indenter),
m_fileIsReadOnly(false),
m_autoSaveRevision(-1)
TextDocumentPrivate()
: m_indenter(new Indenter)
{
}
QTextCursor indentOrUnindent(const QTextCursor &textCursor, bool doIndent,
bool blockSelection = false, int column = 0, int *offset = 0);
bool blockSelection = false, int column = 0,
int *offset = nullptr);
void resetRevisions();
void updateRevisions();
@@ -100,14 +96,14 @@ public:
TabSettings m_tabSettings;
ExtraEncodingSettings m_extraEncodingSettings;
FontSettings m_fontSettings;
bool m_fontSettingsNeedsApply; // for applying font settings delayed till an editor becomes visible
bool m_fontSettingsNeedsApply = false; // for applying font settings delayed till an editor becomes visible
QTextDocument m_document;
SyntaxHighlighter *m_highlighter;
CompletionAssistProvider *m_completionAssistProvider;
SyntaxHighlighter *m_highlighter = nullptr;
CompletionAssistProvider *m_completionAssistProvider = nullptr;
QScopedPointer<Indenter> m_indenter;
bool m_fileIsReadOnly;
int m_autoSaveRevision;
bool m_fileIsReadOnly = false;
int m_autoSaveRevision = -1;
TextMarks m_marksCache; // Marks not owned
Utils::Guard m_modificationChangedGuard;
@@ -181,7 +177,7 @@ QTextCursor TextDocumentPrivate::indentOrUnindent(const QTextCursor &textCursor,
text = block.text();
}
int indentPosition = ts.positionAtColumn(text, column, 0, true);
int indentPosition = ts.positionAtColumn(text, column, nullptr, true);
int spaces = ts.spacesLeftFromPosition(text, indentPosition);
int startColumn = ts.columnAt(text, indentPosition - spaces);
int targetColumn = ts.indentedColumn(ts.columnAt(text, indentPosition), doIndent);
@@ -449,7 +445,7 @@ void TextDocument::setIndenter(Indenter *indenter)
for (QTextBlock it = document()->begin(); it.isValid(); it = it.next()) {
TextBlockUserData *userData = TextDocumentLayout::testUserData(it);
if (userData)
userData->setCodeFormatterData(0);
userData->setCodeFormatterData(nullptr);
}
d->m_indenter.reset(indenter);
}
@@ -506,7 +502,7 @@ bool TextDocument::save(QString *errorString, const QString &saveFileName, bool
QTextCursor cursor(&d->m_document);
// When autosaving, we don't want to modify the document/location under the user's fingers.
TextEditorWidget *editorWidget = 0;
TextEditorWidget *editorWidget = nullptr;
int savedPosition = 0;
int savedAnchor = 0;
int savedVScrollBarValue = 0;
@@ -979,7 +975,7 @@ void TextDocument::removeMark(TextMark *mark)
removeMarkFromMarksCache(mark);
emit markRemoved(mark);
mark->setBaseTextDocument(0);
mark->setBaseTextDocument(nullptr);
updateLayout();
}
@@ -1003,7 +999,7 @@ void TextDocument::moveMark(TextMark *mark, int previousLine)
qDebug() << "Could not find mark" << mark << "on line" << previousLine;
}
removeMarkFromMarksCache(mark);
mark->setBaseTextDocument(0);
mark->setBaseTextDocument(nullptr);
addMark(mark);
}

View File

@@ -89,9 +89,9 @@ public:
void autoIndent(const QTextCursor &cursor, QChar typedChar = QChar::Null);
void autoReindent(const QTextCursor &cursor);
QTextCursor indent(const QTextCursor &cursor, bool blockSelection = false, int column = 0,
int *offset = 0);
int *offset = nullptr);
QTextCursor unindent(const QTextCursor &cursor, bool blockSelection = false, int column = 0,
int *offset = 0);
int *offset = nullptr);
TextMarks marks() const;
bool addMark(TextMark *mark);