Fri, 13 May 2022 20:51:15 +0200
First changes for brewdate date edit.
src/EditProduct.cpp | file | annotate | diff | comparison | revisions | |
src/EditProduct.h | file | annotate | diff | comparison | revisions | |
src/EditProductTab1.cpp | file | annotate | diff | comparison | revisions | |
src/EditProductTab9.cpp | file | annotate | diff | comparison | revisions | |
ui/EditProduct.ui | file | annotate | diff | comparison | revisions |
--- 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<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::sp_type_changed); connect(ui->sp_phEdit, QOverload<double>::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);
--- 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
--- 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);
--- 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; +} + +
--- 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 @@ </rect> </property> <property name="text"> - <string>Brewday start:</string> + <string>Brewday plan:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -6178,7 +6178,7 @@ <property name="geometry"> <rect> <x>10</x> - <y>40</y> + <y>70</y> <width>131</width> <height>20</height> </rect> @@ -6190,77 +6190,11 @@ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> - <widget class="QLineEdit" name="brew_startEdit"> - <property name="geometry"> - <rect> - <x>150</x> - <y>10</y> - <width>141</width> - <height>23</height> - </rect> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - <widget class="QLineEdit" name="brew_endEdit"> - <property name="geometry"> - <rect> - <x>150</x> - <y>40</y> - <width>141</width> - <height>23</height> - </rect> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - <widget class="QToolButton" name="brew_startButton"> - <property name="geometry"> - <rect> - <x>300</x> - <y>10</y> - <width>28</width> - <height>22</height> - </rect> - </property> - <property name="toolTip"> - <string>Edit brew start</string> - </property> - <property name="text"> - <string>...</string> - </property> - <property name="icon"> - <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> - <normaloff>:/icons/silk/clock_edit.png</normaloff>:/icons/silk/clock_edit.png</iconset> - </property> - </widget> - <widget class="QToolButton" name="brew_endButton"> - <property name="geometry"> - <rect> - <x>300</x> - <y>40</y> - <width>28</width> - <height>22</height> - </rect> - </property> - <property name="toolTip"> - <string>Edit brew end</string> - </property> - <property name="text"> - <string>...</string> - </property> - <property name="icon"> - <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> - <normaloff>:/icons/silk/clock_edit.png</normaloff>:/icons/silk/clock_edit.png</iconset> - </property> - </widget> <widget class="QGroupBox" name="brew_mashBox"> <property name="geometry"> <rect> <x>10</x> - <y>90</y> + <y>200</y> <width>341</width> <height>241</height> </rect> @@ -6623,7 +6557,7 @@ <property name="geometry"> <rect> <x>370</x> - <y>20</y> + <y>10</y> <width>361</width> <height>151</height> </rect> @@ -6873,7 +6807,7 @@ <property name="geometry"> <rect> <x>750</x> - <y>20</y> + <y>10</y> <width>361</width> <height>151</height> </rect> @@ -7062,9 +6996,9 @@ <property name="geometry"> <rect> <x>750</x> - <y>180</y> + <y>170</y> <width>361</width> - <height>211</height> + <height>271</height> </rect> </property> <property name="title"> @@ -7206,7 +7140,7 @@ <property name="geometry"> <rect> <x>10</x> - <y>110</y> + <y>170</y> <width>151</width> <height>20</height> </rect> @@ -7222,7 +7156,7 @@ <property name="geometry"> <rect> <x>10</x> - <y>140</y> + <y>200</y> <width>151</width> <height>20</height> </rect> @@ -7238,7 +7172,7 @@ <property name="geometry"> <rect> <x>10</x> - <y>170</y> + <y>230</y> <width>151</width> <height>20</height> </rect> @@ -7254,7 +7188,7 @@ <property name="geometry"> <rect> <x>170</x> - <y>140</y> + <y>200</y> <width>71</width> <height>24</height> </rect> @@ -7288,7 +7222,7 @@ <property name="geometry"> <rect> <x>170</x> - <y>170</y> + <y>230</y> <width>71</width> <height>24</height> </rect> @@ -7322,7 +7256,7 @@ <property name="geometry"> <rect> <x>170</x> - <y>110</y> + <y>170</y> <width>71</width> <height>24</height> </rect> @@ -7340,25 +7274,66 @@ <number>3</number> </property> </widget> - </widget> - <widget class="QGroupBox" name="brew_aerationBox"> - <property name="geometry"> - <rect> - <x>10</x> - <y>340</y> - <width>341</width> - <height>121</height> - </rect> - </property> - <property name="title"> - <string>Aeration</string> - </property> + <widget class="QLabel" name="brew_aertimeLabel"> + <property name="geometry"> + <rect> + <x>10</x> + <y>140</y> + <width>151</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Aeration time & speed:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QDoubleSpinBox" name="brew_aerspeedEdit"> + <property name="geometry"> + <rect> + <x>260</x> + <y>140</y> + <width>81</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="accelerated"> + <bool>true</bool> + </property> + <property name="suffix"> + <string> L/m</string> + </property> + <property name="decimals"> + <number>0</number> + </property> + <property name="maximum"> + <double>1000.000000000000000</double> + </property> + <property name="singleStep"> + <double>1.000000000000000</double> + </property> + </widget> + <widget class="QComboBox" name="brew_aerwithEdit"> + <property name="geometry"> + <rect> + <x>170</x> + <y>110</y> + <width>151</width> + <height>23</height> + </rect> + </property> + </widget> <widget class="QLabel" name="brew_aerwithLabel"> <property name="geometry"> <rect> <x>10</x> - <y>20</y> - <width>141</width> + <y>110</y> + <width>151</width> <height>20</height> </rect> </property> @@ -7369,53 +7344,11 @@ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> - <widget class="QLabel" name="brew_aertimeLabel"> - <property name="geometry"> - <rect> - <x>10</x> - <y>50</y> - <width>141</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string>Aeration time:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - <widget class="QLabel" name="brew_aerspeedLabel"> - <property name="geometry"> - <rect> - <x>10</x> - <y>80</y> - <width>141</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string>Aeration speed:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - <widget class="QComboBox" name="brew_aerwithEdit"> - <property name="geometry"> - <rect> - <x>160</x> - <y>20</y> - <width>151</width> - <height>23</height> - </rect> - </property> - </widget> <widget class="QDoubleSpinBox" name="brew_aertimeEdit"> <property name="geometry"> <rect> - <x>160</x> - <y>50</y> + <x>170</x> + <y>140</y> <width>81</width> <height>24</height> </rect> @@ -7439,40 +7372,12 @@ <double>1.000000000000000</double> </property> </widget> - <widget class="QDoubleSpinBox" name="brew_aerspeedEdit"> - <property name="geometry"> - <rect> - <x>160</x> - <y>80</y> - <width>81</width> - <height>24</height> - </rect> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="accelerated"> - <bool>true</bool> - </property> - <property name="suffix"> - <string> L/m</string> - </property> - <property name="decimals"> - <number>0</number> - </property> - <property name="maximum"> - <double>1000.000000000000000</double> - </property> - <property name="singleStep"> - <double>1.000000000000000</double> - </property> - </widget> </widget> <widget class="QToolButton" name="brew_logButton"> <property name="geometry"> <rect> - <x>300</x> - <y>70</y> + <x>150</x> + <y>160</y> <width>28</width> <height>22</height> </rect> @@ -7492,7 +7397,7 @@ <property name="geometry"> <rect> <x>370</x> - <y>340</y> + <y>330</y> <width>361</width> <height>121</height> </rect> @@ -7619,7 +7524,7 @@ <property name="geometry"> <rect> <x>370</x> - <y>180</y> + <y>170</y> <width>361</width> <height>151</height> </rect> @@ -7865,6 +7770,184 @@ </property> </widget> </widget> + <widget class="QToolButton" name="brew_startButton1"> + <property name="geometry"> + <rect> + <x>270</x> + <y>10</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Set the date to today.</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> + <normaloff>:/icons/silk/date.png</normaloff>:/icons/silk/date.png</iconset> + </property> + </widget> + <widget class="NullDateEdit" name="brew_startDate"> + <property name="geometry"> + <rect> + <x>150</x> + <y>10</y> + <width>111</width> + <height>24</height> + </rect> + </property> + <property name="toolTip"> + <string>Edit the brewdate plan or start.</string> + </property> + <property name="displayFormat"> + <string>dd-MM-yyyy</string> + </property> + <property name="calendarPopup"> + <bool>true</bool> + </property> + </widget> + <widget class="QToolButton" name="brew_startButton2"> + <property name="geometry"> + <rect> + <x>300</x> + <y>10</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Clear planned brewdate</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> + <normaloff>:/icons/silk/delete.png</normaloff>:/icons/silk/delete.png</iconset> + </property> + </widget> + <widget class="QTimeEdit" name="brew_startTime"> + <property name="geometry"> + <rect> + <x>150</x> + <y>40</y> + <width>111</width> + <height>24</height> + </rect> + </property> + <property name="toolTip"> + <string>Edit the brewdate start time.</string> + </property> + <property name="displayFormat"> + <string>hh:mm</string> + </property> + </widget> + <widget class="NullDateEdit" name="brew_endDate"> + <property name="geometry"> + <rect> + <x>150</x> + <y>70</y> + <width>111</width> + <height>24</height> + </rect> + </property> + <property name="toolTip"> + <string>Edit the brewdate end.</string> + </property> + <property name="displayFormat"> + <string>dd-MM-yyyy</string> + </property> + <property name="calendarPopup"> + <bool>true</bool> + </property> + </widget> + <widget class="QTimeEdit" name="brew_endTime"> + <property name="geometry"> + <rect> + <x>150</x> + <y>100</y> + <width>111</width> + <height>24</height> + </rect> + </property> + <property name="toolTip"> + <string>Edit the brewdate end time.</string> + </property> + <property name="displayFormat"> + <string>hh:mm</string> + </property> + </widget> + <widget class="QToolButton" name="brew_endButton1"> + <property name="geometry"> + <rect> + <x>270</x> + <y>70</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Set the brewdate end date.</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> + <normaloff>:/icons/silk/date.png</normaloff>:/icons/silk/date.png</iconset> + </property> + </widget> + <widget class="QLabel" name="brew_endLabel2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>100</y> + <width>131</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>End time:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="brew_startLabel2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>131</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Start time:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="brew_logLabel"> + <property name="geometry"> + <rect> + <x>10</x> + <y>160</y> + <width>131</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Brewlog:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> </widget> <widget class="QWidget" name="ferment"> <attribute name="icon">