--- a/src/EditProductTab4.cpp Fri Apr 29 20:29:26 2022 +0200 +++ b/src/EditProductTab4.cpp Fri Apr 29 21:42:00 2022 +0200 @@ -46,20 +46,21 @@ std::sort(product->hops.begin(), product->hops.end(), hop_sort_test); const QStringList labels({tr("Origin"), tr("Hop"), tr("Type"), tr("Form"), tr("Alpha"), tr("Use at"), tr("Time"), - tr("IBU"), tr("Amount"), tr("Delete"), tr("Edit") }); + tr("IBU"), tr("Amount"), tr("Stock"), tr("Delete"), tr("Edit") }); - ui->hopsTable->setColumnCount(11); - ui->hopsTable->setColumnWidth(0, 150); /* Origin */ + ui->hopsTable->setColumnCount(12); + ui->hopsTable->setColumnWidth(0, 130); /* Origin */ ui->hopsTable->setColumnWidth(1, 225); /* Hop */ - ui->hopsTable->setColumnWidth(2, 84); /* Type */ + ui->hopsTable->setColumnWidth(2, 74); /* Type */ ui->hopsTable->setColumnWidth(3, 84); /* Form */ - ui->hopsTable->setColumnWidth(4, 75); /* Alpha% */ + ui->hopsTable->setColumnWidth(4, 55); /* Alpha% */ ui->hopsTable->setColumnWidth(5, 75); /* Added */ - ui->hopsTable->setColumnWidth(6, 75); /* Time */ - ui->hopsTable->setColumnWidth(7, 60); /* IBU */ - ui->hopsTable->setColumnWidth(8, 90); /* Amount */ - ui->hopsTable->setColumnWidth(9, 80); /* Delete */ - ui->hopsTable->setColumnWidth(10, 80); /* Edit */ + ui->hopsTable->setColumnWidth(6, 65); /* Time */ + ui->hopsTable->setColumnWidth(7, 50); /* IBU */ + ui->hopsTable->setColumnWidth(8, 80); /* Amount */ + ui->hopsTable->setColumnWidth(9, 80); /* Stock */ + ui->hopsTable->setColumnWidth(10, 80); /* Delete */ + ui->hopsTable->setColumnWidth(11, 80); /* Edit */ ui->hopsTable->setHorizontalHeaderLabels(labels); ui->hopsTable->verticalHeader()->hide(); ui->hopsTable->setRowCount(product->hops.size()); @@ -109,6 +110,14 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(i, 8, item); + if (product->hops.at(i).h_inventory < 1.0) { + item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).h_inventory * 1000.0, 2, 'f', 1, '0')); + } else { + item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).h_inventory, 4, 'f', 3, '0')); + } + item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + ui->hopsTable->setItem(i, 9, item); + /* Add the Delete row button */ pWidget = new QWidget(); QPushButton* btn_dele = new QPushButton(); @@ -119,7 +128,7 @@ pLayout->addWidget(btn_dele); pLayout->setContentsMargins(5, 0, 5, 0); pWidget->setLayout(pLayout); - ui->hopsTable->setCellWidget(i, 9, pWidget); + ui->hopsTable->setCellWidget(i, 10, pWidget); pWidget = new QWidget(); QPushButton* btn_edit = new QPushButton(); @@ -130,7 +139,7 @@ pLayout->addWidget(btn_edit); pLayout->setContentsMargins(5, 0, 5, 0); pWidget->setLayout(pLayout); - ui->hopsTable->setCellWidget(i, 10, pWidget); + ui->hopsTable->setCellWidget(i, 11, pWidget); } }