Changeset 86678 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 22, 2020 7:06:17 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r86665 r86678 757 757 return; 758 758 759 /* Compose corresponding group path: */ 760 const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName); 761 /* Make sure there is no VM with such ID already: */ 762 QUuid uId; 763 if (!cloudMachineId(comMachine, uId)) 764 return; 765 if (checkIfNodeContainChildWithId(pProfileNode, uId)) 766 return; 759 767 /* Add new machine-item: */ 760 const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName);761 768 addCloudMachineIntoTheTree(strGroup, comMachine, true /* make it visible? */); 762 769 … … 774 781 return; 775 782 776 /* Add new machine-items: */783 /* Compose corresponding group path: */ 777 784 const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName); 778 785 foreach (const CCloudMachine &comMachine, machines) 786 { 787 /* Make sure there is no VM with such ID already: */ 788 QUuid uId; 789 if (!cloudMachineId(comMachine, uId)) 790 continue; 791 if (checkIfNodeContainChildWithId(pProfileNode, uId)) 792 continue; 793 /* Add new machine-item: */ 779 794 addCloudMachineIntoTheTree(strGroup, comMachine, false /* make it visible? */); 795 } 780 796 781 797 /* Delete fake node if present: */ … … 1496 1512 } 1497 1513 1514 bool UIChooserAbstractModel::checkIfNodeContainChildWithId(UIChooserNode *pParentNode, const QUuid &uId) const 1515 { 1516 /* Check parent-node type: */ 1517 AssertPtrReturn(pParentNode, false); 1518 switch (pParentNode->type()) 1519 { 1520 case UIChooserNodeType_Machine: 1521 { 1522 /* Check if pParentNode has the passed uId itself: */ 1523 UIChooserNodeMachine *pMachineNode = pParentNode->toMachineNode(); 1524 AssertPtrReturn(pMachineNode, false); 1525 if (pMachineNode->id() == uId) 1526 return true; 1527 break; 1528 } 1529 case UIChooserNodeType_Group: 1530 { 1531 /* Recursively iterate through children: */ 1532 foreach (UIChooserNode *pChildNode, pParentNode->nodes()) 1533 if (checkIfNodeContainChildWithId(pChildNode, uId)) 1534 return true; 1535 break; 1536 } 1537 default: 1538 break; 1539 } 1540 1541 /* False by default: */ 1542 return false; 1543 } 1544 1498 1545 void UIChooserAbstractModel::saveGroupSettings() 1499 1546 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r86665 r86678 288 288 /** Gathers a list of possible group node names for machine nodes listed in @a exceptions, starting from @a pCurrentNode. */ 289 289 QStringList gatherPossibleGroupNodeNames(UIChooserNode *pCurrentNode, QList<UIChooserNode*> exceptions) const; 290 291 /** Returns whether passed @a pParentNode contains child node with passed @a uId. */ 292 bool checkIfNodeContainChildWithId(UIChooserNode *pParentNode, const QUuid &uId) const; 290 293 /** @} */ 291 294
Note:
See TracChangeset
for help on using the changeset viewer.