diff -r 8aa2bd9ba9e8 -r c9cdc15d3caf src/InventorySuppliers.cpp --- a/src/InventorySuppliers.cpp Mon Feb 14 20:58:07 2022 +0100 +++ b/src/InventorySuppliers.cpp Tue Feb 15 21:21:12 2022 +0100 @@ -34,18 +34,25 @@ qDebug() << Q_FUNC_INFO; ui->setupUi(this); - InventorySuppliers::loadTable(); + emit refreshTable(); setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING) ); } -void InventorySuppliers::loadTable(void) +void InventorySuppliers::refreshTable() { + qDebug() << "slot" << Q_FUNC_INFO; + ui->tableSuppliers = new QTableWidget(ui->tableSuppliers); + emit ui->tableSuppliers->clearContents(); 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")}); +// ui->tableSuppliers->clear(); +// ui->tableSuppliers->setRowCount(0); +// ui->tableSuppliers->setColumnCount(0); + ui->tableSuppliers->setColumnCount(7); ui->tableSuppliers->setColumnWidth(0, 50); /* Record */ ui->tableSuppliers->setColumnWidth(1, 250); /* Name */ @@ -97,16 +104,18 @@ } -bool InventorySuppliers::edit(int recno) +void InventorySuppliers::edit(int recno) { qDebug() << Q_FUNC_INFO << recno; EditSupplier dialog(recno, this); - dialog.setModal(true); - int rc = dialog.exec(); /* rc 0 == cancel, rc 1 == ok */ + /* Signal from editor if a refresh is needed */ + connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); - qDebug() << Q_FUNC_INFO << recno << rc; - return false; + dialog.setModal(true); + dialog.exec(); + + qDebug() << Q_FUNC_INFO << "Back from edit record:" << recno; } @@ -128,7 +137,6 @@ void InventorySuppliers::on_quitButton_clicked() { - qDebug() << Q_FUNC_INFO; emit firstWindow(); }