Changeset 83705 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 15, 2020 3:46:18 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 137212
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r83698 r83705 24 24 #include "UIChooserNodeGlobal.h" 25 25 #include "UIChooserNodeMachine.h" 26 #include "UICloudNetworkingStuff.h" 26 27 #include "UIExtraDataManager.h" 27 28 #include "UIMessageCenter.h" … … 398 399 } 399 400 401 void UIChooserAbstractModel::sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName, 402 const QUuid &uMachineId, const bool fRegistered) 403 { 404 /* Existing VM unregistered? */ 405 if (!fRegistered) 406 { 407 /* Remove machine-items with passed id: */ 408 invisibleRoot()->removeAllNodes(uMachineId); 409 /// @todo make sure there is fake item if no real item exist, never wipe out empty groups .. 410 } 411 /* New VM registered? */ 412 else 413 { 414 /* Add new machine-item: */ 415 const QString strGroupName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 416 const CCloudMachine comMachine = cloudMachineById(strProviderShortName, strProfileName, uMachineId); 417 addCloudMachineIntoTheTree(strGroupName, comMachine, true /* make it visible */); 418 /// @todo make sure there is no fake item if at least one real item exists .. 419 } 420 } 421 400 422 void UIChooserAbstractModel::sltSessionStateChanged(const QUuid &uMachineId, const KSessionState) 401 423 { … … 552 574 553 575 /* Which VM we are loading: */ 554 const QUuid u MachineId = comMachine.GetId();576 const QUuid uId = comMachine.GetId(); 555 577 LogRelFlow(("UIChooserModel: Loading local VM with ID={%s}...\n", 556 toOldStyleUuid(u MachineId).toUtf8().constData()));578 toOldStyleUuid(uId).toUtf8().constData())); 557 579 /* Is that machine accessible? */ 558 580 if (comMachine.GetAccessible()) … … 578 600 } 579 601 /* Update group definitions: */ 580 m_groups[toOldStyleUuid(u MachineId)] = groupList;602 m_groups[toOldStyleUuid(uId)] = groupList; 581 603 } 582 604 /* Inaccessible machine: */ … … 585 607 /* VM is accessible: */ 586 608 LogRelFlow(("UIChooserModel: Local VM {%s} is inaccessible.\n", 587 toOldStyleUuid(u MachineId).toUtf8().constData()));609 toOldStyleUuid(uId).toUtf8().constData())); 588 610 /* Create machine-item with main-root group-item as parent: */ 589 611 createLocalMachineNode(invisibleRoot(), comMachine); 590 612 } 613 } 614 615 void UIChooserAbstractModel::addCloudMachineIntoTheTree(const QString &strGroup, 616 const CCloudMachine &comMachine, 617 bool fMakeItVisible /* = false */) 618 { 619 /* Make sure passed VM is not NULL: */ 620 if (comMachine.isNull()) 621 LogRelFlow(("UIChooserModel: ERROR: Passed cloud VM is NULL!\n")); 622 AssertReturnVoid(!comMachine.isNull()); 623 624 /* Which VM we are loading: */ 625 const QUuid uId = comMachine.GetId(); 626 LogRelFlow(("UIChooserModel: Loading cloud VM with ID={%s}...\n", 627 toOldStyleUuid(uId).toUtf8().constData())); 628 /* Acquire VM name: */ 629 QString strName = comMachine.GetName(); 630 if (strName.isEmpty()) 631 strName = uId.toString(); 632 LogRelFlow(("UIChooserModel: Creating node for cloud VM {%s} in group {%s}.\n", 633 strName.toUtf8().constData(), strGroup.toUtf8().constData())); 634 /* Create machine-item with found group-item as parent: */ 635 createCloudMachineNode(getCloudGroupNode(strGroup, invisibleRoot(), fMakeItVisible), comMachine); 636 /* Update group definitions: */ 637 const QStringList groupList(strGroup); 638 m_groups[toOldStyleUuid(uId)] = groupList; 591 639 } 592 640 … … 632 680 fAllGroupsOpened || shouldGroupNodeBeOpened(pParentNode, strSecondSubName)); 633 681 return strSecondSuffix.isEmpty() ? pNewGroupNode : getLocalGroupNode(strFirstSuffix, pNewGroupNode, fAllGroupsOpened); 682 } 683 684 UIChooserNode *UIChooserAbstractModel::getCloudGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened) 685 { 686 /* Check passed stuff: */ 687 if (pParentNode->name() == strName) 688 return pParentNode; 689 690 /* Prepare variables: */ 691 const QString strFirstSubName = strName.section('/', 0, 0); 692 const QString strFirstSuffix = strName.section('/', 1, -1); 693 const QString strSecondSubName = strFirstSuffix.section('/', 0, 0); 694 695 /* Passed group name equal to first sub-name: */ 696 if (pParentNode->name() == strFirstSubName) 697 { 698 /* Make sure first-suffix is NOT empty: */ 699 AssertMsg(!strFirstSuffix.isEmpty(), ("Invalid group name!")); 700 /* Trying to get group node among our children: */ 701 foreach (UIChooserNode *pGroupNode, pParentNode->nodes(UIChooserNodeType_Group)) 702 { 703 if ( pGroupNode->toGroupNode()->groupType() != UIChooserNodeGroupType_Local 704 && pGroupNode->name() == strSecondSubName) 705 { 706 UIChooserNode *pFoundNode = getCloudGroupNode(strFirstSuffix, pGroupNode, fAllGroupsOpened); 707 if (UIChooserNodeGroup *pFoundGroupNode = pFoundNode->toGroupNode()) 708 if (fAllGroupsOpened && pFoundGroupNode->isClosed()) 709 pFoundGroupNode->open(); 710 return pFoundNode; 711 } 712 } 713 } 714 715 /* Found nothing? Returning parent: */ 716 AssertFailedReturn(pParentNode); 634 717 } 635 718 … … 794 877 void UIChooserAbstractModel::createLocalMachineNode(UIChooserNode *pParentNode, const CMachine &comMachine) 795 878 { 796 /* Create machine node: */797 879 new UIChooserNodeMachine(pParentNode, 798 880 false /* favorite */, 799 881 getDesiredNodePosition(pParentNode, UIChooserNodeType_Machine, toOldStyleUuid(comMachine.GetId())), 800 882 comMachine); 883 } 884 885 void UIChooserAbstractModel::createCloudMachineNode(UIChooserNode *pParentNode, const CCloudMachine &comMachine) 886 { 887 UIChooserNodeMachine *pNode = new UIChooserNodeMachine(pParentNode, 888 false /* favorite */, 889 getDesiredNodePosition(pParentNode, 890 UIChooserNodeType_Machine, 891 toOldStyleUuid(comMachine.GetId())), 892 comMachine); 893 /* Request for async node update if necessary: */ 894 if (!comMachine.GetAccessible()) 895 pNode->cache()->toCloud()->updateInfoAsync(false /* delayed? */); 801 896 } 802 897 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r83698 r83705 35 35 class UIChooser; 36 36 class UIChooserNode; 37 class CCloudMachine; 37 38 class CMachine; 38 39 #ifdef VBOX_GUI_WITH_CLOUD_VMS … … 134 135 /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */ 135 136 virtual void sltLocalMachineRegistered(const QUuid &uMachineId, const bool fRegistered); 137 /** Handles cloud machine registering/unregistering for machine with certain @a uMachineId. 138 * @param strProviderShortName Brings provider short name. 139 * @param strProfileName Brings profile name. */ 140 virtual void sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName, 141 const QUuid &uMachineId, const bool fRegistered); 136 142 /** Handles session @a enmState change for machine with certain @a uMachineId. */ 137 143 virtual void sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmState); … … 176 182 /** Adds local machine item based on certain @a comMachine and optionally @a fMakeItVisible. */ 177 183 void addLocalMachineIntoTheTree(const CMachine &comMachine, bool fMakeItVisible = false); 184 /** Adds cloud machine item based on certain @a comMachine and optionally @a fMakeItVisible, into @a strGroup. */ 185 void addCloudMachineIntoTheTree(const QString &strGroup, const CCloudMachine &comMachine, bool fMakeItVisible = false); 178 186 179 187 /** Acquires local group node, creates one if necessary. … … 182 190 * @param fAllGroupsOpened Brings whether we should open all the groups till the required one. */ 183 191 UIChooserNode *getLocalGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened); 192 /** Acquires cloud group node, never create new, returns root if nothing found. 193 * @param strName Brings the name of group we looking for. 194 * @param pParentNode Brings the parent we starting to look for a group from. 195 * @param fAllGroupsOpened Brings whether we should open all the groups till the required one. */ 196 UIChooserNode *getCloudGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened); 184 197 185 198 /** Returns whether group node with certain @a strName should be opened, searching starting from the passed @a pParentItem. */ … … 199 212 /** Creates local machine node based on certain @a comMachine as a child of specified @a pParentNode. */ 200 213 void createLocalMachineNode(UIChooserNode *pParentNode, const CMachine &comMachine); 214 /** Creates cloud machine node based on certain @a comMachine as a child of specified @a pParentNode. */ 215 void createCloudMachineNode(UIChooserNode *pParentNode, const CCloudMachine &comMachine); 201 216 /** @} */ 202 217 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r83698 r83705 696 696 } 697 697 698 void UIChooserModel::sltCloudMachineRegistered(const QString &strProviderName, const QString &strProfileName, 699 const QUuid &uId, const bool fRegistered) 700 { 701 /* Call to base-class: */ 702 UIChooserAbstractModel::sltCloudMachineRegistered(strProviderName, strProfileName, uId, fRegistered); 703 704 /* Existing VM unregistered? */ 705 if (!fRegistered) 706 { 707 /* Update tree for main root: */ 708 updateNavigationItemList(); 709 updateLayout(); 710 711 /* Make sure selected-item present, if possible: */ 712 if (!firstSelectedItem() && !navigationItems().isEmpty()) 713 { 714 setSelectedItem(navigationItems().first()); 715 emit sigSelectionInvalidated(); 716 } 717 /* Make sure current-item present, if possible: */ 718 else if (!currentItem() && firstSelectedItem()) 719 setCurrentItem(firstSelectedItem()); 720 /* Notify about selected-item change: */ 721 emit sigSelectionChanged(); 722 } 723 /* New VM registered? */ 724 else 725 { 726 /* Rebuild tree for main root: */ 727 buildTreeForMainRoot(); 728 updateNavigationItemList(); 729 updateLayout(); 730 731 /* Select newly added item: */ 732 setSelectedItem(root()->searchForItem(uId.toString(), 733 UIChooserItemSearchFlag_Machine | 734 UIChooserItemSearchFlag_ExactId)); 735 } 736 } 737 698 738 void UIChooserModel::sltReloadMachine(const QUuid &uId) 699 739 { … … 940 980 941 981 // WORKAROUND: 942 // Hehey! Now we have to inject created VM nodes and then rebuild tree for the main root node ourselves943 // cause there is no corresponding event yet. Later this to be done in corresponding event handler instead.982 // Hehey! Now we have to inject created VM nodes and then rebuild tree for the main root node 983 // ourselves cause there is no corresponding event yet. So we are calling actual handler to do that. 944 984 foreach (const CCloudMachine &comMachine, pWizard->machines()) 945 new UIChooserNodeMachine(pGroup->node(), 946 false /* favorite */, 947 pGroup->node()->nodes().size() /* position */, 948 comMachine); 949 // Remember first selected item definition: 950 const QString strDefinition = firstSelectedItem()->definition(); 951 // Rebuild tree for main root: 952 buildTreeForMainRoot(); 953 updateNavigationItemList(); 954 updateLayout(); 955 // Restore selection: 956 setSelectedItem(strDefinition); 985 sltCloudMachineRegistered(pGroup->parentItem()->name() /* provider name */, 986 pGroup->name() /* profile name */, 987 comMachine.GetId() /* machine ID */, 988 true /* registered? */); 957 989 958 990 delete pWizard; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r83698 r83705 249 249 /** Handles local machine registering/unregistering for machine with certain @a uId. */ 250 250 virtual void sltLocalMachineRegistered(const QUuid &uId, const bool fRegistered) /* override */; 251 /** Handles cloud machine registering/unregistering for machine with certain @a uId. 252 * @param strProviderName Brings provider short name. 253 * @param strProfileName Brings profile name. */ 254 virtual void sltCloudMachineRegistered(const QString &strProviderName, const QString &strProfileName, 255 const QUuid &uId, const bool fRegistered); 251 256 /** @} */ 252 257
Note:
See TracChangeset
for help on using the changeset viewer.