VirtualBox

Changeset 46796 in vbox


Ignore:
Timestamp:
Jun 26, 2013 10:58:39 AM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: UI converter: Support string conversions for the runtime-menu-type enum.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r46760 r46796  
    5656/* Declare global canConvert specializations: */
    5757template<> bool canConvert<StorageSlot>();
     58template<> bool canConvert<RuntimeMenuType>();
    5859template<> bool canConvert<DetailsElementType>();
    5960template<> bool canConvert<GlobalSettingsPageType>();
     
    8788template<> QString toString(const StorageSlot &storageSlot);
    8889template<> StorageSlot fromString<StorageSlot>(const QString &strStorageSlot);
     90template<> QString toInternalString(const RuntimeMenuType &runtimeMenuType);
     91template<> RuntimeMenuType fromInternalString<RuntimeMenuType>(const QString &strRuntimeMenuType);
    8992template<> QString toString(const DetailsElementType &detailsElementType);
    9093template<> DetailsElementType fromString<DetailsElementType>(const QString &strDetailsElementType);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r46761 r46796  
    3232 * These functions returns 'true' for all allowed conversions. */
    3333template<> bool canConvert<StorageSlot>() { return true; }
     34template<> bool canConvert<RuntimeMenuType>() { return true; }
    3435template<> bool canConvert<DetailsElementType>() { return true; }
    3536template<> bool canConvert<GlobalSettingsPageType>() { return true; }
     
    264265    }
    265266    return result;
     267}
     268
     269/* QString <= RuntimeMenuType: */
     270template<> QString toInternalString(const RuntimeMenuType &runtimeMenuType)
     271{
     272    QString strResult;
     273    switch (runtimeMenuType)
     274    {
     275        case RuntimeMenuType_Machine: strResult = "Machine"; break;
     276        case RuntimeMenuType_View:    strResult = "View"; break;
     277        case RuntimeMenuType_Devices: strResult = "Devices"; break;
     278        case RuntimeMenuType_Debug:   strResult = "Debug"; break;
     279        case RuntimeMenuType_Help:    strResult = "Help"; break;
     280        case RuntimeMenuType_All:     strResult = "All"; break;
     281        default:
     282        {
     283            AssertMsgFailed(("No text for indicator type=%d", runtimeMenuType));
     284            break;
     285        }
     286    }
     287    return strResult;
     288}
     289
     290/* RuntimeMenuType <= QString: */
     291template<> RuntimeMenuType fromInternalString<RuntimeMenuType>(const QString &strRuntimeMenuType)
     292{
     293    /* Here we have some fancy stuff allowing us
     294     * to search through the keys using 'case-insensitive' rule: */
     295    QStringList keys;  QList<RuntimeMenuType> values;
     296    keys << "Machine"; values << RuntimeMenuType_Machine;
     297    keys << "View";    values << RuntimeMenuType_View;
     298    keys << "Devices"; values << RuntimeMenuType_Devices;
     299    keys << "Debug";   values << RuntimeMenuType_Debug;
     300    keys << "Help";    values << RuntimeMenuType_Help;
     301    keys << "All";     values << RuntimeMenuType_All;
     302    /* Invalid type for unknown words: */
     303    if (!keys.contains(strRuntimeMenuType, Qt::CaseInsensitive))
     304        return RuntimeMenuType_Invalid;
     305    /* Corresponding type for known words: */
     306    return values.at(keys.indexOf(QRegExp(strRuntimeMenuType, Qt::CaseInsensitive)));
    266307}
    267308
     
    553594    return values.at(keys.indexOf(QRegExp(strMachineCloseAction, Qt::CaseInsensitive)));
    554595}
     596
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