Tue, 01 Mar 2022 13:19:25 +0100
Finisch miscs dutch translation.
/** * InventoryYeasts.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 "InventoryYeasts.h" #include "EditYeast.h" #include "../ui/ui_InventoryYeasts.h" #include "config.h" #include "bmsapp.h" InventoryYeasts::InventoryYeasts(QWidget *parent) : QDialog(parent), ui(new Ui::InventoryYeasts) { qDebug() << "InventoryYeasts start"; ui->setupUi(this); emit refreshTable(); setWindowTitle( QString("BMSapp - %1 - Inventory Yeasts").arg(VERSIONSTRING) ); } void InventoryYeasts::refreshTable() { QString w; QWidget* pWidget; QLabel *label; QHBoxLayout* pLayout; qDebug() << "InventoryYeasts reload"; QSqlQuery query("SELECT * FROM inventory_yeasts ORDER BY laboratory,product_id,name"); const QStringList labels({tr("Laboratory"), tr("Product id"), tr("Name"), tr("Type"), tr("Form"), tr("SVG %"), tr("Tol %"), tr("POF+"), tr("STA1"), tr("Stock"), tr("Edit")}); const QStringList types({tr("Lager"), tr("Ale"), tr("Wheat"), tr("Wine"), tr("Champagne"), tr("Brett"), tr("Kveik"), tr("Hybrid")}); const QStringList form({tr("Liquid"), tr("Dry"), tr("Slant"), tr("Culture"), tr("Frozen"), tr("Bottle"), tr("Dried")}); /* origin supplier name type graintype color yield inventory Edit */ ui->tableYeasts->setColumnCount(11); ui->tableYeasts->setColumnWidth(0, 120); /* Laboratory */ ui->tableYeasts->setColumnWidth(1, 120); /* Product ID */ ui->tableYeasts->setColumnWidth(2, 250); /* Name */ ui->tableYeasts->setColumnWidth(3, 70); /* Type */ ui->tableYeasts->setColumnWidth(4, 70); /* Form */ ui->tableYeasts->setColumnWidth(5, 80); /* SVG */ ui->tableYeasts->setColumnWidth(6, 80); /* Tolerance */ ui->tableYeasts->setColumnWidth(7, 60); /* POF+ */ ui->tableYeasts->setColumnWidth(8, 60); /* STA1 */ ui->tableYeasts->setColumnWidth(9, 80); /* Stock */ ui->tableYeasts->setColumnWidth(10, 80); /* Edit button */ ui->tableYeasts->setRowCount(query.size()); ui->tableYeasts->setHorizontalHeaderLabels(labels); ui->tableYeasts->verticalHeader()->hide(); ui->tableYeasts->setFixedSize(1070 + 24, 640); /* Even if this is too large, it works */ QTableWidgetItem *rightitem = new QTableWidgetItem(); rightitem->setTextAlignment(Qt::AlignRight); query.first(); for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { ui->tableYeasts->setItem(ridx, 0, new QTableWidgetItem(query.value(4).toString())); /* Laboratory */ ui->tableYeasts->setItem(ridx, 1, new QTableWidgetItem(query.value(5).toString())); /* Product id */ ui->tableYeasts->setItem(ridx, 2, new QTableWidgetItem(query.value(1).toString())); /* Name */ ui->tableYeasts->setItem(ridx, 3, new QTableWidgetItem(types[query.value(2).toInt()])); /* Type */ ui->tableYeasts->setItem(ridx, 4, new QTableWidgetItem(form[query.value(3).toInt()])); /* Form */ w = QString("%1 %").arg(query.value(9).toDouble(), 2, 'f', 1, '0' ); /* Attenuation% */ QTableWidgetItem *item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->tableYeasts->setItem(ridx, 5, item); w = QString(""); if (query.value(10).toDouble() > 0) w = QString("%1 %").arg(query.value(10).toDouble(), 2, 'f', 1, '0' ); /* Alcohol% */ item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->tableYeasts->setItem(ridx, 6, item); if (query.value(24).toInt()) { pWidget = new QWidget(); label = new QLabel; label->setPixmap(QPixmap(":icons/silk/tick.png")); pLayout = new QHBoxLayout(pWidget); pLayout->addWidget(label); pLayout->setAlignment(Qt::AlignCenter); pLayout->setContentsMargins(0, 0, 0, 0); pWidget->setLayout(pLayout); ui->tableYeasts->setCellWidget(ridx, 7, pWidget); } else { ui->tableYeasts->removeCellWidget(ridx, 7); } if (query.value(19).toInt()) { pWidget = new QWidget(); label = new QLabel; label->setPixmap(QPixmap(":icons/silk/tick.png")); pLayout = new QHBoxLayout(pWidget); pLayout->addWidget(label); pLayout->setAlignment(Qt::AlignCenter); pLayout->setContentsMargins(0, 0, 0, 0); pWidget->setLayout(pLayout); ui->tableYeasts->setCellWidget(ridx, 8, pWidget); } else { ui->tableYeasts->removeCellWidget(ridx, 8); } w = QString(""); if (query.value(14).toDouble() > 0) { if (query.value(3).toInt() == 0 && query.value(14).toDouble() > 1) { /* Liquid yeast, multiple packs */ w = QString("%1 packs").arg(query.value(14).toDouble(), 1, 'f', 0, '0'); } else if (query.value(3).toInt() == 0) { /* Liquid yeast */ w = QString("%1 pack").arg(query.value(14).toDouble(), 1, 'f', 0, '0'); } else if (query.value(3).toInt() == 1 || query.value(3).toInt() == 6) { /* Dry or dried */ w = QString("%1 gram").arg(query.value(14).toDouble() * 1000, 2, 'f', 1, '0'); } else { /* Any other form */ w = QString("%1 ml").arg(query.value(14).toDouble() * 1000, 2, 'f', 1, '0'); } } item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->tableYeasts->setItem(ridx, 9, item); /* Add the Edit button */ 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())); pLayout = new QHBoxLayout(pWidget); pLayout->addWidget(btn_edit); pLayout->setContentsMargins(5, 0, 5, 0); pWidget->setLayout(pLayout); ui->tableYeasts->setCellWidget(ridx, 10, pWidget); query.next(); } setWindowTitle( QString("BMSapp - %1 - Inventory Yeasts").arg(VERSIONSTRING) ); } InventoryYeasts::~InventoryYeasts() { qDebug() << "InventoryYeasts done"; delete ui; } void InventoryYeasts::edit(int recno) { qDebug() << "InventoryYeasts edit:" << recno; EditYeast 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 InventoryYeasts::on_editButton_clicked() { QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); int recno = pb->objectName().toInt(); qDebug() << Q_FUNC_INFO << recno; edit(recno); } void InventoryYeasts::on_insertButton_clicked() { qDebug() << Q_FUNC_INFO; edit(-1); } void InventoryYeasts::on_quitButton_clicked() { emit firstWindow(); }