Add progress bar to search tab

This commit is contained in:
LoudSnorer 2023-02-23 16:00:40 -05:00
parent 7e8e553e0e
commit 33cf3f104f
2 changed files with 33 additions and 18 deletions

View File

@ -13,6 +13,7 @@
#include <QWidget> #include <QWidget>
#include <QTabWidget> #include <QTabWidget>
#include <QProgressBar>
#include <QMessageBox> #include <QMessageBox>
#include <QAbstractButton> #include <QAbstractButton>
#include <QPixmap> #include <QPixmap>
@ -136,6 +137,7 @@ void DailySearchTab::createUi() {
summaryProgress = new QLabel(this); summaryProgress = new QLabel(this);
summaryFound = new QLabel(this); summaryFound = new QLabel(this);
summaryMinMax = new QLabel(this); summaryMinMax = new QLabel(this);
guiProgressBar = new QProgressBar(this);
guiDisplayTable = new QTableWidget(this); guiDisplayTable = new QTableWidget(this);
searchTabLayout ->addWidget(helpButton); searchTabLayout ->addWidget(helpButton);
@ -171,6 +173,7 @@ void DailySearchTab::createUi() {
summaryLayout ->addWidget(summaryMinMax); summaryLayout ->addWidget(summaryMinMax);
searchTabLayout ->addLayout(summaryLayout); searchTabLayout ->addLayout(summaryLayout);
searchTabLayout ->addWidget(guiProgressBar);
searchTabLayout ->addWidget(guiDisplayTable); searchTabLayout ->addWidget(guiDisplayTable);
// End of UI creatation // End of UI creatation
@ -181,9 +184,10 @@ void DailySearchTab::createUi() {
searchTabWidget ->setFont(baseFont); searchTabWidget ->setFont(baseFont);
helpButton ->setFont(baseFont); helpButton ->setFont(baseFont);
helpButton ->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); //helpButton ->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
helpButton ->setStyleSheet("QPushButton { border:none ;}"); //helpButton ->setStyleSheet(QString("QPushButton:flat {border: none }"));
//helpButton ->setStyleSheet(" text-align:left ; padding: 4;border: 1px"); //helpButton ->setStyleSheet(" text-align:left ; padding: 4;border: 1px");
helpInfo ->setText(helpStr()); helpInfo ->setText(helpStr());
helpInfo ->setFont(baseFont); helpInfo ->setFont(baseFont);
helpInfo ->setStyleSheet(" text-align:left ; padding: 4;border: 1px"); helpInfo ->setStyleSheet(" text-align:left ; padding: 4;border: 1px");
@ -478,7 +482,8 @@ QString DailySearchTab::valueToString(int value, QString defaultValue) {
case minutesToMs: case minutesToMs:
return formatTime(value); return formatTime(value);
break; break;
case whole: case displayWhole:
case opWhole:
return QString().setNum(value); return QString().setNum(value);
break; break;
case displayString: case displayString:
@ -513,13 +518,7 @@ void DailySearchTab::on_selectOperationCombo_activated(int index) {
void DailySearchTab::on_selectCommandCombo_activated(int index) { void DailySearchTab::on_selectCommandCombo_activated(int index) {
// here to select new search criteria // here to select new search criteria
// must reset all variables and label, button, etc // must reset all variables and label, button, etc
on_clearButton_clicked() ;
selectDouble->hide();
selectDouble->setDecimals(3);
selectInteger->hide();
selectString->hide();
selectUnits->hide();
selectOperationButton->hide();
valueMode = notUsed; valueMode = notUsed;
selectValue = 0; selectValue = 0;
@ -544,7 +543,7 @@ void DailySearchTab::on_selectCommandCombo_activated(int index) {
horizontalHeader1->setText(tr("Number Disabled Session\nJumps to Notes")); horizontalHeader1->setText(tr("Number Disabled Session\nJumps to Notes"));
nextTab = TW_DETAILED ; nextTab = TW_DETAILED ;
selectInteger->setValue(0); selectInteger->setValue(0);
setSelectOperation(OP_GT,whole); setSelectOperation(OP_NO_PARMS,displayWhole);
break; break;
case OT_NOTES : case OT_NOTES :
horizontalHeader1->setText(tr("Note\nJumps to Notes")); horizontalHeader1->setText(tr("Note\nJumps to Notes"));
@ -586,7 +585,7 @@ void DailySearchTab::on_selectCommandCombo_activated(int index) {
case OT_SESSIONS_QTY : case OT_SESSIONS_QTY :
horizontalHeader1->setText(tr("Number of Sessions\nJumps to Details")); horizontalHeader1->setText(tr("Number of Sessions\nJumps to Details"));
nextTab = TW_DETAILED ; nextTab = TW_DETAILED ;
setSelectOperation(OP_GT,whole); setSelectOperation(OP_GT,opWhole);
selectInteger->setRange(0,999); selectInteger->setRange(0,999);
selectInteger->setValue(1); selectInteger->setValue(1);
break; break;
@ -601,7 +600,7 @@ void DailySearchTab::on_selectCommandCombo_activated(int index) {
// Have an Event // Have an Event
horizontalHeader1->setText(tr("Number of events\nJumps to Events")); horizontalHeader1->setText(tr("Number of events\nJumps to Events"));
nextTab = TW_EVENTS ; nextTab = TW_EVENTS ;
setSelectOperation(OP_GT,whole); setSelectOperation(OP_GT,opWhole);
selectInteger->setValue(0); selectInteger->setValue(0);
break; break;
} }
@ -784,6 +783,8 @@ bool DailySearchTab::find(QDate& date,Day* day)
void DailySearchTab::search(QDate date) void DailySearchTab::search(QDate date)
{ {
guiProgressBar->show();
statusProgress->show();
guiDisplayTable->clearContents(); guiDisplayTable->clearContents();
for (int index=0; index<guiDisplayTable->rowCount();index++) { for (int index=0; index<guiDisplayTable->rowCount();index++) {
guiDisplayTable->setRowHidden(index,true); guiDisplayTable->setRowHidden(index,true);
@ -806,6 +807,7 @@ void DailySearchTab::search(QDate date)
break; break;
} }
daysSearched++; daysSearched++;
guiProgressBar->setValue(daysSearched);
if (date.isValid()) { if (date.isValid()) {
// use date // use date
// find and add // find and add
@ -976,8 +978,9 @@ void DailySearchTab::setSelectOperation(OpCode opCode,ValueMode mode) {
selectDouble->setRange(0,9999); selectDouble->setRange(0,9999);
selectDouble->show(); selectDouble->show();
break; break;
case whole: case opWhole:
selectInteger->show(); selectInteger->show();
case displayWhole:
break; break;
case opString: case opString:
selectOperationButton->show(); selectOperationButton->show();
@ -1026,6 +1029,8 @@ void DailySearchTab::on_clearButton_clicked()
summaryFound->hide(); summaryFound->hide();
summaryMinMax->hide(); summaryMinMax->hide();
guiProgressBar->hide();
// clear display table && hide // clear display table && hide
guiDisplayTable->horizontalHeader()->hide(); guiDisplayTable->horizontalHeader()->hide();
for (int index=0; index<guiDisplayTable->rowCount();index++) { for (int index=0; index<guiDisplayTable->rowCount();index++) {
@ -1040,8 +1045,7 @@ void DailySearchTab::on_startButton_clicked()
if (startButtonMode) { if (startButtonMode) {
// have start mode // have start mode
// must set up search from the latest date and go to the first date. // must set up search from the latest date and go to the first date.
// set up variables for multiple passes.
//startButton->setText("Continue Search");
search (lastDate ); search (lastDate );
startButtonMode=false; startButtonMode=false;
} else { } else {
@ -1115,7 +1119,8 @@ void DailySearchTab::criteriaChanged() {
case hoursToMs: case hoursToMs:
selectValue = (int)(selectDouble->value()*3600000.0); //convert to ms selectValue = (int)(selectDouble->value()*3600000.0); //convert to ms
break; break;
case whole: case displayWhole:
case opWhole:
selectValue = selectInteger->value();; selectValue = selectInteger->value();;
break; break;
case opString: case opString:
@ -1156,6 +1161,14 @@ void DailySearchTab::criteriaChanged() {
daysSearched=0; daysSearched=0;
startButtonMode=true; startButtonMode=true;
//initialize progress bar.
guiProgressBar->hide();
guiProgressBar->setMinimum(0);
guiProgressBar->setMaximum(daysTotal);
guiProgressBar->setTextVisible(true);
//guiProgressBar->setTextVisible(false);
guiProgressBar->setMaximumHeight(15);
guiProgressBar->reset();
} }
// inputs character string. // inputs character string.

View File

@ -20,6 +20,7 @@
#include "SleepLib/common.h" #include "SleepLib/common.h"
class QWidget ; class QWidget ;
class QProgressBar ;
class QHBoxLayout ; class QHBoxLayout ;
class QVBoxLayout ; class QVBoxLayout ;
class QPushButton ; class QPushButton ;
@ -57,7 +58,7 @@ private:
const int passDisplayLimit = 30; const int passDisplayLimit = 30;
const int stringDisplayLen = 80; const int stringDisplayLen = 80;
enum ValueMode { invalidValueMode, notUsed , minutesToMs ,hoursToMs, hundredths , whole , opString, displayString}; enum ValueMode { invalidValueMode, notUsed , minutesToMs ,hoursToMs, hundredths , opWhole , displayWhole , opString, displayString};
enum OpCode { enum OpCode {
//DO NOT CHANGE NUMERIC OP CODES because THESE VALUES impact compare operations. //DO NOT CHANGE NUMERIC OP CODES because THESE VALUES impact compare operations.
@ -102,6 +103,7 @@ enum OpCode {
QPushButton* startButton; QPushButton* startButton;
QPushButton* clearButton; QPushButton* clearButton;
QProgressBar* guiProgressBar;
QTableWidget* guiDisplayTable; QTableWidget* guiDisplayTable;
QTableWidgetItem* horizontalHeader0; QTableWidgetItem* horizontalHeader0;
QTableWidgetItem* horizontalHeader1; QTableWidgetItem* horizontalHeader1;