# HG changeset patch # User Michiel Broek # Date 1654536939 -7200 # Node ID 246893ad04a6435f8e244c8a4c74a152c42ec242 # Parent 42b88d85fefc6fe6dd28fc5741ad08a337ca4644 Updated the changes from the product misc editor to the recipe misc editor. diff -r 42b88d85fefc -r 246893ad04a6 src/EditRecipeTab4.cpp --- a/src/EditRecipeTab4.cpp Mon Jun 06 17:15:27 2022 +0200 +++ b/src/EditRecipeTab4.cpp Mon Jun 06 19:35:39 2022 +0200 @@ -78,9 +78,9 @@ item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->miscsTable->setItem(i, 2, item); - if (recipe->miscs.at(i).m_use_use == 2) { // Boil + if (recipe->miscs.at(i).m_use_use == MISC_USES_BOIL) { item = new QTableWidgetItem(QString("%1 min.").arg(recipe->miscs.at(i).m_time, 1, 'f', 0, '0')); - } else if (recipe->miscs.at(i).m_use_use == 3 || recipe->miscs.at(i).m_use_use == 4) { // Primary or secondary + } else if (recipe->miscs.at(i).m_use_use == MISC_USES_PRIMARY || recipe->miscs.at(i).m_use_use == MISC_USES_SECONDARY) { item = new QTableWidgetItem(QString("%1 days.").arg(recipe->miscs.at(i).m_time / 1440, 1, 'f', 0, '0')); } else { item = new QTableWidgetItem(QString("")); @@ -99,10 +99,22 @@ * Add the Delete and Edit row buttons. * Not for water agents, these are set on the water tab. */ - if (recipe->miscs.at(i).m_type == 4) { + if (recipe->miscs.at(i).m_type == MISC_TYPES_WATER_AGENT) { ui->miscsTable->removeCellWidget(i, 5); ui->miscsTable->removeCellWidget(i, 6); + item = new QTableWidgetItem(""); + item->setToolTip(tr("Edit this from the water tab")); + ui->miscsTable->setItem(i, 5, item); + item = new QTableWidgetItem(""); + item->setToolTip(tr("Edit this from the water tab")); + ui->miscsTable->setItem(i, 6, item); } else { + if (ui->miscsTable->item(i, 5)) { + ui->miscsTable->takeItem(i, 5); /* to remove the old tooltip */ + } + if (ui->miscsTable->item(i, 6)) { + ui->miscsTable->takeItem(i, 6); + } pWidget = new QWidget(); QPushButton* btn_dele = new QPushButton(); btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ @@ -129,7 +141,7 @@ /* * Update the water agents. */ - if (recipe->miscs.at(i).m_type == 4) { + if (recipe->miscs.at(i).m_type == MISC_TYPES_WATER_AGENT) { if (recipe->miscs.at(i).m_name == "CaCl2") { ui->bs_cacl2Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); } else if (recipe->miscs.at(i).m_name == "CaSO4") { @@ -273,7 +285,7 @@ newm.m_cost = 0; recipe->miscs.append(newm); is_changed(); - emit refreshAll(); + refreshMiscs(); } @@ -322,10 +334,11 @@ qDebug() << "misc_time_changed()" << recipe->miscs_row << val; - if (recipe->miscs.at(recipe->miscs_row).m_use_use == 2) { // Boil + if (recipe->miscs.at(recipe->miscs_row).m_use_use == MISC_USES_BOIL) { recipe->miscs[recipe->miscs_row].m_time = val; item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); - } else if (recipe->miscs.at(recipe->miscs_row).m_use_use == 3 || recipe->miscs.at(recipe->miscs_row).m_use_use == 4) { // Primary or secondary + } else if (recipe->miscs.at(recipe->miscs_row).m_use_use == MISC_USES_PRIMARY || + recipe->miscs.at(recipe->miscs_row).m_use_use == MISC_USES_SECONDARY) { recipe->miscs[recipe->miscs_row].m_time = val * 1440; item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0')); } else { @@ -419,8 +432,21 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->miscsTable->setItem(recipe->miscs_row, 4, item); + qDebug() << "before" << recipe->miscs_row; is_changed(); - emit refreshAll(); + refreshMiscs(); + /* + * The order of the list is changed, lookup the item we just added. + */ + for (int i = 0; i < recipe->miscs.size(); i++) { + if ((recipe->miscs.at(i).m_name == query.value(0).toString()) && + (recipe->miscs.at(i).m_type == query.value(1).toInt()) && + (recipe->miscs.at(i).m_use_use == query.value(2).toInt())) { + recipe->miscs_row = i; + break; + } + } + qDebug() << "after" << recipe->miscs_row; } @@ -458,12 +484,12 @@ item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->miscsTable->setItem(recipe->miscs_row, 2, item); - if (val == 3 || val == 4) { // Fermentation stages + if (val == MISC_USES_PRIMARY || val == MISC_USES_SECONDARY) { recipe->miscs[recipe->miscs_row].m_time = mtimeEdit->value() * 1440; mtimeEdit->setReadOnly(false); mtimeLabel->setText(tr("Time in days:")); item = new QTableWidgetItem(QString("%1 days.").arg(recipe->miscs.at(recipe->miscs_row).m_time / 1440, 1, 'f', 0, '0')); - } else if (val == 2) { // Boil + } else if (val == MISC_USES_BOIL) { recipe->miscs[recipe->miscs_row].m_time = mtimeEdit->value(); mtimeEdit->setReadOnly(false); mtimeLabel->setText(tr("Time in minutes:")); @@ -654,7 +680,7 @@ /* * Update the water agents. */ - if (recipe->miscs.at(i).m_type == 4) { + if (recipe->miscs.at(i).m_type == MISC_TYPES_WATER_AGENT) { if (recipe->miscs.at(i).m_name == "CaCl2") { ui->bs_cacl2Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); } else if (recipe->miscs.at(i).m_name == "CaSO4") {