EditorManager: Auto-suspend editors

Adds an option (enabled by default) to close older documents when
opening new documents. These documents are put into "suspended" state,
similar to when restoring sessions: They editors and document are
removed, freeing the memory from their content and attached resources
(e.g. code model resources), but keeping the entry in the open editor
list (and history list, of course).
This is limited to editor/document types that can restore their UI state
when the document is reopened.

Task-number: QTCREATORBUG-10016
Change-Id: Icb5595aec950e3f666d42177fe2fd233954f2772
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Eike Ziller
2016-06-13 12:59:35 +02:00
parent 98192159da
commit 92e352f4f0
11 changed files with 322 additions and 148 deletions

View File

@@ -78,6 +78,7 @@ public:
bool temporary = false;
bool hasWriteWarning = false;
bool restored = false;
bool isSuspendAllowed = false;
};
} // namespace Internal
@@ -207,6 +208,16 @@ bool IDocument::isSaveAsAllowed() const
return false;
}
bool IDocument::isSuspendAllowed() const
{
return d->isSuspendAllowed;
}
void IDocument::setSuspendAllowed(bool value)
{
d->isSuspendAllowed = value;
}
bool IDocument::isFileReadOnly() const
{
if (filePath().isEmpty())
@@ -351,6 +362,11 @@ void IDocument::setPreferredDisplayName(const QString &name)
emit changed();
}
QString IDocument::preferredDisplayName() const
{
return d->preferredDisplayName;
}
/*!
\internal
Returns displayName without disambiguation.
@@ -369,4 +385,9 @@ void IDocument::setUniqueDisplayName(const QString &name)
d->uniqueDisplayName = name;
}
QString IDocument::uniqueDisplayName() const
{
return d->uniqueDisplayName;
}
} // namespace Core