# HG changeset patch # User Michiel Broek # Date 1644761703 -3600 # Node ID 51fbea52551e7ba58767e2073de8488f9db2e8f1 # Parent f8474f2c5db97e145bac698bb8207dad86d3956a The suppliers table now shows on the right screen. diff -r f8474f2c5db9 -r 51fbea52551e src/InventorySuppliers.cpp --- a/src/InventorySuppliers.cpp Sat Feb 12 21:24:43 2022 +0100 +++ b/src/InventorySuppliers.cpp Sun Feb 13 15:15:03 2022 +0100 @@ -19,40 +19,48 @@ #include "config.h" #include -//#include -//#include -//#include #include #include - InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent), ui(new Ui::InventorySuppliers) { qDebug() << Q_FUNC_INFO; - QTableWidget* table = new QTableWidget(); + ui->setupUi(this); + + ui->tableSuppliers = new QTableWidget(ui->tableSuppliers); QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name"); + const QStringList labels({tr("Record"), tr("Name"), tr("Address"), tr("City"), tr("Country"), tr("Phone"), tr("Edit")}); - table->setColumnCount(query.record().count() - 1); /* Skip the last uuid column */ - table->setRowCount(query.size()); - - table->setHorizontalHeaderLabels({"record", "name", "address", "city", "zip", "country", "website", "email", "phone", "remark"}); + ui->tableSuppliers->setColumnCount(7); + ui->tableSuppliers->setColumnWidth(0, 50); /* Record */ + ui->tableSuppliers->setColumnWidth(1, 250); /* Name */ + ui->tableSuppliers->setColumnWidth(2, 250); /* Address */ + ui->tableSuppliers->setColumnWidth(3, 200); /* City */ + ui->tableSuppliers->setColumnWidth(4, 120); /* Country */ + ui->tableSuppliers->setColumnWidth(5, 120); /* Phone */ + ui->tableSuppliers->setColumnWidth(6, 150); /* Edit button */ + ui->tableSuppliers->setRowCount(query.size()); + ui->tableSuppliers->setHorizontalHeaderLabels(labels); + ui->tableSuppliers->verticalHeader()->hide(); + ui->tableSuppliers->setFixedSize(1280, 640); /* Even if this is too large, it works */ qDebug() << query.record().count() << query.size(); // So far, so good. query.first(); for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { - for (int cidx = 0 ; cidx < query.record().count() - 1; cidx++) { + for (int cidx = 0 ; cidx < 4; cidx++) { QTableWidgetItem* item = new QTableWidgetItem(query.value(cidx).toString()); - table->setItem(ridx, cidx, item ); - //qDebug() << ridx << cidx << query.value(cidx).toString(); + ui->tableSuppliers->setItem(ridx, cidx, item ); } + QTableWidgetItem* item = new QTableWidgetItem(query.value(5).toString()); + ui->tableSuppliers->setItem(ridx, 4, item ); + item = new QTableWidgetItem(query.value(8).toString()); + ui->tableSuppliers->setItem(ridx, 5, item ); query.next(); } - table->show(); /* TODO: Uses a separate window */ - ui->setupUi(this); setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING) ); } diff -r f8474f2c5db9 -r 51fbea52551e ui/InventorySuppliers.ui --- a/ui/InventorySuppliers.ui Sat Feb 12 21:24:43 2022 +0100 +++ b/ui/InventorySuppliers.ui Sun Feb 13 15:15:03 2022 +0100 @@ -15,7 +15,11 @@ - + + + true + +