logic: Added full refresh checkbox to indexing start dialog
* Checkbox allows for switching between refresh and full refresh * Renamed menu option Force Refresh to Full Refresh * Checkbox is not visible when project needs to be fully refreshed
This commit is contained in:
@@ -67,19 +67,23 @@ void QtDialogView::hideProgressDialog()
|
||||
);
|
||||
}
|
||||
|
||||
bool QtDialogView::startIndexingDialog(size_t cleanFileCount, size_t indexFileCount)
|
||||
DialogView::IndexMode QtDialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh)
|
||||
{
|
||||
bool result = false;
|
||||
IndexMode result = INDEX_ABORT;
|
||||
m_resultReady = false;
|
||||
|
||||
m_onQtThread(
|
||||
[=, &result]()
|
||||
{
|
||||
QtIndexingDialog* window = createWindow<QtIndexingDialog>();
|
||||
window->setupStart(cleanFileCount, indexFileCount,
|
||||
[&](bool start)
|
||||
window->setupStart(cleanFileCount, indexFileCount, totalFileCount, forceRefresh, needsFullRefresh,
|
||||
[&](bool start, bool fullRefresh)
|
||||
{
|
||||
result = start;
|
||||
if (start)
|
||||
{
|
||||
result = (!fullRefresh && !needsFullRefresh ? INDEX_REFRESH : INDEX_FULL);
|
||||
}
|
||||
m_resultReady = true;
|
||||
|
||||
setUIBlocked(false);
|
||||
|
||||
@@ -31,7 +31,8 @@ public:
|
||||
void showProgressDialog(const std::string& title, const std::string& message) override;
|
||||
void hideProgressDialog() override;
|
||||
|
||||
bool startIndexingDialog(size_t cleanFileCount, size_t indexFileCount) override;
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "qt/window/QtIndexingDialog.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <QPainter>
|
||||
@@ -21,8 +22,9 @@ QtIndexingDialog::QtIndexingDialog(QWidget* parent)
|
||||
, m_messageLabel(nullptr)
|
||||
, m_filePathLabel(nullptr)
|
||||
, m_errorLabel(nullptr)
|
||||
, m_checkBox(nullptr)
|
||||
, m_sizeHint(QSize(450, 450))
|
||||
, m_callback([](bool){})
|
||||
, m_callback([](bool, bool){})
|
||||
{
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
setSizeGripStyle(false);
|
||||
@@ -38,26 +40,60 @@ QtIndexingDialog::DialogType QtIndexingDialog::getType() const
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void QtIndexingDialog::setupStart(size_t cleanFileCount, size_t indexFileCount, std::function<void(bool)> callback)
|
||||
void QtIndexingDialog::setupStart(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback)
|
||||
{
|
||||
QBoxLayout* layout = createLayout();
|
||||
|
||||
addTitle("Start Indexing", layout);
|
||||
layout->addSpacing(5);
|
||||
|
||||
if (cleanFileCount)
|
||||
{
|
||||
QLabel* cleanLabel = new QLabel("Clear: " + QString::number(cleanFileCount) + " File" + (cleanFileCount > 1 ? "s" : ""));
|
||||
cleanLabel->setObjectName("message");
|
||||
cleanLabel->setAlignment(Qt::AlignRight);
|
||||
layout->addWidget(cleanLabel, 0, Qt::AlignRight);
|
||||
}
|
||||
QLabel* clearLabel = createMessageLabel(layout);
|
||||
QLabel* indexLabel = createMessageLabel(layout);
|
||||
QLabel* fullLabel = createMessageLabel(layout);
|
||||
|
||||
addMessageLabel(layout);
|
||||
updateMessage("Index: " + QString::number(indexFileCount) + " File" + (indexFileCount > 1 ? "s" : ""));
|
||||
clearLabel->setText("Clear: " + QString::number(cleanFileCount) + " File" + (cleanFileCount != 1 ? "s" : ""));
|
||||
indexLabel->setText("Index: " + QString::number(indexFileCount) + " File" + (indexFileCount != 1 ? "s" : ""));
|
||||
fullLabel->setText("Index: " + QString::number(totalFileCount) + " File" + (totalFileCount != 1 ? "s" : ""));
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
if (needsFullRefresh)
|
||||
{
|
||||
clearLabel->hide();
|
||||
indexLabel->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_checkBox = new QCheckBox("full refresh", this);
|
||||
m_checkBox->setObjectName("message");
|
||||
|
||||
connect(m_checkBox, static_cast<void(QCheckBox::*)(bool)>(&QCheckBox::toggled),
|
||||
[=](bool checked = false)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
clearLabel->hide();
|
||||
indexLabel->hide();
|
||||
fullLabel->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
clearLabel->show();
|
||||
indexLabel->show();
|
||||
fullLabel->hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
m_checkBox->setChecked(!forceRefresh);
|
||||
m_checkBox->setChecked(forceRefresh);
|
||||
|
||||
layout->addWidget(m_checkBox, 0, Qt::AlignRight);
|
||||
layout->addSpacing(30);
|
||||
}
|
||||
|
||||
addButtons(layout);
|
||||
updateNextButton("Start");
|
||||
updateCloseButton("Cancel");
|
||||
@@ -211,7 +247,7 @@ void QtIndexingDialog::handleNext()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(true);
|
||||
m_callback(true, !m_checkBox || m_checkBox->isChecked());
|
||||
}
|
||||
|
||||
QtWindow::handleNext();
|
||||
@@ -221,7 +257,7 @@ void QtIndexingDialog::handleClose()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(false);
|
||||
m_callback(false, false);
|
||||
}
|
||||
|
||||
if (m_type == DIALOG_INDEXING)
|
||||
@@ -308,6 +344,16 @@ void QtIndexingDialog::addMessageLabel(QBoxLayout* layout)
|
||||
layout->addWidget(m_messageLabel, 0, Qt::AlignRight);
|
||||
}
|
||||
|
||||
QLabel* QtIndexingDialog::createMessageLabel(QBoxLayout* layout)
|
||||
{
|
||||
QLabel* label = new QLabel();
|
||||
label->setObjectName("message");
|
||||
label->setAlignment(Qt::AlignRight);
|
||||
label->setWordWrap(true);
|
||||
layout->addWidget(label, 0, Qt::AlignRight);
|
||||
return label;
|
||||
}
|
||||
|
||||
void QtIndexingDialog::addFilePathLabel(QBoxLayout* layout)
|
||||
{
|
||||
m_filePathLabel = new QLabel();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "qt/window/QtWindow.h"
|
||||
|
||||
class QCheckBox;
|
||||
class QLabel;
|
||||
class QtProgressBar;
|
||||
|
||||
@@ -26,7 +27,8 @@ public:
|
||||
|
||||
DialogType getType() const;
|
||||
|
||||
void setupStart(size_t cleanFileCount, size_t indexFileCount, std::function<void(bool)> callback);
|
||||
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);
|
||||
@@ -50,6 +52,7 @@ private:
|
||||
|
||||
void addPercentLabel(QBoxLayout* layout);
|
||||
void addMessageLabel(QBoxLayout* layout);
|
||||
QLabel* createMessageLabel(QBoxLayout* layout);
|
||||
void addFilePathLabel(QBoxLayout* layout);
|
||||
void addErrorLabel(QBoxLayout* layout);
|
||||
|
||||
@@ -69,10 +72,11 @@ private:
|
||||
QLabel* m_messageLabel;
|
||||
QLabel* m_filePathLabel;
|
||||
QPushButton* m_errorLabel;
|
||||
QCheckBox* m_checkBox;
|
||||
|
||||
QSize m_sizeHint;
|
||||
|
||||
std::function<void(bool)> m_callback;
|
||||
std::function<void(bool, bool)> m_callback;
|
||||
QString m_sourcePath;
|
||||
};
|
||||
|
||||
|
||||
@@ -593,13 +593,13 @@ void QtMainWindow::setupEditMenu()
|
||||
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
|
||||
{
|
||||
m_trialDisabledActions.push_back(
|
||||
menu->addAction(tr("&Force Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::Key_F5))
|
||||
menu->addAction(tr("&Full Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::Key_F5))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_trialDisabledActions.push_back(menu->addAction(
|
||||
tr("&Force Refresh"),
|
||||
tr("&Full Refresh"),
|
||||
this,
|
||||
SLOT(forceRefresh()),
|
||||
QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_R)
|
||||
|
||||
Reference in New Issue
Block a user