VirtualBox

Changeset 51953 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 9, 2014 12:27:52 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 6660: Extra-data Manager: Map acknowledging support.

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

Legend:

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

    r51952 r51953  
    356356        /** Handles machine (un)registration. */
    357357        void sltMachineRegistered(QString strID, bool fAdded);
     358        /** Handles extra-data map acknowledging. */
     359        void sltExtraDataMapAcknowledging(QString strID);
    358360        /** Handles extra-data change. */
    359361        void sltExtraDataChange(QString strID, QString strKey, QString strValue);
     
    639641}
    640642
     643void UIExtraDataManagerWindow::sltExtraDataMapAcknowledging(QString strID)
     644{
     645    /* Update item with 'changed ID' if it is among 'known IDs': */
     646    for (int iRow = 0; iRow < m_pModelSourceOfChooser->rowCount(); ++iRow)
     647        if (chooserID(iRow) == strID)
     648            m_pModelSourceOfChooser->itemFromIndex(chooserIndex(iRow))->setData(true, Field_Known);
     649}
     650
    641651void UIExtraDataManagerWindow::sltExtraDataChange(QString strID, QString strKey, QString strValue)
    642652{
     
    705715    /* Add all the new items finally: */
    706716    const QString strID = index.data(Field_ID).toString();
    707     AssertReturnVoid(gEDataManager->contains(strID));
     717    if (!gEDataManager->contains(strID))
     718        gEDataManager->hotloadMachineExtraDataMap(strID);
    708719    const ExtraDataMap data = gEDataManager->map(strID);
    709720    foreach (const QString &strKey, data.keys())
     
    18281839#endif /* DEBUG */
    18291840
     1841void UIExtraDataManager::hotloadMachineExtraDataMap(const QString &strID)
     1842{
     1843    /* Make sure it is valid ID: */
     1844    AssertMsgReturnVoid(!strID.isNull() && strID != GlobalID,
     1845                        ("Invalid VM ID = {%s}\n", strID.toAscii().constData()));
     1846    /* Which is not loaded yet: */
     1847    AssertReturnVoid(!m_data.contains(strID));
     1848
     1849    /* Search for corresponding machine: */
     1850    CVirtualBox vbox = vboxGlobal().virtualBox();
     1851    CMachine machine = vbox.FindMachine(strID);
     1852    AssertReturnVoid(vbox.isOk() && !machine.isNull());
     1853
     1854    /* Make sure at least empty map is created: */
     1855    m_data[strID] = ExtraDataMap();
     1856
     1857    /* Do not handle inaccessible machine: */
     1858    if (!machine.GetAccessible())
     1859        return;
     1860
     1861    /* Load machine extra-data map: */
     1862    foreach (const QString &strKey, machine.GetExtraDataKeys())
     1863        m_data[strID][strKey] = machine.GetExtraData(strKey);
     1864
     1865    /* Notifies about extra-data map acknowledged: */
     1866    emit sigExtraDataMapAcknowledging(strID);
     1867}
     1868
    18301869QString UIExtraDataManager::extraDataString(const QString &strKey, const QString &strID /* = GlobalID */)
    18311870{
     
    31993238        m_pWindow = new UIExtraDataManagerWindow;
    32003239        /* Configure window connections: */
     3240        connect(this, SIGNAL(sigExtraDataMapAcknowledging(QString)),
     3241                m_pWindow, SLOT(sltExtraDataMapAcknowledging(QString)));
    32013242        connect(this, SIGNAL(sigExtraDataChange(QString, QString, QString)),
    32023243                m_pWindow, SLOT(sltExtraDataChange(QString, QString, QString)));
     
    32063247}
    32073248#endif /* DEBUG */
    3208 
    3209 void UIExtraDataManager::hotloadMachineExtraDataMap(const QString &strID)
    3210 {
    3211     /* Make sure it is valid ID: */
    3212     AssertMsgReturnVoid(!strID.isNull() && strID != GlobalID,
    3213                         ("Invalid VM ID = {%s}\n", strID.toAscii().constData()));
    3214     /* Which is not loaded yet: */
    3215     AssertReturnVoid(!m_data.contains(strID));
    3216 
    3217     /* Search for corresponding machine: */
    3218     CVirtualBox vbox = vboxGlobal().virtualBox();
    3219     CMachine machine = vbox.FindMachine(strID);
    3220     AssertReturnVoid(vbox.isOk() && !machine.isNull());
    3221 
    3222     /* Make sure at least empty map is created: */
    3223     m_data[strID] = ExtraDataMap();
    3224 
    3225     /* Do not handle inaccessible machine: */
    3226     if (!machine.GetAccessible())
    3227         return;
    3228 
    3229     /* Load machine extra-data map: */
    3230     foreach (const QString &strKey, machine.GetExtraDataKeys())
    3231         m_data[strID][strKey] = machine.GetExtraData(strKey);
    3232 }
    32333249
    32343250bool UIExtraDataManager::isFeatureAllowed(const QString &strKey, const QString &strID /* = GlobalID */)
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r51931 r51953  
    5454signals:
    5555
     56    /** Notifies about extra-data map acknowledging. */
     57    void sigExtraDataMapAcknowledging(QString strID);
     58
    5659    /** Notifies about extra-data change. */
    5760    void sigExtraDataChange(QString strID, QString strKey, QString strValue);
     
    9699        /** Returns read-only extra-data map for passed @a strID. */
    97100        const ExtraDataMap map(const QString &strID) const { return m_data.value(strID); }
     101
     102        /** Hot-load machine extra-data map. */
     103        void hotloadMachineExtraDataMap(const QString &strID);
    98104
    99105        /** Returns extra-data value corresponding to passed @a strKey as QString.
     
    470476#endif /* DEBUG */
    471477
    472     /** Hot-load machine extra-data map. */
    473     void hotloadMachineExtraDataMap(const QString &strID);
    474 
    475478    /** Determines whether feature corresponding to passed @a strKey is allowed.
    476479      * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */
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