diff options
author | con <qtc-committer@nokia.com> | 2010-03-19 10:28:05 +0100 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2010-03-22 16:01:55 +0100 |
commit | d6061a23e16bfa1f76cf9a153d3d5a923bb0fa59 (patch) | |
tree | caccfe93f588b3282af3c4be209dc755a5f7cc83 /src/plugins/resourceeditor | |
parent | 5bc886c5b643d69c841005777538e24cb223d75d (diff) | |
download | qt-creator-d6061a23e16bfa1f76cf9a153d3d5a923bb0fa59.tar.gz |
Refactor the externally modified file handling
Reviewed-by: dt
Diffstat (limited to 'src/plugins/resourceeditor')
-rw-r--r-- | src/plugins/resourceeditor/resourceeditorw.cpp | 48 | ||||
-rw-r--r-- | src/plugins/resourceeditor/resourceeditorw.h | 3 |
2 files changed, 18 insertions, 33 deletions
diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp index df993a58fa..7fde0e20ae 100644 --- a/src/plugins/resourceeditor/resourceeditorw.cpp +++ b/src/plugins/resourceeditor/resourceeditorw.cpp @@ -185,42 +185,26 @@ bool ResourceEditorFile::isSaveAsAllowed() const return true; } -void ResourceEditorFile::modified(Core::IFile::ReloadBehavior *behavior) +Core::IFile::ReloadBehavior ResourceEditorFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { - const QString fileName = m_parent->m_resourceEditor->fileName(); + if (type == TypePermissions) + return BehaviorSilent; + if (type == TypeContents) { + if (state == TriggerInternal && !isModified()) + return BehaviorSilent; + return BehaviorAsk; + } + return BehaviorAsk; +} - switch (*behavior) { - case Core::IFile::ReloadNone: - return; - case Core::IFile::ReloadUnmodified: - if (!isModified()) { - m_parent->open(fileName); - return; - } - break; - case Core::IFile::ReloadAll: - m_parent->open(fileName); +void ResourceEditorFile::reload(ReloadFlag flag, ChangeType type) +{ + if (flag == FlagIgnore) return; - case Core::IFile::ReloadPermissions: + if (type == TypePermissions) { emit changed(); - return; - case Core::IFile::AskForReload: - break; - } - - switch (Utils::reloadPrompt(fileName, isModified(), Core::ICore::instance()->mainWindow())) { - case Utils::ReloadCurrent: - m_parent->open(fileName); - break; - case Utils::ReloadAll: - m_parent->open(fileName); - *behavior = Core::IFile::ReloadAll; - break; - case Utils::ReloadSkipCurrent: - break; - case Utils::ReloadNone: - *behavior = Core::IFile::ReloadNone; - break; + } else { + m_parent->open(m_parent->m_resourceEditor->fileName()); } } diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h index f8b275d6ef..e0a2e5f7b2 100644 --- a/src/plugins/resourceeditor/resourceeditorw.h +++ b/src/plugins/resourceeditor/resourceeditorw.h @@ -62,7 +62,8 @@ public: bool isModified() const; bool isReadOnly() const; bool isSaveAsAllowed() const; - void modified(Core::IFile::ReloadBehavior *behavior); + ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; + void reload(ReloadFlag flag, ChangeType type); QString defaultPath() const; QString suggestedFileName() const; virtual QString mimeType() const; |