VirtualBox

Changeset 51532 in vbox


Ignore:
Timestamp:
Jun 4, 2014 3:07:21 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 6660: Advanced extra-data management framework: Integrate GUI_DetailsPageBoxes.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r51531 r51532  
    747747template<> DetailsElementType fromString<DetailsElementType>(const QString &strDetailsElementType)
    748748{
    749     QHash<QString, DetailsElementType> list;
    750     list.insert(QApplication::translate("VBoxGlobal", "General", "DetailsElementType"),        DetailsElementType_General);
    751     list.insert(QApplication::translate("VBoxGlobal", "Preview", "DetailsElementType"),        DetailsElementType_Preview);
    752     list.insert(QApplication::translate("VBoxGlobal", "System", "DetailsElementType"),         DetailsElementType_System);
    753     list.insert(QApplication::translate("VBoxGlobal", "Display", "DetailsElementType"),        DetailsElementType_Display);
    754     list.insert(QApplication::translate("VBoxGlobal", "Storage", "DetailsElementType"),        DetailsElementType_Storage);
    755     list.insert(QApplication::translate("VBoxGlobal", "Audio", "DetailsElementType"),          DetailsElementType_Audio);
    756     list.insert(QApplication::translate("VBoxGlobal", "Network", "DetailsElementType"),        DetailsElementType_Network);
    757     list.insert(QApplication::translate("VBoxGlobal", "Serial ports", "DetailsElementType"),   DetailsElementType_Serial);
     749    /* Here we have some fancy stuff allowing us
     750     * to search through the keys using 'case-insensitive' rule: */
     751    QStringList keys;                                                                      QList<DetailsElementType> values;
     752    keys << QApplication::translate("VBoxGlobal", "General", "DetailsElementType");        values << DetailsElementType_General;
     753    keys << QApplication::translate("VBoxGlobal", "Preview", "DetailsElementType");        values << DetailsElementType_Preview;
     754    keys << QApplication::translate("VBoxGlobal", "System", "DetailsElementType");         values << DetailsElementType_System;
     755    keys << QApplication::translate("VBoxGlobal", "Display", "DetailsElementType");        values << DetailsElementType_Display;
     756    keys << QApplication::translate("VBoxGlobal", "Storage", "DetailsElementType");        values << DetailsElementType_Storage;
     757    keys << QApplication::translate("VBoxGlobal", "Audio", "DetailsElementType");          values << DetailsElementType_Audio;
     758    keys << QApplication::translate("VBoxGlobal", "Network", "DetailsElementType");        values << DetailsElementType_Network;
     759    keys << QApplication::translate("VBoxGlobal", "Serial ports", "DetailsElementType");   values << DetailsElementType_Serial;
    758760#ifdef VBOX_WITH_PARALLEL_PORTS
    759     list.insert(QApplication::translate("VBoxGlobal", "Parallel ports", "DetailsElementType"), DetailsElementType_Parallel);
     761    keys << QApplication::translate("VBoxGlobal", "Parallel ports", "DetailsElementType"); values << DetailsElementType_Parallel;
    760762#endif /* VBOX_WITH_PARALLEL_PORTS */
    761     list.insert(QApplication::translate("VBoxGlobal", "USB", "DetailsElementType"),            DetailsElementType_USB);
    762     list.insert(QApplication::translate("VBoxGlobal", "Shared folders", "DetailsElementType"), DetailsElementType_SF);
    763     list.insert(QApplication::translate("VBoxGlobal", "Description", "DetailsElementType"),    DetailsElementType_Description);
    764     if (!list.contains(strDetailsElementType))
    765     {
    766         AssertMsgFailed(("No value for '%s'", strDetailsElementType.toAscii().constData()));
    767     }
    768     return list.value(strDetailsElementType);
     763    keys << QApplication::translate("VBoxGlobal", "USB", "DetailsElementType");            values << DetailsElementType_USB;
     764    keys << QApplication::translate("VBoxGlobal", "Shared folders", "DetailsElementType"); values << DetailsElementType_SF;
     765    keys << QApplication::translate("VBoxGlobal", "Description", "DetailsElementType");    values << DetailsElementType_Description;
     766    /* Invalid type for unknown words: */
     767    if (!keys.contains(strDetailsElementType, Qt::CaseInsensitive))
     768        return DetailsElementType_Invalid;
     769    /* Corresponding type for known words: */
     770    return values.at(keys.indexOf(QRegExp(strDetailsElementType, Qt::CaseInsensitive)));
    769771}
    770772
     
    801803template<> DetailsElementType fromInternalString<DetailsElementType>(const QString &strDetailsElementType)
    802804{
    803     QHash<QString, DetailsElementType> list;
    804     list.insert("general",       DetailsElementType_General);
    805     list.insert("preview",       DetailsElementType_Preview);
    806     list.insert("system",        DetailsElementType_System);
    807     list.insert("display",       DetailsElementType_Display);
    808     list.insert("storage",       DetailsElementType_Storage);
    809     list.insert("audio",         DetailsElementType_Audio);
    810     list.insert("network",       DetailsElementType_Network);
    811     list.insert("serialPorts",   DetailsElementType_Serial);
     805    /* Here we have some fancy stuff allowing us
     806     * to search through the keys using 'case-insensitive' rule: */
     807    QStringList keys;        QList<DetailsElementType> values;
     808    keys << "general";       values << DetailsElementType_General;
     809    keys << "preview";       values << DetailsElementType_Preview;
     810    keys << "system";        values << DetailsElementType_System;
     811    keys << "display";       values << DetailsElementType_Display;
     812    keys << "storage";       values << DetailsElementType_Storage;
     813    keys << "audio";         values << DetailsElementType_Audio;
     814    keys << "network";       values << DetailsElementType_Network;
     815    keys << "serialPorts";   values << DetailsElementType_Serial;
    812816#ifdef VBOX_WITH_PARALLEL_PORTS
    813     list.insert("parallelPorts", DetailsElementType_Parallel);
     817    keys << "parallelPorts"; values << DetailsElementType_Parallel;
    814818#endif /* VBOX_WITH_PARALLEL_PORTS */
    815     list.insert("usb",           DetailsElementType_USB);
    816     list.insert("sharedFolders", DetailsElementType_SF);
    817     list.insert("description",   DetailsElementType_Description);
    818     if (!list.contains(strDetailsElementType))
    819     {
    820         AssertMsgFailed(("No value for '%s'", strDetailsElementType.toAscii().constData()));
    821     }
    822     return list.value(strDetailsElementType);
     819    keys << "usb";           values << DetailsElementType_USB;
     820    keys << "sharedFolders"; values << DetailsElementType_SF;
     821    keys << "description";   values << DetailsElementType_Description;
     822    /* Invalid type for unknown words: */
     823    if (!keys.contains(strDetailsElementType, Qt::CaseInsensitive))
     824        return DetailsElementType_Invalid;
     825    /* Corresponding type for known words: */
     826    return values.at(keys.indexOf(QRegExp(strDetailsElementType, Qt::CaseInsensitive)));
    823827}
    824828
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r51531 r51532  
    210210enum DetailsElementType
    211211{
     212    DetailsElementType_Invalid,
    212213    DetailsElementType_General,
    213214    DetailsElementType_System,
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r51531 r51532  
    427427}
    428428
     429QMap<DetailsElementType, bool> UIExtraDataManager::selectorWindowDetailsElements()
     430{
     431    /* Load corresponding extra-data: */
     432    const QStringList data = extraDataStringList(GUI_DetailsPageBoxes);
     433
     434    /* Prepare elements: */
     435    QMap<DetailsElementType, bool> elements;
     436    /* Enumerate all the data items: */
     437    foreach (QString strItem, data)
     438    {
     439        bool fOpened = true;
     440        if (strItem.endsWith("Closed", Qt::CaseInsensitive))
     441        {
     442            fOpened = false;
     443            strItem.remove("Closed");
     444        }
     445        DetailsElementType type = gpConverter->fromInternalString<DetailsElementType>(strItem);
     446        if (type != DetailsElementType_Invalid)
     447            elements[type] = fOpened;
     448    }
     449
     450    /* Return elements: */
     451    return elements;
     452}
     453
     454void UIExtraDataManager::setSelectorWindowDetailsElements(const QMap<DetailsElementType, bool> &elements)
     455{
     456    /* Prepare corresponding extra-data: */
     457    QStringList data;
     458
     459    /* Searialize passed elements: */
     460    foreach (DetailsElementType type, elements.keys())
     461    {
     462        QString strValue = gpConverter->toInternalString(type);
     463        if (!elements[type])
     464            strValue += "Closed";
     465        data << strValue;
     466    }
     467
     468    /* Save corresponding extra-data: */
     469    setExtraDataStringList(GUI_DetailsPageBoxes, data);
     470}
     471
    429472PreviewUpdateIntervalType UIExtraDataManager::selectorWindowPreviewUpdateInterval() const
    430473{
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r51531 r51532  
    151151    /** Defines whether selector-window status-bar @a fVisible. */
    152152    void setSelectorWindowStatusBarVisible(bool fVisible);
     153
     154    /** Returns selector-window details-pane elements. */
     155    QMap<DetailsElementType, bool> selectorWindowDetailsElements();
     156    /** Defines selector-window details-pane @a elements. */
     157    void setSelectorWindowDetailsElements(const QMap<DetailsElementType, bool> &elements);
    153158
    154159    /** Returns selector-window preview update interval. */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.cpp

    r50041 r51532  
    2525#include "UIGDetailsSet.h"
    2626#include "UIGDetailsModel.h"
    27 #include "UIConverter.h"
     27#include "UIExtraDataManager.h"
    2828#include "VBoxGlobal.h"
    2929#include "UIVMItem.h"
     
    196196{
    197197    /* Load settings: */
    198     m_settings = vboxGlobal().virtualBox().GetExtraDataStringList(GUI_DetailsPageBoxes);
     198    m_settings = gEDataManager->selectorWindowDetailsElements();
    199199    /* If settings are empty: */
    200200    if (m_settings.isEmpty())
    201201    {
    202202        /* Propose the defaults: */
    203         m_settings << gpConverter->toInternalString(DetailsElementType_General);
    204         m_settings << gpConverter->toInternalString(DetailsElementType_Preview);
    205         m_settings << gpConverter->toInternalString(DetailsElementType_System);
    206         m_settings << gpConverter->toInternalString(DetailsElementType_Display);
    207         m_settings << gpConverter->toInternalString(DetailsElementType_Storage);
    208         m_settings << gpConverter->toInternalString(DetailsElementType_Audio);
    209         m_settings << gpConverter->toInternalString(DetailsElementType_Network);
    210         m_settings << gpConverter->toInternalString(DetailsElementType_USB);
    211         m_settings << gpConverter->toInternalString(DetailsElementType_SF);
    212         m_settings << gpConverter->toInternalString(DetailsElementType_Description);
    213         vboxGlobal().virtualBox().SetExtraDataStringList(GUI_DetailsPageBoxes, m_settings);
     203        m_settings[DetailsElementType_General] = true;
     204        m_settings[DetailsElementType_Preview] = true;
     205        m_settings[DetailsElementType_System] = true;
     206        m_settings[DetailsElementType_Display] = true;
     207        m_settings[DetailsElementType_Storage] = true;
     208        m_settings[DetailsElementType_Audio] = true;
     209        m_settings[DetailsElementType_Network] = true;
     210        m_settings[DetailsElementType_USB] = true;
     211        m_settings[DetailsElementType_SF] = true;
     212        m_settings[DetailsElementType_Description] = true;
     213        gEDataManager->setSelectorWindowDetailsElements(m_settings);
    214214    }
    215215}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.h

    r50041 r51532  
    2222/* GUI includes: */
    2323#include "UIGDetailsItem.h"
     24#include "UIExtraDataDefs.h"
    2425
    2526/* Forward declarations: */
     
    9697    UIBuildStep *m_pBuildStep;
    9798    QString m_strGroupId;
    98     QStringList m_settings;
     99    QMap<DetailsElementType, bool> m_settings;
    99100
    100101    /* Friends: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.cpp

    r50041 r51532  
    2727#include "UIGDetailsGroup.h"
    2828#include "UIGDetailsElement.h"
     29#include "UIExtraDataManager.h"
    2930#include "VBoxGlobal.h"
    3031#include "UIConverter.h"
     
    156157    updateLayout();
    157158
    158     /* Update details settings: */
    159     QStringList detailsSettings = vboxGlobal().virtualBox().GetExtraDataStringList(GUI_DetailsPageBoxes);
    160     QString strOldElementName = gpConverter->toInternalString(type);
    161     QString strNewElementName = strOldElementName;
    162     if (fToggled)
    163         strOldElementName += "Closed";
    164     else
    165         strNewElementName += "Closed";
    166     int iIndex = detailsSettings.indexOf(strOldElementName);
    167     if (iIndex != -1)
    168     {
    169         detailsSettings[iIndex] = strNewElementName;
    170         vboxGlobal().virtualBox().SetExtraDataStringList(GUI_DetailsPageBoxes, detailsSettings);
     159    /* Load elements settings to modify: */
     160    QMap<DetailsElementType, bool> settings = gEDataManager->selectorWindowDetailsElements();
     161    /* If setting for corresponding element type exists: */
     162    if (settings.contains(type))
     163    {
     164        /* Update element open/close status: */
     165        settings[type] = fToggled;
     166        /* Save elements settings back: */
     167        gEDataManager->setSelectorWindowDetailsElements(settings);
    171168    }
    172169}
     
    176173    /* Which item was toggled? */
    177174    QAction *pAction = qobject_cast<QAction*>(sender());
    178     DetailsElementType elementType = pAction->data().value<DetailsElementType>();
    179     QString strElementTypeOpened = gpConverter->toInternalString(elementType);
    180     QString strElementTypeClosed = strElementTypeOpened + "Closed";
    181     QStringList detailsSettings = vboxGlobal().virtualBox().GetExtraDataStringList(GUI_DetailsPageBoxes);
    182     /* Update details settings: */
    183     bool fElementExists = detailsSettings.contains(strElementTypeOpened) ||
    184                           detailsSettings.contains(strElementTypeClosed);
    185     if (fElementExists)
    186     {
    187         detailsSettings.removeAll(strElementTypeOpened);
    188         detailsSettings.removeAll(strElementTypeClosed);
    189     }
     175    DetailsElementType type = pAction->data().value<DetailsElementType>();
     176
     177    /* Load elements settings to modify: */
     178    QMap<DetailsElementType, bool> settings = gEDataManager->selectorWindowDetailsElements();
     179    /* Toggle element visibility setting: */
     180    if (settings.contains(type))
     181        settings.remove(type);
    190182    else
    191     {
    192         detailsSettings.append(strElementTypeOpened);
    193     }
    194     vboxGlobal().virtualBox().SetExtraDataStringList(GUI_DetailsPageBoxes, detailsSettings);
     183        settings[type] = true;
     184    /* Save elements settings back: */
     185    gEDataManager->setSelectorWindowDetailsElements(settings);
     186
     187    /* Rebuild group: */
    195188    m_pRoot->rebuildGroup();
    196189}
     
    267260    /* Prepare context-menu: */
    268261    QMenu contextMenu;
    269     QStringList detailsSettings = vboxGlobal().virtualBox().GetExtraDataStringList(GUI_DetailsPageBoxes);
     262    /* Load elements settings: */
     263    QMap<DetailsElementType, bool> settings = gEDataManager->selectorWindowDetailsElements();
    270264    for (int iType = DetailsElementType_General; iType <= DetailsElementType_Description; ++iType)
    271265    {
     
    273267        QAction *pAction = contextMenu.addAction(gpConverter->toString(currentElementType), this, SLOT(sltElementTypeToggled()));
    274268        pAction->setCheckable(true);
    275         QString strTypeIdOpened = gpConverter->toInternalString(currentElementType);
    276         QString strTypeIdClosed = strTypeIdOpened + "Closed";
    277         pAction->setChecked(detailsSettings.contains(strTypeIdOpened) || detailsSettings.contains(strTypeIdClosed));
     269        pAction->setChecked(settings.contains(currentElementType));
    278270        pAction->setData(QVariant::fromValue(currentElementType));
    279271    }
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp

    r50907 r51532  
    2323#include "UIGDetailsElements.h"
    2424#include "UIVMItem.h"
    25 #include "UIConverter.h"
    2625#include "UIVirtualBoxEventHandler.h"
    2726#include "VBoxGlobal.h"
     
    5958}
    6059
    61 void UIGDetailsSet::buildSet(UIVMItem *pMachineItem, bool fFullSet, const QStringList &settings)
     60void UIGDetailsSet::buildSet(UIVMItem *pMachineItem, bool fFullSet, const QMap<DetailsElementType, bool> &settings)
    6261{
    6362    /* Remember passed arguments: */
     
    10099    const CUSBDeviceFilters &filters = m_machine.GetUSBDeviceFilters();
    101100    if (filters.isNull() || !m_machine.GetUSBProxyAvailable())
    102     {
    103         QString strElementTypeOpened = gpConverter->toInternalString(DetailsElementType_USB);
    104         QString strElementTypeClosed = strElementTypeOpened + "Closed";
    105         m_settings.removeAll(strElementTypeOpened);
    106         m_settings.removeAll(strElementTypeClosed);
    107     }
     101        m_settings.remove(DetailsElementType_USB);
    108102
    109103    /* Start building set: */
     
    126120        /* Load details settings: */
    127121        DetailsElementType elementType = (DetailsElementType)iStepNumber;
    128         QString strElementTypeOpened = gpConverter->toInternalString(elementType);
    129         QString strElementTypeClosed = strElementTypeOpened + "Closed";
    130122        /* Should the element be visible? */
    131         bool fVisible = m_settings.contains(strElementTypeOpened) || m_settings.contains(strElementTypeClosed);
     123        bool fVisible = m_settings.contains(elementType);
    132124        /* Should the element be opened? */
    133         bool fOpen = m_settings.contains(strElementTypeOpened);
     125        bool fOpen = fVisible && m_settings[elementType];
    134126
    135127        /* Check if element is present already: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.h

    r51187 r51532  
    5252
    5353    /* API: Build stuff: */
    54     void buildSet(UIVMItem *pMachineItem, bool fFullSet, const QStringList &settings);
     54    void buildSet(UIVMItem *pMachineItem, bool fFullSet, const QMap<DetailsElementType, bool> &settings);
    5555
    5656    /* API: Machine stuff: */
     
    123123    int m_iLastStepNumber;
    124124    QString m_strSetId;
    125     QStringList m_settings;
     125    QMap<DetailsElementType, bool> m_settings;
    126126};
    127127
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