Added the inventory miscs table.

Fri, 25 Feb 2022 10:51:36 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 25 Feb 2022 10:51:36 +0100
changeset 28
93a70b1502ca
parent 27
94da58c66913
child 29
76846c99f827

Added the inventory miscs table.

CMakeLists.txt file | annotate | diff | comparison | revisions
src/EditMisc.cpp file | annotate | diff | comparison | revisions
src/EditMisc.h file | annotate | diff | comparison | revisions
src/InventoryMiscs.cpp file | annotate | diff | comparison | revisions
src/InventoryMiscs.h file | annotate | diff | comparison | revisions
src/MainWindow.cpp file | annotate | diff | comparison | revisions
src/MainWindow.h file | annotate | diff | comparison | revisions
ui/EditMisc.ui file | annotate | diff | comparison | revisions
ui/MainWindow.ui file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Thu Feb 24 14:36:56 2022 +0100
+++ b/CMakeLists.txt	Fri Feb 25 10:51:36 2022 +0100
@@ -106,6 +106,8 @@
     ${SRCDIR}/EditHop.cpp
     ${SRCDIR}/InventoryYeasts.cpp
     ${SRCDIR}/EditYeast.cpp
+    ${SRCDIR}/InventoryMiscs.cpp
+    ${SRCDIR}/EditMisc.cpp
     ${SRCDIR}/Setup.cpp
     ${SRCDIR}/Utils.cpp
     ${SRCDIR}/MainWindow.cpp
@@ -124,6 +126,8 @@
     ${SRCDIR}/EditHop.h
     ${SRCDIR}/InventoryYeasts.h
     ${SRCDIR}/EditYeast.h
+    ${SRCDIR}/InventoryMiscs.h
+    ${SRCDIR}/EditMisc.h
     ${SRCDIR}/Setup.h
     ${SRCDIR}/Utils.h
     ${SRCDIR}/MainWindow.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/EditMisc.cpp	Fri Feb 25 10:51:36 2022 +0100
