From 74668b9363d877d055a5e8b8c7d001ba448dc832 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Sun, 24 Sep 2023 19:03:08 -0500 Subject: Fixes for table * row increment needs to be before the logic but after the ID check/continue * avoid running context menu logic on null rows --- src/categoriesdialog.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/categoriesdialog.cpp') diff --git a/src/categoriesdialog.cpp b/src/categoriesdialog.cpp index e577eb5f..ff226286 100644 --- a/src/categoriesdialog.cpp +++ b/src/categoriesdialog.cpp @@ -214,6 +214,7 @@ void CategoriesDialog::fillTable() --row; continue; } + ++row; table->insertRow(row); // table->setVerticalHeaderItem(row, new QTableWidgetItem(" ")); @@ -229,7 +230,6 @@ void CategoriesDialog::fillTable() table->setItem(row, 1, nameItem.take()); table->setItem(row, 2, parentIDItem.take()); table->setItem(row, 3, nexusCatItem.take()); - ++row; } for (const auto& nexusCat : categories.m_NexusMap) { @@ -270,14 +270,16 @@ void CategoriesDialog::addCategory_clicked() void CategoriesDialog::removeCategory_clicked() { - ui->categoriesTable->removeRow(m_ContextRow); + if (m_ContextRow >= 0) + ui->categoriesTable->removeRow(m_ContextRow); } void CategoriesDialog::removeNexusMap_clicked() { - ui->categoriesTable->item(m_ContextRow, 3)->setData(Qt::UserRole, QVariantList()); - ui->categoriesTable->item(m_ContextRow, 3)->setData(Qt::DisplayRole, QString()); - // ui->categoriesTable->update(); + if (m_ContextRow >= 0) { + ui->categoriesTable->item(m_ContextRow, 3)->setData(Qt::UserRole, QVariantList()); + ui->categoriesTable->item(m_ContextRow, 3)->setData(Qt::DisplayRole, QString()); + } } void CategoriesDialog::nexusRefresh_clicked() -- cgit v1.3.1