src/InventorySuppliers.cpp

changeset 6
f8474f2c5db9
child 7
51fbea52551e
equal deleted inserted replaced
5:22baafbf770d 6:f8474f2c5db9
1 /**
2 * InventorySuppliers.cpp is part of bmsapp.
3 *
4 * bmsapp is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * bmsapp is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #include "InventorySuppliers.h"
18 #include "../ui/ui_InventorySuppliers.h"
19 #include "config.h"
20
21 #include <QDebug>
22 //#include <QSqlTableModel>
23 //#include <QTableView>
24 //#include <QtWidgets>
25 #include <QtSql>
26 #include <QTableWidget>
27
28
29
30 InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent), ui(new Ui::InventorySuppliers)
31 {
32 qDebug() << Q_FUNC_INFO;
33
34 QTableWidget* table = new QTableWidget();
35 QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name");
36
37 table->setColumnCount(query.record().count() - 1); /* Skip the last uuid column */
38 table->setRowCount(query.size());
39
40 table->setHorizontalHeaderLabels({"record", "name", "address", "city", "zip", "country", "website", "email", "phone", "remark"});
41
42 qDebug() << query.record().count() << query.size();
43 // So far, so good.
44 query.first();
45 for (int ridx = 0 ; ridx < query.size() ; ridx++ ) {
46 for (int cidx = 0 ; cidx < query.record().count() - 1; cidx++) {
47 QTableWidgetItem* item = new QTableWidgetItem(query.value(cidx).toString());
48 table->setItem(ridx, cidx, item );
49 //qDebug() << ridx << cidx << query.value(cidx).toString();
50 }
51 query.next();
52 }
53 table->show(); /* TODO: Uses a separate window */
54
55 ui->setupUi(this);
56 setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING) );
57 }
58
59 InventorySuppliers::~InventorySuppliers()
60 {
61 qDebug() << Q_FUNC_INFO;
62 delete ui;
63 }
64
65
66 void InventorySuppliers::on_changeButton_clicked()
67 {
68 qDebug() << Q_FUNC_INFO;
69 emit firstWindow();
70 }
71

mercurial