Thu, 21 Apr 2022 17:22:01 +0200
New recipe, calculate the boil_size. Lot's of ignoreChanges removeals and where needed QSignalBlocker is used. Bottle priming calculation added. In fermentables editor block and release to100 settings only in mash to fermentation steps, bottle and kegging are ignored. Update the IBU slider after hop changes. Set the mash name when another mash profile is selected. Don't backup initial infuse amount if there was no mash table. A small cosmetic layout change on the mash tab.
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * InventoryEquipments.cpp is part of bmsapp. |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * bmsapp is free software: you can redistribute it and/or modify |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * it under the terms of the GNU General Public License as published by |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * the Free Software Foundation, either version 3 of the License, or |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * (at your option) any later version. |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * bmsapp is distributed in the hope that it will be useful, |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * GNU General Public License for more details. |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * You should have received a copy of the GNU General Public License |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | */ |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | #include "InventoryEquipments.h" |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | #include "EditEquipment.h" |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
19 | #include "MainWindow.h" |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | #include "config.h" |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
23 | InventoryEquipments::InventoryEquipments(QWidget *parent) : QDialog(parent) |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | { |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | qDebug() << "InventoryEquipments start"; |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
27 | gridLayout = new QGridLayout(this); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
28 | gridLayout->setObjectName(QString::fromUtf8("gridLayout")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
29 | tableEquipments = new QTableWidget(this); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
30 | tableEquipments->setObjectName(QString::fromUtf8("tableEquipments")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
31 | tableEquipments->setEnabled(true); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
32 | QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
33 | sizePolicy.setHorizontalStretch(0); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
34 | sizePolicy.setVerticalStretch(0); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
35 | tableEquipments->setSizePolicy(sizePolicy); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
36 | tableEquipments->setMinimumSize(QSize(1144, 0)); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
37 | gridLayout->addWidget(tableEquipments, 0, 0, 1, 1); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
38 | |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
39 | groupBox = new QGroupBox(this); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
40 | groupBox->setObjectName(QString::fromUtf8("groupBox")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
41 | groupBox->setEnabled(true); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
42 | groupBox->setFlat(false); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
43 | horizontalLayout = new QHBoxLayout(groupBox); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
44 | horizontalLayout->setSpacing(6); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
45 | horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
46 | horizontalLayout->setContentsMargins(0, 0, 0, 0); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
47 | |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
48 | quitButton = new QPushButton(groupBox); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
49 | quitButton->setObjectName(QString::fromUtf8("quitButton")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
50 | quitButton->setMinimumSize(QSize(80, 24)); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
51 | quitButton->setText(tr("Quit")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
52 | QIcon icon; |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
53 | icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
54 | quitButton->setIcon(icon); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
55 | horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
56 | |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
57 | exportButton = new QPushButton(groupBox); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
58 | exportButton->setObjectName(QString::fromUtf8("exportButton")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
59 | exportButton->setMinimumSize(QSize(80, 24)); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
60 | exportButton->setText(tr("Export")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
61 | QIcon icon1; |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
62 | icon1.addFile(QString::fromUtf8(":/icons/silk/database_save.png"), QSize(), QIcon::Normal, QIcon::Off); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
63 | exportButton->setIcon(icon1); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
64 | horizontalLayout->addWidget(exportButton, 0, Qt::AlignRight); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
65 | |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
66 | importButton = new QPushButton(groupBox); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
67 | importButton->setObjectName(QString::fromUtf8("importButton")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
68 | importButton->setMinimumSize(QSize(80, 24)); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
69 | importButton->setText(tr("Import")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
70 | QIcon icon2; |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
71 | icon2.addFile(QString::fromUtf8(":/icons/silk/database_add.png"), QSize(), QIcon::Normal, QIcon::Off); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
72 | importButton->setIcon(icon2); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
73 | horizontalLayout->addWidget(importButton, 0, Qt::AlignRight); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
74 | |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
75 | insertButton = new QPushButton(groupBox); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
76 | insertButton->setObjectName(QString::fromUtf8("insertButton")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
77 | insertButton->setMinimumSize(QSize(80, 24)); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
78 | insertButton->setText(tr("New")); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
79 | QIcon icon3; |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
80 | icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
81 | insertButton->setIcon(icon3); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
82 | horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
83 | gridLayout->addWidget(groupBox, 1, 0, 1, 1); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
84 | |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
85 | connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventoryEquipments())); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
86 | connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
87 | connect(exportButton, SIGNAL(clicked()), this, SLOT(on_exportButton_clicked())); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
88 | // connect(importButton, SIGNAL(clicked()), this, SLOT(on_importButton_clicked())); |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
73
diff
changeset
|
89 | connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString))); |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | emit refreshTable(); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | } |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | void InventoryEquipments::refreshTable() |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | { |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | QString w; |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | qDebug() << "InventoryEquipments reload"; |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | QSqlQuery query("SELECT * FROM inventory_equipments ORDER BY name"); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | const QStringList labels({tr("Name"), tr("Boil volume"), tr("Batch size"), tr("Notes"), tr("Edit")}); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
103 | this->tableEquipments->setColumnCount(5); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
104 | this->tableEquipments->setColumnWidth(0, 180); /* Name */ |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
105 | this->tableEquipments->setColumnWidth(1, 90); /* Boil volume */ |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
106 | this->tableEquipments->setColumnWidth(2, 90); /* Batch size */ |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
107 | this->tableEquipments->setColumnWidth(3, 680); /* Notes */ |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
108 | this->tableEquipments->setColumnWidth(4, 80); /* Edit button */ |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
109 | this->tableEquipments->setRowCount(query.size()); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
110 | this->tableEquipments->setHorizontalHeaderLabels(labels); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
111 | this->tableEquipments->verticalHeader()->hide(); |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | QTableWidgetItem *rightitem = new QTableWidgetItem(); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | rightitem->setTextAlignment(Qt::AlignRight); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | query.first(); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
118 | this->tableEquipments->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString())); /* Name */ |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | w = QString("%1 L").arg(query.value(2).toDouble(), 2, 'f', 1, '0' ); /* Boil volume */ |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | QTableWidgetItem *item = new QTableWidgetItem(w); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
122 | this->tableEquipments->setItem(ridx, 1, item); |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | w = QString("%1 L").arg(query.value(3).toDouble(), 2, 'f', 1, '0' ); /* Batch size */ |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | item = new QTableWidgetItem(w); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
126 | this->tableEquipments->setItem(ridx, 2, item); |
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
127 | this->tableEquipments->setItem(ridx, 3, new QTableWidgetItem(query.value(16).toString())); /* Notes */ |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | /* Add the Edit button */ |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | QWidget* pWidget = new QWidget(); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | QPushButton* btn_edit = new QPushButton(); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | btn_edit->setObjectName(QString("%1").arg(query.value(0).toString())); /* Send record with the button */ |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | btn_edit->setText(tr("Edit")); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | QHBoxLayout* pLayout = new QHBoxLayout(pWidget); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | pLayout->addWidget(btn_edit); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | pLayout->setContentsMargins(5, 0, 5, 0); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | pWidget->setLayout(pLayout); |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
139 | this->tableEquipments->setCellWidget(ridx, 4, pWidget); |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | query.next(); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | } |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
73
diff
changeset
|
142 | emit setStatus(QString(tr("Total items: %1")).arg(query.size())); |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | } |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
47
diff
changeset
|
146 | InventoryEquipments::~InventoryEquipments() {} |
30
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | void InventoryEquipments::edit(int recno) |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | { |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | EditEquipment dialog(recno, this); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | /* Signal from editor if a refresh is needed */ |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | dialog.setModal(true); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | dialog.exec(); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | } |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | void InventoryEquipments::on_editButton_clicked() |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | { |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | int recno = pb->objectName().toInt(); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | edit(recno); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | } |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | void InventoryEquipments::on_insertButton_clicked() |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | { |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | edit(-1); |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | } |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | |
0fec6a1abd13
Added inventory equipment table and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | |
47 | 173 | void InventoryEquipments::on_exportButton_clicked() |
174 | { | |
175 | qDebug() << Q_FUNC_INFO; | |
176 | ||
177 | QSqlQuery query("SELECT * FROM inventory_equipments ORDER BY name"); | |
178 | ||
179 | QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/equipments.xml", tr("Files (*.xml)")); | |
180 | if (fileName == 0) { | |
181 | QMessageBox::warning(this, tr("Save File"), tr("No XML file selected.")); | |
182 | return; | |
183 | } | |
184 | ||
185 | QFile file(fileName); | |
186 | file.open(QIODevice::WriteOnly); | |
187 | ||
188 | QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file); | |
189 | xmlWriter->writeStartDocument(); | |
190 | xmlWriter->setAutoFormatting(true); | |
191 | xmlWriter->setAutoFormattingIndent(1); | |
192 | xmlWriter->writeStartElement("EQUIPMENTS"); | |
193 | ||
194 | query.first(); | |
195 | for (int i = 0 ; i < query.size() ; i++ ) { | |
196 | xmlWriter->writeStartElement("EQUIPMENT"); | |
197 | xmlWriter->writeTextElement("VERSION", "1"); | |
198 | xmlWriter->writeTextElement("NAME", query.value(1).toString()); | |
199 | xmlWriter->writeTextElement("NOTES", query.value(16).toString()); | |
200 | xmlWriter->writeTextElement("BOIL_SIZE", QString::number(query.value(2).toDouble(), 'f', 4)); | |
201 | xmlWriter->writeTextElement("BATCH_SIZE", QString::number(query.value(3).toDouble(), 'f', 4)); | |
202 | xmlWriter->writeTextElement("TUN_VOLUME", QString::number(query.value(4).toDouble(), 'f', 5)); | |
203 | xmlWriter->writeTextElement("TUN_WEIGHT", QString::number(query.value(5).toDouble(), 'f', 5)); | |
204 | xmlWriter->writeTextElement("TUN_SPECIFIC_HEAT", QString::number(query.value(6).toDouble(), 'f', 5)); | |
205 | xmlWriter->writeTextElement("TUN_HEIGHT", QString::number(query.value(8).toDouble(), 'f', 5)); | |
206 | xmlWriter->writeTextElement("TRUB_CHILLER_LOSS", QString::number(query.value(10).toDouble(), 'f', 5)); | |
207 | xmlWriter->writeTextElement("EVAP_RATE", QString::number(query.value(11).toDouble(), 'f', 5)); | |
208 | xmlWriter->writeTextElement("BOIL_TIME", QString::number(query.value(12).toDouble(), 'f', 5)); | |
209 | xmlWriter->writeTextElement("CALC_BOIL_VOLUME", query.value(13).toInt() ? "TRUE":"FALSE"); | |
210 | xmlWriter->writeTextElement("TOP_UP_KETTLE", QString::number(query.value(14).toDouble(), 'f', 5)); | |
211 | xmlWriter->writeTextElement("HOP_UTILIZATION", QString::number(query.value(15).toDouble(), 'f', 5)); | |
212 | xmlWriter->writeTextElement("LAUTER_VOLUME", QString::number(query.value(17).toDouble(), 'f', 5)); | |
213 | xmlWriter->writeTextElement("LAUTER_HEIGHT", QString::number(query.value(18).toDouble(), 'f', 5)); | |
214 | xmlWriter->writeTextElement("LAUTER_DEADSPACE", QString::number(query.value(19).toDouble(), 'f', 5)); | |
215 | xmlWriter->writeTextElement("KETTLE_VOLUME", QString::number(query.value(20).toDouble(), 'f', 5)); | |
216 | xmlWriter->writeTextElement("KETTLE_HEIGHT", QString::number(query.value(21).toDouble(), 'f', 5)); | |
217 | xmlWriter->writeTextElement("MASH_VOLUME", QString::number(query.value(22).toDouble(), 'f', 5)); | |
218 | xmlWriter->writeTextElement("EFFICIENCY", QString::number(query.value(24).toDouble(), 'f', 5)); | |
219 | xmlWriter->writeEndElement(); | |
220 | query.next(); | |
221 | } | |
222 | ||
223 | xmlWriter->writeEndElement(); | |
224 | xmlWriter->writeEndDocument(); | |
225 | QMessageBox::information(this, tr("Save File"), tr("XML export ready")); | |
226 | ||
227 | file.close(); | |
228 | } | |
229 | ||
230 |