VirtualBox

Changeset 85036 in vbox for trunk


Ignore:
Timestamp:
Jul 1, 2020 6:02:06 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: A bit of rework for init stuff, move code related to local and cloud VMs to separate functions.

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

    r84625 r85036  
    380380                                QString() /* tip */);
    381381
    382         /* Acquire VBox: */
    383         const CVirtualBox comVBox = uiCommon().virtualBox();
    384 
    385         /* Add local machines: */
    386         LogRelFlow(("UIChooserAbstractModel: Loading local VMs...\n"));
    387         /* Acquire existing machines: */
    388         const QVector<CMachine> machines = comVBox.GetMachines();
    389         /* Show error message if necessary: */
    390         if (!comVBox.isOk())
    391             msgCenter().cannotAcquireVirtualBoxParameter(comVBox);
    392         else
    393         {
    394             /* Iterate through existing machines: */
    395             foreach (const CMachine &comMachine, machines)
    396             {
    397                 /* Skip if we have nothing to populate (wtf happened?): */
    398                 if (comMachine.isNull())
    399                     continue;
    400 
    401                 /* Get machine ID: */
    402                 const QUuid uMachineID = comMachine.GetId();
    403                 /* Show error message if necessary: */
    404                 if (!comMachine.isOk())
    405                 {
    406                     msgCenter().cannotAcquireMachineParameter(comMachine);
    407                     continue;
    408                 }
    409 
    410                 /* Skip if we have nothing to show (wtf happened?): */
    411                 if (uMachineID.isNull())
    412                     continue;
    413 
    414                 /* Skip if machine is restricted from being shown: */
    415                 if (!gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineID))
    416                     continue;
    417 
    418                 /* Add machine into tree: */
    419                 addLocalMachineIntoTheTree(comMachine);
    420             }
    421         }
    422         LogRelFlow(("UIChooserAbstractModel: Local VMs loaded.\n"));
    423 
    424 #ifdef VBOX_GUI_WITH_CLOUD_VMS
    425         /* Add cloud providers/profiles: */
    426         LogRelFlow(("UIChooserAbstractModel: Loading cloud providers/profiles...\n"));
    427         /* Iterate through existing providers: */
    428         foreach (CCloudProvider comCloudProvider, listCloudProviders())
    429         {
    430             /* Skip if we have nothing to populate: */
    431             if (comCloudProvider.isNull())
    432                 continue;
    433 
    434             /* Acquire provider short name: */
    435             QString strProviderShortName;
    436             if (!cloudProviderShortName(comCloudProvider, strProviderShortName))
    437                 continue;
    438 
    439             /* Acquire list of profiles: */
    440             const QVector<CCloudProfile> profiles = listCloudProfiles(comCloudProvider);
    441             if (profiles.isEmpty())
    442                 continue;
    443 
    444             /* Add provider group node: */
    445             UIChooserNodeGroup *pProviderNode =
    446                 new UIChooserNodeGroup(invisibleRoot() /* parent */,
    447                                        getDesiredNodePosition(invisibleRoot(),
    448                                                               UIChooserNodeDataPrefixType_Provider,
    449                                                               strProviderShortName),
    450                                        shouldGroupNodeBeOpened(invisibleRoot(),
    451                                                                UIChooserNodeDataPrefixType_Provider,
    452                                                                strProviderShortName),
    453                                        strProviderShortName,
    454                                        UIChooserNodeGroupType_Provider);
    455 
    456             /* Iterate through provider's profiles: */
    457             foreach (CCloudProfile comCloudProfile, profiles)
    458             {
    459                 /* Skip if we have nothing to populate: */
    460                 if (comCloudProfile.isNull())
    461                     continue;
    462 
    463                 /* Acquire profile name: */
    464                 QString strProfileName;
    465                 if (!cloudProfileName(comCloudProfile, strProfileName))
    466                     continue;
    467 
    468                 /* Add profile sub-group node: */
    469                 UIChooserNodeGroup *pProfileNode =
    470                     new UIChooserNodeGroup(pProviderNode /* parent */,
    471                                            getDesiredNodePosition(pProviderNode,
    472                                                                   UIChooserNodeDataPrefixType_Profile,
    473                                                                   strProfileName),
    474                                            shouldGroupNodeBeOpened(pProviderNode,
    475                                                                    UIChooserNodeDataPrefixType_Profile,
    476                                                                    strProfileName),
    477                                            strProfileName,
    478                                            UIChooserNodeGroupType_Profile);
    479 
    480                 /* Add fake cloud VM item: */
    481                 new UIChooserNodeMachine(pProfileNode /* parent */,
    482                                          0 /* position */,
    483                                          UIFakeCloudVirtualMachineItemState_Loading);
    484 
    485                 /* Create list cloud machines task: */
    486                 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(strProviderShortName,
    487                                                                              strProfileName);
    488                 if (pTask)
    489                     uiCommon().threadPoolCloud()->enqueueTask(pTask);
    490             }
    491         }
    492         LogRelFlow(("UIChooserAbstractModel: Cloud providers/profiles loaded.\n"));
    493 #endif /* VBOX_GUI_WITH_CLOUD_VMS */
     382        /* Reload local tree: */
     383        reloadLocalTree();
     384        /* Reload cloud tree: */
     385        reloadCloudTree();
    494386    }
    495387}
     
    904796            this, &UIChooserAbstractModel::sltStartGroupSaving,
    905797            Qt::QueuedConnection);
     798}
     799
     800void UIChooserAbstractModel::reloadLocalTree()
     801{
     802    LogRelFlow(("UIChooserAbstractModel: Loading local VMs...\n"));
     803
     804    /* Acquire VBox: */
     805    const CVirtualBox comVBox = uiCommon().virtualBox();
     806
     807    /* Acquire existing local machines: */
     808    const QVector<CMachine> machines = comVBox.GetMachines();
     809    /* Show error message if necessary: */
     810    if (!comVBox.isOk())
     811        msgCenter().cannotAcquireVirtualBoxParameter(comVBox);
     812    else
     813    {
     814        /* Iterate through existing machines: */
     815        foreach (const CMachine &comMachine, machines)
     816        {
     817            /* Skip if we have nothing to populate (wtf happened?): */
     818            if (comMachine.isNull())
     819                continue;
     820
     821            /* Get machine ID: */
     822            const QUuid uMachineID = comMachine.GetId();
     823            /* Show error message if necessary: */
     824            if (!comMachine.isOk())
     825            {
     826                msgCenter().cannotAcquireMachineParameter(comMachine);
     827                continue;
     828            }
     829
     830            /* Skip if we have nothing to show (wtf happened?): */
     831            if (uMachineID.isNull())
     832                continue;
     833
     834            /* Skip if machine is restricted from being shown: */
     835            if (!gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineID))
     836                continue;
     837
     838            /* Add machine into tree: */
     839            addLocalMachineIntoTheTree(comMachine);
     840        }
     841    }
     842
     843    LogRelFlow(("UIChooserAbstractModel: Local VMs loaded.\n"));
     844}
     845
     846void UIChooserAbstractModel::reloadCloudTree()
     847{
     848#ifdef VBOX_GUI_WITH_CLOUD_VMS
     849    LogRelFlow(("UIChooserAbstractModel: Loading cloud providers/profiles...\n"));
     850
     851    /* Iterate through existing providers: */
     852    foreach (CCloudProvider comCloudProvider, listCloudProviders())
     853    {
     854        /* Skip if we have nothing to populate: */
     855        if (comCloudProvider.isNull())
     856            continue;
     857
     858        /* Acquire provider short name: */
     859        QString strProviderShortName;
     860        if (!cloudProviderShortName(comCloudProvider, strProviderShortName))
     861            continue;
     862
     863        /* Acquire list of profiles: */
     864        const QVector<CCloudProfile> profiles = listCloudProfiles(comCloudProvider);
     865        if (profiles.isEmpty())
     866            continue;
     867
     868        /* Add provider group node: */
     869        UIChooserNodeGroup *pProviderNode =
     870            new UIChooserNodeGroup(invisibleRoot() /* parent */,
     871                                   getDesiredNodePosition(invisibleRoot(),
     872                                                          UIChooserNodeDataPrefixType_Provider,
     873                                                          strProviderShortName),
     874                                   shouldGroupNodeBeOpened(invisibleRoot(),
     875                                                           UIChooserNodeDataPrefixType_Provider,
     876                                                           strProviderShortName),
     877                                   strProviderShortName,
     878                                   UIChooserNodeGroupType_Provider);
     879
     880        /* Iterate through provider's profiles: */
     881        foreach (CCloudProfile comCloudProfile, profiles)
     882        {
     883            /* Skip if we have nothing to populate: */
     884            if (comCloudProfile.isNull())
     885                continue;
     886
     887            /* Acquire profile name: */
     888            QString strProfileName;
     889            if (!cloudProfileName(comCloudProfile, strProfileName))
     890                continue;
     891
     892            /* Add profile sub-group node: */
     893            UIChooserNodeGroup *pProfileNode =
     894                new UIChooserNodeGroup(pProviderNode /* parent */,
     895                                       getDesiredNodePosition(pProviderNode,
     896                                                              UIChooserNodeDataPrefixType_Profile,
     897                                                              strProfileName),
     898                                       shouldGroupNodeBeOpened(pProviderNode,
     899                                                               UIChooserNodeDataPrefixType_Profile,
     900                                                               strProfileName),
     901                                       strProfileName,
     902                                       UIChooserNodeGroupType_Profile);
     903
     904            /* Add fake cloud VM item: */
     905            new UIChooserNodeMachine(pProfileNode /* parent */,
     906                                     0 /* position */,
     907                                     UIFakeCloudVirtualMachineItemState_Loading);
     908
     909            /* Create list cloud machines task: */
     910            UITaskCloudListMachines *pTask = new UITaskCloudListMachines(strProviderShortName,
     911                                                                         strProfileName);
     912            if (pTask)
     913                uiCommon().threadPoolCloud()->enqueueTask(pTask);
     914        }
     915    }
     916
     917    LogRelFlow(("UIChooserAbstractModel: Cloud providers/profiles loaded.\n"));
     918#endif /* VBOX_GUI_WITH_CLOUD_VMS */
    906919}
    907920
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r84625 r85036  
    188188    /** @name Children stuff.
    189189      * @{ */
     190        /** Reloads local tree. */
     191        void reloadLocalTree();
     192        /** Reloads cloud tree. */
     193        void reloadCloudTree();
     194
    190195        /** Adds local machine item based on certain @a comMachine and optionally @a fMakeItVisible. */
    191196        void addLocalMachineIntoTheTree(const CMachine &comMachine, bool fMakeItVisible = false);
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