logic: Show hidden indexing dialog on refresh
* Fixed refresh restarted when refreshing while processing files
This commit is contained in:
@@ -42,8 +42,8 @@ void DialogView::hideProgressDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DialogView::startIndexingDialog(
|
void DialogView::startIndexingDialog(
|
||||||
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info,
|
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode,
|
||||||
std::function<void(const RefreshInfo& info)> onStartIndexing)
|
std::function<void(const RefreshInfo& info)> onStartIndexing, std::function<void()> onCancelIndexing)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ public:
|
|||||||
virtual void hideProgressDialog();
|
virtual void hideProgressDialog();
|
||||||
|
|
||||||
virtual void startIndexingDialog(
|
virtual void startIndexingDialog(
|
||||||
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info,
|
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode,
|
||||||
std::function<void(const RefreshInfo& info)> onStartIndexing);
|
std::function<void(const RefreshInfo& info)> onStartIndexing, std::function<void()> onCancelIndexing);
|
||||||
virtual void updateIndexingDialog(
|
virtual void updateIndexingDialog(
|
||||||
size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector<FilePath>& sourcePaths);
|
size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector<FilePath>& sourcePaths);
|
||||||
virtual DatabasePolicy finishedIndexingDialog(
|
virtual DatabasePolicy finishedIndexingDialog(
|
||||||
|
|||||||
+15
-18
@@ -36,7 +36,6 @@
|
|||||||
#include "TaskLambda.h"
|
#include "TaskLambda.h"
|
||||||
#include "TaskReturnSuccessIf.h"
|
#include "TaskReturnSuccessIf.h"
|
||||||
#include "TaskSetValue.h"
|
#include "TaskSetValue.h"
|
||||||
#include "ScopedFunctor.h"
|
|
||||||
#include "TextAccess.h"
|
#include "TextAccess.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "utilityApp.h"
|
#include "utilityApp.h"
|
||||||
@@ -52,7 +51,7 @@ Project::Project(std::shared_ptr<ProjectSettings> settings, StorageCache* storag
|
|||||||
: m_settings(settings)
|
: m_settings(settings)
|
||||||
, m_storageCache(storageCache)
|
, m_storageCache(storageCache)
|
||||||
, m_state(PROJECT_STATE_NOT_LOADED)
|
, m_state(PROJECT_STATE_NOT_LOADED)
|
||||||
, m_isIndexing(false)
|
, m_refreshStage(RefreshStageType::NONE)
|
||||||
, m_appUUID(appUUID)
|
, m_appUUID(appUUID)
|
||||||
, m_hasGUI(hasGUI)
|
, m_hasGUI(hasGUI)
|
||||||
{
|
{
|
||||||
@@ -74,7 +73,7 @@ std::string Project::getDescription() const
|
|||||||
|
|
||||||
bool Project::isIndexing() const
|
bool Project::isIndexing() const
|
||||||
{
|
{
|
||||||
return m_isIndexing;
|
return m_refreshStage == RefreshStageType::INDEXING;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const
|
bool Project::settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const
|
||||||
@@ -92,7 +91,7 @@ void Project::setStateOutdated()
|
|||||||
|
|
||||||
void Project::load(std::shared_ptr<DialogView> dialogView)
|
void Project::load(std::shared_ptr<DialogView> dialogView)
|
||||||
{
|
{
|
||||||
if (m_isIndexing)
|
if (m_refreshStage != RefreshStageType::NONE)
|
||||||
{
|
{
|
||||||
MessageStatus(L"Cannot load another project while indexing.", true, false).dispatch();
|
MessageStatus(L"Cannot load another project while indexing.", true, false).dispatch();
|
||||||
return;
|
return;
|
||||||
@@ -234,12 +233,13 @@ void Project::load(std::shared_ptr<DialogView> dialogView)
|
|||||||
|
|
||||||
void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialogView)
|
void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialogView)
|
||||||
{
|
{
|
||||||
if (m_isIndexing)
|
if (m_refreshStage != RefreshStageType::NONE)
|
||||||
{
|
{
|
||||||
MessageStatus(L"Cannot refresh the project while indexing.", true, false).dispatch();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_refreshStage = RefreshStageType::REFRESHING;
|
||||||
|
|
||||||
if (m_state == PROJECT_STATE_NOT_LOADED)
|
if (m_state == PROJECT_STATE_NOT_LOADED)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -312,11 +312,6 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Processing Files");
|
|
||||||
ScopedFunctor dialogHider([&dialogView](){
|
|
||||||
dialogView->hideUnknownProgressDialog();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (m_state == PROJECT_STATE_NEEDS_MIGRATION)
|
if (m_state == PROJECT_STATE_NEEDS_MIGRATION)
|
||||||
{
|
{
|
||||||
m_settings->migrate();
|
m_settings->migrate();
|
||||||
@@ -342,8 +337,6 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialo
|
|||||||
refreshMode = REFRESH_UPDATED_FILES;
|
refreshMode = REFRESH_UPDATED_FILES;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshInfo info = getRefreshInfo(refreshMode);
|
|
||||||
|
|
||||||
if (m_hasGUI)
|
if (m_hasGUI)
|
||||||
{
|
{
|
||||||
std::vector<RefreshMode> enabledModes = { REFRESH_ALL_FILES };
|
std::vector<RefreshMode> enabledModes = { REFRESH_ALL_FILES };
|
||||||
@@ -352,16 +345,20 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialo
|
|||||||
enabledModes.insert(enabledModes.end(), { REFRESH_UPDATED_FILES, REFRESH_UPDATED_AND_INCOMPLETE_FILES });
|
enabledModes.insert(enabledModes.end(), { REFRESH_UPDATED_FILES, REFRESH_UPDATED_AND_INCOMPLETE_FILES });
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogView->startIndexingDialog(this, enabledModes, info,
|
dialogView->startIndexingDialog(this, enabledModes, refreshMode,
|
||||||
[this, dialogView](const RefreshInfo& info)
|
[this, dialogView](const RefreshInfo& info)
|
||||||
{
|
{
|
||||||
buildIndex(info, dialogView);
|
buildIndex(info, dialogView);
|
||||||
|
},
|
||||||
|
[this]()
|
||||||
|
{
|
||||||
|
m_refreshStage = RefreshStageType::NONE;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buildIndex(info, dialogView);
|
buildIndex(getRefreshInfo(refreshMode), dialogView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +382,7 @@ RefreshInfo Project::getRefreshInfo(RefreshMode mode) const
|
|||||||
|
|
||||||
void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> dialogView)
|
void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> dialogView)
|
||||||
{
|
{
|
||||||
if (m_isIndexing)
|
if (m_refreshStage == RefreshStageType::INDEXING)
|
||||||
{
|
{
|
||||||
MessageStatus(L"Cannot refresh project while indexing.", true, false).dispatch();
|
MessageStatus(L"Cannot refresh project while indexing.", true, false).dispatch();
|
||||||
return;
|
return;
|
||||||
@@ -572,14 +569,14 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
|
|||||||
));
|
));
|
||||||
|
|
||||||
taskSequential->addTask(std::make_shared<TaskLambda>([dialogView, this]() {
|
taskSequential->addTask(std::make_shared<TaskLambda>([dialogView, this]() {
|
||||||
m_isIndexing = false;
|
m_refreshStage = RefreshStageType::NONE;
|
||||||
MessageIndexingFinished().dispatch();
|
MessageIndexingFinished().dispatch();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
taskSequential->setIsBackgroundTask(true);
|
taskSequential->setIsBackgroundTask(true);
|
||||||
Task::dispatch(taskSequential);
|
Task::dispatch(taskSequential);
|
||||||
|
|
||||||
m_isIndexing = true;
|
m_refreshStage = RefreshStageType::INDEXING;
|
||||||
MessageIndexingStarted().dispatch();
|
MessageIndexingStarted().dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,13 @@ private:
|
|||||||
PROJECT_STATE_DB_CORRUPTED
|
PROJECT_STATE_DB_CORRUPTED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class RefreshStageType
|
||||||
|
{
|
||||||
|
REFRESHING,
|
||||||
|
INDEXING,
|
||||||
|
NONE
|
||||||
|
};
|
||||||
|
|
||||||
Project(const Project&);
|
Project(const Project&);
|
||||||
|
|
||||||
void swapToTempStorage(std::shared_ptr<DialogView> dialogView);
|
void swapToTempStorage(std::shared_ptr<DialogView> dialogView);
|
||||||
@@ -67,7 +74,7 @@ private:
|
|||||||
StorageCache* const m_storageCache;
|
StorageCache* const m_storageCache;
|
||||||
|
|
||||||
ProjectStateType m_state;
|
ProjectStateType m_state;
|
||||||
bool m_isIndexing = false;
|
RefreshStageType m_refreshStage;
|
||||||
|
|
||||||
std::shared_ptr<PersistentStorage> m_storage;
|
std::shared_ptr<PersistentStorage> m_storage;
|
||||||
std::vector<std::shared_ptr<SourceGroup>> m_sourceGroups;
|
std::vector<std::shared_ptr<SourceGroup>> m_sourceGroups;
|
||||||
|
|||||||
@@ -12,13 +12,10 @@ public:
|
|||||||
return "MessageIndexingShowDialog";
|
return "MessageIndexingShowDialog";
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageIndexingShowDialog(bool showDialog)
|
MessageIndexingShowDialog()
|
||||||
: showDialog(showDialog)
|
|
||||||
{
|
{
|
||||||
setSendAsTask(false);
|
setSendAsTask(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool showDialog;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_INDEXING_SHOW_DIALOG_H
|
#endif // MESSAGE_INDEXING_SHOW_DIALOG_H
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ void QtStatusBar::showErrors()
|
|||||||
|
|
||||||
void QtStatusBar::clickedIndexingProgress()
|
void QtStatusBar::clickedIndexingProgress()
|
||||||
{
|
{
|
||||||
MessageIndexingShowDialog(true).dispatch();
|
MessageIndexingShowDialog().dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* QtStatusBar::addPermanentVLine()
|
QWidget* QtStatusBar::addPermanentVLine()
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ void QtDialogView::hideProgressDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QtDialogView::startIndexingDialog(
|
void QtDialogView::startIndexingDialog(
|
||||||
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info,
|
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode,
|
||||||
std::function<void(const RefreshInfo& info)> onStartIndexing)
|
std::function<void(const RefreshInfo& info)> onStartIndexing, std::function<void()> onCancelIndexing)
|
||||||
{
|
{
|
||||||
m_refreshInfos.clear();
|
m_refreshInfos.clear();
|
||||||
|
|
||||||
@@ -146,9 +146,6 @@ void QtDialogView::startIndexingDialog(
|
|||||||
m_windowStack.clearWindows();
|
m_windowStack.clearWindows();
|
||||||
|
|
||||||
QtIndexingDialog* window = createWindow();
|
QtIndexingDialog* window = createWindow();
|
||||||
window->setupStart(enabledModes);
|
|
||||||
|
|
||||||
m_refreshInfos.emplace(info.mode, info);
|
|
||||||
|
|
||||||
connect(window, &QtIndexingDialog::setMode,
|
connect(window, &QtIndexingDialog::setMode,
|
||||||
[=](RefreshMode refreshMode)
|
[=](RefreshMode refreshMode)
|
||||||
@@ -157,6 +154,7 @@ void QtDialogView::startIndexingDialog(
|
|||||||
if (it != m_refreshInfos.end())
|
if (it != m_refreshInfos.end())
|
||||||
{
|
{
|
||||||
window->updateRefreshInfo(it->second);
|
window->updateRefreshInfo(it->second);
|
||||||
|
window->show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +182,7 @@ void QtDialogView::startIndexingDialog(
|
|||||||
|
|
||||||
timer->stop();
|
timer->stop();
|
||||||
hideUnknownProgress();
|
hideUnknownProgress();
|
||||||
|
window->show();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -209,11 +208,19 @@ void QtDialogView::startIndexingDialog(
|
|||||||
connect(window, &QtWindow::canceled,
|
connect(window, &QtWindow::canceled,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
Task::dispatch(std::make_shared<TaskLambda>(
|
||||||
|
[=]()
|
||||||
|
{
|
||||||
|
onCancelIndexing();
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
setUIBlocked(false);
|
setUIBlocked(false);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
window->updateRefreshInfo(info);
|
window->setupStart(enabledModes, initialMode);
|
||||||
|
window->hide();
|
||||||
setUIBlocked(true);
|
setUIBlocked(true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ public:
|
|||||||
void hideProgressDialog() override;
|
void hideProgressDialog() override;
|
||||||
|
|
||||||
void startIndexingDialog(
|
void startIndexingDialog(
|
||||||
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info,
|
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode,
|
||||||
std::function<void(const RefreshInfo& info)> onStartIndexing) override;
|
std::function<void(const RefreshInfo& info)> onStartIndexing, std::function<void()> onCancelIndexing) override;
|
||||||
void updateIndexingDialog(
|
void updateIndexingDialog(
|
||||||
size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector<FilePath>& sourcePaths) override;
|
size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector<FilePath>& sourcePaths) override;
|
||||||
DatabasePolicy finishedIndexingDialog(
|
DatabasePolicy finishedIndexingDialog(
|
||||||
|
|||||||
@@ -3,12 +3,13 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
|
#include "MessageIndexingShowDialog.h"
|
||||||
#include "MessageRefresh.h"
|
#include "MessageRefresh.h"
|
||||||
#include "ResourcePaths.h"
|
#include "ResourcePaths.h"
|
||||||
|
|
||||||
#include "QtSearchBarButton.h"
|
#include "QtSearchBarButton.h"
|
||||||
#include "utilityQt.h"
|
|
||||||
#include "QtViewWidgetWrapper.h"
|
#include "QtViewWidgetWrapper.h"
|
||||||
|
#include "utilityQt.h"
|
||||||
|
|
||||||
QtRefreshView::QtRefreshView(ViewLayout* viewLayout)
|
QtRefreshView::QtRefreshView(ViewLayout* viewLayout)
|
||||||
: RefreshView(viewLayout)
|
: RefreshView(viewLayout)
|
||||||
@@ -25,7 +26,13 @@ QtRefreshView::QtRefreshView(ViewLayout* viewLayout)
|
|||||||
new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"refresh_view/images/refresh.png"));
|
new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"refresh_view/images/refresh.png"));
|
||||||
refreshButton->setObjectName("refresh_button");
|
refreshButton->setObjectName("refresh_button");
|
||||||
refreshButton->setToolTip("refresh");
|
refreshButton->setToolTip("refresh");
|
||||||
m_widget->connect(refreshButton, &QPushButton::clicked, [](){ MessageRefresh().dispatch(); });
|
m_widget->connect(refreshButton, &QPushButton::clicked,
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
MessageIndexingShowDialog().dispatch();
|
||||||
|
MessageRefresh().dispatch();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
layout->addWidget(refreshButton);
|
layout->addWidget(refreshButton);
|
||||||
m_widget->setLayout(layout);
|
m_widget->setLayout(layout);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ QtIndexingDialog::DialogType QtIndexingDialog::getType() const
|
|||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtIndexingDialog::setupStart(const std::vector<RefreshMode>& enabledModes)
|
void QtIndexingDialog::setupStart(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode)
|
||||||
{
|
{
|
||||||
setType(DIALOG_START_INDEXING);
|
setType(DIALOG_START_INDEXING);
|
||||||
|
|
||||||
@@ -111,6 +111,10 @@ void QtIndexingDialog::setupStart(const std::vector<RefreshMode>& enabledModes)
|
|||||||
QRadioButton* button = p.second;
|
QRadioButton* button = p.second;
|
||||||
button->setObjectName("option");
|
button->setObjectName("option");
|
||||||
button->setEnabled(false);
|
button->setEnabled(false);
|
||||||
|
if (p.first == initialMode)
|
||||||
|
{
|
||||||
|
button->setChecked(true);
|
||||||
|
}
|
||||||
modeLayout->addWidget(button);
|
modeLayout->addWidget(button);
|
||||||
connect(button, &QRadioButton::toggled, func);
|
connect(button, &QRadioButton::toggled, func);
|
||||||
}
|
}
|
||||||
@@ -132,6 +136,8 @@ void QtIndexingDialog::setupStart(const std::vector<RefreshMode>& enabledModes)
|
|||||||
m_sizeHint = QSize(350, 310);
|
m_sizeHint = QSize(350, 310);
|
||||||
|
|
||||||
finishSetup();
|
finishSetup();
|
||||||
|
|
||||||
|
emit setMode(initialMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtIndexingDialog::updateRefreshInfo(const RefreshInfo& info)
|
void QtIndexingDialog::updateRefreshInfo(const RefreshInfo& info)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
DialogType getType() const;
|
DialogType getType() const;
|
||||||
|
|
||||||
void setupStart(const std::vector<RefreshMode>& enabledModes);
|
void setupStart(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode);
|
||||||
void updateRefreshInfo(const RefreshInfo& info);
|
void updateRefreshInfo(const RefreshInfo& info);
|
||||||
|
|
||||||
void setupIndexing(bool hideable);
|
void setupIndexing(bool hideable);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "MessageDisplayBookmarks.h"
|
#include "MessageDisplayBookmarks.h"
|
||||||
#include "MessageEnteredLicense.h"
|
#include "MessageEnteredLicense.h"
|
||||||
#include "MessageFind.h"
|
#include "MessageFind.h"
|
||||||
|
#include "MessageIndexingShowDialog.h"
|
||||||
#include "MessageInterruptTasks.h"
|
#include "MessageInterruptTasks.h"
|
||||||
#include "MessageLoadProject.h"
|
#include "MessageLoadProject.h"
|
||||||
#include "MessageRefresh.h"
|
#include "MessageRefresh.h"
|
||||||
@@ -660,11 +661,13 @@ void QtMainWindow::closeWindow()
|
|||||||
|
|
||||||
void QtMainWindow::refresh()
|
void QtMainWindow::refresh()
|
||||||
{
|
{
|
||||||
|
MessageIndexingShowDialog().dispatch();
|
||||||
MessageRefresh().dispatch();
|
MessageRefresh().dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMainWindow::forceRefresh()
|
void QtMainWindow::forceRefresh()
|
||||||
{
|
{
|
||||||
|
MessageIndexingShowDialog().dispatch();
|
||||||
MessageRefresh().refreshAll().dispatch();
|
MessageRefresh().refreshAll().dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user