VirtualBox

Changeset 51363 in vbox


Ignore:
Timestamp:
May 23, 2014 12:52:48 AM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 6660: Advanced extra-data management framework: Proper handling for global extra-data ID.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/extradata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r51216 r51363  
    115115/* static */
    116116UIExtraDataManager *UIExtraDataManager::m_pInstance = 0;
     117QString UIExtraDataManager::m_sstrGlobalID = QUuid().toString().remove(QRegExp("[{}]"));
    117118
    118119/* static */
     
    560561
    561562    /* Global extra-data 'change' event: */
    562     if (QUuid(strMachineID).isNull())
     563    if (strMachineID == m_sstrGlobalID)
    563564    {
    564565        if (strKey.startsWith("GUI/"))
     
    610611
    611612    /* Make sure at least empty map is created: */
    612     m_data[QString()] = ExtraDataMap();
     613    m_data[m_sstrGlobalID] = ExtraDataMap();
    613614
    614615    /* Load global extra-data map: */
    615616    foreach (const QString &strKey, vbox.GetExtraDataKeys())
    616         m_data[QString()][strKey] = vbox.GetExtraData(strKey);
     617        m_data[m_sstrGlobalID][strKey] = vbox.GetExtraData(strKey);
    617618}
    618619
     
    674675void UIExtraDataManager::hotloadMachineExtraDataMap(const QString &strID) const
    675676{
    676     /* Make sure it is not yet loaded: */
    677     AssertReturnVoid(!strID.isNull() && !m_data.contains(strID));
     677    /* Make sure it is valid ID: */
     678    AssertReturnVoid(!strID.isNull() && strID != m_sstrGlobalID);
     679    /* Which is not loaded yet: */
     680    AssertReturnVoid(!m_data.contains(strID));
    678681
    679682    /* Search for corresponding machine: */
     
    694697}
    695698
    696 bool UIExtraDataManager::isFeatureAllowed(const QString &strKey, const QString &strID /* = QString() */) const
     699bool UIExtraDataManager::isFeatureAllowed(const QString &strKey, const QString &strID /* = m_sstrGlobalID */) const
    697700{
    698701    /* Hot-load machine extra-data map if necessary: */
    699     if (!strID.isNull() && !m_data.contains(strID))
     702    if (strID != m_sstrGlobalID && !m_data.contains(strID))
    700703        hotloadMachineExtraDataMap(strID);
    701704
     
    715718}
    716719
    717 bool UIExtraDataManager::isFeatureRestricted(const QString &strKey, const QString &strID /* = QString() */) const
     720bool UIExtraDataManager::isFeatureRestricted(const QString &strKey, const QString &strID /* = m_sstrGlobalID */) const
    718721{
    719722    /* Hot-load machine extra-data map if necessary: */
    720     if (!strID.isNull() && !m_data.contains(strID))
     723    if (strID != m_sstrGlobalID && !m_data.contains(strID))
    721724        hotloadMachineExtraDataMap(strID);
    722725
     
    746749}
    747750
    748 QString UIExtraDataManager::extraDataString(const QString &strKey, const QString &strID /* = QString() */) const
     751QString UIExtraDataManager::extraDataString(const QString &strKey, const QString &strID /* = m_sstrGlobalID */) const
    749752{
    750753    /* Hot-load machine extra-data map if necessary: */
    751     if (!strID.isNull() && !m_data.contains(strID))
     754    if (strID != m_sstrGlobalID && !m_data.contains(strID))
    752755        hotloadMachineExtraDataMap(strID);
    753756
     
    763766}
    764767
    765 void UIExtraDataManager::setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID /* = QString() */)
     768void UIExtraDataManager::setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID /* = m_sstrGlobalID */)
    766769{
    767770    /* Hot-load machine extra-data map if necessary: */
    768     if (!strID.isNull() && !m_data.contains(strID))
     771    if (strID != m_sstrGlobalID && !m_data.contains(strID))
    769772        hotloadMachineExtraDataMap(strID);
    770773
     
    776779
    777780    /* Global extra-data: */
    778     if (strID.isNull())
     781    if (strID == m_sstrGlobalID)
    779782    {
    780783        /* Get global object: */
     
    795798}
    796799
    797 QStringList UIExtraDataManager::extraDataStringList(const QString &strKey, const QString &strID /* = QString() */) const
     800QStringList UIExtraDataManager::extraDataStringList(const QString &strKey, const QString &strID /* = m_sstrGlobalID */) const
    798801{
    799802    /* Hot-load machine extra-data map if necessary: */
    800     if (!strID.isNull() && !m_data.contains(strID))
     803    if (strID != m_sstrGlobalID && !m_data.contains(strID))
    801804        hotloadMachineExtraDataMap(strID);
    802805
     
    813816}
    814817
    815 void UIExtraDataManager::setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID /* = QString() */)
     818void UIExtraDataManager::setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID /* = m_sstrGlobalID */)
    816819{
    817820    /* Hot-load machine extra-data map if necessary: */
    818     if (!strID.isNull() && !m_data.contains(strID))
     821    if (strID != m_sstrGlobalID && !m_data.contains(strID))
    819822        hotloadMachineExtraDataMap(strID);
    820823
     
    826829
    827830    /* Global extra-data: */
    828     if (strID.isNull())
     831    if (strID == m_sstrGlobalID)
    829832    {
    830833        /* Get global object: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r51216 r51363  
    227227    /** Determines whether feature corresponding to passed @a strKey is allowed.
    228228      * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
    229     bool isFeatureAllowed(const QString &strKey, const QString &strID = QString()) const;
     229    bool isFeatureAllowed(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
    230230    /** Determines whether feature corresponding to passed @a strKey is restricted.
    231231      * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
    232     bool isFeatureRestricted(const QString &strKey, const QString &strID = QString()) const;
     232    bool isFeatureRestricted(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
    233233
    234234    /** Translates bool flag into 'allowed' value. */
     
    239239    /** Returns extra-data value corresponding to passed @a strKey as QString.
    240240      * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
    241     QString extraDataString(const QString &strKey, const QString &strID = QString()) const;
     241    QString extraDataString(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
    242242    /** Defines extra-data value corresponding to passed @a strKey as strValue.
    243243      * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
    244     void setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID = QString());
     244    void setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID = m_sstrGlobalID);
    245245
    246246    /** Returns extra-data value corresponding to passed @a strKey as QStringList.
    247247      * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
    248     QStringList extraDataStringList(const QString &strKey, const QString &strID = QString()) const;
     248    QStringList extraDataStringList(const QString &strKey, const QString &strID = m_sstrGlobalID) const;
    249249    /** Defines extra-data value corresponding to passed @a strKey as strValue.
    250250      * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
    251     void setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID = QString());
     251    void setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID = m_sstrGlobalID);
    252252
    253253    /** Singleton Extra-data Manager instance. */
    254254    static UIExtraDataManager *m_pInstance;
     255
     256    /** Global extra-data ID. */
     257    static QString m_sstrGlobalID;
    255258
    256259    /** Main event-listener instance. */
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