Wed, 15 Jun 2022 14:48:10 +0200
Fixed missing settings from the Miscs and Hops editors.
src/EditHop.cpp | file | annotate | diff | comparison | revisions | |
src/EditHop.h | file | annotate | diff | comparison | revisions | |
src/EditMisc.cpp | file | annotate | diff | comparison | revisions | |
src/EditMisc.h | file | annotate | diff | comparison | revisions | |
ui/EditHop.ui | file | annotate | diff | comparison | revisions | |
ui/EditMisc.ui | file | annotate | diff | comparison | revisions |
--- a/src/EditHop.cpp Wed Jun 15 10:54:04 2022 +0200 +++ b/src/EditHop.cpp Wed Jun 15 14:48:10 2022 +0200 @@ -97,7 +97,11 @@ connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed); connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed); connect(ui->prodEdit, &QDateEdit::dateChanged, this, &EditHop::is_changed); + connect(ui->prodButton1, SIGNAL(clicked()), this, SLOT(prod_date_today())); + connect(ui->prodButton2, SIGNAL(clicked()), this, SLOT(prod_date_clear())); connect(ui->thtEdit, &QDateEdit::dateChanged, this, &EditHop::is_changed); + connect(ui->thtButton1, SIGNAL(clicked()), this, SLOT(tht_date_today())); + connect(ui->thtButton2, SIGNAL(clicked()), this, SLOT(tht_date_clear())); connect(ui->oilEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed); ui->saveButton->setEnabled(false); @@ -257,3 +261,32 @@ this->close(); this->setResult(1); } + + +void EditHop::prod_date_clear() +{ + ui->prodEdit->setDate(QDate()); + is_changed(); +} + + +void EditHop::prod_date_today() +{ + ui->prodEdit->setDate(QDate::currentDate()); + is_changed(); +} + + +void EditHop::tht_date_clear() +{ + ui->thtEdit->setDate(QDate()); + is_changed(); +} + + +void EditHop::tht_date_today() +{ + ui->thtEdit->setDate(QDate::currentDate()); + is_changed(); +} +
--- a/src/EditHop.h Wed Jun 15 10:54:04 2022 +0200 +++ b/src/EditHop.h Wed Jun 15 14:48:10 2022 +0200 @@ -24,6 +24,10 @@ void on_quitButton_clicked(); void on_deleteButton_clicked(); void is_changed(); + void prod_date_clear(); + void prod_date_today(); + void tht_date_clear(); + void tht_date_today(); private: Ui::EditHop *ui;
--- a/src/EditMisc.cpp Wed Jun 15 10:54:04 2022 +0200 +++ b/src/EditMisc.cpp Wed Jun 15 14:48:10 2022 +0200 @@ -50,24 +50,24 @@ query.exec(); query.next(); - ui->nameEdit->setText(query.value(1).toString()); - ui->typeEdit->setCurrentIndex(query.value(2).toInt()); - ui->useEdit->setCurrentIndex(query.value(3).toInt()); - ui->timeEdit->setValue(query.value(4).toInt()); - ui->isweightEdit->setChecked(query.value(5).toInt() ? true:false); - ui->useforEdit->setPlainText(query.value(6).toString()); - ui->notesEdit->setPlainText(query.value(7).toString()); - ui->alwaysEdit->setChecked(query.value(8).toInt() ? true:false); - ui->inventoryEdit->setValue(query.value(9).toDouble()); - ui->costEdit->setValue(query.value(10).toDouble()); - ui->valueEdit->setValue(query.value(9).toDouble() * query.value(10).toDouble()); - if (query.value(11).toString().length() == 10) { - ui->prodEdit->setDate(query.value(11).toDate()); + ui->nameEdit->setText(query.value("name").toString()); + ui->typeEdit->setCurrentIndex(query.value("type").toInt()); + ui->useEdit->setCurrentIndex(query.value("use_use").toInt()); + ui->timeEdit->setValue(query.value("time").toInt()); + ui->isweightEdit->setChecked(query.value("amount_is_weight").toInt() ? true:false); + ui->useforEdit->setPlainText(query.value("use_for").toString()); + ui->notesEdit->setPlainText(query.value("notes").toString()); + ui->alwaysEdit->setChecked(query.value("always_on_stock").toInt() ? true:false); + ui->inventoryEdit->setValue(query.value("inventory").toDouble() * 1000.0); + ui->costEdit->setValue(query.value("cost").toDouble()); + ui->valueEdit->setValue(query.value("inventory").toDouble() * query.value("cost").toDouble()); + if (query.value("production_date").toString().length() == 10) { + ui->prodEdit->setDate(query.value("production_date").toDate()); } else { ui->prodEdit->clear(); } - if (query.value(12).toString().length() == 10) { - ui->thtEdit->setDate(query.value(12).toDate()); + if (query.value("tht_date").toString().length() == 10) { + ui->thtEdit->setDate(query.value("tht_date").toDate()); } else { ui->thtEdit->clear(); } @@ -79,19 +79,24 @@ ui->prodEdit->clear(); ui->thtEdit->clear(); } + UnitSet(); TimeSet(); connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditMisc::is_changed); connect(ui->typeEdit, &QComboBox::currentTextChanged, this, &EditMisc::is_changed); connect(ui->useEdit, &QComboBox::currentTextChanged, this, &EditMisc::is_changed); connect(ui->timeEdit, &QSpinBox::textChanged, this, &EditMisc::time_changed); - connect(ui->isweightEdit, &QCheckBox::stateChanged, this, &EditMisc::is_changed); + connect(ui->isweightEdit, &QCheckBox::stateChanged, this, &EditMisc::weight_changed); connect(ui->useforEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); connect(ui->alwaysEdit, &QCheckBox::stateChanged, this, &EditMisc::is_changed); connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditMisc::is_changed); connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditMisc::is_changed); connect(ui->prodEdit, &QDateEdit::dateChanged, this, &EditMisc::is_changed); + connect(ui->prodButton1, SIGNAL(clicked()), this, SLOT(prod_date_today())); + connect(ui->prodButton2, SIGNAL(clicked()), this, SLOT(prod_date_clear())); connect(ui->thtEdit, &QDateEdit::dateChanged, this, &EditMisc::is_changed); + connect(ui->thtButton1, SIGNAL(clicked()), this, SLOT(tht_date_today())); + connect(ui->thtButton2, SIGNAL(clicked()), this, SLOT(tht_date_clear())); ui->saveButton->setEnabled(false); ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false); @@ -208,6 +213,16 @@ } +void EditMisc::UnitSet() +{ + if (ui->isweightEdit->isChecked()) { + ui->inventoryEdit->setSuffix(tr(" gr")); + } else { + ui->inventoryEdit->setSuffix(tr(" ml")); + } +} + + void EditMisc::TimeSet() { int time = ui->timeEdit->value(); @@ -254,7 +269,7 @@ void EditMisc::is_changed() { - ui->valueEdit->setValue(ui->inventoryEdit->value() * ui->costEdit->value()); + ui->valueEdit->setValue((ui->inventoryEdit->value() / 1000.0) * ui->costEdit->value()); ui->saveButton->setEnabled(true); ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && this->recno >= 0) ? true:false); this->textIsChanged = true; @@ -262,6 +277,13 @@ } +void EditMisc::weight_changed() +{ + UnitSet(); + is_changed(); +} + + void EditMisc::time_changed() { TimeSet(); @@ -288,3 +310,33 @@ this->close(); this->setResult(1); } + + +void EditMisc::prod_date_clear() +{ + ui->prodEdit->setDate(QDate()); + is_changed(); +} + + +void EditMisc::prod_date_today() +{ + ui->prodEdit->setDate(QDate::currentDate()); + is_changed(); +} + + +void EditMisc::tht_date_clear() +{ + ui->thtEdit->setDate(QDate()); + is_changed(); +} + + +void EditMisc::tht_date_today() +{ + ui->thtEdit->setDate(QDate::currentDate()); + is_changed(); +} + +
--- a/src/EditMisc.h Wed Jun 15 10:54:04 2022 +0200 +++ b/src/EditMisc.h Wed Jun 15 14:48:10 2022 +0200 @@ -24,7 +24,12 @@ void on_quitButton_clicked(); void on_deleteButton_clicked(); void is_changed(); + void weight_changed(); void time_changed(); + void prod_date_clear(); + void prod_date_today(); + void tht_date_clear(); + void tht_date_today(); private: Ui::EditMisc *ui; @@ -32,6 +37,7 @@ bool textIsChanged = false; void WindowTitle(); + void UnitSet(); void TimeSet(); };
--- a/ui/EditHop.ui Wed Jun 15 10:54:04 2022 +0200 +++ b/ui/EditHop.ui Wed Jun 15 14:48:10 2022 +0200 @@ -99,7 +99,7 @@ <widget class="QLabel" name="prodLabel"> <property name="geometry"> <rect> - <x>660</x> + <x>590</x> <y>350</y> <width>141</width> <height>20</height> @@ -115,7 +115,7 @@ <widget class="QLabel" name="thtLabel"> <property name="geometry"> <rect> - <x>660</x> + <x>590</x> <y>380</y> <width>141</width> <height>20</height> @@ -178,6 +178,9 @@ <property name="accelerated"> <bool>true</bool> </property> + <property name="suffix"> + <string> Kg</string> + </property> <property name="decimals"> <number>4</number> </property> @@ -206,6 +209,9 @@ <property name="accelerated"> <bool>true</bool> </property> + <property name="suffix"> + <string> €</string> + </property> <property name="maximum"> <double>1000.000000000000000</double> </property> @@ -216,16 +222,16 @@ <enum>QAbstractSpinBox::DefaultStepType</enum> </property> </widget> - <widget class="NullDateEdit" name="prodEdit" native="true"> + <widget class="NullDateEdit" name="prodEdit"> <property name="geometry"> <rect> - <x>810</x> + <x>740</x> <y>350</y> <width>121</width> <height>24</height> </rect> </property> - <property name="dateTime" stdset="0"> + <property name="dateTime"> <datetime> <hour>0</hour> <minute>0</minute> @@ -235,26 +241,50 @@ <day>1</day> </datetime> </property> - <property name="displayFormat" stdset="0"> + <property name="minimumDate"> + <date> + <year>2000</year> + <month>1</month> + <day>1</day> + </date> + </property> + <property name="displayFormat"> <string>yyyy-MM-dd</string> </property> - <property name="calendarPopup" stdset="0"> + <property name="calendarPopup"> <bool>true</bool> </property> </widget> - <widget class="NullDateEdit" name="thtEdit" native="true"> + <widget class="NullDateEdit" name="thtEdit"> <property name="geometry"> <rect> - <x>810</x> + <x>740</x> <y>380</y> <width>121</width> <height>24</height> </rect> </property> - <property name="displayFormat" stdset="0"> + <property name="dateTime"> + <datetime> + <hour>0</hour> + <minute>0</minute> + <second>0</second> + <year>2000</year> + <month>1</month> + <day>1</day> + </datetime> + </property> + <property name="minimumDate"> + <date> + <year>2000</year> + <month>1</month> + <day>1</day> + </date> + </property> + <property name="displayFormat"> <string>yyyy-MM-dd</string> </property> - <property name="calendarPopup" stdset="0"> + <property name="calendarPopup"> <bool>true</bool> </property> </widget> @@ -339,6 +369,9 @@ <property name="buttonSymbols"> <enum>QAbstractSpinBox::NoButtons</enum> </property> + <property name="suffix"> + <string> €</string> + </property> <property name="maximum"> <double>100000.000000000000000</double> </property> @@ -759,6 +792,86 @@ <string>Yes</string> </property> </widget> + <widget class="QToolButton" name="prodButton1"> + <property name="geometry"> + <rect> + <x>870</x> + <y>350</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Set the production 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="QToolButton" name="prodButton2"> + <property name="geometry"> + <rect> + <x>902</x> + <y>350</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Clear production date</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="QToolButton" name="thtButton2"> + <property name="geometry"> + <rect> + <x>902</x> + <y>380</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Clear tht date</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="QToolButton" name="thtButton1"> + <property name="geometry"> + <rect> + <x>870</x> + <y>380</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Set the tht 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> </item> </layout> @@ -766,7 +879,7 @@ <customwidgets> <customwidget> <class>NullDateEdit</class> - <extends>QWidget</extends> + <extends>QDateEdit</extends> <header>NullDateEdit.h</header> </customwidget> </customwidgets>
--- a/ui/EditMisc.ui Wed Jun 15 10:54:04 2022 +0200 +++ b/ui/EditMisc.ui Wed Jun 15 14:48:10 2022 +0200 @@ -115,7 +115,7 @@ <widget class="QLabel" name="thtLabel"> <property name="geometry"> <rect> - <x>660</x> + <x>590</x> <y>340</y> <width>141</width> <height>20</height> @@ -178,14 +178,17 @@ <property name="accelerated"> <bool>true</bool> </property> + <property name="suffix"> + <string> gr</string> + </property> <property name="decimals"> - <number>3</number> + <number>1</number> </property> <property name="maximum"> <double>100000.000000000000000</double> </property> <property name="singleStep"> - <double>0.001000000000000</double> + <double>0.500000000000000</double> </property> <property name="stepType"> <enum>QAbstractSpinBox::DefaultStepType</enum> @@ -206,6 +209,9 @@ <property name="accelerated"> <bool>true</bool> </property> + <property name="suffix"> + <string> €</string> + </property> <property name="maximum"> <double>1000.000000000000000</double> </property> @@ -216,7 +222,7 @@ <enum>QAbstractSpinBox::DefaultStepType</enum> </property> </widget> - <widget class="NullDateEdit" name="prodEdit" native="true"> + <widget class="NullDateEdit" name="prodEdit"> <property name="geometry"> <rect> <x>140</x> @@ -225,7 +231,17 @@ <height>24</height> </rect> </property> - <property name="dateTime" stdset="0"> + <property name="dateTime"> + <datetime> + <hour>0</hour> + <minute>0</minute> + <second>0</second> + <year>2000</year> + <month>1</month> + <day>1</day> + </datetime> + </property> + <property name="minimumDateTime"> <datetime> <hour>0</hour> <minute>0</minute> @@ -235,26 +251,46 @@ <day>1</day> </datetime> </property> - <property name="displayFormat" stdset="0"> + <property name="displayFormat"> <string>yyyy-MM-dd</string> </property> - <property name="calendarPopup" stdset="0"> + <property name="calendarPopup"> <bool>true</bool> </property> </widget> - <widget class="NullDateEdit" name="thtEdit" native="true"> + <widget class="NullDateEdit" name="thtEdit"> <property name="geometry"> <rect> - <x>810</x> + <x>740</x> <y>340</y> <width>121</width> <height>24</height> </rect> </property> - <property name="displayFormat" stdset="0"> + <property name="dateTime"> + <datetime> + <hour>0</hour> + <minute>0</minute> + <second>0</second> + <year>2000</year> + <month>1</month> + <day>1</day> + </datetime> + </property> + <property name="minimumDateTime"> + <datetime> + <hour>0</hour> + <minute>0</minute> + <second>0</second> + <year>2000</year> + <month>1</month> + <day>1</day> + </datetime> + </property> + <property name="displayFormat"> <string>yyyy-MM-dd</string> </property> - <property name="calendarPopup" stdset="0"> + <property name="calendarPopup"> <bool>true</bool> </property> </widget> @@ -339,6 +375,12 @@ <property name="buttonSymbols"> <enum>QAbstractSpinBox::NoButtons</enum> </property> + <property name="suffix"> + <string> €</string> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> </widget> <widget class="QLabel" name="typeLabel"> <property name="geometry"> @@ -539,6 +581,86 @@ <bool>true</bool> </property> </widget> + <widget class="QToolButton" name="prodButton2"> + <property name="geometry"> + <rect> + <x>302</x> + <y>340</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Clear production date</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="QToolButton" name="prodButton1"> + <property name="geometry"> + <rect> + <x>270</x> + <y>340</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Set the production 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="QToolButton" name="thtButton2"> + <property name="geometry"> + <rect> + <x>902</x> + <y>340</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Clear tht date</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="QToolButton" name="thtButton1"> + <property name="geometry"> + <rect> + <x>870</x> + <y>340</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Set the tht 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> </item> </layout> @@ -546,7 +668,7 @@ <customwidgets> <customwidget> <class>NullDateEdit</class> - <extends>QWidget</extends> + <extends>QDateEdit</extends> <header>NullDateEdit.h</header> </customwidget> </customwidgets>