ui: file clearing progress

* display some progress information when clearing files
This commit is contained in:
malte_langkabel
2017-02-06 13:02:15 +01:00
parent 9177073ac3
commit be1a44a763
18 changed files with 256 additions and 94 deletions
+46 -2
View File
@@ -25,10 +25,52 @@ QtDialogView::~QtDialogView()
m_resultReady = true;
}
void QtDialogView::showProgressDialog(const std::string& title, const std::string& message)
void QtDialogView::showStatusDialog(const std::string& title, const std::string& message)
{
MessageStatus(title + ": " + message, false, true).dispatch();
m_onQtThread(
[=]()
{
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
if (!window || window->getType() != QtIndexingDialog::DIALOG_STATUS)
{
m_windowStack.clearWindows();
window = createWindow<QtIndexingDialog>();
window->setupStatus();
}
window->updateTitle(title.c_str());
window->updateMessage(message.c_str());
setUIBlocked(true);
}
);
}
void QtDialogView::hideStatusDialog()
{
MessageStatus("", false, false).dispatch();
m_onQtThread(
[=]()
{
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
if (window && window->getType() == QtIndexingDialog::DIALOG_STATUS)
{
m_windowStack.popWindow();
}
setUIBlocked(false);
}
);
}
void QtDialogView::showProgressDialog(const std::string& title, const std::string& message, int progress)
{
MessageStatus(title + ": " + message + " [" + std::to_string(progress) + "%]", false, true).dispatch();
m_onQtThread(
[=]()
{
@@ -43,6 +85,7 @@ void QtDialogView::showProgressDialog(const std::string& title, const std::strin
window->updateTitle(title.c_str());
window->updateMessage(message.c_str());
window->updateProgress(progress);
setUIBlocked(true);
}
@@ -67,6 +110,7 @@ void QtDialogView::hideProgressDialog()
);
}
DialogView::IndexMode QtDialogView::startIndexingDialog(
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh)
{
@@ -211,7 +255,7 @@ void QtDialogView::handleMessage(MessageInterruptTasks* message)
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
if (window && window->getType() == QtIndexingDialog::DIALOG_INDEXING)
{
showProgressDialog("Interrupting Indexing", "Waiting for indexer\nthreads to finish");
showStatusDialog("Interrupting Indexing", "Waiting for indexer\nthreads to finish");
}
}
);
+8 -5
View File
@@ -28,13 +28,16 @@ public:
QtDialogView(QtMainWindow* mainWindow, StorageAccess* storageAccess);
virtual ~QtDialogView();
void showProgressDialog(const std::string& title, const std::string& message) override;
void hideProgressDialog() override;
virtual void showStatusDialog(const std::string& title, const std::string& message) override;
virtual void hideStatusDialog() override;
DialogView::IndexMode startIndexingDialog(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress) override;
virtual void hideProgressDialog() override;
virtual DialogView::IndexMode startIndexingDialog(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
bool forceRefresh, bool needsFullRefresh) override;
void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath) override;
void finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo) override;
virtual void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath) override;
virtual void finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo) override;
int confirm(const std::string& message, const std::vector<std::string>& options) override;
+53 -26
View File
@@ -104,27 +104,6 @@ void QtIndexingDialog::setupStart(
finishSetup();
}
void QtIndexingDialog::setupProgress()
{
setType(DIALOG_PROGRESS);
QBoxLayout* layout = createLayout();
addTopAndProgressBar(0.5);
addTitle("Clearing", layout);
addMessageLabel(layout);
layout->addStretch();
m_sizeHint = QSize(350, 280);
m_progressBar->showUnknownProgressAnimated();
setCancelAble(false);
finishSetup();
}
void QtIndexingDialog::setupIndexing()
{
setType(DIALOG_INDEXING);
@@ -192,6 +171,47 @@ void QtIndexingDialog::setupReport(size_t fileCount, size_t totalFileCount, floa
finishSetup();
}
void QtIndexingDialog::setupStatus()
{
setType(DIALOG_STATUS);
QBoxLayout* layout = createLayout();
addTopAndProgressBar(0.5);
addTitle("Status", layout);
addMessageLabel(layout);
layout->addStretch();
m_sizeHint = QSize(350, 280);
m_progressBar->showUnknownProgressAnimated();
setCancelAble(false);
finishSetup();
}
void QtIndexingDialog::setupProgress()
{
setType(DIALOG_PROGRESS);
QBoxLayout* layout = createLayout();
addTopAndProgressBar(0.5);
addTitle("Progress", layout);
addPercentLabel(layout);
addMessageLabel(layout);
layout->addStretch();
m_sizeHint = QSize(350, 280);
setCancelAble(false);
finishSetup();
}
void QtIndexingDialog::updateMessage(QString message)
{
if (m_messageLabel)
@@ -200,20 +220,27 @@ void QtIndexingDialog::updateMessage(QString message)
}
}
void QtIndexingDialog::updateProgress(int progress)
{
int percent = std::min(std::max(progress, 0), 100);
m_progressBar->showProgress(percent);
m_percentLabel->setText(QString::number(percent) + "% Progress");
setGeometries();
}
void QtIndexingDialog::updateIndexingProgress(size_t fileCount, size_t totalFileCount, std::string sourcePath)
{
updateMessage(QString::number(fileCount) + "/" + QString::number(totalFileCount) + " File" + (totalFileCount > 1 ? "s" : ""));
size_t percent = 0;
int progress = 0;
if (totalFileCount > 0)
{
percent = fileCount * 100 / totalFileCount;
progress = fileCount * 100 / totalFileCount;
}
m_progressBar->showProgress(percent);
m_percentLabel->setText(QString::number(percent) + "% Progress");
m_sourcePath = QString::fromStdString(sourcePath);
setGeometries();
updateProgress(progress);
}
void QtIndexingDialog::updateErrorCount(size_t errorCount, size_t fatalCount)
+5 -1
View File
@@ -18,6 +18,7 @@ public:
enum DialogType
{
DIALOG_MESSAGE,
DIALOG_STATUS,
DIALOG_PROGRESS,
DIALOG_INDEXING
};
@@ -29,11 +30,14 @@ public:
void setupStart(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback);
void setupProgress();
void setupIndexing();
void setupReport(size_t fileCount, size_t totalFileCount, float time);
void setupStatus();
void setupProgress();
void updateMessage(QString message);
void updateProgress(int progress);
void updateIndexingProgress(size_t fileCount, size_t totalFileCount, std::string sourcePath);
void updateErrorCount(size_t errorCount, size_t fatalCount);