# HG changeset patch # User Michiel Broek # Date 1645991141 -3600 # Node ID 0fec6a1abd134b54106c4a11d04b0308185db6dd # Parent 76846c99f827265009eb8d3269612be8fbfcede5 Added inventory equipment table and editor. diff -r 76846c99f827 -r 0fec6a1abd13 CMakeLists.txt --- a/CMakeLists.txt Sat Feb 26 16:34:20 2022 +0100 +++ b/CMakeLists.txt Sun Feb 27 20:45:41 2022 +0100 @@ -110,6 +110,8 @@ ${SRCDIR}/EditMisc.cpp ${SRCDIR}/InventoryWaters.cpp ${SRCDIR}/EditWater.cpp + ${SRCDIR}/InventoryEquipments.cpp + ${SRCDIR}/EditEquipment.cpp ${SRCDIR}/Setup.cpp ${SRCDIR}/Utils.cpp ${SRCDIR}/MainWindow.cpp @@ -132,6 +134,8 @@ ${SRCDIR}/EditMisc.h ${SRCDIR}/InventoryWaters.h ${SRCDIR}/EditWater.h + ${SRCDIR}/InventoryEquipments.h + ${SRCDIR}/EditEquipment.h ${SRCDIR}/Setup.h ${SRCDIR}/Utils.h ${SRCDIR}/MainWindow.h @@ -152,6 +156,9 @@ ${UIDIR}/InventoryMiscs.ui ${UIDIR}/EditMisc.ui ${UIDIR}/InventoryWaters.ui + ${UIDIR}/EditWater.ui + ${UIDIR}/InventoryEquipments.ui + ${UIDIR}/EditEquipment.ui ${UIDIR}/Setup.ui ${UIDIR}/MainWindow.ui ) diff -r 76846c99f827 -r 0fec6a1abd13 src/EditEquipment.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/EditEquipment.cpp Sun Feb 27 20:45:41 2022 +0100 @@ -0,0 +1,314 @@ +/** + * EditEquipment.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 . + */ +#include "EditEquipment.h" +#include "../ui/ui_EditEquipment.h" +#include "bmsapp.h" + + +EditEquipment::EditEquipment(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditEquipment) +{ + QSqlQuery query, query2; + + qDebug() << "EditEquipment record:" << id; + ui->setupUi(this); + this->recno = id; + + WindowTitle(); + + ui->tun_materialEdit->addItem(tr("Stainless Steel")); + ui->tun_materialEdit->addItem(tr("Aluminium")); + ui->tun_materialEdit->addItem(tr("Plastics")); + ui->tun_materialEdit->addItem(tr("Copper")); + + if (id >= 0) { + query.prepare("SELECT * FROM inventory_equipments WHERE record = :recno"); + query.bindValue(":recno", id); + query.exec(); + query.next(); + + ui->nameEdit->setText(query.value(1).toString()); + ui->boil_sizeEdit->setValue(query.value(2).toDouble()); + ui->batch_sizeEdit->setValue(query.value(3).toDouble()); + ui->tun_volumeEdit->setValue(query.value(4).toDouble()); + ui->tun_weightEdit->setValue(query.value(5).toDouble()); + ui->tun_specific_heatEdit->setValue(query.value(6).toDouble()); + ui->tun_materialEdit->setCurrentIndex(query.value(7).toInt()); + ui->tun_heightEdit->setValue(query.value(8).toDouble() * 100.0); + ui->top_up_waterEdit->setValue(query.value(9).toDouble()); + ui->chiller_lossEdit->setValue(query.value(10).toDouble()); + ui->evap_rateEdit->setValue(query.value(11).toDouble()); + ui->boil_timeEdit->setValue(query.value(12).toDouble()); + ui->calcboilEdit->setChecked(query.value(13).toInt() ? true:false); + ui->top_up_kettleEdit->setValue(query.value(14).toDouble()); + ui->hopfactorEdit->setValue(query.value(15).toDouble()); + ui->notesEdit->setPlainText(query.value(16).toString()); + ui->lauter_volumeEdit->setValue(query.value(17).toDouble()); + ui->lauter_heightEdit->setValue(query.value(18).toDouble() * 100.0); + ui->lauter_deadspaceEdit->setValue(query.value(19).toDouble()); + ui->kettle_volumeEdit->setValue(query.value(20).toDouble()); + ui->kettle_heightEdit->setValue(query.value(21).toDouble() * 100.0); + ui->mash_volumeEdit->setValue(query.value(22).toDouble()); + ui->mash_maxEdit->setValue(query.value(23).toDouble()); + ui->efficiencyEdit->setValue(query.value(24).toDouble()); + /* + * Now we have loaded this record, check if this equipment is + * being used by a product. If so, make the name field read-only. + */ + query2.prepare("SELECT eq_name FROM products WHERE eq_name=:name"); + query2.bindValue(":name", query.value(1).toString()); + query2.exec(); + inuse = query2.size(); + qDebug() << "in use" << inuse; + ui->nameEdit->setReadOnly(inuse > 0); + } else { + /* Set some defaults */ + ui->boil_sizeEdit->setValue(18); + ui->batch_sizeEdit->setValue(15.3); + ui->tun_volumeEdit->setValue(20); + ui->tun_weightEdit->setValue(2); + ui->tun_specific_heatEdit->setValue(0.11); + ui->tun_materialEdit->setCurrentIndex(0); + ui->tun_heightEdit->setValue(20); + ui->top_up_waterEdit->setValue(0); + ui->chiller_lossEdit->setValue(0.5); + ui->evap_rateEdit->setValue(1.8); + ui->boil_timeEdit->setValue(90); + ui->calcboilEdit->setChecked(true); + ui->top_up_kettleEdit->setValue(0); + ui->hopfactorEdit->setValue(100); + ui->lauter_volumeEdit->setValue(20); + ui->lauter_heightEdit->setValue(20); + ui->lauter_deadspaceEdit->setValue(0.5); + ui->kettle_volumeEdit->setValue(20); + ui->kettle_heightEdit->setValue(20); + ui->mash_volumeEdit->setValue(18); + ui->mash_maxEdit->setValue(6); + ui->efficiencyEdit->setValue(75); + inuse = 0; + } + connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditEquipment::is_changed); + connect(ui->boil_sizeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->batch_sizeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->tun_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->tun_weightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->tun_materialEdit, &QComboBox::currentTextChanged, this, &EditEquipment::material_changed); + connect(ui->tun_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->top_up_waterEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->chiller_lossEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->evap_rateEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->boil_timeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->calcboilEdit, &QCheckBox::stateChanged, this, &EditEquipment::is_changed); + connect(ui->top_up_kettleEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->hopfactorEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); + connect(ui->lauter_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->lauter_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->lauter_deadspaceEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->kettle_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->kettle_heightEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->mash_volumeEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->mash_maxEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + connect(ui->efficiencyEdit, &QDoubleSpinBox::textChanged, this, &EditEquipment::is_changed); + + calcBatchVolume(); + ui->saveButton->setEnabled(false); + ui->deleteButton->setEnabled((inuse == 0 && id >= 0) ? true:false); +} + + +EditEquipment::~EditEquipment() +{ + qDebug() << "EditEquipment done"; + delete ui; + emit entry_changed(); +} + + +/* + * Window header, mark any change with '**' + */ +void EditEquipment::WindowTitle() +{ + QString txt; + + if (this->recno < 0) { + txt = QString(tr("BMSapp - Add new equipment")); + } else { + txt = QString(tr("BMSapp - Edit equipment %1").arg(this->recno)); + } + + if (this->textIsChanged) { + txt.append((QString(" **"))); + } + setWindowTitle(txt); +} + + +void EditEquipment::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 Equipment"), tr("Name empty or too short.")); + return; + } + + if (this->textIsChanged) { + if (this->recno == -1) { + query.prepare("INSERT INTO inventory_equipments SET name=:name, boil_size=:boil_size, " + "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, " + "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, " + "top_up_water=:top_up_water, trub_chiller_loss=:chiller_loss, evap_rate=:evap_rate, " + "boil_time=:boil_time, calc_boil_volume=:calcboil, top_up_kettle=:top_up_kettle, " + "hop_utilization=:hopfactor, notes=:notes, lauter_volume=:lauter_volume, " + "lauter_height=:lauter_height, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " + "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " + "efficiency=:efficiency, uuid=:uuid"); + } else { + query.prepare("UPDATE inventory_equipments SET name=:name, boil_size=:boil_size, " + "batch_size=:batch_size, tun_volume=:tun_volume, tun_weight=:tun_weight, " + "tun_specific_heat=:tun_specific_heat, tun_material=:tun_material, tun_height=:tun_height, " + "top_up_water=:top_up_water, trub_chiller_loss=:chiller_loss, evap_rate=:evap_rate, " + "boil_time=:boil_time, calc_boil_volume=:calcboil, top_up_kettle=:top_up_kettle, " + "hop_utilization=:hopfactor, notes=:notes, lauter_volume=:lauter_volume, " + "lauter_height=:lauter_height, lauter_deadspace=:lauter_deadspace, kettle_volume=:kettle_volume, " + "kettle_height=:kettle_height, mash_volume=:mash_volume, mash_max=:mash_max, " + "efficiency=:efficiency WHERE record=:recno"); + } + query.bindValue(":name", ui->nameEdit->text()); + query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 3, 'f', 2, '0')); + query.bindValue(":tun_volume", QString("%1").arg(ui->tun_volumeEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":tun_weight", QString("%1").arg(ui->tun_weightEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":tun_specific_heat", QString("%1").arg(ui->tun_specific_heatEdit->value(), 4, 'f', 3, '0')); + query.bindValue(":tun_material", ui->tun_materialEdit->currentIndex()); + query.bindValue(":tun_height", QString("%1").arg(ui->tun_heightEdit->value() / 100, 4, 'f', 3, '0')); + query.bindValue(":top_up_water", QString("%1").arg(ui->top_up_waterEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":chiller_loss", QString("%1").arg(ui->chiller_lossEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":evap_rate", QString("%1").arg(ui->evap_rateEdit->value(), 3, 'f', 2, '0')); + query.bindValue(":boil_time", QString("%1").arg(ui->boil_timeEdit->value(), 1, 'f', 0, '0')); + query.bindValue(":calcboil", ui->calcboilEdit->isChecked() ? 1:0); + query.bindValue(":top_up_kettle", QString("%1").arg(ui->top_up_kettleEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":hopfactor", QString("%1").arg(ui->hopfactorEdit->value(), 1, 'f', 0, '0')); + query.bindValue(":notes", ui->notesEdit->toPlainText()); + query.bindValue(":lauter_volume", QString("%1").arg(ui->lauter_volumeEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":lauter_height", QString("%1").arg(ui->lauter_heightEdit->value() / 100, 4, 'f', 3, '0')); + query.bindValue(":lauter_deadspace", QString("%1").arg(ui->lauter_deadspaceEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":kettle_volume", QString("%1").arg(ui->kettle_volumeEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":kettle_height", QString("%1").arg(ui->kettle_heightEdit->value() / 100, 4, 'f', 3, '0')); + query.bindValue(":mash_volume", QString("%1").arg(ui->mash_volumeEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":mash_max", QString("%1").arg(ui->mash_maxEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":efficiency", QString("%1").arg(ui->efficiencyEdit->value(), 2, 'f', 1, '0')); + 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() << "EditEquipment" << 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() << "EditEquipment Saved"; + } + } + + ui->saveButton->setEnabled(false); + this->textIsChanged = false; + WindowTitle(); +} + + +void EditEquipment::on_deleteButton_clicked() +{ + QSqlQuery query; + + query.prepare("DELETE FROM inventory_equipments WHERE record = :recno"); + query.bindValue(":recno", this->recno); + query.exec(); + if (query.lastError().isValid()) { + qDebug() << "EditEquipment" << 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() << "EditEquipment Deleted" << this->recno; + } + + this->close(); + this->setResult(1); +} + + +void EditEquipment::calcBatchVolume() +{ + double batch = ui->boil_sizeEdit->value() - (ui->evap_rateEdit->value() * ui->boil_timeEdit->value() / 60) + ui->top_up_kettleEdit->value(); + double fermenter = round(((batch / 1.04) + ui->top_up_waterEdit->value() - ui->chiller_lossEdit->value()) * 100) / 100.0; + batch = round(batch * 100) / 100.0; + ui->batch_sizeEdit->setValue(batch); + ui->vol_fermenterEdit->setValue(fermenter); +} + + +void EditEquipment::is_changed() +{ + calcBatchVolume(); + ui->saveButton->setEnabled(true); + ui->deleteButton->setEnabled((inuse == 0 && this->recno >= 0) ? true:false); + this->textIsChanged = true; + WindowTitle(); +} + + +void EditEquipment::material_changed() +{ + switch (ui->tun_materialEdit->currentIndex()) { + case 0: ui->tun_specific_heatEdit->setValue(0.11); break; + case 1: ui->tun_specific_heatEdit->setValue(0.22); break; + case 2: ui->tun_specific_heatEdit->setValue(0.46); break; + case 3: ui->tun_specific_heatEdit->setValue(0.092); break; + } + is_changed(); +} + + +void EditEquipment::on_quitButton_clicked() +{ + if (this->textIsChanged) { + int rc = QMessageBox::warning(this, tr("Equipment changed"), tr("This equipment 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); +} diff -r 76846c99f827 -r 0fec6a1abd13 src/EditEquipment.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/EditEquipment.h Sun Feb 27 20:45:41 2022 +0100 @@ -0,0 +1,38 @@ +#ifndef _EDITEQUIP_H +#define _EDITEQUIP_H + +#include + + +namespace Ui { +class EditEquipment; +} + +class EditEquipment : public QDialog +{ + Q_OBJECT + +signals: + void entry_changed(); + +public: + explicit EditEquipment(int id, QWidget *parent = 0); + ~EditEquipment(); + +private slots: + void on_saveButton_clicked(); + void on_quitButton_clicked(); + void on_deleteButton_clicked(); + void is_changed(); + void material_changed(); + +private: + Ui::EditEquipment *ui; + int recno, inuse; + bool textIsChanged = false; + + void WindowTitle(); + void calcBatchVolume(); +}; + +#endif diff -r 76846c99f827 -r 0fec6a1abd13 src/InventoryEquipments.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/InventoryEquipments.cpp Sun Feb 27 20:45:41 2022 +0100 @@ -0,0 +1,130 @@ +/** + * InventoryEquipments.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 . + */ +#include "InventoryEquipments.h" +#include "EditEquipment.h" +#include "../ui/ui_InventoryEquipments.h" +#include "config.h" +#include "bmsapp.h" + + +InventoryEquipments::InventoryEquipments(QWidget *parent) : QDialog(parent), ui(new Ui::InventoryEquipments) +{ + qDebug() << "InventoryEquipments start"; + + ui->setupUi(this); + emit refreshTable(); + + setWindowTitle( QString("BMSapp - %1 - Inventory Equipments").arg(VERSIONSTRING) ); +} + + +void InventoryEquipments::refreshTable() +{ + QString w; + + qDebug() << "InventoryEquipments reload"; + + QSqlQuery query("SELECT * FROM inventory_equipments ORDER BY name"); + const QStringList labels({tr("Name"), tr("Boil volume"), tr("Batch size"), tr("Notes"), tr("Edit")}); + const QStringList types({tr("Bittering"), tr("Aroma"), tr("Both")}); + const QStringList form({tr("Pellet"), tr("Plug"), tr("Leaf"), tr("Leaf Wet"), tr("Cryo")}); + + ui->tableEquipments->setColumnCount(5); + ui->tableEquipments->setColumnWidth(0, 180); /* Name */ + ui->tableEquipments->setColumnWidth(1, 80); /* Boil volume */ + ui->tableEquipments->setColumnWidth(2, 80); /* Batch size */ + ui->tableEquipments->setColumnWidth(3, 680); /* Notes */ + ui->tableEquipments->setColumnWidth(4, 80); /* Edit button */ + ui->tableEquipments->setRowCount(query.size()); + ui->tableEquipments->setHorizontalHeaderLabels(labels); + ui->tableEquipments->verticalHeader()->hide(); + ui->tableEquipments->setFixedSize(1100 + 24, 640); /* Even if this is too large, it works */ + + QTableWidgetItem *rightitem = new QTableWidgetItem(); + rightitem->setTextAlignment(Qt::AlignRight); + + query.first(); + for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { + ui->tableEquipments->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString())); /* Name */ + w = QString("%1 L").arg(query.value(2).toDouble(), 2, 'f', 1, '0' ); /* Boil volume */ + QTableWidgetItem *item = new QTableWidgetItem(w); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + ui->tableEquipments->setItem(ridx, 1, item); + w = QString("%1 L").arg(query.value(3).toDouble(), 2, 'f', 1, '0' ); /* Batch size */ + item = new QTableWidgetItem(w); + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + ui->tableEquipments->setItem(ridx, 2, item); + ui->tableEquipments->setItem(ridx, 3, new QTableWidgetItem(query.value(16).toString())); /* Notes */ + + /* Add the Edit button */ + QWidget* pWidget = new QWidget(); + QPushButton* btn_edit = new QPushButton(); + btn_edit->setObjectName(QString("%1").arg(query.value(0).toString())); /* Send record with the button */ + btn_edit->setText(tr("Edit")); + connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); + QHBoxLayout* pLayout = new QHBoxLayout(pWidget); + pLayout->addWidget(btn_edit); + pLayout->setContentsMargins(5, 0, 5, 0); + pWidget->setLayout(pLayout); + ui->tableEquipments->setCellWidget(ridx, 4, pWidget); + query.next(); + } + + setWindowTitle( QString("BMSapp - %1 - Inventory Equipments").arg(VERSIONSTRING) ); +} + + +InventoryEquipments::~InventoryEquipments() +{ + qDebug() << "InventoryEquipments done"; + delete ui; +} + + +void InventoryEquipments::edit(int recno) +{ + qDebug() << "InventoryEquipments edit:" << recno; + + EditEquipment dialog(recno, this); + /* Signal from editor if a refresh is needed */ + connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); + dialog.setModal(true); + dialog.exec(); +} + + +void InventoryEquipments::on_editButton_clicked() +{ + QPushButton *pb = qobject_cast(QObject::sender()); + int recno = pb->objectName().toInt(); + qDebug() << Q_FUNC_INFO << recno; + edit(recno); +} + + +void InventoryEquipments::on_insertButton_clicked() +{ + qDebug() << Q_FUNC_INFO; + edit(-1); +} + + +void InventoryEquipments::on_quitButton_clicked() +{ + emit firstWindow(); +} + diff -r 76846c99f827 -r 0fec6a1abd13 src/InventoryEquipments.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/InventoryEquipments.h Sun Feb 27 20:45:41 2022 +0100 @@ -0,0 +1,32 @@ +#ifndef _INVENTORYEQUIPS_H +#define _INVENTORYEQUIPS_H + +#include + +namespace Ui { +class InventoryEquipments; +} + +class InventoryEquipments : public QDialog +{ + Q_OBJECT + +public: + explicit InventoryEquipments(QWidget *parent = nullptr); + ~InventoryEquipments(); + +signals: + void firstWindow(); + +private slots: + void on_quitButton_clicked(); + void on_insertButton_clicked(); + void on_editButton_clicked(); + void refreshTable(void); + +private: + Ui::InventoryEquipments *ui; + void edit(int recno); +}; + +#endif diff -r 76846c99f827 -r 0fec6a1abd13 src/MainWindow.cpp --- a/src/MainWindow.cpp Sat Feb 26 16:34:20 2022 +0100 +++ b/src/MainWindow.cpp Sun Feb 27 20:45:41 2022 +0100 @@ -22,6 +22,7 @@ #include "InventoryYeasts.h" #include "InventoryMiscs.h" #include "InventoryWaters.h" +#include "InventoryEquipments.h" #include "Setup.h" #include "../ui/ui_MainWindow.h" #include "config.h" @@ -164,6 +165,24 @@ } +void MainWindow::fromInventoryEquipments() +{ + qDebug() << Q_FUNC_INFO; + delete InventoryEquipmentsWindow; + this->show(); +} + + +void MainWindow::on_actionEquipments_triggered() +{ + qDebug() << Q_FUNC_INFO; + InventoryEquipmentsWindow = new InventoryEquipments(this); + QObject::connect(InventoryEquipmentsWindow, SIGNAL(firstWindow()), this, SLOT(fromInventoryEquipments())); + this->hide(); // Close the main window + InventoryEquipmentsWindow->show(); // Show a second window +} + + void MainWindow::fromSetup() { qDebug() << Q_FUNC_INFO; diff -r 76846c99f827 -r 0fec6a1abd13 src/MainWindow.h --- a/src/MainWindow.h Sat Feb 26 16:34:20 2022 +0100 +++ b/src/MainWindow.h Sun Feb 27 20:45:41 2022 +0100 @@ -7,6 +7,7 @@ #include "InventoryYeasts.h" #include "InventoryMiscs.h" #include "InventoryWaters.h" +#include "InventoryEquipments.h" #include "Setup.h" #include @@ -34,6 +35,7 @@ void on_actionYeasts_triggered(); void on_actionMiscs_triggered(); void on_actionWaters_triggered(); + void on_actionEquipments_triggered(); void on_actionSetup_triggered(); void on_actionAbout_triggered(); @@ -44,6 +46,7 @@ void fromInventoryYeasts(); void fromInventoryMiscs(); void fromInventoryWaters(); + void fromInventoryEquipments(); void fromSetup(); private: @@ -56,6 +59,7 @@ InventoryYeasts *InventoryYeastsWindow; InventoryMiscs *InventoryMiscsWindow; InventoryWaters *InventoryWatersWindow; + InventoryEquipments *InventoryEquipmentsWindow; Setup *SetupWindow; }; diff -r 76846c99f827 -r 0fec6a1abd13 ui/EditEquipment.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/EditEquipment.ui Sun Feb 27 20:45:41 2022 +0100 @@ -0,0 +1,1226 @@ + + + EditEquipment + + + + 0 + 0 + 1024 + 597 + + + + Dialog + + + + + + + + 40 + 10 + 91 + 20 + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 40 + 40 + 91 + 20 + + + + Notes: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 140 + 10 + 511 + 23 + + + + 128 + + + Name of this equipment + + + + + + 140 + 40 + 791 + 61 + + + + Notes and usage tips. + + + + + + 70 + 550 + 80 + 23 + + + + + 0 + 0 + + + + Quit + + + + :icons/silk/door_out.png:icons/silk/door_out.png + + + + + false + + + + 850 + 550 + 80 + 23 + + + + Save + + + + :icons/silk/disk.png:icons/silk/disk.png + + + + + false + + + + 463 + 550 + 80 + 23 + + + + Delete + + + + :icons/silk/delete.png:icons/silk/delete.png + + + + + + 720 + 10 + 141 + 16 + + + + Calculate boil volume: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 870 + 10 + 85 + 21 + + + + Yes + + + + + + 70 + 110 + 401 + 251 + + + + Mashing + + + Qt::AlignCenter + + + true + + + + + 200 + 30 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 10 + 30 + 181 + 20 + + + + Tun volume L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 60 + 181 + 20 + + + + Tun height cm: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 90 + 181 + 20 + + + + Tun weight kg: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 120 + 181 + 20 + + + + Tun material: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 150 + 181 + 20 + + + + Tun specific heat: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 180 + 181 + 20 + + + + Mash water L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 210 + 181 + 20 + + + + Maximum malts kg: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 200 + 60 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 90 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.100000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 150 + 71 + 24 + + + + true + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + false + + + 3 + + + 100000.000000000000000 + + + 0.010000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 180 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 210 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 120 + 121 + 23 + + + + + + + + 70 + 370 + 401 + 161 + + + + Lautering + + + Qt::AlignCenter + + + + + 10 + 30 + 181 + 20 + + + + Lauter volume L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 60 + 181 + 20 + + + + Lauter height cm: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 90 + 181 + 20 + + + + Lauter deadspace L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 120 + 181 + 20 + + + + Brewhouse efficiency %: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 200 + 30 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 60 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 90 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.100000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 120 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + + 530 + 110 + 401 + 281 + + + + Boiling + + + + + 10 + 30 + 181 + 20 + + + + Kettle volume L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 200 + 30 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 10 + 60 + 181 + 20 + + + + Kettle heigh cmt: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 200 + 60 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 10 + 90 + 181 + 20 + + + + Boil size L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 200 + 90 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.500000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 10 + 120 + 181 + 20 + + + + Evaporation L/hour: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 150 + 181 + 20 + + + + Boil time minutes: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 180 + 181 + 20 + + + + Top up kettle L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 210 + 181 + 20 + + + + Hop utilization %: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 240 + 181 + 20 + + + + Batch size L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 200 + 120 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 2 + + + 100000.000000000000000 + + + 0.010000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 150 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 0 + + + 1440.000000000000000 + + + 1.000000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 180 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.100000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 210 + 121 + 24 + + + + 100% for small breweries, higher for large breweries. + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 0 + + + 200.000000000000000 + + + 1.000000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 240 + 107 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + true + + + 2 + + + 100000.000000000000000 + + + 0.010000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + + 530 + 400 + 401 + 131 + + + + Chilling + + + Qt::AlignCenter + + + + + 10 + 30 + 181 + 20 + + + + Trub chiller loss L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 200 + 30 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.100000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 10 + 60 + 181 + 20 + + + + Extra water in fermenter L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 90 + 181 + 20 + + + + Volume in fermenter L: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 200 + 60 + 121 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + 1 + + + 100000.000000000000000 + + + 0.100000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + 200 + 90 + 107 + 24 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + QAbstractSpinBox::NoButtons + + + true + + + 2 + + + 100000.000000000000000 + + + 0.010000000000000 + + + QAbstractSpinBox::DefaultStepType + + + + + + + + + nameEdit + notesEdit + tun_volumeEdit + quitButton + deleteButton + saveButton + + + + + + diff -r 76846c99f827 -r 0fec6a1abd13 ui/InventoryEquipments.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/InventoryEquipments.ui Sun Feb 27 20:45:41 2022 +0100 @@ -0,0 +1,141 @@ + + + InventoryEquipments + + + + 0 + 0 + 1280 + 640 + + + + Dialog + + + + + + true + + + + + + + true + + + false + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 80 + 24 + + + + Quit + + + + :icons/silk/door_out.png:icons/silk/door_out.png + + + + + + + + 0 + 0 + + + + + 80 + 24 + + + + Export + + + + + + + + 0 + 0 + + + + + 80 + 24 + + + + Import + + + + + + + + 0 + 0 + + + + + 80 + 24 + + + + New + + + + :icons/silk/table_row_insert.png:icons/silk/table_row_insert.png + + + + + + + + + + + + + diff -r 76846c99f827 -r 0fec6a1abd13 ui/MainWindow.ui --- a/ui/MainWindow.ui Sat Feb 26 16:34:20 2022 +0100 +++ b/ui/MainWindow.ui Sun Feb 27 20:45:41 2022 +0100 @@ -254,7 +254,7 @@ - false + true