src/InventorySuppliers.cpp

Sat, 19 Mar 2022 22:59:11 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 19 Mar 2022 22:59:11 +0100
changeset 65
2ef981980daa
parent 64
b0d30697af67
child 66
72386c164f54
permissions
-rw-r--r--

Finally found out how to make these databases work on a single main window. And it's dynamic too.

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
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
25 InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent) /*, ui(new Ui::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
26 {
12
66e10898a2a9 Suppliers table refresh works after edit.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
27 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
28
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
29 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
30 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
31 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
32 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
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41
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 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 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
52 quitButton->setMinimumSize(QSize(80, 24));
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 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
54 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
55 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
56 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
57
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 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
59 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
60 insertButton->setMinimumSize(QSize(80, 24));
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 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
62 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
63 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
64 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
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 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
67
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 //retranslateUi(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
69
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 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
71 connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked()));
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
72 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
73 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
74
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents: 9
diff changeset
75
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 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
77 {
22
b52978ee7412 Backport of the InventorySuppliers window.
Michiel Broek <mbroek@mbse.eu>
parents: 19
diff changeset
78 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
79
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
80 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
81 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
82
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
83 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
84 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
85 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
86 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
87 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
88 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
89 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
90 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
91 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
92 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
93 /* 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
94
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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
103 /* Add the Edit button */
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
104 QWidget* pWidget = new QWidget();
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
105 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
106 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
107 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
108 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
109 QHBoxLayout* pLayout = new QHBoxLayout(pWidget);
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
110 pLayout->addWidget(btn_edit);
19
c94edc758a5b Added Inventory Fermentables table.
Michiel Broek <mbroek@mbse.eu>
parents: 12
diff changeset
111 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
112 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
113 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
114 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
115 }
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
116 }
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
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
118
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
119 InventorySuppliers::~InventorySuppliers()
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 {
12
66e10898a2a9 Suppliers table refresh works after edit.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
121 qDebug() << "InventorySuppliers done";
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
122 }
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
123
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
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
125 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
126 {
12
66e10898a2a9 Suppliers table refresh works after edit.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
127 qDebug() << "InventorySuppliers edit:" << 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();
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 qDebug() << Q_FUNC_INFO << 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
142 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
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
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
145
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
146 void InventorySuppliers::on_insertButton_clicked()
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 qDebug() << Q_FUNC_INFO;
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
149 edit(-1);
8
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
150 }
ac4e363c09a7 The table screen is more or less complete.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
151

mercurial