ui: Made all indexing dialogs hideable

* all dialogs for the indexing usecase can be hidden regardless of project state
* fixed some dialogs could not be shown
* pass dialogview into project and all indexing tasks
* pass application to project and tasks
This commit is contained in:
Eberhard Graether
2018-07-25 23:49:46 +02:00
parent b055b4c7dc
commit afec261872
16 changed files with 83 additions and 64 deletions
+2 -2
View File
@@ -273,11 +273,11 @@ void Application::handleMessage(MessageLoadProject* message)
m_storageCache->setSubject(nullptr);
m_project = std::make_shared<Project>(
std::make_shared<ProjectSettings>(projectSettingsFilePath), m_storageCache.get(), hasGUI());
std::make_shared<ProjectSettings>(projectSettingsFilePath), m_storageCache.get(), getUUID(), hasGUI());
if (m_project)
{
m_project->load();
m_project->load(getDialogView(DialogView::UseCase::GENERAL));
}
else
{
+2
View File
@@ -70,6 +70,8 @@ void ComponentManager::setup(ViewLayout* viewLayout)
);
}
m_dialogViews[DialogView::UseCase::INDEXING]->setDialogsHideable(true);
std::shared_ptr<TabbedView> tabbedView =
m_componentFactory->getViewFactory()->createTabbedView(viewLayout, "Status");
m_tabbedViews.push_back(tabbedView);
@@ -39,6 +39,11 @@ void StatusBarController::handleMessage(MessageIndexingFinished* message)
getView()->hideIndexingProgress();
}
void StatusBarController::handleMessage(MessageIndexingStarted* message)
{
getView()->showIndexingProgress(0);
}
void StatusBarController::handleMessage(MessageIndexingStatus* message)
{
if (message->showProgress)
@@ -9,6 +9,7 @@
#include "utility/messaging/type/error/MessageErrorCountClear.h"
#include "utility/messaging/type/error/MessageErrorCountUpdate.h"
#include "utility/messaging/type/indexing/MessageIndexingFinished.h"
#include "utility/messaging/type/indexing/MessageIndexingStarted.h"
#include "utility/messaging/type/indexing/MessageIndexingStatus.h"
#include "utility/messaging/type/MessagePingReceived.h"
#include "utility/messaging/type/MessageRefresh.h"
@@ -22,6 +23,7 @@ class StatusBarController
, public MessageListener<MessageErrorCountClear>
, public MessageListener<MessageErrorCountUpdate>
, public MessageListener<MessageIndexingFinished>
, public MessageListener<MessageIndexingStarted>
, public MessageListener<MessageIndexingStatus>
, public MessageListener<MessagePingReceived>
, public MessageListener<MessageRefresh>
@@ -39,6 +41,7 @@ private:
virtual void handleMessage(MessageErrorCountClear* message);
virtual void handleMessage(MessageErrorCountUpdate* message);
virtual void handleMessage(MessageIndexingFinished* message);
virtual void handleMessage(MessageIndexingStarted* message);
virtual void handleMessage(MessageIndexingStatus* message);
virtual void handleMessage(MessagePingReceived* message);
virtual void handleMessage(MessageRefresh* message);
+6 -6
View File
@@ -8,9 +8,11 @@
#include "Application.h"
TaskCleanStorage::TaskCleanStorage(
std::weak_ptr<PersistentStorage> storage, const std::vector<FilePath>& filePaths, bool clearAllErrors
std::weak_ptr<PersistentStorage> storage, std::shared_ptr<DialogView> dialogView,
const std::vector<FilePath>& filePaths, bool clearAllErrors
)
: m_storage(storage)
, m_dialogView(dialogView)
, m_filePaths(filePaths)
, m_clearAllErrors(clearAllErrors)
{
@@ -18,8 +20,7 @@ TaskCleanStorage::TaskCleanStorage(
void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
{
Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->showUnknownProgressDialog(
L"Clearing Files", std::to_wstring(m_filePaths.size()) + L" Files");
m_dialogView->showUnknownProgressDialog(L"Clearing Files", std::to_wstring(m_filePaths.size()) + L" Files");
m_start = utility::durationStart();
@@ -43,8 +44,7 @@ Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboar
storage->clearFileElements(m_filePaths, [=](int progress)
{
Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->showProgressDialog(
L"Clearing", std::to_wstring(m_filePaths.size()) + L" Files", progress);
m_dialogView->showProgressDialog(L"Clearing", std::to_wstring(m_filePaths.size()) + L" Files", progress);
}
);
}
@@ -58,7 +58,7 @@ void TaskCleanStorage::doExit(std::shared_ptr<Blackboard> blackboard)
{
blackboard->set("clear_time", utility::duration(m_start));
Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->hideProgressDialog();
m_dialogView->hideProgressDialog();
}
void TaskCleanStorage::doReset(std::shared_ptr<Blackboard> blackboard)
+2
View File
@@ -16,6 +16,7 @@ class TaskCleanStorage
public:
TaskCleanStorage(
std::weak_ptr<PersistentStorage> storage,
std::shared_ptr<DialogView> dialogView,
const std::vector<FilePath>& filePaths,
bool clearAllErrors
);
@@ -27,6 +28,7 @@ private:
void doReset(std::shared_ptr<Blackboard> blackboard) override;
std::weak_ptr<PersistentStorage> m_storage;
std::shared_ptr<DialogView> m_dialogView;
std::vector<FilePath> m_filePaths;
bool m_clearAllErrors;
+6 -11
View File
@@ -11,18 +11,15 @@
#include "utility/utilityString.h"
#include "Application.h"
TaskFinishParsing::TaskFinishParsing(std::shared_ptr<PersistentStorage> storage)
TaskFinishParsing::TaskFinishParsing(std::shared_ptr<PersistentStorage> storage, std::shared_ptr<DialogView> dialogView)
: m_storage(storage)
, m_dialogView(dialogView)
{
}
void TaskFinishParsing::terminate()
{
Application* app = Application::getInstance().get();
if (app)
{
app->getDialogView(DialogView::UseCase::INDEXING)->clearDialogs();
}
m_dialogView->clearDialogs();
MessageStatus(L"An unknown exception was thrown during indexing.", true, false).dispatch();
MessageIndexingFinished().dispatch();
@@ -37,11 +34,9 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
{
TimeStamp start = utility::durationStart();
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING);
dialogView->showUnknownProgressDialog(L"Finish Indexing", L"Optimizing database");
m_dialogView->showUnknownProgressDialog(L"Finish Indexing", L"Optimizing database");
m_storage->optimizeMemory();
dialogView->hideUnknownProgressDialog();
m_dialogView->hideUnknownProgressDialog();
float time = utility::duration(start);
@@ -82,7 +77,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
MessageStatus(status, false, false).dispatch();
StorageStats stats = m_storage->getStorageStats();
DatabasePolicy policy = dialogView->finishedIndexingDialog(
DatabasePolicy policy = m_dialogView->finishedIndexingDialog(
indexedSourceFileCount,
sourceFileCount,
stats.completedFileCount,
+2 -1
View File
@@ -14,7 +14,7 @@ class TaskFinishParsing
: public Task
{
public:
TaskFinishParsing(std::shared_ptr<PersistentStorage> storage);
TaskFinishParsing(std::shared_ptr<PersistentStorage> storage, std::shared_ptr<DialogView> dialogView);
void terminate() override;
@@ -25,6 +25,7 @@ private:
void doReset(std::shared_ptr<Blackboard> blackboard) override;
std::shared_ptr<PersistentStorage> m_storage;
std::shared_ptr<DialogView> m_dialogView;
};
#endif // TASK_FINISH_PARSING_H
+14 -11
View File
@@ -3,16 +3,16 @@
#include "utility/AppPath.h"
#include "utility/logging/FileLogger.h"
#include "utility/messaging/type/indexing/MessageIndexingStatus.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/scheduling/Blackboard.h"
#include "utility/TimeStamp.h"
#include "utility/UserPaths.h"
#include "utility/utilityApp.h"
#include "Application.h"
#include "component/view/DialogView.h"
#include "data/indexer/IndexerCommandList.h"
#include "data/indexer/interprocess/InterprocessIndexer.h"
#include "data/storage/StorageProvider.h"
#include "utility/messaging/type/MessageStatus.h"
#if _WIN32
const std::wstring TaskBuildIndex::s_processName(L"sourcetrail_indexer.exe");
@@ -21,16 +21,20 @@ const std::wstring TaskBuildIndex::s_processName(L"sourcetrail_indexer");
#endif
TaskBuildIndex::TaskBuildIndex(
unsigned int processCount,
size_t processCount,
std::shared_ptr<IndexerCommandList> indexerCommandList,
std::shared_ptr<StorageProvider> storageProvider,
std::shared_ptr<DialogView> dialogView,
const std::string& appUUID,
bool multiProcessIndexing
)
: m_indexerCommandList(indexerCommandList)
, m_storageProvider(storageProvider)
, m_dialogView(dialogView)
, m_appUUID(appUUID)
, m_multiProcessIndexing(multiProcessIndexing)
, m_interprocessIndexerCommandManager(Application::getUUID(), 0, true)
, m_interprocessIndexingStatusManager(Application::getUUID(), 0, true)
, m_interprocessIndexerCommandManager(appUUID, 0, true)
, m_interprocessIndexingStatusManager(appUUID, 0, true)
, m_processCount(processCount)
, m_interrupted(false)
, m_lastCommandCount(0)
@@ -66,7 +70,7 @@ void TaskBuildIndex::doEnter(std::shared_ptr<Blackboard> blackboard)
const int processId = i + 1; // 0 remains reserved for the main process
m_interprocessIntermediateStorageManagers.push_back(
std::make_shared<InterprocessIntermediateStorageManager>(Application::getUUID(), processId, true)
std::make_shared<InterprocessIntermediateStorageManager>(m_appUUID, processId, true)
);
if (m_multiProcessIndexing)
@@ -168,7 +172,7 @@ void TaskBuildIndex::terminate()
void TaskBuildIndex::handleMessage(MessageInterruptTasks* message)
{
if (!Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->dialogsHidden())
if (!m_dialogView->dialogsHidden())
{
m_interrupted = true;
}
@@ -192,7 +196,7 @@ void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFil
const std::wstring commandPath = L"\"" + indexerProcessPath.wstr() + L"\"";
std::vector<std::wstring> commandArguments;
commandArguments.push_back(std::to_wstring(processId));
commandArguments.push_back(utility::decodeFromUtf8(Application::getUUID()));
commandArguments.push_back(utility::decodeFromUtf8(m_appUUID));
commandArguments.push_back(L"\"" + AppPath::getAppPath().getAbsolute().wstr() + L"\"");
commandArguments.push_back(L"\"" + UserPaths::getUserDataPath().getAbsolute().wstr() + L"\"");
@@ -222,7 +226,7 @@ void TaskBuildIndex::runIndexerThread(int processId)
m_runningThreadCount++;
}
InterprocessIndexer indexer(Application::getUUID(), processId);
InterprocessIndexer indexer(m_appUUID, processId);
indexer.work();
{
@@ -297,8 +301,7 @@ void TaskBuildIndex::updateIndexingDialog(
m_indexingFileCount += sourcePaths.size();
Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->updateIndexingDialog(
m_indexingFileCount, indexedSourceFileCount, sourceFileCount, sourcePaths);
m_dialogView->updateIndexingDialog(m_indexingFileCount, indexedSourceFileCount, sourceFileCount, sourcePaths);
int progress = 0;
if (sourceFileCount)
+6 -2
View File
@@ -21,9 +21,11 @@ class TaskBuildIndex
{
public:
TaskBuildIndex(
unsigned int processCount,
size_t processCount,
std::shared_ptr<IndexerCommandList> indexerCommandList,
std::shared_ptr<StorageProvider> storageProvider,
std::shared_ptr<DialogView> dialogView,
const std::string& appUUID,
bool multiProcessIndexing
);
@@ -45,12 +47,14 @@ protected:
std::shared_ptr<IndexerCommandList> m_indexerCommandList;
std::shared_ptr<StorageProvider> m_storageProvider;
std::shared_ptr<DialogView> m_dialogView;
const std::string m_appUUID;
bool m_multiProcessIndexing;
InterprocessIndexerCommandManager m_interprocessIndexerCommandManager;
InterprocessIndexingStatusManager m_interprocessIndexingStatusManager;
unsigned int m_processCount;
size_t m_processCount;
bool m_interrupted;
size_t m_lastCommandCount;
size_t m_indexingFileCount;
+4 -10
View File
@@ -2,13 +2,12 @@
#include "component/view/DialogView.h"
#include "data/storage/PersistentStorage.h"
#include "utility/messaging/type/indexing/MessageIndexingStatus.h"
#include "utility/scheduling/Blackboard.h"
#include "utility/utility.h"
#include "Application.h"
TaskParseWrapper::TaskParseWrapper(std::weak_ptr<PersistentStorage> storage)
TaskParseWrapper::TaskParseWrapper(std::weak_ptr<PersistentStorage> storage, std::shared_ptr<DialogView> dialogView)
: m_storage(storage)
, m_dialogView(dialogView)
{
}
@@ -17,13 +16,8 @@ void TaskParseWrapper::doEnter(std::shared_ptr<Blackboard> blackboard)
int sourceFileCount = 0;
blackboard->get("source_file_count", sourceFileCount);
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING))
{
dialogView->clearDialogs();
dialogView->updateIndexingDialog(0, 0, sourceFileCount, { });
MessageIndexingStatus(true, 0).dispatch();
}
m_dialogView->clearDialogs();
m_dialogView->updateIndexingDialog(0, 0, sourceFileCount, { });
m_start = utility::durationStart();
+2 -1
View File
@@ -16,7 +16,7 @@ class TaskParseWrapper
: public TaskDecorator
{
public:
TaskParseWrapper(std::weak_ptr<PersistentStorage> storage);
TaskParseWrapper(std::weak_ptr<PersistentStorage> storage, std::shared_ptr<DialogView> dialogView);
private:
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
@@ -25,6 +25,7 @@ private:
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
std::weak_ptr<PersistentStorage> m_storage;
std::shared_ptr<DialogView> m_dialogView;
TimeStamp m_start;
};
+21 -16
View File
@@ -41,18 +41,18 @@
#include "utility/utilityApp.h"
#include "utility/utilityFile.h"
#include "utility/utilityString.h"
#include "Application.h"
const std::wstring Project::PROJECT_FILE_EXTENSION = L".srctrlprj";
const std::wstring Project::BOOKMARK_DB_FILE_EXTENSION = L".srctrlbm";
const std::wstring Project::INDEX_DB_FILE_EXTENSION = L".srctrldb";
const std::wstring Project::TEMP_INDEX_DB_FILE_EXTENSION = L".srctrldb_tmp";
Project::Project(std::shared_ptr<ProjectSettings> settings, StorageCache* storageCache, bool hasGUI)
Project::Project(std::shared_ptr<ProjectSettings> settings, StorageCache* storageCache, const std::string& appUUID, bool hasGUI)
: m_settings(settings)
, m_storageCache(storageCache)
, m_state(PROJECT_STATE_NOT_LOADED)
, m_isIndexing(false)
, m_appUUID(appUUID)
, m_hasGUI(hasGUI)
{
}
@@ -89,7 +89,7 @@ void Project::setStateOutdated()
}
}
void Project::load()
void Project::load(std::shared_ptr<DialogView> dialogView)
{
if (m_isIndexing)
{
@@ -114,9 +114,10 @@ void Project::load()
{
if (dbPath.exists())
{
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?",
if (dialogView->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)
{
LOG_INFO("Switching to temporary indexing data on user's decision");
@@ -346,7 +347,12 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialo
enabledModes.insert(enabledModes.end(), { REFRESH_UPDATED_FILES, REFRESH_UPDATED_AND_INCOMPLETE_FILES });
}
dialogView->startIndexingDialog(this, enabledModes, info, [this, dialogView](const RefreshInfo& info) { buildIndex(info, dialogView); });
dialogView->startIndexingDialog(this, enabledModes, info,
[this, dialogView](const RefreshInfo& info)
{
buildIndex(info, dialogView);
}
);
}
else
{
@@ -412,18 +418,17 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
FileSystem::copyFile(indexDbFilePath, tempIndexDbFilePath);
}
std::shared_ptr<PersistentStorage> tempStorage = std::make_shared<PersistentStorage>(tempIndexDbFilePath, m_storage->getBookmarkDbFilePath());
std::shared_ptr<PersistentStorage> tempStorage =
std::make_shared<PersistentStorage>(tempIndexDbFilePath, m_storage->getBookmarkDbFilePath());
tempStorage->setup();
std::shared_ptr<TaskGroupSequence> taskSequential = std::make_shared<TaskGroupSequence>();
bool hideable = m_state == PROJECT_STATE_LOADED || m_state == PROJECT_STATE_OUTDATED;
dialogView->setDialogsHideable(hideable);
if (info.mode != REFRESH_ALL_FILES && (info.filesToClear.size() || info.nonIndexedFilesToClear.size()))
{
taskSequential->addTask(std::make_shared<TaskCleanStorage>(
tempStorage,
dialogView,
utility::toVector(utility::concat(info.filesToClear, info.nonIndexedFilesToClear)),
info.mode == REFRESH_UPDATED_AND_INCOMPLETE_FILES
));
@@ -468,11 +473,12 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("indexed_source_file_count", 0));
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("indexer_count", 0));
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(tempStorage);
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(tempStorage, dialogView);
taskSequential->addTask(taskParserWrapper);
std::shared_ptr<TaskGroupParallel> taskParallelIndexing = std::make_shared<TaskGroupParallel>();
taskParserWrapper->setTask(taskParallelIndexing);
// add task for indexing
if (indexerThreadCount > 0)
{
@@ -480,7 +486,7 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
taskParallelIndexing->addChildTasks(
std::make_shared<TaskDecoratorRepeat>(TaskDecoratorRepeat::CONDITION_WHILE_SUCCESS, Task::STATE_SUCCESS)->addChildTask(
std::make_shared<TaskBuildIndex>(indexerThreadCount, indexerCommandList, storageProvider, multiProcess)
std::make_shared<TaskBuildIndex>(indexerThreadCount, indexerCommandList, storageProvider, dialogView, m_appUUID, multiProcess)
)
);
}
@@ -536,7 +542,7 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
dialogView->hideUnknownProgressDialog();
}
taskSequential->addTask(std::make_shared<TaskFinishParsing>(tempStorage));
taskSequential->addTask(std::make_shared<TaskFinishParsing>(tempStorage, dialogView));
taskSequential->addTask(std::make_shared<TaskGroupSelector>()->addChildTasks(
std::make_shared<TaskGroupSequence>()->addChildTasks(
@@ -560,7 +566,6 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
taskSequential->addTask(std::make_shared<TaskLambda>([dialogView, this]() {
m_isIndexing = false;
dialogView->setDialogsHideable(false);
MessageIndexingFinished().dispatch();
}));
+3 -2
View File
@@ -24,7 +24,7 @@ public:
static const std::wstring INDEX_DB_FILE_EXTENSION;
static const std::wstring TEMP_INDEX_DB_FILE_EXTENSION;
Project(std::shared_ptr<ProjectSettings> settings, StorageCache* storageCache, bool hasGUI);
Project(std::shared_ptr<ProjectSettings> settings, StorageCache* storageCache, const std::string& appUUID, bool hasGUI);
virtual ~Project();
FilePath getProjectSettingsFilePath() const;
@@ -35,7 +35,7 @@ public:
bool settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const;
void setStateOutdated();
void load();
void load(std::shared_ptr<DialogView> dialogView);
void refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialogView);
@@ -71,6 +71,7 @@ private:
std::shared_ptr<PersistentStorage> m_storage;
std::vector<std::shared_ptr<SourceGroup>> m_sourceGroups;
std::string m_appUUID;
bool m_hasGUI;
};
@@ -15,6 +15,7 @@ public:
MessageIndexingShowDialog(bool showDialog)
: showDialog(showDialog)
{
setSendAsTask(false);
}
const bool showDialog;
+4 -2
View File
@@ -142,6 +142,7 @@ void QtDialogView::startIndexingDialog(
m_onQtThread(
[=]()
{
m_dialogsVisible = true;
m_windowStack.clearWindows();
QtIndexingDialog* window = createWindow();
@@ -177,6 +178,7 @@ void QtDialogView::startIndexingDialog(
m_onQtThread2(
[=]()
{
m_dialogsVisible = true;
m_refreshInfos.emplace(info.mode, info);
window->updateRefreshInfo(info);
@@ -464,7 +466,7 @@ void QtDialogView::setUIBlocked(bool blocked)
void QtDialogView::dialogVisibilityChanged(bool visible)
{
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
QtWindowStackElement* window = m_windowStack.getTopWindow();
if (!window)
{
return;
@@ -474,7 +476,7 @@ void QtDialogView::dialogVisibilityChanged(bool visible)
m_dialogsVisible = visible;
setUIBlocked(visible);
if (!visible)
if (!visible && dynamic_cast<QtIndexingDialog*>(window))
{
MessageStatus(L"", false, false).dispatch();
}