# HG changeset patch # User Michiel Broek # Date 1651157279 -7200 # Node ID 8514932b61aada8d05dcdb2cbcb9af926bf566fa # Parent b93f5e5afc6778cc3154e5d4fdef67e06f133acf Added menu entry products in production diff -r b93f5e5afc67 -r 8514932b61aa CMakeLists.txt --- a/CMakeLists.txt Thu Apr 28 13:17:36 2022 +0200 +++ b/CMakeLists.txt Thu Apr 28 16:47:59 2022 +0200 @@ -179,6 +179,7 @@ ${SRCDIR}/ProfileFerments.cpp ${SRCDIR}/EditProfileFerment.cpp ${SRCDIR}/EditRecipe.cpp + ${SRCDIR}/ProdInprod.cpp ${SRCDIR}/Setup.cpp ${SRCDIR}/Utils.cpp ${SRCDIR}/PrinterDialog.cpp @@ -215,6 +216,7 @@ ${SRCDIR}/ProfileFerments.h ${SRCDIR}/EditProfileFerment.h ${SRCDIR}/EditRecipe.h + ${SRCDIR}/ProdInprod.h ${SRCDIR}/Setup.h ${SRCDIR}/Utils.h ${SRCDIR}/PrinterDialog.h diff -r b93f5e5afc67 -r 8514932b61aa src/MainWindow.cpp --- a/src/MainWindow.cpp Thu Apr 28 13:17:36 2022 +0200 +++ b/src/MainWindow.cpp Thu Apr 28 16:47:59 2022 +0200 @@ -24,6 +24,7 @@ #include "InventoryMiscs.h" #include "InventoryWaters.h" #include "InventoryEquipments.h" +#include "ProdInprod.h" #include "ProfileWaters.h" #include "ProfileMashs.h" #include "ProfileStyles.h" @@ -500,6 +501,30 @@ } +void MainWindow::fromProdInprod() +{ + qDebug() << Q_FUNC_INFO; + ui->mainStack->setCurrentIndex(-1); + ui->mainStack->removeWidget(ProdInprodWindow); + delete ProdInprodWindow; + setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) ); + ui->menuBar->setVisible(true); + statusBar()->clearMessage(); +} + + +void MainWindow::on_actionProd_inprod_triggered() +{ + qDebug() << Q_FUNC_INFO; + ProdInprodWindow = new ProdInprod(this); + int index = ui->mainStack->count(); + ui->mainStack->addWidget(ProdInprodWindow); + ui->mainStack->setCurrentIndex(index); + setWindowTitle(QString("BMSapp - %1 - Products in production").arg(VERSIONSTRING)); + ui->menuBar->setVisible(false); +} + + void MainWindow::fromProfileWaters() { qDebug() << Q_FUNC_INFO; diff -r b93f5e5afc67 -r 8514932b61aa src/MainWindow.h --- a/src/MainWindow.h Thu Apr 28 13:17:36 2022 +0200 +++ b/src/MainWindow.h Thu Apr 28 16:47:59 2022 +0200 @@ -9,6 +9,7 @@ #include "InventoryMiscs.h" #include "InventoryWaters.h" #include "InventoryEquipments.h" +#include "ProdInprod.h" #include "ProfileWaters.h" #include "ProfileMashs.h" #include "ProfileStyles.h" @@ -79,20 +80,6 @@ static IniWS wsDev; -//struct Acid -//{ -// QString name; -// double pK1; -// double pK2; -// double pK3; -// double MolWt; -// double AcidSG; -// double AcidPrc; -//}; - -//static QList my_acids; - - namespace Ui { class MainWindow; } @@ -114,6 +101,7 @@ InventoryMiscs *InventoryMiscsWindow; InventoryWaters *InventoryWatersWindow; InventoryEquipments *InventoryEquipmentsWindow; + ProdInprod *ProdInprodWindow; ProfileWaters *ProfileWatersWindow; ProfileMashs *ProfileMashsWindow; ProfileStyles *ProfileStylesWindow; @@ -122,6 +110,7 @@ private slots: void on_actionExit_triggered(); + void on_actionProd_inprod_triggered(); void on_actionRecipes_triggered(); void on_actionSuppliers_triggered(); void on_actionFermentables_triggered(); @@ -148,6 +137,7 @@ void fromInventoryMiscs(); void fromInventoryWaters(); void fromInventoryEquipments(); + void fromProdInprod(); void fromProfileWaters(); void fromProfileMashs(); void fromProfileStyles(); diff -r b93f5e5afc67 -r 8514932b61aa src/ProdInprod.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ProdInprod.cpp Thu Apr 28 16:47:59 2022 +0200 @@ -0,0 +1,157 @@ +/** + * ProdInprod.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 "ProdInprod.h" +#include "MainWindow.h" +#include "config.h" +#include "global.h" + + +ProdInprod::ProdInprod(QWidget *parent) : QDialog(parent) +{ + qDebug() << "ProdInprod start"; + + gridLayout = new QGridLayout(this); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + tableInprod = new QTableWidget(this); + tableInprod->setObjectName(QString::fromUtf8("tableInprod")); + tableInprod->setEnabled(true); + QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(tableInprod->sizePolicy().hasHeightForWidth()); + tableInprod->setSizePolicy(sizePolicy); + tableInprod->setMinimumSize(QSize(1164, 0)); + gridLayout->addWidget(tableInprod, 0, 0, 1, 1); + + groupBox = new QGroupBox(this); + groupBox->setObjectName(QString::fromUtf8("groupBox")); + groupBox->setEnabled(true); + groupBox->setFlat(false); + + horizontalLayout = new QHBoxLayout(groupBox); + horizontalLayout->setSpacing(6); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + horizontalLayout->setContentsMargins(0, 0, 0, 0); + + quitButton = new QPushButton(groupBox); + quitButton->setObjectName(QString::fromUtf8("quitButton")); + quitButton->setMinimumSize(QSize(80, 24)); + quitButton->setText(tr("Quit")); + QIcon icon; + icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); + quitButton->setIcon(icon); + horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft); + + insertButton = new QPushButton(groupBox); + insertButton->setObjectName(QString::fromUtf8("insertButton")); + insertButton->setMinimumSize(QSize(80, 24)); + insertButton->setText(tr("New")); + QIcon icon1; + icon1.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off); + insertButton->setIcon(icon1); + horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight); + gridLayout->addWidget(groupBox, 1, 0, 1, 1); + + connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromProdInprod())); + //connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); + connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString))); + emit refreshTable(); +} + + +void ProdInprod::refreshTable() +{ + QString w; + QWidget* pWidget; + QHBoxLayout* pLayout; + + qDebug() << "ProdInprod reload"; + QSqlQuery query("SELECT record,name,code,birth,stage,brew_date_start,package_date,st_name FROM products WHERE stage != '11' ORDER BY stage,code,birth"); + const QStringList labels({tr("Date"), tr("Code"), tr("Style"), tr("Product"), tr("Stage"), tr("Edit")}); + + this->tableInprod->setColumnCount(6); + this->tableInprod->setColumnWidth(0, 100); /* Date */ + this->tableInprod->setColumnWidth(1, 100); /* Code */ + this->tableInprod->setColumnWidth(2, 150); /* Style */ + this->tableInprod->setColumnWidth(3, 500); /* Product */ + this->tableInprod->setColumnWidth(4, 200); /* Stage */ + this->tableInprod->setColumnWidth(5, 90); /* Edit button */ + this->tableInprod->setRowCount(query.size()); + this->tableInprod->setHorizontalHeaderLabels(labels); + this->tableInprod->verticalHeader()->hide(); + /* Set the widget size to 1064 x 575 in the ui. */ + + query.first(); + for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { + + this->tableInprod->setItem(ridx, 0, new QTableWidgetItem(query.value("birth").toDate().toString("dd MMM yyyy"))); + this->tableInprod->setItem(ridx, 1, new QTableWidgetItem(query.value("code").toString())); + this->tableInprod->setItem(ridx, 2, new QTableWidgetItem(query.value("st_name").toString())); + this->tableInprod->setItem(ridx, 3, new QTableWidgetItem(query.value("name").toString())); + + int stage = query.value("stage").toInt(); + QString fase = prod_stages[stage]; + if (stage == PROD_STAGE_BREW) { + fase = prod_stages[stage] + tr(" on ") + query.value("brew_date_start").toDate().toString("dd MMM yyyy"); + } else if (stage == PROD_STAGE_CARBONATION) { + int timeDiff = query.value("package_date").toDate().daysTo(QDate::currentDate()); + fase = prod_stages[stage] + QString(tr(" day %1 of day 14")).arg(timeDiff); + } else if (stage == PROD_STAGE_MATURE) { + int timeDiff = query.value("package_date").toDate().daysTo(QDate::currentDate()) - 14; + fase = prod_stages[stage] + QString(tr(" day %1 of day 28")).arg(timeDiff); + } + this->tableInprod->setItem(ridx, 4, new QTableWidgetItem(fase)); + + /* 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); + this->tableInprod->setCellWidget(ridx, 5, pWidget); + query.next(); + } + + emit setStatus(QString(tr("Total items: %1")).arg(query.size())); +} + + +ProdInprod::~ProdInprod() {} + + +void ProdInprod::edit(int recno) +{ +// EditProfileMash 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 ProdInprod::on_editButton_clicked() +{ + QPushButton *pb = qobject_cast(QObject::sender()); + int recno = pb->objectName().toInt(); + edit(recno); +} + + diff -r b93f5e5afc67 -r 8514932b61aa src/ProdInprod.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ProdInprod.h Thu Apr 28 16:47:59 2022 +0200 @@ -0,0 +1,42 @@ +#ifndef _PRODINPROD_H +#define _PRODINPROD_H + +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { +class ProdInprod; +} + +class ProdInprod : public QDialog +{ + Q_OBJECT + +public: + explicit ProdInprod(QWidget *parent = nullptr); + ~ProdInprod(); + +signals: + void setStatus(QString); + +private slots: + void on_editButton_clicked(); + void refreshTable(void); + +private: + QGridLayout *gridLayout; + QTableWidget *tableInprod; + QGroupBox *groupBox; + QHBoxLayout *horizontalLayout; + QPushButton *quitButton; + QPushButton *insertButton; + + void edit(int recno); +}; + +#endif diff -r b93f5e5afc67 -r 8514932b61aa src/global.cpp --- a/src/global.cpp Thu Apr 28 13:17:36 2022 +0200 +++ b/src/global.cpp Thu Apr 28 16:47:59 2022 +0200 @@ -22,6 +22,31 @@ Recipe *recipe; +const QStringList prod_stages({ + QObject::tr("Plan"), + QObject::tr("Wait"), + QObject::tr("Brew"), + QObject::tr("Primary"), + QObject::tr("Secondary"), + QObject::tr("Tertiary"), + QObject::tr("Package"), + QObject::tr("Carbonation"), + QObject::tr("Mature"), + QObject::tr("Taste"), + QObject::tr("Ready"), + QObject::tr("Closed") +}); + +const QStringList prod_split({ + QObject::tr("Not divided"), + QObject::tr("After mash"), + QObject::tr("After boil"), + QObject::tr("After cooling"), + QObject::tr("After primary"), + QObject::tr("After secondary"), + QObject::tr("After tertiary") +}); + const QStringList recipe_types({ QObject::tr("Extract"), QObject::tr("Partial Mash"), diff -r b93f5e5afc67 -r 8514932b61aa src/global.h --- a/src/global.h Thu Apr 28 13:17:36 2022 +0200 +++ b/src/global.h Thu Apr 28 16:47:59 2022 +0200 @@ -551,6 +551,23 @@ extern int my_default_water; extern QString my_yeastlab; +enum ProdStages { + PROD_STAGE_PLAN, + PROD_STAGE_WAIT, + PROD_STAGE_BREW, + PROD_STAGE_PRIMARY, + PROD_STAGE_SECONDARY, + PROD_STAGE_TERTIARY, + PROD_STAGE_PACKAGE, + PROD_STAGE_CARBONATION, + PROD_STAGE_MATURE, + PROD_STAGE_TASTE, + PROD_STAGE_READY, + PROD_STAGE_CLOSED +}; + +extern const QStringList prod_stages; +extern const QStringList prod_split; extern const QStringList recipe_types; extern const QStringList style_types; extern const QStringList fermentable_types; diff -r b93f5e5afc67 -r 8514932b61aa ui/MainWindow.ui --- a/ui/MainWindow.ui Thu Apr 28 13:17:36 2022 +0200 +++ b/ui/MainWindow.ui Thu Apr 28 16:47:59 2022 +0200 @@ -96,6 +96,7 @@ Products + @@ -351,6 +352,15 @@ Import beerxml + + + + :/icons/bms/beerstyles.png:/icons/bms/beerstyles.png + + + In Production + +