Tue, 01 Mar 2022 13:19:25 +0100
Finisch miscs dutch translation.
/** * InventorySuppliers.cpp is part of bmsapp. * * bmsapp is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * bmsapp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "InventorySuppliers.h" #include "EditSupplier.h" #include "../ui/ui_InventorySuppliers.h" #include "config.h" #include "bmsapp.h" InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent), ui(new Ui::InventorySuppliers) { qDebug() << "InventorySuppliers start"; ui->setupUi(this); emit refreshTable(); setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING) ); } void InventorySuppliers::refreshTable() { qDebug() << "InventorySuppliers reload"; QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name"); const QStringList labels({tr("Name"), tr("Address"), tr("City"), tr("Country"), tr("Phone"), tr("Edit")}); ui->tableSuppliers->setColumnCount(6); ui->tableSuppliers->setColumnWidth(0, 250); /* Name */ ui->tableSuppliers->setColumnWidth(1, 250); /* Address */ ui->tableSuppliers->setColumnWidth(2, 200); /* City */ ui->tableSuppliers->setColumnWidth(3, 120); /* Country */ ui->tableSuppliers->setColumnWidth(4, 120); /* Phone */ ui->tableSuppliers->setColumnWidth(5, 90); /* Edit button */ ui->tableSuppliers->setRowCount(query.size()); ui->tableSuppliers->setHorizontalHeaderLabels(labels); ui->tableSuppliers->verticalHeader()->hide(); ui->tableSuppliers->setFixedSize(1030 + 24, 640); /* Even if this is too large, it works */ query.first(); for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { ui->tableSuppliers->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString())); ui->tableSuppliers->setItem(ridx, 1, new QTableWidgetItem(query.value(2).toString())); ui->tableSuppliers->setItem(ridx, 2, new QTableWidgetItem(query.value(3).toString())); ui->tableSuppliers->setItem(ridx, 3, new QTableWidgetItem(query.value(5).toString())); ui->tableSuppliers->setItem(ridx, 4, new QTableWidgetItem(query.value(8).toString())); /* Add the Edit button */ QWidget* pWidget = new QWidget(); QPushButton* btn_edit = new QPushButton(); btn_edit->setObjectName(QString("%1").arg(query.value(0).toString())); /* Send record with the button */ btn_edit->setText(tr("Edit")); connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); QHBoxLayout* pLayout = new QHBoxLayout(pWidget); pLayout->addWidget(btn_edit); pLayout->setContentsMargins(5, 0, 5, 0); pWidget->setLayout(pLayout); ui->tableSuppliers->setCellWidget(ridx, 5, pWidget); query.next(); } setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING) ); } InventorySuppliers::~InventorySuppliers() { qDebug() << "InventorySuppliers done"; delete ui; } void InventorySuppliers::edit(int recno) { qDebug() << "InventorySuppliers edit:" << recno; EditSupplier dialog(recno, this); /* Signal from editor if a refresh is needed */ connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); dialog.setModal(true); dialog.exec(); } void InventorySuppliers::on_editButton_clicked() { QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); int recno = pb->objectName().toInt(); qDebug() << Q_FUNC_INFO << recno; edit(recno); } void InventorySuppliers::on_insertButton_clicked() { qDebug() << Q_FUNC_INFO; edit(-1); } void InventorySuppliers::on_quitButton_clicked() { emit firstWindow(); }