VirtualBox

Changeset 85035 in vbox


Ignore:
Timestamp:
Jul 1, 2020 4:45:17 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: Extend Cloud Profile Manager with possibility to restrict providers/profiles; This isn't used right now but will be used to hide/show corresponding cloud VMs.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r85013 r85035  
    928928#
    929929VirtualBox_QT_MOCSRCS = \
     930        src/cloud/profilemanager/UICloudProfileManager.cpp \
    930931        src/hostnetwork/UIHostNetworkManager.cpp \
    931932        src/manager/UIWelcomePane.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileDetailsWidget.h

    r83950 r85035  
    4545    /** Constructs data. */
    4646    UIDataCloudProvider()
    47         : m_strName(QString())
     47        : m_fRestricted(false)
    4848    {}
    4949
     
    5353        return true
    5454               && (m_uuid == other.m_uuid)
     55               && (m_strShortName == other.m_strShortName)
    5556               && (m_strName == other.m_strName)
     57               && (m_fRestricted == other.m_fRestricted)
    5658               ;
    5759    }
     
    6466    /** Holds the provider ID. */
    6567    QUuid    m_uuid;
     68    /** Holds the provider short name. */
     69    QString  m_strShortName;
    6670    /** Holds the provider name. */
    6771    QString  m_strName;
     72    /** Holds whether provider is restricted. */
     73    bool     m_fRestricted;
    6874
    6975    /** Holds the profile supported property descriptions. */
     
    7682    /** Constructs data. */
    7783    UIDataCloudProfile()
    78         : m_strName(QString())
     84        : m_fRestricted(false)
    7985    {}
    8086
     
    8389    {
    8490        return true
     91               && (m_strProviderShortName == other.m_strProviderShortName)
    8592               && (m_strName == other.m_strName)
     93               && (m_fRestricted == other.m_fRestricted)
    8694               && (m_data == other.m_data)
    8795               ;
     
    93101    bool operator!=(const UIDataCloudProfile &other) const { return !equal(other); }
    94102
     103    /** Holds the provider short name. */
     104    QString  m_strProviderShortName;
    95105    /** Holds the profile name. */
    96106    QString  m_strName;
     107    /** Holds whether provider is restricted. */
     108    bool     m_fRestricted;
    97109
    98110    /** Holds the profile data. */
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.cpp

    r85034 r85035  
    6363{
    6464    Column_Name,
     65    Column_ListVMs,
    6566    Column_Max
    6667};
     
    7071class UIItemCloudProvider : public QITreeWidgetItem, public UIDataCloudProvider
    7172{
     73    Q_OBJECT;
     74
    7275public:
    7376
     
    8588class UIItemCloudProfile : public QITreeWidgetItem, public UIDataCloudProfile
    8689{
     90    Q_OBJECT;
     91
    8792public:
    8893
     
    115120    setText(Column_Name, m_strName);
    116121    setData(Column_Name, Data_ProviderID, m_uuid);
     122    setCheckState(Column_ListVMs, m_fRestricted ? Qt::Unchecked : Qt::Checked);
    117123}
    118124
     
    134140    /* Update item fields: */
    135141    setText(Column_Name, m_strName);
     142    setCheckState(Column_ListVMs, m_fRestricted ? Qt::Unchecked : Qt::Checked);
    136143}
    137144
     
    172179        m_pToolBar->updateLayout();
    173180#endif
     181
     182    /* Translate tree-widget: */
     183    m_pTreeWidget->setHeaderLabels(   QStringList()
     184                                   << tr("Source")
     185                                   << tr("List VMs"));
    174186}
    175187
     
    491503}
    492504
     505void UICloudProfileManagerWidget::sltPerformTableAdjustment()
     506{
     507    AssertPtrReturnVoid(m_pTreeWidget);
     508    AssertPtrReturnVoid(m_pTreeWidget->header());
     509    AssertPtrReturnVoid(m_pTreeWidget->viewport());
     510    m_pTreeWidget->header()->resizeSection(0, m_pTreeWidget->viewport()->width() - m_pTreeWidget->header()->sectionSize(1));
     511}
     512
    493513void UICloudProfileManagerWidget::sltHandleCurrentItemChange()
    494514{
     
    546566    /* And show it: */
    547567    menu.exec(m_pTreeWidget->mapToGlobal(position));
     568}
     569
     570void UICloudProfileManagerWidget::sltHandleItemChange(QTreeWidgetItem *pItem)
     571{
     572    /* Cast pItem to QITreeWidgetItem: */
     573    QITreeWidgetItem *pChangedItem = QITreeWidgetItem::toItem(pItem);
     574    AssertMsgReturnVoid(pChangedItem, ("Changed item must not be null!\n"));
     575
     576    /* Check whether item is of provider or profile type, then check whether it changed: */
     577    bool fChanged = false;
     578    UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pChangedItem);
     579    UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pChangedItem);
     580    if (pProviderItem)
     581    {
     582        const UIDataCloudProvider oldData = *pProviderItem;
     583        if (   (oldData.m_fRestricted && pProviderItem->checkState(Column_ListVMs) == Qt::Checked)
     584            || (!oldData.m_fRestricted && pProviderItem->checkState(Column_ListVMs) == Qt::Unchecked))
     585            fChanged = true;
     586    }
     587    else if (pProfileItem)
     588    {
     589        const UIDataCloudProfile oldData = *pProfileItem;
     590        if (   (oldData.m_fRestricted && pProfileItem->checkState(Column_ListVMs) == Qt::Checked)
     591            || (!oldData.m_fRestricted && pProfileItem->checkState(Column_ListVMs) == Qt::Unchecked))
     592            fChanged = true;
     593    }
     594
     595    /* Gather Cloud Profile Manager restrictions and save them to extra-data: */
     596    if (fChanged)
     597        gEDataManager->setCloudProfileManagerRestrictions(gatherCloudProfileManagerRestrictions(m_pTreeWidget->invisibleRootItem()));
    548598}
    549599
     
    644694    {
    645695        /* Configure tree-widget: */
    646         m_pTreeWidget->header()->hide();
     696        m_pTreeWidget->header()->setStretchLastSection(false);
    647697        m_pTreeWidget->setRootIsDecorated(false);
    648698        m_pTreeWidget->setAlternatingRowColors(true);
     
    691741
    692742    /* Tree-widget connections: */
     743    connect(m_pTreeWidget, &QITreeWidget::resized,
     744            this, &UICloudProfileManagerWidget::sltPerformTableAdjustment, Qt::QueuedConnection);
     745    connect(m_pTreeWidget->header(), &QHeaderView::sectionResized,
     746            this, &UICloudProfileManagerWidget::sltPerformTableAdjustment, Qt::QueuedConnection);
    693747    connect(m_pTreeWidget, &QITreeWidget::currentItemChanged,
    694748            this, &UICloudProfileManagerWidget::sltHandleCurrentItemChange);
     
    697751    connect(m_pTreeWidget, &QITreeWidget::itemDoubleClicked,
    698752            m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details), &QAction::setChecked);
     753    connect(m_pTreeWidget, &QITreeWidget::itemChanged,
     754            this, &UICloudProfileManagerWidget::sltHandleItemChange);
    699755
    700756    /* Details-widget connections: */
     
    705761    connect(m_pDetailsWidget, &UICloudProfileDetailsWidget::sigDataChangeAccepted,
    706762            this, &UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges);
     763
     764    /* Extra-data connections: */
     765    connect(gEDataManager, &UIExtraDataManager::sigCloudProfileManagerRestrictionChange,
     766            this, &UICloudProfileManagerWidget::sltLoadCloudStuff);
    707767}
    708768
     
    719779    m_pTreeWidget->clear();
    720780
     781    /* Acquire cloud profile manager restrictions: */
     782    const QStringList restrictions = gEDataManager->cloudProfileManagerRestrictions();
     783
    721784    /* Iterate through existing providers: */
    722785    foreach (const CCloudProvider &comCloudProvider, listCloudProviders())
     
    729792        UIDataCloudProvider providerData;
    730793        loadCloudProvider(comCloudProvider, providerData);
     794        const QString strProviderPath = QString("/%1").arg(providerData.m_strShortName);
     795        providerData.m_fRestricted = restrictions.contains(strProviderPath);
    731796        createItemForCloudProvider(providerData, false);
    732797
     
    744809            UIDataCloudProfile profileData;
    745810            loadCloudProfile(comCloudProfile, providerData, profileData);
     811            const QString strProfilePath = QString("/%1/%2").arg(providerData.m_strShortName).arg(profileData.m_strName);
     812            profileData.m_fRestricted = restrictions.contains(strProfilePath);
    746813            createItemForCloudProfile(pItem, profileData, false);
    747814        }
     
    762829        data.m_uuid = comProvider.GetId();
    763830    if (comProvider.isOk())
     831        data.m_strShortName = comProvider.GetShortName();
     832    if (comProvider.isOk())
    764833        data.m_strName = comProvider.GetName();
    765834    foreach (const QString &strSupportedPropertyName, comProvider.GetSupportedPropertyNames())
     
    773842void UICloudProfileManagerWidget::loadCloudProfile(const CCloudProfile &comProfile, const UIDataCloudProvider &providerData, UIDataCloudProfile &profileData)
    774843{
     844    /* Gather provider settings: */
     845    profileData.m_strProviderShortName = providerData.m_strShortName;
     846
    775847    /* Gather profile settings: */
    776848    if (comProfile.isOk())
     
    858930            m_pTreeWidget->setCurrentItem(pItem);
    859931    }
     932}
     933
     934QStringList UICloudProfileManagerWidget::gatherCloudProfileManagerRestrictions(QTreeWidgetItem *pParentItem)
     935{
     936    /* Prepare result: */
     937    QStringList result;
     938    AssertPtrReturn(pParentItem, result);
     939
     940    /* Process unchecked QITreeWidgetItem(s) only: */
     941    QITreeWidgetItem *pChangedItem = QITreeWidgetItem::toItem(pParentItem);
     942    if (   pChangedItem
     943        && pChangedItem->checkState(Column_ListVMs) == Qt::Unchecked)
     944    {
     945        /* Check whether item is of provider or profile type: */
     946        UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pChangedItem);
     947        UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pChangedItem);
     948        if (pProviderItem)
     949        {
     950            const UIDataCloudProvider oldData = *pProviderItem;
     951            result << QString("/%1").arg(oldData.m_strShortName);
     952        }
     953        else if (pProfileItem)
     954        {
     955            const UIDataCloudProfile oldData = *pProfileItem;
     956            result << QString("/%1/%2").arg(oldData.m_strProviderShortName, oldData.m_strName);
     957        }
     958    }
     959
     960    /* Iterate through children recursively: */
     961    for (int i = 0; i < pParentItem->childCount(); ++i)
     962        result << gatherCloudProfileManagerRestrictions(pParentItem->child(i));
     963
     964    /* Return result: */
     965    return result;
    860966}
    861967
     
    9801086    return qobject_cast<UICloudProfileManagerWidget*>(QIManagerDialog::widget());
    9811087}
     1088
     1089
     1090#include "UICloudProfileManager.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.h

    r85033 r85035  
    111111    /** @name Tree-widget stuff.
    112112      * @{ */
     113        /** Handles request to load cloud stuff. */
     114        void sltLoadCloudStuff() { loadCloudStuff(); }
     115        /** Adjusts tree-widget according content. */
     116        void sltPerformTableAdjustment();
    113117        /** Handles tree-widget current item change. */
    114118        void sltHandleCurrentItemChange();
    115119        /** Handles context menu request for tree-widget @a position. */
    116120        void sltHandleContextMenuRequest(const QPoint &position);
     121        /** Handles tree-widget @a pItem change. */
     122        void sltHandleItemChange(QTreeWidgetItem *pItem);
    117123    /** @} */
    118124
     
    161167        /** Updates the passed tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
    162168        void updateItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem, UIItemCloudProfile *pItem);
     169
     170        /* Gathers a list of Cloud Profile Manager restrictions starting from @a pParentItem. */
     171        QStringList gatherCloudProfileManagerRestrictions(QTreeWidgetItem *pParentItem);
    163172    /** @} */
    164173
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r84790 r85035  
    111111
    112112/* Cloud Profile Manager: */
     113const char *UIExtraDataDefs::GUI_CloudProfileManager_Restrictions = "GUI/CloudProfileManager/Restrictions";
    113114const char *UIExtraDataDefs::GUI_CloudProfileManager_Details_Expanded = "GUI/CloudProfileManager/Details/Expanded";
    114115
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r84910 r85035  
    216216    /** @name Cloud Profile Manager
    217217      * @{ */
     218        /** Holds Cloud Profile Manager restrictions. */
     219        SHARED_LIBRARY_STUFF extern const char *GUI_CloudProfileManager_Restrictions;
    218220        /** Holds whether Cloud Profile Manager details expanded. */
    219221        SHARED_LIBRARY_STUFF extern const char *GUI_CloudProfileManager_Details_Expanded;
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r84990 r85035  
    19291929           << GUI_VirtualMediaManager_Details_Expanded
    19301930           << GUI_HostNetworkManager_Details_Expanded
     1931           << GUI_CloudProfileManager_Restrictions
    19311932           << GUI_CloudProfileManager_Details_Expanded
    19321933           << GUI_HideDescriptionForWizards
     
    29742975}
    29752976
     2977QStringList UIExtraDataManager::cloudProfileManagerRestrictions()
     2978{
     2979    return extraDataStringList(GUI_CloudProfileManager_Restrictions);
     2980}
     2981
     2982void UIExtraDataManager::setCloudProfileManagerRestrictions(const QStringList &restrictions)
     2983{
     2984    return setExtraDataStringList(GUI_CloudProfileManager_Restrictions, restrictions);
     2985}
     2986
    29762987bool UIExtraDataManager::cloudProfileManagerDetailsExpanded()
    29772988{
     
    45684579            else if (strKey == GUI_Input_HostKeyCombination)
    45694580                emit sigRuntimeUIHostKeyCombinationChange();
     4581            /* Cloud Profile Manager restrictions changed: */
     4582            else if (strKey == GUI_CloudProfileManager_Restrictions)
     4583                emit sigCloudProfileManagerRestrictionChange();
    45704584            /* Details categories: */
    45714585            else if (strKey == GUI_Details_Elements)
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r84990 r85035  
    7575    /** Notifies about Runtime UI host-key combination change. */
    7676    void sigRuntimeUIHostKeyCombinationChange();
     77
     78    /** Notifies about Cloud Profile Manager restriction change. */
     79    void sigCloudProfileManagerRestrictionChange();
    7780
    7881    /** Notifies about VirtualBox Manager / Details pane categories change. */
     
    405408    /** @name Cloud Profile Manager
    406409      * @{ */
     410        /** Returns Cloud Profile Manager restrictions. */
     411        QStringList cloudProfileManagerRestrictions();
     412        /** Defines Cloud Profile Manager @a restrictions. */
     413        void setCloudProfileManagerRestrictions(const QStringList &restrictions);
     414
    407415        /** Returns whether Cloud Profile Manager details expanded. */
    408416        bool cloudProfileManagerDetailsExpanded();
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