VirtualBox

Changeset 86689 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 23, 2020 2:23:39 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Cloud Profile Manager: Replace search provider function with search item by definition function, which became possible since r141049.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager
Files:
2 edited

Legend:

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

    r86688 r86689  
    8484    /** Returns item name. */
    8585    QString name() const { return m_strName; }
     86
     87    /** Returns definition composed on the basis of @a strShortName. */
     88    static QString definition(const QString &strShortName);
    8689};
    8790
     
    101104    /** Returns item name. */
    102105    QString name() const { return m_strName; }
     106
     107    /** Returns definition composed on the basis of @a strProviderShortName and @a strName. */
     108    static QString definition(const QString &strProviderShortName, const QString &strName);
    103109};
    104110
     
    121127    setText(Column_Name, m_strName);
    122128    setData(Column_Name, Data_ProviderID, m_uId);
    123     setData(Column_Name, Data_Definition, QVariant::fromValue(QString("/%1").arg(m_strShortName)));
     129    setData(Column_Name, Data_Definition, QVariant::fromValue(definition(m_strShortName)));
    124130    setCheckState(Column_ListVMs, m_fRestricted ? Qt::Unchecked : Qt::Checked);
     131}
     132
     133/* static */
     134QString UIItemCloudProvider::definition(const QString &strShortName)
     135{
     136    return QString("/%1").arg(strShortName);
    125137}
    126138
     
    142154    /* Update item fields: */
    143155    setText(Column_Name, m_strName);
    144     setData(Column_Name, Data_Definition, QVariant::fromValue(QString("/%1/%2").arg(m_strProviderShortName, m_strName)));
     156    setData(Column_Name, Data_Definition, QVariant::fromValue(definition(m_strProviderShortName, m_strName)));
    145157    setCheckState(Column_ListVMs, m_fRestricted ? Qt::Unchecked : Qt::Checked);
     158}
     159
     160/* static */
     161QString UIItemCloudProfile::definition(const QString &strProviderShortName, const QString &strName)
     162{
     163    return QString("/%1/%2").arg(strProviderShortName, strName);
    146164}
    147165
     
    801819
    802820        /* Make sure provider item is properly inserted: */
    803         UIItemCloudProvider *pItem = searchItem(providerData.m_uId);
     821        QTreeWidgetItem *pItem = searchItem(UIItemCloudProvider::definition(providerData.m_strShortName));
     822        AssertPtrReturnVoid(pItem);
    804823
    805824        /* Iterate through provider's profiles: */
     
    841860    if (comProvider.isOk())
    842861        providerData.m_strName = comProvider.GetName();
    843     const QString strProviderPath = QString("/%1").arg(providerData.m_strShortName);
     862    const QString strProviderPath = UIItemCloudProvider::definition(providerData.m_strShortName);
    844863    providerData.m_fRestricted = restrictions.contains(strProviderPath);
    845864    foreach (const QString &strSupportedPropertyName, comProvider.GetSupportedPropertyNames())
     
    862881    if (comProfile.isOk())
    863882        profileData.m_strName = comProfile.GetName();
    864     const QString strProfilePath = QString("/%1/%2").arg(providerData.m_strShortName).arg(profileData.m_strName);
     883    const QString strProfilePath = UIItemCloudProfile::definition(providerData.m_strShortName, profileData.m_strName);
    865884    profileData.m_fRestricted = restrictions.contains(strProfilePath);
    866885
     
    911930            return pChildItem;
    912931
    913     /* Null by default: */
    914     return 0;
    915 }
    916 
    917 UIItemCloudProvider *UICloudProfileManagerWidget::searchItem(const QUuid &uId) const
    918 {
    919     /* Iterate through tree-widget children: */
    920     for (int i = 0; i < m_pTreeWidget->childCount(); ++i)
    921         if (m_pTreeWidget->childItem(i)->data(Column_Name, Data_ProviderID).toUuid() == uId)
    922             return qobject_cast<UIItemCloudProvider*>(m_pTreeWidget->childItem(i));
    923932    /* Null by default: */
    924933    return 0;
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.h

    r86688 r86689  
    169169        QTreeWidgetItem *searchItem(const QString &strDefinition,
    170170                                    QTreeWidgetItem *pParentItem = 0) const;
    171         /** Searches for a provider item with specified @a uId. */
    172         UIItemCloudProvider *searchItem(const QUuid &uId) const;
    173171
    174172        /** Creates a new tree-widget item
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