VirtualBox

Changeset 83690 in vbox for trunk


Ignore:
Timestamp:
Apr 14, 2020 2:08:19 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137188
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Rework for abstract model init procedure; Intended to bring local and cloud node population to common technique.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r83643 r83690  
    595595          tr("Encryption password for <nobr>ID = '%1'</nobr> is invalid.")
    596596             .arg(strPasswordId));
     597}
     598
     599void UIMessageCenter::cannotAcquireVirtualBoxParameter(const CVirtualBox &comVBox, QWidget *pParent /* = 0 */) const
     600{
     601    /* Show the error: */
     602    error(pParent, MessageType_Error,
     603          tr("Failed to acquire VirtualBox parameter."), UIErrorString::formatErrorInfo(comVBox));
    597604}
    598605
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r83643 r83690  
    263263    void cannotSetExtraData(const CMachine &machine, const QString &strKey, const QString &strValue);
    264264    void warnAboutInvalidEncryptionPassword(const QString &strPasswordId, QWidget *pParent = 0);
     265    void cannotAcquireVirtualBoxParameter(const CVirtualBox &comVBox, QWidget *pParent = 0) const;
    265266    void cannotAcquireMachineParameter(const CMachine &comMachine, QWidget *pParent = 0) const;
    266267
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp

    r83689 r83690  
    7575
    7676        /* Create global node: */
    77         new UIChooserNodeGlobal(invisibleRoot(),
     77        new UIChooserNodeGlobal(invisibleRoot() /* parent */,
    7878                                isGlobalNodeFavorite(invisibleRoot()),
    7979                                0 /* position */,
    8080                                QString() /* tip */);
    8181
    82         /* Add all the approved machine nodes into the tree: */
    83         LogRelFlow(("UIChooserModel: Loading VMs...\n"));
    84         foreach (const CMachine &comMachine, uiCommon().virtualBox().GetMachines())
     82        /* Acquire VBox: */
     83        const CVirtualBox comVBox = uiCommon().virtualBox();
     84
     85        /* Add local machines: */
     86        LogRelFlow(("UIChooserAbstractModel: Loading local VMs...\n"));
     87        /* Acquire existing machines: */
     88        const QVector<CMachine> machines = comVBox.GetMachines();
     89        /* Show error message if necessary: */
     90        if (!comVBox.isOk())
     91            msgCenter().cannotAcquireVirtualBoxParameter(comVBox);
     92        else
    8593        {
    86             const QUuid uMachineID = comMachine.GetId();
    87             if (!uMachineID.isNull() && gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineID))
     94            /* Iterate through existing machines: */
     95            foreach (const CMachine &comMachine, machines)
     96            {
     97                /* Skip if we have nothing to populate (wtf happened?): */
     98                if (comMachine.isNull())
     99                    continue;
     100
     101                /* Get machine ID: */
     102                const QUuid uMachineID = comMachine.GetId();
     103                /* Show error message if necessary: */
     104                if (!comMachine.isOk())
     105                {
     106                    msgCenter().cannotAcquireMachineParameter(comMachine);
     107                    continue;
     108                }
     109
     110                /* Skip if we have nothing to show (wtf happened?): */
     111                if (uMachineID.isNull())
     112                    continue;
     113
     114                /* Skip if machine is restricted from being shown: */
     115                if (!gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineID))
     116                    continue;
     117
     118                /* Add machine into tree: */
    88119                addMachineIntoTheTree(comMachine);
     120            }
    89121        }
    90         LogRelFlow(("UIChooserModel: VMs loaded.\n"));
     122        LogRelFlow(("UIChooserAbstractModel: Local VMs loaded.\n"));
    91123
    92124#ifdef VBOX_GUI_WITH_CLOUD_VMS
    93         /* Add cloud provider groups: */
    94         LogRelFlow(("UIChooserModel: Loading cloud providers...\n"));
    95         /* Acquire VBox: */
    96         CVirtualBox comVBox = uiCommon().virtualBox();
    97         /* Acquire Cloud Provider Manager: */
    98         CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager();
     125        /* Add cloud providers/profiles: */
     126        LogRelFlow(("UIChooserAbstractModel: Loading cloud providers/profiles...\n"));
     127        /* Acquire cloud provider manager: */
     128        const CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager();
    99129        /* Show error message if necessary: */
    100130        if (!comVBox.isOk())
     
    115145                    if (comCloudProvider.isNull())
    116146                        continue;
     147
     148                    /* Get profile names: */
     149                    const QVector<QString> profileNames = comCloudProvider.GetProfileNames();
     150                    /* Show error message if necessary: */
     151                    if (!comCloudProvider.isOk())
     152                    {
     153                        msgCenter().cannotAcquireCloudProviderParameter(comCloudProvider);
     154                        continue;
     155                    }
     156
    117157                    /* Skip if we have nothing to populate (profiles missing?): */
    118                     const QVector<QString> profileNames = comCloudProvider.GetProfileNames();
    119158                    if (profileNames.isEmpty())
    120159                        continue;
     
    124163                    /* Show error message if necessary: */
    125164                    if (!comCloudProvider.isOk())
     165                    {
    126166                        msgCenter().cannotAcquireCloudProviderParameter(comCloudProvider);
    127                     else
     167                        continue;
     168                    }
     169
     170                    /* Add provider group node: */
     171                    UIChooserNodeGroup *pProviderNode =
     172                        new UIChooserNodeGroup(invisibleRoot() /* parent */,
     173                                               false /* favorite */,
     174                                               getDesiredNodePosition(invisibleRoot(),
     175                                                                      UIChooserNodeType_Group,
     176                                                                      strProviderName),
     177                                               strProviderName,
     178                                               UIChooserNodeGroupType_Provider,
     179                                               false /* opened */);
     180
     181                    /* Iterate through provider's profile names: */
     182                    foreach (const QString &strProfileName, profileNames)
    128183                    {
    129                         /* Add provider group node: */
    130                         UIChooserNodeGroup *pProviderNode =
    131                             new UIChooserNodeGroup(invisibleRoot(),
     184                        /* Skip if we have nothing to show (wtf happened?): */
     185                        if (strProfileName.isEmpty())
     186                            continue;
     187
     188                        /* Acquire cloud profile: */
     189                        CCloudProfile comCloudProfile = comCloudProvider.GetProfileByName(strProfileName);
     190                        /* Show error message if necessary: */
     191                        if (!comCloudProvider.isOk())
     192                        {
     193                            msgCenter().cannotFindCloudProfile(comCloudProvider, strProfileName);
     194                            continue;
     195                        }
     196
     197                        /* Create cloud client: */
     198                        CCloudClient comCloudClient = comCloudProfile.CreateCloudClient();
     199                        /* Show error message if necessary: */
     200                        if (!comCloudProfile.isOk())
     201                        {
     202                            msgCenter().cannotCreateCloudClient(comCloudProfile);
     203                            continue;
     204                        }
     205
     206                        /* Add profile sub-group node: */
     207                        UIChooserNodeGroup *pProfileNode =
     208                            new UIChooserNodeGroup(pProviderNode /* parent */,
    132209                                                   false /* favorite */,
    133                                                    getDesiredNodePosition(invisibleRoot(),
     210                                                   getDesiredNodePosition(pProviderNode,
    134211                                                                          UIChooserNodeType_Group,
    135                                                                           strProviderName),
    136                                                    strProviderName,
    137                                                    UIChooserNodeGroupType_Provider,
    138                                                    false /* opened */);
    139 
    140                         /* Iterate through existing profile names: */
    141                         foreach (const QString &strProfileName, profileNames)
     212                                                                          strProfileName),
     213                                                   strProfileName,
     214                                                   UIChooserNodeGroupType_Profile,
     215                                                   true /* opened */);
     216                        /* Add fake cloud VM item: */
     217                        new UIChooserNodeMachine(pProfileNode /* parent */,
     218                                                 false /* favorite */,
     219                                                 0 /* position */);
     220
     221                        /* Create cloud list machines task: */
     222                        UITaskCloudListMachines *pTask = new UITaskCloudListMachines(comCloudClient,
     223                                                                                     pProfileNode);
     224                        if (pTask)
    142225                        {
    143                             /* Skip if we have nothing to show (wtf happened?): */
    144                             if (strProfileName.isEmpty())
    145                                 continue;
    146 
    147                             /* Acquire Cloud Profile: */
    148                             CCloudProfile comCloudProfile = comCloudProvider.GetProfileByName(strProfileName);
    149                             /* Show error message if necessary: */
    150                             if (!comCloudProvider.isOk())
    151                                 msgCenter().cannotFindCloudProfile(comCloudProvider, strProfileName);
    152                             else
    153                             {
    154                                 /* Create Cloud Client: */
    155                                 CCloudClient comCloudClient = comCloudProfile.CreateCloudClient();
    156                                 /* Show error message if necessary: */
    157                                 if (!comCloudProfile.isOk())
    158                                     msgCenter().cannotCreateCloudClient(comCloudProfile);
    159                                 else
    160                                 {
    161                                     /* Add profile sub-group node: */
    162                                     UIChooserNodeGroup *pProfileNode =
    163                                         new UIChooserNodeGroup(pProviderNode,
    164                                                                false /* favorite */,
    165                                                                getDesiredNodePosition(pProviderNode,
    166                                                                                       UIChooserNodeType_Group,
    167                                                                                       strProfileName),
    168                                                                strProfileName,
    169                                                                UIChooserNodeGroupType_Profile,
    170                                                                true /* opened */);
    171                                     /* Add fake cloud VM item: */
    172                                     new UIChooserNodeMachine(pProfileNode,
    173                                                              false /* favorite */,
    174                                                              0 /* position */);
    175 
    176                                     /* Create cloud acquire isntances task: */
    177                                     UITaskCloudListMachines *pTask = new UITaskCloudListMachines(comCloudClient,
    178                                                                                                  pProfileNode);
    179                                     if (pTask)
    180                                     {
    181                                         connect(uiCommon().threadPoolCloud(), &UIThreadPool::sigTaskComplete,
    182                                                 this, &UIChooserAbstractModel::sltHandleCloudListMachinesTaskComplete);
    183                                         uiCommon().threadPoolCloud()->enqueueTask(pTask);
    184                                     }
    185                                 }
    186                             }
     226                            connect(uiCommon().threadPoolCloud(), &UIThreadPool::sigTaskComplete,
     227                                    this, &UIChooserAbstractModel::sltHandleCloudListMachinesTaskComplete);
     228                            uiCommon().threadPoolCloud()->enqueueTask(pTask);
    187229                        }
    188230                    }
     
    190232            }
    191233        }
    192         LogRelFlow(("UIChooserModel: Cloud providers loaded.\n"));
     234        LogRelFlow(("UIChooserAbstractModel: Cloud providers/profiles loaded.\n"));
    193235#endif /* VBOX_GUI_WITH_CLOUD_VMS */
    194236    }
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