Sun, 20 Mar 2022 16:13:26 +0100
Inventory Hops now on the mainscreen.
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
src/InventoryHops.cpp | file | annotate | diff | comparison | revisions | |
src/InventoryHops.h | file | annotate | diff | comparison | revisions | |
src/MainWindow.cpp | file | annotate | diff | comparison | revisions | |
ui/InventoryHops.ui | file | annotate | diff | comparison | revisions |
--- a/CMakeLists.txt Sun Mar 20 15:51:09 2022 +0100 +++ b/CMakeLists.txt Sun Mar 20 16:13:26 2022 +0100 @@ -168,7 +168,6 @@ ${UIDIR}/AboutDialog.ui ${UIDIR}/EditSupplier.ui ${UIDIR}/EditFermentable.ui - ${UIDIR}/InventoryHops.ui ${UIDIR}/EditHop.ui ${UIDIR}/InventoryYeasts.ui ${UIDIR}/EditYeast.ui
--- a/src/InventoryHops.cpp Sun Mar 20 15:51:09 2022 +0100 +++ b/src/InventoryHops.cpp Sun Mar 20 16:13:26 2022 +0100 @@ -16,19 +16,79 @@ */ #include "InventoryHops.h" #include "EditHop.h" -#include "../ui/ui_InventoryHops.h" +#include "MainWindow.h" #include "config.h" #include "bmsapp.h" -InventoryHops::InventoryHops(QWidget *parent) : QDialog(parent), ui(new Ui::InventoryHops) +InventoryHops::InventoryHops(QWidget *parent) : QDialog(parent) { qDebug() << "InventoryHops start"; - ui->setupUi(this); + gridLayout = new QGridLayout(this); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + tableHops = new QTableWidget(this); + tableHops->setObjectName(QString::fromUtf8("tableHops")); + tableHops->setEnabled(true); + QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + //sizePolicy.setHeightForWidth(tableHops->sizePolicy().hasHeightForWidth()); + tableHops->setSizePolicy(sizePolicy); + tableHops->setMinimumSize(QSize(1124, 0)); + gridLayout->addWidget(tableHops, 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); + + exportButton = new QPushButton(groupBox); + exportButton->setObjectName(QString::fromUtf8("exportButton")); + exportButton->setMinimumSize(QSize(80, 24)); + exportButton->setText(tr("Export")); + QIcon icon1; + icon1.addFile(QString::fromUtf8(":/icons/silk/database_save.png"), QSize(), QIcon::Normal, QIcon::Off); + exportButton->setIcon(icon1); + horizontalLayout->addWidget(exportButton, 0, Qt::AlignRight); + + importButton = new QPushButton(groupBox); + importButton->setObjectName(QString::fromUtf8("importButton")); + importButton->setMinimumSize(QSize(80, 24)); + importButton->setText(tr("Import")); + QIcon icon2; + icon2.addFile(QString::fromUtf8(":/icons/silk/database_add.png"), QSize(), QIcon::Normal, QIcon::Off); + importButton->setIcon(icon2); + horizontalLayout->addWidget(importButton, 0, Qt::AlignRight); + + insertButton = new QPushButton(groupBox); + insertButton->setObjectName(QString::fromUtf8("insertButton")); + insertButton->setMinimumSize(QSize(80, 24)); + insertButton->setText(tr("New")); + QIcon icon3; + icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off); + insertButton->setIcon(icon3); + horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight); + gridLayout->addWidget(groupBox, 1, 0, 1, 1); + + connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventoryHops())); + connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); + connect(exportButton, SIGNAL(clicked()), this, SLOT(on_exportButton_clicked())); +// connect(importButton, SIGNAL(clicked()), this, SLOT(on_importButton_clicked())); emit refreshTable(); - - setWindowTitle( QString("BMSapp - %1 - Inventory Hops").arg(VERSIONSTRING) ); } @@ -44,55 +104,54 @@ const QStringList form({tr("Pellet"), tr("Plug"), tr("Leaf"), tr("Leaf Wet"), tr("Cryo")}); /* origin supplier name type graintype color yield inventory Edit */ - ui->tableHops->setColumnCount(11); - ui->tableHops->setColumnWidth(0, 130); /* Origin */ - ui->tableHops->setColumnWidth(1, 250); /* Name */ - ui->tableHops->setColumnWidth(2, 80); /* Type */ - ui->tableHops->setColumnWidth(3, 80); /* Form */ - ui->tableHops->setColumnWidth(4, 80); /* Alpha */ - ui->tableHops->setColumnWidth(5, 80); /* Beta */ - ui->tableHops->setColumnWidth(6, 80); /* cohumulone */ - ui->tableHops->setColumnWidth(7, 80); /* HSI */ - ui->tableHops->setColumnWidth(8, 80); /* Harvest date */ - ui->tableHops->setColumnWidth(9, 80); /* Stock */ - ui->tableHops->setColumnWidth(10, 80); /* Edit button */ - ui->tableHops->setRowCount(query.size()); - ui->tableHops->setHorizontalHeaderLabels(labels); - ui->tableHops->verticalHeader()->hide(); - ui->tableHops->setFixedSize(1100 + 24, 640); /* Even if this is too large, it works */ + this->tableHops->setColumnCount(11); + this->tableHops->setColumnWidth(0, 130); /* Origin */ + this->tableHops->setColumnWidth(1, 250); /* Name */ + this->tableHops->setColumnWidth(2, 80); /* Type */ + this->tableHops->setColumnWidth(3, 80); /* Form */ + this->tableHops->setColumnWidth(4, 80); /* Alpha */ + this->tableHops->setColumnWidth(5, 80); /* Beta */ + this->tableHops->setColumnWidth(6, 80); /* cohumulone */ + this->tableHops->setColumnWidth(7, 80); /* HSI */ + this->tableHops->setColumnWidth(8, 80); /* Harvest date */ + this->tableHops->setColumnWidth(9, 80); /* Stock */ + this->tableHops->setColumnWidth(10, 80); /* Edit button */ + this->tableHops->setRowCount(query.size()); + this->tableHops->setHorizontalHeaderLabels(labels); + this->tableHops->verticalHeader()->hide(); QTableWidgetItem *rightitem = new QTableWidgetItem(); rightitem->setTextAlignment(Qt::AlignRight); query.first(); for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { - ui->tableHops->setItem(ridx, 0, new QTableWidgetItem(query.value(12).toString())); /* Origin */ - ui->tableHops->setItem(ridx, 1, new QTableWidgetItem(query.value(1).toString())); /* Name */ - ui->tableHops->setItem(ridx, 2, new QTableWidgetItem(types[query.value(9).toInt()])); /* Type */ - ui->tableHops->setItem(ridx, 3, new QTableWidgetItem(form[query.value(10).toInt()])); /* Form */ + this->tableHops->setItem(ridx, 0, new QTableWidgetItem(query.value(12).toString())); /* Origin */ + this->tableHops->setItem(ridx, 1, new QTableWidgetItem(query.value(1).toString())); /* Name */ + this->tableHops->setItem(ridx, 2, new QTableWidgetItem(types[query.value(9).toInt()])); /* Type */ + this->tableHops->setItem(ridx, 3, new QTableWidgetItem(form[query.value(10).toInt()])); /* Form */ w = QString("%1 %").arg(query.value(2).toDouble(), 2, 'f', 1, '0' ); /* Alpha% */ QTableWidgetItem *item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->tableHops->setItem(ridx, 4, item); + this->tableHops->setItem(ridx, 4, item); w = QString("%1 %").arg(query.value(3).toDouble(), 2, 'f', 1, '0' ); /* Beta% */ item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->tableHops->setItem(ridx, 5, item); + this->tableHops->setItem(ridx, 5, item); w = QString("%1 %").arg(query.value(6).toDouble(), 2, 'f', 1, '0' ); /* Cohumulone */ item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->tableHops->setItem(ridx, 6, item); + this->tableHops->setItem(ridx, 6, item); w = QString("%1").arg(query.value(8).toDouble(), 2, 'f', 1, '0' ); /* HSI */ item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->tableHops->setItem(ridx, 7, item); + this->tableHops->setItem(ridx, 7, item); if (query.value(15).toDouble() > 0) - ui->tableHops->setItem(ridx, 8, new QTableWidgetItem(query.value(17).toString())); /* Harvest */ + this->tableHops->setItem(ridx, 8, new QTableWidgetItem(query.value(17).toString())); /* Harvest */ else - ui->tableHops->setItem(ridx, 8, new QTableWidgetItem(QString(""))); + this->tableHops->setItem(ridx, 8, new QTableWidgetItem(QString(""))); w = QString(""); if (query.value(15).toDouble() > 0) { @@ -104,7 +163,7 @@ } item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - ui->tableHops->setItem(ridx, 9, item); + this->tableHops->setItem(ridx, 9, item); /* Add the Edit button */ QWidget* pWidget = new QWidget(); @@ -116,25 +175,17 @@ pLayout->addWidget(btn_edit); pLayout->setContentsMargins(5, 0, 5, 0); pWidget->setLayout(pLayout); - ui->tableHops->setCellWidget(ridx, 10, pWidget); + this->tableHops->setCellWidget(ridx, 10, pWidget); query.next(); } - - setWindowTitle( QString("BMSapp - %1 - Inventory Hops").arg(VERSIONSTRING) ); } -InventoryHops::~InventoryHops() -{ - qDebug() << "InventoryHops done"; - delete ui; -} +InventoryHops::~InventoryHops() {} void InventoryHops::edit(int recno) { - qDebug() << "InventoryHops edit:" << recno; - EditHop dialog(recno, this); /* Signal from editor if a refresh is needed */ connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); @@ -147,14 +198,12 @@ { QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); int recno = pb->objectName().toInt(); - qDebug() << Q_FUNC_INFO << recno; edit(recno); } void InventoryHops::on_insertButton_clicked() { - qDebug() << Q_FUNC_INFO; edit(-1); } @@ -166,9 +215,9 @@ QSqlQuery query("SELECT * FROM inventory_hops ORDER BY origin,name"); const QStringList types({ "Bittering", "Aroma", "Both" }); const QStringList forms({ "Pellet", "Plug", "Leaf", "Leaf", "Pellet" }); - /* "Leaf Wet", "Cryo" */ - /* We use more hp forms then beerxml knows about, so we send known names */ - /* instead of what we internally use. */ + /* "Leaf Wet", "Cryo" */ + /* We use more hop forms then beerxml knows about, so we send known names */ + /* instead of what we internally use. */ QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/hops.xml", tr("Files (*.xml)")); if (fileName == 0) { @@ -220,8 +269,3 @@ } -void InventoryHops::on_quitButton_clicked() -{ - emit firstWindow(); -} -
--- a/src/InventoryHops.h Sun Mar 20 15:51:09 2022 +0100 +++ b/src/InventoryHops.h Sun Mar 20 16:13:26 2022 +0100 @@ -2,6 +2,12 @@ #define _INVENTORYHOPS_H #include <QDialog> +#include <QtWidgets/QGridLayout> +#include <QtWidgets/QGroupBox> +#include <QtWidgets/QHBoxLayout> +#include <QtWidgets/QHeaderView> +#include <QtWidgets/QPushButton> +#include <QtWidgets/QTableWidget> namespace Ui { class InventoryHops; @@ -15,18 +21,22 @@ explicit InventoryHops(QWidget *parent = nullptr); ~InventoryHops(); -signals: - void firstWindow(); - private slots: - void on_quitButton_clicked(); void on_insertButton_clicked(); void on_editButton_clicked(); void on_exportButton_clicked(); void refreshTable(void); private: - Ui::InventoryHops *ui; + QGridLayout *gridLayout; + QTableWidget *tableHops; + QGroupBox *groupBox; + QHBoxLayout *horizontalLayout; + QPushButton *quitButton; + QPushButton *exportButton; + QPushButton *importButton; + QPushButton *insertButton; + void edit(int recno); };
--- a/src/MainWindow.cpp Sun Mar 20 15:51:09 2022 +0100 +++ b/src/MainWindow.cpp Sun Mar 20 16:13:26 2022 +0100 @@ -116,8 +116,11 @@ void MainWindow::fromInventoryHops() { qDebug() << Q_FUNC_INFO; + ui->mainStack->setCurrentIndex(-1); + ui->mainStack->removeWidget(InventoryHopsWindow); delete InventoryHopsWindow; - this->show(); + setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) ); + ui->menuBar->setVisible(true); } @@ -125,9 +128,11 @@ { qDebug() << Q_FUNC_INFO; InventoryHopsWindow = new InventoryHops(this); - QObject::connect(InventoryHopsWindow, SIGNAL(firstWindow()), this, SLOT(fromInventoryHops())); - this->hide(); // Close the main window - InventoryHopsWindow->show(); // Show a second window + int index = ui->mainStack->count(); + ui->mainStack->addWidget(InventoryHopsWindow); + ui->mainStack->setCurrentIndex(index); + setWindowTitle(QString("BMSapp - %1 - Inventory Hops").arg(VERSIONSTRING)); + ui->menuBar->setVisible(false); }
--- a/ui/InventoryHops.ui Sun Mar 20 15:51:09 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>InventoryHops</class> - <widget class="QDialog" name="InventoryHops"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1280</width> - <height>640</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QTableWidget" name="tableHops"> - <property name="enabled"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QGroupBox" name="groupBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item alignment="Qt::AlignLeft"> - <widget class="QPushButton" name="quitButton"> - <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>Quit</string> - </property> - <property name="icon"> - <iconset> - <normaloff>:icons/silk/door_out.png</normaloff>:icons/silk/door_out.png</iconset> - </property> - </widget> - </item> - <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> - <property name="icon"> - <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> - <normaloff>:/icons/silk/database_save.png</normaloff>:/icons/silk/database_save.png</iconset> - </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> - <property name="icon"> - <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> - <normaloff>:/icons/silk/database_add.png</normaloff>:/icons/silk/database_add.png</iconset> - </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> - <height>24</height> - </size> - </property> - <property name="text"> - <string>New</string> - </property> - <property name="icon"> - <iconset> - <normaloff>:icons/silk/table_row_insert.png</normaloff>:icons/silk/table_row_insert.png</iconset> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"/> - </resources> - <connections/> -</ui>