From 9e7a4c7d4ff5d1fb05cd47b0c00a102edb19f313 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 15 Apr 2011 11:53:46 +0200 Subject: [PATCH] provide default implementation of IFile::reloadBehavior() there only two classes of files anyway: regularly editable ones which may ask for interaction, and "background" files which always operate silently. the regular case is the more complex one, so put that into the base class. --- src/plugins/bineditor/bineditorplugin.cpp | 11 ----------- src/plugins/coreplugin/ifile.cpp | 9 +++++++++ src/plugins/coreplugin/ifile.h | 2 +- src/plugins/designer/formwindowfile.cpp | 12 ------------ src/plugins/designer/formwindowfile.h | 1 - src/plugins/imageviewer/imageviewerfile.cpp | 10 ---------- src/plugins/imageviewer/imageviewerfile.h | 1 - src/plugins/resourceeditor/resourceeditorw.cpp | 12 ------------ src/plugins/resourceeditor/resourceeditorw.h | 1 - src/plugins/texteditor/basetextdocument.cpp | 12 ------------ src/plugins/texteditor/basetextdocument.h | 1 - 11 files changed, 10 insertions(+), 62 deletions(-) diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 38a3caea48c..3e4a8aa2779 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -299,17 +299,6 @@ public: bool isSaveAsAllowed() const { return true; } - ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const { - if (type == TypePermissions) - return BehaviorSilent; - if (type == TypeContents) { - if (state == TriggerInternal && !isModified()) - return BehaviorSilent; - return BehaviorAsk; - } - return BehaviorAsk; - } - bool reload(QString *errorString, ReloadFlag flag, ChangeType type) { if (flag == FlagIgnore) return true; diff --git a/src/plugins/coreplugin/ifile.cpp b/src/plugins/coreplugin/ifile.cpp index 099dc38ff93..8ea80a789ad 100644 --- a/src/plugins/coreplugin/ifile.cpp +++ b/src/plugins/coreplugin/ifile.cpp @@ -42,6 +42,15 @@ IFile::~IFile() { } +IFile::ReloadBehavior IFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +{ + if (type == TypePermissions) + return BehaviorSilent; + if (type == TypeContents && state == TriggerInternal && !isModified()) + return BehaviorSilent; + return BehaviorAsk; +} + void IFile::checkPermissions() { } diff --git a/src/plugins/coreplugin/ifile.h b/src/plugins/coreplugin/ifile.h index 88262348e31..c0209c35fe6 100644 --- a/src/plugins/coreplugin/ifile.h +++ b/src/plugins/coreplugin/ifile.h @@ -94,7 +94,7 @@ public: virtual bool isReadOnly() const = 0; virtual bool isSaveAsAllowed() const = 0; - virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const = 0; + virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; virtual bool reload(QString *errorString, ReloadFlag flag, ChangeType type) = 0; virtual void rename(const QString &newName) = 0; diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp index 714d479efe8..dfa395af66d 100644 --- a/src/plugins/designer/formwindowfile.cpp +++ b/src/plugins/designer/formwindowfile.cpp @@ -129,18 +129,6 @@ bool FormWindowFile::isSaveAsAllowed() const return true; } -Core::IFile::ReloadBehavior FormWindowFile::reloadBehavior(ChangeTrigger state, ChangeType type) const -{ - if (type == TypePermissions) - return BehaviorSilent; - if (type == TypeContents) { - if (state == TriggerInternal && !isModified()) - return BehaviorSilent; - return BehaviorAsk; - } - return BehaviorAsk; -} - bool FormWindowFile::reload(QString *errorString, ReloadFlag flag, ChangeType type) { if (flag == FlagIgnore) diff --git a/src/plugins/designer/formwindowfile.h b/src/plugins/designer/formwindowfile.h index 4bc1075927b..262f7556448 100644 --- a/src/plugins/designer/formwindowfile.h +++ b/src/plugins/designer/formwindowfile.h @@ -58,7 +58,6 @@ public: virtual bool isModified() const; virtual bool isReadOnly() const; virtual bool isSaveAsAllowed() const; - ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; bool reload(QString *errorString, ReloadFlag flag, ChangeType type); virtual QString defaultPath() const; virtual QString suggestedFileName() const; diff --git a/src/plugins/imageviewer/imageviewerfile.cpp b/src/plugins/imageviewer/imageviewerfile.cpp index 4d1fa464551..5c5c600e77d 100644 --- a/src/plugins/imageviewer/imageviewerfile.cpp +++ b/src/plugins/imageviewer/imageviewerfile.cpp @@ -64,16 +64,6 @@ ImageViewerFile::~ImageViewerFile() { } -Core::IFile::ReloadBehavior ImageViewerFile::reloadBehavior(Core::IFile::ChangeTrigger state, - Core::IFile::ChangeType type) const -{ - if (type == TypePermissions) - return BehaviorSilent; - if (type == TypeContents && state == TriggerInternal) - return BehaviorSilent; - return BehaviorAsk; -} - bool ImageViewerFile::reload(QString *errorString, Core::IFile::ReloadFlag flag, Core::IFile::ChangeType type) diff --git a/src/plugins/imageviewer/imageviewerfile.h b/src/plugins/imageviewer/imageviewerfile.h index b449bb16c09..5fbe32a95c5 100644 --- a/src/plugins/imageviewer/imageviewerfile.h +++ b/src/plugins/imageviewer/imageviewerfile.h @@ -61,7 +61,6 @@ public: bool isReadOnly() const; bool isSaveAsAllowed() const; - ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; bool reload(QString *errorString, ReloadFlag flag, ChangeType type); void setMimetype(const QString &mimetype); diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp index 8612f2d8d26..e904506837f 100644 --- a/src/plugins/resourceeditor/resourceeditorw.cpp +++ b/src/plugins/resourceeditor/resourceeditorw.cpp @@ -193,18 +193,6 @@ bool ResourceEditorFile::isSaveAsAllowed() const return true; } -Core::IFile::ReloadBehavior ResourceEditorFile::reloadBehavior(ChangeTrigger state, ChangeType type) const -{ - if (type == TypePermissions) - return BehaviorSilent; - if (type == TypeContents) { - if (state == TriggerInternal && !isModified()) - return BehaviorSilent; - return BehaviorAsk; - } - return BehaviorAsk; -} - bool ResourceEditorFile::reload(QString *errorString, ReloadFlag flag, ChangeType type) { if (flag == FlagIgnore) diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h index 031079c2ff2..e3aebe87750 100644 --- a/src/plugins/resourceeditor/resourceeditorw.h +++ b/src/plugins/resourceeditor/resourceeditorw.h @@ -62,7 +62,6 @@ public: bool isModified() const; bool isReadOnly() const; bool isSaveAsAllowed() const; - ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; bool reload(QString *errorString, ReloadFlag flag, ChangeType type); QString defaultPath() const; QString suggestedFileName() const; diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index e8ee9faeafc..b7add622fac 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -609,18 +609,6 @@ bool BaseTextDocument::reload(QString *errorString) return true; } -Core::IFile::ReloadBehavior BaseTextDocument::reloadBehavior(ChangeTrigger state, ChangeType type) const -{ - if (type == TypePermissions) - return BehaviorSilent; - if (type == TypeContents) { - if (state == TriggerInternal && !isModified()) - return BehaviorSilent; - return BehaviorAsk; - } - return BehaviorAsk; -} - bool BaseTextDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type) { if (flag == FlagIgnore) diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index bc59daae7bf..8e3847d6cb1 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -76,7 +76,6 @@ public: virtual bool isModified() const; virtual bool isSaveAsAllowed() const; virtual void checkPermissions(); - ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; bool reload(QString *errorString, ReloadFlag flag, ChangeType type); virtual QString mimeType() const; void setMimeType(const QString &mt);