Changeset 40202 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 21, 2012 3:39:22 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 76368
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp ¶
r40196 r40202 273 273 /* Show New Machine wizard: */ 274 274 UINewVMWzd wizard(this); 275 if (wizard.exec() == QDialog::Accepted) 276 { 277 /* Wait until the list is updated by OnMachineRegistered(): */ 278 const CMachine &machine = wizard.machine(); 279 QModelIndex index; 280 while(!index.isValid()) 281 { 282 qApp->processEvents(); 283 index = m_pVMModel->indexById(machine.GetId()); 284 } 285 /* Choose newly created item: */ 286 m_pVMListView->setCurrentIndex(index); 287 } 275 wizard.exec(); 288 276 } 289 277 … … 326 314 /* Register that machine: */ 327 315 vbox.RegisterMachine(newMachine); 328 /* Wait until the list is updated by OnMachineRegistered(): */329 QModelIndex index;330 while(!index.isValid())331 {332 qApp->processEvents();333 index = m_pVMModel->indexById(newMachine.GetId());334 }335 /* And choose added item: */336 m_pVMListView->setCurrentIndex(index);337 316 } 338 317 else … … 1014 993 void UISelectorWindow::sltMachineRegistered(QString strMachineId, bool fRegistered) 1015 994 { 995 /* Add/remove VM: */ 1016 996 if (fRegistered) 1017 997 { 1018 CVirtualBox vbox = vboxGlobal().virtualBox(); 1019 CMachine m = vbox.FindMachine(strMachineId); 998 CMachine m = vboxGlobal().virtualBox().FindMachine(strMachineId); 1020 999 if (!m.isNull()) 1021 1000 { 1022 1001 m_pVMModel->addItem(m); 1023 /* Make sure the description, ... pages are properly updated. 1024 * Actually we haven't call the next method, but unfortunately Qt 1025 * seems buggy if the new item is on the same position as the 1026 * previous one. So go on the safe side and call this by our self. */ 1027 sltCurrentVMItemChanged(); 1002 int iRow = m_pVMModel->rowById(strMachineId); 1003 m_pVMListView->ensureOneRowSelected(iRow); 1028 1004 } 1029 1005 /* m.isNull() is ok (theoretically, the machine could have been … … 1035 1011 if (pItem) 1036 1012 { 1037 int iRow = m_pVMModel->rowById( pItem->id());1013 int iRow = m_pVMModel->rowById(strMachineId); 1038 1014 m_pVMModel->removeItem(pItem); 1039 1015 m_pVMListView->ensureOneRowSelected(iRow); … … 1042 1018 * has been already removed) */ 1043 1019 } 1020 /* Make sure all updated: */ 1021 sltCurrentVMItemChanged(); 1044 1022 } 1045 1023 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp ¶
r40196 r40202 7 7 8 8 /* 9 * Copyright (C) 2006-201 0Oracle Corporation9 * Copyright (C) 2006-2012 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 394 394 { 395 395 setCurrentIndex(model()->index(row, 0)); 396 selectionModel()->select(currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect); 396 397 } 397 398 … … 417 418 * or other than hinted row is selected: */ 418 419 if (selectedIndexes.size() != 1 || selectedIndexes[0].row() != aRowHint) 419 { 420 /* Make sure that only necessary item is selected: */ 421 setCurrentIndex(model()->index(aRowHint, 0)); 422 selectionModel()->select(currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect); 423 } 420 selectItemByRow(aRowHint); 424 421 } 425 422 … … 458 455 /* If selection is empty => select 'current item': */ 459 456 if (selectionModel()->selectedIndexes().isEmpty()) 460 selectionModel()->select(currentIndex(), QItemSelectionModel:: SelectCurrent);457 selectionModel()->select(currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect); 461 458 462 459 /* Ensure current index is visible: */
Note:
See TracChangeset
for help on using the changeset viewer.