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.
This commit is contained in:
Oswald Buddenhagen
2011-04-15 11:53:46 +02:00
parent 801e5a2fdd
commit 9e7a4c7d4f
11 changed files with 10 additions and 62 deletions

View File

@@ -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;

View File

@@ -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()
{
}

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;

View File

@@ -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)

View File

@@ -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);

View File

@@ -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)

View File

@@ -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;

View File

@@ -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)

View File

@@ -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);