diff --git a/src/lib/app/Application.cpp b/src/lib/app/Application.cpp index 0fd1202b..d7be30eb 100644 --- a/src/lib/app/Application.cpp +++ b/src/lib/app/Application.cpp @@ -467,6 +467,11 @@ void Application::refreshProject(RefreshMode refreshMode) if (m_project && checkSharedMemory()) { m_project->refresh(refreshMode, getDialogView(DialogView::UseCase::INDEXING)); + + if (!m_hasGUI && !m_project->isIndexing()) + { + MessageQuitApplication().dispatch(); + } } } diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index 6bd9ed68..ffd46f0c 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -516,8 +516,9 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie } } - taskSequential->addTask(std::make_shared>( - "source_file_count", indexerCommandProvider->size() + customIndexerCommandProvider->size())); + size_t sourceFileCount = indexerCommandProvider->size() + customIndexerCommandProvider->size(); + + taskSequential->addTask(std::make_shared>("source_file_count", sourceFileCount)); taskSequential->addTask(std::make_shared>("indexed_source_file_count", 0)); taskSequential->addTask(std::make_shared>("interrupted_indexing", false)); taskSequential->addTask(std::make_shared>("index_time", 0.0f)); @@ -673,6 +674,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie Task::dispatch(TabId::app(), taskSequential); m_refreshStage = RefreshStageType::INDEXING; + MessageStatus(L"Starting Indexing: " + std::to_wstring(sourceFileCount) + L" source files", false, true).dispatch(); MessageIndexingStarted().dispatch(); } diff --git a/src/lib_cxx/project/SourceGroupCxxCdb.cpp b/src/lib_cxx/project/SourceGroupCxxCdb.cpp index 5332e7b9..5f4bbd98 100644 --- a/src/lib_cxx/project/SourceGroupCxxCdb.cpp +++ b/src/lib_cxx/project/SourceGroupCxxCdb.cpp @@ -26,18 +26,10 @@ bool SourceGroupCxxCdb::prepareIndexing() FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute(); if (!cdbPath.empty() && !cdbPath.exists()) { - MessageStatus(L"Can't refresh project").dispatch(); - - if (std::shared_ptr application = Application::getInstance()) - { - if (application->hasGUI()) - { - application->handleDialog( - L"Can't refresh. The compilation database of the project does not exist anymore: " + cdbPath.wstr(), - { L"Ok" } - ); - } - } + std::wstring error = L"Can't refresh project. The compilation database of the project does not exist anymore: " + + cdbPath.wstr(); + MessageStatus(error, true).dispatch(); + Application::getInstance()->handleDialog(error, { L"Ok" }); return false; } return true; diff --git a/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp b/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp index 4557460e..f20d8857 100644 --- a/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp +++ b/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp @@ -19,18 +19,10 @@ bool SourceGroupCxxCodeblocks::prepareIndexing() FilePath codeblocksProjectPath = m_settings->getCodeblocksProjectPathExpandedAndAbsolute(); if (!codeblocksProjectPath.empty() && !codeblocksProjectPath.exists()) { - MessageStatus(L"Can't refresh project").dispatch(); - - if (std::shared_ptr application = Application::getInstance()) - { - if (application->hasGUI()) - { - application->handleDialog( - L"Can't refresh. The referenced Code::Blocks project does not exist anymore: " + codeblocksProjectPath.wstr(), - { L"Ok" } - ); - } - } + std::wstring error = L"Can't refresh project. The referenced Code::Blocks project does not exist anymore: " + + codeblocksProjectPath.wstr(); + MessageStatus(error, true).dispatch(); + Application::getInstance()->handleDialog(error, { L"Ok" }); return false; } return true; diff --git a/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp b/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp index 6bc24d1e..227c7b9f 100644 --- a/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp +++ b/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp @@ -19,19 +19,10 @@ bool SourceGroupCxxSonargraph::prepareIndexing() FilePath sonargraphProjectPath = m_settings->getSonargraphProjectPathExpandedAndAbsolute(); if (!sonargraphProjectPath.empty() && !sonargraphProjectPath.exists()) { - MessageStatus(L"Can't refresh project").dispatch(); - - if (std::shared_ptr application = Application::getInstance()) - { - if (application->hasGUI()) - { - application->handleDialog( - L"Can't refresh. The referenced Sonargraph project does not exist anymore: " + sonargraphProjectPath.wstr(), - { L"Ok" } - ); - } - } - return false; + std::wstring error = L"Can't refresh project. The referenced Sonargraph project does not exist anymore: " + + sonargraphProjectPath.wstr(); + MessageStatus(error, true).dispatch(); + Application::getInstance()->handleDialog(error, { L"Ok" }); } return true; } diff --git a/src/lib_gui/qt/QtCoreApplication.cpp b/src/lib_gui/qt/QtCoreApplication.cpp index 978312c8..fbb716b3 100644 --- a/src/lib_gui/qt/QtCoreApplication.cpp +++ b/src/lib_gui/qt/QtCoreApplication.cpp @@ -7,18 +7,27 @@ QtCoreApplication::QtCoreApplication(int argc, char **argv ) { } -QtCoreApplication::~QtCoreApplication() -{ -} - void QtCoreApplication::handleMessage(MessageQuitApplication* message) { - std::cout << "quit" << std::endl; + std::cout << "Quitting" << std::endl; emit quit(); } +void QtCoreApplication::handleMessage(MessageIndexingStatus* message) +{ + if (message->showProgress) + { + std::cout << message->progressPercent << "% " << '\r' << std::flush; + } +} + void QtCoreApplication::handleMessage(MessageStatus* message) { + if (message->isError) + { + std::wcout << L"ERROR: "; + } + for (const std::wstring& status : message->stati()) { std::wcout << status << std::endl; diff --git a/src/lib_gui/qt/QtCoreApplication.h b/src/lib_gui/qt/QtCoreApplication.h index 44c632e1..65c955ca 100644 --- a/src/lib_gui/qt/QtCoreApplication.h +++ b/src/lib_gui/qt/QtCoreApplication.h @@ -3,6 +3,7 @@ #include +#include "MessageIndexingStatus.h" #include "MessageListener.h" #include "MessageQuitApplication.h" #include "MessageStatus.h" @@ -10,16 +11,18 @@ class QtCoreApplication : public QCoreApplication , public MessageListener + , public MessageListener , public MessageListener { Q_OBJECT public: QtCoreApplication(int argc, char **argv); - virtual ~QtCoreApplication(); + virtual ~QtCoreApplication() = default; private: virtual void handleMessage(MessageQuitApplication* message); + virtual void handleMessage(MessageIndexingStatus* message); virtual void handleMessage(MessageStatus* message); }; diff --git a/src/lib_java/project/SourceGroupJavaSonargraph.cpp b/src/lib_java/project/SourceGroupJavaSonargraph.cpp index 2cf4a8c5..bc04c87d 100644 --- a/src/lib_java/project/SourceGroupJavaSonargraph.cpp +++ b/src/lib_java/project/SourceGroupJavaSonargraph.cpp @@ -23,18 +23,10 @@ bool SourceGroupJavaSonargraph::prepareIndexing() FilePath sonargraphProjectPath = m_settings->getSonargraphProjectPathExpandedAndAbsolute(); if (!sonargraphProjectPath.empty() && !sonargraphProjectPath.exists()) { - MessageStatus(L"Can't refresh project. The referenced Sonargraph project does not exist anymore.").dispatch(); - - if (std::shared_ptr application = Application::getInstance()) - { - if (application->hasGUI()) - { - application->handleDialog( - L"Can't refresh project. The referenced Sonargraph project does not exist anymore: " + sonargraphProjectPath.wstr(), - { L"Ok" } - ); - } - } + std::wstring error = L"Can't refresh project. The referenced Sonargraph project does not exist anymore: " + + sonargraphProjectPath.wstr(); + MessageStatus(error, true).dispatch(); + Application::getInstance()->handleDialog(error, { L"Ok" }); return false; } return true;