@@ -0,0 +1,290 @@
+/**
+ * EditMisc.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 "EditMisc.h"
+#include "../ui/ui_EditMisc.h"
+#include "bmsapp.h"
+
+
+EditMisc::EditMisc(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditMisc)
+{
+    QSqlQuery query;
+
+    qDebug() << "EditMisc record:" << id;
+    ui->setupUi(this);
+    this->recno = id;
+
+    WindowTitle();
+
+    ui->typeEdit->addItem(tr("Spice"));
+    ui->typeEdit->addItem(tr("Herb"));
+    ui->typeEdit->addItem(tr("Flavor"));
+    ui->typeEdit->addItem(tr("Fining"));
+    ui->typeEdit->addItem(tr("Water agent"));
+    ui->typeEdit->addItem(tr("Yeast nutrient"));
+    ui->typeEdit->addItem(tr("Other"));
+
+    ui->useEdit->addItem(tr("Starter"));
+    ui->useEdit->addItem(tr("Mash"));
+    ui->useEdit->addItem(tr("Boil"));
+    ui->useEdit->addItem(tr("Primary"));
+    ui->useEdit->addItem(tr("Secondary"));
+    ui->useEdit->addItem(tr("Bottling"));
+
+    if (id >= 0) {
+	query.prepare("SELECT * FROM inventory_miscs WHERE record = :recno");
+	query.bindValue(":recno", id);
+	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());
+        } else {
+            ui->prodEdit->clear();
+        }
+	if (query.value(12).toString().length() == 10) {
+	    ui->thtEdit->setDate(query.value(12).toDate());
+	} else {
+	    ui->thtEdit->clear();
+	}
+    } else {
+	/* Set some defaults */
+	ui->typeEdit->setCurrentIndex(0);
+	ui->useEdit->setCurrentIndex(0);
+	ui->timeEdit->setValue(0);
+	ui->prodEdit->clear();
+	ui->thtEdit->clear();
+    }
+    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->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->thtEdit, &QDateEdit::dateChanged, this, &EditMisc::is_changed);
+
+    ui->saveButton->setEnabled(false);
+    ui->deleteButton->setEnabled((ui->inventoryEdit->value() == 0 && id >= 0) ? true:false);
+}
+
+
+EditMisc::~EditMisc()
+{
+    qDebug() << "EditMisc done";
+    delete ui;
+    emit entry_changed();
+}
+
+
+/*
+ * Window header, mark any change with '**'
+ */
+void EditMisc::WindowTitle()
+{
+    QString txt;
+
+    if (this->recno < 0) {
+	txt = QString(tr("BMSapp - Add new misc ingredient"));
+    } else {
+	txt = QString(tr("BMSapp - Edit misc ingredient %1").arg(this->recno));
+    }
+
+    if (this->textIsChanged) {
+	txt.append((QString(" **")));
+    }
+    setWindowTitle(txt);
+}
+
+
+void EditMisc::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 Misc"), tr("Name empty or too short."));
+	return;
+    }
+
+    if (this->textIsChanged) {
+    	if (this->recno == -1) {
+    	    query.prepare("INSERT INTO inventory_miscs SET name=:name, type=:type, use_use=:use, "
+		"time=:time, amount_is_weight=:isweight, use_for=:usefor, notes=:notes, "
+		"always_on_stock=:always, inventory=:inventory, cost=:cost, production_date=:prod, "
+		"tht_date=:tht, uuid = :uuid");
+    	} else {
+	    query.prepare("UPDATE inventory_miscs SET name=:name, type=:type, use_use=:use, "
+		"time=:time, amount_is_weight=:isweight, use_for=:usefor, notes=:notes, "
+		"always_on_stock=:always, 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(":use", ui->useEdit->currentIndex());
+	query.bindValue(":time", ui->timeEdit->value());
+	query.bindValue(":isweight", ui->isweightEdit->isChecked() ? 1:0);
+	query.bindValue(":usefor", ui->useforEdit->toPlainText());
+	query.bindValue(":notes", ui->notesEdit->toPlainText());
+	query.bindValue(":always", ui->alwaysEdit->isChecked() ? 1:0);
+	query.bindValue(":inventory", QString("%1").arg(ui->inventoryEdit->value() / 1000.0, 5, 'f', 4, '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() << "EditMisc" << 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() << "EditMisc Saved";
+	}
+    }
+
+    ui->saveButton->setEnabled(false);
+    this->textIsChanged = false;
+    WindowTitle();
+}
+
+
+void EditMisc::on_deleteButton_clicked()
+{
+    QSqlQuery query;
+
+    query.prepare("DELETE FROM inventory_miscs WHERE record = :recno");
+    query.bindValue(":recno", this->recno);
+    query.exec();
+    if (query.lastError().isValid()) {
+	qDebug() << "EditMisc" << 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() << "EditMisc Deleted" << this->recno;
+    }
+
+    this->close();
+    this->setResult(1);
+}
+
+
+void EditMisc::TimeSet()
+{
+    int	time = ui->timeEdit->value();
+    QString w = QString("");
+
+    if (time == 0) {
+	ui->timeEdit->setSingleStep(1);
+
+    } else if (time == 1) {
+	w = QString("1 minute");
+	ui->timeEdit->setSingleStep(1);
+
+    } else if (time < 180) {
+	w = QString("%1 minutes").arg(time);
+	ui->timeEdit->setSingleStep(1);
+
+    } else if (time == 180) {
+	w = QString("3 hours");
+	if (lasttime == 240)
+	    ui->timeEdit->setSingleStep(1);	/* Going down */
+	else
+	    ui->timeEdit->setSingleStep(60);
+
+    } else if (time < 1440) {
+	w = QString("%1 hours").arg(time / 60);
+	ui->timeEdit->setSingleStep(60);
+
+    } else if (time == 1440) {
+	w = QString("1 day");
+	if (lasttime == 2880)
+	    ui->timeEdit->setSingleStep(60);	/* Going down */
+	else
+	    ui->timeEdit->setSingleStep(1440);
+
+    } else {
+	w = QString("%1 days").arg(time / 1440);
+	ui->timeEdit->setSingleStep(1440);
+
+    }
+    ui->timeShow->setText(w);
+    lasttime = time;
+}
+
+
+void EditMisc::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 EditMisc::time_changed()
+{
+    TimeSet();
+    is_changed();
+}
+
+
+void EditMisc::on_quitButton_clicked()
+{
+    if (this->textIsChanged) {
+	int rc = QMessageBox::warning(this, tr("Misc changed"), tr("The ingredient 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/EditMisc.h	Fri Feb 25 10:51:36 2022 +0100
@@ -0,0 +1,38 @@
+#ifndef _EDITMISC_H
+#define _EDITMISC_H
+
+#include <QDialog>
+
+
+namespace Ui {
+class EditMisc;
+}
+
+class EditMisc : public QDialog
+{
+    Q_OBJECT
+
+signals:
+    void entry_changed();
+
+public:
+    explicit EditMisc(int id, QWidget *parent = 0);
+    ~EditMisc();
+
+private slots:
+    void on_saveButton_clicked();
+    void on_quitButton_clicked();
+    void on_deleteButton_clicked();
+    void is_changed();
+    void time_changed();
+
+private:
+    Ui::EditMisc *ui;
+    int recno, lasttime = 0;
+    bool textIsChanged = false;
+
+    void WindowTitle();
+    void TimeSet();
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/InventoryMiscs.cpp	Fri Feb 25 10:51:36 2022 +0100
@@ -0,0 +1,154 @@
+/**
+ * InventoryMiscs.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 "InventoryMiscs.h"
+#include "EditMisc.h"
+#include "../ui/ui_InventoryMiscs.h"
+#include "config.h"
+#include "bmsapp.h"
+
+
+InventoryMiscs::InventoryMiscs(QWidget *parent) : QDialog(parent), ui(new Ui::InventoryMiscs)
+{
+    qDebug() << "InventoryMiscs start";
+
+    ui->setupUi(this);
+    emit refreshTable();
+
+    setWindowTitle( QString("BMSapp - %1 - Inventory Miscs").arg(VERSIONSTRING) );
+}
+
+
+void InventoryMiscs::refreshTable()
+{
+    QString w;
+
+    qDebug() << "InventoryMiscs reload";
+
+    QSqlQuery query("SELECT * FROM inventory_miscs ORDER BY name");
+    const QStringList labels({tr("Name"), tr("Type"), tr("Use"), tr("Time"), tr("Stock"), tr("Edit")});
+    const QStringList types({tr("Spice"), tr("Herb"), tr("Flavor"), tr("Fining"), tr("Water agent"), tr("Yeast nutrient"), tr("Other")});
+    const QStringList use({tr("Starter"), tr("Mash"), tr("Boil"), tr("Primary"), tr("Secondary"), tr("Bottling")});
+
+    /* origin supplier name type graintype color yield inventory Edit */
+    ui->tableMiscs->setColumnCount(6);
+    ui->tableMiscs->setColumnWidth(0, 275);	/* Name		*/
+    ui->tableMiscs->setColumnWidth(1, 120);	/* Type		*/
+    ui->tableMiscs->setColumnWidth(2, 120);	/* Use 		*/
+    ui->tableMiscs->setColumnWidth(3, 120);	/* Time		*/
+    ui->tableMiscs->setColumnWidth(4,  80);	/* Stock	*/
+    ui->tableMiscs->setColumnWidth(5,  80);	/* Edit button	*/
+    ui->tableMiscs->setRowCount(query.size());
+    ui->tableMiscs->setHorizontalHeaderLabels(labels);
+    ui->tableMiscs->verticalHeader()->hide();
+    ui->tableMiscs->setFixedSize(795 + 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->tableMiscs->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString()));	/* Name */
+	ui->tableMiscs->setItem(ridx, 1, new QTableWidgetItem(types[query.value(2).toInt()]));	/* Type */
+	ui->tableMiscs->setItem(ridx, 2, new QTableWidgetItem(use[query.value(3).toInt()]));	/* Use */
+
+	w = QString("");	/* Use time */
+	if (query.value(4).toInt() > 0) {
+	  if (query.value(4).toInt() == 1)
+	    w = QString("1 minute");
+	  else if (query.value(4).toInt() < 180)
+	    w = QString("%1 minutes").arg(query.value(4).toInt());
+	  else if (query.value(4).toInt() < 1440)
+	    w = QString("%1 hours").arg(query.value(4).toInt() / 60);
+	  else if (query.value(4).toInt() == 1440)
+	    w = QString("1 day");
+	  else
+	    w = QString("%1 days").arg(query.value(4).toInt() / 1440);
+	}
+	QTableWidgetItem *item = new QTableWidgetItem(w);
+        item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+        ui->tableMiscs->setItem(ridx, 3, item);
+
+	w = QString("");
+	if (query.value(9).toDouble() > 0) {
+	  if (query.value(5).toInt()) { /* Amount is weight */
+	    w = QString("%1 gr").arg(query.value(9).toDouble() * 1000.0, 2, 'f', 1, '0' );
+	  } else {
+            w = QString("%1 ml").arg(query.value(9).toDouble() * 1000.0, 2, 'f', 1, '0' );
+	  }
+	}
+	item = new QTableWidgetItem(w);
+	item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+	ui->tableMiscs->setItem(ridx, 4, item);
+
+	/* 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->tableMiscs->setCellWidget(ridx, 5, pWidget);
+	query.next();
+    }
+
+    setWindowTitle( QString("BMSapp - %1 - Inventory Miscs").arg(VERSIONSTRING) );
+}
+
+
+InventoryMiscs::~InventoryMiscs()
+{
+    qDebug() << "InventoryMiscs done";
+    delete ui;
+}
+
+
+void InventoryMiscs::edit(int recno)
+{
+    qDebug() << "InventoryMiscs edit:" << recno;
+
+    EditMisc 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 InventoryMiscs::on_editButton_clicked()
+{
+    QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
+    int recno = pb->objectName().toInt();
+    qDebug() << Q_FUNC_INFO << recno;
+    edit(recno);
+}
+
+
+void InventoryMiscs::on_insertButton_clicked()
+{
+    qDebug() << Q_FUNC_INFO;
+    edit(-1);
+}
+
+
+void InventoryMiscs::on_quitButton_clicked()
+{
+    emit firstWindow();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/InventoryMiscs.h	Fri Feb 25 10:51:36 2022 +0100
@@ -0,0 +1,32 @@
+#ifndef _INVENTORYMISCS_H
+#define _INVENTORYMISCS_H
+
+#include <QDialog>
+
+namespace Ui {
+class InventoryMiscs;
+}
+
+class InventoryMiscs : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit InventoryMiscs(QWidget *parent = nullptr);
+    ~InventoryMiscs();
+
+signals:
+    void firstWindow();
+
+private slots:
+    void on_quitButton_clicked();
+    void on_insertButton_clicked();
+    void on_editButton_clicked();
+    void refreshTable(void);
+
+private:
+    Ui::InventoryMiscs *ui;
+    void edit(int recno);
+};
+
+#endif
--- a/src/MainWindow.cpp	Thu Feb 24 14:36:56 2022 +0100
+++ b/src/MainWindow.cpp	Fri Feb 25 10:51:36 2022 +0100
@@ -20,6 +20,7 @@
 #include "InventoryFermentables.h"
 #include "InventoryHops.h"
 #include "InventoryYeasts.h"
+#include "InventoryMiscs.h"
 #include "Setup.h"
 #include "../ui/ui_MainWindow.h"
 #include "config.h"
@@ -126,6 +127,24 @@
 }
 
 
+void MainWindow::fromInventoryMiscs()
+{
+    qDebug() << Q_FUNC_INFO;
+    delete InventoryMiscsWindow;
+    this->show();
+}
+
+
+void MainWindow::on_actionMiscs_triggered()
+{
+    qDebug() << Q_FUNC_INFO;
+    InventoryMiscsWindow = new InventoryMiscs(this);
+    QObject::connect(InventoryMiscsWindow, SIGNAL(firstWindow()), this, SLOT(fromInventoryMiscs()));
+    this->hide();    // Close the main window
+    InventoryMiscsWindow->show();  // Show a second window
+}
+
+
 void MainWindow::fromSetup()
 {
     qDebug() << Q_FUNC_INFO;
--- a/src/MainWindow.h	Thu Feb 24 14:36:56 2022 +0100
+++ b/src/MainWindow.h	Fri Feb 25 10:51:36 2022 +0100
@@ -5,6 +5,7 @@
 #include "InventoryFermentables.h"
 #include "InventoryHops.h"
 #include "InventoryYeasts.h"
+#include "InventoryMiscs.h"
 #include "Setup.h"
 
 #include <QMainWindow>
@@ -30,6 +31,7 @@
     void on_actionFermentables_triggered();
     void on_actionHops_triggered();
     void on_actionYeasts_triggered();
+    void on_actionMiscs_triggered();
     void on_actionSetup_triggered();
     void on_actionAbout_triggered();
 
@@ -38,6 +40,7 @@
     void fromInventoryFermentables();
     void fromInventoryHops();
     void fromInventoryYeasts();
+    void fromInventoryMiscs();
     void fromSetup();
 
 private:
@@ -48,6 +51,7 @@
     InventoryFermentables *InventoryFermentablesWindow;
     InventoryHops *InventoryHopsWindow;
     InventoryYeasts *InventoryYeastsWindow;
+    InventoryMiscs *InventoryMiscsWindow;
     Setup *SetupWindow;
 };
 
--- a/ui/EditMisc.ui	Thu Feb 24 14:36:56 2022 +0100
+++ b/ui/EditMisc.ui	Fri Feb 25 10:51:36 2022 +0100
@@ -51,8 +51,8 @@
      <widget class="QLabel" name="inventoryLabel">
       <property name="geometry">
        <rect>
-        <x>5</x>
-        <y>410</y>
+        <x>680</x>
+        <y>130</y>
         <width>121</width>
         <height>20</height>
        </rect>
@@ -67,8 +67,8 @@
      <widget class="QLabel" name="costLabel">
       <property name="geometry">
        <rect>
-        <x>5</x>
-        <y>440</y>
+        <x>680</x>
+        <y>160</y>
         <width>121</width>
         <height>20</height>
        </rect>
@@ -83,8 +83,8 @@
      <widget class="QLabel" name="valueLabel">
       <property name="geometry">
        <rect>
-        <x>5</x>
-        <y>470</y>
+        <x>680</x>
+        <y>190</y>
         <width>121</width>
         <height>20</height>
        </rect>
@@ -99,9 +99,9 @@
      <widget class="QLabel" name="prodLabel">
       <property name="geometry">
        <rect>
-        <x>660</x>
-        <y>410</y>
-        <width>141</width>
+        <x>20</x>
+        <y>340</y>
+        <width>101</width>
         <height>20</height>
        </rect>
       </property>
@@ -116,7 +116,7 @@
       <property name="geometry">
        <rect>
         <x>660</x>
-        <y>440</y>
+        <y>340</y>
         <width>141</width>
         <height>20</height>
        </rect>
@@ -141,7 +141,7 @@
        <number>128</number>
       </property>
       <property name="placeholderText">
-       <string>Name of the fermentable</string>
+       <string>Name of the misc ingredient</string>
       </property>
      </widget>
      <widget class="QPlainTextEdit" name="notesEdit">
@@ -160,8 +160,8 @@
      <widget class="QDoubleSpinBox" name="inventoryEdit">
       <property name="geometry">
        <rect>
-        <x>140</x>
-        <y>410</y>
+        <x>810</x>
+        <y>130</y>
         <width>121</width>
         <height>24</height>
        </rect>
@@ -194,8 +194,8 @@
      <widget class="QDoubleSpinBox" name="costEdit">
       <property name="geometry">
        <rect>
-        <x>140</x>
-        <y>440</y>
+        <x>810</x>
+        <y>160</y>
         <width>121</width>
         <height>24</height>
        </rect>
@@ -219,8 +219,8 @@
      <widget class="NullDateEdit" name="prodEdit" native="true">
       <property name="geometry">
        <rect>
-        <x>810</x>
-        <y>410</y>
+        <x>140</x>
+        <y>340</y>
         <width>121</width>
         <height>24</height>
        </rect>
@@ -246,7 +246,7 @@
       <property name="geometry">
        <rect>
         <x>810</x>
-        <y>440</y>
+        <y>340</y>
         <width>121</width>
         <height>24</height>
        </rect>
@@ -277,7 +277,7 @@
        <string>Quit</string>
       </property>
       <property name="icon">
-       <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc">
+       <iconset>
         <normaloff>:icons/silk/door_out.png</normaloff>:icons/silk/door_out.png</iconset>
       </property>
      </widget>
@@ -297,7 +297,7 @@
        <string>Save</string>
       </property>
       <property name="icon">
-       <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc">
+       <iconset>
         <normaloff>:icons/silk/disk.png</normaloff>:icons/silk/disk.png</iconset>
       </property>
      </widget>
@@ -317,15 +317,15 @@
        <string>Delete</string>
       </property>
       <property name="icon">
-       <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc">
+       <iconset>
         <normaloff>:icons/silk/delete.png</normaloff>:icons/silk/delete.png</iconset>
       </property>
      </widget>
      <widget class="QDoubleSpinBox" name="valueEdit">
       <property name="geometry">
        <rect>
-        <x>140</x>
-        <y>470</y>
+        <x>810</x>
+        <y>190</y>
         <width>107</width>
         <height>24</height>
        </rect>
@@ -340,6 +340,193 @@
        <enum>QAbstractSpinBox::NoButtons</enum>
       </property>
      </widget>
+     <widget class="QLabel" name="typeLabel">
+      <property name="geometry">
+       <rect>
+        <x>30</x>
+        <y>130</y>
+        <width>91</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="isweightLabel">
+      <property name="geometry">
+       <rect>
+        <x>10</x>
+        <y>160</y>
+        <width>111</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Amount is weight:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QLabel" name="useLabel">
+      <property name="geometry">
+       <rect>
+        <x>30</x>
+        <y>190</y>
+        <width>91</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Use at:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QLabel" name="timeLabel">
+      <property name="geometry">
+       <rect>
+        <x>30</x>
+        <y>220</y>
+        <width>91</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Time:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QLabel" name="useforLabel">
+      <property name="geometry">
+       <rect>
+        <x>30</x>
+        <y>250</y>
+        <width>91</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Use for:</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>690</x>
+        <y>220</y>
+        <width>111</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="QComboBox" name="typeEdit">
+      <property name="geometry">
+       <rect>
+        <x>140</x>
+        <y>130</y>
+        <width>131</width>
+        <height>23</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QComboBox" name="useEdit">
+      <property name="geometry">
+       <rect>
+        <x>140</x>
+        <y>190</y>
+        <width>131</width>
+        <height>23</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QCheckBox" name="isweightEdit">
+      <property name="geometry">
+       <rect>
+        <x>140</x>
+        <y>160</y>
+        <width>85</width>
+        <height>21</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Yes</string>
+      </property>
+     </widget>
+     <widget class="QSpinBox" name="timeEdit">
+      <property name="geometry">
+       <rect>
+        <x>140</x>
+        <y>220</y>
+        <width>71</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">
+       <number>99360</number>
+      </property>
+     </widget>
+     <widget class="QCheckBox" name="alwaysEdit">
+      <property name="geometry">
+       <rect>
+        <x>810</x>
+        <y>220</y>
+        <width>85</width>
+        <height>21</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Yes</string>
+      </property>
+     </widget>
+     <widget class="QPlainTextEdit" name="useforEdit">
+      <property name="geometry">
+       <rect>
+        <x>140</x>
+        <y>250</y>
+        <width>791</width>
+        <height>61</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="timeShow">
+      <property name="geometry">
+       <rect>
+        <x>220</x>
+        <y>220</y>
+        <width>113</width>
+        <height>23</height>
+       </rect>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignCenter</set>
+      </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+     </widget>
     </widget>
    </item>
   </layout>
--- a/ui/MainWindow.ui	Thu Feb 24 14:36:56 2022 +0100
+++ b/ui/MainWindow.ui	Fri Feb 25 10:51:36 2022 +0100
@@ -131,7 +131,7 @@
   </widget>
   <action name="actionExit">
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/silk/cross.png</normaloff>:icons/silk/cross.png</iconset>
    </property>
    <property name="text">
@@ -140,7 +140,7 @@
   </action>
   <action name="actionAbout">
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/silk/information.png</normaloff>:icons/silk/information.png</iconset>
    </property>
    <property name="text">
@@ -149,7 +149,7 @@
   </action>
   <action name="actionSystens">
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/silk/server.png</normaloff>:icons/silk/server.png</iconset>
    </property>
    <property name="text">
@@ -158,7 +158,7 @@
   </action>
   <action name="actionFermenters">
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/fridge.png</normaloff>:icons/bms/fridge.png</iconset>
    </property>
    <property name="text">
@@ -167,7 +167,7 @@
   </action>
   <action name="actionCO2_Meters">
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/beerbottle.png</normaloff>:icons/bms/beerbottle.png</iconset>
    </property>
    <property name="text">
@@ -176,7 +176,7 @@
   </action>
   <action name="actioniSpindels">
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/fermenter.png</normaloff>:icons/bms/fermenter.png</iconset>
    </property>
    <property name="text">
@@ -185,7 +185,7 @@
   </action>
   <action name="actionSuppliers">
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/silk/user.png</normaloff>:icons/silk/user.png</iconset>
    </property>
    <property name="text">
@@ -197,7 +197,7 @@
     <bool>true</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/graan.png</normaloff>:icons/bms/graan.png</iconset>
    </property>
    <property name="text">
@@ -209,7 +209,7 @@
     <bool>true</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/hop.png</normaloff>:icons/bms/hop.png</iconset>
    </property>
    <property name="text">
@@ -221,7 +221,7 @@
     <bool>true</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/erlenmeyer.png</normaloff>:icons/bms/erlenmeyer.png</iconset>
    </property>
    <property name="text">
@@ -230,10 +230,10 @@
   </action>
   <action name="actionMiscs">
    <property name="enabled">
-    <bool>false</bool>
+    <bool>true</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/peper.png</normaloff>:icons/bms/peper.png</iconset>
    </property>
    <property name="text">
@@ -245,7 +245,7 @@
     <bool>false</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/water.png</normaloff>:icons/bms/water.png</iconset>
    </property>
    <property name="text">
@@ -257,7 +257,7 @@
     <bool>false</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/mash.png</normaloff>:icons/bms/mash.png</iconset>
    </property>
    <property name="text">
@@ -269,7 +269,7 @@
     <bool>false</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/silk/database.png</normaloff>:icons/silk/database.png</iconset>
    </property>
    <property name="text">
@@ -281,7 +281,7 @@
     <bool>false</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/science.png</normaloff>:icons/bms/science.png</iconset>
    </property>
    <property name="text">
@@ -293,7 +293,7 @@
     <bool>false</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/water.png</normaloff>:icons/bms/water.png</iconset>
    </property>
    <property name="text">
@@ -305,7 +305,7 @@
     <bool>false</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/mash.png</normaloff>:icons/bms/mash.png</iconset>
    </property>
    <property name="text">
@@ -317,7 +317,7 @@
     <bool>false</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/beerstyles.png</normaloff>:icons/bms/beerstyles.png</iconset>
    </property>
    <property name="text">
@@ -329,7 +329,7 @@
     <bool>false</bool>
    </property>
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/bms/fermenter.png</normaloff>:icons/bms/fermenter.png</iconset>
    </property>
    <property name="text">
@@ -338,7 +338,7 @@
   </action>
   <action name="actionSetup">
    <property name="icon">
-    <iconset resource="../resources/icons.qrc">
+    <iconset>
      <normaloff>:icons/silk/wrench.png</normaloff>:icons/silk/wrench.png</iconset>
    </property>
    <property name="text">

mercurial