IDocument: Simplify permission changes

Take care of handling file permission changes centrally.

TextDocument had its own, caching implementation of tracking the backing
file's read-only state. Move that into IDocument directly.

IDocument::reload with a permission-only change is not a very
interesting case, but every subclass needed to add handling of it.
Instead, remove TypePermission from the file-change types, and handle it
separately via the now unified checkPermissions() implementation.
IDocument::reloadBehavior already was never called with TypePermission.

Change-Id: I321d47ba6193bc878efa9bb50ba7a739fa492745
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2021-01-13 16:27:02 +01:00
parent 71b5a9e19a
commit 484d40258a
15 changed files with 65 additions and 120 deletions

View File

@@ -148,7 +148,7 @@ Core::IDocument::OpenResult ImageViewerFile::openImpl(QString *errorString, cons
Core::IDocument::ReloadBehavior ImageViewerFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{
if (type == TypeRemoved || type == TypePermissions)
if (type == TypeRemoved)
return BehaviorSilent;
if (type == TypeContents && state == TriggerInternal && !isModified())
return BehaviorSilent;
@@ -159,12 +159,9 @@ bool ImageViewerFile::reload(QString *errorString,
Core::IDocument::ReloadFlag flag,
Core::IDocument::ChangeType type)
{
Q_UNUSED(type)
if (flag == FlagIgnore)
return true;
if (type == TypePermissions) {
emit changed();
return true;
}
emit aboutToReload();
bool success = (openImpl(errorString, filePath().toString()) == OpenResult::Success);
emit reloadFinished(success);