VirtualBox

Changeset 74887 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 17, 2018 3:23:38 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
125872
Message:

FE/Qt: bugref:9230: Populate providers/profiles tree.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileManager.cpp

    r74884 r74887  
    3434# include "UICloudProfileDetailsWidget.h"
    3535# include "UICloudProfileManager.h"
     36# include "UIMessageCenter.h"
    3637# include "UIToolBar.h"
    3738# ifdef VBOX_WS_MAC
     
    4243#include "CCloudProfile.h"
    4344#include "CCloudProvider.h"
     45#include "CCloudProviderManager.h"
    4446
    4547#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    428430    m_pTreeWidget->clear();
    429431
    430     /// @todo load cloud profiles!
     432    /* Get VirtualBox for further activities: */
     433    const CVirtualBox comVBox = vboxGlobal().virtualBox();
     434
     435    /* Get CloudProviderManager for further activities: */
     436    const CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager();
     437    /* Show error message if necessary: */
     438    if (!comVBox.isOk())
     439        msgCenter().cannotAcquireCloudProviderManager(comVBox, this);
     440    else
     441    {
     442        /* Iterate through existing providers: */
     443        foreach (const CCloudProvider &comCloudProvider, comCloudProviderManager.GetProviders())
     444        {
     445            /* Skip if we have nothing to populate (file missing?): */
     446            if (comCloudProvider.isNull())
     447                continue;
     448
     449            /* Load provider data: */
     450            UIDataCloudProvider providerData;
     451            loadCloudProvider(comCloudProvider, providerData);
     452            createItemForCloudProvider(providerData, false);
     453
     454            /* Make sure provider item is properly inserted: */
     455            UIItemCloudProvider *pItem = searchItem(providerData.m_uuid);
     456
     457            /* Iterate through existing profiles: */
     458            foreach (const CCloudProfile &comCloudProfile, comCloudProvider.GetProfiles())
     459            {
     460                /* Load profile data: */
     461                UIDataCloudProfile profileData;
     462                loadCloudProfile(comCloudProfile, profileData);
     463                createItemForCloudProfile(pItem, profileData, false);
     464            }
     465
     466            /* Expand provider item finally: */
     467            pItem->setExpanded(true);
     468        }
     469
     470        /* Choose the 1st item as current initially: */
     471        m_pTreeWidget->setCurrentItem(m_pTreeWidget->topLevelItem(0));
     472        sltHandleCurrentItemChange();
     473    }
    431474}
    432475
     
    436479    Q_UNUSED(data);
    437480
    438     /// @todo load cloud profile!
     481    /* Gather provider settings: */
     482    if (comProvider.isOk())
     483        data.m_uuid = comProvider.GetId();
     484    if (comProvider.isOk())
     485        data.m_strName = comProvider.GetName();
     486
     487    /* Show error message if necessary: */
     488    if (!comProvider.isOk())
     489        msgCenter().cannotAcquireCloudProviderParameter(comProvider, this);
    439490}
    440491
     
    444495    Q_UNUSED(data);
    445496
    446     /// @todo load cloud profile!
     497    /* Gather profile settings: */
     498    if (comProfile.isOk())
     499        data.m_strName = comProfile.GetName();
     500
     501    /* Show error message if necessary: */
     502    if (!comProfile.isOk())
     503        msgCenter().cannotAcquireCloudProfileParameter(comProfile, this);
     504}
     505
     506UIItemCloudProvider *UICloudProfileManagerWidget::searchItem(const QUuid &uuid) const
     507{
     508    /* Iterated through top-level items: */
     509    for (int i = 0; i < m_pTreeWidget->topLevelItemCount(); ++i)
     510        if (m_pTreeWidget->topLevelItem(i)->data(0, Data_ProviderID).toUuid() == uuid)
     511            return static_cast<UIItemCloudProvider*>(m_pTreeWidget->topLevelItem(i));
     512    /* Null by default: */
     513    return 0;
    447514}
    448515
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileManager.h

    r74881 r74887  
    141141    /** @name Tree-widget stuff.
    142142      * @{ */
     143        /** Seearches a provider item with specified @a uuid. */
     144        UIItemCloudProvider *searchItem(const QUuid &uuid) const;
     145
    143146        /** Creates a new tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
    144147        void createItemForCloudProvider(const UIDataCloudProvider &data, bool fChooseItem);
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r74878 r74887  
    5757
    5858/* COM includes: */
     59# include "CCloudProfile.h"
     60# include "CCloudProvider.h"
    5961# include "CNATNetwork.h"
    6062# include "CDHCPServer.h"
     
    16101612}
    16111613
     1614void UIMessageCenter::cannotAcquireCloudProviderManager(const CVirtualBox &comVBox, QWidget *pParent /* = 0 */) const
     1615{
     1616    error(pParent, MessageType_Error,
     1617          tr("Failed to acquire cloud provider manager."),
     1618          UIErrorString::formatErrorInfo(comVBox));
     1619}
     1620
     1621void UIMessageCenter::cannotAcquireCloudProviderParameter(const CCloudProvider &comProvider, QWidget *pParent /* = 0 */) const
     1622{
     1623    error(pParent, MessageType_Error,
     1624          tr("Failed to acquire cloud provider parameter."),
     1625          UIErrorString::formatErrorInfo(comProvider));
     1626}
     1627
     1628void UIMessageCenter::cannotAcquireCloudProfileParameter(const CCloudProfile &comProfile, QWidget *pParent /* = 0 */) const
     1629{
     1630    error(pParent, MessageType_Error,
     1631          tr("Failed to acquire cloud profile parameter."),
     1632          UIErrorString::formatErrorInfo(comProfile));
     1633}
     1634
    16121635bool UIMessageCenter::confirmHardDisklessMachine(QWidget *pParent /* = 0*/) const
    16131636{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r74878 r74887  
    359359    void cannotAcquireDHCPServerParameter(const CDHCPServer &comServer, QWidget *pParent = 0) const;
    360360    void cannotSaveDHCPServerParameter(const CDHCPServer &comServer, QWidget *pParent = 0) const;
     361
     362    /* API: Cloud Profile Manager warnings: */
     363    void cannotAcquireCloudProviderManager(const CVirtualBox &comVBox, QWidget *pParent = 0) const;
     364    void cannotAcquireCloudProviderParameter(const CCloudProvider &comProvider, QWidget *pParent = 0) const;
     365    void cannotAcquireCloudProfileParameter(const CCloudProfile &comProfile, QWidget *pParent = 0) const;
    361366
    362367    /* API: Wizards warnings: */
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