forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user