# HG changeset patch # User Michiel Broek # Date 1652467875 -7200 # Node ID ae6109192fb24358d98346415ada659b821c74b3 # Parent decbf82ae9a5019756d50682e78c44c892e7db66 First changes for brewdate date edit. diff -r decbf82ae9a5 -r ae6109192fb2 src/EditProduct.cpp --- a/src/EditProduct.cpp Thu May 12 22:41:11 2022 +0200 +++ b/src/EditProduct.cpp Fri May 13 20:51:15 2022 +0200 @@ -923,8 +923,7 @@ ui->sp_acidvolEdit->setValue(product->sparge_acid_amount); // Tab brewday. - ui->brew_startEdit->setText(product->brew_date_start.toString("dd MMM yyyy hh:mm")); - ui->brew_endEdit->setText(product->brew_date_end.toString("dd MMM yyyy hh:mm")); + updateBrewday(); ui->brew_mashphEdit->setValue(product->brew_mash_ph); ui->brew_mashphShow->setValue(product->mash_ph); ui->brew_mashsgEdit->setValue(product->brew_mash_sg); @@ -1080,6 +1079,11 @@ connect(ui->sp_acidtypeEdit, QOverload::of(&QComboBox::currentIndexChanged), this, &EditProduct::sp_type_changed); connect(ui->sp_phEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::sp_ph_changed); + /* All signals from tab Brewday */ + connect(ui->brew_startButton1, SIGNAL(clicked()), this, SLOT(brew_date_today())); + connect(ui->brew_startButton2, SIGNAL(clicked()), this, SLOT(brew_date_clear())); + connect(ui->brew_startDate, &QDateEdit::dateChanged, this, &EditProduct::brew_start_date_changed); + setStage(); ui->saveButton->setEnabled(false); diff -r decbf82ae9a5 -r ae6109192fb2 src/EditProduct.h --- a/src/EditProduct.h Thu May 12 22:41:11 2022 +0200 +++ b/src/EditProduct.h Fri May 13 20:51:15 2022 +0200 @@ -140,6 +140,11 @@ void stepph_changed(double val); void stepsg_changed(double val); void stepbrix_changed(double val); + void brew_date_clear(); + void brew_date_today(); + void brew_start_date_changed(QDate val); + void brew_end_today(); + void brew_end_date_changed(QDate val); /* Modified progress bars */ void ferment_perc_mash_valueChanged(int value); @@ -211,6 +216,7 @@ double decoctionVol(double step_volume, double step_temp, double prev_temp); void calcMash(); void adjustWaters(double factor); + void updateBrewday(); }; #endif diff -r decbf82ae9a5 -r ae6109192fb2 src/EditProductTab1.cpp --- a/src/EditProductTab1.cpp Thu May 12 22:41:11 2022 +0200 +++ b/src/EditProductTab1.cpp Fri May 13 20:51:15 2022 +0200 @@ -197,7 +197,11 @@ * See if we need to set a new stage. */ if ((stage == PROD_STAGE_PLAN) && (product->est_og > 1.005) && (product->est_color > 3) && (product->est_ibu > 3)) - stage = 1; + stage = PROD_STAGE_WAIT; + if ((stage == PROD_STAGE_WAIT) && (product->brew_date_start.date().isValid())) + stage = PROD_STAGE_BREW; + if ((stage == PROD_STAGE_BREW) && (! product->brew_date_start.date().isValid())) + stage = PROD_STAGE_WAIT; if (product->stage != stage) { qDebug() << "setStage() change state:" << prod_stages[product->stage] << "to:" << prod_stages[stage]; @@ -295,6 +299,50 @@ /* Tab 9, brewday */ ui->tabWidget->setTabEnabled(8, stage > PROD_STAGE_PLAN); + if (product->stage < PROD_STAGE_BREW) { + ui->brew_startButton1->show(); + ui->brew_startButton2->show(); + ui->brew_startDate->setReadOnly(false); + ui->brew_endButton1->hide(); + ui->brew_startLabel2->hide(); + ui->brew_endLabel->hide(); + ui->brew_endLabel2->hide(); + ui->brew_startTime->hide(); + ui->brew_endDate->hide(); + ui->brew_endTime->hide(); + } else if (product->stage == PROD_STAGE_BREW) { + ui->brew_startButton1->show(); + ui->brew_startButton2->show(); + ui->brew_startDate->setReadOnly(false); + ui->brew_startLabel2->show(); + ui->brew_endLabel->show(); + ui->brew_endLabel2->show(); + ui->brew_endButton1->show(); + ui->brew_startTime->setButtonSymbols(QAbstractSpinBox::UpDownArrows); + ui->brew_startTime->show(); + ui->brew_endDate->setButtonSymbols(QAbstractSpinBox::UpDownArrows); + ui->brew_endDate->show(); + ui->brew_endDate->setReadOnly(false); + ui->brew_endTime->setButtonSymbols(QAbstractSpinBox::UpDownArrows); + ui->brew_endTime->show(); + } else { + ui->brew_startButton1->hide(); + ui->brew_startButton2->hide(); + ui->brew_startDate->setReadOnly(true); + ui->brew_startLabel2->show(); + ui->brew_endLabel->show(); + ui->brew_endLabel2->show(); + ui->brew_endButton1->hide(); + ui->brew_startTime->setButtonSymbols(QAbstractSpinBox::NoButtons); + ui->brew_startTime->show(); + ui->brew_startTime->setReadOnly(true); + ui->brew_endDate->setButtonSymbols(QAbstractSpinBox::NoButtons); + ui->brew_endDate->show(); + ui->brew_endDate->setReadOnly(true); + ui->brew_endTime->setButtonSymbols(QAbstractSpinBox::NoButtons); + ui->brew_endTime->show(); + ui->brew_endTime->setReadOnly(true); + } /* Tab 10, fermentation */ ui->tabWidget->setTabEnabled(9, stage > PROD_STAGE_WAIT); diff -r decbf82ae9a5 -r ae6109192fb2 src/EditProductTab9.cpp --- a/src/EditProductTab9.cpp Thu May 12 22:41:11 2022 +0200 +++ b/src/EditProductTab9.cpp Fri May 13 20:51:15 2022 +0200 @@ -18,3 +18,63 @@ */ +/** + * @brief Check the state by examining the date values. + * 1. startdate and enddate invalid, planning/wait status. + * The enddate cannot be set. + * 2. startdate valid and endate invalid, brewdate is planned. + * The fase will be brew. Enable setting of enddate. + * 3. startdate valid, enddate and start and endtime can be set. + * The enddate cannot be before the startdate and not after 4 + * days from the start. + * 4. startdate and enddate and times are set and valid. Block + * the startdate setting. But only after setting a lot of + * brewdata move the fase to primary. + * + */ +void EditProduct::updateBrewday() +{ + setStage(); + + qDebug() << "updateBrewday" << product->brew_date_start.date() << product->brew_date_end.date(); + + ui->brew_startDate->setDate(product->brew_date_start.date()); + ui->brew_startTime->setTime(product->brew_date_start.time()); + ui->brew_endDate->setDate(product->brew_date_end.date()); + ui->brew_endTime->setTime(product->brew_date_end.time()); +} + + +void EditProduct::brew_date_clear() +{ + product->brew_date_start.setDate(QDate()); + ui->brew_startDate->setDate(QDate()); +} + + +void EditProduct::brew_date_today() +{ + product->brew_date_start.setDate(QDate::currentDate()); + ui->brew_startDate->setDate(QDate::currentDate()); +} + + +void EditProduct::brew_start_date_changed(QDate val) +{ + product->brew_date_start.setDate(ui->brew_startDate->nullDate()); + qDebug() << "brew_start_date_changed" << product->brew_date_start.date(); + updateBrewday(); +} + + +void EditProduct::brew_end_today() +{ +} + + +void EditProduct::brew_end_date_changed(QDate val) +{ + qDebug() << "brew_end_date_changed" << val; +} + + diff -r decbf82ae9a5 -r ae6109192fb2 ui/EditProduct.ui --- a/ui/EditProduct.ui Thu May 12 22:41:11 2022 +0200 +++ b/ui/EditProduct.ui Fri May 13 20:51:15 2022 +0200 @@ -6168,7 +6168,7 @@ - Brewday start: + Brewday plan: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -6178,7 +6178,7 @@ 10 - 40 + 70 131 20 @@ -6190,77 +6190,11 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - 150 - 10 - 141 - 23 - - - - true - - - - - - 150 - 40 - 141 - 23 - - - - true - - - - - - 300 - 10 - 28 - 22 - - - - Edit brew start - - - ... - - - - :/icons/silk/clock_edit.png:/icons/silk/clock_edit.png - - - - - - 300 - 40 - 28 - 22 - - - - Edit brew end - - - ... - - - - :/icons/silk/clock_edit.png:/icons/silk/clock_edit.png - - 10 - 90 + 200 341 241 @@ -6623,7 +6557,7 @@ 370 - 20 + 10 361 151 @@ -6873,7 +6807,7 @@ 750 - 20 + 10 361 151 @@ -7062,9 +6996,9 @@ 750 - 180 + 170 361 - 211 + 271 @@ -7206,7 +7140,7 @@ 10 - 110 + 170 151 20 @@ -7222,7 +7156,7 @@ 10 - 140 + 200 151 20 @@ -7238,7 +7172,7 @@ 10 - 170 + 230 151 20 @@ -7254,7 +7188,7 @@ 170 - 140 + 200 71 24 @@ -7288,7 +7222,7 @@ 170 - 170 + 230 71 24 @@ -7322,7 +7256,7 @@ 170 - 110 + 170 71 24 @@ -7340,25 +7274,66 @@ 3 - - - - - 10 - 340 - 341 - 121 - - - - Aeration - + + + + 10 + 140 + 151 + 20 + + + + Aeration time & speed: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 260 + 140 + 81 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + L/m + + + 0 + + + 1000.000000000000000 + + + 1.000000000000000 + + + + + + 170 + 110 + 151 + 23 + + + 10 - 20 - 141 + 110 + 151 20 @@ -7369,53 +7344,11 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - 10 - 50 - 141 - 20 - - - - Aeration time: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 10 - 80 - 141 - 20 - - - - Aeration speed: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 160 - 20 - 151 - 23 - - - - 160 - 50 + 170 + 140 81 24 @@ -7439,40 +7372,12 @@ 1.000000000000000 - - - - 160 - 80 - 81 - 24 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - L/m - - - 0 - - - 1000.000000000000000 - - - 1.000000000000000 - - - 300 - 70 + 150 + 160 28 22 @@ -7492,7 +7397,7 @@ 370 - 340 + 330 361 121 @@ -7619,7 +7524,7 @@ 370 - 180 + 170 361 151 @@ -7865,6 +7770,184 @@ + + + + 270 + 10 + 28 + 22 + + + + Set the date to today. + + + ... + + + + :/icons/silk/date.png:/icons/silk/date.png + + + + + + 150 + 10 + 111 + 24 + + + + Edit the brewdate plan or start. + + + dd-MM-yyyy + + + true + + + + + + 300 + 10 + 28 + 22 + + + + Clear planned brewdate + + + ... + + + + :/icons/silk/delete.png:/icons/silk/delete.png + + + + + + 150 + 40 + 111 + 24 + + + + Edit the brewdate start time. + + + hh:mm + + + + + + 150 + 70 + 111 + 24 + + + + Edit the brewdate end. + + + dd-MM-yyyy + + + true + + + + + + 150 + 100 + 111 + 24 + + + + Edit the brewdate end time. + + + hh:mm + + + + + + 270 + 70 + 28 + 22 + + + + Set the brewdate end date. + + + ... + + + + :/icons/silk/date.png:/icons/silk/date.png + + + + + + 10 + 100 + 131 + 20 + + + + End time: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 40 + 131 + 20 + + + + Start time: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 160 + 131 + 20 + + + + Brewlog: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + +