VirtualBox

Changeset 66183 in vbox


Ignore:
Timestamp:
Mar 21, 2017 4:26:35 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings: Refactoring some of help-classes like cache related stuff and sub-elements to be in sources, not headers.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r65381 r66183  
    555555        src/selector/UISnapshotPane.cpp \
    556556        src/settings/global/UIGlobalSettingsInput.cpp \
     557        src/settings/machine/UIMachineSettingsNetwork.cpp \
     558        src/settings/machine/UIMachineSettingsParallel.cpp \
     559        src/settings/machine/UIMachineSettingsSerial.cpp \
    557560        src/settings/machine/UIMachineSettingsStorage.cpp \
    558561        src/settings/machine/UIMachineSettingsUSB.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.cpp

    r66163 r66183  
    55
    66/*
    7  * Copyright (C) 2006-2016 Oracle Corporation
     7 * Copyright (C) 2006-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121
    2222/* GUI includes: */
     23# include "UIConverter.h"
    2324# include "UIMachineSettingsAudio.h"
    24 # include "UIConverter.h"
    2525
    2626/* COM includes: */
     
    3030
    3131
     32/** Machine settings: Audio page data structure. */
     33struct UIDataSettingsMachineAudio
     34{
     35    /** Constructs data. */
     36    UIDataSettingsMachineAudio()
     37        : m_fAudioEnabled(false)
     38        , m_audioDriverType(KAudioDriverType_Null)
     39        , m_audioControllerType(KAudioControllerType_AC97)
     40    {}
     41
     42    /** Returns whether the @a other passed data is equal to this one. */
     43    bool equal(const UIDataSettingsMachineAudio &other) const
     44    {
     45        return true
     46               && (m_fAudioEnabled == other.m_fAudioEnabled)
     47               && (m_audioDriverType == other.m_audioDriverType)
     48               && (m_audioControllerType == other.m_audioControllerType)
     49               ;
     50    }
     51
     52    /** Returns whether the @a other passed data is equal to this one. */
     53    bool operator==(const UIDataSettingsMachineAudio &other) const { return equal(other); }
     54    /** Returns whether the @a other passed data is different from this one. */
     55    bool operator!=(const UIDataSettingsMachineAudio &other) const { return !equal(other); }
     56
     57    /** Holds whether the audio is enabled. */
     58    bool                  m_fAudioEnabled;
     59    /** Holds the audio driver type. */
     60    KAudioDriverType      m_audioDriverType;
     61    /** Holds the audio controller type. */
     62    KAudioControllerType  m_audioControllerType;
     63};
     64
     65
    3266UIMachineSettingsAudio::UIMachineSettingsAudio()
     67    : m_pCache(new UISettingsCacheMachineAudio)
    3368{
    3469    /* Prepare: */
     
    3671}
    3772
     73UIMachineSettingsAudio::~UIMachineSettingsAudio()
     74{
     75    /* Cleanup cache: */
     76    delete m_pCache;
     77    m_pCache = 0;
     78}
     79
     80bool UIMachineSettingsAudio::changed() const
     81{
     82    return m_pCache->wasChanged();
     83}
     84
    3885void UIMachineSettingsAudio::loadToCacheFrom(QVariant &data)
    3986{
     
    4289
    4390    /* Clear cache initially: */
    44     m_cache.clear();
     91    m_pCache->clear();
    4592
    4693    /* Prepare audio data: */
     
    58105
    59106    /* Cache audio data: */
    60     m_cache.cacheInitialData(audioData);
     107    m_pCache->cacheInitialData(audioData);
    61108
    62109    /* Upload machine to data: */
     
    67114{
    68115    /* Get audio data from cache: */
    69     const UIDataSettingsMachineAudio &audioData = m_cache.base();
     116    const UIDataSettingsMachineAudio &audioData = m_pCache->base();
    70117
    71118    /* Load audio data to page: */
     
    81128{
    82129    /* Prepare audio data: */
    83     UIDataSettingsMachineAudio audioData = m_cache.base();
     130    UIDataSettingsMachineAudio audioData = m_pCache->base();
    84131
    85132    /* Gather audio data: */
     
    89136
    90137    /* Cache audio data: */
    91     m_cache.cacheCurrentData(audioData);
     138    m_pCache->cacheCurrentData(audioData);
    92139}
    93140
     
    98145
    99146    /* Make sure machine is in 'offline' mode & audio data was changed: */
    100     if (isMachineOffline() && m_cache.wasChanged())
     147    if (isMachineOffline() && m_pCache->wasChanged())
    101148    {
    102149        /* Check if adapter still valid: */
     
    105152        {
    106153            /* Get audio data from cache: */
    107             const UIDataSettingsMachineAudio &audioData = m_cache.data();
     154            const UIDataSettingsMachineAudio &audioData = m_pCache->data();
    108155
    109156            /* Store audio data: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.h

    r66176 r66183  
    2323#include "UIMachineSettingsAudio.gen.h"
    2424
    25 
    26 /** Machine settings: Audio page data structure. */
    27 struct UIDataSettingsMachineAudio
    28 {
    29     /** Constructs data. */
    30     UIDataSettingsMachineAudio()
    31         : m_fAudioEnabled(false)
    32         , m_audioDriverType(KAudioDriverType_Null)
    33         , m_audioControllerType(KAudioControllerType_AC97)
    34     {}
    35 
    36     /** Returns whether the @a other passed data is equal to this one. */
    37     bool equal(const UIDataSettingsMachineAudio &other) const
    38     {
    39         return true
    40                && (m_fAudioEnabled == other.m_fAudioEnabled)
    41                && (m_audioDriverType == other.m_audioDriverType)
    42                && (m_audioControllerType == other.m_audioControllerType)
    43                ;
    44     }
    45 
    46     /** Returns whether the @a other passed data is equal to this one. */
    47     bool operator==(const UIDataSettingsMachineAudio &other) const { return equal(other); }
    48     /** Returns whether the @a other passed data is different from this one. */
    49     bool operator!=(const UIDataSettingsMachineAudio &other) const { return !equal(other); }
    50 
    51     /** Holds whether the audio is enabled. */
    52     bool                  m_fAudioEnabled;
    53     /** Holds the audio driver type. */
    54     KAudioDriverType      m_audioDriverType;
    55     /** Holds the audio controller type. */
    56     KAudioControllerType  m_audioControllerType;
    57 };
     25/* Forward declarations: */
     26struct UIDataSettingsMachineAudio;
    5827typedef UISettingsCache<UIDataSettingsMachineAudio> UISettingsCacheMachineAudio;
    5928
     
    6736public:
    6837
    69     /* Constructor: */
     38    /** Constructs Audio settings page. */
    7039    UIMachineSettingsAudio();
     40    /** Destructs Audio settings page. */
     41    ~UIMachineSettingsAudio();
    7142
    7243protected:
    7344
    7445    /** Returns whether the page content was changed. */
    75     bool changed() const { return m_cache.wasChanged(); }
     46    bool changed() const /* override */;
    7647
    7748    /** Loads data into the cache from corresponding external object(s),
     
    10475    void prepareComboboxes();
    10576
    106     /* Cache: */
    107     UISettingsCacheMachineAudio m_cache;
     77    /** Holds the page data cache instance. */
     78    UISettingsCacheMachineAudio *m_pCache;
    10879};
    10980
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r66163 r66183  
    55
    66/*
    7  * Copyright (C) 2008-2016 Oracle Corporation
     7 * Copyright (C) 2008-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2222/* GUI includes: */
    2323# include "QIWidgetValidator.h"
    24 # include "UIMachineSettingsDisplay.h"
     24# include "UIConverter.h"
    2525# include "UIDesktopWidgetWatchdog.h"
    2626# include "UIExtraDataManager.h"
    27 # include "UIConverter.h"
     27# include "UIMachineSettingsDisplay.h"
    2828# include "VBoxGlobal.h"
    2929
    3030/* COM includes: */
     31# include "CExtPack.h"
     32# include "CExtPackManager.h"
    3133# include "CVRDEServer.h"
    32 # include "CExtPackManager.h"
    33 # include "CExtPack.h"
    3434
    3535#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     36
     37
     38/** Machine settings: Display page data structure. */
     39struct UIDataSettingsMachineDisplay
     40{
     41    /** Constructs data. */
     42    UIDataSettingsMachineDisplay()
     43        : m_iCurrentVRAM(0)
     44        , m_cGuestScreenCount(0)
     45        , m_dScaleFactor(1.0)
     46#ifdef VBOX_WS_MAC
     47        , m_fUseUnscaledHiDPIOutput(false)
     48#endif /* VBOX_WS_MAC */
     49        , m_f3dAccelerationEnabled(false)
     50#ifdef VBOX_WITH_VIDEOHWACCEL
     51        , m_f2dAccelerationEnabled(false)
     52#endif /* VBOX_WITH_VIDEOHWACCEL */
     53        , m_fRemoteDisplayServerSupported(false)
     54        , m_fRemoteDisplayServerEnabled(false)
     55        , m_strRemoteDisplayPort(QString())
     56        , m_remoteDisplayAuthType(KAuthType_Null)
     57        , m_uRemoteDisplayTimeout(0)
     58        , m_fRemoteDisplayMultiConnAllowed(false)
     59        , m_fVideoCaptureEnabled(false)
     60        , m_strVideoCaptureFolder(QString())
     61        , m_strVideoCaptureFilePath(QString())
     62        , m_iVideoCaptureFrameWidth(0)
     63        , m_iVideoCaptureFrameHeight(0)
     64        , m_iVideoCaptureFrameRate(0)
     65        , m_iVideoCaptureBitRate(0)
     66    {}
     67
     68    /** Returns whether the @a other passed data is equal to this one. */
     69    bool equal(const UIDataSettingsMachineDisplay &other) const
     70    {
     71        return true
     72               && (m_iCurrentVRAM == other.m_iCurrentVRAM)
     73               && (m_cGuestScreenCount == other.m_cGuestScreenCount)
     74               && (m_dScaleFactor == other.m_dScaleFactor)
     75#ifdef VBOX_WS_MAC
     76               && (m_fUseUnscaledHiDPIOutput == other.m_fUseUnscaledHiDPIOutput)
     77#endif /* VBOX_WS_MAC */
     78               && (m_f3dAccelerationEnabled == other.m_f3dAccelerationEnabled)
     79#ifdef VBOX_WITH_VIDEOHWACCEL
     80               && (m_f2dAccelerationEnabled == other.m_f2dAccelerationEnabled)
     81#endif /* VBOX_WITH_VIDEOHWACCEL */
     82               && (m_fRemoteDisplayServerSupported == other.m_fRemoteDisplayServerSupported)
     83               && (m_fRemoteDisplayServerEnabled == other.m_fRemoteDisplayServerEnabled)
     84               && (m_strRemoteDisplayPort == other.m_strRemoteDisplayPort)
     85               && (m_remoteDisplayAuthType == other.m_remoteDisplayAuthType)
     86               && (m_uRemoteDisplayTimeout == other.m_uRemoteDisplayTimeout)
     87               && (m_fRemoteDisplayMultiConnAllowed == other.m_fRemoteDisplayMultiConnAllowed)
     88               && (m_fVideoCaptureEnabled == other.m_fVideoCaptureEnabled)
     89               && (m_strVideoCaptureFilePath == other.m_strVideoCaptureFilePath)
     90               && (m_iVideoCaptureFrameWidth == other.m_iVideoCaptureFrameWidth)
     91               && (m_iVideoCaptureFrameHeight == other.m_iVideoCaptureFrameHeight)
     92               && (m_iVideoCaptureFrameRate == other.m_iVideoCaptureFrameRate)
     93               && (m_iVideoCaptureBitRate == other.m_iVideoCaptureBitRate)
     94               && (m_screens == other.m_screens)
     95               ;
     96    }
     97
     98    /** Returns whether the @a other passed data is equal to this one. */
     99    bool operator==(const UIDataSettingsMachineDisplay &other) const { return equal(other); }
     100    /** Returns whether the @a other passed data is different from this one. */
     101    bool operator!=(const UIDataSettingsMachineDisplay &other) const { return !equal(other); }
     102
     103    /** Holds the video RAM amount. */
     104    int     m_iCurrentVRAM;
     105    /** Holds the guest screen count. */
     106    int     m_cGuestScreenCount;
     107    /** Holds the guest screen scale-factor. */
     108    double  m_dScaleFactor;
     109#ifdef VBOX_WS_MAC
     110    /** Holds whether automatic Retina scaling is disabled. */
     111    bool    m_fUseUnscaledHiDPIOutput;
     112#endif /* VBOX_WS_MAC */
     113    /** Holds whether the 3D acceleration is enabled. */
     114    bool    m_f3dAccelerationEnabled;
     115#ifdef VBOX_WITH_VIDEOHWACCEL
     116    /** Holds whether the 2D video acceleration is enabled. */
     117    bool    m_f2dAccelerationEnabled;
     118#endif /* VBOX_WITH_VIDEOHWACCEL */
     119
     120    /** Holds whether the remote display server is supported. */
     121    bool       m_fRemoteDisplayServerSupported;
     122    /** Holds whether the remote display server is enabled. */
     123    bool       m_fRemoteDisplayServerEnabled;
     124    /** Holds the remote display server port. */
     125    QString    m_strRemoteDisplayPort;
     126    /** Holds the remote display server auth type. */
     127    KAuthType  m_remoteDisplayAuthType;
     128    /** Holds the remote display server timeout. */
     129    ulong      m_uRemoteDisplayTimeout;
     130    /** Holds whether the remote display server allows multiple connections. */
     131    bool       m_fRemoteDisplayMultiConnAllowed;
     132
     133    /** Holds whether the video capture is enabled. */
     134    bool m_fVideoCaptureEnabled;
     135    /** Holds the video capture folder. */
     136    QString m_strVideoCaptureFolder;
     137    /** Holds the video capture file path. */
     138    QString m_strVideoCaptureFilePath;
     139    /** Holds the video capture frame width. */
     140    int m_iVideoCaptureFrameWidth;
     141    /** Holds the video capture frame height. */
     142    int m_iVideoCaptureFrameHeight;
     143    /** Holds the video capture frame rate. */
     144    int m_iVideoCaptureFrameRate;
     145    /** Holds the video capture bit rate. */
     146    int m_iVideoCaptureBitRate;
     147    /** Holds which of the guest screens should be captured. */
     148    QVector<BOOL> m_screens;
     149};
     150
    36151
    37152UIMachineSettingsDisplay::UIMachineSettingsDisplay()
     
    46161    , m_fWddmModeSupported(false)
    47162#endif /* VBOX_WITH_CRHGSMI */
     163    , m_pCache(new UISettingsCacheMachineDisplay)
    48164{
    49165    /* Prepare: */
    50166    prepare();
     167}
     168
     169UIMachineSettingsDisplay::~UIMachineSettingsDisplay()
     170{
     171    /* Cleanup cache: */
     172    delete m_pCache;
     173    m_pCache = 0;
    51174}
    52175
     
    85208#endif /* VBOX_WITH_VIDEOHWACCEL */
    86209
     210bool UIMachineSettingsDisplay::changed() const
     211{
     212    return m_pCache->wasChanged();
     213}
     214
    87215void UIMachineSettingsDisplay::loadToCacheFrom(QVariant &data)
    88216{
     
    91219
    92220    /* Clear cache initially: */
    93     m_cache.clear();
     221    m_pCache->clear();
    94222
    95223    /* Prepare display data: */
     
    135263
    136264    /* Cache display data: */
    137     m_cache.cacheInitialData(displayData);
     265    m_pCache->cacheInitialData(displayData);
    138266
    139267    /* Upload machine to data: */
     
    144272{
    145273    /* Get display data from cache: */
    146     const UIDataSettingsMachineDisplay &displayData = m_cache.base();
     274    const UIDataSettingsMachineDisplay &displayData = m_pCache->base();
    147275
    148276    /* Load Screen data to page: */
     
    190318{
    191319    /* Prepare display data: */
    192     UIDataSettingsMachineDisplay displayData = m_cache.base();
     320    UIDataSettingsMachineDisplay displayData = m_pCache->base();
    193321
    194322    /* Gather Screen data from page: */
     
    225353
    226354    /* Cache display data: */
    227     m_cache.cacheCurrentData(displayData);
     355    m_pCache->cacheCurrentData(displayData);
    228356}
    229357
     
    234362
    235363    /* Make sure machine is in valid mode & display data was changed: */
    236     if (isMachineInValidMode() && m_cache.wasChanged())
     364    if (isMachineInValidMode() && m_pCache->wasChanged())
    237365    {
    238366        /* Get display data from cache: */
    239         const UIDataSettingsMachineDisplay &displayData = m_cache.data();
     367        const UIDataSettingsMachineDisplay &displayData = m_pCache->data();
    240368
    241369        /* Store Screen data: */
     
    275403        {
    276404            /* If Video Capture is *enabled* now: */
    277             if (m_cache.base().m_fVideoCaptureEnabled)
     405            if (m_pCache->base().m_fVideoCaptureEnabled)
    278406            {
    279407                /* We can still save the *screens* option: */
     
    507635{
    508636    /* Get system data from cache: */
    509     const UIDataSettingsMachineDisplay &displayData = m_cache.base();
     637    const UIDataSettingsMachineDisplay &displayData = m_pCache->base();
    510638
    511639    /* Screen tab: */
     
    630758     * 2. Machine is in 'online' state, check-box is checked, and video recording is *disabled* currently. */
    631759    bool fIsVideoCaptureOptionsEnabled = ((isMachineOffline() || isMachineSaved()) && m_pCheckboxVideoCapture->isChecked()) ||
    632                                          (isMachineOnline() && !m_cache.base().m_fVideoCaptureEnabled && m_pCheckboxVideoCapture->isChecked());
     760                                         (isMachineOnline() && !m_pCache->base().m_fVideoCaptureEnabled && m_pCheckboxVideoCapture->isChecked());
    633761
    634762    /* Video Capture Screens option should be enabled only if:
     
    10021130{
    10031131    /* Update copy of the cached item to get the desired result: */
    1004     QVector<BOOL> screens = m_cache.base().m_screens;
     1132    QVector<BOOL> screens = m_pCache->base().m_screens;
    10051133    screens.resize(m_pEditorVideoScreenCount->value());
    10061134    m_pScrollerVideoCaptureScreens->setValue(screens);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r66176 r66183  
    2828/* Forward declarations: */
    2929class UIActionPool;
    30 
    31 
    32 /** Machine settings: Display page data structure. */
    33 struct UIDataSettingsMachineDisplay
    34 {
    35     /** Constructs data. */
    36     UIDataSettingsMachineDisplay()
    37         : m_iCurrentVRAM(0)
    38         , m_cGuestScreenCount(0)
    39         , m_dScaleFactor(1.0)
    40 #ifdef VBOX_WS_MAC
    41         , m_fUseUnscaledHiDPIOutput(false)
    42 #endif /* VBOX_WS_MAC */
    43         , m_f3dAccelerationEnabled(false)
    44 #ifdef VBOX_WITH_VIDEOHWACCEL
    45         , m_f2dAccelerationEnabled(false)
    46 #endif /* VBOX_WITH_VIDEOHWACCEL */
    47         , m_fRemoteDisplayServerSupported(false)
    48         , m_fRemoteDisplayServerEnabled(false)
    49         , m_strRemoteDisplayPort(QString())
    50         , m_remoteDisplayAuthType(KAuthType_Null)
    51         , m_uRemoteDisplayTimeout(0)
    52         , m_fRemoteDisplayMultiConnAllowed(false)
    53         , m_fVideoCaptureEnabled(false)
    54         , m_strVideoCaptureFolder(QString())
    55         , m_strVideoCaptureFilePath(QString())
    56         , m_iVideoCaptureFrameWidth(0)
    57         , m_iVideoCaptureFrameHeight(0)
    58         , m_iVideoCaptureFrameRate(0)
    59         , m_iVideoCaptureBitRate(0)
    60     {}
    61 
    62     /** Returns whether the @a other passed data is equal to this one. */
    63     bool equal(const UIDataSettingsMachineDisplay &other) const
    64     {
    65         return true
    66                && (m_iCurrentVRAM == other.m_iCurrentVRAM)
    67                && (m_cGuestScreenCount == other.m_cGuestScreenCount)
    68                && (m_dScaleFactor == other.m_dScaleFactor)
    69 #ifdef VBOX_WS_MAC
    70                && (m_fUseUnscaledHiDPIOutput == other.m_fUseUnscaledHiDPIOutput)
    71 #endif /* VBOX_WS_MAC */
    72                && (m_f3dAccelerationEnabled == other.m_f3dAccelerationEnabled)
    73 #ifdef VBOX_WITH_VIDEOHWACCEL
    74                && (m_f2dAccelerationEnabled == other.m_f2dAccelerationEnabled)
    75 #endif /* VBOX_WITH_VIDEOHWACCEL */
    76                && (m_fRemoteDisplayServerSupported == other.m_fRemoteDisplayServerSupported)
    77                && (m_fRemoteDisplayServerEnabled == other.m_fRemoteDisplayServerEnabled)
    78                && (m_strRemoteDisplayPort == other.m_strRemoteDisplayPort)
    79                && (m_remoteDisplayAuthType == other.m_remoteDisplayAuthType)
    80                && (m_uRemoteDisplayTimeout == other.m_uRemoteDisplayTimeout)
    81                && (m_fRemoteDisplayMultiConnAllowed == other.m_fRemoteDisplayMultiConnAllowed)
    82                && (m_fVideoCaptureEnabled == other.m_fVideoCaptureEnabled)
    83                && (m_strVideoCaptureFilePath == other.m_strVideoCaptureFilePath)
    84                && (m_iVideoCaptureFrameWidth == other.m_iVideoCaptureFrameWidth)
    85                && (m_iVideoCaptureFrameHeight == other.m_iVideoCaptureFrameHeight)
    86                && (m_iVideoCaptureFrameRate == other.m_iVideoCaptureFrameRate)
    87                && (m_iVideoCaptureBitRate == other.m_iVideoCaptureBitRate)
    88                && (m_screens == other.m_screens)
    89                ;
    90     }
    91 
    92     /** Returns whether the @a other passed data is equal to this one. */
    93     bool operator==(const UIDataSettingsMachineDisplay &other) const { return equal(other); }
    94     /** Returns whether the @a other passed data is different from this one. */
    95     bool operator!=(const UIDataSettingsMachineDisplay &other) const { return !equal(other); }
    96 
    97     /** Holds the video RAM amount. */
    98     int     m_iCurrentVRAM;
    99     /** Holds the guest screen count. */
    100     int     m_cGuestScreenCount;
    101     /** Holds the guest screen scale-factor. */
    102     double  m_dScaleFactor;
    103 #ifdef VBOX_WS_MAC
    104     /** Holds whether automatic Retina scaling is disabled. */
    105     bool    m_fUseUnscaledHiDPIOutput;
    106 #endif /* VBOX_WS_MAC */
    107     /** Holds whether the 3D acceleration is enabled. */
    108     bool    m_f3dAccelerationEnabled;
    109 #ifdef VBOX_WITH_VIDEOHWACCEL
    110     /** Holds whether the 2D video acceleration is enabled. */
    111     bool    m_f2dAccelerationEnabled;
    112 #endif /* VBOX_WITH_VIDEOHWACCEL */
    113 
    114     /** Holds whether the remote display server is supported. */
    115     bool       m_fRemoteDisplayServerSupported;
    116     /** Holds whether the remote display server is enabled. */
    117     bool       m_fRemoteDisplayServerEnabled;
    118     /** Holds the remote display server port. */
    119     QString    m_strRemoteDisplayPort;
    120     /** Holds the remote display server auth type. */
    121     KAuthType  m_remoteDisplayAuthType;
    122     /** Holds the remote display server timeout. */
    123     ulong      m_uRemoteDisplayTimeout;
    124     /** Holds whether the remote display server allows multiple connections. */
    125     bool       m_fRemoteDisplayMultiConnAllowed;
    126 
    127     /** Holds whether the video capture is enabled. */
    128     bool m_fVideoCaptureEnabled;
    129     /** Holds the video capture folder. */
    130     QString m_strVideoCaptureFolder;
    131     /** Holds the video capture file path. */
    132     QString m_strVideoCaptureFilePath;
    133     /** Holds the video capture frame width. */
    134     int m_iVideoCaptureFrameWidth;
    135     /** Holds the video capture frame height. */
    136     int m_iVideoCaptureFrameHeight;
    137     /** Holds the video capture frame rate. */
    138     int m_iVideoCaptureFrameRate;
    139     /** Holds the video capture bit rate. */
    140     int m_iVideoCaptureBitRate;
    141     /** Holds which of the guest screens should be captured. */
    142     QVector<BOOL> m_screens;
    143 };
     30struct UIDataSettingsMachineDisplay;
    14431typedef UISettingsCache<UIDataSettingsMachineDisplay> UISettingsCacheMachineDisplay;
    14532
     
    15340public:
    15441
    155     /** Constructor. */
     42    /** Constructs Display settings page. */
    15643    UIMachineSettingsDisplay();
     44    /** Destructs Display settings page. */
     45    ~UIMachineSettingsDisplay();
    15746
    15847    /* API: Correlation stuff: */
     
    16554
    16655    /** Returns whether the page content was changed. */
    167     bool changed() const { return m_cache.wasChanged(); }
     56    bool changed() const /* override */;
    16857
    16958    /** Loads data into the cache from corresponding external object(s),
     
    259148#endif /* VBOX_WITH_CRHGSMI */
    260149
    261     /* Cache: */
    262     UISettingsCacheMachineDisplay m_cache;
     150    /** Holds the page data cache instance. */
     151    UISettingsCacheMachineDisplay *m_pCache;
    263152};
    264153
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r62493 r66183  
    55
    66/*
    7  * Copyright (C) 2006-2016 Oracle Corporation
     7 * Copyright (C) 2006-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919# include <precomp.h>
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
     21
    2122/* Qt includes: */
    2223# include <QDir>
    2324# include <QLineEdit>
     25
    2426/* GUI includes: */
    2527# include "QIWidgetValidator.h"
     28# include "UIConverter.h"
    2629# include "UIMachineSettingsGeneral.h"
     30# include "UIMessageCenter.h"
    2731# include "UIModalWindowManager.h"
    2832# include "UIProgressDialog.h"
    29 # include "UIMessageCenter.h"
    30 # include "UIConverter.h"
     33
    3134/* COM includes: */
    32 # include "CMedium.h"
    3335# include "CExtPack.h"
    3436# include "CExtPackManager.h"
     37# include "CMedium.h"
    3538# include "CMediumAttachment.h"
     39
    3640#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     41
     42
     43/** Machine settings: General page data structure. */
     44struct UIDataSettingsMachineGeneral
     45{
     46    /** Constructs data. */
     47    UIDataSettingsMachineGeneral()
     48        : m_strName(QString())
     49        , m_strGuestOsTypeId(QString())
     50        , m_strSnapshotsFolder(QString())
     51        , m_strSnapshotsHomeDir(QString())
     52        , m_clipboardMode(KClipboardMode_Disabled)
     53        , m_dndMode(KDnDMode_Disabled)
     54        , m_strDescription(QString())
     55        , m_fEncryptionEnabled(false)
     56        , m_fEncryptionCipherChanged(false)
     57        , m_fEncryptionPasswordChanged(false)
     58        , m_iEncryptionCipherIndex(-1)
     59        , m_strEncryptionPassword(QString())
     60    {}
     61
     62    /** Returns whether the @a other passed data is equal to this one. */
     63    bool equal(const UIDataSettingsMachineGeneral &other) const
     64    {
     65        return true
     66               && (m_strName == other.m_strName)
     67               && (m_strGuestOsTypeId == other.m_strGuestOsTypeId)
     68               && (m_strSnapshotsFolder == other.m_strSnapshotsFolder)
     69               && (m_strSnapshotsHomeDir == other.m_strSnapshotsHomeDir)
     70               && (m_clipboardMode == other.m_clipboardMode)
     71               && (m_dndMode == other.m_dndMode)
     72               && (m_strDescription == other.m_strDescription)
     73               && (m_fEncryptionEnabled == other.m_fEncryptionEnabled)
     74               && (m_fEncryptionCipherChanged == other.m_fEncryptionCipherChanged)
     75               && (m_fEncryptionPasswordChanged == other.m_fEncryptionPasswordChanged)
     76               ;
     77    }
     78
     79    /** Returns whether the @a other passed data is equal to this one. */
     80    bool operator==(const UIDataSettingsMachineGeneral &other) const { return equal(other); }
     81    /** Returns whether the @a other passed data is different from this one. */
     82    bool operator!=(const UIDataSettingsMachineGeneral &other) const { return !equal(other); }
     83
     84    /** Holds the VM name. */
     85    QString  m_strName;
     86    /** Holds the VM OS type ID. */
     87    QString  m_strGuestOsTypeId;
     88
     89    /** Holds the VM snapshot folder. */
     90    QString         m_strSnapshotsFolder;
     91    /** Holds the default VM snapshot folder. */
     92    QString         m_strSnapshotsHomeDir;
     93    /** Holds the VM shared clipboard mode. */
     94    KClipboardMode  m_clipboardMode;
     95    /** Holds the VM drag&drop mode. */
     96    KDnDMode        m_dndMode;
     97
     98    /** Holds the VM description. */
     99    QString  m_strDescription;
     100
     101    /** Holds whether the encryption is enabled. */
     102    bool                   m_fEncryptionEnabled;
     103    /** Holds whether the encryption cipher was changed. */
     104    bool                   m_fEncryptionCipherChanged;
     105    /** Holds whether the encryption password was changed. */
     106    bool                   m_fEncryptionPasswordChanged;
     107    /** Holds the encryption cipher index. */
     108    int                    m_iEncryptionCipherIndex;
     109    /** Holds the encryption password. */
     110    QString                m_strEncryptionPassword;
     111    /** Holds the encrypted medium ids. */
     112    EncryptedMediumMap     m_encryptedMediums;
     113    /** Holds the encryption passwords. */
     114    EncryptionPasswordMap  m_encryptionPasswords;
     115};
     116
    37117
    38118UIMachineSettingsGeneral::UIMachineSettingsGeneral()
     
    40120    , m_fEncryptionCipherChanged(false)
    41121    , m_fEncryptionPasswordChanged(false)
     122    , m_pCache(new UISettingsCacheMachineGeneral)
    42123{
    43124    /* Prepare: */
     
    46127    /* Translate: */
    47128    retranslateUi();
     129}
     130
     131UIMachineSettingsGeneral::~UIMachineSettingsGeneral()
     132{
     133    /* Cleanup cache: */
     134    delete m_pCache;
     135    m_pCache = 0;
    48136}
    49137
     
    81169}
    82170
     171bool UIMachineSettingsGeneral::changed() const
     172{
     173    return m_pCache->wasChanged();
     174}
     175
    83176void UIMachineSettingsGeneral::loadToCacheFrom(QVariant &data)
    84177{
     
    87180
    88181    /* Clear cache initially: */
    89     m_cache.clear();
     182    m_pCache->clear();
    90183
    91184    /* Prepare general data: */
     
    143236
    144237    /* Cache general data: */
    145     m_cache.cacheInitialData(generalData);
     238    m_pCache->cacheInitialData(generalData);
    146239
    147240    /* Upload machine to data: */
     
    152245{
    153246    /* Get general data from cache: */
    154     const UIDataSettingsMachineGeneral &generalData = m_cache.base();
     247    const UIDataSettingsMachineGeneral &generalData = m_pCache->base();
    155248
    156249    /* 'Basic' tab data: */
     
    190283{
    191284    /* Prepare general data: */
    192     UIDataSettingsMachineGeneral generalData = m_cache.base();
     285    UIDataSettingsMachineGeneral generalData = m_pCache->base();
    193286
    194287    /* 'Basic' tab data: */
     
    220313    generalData.m_strEncryptionPassword = m_pEditorEncryptionPassword->text();
    221314    /* If encryption status, cipher or password is changed: */
    222     if (generalData.m_fEncryptionEnabled != m_cache.base().m_fEncryptionEnabled ||
    223         generalData.m_fEncryptionCipherChanged != m_cache.base().m_fEncryptionCipherChanged ||
    224         generalData.m_fEncryptionPasswordChanged != m_cache.base().m_fEncryptionPasswordChanged)
     315    if (generalData.m_fEncryptionEnabled != m_pCache->base().m_fEncryptionEnabled ||
     316        generalData.m_fEncryptionCipherChanged != m_pCache->base().m_fEncryptionCipherChanged ||
     317        generalData.m_fEncryptionPasswordChanged != m_pCache->base().m_fEncryptionPasswordChanged)
    225318    {
    226319        /* Ask for the disk encryption passwords if necessary: */
    227         if (!m_cache.base().m_encryptedMediums.isEmpty())
     320        if (!m_pCache->base().m_encryptedMediums.isEmpty())
    228321        {
    229322            /* Create corresponding dialog: */
     
    243336
    244337    /* Cache general data: */
    245     m_cache.cacheCurrentData(generalData);
     338    m_pCache->cacheCurrentData(generalData);
    246339}
    247340
     
    252345
    253346    /* Check if general data was changed: */
    254     if (m_cache.wasChanged())
     347    if (m_pCache->wasChanged())
    255348    {
    256349        /* Get general data from cache: */
    257         const UIDataSettingsMachineGeneral &generalData = m_cache.data();
     350        const UIDataSettingsMachineGeneral &generalData = m_pCache->data();
    258351
    259352        if (isMachineInValidMode())
    260353        {
    261354            /* 'Advanced' tab data: */
    262             if (generalData.m_clipboardMode != m_cache.base().m_clipboardMode)
     355            if (generalData.m_clipboardMode != m_pCache->base().m_clipboardMode)
    263356                m_machine.SetClipboardMode(generalData.m_clipboardMode);
    264             if (generalData.m_dndMode != m_cache.base().m_dndMode)
     357            if (generalData.m_dndMode != m_pCache->base().m_dndMode)
    265358                m_machine.SetDnDMode(generalData.m_dndMode);
    266359
    267360            /* 'Description' tab: */
    268             if (generalData.m_strDescription != m_cache.base().m_strDescription)
     361            if (generalData.m_strDescription != m_pCache->base().m_strDescription)
    269362                m_machine.SetDescription(generalData.m_strDescription);
    270363        }
     
    273366        {
    274367            /* 'Basic' tab data: Must update long mode CPU feature bit when os type changes. */
    275             if (generalData.m_strGuestOsTypeId != m_cache.base().m_strGuestOsTypeId)
     368            if (generalData.m_strGuestOsTypeId != m_pCache->base().m_strGuestOsTypeId)
    276369            {
    277370                m_machine.SetOSTypeId(generalData.m_strGuestOsTypeId);
     
    282375
    283376            /* 'Advanced' tab data: */
    284             if (generalData.m_strSnapshotsFolder != m_cache.base().m_strSnapshotsFolder)
     377            if (generalData.m_strSnapshotsFolder != m_pCache->base().m_strSnapshotsFolder)
    285378                m_machine.SetSnapshotFolder(generalData.m_strSnapshotsFolder);
    286379
     
    289382             * can collide with other settings in the config,
    290383             * especially with the snapshot folder: */
    291             if (generalData.m_strName != m_cache.base().m_strName)
     384            if (generalData.m_strName != m_pCache->base().m_strName)
    292385                m_machine.SetName(generalData.m_strName);
    293386
     
    295388             * Make sure it either encryption is changed itself,
    296389             * or the encryption was already enabled and either cipher or password is changed. */
    297             if (   generalData.m_fEncryptionEnabled != m_cache.base().m_fEncryptionEnabled
    298                 || (   m_cache.base().m_fEncryptionEnabled
    299                     && (   generalData.m_fEncryptionCipherChanged != m_cache.base().m_fEncryptionCipherChanged
    300                         || generalData.m_fEncryptionPasswordChanged != m_cache.base().m_fEncryptionPasswordChanged)))
     390            if (   generalData.m_fEncryptionEnabled != m_pCache->base().m_fEncryptionEnabled
     391                || (   m_pCache->base().m_fEncryptionEnabled
     392                    && (   generalData.m_fEncryptionCipherChanged != m_pCache->base().m_fEncryptionCipherChanged
     393                        || generalData.m_fEncryptionPasswordChanged != m_pCache->base().m_fEncryptionPasswordChanged)))
    301394            {
    302395                /* Cipher attribute changed? */
     
    418511        /* Cipher should be chosen if once changed: */
    419512        AssertPtrReturn(m_pComboCipher, false);
    420         if (!m_cache.base().m_fEncryptionEnabled ||
     513        if (!m_pCache->base().m_fEncryptionEnabled ||
    421514            m_fEncryptionCipherChanged)
    422515        {
     
    429522        AssertPtrReturn(m_pEditorEncryptionPassword, false);
    430523        AssertPtrReturn(m_pEditorEncryptionPasswordConfirm, false);
    431         if (!m_cache.base().m_fEncryptionEnabled ||
     524        if (!m_pCache->base().m_fEncryptionEnabled ||
    432525            m_fEncryptionPasswordChanged)
    433526        {
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r66176 r66183  
    2020
    2121/* GUI includes: */
     22#include "UIAddDiskEncryptionPasswordDialog.h"
    2223#include "UISettingsPage.h"
    2324#include "UIMachineSettingsGeneral.gen.h"
    24 #include "UIAddDiskEncryptionPasswordDialog.h"
    2525
    26 
    27 /** Machine settings: General page data structure. */
    28 struct UIDataSettingsMachineGeneral
    29 {
    30     /** Constructs data. */
    31     UIDataSettingsMachineGeneral()
    32         : m_strName(QString())
    33         , m_strGuestOsTypeId(QString())
    34         , m_strSnapshotsFolder(QString())
    35         , m_strSnapshotsHomeDir(QString())
    36         , m_clipboardMode(KClipboardMode_Disabled)
    37         , m_dndMode(KDnDMode_Disabled)
    38         , m_strDescription(QString())
    39         , m_fEncryptionEnabled(false)
    40         , m_fEncryptionCipherChanged(false)
    41         , m_fEncryptionPasswordChanged(false)
    42         , m_iEncryptionCipherIndex(-1)
    43         , m_strEncryptionPassword(QString())
    44     {}
    45 
    46     /** Returns whether the @a other passed data is equal to this one. */
    47     bool equal(const UIDataSettingsMachineGeneral &other) const
    48     {
    49         return true
    50                && (m_strName == other.m_strName)
    51                && (m_strGuestOsTypeId == other.m_strGuestOsTypeId)
    52                && (m_strSnapshotsFolder == other.m_strSnapshotsFolder)
    53                && (m_strSnapshotsHomeDir == other.m_strSnapshotsHomeDir)
    54                && (m_clipboardMode == other.m_clipboardMode)
    55                && (m_dndMode == other.m_dndMode)
    56                && (m_strDescription == other.m_strDescription)
    57                && (m_fEncryptionEnabled == other.m_fEncryptionEnabled)
    58                && (m_fEncryptionCipherChanged == other.m_fEncryptionCipherChanged)
    59                && (m_fEncryptionPasswordChanged == other.m_fEncryptionPasswordChanged)
    60                ;
    61     }
    62 
    63     /** Returns whether the @a other passed data is equal to this one. */
    64     bool operator==(const UIDataSettingsMachineGeneral &other) const { return equal(other); }
    65     /** Returns whether the @a other passed data is different from this one. */
    66     bool operator!=(const UIDataSettingsMachineGeneral &other) const { return !equal(other); }
    67 
    68     /** Holds the VM name. */
    69     QString  m_strName;
    70     /** Holds the VM OS type ID. */
    71     QString  m_strGuestOsTypeId;
    72 
    73     /** Holds the VM snapshot folder. */
    74     QString         m_strSnapshotsFolder;
    75     /** Holds the default VM snapshot folder. */
    76     QString         m_strSnapshotsHomeDir;
    77     /** Holds the VM shared clipboard mode. */
    78     KClipboardMode  m_clipboardMode;
    79     /** Holds the VM drag&drop mode. */
    80     KDnDMode        m_dndMode;
    81 
    82     /** Holds the VM description. */
    83     QString  m_strDescription;
    84 
    85     /** Holds whether the encryption is enabled. */
    86     bool                   m_fEncryptionEnabled;
    87     /** Holds whether the encryption cipher was changed. */
    88     bool                   m_fEncryptionCipherChanged;
    89     /** Holds whether the encryption password was changed. */
    90     bool                   m_fEncryptionPasswordChanged;
    91     /** Holds the encryption cipher index. */
    92     int                    m_iEncryptionCipherIndex;
    93     /** Holds the encryption password. */
    94     QString                m_strEncryptionPassword;
    95     /** Holds the encrypted medium ids. */
    96     EncryptedMediumMap     m_encryptedMediums;
    97     /** Holds the encryption passwords. */
    98     EncryptionPasswordMap  m_encryptionPasswords;
    99 };
     26/* Forward declarations: */
     27struct UIDataSettingsMachineGeneral;
    10028typedef UISettingsCache<UIDataSettingsMachineGeneral> UISettingsCacheMachineGeneral;
    10129
     
    10937public:
    11038
    111     /** Constructor. */
     39    /** Constructs General settings page. */
    11240    UIMachineSettingsGeneral();
     41    /** Destructs General settings page. */
     42    ~UIMachineSettingsGeneral();
    11343
    11444    /** Returns the VM OS type ID. */
     
    12656protected:
    12757
     58    /** Returns whether the page content was changed. */
     59    bool changed() const /* override */;
     60
    12861    /** Loads data into the cache from the corresponding external object(s).
    12962      * @note This task COULD be performed in other than GUI thread. */
     
    13265      * @note This task SHOULD be performed in GUI thread only! */
    13366    void getFromCache();
    134 
    135     /** Returns whether the page was changed: */
    136     bool changed() const { return m_cache.wasChanged(); }
    13767
    13868    /** Saves the data from the corresponding widgets into the cache,
     
    175105    void polishPage();
    176106
    177     /** Holds the page cache. */
    178     UISettingsCacheMachineGeneral m_cache;
    179 
    180107    /** Holds whether HW virtualization extension is enabled. */
    181108    bool m_fHWVirtExEnabled;
     
    193120      * We are hard-coding it because there is no place we can get it from. */
    194121    QStringList m_encryptionCiphers;
     122
     123    /** Holds the page data cache instance. */
     124    UISettingsCacheMachineGeneral *m_pCache;
    195125};
    196126
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.cpp

    r66163 r66183  
    55
    66/*
    7  * Copyright (C) 2008-2016 Oracle Corporation
     7 * Copyright (C) 2008-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121
    2222/* GUI includes: */
     23# include "UIActionPool.h"
     24# include "UIExtraDataManager.h"
    2325# include "UIMachineSettingsInterface.h"
    24 # include "UIExtraDataManager.h"
    25 # include "UIActionPool.h"
    2626
    2727#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     28
     29
     30/** Machine settings: User Interface page data structure. */
     31struct UIDataSettingsMachineInterface
     32{
     33    /** Constructs data. */
     34    UIDataSettingsMachineInterface()
     35        : m_fStatusBarEnabled(false)
     36#ifndef VBOX_WS_MAC
     37        , m_fMenuBarEnabled(false)
     38#endif /* !VBOX_WS_MAC */
     39        , m_restrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType_Invalid)
     40        , m_restrictionsOfMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Invalid)
     41        , m_restrictionsOfMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid)
     42        , m_restrictionsOfMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid)
     43        , m_restrictionsOfMenuInput(UIExtraDataMetaDefs::RuntimeMenuInputActionType_Invalid)
     44        , m_restrictionsOfMenuDevices(UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid)
     45#ifdef VBOX_WITH_DEBUGGER_GUI
     46        , m_restrictionsOfMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Invalid)
     47#endif /* VBOX_WITH_DEBUGGER_GUI */
     48#ifdef VBOX_WS_MAC
     49        , m_restrictionsOfMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Invalid)
     50#endif /* VBOX_WS_MAC */
     51        , m_restrictionsOfMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Invalid)
     52#ifndef VBOX_WS_MAC
     53        , m_fShowMiniToolBar(false)
     54        , m_fMiniToolBarAtTop(false)
     55#endif /* !VBOX_WS_MAC */
     56    {}
     57
     58    /** Returns whether the @a other passed data is equal to this one. */
     59    bool equal(const UIDataSettingsMachineInterface &other) const
     60    {
     61        return true
     62               && (m_fStatusBarEnabled == other.m_fStatusBarEnabled)
     63               && (m_statusBarRestrictions == other.m_statusBarRestrictions)
     64               && (m_statusBarOrder == other.m_statusBarOrder)
     65#ifndef VBOX_WS_MAC
     66               && (m_fMenuBarEnabled == other.m_fMenuBarEnabled)
     67#endif /* !VBOX_WS_MAC */
     68               && (m_restrictionsOfMenuBar == other.m_restrictionsOfMenuBar)
     69               && (m_restrictionsOfMenuApplication == other.m_restrictionsOfMenuApplication)
     70               && (m_restrictionsOfMenuMachine == other.m_restrictionsOfMenuMachine)
     71               && (m_restrictionsOfMenuView == other.m_restrictionsOfMenuView)
     72               && (m_restrictionsOfMenuInput == other.m_restrictionsOfMenuInput)
     73               && (m_restrictionsOfMenuDevices == other.m_restrictionsOfMenuDevices)
     74#ifdef VBOX_WITH_DEBUGGER_GUI
     75               && (m_restrictionsOfMenuDebug == other.m_restrictionsOfMenuDebug)
     76#endif /* VBOX_WITH_DEBUGGER_GUI */
     77#ifdef VBOX_WS_MAC
     78               && (m_restrictionsOfMenuWindow == other.m_restrictionsOfMenuWindow)
     79#endif /* VBOX_WS_MAC */
     80               && (m_restrictionsOfMenuHelp == other.m_restrictionsOfMenuHelp)
     81#ifndef VBOX_WS_MAC
     82               && (m_fShowMiniToolBar == other.m_fShowMiniToolBar)
     83               && (m_fMiniToolBarAtTop == other.m_fMiniToolBarAtTop)
     84#endif /* !VBOX_WS_MAC */
     85               ;
     86    }
     87
     88    /** Returns whether the @a other passed data is equal to this one. */
     89    bool operator==(const UIDataSettingsMachineInterface &other) const { return equal(other); }
     90    /** Returns whether the @a other passed data is different from this one. */
     91    bool operator!=(const UIDataSettingsMachineInterface &other) const { return !equal(other); }
     92
     93    /** Holds whether the status-bar is enabled. */
     94    bool                  m_fStatusBarEnabled;
     95    /** Holds the status-bar indicator restrictions. */
     96    QList<IndicatorType>  m_statusBarRestrictions;
     97    /** Holds the status-bar indicator order. */
     98    QList<IndicatorType>  m_statusBarOrder;
     99
     100#ifndef VBOX_WS_MAC
     101    /** Holds whether the menu-bar is enabled. */
     102    bool                                                m_fMenuBarEnabled;
     103#endif /* !VBOX_WS_MAC */
     104    /** Holds the menu-bar menu restrictions. */
     105    UIExtraDataMetaDefs::MenuType                       m_restrictionsOfMenuBar;
     106    /** Holds the Application menu restrictions. */
     107    UIExtraDataMetaDefs::MenuApplicationActionType      m_restrictionsOfMenuApplication;
     108    /** Holds the Machine menu restrictions. */
     109    UIExtraDataMetaDefs::RuntimeMenuMachineActionType   m_restrictionsOfMenuMachine;
     110    /** Holds the View menu restrictions. */
     111    UIExtraDataMetaDefs::RuntimeMenuViewActionType      m_restrictionsOfMenuView;
     112    /** Holds the Input menu restrictions. */
     113    UIExtraDataMetaDefs::RuntimeMenuInputActionType     m_restrictionsOfMenuInput;
     114    /** Holds the Devices menu restrictions. */
     115    UIExtraDataMetaDefs::RuntimeMenuDevicesActionType   m_restrictionsOfMenuDevices;
     116#ifdef VBOX_WITH_DEBUGGER_GUI
     117    /** Holds the Debug menu restrictions. */
     118    UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType  m_restrictionsOfMenuDebug;
     119#endif /* VBOX_WITH_DEBUGGER_GUI */
     120#ifdef VBOX_WS_MAC
     121    /** Holds the Window menu restrictions. */
     122    UIExtraDataMetaDefs::MenuWindowActionType           m_restrictionsOfMenuWindow;
     123#endif /* VBOX_WS_MAC */
     124    /** Holds the Help menu restrictions. */
     125    UIExtraDataMetaDefs::MenuHelpActionType             m_restrictionsOfMenuHelp;
     126
     127#ifndef VBOX_WS_MAC
     128    /** Holds whether the mini-toolbar is enabled. */
     129    bool  m_fShowMiniToolBar;
     130    /** Holds whether the mini-toolbar should be aligned at top of screen. */
     131    bool  m_fMiniToolBarAtTop;
     132#endif /* !VBOX_WS_MAC */
     133};
     134
    28135
    29136UIMachineSettingsInterface::UIMachineSettingsInterface(const QString strMachineID)
    30137    : m_strMachineID(strMachineID)
    31138    , m_pActionPool(0)
     139    , m_pCache(new UISettingsCacheMachineInterface)
    32140{
    33141    /* Prepare: */
     
    41149}
    42150
     151bool UIMachineSettingsInterface::changed() const
     152{
     153    return m_pCache->wasChanged();
     154}
     155
    43156void UIMachineSettingsInterface::loadToCacheFrom(QVariant &data)
    44157{
     
    47160
    48161    /* Clear cache initially: */
    49     m_cache.clear();
     162    m_pCache->clear();
    50163
    51164    /* Prepare interface data: */
     
    78191
    79192    /* Cache interface data: */
    80     m_cache.cacheInitialData(interfaceData);
     193    m_pCache->cacheInitialData(interfaceData);
    81194
    82195    /* Upload machine to data: */
     
    87200{
    88201    /* Get interface data from cache: */
    89     const UIDataSettingsMachineInterface &interfaceData = m_cache.base();
     202    const UIDataSettingsMachineInterface &interfaceData = m_pCache->base();
    90203
    91204    /* Prepare interface data: */
     
    124237{
    125238    /* Prepare interface data: */
    126     UIDataSettingsMachineInterface interfaceData = m_cache.base();
     239    UIDataSettingsMachineInterface interfaceData = m_pCache->base();
    127240
    128241    /* Gather interface data from page: */
     
    152265
    153266    /* Cache interface data: */
    154     m_cache.cacheCurrentData(interfaceData);
     267    m_pCache->cacheCurrentData(interfaceData);
    155268}
    156269
     
    161274
    162275    /* Make sure machine is in valid mode & interface data was changed: */
    163     if (isMachineInValidMode() && m_cache.wasChanged())
     276    if (isMachineInValidMode() && m_pCache->wasChanged())
    164277    {
    165278        /* Get interface data from cache: */
    166         const UIDataSettingsMachineInterface &interfaceData = m_cache.data();
     279        const UIDataSettingsMachineInterface &interfaceData = m_pCache->data();
    167280
    168281        /* Store interface data: */
     
    249362    /* Destroy personal action-pool: */
    250363    UIActionPool::destroy(m_pActionPool);
    251 }
    252 
     364
     365    /* Cleanup cache: */
     366    delete m_pCache;
     367    m_pCache = 0;
     368}
     369
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.h

    r66176 r66183  
    2525/* Forward declarations: */
    2626class UIActionPool;
    27 
    28 
    29 /** Machine settings: User Interface page data structure. */
    30 struct UIDataSettingsMachineInterface
    31 {
    32     /** Constructs data. */
    33     UIDataSettingsMachineInterface()
    34         : m_fStatusBarEnabled(false)
    35 #ifndef VBOX_WS_MAC
    36         , m_fMenuBarEnabled(false)
    37 #endif /* !VBOX_WS_MAC */
    38         , m_restrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType_Invalid)
    39         , m_restrictionsOfMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Invalid)
    40         , m_restrictionsOfMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid)
    41         , m_restrictionsOfMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid)
    42         , m_restrictionsOfMenuInput(UIExtraDataMetaDefs::RuntimeMenuInputActionType_Invalid)
    43         , m_restrictionsOfMenuDevices(UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid)
    44 #ifdef VBOX_WITH_DEBUGGER_GUI
    45         , m_restrictionsOfMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Invalid)
    46 #endif /* VBOX_WITH_DEBUGGER_GUI */
    47 #ifdef VBOX_WS_MAC
    48         , m_restrictionsOfMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Invalid)
    49 #endif /* VBOX_WS_MAC */
    50         , m_restrictionsOfMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Invalid)
    51 #ifndef VBOX_WS_MAC
    52         , m_fShowMiniToolBar(false)
    53         , m_fMiniToolBarAtTop(false)
    54 #endif /* !VBOX_WS_MAC */
    55     {}
    56 
    57     /** Returns whether the @a other passed data is equal to this one. */
    58     bool equal(const UIDataSettingsMachineInterface &other) const
    59     {
    60         return true
    61                && (m_fStatusBarEnabled == other.m_fStatusBarEnabled)
    62                && (m_statusBarRestrictions == other.m_statusBarRestrictions)
    63                && (m_statusBarOrder == other.m_statusBarOrder)
    64 #ifndef VBOX_WS_MAC
    65                && (m_fMenuBarEnabled == other.m_fMenuBarEnabled)
    66 #endif /* !VBOX_WS_MAC */
    67                && (m_restrictionsOfMenuBar == other.m_restrictionsOfMenuBar)
    68                && (m_restrictionsOfMenuApplication == other.m_restrictionsOfMenuApplication)
    69                && (m_restrictionsOfMenuMachine == other.m_restrictionsOfMenuMachine)
    70                && (m_restrictionsOfMenuView == other.m_restrictionsOfMenuView)
    71                && (m_restrictionsOfMenuInput == other.m_restrictionsOfMenuInput)
    72                && (m_restrictionsOfMenuDevices == other.m_restrictionsOfMenuDevices)
    73 #ifdef VBOX_WITH_DEBUGGER_GUI
    74                && (m_restrictionsOfMenuDebug == other.m_restrictionsOfMenuDebug)
    75 #endif /* VBOX_WITH_DEBUGGER_GUI */
    76 #ifdef VBOX_WS_MAC
    77                && (m_restrictionsOfMenuWindow == other.m_restrictionsOfMenuWindow)
    78 #endif /* VBOX_WS_MAC */
    79                && (m_restrictionsOfMenuHelp == other.m_restrictionsOfMenuHelp)
    80 #ifndef VBOX_WS_MAC
    81                && (m_fShowMiniToolBar == other.m_fShowMiniToolBar)
    82                && (m_fMiniToolBarAtTop == other.m_fMiniToolBarAtTop)
    83 #endif /* !VBOX_WS_MAC */
    84                ;
    85     }
    86 
    87     /** Returns whether the @a other passed data is equal to this one. */
    88     bool operator==(const UIDataSettingsMachineInterface &other) const { return equal(other); }
    89     /** Returns whether the @a other passed data is different from this one. */
    90     bool operator!=(const UIDataSettingsMachineInterface &other) const { return !equal(other); }
    91 
    92     /** Holds whether the status-bar is enabled. */
    93     bool                  m_fStatusBarEnabled;
    94     /** Holds the status-bar indicator restrictions. */
    95     QList<IndicatorType>  m_statusBarRestrictions;
    96     /** Holds the status-bar indicator order. */
    97     QList<IndicatorType>  m_statusBarOrder;
    98 
    99 #ifndef VBOX_WS_MAC
    100     /** Holds whether the menu-bar is enabled. */
    101     bool                                                m_fMenuBarEnabled;
    102 #endif /* !VBOX_WS_MAC */
    103     /** Holds the menu-bar menu restrictions. */
    104     UIExtraDataMetaDefs::MenuType                       m_restrictionsOfMenuBar;
    105     /** Holds the Application menu restrictions. */
    106     UIExtraDataMetaDefs::MenuApplicationActionType      m_restrictionsOfMenuApplication;
    107     /** Holds the Machine menu restrictions. */
    108     UIExtraDataMetaDefs::RuntimeMenuMachineActionType   m_restrictionsOfMenuMachine;
    109     /** Holds the View menu restrictions. */
    110     UIExtraDataMetaDefs::RuntimeMenuViewActionType      m_restrictionsOfMenuView;
    111     /** Holds the Input menu restrictions. */
    112     UIExtraDataMetaDefs::RuntimeMenuInputActionType     m_restrictionsOfMenuInput;
    113     /** Holds the Devices menu restrictions. */
    114     UIExtraDataMetaDefs::RuntimeMenuDevicesActionType   m_restrictionsOfMenuDevices;
    115 #ifdef VBOX_WITH_DEBUGGER_GUI
    116     /** Holds the Debug menu restrictions. */
    117     UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType  m_restrictionsOfMenuDebug;
    118 #endif /* VBOX_WITH_DEBUGGER_GUI */
    119 #ifdef VBOX_WS_MAC
    120     /** Holds the Window menu restrictions. */
    121     UIExtraDataMetaDefs::MenuWindowActionType           m_restrictionsOfMenuWindow;
    122 #endif /* VBOX_WS_MAC */
    123     /** Holds the Help menu restrictions. */
    124     UIExtraDataMetaDefs::MenuHelpActionType             m_restrictionsOfMenuHelp;
    125 
    126 #ifndef VBOX_WS_MAC
    127     /** Holds whether the mini-toolbar is enabled. */
    128     bool  m_fShowMiniToolBar;
    129     /** Holds whether the mini-toolbar should be aligned at top of screen. */
    130     bool  m_fMiniToolBarAtTop;
    131 #endif /* !VBOX_WS_MAC */
    132 };
     27struct UIDataSettingsMachineInterface;
    13328typedef UISettingsCache<UIDataSettingsMachineInterface> UISettingsCacheMachineInterface;
    13429
     
    14237public:
    14338
    144     /** Constructor, early takes @a strMachineID into account for size-hint calculation. */
     39    /** Constructs User Interface settings page. */
    14540    UIMachineSettingsInterface(const QString strMachineID);
    146     /** Destructor. */
     41    /** Destructs User Interface settings page. */
    14742    ~UIMachineSettingsInterface();
    14843
     
    15045
    15146    /** Returns whether the page content was changed. */
    152     bool changed() const { return m_cache.wasChanged(); }
     47    bool changed() const /* override */;
    15348
    15449    /** Loads data into the cache from corresponding external object(s),
     
    18378    void cleanup();
    18479
    185     /* Cache: */
    186     UISettingsCacheMachineInterface m_cache;
    187 
    18880    /** Holds the machine ID copy. */
    18981    const QString m_strMachineID;
    19082    /** Holds the action-pool instance. */
    19183    UIActionPool *m_pActionPool;
     84
     85    /** Holds the page data cache instance. */
     86    UISettingsCacheMachineInterface *m_pCache;
    19287};
    19388
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r66163 r66183  
    55
    66/*
    7  * Copyright (C) 2008-2016 Oracle Corporation
     7 * Copyright (C) 2008-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121
    2222/* GUI includes: */
     23# include "QIArrowButtonSwitch.h"
     24# include "QITabWidget.h"
    2325# include "QIWidgetValidator.h"
    24 # include "QIArrowButtonSwitch.h"
    25 # include "UIMachineSettingsNetwork.h"
    26 # include "QITabWidget.h"
    27 # include "VBoxGlobal.h"
    2826# include "UIConverter.h"
    2927# include "UIIconPool.h"
     28# include "UIMachineSettingsNetwork.h"
     29# include "VBoxGlobal.h"
    3030
    3131/* COM includes: */
     
    5252    return strInputString.isEmpty() ? QString() : strInputString;
    5353}
     54
     55
     56/** Machine settings: Network Adapter data structure. */
     57struct UIDataSettingsMachineNetworkAdapter
     58{
     59    /** Constructs data. */
     60    UIDataSettingsMachineNetworkAdapter()
     61        : m_iSlot(0)
     62        , m_fAdapterEnabled(false)
     63        , m_adapterType(KNetworkAdapterType_Null)
     64        , m_attachmentType(KNetworkAttachmentType_Null)
     65        , m_promiscuousMode(KNetworkAdapterPromiscModePolicy_Deny)
     66        , m_strBridgedAdapterName(QString())
     67        , m_strInternalNetworkName(QString())
     68        , m_strHostInterfaceName(QString())
     69        , m_strGenericDriverName(QString())
     70        , m_strGenericProperties(QString())
     71        , m_strNATNetworkName(QString())
     72        , m_strMACAddress(QString())
     73        , m_fCableConnected(false)
     74        , m_redirects(UIPortForwardingDataList())
     75    {}
     76
     77    /** Returns whether the @a other passed data is equal to this one. */
     78    bool equal(const UIDataSettingsMachineNetworkAdapter &other) const
     79    {
     80        return true
     81               && (m_iSlot == other.m_iSlot)
     82               && (m_fAdapterEnabled == other.m_fAdapterEnabled)
     83               && (m_adapterType == other.m_adapterType)
     84               && (m_attachmentType == other.m_attachmentType)
     85               && (m_promiscuousMode == other.m_promiscuousMode)
     86               && (m_strBridgedAdapterName == other.m_strBridgedAdapterName)
     87               && (m_strInternalNetworkName == other.m_strInternalNetworkName)
     88               && (m_strHostInterfaceName == other.m_strHostInterfaceName)
     89               && (m_strGenericDriverName == other.m_strGenericDriverName)
     90               && (m_strGenericProperties == other.m_strGenericProperties)
     91               && (m_strNATNetworkName == other.m_strNATNetworkName)
     92               && (m_strMACAddress == other.m_strMACAddress)
     93               && (m_fCableConnected == other.m_fCableConnected)
     94               && (m_redirects == other.m_redirects)
     95               ;
     96    }
     97
     98    /** Returns whether the @a other passed data is equal to this one. */
     99    bool operator==(const UIDataSettingsMachineNetworkAdapter &other) const { return equal(other); }
     100    /** Returns whether the @a other passed data is different from this one. */
     101    bool operator!=(const UIDataSettingsMachineNetworkAdapter &other) const { return !equal(other); }
     102
     103    /** Holds the network adapter slot number. */
     104    int                               m_iSlot;
     105    /** Holds whether the network adapter is enabled. */
     106    bool                              m_fAdapterEnabled;
     107    /** Holds the network adapter type. */
     108    KNetworkAdapterType               m_adapterType;
     109    /** Holds the network attachment type. */
     110    KNetworkAttachmentType            m_attachmentType;
     111    /** Holds the network promiscuous mode policy. */
     112    KNetworkAdapterPromiscModePolicy  m_promiscuousMode;
     113    /** Holds the bridged adapter name. */
     114    QString                           m_strBridgedAdapterName;
     115    /** Holds the internal network name. */
     116    QString                           m_strInternalNetworkName;
     117    /** Holds the host interface name. */
     118    QString                           m_strHostInterfaceName;
     119    /** Holds the generic driver name. */
     120    QString                           m_strGenericDriverName;
     121    /** Holds the generic driver properties. */
     122    QString                           m_strGenericProperties;
     123    /** Holds the NAT network name. */
     124    QString                           m_strNATNetworkName;
     125    /** Holds the network adapter MAC address. */
     126    QString                           m_strMACAddress;
     127    /** Holds whether the network adapter is connected. */
     128    bool                              m_fCableConnected;
     129    /** Holds the set of network redirection rules. */
     130    UIPortForwardingDataList          m_redirects;
     131};
     132
     133
     134/** Machine settings: Network page data structure. */
     135struct UIDataSettingsMachineNetwork
     136{
     137    /** Constructs data. */
     138    UIDataSettingsMachineNetwork() {}
     139
     140    /** Returns whether the @a other passed data is equal to this one. */
     141    bool operator==(const UIDataSettingsMachineNetwork & /* other */) const { return true; }
     142    /** Returns whether the @a other passed data is different from this one. */
     143    bool operator!=(const UIDataSettingsMachineNetwork & /* other */) const { return false; }
     144};
     145
     146
     147/** Machine settings: Network Adapter tab. */
     148class UIMachineSettingsNetwork : public QIWithRetranslateUI<QWidget>,
     149                                 public Ui::UIMachineSettingsNetwork
     150{
     151    Q_OBJECT;
     152
     153public:
     154
     155    /* Constructor: */
     156    UIMachineSettingsNetwork(UIMachineSettingsNetworkPage *pParent);
     157
     158    /* Load / Save API: */
     159    void fetchAdapterCache(const UISettingsCacheMachineNetworkAdapter &adapterCache);
     160    void uploadAdapterCache(UISettingsCacheMachineNetworkAdapter &adapterCache);
     161
     162    /** Performs validation, updates @a messages list if something is wrong. */
     163    bool validate(QList<UIValidationMessage> &messages);
     164
     165    /* Navigation stuff: */
     166    QWidget* setOrderAfter(QWidget *pAfter);
     167
     168    /* Other public stuff: */
     169    QString tabTitle() const;
     170    KNetworkAttachmentType attachmentType() const;
     171    QString alternativeName(int iType = -1) const;
     172    void polishTab();
     173    void reloadAlternative();
     174
     175    /** Defines whether the advanced button is @a fExpanded. */
     176    void setAdvancedButtonState(bool fExpanded);
     177
     178signals:
     179
     180    /* Signal to notify listeners about tab content changed: */
     181    void sigTabUpdated();
     182
     183    /** Notifies about the advanced button has @a fExpanded. */
     184    void sigNotifyAdvancedButtonStateChange(bool fExpanded);
     185
     186protected:
     187
     188    /** Handles translation event. */
     189    void retranslateUi();
     190
     191private slots:
     192
     193    /* Different handlers: */
     194    void sltHandleAdapterActivityChange();
     195    void sltHandleAttachmentTypeChange();
     196    void sltHandleAlternativeNameChange();
     197    void sltHandleAdvancedButtonStateChange();
     198    void sltGenerateMac();
     199    void sltOpenPortForwardingDlg();
     200
     201private:
     202
     203    /* Helper: Prepare stuff: */
     204    void prepareValidation();
     205
     206    /* Helping stuff: */
     207    void populateComboboxes();
     208    void updateAlternativeList();
     209    void updateAlternativeName();
     210
     211    /** Handles advanced button state change. */
     212    void handleAdvancedButtonStateChange();
     213
     214    /* Various static stuff: */
     215    static int position(QComboBox *pComboBox, int iData);
     216    static int position(QComboBox *pComboBox, const QString &strText);
     217
     218    /* Parent page: */
     219    UIMachineSettingsNetworkPage *m_pParent;
     220
     221    /* Other variables: */
     222    int m_iSlot;
     223    QString m_strBridgedAdapterName;
     224    QString m_strInternalNetworkName;
     225    QString m_strHostInterfaceName;
     226    QString m_strGenericDriverName;
     227    QString m_strNATNetworkName;
     228    UIPortForwardingDataList m_portForwardingRules;
     229};
     230
    54231
    55232UIMachineSettingsNetwork::UIMachineSettingsNetwork(UIMachineSettingsNetworkPage *pParent)
     
    816993UIMachineSettingsNetworkPage::UIMachineSettingsNetworkPage()
    817994    : m_pTwAdapters(0)
     995    , m_pCache(new UISettingsCacheMachineNetwork)
    818996{
    819997    /* Setup main layout: */
     
    8421020}
    8431021
     1022UIMachineSettingsNetworkPage::~UIMachineSettingsNetworkPage()
     1023{
     1024    /* Cleanup cache: */
     1025    delete m_pCache;
     1026    m_pCache = 0;
     1027}
     1028
     1029bool UIMachineSettingsNetworkPage::changed() const
     1030{
     1031    return m_pCache->wasChanged();
     1032}
     1033
    8441034void UIMachineSettingsNetworkPage::loadToCacheFrom(QVariant &data)
    8451035{
     
    8481038
    8491039    /* Clear cache initially: */
    850     m_cache.clear();
     1040    m_pCache->clear();
    8511041
    8521042    /* Cache name lists: */
     
    9001090
    9011091        /* Cache adapter data: */
    902         m_cache.child(iSlot).cacheInitialData(adapterData);
     1092        m_pCache->child(iSlot).cacheInitialData(adapterData);
    9031093    }
    9041094
     
    9211111
    9221112        /* Load adapter data to page: */
    923         pTab->fetchAdapterCache(m_cache.child(iSlot));
     1113        pTab->fetchAdapterCache(m_pCache->child(iSlot));
    9241114
    9251115        /* Setup tab order: */
     
    9461136
    9471137        /* Gather & cache adapter data: */
    948         pTab->uploadAdapterCache(m_cache.child(iSlot));
     1138        pTab->uploadAdapterCache(m_pCache->child(iSlot));
    9491139    }
    9501140}
     
    9561146
    9571147    /* Check if network data was changed: */
    958     if (m_cache.wasChanged())
     1148    if (m_pCache->wasChanged())
    9591149    {
    9601150        /* For each network adapter: */
     
    9621152        {
    9631153            /* Check if adapter data was changed: */
    964             const UISettingsCacheMachineNetworkAdapter &adapterCache = m_cache.child(iSlot);
     1154            const UISettingsCacheMachineNetworkAdapter &adapterCache = m_pCache->child(iSlot);
    9651155            if (adapterCache.wasChanged())
    9661156            {
     
    11171307        m_pTwAdapters->setTabEnabled(iSlot,
    11181308                                     isMachineOffline() ||
    1119                                      (isMachineInValidMode() && m_cache.child(iSlot).base().m_fAdapterEnabled));
     1309                                     (isMachineInValidMode() && m_pCache->child(iSlot).base().m_fAdapterEnabled));
    11201310        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTwAdapters->widget(iSlot));
    11211311        pTab->polishTab();
     
    12721462}
    12731463
     1464# include "UIMachineSettingsNetwork.moc"
     1465
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.h

    r66176 r66183  
    2525
    2626/* Forward declarations: */
     27class QITabWidget;
    2728class UIMachineSettingsNetworkPage;
    28 class QITabWidget;
    29 
    30 
    31 /** Machine settings: Network Adapter data structure. */
    32 struct UIDataSettingsMachineNetworkAdapter
    33 {
    34     /** Constructs data. */
    35     UIDataSettingsMachineNetworkAdapter()
    36         : m_iSlot(0)
    37         , m_fAdapterEnabled(false)
    38         , m_adapterType(KNetworkAdapterType_Null)
    39         , m_attachmentType(KNetworkAttachmentType_Null)
    40         , m_promiscuousMode(KNetworkAdapterPromiscModePolicy_Deny)
    41         , m_strBridgedAdapterName(QString())
    42         , m_strInternalNetworkName(QString())
    43         , m_strHostInterfaceName(QString())
    44         , m_strGenericDriverName(QString())
    45         , m_strGenericProperties(QString())
    46         , m_strNATNetworkName(QString())
    47         , m_strMACAddress(QString())
    48         , m_fCableConnected(false)
    49         , m_redirects(UIPortForwardingDataList())
    50     {}
    51 
    52     /** Returns whether the @a other passed data is equal to this one. */
    53     bool equal(const UIDataSettingsMachineNetworkAdapter &other) const
    54     {
    55         return true
    56                && (m_iSlot == other.m_iSlot)
    57                && (m_fAdapterEnabled == other.m_fAdapterEnabled)
    58                && (m_adapterType == other.m_adapterType)
    59                && (m_attachmentType == other.m_attachmentType)
    60                && (m_promiscuousMode == other.m_promiscuousMode)
    61                && (m_strBridgedAdapterName == other.m_strBridgedAdapterName)
    62                && (m_strInternalNetworkName == other.m_strInternalNetworkName)
    63                && (m_strHostInterfaceName == other.m_strHostInterfaceName)
    64                && (m_strGenericDriverName == other.m_strGenericDriverName)
    65                && (m_strGenericProperties == other.m_strGenericProperties)
    66                && (m_strNATNetworkName == other.m_strNATNetworkName)
    67                && (m_strMACAddress == other.m_strMACAddress)
    68                && (m_fCableConnected == other.m_fCableConnected)
    69                && (m_redirects == other.m_redirects)
    70                ;
    71     }
    72 
    73     /** Returns whether the @a other passed data is equal to this one. */
    74     bool operator==(const UIDataSettingsMachineNetworkAdapter &other) const { return equal(other); }
    75     /** Returns whether the @a other passed data is different from this one. */
    76     bool operator!=(const UIDataSettingsMachineNetworkAdapter &other) const { return !equal(other); }
    77 
    78     /** Holds the network adapter slot number. */
    79     int                               m_iSlot;
    80     /** Holds whether the network adapter is enabled. */
    81     bool                              m_fAdapterEnabled;
    82     /** Holds the network adapter type. */
    83     KNetworkAdapterType               m_adapterType;
    84     /** Holds the network attachment type. */
    85     KNetworkAttachmentType            m_attachmentType;
    86     /** Holds the network promiscuous mode policy. */
    87     KNetworkAdapterPromiscModePolicy  m_promiscuousMode;
    88     /** Holds the bridged adapter name. */
    89     QString                           m_strBridgedAdapterName;
    90     /** Holds the internal network name. */
    91     QString                           m_strInternalNetworkName;
    92     /** Holds the host interface name. */
    93     QString                           m_strHostInterfaceName;
    94     /** Holds the generic driver name. */
    95     QString                           m_strGenericDriverName;
    96     /** Holds the generic driver properties. */
    97     QString                           m_strGenericProperties;
    98     /** Holds the NAT network name. */
    99     QString                           m_strNATNetworkName;
    100     /** Holds the network adapter MAC address. */
    101     QString                           m_strMACAddress;
    102     /** Holds whether the network adapter is connected. */
    103     bool                              m_fCableConnected;
    104     /** Holds the set of network redirection rules. */
    105     UIPortForwardingDataList          m_redirects;
    106 };
     29struct UIDataSettingsMachineNetwork;
     30struct UIDataSettingsMachineNetworkAdapter;
    10731typedef UISettingsCache<UIDataSettingsMachineNetworkAdapter> UISettingsCacheMachineNetworkAdapter;
    108 
    109 
    110 /** Machine settings: Network page data structure. */
    111 struct UIDataSettingsMachineNetwork
    112 {
    113     /** Constructs data. */
    114     UIDataSettingsMachineNetwork() {}
    115 
    116     /** Returns whether the @a other passed data is equal to this one. */
    117     bool operator==(const UIDataSettingsMachineNetwork & /* other */) const { return true; }
    118     /** Returns whether the @a other passed data is different from this one. */
    119     bool operator!=(const UIDataSettingsMachineNetwork & /* other */) const { return false; }
    120 };
    12132typedef UISettingsCachePool<UIDataSettingsMachineNetwork, UISettingsCacheMachineNetworkAdapter> UISettingsCacheMachineNetwork;
    122 
    123 
    124 /** Machine settings: Network Adapter tab. */
    125 class UIMachineSettingsNetwork : public QIWithRetranslateUI<QWidget>,
    126                                  public Ui::UIMachineSettingsNetwork
    127 {
    128     Q_OBJECT;
    129 
    130 public:
    131 
    132     /* Constructor: */
    133     UIMachineSettingsNetwork(UIMachineSettingsNetworkPage *pParent);
    134 
    135     /* Load / Save API: */
    136     void fetchAdapterCache(const UISettingsCacheMachineNetworkAdapter &adapterCache);
    137     void uploadAdapterCache(UISettingsCacheMachineNetworkAdapter &adapterCache);
    138 
    139     /** Performs validation, updates @a messages list if something is wrong. */
    140     bool validate(QList<UIValidationMessage> &messages);
    141 
    142     /* Navigation stuff: */
    143     QWidget* setOrderAfter(QWidget *pAfter);
    144 
    145     /* Other public stuff: */
    146     QString tabTitle() const;
    147     KNetworkAttachmentType attachmentType() const;
    148     QString alternativeName(int iType = -1) const;
    149     void polishTab();
    150     void reloadAlternative();
    151 
    152     /** Defines whether the advanced button is @a fExpanded. */
    153     void setAdvancedButtonState(bool fExpanded);
    154 
    155 signals:
    156 
    157     /* Signal to notify listeners about tab content changed: */
    158     void sigTabUpdated();
    159 
    160     /** Notifies about the advanced button has @a fExpanded. */
    161     void sigNotifyAdvancedButtonStateChange(bool fExpanded);
    162 
    163 protected:
    164 
    165     /** Handles translation event. */
    166     void retranslateUi();
    167 
    168 private slots:
    169 
    170     /* Different handlers: */
    171     void sltHandleAdapterActivityChange();
    172     void sltHandleAttachmentTypeChange();
    173     void sltHandleAlternativeNameChange();
    174     void sltHandleAdvancedButtonStateChange();
    175     void sltGenerateMac();
    176     void sltOpenPortForwardingDlg();
    177 
    178 private:
    179 
    180     /* Helper: Prepare stuff: */
    181     void prepareValidation();
    182 
    183     /* Helping stuff: */
    184     void populateComboboxes();
    185     void updateAlternativeList();
    186     void updateAlternativeName();
    187 
    188     /** Handles advanced button state change. */
    189     void handleAdvancedButtonStateChange();
    190 
    191     /* Various static stuff: */
    192     static int position(QComboBox *pComboBox, int iData);
    193     static int position(QComboBox *pComboBox, const QString &strText);
    194 
    195     /* Parent page: */
    196     UIMachineSettingsNetworkPage *m_pParent;
    197 
    198     /* Other variables: */
    199     int m_iSlot;
    200     QString m_strBridgedAdapterName;
    201     QString m_strInternalNetworkName;
    202     QString m_strHostInterfaceName;
    203     QString m_strGenericDriverName;
    204     QString m_strNATNetworkName;
    205     UIPortForwardingDataList m_portForwardingRules;
    206 };
    20733
    20834
     
    21440public:
    21541
    216     /* Constructor: */
     42    /** Constructs Network settings page. */
    21743    UIMachineSettingsNetworkPage();
     44    /** Destructs Network settings page. */
     45    ~UIMachineSettingsNetworkPage();
    21846
    21947    /* Bridged adapter list: */
     
    23058protected:
    23159
     60    /** Returns whether the page content was changed. */
     61    bool changed() const /* override */;
     62
    23263    /** Loads data into the cache from corresponding external object(s),
    23364      * this task COULD be performed in other than the GUI thread. */
     
    24374      * this task COULD be performed in other than the GUI thread. */
    24475    void saveFromCacheTo(QVariant &data);
    245 
    246     /** Returns whether the page content was changed. */
    247     bool changed() const { return m_cache.wasChanged(); }
    24876
    24977    /** Performs validation, updates @a messages list if something is wrong. */
     
    287115    QStringList m_natNetworkList;
    288116
    289     /* Cache: */
    290     UISettingsCacheMachineNetwork m_cache;
     117    /** Holds the page data cache instance. */
     118    UISettingsCacheMachineNetwork *m_pCache;
    291119};
    292120
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp

    r66163 r66183  
    55
    66/*
    7  * Copyright (C) 2006-2016 Oracle Corporation
     7 * Copyright (C) 2006-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424
    2525/* GUI includes: */
     26# include "QIWidgetValidator.h"
     27# include "QITabWidget.h"
    2628# include "UIMachineSettingsParallel.h"
    27 # include "QIWidgetValidator.h"
    2829# include "VBoxGlobal.h"
    29 # include "QITabWidget.h"
    3030
    3131/* COM includes: */
     
    3333
    3434#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     35
     36
     37/** Machine settings: Parallel Port tab data structure. */
     38struct UIDataSettingsMachineParallelPort
     39{
     40    /** Constructs data. */
     41    UIDataSettingsMachineParallelPort()
     42        : m_iSlot(-1)
     43        , m_fPortEnabled(false)
     44        , m_uIRQ(0)
     45        , m_uIOBase(0)
     46        , m_strPath(QString())
     47    {}
     48
     49    /** Returns whether the @a other passed data is equal to this one. */
     50    bool equal(const UIDataSettingsMachineParallelPort &other) const
     51    {
     52        return true
     53               && (m_iSlot == other.m_iSlot)
     54               && (m_fPortEnabled == other.m_fPortEnabled)
     55               && (m_uIRQ == other.m_uIRQ)
     56               && (m_uIOBase == other.m_uIOBase)
     57               && (m_strPath == other.m_strPath)
     58               ;
     59    }
     60
     61    /** Returns whether the @a other passed data is equal to this one. */
     62    bool operator==(const UIDataSettingsMachineParallelPort &other) const { return equal(other); }
     63    /** Returns whether the @a other passed data is different from this one. */
     64    bool operator!=(const UIDataSettingsMachineParallelPort &other) const { return !equal(other); }
     65
     66    /** Holds the parallel port slot number. */
     67    int      m_iSlot;
     68    /** Holds whether the parallel port is enabled. */
     69    bool     m_fPortEnabled;
     70    /** Holds the parallel port IRQ. */
     71    ulong    m_uIRQ;
     72    /** Holds the parallel port IO base. */
     73    ulong    m_uIOBase;
     74    /** Holds the parallel port path. */
     75    QString  m_strPath;
     76};
     77
     78
     79/** Machine settings: Parallel page data structure. */
     80struct UIDataSettingsMachineParallel
     81{
     82    /** Constructs data. */
     83    UIDataSettingsMachineParallel() {}
     84
     85    /** Returns whether the @a other passed data is equal to this one. */
     86    bool operator==(const UIDataSettingsMachineParallel & /* other */) const { return true; }
     87    /** Returns whether the @a other passed data is different from this one. */
     88    bool operator!=(const UIDataSettingsMachineParallel & /* other */) const { return false; }
     89};
     90
     91
     92/** Machine settings: Parallel Port tab. */
     93class UIMachineSettingsParallel : public QIWithRetranslateUI<QWidget>,
     94                                  public Ui::UIMachineSettingsParallel
     95{
     96    Q_OBJECT;
     97
     98public:
     99
     100    UIMachineSettingsParallel(UIMachineSettingsParallelPage *pParent);
     101
     102    void polishTab();
     103
     104    void fetchPortData(const UISettingsCacheMachineParallelPort &portCache);
     105    void uploadPortData(UISettingsCacheMachineParallelPort &portCache);
     106
     107    QWidget* setOrderAfter (QWidget *aAfter);
     108
     109    QString pageTitle() const;
     110    bool isUserDefined();
     111
     112protected:
     113
     114    void retranslateUi();
     115
     116private slots:
     117
     118    void mGbParallelToggled (bool aOn);
     119    void mCbNumberActivated (const QString &aText);
     120
     121private:
     122
     123    /* Helper: Prepare stuff: */
     124    void prepareValidation();
     125
     126    UIMachineSettingsParallelPage *m_pParent;
     127    int m_iSlot;
     128};
    35129
    36130
     
    188282UIMachineSettingsParallelPage::UIMachineSettingsParallelPage()
    189283    : mTabWidget(0)
     284    , m_pCache(new UISettingsCacheMachineParallel)
    190285{
    191286    /* TabWidget creation */
     
    206301}
    207302
     303UIMachineSettingsParallelPage::~UIMachineSettingsParallelPage()
     304{
     305    /* Cleanup cache: */
     306    delete m_pCache;
     307    m_pCache = 0;
     308}
     309
     310bool UIMachineSettingsParallelPage::changed() const
     311{
     312    return m_pCache->wasChanged();
     313}
     314
    208315void UIMachineSettingsParallelPage::loadToCacheFrom(QVariant &data)
    209316{
     
    212319
    213320    /* Clear cache initially: */
    214     m_cache.clear();
     321    m_pCache->clear();
    215322
    216323    /* For each parallel port: */
     
    233340
    234341        /* Cache port data: */
    235         m_cache.child(iSlot).cacheInitialData(portData);
     342        m_pCache->child(iSlot).cacheInitialData(portData);
    236343    }
    237344
     
    254361
    255362        /* Load port data to page: */
    256         pPage->fetchPortData(m_cache.child(iPort));
     363        pPage->fetchPortData(m_pCache->child(iPort));
    257364
    258365        /* Setup tab order: */
     
    279386
    280387        /* Gather & cache port data: */
    281         pPage->uploadPortData(m_cache.child(iPort));
     388        pPage->uploadPortData(m_pCache->child(iPort));
    282389    }
    283390}
     
    289396
    290397    /* Check if ports data was changed: */
    291     if (m_cache.wasChanged())
     398    if (m_pCache->wasChanged())
    292399    {
    293400        /* For each parallel port: */
     
    295402        {
    296403            /* Check if port data was changed: */
    297             const UISettingsCacheMachineParallelPort &portCache = m_cache.child(iPort);
     404            const UISettingsCacheMachineParallelPort &portCache = m_pCache->child(iPort);
    298405            if (portCache.wasChanged())
    299406            {
     
    405512        mTabWidget->setTabEnabled(iPort,
    406513                                  isMachineOffline() ||
    407                                   (isMachineInValidMode() && m_cache.child(iPort).base().m_fPortEnabled));
     514                                  (isMachineInValidMode() && m_pCache->child(iPort).base().m_fPortEnabled));
    408515        UIMachineSettingsParallel *pTab = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iPort));
    409516        pTab->polishTab();
     
    411518}
    412519
     520# include "UIMachineSettingsParallel.moc"
     521
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h

    r66176 r66183  
    2424
    2525/* Forward declarations: */
     26class QITabWidget;
    2627class UIMachineSettingsParallelPage;
    27 class QITabWidget;
    28 
    29 
    30 /** Machine settings: Parallel Port tab data structure. */
    31 struct UIDataSettingsMachineParallelPort
    32 {
    33     /** Constructs data. */
    34     UIDataSettingsMachineParallelPort()
    35         : m_iSlot(-1)
    36         , m_fPortEnabled(false)
    37         , m_uIRQ(0)
    38         , m_uIOBase(0)
    39         , m_strPath(QString())
    40     {}
    41 
    42     /** Returns whether the @a other passed data is equal to this one. */
    43     bool equal(const UIDataSettingsMachineParallelPort &other) const
    44     {
    45         return true
    46                && (m_iSlot == other.m_iSlot)
    47                && (m_fPortEnabled == other.m_fPortEnabled)
    48                && (m_uIRQ == other.m_uIRQ)
    49                && (m_uIOBase == other.m_uIOBase)
    50                && (m_strPath == other.m_strPath)
    51                ;
    52     }
    53 
    54     /** Returns whether the @a other passed data is equal to this one. */
    55     bool operator==(const UIDataSettingsMachineParallelPort &other) const { return equal(other); }
    56     /** Returns whether the @a other passed data is different from this one. */
    57     bool operator!=(const UIDataSettingsMachineParallelPort &other) const { return !equal(other); }
    58 
    59     /** Holds the parallel port slot number. */
    60     int      m_iSlot;
    61     /** Holds whether the parallel port is enabled. */
    62     bool     m_fPortEnabled;
    63     /** Holds the parallel port IRQ. */
    64     ulong    m_uIRQ;
    65     /** Holds the parallel port IO base. */
    66     ulong    m_uIOBase;
    67     /** Holds the parallel port path. */
    68     QString  m_strPath;
    69 };
     28struct UIDataSettingsMachineParallel;
     29struct UIDataSettingsMachineParallelPort;
    7030typedef UISettingsCache<UIDataSettingsMachineParallelPort> UISettingsCacheMachineParallelPort;
    71 
    72 
    73 /** Machine settings: Parallel page data structure. */
    74 struct UIDataSettingsMachineParallel
    75 {
    76     /** Constructs data. */
    77     UIDataSettingsMachineParallel() {}
    78 
    79     /** Returns whether the @a other passed data is equal to this one. */
    80     bool operator==(const UIDataSettingsMachineParallel & /* other */) const { return true; }
    81     /** Returns whether the @a other passed data is different from this one. */
    82     bool operator!=(const UIDataSettingsMachineParallel & /* other */) const { return false; }
    83 };
    8431typedef UISettingsCachePool<UIDataSettingsMachineParallel, UISettingsCacheMachineParallelPort> UISettingsCacheMachineParallel;
    85 
    86 
    87 /** Machine settings: Parallel Port tab. */
    88 class UIMachineSettingsParallel : public QIWithRetranslateUI<QWidget>,
    89                                   public Ui::UIMachineSettingsParallel
    90 {
    91     Q_OBJECT;
    92 
    93 public:
    94 
    95     UIMachineSettingsParallel(UIMachineSettingsParallelPage *pParent);
    96 
    97     void polishTab();
    98 
    99     void fetchPortData(const UISettingsCacheMachineParallelPort &portCache);
    100     void uploadPortData(UISettingsCacheMachineParallelPort &portCache);
    101 
    102     QWidget* setOrderAfter (QWidget *aAfter);
    103 
    104     QString pageTitle() const;
    105     bool isUserDefined();
    106 
    107 protected:
    108 
    109     void retranslateUi();
    110 
    111 private slots:
    112 
    113     void mGbParallelToggled (bool aOn);
    114     void mCbNumberActivated (const QString &aText);
    115 
    116 private:
    117 
    118     /* Helper: Prepare stuff: */
    119     void prepareValidation();
    120 
    121     UIMachineSettingsParallelPage *m_pParent;
    122     int m_iSlot;
    123 };
    12432
    12533
     
    13139public:
    13240
     41    /** Constructs Parallel settings page. */
    13342    UIMachineSettingsParallelPage();
     43    /** Destructs Parallel settings page. */
     44    ~UIMachineSettingsParallelPage();
    13445
    13546protected:
     47
     48    /** Returns whether the page content was changed. */
     49    bool changed() const /* override */;
    13650
    13751    /** Loads data into the cache from corresponding external object(s),
     
    14963    void saveFromCacheTo(QVariant &data);
    15064
    151     /** Returns whether the page content was changed. */
    152     bool changed() const { return m_cache.wasChanged(); }
    153 
    15465    /** Performs validation, updates @a messages list if something is wrong. */
    15566    bool validate(QList<UIValidationMessage> &messages);
     
    16475    QITabWidget *mTabWidget;
    16576
    166     /* Cache: */
    167     UISettingsCacheMachineParallel m_cache;
     77    /** Holds the page data cache instance. */
     78    UISettingsCacheMachineParallel *m_pCache;
    16879};
    16980
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp

    r66163 r66183  
    55
    66/*
    7  * Copyright (C) 2008-2016 Oracle Corporation
     7 * Copyright (C) 2008-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2121
    22 /* Local includes */
     22/* Qt includes: */
     23# include <QHeaderView>
     24# include <QTimer>
     25
     26/* GUI includes: */
    2327# include "UIIconPool.h"
    24 # include "VBoxGlobal.h"
    25 # include "UIMessageCenter.h"
    26 # include "VBoxUtils.h"
    2728# include "UIMachineSettingsSF.h"
    2829# include "UIMachineSettingsSFDetails.h"
    29 
    30 /* Global includes */
    31 # include <QHeaderView>
    32 # include <QTimer>
     30# include "UIMessageCenter.h"
     31# include "VBoxGlobal.h"
     32# include "VBoxUtils.h"
    3333
    3434#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     35
     36
     37/** Machine settings: Shared Folder data structure. */
     38struct UIDataSettingsSharedFolder
     39{
     40    /** Constructs data. */
     41    UIDataSettingsSharedFolder()
     42        : m_type(MachineType)
     43        , m_strName(QString())
     44        , m_strHostPath(QString())
     45        , m_fAutoMount(false)
     46        , m_fWritable(false)
     47    {}
     48
     49    /** Returns whether the @a other passed data is equal to this one. */
     50    bool equal(const UIDataSettingsSharedFolder &other) const
     51    {
     52        return true
     53               && (m_type == other.m_type)
     54               && (m_strName == other.m_strName)
     55               && (m_strHostPath == other.m_strHostPath)
     56               && (m_fAutoMount == other.m_fAutoMount)
     57               && (m_fWritable == other.m_fWritable)
     58               ;
     59    }
     60
     61    /** Returns whether the @a other passed data is equal to this one. */
     62    bool operator==(const UIDataSettingsSharedFolder &other) const { return equal(other); }
     63    /** Returns whether the @a other passed data is different from this one. */
     64    bool operator!=(const UIDataSettingsSharedFolder &other) const { return !equal(other); }
     65
     66    /** Holds the shared folder type. */
     67    UISharedFolderType  m_type;
     68    /** Holds the shared folder name. */
     69    QString             m_strName;
     70    /** Holds the shared folder path. */
     71    QString             m_strHostPath;
     72    /** Holds whether the shared folder should be auto-mounted at startup. */
     73    bool                m_fAutoMount;
     74    /** Holds whether the shared folder should be writeable. */
     75    bool                m_fWritable;
     76};
     77
     78
     79/** Machine settings: Shared Folders page data structure. */
     80struct UIDataSettingsSharedFolders
     81{
     82    /** Constructs data. */
     83    UIDataSettingsSharedFolders() {}
     84
     85    /** Returns whether the @a other passed data is equal to this one. */
     86    bool operator==(const UIDataSettingsSharedFolders & /* other */) const { return true; }
     87    /** Returns whether the @a other passed data is different from this one. */
     88    bool operator!=(const UIDataSettingsSharedFolders & /* other */) const { return false; }
     89};
    3590
    3691
     
    183238UIMachineSettingsSF::UIMachineSettingsSF()
    184239    : mNewAction(0), mEdtAction(0), mDelAction(0)
     240    , m_pCache(new UISettingsCacheSharedFolders)
    185241{
    186242    /* Apply UI decorations */
     
    233289}
    234290
     291UIMachineSettingsSF::~UIMachineSettingsSF()
     292{
     293    /* Cleanup cache: */
     294    delete m_pCache;
     295    m_pCache = 0;
     296}
     297
    235298void UIMachineSettingsSF::resizeEvent (QResizeEvent *aEvent)
    236299{
     
    239302}
    240303
     304bool UIMachineSettingsSF::changed() const
     305{
     306    return m_pCache->wasChanged();
     307}
     308
    241309void UIMachineSettingsSF::loadToCacheFrom(QVariant &data)
    242310{
     
    245313
    246314    /* Clear cache initially: */
    247     m_cache.clear();
     315    m_pCache->clear();
    248316
    249317    /* Load machine (permanent) shared folders into shared folders cache if possible: */
     
    285353
    286354        /* Cache shared folder data: */
    287         m_cache.child(strSharedFolderKey).cacheInitialData(sharedFolderData);
     355        m_pCache->child(strSharedFolderKey).cacheInitialData(sharedFolderData);
    288356    }
    289357}
     
    298366
    299367    /* Load shared folders data: */
    300     for (int iFolderIndex = 0; iFolderIndex < m_cache.childCount(); ++iFolderIndex)
     368    for (int iFolderIndex = 0; iFolderIndex < m_pCache->childCount(); ++iFolderIndex)
    301369    {
    302370        /* Get shared folder data: */
    303         const UIDataSettingsSharedFolder &sharedFolderData = m_cache.child(iFolderIndex).base();
     371        const UIDataSettingsSharedFolder &sharedFolderData = m_pCache->child(iFolderIndex).base();
    304372        /* Prepare item fields: */
    305373        QStringList fields;
     
    338406            sharedFolderData.m_fAutoMount = pFolderItem->getText(2) == mTrYes ? true : false;
    339407            sharedFolderData.m_fWritable = pFolderItem->getText(3) == mTrFull ? true : false;
    340             m_cache.child(sharedFolderData.m_strName).cacheCurrentData(sharedFolderData);
     408            m_pCache->child(sharedFolderData.m_strName).cacheCurrentData(sharedFolderData);
    341409        }
    342410    }
     
    349417
    350418    /* Check if shared folders data was changed at all: */
    351     if (m_cache.wasChanged())
     419    if (m_pCache->wasChanged())
    352420    {
    353421        /* Save machine (permanent) shared folders if possible: */
     
    366434{
    367435    /* For each shared folder data set: */
    368     for (int iSharedFolderIndex = 0; iSharedFolderIndex < m_cache.childCount(); ++iSharedFolderIndex)
     436    for (int iSharedFolderIndex = 0; iSharedFolderIndex < m_pCache->childCount(); ++iSharedFolderIndex)
    369437    {
    370438        /* Check if this shared folder data was actually changed: */
    371         const UISettingsCacheSharedFolder &sharedFolderCache = m_cache.child(iSharedFolderIndex);
     439        const UISettingsCacheSharedFolder &sharedFolderCache = m_pCache->child(iSharedFolderIndex);
    372440        if (sharedFolderCache.wasChanged())
    373441        {
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.h

    r66176 r66183  
    2828/* Forward declarations: */
    2929class SFTreeViewItem;
    30 
     30struct UIDataSettingsSharedFolder;
     31struct UIDataSettingsSharedFolders;
    3132enum UISharedFolderType { MachineType, ConsoleType };
    32 typedef QPair <QString, UISharedFolderType> SFolderName;
    33 typedef QList <SFolderName> SFoldersNameList;
    34 
    35 
    36 /** Machine settings: Shared Folder data structure. */
    37 struct UIDataSettingsSharedFolder
    38 {
    39     /** Constructs data. */
    40     UIDataSettingsSharedFolder()
    41         : m_type(MachineType)
    42         , m_strName(QString())
    43         , m_strHostPath(QString())
    44         , m_fAutoMount(false)
    45         , m_fWritable(false)
    46     {}
    47 
    48     /** Returns whether the @a other passed data is equal to this one. */
    49     bool equal(const UIDataSettingsSharedFolder &other) const
    50     {
    51         return true
    52                && (m_type == other.m_type)
    53                && (m_strName == other.m_strName)
    54                && (m_strHostPath == other.m_strHostPath)
    55                && (m_fAutoMount == other.m_fAutoMount)
    56                && (m_fWritable == other.m_fWritable)
    57                ;
    58     }
    59 
    60     /** Returns whether the @a other passed data is equal to this one. */
    61     bool operator==(const UIDataSettingsSharedFolder &other) const { return equal(other); }
    62     /** Returns whether the @a other passed data is different from this one. */
    63     bool operator!=(const UIDataSettingsSharedFolder &other) const { return !equal(other); }
    64 
    65     /** Holds the shared folder type. */
    66     UISharedFolderType  m_type;
    67     /** Holds the shared folder name. */
    68     QString             m_strName;
    69     /** Holds the shared folder path. */
    70     QString             m_strHostPath;
    71     /** Holds whether the shared folder should be auto-mounted at startup. */
    72     bool                m_fAutoMount;
    73     /** Holds whether the shared folder should be writeable. */
    74     bool                m_fWritable;
    75 };
    7633typedef UISettingsCache<UIDataSettingsSharedFolder> UISettingsCacheSharedFolder;
    77 
    78 
    79 /** Machine settings: Shared Folders page data structure. */
    80 struct UIDataSettingsSharedFolders
    81 {
    82     /** Constructs data. */
    83     UIDataSettingsSharedFolders() {}
    84 
    85     /** Returns whether the @a other passed data is equal to this one. */
    86     bool operator==(const UIDataSettingsSharedFolders & /* other */) const { return true; }
    87     /** Returns whether the @a other passed data is different from this one. */
    88     bool operator!=(const UIDataSettingsSharedFolders & /* other */) const { return false; }
    89 };
    9034typedef UISettingsCachePool<UIDataSettingsSharedFolders, UISettingsCacheSharedFolder> UISettingsCacheSharedFolders;
     35typedef QPair<QString, UISharedFolderType> SFolderName;
     36typedef QList<SFolderName> SFoldersNameList;
    9137
    9238
     
    9945public:
    10046
     47    /** Constructs Shared Folders settings page. */
    10148    UIMachineSettingsSF();
     49    /** Destructs Shared Folders settings page. */
     50    ~UIMachineSettingsSF();
    10251
    10352protected:
     53
     54    /** Returns whether the page content was changed. */
     55    bool changed() const /* override */;
    10456
    10557    /** Loads data into the cache from corresponding external object(s),
     
    12072      * this task COULD be performed in other than the GUI thread. */
    12173    void saveFromCacheTo(UISharedFolderType sharedFoldersType);
    122 
    123     /** Returns whether the page content was changed. */
    124     bool changed() const { return m_cache.wasChanged(); }
    12574
    12675    /** Defines TAB order. */
     
    170119    QString   mTrYes;
    171120
    172     /* Cache: */
    173     UISettingsCacheSharedFolders m_cache;
     121    /** Holds the page data cache instance. */
     122    UISettingsCacheSharedFolders *m_pCache;
    174123};
    175124
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp

    r66163 r66183  
    55
    66/*
    7  * Copyright (C) 2006-2016 Oracle Corporation
     7 * Copyright (C) 2006-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424
    2525/* GUI includes: */
     26# include "QITabWidget.h"
     27# include "QIWidgetValidator.h"
     28# include "UIConverter.h"
    2629# include "UIMachineSettingsSerial.h"
    27 # include "QIWidgetValidator.h"
    2830# include "VBoxGlobal.h"
    29 # include "QITabWidget.h"
    30 # include "UIConverter.h"
    3131
    3232/* COM includes: */
     
    3434
    3535#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     36
     37
     38/** Machine settings: Serial Port tab data structure. */
     39struct UIDataSettingsMachineSerialPort
     40{
     41    /** Constructs data. */
     42    UIDataSettingsMachineSerialPort()
     43        : m_iSlot(-1)
     44        , m_fPortEnabled(false)
     45        , m_uIRQ(0)
     46        , m_uIOBase(0)
     47        , m_hostMode(KPortMode_Disconnected)
     48        , m_fServer(false)
     49        , m_strPath(QString())
     50    {}
     51
     52    /** Returns whether the @a other passed data is equal to this one. */
     53    bool equal(const UIDataSettingsMachineSerialPort &other) const
     54    {
     55        return true
     56               && (m_iSlot == other.m_iSlot)
     57               && (m_fPortEnabled == other.m_fPortEnabled)
     58               && (m_uIRQ == other.m_uIRQ)
     59               && (m_uIOBase == other.m_uIOBase)
     60               && (m_hostMode == other.m_hostMode)
     61               && (m_fServer == other.m_fServer)
     62               && (m_strPath == other.m_strPath)
     63               ;
     64    }
     65
     66    /** Returns whether the @a other passed data is equal to this one. */
     67    bool operator==(const UIDataSettingsMachineSerialPort &other) const { return equal(other); }
     68    /** Returns whether the @a other passed data is different from this one. */
     69    bool operator!=(const UIDataSettingsMachineSerialPort &other) const { return !equal(other); }
     70
     71    /** Holds the serial port slot number. */
     72    int        m_iSlot;
     73    /** Holds whether the serial port is enabled. */
     74    bool       m_fPortEnabled;
     75    /** Holds the serial port IRQ. */
     76    ulong      m_uIRQ;
     77    /** Holds the serial port IO base. */
     78    ulong      m_uIOBase;
     79    /** Holds the serial port host mode. */
     80    KPortMode  m_hostMode;
     81    /** Holds whether the serial port is server. */
     82    bool       m_fServer;
     83    /** Holds the serial port path. */
     84    QString    m_strPath;
     85};
     86
     87
     88/** Machine settings: Serial page data structure. */
     89struct UIDataSettingsMachineSerial
     90{
     91    /** Constructs data. */
     92    UIDataSettingsMachineSerial() {}
     93
     94    /** Returns whether the @a other passed data is equal to this one. */
     95    bool operator==(const UIDataSettingsMachineSerial & /* other */) const { return true; }
     96    /** Returns whether the @a other passed data is different from this one. */
     97    bool operator!=(const UIDataSettingsMachineSerial & /* other */) const { return false; }
     98};
     99
     100
     101/** Machine settings: Serial Port tab. */
     102class UIMachineSettingsSerial : public QIWithRetranslateUI<QWidget>,
     103                                public Ui::UIMachineSettingsSerial
     104{
     105    Q_OBJECT;
     106
     107public:
     108
     109    UIMachineSettingsSerial(UIMachineSettingsSerialPage *pParent);
     110
     111    void polishTab();
     112
     113    void fetchPortData(const UISettingsCacheMachineSerialPort &data);
     114    void uploadPortData(UISettingsCacheMachineSerialPort &data);
     115
     116    QWidget* setOrderAfter (QWidget *aAfter);
     117
     118    QString pageTitle() const;
     119    bool isUserDefined();
     120
     121protected:
     122
     123    void retranslateUi();
     124
     125private slots:
     126
     127    void mGbSerialToggled (bool aOn);
     128    void mCbNumberActivated (const QString &aText);
     129    void mCbModeActivated (const QString &aText);
     130
     131private:
     132
     133    /* Helper: Prepare stuff: */
     134    void prepareValidation();
     135
     136    UIMachineSettingsSerialPage *m_pParent;
     137    int m_iSlot;
     138};
    36139
    37140
     
    227330UIMachineSettingsSerialPage::UIMachineSettingsSerialPage()
    228331    : mTabWidget(0)
     332    , m_pCache(new UISettingsCacheMachineSerial)
    229333{
    230334    /* TabWidget creation */
     
    245349}
    246350
     351UIMachineSettingsSerialPage::~UIMachineSettingsSerialPage()
     352{
     353    /* Cleanup cache: */
     354    delete m_pCache;
     355    m_pCache = 0;
     356}
     357
     358bool UIMachineSettingsSerialPage::changed() const
     359{
     360    return m_pCache->wasChanged();
     361}
     362
    247363void UIMachineSettingsSerialPage::loadToCacheFrom(QVariant &data)
    248364{
     
    251367
    252368    /* Clear cache initially: */
    253     m_cache.clear();
     369    m_pCache->clear();
    254370
    255371    /* For each serial port: */
     
    274390
    275391        /* Cache port data: */
    276         m_cache.child(iSlot).cacheInitialData(portData);
     392        m_pCache->child(iSlot).cacheInitialData(portData);
    277393    }
    278394
     
    295411
    296412        /* Load port data to page: */
    297         pPage->fetchPortData(m_cache.child(iPort));
     413        pPage->fetchPortData(m_pCache->child(iPort));
    298414
    299415        /* Setup tab order: */
     
    320436
    321437        /* Gather & cache port data: */
    322         pPage->uploadPortData(m_cache.child(iPort));
     438        pPage->uploadPortData(m_pCache->child(iPort));
    323439    }
    324440}
     
    330446
    331447    /* Check if ports data was changed: */
    332     if (m_cache.wasChanged())
     448    if (m_pCache->wasChanged())
    333449    {
    334450        /* For each serial port: */
     
    336452        {
    337453            /* Check if port data was changed: */
    338             const UISettingsCacheMachineSerialPort &portCache = m_cache.child(iPort);
     454            const UISettingsCacheMachineSerialPort &portCache = m_pCache->child(iPort);
    339455            if (portCache.wasChanged())
    340456            {
     
    458574        mTabWidget->setTabEnabled(iPort,
    459575                                  isMachineOffline() ||
    460                                   (isMachineInValidMode() && m_cache.child(iPort).base().m_fPortEnabled));
     576                                  (isMachineInValidMode() && m_pCache->child(iPort).base().m_fPortEnabled));
    461577        UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(mTabWidget->widget(iPort));
    462578        pTab->polishTab();
     
    464580}
    465581
     582# include "UIMachineSettingsSerial.moc"
     583
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.h

    r66176 r66183  
    2424
    2525/* Forward declarations: */
     26class QITabWidget;
    2627class UIMachineSettingsSerialPage;
    27 class QITabWidget;
    28 
    29 
    30 /** Machine settings: Serial Port tab data structure. */
    31 struct UIDataSettingsMachineSerialPort
    32 {
    33     /** Constructs data. */
    34     UIDataSettingsMachineSerialPort()
    35         : m_iSlot(-1)
    36         , m_fPortEnabled(false)
    37         , m_uIRQ(0)
    38         , m_uIOBase(0)
    39         , m_hostMode(KPortMode_Disconnected)
    40         , m_fServer(false)
    41         , m_strPath(QString())
    42     {}
    43 
    44     /** Returns whether the @a other passed data is equal to this one. */
    45     bool equal(const UIDataSettingsMachineSerialPort &other) const
    46     {
    47         return true
    48                && (m_iSlot == other.m_iSlot)
    49                && (m_fPortEnabled == other.m_fPortEnabled)
    50                && (m_uIRQ == other.m_uIRQ)
    51                && (m_uIOBase == other.m_uIOBase)
    52                && (m_hostMode == other.m_hostMode)
    53                && (m_fServer == other.m_fServer)
    54                && (m_strPath == other.m_strPath)
    55                ;
    56     }
    57 
    58     /** Returns whether the @a other passed data is equal to this one. */
    59     bool operator==(const UIDataSettingsMachineSerialPort &other) const { return equal(other); }
    60     /** Returns whether the @a other passed data is different from this one. */
    61     bool operator!=(const UIDataSettingsMachineSerialPort &other) const { return !equal(other); }
    62 
    63     /** Holds the serial port slot number. */
    64     int        m_iSlot;
    65     /** Holds whether the serial port is enabled. */
    66     bool       m_fPortEnabled;
    67     /** Holds the serial port IRQ. */
    68     ulong      m_uIRQ;
    69     /** Holds the serial port IO base. */
    70     ulong      m_uIOBase;
    71     /** Holds the serial port host mode. */
    72     KPortMode  m_hostMode;
    73     /** Holds whether the serial port is server. */
    74     bool       m_fServer;
    75     /** Holds the serial port path. */
    76     QString    m_strPath;
    77 };
     28struct UIDataSettingsMachineSerial;
     29struct UIDataSettingsMachineSerialPort;
    7830typedef UISettingsCache<UIDataSettingsMachineSerialPort> UISettingsCacheMachineSerialPort;
    79 
    80 
    81 /** Machine settings: Serial page data structure. */
    82 struct UIDataSettingsMachineSerial
    83 {
    84     /** Constructs data. */
    85     UIDataSettingsMachineSerial() {}
    86 
    87     /** Returns whether the @a other passed data is equal to this one. */
    88     bool operator==(const UIDataSettingsMachineSerial & /* other */) const { return true; }
    89     /** Returns whether the @a other passed data is different from this one. */
    90     bool operator!=(const UIDataSettingsMachineSerial & /* other */) const { return false; }
    91 };
    9231typedef UISettingsCachePool<UIDataSettingsMachineSerial, UISettingsCacheMachineSerialPort> UISettingsCacheMachineSerial;
    93 
    94 
    95 /** Machine settings: Serial Port tab. */
    96 class UIMachineSettingsSerial : public QIWithRetranslateUI<QWidget>,
    97                                 public Ui::UIMachineSettingsSerial
    98 {
    99     Q_OBJECT;
    100 
    101 public:
    102 
    103     UIMachineSettingsSerial(UIMachineSettingsSerialPage *pParent);
    104 
    105     void polishTab();
    106 
    107     void fetchPortData(const UISettingsCacheMachineSerialPort &data);
    108     void uploadPortData(UISettingsCacheMachineSerialPort &data);
    109 
    110     QWidget* setOrderAfter (QWidget *aAfter);
    111 
    112     QString pageTitle() const;
    113     bool isUserDefined();
    114 
    115 protected:
    116 
    117     void retranslateUi();
    118 
    119 private slots:
    120 
    121     void mGbSerialToggled (bool aOn);
    122     void mCbNumberActivated (const QString &aText);
    123     void mCbModeActivated (const QString &aText);
    124 
    125 private:
    126 
    127     /* Helper: Prepare stuff: */
    128     void prepareValidation();
    129 
    130     UIMachineSettingsSerialPage *m_pParent;
    131     int m_iSlot;
    132 };
    13332
    13433
     
    14039public:
    14140
     41    /** Constructs Serial settings page. */
    14242    UIMachineSettingsSerialPage();
     43    /** Destructs Serial settings page. */
     44    ~UIMachineSettingsSerialPage();
    14345
    14446protected:
     47
     48    /** Returns whether the page content was changed. */
     49    bool changed() const /* override */;
    14550
    14651    /** Loads data into the cache from corresponding external object(s),
     
    15863    void saveFromCacheTo(QVariant &data);
    15964
    160     /** Returns whether the page content was changed. */
    161     bool changed() const { return m_cache.wasChanged(); }
    162 
    16365    /** Performs validation, updates @a messages list if something is wrong. */
    16466    bool validate(QList<UIValidationMessage> &messages);
     
    17375    QITabWidget *mTabWidget;
    17476
    175     /* Cache: */
    176     UISettingsCacheMachineSerial m_cache;
     77    /** Holds the page data cache instance. */
     78    UISettingsCacheMachineSerial *m_pCache;
    17779};
    17880
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r66163 r66183  
    5454    return QString ("<nobr><compact elipsis=\"end\">%1</compact></nobr>").arg (aText);
    5555}
     56
     57
     58/** Machine settings: Storage Attachment data structure. */
     59struct UIDataSettingsMachineStorageAttachment
     60{
     61    /** Constructs data. */
     62    UIDataSettingsMachineStorageAttachment()
     63        : m_attachmentType(KDeviceType_Null)
     64        , m_iAttachmentPort(-1)
     65        , m_iAttachmentDevice(-1)
     66        , m_strAttachmentMediumId(QString())
     67        , m_fAttachmentPassthrough(false)
     68        , m_fAttachmentTempEject(false)
     69        , m_fAttachmentNonRotational(false)
     70        , m_fAttachmentHotPluggable(false)
     71    {}
     72
     73    /** Returns whether the @a other passed data is equal to this one. */
     74    bool equal(const UIDataSettingsMachineStorageAttachment &other) const
     75    {
     76        return true
     77               && (m_attachmentType == other.m_attachmentType)
     78               && (m_iAttachmentPort == other.m_iAttachmentPort)
     79               && (m_iAttachmentDevice == other.m_iAttachmentDevice)
     80               && (m_strAttachmentMediumId == other.m_strAttachmentMediumId)
     81               && (m_fAttachmentPassthrough == other.m_fAttachmentPassthrough)
     82               && (m_fAttachmentTempEject == other.m_fAttachmentTempEject)
     83               && (m_fAttachmentNonRotational == other.m_fAttachmentNonRotational)
     84               && (m_fAttachmentHotPluggable == other.m_fAttachmentHotPluggable)
     85               ;
     86    }
     87
     88    /** Returns whether the @a other passed data is equal to this one. */
     89    bool operator==(const UIDataSettingsMachineStorageAttachment &other) const { return equal(other); }
     90    /** Returns whether the @a other passed data is different from this one. */
     91    bool operator!=(const UIDataSettingsMachineStorageAttachment &other) const { return !equal(other); }
     92
     93    /** Holds the attachment type. */
     94    KDeviceType  m_attachmentType;
     95    /** Holds the attachment port. */
     96    LONG         m_iAttachmentPort;
     97    /** Holds the attachment device. */
     98    LONG         m_iAttachmentDevice;
     99    /** Holds the attachment medium ID. */
     100    QString      m_strAttachmentMediumId;
     101    /** Holds whether the attachment being passed through. */
     102    bool         m_fAttachmentPassthrough;
     103    /** Holds whether the attachment being temporarily eject. */
     104    bool         m_fAttachmentTempEject;
     105    /** Holds whether the attachment is solid-state. */
     106    bool         m_fAttachmentNonRotational;
     107    /** Holds whether the attachment is hot-pluggable. */
     108    bool         m_fAttachmentHotPluggable;
     109};
     110
     111
     112/** Machine settings: Storage Controller data structure. */
     113struct UIDataSettingsMachineStorageController
     114{
     115    /** Constructs data. */
     116    UIDataSettingsMachineStorageController()
     117        : m_strControllerName(QString())
     118        , m_controllerBus(KStorageBus_Null)
     119        , m_controllerType(KStorageControllerType_Null)
     120        , m_uPortCount(0)
     121        , m_fUseHostIOCache(false)
     122    {}
     123
     124    /** Returns whether the @a other passed data is equal to this one. */
     125    bool equal(const UIDataSettingsMachineStorageController &other) const
     126    {
     127        return true
     128               && (m_strControllerName == other.m_strControllerName)
     129               && (m_controllerBus == other.m_controllerBus)
     130               && (m_controllerType == other.m_controllerType)
     131               && (m_uPortCount == other.m_uPortCount)
     132               && (m_fUseHostIOCache == other.m_fUseHostIOCache)
     133               ;
     134    }
     135
     136    /** Returns whether the @a other passed data is equal to this one. */
     137    bool operator==(const UIDataSettingsMachineStorageController &other) const { return equal(other); }
     138    /** Returns whether the @a other passed data is different from this one. */
     139    bool operator!=(const UIDataSettingsMachineStorageController &other) const { return !equal(other); }
     140
     141    /** Holds the controller name. */
     142    QString                 m_strControllerName;
     143    /** Holds the controller bus. */
     144    KStorageBus             m_controllerBus;
     145    /** Holds the controller type. */
     146    KStorageControllerType  m_controllerType;
     147    /** Holds the controller port count. */
     148    uint                    m_uPortCount;
     149    /** Holds whether the controller uses host IO cache. */
     150    bool                    m_fUseHostIOCache;
     151};
     152
     153
     154/** Machine settings: Storage page data structure. */
     155struct UIDataSettingsMachineStorage
     156{
     157    /** Constructs data. */
     158    UIDataSettingsMachineStorage() {}
     159
     160    /** Returns whether the @a other passed data is equal to this one. */
     161    bool operator==(const UIDataSettingsMachineStorage& /* other */) const { return true; }
     162    /** Returns whether the @a other passed data is different from this one. */
     163    bool operator!=(const UIDataSettingsMachineStorage& /* other */) const { return false; }
     164};
    56165
    57166
     
    20102119    , mIsPolished(false)
    20112120    , mDisableStaticControls(0)
     2121    , m_pCache(new UISettingsCacheMachineStorage)
    20122122{
    20132123    /* Apply UI decorations */
     
    21802290    /* Destroy icon-pool: */
    21812291    UIIconPoolStorageSettings::destroy();
     2292
     2293    /* Cleanup cache: */
     2294    delete m_pCache;
     2295    m_pCache = 0;
    21822296}
    21832297
     
    21962310}
    21972311
     2312bool UIMachineSettingsStorage::changed() const
     2313{
     2314    return m_pCache->wasChanged();
     2315}
     2316
    21982317void UIMachineSettingsStorage::loadToCacheFrom(QVariant &data)
    21992318{
     
    22022321
    22032322    /* Clear cache initially: */
    2204     m_cache.clear();
     2323    m_pCache->clear();
    22052324
    22062325    /* Gather storage data: */
     
    22622381
    22632382                /* Cache storage attachment data: */
    2264                 m_cache.child(iControllerIndex).child(iAttachmentIndex).cacheInitialData(storageAttachmentData);
     2383                m_pCache->child(iControllerIndex).child(iAttachmentIndex).cacheInitialData(storageAttachmentData);
    22652384            }
    22662385        }
    22672386
    22682387        /* Cache storage controller data: */
    2269         m_cache.child(iControllerIndex).cacheInitialData(storageControllerData);
     2388        m_pCache->child(iControllerIndex).cacheInitialData(storageControllerData);
    22702389    }
    22712390
     
    22832402
    22842403    /* For each storage controller: */
    2285     for (int iControllerIndex = 0; iControllerIndex < m_cache.childCount(); ++iControllerIndex)
     2404    for (int iControllerIndex = 0; iControllerIndex < m_pCache->childCount(); ++iControllerIndex)
    22862405    {
    22872406        /* Get storage controller cache: */
    2288         const UISettingsCacheMachineStorageController &controllerCache = m_cache.child(iControllerIndex);
     2407        const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex);
    22892408        /* Get storage controller data from cache: */
    22902409        const UIDataSettingsMachineStorageController &controllerData = controllerCache.base();
     
    23352454{
    23362455    /* Prepare storage data: */
    2337     UIDataSettingsMachineStorage storageData = m_cache.base();
     2456    UIDataSettingsMachineStorage storageData = m_pCache->base();
    23382457
    23392458    /* For each storage controller: */
     
    23712490
    23722491            /* Recache storage attachment data: */
    2373             m_cache.child(iControllerIndex).child(iAttachmentIndex).cacheCurrentData(attachmentData);
     2492            m_pCache->child(iControllerIndex).child(iAttachmentIndex).cacheCurrentData(attachmentData);
    23742493        }
    23752494
    23762495        /* Recache storage controller data: */
    2377         m_cache.child(iControllerIndex).cacheCurrentData(controllerData);
     2496        m_pCache->child(iControllerIndex).cacheCurrentData(controllerData);
    23782497    }
    23792498
    23802499    /* Recache storage data: */
    2381     m_cache.cacheCurrentData(storageData);
     2500    m_pCache->cacheCurrentData(storageData);
    23822501}
    23832502
     
    35763695    {
    35773696        /* Check if storage data was changed: */
    3578         if (m_cache.wasChanged())
     3697        if (m_pCache->wasChanged())
    35793698        {
    35803699            /* For each controller (removing step): */
    3581             for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_cache.childCount(); ++iControllerIndex)
     3700            for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_pCache->childCount(); ++iControllerIndex)
    35823701            {
    35833702                /* Get controller cache: */
    3584                 const UISettingsCacheMachineStorageController &controllerCache = m_cache.child(iControllerIndex);
     3703                const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex);
    35853704
    35863705                /* Remove controllers marked for 'remove' and 'update' (if they can't be updated): */
     
    36073726
    36083727            /* For each controller (creating step): */
    3609             for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_cache.childCount(); ++iControllerIndex)
     3728            for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_pCache->childCount(); ++iControllerIndex)
    36103729            {
    36113730                /* Get controller cache: */
    3612                 const UISettingsCacheMachineStorageController &controllerCache = m_cache.child(iControllerIndex);
     3731                const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex);
    36133732
    36143733                /* Create controllers marked for 'create' or 'update' (if they can't be updated): */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r66176 r66183  
    3838class ControllerItem;
    3939class UIMediumIDHolder;
     40struct UIDataSettingsMachineStorage;
     41struct UIDataSettingsMachineStorageController;
     42struct UIDataSettingsMachineStorageAttachment;
     43typedef UISettingsCache<UIDataSettingsMachineStorageAttachment> UISettingsCacheMachineStorageAttachment;
     44typedef UISettingsCachePool<UIDataSettingsMachineStorageController, UISettingsCacheMachineStorageAttachment> UISettingsCacheMachineStorageController;
     45typedef UISettingsCachePool<UIDataSettingsMachineStorage, UISettingsCacheMachineStorageController> UISettingsCacheMachineStorage;
    4046
    4147/* Internal Types */
     
    4652Q_DECLARE_METATYPE (DeviceTypeList);
    4753Q_DECLARE_METATYPE (ControllerTypeList);
     54
    4855
    4956/** Known item states. */
     
    589596
    590597
    591 /** Machine settings: Storage Attachment data structure. */
    592 struct UIDataSettingsMachineStorageAttachment
    593 {
    594     /** Constructs data. */
    595     UIDataSettingsMachineStorageAttachment()
    596         : m_attachmentType(KDeviceType_Null)
    597         , m_iAttachmentPort(-1)
    598         , m_iAttachmentDevice(-1)
    599         , m_strAttachmentMediumId(QString())
    600         , m_fAttachmentPassthrough(false)
    601         , m_fAttachmentTempEject(false)
    602         , m_fAttachmentNonRotational(false)
    603         , m_fAttachmentHotPluggable(false)
    604     {}
    605 
    606     /** Returns whether the @a other passed data is equal to this one. */
    607     bool equal(const UIDataSettingsMachineStorageAttachment &other) const
    608     {
    609         return true
    610                && (m_attachmentType == other.m_attachmentType)
    611                && (m_iAttachmentPort == other.m_iAttachmentPort)
    612                && (m_iAttachmentDevice == other.m_iAttachmentDevice)
    613                && (m_strAttachmentMediumId == other.m_strAttachmentMediumId)
    614                && (m_fAttachmentPassthrough == other.m_fAttachmentPassthrough)
    615                && (m_fAttachmentTempEject == other.m_fAttachmentTempEject)
    616                && (m_fAttachmentNonRotational == other.m_fAttachmentNonRotational)
    617                && (m_fAttachmentHotPluggable == other.m_fAttachmentHotPluggable)
    618                ;
    619     }
    620 
    621     /** Returns whether the @a other passed data is equal to this one. */
    622     bool operator==(const UIDataSettingsMachineStorageAttachment &other) const { return equal(other); }
    623     /** Returns whether the @a other passed data is different from this one. */
    624     bool operator!=(const UIDataSettingsMachineStorageAttachment &other) const { return !equal(other); }
    625 
    626     /** Holds the attachment type. */
    627     KDeviceType  m_attachmentType;
    628     /** Holds the attachment port. */
    629     LONG         m_iAttachmentPort;
    630     /** Holds the attachment device. */
    631     LONG         m_iAttachmentDevice;
    632     /** Holds the attachment medium ID. */
    633     QString      m_strAttachmentMediumId;
    634     /** Holds whether the attachment being passed through. */
    635     bool         m_fAttachmentPassthrough;
    636     /** Holds whether the attachment being temporarily eject. */
    637     bool         m_fAttachmentTempEject;
    638     /** Holds whether the attachment is solid-state. */
    639     bool         m_fAttachmentNonRotational;
    640     /** Holds whether the attachment is hot-pluggable. */
    641     bool         m_fAttachmentHotPluggable;
    642 };
    643 typedef UISettingsCache<UIDataSettingsMachineStorageAttachment> UISettingsCacheMachineStorageAttachment;
    644 
    645 
    646 /** Machine settings: Storage Controller data structure. */
    647 struct UIDataSettingsMachineStorageController
    648 {
    649     /** Constructs data. */
    650     UIDataSettingsMachineStorageController()
    651         : m_strControllerName(QString())
    652         , m_controllerBus(KStorageBus_Null)
    653         , m_controllerType(KStorageControllerType_Null)
    654         , m_uPortCount(0)
    655         , m_fUseHostIOCache(false)
    656     {}
    657 
    658     /** Returns whether the @a other passed data is equal to this one. */
    659     bool equal(const UIDataSettingsMachineStorageController &other) const
    660     {
    661         return true
    662                && (m_strControllerName == other.m_strControllerName)
    663                && (m_controllerBus == other.m_controllerBus)
    664                && (m_controllerType == other.m_controllerType)
    665                && (m_uPortCount == other.m_uPortCount)
    666                && (m_fUseHostIOCache == other.m_fUseHostIOCache)
    667                ;
    668     }
    669 
    670     /** Returns whether the @a other passed data is equal to this one. */
    671     bool operator==(const UIDataSettingsMachineStorageController &other) const { return equal(other); }
    672     /** Returns whether the @a other passed data is different from this one. */
    673     bool operator!=(const UIDataSettingsMachineStorageController &other) const { return !equal(other); }
    674 
    675     /** Holds the controller name. */
    676     QString                 m_strControllerName;
    677     /** Holds the controller bus. */
    678     KStorageBus             m_controllerBus;
    679     /** Holds the controller type. */
    680     KStorageControllerType  m_controllerType;
    681     /** Holds the controller port count. */
    682     uint                    m_uPortCount;
    683     /** Holds whether the controller uses host IO cache. */
    684     bool                    m_fUseHostIOCache;
    685 };
    686 typedef UISettingsCachePool<UIDataSettingsMachineStorageController, UISettingsCacheMachineStorageAttachment> UISettingsCacheMachineStorageController;
    687 
    688 
    689 /** Machine settings: Storage page data structure. */
    690 struct UIDataSettingsMachineStorage
    691 {
    692     /** Constructs data. */
    693     UIDataSettingsMachineStorage() {}
    694 
    695     /** Returns whether the @a other passed data is equal to this one. */
    696     bool operator==(const UIDataSettingsMachineStorage& /* other */) const { return true; }
    697     /** Returns whether the @a other passed data is different from this one. */
    698     bool operator!=(const UIDataSettingsMachineStorage& /* other */) const { return false; }
    699 };
    700 typedef UISettingsCachePool<UIDataSettingsMachineStorage, UISettingsCacheMachineStorageController> UISettingsCacheMachineStorage;
    701 
    702 
    703598/** Machine settings: Storage page. */
    704599class UIMachineSettingsStorage : public UISettingsPageMachine,
     
    709604public:
    710605
     606    /** Constructs Storage settings page. */
    711607    UIMachineSettingsStorage();
     608    /** Destructs Storage settings page. */
    712609    ~UIMachineSettingsStorage();
    713610
     
    719616
    720617protected:
     618
     619    /** Returns whether the page content was changed. */
     620    bool changed() const /* override */;
    721621
    722622    /** Loads data into the cache from corresponding external object(s),
     
    733633      * this task COULD be performed in other than the GUI thread. */
    734634    void saveFromCacheTo(QVariant &data);
    735 
    736     /** Returns whether the page content was changed. */
    737     bool changed() const { return m_cache.wasChanged(); }
    738635
    739636    /** Performs validation, updates @a messages list if something is wrong. */
     
    857754    bool mDisableStaticControls;
    858755
    859     /* Cache: */
    860     UISettingsCacheMachineStorage m_cache;
     756    /** Holds the page data cache instance. */
     757    UISettingsCacheMachineStorage *m_pCache;
    861758};
    862759
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r66163 r66183  
    55
    66/*
    7  * Copyright (C) 2008-2016 Oracle Corporation
     7 * Copyright (C) 2008-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2525/* GUI includes: */
    2626# include "QIWidgetValidator.h"
     27# include "UIConverter.h"
    2728# include "UIIconPool.h"
     29# include "UIMachineSettingsSystem.h"
    2830# include "VBoxGlobal.h"
    29 # include "UIMachineSettingsSystem.h"
    30 # include "UIConverter.h"
    3131
    3232/* COM includes: */
     
    3737
    3838#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     39
     40
     41/** Machine settings: System Boot data structure. */
     42struct UIBootItemData
     43{
     44    /** Constructs data. */
     45    UIBootItemData()
     46        : m_type(KDeviceType_Null)
     47        , m_fEnabled(false)
     48    {}
     49
     50    /** Returns whether the @a other passed data is equal to this one. */
     51    bool operator==(const UIBootItemData &other) const
     52    {
     53        return true
     54               && (m_type == other.m_type)
     55               && (m_fEnabled == other.m_fEnabled)
     56               ;
     57    }
     58
     59    /** Holds the boot device type. */
     60    KDeviceType m_type;
     61    /** Holds whether the boot device enabled. */
     62    bool m_fEnabled;
     63};
     64
     65
     66/** Machine settings: System page data structure. */
     67struct UIDataSettingsMachineSystem
     68{
     69    /** Constructs data. */
     70    UIDataSettingsMachineSystem()
     71        /* Support flags: */
     72        : m_fSupportedPAE(false)
     73        , m_fSupportedHwVirtEx(false)
     74        /* Motherboard data: */
     75        , m_iMemorySize(-1)
     76        , m_bootItems(QList<UIBootItemData>())
     77        , m_chipsetType(KChipsetType_Null)
     78        , m_pointingHIDType(KPointingHIDType_None)
     79        , m_fEnabledIoApic(false)
     80        , m_fEnabledEFI(false)
     81        , m_fEnabledUTC(false)
     82        /* CPU data: */
     83        , m_cCPUCount(-1)
     84        , m_iCPUExecCap(-1)
     85        , m_fEnabledPAE(false)
     86        /* Acceleration data: */
     87        , m_paravirtProvider(KParavirtProvider_None)
     88        , m_fEnabledHwVirtEx(false)
     89        , m_fEnabledNestedPaging(false)
     90    {}
     91
     92    /** Returns whether the @a other passed data is equal to this one. */
     93    bool equal(const UIDataSettingsMachineSystem &other) const
     94    {
     95        return true
     96               /* Support flags: */
     97               && (m_fSupportedPAE == other.m_fSupportedPAE)
     98               && (m_fSupportedHwVirtEx == other.m_fSupportedHwVirtEx)
     99               /* Motherboard data: */
     100               && (m_iMemorySize == other.m_iMemorySize)
     101               && (m_bootItems == other.m_bootItems)
     102               && (m_chipsetType == other.m_chipsetType)
     103               && (m_pointingHIDType == other.m_pointingHIDType)
     104               && (m_fEnabledIoApic == other.m_fEnabledIoApic)
     105               && (m_fEnabledEFI == other.m_fEnabledEFI)
     106               && (m_fEnabledUTC == other.m_fEnabledUTC)
     107               /* CPU data: */
     108               && (m_cCPUCount == other.m_cCPUCount)
     109               && (m_iCPUExecCap == other.m_iCPUExecCap)
     110               && (m_fEnabledPAE == other.m_fEnabledPAE)
     111               /* Acceleration data: */
     112               && (m_paravirtProvider == other.m_paravirtProvider)
     113               && (m_fEnabledHwVirtEx == other.m_fEnabledHwVirtEx)
     114               && (m_fEnabledNestedPaging == other.m_fEnabledNestedPaging)
     115               ;
     116    }
     117
     118    /** Returns whether the @a other passed data is equal to this one. */
     119    bool operator==(const UIDataSettingsMachineSystem &other) const { return equal(other); }
     120    /** Returns whether the @a other passed data is different from this one. */
     121    bool operator!=(const UIDataSettingsMachineSystem &other) const { return !equal(other); }
     122
     123    /** Holds whether the PAE is supported. */
     124    bool  m_fSupportedPAE;
     125    /** Holds whether the HW Virt Ex is supported. */
     126    bool  m_fSupportedHwVirtEx;
     127
     128    /** Holds the RAM size. */
     129    int                    m_iMemorySize;
     130    /** Holds the boot items. */
     131    QList<UIBootItemData>  m_bootItems;
     132    /** Holds the chipset type. */
     133    KChipsetType           m_chipsetType;
     134    /** Holds the pointing HID type. */
     135    KPointingHIDType       m_pointingHIDType;
     136    /** Holds whether the IO APIC is enabled. */
     137    bool                   m_fEnabledIoApic;
     138    /** Holds whether the EFI is enabled. */
     139    bool                   m_fEnabledEFI;
     140    /** Holds whether the UTC is enabled. */
     141    bool                   m_fEnabledUTC;
     142
     143    /** Holds the CPU count. */
     144    int   m_cCPUCount;
     145    /** Holds the CPU execution cap. */
     146    int   m_iCPUExecCap;
     147    /** Holds whether the PAE is enabled. */
     148    bool  m_fEnabledPAE;
     149
     150    /** Holds the paravirtualization provider. */
     151    KParavirtProvider  m_paravirtProvider;
     152    /** Holds whether the HW Virt Ex is enabled. */
     153    bool               m_fEnabledHwVirtEx;
     154    /** Holds whether the Nested Paging is enabled. */
     155    bool               m_fEnabledNestedPaging;
     156};
    39157
    40158
     
    43161    , m_uMinGuestCPUExecCap(0), m_uMedGuestCPUExecCap(0), m_uMaxGuestCPUExecCap(0)
    44162    , m_fIsUSBEnabled(false)
     163    , m_pCache(new UISettingsCacheMachineSystem)
    45164{
    46165    /* Prepare: */
    47166    prepare();
     167}
     168
     169UIMachineSettingsSystem::~UIMachineSettingsSystem()
     170{
     171    /* Cleanup cache: */
     172    delete m_pCache;
     173    m_pCache = 0;
    48174}
    49175
     
    76202}
    77203
     204bool UIMachineSettingsSystem::changed() const
     205{
     206    return m_pCache->wasChanged();
     207}
     208
    78209void UIMachineSettingsSystem::loadToCacheFrom(QVariant &data)
    79210{
     
    82213
    83214    /* Clear cache initially: */
    84     m_cache.clear();
     215    m_pCache->clear();
    85216
    86217    /* Prepare system data: */
     
    137268
    138269    /* Cache system data: */
    139     m_cache.cacheInitialData(systemData);
     270    m_pCache->cacheInitialData(systemData);
    140271
    141272    /* Upload machine to data: */
     
    146277{
    147278    /* Get system data from cache: */
    148     const UIDataSettingsMachineSystem &systemData = m_cache.base();
     279    const UIDataSettingsMachineSystem &systemData = m_pCache->base();
    149280
    150281    /* Repopulate 'pointing HID type' combo.
     
    196327{
    197328    /* Prepare system data: */
    198     UIDataSettingsMachineSystem systemData = m_cache.base();
     329    UIDataSettingsMachineSystem systemData = m_pCache->base();
    199330
    200331    /* Gather motherboard data: */
     
    229360
    230361    /* Cache system data: */
    231     m_cache.cacheCurrentData(systemData);
     362    m_pCache->cacheCurrentData(systemData);
    232363}
    233364
     
    238369
    239370    /* Check if system data was changed: */
    240     if (m_cache.wasChanged())
     371    if (m_pCache->wasChanged())
    241372    {
    242373        /* Get system data from cache: */
    243         const UIDataSettingsMachineSystem &systemData = m_cache.data();
     374        const UIDataSettingsMachineSystem &systemData = m_pCache->data();
    244375
    245376        /* Store system data: */
     
    457588{
    458589    /* Get system data from cache: */
    459     const UIDataSettingsMachineSystem &systemData = m_cache.base();
     590    const UIDataSettingsMachineSystem &systemData = m_pCache->base();
    460591
    461592    /* Motherboard tab: */
     
    751882
    752883    /* Repopulate combo taking into account currently cached value: */
    753     KPointingHIDType cachedValue = m_cache.base().m_pointingHIDType;
     884    KPointingHIDType cachedValue = m_pCache->base().m_pointingHIDType;
    754885    {
    755886        /* "PS/2 Mouse" value is always here: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r66176 r66183  
    2323#include "UIMachineSettingsSystem.gen.h"
    2424
    25 
    26 /** Machine settings: System Boot data structure. */
    27 struct UIBootItemData
    28 {
    29     /** Constructs data. */
    30     UIBootItemData()
    31         : m_type(KDeviceType_Null)
    32         , m_fEnabled(false)
    33     {}
    34 
    35     /** Returns whether the @a other passed data is equal to this one. */
    36     bool operator==(const UIBootItemData &other) const
    37     {
    38         return true
    39                && (m_type == other.m_type)
    40                && (m_fEnabled == other.m_fEnabled)
    41                ;
    42     }
    43 
    44     /** Holds the boot device type. */
    45     KDeviceType m_type;
    46     /** Holds whether the boot device enabled. */
    47     bool m_fEnabled;
    48 };
    49 
    50 
    51 /** Machine settings: System page data structure. */
    52 struct UIDataSettingsMachineSystem
    53 {
    54     /** Constructs data. */
    55     UIDataSettingsMachineSystem()
    56         /* Support flags: */
    57         : m_fSupportedPAE(false)
    58         , m_fSupportedHwVirtEx(false)
    59         /* Motherboard data: */
    60         , m_iMemorySize(-1)
    61         , m_bootItems(QList<UIBootItemData>())
    62         , m_chipsetType(KChipsetType_Null)
    63         , m_pointingHIDType(KPointingHIDType_None)
    64         , m_fEnabledIoApic(false)
    65         , m_fEnabledEFI(false)
    66         , m_fEnabledUTC(false)
    67         /* CPU data: */
    68         , m_cCPUCount(-1)
    69         , m_iCPUExecCap(-1)
    70         , m_fEnabledPAE(false)
    71         /* Acceleration data: */
    72         , m_paravirtProvider(KParavirtProvider_None)
    73         , m_fEnabledHwVirtEx(false)
    74         , m_fEnabledNestedPaging(false)
    75     {}
    76 
    77     /** Returns whether the @a other passed data is equal to this one. */
    78     bool equal(const UIDataSettingsMachineSystem &other) const
    79     {
    80         return true
    81                /* Support flags: */
    82                && (m_fSupportedPAE == other.m_fSupportedPAE)
    83                && (m_fSupportedHwVirtEx == other.m_fSupportedHwVirtEx)
    84                /* Motherboard data: */
    85                && (m_iMemorySize == other.m_iMemorySize)
    86                && (m_bootItems == other.m_bootItems)
    87                && (m_chipsetType == other.m_chipsetType)
    88                && (m_pointingHIDType == other.m_pointingHIDType)
    89                && (m_fEnabledIoApic == other.m_fEnabledIoApic)
    90                && (m_fEnabledEFI == other.m_fEnabledEFI)
    91                && (m_fEnabledUTC == other.m_fEnabledUTC)
    92                /* CPU data: */
    93                && (m_cCPUCount == other.m_cCPUCount)
    94                && (m_iCPUExecCap == other.m_iCPUExecCap)
    95                && (m_fEnabledPAE == other.m_fEnabledPAE)
    96                /* Acceleration data: */
    97                && (m_paravirtProvider == other.m_paravirtProvider)
    98                && (m_fEnabledHwVirtEx == other.m_fEnabledHwVirtEx)
    99                && (m_fEnabledNestedPaging == other.m_fEnabledNestedPaging)
    100                ;
    101     }
    102 
    103     /** Returns whether the @a other passed data is equal to this one. */
    104     bool operator==(const UIDataSettingsMachineSystem &other) const { return equal(other); }
    105     /** Returns whether the @a other passed data is different from this one. */
    106     bool operator!=(const UIDataSettingsMachineSystem &other) const { return !equal(other); }
    107 
    108     /** Holds whether the PAE is supported. */
    109     bool  m_fSupportedPAE;
    110     /** Holds whether the HW Virt Ex is supported. */
    111     bool  m_fSupportedHwVirtEx;
    112 
    113     /** Holds the RAM size. */
    114     int                    m_iMemorySize;
    115     /** Holds the boot items. */
    116     QList<UIBootItemData>  m_bootItems;
    117     /** Holds the chipset type. */
    118     KChipsetType           m_chipsetType;
    119     /** Holds the pointing HID type. */
    120     KPointingHIDType       m_pointingHIDType;
    121     /** Holds whether the IO APIC is enabled. */
    122     bool                   m_fEnabledIoApic;
    123     /** Holds whether the EFI is enabled. */
    124     bool                   m_fEnabledEFI;
    125     /** Holds whether the UTC is enabled. */
    126     bool                   m_fEnabledUTC;
    127 
    128     /** Holds the CPU count. */
    129     int   m_cCPUCount;
    130     /** Holds the CPU execution cap. */
    131     int   m_iCPUExecCap;
    132     /** Holds whether the PAE is enabled. */
    133     bool  m_fEnabledPAE;
    134 
    135     /** Holds the paravirtualization provider. */
    136     KParavirtProvider  m_paravirtProvider;
    137     /** Holds whether the HW Virt Ex is enabled. */
    138     bool               m_fEnabledHwVirtEx;
    139     /** Holds whether the Nested Paging is enabled. */
    140     bool               m_fEnabledNestedPaging;
    141 };
     25/* Forward declarations: */
     26struct UIDataSettingsMachineSystem;
    14227typedef UISettingsCache<UIDataSettingsMachineSystem> UISettingsCacheMachineSystem;
    14328
     
    15136public:
    15237
    153     /* Constructor: */
     38    /** Constructs System settings page. */
    15439    UIMachineSettingsSystem();
     40    /** Destructs System settings page. */
     41    ~UIMachineSettingsSystem();
    15542
    15643    /* API: Correlation stuff: */
     
    16350
    16451    /** Returns whether the page content was changed. */
    165     bool changed() const { return m_cache.wasChanged(); }
     52    bool changed() const /* override */;
    16653
    16754    /** Loads data into the cache from corresponding external object(s),
     
    242129    bool m_fIsUSBEnabled;
    243130
    244     /* Cache: */
    245     UISettingsCacheMachineSystem m_cache;
     131    /** Holds the page data cache instance. */
     132    UISettingsCacheMachineSystem *m_pCache;
    246133};
    247134
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp

    r66163 r66183  
    55
    66/*
    7  * Copyright (C) 2006-2016 Oracle Corporation
     7 * Copyright (C) 2006-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2727/* GUI includes: */
    2828# include "QIWidgetValidator.h"
     29# include "UIConverter.h"
    2930# include "UIIconPool.h"
    30 # include "VBoxGlobal.h"
     31# include "UIMachineSettingsUSB.h"
     32# include "UIMachineSettingsUSBFilterDetails.h"
    3133# include "UIMessageCenter.h"
    3234# include "UIToolBar.h"
    33 # include "UIMachineSettingsUSB.h"
    34 # include "UIMachineSettingsUSBFilterDetails.h"
    35 # include "UIConverter.h"
     35# include "VBoxGlobal.h"
    3636
    3737/* COM includes: */
     
    5454# include "VirtualBox_XPCOM.h"
    5555#endif /* VBOX_WITH_XPCOM */
     56
     57
     58/** Machine settings: USB filter data structure. */
     59struct UIDataSettingsMachineUSBFilter
     60{
     61    /** Constructs data. */
     62    UIDataSettingsMachineUSBFilter()
     63        : m_fActive(false)
     64        , m_strName(QString())
     65        , m_strVendorId(QString())
     66        , m_strProductId(QString())
     67        , m_strRevision(QString())
     68        , m_strManufacturer(QString())
     69        , m_strProduct(QString())
     70        , m_strSerialNumber(QString())
     71        , m_strPort(QString())
     72        , m_strRemote(QString())
     73        , m_action(KUSBDeviceFilterAction_Null)
     74        , m_fHostUSBDevice(false)
     75        , m_hostUSBDeviceState(KUSBDeviceState_NotSupported)
     76    {}
     77
     78    /** Returns whether the @a other passed data is equal to this one. */
     79    bool equal(const UIDataSettingsMachineUSBFilter &other) const
     80    {
     81        return true
     82               && (m_fActive == other.m_fActive)
     83               && (m_strName == other.m_strName)
     84               && (m_strVendorId == other.m_strVendorId)
     85               && (m_strProductId == other.m_strProductId)
     86               && (m_strRevision == other.m_strRevision)
     87               && (m_strManufacturer == other.m_strManufacturer)
     88               && (m_strProduct == other.m_strProduct)
     89               && (m_strSerialNumber == other.m_strSerialNumber)
     90               && (m_strPort == other.m_strPort)
     91               && (m_strRemote == other.m_strRemote)
     92               && (m_action == other.m_action)
     93               && (m_hostUSBDeviceState == other.m_hostUSBDeviceState)
     94               ;
     95    }
     96
     97    /** Returns whether the @a other passed data is equal to this one. */
     98    bool operator==(const UIDataSettingsMachineUSBFilter &other) const { return equal(other); }
     99    /** Returns whether the @a other passed data is different from this one. */
     100    bool operator!=(const UIDataSettingsMachineUSBFilter &other) const { return !equal(other); }
     101
     102    /** Holds whether the USB filter is enabled. */
     103    bool     m_fActive;
     104    /** Holds the USB filter name. */
     105    QString  m_strName;
     106    /** Holds the USB filter vendor ID. */
     107    QString  m_strVendorId;
     108    /** Holds the USB filter product ID. */
     109    QString  m_strProductId;
     110    /** Holds the USB filter revision. */
     111    QString  m_strRevision;
     112    /** Holds the USB filter manufacturer. */
     113    QString  m_strManufacturer;
     114    /** Holds the USB filter product. */
     115    QString  m_strProduct;
     116    /** Holds the USB filter serial number. */
     117    QString  m_strSerialNumber;
     118    /** Holds the USB filter port. */
     119    QString  m_strPort;
     120    /** Holds the USB filter remote. */
     121    QString  m_strRemote;
     122
     123    /** Holds the USB filter action. */
     124    KUSBDeviceFilterAction  m_action;
     125    /** Holds whether the USB filter is host USB device. */
     126    bool                    m_fHostUSBDevice;
     127    /** Holds the USB device state. */
     128    KUSBDeviceState         m_hostUSBDeviceState;
     129};
     130
     131
     132/** Machine settings: USB page data structure. */
     133struct UIDataSettingsMachineUSB
     134{
     135    /** Constructs data. */
     136    UIDataSettingsMachineUSB()
     137        : m_fUSBEnabled(false)
     138        , m_USBControllerType(KUSBControllerType_Null)
     139    {}
     140
     141    /** Returns whether the @a other passed data is equal to this one. */
     142    bool equal(const UIDataSettingsMachineUSB &other) const
     143    {
     144        return true
     145               && (m_fUSBEnabled == other.m_fUSBEnabled)
     146               && (m_USBControllerType == other.m_USBControllerType)
     147               ;
     148    }
     149
     150    /** Returns whether the @a other passed data is equal to this one. */
     151    bool operator==(const UIDataSettingsMachineUSB &other) const { return equal(other); }
     152    /** Returns whether the @a other passed data is different from this one. */
     153    bool operator!=(const UIDataSettingsMachineUSB &other) const { return !equal(other); }
     154
     155    /** Holds whether the USB is enabled. */
     156    bool m_fUSBEnabled;
     157    /** Holds the USB controller type. */
     158    KUSBControllerType m_USBControllerType;
     159};
    56160
    57161
     
    176280    , mMupAction(0), mMdnAction(0)
    177281    , mUSBDevicesMenu(0)
     282    , m_pCache(new UISettingsCacheMachineUSB)
    178283{
    179284    /* Apply UI decorations */
     
    267372{
    268373    delete mUSBDevicesMenu;
     374
     375    /* Cleanup cache: */
     376    delete m_pCache;
     377    m_pCache = 0;
    269378}
    270379
     
    272381{
    273382    return mGbUSB->isChecked();
     383}
     384
     385bool UIMachineSettingsUSB::changed() const
     386{
     387    return m_pCache->wasChanged();
    274388}
    275389
     
    280394
    281395    /* Clear cache initially: */
    282     m_cache.clear();
     396    m_pCache->clear();
    283397
    284398    /* Prepare USB data: */
     
    320434
    321435            /* Cache USB filter data: */
    322             m_cache.child(iFilterIndex).cacheInitialData(usbFilterData);
     436            m_pCache->child(iFilterIndex).cacheInitialData(usbFilterData);
    323437        }
    324438    }
    325439
    326440    /* Cache USB data: */
    327     m_cache.cacheInitialData(usbData);
     441    m_pCache->cacheInitialData(usbData);
    328442
    329443    /* Upload properties & settings or machine to data: */
     
    338452
    339453    /* Get USB data from cache: */
    340     const UIDataSettingsMachineUSB &usbData = m_cache.base();
     454    const UIDataSettingsMachineUSB &usbData = m_pCache->base();
    341455    /* Load USB data to page: */
    342456    mGbUSB->setChecked(usbData.m_fUSBEnabled);
     
    350464
    351465    /* For each USB filter => load it to the page: */
    352     for (int iFilterIndex = 0; iFilterIndex < m_cache.childCount(); ++iFilterIndex)
    353         addUSBFilter(m_cache.child(iFilterIndex).base(), false /* its new? */);
     466    for (int iFilterIndex = 0; iFilterIndex < m_pCache->childCount(); ++iFilterIndex)
     467        addUSBFilter(m_pCache->child(iFilterIndex).base(), false /* its new? */);
    354468
    355469    /* Choose first filter as current: */
     
    369483{
    370484    /* Prepare USB data: */
    371     UIDataSettingsMachineUSB usbData = m_cache.base();
     485    UIDataSettingsMachineUSB usbData = m_pCache->base();
    372486
    373487    /* Is USB controller enabled? */
     
    387501
    388502    /* Update USB cache: */
    389     m_cache.cacheCurrentData(usbData);
     503    m_pCache->cacheCurrentData(usbData);
    390504
    391505    /* For each USB filter => recache USB filter data: */
    392506    for (int iFilterIndex = 0; iFilterIndex < m_filters.size(); ++iFilterIndex)
    393         m_cache.child(iFilterIndex).cacheCurrentData(m_filters[iFilterIndex]);
     507        m_pCache->child(iFilterIndex).cacheCurrentData(m_filters[iFilterIndex]);
    394508}
    395509
     
    400514
    401515    /* Check if USB data really changed: */
    402     if (m_cache.wasChanged())
     516    if (m_pCache->wasChanged())
    403517    {
    404518        /* Check if controller is valid: */
     
    407521        {
    408522            /* Get USB data from cache: */
    409             const UIDataSettingsMachineUSB &usbData = m_cache.data();
     523            const UIDataSettingsMachineUSB &usbData = m_pCache->data();
    410524            /* Store USB data: */
    411525            if (isMachineOffline())
     
    506620                /* For each USB filter data set: */
    507621                int iOperationPosition = 0;
    508                 for (int iFilterIndex = 0; iFilterIndex < m_cache.childCount(); ++iFilterIndex)
     622                for (int iFilterIndex = 0; iFilterIndex < m_pCache->childCount(); ++iFilterIndex)
    509623                {
    510624                    /* Check if USB filter data really changed: */
    511                     const UISettingsCacheMachineUSBFilter &usbFilterCache = m_cache.child(iFilterIndex);
     625                    const UISettingsCacheMachineUSBFilter &usbFilterCache = m_pCache->child(iFilterIndex);
    512626                    if (usbFilterCache.wasChanged())
    513627                    {
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.h

    r66176 r66183  
    2626class VBoxUSBMenu;
    2727class UIToolBar;
    28 
    29 
    30 /** Machine settings: USB filter data structure. */
    31 struct UIDataSettingsMachineUSBFilter
    32 {
    33     /** Constructs data. */
    34     UIDataSettingsMachineUSBFilter()
    35         : m_fActive(false)
    36         , m_strName(QString())
    37         , m_strVendorId(QString())
    38         , m_strProductId(QString())
    39         , m_strRevision(QString())
    40         , m_strManufacturer(QString())
    41         , m_strProduct(QString())
    42         , m_strSerialNumber(QString())
    43         , m_strPort(QString())
    44         , m_strRemote(QString())
    45         , m_action(KUSBDeviceFilterAction_Null)
    46         , m_fHostUSBDevice(false)
    47         , m_hostUSBDeviceState(KUSBDeviceState_NotSupported)
    48     {}
    49 
    50     /** Returns whether the @a other passed data is equal to this one. */
    51     bool equal(const UIDataSettingsMachineUSBFilter &other) const
    52     {
    53         return true
    54                && (m_fActive == other.m_fActive)
    55                && (m_strName == other.m_strName)
    56                && (m_strVendorId == other.m_strVendorId)
    57                && (m_strProductId == other.m_strProductId)
    58                && (m_strRevision == other.m_strRevision)
    59                && (m_strManufacturer == other.m_strManufacturer)
    60                && (m_strProduct == other.m_strProduct)
    61                && (m_strSerialNumber == other.m_strSerialNumber)
    62                && (m_strPort == other.m_strPort)
    63                && (m_strRemote == other.m_strRemote)
    64                && (m_action == other.m_action)
    65                && (m_hostUSBDeviceState == other.m_hostUSBDeviceState)
    66                ;
    67     }
    68 
    69     /** Returns whether the @a other passed data is equal to this one. */
    70     bool operator==(const UIDataSettingsMachineUSBFilter &other) const { return equal(other); }
    71     /** Returns whether the @a other passed data is different from this one. */
    72     bool operator!=(const UIDataSettingsMachineUSBFilter &other) const { return !equal(other); }
    73 
    74     /** Holds whether the USB filter is enabled. */
    75     bool     m_fActive;
    76     /** Holds the USB filter name. */
    77     QString  m_strName;
    78     /** Holds the USB filter vendor ID. */
    79     QString  m_strVendorId;
    80     /** Holds the USB filter product ID. */
    81     QString  m_strProductId;
    82     /** Holds the USB filter revision. */
    83     QString  m_strRevision;
    84     /** Holds the USB filter manufacturer. */
    85     QString  m_strManufacturer;
    86     /** Holds the USB filter product. */
    87     QString  m_strProduct;
    88     /** Holds the USB filter serial number. */
    89     QString  m_strSerialNumber;
    90     /** Holds the USB filter port. */
    91     QString  m_strPort;
    92     /** Holds the USB filter remote. */
    93     QString  m_strRemote;
    94 
    95     /** Holds the USB filter action. */
    96     KUSBDeviceFilterAction  m_action;
    97     /** Holds whether the USB filter is host USB device. */
    98     bool                    m_fHostUSBDevice;
    99     /** Holds the USB device state. */
    100     KUSBDeviceState         m_hostUSBDeviceState;
    101 };
     28struct UIDataSettingsMachineUSB;
     29struct UIDataSettingsMachineUSBFilter;
    10230typedef UISettingsCache<UIDataSettingsMachineUSBFilter> UISettingsCacheMachineUSBFilter;
    103 
    104 
    105 /** Machine settings: USB page data structure. */
    106 struct UIDataSettingsMachineUSB
    107 {
    108     /** Constructs data. */
    109     UIDataSettingsMachineUSB()
    110         : m_fUSBEnabled(false)
    111         , m_USBControllerType(KUSBControllerType_Null)
    112     {}
    113 
    114     /** Returns whether the @a other passed data is equal to this one. */
    115     bool equal(const UIDataSettingsMachineUSB &other) const
    116     {
    117         return true
    118                && (m_fUSBEnabled == other.m_fUSBEnabled)
    119                && (m_USBControllerType == other.m_USBControllerType)
    120                ;
    121     }
    122 
    123     /** Returns whether the @a other passed data is equal to this one. */
    124     bool operator==(const UIDataSettingsMachineUSB &other) const { return equal(other); }
    125     /** Returns whether the @a other passed data is different from this one. */
    126     bool operator!=(const UIDataSettingsMachineUSB &other) const { return !equal(other); }
    127 
    128     /** Holds whether the USB is enabled. */
    129     bool m_fUSBEnabled;
    130     /** Holds the USB controller type. */
    131     KUSBControllerType m_USBControllerType;
    132 };
    13331typedef UISettingsCachePool<UIDataSettingsMachineUSB, UISettingsCacheMachineUSBFilter> UISettingsCacheMachineUSB;
    13432
     
    14947    };
    15048
     49    /** Constructs USB settings page. */
    15150    UIMachineSettingsUSB();
     51    /** Destructs USB settings page. */
    15252    ~UIMachineSettingsUSB();
    15353
     
    15555
    15656protected:
     57
     58    /** Returns whether the page content was changed. */
     59    bool changed() const /* override */;
    15760
    15861    /** Loads data into the cache from corresponding external object(s),
     
    16972      * this task COULD be performed in other than the GUI thread. */
    17073    void saveFromCacheTo(QVariant &data);
    171 
    172     /** Returns whether the page content was changed. */
    173     bool changed() const { return m_cache.wasChanged(); }
    17474
    17575    /** Performs validation, updates @a messages list if something is wrong. */
     
    221121    QList<UIDataSettingsMachineUSBFilter> m_filters;
    222122
    223     /* Cache: */
    224     UISettingsCacheMachineUSB m_cache;
     123    /** Holds the page data cache instance. */
     124    UISettingsCacheMachineUSB *m_pCache;
    225125};
    226126
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy