From f93638bcd1d0cfc78539805399df60a7353f3239 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Sat, 24 Mar 2018 19:15:39 +0100 Subject: [PATCH] logic: Fixed project state messages wrong on loading --- src/lib/Application.cpp | 2 +- src/lib/project/Project.cpp | 36 +++++++++++++++++------------------- src/lib/project/Project.h | 3 +-- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 8cee65db..d9eaa746 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -286,7 +286,7 @@ void Application::handleMessage(MessageLoadProject* message) { if (message->settingsChanged && m_hasGUI) { - m_project->setStateSettingsUpdated(); + m_project->setStateOutdated(); refreshProject(REFRESH_ALL_FILES); } } diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index 0dd7d09b..0253f4d4 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -64,11 +64,11 @@ bool Project::settingsEqualExceptNameAndLocation(const ProjectSettings& otherSet return m_settings->equalsExceptNameAndLocation(otherSettings); } -void Project::setStateSettingsUpdated() +void Project::setStateOutdated() { - if (m_state != PROJECT_STATE_NOT_LOADED && m_state != PROJECT_STATE_EMPTY) + if (m_state == PROJECT_STATE_LOADED) { - m_state = PROJECT_STATE_SETTINGS_UPDATED; + m_state = PROJECT_STATE_OUTDATED; } } @@ -126,7 +126,7 @@ void Project::load() { m_storage->setup(); } - catch(...) + catch (...) { LOG_ERROR("Exception has been encountered while loading the project."); @@ -153,13 +153,16 @@ void Project::load() switch (m_state) { case PROJECT_STATE_NEEDS_MIGRATION: - MessageStatus(L"Project could not be loaded and needs to be re-indexed after automatic migration to latest version.", false, false).dispatch(); + MessageStatus(L"Project could not be loaded and needs to be re-indexed after automatic migration to latest " + "version.", false, false).dispatch(); break; case PROJECT_STATE_EMPTY: - MessageStatus(L"Project could load any symbols because the index database is empty. Please re-index the project.", false, false).dispatch(); + MessageStatus(L"Project could load any symbols because the index database is empty. Please re-index the " + "project.", false, false).dispatch(); break; case PROJECT_STATE_OUTVERSIONED: - MessageStatus(L"Project could not be loaded because the indexed data format is incompatible to the current version of Sourcetrail. Please re-index the project.", false, false).dispatch(); + MessageStatus(L"Project could not be loaded because the indexed data format is incompatible to the current " + "version of Sourcetrail. Please re-index the project.", false, false).dispatch(); break; default: MessageStatus(L"Project could not be loaded.", false, false).dispatch(); @@ -202,30 +205,25 @@ void Project::refresh(RefreshMode refreshMode, DialogView* dialogView) case PROJECT_STATE_OUTVERSIONED: question = - "This project was indexed with a different version of Sourcetrail. It needs to be fully reindexed to be used " - "with this version of Sourcetrail. Do you want to reindex the project?"; + "This project was indexed with a different version of Sourcetrail. It needs to be fully reindexed to " + "be used with this version of Sourcetrail. Do you want to reindex the project?"; needsFullRefresh = true; break; - case PROJECT_STATE_SETTINGS_UPDATED: - question = - "Some settings were changed, the project should be fully reindexed. Alternatively you can also choose to " - "just reindex updated or incomplete files. " - "Do you want to reindex the project?"; - fullRefresh = true; - break; - case PROJECT_STATE_NEEDS_MIGRATION: question = - "This project was created with a different version of Sourcetrail. The project file needs to get updated and " - "the project fully reindexed. Do you want to update the project file and reindex the project?"; + "This project was created with a different version and uses an old project file format. " + "The project can still be opened and used with this version, but needs to be fully reindexed. " + "Do you want Sourcetrail to update the project file and reindex the project?"; needsFullRefresh = true; + break; case PROJECT_STATE_DB_CORRUPTED: question = "There was a problem loading the index of this project. The project needs to get fully reindexed. " "Do you want to reindex the project?"; needsFullRefresh = true; + break; default: break; diff --git a/src/lib/project/Project.h b/src/lib/project/Project.h index 4e727bc3..ed6dba74 100644 --- a/src/lib/project/Project.h +++ b/src/lib/project/Project.h @@ -26,7 +26,7 @@ public: std::string getDescription() const; bool settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const; - void setStateSettingsUpdated(); + void setStateOutdated(); void load(); @@ -44,7 +44,6 @@ private: PROJECT_STATE_LOADED, PROJECT_STATE_OUTDATED, PROJECT_STATE_OUTVERSIONED, - PROJECT_STATE_SETTINGS_UPDATED, PROJECT_STATE_NEEDS_MIGRATION, PROJECT_STATE_DB_CORRUPTED };