Commit 45850c23 authored by Daniel Teske's avatar Daniel Teske
Browse files

Move BaseTextDocument::documentClosing to BaseTextDocumentLayout



Centralizing mark handling

Change-Id: Ie29c15d97aa171fbf3516d4242fe3f962091477a
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent c44d65d3
......@@ -97,7 +97,6 @@ BaseTextDocument::BaseTextDocument() : d(new BaseTextDocumentPrivate(this))
BaseTextDocument::~BaseTextDocument()
{
documentClosing();
delete d->m_document;
d->m_document = 0;
delete d;
......@@ -377,7 +376,10 @@ bool BaseTextDocument::reload(QString *errorString, QTextCodec *codec)
bool BaseTextDocument::reload(QString *errorString)
{
emit aboutToReload();
documentClosing(); // removes text marks non-permanently
BaseTextDocumentLayout *documentLayout =
qobject_cast<BaseTextDocumentLayout*>(d->m_document->documentLayout());
if (documentLayout)
documentLayout->documentClosing(); // removes text marks non-permanently
if (!open(errorString, d->m_fileName, d->m_fileName))
return false;
......@@ -471,16 +473,6 @@ void BaseTextDocument::ensureFinalNewLine(QTextCursor& cursor)
}
}
void BaseTextDocument::documentClosing()
{
QTextBlock block = d->m_document->begin();
while (block.isValid()) {
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData()))
data->documentClosing();
block = block.next();
}
}
bool BaseTextDocument::hasHighlightWarning() const
{
return d->m_hasHighlightWarning;
......
......@@ -110,7 +110,6 @@ signals:
private:
void cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument);
void ensureFinalNewLine(QTextCursor &cursor);
void documentClosing();
BaseTextDocumentPrivate *d;
};
......
......@@ -516,6 +516,7 @@ BaseTextDocumentLayout::BaseTextDocumentLayout(QTextDocument *doc)
BaseTextDocumentLayout::~BaseTextDocumentLayout()
{
documentClosing();
}
void BaseTextDocumentLayout::setParentheses(const QTextBlock &block, const Parentheses &parentheses)
......@@ -699,6 +700,17 @@ QSizeF BaseTextDocumentLayout::documentSize() const
return size;
}
void BaseTextDocumentLayout::documentClosing()
{
QTextBlock block = document()->begin();
while (block.isValid()) {
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData()))
data->documentClosing();
block = block.next();
}
}
void BaseTextDocumentLayout::updateMarksLineNumber()
{
QTextBlock block = document()->begin();
......
......@@ -214,6 +214,7 @@ public:
QSizeF documentSize() const;
void documentClosing();
void updateMarksLineNumber();
void updateMarksBlock(const QTextBlock &block);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment