Changeset 43616 in vbox
- Timestamp:
- Oct 11, 2012 12:29:00 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r43615 r43616 972 972 UIGChooserItemMachine::enumerateMachineItems(mainRoot()->items(), existingMachineItemList); 973 973 974 /* Prepare maps: */ 975 QMap<QString, bool> verdictMap; 976 QMap<QString, QString> namesMap; 974 /* Prepare arrays: */ 975 QMap<QString, bool> verdicts; 976 QList<UIGChooserItem*> itemsToRemove; 977 QStringList machinesToUnregister; 977 978 978 979 /* For each selected machine-item: */ 979 980 foreach (UIGChooserItem *pItem, selectedMachineItemList) 980 981 { 981 /* Get item name/id: */ 982 QString strName = pItem->name(); 982 /* Get machine-item id: */ 983 983 QString strId = pItem->toMachineItem()->id(); 984 984 985 /* Check if we already decided for that machine: */ 986 if (verdictMap.contains(strId)) 985 /* We already decided for that machine? */ 986 if (verdicts.contains(strId)) 987 { 988 /* To remove similar machine items? */ 989 if (!verdicts[strId]) 990 itemsToRemove << pItem; 987 991 continue; 992 } 988 993 989 994 /* Selected copy count: */ … … 992 997 if (pSelectedItem->toMachineItem()->id() == strId) 993 998 ++iSelectedCopyCount; 994 995 999 /* Existing copy count: */ 996 1000 int iExistingCopyCount = 0; … … 998 1002 if (pExistingItem->toMachineItem()->id() == strId) 999 1003 ++iExistingCopyCount; 1000 1001 1004 /* If selected copy count equal to existing copy count, 1002 1005 * we will propose ro unregister machine fully else 1003 1006 * we will just propose to remove selected items: */ 1004 verdictMap.insert(strId, iSelectedCopyCount == iExistingCopyCount); 1005 namesMap.insert(strId, strName); 1007 bool fVerdict = iSelectedCopyCount == iExistingCopyCount; 1008 verdicts.insert(strId, fVerdict); 1009 if (fVerdict) 1010 machinesToUnregister << strId; 1011 else 1012 itemsToRemove << pItem; 1006 1013 } 1007 1014 1008 1015 /* If we have something to remove: */ 1009 if (verdictMap.values().contains(false)) 1010 { 1011 /* Gather names: */ 1012 QStringList names; 1013 foreach (const QString &strId, verdictMap.keys()) 1014 if (!verdictMap[strId]) 1015 names << namesMap[strId]; 1016 removeMachineItems(names, selectedMachineItemList); 1017 } 1016 if (!itemsToRemove.isEmpty()) 1017 removeItems(itemsToRemove); 1018 1018 /* If we have something to unregister: */ 1019 if (verdictMap.values().contains(true)) 1020 { 1021 /* Gather ids: */ 1022 QStringList ids; 1023 foreach (const QString &strId, verdictMap.keys()) 1024 if (verdictMap[strId]) 1025 ids << strId; 1026 unregisterMachines(ids); 1027 } 1019 if (!machinesToUnregister.isEmpty()) 1020 unregisterMachines(machinesToUnregister); 1028 1021 } 1029 1022 … … 1459 1452 } 1460 1453 1461 void UIGChooserModel::remove MachineItems(const QStringList &names, QList<UIGChooserItemMachine*> &items)1454 void UIGChooserModel::removeItems(const QList<UIGChooserItem*> &itemsToRemove) 1462 1455 { 1463 1456 /* Show machine-items remove dialog: */ 1457 QStringList names; 1458 foreach (UIGChooserItem *pItem, itemsToRemove) 1459 names << pItem->name(); 1464 1460 int rc = msgCenter().confirmMachineItemRemoval(names); 1465 1461 if (rc == QIMessageBox::Cancel) 1466 1462 return; 1467 1463 1468 /* Remove all the required items: */ 1469 foreach (UIGChooserItem *pItem, items) 1470 if (names.contains(pItem->name())) 1471 delete pItem; 1464 /* Remove all the passed items: */ 1465 foreach (UIGChooserItem *pItem, itemsToRemove) 1466 delete pItem; 1472 1467 1473 1468 /* And update model: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r43615 r43616 249 249 void updateMachineItems(const QString &strId, UIGChooserItem *pParent); 250 250 void removeMachineItems(const QString &strId, UIGChooserItem *pParent); 251 void remove MachineItems(const QStringList &names, QList<UIGChooserItemMachine*> &selectedItems);251 void removeItems(const QList<UIGChooserItem*> &itemsToRemove); 252 252 void unregisterMachines(const QStringList &ids); 253 253
Note:
See TracChangeset
for help on using the changeset viewer.