32 InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent), ui(new Ui::InventorySuppliers) |
32 InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent), ui(new Ui::InventorySuppliers) |
33 { |
33 { |
34 qDebug() << Q_FUNC_INFO; |
34 qDebug() << Q_FUNC_INFO; |
35 |
35 |
36 ui->setupUi(this); |
36 ui->setupUi(this); |
37 InventorySuppliers::loadTable(); |
37 emit refreshTable(); |
38 |
38 |
39 setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING) ); |
39 setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING) ); |
40 } |
40 } |
41 |
41 |
42 |
42 |
43 void InventorySuppliers::loadTable(void) |
43 void InventorySuppliers::refreshTable() |
44 { |
44 { |
|
45 qDebug() << "slot" << Q_FUNC_INFO; |
|
46 |
45 ui->tableSuppliers = new QTableWidget(ui->tableSuppliers); |
47 ui->tableSuppliers = new QTableWidget(ui->tableSuppliers); |
|
48 emit ui->tableSuppliers->clearContents(); |
46 QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name"); |
49 QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name"); |
47 const QStringList labels({tr("Record"), tr("Name"), tr("Address"), tr("City"), tr("Country"), tr("Phone"), tr("Edit")}); |
50 const QStringList labels({tr("Record"), tr("Name"), tr("Address"), tr("City"), tr("Country"), tr("Phone"), tr("Edit")}); |
|
51 |
|
52 // ui->tableSuppliers->clear(); |
|
53 // ui->tableSuppliers->setRowCount(0); |
|
54 // ui->tableSuppliers->setColumnCount(0); |
48 |
55 |
49 ui->tableSuppliers->setColumnCount(7); |
56 ui->tableSuppliers->setColumnCount(7); |
50 ui->tableSuppliers->setColumnWidth(0, 50); /* Record */ |
57 ui->tableSuppliers->setColumnWidth(0, 50); /* Record */ |
51 ui->tableSuppliers->setColumnWidth(1, 250); /* Name */ |
58 ui->tableSuppliers->setColumnWidth(1, 250); /* Name */ |
52 ui->tableSuppliers->setColumnWidth(2, 250); /* Address */ |
59 ui->tableSuppliers->setColumnWidth(2, 250); /* Address */ |
95 qDebug() << Q_FUNC_INFO; |
102 qDebug() << Q_FUNC_INFO; |
96 delete ui; |
103 delete ui; |
97 } |
104 } |
98 |
105 |
99 |
106 |
100 bool InventorySuppliers::edit(int recno) |
107 void InventorySuppliers::edit(int recno) |
101 { |
108 { |
102 qDebug() << Q_FUNC_INFO << recno; |
109 qDebug() << Q_FUNC_INFO << recno; |
103 |
110 |
104 EditSupplier dialog(recno, this); |
111 EditSupplier dialog(recno, this); |
|
112 /* Signal from editor if a refresh is needed */ |
|
113 connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); |
|
114 |
105 dialog.setModal(true); |
115 dialog.setModal(true); |
106 int rc = dialog.exec(); /* rc 0 == cancel, rc 1 == ok */ |
116 dialog.exec(); |
107 |
117 |
108 qDebug() << Q_FUNC_INFO << recno << rc; |
118 qDebug() << Q_FUNC_INFO << "Back from edit record:" << recno; |
109 return false; |
|
110 } |
119 } |
111 |
120 |
112 |
121 |
113 void InventorySuppliers::on_editButton_clicked() |
122 void InventorySuppliers::on_editButton_clicked() |
114 { |
123 { |