src/InventorySuppliers.cpp

Mon, 21 Mar 2022 12:08:41 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 21 Mar 2022 12:08:41 +0100
changeset 79
e726db72da3c
parent 66
72386c164f54
child 90
2396457a8167
permissions
-rw-r--r--

All inventory and profiles now show the items sizes in the statusbar.

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"
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
21 #include "bmsapp.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
22
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
23
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
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
25 /*
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 * 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
27 * 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
28 */
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
29 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
30 {
12
66e10898a2a9 Suppliers table refresh works after edit.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
31 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
32
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
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45
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 = 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62
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 = 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72
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(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
74 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
75 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
76 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
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
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
79
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
80 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
81 {
22
b52978ee7412 Backport of the InventorySuppliers window.
Michiel Broek <mbroek@mbse.eu>
parents: 19
diff changeset
82 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
83
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
84 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
85 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
86
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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 /* 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
98
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 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
100 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
101 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
102 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
103 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
104 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
105 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
106
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
107 /* Add the Edit button */
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
108 QWidget* pWidget = new QWidget();
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
109 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
110 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
111 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
112 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
113 QHBoxLayout* pLayout = new QHBoxLayout(pWidget);
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
114 pLayout->addWidget(btn_edit);
19
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 12
diff changeset
115 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
116 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
117 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
118 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
119 }
79
e726db72da3c All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents: 66
diff changeset
120 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
121 }
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
122
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
123
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
124 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
125
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
126
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
127 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
128 {
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
129 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
130 /* 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
131 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
132 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
133 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
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
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
136
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
137 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
138 {
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 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
140 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
141 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
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
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
144
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
145 void InventorySuppliers::on_insertButton_clicked()
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
146 {
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
147 edit(-1);
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
148 }
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
149

mercurial