# HG changeset patch # User smaxx # Date 1284478971 -7200 # Node ID cbd37f91d9a2dab367413153fcaba35ce7f832e2 # Parent 95040bd7ace4b353f5857a92da21875033af2a1d Frontend: * Avoid losing current selection if the rooms list is updated (annoyed me for so long ...) diff -r 95040bd7ace4 -r cbd37f91d9a2 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Tue Sep 14 13:45:19 2010 +0200 +++ b/QTfrontend/pages.cpp Tue Sep 14 17:42:51 2010 +0200 @@ -1176,6 +1176,11 @@ { listFromServer = list; + QString selection = ""; + + if(QTableWidgetItem *item = roomsList->item(roomsList->currentRow(), 0)) + selection = item->text(); + roomsList->clear(); roomsList->setColumnCount(7); roomsList->setHorizontalHeaderLabels( @@ -1303,6 +1308,8 @@ item->setToolTip(tr("The Weapon Scheme defines available weapons and their ammunition count.")); roomsList->setItem(r, 6, item); + if(!list[i + 1].compare(selection) && !selection.isEmpty()) + roomsList->selectionModel()->setCurrentIndex(roomsList->model()->index(r,0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); } roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); roomsList->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);