From ad325ac974bf22ad6169118050fe97d499c7b82b Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Tue, 10 Jul 2018 11:42:58 +0200 Subject: [PATCH] logic: background indexing (issue #175) * allow hiding of indexing dialogs to browse loaded project while indexing * show indexing status in status bar while indexing * use different dialog views for different use cases to avoid state collisions * fixed error label in status bar jittering while indexing * show hand cursors for clickable elements in status bar * indexing is not interrupted on pressing ESC while in hidden * disable error table and error label while indexing * refactored indexing messages * forbid indexing and changing project while indexing * don't show indexing status messages in status bar when indexing in the background * allow tasks to run in the background fortune cookie message = A journey is waiting for you. --- bin/app/data/color_schemes/bad_rainbow.xml | 1 + bin/app/data/color_schemes/bright.xml | 1 + bin/app/data/color_schemes/dark.xml | 1 + bin/app/data/gui/tabbed_view/tabbed_view.css | 16 ++ src/lib/Application.cpp | 125 ++++++------- src/lib/Application.h | 11 +- src/lib/CMakeLists.txt | 8 +- src/lib/component/ComponentManager.cpp | 25 ++- src/lib/component/ComponentManager.h | 5 +- .../controller/BookmarkController.cpp | 2 +- .../component/controller/BookmarkController.h | 6 +- .../component/controller/ErrorController.cpp | 17 +- .../component/controller/ErrorController.h | 9 +- .../controller/StatusBarController.cpp | 20 +- .../controller/StatusBarController.h | 9 +- .../controller/UndoRedoController.cpp | 52 +++--- .../component/controller/UndoRedoController.h | 6 +- src/lib/component/view/CompositeView.cpp | 5 + src/lib/component/view/CompositeView.h | 2 + src/lib/component/view/DialogView.cpp | 33 +++- src/lib/component/view/DialogView.h | 27 ++- src/lib/component/view/StatusBarView.cpp | 4 - src/lib/component/view/StatusBarView.h | 8 +- src/lib/component/view/TabbedView.cpp | 5 + src/lib/component/view/TabbedView.h | 2 + src/lib/component/view/View.cpp | 5 + src/lib/component/view/View.h | 2 + src/lib/component/view/ViewFactory.cpp | 4 - src/lib/component/view/ViewFactory.h | 7 +- src/lib/component/view/ViewLayout.h | 2 + src/lib/data/TaskCleanStorage.cpp | 6 +- src/lib/data/TaskFinishParsing.cpp | 8 +- .../data/TaskShowUnknownProgressDialog.cpp | 34 ---- src/lib/data/TaskShowUnknownProgressDialog.h | 27 --- src/lib/data/indexer/TaskBuildIndex.cpp | 21 +-- src/lib/data/parser/TaskParseWrapper.cpp | 7 +- src/lib/data/storage/PersistentStorage.cpp | 6 +- src/lib/project/Project.cpp | 111 ++++++----- src/lib/project/Project.h | 7 +- .../messaging/type/MessageFinishedParsing.h | 20 -- .../utility/messaging/type/MessageStatus.cpp | 6 +- .../utility/messaging/type/MessageStatus.h | 5 +- .../type/indexing/MessageIndexingFinished.h | 20 ++ .../type/indexing/MessageIndexingShowDialog.h | 23 +++ .../type/indexing/MessageIndexingStarted.h | 20 ++ .../type/indexing/MessageIndexingStatus.h | 28 +++ src/lib/utility/scheduling/Task.cpp | 17 +- src/lib/utility/scheduling/Task.h | 11 +- .../utility/scheduling/TaskGroupSelector.h | 2 +- .../utility/scheduling/TaskGroupSequence.h | 2 +- src/lib/utility/scheduling/TaskRunner.cpp | 18 +- src/lib/utility/scheduling/TaskRunner.h | 4 +- src/lib/utility/scheduling/TaskScheduler.cpp | 4 +- src/lib_gui/qt/element/QtCodeNavigator.cpp | 2 +- src/lib_gui/qt/element/QtCodeNavigator.h | 6 +- src/lib_gui/qt/element/QtStatusBar.cpp | 127 +++++++++++-- src/lib_gui/qt/element/QtStatusBar.h | 14 ++ src/lib_gui/qt/view/QtDialogView.cpp | 175 +++++++++++++----- src/lib_gui/qt/view/QtDialogView.h | 19 +- src/lib_gui/qt/view/QtErrorView.cpp | 1 - src/lib_gui/qt/view/QtMainView.cpp | 12 ++ src/lib_gui/qt/view/QtMainView.h | 2 + src/lib_gui/qt/view/QtStatusBarView.cpp | 24 ++- src/lib_gui/qt/view/QtStatusBarView.h | 5 +- src/lib_gui/qt/view/QtViewFactory.cpp | 9 +- src/lib_gui/qt/view/QtViewFactory.h | 8 +- src/lib_gui/qt/window/QtIndexingDialog.cpp | 35 +++- src/lib_gui/qt/window/QtIndexingDialog.h | 7 +- src/lib_gui/qt/window/QtPreferencesWindow.cpp | 2 +- src/lib_gui/qt/window/QtWindowStack.cpp | 6 +- src/lib_gui/qt/window/QtWindowStack.h | 6 +- .../QtProjectWizzardContentPath.cpp | 6 +- .../QtProjectWizzardContentPaths.cpp | 20 +- .../project/SourceGroupJavaGradle.cpp | 4 +- src/lib_java/project/SourceGroupJavaMaven.cpp | 4 +- src/lib_java/utility/utilityJava.cpp | 2 +- 76 files changed, 875 insertions(+), 448 deletions(-) delete mode 100644 src/lib/data/TaskShowUnknownProgressDialog.cpp delete mode 100644 src/lib/data/TaskShowUnknownProgressDialog.h delete mode 100644 src/lib/utility/messaging/type/MessageFinishedParsing.h create mode 100644 src/lib/utility/messaging/type/indexing/MessageIndexingFinished.h create mode 100644 src/lib/utility/messaging/type/indexing/MessageIndexingShowDialog.h create mode 100644 src/lib/utility/messaging/type/indexing/MessageIndexingStarted.h create mode 100644 src/lib/utility/messaging/type/indexing/MessageIndexingStatus.h diff --git a/bin/app/data/color_schemes/bad_rainbow.xml b/bin/app/data/color_schemes/bad_rainbow.xml index 31bc0eae..31f8d967 100644 --- a/bin/app/data/color_schemes/bad_rainbow.xml +++ b/bin/app/data/color_schemes/bad_rainbow.xml @@ -541,6 +541,7 @@ #D4D4D4 black + #AAA #494949 diff --git a/bin/app/data/color_schemes/bright.xml b/bin/app/data/color_schemes/bright.xml index 65de7496..c5c7dd9a 100644 --- a/bin/app/data/color_schemes/bright.xml +++ b/bin/app/data/color_schemes/bright.xml @@ -508,6 +508,7 @@ black white + #777 white diff --git a/bin/app/data/color_schemes/dark.xml b/bin/app/data/color_schemes/dark.xml index dbe2b91b..bf862534 100644 --- a/bin/app/data/color_schemes/dark.xml +++ b/bin/app/data/color_schemes/dark.xml @@ -518,6 +518,7 @@ white black + #AAA #272728 diff --git a/bin/app/data/gui/tabbed_view/tabbed_view.css b/bin/app/data/gui/tabbed_view/tabbed_view.css index 21ef1f1e..4355800e 100644 --- a/bin/app/data/gui/tabbed_view/tabbed_view.css +++ b/bin/app/data/gui/tabbed_view/tabbed_view.css @@ -50,6 +50,10 @@ QTableView { font-size: px; } +QTableView:disabled { + color: ; +} + QTableView::item { border-left: 1px solid ; } @@ -92,6 +96,10 @@ QHeaderView::section:vertical { padding: 2px 5px 1px; } +QHeaderView::section:disabled { + color: ; +} + QTableView QTableCornerButton::section { background-color: ; border-bottom: 1px solid ; @@ -103,6 +111,14 @@ QCheckBox { font-size: px; } +QLabel { + color: ; +} + +QLabel:disabled { + color: ; +} + #help_button { background: transparent; border: none; diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index f5acd394..3678faef 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -153,32 +153,32 @@ bool Application::hasGUI() int Application::handleDialog(const std::string& message) { - return getDialogView()->confirm(message); + return getDialogView(DialogView::UseCase::GENERAL)->confirm(message); } int Application::handleDialog(const std::string& message, const std::vector& options) { - return getDialogView()->confirm(message, options); + return getDialogView(DialogView::UseCase::GENERAL)->confirm(message, options); } int Application::handleDialog(const std::wstring& message) { - return getDialogView()->confirm(message); + return getDialogView(DialogView::UseCase::GENERAL)->confirm(message); } int Application::handleDialog(const std::wstring& message, const std::vector& options) { - return getDialogView()->confirm(message, options); + return getDialogView(DialogView::UseCase::GENERAL)->confirm(message, options); } -std::shared_ptr Application::getDialogView() +std::shared_ptr Application::getDialogView(DialogView::UseCase useCase) { if (m_componentManager) { - return m_componentManager->getDialogView(); + return m_componentManager->getDialogView(useCase); } - return std::make_shared(nullptr); + return std::make_shared(useCase, nullptr); } void Application::updateHistoryMenu(const std::vector>& historyMenuItems) @@ -191,59 +191,6 @@ void Application::updateBookmarks(const std::vector>& m_mainView->updateBookmarksMenu(bookmarks); } -void Application::createAndLoadProject(FilePath projectSettingsFilePath) -{ - MessageStatus(L"Loading Project: " + projectSettingsFilePath.wstr(), false, true).dispatch(); - - projectSettingsFilePath = migrateProjectSettings(projectSettingsFilePath); - - try - { - updateRecentProjects(projectSettingsFilePath); - - m_storageCache->clear(); - m_storageCache->setSubject(nullptr); - - m_project = std::make_shared( - std::make_shared(projectSettingsFilePath), m_storageCache.get(), hasGUI()); - - if (m_project) - { - m_project->load(); - } - else - { - LOG_ERROR_STREAM(<< "Failed to load project."); - MessageStatus(L"Failed to load project: " + projectSettingsFilePath.wstr(), true).dispatch(); - } - - updateTitle(); - } - catch (std::exception& e) - { - LOG_ERROR_STREAM(<< "Failed to load project, exception thrown: " << e.what()); - MessageStatus(L"Failed to load project, exception was thrown: " + projectSettingsFilePath.wstr(), true).dispatch(); - } - catch (...) - { - LOG_ERROR_STREAM(<< "Failed to load project, unknown exception thrown."); - MessageStatus(L"Failed to load project, unknown exception was thrown: " + projectSettingsFilePath.wstr(), true).dispatch(); - } - - if (m_hasGUI) - { - m_componentManager->clearComponents(); - } -} - -void Application::refreshProject(RefreshMode refreshMode) -{ - if (m_project && checkSharedMemory()) - { - m_project->refresh(refreshMode, getDialogView().get()); - } -} - void Application::handleMessage(MessageActivateWindow* message) { if (m_hasGUI) @@ -261,7 +208,7 @@ void Application::handleMessage(MessageEnteredLicense* message) updateTitle(); } -void Application::handleMessage(MessageFinishedParsing* message) +void Application::handleMessage(MessageIndexingFinished* message) { logStorageStats(); @@ -285,6 +232,12 @@ void Application::handleMessage(MessageLoadProject* message) return; } + if (m_project && m_project->isIndexing()) + { + MessageStatus(L"Cannot load another project while indexing.", true, false).dispatch(); + return; + } + if (m_project && projectSettingsFilePath == m_project->getProjectSettingsFilePath()) { if (message->settingsChanged && m_hasGUI) @@ -295,7 +248,47 @@ void Application::handleMessage(MessageLoadProject* message) } else { - createAndLoadProject(projectSettingsFilePath); + MessageStatus(L"Loading Project: " + projectSettingsFilePath.wstr(), false, true).dispatch(); + + projectSettingsFilePath = migrateProjectSettings(projectSettingsFilePath); + + try + { + updateRecentProjects(projectSettingsFilePath); + + m_storageCache->clear(); + m_storageCache->setSubject(nullptr); + + m_project = std::make_shared( + std::make_shared(projectSettingsFilePath), m_storageCache.get(), hasGUI()); + + if (m_project) + { + m_project->load(); + } + else + { + LOG_ERROR_STREAM(<< "Failed to load project."); + MessageStatus(L"Failed to load project: " + projectSettingsFilePath.wstr(), true).dispatch(); + } + + updateTitle(); + } + catch (std::exception& e) + { + LOG_ERROR_STREAM(<< "Failed to load project, exception thrown: " << e.what()); + MessageStatus(L"Failed to load project, exception was thrown: " + projectSettingsFilePath.wstr(), true).dispatch(); + } + catch (...) + { + LOG_ERROR_STREAM(<< "Failed to load project, unknown exception thrown."); + MessageStatus(L"Failed to load project, unknown exception was thrown: " + projectSettingsFilePath.wstr(), true).dispatch(); + } + + if (m_hasGUI) + { + m_componentManager->clearComponents(); + } if (message->refreshMode != REFRESH_NONE) { @@ -400,6 +393,14 @@ void Application::startMessagingAndScheduling() queue->startMessageLoopThreaded(); } +void Application::refreshProject(RefreshMode refreshMode) +{ + if (m_project && checkSharedMemory()) + { + m_project->refresh(refreshMode, getDialogView(DialogView::UseCase::INDEXING).get()); + } +} + void Application::updateRecentProjects(const FilePath& projectSettingsFilePath) { if (m_hasGUI) diff --git a/src/lib/Application.h b/src/lib/Application.h index 2315b687..a6634a73 100644 --- a/src/lib/Application.h +++ b/src/lib/Application.h @@ -6,9 +6,9 @@ #include "component/ComponentManager.h" #include "project/Project.h" #include "utility/messaging/MessageListener.h" +#include "utility/messaging/type/indexing/MessageIndexingFinished.h" #include "utility/messaging/type/MessageActivateWindow.h" #include "utility/messaging/type/MessageEnteredLicense.h" -#include "utility/messaging/type/MessageFinishedParsing.h" #include "utility/messaging/type/MessageLoadProject.h" #include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageSwitchColorScheme.h" @@ -27,7 +27,7 @@ class ViewFactory; class Application : public MessageListener , public MessageListener - , public MessageListener + , public MessageListener , public MessageListener , public MessageListener , public MessageListener @@ -47,15 +47,13 @@ public: const std::shared_ptr getCurrentProject(); - void createAndLoadProject(FilePath projectSettingsFilePath); - void refreshProject(RefreshMode refreshMode); bool hasGUI(); int handleDialog(const std::string& message); int handleDialog(const std::string& message, const std::vector& options); int handleDialog(const std::wstring& message); int handleDialog(const std::wstring& message, const std::vector& options); - std::shared_ptr getDialogView(); + std::shared_ptr getDialogView(DialogView::UseCase useCase); void updateHistoryMenu(const std::vector>& historyMenuItems); void updateBookmarks(const std::vector>& bookmarks); @@ -68,7 +66,7 @@ private: virtual void handleMessage(MessageActivateWindow* message); virtual void handleMessage(MessageEnteredLicense* message); - virtual void handleMessage(MessageFinishedParsing* message); + virtual void handleMessage(MessageIndexingFinished* message); virtual void handleMessage(MessageLoadProject* message); virtual void handleMessage(MessageRefresh* message); virtual void handleMessage(MessageSwitchColorScheme* message); @@ -77,6 +75,7 @@ private: FilePath migrateProjectSettings(const FilePath& projectSettingsFilePath) const; void startMessagingAndScheduling(); + void refreshProject(RefreshMode refreshMode); void updateRecentProjects(const FilePath& projectSettingsFilePath); void logStorageStats() const; diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 2f3e7a82..d3b43db5 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -277,8 +277,6 @@ add_files( data/TaskInjectStorage.h data/TaskMergeStorages.cpp data/TaskMergeStorages.h - data/TaskShowUnknownProgressDialog.cpp - data/TaskShowUnknownProgressDialog.h project/Project.cpp project/Project.h @@ -432,6 +430,11 @@ add_files( utility/messaging/type/history/MessageHistoryRedo.h utility/messaging/type/history/MessageHistoryUndo.h + utility/messaging/type/indexing/MessageIndexingFinished.h + utility/messaging/type/indexing/MessageIndexingShowDialog.h + utility/messaging/type/indexing/MessageIndexingStarted.h + utility/messaging/type/indexing/MessageIndexingStatus.h + utility/messaging/type/MessageActivateAll.h utility/messaging/type/MessageActivateBase.h utility/messaging/type/MessageActivateBookmark.h @@ -455,7 +458,6 @@ add_files( utility/messaging/type/MessageDisplayBookmarks.h utility/messaging/type/MessageEnteredLicense.h utility/messaging/type/MessageFind.h - utility/messaging/type/MessageFinishedParsing.h utility/messaging/type/MessageFlushUpdates.h utility/messaging/type/MessageFocusIn.h utility/messaging/type/MessageFocusOut.h diff --git a/src/lib/component/ComponentManager.cpp b/src/lib/component/ComponentManager.cpp index a3d4df65..0382bbd5 100644 --- a/src/lib/component/ComponentManager.cpp +++ b/src/lib/component/ComponentManager.cpp @@ -1,5 +1,7 @@ #include "component/ComponentManager.h" +#include "utility/logging/logging.h" + #include "component/controller/Controller.h" #include "component/controller/ScreenSearchController.h" #include "component/view/CompositeView.h" @@ -59,15 +61,19 @@ void ComponentManager::setup(ViewLayout* viewLayout) screenSearchController->addResponder(dynamic_cast(codeComponent->getViewPtr())); m_components.push_back(screenSearchComponent); - m_dialogView = m_componentFactory->getViewFactory()->createDialogView(viewLayout, m_componentFactory->getStorageAccess()); + for (DialogView::UseCase useCase : + { DialogView::UseCase::GENERAL, DialogView::UseCase::INDEXING, DialogView::UseCase::PROJECT_SETUP }) + { + m_dialogViews.emplace( + useCase, + m_componentFactory->getViewFactory()->createDialogView(viewLayout, useCase, m_componentFactory->getStorageAccess()) + ); + } std::shared_ptr tabbedView = m_componentFactory->getViewFactory()->createTabbedView(viewLayout, "Status"); m_tabbedViews.push_back(tabbedView); - // std::shared_ptr logComponent = m_componentFactory->createLogComponent(tabbedView.get()); - // m_components.push_back(logComponent); - std::shared_ptr statusComponent = m_componentFactory->createStatusComponent(tabbedView.get()); m_components.push_back(statusComponent); @@ -112,9 +118,16 @@ void ComponentManager::refreshViews() } } -std::shared_ptr ComponentManager::getDialogView() const +std::shared_ptr ComponentManager::getDialogView(DialogView::UseCase useCase) const { - return m_dialogView; + auto it = m_dialogViews.find(useCase); + if (it == m_dialogViews.end()) + { + LOG_ERROR_STREAM(<< "No DialogView available for useCase " << int(useCase)); + return nullptr; + } + + return it->second; } ComponentManager::ComponentManager() diff --git a/src/lib/component/ComponentManager.h b/src/lib/component/ComponentManager.h index 3237e217..1ccd442e 100644 --- a/src/lib/component/ComponentManager.h +++ b/src/lib/component/ComponentManager.h @@ -6,6 +6,7 @@ #include "component/Component.h" #include "component/ComponentFactory.h" +#include "component/view/DialogView.h" class CompositeView; class DialogView; @@ -27,7 +28,7 @@ public: void clearComponents(); void refreshViews(); - std::shared_ptr getDialogView() const; + std::shared_ptr getDialogView(DialogView::UseCase useCase) const; private: ComponentManager(); @@ -39,7 +40,7 @@ private: std::vector> m_tabbedViews; std::vector> m_components; - std::shared_ptr m_dialogView; + std::map> m_dialogViews; }; #endif // COMPONENT_MANAGER_H diff --git a/src/lib/component/controller/BookmarkController.cpp b/src/lib/component/controller/BookmarkController.cpp index 7b1251fc..078195da 100644 --- a/src/lib/component/controller/BookmarkController.cpp +++ b/src/lib/component/controller/BookmarkController.cpp @@ -349,7 +349,7 @@ void BookmarkController::handleMessage(MessageDisplayBookmarkCreator* message) showBookmarkCreator(message->nodeId); } -void BookmarkController::handleMessage(MessageFinishedParsing* message) +void BookmarkController::handleMessage(MessageIndexingFinished* message) { m_bookmarkCache.clear(); getView()->enableDisplayBookmarks(true); diff --git a/src/lib/component/controller/BookmarkController.h b/src/lib/component/controller/BookmarkController.h index 80e0cc59..71ae986d 100644 --- a/src/lib/component/controller/BookmarkController.h +++ b/src/lib/component/controller/BookmarkController.h @@ -7,12 +7,12 @@ #include "utility/messaging/MessageListener.h" #include "utility/messaging/type/error/MessageActivateErrors.h" +#include "utility/messaging/type/indexing/MessageIndexingFinished.h" #include "utility/messaging/type/MessageActivateAll.h" #include "utility/messaging/type/MessageActivateBookmark.h" #include "utility/messaging/type/MessageActivateTokens.h" #include "utility/messaging/type/MessageDisplayBookmarkCreator.h" #include "utility/messaging/type/MessageDisplayBookmarks.h" -#include "utility/messaging/type/MessageFinishedParsing.h" #include "component/controller/Controller.h" @@ -26,7 +26,7 @@ class BookmarkController , public MessageListener , public MessageListener , public MessageListener - , public MessageListener + , public MessageListener { public: BookmarkController(StorageAccess* storageAccess); @@ -74,7 +74,7 @@ private: virtual void handleMessage(MessageActivateTokens* message); virtual void handleMessage(MessageDisplayBookmarkCreator* message); virtual void handleMessage(MessageDisplayBookmarks* message); - virtual void handleMessage(MessageFinishedParsing* message); + virtual void handleMessage(MessageIndexingFinished* message); std::vector getActiveTokenDisplayNames() const; std::vector getDisplayNamesForNodeId(Id nodeId) const; diff --git a/src/lib/component/controller/ErrorController.cpp b/src/lib/component/controller/ErrorController.cpp index 68edafba..995d19b0 100644 --- a/src/lib/component/controller/ErrorController.cpp +++ b/src/lib/component/controller/ErrorController.cpp @@ -1,5 +1,7 @@ #include "component/controller/ErrorController.h" +#include "Application.h" +#include "component/view/DialogView.h" #include "data/access/StorageAccess.h" #include "settings/ApplicationSettings.h" @@ -100,7 +102,11 @@ void ErrorController::handleMessage(MessageErrorCountUpdate* message) } getView()->addErrors(errors, message->errorCount, true); - getView()->showDockWidget(); + + if (!Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->dialogsHidden()) + { + getView()->showDockWidget(); + } m_errorCount += errors.size(); } @@ -139,11 +145,18 @@ void ErrorController::handleMessage(MessageErrorsHelpMessage* message) getView()->showErrorHelpMessage(); } -void ErrorController::handleMessage(MessageFinishedParsing* message) +void ErrorController::handleMessage(MessageIndexingFinished* message) { clear(); showErrors(getView()->getErrorFilter(), false); + + getView()->setEnabled(true); +} + +void ErrorController::handleMessage(MessageIndexingStarted* message) +{ + getView()->setEnabled(false); } void ErrorController::handleMessage(MessageShowError* message) diff --git a/src/lib/component/controller/ErrorController.h b/src/lib/component/controller/ErrorController.h index 4777a239..7e39f76e 100644 --- a/src/lib/component/controller/ErrorController.h +++ b/src/lib/component/controller/ErrorController.h @@ -9,10 +9,11 @@ #include "utility/messaging/type/error/MessageErrorsForFile.h" #include "utility/messaging/type/error/MessageErrorsHelpMessage.h" #include "utility/messaging/type/error/MessageShowError.h" +#include "utility/messaging/type/indexing/MessageIndexingFinished.h" +#include "utility/messaging/type/indexing/MessageIndexingStarted.h" #include "utility/messaging/type/MessageActivateAll.h" #include "utility/messaging/type/MessageActivateFullTextSearch.h" #include "utility/messaging/type/MessageActivateTokens.h" -#include "utility/messaging/type/MessageFinishedParsing.h" #include "component/controller/Controller.h" #include "component/view/ErrorView.h" @@ -30,7 +31,8 @@ class ErrorController , public MessageListener , public MessageListener , public MessageListener - , public MessageListener + , public MessageListener + , public MessageListener , public MessageListener { public: @@ -50,7 +52,8 @@ private: virtual void handleMessage(MessageErrorsAll* message); virtual void handleMessage(MessageErrorsForFile* message); virtual void handleMessage(MessageErrorsHelpMessage* message); - virtual void handleMessage(MessageFinishedParsing* message); + virtual void handleMessage(MessageIndexingFinished* message); + virtual void handleMessage(MessageIndexingStarted* message); virtual void handleMessage(MessageShowError* message); ErrorView* getView() const; diff --git a/src/lib/component/controller/StatusBarController.cpp b/src/lib/component/controller/StatusBarController.cpp index 44aff905..d79f4f11 100644 --- a/src/lib/component/controller/StatusBarController.cpp +++ b/src/lib/component/controller/StatusBarController.cpp @@ -33,9 +33,22 @@ void StatusBarController::handleMessage(MessageErrorCountUpdate* message) getView()->setErrorCount(message->errorCount); } -void StatusBarController::handleMessage(MessageFinishedParsing* message) +void StatusBarController::handleMessage(MessageIndexingFinished* message) { getView()->setErrorCount(m_storageAccess->getErrorCount()); + getView()->hideIndexingProgress(); +} + +void StatusBarController::handleMessage(MessageIndexingStatus* message) +{ + if (message->showProgress) + { + getView()->showIndexingProgress(message->unknownProgress, message->progressPercent); + } + else + { + getView()->hideIndexingProgress(); + } } void StatusBarController::handleMessage(MessagePingReceived* message) @@ -63,7 +76,10 @@ void StatusBarController::handleMessage(MessageRefresh* message) void StatusBarController::handleMessage(MessageStatus* message) { - setStatus(message->status(), message->isError, message->showLoader); + if (message->showInStatusBar) + { + setStatus(message->status(), message->isError, message->showLoader); + } } void StatusBarController::setStatus(const std::wstring& status, bool isError, bool showLoader) diff --git a/src/lib/component/controller/StatusBarController.h b/src/lib/component/controller/StatusBarController.h index d332286b..9473a96a 100644 --- a/src/lib/component/controller/StatusBarController.h +++ b/src/lib/component/controller/StatusBarController.h @@ -8,7 +8,8 @@ #include "utility/messaging/MessageListener.h" #include "utility/messaging/type/error/MessageErrorCountClear.h" #include "utility/messaging/type/error/MessageErrorCountUpdate.h" -#include "utility/messaging/type/MessageFinishedParsing.h" +#include "utility/messaging/type/indexing/MessageIndexingFinished.h" +#include "utility/messaging/type/indexing/MessageIndexingStatus.h" #include "utility/messaging/type/MessagePingReceived.h" #include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageStatus.h" @@ -20,7 +21,8 @@ class StatusBarController : public Controller , public MessageListener , public MessageListener - , public MessageListener + , public MessageListener + , public MessageListener , public MessageListener , public MessageListener , public MessageListener @@ -36,7 +38,8 @@ public: private: virtual void handleMessage(MessageErrorCountClear* message); virtual void handleMessage(MessageErrorCountUpdate* message); - virtual void handleMessage(MessageFinishedParsing* message); + virtual void handleMessage(MessageIndexingFinished* message); + virtual void handleMessage(MessageIndexingStatus* message); virtual void handleMessage(MessagePingReceived* message); virtual void handleMessage(MessageRefresh* message); virtual void handleMessage(MessageStatus* message); diff --git a/src/lib/component/controller/UndoRedoController.cpp b/src/lib/component/controller/UndoRedoController.cpp index ced2ca09..540bd61b 100644 --- a/src/lib/component/controller/UndoRedoController.cpp +++ b/src/lib/component/controller/UndoRedoController.cpp @@ -163,32 +163,6 @@ void UndoRedoController::handleMessage(MessageDeactivateEdge* message) m->setKeepContent(keepContent); } -void UndoRedoController::handleMessage(MessageFinishedParsing* message) -{ - std::list newList; - - for (const Command& command : m_list) - { - if (command.order == Command::ORDER_ACTIVATE) - { - MessageActivateTokens* msg = dynamic_cast(command.message.get()); - if (msg) - { - if (msg->isAggregation) - { - continue; - } - msg->isFromSearch = false; - } - - newList.insert(newList.end(), command); - } - } - - m_list = newList; - m_iterator = m_list.end(); -} - void UndoRedoController::handleMessage(MessageGraphNodeBundleSplit* message) { Command command(std::make_shared(*message), Command::ORDER_ADAPT); @@ -328,6 +302,32 @@ void UndoRedoController::handleMessage(MessageHistoryUndo* message) updateHistory(); } +void UndoRedoController::handleMessage(MessageIndexingFinished* message) +{ + std::list newList; + + for (const Command& command : m_list) + { + if (command.order == Command::ORDER_ACTIVATE) + { + MessageActivateTokens* msg = dynamic_cast(command.message.get()); + if (msg) + { + if (msg->isAggregation) + { + continue; + } + msg->isFromSearch = false; + } + + newList.insert(newList.end(), command); + } + } + + m_list = newList; + m_iterator = m_list.end(); +} + void UndoRedoController::handleMessage(MessageRefresh* message) { if (!message->uiOnly) diff --git a/src/lib/component/controller/UndoRedoController.h b/src/lib/component/controller/UndoRedoController.h index b69e62f5..5c13c0fb 100644 --- a/src/lib/component/controller/UndoRedoController.h +++ b/src/lib/component/controller/UndoRedoController.h @@ -10,6 +10,7 @@ #include "utility/messaging/type/history/MessageHistoryRedo.h" #include "utility/messaging/type/history/MessageHistoryToPosition.h" #include "utility/messaging/type/history/MessageHistoryUndo.h" +#include "utility/messaging/type/indexing/MessageIndexingFinished.h" #include "utility/messaging/type/MessageActivateAll.h" #include "utility/messaging/type/MessageActivateFullTextSearch.h" #include "utility/messaging/type/MessageActivateLocalSymbols.h" @@ -18,7 +19,6 @@ #include "utility/messaging/type/MessageActivateTrailEdge.h" #include "utility/messaging/type/MessageChangeFileView.h" #include "utility/messaging/type/MessageDeactivateEdge.h" -#include "utility/messaging/type/MessageFinishedParsing.h" #include "utility/messaging/type/MessageGraphNodeBundleSplit.h" #include "utility/messaging/type/MessageGraphNodeExpand.h" #include "utility/messaging/type/MessageGraphNodeHide.h" @@ -45,7 +45,6 @@ class UndoRedoController , public MessageListener , public MessageListener , public MessageListener - , public MessageListener , public MessageListener , public MessageListener , public MessageListener @@ -53,6 +52,7 @@ class UndoRedoController , public MessageListener , public MessageListener , public MessageListener + , public MessageListener , public MessageListener , public MessageListener , public MessageListener @@ -94,7 +94,6 @@ private: virtual void handleMessage(MessageActivateTrailEdge* message); virtual void handleMessage(MessageChangeFileView* message); virtual void handleMessage(MessageDeactivateEdge* message); - virtual void handleMessage(MessageFinishedParsing* message); virtual void handleMessage(MessageGraphNodeBundleSplit* message); virtual void handleMessage(MessageGraphNodeExpand* message); virtual void handleMessage(MessageGraphNodeHide* message); @@ -102,6 +101,7 @@ private: virtual void handleMessage(MessageHistoryRedo* message); virtual void handleMessage(MessageHistoryToPosition* message); virtual void handleMessage(MessageHistoryUndo* message); + virtual void handleMessage(MessageIndexingFinished* message); virtual void handleMessage(MessageRefresh* message); virtual void handleMessage(MessageScrollCode* message); virtual void handleMessage(MessageScrollGraph* message); diff --git a/src/lib/component/view/CompositeView.cpp b/src/lib/component/view/CompositeView.cpp index 450a042c..fba80bf8 100644 --- a/src/lib/component/view/CompositeView.cpp +++ b/src/lib/component/view/CompositeView.cpp @@ -53,3 +53,8 @@ void CompositeView::showView(View* view) void CompositeView::hideView(View* view) { } + +void CompositeView::setViewEnabled(View* view, bool enabled) +{ + getViewLayout()->setViewEnabled(view, enabled); +} diff --git a/src/lib/component/view/CompositeView.h b/src/lib/component/view/CompositeView.h index e889af8e..c6c33b2b 100644 --- a/src/lib/component/view/CompositeView.h +++ b/src/lib/component/view/CompositeView.h @@ -35,6 +35,8 @@ public: virtual void showView(View* view); virtual void hideView(View* view); + virtual void setViewEnabled(View* view, bool enabled); + private: std::vector m_views; CompositeDirection m_direction; diff --git a/src/lib/component/view/DialogView.cpp b/src/lib/component/view/DialogView.cpp index 38fcd5ce..fbbf0dad 100644 --- a/src/lib/component/view/DialogView.cpp +++ b/src/lib/component/view/DialogView.cpp @@ -1,11 +1,32 @@ #include "component/view/DialogView.h" -DialogView::DialogView(StorageAccess* storageAccess) - : m_storageAccess(storageAccess) +DialogView::DialogView(UseCase useCase, StorageAccess* storageAccess) + : m_useCase(useCase) + , m_storageAccess(storageAccess) { } -DialogView::~DialogView() +DialogView::UseCase DialogView::getUseCase() const +{ + return m_useCase; +} + +void DialogView::setDialogsHideable(bool hideable) +{ + m_dialogsHideable = hideable; +} + +void DialogView::setUpdateIndexingStatus(bool updateStatus) +{ + m_updateIndexingStatus = updateStatus; +} + +bool DialogView::dialogsHidden() const +{ + return false; +} + +void DialogView::clearDialogs() { } @@ -31,7 +52,7 @@ void DialogView::startIndexingDialog( } void DialogView::updateIndexingDialog( - size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const FilePath& sourcePath) + size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths) { } @@ -42,10 +63,6 @@ DatabasePolicy DialogView::finishedIndexingDialog( return DATABASE_POLICY_KEEP; // used in non-gui mode } -void DialogView::hideDialogs(bool unblockUI) -{ -} - int DialogView::confirm(const std::string& message) { return confirm(message, std::vector()); diff --git a/src/lib/component/view/DialogView.h b/src/lib/component/view/DialogView.h index 14bdc05a..a8276318 100644 --- a/src/lib/component/view/DialogView.h +++ b/src/lib/component/view/DialogView.h @@ -20,8 +20,23 @@ enum DatabasePolicy class DialogView { public: - DialogView(StorageAccess* storageAccess); - virtual ~DialogView(); + enum class UseCase + { + GENERAL, + INDEXING, + PROJECT_SETUP + }; + + DialogView(UseCase useCase, StorageAccess* storageAccess); + virtual ~DialogView() = default; + + UseCase getUseCase() const; + + void setDialogsHideable(bool hideable); + void setUpdateIndexingStatus(bool updateStatus); + + virtual bool dialogsHidden() const; + virtual void clearDialogs(); virtual void showUnknownProgressDialog(const std::wstring& title, const std::wstring& message); virtual void hideUnknownProgressDialog(); @@ -32,20 +47,22 @@ public: virtual void startIndexingDialog( Project* project, const std::vector& enabledModes, const RefreshInfo& info); virtual void updateIndexingDialog( - size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const FilePath& sourcePath); + size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths); virtual DatabasePolicy finishedIndexingDialog( size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo, bool interrupted); - virtual void hideDialogs(bool unblockUI = true); - int confirm(const std::string& message); virtual int confirm(const std::string& message, const std::vector& options); int confirm(const std::wstring& message); virtual int confirm(const std::wstring& message, const std::vector& options); protected: + const UseCase m_useCase; StorageAccess* m_storageAccess; + + bool m_dialogsHideable = false; + bool m_updateIndexingStatus = false; }; #endif // DIALOG_VIEW_H diff --git a/src/lib/component/view/StatusBarView.cpp b/src/lib/component/view/StatusBarView.cpp index 885b0c35..276eb7c3 100644 --- a/src/lib/component/view/StatusBarView.cpp +++ b/src/lib/component/view/StatusBarView.cpp @@ -7,10 +7,6 @@ StatusBarView::StatusBarView(ViewLayout* viewLayout) { } -StatusBarView::~StatusBarView() -{ -} - std::string StatusBarView::getName() const { return "StatusBarView"; diff --git a/src/lib/component/view/StatusBarView.h b/src/lib/component/view/StatusBarView.h index 72a05c33..9da605db 100644 --- a/src/lib/component/view/StatusBarView.h +++ b/src/lib/component/view/StatusBarView.h @@ -6,11 +6,12 @@ class StatusBarController; -class StatusBarView : public View +class StatusBarView + : public View { public: StatusBarView(ViewLayout* viewLayout); - ~StatusBarView(void); + virtual ~StatusBarView() = default; virtual std::string getName() const; virtual void showMessage(const std::wstring& message, bool isError, bool showLoader) = 0; @@ -18,6 +19,9 @@ public: virtual void showIdeStatus(const std::wstring& message) = 0; + virtual void showIndexingProgress(bool unknownProgress, size_t progressPercent) = 0; + virtual void hideIndexingProgress() = 0; + protected: StatusBarController* getController(); }; diff --git a/src/lib/component/view/TabbedView.cpp b/src/lib/component/view/TabbedView.cpp index d702e08f..72da6f52 100644 --- a/src/lib/component/view/TabbedView.cpp +++ b/src/lib/component/view/TabbedView.cpp @@ -45,3 +45,8 @@ void TabbedView::hideView(View* view) { getViewLayout()->hideView(this); } + +void TabbedView::setViewEnabled(View* view, bool enabled) +{ + getViewLayout()->setViewEnabled(view, enabled); +} diff --git a/src/lib/component/view/TabbedView.h b/src/lib/component/view/TabbedView.h index 939284b1..d0744e28 100644 --- a/src/lib/component/view/TabbedView.h +++ b/src/lib/component/view/TabbedView.h @@ -28,6 +28,8 @@ public: virtual void showView(View* view); virtual void hideView(View* view); + virtual void setViewEnabled(View* view, bool enabled); + private: std::vector m_views; std::string m_name; diff --git a/src/lib/component/view/View.cpp b/src/lib/component/view/View.cpp index fbaafb8f..9184d3cf 100644 --- a/src/lib/component/view/View.cpp +++ b/src/lib/component/view/View.cpp @@ -45,6 +45,11 @@ ViewLayout* View::getViewLayout() const return m_viewLayout; } +void View::setEnabled(bool enabled) +{ + return getViewLayout()->setViewEnabled(this, enabled); +} + void View::setWidgetWrapper(std::shared_ptr widgetWrapper) { m_widgetWrapper = widgetWrapper; diff --git a/src/lib/component/view/View.h b/src/lib/component/view/View.h index e5ab74c5..773c1324 100644 --- a/src/lib/component/view/View.h +++ b/src/lib/component/view/View.h @@ -39,6 +39,8 @@ public: ViewWidgetWrapper* getWidgetWrapper() const; ViewLayout* getViewLayout() const; + void setEnabled(bool enabled); + protected: template ControllerType* getController(); diff --git a/src/lib/component/view/ViewFactory.cpp b/src/lib/component/view/ViewFactory.cpp index 07d76402..20fb9730 100644 --- a/src/lib/component/view/ViewFactory.cpp +++ b/src/lib/component/view/ViewFactory.cpp @@ -3,7 +3,3 @@ ViewFactory::ViewFactory() { } - -ViewFactory::~ViewFactory() -{ -} diff --git a/src/lib/component/view/ViewFactory.h b/src/lib/component/view/ViewFactory.h index 066dbc40..a92fa0fa 100644 --- a/src/lib/component/view/ViewFactory.h +++ b/src/lib/component/view/ViewFactory.h @@ -4,10 +4,10 @@ #include #include "component/view/CompositeView.h" +#include "component/view/DialogView.h" class BookmarkView; class CodeView; -class DialogView; class ErrorView; class GraphView; class MainView; @@ -26,7 +26,7 @@ class ViewFactory { public: ViewFactory(); - virtual ~ViewFactory(); + virtual ~ViewFactory() = default; virtual std::shared_ptr createMainView() const = 0; virtual std::shared_ptr createCompositeView( @@ -45,7 +45,8 @@ public: virtual std::shared_ptr createTooltipView(ViewLayout* viewLayout) const = 0; virtual std::shared_ptr createUndoRedoView(ViewLayout* viewLayout) const = 0; - virtual std::shared_ptr createDialogView(ViewLayout* viewLayout, StorageAccess* storageAccess) const = 0; + virtual std::shared_ptr createDialogView( + ViewLayout* viewLayout, DialogView::UseCase useCase, StorageAccess* storageAccess) const = 0; }; #endif // VIEW_FACTORY_H diff --git a/src/lib/component/view/ViewLayout.h b/src/lib/component/view/ViewLayout.h index 96534fd3..f0252f92 100644 --- a/src/lib/component/view/ViewLayout.h +++ b/src/lib/component/view/ViewLayout.h @@ -17,6 +17,8 @@ public: virtual void showView(View* view) = 0; virtual void hideView(View* view) = 0; + virtual void setViewEnabled(View* view, bool enabled) = 0; + virtual View* findFloatingView(const std::string& name) const; }; diff --git a/src/lib/data/TaskCleanStorage.cpp b/src/lib/data/TaskCleanStorage.cpp index bd0575f8..f14b4736 100644 --- a/src/lib/data/TaskCleanStorage.cpp +++ b/src/lib/data/TaskCleanStorage.cpp @@ -18,7 +18,7 @@ TaskCleanStorage::TaskCleanStorage( void TaskCleanStorage::doEnter(std::shared_ptr blackboard) { - Application::getInstance()->getDialogView()->showUnknownProgressDialog( + Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->showUnknownProgressDialog( L"Clearing Files", std::to_wstring(m_filePaths.size()) + L" Files"); m_start = utility::durationStart(); @@ -38,7 +38,7 @@ Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr blackboar m_storage->clearFileElements(m_filePaths, [=](int progress) { - Application::getInstance()->getDialogView()->showProgressDialog( + Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->showProgressDialog( L"Clearing", std::to_wstring(m_filePaths.size()) + L" Files", progress); } ); @@ -52,7 +52,7 @@ void TaskCleanStorage::doExit(std::shared_ptr blackboard) { blackboard->set("clear_time", utility::duration(m_start)); - Application::getInstance()->getDialogView()->hideProgressDialog(); + Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->hideProgressDialog(); } void TaskCleanStorage::doReset(std::shared_ptr blackboard) diff --git a/src/lib/data/TaskFinishParsing.cpp b/src/lib/data/TaskFinishParsing.cpp index ec3e56ed..cf0259ef 100644 --- a/src/lib/data/TaskFinishParsing.cpp +++ b/src/lib/data/TaskFinishParsing.cpp @@ -2,7 +2,7 @@ #include "component/view/DialogView.h" #include "data/storage/PersistentStorage.h" -#include "utility/messaging/type/MessageFinishedParsing.h" +#include "utility/messaging/type/indexing/MessageIndexingFinished.h" #include "utility/messaging/type/MessageQuitApplication.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/scheduling/Blackboard.h" @@ -20,11 +20,11 @@ void TaskFinishParsing::terminate() Application* app = Application::getInstance().get(); if (app) { - app->getDialogView()->hideDialogs(); + app->getDialogView(DialogView::UseCase::INDEXING)->clearDialogs(); } MessageStatus(L"An unknown exception was thrown during indexing.", true, false).dispatch(); - MessageFinishedParsing().dispatch(); + MessageIndexingFinished().dispatch(); } void TaskFinishParsing::doEnter(std::shared_ptr blackboard) @@ -36,7 +36,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa { TimeStamp start = utility::durationStart(); - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + std::shared_ptr dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING); dialogView->showUnknownProgressDialog(L"Finish Indexing", L"Optimizing database"); m_storage->optimizeMemory(); diff --git a/src/lib/data/TaskShowUnknownProgressDialog.cpp b/src/lib/data/TaskShowUnknownProgressDialog.cpp deleted file mode 100644 index 084858ec..00000000 --- a/src/lib/data/TaskShowUnknownProgressDialog.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "data/TaskShowUnknownProgressDialog.h" - -#include "component/view/DialogView.h" -#include "Application.h" - -TaskShowUnknownProgressDialog::TaskShowUnknownProgressDialog( - const std::wstring& title, - const std::wstring& message -) - : m_title(title) - , m_message(message) -{ -} - -void TaskShowUnknownProgressDialog::doEnter(std::shared_ptr blackboard) -{ -} - -Task::TaskState TaskShowUnknownProgressDialog::doUpdate(std::shared_ptr blackboard) -{ - if (std::shared_ptr dialogView = Application::getInstance()->getDialogView()) - { - dialogView->showUnknownProgressDialog(m_title, m_message); - } - return STATE_SUCCESS; -} - -void TaskShowUnknownProgressDialog::doExit(std::shared_ptr blackboard) -{ -} - -void TaskShowUnknownProgressDialog::doReset(std::shared_ptr blackboard) -{ -} diff --git a/src/lib/data/TaskShowUnknownProgressDialog.h b/src/lib/data/TaskShowUnknownProgressDialog.h deleted file mode 100644 index cdfab706..00000000 --- a/src/lib/data/TaskShowUnknownProgressDialog.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef TASK_SHOW_UNKNOWN_PROGRESS_DIALOG_H -#define TASK_SHOW_UNKNOWN_PROGRESS_DIALOG_H - -#include - -#include "utility/scheduling/Task.h" - -class TaskShowUnknownProgressDialog - : public Task -{ -public: - TaskShowUnknownProgressDialog( - const std::wstring& title, - const std::wstring& message - ); - -private: - void doEnter(std::shared_ptr blackboard) override; - TaskState doUpdate(std::shared_ptr blackboard) override; - void doExit(std::shared_ptr blackboard) override; - void doReset(std::shared_ptr blackboard) override; - - const std::wstring m_title; - const std::wstring m_message; -}; - -#endif // TASK_SHOW_UNKNOWN_PROGRESS_DIALOG_H diff --git a/src/lib/data/indexer/TaskBuildIndex.cpp b/src/lib/data/indexer/TaskBuildIndex.cpp index 0d966d6f..ca783b1e 100644 --- a/src/lib/data/indexer/TaskBuildIndex.cpp +++ b/src/lib/data/indexer/TaskBuildIndex.cpp @@ -167,7 +167,10 @@ void TaskBuildIndex::terminate() void TaskBuildIndex::handleMessage(MessageInterruptTasks* message) { - m_interrupted = true; + if (!Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->dialogsHidden()) + { + m_interrupted = true; + } } void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFilePath) @@ -291,18 +294,8 @@ void TaskBuildIndex::updateIndexingDialog( blackboard->get("indexed_source_file_count", indexedSourceFileCount); } - if (!sourcePaths.empty()) - { - std::vector stati; - for (const FilePath& path : sourcePaths) - { - m_indexingFileCount++; - stati.push_back(L"[" + std::to_wstring(m_indexingFileCount) + L"/" + std::to_wstring(sourceFileCount) + L"] Indexing file: " + path.wstr()); - } - MessageStatus(stati, false, true).dispatch(); - } + m_indexingFileCount += sourcePaths.size(); - Application::getInstance()->getDialogView()->updateIndexingDialog( - m_indexingFileCount, indexedSourceFileCount, sourceFileCount, (sourcePaths.empty() ? FilePath() : sourcePaths.back()) - ); + Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->updateIndexingDialog( + m_indexingFileCount, indexedSourceFileCount, sourceFileCount, sourcePaths); } diff --git a/src/lib/data/parser/TaskParseWrapper.cpp b/src/lib/data/parser/TaskParseWrapper.cpp index b99444f5..c000df4b 100644 --- a/src/lib/data/parser/TaskParseWrapper.cpp +++ b/src/lib/data/parser/TaskParseWrapper.cpp @@ -19,10 +19,11 @@ void TaskParseWrapper::doEnter(std::shared_ptr blackboard) { int sourceFileCount = 0; blackboard->get("source_file_count", sourceFileCount); - if (std::shared_ptr dialogView = Application::getInstance()->getDialogView()) + + if (std::shared_ptr dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)) { - dialogView->hideDialogs(false); - dialogView->updateIndexingDialog(0, 0, sourceFileCount, FilePath()); + dialogView->clearDialogs(); + dialogView->updateIndexingDialog(0, 0, sourceFileCount, { }); } m_start = utility::durationStart(); diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index 4a0e22f5..7e9b4361 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -351,7 +351,11 @@ void PersistentStorage::clearFileElements(const std::vector& filePaths { TRACE(); - const std::vector fileNodeIds = getFileNodeIds(filePaths); + std::vector fileNodeIds; + for (const StorageFile& file : m_sqliteIndexStorage.getFilesByPaths(filePaths)) + { + fileNodeIds.push_back(file.id); + } if (!fileNodeIds.empty()) { diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index 5fd0ef27..9040673e 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -12,7 +12,6 @@ #include "data/TaskFinishParsing.h" #include "data/TaskInjectStorage.h" #include "data/TaskMergeStorages.h" -#include "data/TaskShowUnknownProgressDialog.h" #include "project/RefreshInfoGenerator.h" #include "project/SourceGroup.h" #include "project/SourceGroupFactory.h" @@ -23,7 +22,8 @@ #include "utility/file/FilePath.h" #include "utility/file/FileSystem.h" #include "utility/messaging/type/error/MessageErrorCountClear.h" -#include "utility/messaging/type/MessageFinishedParsing.h" +#include "utility/messaging/type/indexing/MessageIndexingFinished.h" +#include "utility/messaging/type/indexing/MessageIndexingStarted.h" #include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/scheduling/TaskDecoratorRepeat.h" @@ -51,6 +51,7 @@ Project::Project(std::shared_ptr settings, StorageCache* storag : m_settings(settings) , m_storageCache(storageCache) , m_state(PROJECT_STATE_NOT_LOADED) + , m_isIndexing(false) , m_hasGUI(hasGUI) { } @@ -69,6 +70,11 @@ std::string Project::getDescription() const return m_settings->getDescription(); } +bool Project::isIndexing() const +{ + return m_isIndexing; +} + bool Project::settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const { return m_settings->equalsExceptNameAndLocation(otherSettings); @@ -84,6 +90,12 @@ void Project::setStateOutdated() void Project::load() { + if (m_isIndexing) + { + MessageStatus(L"Cannot load another project while indexing.", true, false).dispatch(); + return; + } + m_storageCache->clear(); m_storageCache->setSubject(nullptr); @@ -101,9 +113,10 @@ void Project::load() { if (dbPath.exists()) { - if (Application::getInstance()->getDialogView()->confirm( + if (Application::getInstance()->getDialogView(DialogView::UseCase::GENERAL)->confirm( "Sourcetrail has been closed unexpectedly while indexing this project. You can either choose to keep the data that has " - "already been indexed or discard that data and restore the state of your project before indexing?", { "Keep and Continue", "Discard and Restore" }) == 0) + "already been indexed or discard that data and restore the state of your project before indexing?", + { "Keep and Continue", "Discard and Restore" }) == 0) { LOG_INFO("Switching to temporary indexing data on user's decision"); FileSystem::remove(dbPath); @@ -124,7 +137,7 @@ void Project::load() } m_storage = std::make_shared( - projectSettingsPath.replaceExtension(INDEX_DB_FILE_EXTENSION), + projectSettingsPath.replaceExtension(INDEX_DB_FILE_EXTENSION), projectSettingsPath.replaceExtension(BOOKMARK_DB_FILE_EXTENSION) ); @@ -181,7 +194,7 @@ void Project::load() if (m_hasGUI) { - MessageFinishedParsing().dispatch(); + MessageIndexingFinished().dispatch(); } MessageStatus(L"Finished Loading", false, false).dispatch(); } @@ -214,6 +227,12 @@ void Project::load() void Project::refresh(RefreshMode refreshMode, DialogView* dialogView) { + if (m_isIndexing) + { + MessageStatus(L"Cannot refresh the project while indexing.", true, false).dispatch(); + return; + } + if (m_state == PROJECT_STATE_NOT_LOADED) { return; @@ -354,15 +373,21 @@ RefreshInfo Project::getRefreshInfo(RefreshMode mode) const void Project::buildIndex(const RefreshInfo& info, DialogView* dialogView) { + if (m_isIndexing) + { + MessageStatus(L"Cannot refresh project while indexing.", true, false).dispatch(); + return; + } + if (info.mode != REFRESH_ALL_FILES && info.filesToClear.empty() && info.filesToIndex.empty()) { if (m_hasGUI) { - dialogView->hideDialogs(); + dialogView->clearDialogs(); } else { - MessageFinishedParsing().dispatch(); + MessageIndexingFinished().dispatch(); } MessageStatus(L"Nothing to refresh, all files are up-to-date.").dispatch(); @@ -390,6 +415,10 @@ void Project::buildIndex(const RefreshInfo& info, DialogView* dialogView) std::shared_ptr taskSequential = std::make_shared(); + bool hideable = m_state == PROJECT_STATE_LOADED || m_state == PROJECT_STATE_OUTDATED; + dialogView->setDialogsHideable(hideable); + dialogView->setUpdateIndexingStatus(true); + if (info.mode != REFRESH_ALL_FILES && (info.filesToClear.size() || info.nonIndexedFilesToClear.size())) { taskSequential->addTask(std::make_shared( @@ -489,7 +518,9 @@ void Project::buildIndex(const RefreshInfo& info, DialogView* dialogView) ); // add task that notifies the user of what's going on taskSequential->addTask( // we don't need to hide this dialog again, because it's overridden by other dialogs later on. - std::make_shared(L"Finish Indexing", L"Saving\nRemaining Data") + std::make_shared([dialogView]() { + dialogView->showUnknownProgressDialog(L"Finish Indexing", L"Saving\nRemaining Data"); + }) ); // add task that injects the remaining intermediate storages into the persistent storage @@ -509,7 +540,7 @@ void Project::buildIndex(const RefreshInfo& info, DialogView* dialogView) taskSequential->addTask(std::make_shared()->addChildTasks( std::make_shared()->addChildTasks( - std::make_shared("keep_database"), + std::make_shared("keep_database"), std::make_shared([this]() { Task::dispatch(std::make_shared([this]() { swapToTempStorage(); @@ -521,37 +552,42 @@ void Project::buildIndex(const RefreshInfo& info, DialogView* dialogView) std::make_shared("discard_database"), std::make_shared([this]() { Task::dispatch(std::make_shared([this]() { - const FilePath tempIndexDbPath = m_storage->getIndexDbFilePath().replaceExtension(TEMP_INDEX_DB_FILE_EXTENSION); - if (tempIndexDbPath.exists()) - { - LOG_INFO("Discarding temporary indexing data"); - FileSystem::remove(tempIndexDbPath); - } + discardTempStorage(); })); }) ) )); - taskSequential->addTask(std::make_shared([]() { - MessageFinishedParsing().dispatch(); + taskSequential->addTask(std::make_shared([dialogView, this]() { + m_isIndexing = false; + dialogView->setDialogsHideable(false); + dialogView->setUpdateIndexingStatus(false); + + MessageIndexingFinished().dispatch(); })); + taskSequential->setIsBackgroundTask(true); Task::dispatch(taskSequential); + + m_isIndexing = true; + MessageIndexingStarted().dispatch(); } void Project::swapToTempStorage() { LOG_INFO("Switching to temporary indexing data"); + const FilePath indexDbFilePath = m_storage->getIndexDbFilePath(); const FilePath tempIndexDbFilePath = indexDbFilePath.replaceExtension(TEMP_INDEX_DB_FILE_EXTENSION); const FilePath bookmarkDbFilePath = m_storage->getBookmarkDbFilePath(); + m_storage.reset(); FileSystem::remove(indexDbFilePath); FileSystem::rename(tempIndexDbFilePath, indexDbFilePath); m_storage = std::make_shared(indexDbFilePath, bookmarkDbFilePath); m_storage->setup(); - //std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + //std::shared_ptr dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING); //dialogView->showUnknownProgressDialog(L"Finish Indexing", L"Building caches"); m_storage->buildCaches(); //dialogView->hideUnknownProgressDialog(); @@ -559,6 +595,16 @@ void Project::swapToTempStorage() m_storageCache->setSubject(m_storage.get()); } +void Project::discardTempStorage() +{ + const FilePath tempIndexDbPath = m_storage->getIndexDbFilePath().replaceExtension(TEMP_INDEX_DB_FILE_EXTENSION); + if (tempIndexDbPath.exists()) + { + LOG_INFO("Discarding temporary indexing data"); + FileSystem::remove(tempIndexDbPath); + } +} + bool Project::hasCxxSourceGroup() const { for (const std::shared_ptr& sourceGroup: m_sourceGroups) @@ -573,30 +619,3 @@ bool Project::hasCxxSourceGroup() const } return false; } - -bool Project::didFileChange(const FileInfo& info) const -{ - FileInfo diskFileInfo = FileSystem::getFileInfoForPath(info.path); - if (diskFileInfo.lastWriteTime > info.lastWriteTime) - { - std::shared_ptr storedFileContent = m_storage->getFileContent(info.path); - std::shared_ptr diskFileContent = TextAccess::createFromFile(diskFileInfo.path); - - const std::vector& diskFileLines = diskFileContent->getAllLines(); - const std::vector& storedFileLines = storedFileContent->getAllLines(); - - if (diskFileLines.size() == storedFileLines.size()) - { - for (size_t i = 0; i < diskFileLines.size(); i++) - { - if (diskFileLines[i] != storedFileLines[i]) - { - return true; - } - } - return false; - } - return true; - } - return false; -} diff --git a/src/lib/project/Project.h b/src/lib/project/Project.h index 7eac1d49..a54b5d07 100644 --- a/src/lib/project/Project.h +++ b/src/lib/project/Project.h @@ -30,6 +30,8 @@ public: FilePath getProjectSettingsFilePath() const; std::string getDescription() const; + bool isIndexing() const; + bool settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const; void setStateOutdated(); @@ -56,13 +58,16 @@ private: Project(const Project&); void swapToTempStorage(); + void discardTempStorage(); + bool hasCxxSourceGroup() const; - bool didFileChange(const FileInfo& info) const; std::shared_ptr m_settings; StorageCache* const m_storageCache; ProjectStateType m_state; + bool m_isIndexing = false; + std::shared_ptr m_storage; std::vector> m_sourceGroups; diff --git a/src/lib/utility/messaging/type/MessageFinishedParsing.h b/src/lib/utility/messaging/type/MessageFinishedParsing.h deleted file mode 100644 index bb7e46e0..00000000 --- a/src/lib/utility/messaging/type/MessageFinishedParsing.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef MESSAGE_FINISHED_PARSING_H -#define MESSAGE_FINISHED_PARSING_H - -#include "utility/messaging/Message.h" - -class MessageFinishedParsing - : public Message -{ -public: - MessageFinishedParsing() - { - } - - static const std::string getStaticType() - { - return "MessageFinishedParsing"; - } -}; - -#endif // MESSAGE_FINISHED_PARSING_H diff --git a/src/lib/utility/messaging/type/MessageStatus.cpp b/src/lib/utility/messaging/type/MessageStatus.cpp index 37e1ef08..902556a7 100644 --- a/src/lib/utility/messaging/type/MessageStatus.cpp +++ b/src/lib/utility/messaging/type/MessageStatus.cpp @@ -2,18 +2,20 @@ #include "utility/utilityString.h" -MessageStatus::MessageStatus(const std::wstring& status, bool isError, bool showLoader) +MessageStatus::MessageStatus(const std::wstring& status, bool isError, bool showLoader, bool showInStatusBar) : isError(isError) , showLoader(showLoader) + , showInStatusBar(showInStatusBar) { m_stati.push_back(utility::replace(status, L"\n", L" ")); setSendAsTask(false); } -MessageStatus::MessageStatus(const std::vector& stati, bool isError, bool showLoader) +MessageStatus::MessageStatus(const std::vector& stati, bool isError, bool showLoader, bool showInStatusBar) : isError(isError) , showLoader(showLoader) + , showInStatusBar(showInStatusBar) , m_stati(stati) { setSendAsTask(false); diff --git a/src/lib/utility/messaging/type/MessageStatus.h b/src/lib/utility/messaging/type/MessageStatus.h index 9a07c83c..b8a7eb10 100644 --- a/src/lib/utility/messaging/type/MessageStatus.h +++ b/src/lib/utility/messaging/type/MessageStatus.h @@ -10,8 +10,8 @@ class MessageStatus : public Message { public: - MessageStatus(const std::wstring& status, bool isError = false, bool showLoader = false); - MessageStatus(const std::vector& stati, bool isError = false, bool showLoader = false); + MessageStatus(const std::wstring& status, bool isError = false, bool showLoader = false, bool showInStatusBar = true); + MessageStatus(const std::vector& stati, bool isError = false, bool showLoader = false, bool showInStatusBar = true); static const std::string getStaticType(); @@ -21,6 +21,7 @@ public: const bool isError; const bool showLoader; + const bool showInStatusBar; private: std::vector m_stati; diff --git a/src/lib/utility/messaging/type/indexing/MessageIndexingFinished.h b/src/lib/utility/messaging/type/indexing/MessageIndexingFinished.h new file mode 100644 index 00000000..d7d20ea6 --- /dev/null +++ b/src/lib/utility/messaging/type/indexing/MessageIndexingFinished.h @@ -0,0 +1,20 @@ +#ifndef MESSAGE_INDEXING_FINISHED_H +#define MESSAGE_INDEXING_FINISHED_H + +#include "utility/messaging/Message.h" + +class MessageIndexingFinished + : public Message +{ +public: + static const std::string getStaticType() + { + return "MessageIndexingFinished"; + } + + MessageIndexingFinished() + { + } +}; + +#endif // MESSAGE_INDEXING_FINISHED_H diff --git a/src/lib/utility/messaging/type/indexing/MessageIndexingShowDialog.h b/src/lib/utility/messaging/type/indexing/MessageIndexingShowDialog.h new file mode 100644 index 00000000..5a046adc --- /dev/null +++ b/src/lib/utility/messaging/type/indexing/MessageIndexingShowDialog.h @@ -0,0 +1,23 @@ +#ifndef MESSAGE_INDEXING_SHOW_DIALOG_H +#define MESSAGE_INDEXING_SHOW_DIALOG_H + +#include "utility/messaging/Message.h" + +class MessageIndexingShowDialog + : public Message +{ +public: + static const std::string getStaticType() + { + return "MessageIndexingShowDialog"; + } + + MessageIndexingShowDialog(bool showDialog) + : showDialog(showDialog) + { + } + + const bool showDialog; +}; + +#endif // MESSAGE_INDEXING_SHOW_DIALOG_H diff --git a/src/lib/utility/messaging/type/indexing/MessageIndexingStarted.h b/src/lib/utility/messaging/type/indexing/MessageIndexingStarted.h new file mode 100644 index 00000000..40462207 --- /dev/null +++ b/src/lib/utility/messaging/type/indexing/MessageIndexingStarted.h @@ -0,0 +1,20 @@ +#ifndef MESSAGE_INDEXING_STARTED_H +#define MESSAGE_INDEXING_STARTED_H + +#include "utility/messaging/Message.h" + +class MessageIndexingStarted + : public Message +{ +public: + static const std::string getStaticType() + { + return "MessageIndexingStarted"; + } + + MessageIndexingStarted() + { + } +}; + +#endif // MESSAGE_INDEXING_STARTED_H diff --git a/src/lib/utility/messaging/type/indexing/MessageIndexingStatus.h b/src/lib/utility/messaging/type/indexing/MessageIndexingStatus.h new file mode 100644 index 00000000..45ff526e --- /dev/null +++ b/src/lib/utility/messaging/type/indexing/MessageIndexingStatus.h @@ -0,0 +1,28 @@ +#ifndef MESSAGE_INDEXING_STATUS_H +#define MESSAGE_INDEXING_STATUS_H + +#include "utility/messaging/Message.h" + +class MessageIndexingStatus + : public Message +{ +public: + static const std::string getStaticType() + { + return "MessageIndexingStatus"; + } + + MessageIndexingStatus(bool showProgress, bool unknownProgress, size_t progressPercent) + : showProgress(showProgress) + , unknownProgress(unknownProgress) + , progressPercent(progressPercent) + { + setSendAsTask(false); + } + + const bool showProgress; + const bool unknownProgress; + const size_t progressPercent; +}; + +#endif // MESSAGE_INDEXING_STATUS_H diff --git a/src/lib/utility/scheduling/Task.cpp b/src/lib/utility/scheduling/Task.cpp index b08541fc..7dc5060a 100644 --- a/src/lib/utility/scheduling/Task.cpp +++ b/src/lib/utility/scheduling/Task.cpp @@ -12,14 +12,9 @@ void Task::dispatchNext(std::shared_ptr task) TaskScheduler::getInstance()->pushNextTask(task); } -Task::Task() - : m_enterCalled(false) - , m_exitCalled(false) -{ -} - -Task::~Task() +void Task::setIsBackgroundTask(bool background) { + m_isBackgroundTask = background; } Task::TaskState Task::update(std::shared_ptr blackboard) @@ -32,7 +27,12 @@ Task::TaskState Task::update(std::shared_ptr blackboard) TaskState state = doUpdate(blackboard); - if (state != STATE_RUNNING && !m_exitCalled) + if (m_isBackgroundTask && state == STATE_RUNNING) + { + state = STATE_HOLD; + } + + if ((state == STATE_SUCCESS || state == STATE_FAILURE) && !m_exitCalled) { doExit(blackboard); m_exitCalled = true; @@ -51,4 +51,3 @@ void Task::reset(std::shared_ptr blackboard) void Task::terminate() { } - diff --git a/src/lib/utility/scheduling/Task.h b/src/lib/utility/scheduling/Task.h index 9333227b..21acbf7b 100644 --- a/src/lib/utility/scheduling/Task.h +++ b/src/lib/utility/scheduling/Task.h @@ -19,8 +19,9 @@ public: static void dispatch(std::shared_ptr task); static void dispatchNext(std::shared_ptr task); - Task(); - virtual ~Task(); + virtual ~Task() = default; + + void setIsBackgroundTask(bool background); TaskState update(std::shared_ptr blackboard); void reset(std::shared_ptr blackboard); @@ -32,8 +33,10 @@ private: virtual void doExit(std::shared_ptr blackboard) = 0; virtual void doReset(std::shared_ptr blackboard) = 0; - bool m_enterCalled; - bool m_exitCalled; + bool m_isBackgroundTask = false; + + bool m_enterCalled = false; + bool m_exitCalled = false; }; #endif // TASK_H diff --git a/src/lib/utility/scheduling/TaskGroupSelector.h b/src/lib/utility/scheduling/TaskGroupSelector.h index e372ebc4..f4972b50 100644 --- a/src/lib/utility/scheduling/TaskGroupSelector.h +++ b/src/lib/utility/scheduling/TaskGroupSelector.h @@ -10,7 +10,7 @@ class TaskGroupSelector public: TaskGroupSelector(); - virtual void addTask(std::shared_ptr task); + void addTask(std::shared_ptr task) override; private: void doEnter(std::shared_ptr blackboard) override; diff --git a/src/lib/utility/scheduling/TaskGroupSequence.h b/src/lib/utility/scheduling/TaskGroupSequence.h index 9a26510b..e1ad0883 100644 --- a/src/lib/utility/scheduling/TaskGroupSequence.h +++ b/src/lib/utility/scheduling/TaskGroupSequence.h @@ -10,7 +10,7 @@ class TaskGroupSequence public: TaskGroupSequence(); - virtual void addTask(std::shared_ptr task); + void addTask(std::shared_ptr task) override; private: void doEnter(std::shared_ptr blackboard) override; diff --git a/src/lib/utility/scheduling/TaskRunner.cpp b/src/lib/utility/scheduling/TaskRunner.cpp index e1f7a54b..07673334 100644 --- a/src/lib/utility/scheduling/TaskRunner.cpp +++ b/src/lib/utility/scheduling/TaskRunner.cpp @@ -1,6 +1,7 @@ #include "utility/scheduling/TaskRunner.h" #include "utility/logging/logging.h" +#include "utility/scheduling/Blackboard.h" #include "utility/scheduling/TaskScheduler.h" TaskRunner::TaskRunner(std::shared_ptr task) @@ -9,12 +10,18 @@ TaskRunner::TaskRunner(std::shared_ptr task) { } -TaskRunner::~TaskRunner() -{ -} - Task::TaskState TaskRunner::update(std::shared_ptr blackboard) { + if (!blackboard) + { + if (!m_blackboard) + { + m_blackboard = std::make_shared(); + } + + blackboard = m_blackboard; + } + try { if (m_reset) @@ -50,6 +57,3 @@ void TaskRunner::terminate() m_task->terminate(); } } - - - diff --git a/src/lib/utility/scheduling/TaskRunner.h b/src/lib/utility/scheduling/TaskRunner.h index 4aa358be..0f98d30f 100644 --- a/src/lib/utility/scheduling/TaskRunner.h +++ b/src/lib/utility/scheduling/TaskRunner.h @@ -9,7 +9,6 @@ class TaskRunner { public: TaskRunner(std::shared_ptr task); - ~TaskRunner(); Task::TaskState update(std::shared_ptr blackboard); void reset(); @@ -18,6 +17,9 @@ public: private: std::shared_ptr m_task; bool m_reset; + + // Only created by the first TaskRunner in the hierarchy, then passed down. + std::shared_ptr m_blackboard; }; #endif // TASK_RUNNER_H diff --git a/src/lib/utility/scheduling/TaskScheduler.cpp b/src/lib/utility/scheduling/TaskScheduler.cpp index 5b45f7a4..1d81eae5 100644 --- a/src/lib/utility/scheduling/TaskScheduler.cpp +++ b/src/lib/utility/scheduling/TaskScheduler.cpp @@ -4,7 +4,6 @@ #include #include "utility/logging/logging.h" -#include "utility/scheduling/Blackboard.h" #include "utility/ScopedFunctor.h" std::shared_ptr TaskScheduler::getInstance() @@ -154,7 +153,6 @@ void TaskScheduler::processTasks() m_tasksMutex.lock(); }); - std::shared_ptr blackboard = std::make_shared(); while (true) { { @@ -167,7 +165,7 @@ void TaskScheduler::processTasks() } } - state = runner->update(blackboard); + state = runner->update(nullptr); if (state != Task::STATE_RUNNING) { break; diff --git a/src/lib_gui/qt/element/QtCodeNavigator.cpp b/src/lib_gui/qt/element/QtCodeNavigator.cpp index ee216cb5..f59ea831 100644 --- a/src/lib_gui/qt/element/QtCodeNavigator.cpp +++ b/src/lib_gui/qt/element/QtCodeNavigator.cpp @@ -883,7 +883,7 @@ void QtCodeNavigator::handleMessage(MessageCodeReference* message) ); } -void QtCodeNavigator::handleMessage(MessageFinishedParsing* message) +void QtCodeNavigator::handleMessage(MessageIndexingFinished* message) { m_onQtThread( [=]() diff --git a/src/lib_gui/qt/element/QtCodeNavigator.h b/src/lib_gui/qt/element/QtCodeNavigator.h index 0e9534e0..0839d48d 100644 --- a/src/lib_gui/qt/element/QtCodeNavigator.h +++ b/src/lib_gui/qt/element/QtCodeNavigator.h @@ -9,8 +9,8 @@ #include "qt/element/QtCodeFileSingle.h" #include "qt/utility/QtThreadedFunctor.h" #include "utility/messaging/MessageListener.h" +#include "utility/messaging/type/indexing/MessageIndexingFinished.h" #include "utility/messaging/type/MessageCodeReference.h" -#include "utility/messaging/type/MessageFinishedParsing.h" #include "utility/messaging/type/MessageShowReference.h" #include "utility/messaging/type/MessageSwitchColorScheme.h" #include "utility/messaging/type/MessageWindowFocus.h" @@ -24,7 +24,7 @@ class SourceLocationFile; class QtCodeNavigator : public QWidget , public MessageListener - , public MessageListener + , public MessageListener , public MessageListener , public MessageListener , public MessageListener @@ -163,7 +163,7 @@ private: }; void handleMessage(MessageCodeReference* message); - void handleMessage(MessageFinishedParsing* message); + void handleMessage(MessageIndexingFinished* message); void handleMessage(MessageShowReference* message); void handleMessage(MessageSwitchColorScheme* message); void handleMessage(MessageWindowFocus* message); diff --git a/src/lib_gui/qt/element/QtStatusBar.cpp b/src/lib_gui/qt/element/QtStatusBar.cpp index f8cb9ae0..5aee4cd1 100644 --- a/src/lib_gui/qt/element/QtStatusBar.cpp +++ b/src/lib_gui/qt/element/QtStatusBar.cpp @@ -1,9 +1,12 @@ #include "qt/element/QtStatusBar.h" +#include #include +#include #include "qt/utility/utilityQt.h" #include "utility/messaging/type/error/MessageErrorsAll.h" +#include "utility/messaging/type/indexing/MessageIndexingShowDialog.h" #include "utility/messaging/type/MessageShowStatus.h" #include "utility/ResourcePaths.h" @@ -13,7 +16,8 @@ QtStatusBar::QtStatusBar() { addWidget(new QWidget()); // add some space - m_movie = std::make_shared(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"statusbar_view/loader.gif").wstr())); + m_movie = std::make_shared(QString::fromStdWString( + ResourcePaths::getGuiPath().concatenate(L"statusbar_view/loader.gif").wstr())); // if movie doesn't loop forever, force it to. if (m_movie->loopCount() != -1) { @@ -28,25 +32,68 @@ QtStatusBar::QtStatusBar() m_text.setFlat(true); m_text.setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac m_text.setSizePolicy(QSizePolicy::Ignored, m_text.sizePolicy().verticalPolicy()); + m_text.setCursor(Qt::PointingHandCursor); addWidget(&m_text, 1); setText(L"", false, false); connect(&m_text, &QPushButton::clicked, this, &QtStatusBar::showStatus); - addPermanentWidget(&m_ideStatusText); + // ide status + { + addPermanentVLine(); + addPermanentWidget(&m_ideStatusText); + } - m_errorButton.hide(); - m_errorButton.setFlat(true); - m_errorButton.setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac - m_errorButton.setStyleSheet("QPushButton { color: #D00000; margin-right: 0; spacing: none; }"); - m_errorButton.setIcon(utility::colorizePixmap( - QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"statusbar_view/dot.png").wstr())), -// "#D00000" - QColor(0xD0, 0, 0) - ).scaledToHeight(12)); - addPermanentWidget(&m_errorButton); + // errors + { + m_vlineError = addPermanentVLine(); + m_vlineError->hide(); + + m_errorButton.hide(); + m_errorButton.setFlat(true); + m_errorButton.setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac + m_errorButton.setStyleSheet("QPushButton { color: #D00000; margin-right: 0; spacing: none; }"); + m_errorButton.setIcon(utility::colorizePixmap( + QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"statusbar_view/dot.png").wstr())), + QColor(0xD0, 0, 0) + ).scaledToHeight(12)); + m_errorButton.setCursor(Qt::PointingHandCursor); + addPermanentWidget(&m_errorButton); + + connect(&m_errorButton, &QPushButton::clicked, this, &QtStatusBar::showErrors); + } + + // indexing status + { + m_vlineIndexing = addPermanentVLine(); + m_vlineIndexing->hide(); + + m_indexingStatus = new QPushButton(this); + m_indexingStatus->setFlat(true); + m_indexingStatus->setMinimumWidth(150); + m_indexingStatus->setStyleSheet("QPushButton { margin-right: 0; spacing: none; }"); + m_indexingStatus->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac + m_indexingStatus->setCursor(Qt::PointingHandCursor); + + connect(m_indexingStatus, &QPushButton::clicked, this, &QtStatusBar::clickedIndexingProgress); + + QHBoxLayout* layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + + layout->addWidget(new QLabel("Indexing:")); + + m_indexingProgress = new QProgressBar(); + m_indexingProgress->setMinimum(0); + m_indexingProgress->setMaximum(0); + m_indexingProgress->setValue(0); + layout->addWidget(m_indexingProgress); + + m_indexingStatus->setLayout(layout); + m_indexingStatus->hide(); + + addPermanentWidget(m_indexingStatus); + } - connect(&m_errorButton, &QPushButton::clicked, this, &QtStatusBar::showErrors); } void QtStatusBar::setText(const std::wstring& text, bool isError, bool showLoader) @@ -69,11 +116,8 @@ void QtStatusBar::setText(const std::wstring& text, bool isError, bool showLoade m_loader.hide(); } - if (!text.empty()) - { - m_textString = text; - m_text.setText(m_text.fontMetrics().elidedText(QString::fromStdWString(m_textString), Qt::ElideRight, m_text.width())); - } + m_textString = text; + m_text.setText(m_text.fontMetrics().elidedText(QString::fromStdWString(m_textString), Qt::ElideRight, m_text.width())); } void QtStatusBar::setErrorCount(ErrorCountInfo errorCount) @@ -84,6 +128,9 @@ void QtStatusBar::setErrorCount(ErrorCountInfo errorCount) QString::number(errorCount.total) + " error" + (errorCount.total > 1 ? "s" : "") + (errorCount.fatal > 0 ? " (" + QString::number(errorCount.fatal) + " fatal)" : "")); + m_errorButton.setMinimumWidth( + m_errorButton.fontMetrics().width(QString(m_errorButton.text().size(), 'a'))); + if (errorCount.fatal > 0) { m_errorButton.setStyleSheet("QPushButton { color: #D00000; margin-right: 0; spacing: none; }"); @@ -94,10 +141,12 @@ void QtStatusBar::setErrorCount(ErrorCountInfo errorCount) } m_errorButton.show(); + m_vlineError->show(); } else { m_errorButton.hide(); + m_vlineError->hide(); } } @@ -106,6 +155,33 @@ void QtStatusBar::setIdeStatus(const std::wstring& text) m_ideStatusText.setText(QString::fromStdWString(text)); } +void QtStatusBar::showIndexingProgress(bool unknownProgress, size_t progressPercent) +{ + m_indexingStatus->show(); + m_vlineIndexing->show(); + + m_errorButton.setEnabled(false); + + if (unknownProgress) + { + m_indexingProgress->setValue(0); + m_indexingProgress->setMaximum(0); + } + else + { + m_indexingProgress->setValue(progressPercent); + m_indexingProgress->setMaximum(100); + } +} + +void QtStatusBar::hideIndexingProgress() +{ + m_indexingStatus->hide(); + m_vlineIndexing->hide(); + + m_errorButton.setEnabled(true); +} + void QtStatusBar::resizeEvent(QResizeEvent* event) { m_text.setText(m_text.fontMetrics().elidedText(QString::fromStdWString(m_textString), Qt::ElideRight, m_text.width())); @@ -120,3 +196,18 @@ void QtStatusBar::showErrors() { MessageErrorsAll().dispatch(); } + +void QtStatusBar::clickedIndexingProgress() +{ + MessageIndexingShowDialog(true).dispatch(); +} + +QWidget* QtStatusBar::addPermanentVLine() +{ + QFrame* vline = new QFrame(this); + vline->setFrameShape(QFrame::VLine); + vline->setStyleSheet("color: #777"); + addPermanentWidget(vline); + return vline; +} + diff --git a/src/lib_gui/qt/element/QtStatusBar.h b/src/lib_gui/qt/element/QtStatusBar.h index 562fe940..4bc3e3ed 100644 --- a/src/lib_gui/qt/element/QtStatusBar.h +++ b/src/lib_gui/qt/element/QtStatusBar.h @@ -10,6 +10,8 @@ #include "data/ErrorCountInfo.h" +class QProgressBar; + class QtStatusBar : public QStatusBar { @@ -23,14 +25,20 @@ public: void setIdeStatus(const std::wstring& text); + void showIndexingProgress(bool unknownProgress, size_t progressPercent); + void hideIndexingProgress(); + protected: virtual void resizeEvent(QResizeEvent* event); private slots: void showStatus(); void showErrors(); + void clickedIndexingProgress(); private: + QWidget* addPermanentVLine(); + std::shared_ptr m_movie; std::wstring m_textString; @@ -40,6 +48,12 @@ private: QPushButton m_errorButton; QLabel m_ideStatusText; + + QPushButton* m_indexingStatus; + QProgressBar* m_indexingProgress; + + QWidget* m_vlineError; + QWidget* m_vlineIndexing; }; #endif // QT_STATUS_BAR_H diff --git a/src/lib_gui/qt/view/QtDialogView.cpp b/src/lib_gui/qt/view/QtDialogView.cpp index cc990c73..ed8edf49 100644 --- a/src/lib_gui/qt/view/QtDialogView.cpp +++ b/src/lib_gui/qt/view/QtDialogView.cpp @@ -11,13 +11,14 @@ #include "qt/window/QtIndexingDialog.h" #include "qt/window/QtMainWindow.h" #include "qt/window/QtWindow.h" +#include "utility/messaging/type/indexing/MessageIndexingStatus.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/scheduling/TaskLambda.h" #include "utility/utility.h" #include "project/Project.h" -QtDialogView::QtDialogView(QtMainWindow* mainWindow, StorageAccess* storageAccess) - : DialogView(storageAccess) +QtDialogView::QtDialogView(QtMainWindow* mainWindow, UseCase useCase, StorageAccess* storageAccess) + : DialogView(useCase, storageAccess) , m_mainWindow(mainWindow) , m_parentWindow(nullptr) , m_windowStack(this) @@ -30,6 +31,31 @@ QtDialogView::~QtDialogView() m_resultReady = true; } +bool QtDialogView::dialogsHidden() const +{ + QtIndexingDialog* window = dynamic_cast(m_windowStack.getTopWindow()); + if (window) + { + return window->isHidden(); + } + + return false; +} + +void QtDialogView::clearDialogs() +{ + m_onQtThread2( + [=]() + { + m_windowStack.clearWindows(); + + setUIBlocked(false); + } + ); + + setParentWindow(nullptr); +} + void QtDialogView::showUnknownProgressDialog(const std::wstring& title, const std::wstring& message) { MessageStatus(title + L": " + message, false, true).dispatch(); @@ -67,8 +93,8 @@ void QtDialogView::showProgressDialog(const std::wstring& title, const std::wstr { m_windowStack.clearWindows(); - window = createWindow(); - window->setupProgress(); + window = createWindow(); + window->setupProgress(m_dialogsHideable); } else { @@ -88,7 +114,12 @@ void QtDialogView::showProgressDialog(const std::wstring& title, const std::wstr window->updateMessage(QString::fromStdWString(message)); window->updateProgress(progress); - setUIBlocked(true); + if (m_updateIndexingStatus) + { + MessageIndexingStatus(true, false, progress).dispatch(); + } + + setUIBlocked(m_dialogsVisible); } ); } @@ -123,7 +154,7 @@ void QtDialogView::startIndexingDialog( { m_windowStack.clearWindows(); - QtIndexingDialog* window = createWindow(); + QtIndexingDialog* window = createWindow(); window->setupStart(enabledModes); m_refreshInfos.emplace(info.mode, info); @@ -197,26 +228,48 @@ void QtDialogView::startIndexingDialog( } void QtDialogView::updateIndexingDialog( - size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const FilePath& sourcePath) + size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths) { m_onQtThread( [=]() { + if (!sourcePaths.empty()) + { + std::vector stati; + for (const FilePath& path : sourcePaths) + { + stati.push_back(L"[" + std::to_wstring(startedFileCount) + L"/" + std::to_wstring(totalFileCount) + L"] Indexing file: " + path.wstr()); + } + MessageStatus(stati, false, true, m_dialogsVisible).dispatch(); + } + QtIndexingDialog* window = dynamic_cast(m_windowStack.getTopWindow()); if (!window) { m_windowStack.clearWindows(); - window = createWindow(); - window->setupIndexing(); + window = createWindow(); + window->setupIndexing(m_dialogsHideable); } if (window && window->getType() == QtIndexingDialog::DIALOG_INDEXING) { - window->updateIndexingProgress(finishedFileCount, totalFileCount, sourcePath); - setUIBlocked(true); + window->updateIndexingProgress(finishedFileCount, totalFileCount, sourcePaths.empty() ? FilePath() : sourcePaths.back()); } m_mainWindow->setWindowsTaskbarProgress(float(finishedFileCount) / totalFileCount); + + if (m_updateIndexingStatus) + { + int progress = 0; + if (totalFileCount) + { + progress = finishedFileCount * 100 / totalFileCount; + } + + MessageIndexingStatus(true, false, progress).dispatch(); + } + + setUIBlocked(m_dialogsVisible); } ); } @@ -225,15 +278,21 @@ DatabasePolicy QtDialogView::finishedIndexingDialog( size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo, bool interrupted) { + if (m_updateIndexingStatus) + { + MessageIndexingStatus(false, false, 0).dispatch(); + } + DatabasePolicy policy = DATABASE_POLICY_UNKNOWN; m_resultReady = false; m_onQtThread( [=, &policy]() { + m_dialogsVisible = true; m_windowStack.clearWindows(); - QtIndexingDialog* window = createWindow(); + QtIndexingDialog* window = createWindow(); window->setupReport(indexedFileCount, totalIndexedFileCount, completedFileCount, totalFileCount, time, interrupted); window->updateErrorCount(errorInfo.total, errorInfo.fatal); connect(window, &QtWindow::finished, @@ -267,23 +326,6 @@ DatabasePolicy QtDialogView::finishedIndexingDialog( return policy; } -void QtDialogView::hideDialogs(bool unblockUI) -{ - m_onQtThread2( - [=]() - { - m_windowStack.clearWindows(); - - if (unblockUI) - { - setUIBlocked(false); - } - } - ); - - setParentWindow(nullptr); -} - int QtDialogView::confirm(const std::string& message, const std::vector& options) { int result = -1; @@ -391,14 +433,19 @@ void QtDialogView::showUnknownProgress(const std::wstring& title, const std::wst if (!window) { - window = createWindow(); - window->setupUnknownProgress(); + window = createWindow(); + window->setupUnknownProgress(m_dialogsHideable); } window->updateTitle(QString::fromStdWString(title)); window->updateMessage(QString::fromStdWString(message)); - setUIBlocked(true); + if (m_updateIndexingStatus) + { + MessageIndexingStatus(true, true, 0).dispatch(); + } + + setUIBlocked(m_dialogsVisible); } void QtDialogView::hideUnknownProgress() @@ -417,6 +464,13 @@ void QtDialogView::hideUnknownProgress() void QtDialogView::setUIBlocked(bool blocked) { + if (m_uiBlocked == blocked) + { + return; + } + + m_uiBlocked = blocked; + if (m_parentWindow) { m_parentWindow->setEnabled(!blocked); @@ -436,8 +490,41 @@ void QtDialogView::setUIBlocked(bool blocked) } } +void QtDialogView::dialogVisibilityChanged(bool visible) +{ + QtIndexingDialog* window = dynamic_cast(m_windowStack.getTopWindow()); + if (!window) + { + return; + } + + window->setVisible(visible); + m_dialogsVisible = visible; + setUIBlocked(visible); + + if (!visible) + { + MessageStatus(L"", false, false).dispatch(); + } +} + +void QtDialogView::handleMessage(MessageIndexingShowDialog* message) +{ + m_onQtThread3( + [=]() + { + dialogVisibilityChanged(true); + } + ); +} + void QtDialogView::handleMessage(MessageInterruptTasks* message) { + if (!m_dialogsVisible) + { + return; + } + m_onQtThread3( [=]() { @@ -475,26 +562,28 @@ void QtDialogView::updateErrorCount(size_t errorCount, size_t fatalCount) } } -template - T* QtDialogView::createWindow() +QtIndexingDialog* QtDialogView::createWindow() { - T* window = nullptr; + QtIndexingDialog* window = nullptr; if (m_parentWindow) { - window = new T(m_parentWindow); + window = new QtIndexingDialog(m_parentWindow); } else { - window = new T(m_mainWindow); + window = new QtIndexingDialog(m_mainWindow); } - //make sure T is a QtWindow - if (dynamic_cast(window)) - { - connect(window, &QtWindow::canceled, &m_windowStack, &QtWindowStack::popWindow); - connect(window, &QtWindow::finished, &m_windowStack, &QtWindowStack::clearWindows); + connect(window, &QtWindow::canceled, &m_windowStack, &QtWindowStack::popWindow); + connect(window, &QtWindow::finished, &m_windowStack, &QtWindowStack::clearWindows); - m_windowStack.pushWindow(window); + connect(window, &QtIndexingDialog::visibleChanged, this, &QtDialogView::dialogVisibilityChanged); + + m_windowStack.pushWindow(window); + + if (!m_dialogsVisible) + { + window->hide(); } return window; diff --git a/src/lib_gui/qt/view/QtDialogView.h b/src/lib_gui/qt/view/QtDialogView.h index 09fddebe..ab8c18c1 100644 --- a/src/lib_gui/qt/view/QtDialogView.h +++ b/src/lib_gui/qt/view/QtDialogView.h @@ -8,9 +8,11 @@ #include "utility/messaging/MessageListener.h" #include "utility/messaging/type/error/MessageErrorCountUpdate.h" +#include "utility/messaging/type/indexing/MessageIndexingShowDialog.h" #include "utility/messaging/type/MessageInterruptTasks.h" #include "utility/messaging/type/MessageWindowClosed.h" +class QtIndexingDialog; class QtMainWindow; class QtWindow; @@ -18,15 +20,19 @@ class QtDialogView : public QObject , public DialogView , public MessageListener + , public MessageListener , public MessageListener , public MessageListener { Q_OBJECT public: - QtDialogView(QtMainWindow* mainWindow, StorageAccess* storageAccess); + QtDialogView(QtMainWindow* mainWindow, UseCase useCase, StorageAccess* storageAccess); ~QtDialogView() override; + bool dialogsHidden() const override; + void clearDialogs() override; + void showUnknownProgressDialog(const std::wstring& title, const std::wstring& message) override; void hideUnknownProgressDialog() override; @@ -36,13 +42,11 @@ public: void startIndexingDialog( Project* project, const std::vector& enabledModes, const RefreshInfo& info) override; void updateIndexingDialog( - size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const FilePath& sourcePath) override; + size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths) override; DatabasePolicy finishedIndexingDialog( size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo, bool interrupted) override; - void hideDialogs(bool unblockUI = true) override; - int confirm(const std::string& message, const std::vector& options) override; int confirm(const std::wstring& message, const std::vector& options) override; @@ -53,16 +57,17 @@ private slots: void hideUnknownProgress(); void setUIBlocked(bool blocked); + void dialogVisibilityChanged(bool visible); private: void handleMessage(MessageErrorCountUpdate* message) override; + void handleMessage(MessageIndexingShowDialog* message) override; void handleMessage(MessageInterruptTasks* message) override; void handleMessage(MessageWindowClosed* message) override; void updateErrorCount(size_t errorCount, size_t fatalCount); - template - T* createWindow(); + QtIndexingDialog* createWindow(); QtMainWindow* m_mainWindow; QtWindow* m_parentWindow; @@ -76,6 +81,8 @@ private: std::map m_refreshInfos; bool m_resultReady; + bool m_uiBlocked = false; + bool m_dialogsVisible = true; }; #endif // QT_DIALOG_VIEW_H diff --git a/src/lib_gui/qt/view/QtErrorView.cpp b/src/lib_gui/qt/view/QtErrorView.cpp index 2ce2b088..04e97aaf 100644 --- a/src/lib_gui/qt/view/QtErrorView.cpp +++ b/src/lib_gui/qt/view/QtErrorView.cpp @@ -176,7 +176,6 @@ void QtErrorView::initView() checkboxes->addSpacing(10); - { m_editButton = new QtSelfRefreshIconButton( "Edit Project", diff --git a/src/lib_gui/qt/view/QtMainView.cpp b/src/lib_gui/qt/view/QtMainView.cpp index b9fb4eda..35773db4 100644 --- a/src/lib_gui/qt/view/QtMainView.cpp +++ b/src/lib_gui/qt/view/QtMainView.cpp @@ -1,5 +1,6 @@ #include "qt/view/QtMainView.h" +#include "qt/view/QtViewWidgetWrapper.h" #include "qt/window/QtMainWindow.h" QtMainView::QtMainView() @@ -55,6 +56,17 @@ void QtMainView::hideView(View* view) ); } +void QtMainView::setViewEnabled(View* view, bool enabled) +{ + m_onQtThread( + [=]() + { + QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(view); + widget->setEnabled(enabled); + } + ); +} + View* QtMainView::findFloatingView(const std::string& name) const { return m_window->findFloatingView(name); diff --git a/src/lib_gui/qt/view/QtMainView.h b/src/lib_gui/qt/view/QtMainView.h index fc49e294..afaca978 100644 --- a/src/lib_gui/qt/view/QtMainView.h +++ b/src/lib_gui/qt/view/QtMainView.h @@ -38,6 +38,8 @@ public: virtual void showView(View* view); virtual void hideView(View* view); + virtual void setViewEnabled(View* view, bool enabled); + virtual View* findFloatingView(const std::string& name) const; virtual QStatusBar* getStatusBar(); diff --git a/src/lib_gui/qt/view/QtStatusBarView.cpp b/src/lib_gui/qt/view/QtStatusBarView.cpp index 0b378cb2..01fdd757 100644 --- a/src/lib_gui/qt/view/QtStatusBarView.cpp +++ b/src/lib_gui/qt/view/QtStatusBarView.cpp @@ -15,10 +15,6 @@ QtStatusBarView::QtStatusBarView(ViewLayout* viewLayout) mw->setStatusBar(sb); } -QtStatusBarView::~QtStatusBarView() -{ -} - void QtStatusBarView::createWidgetWrapper() { } @@ -60,3 +56,23 @@ void QtStatusBarView::showIdeStatus(const std::wstring& message) } ); } + +void QtStatusBarView::showIndexingProgress(bool unknownProgress, size_t progressPercent) +{ + m_onQtThread( + [=]() + { + m_widget->showIndexingProgress(unknownProgress, progressPercent); + } + ); +} + +void QtStatusBarView::hideIndexingProgress() +{ + m_onQtThread( + [=]() + { + m_widget->hideIndexingProgress(); + } + ); +} diff --git a/src/lib_gui/qt/view/QtStatusBarView.h b/src/lib_gui/qt/view/QtStatusBarView.h index 238ffc5a..71f1acd9 100644 --- a/src/lib_gui/qt/view/QtStatusBarView.h +++ b/src/lib_gui/qt/view/QtStatusBarView.h @@ -14,7 +14,7 @@ class QtStatusBarView { public: QtStatusBarView(ViewLayout* viewLayout); - ~QtStatusBarView(); + virtual ~QtStatusBarView() = default; // View implementation virtual void createWidgetWrapper(); @@ -27,6 +27,9 @@ public: virtual void showIdeStatus(const std::wstring& message); + virtual void showIndexingProgress(bool unknownProgress, size_t progressPercent); + virtual void hideIndexingProgress(); + private: QtThreadedLambdaFunctor m_onQtThread; diff --git a/src/lib_gui/qt/view/QtViewFactory.cpp b/src/lib_gui/qt/view/QtViewFactory.cpp index 044bf269..e26a0485 100644 --- a/src/lib_gui/qt/view/QtViewFactory.cpp +++ b/src/lib_gui/qt/view/QtViewFactory.cpp @@ -22,10 +22,6 @@ QtViewFactory::QtViewFactory() { } -QtViewFactory::~QtViewFactory() -{ -} - std::shared_ptr QtViewFactory::createMainView() const { return std::make_shared(); @@ -104,7 +100,8 @@ std::shared_ptr QtViewFactory::createUndoRedoView(ViewLayout* view return View::createInitAndAddToLayout(viewLayout); } -std::shared_ptr QtViewFactory::createDialogView(ViewLayout* viewLayout, StorageAccess* storageAccess) const +std::shared_ptr QtViewFactory::createDialogView( + ViewLayout* viewLayout, DialogView::UseCase useCase, StorageAccess* storageAccess) const { - return std::make_shared(dynamic_cast(viewLayout)->getMainWindow(), storageAccess); + return std::make_shared(dynamic_cast(viewLayout)->getMainWindow(), useCase, storageAccess); } diff --git a/src/lib_gui/qt/view/QtViewFactory.h b/src/lib_gui/qt/view/QtViewFactory.h index 59e26ac2..02b5825c 100644 --- a/src/lib_gui/qt/view/QtViewFactory.h +++ b/src/lib_gui/qt/view/QtViewFactory.h @@ -3,11 +3,12 @@ #include "component/view/ViewFactory.h" -class QtViewFactory: public ViewFactory +class QtViewFactory + : public ViewFactory { public: QtViewFactory(); - virtual ~QtViewFactory(); + virtual ~QtViewFactory() = default; virtual std::shared_ptr createMainView() const; virtual std::shared_ptr createCompositeView( @@ -26,7 +27,8 @@ public: virtual std::shared_ptr createTooltipView(ViewLayout* viewLayout) const; virtual std::shared_ptr createUndoRedoView(ViewLayout* viewLayout) const; - virtual std::shared_ptr createDialogView(ViewLayout* viewLayout, StorageAccess* storageAccess) const; + virtual std::shared_ptr createDialogView( + ViewLayout* viewLayout, DialogView::UseCase useCase, StorageAccess* storageAccess) const; }; #endif // QT_VIEW_FACTORY_H diff --git a/src/lib_gui/qt/window/QtIndexingDialog.cpp b/src/lib_gui/qt/window/QtIndexingDialog.cpp index 936c79d7..f3c0da86 100644 --- a/src/lib_gui/qt/window/QtIndexingDialog.cpp +++ b/src/lib_gui/qt/window/QtIndexingDialog.cpp @@ -152,7 +152,7 @@ void QtIndexingDialog::updateRefreshInfo(const RefreshInfo& info) m_indexLabel->setVisible(true); } -void QtIndexingDialog::setupIndexing() +void QtIndexingDialog::setupIndexing(bool hideable) { setType(DIALOG_INDEXING); @@ -171,7 +171,8 @@ void QtIndexingDialog::setupIndexing() layout->addStretch(); addButtons(layout); - setNextVisible(false); + updateNextButton("Hide"); + setNextVisible(hideable); updateCloseButton("Stop"); m_sizeHint = QSize(350, 350); @@ -232,7 +233,7 @@ void QtIndexingDialog::setupReport( finishSetup(); } -void QtIndexingDialog::setupUnknownProgress() +void QtIndexingDialog::setupUnknownProgress(bool hideable) { setType(DIALOG_UNKNOWN_PROGRESS); @@ -244,6 +245,13 @@ void QtIndexingDialog::setupUnknownProgress() layout->addStretch(); + if (hideable) + { + addButtons(layout); + updateNextButton("Hide"); + setCloseVisible(false); + } + m_sizeHint = QSize(350, 280); m_progressBar->showUnknownProgressAnimated(); @@ -253,7 +261,7 @@ void QtIndexingDialog::setupUnknownProgress() finishSetup(); } -void QtIndexingDialog::setupProgress() +void QtIndexingDialog::setupProgress(bool hideable) { setType(DIALOG_PROGRESS); @@ -266,6 +274,13 @@ void QtIndexingDialog::setupProgress() layout->addStretch(); + if (hideable) + { + addButtons(layout); + updateNextButton("Hide"); + setCloseVisible(false); + } + m_sizeHint = QSize(350, 280); setCancelAble(false); @@ -365,6 +380,12 @@ void QtIndexingDialog::handleNext() } } + if (m_type == DIALOG_INDEXING || m_type == DIALOG_PROGRESS || m_type == DIALOG_UNKNOWN_PROGRESS) + { + emit visibleChanged(false); + return; + } + if (m_type == DIALOG_REPORT) { MessageErrorsHelpMessage().dispatch(); @@ -484,7 +505,8 @@ void QtIndexingDialog::addErrorWidget(QBoxLayout* layout) errorCount->setObjectName("errorCount"); errorCount->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac - errorCount->setIcon(QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/error.png").wstr()))); + errorCount->setIcon(QPixmap(QString::fromStdWString( + ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/error.png").wstr()))); errorLayout->addWidget(errorCount); QtHelpButton* helpButton = new QtHelpButton("aaa", "bbb"); @@ -526,7 +548,8 @@ void QtIndexingDialog::addButtons(QBoxLayout* layout) void QtIndexingDialog::addFlag() { - QtDeviceScaledPixmap flag(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/flag.png").wstr())); + QtDeviceScaledPixmap flag(QString::fromStdWString( + ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/flag.png").wstr())); flag.scaleToWidth(120); QLabel* flagLabel = new QLabel(this); diff --git a/src/lib_gui/qt/window/QtIndexingDialog.h b/src/lib_gui/qt/window/QtIndexingDialog.h index c038c0a9..6c24211b 100644 --- a/src/lib_gui/qt/window/QtIndexingDialog.h +++ b/src/lib_gui/qt/window/QtIndexingDialog.h @@ -19,6 +19,7 @@ class QtIndexingDialog signals: void setMode(RefreshMode mode); void startIndexing(RefreshMode mode); + void visibleChanged(bool visible); public: enum DialogType @@ -39,13 +40,13 @@ public: void setupStart(const std::vector& enabledModes); void updateRefreshInfo(const RefreshInfo& info); - void setupIndexing(); + void setupIndexing(bool hideable); void setupReport( size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, bool interrupted); - void setupUnknownProgress(); - void setupProgress(); + void setupUnknownProgress(bool hideable); + void setupProgress(bool hideable); void updateMessage(const QString& message); std::wstring getMessage() const; diff --git a/src/lib_gui/qt/window/QtPreferencesWindow.cpp b/src/lib_gui/qt/window/QtPreferencesWindow.cpp index 297807e3..fad6e6f9 100644 --- a/src/lib_gui/qt/window/QtPreferencesWindow.cpp +++ b/src/lib_gui/qt/window/QtPreferencesWindow.cpp @@ -75,7 +75,7 @@ void QtPreferencesWindow::handleNext() if (needsRestart) { - app->getDialogView()->confirm( + app->getDialogView(DialogView::UseCase::PROJECT_SETUP)->confirm( "

Please restart the application for all changes to take effect.

Note: These changes may harm " "the execution of the application. In case the application is not useable anymore, please run the " "'resetPreferences.sh' script located in your install directory.

" diff --git a/src/lib_gui/qt/window/QtWindowStack.cpp b/src/lib_gui/qt/window/QtWindowStack.cpp index d299337e..ec1ba837 100644 --- a/src/lib_gui/qt/window/QtWindowStack.cpp +++ b/src/lib_gui/qt/window/QtWindowStack.cpp @@ -13,7 +13,7 @@ QtWindowStack::QtWindowStack(QObject* parent) { } -QtWindowStackElement* QtWindowStack::getTopWindow() +QtWindowStackElement* QtWindowStack::getTopWindow() const { if (m_stack.size()) { @@ -23,7 +23,7 @@ QtWindowStackElement* QtWindowStack::getTopWindow() return nullptr; } -QtWindowStackElement* QtWindowStack::getBottomWindow() +QtWindowStackElement* QtWindowStack::getBottomWindow() const { if (m_stack.size()) { @@ -33,7 +33,7 @@ QtWindowStackElement* QtWindowStack::getBottomWindow() return nullptr; } -size_t QtWindowStack::getWindowCount() +size_t QtWindowStack::getWindowCount() const { return m_stack.size(); } diff --git a/src/lib_gui/qt/window/QtWindowStack.h b/src/lib_gui/qt/window/QtWindowStack.h index 4332bc7e..90995311 100644 --- a/src/lib_gui/qt/window/QtWindowStack.h +++ b/src/lib_gui/qt/window/QtWindowStack.h @@ -30,10 +30,10 @@ signals: public: QtWindowStack(QObject* parent = nullptr); - QtWindowStackElement* getTopWindow(); - QtWindowStackElement* getBottomWindow(); + QtWindowStackElement* getTopWindow() const; + QtWindowStackElement* getBottomWindow() const; - size_t getWindowCount(); + size_t getWindowCount() const; void centerSubWindows(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp index 5bc25906..3952cbe5 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp @@ -545,14 +545,16 @@ std::vector QtProjectWizzardContentPathSourceMaven::getFilePaths() con return std::vector(); } - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + QtDialogView* dialogView = dynamic_cast( + Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); ScopedFunctor scopedFunctor([&dialogView]() { dialogView->hideUnknownProgressDialog(); }); - std::dynamic_pointer_cast(dialogView)->setParentWindow(m_window); + dialogView->setParentWindow(m_window); dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nGenerating Source Files"); + const bool success = utility::mavenGenerateSources(mavenPath, mavenProjectRoot); if (!success) { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index 0f91d197..9a6926fa 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -730,14 +730,15 @@ void QtProjectWizzardContentPathsHeaderSearch::validateIncludesButtonClicked() { std::vector unresolvedIncludes; { - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + QtDialogView* dialogView = dynamic_cast( + Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); std::set sourceFilePaths; std::vector indexedFilePaths; std::vector headerSearchPaths; { - std::dynamic_pointer_cast(dialogView)->setParentWindow(m_window); + dialogView->setParentWindow(m_window); dialogView->showUnknownProgressDialog(L"Processing", L"Gathering Source Files"); ScopedFunctor dialogHider([&dialogView](){ dialogView->hideUnknownProgressDialog(); @@ -761,7 +762,7 @@ void QtProjectWizzardContentPathsHeaderSearch::validateIncludesButtonClicked() } } { - std::dynamic_pointer_cast(dialogView)->setParentWindow(m_window); + dialogView->setParentWindow(m_window); ScopedFunctor dialogHider([&dialogView](){ dialogView->hideProgressDialog(); }); @@ -773,8 +774,9 @@ void QtProjectWizzardContentPathsHeaderSearch::validateIncludesButtonClicked() log2(sourceFilePaths.size()), [&](const float progress) { - Application::getInstance()->getDialogView()->showProgressDialog( - L"Processing", std::to_wstring(int(progress * sourceFilePaths.size())) + L" Files", int(progress * 100.0f) + dialogView->showProgressDialog( + L"Processing", std::to_wstring(int(progress * sourceFilePaths.size())) + L" Files", + int(progress * 100.0f) ); } ); @@ -802,7 +804,8 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootP { std::set detectedHeaderSearchPaths; { - std::shared_ptr dialogView = std::dynamic_pointer_cast(Application::getInstance()->getDialogView()); + QtDialogView* dialogView = dynamic_cast( + Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP).get()); std::set sourceFilePaths; std::vector headerSearchPaths; @@ -841,8 +844,9 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootP log2(sourceFilePaths.size()), [&](const float progress) { - Application::getInstance()->getDialogView()->showProgressDialog( - L"Processing", std::to_wstring(int(progress * sourceFilePaths.size())) + L" Files", int(progress * 100.0f) + dialogView->showProgressDialog( + L"Processing", std::to_wstring(int(progress * sourceFilePaths.size())) + L" Files", + int(progress * 100.0f) ); } ); diff --git a/src/lib_java/project/SourceGroupJavaGradle.cpp b/src/lib_java/project/SourceGroupJavaGradle.cpp index 26a9eeb8..252d71e3 100644 --- a/src/lib_java/project/SourceGroupJavaGradle.cpp +++ b/src/lib_java/project/SourceGroupJavaGradle.cpp @@ -34,7 +34,7 @@ std::vector SourceGroupJavaGradle::getAllSourcePaths() const std::vector sourcePaths; if (m_settings->getGradleProjectFilePathExpandedAndAbsolute().exists()) { - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + std::shared_ptr dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP); dialogView->showUnknownProgressDialog(L"Preparing Project", L"Gradle\nFetching Source Directories"); const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().getParentDirectory(); @@ -87,7 +87,7 @@ bool SourceGroupJavaGradle::prepareGradleData() { const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().getParentDirectory(); - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + std::shared_ptr dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP); ScopedFunctor dialogHider([&dialogView]() { dialogView->hideUnknownProgressDialog(); diff --git a/src/lib_java/project/SourceGroupJavaMaven.cpp b/src/lib_java/project/SourceGroupJavaMaven.cpp index a503bf62..e39f04b7 100644 --- a/src/lib_java/project/SourceGroupJavaMaven.cpp +++ b/src/lib_java/project/SourceGroupJavaMaven.cpp @@ -36,7 +36,7 @@ std::vector SourceGroupJavaMaven::getAllSourcePaths() const std::vector sourcePaths; if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists()) { - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + std::shared_ptr dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP); dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nFetching Source Directories"); const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath()); @@ -87,7 +87,7 @@ bool SourceGroupJavaMaven::prepareMavenData() const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory(); - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + std::shared_ptr dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP); dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nGenerating Source Files"); ScopedFunctor dialogHider([&dialogView](){ diff --git a/src/lib_java/utility/utilityJava.cpp b/src/lib_java/utility/utilityJava.cpp index a01cbe56..1a3c8d0f 100644 --- a/src/lib_java/utility/utilityJava.cpp +++ b/src/lib_java/utility/utilityJava.cpp @@ -104,7 +104,7 @@ namespace utility std::set fetchRootDirectories(const std::set& sourceFilePaths) { - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + std::shared_ptr dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP); dialogView->showUnknownProgressDialog(L"Preparing Project", L"Gathering Root\nDirectories"); ScopedFunctor dialogHider([&dialogView]() {