--- 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; }