Changeset 42851 in vbox for trunk/src/VBox
- Timestamp:
- Aug 16, 2012 5:06:40 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
r42850 r42851 716 716 QList<UIGChooserItem*> existingMachineItemList = gatherMachineItems(mainRoot()->items()); 717 717 718 /* Prepare removing map: */ 719 QMap<QString, bool> removingMap; 718 /* Prepare maps: */ 719 QMap<QString, bool> verdictMap; 720 QMap<QString, QString> namesMap; 720 721 721 722 /* For each selected machine item: */ 722 723 foreach (UIGChooserItem *pItem, selectedMachineItemList) 723 724 { 724 /* Get item name : */725 /* Get item name/id: */ 725 726 QString strName = pItem->name(); 727 QString strId = pItem->toMachineItem()->id(); 726 728 727 729 /* Check if we already decided for that machine: */ 728 if ( removingMap.contains(strName))730 if (verdictMap.contains(strId)) 729 731 continue; 730 732 … … 732 734 int iSelectedCopyCount = 0; 733 735 foreach (UIGChooserItem *pSelectedItem, selectedMachineItemList) 734 if (pSelectedItem-> name() == strName)736 if (pSelectedItem->toMachineItem()->id() == strId) 735 737 ++iSelectedCopyCount; 736 738 … … 738 740 int iExistingCopyCount = 0; 739 741 foreach (UIGChooserItem *pExistingItem, existingMachineItemList) 740 if (pExistingItem-> name() == strName)742 if (pExistingItem->toMachineItem()->id() == strId) 741 743 ++iExistingCopyCount; 742 744 … … 744 746 * we will propose ro unregister machine fully else 745 747 * we will just propose to remove selected items: */ 746 removingMap.insert(strName, iSelectedCopyCount == iExistingCopyCount); 748 verdictMap.insert(strId, iSelectedCopyCount == iExistingCopyCount); 749 namesMap.insert(strId, strName); 747 750 } 748 751 749 752 /* If we have something to remove: */ 750 if ( removingMap.values().contains(false))753 if (verdictMap.values().contains(false)) 751 754 { 752 755 /* Gather names: */ 753 756 QStringList names; 754 foreach (const QString &str Name, removingMap.keys())755 if (! removingMap[strName])756 names << strName;757 foreach (const QString &strId, verdictMap.keys()) 758 if (!verdictMap[strId]) 759 names << namesMap[strId]; 757 760 removeMachineItems(names, selectedMachineItemList); 758 761 } 759 762 /* If we have something to unregister: */ 760 if ( removingMap.values().contains(true))761 { 762 /* Gather names: */763 QStringList names;764 foreach (const QString &str Name, removingMap.keys())765 if ( removingMap[strName])766 names << strName;767 unregisterMachines( names);763 if (verdictMap.values().contains(true)) 764 { 765 /* Gather ids: */ 766 QStringList ids; 767 foreach (const QString &strId, verdictMap.keys()) 768 if (verdictMap[strId]) 769 ids << strId; 770 unregisterMachines(ids); 768 771 } 769 772 } … … 1749 1752 else 1750 1753 unsetCurrentItem(); 1751 } 1752 1753 void UIGChooserModel::unregisterMachines(const QStringList &names) 1754 saveGroupSettings(); 1755 } 1756 1757 void UIGChooserModel::unregisterMachines(const QStringList &ids) 1754 1758 { 1755 1759 /* Populate machine list: */ 1756 1760 QList<CMachine> machines; 1757 1761 CVirtualBox vbox = vboxGlobal().virtualBox(); 1758 foreach (const QString &str Name, names)1759 { 1760 CMachine machine = vbox.FindMachine(str Name);1762 foreach (const QString &strId, ids) 1763 { 1764 CMachine machine = vbox.FindMachine(strId); 1761 1765 if (!machine.isNull()) 1762 1766 machines << machine; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r42832 r42851 296 296 /* Helpers: Remove stuff: */ 297 297 void removeMachineItems(const QStringList &names, QList<UIGChooserItem*> &selectedItems); 298 void unregisterMachines(const QStringList & names);298 void unregisterMachines(const QStringList &ids); 299 299 300 300 /* Helper: Sorting stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.