# HG changeset patch # User Michiel Broek # Date 1655297290 -7200 # Node ID b6ec2e275736044adfd58bec2c3f950d5d586e70 # Parent daa667c1ad6d7a56e6ab57df69a16d6e45e3f626 Fixed missing settings from the Miscs and Hops editors. diff -r daa667c1ad6d -r b6ec2e275736 src/EditHop.cpp --- 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(); +} + diff -r daa667c1ad6d -r b6ec2e275736 src/EditHop.h --- 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; diff -r daa667c1ad6d -r b6ec2e275736 src/EditMisc.cpp --- 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(); +} + + diff -r daa667c1ad6d -r b6ec2e275736 src/EditMisc.h --- 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(); }; diff -r daa667c1ad6d -r b6ec2e275736 ui/EditHop.ui --- 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 @@ - 660 + 590 350 141 20 @@ -115,7 +115,7 @@ - 660 + 590 380 141 20 @@ -178,6 +178,9 @@ true + + Kg + 4 @@ -206,6 +209,9 @@ true + + + 1000.000000000000000 @@ -216,16 +222,16 @@ QAbstractSpinBox::DefaultStepType - + - 810 + 740 350 121 24 - + 0 0 @@ -235,26 +241,50 @@ 1 - + + + 2000 + 1 + 1 + + + yyyy-MM-dd - + true - + - 810 + 740 380 121 24 - + + + 0 + 0 + 0 + 2000 + 1 + 1 + + + + + 2000 + 1 + 1 + + + yyyy-MM-dd - + true @@ -339,6 +369,9 @@ QAbstractSpinBox::NoButtons + + + 100000.000000000000000 @@ -759,6 +792,86 @@ Yes + + + + 870 + 350 + 28 + 22 + + + + Set the production date to today. + + + ... + + + + :/icons/silk/date.png:/icons/silk/date.png + + + + + + 902 + 350 + 28 + 22 + + + + Clear production date + + + ... + + + + :/icons/silk/delete.png:/icons/silk/delete.png + + + + + + 902 + 380 + 28 + 22 + + + + Clear tht date + + + ... + + + + :/icons/silk/delete.png:/icons/silk/delete.png + + + + + + 870 + 380 + 28 + 22 + + + + Set the tht date to today. + + + ... + + + + :/icons/silk/date.png:/icons/silk/date.png + + @@ -766,7 +879,7 @@ NullDateEdit - QWidget + QDateEdit
NullDateEdit.h
diff -r daa667c1ad6d -r b6ec2e275736 ui/EditMisc.ui --- 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 @@ - 660 + 590 340 141 20 @@ -178,14 +178,17 @@ true + + gr + - 3 + 1 100000.000000000000000 - 0.001000000000000 + 0.500000000000000 QAbstractSpinBox::DefaultStepType @@ -206,6 +209,9 @@ true + + + 1000.000000000000000 @@ -216,7 +222,7 @@ QAbstractSpinBox::DefaultStepType - + 140 @@ -225,7 +231,17 @@ 24 - + + + 0 + 0 + 0 + 2000 + 1 + 1 + + + 0 0 @@ -235,26 +251,46 @@ 1 - + yyyy-MM-dd - + true - + - 810 + 740 340 121 24 - + + + 0 + 0 + 0 + 2000 + 1 + 1 + + + + + 0 + 0 + 0 + 2000 + 1 + 1 + + + yyyy-MM-dd - + true @@ -339,6 +375,12 @@ QAbstractSpinBox::NoButtons + + + + + 10000.000000000000000 + @@ -539,6 +581,86 @@ true + + + + 302 + 340 + 28 + 22 + + + + Clear production date + + + ... + + + + :/icons/silk/delete.png:/icons/silk/delete.png + + + + + + 270 + 340 + 28 + 22 + + + + Set the production date to today. + + + ... + + + + :/icons/silk/date.png:/icons/silk/date.png + + + + + + 902 + 340 + 28 + 22 + + + + Clear tht date + + + ... + + + + :/icons/silk/delete.png:/icons/silk/delete.png + + + + + + 870 + 340 + 28 + 22 + + + + Set the tht date to today. + + + ... + + + + :/icons/silk/date.png:/icons/silk/date.png + + @@ -546,7 +668,7 @@ NullDateEdit - QWidget + QDateEdit
NullDateEdit.h