# HG changeset patch # User Michiel Broek # Date 1648069228 -3600 # Node ID 562ed7d1b74d4c1ca68ced60068cd68496420033 # Parent b319a117509296dc4d76b58b1b3dc28eeb79e563 Added start of the Recipes Tree to select a recipe diff -r b319a1175092 -r 562ed7d1b74d CMakeLists.txt --- a/CMakeLists.txt Mon Mar 21 13:46:33 2022 +0100 +++ b/CMakeLists.txt Wed Mar 23 22:00:28 2022 +0100 @@ -100,6 +100,7 @@ set( SRCS ${SRCDIR}/main.cpp ${SRCDIR}/bmsapp.cpp + ${SRCDIR}/RecipesTree.cpp ${SRCDIR}/AboutDialog.cpp ${SRCDIR}/InventorySuppliers.cpp ${SRCDIR}/EditSupplier.cpp @@ -133,6 +134,7 @@ set( HDRS ${SRCDIR}/bmsapp.h + ${SRCDIR}/RecipesTree.h ${SRCDIR}/AboutDialog.h ${SRCDIR}/InventorySuppliers.h ${SRCDIR}/EditSupplier.h @@ -177,7 +179,6 @@ ${UIDIR}/EditProfileMash.ui ${UIDIR}/EditProfileStyle.ui ${UIDIR}/EditProfileFerment.ui - ${UIDIR}/Setup.ui ${UIDIR}/MainWindow.ui ) diff -r b319a1175092 -r 562ed7d1b74d src/MainWindow.cpp --- a/src/MainWindow.cpp Mon Mar 21 13:46:33 2022 +0100 +++ b/src/MainWindow.cpp Wed Mar 23 22:00:28 2022 +0100 @@ -16,6 +16,7 @@ */ #include "MainWindow.h" #include "AboutDialog.h" +#include "RecipesTree.h" #include "InventorySuppliers.h" #include "InventoryFermentables.h" #include "InventoryHops.h" @@ -65,6 +66,30 @@ } +void MainWindow::fromRecipesTree() +{ + qDebug() << Q_FUNC_INFO; + ui->mainStack->setCurrentIndex(-1); + ui->mainStack->removeWidget(RecipesTreeWindow); + delete RecipesTreeWindow; + setWindowTitle( QString("BMSapp - %1").arg(VERSIONSTRING) ); + ui->menuBar->setVisible(true); +} + + +void MainWindow::on_actionRecipes_triggered() +{ + qDebug() << Q_FUNC_INFO; + + RecipesTreeWindow = new RecipesTree(this); + int index = ui->mainStack->count(); + ui->mainStack->addWidget(RecipesTreeWindow); + ui->mainStack->setCurrentIndex(index); + setWindowTitle( QString("BMSapp - %1 - Recipes").arg(VERSIONSTRING)); +// ui->menuBar->setVisible(false); +} + + void MainWindow::fromInventorySuppliers() { qDebug() << Q_FUNC_INFO; diff -r b319a1175092 -r 562ed7d1b74d src/MainWindow.h --- a/src/MainWindow.h Mon Mar 21 13:46:33 2022 +0100 +++ b/src/MainWindow.h Wed Mar 23 22:00:28 2022 +0100 @@ -1,6 +1,7 @@ #ifndef _MAINWINDOW_H #define _MAINWINDOW_H +#include "RecipesTree.h" #include "InventorySuppliers.h" #include "InventoryFermentables.h" #include "InventoryHops.h" @@ -32,6 +33,7 @@ ~MainWindow(); // Keep pointers to new windows. + RecipesTree *RecipesTreeWindow; InventorySuppliers *InventorySuppliersWindow; InventoryFermentables *InventoryFermentablesWindow; InventoryHops *InventoryHopsWindow; @@ -47,6 +49,7 @@ private slots: void on_actionExit_triggered(); + void on_actionRecipes_triggered(); void on_actionSuppliers_triggered(); void on_actionFermentables_triggered(); void on_actionHops_triggered(); @@ -64,6 +67,7 @@ void on_actionAbout_triggered(); public slots: + void fromRecipesTree(); void fromInventorySuppliers(); void fromInventoryFermentables(); void fromInventoryHops(); diff -r b319a1175092 -r 562ed7d1b74d src/RecipesTree.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/RecipesTree.cpp Wed Mar 23 22:00:28 2022 +0100 @@ -0,0 +1,196 @@ +/** + * RecipesTree.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 "RecipesTree.h" +//#include "EditMisc.h" +#include "MainWindow.h" +#include "config.h" +#include "bmsapp.h" + + + +RecipesTree::RecipesTree(QWidget *parent) : QDialog(parent) +{ + qDebug() << "RecipesTree start"; + + gridLayout = new QGridLayout(this); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + treeWidget = new QTreeWidget(this); + treeWidget->setObjectName(QString::fromUtf8("treeWidget")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(treeWidget->sizePolicy().hasHeightForWidth()); + treeWidget->setSizePolicy(sizePolicy); + gridLayout->addWidget(treeWidget, 0, 0, 1, 1); + + listView = new QListView(this); + listView->setObjectName(QString::fromUtf8("listView")); + QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Expanding); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(listView->sizePolicy().hasHeightForWidth()); + listView->setSizePolicy(sizePolicy1); + listView->setMinimumSize(QSize(500, 0)); + gridLayout->addWidget(listView, 0, 1, 2, 1); + + groupBox = new QGroupBox(this); + groupBox->setObjectName(QString::fromUtf8("groupBox")); + QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Preferred); + sizePolicy2.setHorizontalStretch(0); + sizePolicy2.setVerticalStretch(0); + sizePolicy2.setHeightForWidth(groupBox->sizePolicy().hasHeightForWidth()); + groupBox->setSizePolicy(sizePolicy2); + groupBox->setMinimumSize(QSize(0, 0)); + horizontalLayout = new QHBoxLayout(groupBox); + horizontalLayout->setSpacing(200); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + horizontalLayout->setContentsMargins(0, 0, 0, 0); + + quitButton = new QPushButton(groupBox); + quitButton->setObjectName(QString::fromUtf8("quitButton")); + 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); + + insertButton = new QPushButton(groupBox); + insertButton->setObjectName(QString::fromUtf8("insertButton")); + 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); + + openButton = new QPushButton(groupBox); + openButton->setObjectName(QString::fromUtf8("openButton")); + openButton->setText(tr("Open")); + QIcon icon1; + icon1.addFile(QString::fromUtf8(":icons/silk/cup_go.png"), QSize(), QIcon::Normal, QIcon::Off); + openButton->setIcon(icon1); + horizontalLayout->addWidget(openButton); + + gridLayout->addWidget(groupBox, 1, 0, 1, 1); + + connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromRecipesTree())); + //connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); + //connect(exportButton, SIGNAL(clicked()), this, SLOT(on_exportButton_clicked())); + +// connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString))); + emit refreshTable(); +} + + +void RecipesTree::refreshTable() +{ + QTreeWidgetItem *st_guide, *st_group, *st_name, *name; + + qDebug() << "RecipesTree reload"; + + treeWidget->setRootIsDecorated(false); + treeWidget->resizeColumnToContents(2); + treeWidget->setColumnCount(5); + treeWidget->setHeaderLabels(QStringList() << "Guide" << "Group" << "Style" << "Recipe" << "Record"); + + QSqlQuery query0; + query0.prepare("SELECT DISTINCT st_guide FROM recipes ORDER BY st_guide"); + query0.exec(); + query0.first(); + for (int i = 0; i < query0.size() ; i++) { + st_guide = new QTreeWidgetItem(treeWidget); + st_guide->setText(0, query0.value(0).toString()); + + QSqlQuery query1; + query1.prepare("SELECT DISTINCT st_letter FROM recipes WHERE st_guide=:guide ORDER BY st_letter"); + query1.bindValue(":guide", query0.value(0).toString()); + query1.exec(); + query1.first(); + for (int j = 0; j < query1.size(); j++) { + st_group = new QTreeWidgetItem(treeWidget); + st_group->setText(1, query1.value(0).toString()); + st_group->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator); + st_guide->addChild( st_group ); + + QSqlQuery query2; + query2.prepare("SELECT DISTINCT st_name FROM recipes WHERE st_guide=:guide AND st_letter=:group ORDER BY st_name"); + query2.bindValue(":guide", query0.value(0).toString()); + query2.bindValue(":group", query1.value(0).toString()); + query2.exec(); + query2.first(); + for (int k = 0; k < query2.size(); k++) { + st_name = new QTreeWidgetItem(treeWidget); + st_name->setText(2, query2.value(0).toString()); + st_group->addChild( st_name ); + + QSqlQuery query3; + query3.prepare("SELECT name,record FROM recipes WHERE st_guide=:guide AND st_letter=:group AND st_name=:name ORDER BY name"); + query3.bindValue(":guide", query0.value(0).toString()); + query3.bindValue(":group", query1.value(0).toString()); + query3.bindValue(":name", query2.value(0).toString()); + query3.exec(); + query3.first(); + for (int l = 0; l < query3.size(); l++) { + name = new QTreeWidgetItem(treeWidget); + name->setText(3, query3.value(0).toString()); + name->setText(4, query3.value(1).toString()); + st_name->addChild( name ); + + query3.next(); + } + +// qDebug() << query0.value(0).toString() << query1.value(0).toString() << query2.value(0).toString(); + query2.next(); + } + query1.next(); + } + query0.next(); + } + +// treeWidget->expandAll(); + +// QSqlQuery query("SELECT * FROM recipes ORDER BY st_guide,st_letter,st_name,name"); +// emit setStatus(QString(tr("Total items: %1")).arg(query.size())); +} + + +RecipesTree::~RecipesTree() {} + + +void RecipesTree::edit(int 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 RecipesTree::on_editButton_clicked() +{ + QPushButton *pb = qobject_cast(QObject::sender()); + int recno = pb->objectName().toInt(); + edit(recno); +} + + +void RecipesTree::on_insertButton_clicked() +{ + edit(-1); +} + + diff -r b319a1175092 -r 562ed7d1b74d src/RecipesTree.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/RecipesTree.h Wed Mar 23 22:00:28 2022 +0100 @@ -0,0 +1,47 @@ +#ifndef _RECIPESTREE_H +#define _RECIPESTREE_H + +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Ui { +class RecipesTree; +} + +class RecipesTree : public QDialog +{ + Q_OBJECT + +public: + explicit RecipesTree(QWidget *parent = nullptr); + ~RecipesTree(); + +signals: + void setStatus(QString); + +private slots: + void on_insertButton_clicked(); + void on_editButton_clicked(); + void refreshTable(void); + +private: + QGridLayout *gridLayout; + QListView *listView; + QTreeWidget *treeWidget; + QGroupBox *groupBox; + QHBoxLayout *horizontalLayout; + QPushButton *quitButton; + QPushButton *insertButton; + QPushButton *openButton; + + void edit(int recno); +}; + +#endif diff -r b319a1175092 -r 562ed7d1b74d ui/Setup.ui --- a/ui/Setup.ui Mon Mar 21 13:46:33 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,688 +0,0 @@ - - - Setup - - - - 0 - 0 - 1280 - 640 - - - - Dialog - - - - - - - - 60 - 20 - 131 - 20 - - - - Brewery name: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 212 - 20 - 941 - 23 - - - - The name for this brewery. - - - - - - 0 - 60 - 1251 - 20 - - - - Qt::Horizontal - - - - - - 60 - 120 - 131 - 20 - - - - First Wort Hop factor: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 60 - 150 - 131 - 20 - - - - Mash Hop factor: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 60 - 180 - 131 - 20 - - - - Pellet Hop factor: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 60 - 210 - 131 - 20 - - - - Hop Plugs factor: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 60 - 240 - 131 - 20 - - - - Wet Hop factor: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 60 - 270 - 131 - 20 - - - - Cryo HopĀ® factor: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 210 - 120 - 81 - 24 - - - - The efficiency for First Wort Hopping. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - % - - - -50 - - - 50 - - - - - - 210 - 150 - 81 - 24 - - - - The efficiency for Mash hopping. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - % - - - -50 - - - 50 - - - - - - 210 - 180 - 81 - 24 - - - - The efficiency for hop pellets. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - % - - - 0 - - - 20 - - - - - - 210 - 210 - 81 - 24 - - - - The efficiency for hop plugs. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - % - - - 20 - - - - - - 210 - 240 - 81 - 24 - - - - The efficiency for fresh hops. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - % - - - -98 - - - -20 - - - - - - 210 - 270 - 81 - 24 - - - - The efficiency for using Cryo HopĀ®. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - % - - - -20 - - - 150 - - - - - - 400 - 120 - 161 - 20 - - - - Grain Absorbtion: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 400 - 150 - 161 - 20 - - - - Brix Correction factor: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 5 - 80 - 1251 - 20 - - - - - DejaVu Sans - 12 - 75 - true - - - - Brew settings. - - - Qt::AlignCenter - - - - - - 800 - 120 - 121 - 16 - - - - Color Calculation: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 800 - 150 - 121 - 16 - - - - IBU Calculation: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 800 - 180 - 121 - 16 - - - - Default Water: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 800 - 210 - 121 - 16 - - - - Private Yeast bank: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 580 - 120 - 101 - 24 - - - - Absorbtion with water by the grain (L/Kg) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - L/Kg - - - 0.500000000000000 - - - 1.100000000000000 - - - 0.010000000000000 - - - QAbstractSpinBox::DefaultStepType - - - 1.000000000000000 - - - - - - 580 - 150 - 101 - 24 - - - - Plato to Brix conversion factor. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1.000000000000000 - - - 1.090000000000000 - - - 0.010000000000000 - - - QAbstractSpinBox::DefaultStepType - - - 1.000000000000000 - - - - - - 940 - 120 - 161 - 23 - - - - - - - 4 - - - - 0 - 0 - - - - Choose color - - - - - - 940 - 150 - 161 - 23 - - - - - - - 4 - - - - 0 - 0 - - - - Choose color - - - - - - 940 - 180 - 211 - 23 - - - - - - - 4 - - - - 0 - 0 - - - - Choose color - - - - - - 940 - 210 - 211 - 23 - - - - - - - 4 - - - - 0 - 0 - - - - Choose color - - - - - - 940 - 260 - 211 - 211 - - - - Logo here - - - Qt::AlignCenter - - - - - - 50 - 520 - 80 - 23 - - - - Quit - - - - :icons/silk/door_out.png:icons/silk/door_out.png - - - - - - 200 - 520 - 80 - 23 - - - - Save - - - - :icons/silk/disk.png:icons/silk/disk.png - - - - - - 810 - 260 - 111 - 23 - - - - Load logo - - - - :/icons/silk/folder_picture.png:/icons/silk/folder_picture.png - - - - - - - - - - -