src/InventorySuppliers.cpp

Thu, 18 Aug 2022 17:07:47 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 17:07:47 +0200
changeset 398
49cf387e9070
parent 90
2396457a8167
permissions
-rw-r--r--

After brewing show final IBU on the first tab.

6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * InventorySuppliers.cpp is part of bmsapp.
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "InventorySuppliers.h"
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
18 #include "EditSupplier.h"
64
b0d30697af67 First step in loading the Inventory Suppliers database on the mainscreen. But, it is loaded at program start en not removed when done. Weird programming to get this working.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
19 #include "MainWindow.h"
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include "config.h"
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
22
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
23
66
72386c164f54 Added texts on the buttons. Removed a number of debug messages. Hide and show the main menubar during edit. Removed unused and unneeded stackable window pages.
Michiel Broek <mbroek@mbse.eu>
parents: 65
diff changeset
24 /*
72386c164f54 Added texts on the buttons. Removed a number of debug messages. Hide and show the main menubar during edit. Removed unused and unneeded stackable window pages.
Michiel Broek <mbroek@mbse.eu>
parents: 65
diff changeset
25 * Build the table and buttons on the mainscreen.
72386c164f54 Added texts on the buttons. Removed a number of debug messages. Hide and show the main menubar during edit. Removed unused and unneeded stackable window pages.
Michiel Broek <mbroek@mbse.eu>
parents: 65
diff changeset
26 * Don't use a ui file, do it dynamicly.
72386c164f54 Added texts on the buttons. Removed a number of debug messages. Hide and show the main menubar during edit. Removed unused and unneeded stackable window pages.
Michiel Broek <mbroek@mbse.eu>
parents: 65
diff changeset
27 */
72386c164f54 Added texts on the buttons. Removed a number of debug messages. Hide and show the main menubar during edit. Removed unused and unneeded stackable window pages.
Michiel Broek <mbroek@mbse.eu>
parents: 65
diff changeset
28 InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent)
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 {
12
66e10898a2a9 Suppliers table refresh works after edit.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
30 qDebug() << "InventorySuppliers start";
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
65
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
32 gridLayout = new QGridLayout(this);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
33 gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
34 tableSuppliers = new QTableWidget(this);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
35 tableSuppliers->setObjectName(QString::fromUtf8("tableSuppliers"));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
36 tableSuppliers->setEnabled(true);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
37 QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
38 sizePolicy.setHorizontalStretch(0);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
39 sizePolicy.setVerticalStretch(0);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
40 sizePolicy.setHeightForWidth(tableSuppliers->sizePolicy().hasHeightForWidth());
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
41 tableSuppliers->setSizePolicy(sizePolicy);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
42 tableSuppliers->setMinimumSize(QSize(1054, 0));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
43 gridLayout->addWidget(tableSuppliers, 0, 0, 1, 1);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
44
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
45 groupBox = new QGroupBox(this);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
46 groupBox->setObjectName(QString::fromUtf8("groupBox"));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
47 groupBox->setEnabled(true);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
48 groupBox->setFlat(false);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
49 horizontalLayout = new QHBoxLayout(groupBox);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
50 horizontalLayout->setSpacing(6);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
51 horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
52 horizontalLayout->setContentsMargins(0, 0, 0, 0);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
53 quitButton = new QPushButton(groupBox);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
54 quitButton->setObjectName(QString::fromUtf8("quitButton"));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
55 quitButton->setMinimumSize(QSize(80, 24));
66
72386c164f54 Added texts on the buttons. Removed a number of debug messages. Hide and show the main menubar during edit. Removed unused and unneeded stackable window pages.
Michiel Broek <mbroek@mbse.eu>
parents: 65
diff changeset
56 quitButton->setText(tr("Quit"));
65
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
57 QIcon icon;
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
58 icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
59 quitButton->setIcon(icon);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
60 horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
61
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
62 insertButton = new QPushButton(groupBox);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
63 insertButton->setObjectName(QString::fromUtf8("insertButton"));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
64 insertButton->setMinimumSize(QSize(80, 24));
66
72386c164f54 Added texts on the buttons. Removed a number of debug messages. Hide and show the main menubar during edit. Removed unused and unneeded stackable window pages.
Michiel Broek <mbroek@mbse.eu>
parents: 65
diff changeset
65 insertButton->setText(tr("New"));
65
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
66 QIcon icon1;
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
67 icon1.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
68 insertButton->setIcon(icon1);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
69 horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
70 gridLayout->addWidget(groupBox, 1, 0, 1, 1);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
71
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
72 connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventorySuppliers()));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
73 connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked()));
79
e726db72da3c All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
74 connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString)));
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
75 emit refreshTable();
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
76 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
77
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
78
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
79 void InventorySuppliers::refreshTable()
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
80 {
22
b52978ee7412 Backport of the InventorySuppliers window.
Michiel Broek <mbroek@mbse.eu>
parents: 19
diff changeset
81 qDebug() << "InventorySuppliers reload";
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
82
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name");
22
b52978ee7412 Backport of the InventorySuppliers window.
Michiel Broek <mbroek@mbse.eu>
parents: 19
diff changeset
84 const QStringList labels({tr("Name"), tr("Address"), tr("City"), tr("Country"), tr("Phone"), tr("Edit")});
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85
65
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
86 this->tableSuppliers->setColumnCount(6);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
87 this->tableSuppliers->setColumnWidth(0, 250); /* Name */
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
88 this->tableSuppliers->setColumnWidth(1, 250); /* Address */
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
89 this->tableSuppliers->setColumnWidth(2, 200); /* City */
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
90 this->tableSuppliers->setColumnWidth(3, 120); /* Country */
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
91 this->tableSuppliers->setColumnWidth(4, 120); /* Phone */
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
92 this->tableSuppliers->setColumnWidth(5, 90); /* Edit button */
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
93 this->tableSuppliers->setRowCount(query.size());
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
94 this->tableSuppliers->setHorizontalHeaderLabels(labels);
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
95 this->tableSuppliers->verticalHeader()->hide();
61
3fea5dde2b99 Changed the way the inventory is displayed. Suppliers only for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
96 /* Set the widget size to 1054 x 575 in the ui. */
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 query.first();
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 for (int ridx = 0 ; ridx < query.size() ; ridx++ ) {
65
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
100 this->tableSuppliers->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString()));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
101 this->tableSuppliers->setItem(ridx, 1, new QTableWidgetItem(query.value(2).toString()));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
102 this->tableSuppliers->setItem(ridx, 2, new QTableWidgetItem(query.value(3).toString()));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
103 this->tableSuppliers->setItem(ridx, 3, new QTableWidgetItem(query.value(5).toString()));
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
104 this->tableSuppliers->setItem(ridx, 4, new QTableWidgetItem(query.value(8).toString()));
22
b52978ee7412 Backport of the InventorySuppliers window.
Michiel Broek <mbroek@mbse.eu>
parents: 19
diff changeset
105
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
106 /* Add the Edit button */
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
107 QWidget* pWidget = new QWidget();
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
108 QPushButton* btn_edit = new QPushButton();
9
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
109 btn_edit->setObjectName(QString("%1").arg(query.value(0).toString())); /* Send record with the button */
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
110 btn_edit->setText(tr("Edit"));
9
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
111 connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked()));
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
112 QHBoxLayout* pLayout = new QHBoxLayout(pWidget);
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
113 pLayout->addWidget(btn_edit);
19
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 12
diff changeset
114 pLayout->setContentsMargins(5, 0, 5, 0);
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
115 pWidget->setLayout(pLayout);
65
2ef981980daa Finally found out how to make these databases work on a single main window. And it's dynamic too.
Michiel Broek <mbroek@mbse.eu>
parents: 64
diff changeset
116 this->tableSuppliers->setCellWidget(ridx, 5, pWidget);
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 query.next();
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 }
79
e726db72da3c All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
119 emit setStatus(QString(tr("Total items: %1")).arg(query.size()));
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 }
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121
9
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
122
66
72386c164f54 Added texts on the buttons. Removed a number of debug messages. Hide and show the main menubar during edit. Removed unused and unneeded stackable window pages.
Michiel Broek <mbroek@mbse.eu>
parents: 65
diff changeset
123 InventorySuppliers::~InventorySuppliers() {}
6
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124
f8474f2c5db9 We can fetch a list of suppliers and show it in the wrong window. Still a lot to learn about Qt5
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
126 void InventorySuppliers::edit(int recno)
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
127 {
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
128 EditSupplier dialog(recno, this);
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
129 /* Signal from editor if a refresh is needed */
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
130 connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable()));
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
131 dialog.setModal(true);
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
132 dialog.exec();
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
133 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
134
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
135
9
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
136 void InventorySuppliers::on_editButton_clicked()
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
137 {
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
138 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
139 int recno = pb->objectName().toInt();
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
140 edit(recno);
9
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
141 }
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
142
85656dc48131 The Edit buttons include the record number in the database. Ready to build the modal supplier edit/insert/delete screen.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
143
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
144 void InventorySuppliers::on_insertButton_clicked()
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
145 {
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
146 edit(-1);
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
147 }
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
148

mercurial