logic: Show unknown progress dialog when refreshing (issue 341)
* refactored dialog handling * Application always provides a DialogView instance bug id = 341
This commit is contained in:
@@ -133,7 +133,7 @@ std::shared_ptr<DialogView> Application::getDialogView()
|
||||
return m_componentManager->getDialogView();
|
||||
}
|
||||
|
||||
return std::shared_ptr<DialogView>();
|
||||
return std::make_shared<DialogView>(nullptr);
|
||||
}
|
||||
|
||||
bool Application::isInTrial() const
|
||||
|
||||
@@ -9,11 +9,11 @@ DialogView::~DialogView()
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::showStatusDialog(const std::string& title, const std::string& message)
|
||||
void DialogView::showUnknownProgressDialog(const std::string& title, const std::string& message)
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::hideStatusDialog()
|
||||
void DialogView::hideUnknownProgressDialog()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
DialogView(StorageAccess* storageAccess);
|
||||
virtual ~DialogView();
|
||||
|
||||
virtual void showStatusDialog(const std::string& title, const std::string& message);
|
||||
virtual void hideStatusDialog();
|
||||
virtual void showUnknownProgressDialog(const std::string& title, const std::string& message);
|
||||
virtual void hideUnknownProgressDialog();
|
||||
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress);
|
||||
virtual void hideProgressDialog();
|
||||
|
||||
@@ -16,10 +16,8 @@ TaskCleanStorage::TaskCleanStorage(
|
||||
|
||||
void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->showStatusDialog("Clearing Files", std::to_string(m_filePaths.size()) + " Files");
|
||||
}
|
||||
Application::getInstance()->getDialogView()->showUnknownProgressDialog(
|
||||
"Clearing Files", std::to_string(m_filePaths.size()) + " Files");
|
||||
|
||||
m_start = utility::durationStart();
|
||||
|
||||
@@ -33,10 +31,8 @@ Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboar
|
||||
{
|
||||
m_storage->clearFileElements(m_filePaths, [=](int progress)
|
||||
{
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->showProgressDialog("Clearing", std::to_string(m_filePaths.size()) + " Files", progress);
|
||||
}
|
||||
Application::getInstance()->getDialogView()->showProgressDialog(
|
||||
"Clearing", std::to_string(m_filePaths.size()) + " Files", progress);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -48,10 +44,8 @@ Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboar
|
||||
void TaskCleanStorage::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
blackboard->set("clear_time", utility::duration(m_start));
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->hideProgressDialog();
|
||||
}
|
||||
|
||||
Application::getInstance()->getDialogView()->hideProgressDialog();
|
||||
}
|
||||
|
||||
void TaskCleanStorage::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
|
||||
@@ -32,22 +32,13 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
dialogView->showStatusDialog("Finish Indexing", "Optimizing database");
|
||||
}
|
||||
dialogView->showUnknownProgressDialog("Finish Indexing", "Optimizing database");
|
||||
m_storage->optimizeMemory();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
dialogView->showStatusDialog("Finish Indexing", "Building caches");
|
||||
}
|
||||
dialogView->showUnknownProgressDialog("Finish Indexing", "Building caches");
|
||||
m_storage->buildCaches();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
dialogView->hideStatusDialog();
|
||||
}
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
MessageFinishedParsing().dispatch();
|
||||
|
||||
float time = utility::duration(start);
|
||||
@@ -72,19 +63,15 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
int sourceFileCount = 0;
|
||||
blackboard->get("source_file_count", sourceFileCount);
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
StorageStats stats = m_storageAccess->getStorageStats();
|
||||
|
||||
dialogView->finishedIndexingDialog(
|
||||
indexedSourceFileCount,
|
||||
sourceFileCount,
|
||||
stats.completedFileCount,
|
||||
stats.fileCount,
|
||||
time,
|
||||
m_storageAccess->getErrorCount()
|
||||
);
|
||||
}
|
||||
StorageStats stats = m_storageAccess->getStorageStats();
|
||||
dialogView->finishedIndexingDialog(
|
||||
indexedSourceFileCount,
|
||||
sourceFileCount,
|
||||
stats.completedFileCount,
|
||||
stats.fileCount,
|
||||
time,
|
||||
m_storageAccess->getErrorCount()
|
||||
);
|
||||
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -22,10 +22,8 @@ void TaskShowStatusDialog::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
|
||||
Task::TaskState TaskShowStatusDialog::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->showStatusDialog(m_title, m_message);
|
||||
}
|
||||
Application::getInstance()->getDialogView()->showUnknownProgressDialog(m_title, m_message);
|
||||
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "project/Project.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/access/StorageAccessProxy.h"
|
||||
#include "data/indexer/IndexerCommand.h"
|
||||
@@ -32,14 +33,13 @@
|
||||
#include "utility/scheduling/TaskGroupParallel.h"
|
||||
#include "utility/scheduling/TaskReturnSuccessWhile.h"
|
||||
#include "utility/scheduling/TaskSetValue.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityApp.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
Project::Project(std::shared_ptr<ProjectSettings> settings, StorageAccessProxy* storageAccessProxy)
|
||||
: m_settings(settings)
|
||||
, m_storageAccessProxy(storageAccessProxy)
|
||||
@@ -101,12 +101,14 @@ bool Project::refresh(bool forceRefresh)
|
||||
break;
|
||||
}
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
if (!forceRefresh && needsFullRefresh && question.size() && Application::getInstance()->hasGUI())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = Application::getInstance()->getDialogView()->confirm(question, options);
|
||||
int result = dialogView->confirm(question, options);
|
||||
|
||||
if (result == 1)
|
||||
{
|
||||
@@ -118,13 +120,21 @@ bool Project::refresh(bool forceRefresh)
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Ok");
|
||||
Application::getInstance()->getDialogView()->confirm("You can't refresh the project in trial mode, please unlock with a license key.", options);
|
||||
dialogView->confirm("You can't refresh the project in trial mode, please unlock with a license key.", options);
|
||||
|
||||
MessageDispatchWhenLicenseValid(std::make_shared<MessageRefresh>()).dispatch();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Processing Files");
|
||||
|
||||
ScopedFunctor dialogHider([&dialogView](){
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
});
|
||||
|
||||
|
||||
if (m_state == PROJECT_STATE_NEEDS_MIGRATION)
|
||||
{
|
||||
m_settings->migrate();
|
||||
@@ -365,6 +375,8 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
options.preprocessorOnlyVisible = hasCXXSourceGroup;
|
||||
options.preprocessorOnly = false;
|
||||
|
||||
Application::getInstance()->getDialogView()->hideUnknownProgressDialog();
|
||||
|
||||
options = Application::getInstance()->getDialogView()->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), allSourceFilePaths.size(), options);
|
||||
|
||||
@@ -465,7 +477,7 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefres
|
||||
taskParserWrapper->setTask(taskParallelIndexing);
|
||||
|
||||
// add tasks for indexing and merging
|
||||
for (size_t i = 0; i < indexerThreadCount && i < indexerCommandList->size(); i++)
|
||||
for (int i = 0; i < indexerThreadCount && size_t(i) < indexerCommandList->size(); i++)
|
||||
{
|
||||
taskParallelIndexing->addChildTasks(
|
||||
std::make_shared<TaskDecoratorRepeat>(TaskDecoratorRepeat::CONDITION_WHILE_SUCCESS, Task::STATE_SUCCESS)->addChildTask(
|
||||
|
||||
Reference in New Issue
Block a user