VirtualBox

Changeset 84598 in vbox


Ignore:
Timestamp:
May 28, 2020 4:39:06 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: General cleanup for abstract Chooser-model.

File:
1 edited

Legend:

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

    r84562 r84598  
    8282
    8383    /** Contains a thread task to be executed. */
    84     void run();
     84    virtual void run() /* override */;
    8585
    8686    /** Holds the singleton instance. */
     
    339339    /* For every particular group definition: */
    340340    foreach (const QString &strId, m_lists.keys())
    341         gEDataManager->setSelectorWindowGroupsDefinitions(strId, m_lists[strId]);
     341        gEDataManager->setSelectorWindowGroupsDefinitions(strId, m_lists.value(strId));
    342342
    343343    /* Notify listeners about completeness: */
     
    525525    /* Search for all the machine nodes with passed ID: */
    526526    QList<UIChooserNode*> machineNodes;
    527     invisibleRoot()->searchForNodes(toOldStyleUuid(uId),
     527    invisibleRoot()->searchForNodes(uId.toString(),
    528528                                    UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId,
    529529                                    machineNodes);
     
    660660    {
    661661        /* Global nodes: */
    662         case UIChooserNodeDataPrefixType_Global:        return "n";
     662        case UIChooserNodeDataPrefixType_Global:   return "n";
    663663        /* Machine nodes: */
    664         case UIChooserNodeDataPrefixType_Machine:       return "m";
     664        case UIChooserNodeDataPrefixType_Machine:  return "m";
    665665        /* Group nodes: */
    666666        case UIChooserNodeDataPrefixType_Local:    return "g";
     
    695695}
    696696
     697void UIChooserAbstractModel::sltHandleCloudMachineStateChange()
     698{
     699    UIVirtualMachineItem *pCache = qobject_cast<UIVirtualMachineItem*>(sender());
     700    AssertPtrReturnVoid(pCache);
     701    emit sigCloudMachineStateChange(pCache->id());
     702}
     703
     704void UIChooserAbstractModel::sltGroupSettingsSaveComplete()
     705{
     706    makeSureGroupSettingsSaveIsFinished();
     707    emit sigGroupSavingStateChanged();
     708}
     709
     710void UIChooserAbstractModel::sltGroupDefinitionsSaveComplete()
     711{
     712    makeSureGroupDefinitionsSaveIsFinished();
     713    emit sigGroupSavingStateChanged();
     714}
     715
    697716void UIChooserAbstractModel::sltLocalMachineStateChanged(const QUuid &uMachineId, const KMachineState)
    698717{
     
    733752                                                       const QUuid &uMachineId, const bool fRegistered)
    734753{
    735     /* Compose full group name: */
    736     const QString strGroupName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    737     /* Search for corresponding profile node: */
     754    /* Search for profile node: */
     755    const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    738756    QList<UIChooserNode*> profileNodes;
    739     invisibleRoot()->searchForNodes(strGroupName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    740     /* Acquire corresponding profile node: */
     757    invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    741758    AssertReturnVoid(!profileNodes.isEmpty());
    742     UIChooserNodeGroup *pProfileNode = profileNodes.first()->toGroupNode();
     759    UIChooserNode *pProfileNode = profileNodes.first();
    743760    AssertPtrReturnVoid(pProfileNode);
    744761
     
    747764    {
    748765        /* Remove machine-items with passed id: */
    749         invisibleRoot()->removeAllNodes(uMachineId);
     766        pProfileNode->removeAllNodes(uMachineId);
    750767
    751768        /* If there are no items left: */
     
    766783        /* Add new machine-item: */
    767784        const CCloudMachine comMachine = cloudMachineById(strProviderShortName, strProfileName, uMachineId);
    768         addCloudMachineIntoTheTree(strGroupName, comMachine, true /* make it visible */);
     785        addCloudMachineIntoTheTree(strProfileNodeName, comMachine, true /* make it visible */);
    769786
    770787        /* Search for possible fake node: */
    771788        QList<UIChooserNode*> fakeNodes;
    772         pProfileNode->searchForNodes(toOldStyleUuid(QUuid()), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
     789        pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
    773790        /* Delete fake node if present: */
    774         if (!fakeNodes.isEmpty())
    775             delete fakeNodes.first();
     791        delete fakeNodes.value(0);
    776792    }
    777793}
     
    824840    QList<UIChooserNode*> profileNodes;
    825841    invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    826     UIChooserNode *pProfileNode = profileNodes.value(0);
     842    AssertReturnVoid(!profileNodes.isEmpty());
     843    UIChooserNode *pProfileNode = profileNodes.first();
    827844    AssertPtrReturnVoid(pProfileNode);
    828845
    829846    /* Search for fake node: */
    830847    QList<UIChooserNode*> fakeNodes;
    831     pProfileNode->searchForNodes(toOldStyleUuid(QUuid()), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
     848    pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
    832849    UIChooserNode *pFakeNode = fakeNodes.value(0);
    833850    AssertPtrReturnVoid(pFakeNode);
    834     UIChooserNodeMachine *pFakeMachineNode = pFakeNode->toMachineNode();
    835     AssertPtrReturnVoid(pFakeMachineNode);
    836     AssertReturnVoid(pFakeMachineNode->cacheType() == UIVirtualMachineItemType_CloudFake);
    837851
    838852    /* And if we have at least one cloud machine: */
     
    841855    {
    842856        /* Remove fake node: */
    843         delete pFakeMachineNode;
     857        delete pFakeNode;
    844858
    845859        /* Add real cloud VM nodes: */
     
    850864    {
    851865        /* Otherwise toggle and update "Empty" node: */
     866        UIChooserNodeMachine *pFakeMachineNode = pFakeNode->toMachineNode();
     867        AssertReturnVoid(pFakeMachineNode && pFakeMachineNode->cacheType() == UIVirtualMachineItemType_CloudFake);
    852868        UIVirtualMachineItemCloud *pFakeCloudMachineItem = pFakeMachineNode->cache()->toCloud();
    853869        AssertPtrReturnVoid(pFakeCloudMachineItem);
     
    855871        pFakeCloudMachineItem->setFakeCloudItemErrorMessage(pAcquiringTask->errorInfo());
    856872    }
    857 }
    858 
    859 void UIChooserAbstractModel::sltHandleCloudMachineStateChange()
    860 {
    861     UIVirtualMachineItem *pCache = qobject_cast<UIVirtualMachineItem*>(sender());
    862     AssertPtrReturnVoid(pCache);
    863     emit sigCloudMachineStateChange(pCache->id());
    864 }
    865 
    866 void UIChooserAbstractModel::sltGroupSettingsSaveComplete()
    867 {
    868     makeSureGroupSettingsSaveIsFinished();
    869     emit sigGroupSavingStateChanged();
    870 }
    871 
    872 void UIChooserAbstractModel::sltGroupDefinitionsSaveComplete()
    873 {
    874     makeSureGroupDefinitionsSaveIsFinished();
    875     emit sigGroupSavingStateChanged();
    876873}
    877874
     
    929926    LogRelFlow(("UIChooserModel: Loading local VM with ID={%s}...\n",
    930927                toOldStyleUuid(uId).toUtf8().constData()));
     928
    931929    /* Is that machine accessible? */
    932930    if (comMachine.GetAccessible())
     
    978976    LogRelFlow(("UIChooserModel: Loading cloud VM with ID={%s}...\n",
    979977                toOldStyleUuid(uId).toUtf8().constData()));
     978
    980979    /* Acquire VM name: */
    981980    QString strName = comMachine.GetName();
     
    11451144void UIChooserAbstractModel::wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParent)
    11461145{
    1147     /* Cleanup all the group-items recursively first: */
     1146    /* Cleanup all the group children recursively first: */
    11481147    foreach (UIChooserNode *pNode, pParent->nodes(UIChooserNodeType_Group))
    11491148        wipeOutEmptyGroupsStartingFrom(pNode);
    1150     /* If parent has no nodes: */
    1151     if (!pParent->hasNodes())
    1152     {
    1153         /* If that is non-root item: */
    1154         if (!pParent->isRoot())
    1155         {
    1156             /* Delete parent node and item: */
    1157             delete pParent;
    1158         }
     1149    /* If parent isn't root and has no nodes: */
     1150    if (!pParent->isRoot() && !pParent->hasNodes())
     1151    {
     1152        /* Delete parent node and item: */
     1153        delete pParent;
    11591154    }
    11601155}
     
    11691164    const int iNewNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmDataType, strName);
    11701165
    1171     /* If some position wanted: */
     1166    /* If some position defined: */
    11721167    if (iNewNodeDefinitionPosition != -1)
    11731168    {
     
    12191214                    break;
    12201215            }
     1216            /* If some position defined: */
    12211217            const int iNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmNodeDataType, strDefinitionName);
    1222             /* If some position wanted: */
    12231218            if (iNodeDefinitionPosition != -1)
    12241219            {
     
    13231318    if (!comMachine.GetAccessible())
    13241319    {
    1325         AssertPtrReturnVoid(pNode);
    1326         AssertReturnVoid(pNode->cacheType() == UIVirtualMachineItemType_CloudReal);
     1320        AssertReturnVoid(pNode && pNode->cacheType() == UIVirtualMachineItemType_CloudReal);
    13271321        pNode->cache()->toCloud()->updateInfoAsync(false /* delayed? */);
    13281322    }
Note: See TracChangeset for help on using the changeset viewer.

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