VirtualBox

Changeset 75305 in vbox for trunk


Ignore:
Timestamp:
Nov 7, 2018 12:55:58 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9289: UIExtraDataDefs & UIExtraDataManager: A possibility to define obsolete extra-data keys (for each actual key), which will be wiped out on first save call.

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

Legend:

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

    r75224 r75305  
    222222
    223223
     224/* Obsolete keys: */
     225QMap<QString, QString> UIExtraDataDefs::prepareObsoleteKeysMap()
     226{
     227    QMap<QString, QString> map;
     228    // Define substitutes here..
     229    return map;
     230}
     231QMap<QString, QString> UIExtraDataDefs::g_mapOfObsoleteKeys = UIExtraDataDefs::prepareObsoleteKeysMap();
     232
     233
    224234bool UIToolStuff::isTypeOfClass(UIToolType enmType, UIToolClass enmClass)
    225235{
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r75291 r75305  
    2020
    2121/* Qt includes: */
     22#include <QMap>
    2223#include <QMetaType>
    2324#include <QObject>
     
    394395    /** @} */
    395396
     397
     398    /** @name Old key support stuff.
     399      * @{ */
     400        /** Prepares obsolete keys map. */
     401        SHARED_LIBRARY_STUFF QMap<QString, QString> prepareObsoleteKeysMap();
     402
     403        /** Holds the obsolete keys map. */
     404        SHARED_LIBRARY_STUFF extern QMap<QString, QString> g_mapOfObsoleteKeys;
     405    /** @} */
    396406}
    397407
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r75304 r75305  
    21172117QString UIExtraDataManager::extraDataString(const QString &strKey, const QUuid &uID /* = GlobalID */)
    21182118{
    2119     /* Get the value. Return 'QString()' if not found: */
    2120     const QString strValue = extraDataStringUnion(strKey, uID);
     2119    /* Get the actual value: */
     2120    QString strValue = extraDataStringUnion(strKey, uID);
     2121    /* If actual value is null we might be able to find old one: */
    21212122    if (strValue.isNull())
     2123    {
     2124        foreach (const QString &strOldKey, g_mapOfObsoleteKeys.values(strKey))
     2125        {
     2126            strValue = extraDataStringUnion(strOldKey, uID);
     2127            if (!strValue.isNull())
     2128                break;
     2129        }
     2130    }
     2131    /* Return null string if result is empty: */
     2132    if (strValue.isEmpty())
    21222133        return QString();
    21232134
     
    21512162        if (!comVBox.isOk())
    21522163            msgCenter().cannotSetExtraData(comVBox, strKey, strValue);
     2164        /* Wipe out old keys: */
     2165        foreach (const QString &strOldKey, g_mapOfObsoleteKeys.values(strKey))
     2166        {
     2167            comVBox.SetExtraData(strOldKey, QString());
     2168            if (!comVBox.isOk())
     2169            {
     2170                msgCenter().cannotSetExtraData(comVBox, strOldKey, strValue);
     2171                break;
     2172            }
     2173        }
    21532174    }
    21542175    /* Machine extra-data: */
     
    21762197        if (!comSessionMachine.isOk())
    21772198            msgCenter().cannotSetExtraData(comSessionMachine, strKey, strValue);
     2199        /* Wipe out old keys: */
     2200        foreach (const QString &strOldKey, g_mapOfObsoleteKeys.values(strKey))
     2201        {
     2202            comSessionMachine.SetExtraData(strOldKey, QString());
     2203            if (!comSessionMachine.isOk())
     2204            {
     2205                msgCenter().cannotSetExtraData(comSessionMachine, strOldKey, strValue);
     2206                break;
     2207            }
     2208        }
    21782209        comSession.UnlockMachine();
    21792210    }
     
    21822213QStringList UIExtraDataManager::extraDataStringList(const QString &strKey, const QUuid &uID /* = GlobalID */)
    21832214{
    2184     /* Get the value. Return 'QStringList()' if not found: */
    2185     const QString strValue = extraDataStringUnion(strKey, uID);
     2215    /* Get the actual value: */
     2216    QString strValue = extraDataStringUnion(strKey, uID);
     2217    /* If actual value is null we might be able to find old one: */
    21862218    if (strValue.isNull())
     2219    {
     2220        foreach (const QString &strOldKey, g_mapOfObsoleteKeys.values(strKey))
     2221        {
     2222            strValue = extraDataStringUnion(strOldKey, uID);
     2223            if (!strValue.isNull())
     2224                break;
     2225        }
     2226    }
     2227    /* Return empty string list if result is empty: */
     2228    if (strValue.isEmpty())
    21872229        return QStringList();
    21882230
     
    22172259        if (!comVBox.isOk())
    22182260            msgCenter().cannotSetExtraData(comVBox, strKey, value.join(","));
     2261        /* Wipe out old keys: */
     2262        foreach (const QString &strOldKey, g_mapOfObsoleteKeys.values(strKey))
     2263        {
     2264            comVBox.SetExtraData(strOldKey, QString());
     2265            if (!comVBox.isOk())
     2266            {
     2267                msgCenter().cannotSetExtraData(comVBox, strOldKey, value.join(","));
     2268                break;
     2269            }
     2270        }
    22192271    }
    22202272    /* Machine extra-data: */
     
    22422294        if (!comSessionMachine.isOk())
    22432295            msgCenter().cannotSetExtraData(comSessionMachine, strKey, value.join(","));
     2296        /* Wipe out old keys: */
     2297        foreach (const QString &strOldKey, g_mapOfObsoleteKeys.values(strKey))
     2298        {
     2299            comSessionMachine.SetExtraData(strOldKey, QString());
     2300            if (!comSessionMachine.isOk())
     2301            {
     2302                msgCenter().cannotSetExtraData(comSessionMachine, strOldKey, value.join(","));
     2303                break;
     2304            }
     2305        }
    22442306        comSession.UnlockMachine();
    22452307    }
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