forked from qt-creator/qt-creator
Move BaseTextDocument::documentClosing to BaseTextDocumentLayout
Centralizing mark handling Change-Id: Ie29c15d97aa171fbf3516d4242fe3f962091477a Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -97,7 +97,6 @@ BaseTextDocument::BaseTextDocument() : d(new BaseTextDocumentPrivate(this))
|
|||||||
|
|
||||||
BaseTextDocument::~BaseTextDocument()
|
BaseTextDocument::~BaseTextDocument()
|
||||||
{
|
{
|
||||||
documentClosing();
|
|
||||||
delete d->m_document;
|
delete d->m_document;
|
||||||
d->m_document = 0;
|
d->m_document = 0;
|
||||||
delete d;
|
delete d;
|
||||||
@@ -377,7 +376,10 @@ bool BaseTextDocument::reload(QString *errorString, QTextCodec *codec)
|
|||||||
bool BaseTextDocument::reload(QString *errorString)
|
bool BaseTextDocument::reload(QString *errorString)
|
||||||
{
|
{
|
||||||
emit aboutToReload();
|
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))
|
if (!open(errorString, d->m_fileName, d->m_fileName))
|
||||||
return false;
|
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
|
bool BaseTextDocument::hasHighlightWarning() const
|
||||||
{
|
{
|
||||||
return d->m_hasHighlightWarning;
|
return d->m_hasHighlightWarning;
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ signals:
|
|||||||
private:
|
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);
|
||||||
void documentClosing();
|
|
||||||
|
|
||||||
BaseTextDocumentPrivate *d;
|
BaseTextDocumentPrivate *d;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -516,6 +516,7 @@ BaseTextDocumentLayout::BaseTextDocumentLayout(QTextDocument *doc)
|
|||||||
|
|
||||||
BaseTextDocumentLayout::~BaseTextDocumentLayout()
|
BaseTextDocumentLayout::~BaseTextDocumentLayout()
|
||||||
{
|
{
|
||||||
|
documentClosing();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocumentLayout::setParentheses(const QTextBlock &block, const Parentheses &parentheses)
|
void BaseTextDocumentLayout::setParentheses(const QTextBlock &block, const Parentheses &parentheses)
|
||||||
@@ -699,6 +700,17 @@ QSizeF BaseTextDocumentLayout::documentSize() const
|
|||||||
return size;
|
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()
|
void BaseTextDocumentLayout::updateMarksLineNumber()
|
||||||
{
|
{
|
||||||
QTextBlock block = document()->begin();
|
QTextBlock block = document()->begin();
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ public:
|
|||||||
|
|
||||||
QSizeF documentSize() const;
|
QSizeF documentSize() const;
|
||||||
|
|
||||||
|
void documentClosing();
|
||||||
void updateMarksLineNumber();
|
void updateMarksLineNumber();
|
||||||
void updateMarksBlock(const QTextBlock &block);
|
void updateMarksBlock(const QTextBlock &block);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user