forked from qt-creator/qt-creator
VCS editors: Fix revision markers
Resets the revisions when setting the contents of text editor documents in general. Task-number: QTCREATORBUG-11356 Change-Id: I4069d629d8a612d42c7deae707300d50690e2db7 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -70,6 +70,7 @@ public:
|
||||
explicit BaseTextDocumentPrivate(BaseTextDocument *q);
|
||||
|
||||
QTextCursor indentOrUnindent(const QTextCursor &textCursor, bool doIndent);
|
||||
void resetRevisions();
|
||||
|
||||
QString m_defaultPath;
|
||||
QString m_suggestedFileName;
|
||||
@@ -150,6 +151,16 @@ QTextCursor BaseTextDocumentPrivate::indentOrUnindent(const QTextCursor &textCur
|
||||
return cursor;
|
||||
}
|
||||
|
||||
void BaseTextDocumentPrivate::resetRevisions()
|
||||
{
|
||||
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(m_document->documentLayout());
|
||||
QTC_ASSERT(documentLayout, return);
|
||||
documentLayout->lastSaveRevision = m_document->revision();
|
||||
|
||||
for (QTextBlock block = m_document->begin(); block.isValid(); block = block.next())
|
||||
block.setRevision(documentLayout->lastSaveRevision);
|
||||
}
|
||||
|
||||
BaseTextDocument::BaseTextDocument() : d(new BaseTextDocumentPrivate(this))
|
||||
{
|
||||
connect(d->m_document, SIGNAL(modificationChanged(bool)), this, SIGNAL(changed()));
|
||||
@@ -448,14 +459,7 @@ bool BaseTextDocument::save(QString *errorString, const QString &saveFileName, b
|
||||
|
||||
bool BaseTextDocument::setContents(const QByteArray &contents)
|
||||
{
|
||||
if (contents.size() > EditorManager::maxTextFileSize()) {
|
||||
document()->setPlainText(BaseTextEditorWidget::msgTextTooLarge(contents.size()));
|
||||
document()->setModified(false);
|
||||
return false;
|
||||
}
|
||||
document()->setPlainText(QString::fromUtf8(contents));
|
||||
document()->setModified(false);
|
||||
return true;
|
||||
return setPlainText(QString::fromUtf8(contents));
|
||||
}
|
||||
|
||||
bool BaseTextDocument::shouldAutoSave() const
|
||||
@@ -566,6 +570,20 @@ bool BaseTextDocument::reload(QString *errorString)
|
||||
return success;
|
||||
}
|
||||
|
||||
bool BaseTextDocument::setPlainText(const QString &text)
|
||||
{
|
||||
if (text.size() > EditorManager::maxTextFileSize()) {
|
||||
document()->setPlainText(BaseTextEditorWidget::msgTextTooLarge(text.size()));
|
||||
d->resetRevisions();
|
||||
document()->setModified(false);
|
||||
return false;
|
||||
}
|
||||
document()->setPlainText(text);
|
||||
d->resetRevisions();
|
||||
document()->setModified(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BaseTextDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
||||
{
|
||||
if (flag == FlagIgnore)
|
||||
|
||||
Reference in New Issue
Block a user