Sat, 19 Feb 2022 22:17:09 +0100
Completed the Fermentables editor.
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
src/EditFermentable.cpp | file | annotate | diff | comparison | revisions | |
src/EditFermentable.h | file | annotate | diff | comparison | revisions | |
src/InventoryFermentables.cpp | file | annotate | diff | comparison | revisions | |
src/Utils.cpp | file | annotate | diff | comparison | revisions | |
src/Utils.h | file | annotate | diff | comparison | revisions | |
src/bmsapp.h | file | annotate | diff | comparison | revisions | |
src/nulldateedit.cpp | file | annotate | diff | comparison | revisions | |
src/nulldateedit.h | file | annotate | diff | comparison | revisions | |
ui/EditFermentable.ui | file | annotate | diff | comparison | revisions | |
ui/InventoryFermentables.ui | file | annotate | diff | comparison | revisions |
--- a/CMakeLists.txt Fri Feb 18 15:53:02 2022 +0100 +++ b/CMakeLists.txt Sat Feb 19 22:17:09 2022 +0100 @@ -101,9 +101,12 @@ ${SRCDIR}/InventorySuppliers.cpp ${SRCDIR}/EditSupplier.cpp ${SRCDIR}/InventoryFermentables.cpp + ${SRCDIR}/EditFermentable.cpp ${SRCDIR}/Setup.cpp + ${SRCDIR}/Utils.cpp ${SRCDIR}/MainWindow.cpp ${SRCDIR}/database/database.cpp + ${SRCDIR}/nulldateedit.cpp ) set( HDRS @@ -112,9 +115,12 @@ ${SRCDIR}/InventorySuppliers.h ${SRCDIR}/EditSupplier.h ${SRCDIR}/InventoryFermentables.h + ${SRCDIR}/EditFermentable.h ${SRCDIR}/Setup.h + ${SRCDIR}/Utils.h ${SRCDIR}/MainWindow.h ${SRCDIR}/database/database.h + ${SRCDIR}/nulldateedit.h ) set( UIS @@ -122,6 +128,7 @@ ${UIDIR}/InventorySuppliers.ui ${UIDIR}/EditSupplier.ui ${UIDIR}/InventoryFermentables.ui + ${UIDIR}/EditFermentable.ui ${UIDIR}/Setup.ui ${UIDIR}/MainWindow.ui )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/EditFermentable.cpp Sat Feb 19 22:17:09 2022 +0100 @@ -0,0 +1,296 @@ +/** + * EditFermentable.cpp is part of bmsapp. + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "EditFermentable.h" +#include "../ui/ui_EditFermentable.h" +#include "bmsapp.h" + + +EditFermentable::EditFermentable(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditFermentable) +{ + QSqlQuery query; + + qDebug() << "EditFermentable record:" << id; + ui->setupUi(this); + this->recno = id; + + WindowTitle(); + + ui->typeEdit->addItem(tr("Grain")); + ui->typeEdit->addItem(tr("Sugar")); + ui->typeEdit->addItem(tr("Extract")); + ui->typeEdit->addItem(tr("Dry extract")); + ui->typeEdit->addItem(tr("Adjunct")); + + ui->graintypeEdit->addItem(tr("Base")); + ui->graintypeEdit->addItem(tr("Roast")); + ui->graintypeEdit->addItem(tr("Crystal")); + ui->graintypeEdit->addItem(tr("Kilned")); + ui->graintypeEdit->addItem(tr("Sour Malt")); + ui->graintypeEdit->addItem(tr("Special")); + ui->graintypeEdit->addItem(tr("No malt")); + + ui->addedEdit->addItem(tr("Mash")); + ui->addedEdit->addItem(tr("Boil")); + ui->addedEdit->addItem(tr("Fermentation")); + ui->addedEdit->addItem(tr("Lagering")); + ui->addedEdit->addItem(tr("Bottle")); + ui->addedEdit->addItem(tr("Kegs")); + + if (id >= 0) { + query.prepare("SELECT * FROM inventory_fermentables WHERE record = :recno"); + query.bindValue(":recno", id); + query.exec(); + query.next(); + + ui->nameEdit->setText(query.value(1).toString()); + ui->notesEdit->setPlainText(query.value(8).toString()); + ui->originEdit->setText(query.value(6).toString()); + ui->supplierEdit->setText(query.value(7).toString()); + ui->typeEdit->setCurrentIndex(query.value(2).toInt()); + ui->graintypeEdit->setCurrentIndex(query.value(20).toInt()); + ui->maxinbatchEdit->setValue(query.value(14).toDouble()); + ui->mashEdit->setChecked(query.value(16).toInt() ? true:false); + ui->addafterEdit->setChecked(query.value(5).toInt() ? true:false); + ui->addedEdit->setCurrentIndex(query.value(17).toInt()); + ui->alwaysEdit->setChecked(query.value(5).toInt() ? true:false); + ui->inventoryEdit->setValue(query.value(21).toDouble()); + ui->costEdit->setValue(query.value(22).toDouble()); + ui->valueEdit->setValue(query.value(21).toDouble() * query.value(22).toDouble()); + ui->yieldEdit->setValue(query.value(3).toDouble()); + ui->colorEdit->setValue(query.value(4).toDouble()); + ui->moistureEdit->setValue(query.value(10).toDouble()); + ui->coarseEdit->setValue(query.value(9).toDouble()); + ui->proteinEdit->setValue(query.value(12).toDouble()); + ui->dissolvedEdit->setValue(query.value(13).toDouble()); + ui->diastaticEdit->setValue(Utils::lintner_to_kolbach(query.value(11).toDouble())); + ui->diphEdit->setValue(query.value(18).toDouble()); + ui->acidphEdit->setValue(query.value(19).toDouble()); + if (query.value(23).toString().length() == 10) { + ui->prodEdit->setDate(query.value(23).toDate()); + } else { + ui->prodEdit->clear(); + } + if (query.value(24).toString().length() == 10) { + ui->thtEdit->setDate(query.value(24).toDate()); + } else { + ui->thtEdit->clear(); + } + } else { + /* Set some defaults */ + ui->typeEdit->setCurrentIndex(0); + ui->graintypeEdit->setCurrentIndex(0); + ui->maxinbatchEdit->setValue(100); + ui->mashEdit->setChecked(true); + ui->addedEdit->setCurrentIndex(0); + ui->yieldEdit->setValue(80); + ui->colorEdit->setValue(3); + ui->coarseEdit->setValue(3); + ui->moistureEdit->setValue(4); + } + connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditFermentable::is_changed); + connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); + connect(ui->originEdit, &QLineEdit::textChanged, this, &EditFermentable::is_changed); + connect(ui->supplierEdit, &QLineEdit::textChanged, this, &EditFermentable::is_changed); + connect(ui->typeEdit, &QComboBox::currentTextChanged, this, &EditFermentable::is_changed); + connect(ui->graintypeEdit, &QComboBox::currentTextChanged, this, &EditFermentable::is_changed); + connect(ui->maxinbatchEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->mashEdit, &QCheckBox::stateChanged, this, &EditFermentable::is_changed); + connect(ui->addafterEdit, &QCheckBox::stateChanged, this, &EditFermentable::is_changed); + connect(ui->addedEdit, &QComboBox::currentTextChanged, this, &EditFermentable::is_changed); + connect(ui->alwaysEdit, &QCheckBox::stateChanged, this, &EditFermentable::is_changed); + connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->costEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->yieldEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->colorEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->moistureEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->coarseEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->proteinEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->dissolvedEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->diastaticEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->diphEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->acidphEdit, &QDoubleSpinBox::textChanged, this, &EditFermentable::is_changed); + connect(ui->prodEdit, &QDateEdit::dateChanged, this, &EditFermentable::is_changed); + connect(ui->thtEdit, &QDateEdit::dateChanged, this, &EditFermentable::is_changed); + + ui->saveButton->setEnabled(false); + ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false); +} + + +EditFermentable::~EditFermentable() +{ + qDebug() << "EditFermentable done"; + delete ui; + emit entry_changed(); +} + + +/* + * Window header, mark any change with '**' + */ +void EditFermentable::WindowTitle() +{ + QString txt; + + if (this->recno < 0) { + txt = QString(tr("BMSapp - Add new fermentable")); + } else { + txt = QString(tr("BMSapp - Edit fermentable %1").arg(this->recno)); + } + + if (this->textIsChanged) { + txt.append((QString(" **"))); + } + setWindowTitle(txt); +} + + +void EditFermentable::on_saveButton_clicked() +{ + QSqlQuery query; + + /* If there are errors in the form, show a message and do "return;" */ + if (ui->nameEdit->text().length() < 2) { + QMessageBox::warning(this, tr("Edit Fermentable"), tr("Name empty or too short.")); + return; + } + if (ui->originEdit->text().length() < 2) { + QMessageBox::warning(this, tr("Edit Fermentable"), tr("Origin empty or too short.")); + return; + } + if (ui->supplierEdit->text().length() < 2) { + QMessageBox::warning(this, tr("Edit Fermentable"), tr("Supplier empty or too short.")); + return; + } + + if (this->textIsChanged) { + if (this->recno == -1) { + query.prepare("INSERT INTO inventory_fermentables SET name=:name, type=:type, yield=:yield, color=:color, " + "add_after_boil=:addafter, origin=:origin, supplier=:supplier, notes=:notes, coarse_fine_diff=:coarse, " + "moisture=:moisture, diastatic_power=:diastatic, protein=:protein, dissolved_protein=:dissolved, " + "max_in_batch=:maxinbatch, recommend_mash=:mash, added=:added, always_on_stock=:always, di_ph=:diph, " + "acid_to_ph_57=:acidph, graintype=:graintype, inventory=:inventory, cost=:cost, production_date=:prod, " + "tht_date=:tht, uuid = :uuid"); + } else { + query.prepare("UPDATE inventory_fermentables SET name=:name, type=:type, yield=:yield, color=:color, " + "add_after_boil=:addafter, origin=:origin, supplier=:supplier, notes=:notes, coarse_fine_diff=:coarse, " + "moisture=:moisture, diastatic_power=:diastatic, protein=:protein, dissolved_protein=:dissolved, " + "max_in_batch=:maxinbatch, recommend_mash=:mash, added=:added, always_on_stock=:always, di_ph=:diph, " + "acid_to_ph_57=:acidph, graintype=:graintype, inventory=:inventory, cost=:cost, production_date=:prod, " + "tht_date=:tht WHERE record = :recno"); + } + query.bindValue(":name", ui->nameEdit->text()); + query.bindValue(":type", ui->typeEdit->currentIndex()); + query.bindValue(":yield", QString("%1").arg(ui->yieldEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":color", QString("%1").arg(ui->colorEdit->value(), 1, 'f', 0, '0')); + query.bindValue(":addafter", ui->addafterEdit->isChecked() ? 1:0); + query.bindValue(":origin", ui->originEdit->text()); + query.bindValue(":supplier", ui->supplierEdit->text()); + query.bindValue(":notes", ui->notesEdit->toPlainText()); + query.bindValue(":coarse", QString("%1").arg(ui->coarseEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":moisture", QString("%1").arg(ui->moistureEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":diastatic", Utils::kolbach_to_lintner(ui->diastaticEdit->value())); + query.bindValue(":protein", QString("%1").arg(ui->proteinEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":dissolved", QString("%1").arg(ui->dissolvedEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":maxinbatch", QString("%1").arg(ui->maxinbatchEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":mash", ui->mashEdit->isChecked() ? 1:0); + query.bindValue(":added", ui->addedEdit->currentIndex()); + query.bindValue(":always", ui->alwaysEdit->isChecked() ? 1:0); + query.bindValue(":diph", QString("%1").arg(ui->diphEdit->value(), 3, 'f', 2, '0')); + query.bindValue(":acidph", QString("%1").arg(ui->acidphEdit->value(), 6, 'f', 5, '0')); + query.bindValue(":graintype", ui->graintypeEdit->currentIndex()); + query.bindValue(":inventory", QString("%1").arg(ui->inventoryEdit->value(), 4, 'f', 3, '0')); + query.bindValue(":cost", QString("%1").arg(ui->costEdit->value(), 3, 'f', 2, '0')); + /* Uses https://www.qtcentre.org/threads/17295-How-to-put-empty-value-in-QDateEdit */ + query.bindValue(":prod", ui->prodEdit->nullDate()); + query.bindValue(":tht", ui->thtEdit->nullDate()); + if (this->recno == -1) { + query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); + } else { + query.bindValue(":recno", this->recno); + } + query.exec(); + if (query.lastError().isValid()) { + qDebug() << "EditFermentable" << query.lastError(); + QMessageBox::warning(this, tr("Database error"), + tr("MySQL error: %1\n%2\n%3") + .arg(query.lastError().nativeErrorCode()) + .arg(query.lastError().driverText()) + .arg(query.lastError().databaseText())); + } else { + qDebug() << "EditFermentable Saved"; + } + } + + ui->saveButton->setEnabled(false); + this->textIsChanged = false; + WindowTitle(); +} + + +void EditFermentable::on_deleteButton_clicked() +{ + QSqlQuery query; + + query.prepare("DELETE FROM inventory_fermentables WHERE record = :recno"); + query.bindValue(":recno", this->recno); + query.exec(); + if (query.lastError().isValid()) { + qDebug() << "EditFermentable" << query.lastError(); + QMessageBox::warning(this, tr("Database error"), + tr("MySQL error: %1\n%2\n%3") + .arg(query.lastError().nativeErrorCode()) + .arg(query.lastError().driverText()) + .arg(query.lastError().databaseText())); + } else { + qDebug() << "EditFermentable Deleted" << this->recno; + } + + this->close(); + this->setResult(1); +} + + +void EditFermentable::is_changed() +{ + ui->valueEdit->setValue(ui->inventoryEdit->value() * ui->costEdit->value()); + ui->saveButton->setEnabled(true); + ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && this->recno >= 0) ? true:false); + this->textIsChanged = true; + WindowTitle(); +} + + +void EditFermentable::on_quitButton_clicked() +{ + if (this->textIsChanged) { + int rc = QMessageBox::warning(this, tr("Fermentable changed"), tr("The fermentable has been modified\n Save changes?"), + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save); + switch (rc) { + case QMessageBox::Save: + on_saveButton_clicked(); + break; /* Saved and then Quit */ + case QMessageBox::Discard: + break; /* Quit without Save */ + case QMessageBox::Cancel: + return; /* Return to the editor page */ + } + } + + this->close(); + this->setResult(1); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/EditFermentable.h Sat Feb 19 22:17:09 2022 +0100 @@ -0,0 +1,36 @@ +#ifndef _EDITFERMENTABLE_H +#define _EDITFERMENTABLE_H + +#include <QDialog> + + +namespace Ui { +class EditFermentable; +} + +class EditFermentable : public QDialog +{ + Q_OBJECT + +signals: + void entry_changed(); + +public: + explicit EditFermentable(int id, QWidget *parent = 0); + ~EditFermentable(); + +private slots: + void on_saveButton_clicked(); + void on_quitButton_clicked(); + void on_deleteButton_clicked(); + void is_changed(); + +private: + Ui::EditFermentable *ui; + int recno; + bool textIsChanged = false; + + void WindowTitle(); +}; + +#endif
--- a/src/InventoryFermentables.cpp Fri Feb 18 15:53:02 2022 +0100 +++ b/src/InventoryFermentables.cpp Sat Feb 19 22:17:09 2022 +0100 @@ -15,7 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "InventoryFermentables.h" -//#include "EditSupplier.h" +#include "EditFermentable.h" #include "../ui/ui_InventoryFermentables.h" #include "config.h" #include "bmsapp.h" @@ -36,7 +36,7 @@ { QString w; - qDebug() << "slot" << Q_FUNC_INFO; + qDebug() << "InventoryFermentables reload"; QSqlQuery query("SELECT * FROM inventory_fermentables ORDER BY supplier,name"); const QStringList labels({tr("Origin"), tr("Supplier"), tr("Name"), tr("Type"), tr("Grain"), tr("Color"), tr("Yield"), tr("Stock"), tr("Edit")}); @@ -62,7 +62,6 @@ QTableWidgetItem *rightitem = new QTableWidgetItem(); rightitem->setTextAlignment(Qt::AlignRight); - qDebug() << query.record().count() << query.size(); query.first(); for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { ui->tableFermentables->setItem(ridx, 0, new QTableWidgetItem(query.value(6).toString())); @@ -119,11 +118,11 @@ { qDebug() << "InventoryFermentables edit:" << recno; -// EditSupplier dialog(recno, this); + EditFermentable dialog(recno, this); /* Signal from editor if a refresh is needed */ -// connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); -// dialog.setModal(true); -// dialog.exec(); + connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); + dialog.setModal(true); + dialog.exec(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Utils.cpp Sat Feb 19 22:17:09 2022 +0100 @@ -0,0 +1,43 @@ +/** + * Utils.cpp is part of bmsapp. + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "Utils.h" + +#include <math.h> + +double Utils::Round(double n, int d) +{ + int m; + + for (int i = 0, m = 1; i < d; i++, m *= 10); + return round(n * m) / m; +} + + +double Utils::lintner_to_kolbach(double lintner) +{ + double wk = (3.5 * lintner) - 16; + if (wk < 0) + return 0.0; + return wk; +} + + +double Utils::kolbach_to_lintner(double kolbach) +{ + return Round((kolbach + 16) / 3.5, 3); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Utils.h Sat Feb 19 22:17:09 2022 +0100 @@ -0,0 +1,19 @@ +#ifndef _UTILS_H +#define _UTILS_H + + +/** + * @namespace Utils + * + * @brief Global math functions. + */ +namespace Utils { + + double Round(double n, int d); + + double lintner_to_kolbach(double lintner); + + double kolbach_to_lintner(double kolbach); +} + +#endif
--- a/src/bmsapp.h Fri Feb 18 15:53:02 2022 +0100 +++ b/src/bmsapp.h Sat Feb 19 22:17:09 2022 +0100 @@ -21,7 +21,7 @@ #include <QPlainTextEdit> #include <QMessageBox> - +#include "Utils.h" #include "database/database.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/nulldateedit.cpp Sat Feb 19 22:17:09 2022 +0100 @@ -0,0 +1,55 @@ +/** + * Utils.cpp is part of bmsapp. + * + * See https://www.qtcentre.org/threads/17295-How-to-put-empty-value-in-QDateEdit + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "nulldateedit.h" + + +NullDateEdit::NullDateEdit(const QDate& date, QWidget* parent) + : QDateEdit(date, parent) +{ + this->setSpecialValueText("Null"); +} + +NullDateEdit::NullDateEdit(QWidget* parent) + : QDateEdit(parent) +{ + this->setSpecialValueText("Null"); +} + +NullDateEdit::~NullDateEdit() +{ +} + +void NullDateEdit::clear() +{ + this->setDate(this->minimumDate()); +} + +QDate NullDateEdit::nullDate() const +{ + if (date() == this->minimumDate()) + return QDate(); + return date(); +} + +void NullDateEdit::setDate(const QDate & date) +{ + if (date.isNull()) + QDateEdit::setDate(this->minimumDate()); + QDateEdit::setDate(date); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/nulldateedit.h Sat Feb 19 22:17:09 2022 +0100 @@ -0,0 +1,16 @@ +#include <QDateEdit> +class NullDateEdit : public QDateEdit +{ + Q_OBJECT + Q_PROPERTY(QDate nullDate READ nullDate WRITE setDate USER true) +public: + NullDateEdit(const QDate& date, QWidget* parent); + NullDateEdit(QWidget* parent); + ~NullDateEdit(); + + QDate nullDate() const; + +public slots: + void clear(); + void setDate(const QDate& date); +};
--- a/ui/EditFermentable.ui Fri Feb 18 15:53:02 2022 +0100 +++ b/ui/EditFermentable.ui Sat Feb 19 22:17:09 2022 +0100 @@ -1,38 +1,838 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>editFermentable</class> - <widget class="QDialog" name="editFermentable"> + <class>EditFermentable</class> + <widget class="QDialog" name="EditFermentable"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>1280</width> - <height>640</height> + <width>1024</width> + <height>560</height> </rect> </property> <property name="windowTitle"> <string>Dialog</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="0"> - <widget class="QWidget" name="bottomWidget" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>24</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>24</height> - </size> - </property> + <item row="0" column="0"> + <widget class="QWidget" name="topWidget" native="true"> + <widget class="QLabel" name="nameLabel"> + <property name="geometry"> + <rect> + <x>30</x> + <y>10</y> + <width>91</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Name:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="notesLabel"> + <property name="geometry"> + <rect> + <x>30</x> + <y>40</y> + <width>91</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Notes:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="typeLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>130</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Type:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="graintypeLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>160</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Grain type:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="originLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>190</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Origin:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="supplierLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>220</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Supplier:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="maxinbatchLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>250</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Max in batch:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="mashLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>280</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Recommend mash:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="addafterLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>310</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Add after boil:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="addedLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>340</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Add moment:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="alwaysLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>370</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Always on stock:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="inventoryLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>410</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Inventory:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="costLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>440</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Cost per Kg:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="valueLabel"> + <property name="geometry"> + <rect> + <x>5</x> + <y>470</y> + <width>121</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Total value:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="yieldLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>130</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Yield:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="colorLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>160</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Color EBC:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="moistureLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>190</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Moisture:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="coarseLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>220</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Coarse fine diff:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="proteinLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>250</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Protein:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="diastaticLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>310</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Diastatic power:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="dissolvedLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>280</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Dissolved protein:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="diphLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>340</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Dissolved pH:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="acidphLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>370</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Acid to pH 5.7:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="prodLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>410</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Production date:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="thtLabel"> + <property name="geometry"> + <rect> + <x>660</x> + <y>440</y> + <width>141</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Best before date:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLineEdit" name="nameEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>10</y> + <width>791</width> + <height>23</height> + </rect> + </property> + <property name="maxLength"> + <number>128</number> + </property> + <property name="placeholderText"> + <string>Name of the fermentable</string> + </property> + </widget> + <widget class="QPlainTextEdit" name="notesEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>40</y> + <width>791</width> + <height>81</height> + </rect> + </property> + <property name="placeholderText"> + <string>Notes and usage tips.</string> + </property> + </widget> + <widget class="QComboBox" name="typeEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>130</y> + <width>151</width> + <height>23</height> + </rect> + </property> + </widget> + <widget class="QComboBox" name="graintypeEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>160</y> + <width>151</width> + <height>23</height> + </rect> + </property> + </widget> + <widget class="QLineEdit" name="originEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>190</y> + <width>451</width> + <height>23</height> + </rect> + </property> + <property name="maxLength"> + <number>128</number> + </property> + <property name="placeholderText"> + <string>Country of origin</string> + </property> + </widget> + <widget class="QLineEdit" name="supplierEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>220</y> + <width>451</width> + <height>23</height> + </rect> + </property> + <property name="maxLength"> + <number>128</number> + </property> + <property name="placeholderText"> + <string>Producer or supplier</string> + </property> + </widget> + <widget class="QDoubleSpinBox" name="maxinbatchEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>250</y> + <width>121</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> %</string> + </property> + <property name="decimals"> + <number>1</number> + </property> + <property name="singleStep"> + <double>0.500000000000000</double> + </property> + </widget> + <widget class="QDoubleSpinBox" name="inventoryEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>410</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="readOnly"> + <bool>false</bool> + </property> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::UpDownArrows</enum> + </property> + <property name="accelerated"> + <bool>true</bool> + </property> + <property name="decimals"> + <number>3</number> + </property> + <property name="maximum"> + <double>100000.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.001000000000000</double> + </property> + <property name="stepType"> + <enum>QAbstractSpinBox::DefaultStepType</enum> + </property> + </widget> + <widget class="QDoubleSpinBox" name="costEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>440</y> + <width>121</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="maximum"> + <double>1000.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.010000000000000</double> + </property> + <property name="stepType"> + <enum>QAbstractSpinBox::DefaultStepType</enum> + </property> + </widget> + <widget class="QDoubleSpinBox" name="yieldEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>130</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="decimals"> + <number>1</number> + </property> + </widget> + <widget class="QDoubleSpinBox" name="colorEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>160</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="decimals"> + <number>1</number> + </property> + </widget> + <widget class="QDoubleSpinBox" name="moistureEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>190</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="decimals"> + <number>1</number> + </property> + </widget> + <widget class="QDoubleSpinBox" name="coarseEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>220</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="decimals"> + <number>1</number> + </property> + </widget> + <widget class="QDoubleSpinBox" name="proteinEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>250</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="decimals"> + <number>1</number> + </property> + </widget> + <widget class="QDoubleSpinBox" name="dissolvedEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>280</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="decimals"> + <number>1</number> + </property> + </widget> + <widget class="QDoubleSpinBox" name="diastaticEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>310</y> + <width>121</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="decimals"> + <number>0</number> + </property> + <property name="maximum"> + <double>1000.000000000000000</double> + </property> + </widget> + <widget class="QDoubleSpinBox" name="diphEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>340</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QDoubleSpinBox" name="acidphEdit"> + <property name="geometry"> + <rect> + <x>810</x> + <y>370</y> + <width>121</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="decimals"> + <number>4</number> + </property> + <property name="minimum"> + <double>-1000.000000000000000</double> + </property> + <property name="maximum"> + <double>1000.000000000000000</double> + </property> + </widget> + <widget class="QCheckBox" name="mashEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>280</y> + <width>85</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>Yes</string> + </property> + </widget> + <widget class="QCheckBox" name="addafterEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>310</y> + <width>85</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>Yes</string> + </property> + </widget> + <widget class="QCheckBox" name="alwaysEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>370</y> + <width>85</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>Yes</string> + </property> + </widget> + <widget class="QComboBox" name="addedEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>340</y> + <width>151</width> + <height>23</height> + </rect> + </property> + </widget> + <widget class="NullDateEdit" name="prodEdit" native="true"> + <property name="geometry"> + <rect> + <x>810</x> + <y>410</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="dateTime" stdset="0"> + <datetime> + <hour>0</hour> + <minute>0</minute> + <second>0</second> + <year>2000</year> + <month>1</month> + <day>1</day> + </datetime> + </property> + <property name="displayFormat" stdset="0"> + <string>yyyy-MM-dd</string> + </property> + <property name="calendarPopup" stdset="0"> + <bool>true</bool> + </property> + </widget> + <widget class="NullDateEdit" name="thtEdit" native="true"> + <property name="geometry"> + <rect> + <x>810</x> + <y>440</y> + <width>121</width> + <height>24</height> + </rect> + </property> + <property name="displayFormat" stdset="0"> + <string>yyyy-MM-dd</string> + </property> + <property name="calendarPopup" stdset="0"> + <bool>true</bool> + </property> + </widget> <widget class="QPushButton" name="quitButton"> <property name="geometry"> <rect> - <x>10</x> - <y>0</y> + <x>90</x> + <y>510</y> <width>80</width> <height>23</height> </rect> @@ -52,10 +852,13 @@ </property> </widget> <widget class="QPushButton" name="saveButton"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="geometry"> <rect> - <x>1170</x> - <y>0</y> + <x>850</x> + <y>510</y> <width>80</width> <height>23</height> </rect> @@ -68,13 +871,86 @@ <normaloff>:/icons/silk/icons/silk/disk.png</normaloff>:/icons/silk/icons/silk/disk.png</iconset> </property> </widget> + <widget class="QPushButton" name="deleteButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="geometry"> + <rect> + <x>463</x> + <y>510</y> + <width>80</width> + <height>23</height> + </rect> + </property> + <property name="text"> + <string>Delete</string> + </property> + <property name="icon"> + <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> + <normaloff>:/icons/silk/icons/silk/delete.png</normaloff>:/icons/silk/icons/silk/delete.png</iconset> + </property> + </widget> + <widget class="QDoubleSpinBox" name="valueEdit"> + <property name="geometry"> + <rect> + <x>140</x> + <y>470</y> + <width>107</width> + <height>24</height> + </rect> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::NoButtons</enum> + </property> + </widget> </widget> </item> - <item row="1" column="0"> - <widget class="QWidget" name="topWidget" native="true"/> - </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>NullDateEdit</class> + <extends>QWidget</extends> + <header>nulldateedit.h</header> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>nameEdit</tabstop> + <tabstop>notesEdit</tabstop> + <tabstop>typeEdit</tabstop> + <tabstop>graintypeEdit</tabstop> + <tabstop>originEdit</tabstop> + <tabstop>supplierEdit</tabstop> + <tabstop>maxinbatchEdit</tabstop> + <tabstop>mashEdit</tabstop> + <tabstop>addafterEdit</tabstop> + <tabstop>addedEdit</tabstop> + <tabstop>alwaysEdit</tabstop> + <tabstop>inventoryEdit</tabstop> + <tabstop>costEdit</tabstop> + <tabstop>yieldEdit</tabstop> + <tabstop>colorEdit</tabstop> + <tabstop>moistureEdit</tabstop> + <tabstop>coarseEdit</tabstop> + <tabstop>proteinEdit</tabstop> + <tabstop>dissolvedEdit</tabstop> + <tabstop>diastaticEdit</tabstop> + <tabstop>diphEdit</tabstop> + <tabstop>acidphEdit</tabstop> + <tabstop>prodEdit</tabstop> + <tabstop>thtEdit</tabstop> + <tabstop>quitButton</tabstop> + <tabstop>deleteButton</tabstop> + <tabstop>saveButton</tabstop> + <tabstop>valueEdit</tabstop> + </tabstops> <resources> <include location="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"/> </resources>
--- a/ui/InventoryFermentables.ui Fri Feb 18 15:53:02 2022 +0100 +++ b/ui/InventoryFermentables.ui Sat Feb 19 22:17:09 2022 +0100 @@ -68,8 +68,52 @@ </property> </widget> </item> - <item alignment="Qt::AlignRight"> + <item> + <widget class="QPushButton" name="exportButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>80</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>Export</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="importButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>80</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>Import</string> + </property> + </widget> + </item> + <item> <widget class="QPushButton" name="insertButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="minimumSize"> <size> <width>80</width>