Sat, 01 Jun 2024 21:10:54 +0200
Added fields for target_water and auto upgrade the products table
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * InventoryWaters.cpp is part of bmsapp. |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * bmsapp is free software: you can redistribute it and/or modify |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * it under the terms of the GNU General Public License as published by |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * the Free Software Foundation, either version 3 of the License, or |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * (at your option) any later version. |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * bmsapp is distributed in the hope that it will be useful, |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * GNU General Public License for more details. |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * You should have received a copy of the GNU General Public License |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | */ |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | #include "InventoryWaters.h" |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | #include "EditWater.h" |
73
ebd2fc719b1a
Inventory Equipments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
19 | #include "MainWindow.h" |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | #include "config.h" |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
23 | InventoryWaters::InventoryWaters(QWidget *parent) : QDialog(parent) |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | { |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | qDebug() << "InventoryWaters start"; |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
27 | gridLayout = new QGridLayout(this); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
28 | gridLayout->setObjectName(QString::fromUtf8("gridLayout")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
29 | tableWaters = new QTableWidget(this); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
30 | tableWaters->setObjectName(QString::fromUtf8("tableWaters")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
31 | tableWaters->setEnabled(true); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
32 | QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
33 | sizePolicy.setHorizontalStretch(0); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
34 | sizePolicy.setVerticalStretch(0); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
35 | tableWaters->setSizePolicy(sizePolicy); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
36 | tableWaters->setMinimumSize(QSize(954, 0)); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
37 | gridLayout->addWidget(tableWaters, 0, 0, 1, 1); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
38 | |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
39 | groupBox = new QGroupBox(this); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
40 | groupBox->setObjectName(QString::fromUtf8("groupBox")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
41 | groupBox->setEnabled(true); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
42 | groupBox->setFlat(false); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
43 | horizontalLayout = new QHBoxLayout(groupBox); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
44 | horizontalLayout->setSpacing(6); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
45 | horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
46 | horizontalLayout->setContentsMargins(0, 0, 0, 0); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
47 | |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
48 | quitButton = new QPushButton(groupBox); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
49 | quitButton->setObjectName(QString::fromUtf8("quitButton")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
50 | quitButton->setMinimumSize(QSize(80, 24)); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
51 | quitButton->setText(tr("Quit")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
52 | QIcon icon; |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
53 | icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
54 | quitButton->setIcon(icon); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
55 | horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
56 | |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
57 | exportButton = new QPushButton(groupBox); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
58 | exportButton->setObjectName(QString::fromUtf8("exportButton")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
59 | exportButton->setMinimumSize(QSize(80, 24)); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
60 | exportButton->setText(tr("Export")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
61 | QIcon icon1; |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
62 | icon1.addFile(QString::fromUtf8(":/icons/silk/database_save.png"), QSize(), QIcon::Normal, QIcon::Off); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
63 | exportButton->setIcon(icon1); |
290
93820a8ffbff
Removed unneeded import buttons from the inventory screens.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
64 | horizontalLayout->addWidget(exportButton, 0, Qt::AlignCenter); |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
65 | |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
66 | insertButton = new QPushButton(groupBox); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
67 | insertButton->setObjectName(QString::fromUtf8("insertButton")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
68 | insertButton->setMinimumSize(QSize(80, 24)); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
69 | insertButton->setText(tr("New")); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
70 | QIcon icon3; |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
71 | icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
72 | insertButton->setIcon(icon3); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
73 | horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
74 | gridLayout->addWidget(groupBox, 1, 0, 1, 1); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
75 | |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
76 | connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventoryWaters())); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
77 | connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
78 | connect(exportButton, SIGNAL(clicked()), this, SLOT(on_exportButton_clicked())); |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
73
diff
changeset
|
79 | connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString))); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | emit refreshTable(); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | } |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | void InventoryWaters::refreshTable() |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | { |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | QString w; |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | QWidget* pWidget; |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | QLabel *label; |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | QHBoxLayout* pLayout; |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | qDebug() << "InventoryWaters reload"; |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | QSqlQuery query("SELECT * FROM inventory_waters ORDER BY name"); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | const QStringList labels({tr("Name"), tr("Notes"), tr("Unlimited"), tr("Stock"), tr("Edit")}); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
96 | this->tableWaters->setColumnCount(5); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
97 | this->tableWaters->setColumnWidth(0, 200); /* Name */ |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
98 | this->tableWaters->setColumnWidth(1, 500); /* Notes */ |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
99 | this->tableWaters->setColumnWidth(2, 75); /* Unlimited */ |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
100 | this->tableWaters->setColumnWidth(3, 75); /* Stock */ |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
101 | this->tableWaters->setColumnWidth(4, 80); /* Edit button */ |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
102 | this->tableWaters->setRowCount(query.size()); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
103 | this->tableWaters->setHorizontalHeaderLabels(labels); |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
104 | this->tableWaters->verticalHeader()->hide(); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | QTableWidgetItem *rightitem = new QTableWidgetItem(); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | rightitem->setTextAlignment(Qt::AlignRight); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | query.first(); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
111 | this->tableWaters->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString())); /* Name */ |
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
112 | this->tableWaters->setItem(ridx, 1, new QTableWidgetItem(query.value(10).toString())); /* Notes */ |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | if (query.value(2).toInt()) { |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | pWidget = new QWidget(); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | label = new QLabel; |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | label->setPixmap(QPixmap(":icons/silk/tick.png")); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | pLayout = new QHBoxLayout(pWidget); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | pLayout->addWidget(label); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | pLayout->setAlignment(Qt::AlignCenter); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | pLayout->setContentsMargins(0, 0, 0, 0); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | pWidget->setLayout(pLayout); |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
122 | this->tableWaters->setCellWidget(ridx, 2, pWidget); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | } else { |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
124 | this->tableWaters->removeCellWidget(ridx, 2); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | } |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | w = QString(""); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | if (query.value(12).toDouble() > 0) { |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | w = QString("%1 L").arg(query.value(12).toDouble(), 2, 'f', 1, '0' ); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | } |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | QTableWidgetItem *item = new QTableWidgetItem(w); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
133 | this->tableWaters->setItem(ridx, 3, item); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | /* Add the Edit button */ |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | pWidget = new QWidget(); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | QPushButton* btn_edit = new QPushButton(); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | btn_edit->setObjectName(QString("%1").arg(query.value(0).toString())); /* Send record with the button */ |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | btn_edit->setText(tr("Edit")); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | pLayout = new QHBoxLayout(pWidget); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | pLayout->addWidget(btn_edit); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | pLayout->setContentsMargins(5, 0, 5, 0); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | pWidget->setLayout(pLayout); |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
145 | this->tableWaters->setCellWidget(ridx, 4, pWidget); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | query.next(); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | } |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
73
diff
changeset
|
148 | emit setStatus(QString(tr("Total items: %1")).arg(query.size())); |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | } |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | |
72
7992c686e349
Inventory Waters now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
46
diff
changeset
|
152 | InventoryWaters::~InventoryWaters() {} |
29
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | void InventoryWaters::edit(int recno) |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | { |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | EditWater dialog(recno, this); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | /* Signal from editor if a refresh is needed */ |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | dialog.setModal(true); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | dialog.exec(); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | } |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | void InventoryWaters::on_editButton_clicked() |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | { |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | int recno = pb->objectName().toInt(); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | edit(recno); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | } |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | void InventoryWaters::on_insertButton_clicked() |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
174 | { |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | edit(-1); |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | } |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | |
76846c99f827
Added inventory water editor and table. In Yeasts table make sure the fields without a tickmark are empty. Removed Utils::Round function, not reliable.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
178 | |
46 | 179 | void InventoryWaters::on_exportButton_clicked() |
180 | { | |
181 | qDebug() << Q_FUNC_INFO; | |
182 | ||
183 | QSqlQuery query("SELECT * FROM inventory_waters ORDER BY name"); | |
184 | ||
185 | QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QDir::homePath() + "/waters.xml", tr("Files (*.xml)")); | |
186 | if (fileName == 0) { | |
187 | QMessageBox::warning(this, tr("Save File"), tr("No XML file selected.")); | |
188 | return; | |
189 | } | |
190 | ||
191 | QFile file(fileName); | |
192 | file.open(QIODevice::WriteOnly); | |
193 | ||
194 | QXmlStreamWriter *xmlWriter = new QXmlStreamWriter(&file); | |
195 | xmlWriter->writeStartDocument(); | |
196 | xmlWriter->setAutoFormatting(true); | |
197 | xmlWriter->setAutoFormattingIndent(1); | |
198 | xmlWriter->writeStartElement("WATERS"); | |
199 | ||
200 | query.first(); | |
201 | for (int i = 0 ; i < query.size() ; i++ ) { | |
202 | xmlWriter->writeStartElement("WATER"); | |
203 | xmlWriter->writeTextElement("VERSION", "1"); | |
204 | xmlWriter->writeTextElement("NAME", query.value(1).toString()); | |
205 | if (query.value(13).toDouble() > 0) | |
206 | xmlWriter->writeTextElement("COST", QString::number(query.value(13).toDouble(), 'f', 5)); | |
207 | if (query.value(10).toString().length()) | |
208 | xmlWriter->writeTextElement("NOTES", query.value(10).toString()); | |
209 | xmlWriter->writeTextElement("CALCIUM", QString::number(query.value(3).toDouble(), 'f', 4)); | |
210 | xmlWriter->writeTextElement("BICARBONATE", QString::number(query.value(4).toDouble(), 'f', 4)); | |
211 | xmlWriter->writeTextElement("SULFATE", QString::number(query.value(5).toDouble(), 'f', 4)); | |
212 | xmlWriter->writeTextElement("CHLORIDE", QString::number(query.value(6).toDouble(), 'f', 4)); | |
213 | xmlWriter->writeTextElement("SODIUM", QString::number(query.value(7).toDouble(), 'f', 4)); | |
214 | xmlWriter->writeTextElement("MAGNESIUM", QString::number(query.value(8).toDouble(), 'f', 4)); | |
215 | xmlWriter->writeTextElement("TOTAL_ALKALINITY", QString::number(query.value(11).toDouble(), 'f', 4)); | |
216 | xmlWriter->writeTextElement("PH", QString::number(query.value(9).toDouble(), 'f', 5)); | |
217 | xmlWriter->writeEndElement(); | |
218 | query.next(); | |
219 | } | |
220 | ||
221 | xmlWriter->writeEndElement(); | |
222 | xmlWriter->writeEndDocument(); | |
223 | QMessageBox::information(this, tr("Save File"), tr("XML export ready")); | |
224 | ||
225 | file.close(); | |
226 | } | |
227 | ||
228 |