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