Changeset 8907 in vbox
- Timestamp:
- May 19, 2008 9:26:13 AM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMListView.h
r8568 r8907 100 100 101 101 VBoxVMModel(QObject *aParent = 0) 102 :QAbstractListModel (aParent) { refresh();}102 :QAbstractListModel (aParent) {} 103 103 104 104 void addItem (VBoxVMItem *aItem); … … 108 108 void itemChanged (VBoxVMItem *aItem); 109 109 110 void refresh();110 void clear(); 111 111 112 112 VBoxVMItem *itemById (const QUuid &aId) const; -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp
r8630 r8907 484 484 /* VM list view */ 485 485 mVMListView = new VBoxVMListView(); 486 mVMModel = new VBoxVMModel( );486 mVMModel = new VBoxVMModel(mVMListView); 487 487 mVMListView->setModel (mVMModel); 488 488 … … 622 622 } 623 623 624 /* Update the list */ 625 refreshVMList(); 624 626 /* Reset to the first item */ 625 627 mVMListView->selectItemByRow (0); … … 716 718 vbox.SetExtraData (VBoxDefs::GUI_LastVMSelected, curVMId); 717 719 } 720 /* Delete the items from our model */ 721 mVMModel->clear(); 718 722 } 719 723 … … 883 887 machine.DeleteSettings(); 884 888 /* remove the item shortly: cmachine it refers to is no longer valid! */ 885 #warning "port me: check this"886 889 int row = mVMModel->rowById (item->id()); 887 890 mVMModel->removeItem (item); 891 delete item; 888 892 mVMListView->ensureSomeRowSelected (row); 889 893 } … … 1057 1061 void VBoxSelectorWnd::refreshVMList() 1058 1062 { 1059 mVMModel->refresh(); 1063 CVirtualBox vbox = vboxGlobal().virtualBox(); 1064 CMachineVector vec = vbox.GetMachines2(); 1065 for (CMachineVector::ConstIterator m = vec.begin(); 1066 m != vec.end(); ++ m) 1067 mVMModel->addItem (new VBoxVMItem (*m)); 1068 mVMModel->sort(); 1069 1060 1070 vmListViewCurrentChanged(); 1061 1071 } … … 1481 1491 int row = mVMModel->rowById (item->id()); 1482 1492 mVMModel->removeItem (item); 1493 delete item; 1483 1494 mVMListView->ensureSomeRowSelected (row); 1484 1495 } -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMListView.cpp
r8568 r8907 438 438 439 439 /** 440 * Refreshes the model contents by rereading the list of VM's using the441 * IVirtualBox instance.440 * Clear the item model list. Please note that the items itself are also 441 * deleted. 442 442 */ 443 void VBoxVMModel::refresh() 444 { 445 CVirtualBox vbox = vboxGlobal().virtualBox(); 446 CMachineVector vec = vbox.GetMachines2(); 447 for (CMachineVector::ConstIterator m = vec.begin(); 448 m != vec.end(); ++ m) 449 addItem(new VBoxVMItem (*m)); 450 451 sort(); 443 void VBoxVMModel::clear() 444 { 445 qDeleteAll (mVMItemList); 452 446 } 453 447
Note:
See TracChangeset
for help on using the changeset viewer.