# HG changeset patch # User Michiel Broek # Date 1654528527 -7200 # Node ID 42b88d85fefc6fe6dd28fc5741ad08a337ca4644 # Parent 78830c2ec7924f85d0195a9ae98bd4f5559a0830 Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24. diff -r 78830c2ec792 -r 42b88d85fefc src/EditProduct.cpp --- a/src/EditProduct.cpp Mon Jun 06 14:22:18 2022 +0200 +++ b/src/EditProduct.cpp Mon Jun 06 17:15:27 2022 +0200 @@ -235,7 +235,8 @@ product->yeast_prod_date = QDate(); product->yeast_pitchrate = product->prop_volume[0] = product->prop_volume[1] = product->prop_volume[2] = product->prop_volume[3] = 0; product->divide_type = product->divide_parts = product->divide_part = 0; - product->divide_size = product->divide_factor = 0; + product->divide_size = 0; + product->divide_factor = 1; } // Tab generic. diff -r 78830c2ec792 -r 42b88d85fefc src/EditProductTab5.cpp --- a/src/EditProductTab5.cpp Mon Jun 06 14:22:18 2022 +0200 +++ b/src/EditProductTab5.cpp Mon Jun 06 17:15:27 2022 +0200 @@ -110,13 +110,21 @@ * Not for water agents, these are set on the water tab. */ if (product->miscs.at(i).m_type == MISC_TYPES_WATER_AGENT) { + ui->miscsTable->removeCellWidget(i, 6); /* to remove the unneeded button */ item = new QTableWidgetItem(""); item->setToolTip(tr("Edit this from the water tab")); ui->miscsTable->setItem(i, 6, item); + ui->miscsTable->removeCellWidget(i, 7); item = new QTableWidgetItem(""); item->setToolTip(tr("Edit this from the water tab")); ui->miscsTable->setItem(i, 7, item); } else { + if (ui->miscsTable->item(i, 6)) { + ui->miscsTable->takeItem(i, 6); /* to remove the old tooltip */ + } + if (ui->miscsTable->item(i, 7)) { + ui->miscsTable->takeItem(i, 7); + } pWidget = new QWidget(); QPushButton* btn_dele = new QPushButton(); btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ @@ -304,7 +312,7 @@ newm.m_cost = 0; product->miscs.append(newm); is_changed(); - emit refreshAll(); + refreshMiscs(); } @@ -462,7 +470,20 @@ ui->miscsTable->setItem(product->miscs_row, 5, item); is_changed(); - emit refreshAll(); + qDebug() << "before" << product->miscs_row; + refreshMiscs(); + /* + * The order of the list is changed, lookup the item we just added. + */ + for (int i = 0; i < product->miscs.size(); i++) { + if ((product->miscs.at(i).m_name == query.value(0).toString()) && + (product->miscs.at(i).m_type == query.value(1).toInt()) && + (product->miscs.at(i).m_use_use == query.value(2).toInt())) { + product->miscs_row = i; + break; + } + } + qDebug() << "after" << product->miscs_row; } diff -r 78830c2ec792 -r 42b88d85fefc src/EditRecipeExport.cpp --- a/src/EditRecipeExport.cpp Mon Jun 06 14:22:18 2022 +0200 +++ b/src/EditRecipeExport.cpp Mon Jun 06 17:15:27 2022 +0200 @@ -422,7 +422,8 @@ p->yeast_prod_date = QDate(); p->yeast_pitchrate = p->prop_volume[0] = p->prop_volume[1] = p->prop_volume[2] = p->prop_volume[3] = 0; p->divide_type = p->divide_parts = p->divide_part = 0; - p->divide_size = p->divide_factor = 0; + p->divide_size = 0; + p->divide_factor = 1; p->fermentables = recipe->fermentables; p->hops = recipe->hops; diff -r 78830c2ec792 -r 42b88d85fefc src/PrinterDialog.cpp --- a/src/PrinterDialog.cpp Mon Jun 06 14:22:18 2022 +0200 +++ b/src/PrinterDialog.cpp Mon Jun 06 17:15:27 2022 +0200 @@ -1535,7 +1535,7 @@ double mashwater = 0; int numsalts = 0; - qInfo() << "Print checklist" << product->record; + qInfo() << "Print checklist" << product->record << "factor" << factor << product->divide_factor; printHeader(&painter); y = 120; @@ -1911,7 +1911,7 @@ for (int i = 0; i < product->miscs.size(); i++) { if (product->miscs.at(i).m_use_use == MISC_USES_PRIMARY) { QString unit = (product->miscs.at(i).m_amount_is_weight) ? "gr":"ml"; - checkLine(&painter, &y, QString(tr("Add %1 %2 `%3` on day 3 or 4")).arg(product->miscs.at(i).m_amount * factor, 1, 'f', 3) + checkLine(&painter, &y, QString(tr("Add %1 %2 `%3` on day 3 or 4")).arg(product->miscs.at(i).m_amount * 1000 * factor, 1, 'f', 3) .arg(unit).arg(product->miscs.at(i).m_name)); } } @@ -2012,7 +2012,7 @@ for (int i = 0; i < product->miscs.size(); i++) { if (product->miscs.at(i).m_use_use == MISC_USES_SECONDARY) { QString unit = (product->miscs.at(i).m_amount_is_weight) ? "gr":"ml"; - checkLine(&painter, &y, QString(tr("Add %1 %2 `%3` for %4 days")).arg(product->miscs.at(i).m_amount * factor, 1, 'f', 3) + checkLine(&painter, &y, QString(tr("Add %1 %2 `%3` for %4 days")).arg(product->miscs.at(i).m_amount * 1000.0 * factor, 1, 'f', 2) .arg(unit).arg(product->miscs.at(i).m_name).arg(product->miscs.at(i).m_time / 1440)); } } @@ -2069,7 +2069,7 @@ for (int i = 0; i < product->miscs.size(); i++) { if (product->miscs.at(i).m_use_use == MISC_USES_BOTTLING) { QString unit = (product->miscs.at(i).m_amount_is_weight) ? "gr":"ml"; - checkLine(&painter, &y, QString(tr("Add %1 %2 `%3` during bottling")).arg(product->miscs.at(i).m_amount * factor, 1, 'f', 3) + checkLine(&painter, &y, QString(tr("Add %1 %2 `%3` during bottling")).arg(product->miscs.at(i).m_amount * 1000 * factor, 1, 'f', 2) .arg(unit).arg(product->miscs.at(i).m_name)); } } diff -r 78830c2ec792 -r 42b88d85fefc ui/EditProduct.ui --- a/ui/EditProduct.ui Mon Jun 06 14:22:18 2022 +0200 +++ b/ui/EditProduct.ui Mon Jun 06 17:15:27 2022 +0200 @@ -374,7 +374,7 @@ 880 150 - 87 + 101 24 @@ -382,10 +382,10 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - true + false - QAbstractSpinBox::NoButtons + QAbstractSpinBox::UpDownArrows false @@ -2374,7 +2374,7 @@ 200 - 24 + 0 Qt::Horizontal @@ -2396,7 +2396,7 @@ 120 - 24 + 0 Qt::Horizontal @@ -2418,7 +2418,7 @@ 50 - 24 + 0 Qt::Horizontal @@ -2440,7 +2440,7 @@ 50 - 24 + 0 Qt::Horizontal @@ -2623,7 +2623,7 @@ 100 - 24 + 0 Qt::Horizontal @@ -2645,7 +2645,7 @@ 100 - 24 + 0 Qt::Horizontal