- Timestamp:
- Mar 13, 2020 11:02:49 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 136431
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r83212 r83276 276 276 UITaskCloudAcquireInstances *pAcquiringTask = static_cast<UITaskCloudAcquireInstances*>(pTask); 277 277 278 /* Check whether there was an error: */278 /* Make sure there were no errors: */ 279 279 if (!pAcquiringTask->errorInfo().isNull()) 280 280 return msgCenter().cannotAcquireCloudInstanceList(pAcquiringTask->errorInfo()); 281 281 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 283 285 UIChooserNode *pParentNode = pAcquiringTask->parentNode(); 284 286 AssertPtrReturnVoid(pParentNode); 285 286 /* This node always have 1st child: */287 287 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(); 289 291 AssertPtrReturnVoid(pFirstChildNode); 290 292 291 /* Which is machine node of course: */293 /* Which is machine node and has cache of fake-cloud-item type: */ 292 294 UIChooserNodeMachine *pFirstChildNodeMachine = pFirstChildNode->toMachineNode(); 293 295 AssertPtrReturnVoid(pFirstChildNodeMachine); 294 295 /* Which has cache of fake cloud item type: */296 296 AssertPtrReturnVoid(pFirstChildNodeMachine->cache()); 297 297 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(); 316 326 } 317 327 }
Note:
See TracChangeset
for help on using the changeset viewer.