src/InventoryYeastPacks.cpp

Mon, 30 Jan 2023 17:05:13 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 30 Jan 2023 17:05:13 +0100
changeset 480
94b3def5d778
permissions
-rw-r--r--

Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.

480
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * InventoryYeastPacks.cpp is part of bmsapp.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "InventoryYeastPacks.h"
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "EditYeastPack.h"
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "MainWindow.h"
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include "config.h"
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 #include "global.h"
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 InventoryYeastPacks::InventoryYeastPacks(QWidget *parent) : QDialog(parent)
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 qDebug() << "InventoryYeastPacks start";
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 gridLayout = new QGridLayout(this);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 tableYeastPacks = new QTableWidget(this);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 tableYeastPacks->setObjectName(QString::fromUtf8("tableYeastPacks"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 tableYeastPacks->setEnabled(true);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 sizePolicy.setHorizontalStretch(0);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 sizePolicy.setVerticalStretch(0);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 tableYeastPacks->setSizePolicy(sizePolicy);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 tableYeastPacks->setMinimumSize(QSize(824, 0));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 gridLayout->addWidget(tableYeastPacks, 0, 0, 1, 1);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 groupBox = new QGroupBox(this);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 groupBox->setObjectName(QString::fromUtf8("groupBox"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 groupBox->setEnabled(true);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 groupBox->setFlat(false);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 horizontalLayout = new QHBoxLayout(groupBox);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 horizontalLayout->setSpacing(6);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 horizontalLayout->setContentsMargins(0, 0, 0, 0);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 quitButton = new QPushButton(groupBox);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 quitButton->setObjectName(QString::fromUtf8("quitButton"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 quitButton->setMinimumSize(QSize(80, 24));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 quitButton->setText(tr("Quit"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 QIcon icon;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 quitButton->setIcon(icon);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 exportButton = new QPushButton(groupBox);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 exportButton->setObjectName(QString::fromUtf8("exportButton"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 exportButton->setMinimumSize(QSize(80, 24));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 exportButton->setText(tr("Export"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 QIcon icon1;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 icon1.addFile(QString::fromUtf8(":/icons/silk/database_save.png"), QSize(), QIcon::Normal, QIcon::Off);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 exportButton->setIcon(icon1);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 horizontalLayout->addWidget(exportButton, 0, Qt::AlignCenter);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 insertButton = new QPushButton(groupBox);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 insertButton->setObjectName(QString::fromUtf8("insertButton"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 insertButton->setMinimumSize(QSize(80, 24));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 insertButton->setText(tr("New"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 QIcon icon3;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 insertButton->setIcon(icon3);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 gridLayout->addWidget(groupBox, 1, 0, 1, 1);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventoryYeastPacks()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 connect(exportButton, SIGNAL(clicked()), this, SLOT(on_exportButton_clicked()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString)));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 emit refreshTable();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 void InventoryYeastPacks::refreshTable()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 QString w;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 QWidget* pWidget;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 QLabel *label;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 QHBoxLayout* pLayout;
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 qDebug() << "InventoryYeastPacks reload";
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 QSqlQuery query("SELECT * FROM inventory_yeastpack ORDER BY laboratory,package");
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 const QStringList labels({tr("Laboratory"), tr("Package"), tr("Form"), tr("Size"), tr("Edit")});
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 /* origin supplier name type graintype color yield inventory Edit */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 this->tableYeastPacks->setColumnCount(5);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 this->tableYeastPacks->setColumnWidth(0, 250); /* Laboratory */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 this->tableYeastPacks->setColumnWidth(1, 250); /* Package */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 this->tableYeastPacks->setColumnWidth(2, 100); /* Form */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 this->tableYeastPacks->setColumnWidth(3, 100); /* Size */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 this->tableYeastPacks->setColumnWidth(4, 100); /* Edit button */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 this->tableYeastPacks->setRowCount(query.size());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 this->tableYeastPacks->setHorizontalHeaderLabels(labels);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 this->tableYeastPacks->verticalHeader()->hide();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 QTableWidgetItem *rightitem = new QTableWidgetItem();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 rightitem->setTextAlignment(Qt::AlignRight);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 query.first();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 for (int ridx = 0 ; ridx < query.size() ; ridx++ ) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 this->tableYeastPacks->setItem(ridx, 0, new QTableWidgetItem(query.value("laboratory").toString())); /* Laboratory */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 this->tableYeastPacks->setItem(ridx, 1, new QTableWidgetItem(query.value("package").toString())); /* Name */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 this->tableYeastPacks->setItem(ridx, 2, new QTableWidgetItem(QCoreApplication::translate("YeastForm", g_yeast_forms[query.value("form").toInt()])));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 w = QString("");
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 if (query.value("form").toInt() == 1 || query.value("form").toInt() == 6) {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 w = QString("%1 gram").arg(query.value("size").toDouble() * 1000, 2, 'f', 1, '0');
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 } else {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 w = QString("%1 ml").arg(query.value("size").toDouble() * 1000, 2, 'f', 1, '0');
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 QTableWidgetItem *item = new QTableWidgetItem(w);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 this->tableYeastPacks->setItem(ridx, 3, item);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 /* Add the Edit button */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 pWidget = new QWidget();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 QPushButton* btn_edit = new QPushButton();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 btn_edit->setObjectName(QString("%1").arg(query.value(0).toString())); /* Send record with the button */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 btn_edit->setText(tr("Edit"));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 pLayout = new QHBoxLayout(pWidget);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 pLayout->addWidget(btn_edit);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 pLayout->setContentsMargins(5, 0, 5, 0);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 pWidget->setLayout(pLayout);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 this->tableYeastPacks->setCellWidget(ridx, 4, pWidget);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 query.next();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 emit setStatus(QString(tr("Total items: %1")).arg(query.size()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 InventoryYeastPacks::~InventoryYeastPacks() {}
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 void InventoryYeastPacks::edit(int recno)
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 EditYeastPack dialog(recno, this);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 /* Signal from editor if a refresh is needed */
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable()));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 dialog.setModal(true);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 dialog.exec();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 void InventoryYeastPacks::on_editButton_clicked()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 int recno = pb->objectName().toInt();
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 edit(recno);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 void InventoryYeastPacks::on_insertButton_clicked()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 edit(-1);
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 void InventoryYeastPacks::on_exportButton_clicked()
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 {
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 QMessageBox::information(this, QGuiApplication::applicationDisplayName(), tr("BeerXML doesn't support export yeast packages."));
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 }
94b3def5d778 Added yeastpack editor. Expanded the database upgrade. On startup, recount the yeastpack used fields.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175

mercurial