Frontend:
authorsmaxx
Tue, 14 Sep 2010 17:42:51 +0200
changeset 3864 cbd37f91d9a2
parent 3863 95040bd7ace4
child 3865 0b1c426b035f
child 3866 561275a3f33b
Frontend: * Avoid losing current selection if the rooms list is updated (annoyed me for so long ...)
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);