Skip to content

Commit 6995d0a

Browse files
committed
Fix observing list Remove-Object button deleting incorrect items
1 parent f06bef3 commit 6995d0a

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/gui/ObsListDialog.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,9 +1307,13 @@ void ObsListDialog::removeObjectButtonPressed()
13071307
{
13081308
Q_ASSERT(isEditMode);
13091309

1310-
int number = ui->treeView->currentIndex().row();
1311-
QString uuid = itemModel->index(number, ColumnUUID).data().toString();
1312-
itemModel->removeRow(number);
1310+
//Convert selected UI row (potentially sorted) into itemModel row (unsorted)
1311+
QModelIndex index = ui->treeView->currentIndex();
1312+
QSortFilterProxyModel* proxy = qobject_cast<QSortFilterProxyModel*>(ui->treeView->model());
1313+
int sourceRow = proxy ? proxy->mapToSource(index).row() : index.row();
1314+
1315+
QString uuid = itemModel->index(sourceRow, ColumnUUID).data().toString();
1316+
itemModel->removeRow(sourceRow);
13131317
currentItemCollection.remove(uuid);
13141318
tainted=true;
13151319
}

0 commit comments

Comments
 (0)