VirtualBox

Changeset 83276 in vbox for trunk/src


Ignore:
Timestamp:
Mar 13, 2020 11:02:49 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
136431
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Remove fake cloud VM node when at least one cloud VM exists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp

    r83212 r83276  
    276276    UITaskCloudAcquireInstances *pAcquiringTask = static_cast<UITaskCloudAcquireInstances*>(pTask);
    277277
    278     /* Check whether there was an error: */
     278    /* Make sure there were no errors: */
    279279    if (!pAcquiringTask->errorInfo().isNull())
    280280        return msgCenter().cannotAcquireCloudInstanceList(pAcquiringTask->errorInfo());
    281281
    282     /* Acquire parent node we referencing: */
     282    /* Acquire parent node and make sure it has children: */
     283    /// @todo rework task to bring parent by id instead of pointer
     284    ///       to object which maybe deleted to this moment already
    283285    UIChooserNode *pParentNode = pAcquiringTask->parentNode();
    284286    AssertPtrReturnVoid(pParentNode);
    285 
    286     /* This node always have 1st child: */
    287287    AssertReturnVoid(pParentNode->hasNodes());
    288     UIChooserNode *pFirstChildNode = pParentNode->nodes().at(0);
     288
     289    /* Make sure this node have first child: */
     290    UIChooserNode *pFirstChildNode = pParentNode->nodes().first();
    289291    AssertPtrReturnVoid(pFirstChildNode);
    290292
    291     /* Which is machine node of course: */
     293    /* Which is machine node and has cache of fake-cloud-item type: */
    292294    UIChooserNodeMachine *pFirstChildNodeMachine = pFirstChildNode->toMachineNode();
    293295    AssertPtrReturnVoid(pFirstChildNodeMachine);
    294 
    295     /* Which has cache of fake cloud item type: */
    296296    AssertPtrReturnVoid(pFirstChildNodeMachine->cache());
    297297    AssertReturnVoid(pFirstChildNodeMachine->cache()->itemType() == UIVirtualMachineItem::ItemType_CloudFake);
    298     UIVirtualMachineItemCloud *pFakeCloudMachineItem = pFirstChildNodeMachine->cache()->toCloud();
    299     AssertPtrReturnVoid(pFakeCloudMachineItem);
    300 
    301     /* So that we could update this fake cloud item with new state and recache it: */
    302     pFakeCloudMachineItem->setFakeCloudItemState(UIVirtualMachineItemCloud::FakeCloudItemState_Done);
    303     pFakeCloudMachineItem->recache();
    304 
    305     /* Add real cloud VM nodes: */
    306     int iPosition = 1; /* we've got item with index 0 already, the "Empty" one .. */
    307     foreach (const UICloudMachine &guiCloudMachine, pAcquiringTask->result())
    308     {
    309         /* Create new node: */
    310         UIChooserNodeMachine *pNode = new UIChooserNodeMachine(pParentNode,
    311                                                                false /* favorite */,
    312                                                                iPosition++ /* position */,
    313                                                                guiCloudMachine);
    314         /* Request async node update: */
    315         pNode->cache()->toCloud()->updateInfoAsync(false /* delayed? */);
     298
     299    /* And if we have at least one cloud instance: */
     300    const QList<UICloudMachine> instances = pAcquiringTask->result();
     301    if (!instances.isEmpty())
     302    {
     303        /* Remove the "Empty" node: */
     304        delete pFirstChildNodeMachine;
     305
     306        /* Add real cloud VM nodes: */
     307        int iPosition = 0;
     308        foreach (const UICloudMachine &guiCloudMachine, instances)
     309        {
     310            /* Create new node: */
     311            UIChooserNodeMachine *pNode = new UIChooserNodeMachine(pParentNode,
     312                                                                   false /* favorite */,
     313                                                                   iPosition++ /* position */,
     314                                                                   guiCloudMachine);
     315            /* Request async node update: */
     316            pNode->cache()->toCloud()->updateInfoAsync(false /* delayed? */);
     317        }
     318    }
     319    else
     320    {
     321        /* Otherwise toggle and update "Empty" node: */
     322        UIVirtualMachineItemCloud *pFakeCloudMachineItem = pFirstChildNodeMachine->cache()->toCloud();
     323        AssertPtrReturnVoid(pFakeCloudMachineItem);
     324        pFakeCloudMachineItem->setFakeCloudItemState(UIVirtualMachineItemCloud::FakeCloudItemState_Done);
     325        pFakeCloudMachineItem->recache();
    316326    }
    317327}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette