VirtualBox

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


Ignore:
Timestamp:
Feb 8, 2017 4:06:25 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Global preferences: Proxy page: Integrate settings caching.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/global
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp

    r65678 r65688  
    5959    UISettingsPageGlobal::fetchData(data);
    6060
    61     /* Load to cache: */
     61    /* Clear cache initially: */
     62    m_cache.clear();
     63
     64    /* Prepare old data: */
     65    UIDataSettingsGlobalProxy oldData;
     66
     67    /* Gather old data: */
    6268    UIProxyManager proxyManager(m_settings.proxySettings());
    63     m_cache.m_enmProxyState = proxyManager.proxyState();
    64     m_cache.m_strProxyHost = proxyManager.proxyHost();
    65     m_cache.m_strProxyPort = proxyManager.proxyPort();
     69    oldData.m_enmProxyState = proxyManager.proxyState();
     70    oldData.m_strProxyHost = proxyManager.proxyHost();
     71    oldData.m_strProxyPort = proxyManager.proxyPort();
     72
     73    /* Cache old data: */
     74    m_cache.cacheInitialData(oldData);
    6675
    6776    /* Upload properties & settings to data: */
     
    7180void UIGlobalSettingsProxy::getFromCache()
    7281{
    73     /* Fetch from cache: */
    74     switch (m_cache.m_enmProxyState)
     82    /* Get old data from cache: */
     83    const UIDataSettingsGlobalProxy &oldData = m_cache.base();
     84
     85    /* Load old data from cache: */
     86    switch (oldData.m_enmProxyState)
    7587    {
    7688        case UIProxyManager::ProxyState_Auto:     m_pRadioProxyAuto->setChecked(true); break;
     
    7890        case UIProxyManager::ProxyState_Enabled:  m_pRadioProxyEnabled->setChecked(true); break;
    7991    }
    80     m_pHostEditor->setText(m_cache.m_strProxyHost);
    81     m_pPortEditor->setText(m_cache.m_strProxyPort);
     92    m_pHostEditor->setText(oldData.m_strProxyHost);
     93    m_pPortEditor->setText(oldData.m_strProxyPort);
    8294    sltProxyToggled();
    8395
     
    88100void UIGlobalSettingsProxy::putToCache()
    89101{
    90     /* Upload to cache: */
    91     m_cache.m_enmProxyState = m_pRadioProxyEnabled->isChecked()  ? UIProxyManager::ProxyState_Enabled :
     102    /* Prepare new data: */
     103    UIDataSettingsGlobalProxy newData = m_cache.base();
     104
     105    /* Gather new data: */
     106    newData.m_enmProxyState = m_pRadioProxyEnabled->isChecked()  ? UIProxyManager::ProxyState_Enabled :
    92107                              m_pRadioProxyDisabled->isChecked() ? UIProxyManager::ProxyState_Disabled :
    93108                                                                   UIProxyManager::ProxyState_Auto;
    94     m_cache.m_strProxyHost = m_pHostEditor->text();
    95     m_cache.m_strProxyPort = m_pPortEditor->text();
     109    newData.m_strProxyHost = m_pHostEditor->text();
     110    newData.m_strProxyPort = m_pPortEditor->text();
     111
     112    /* Cache new data: */
     113    m_cache.cacheCurrentData(newData);
    96114}
    97115
     
    101119    UISettingsPageGlobal::fetchData(data);
    102120
    103     /* Save from cache: */
    104     UIProxyManager proxyManager;
    105     proxyManager.setProxyState(m_cache.m_enmProxyState);
    106     proxyManager.setProxyHost(m_cache.m_strProxyHost);
    107     proxyManager.setProxyPort(m_cache.m_strProxyPort);
    108     m_settings.setProxySettings(proxyManager.toString());
     121    /* Save new data from cache: */
     122    if (m_cache.wasChanged())
     123    {
     124        UIProxyManager proxyManager;
     125        proxyManager.setProxyState(m_cache.data().m_enmProxyState);
     126        proxyManager.setProxyHost(m_cache.data().m_strProxyHost);
     127        proxyManager.setProxyPort(m_cache.data().m_strProxyPort);
     128        m_settings.setProxySettings(proxyManager.toString());
     129    }
    109130
    110131    /* Upload properties & settings to data: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.h

    r65678 r65688  
    2525
    2626
    27 /** Global settings: Proxy page cache structure. */
    28 struct UISettingsCacheGlobalProxy
     27/** Global settings: Proxy page data structure. */
     28struct UIDataSettingsGlobalProxy
    2929{
    3030    /** Constructs data. */
    31     UISettingsCacheGlobalProxy()
     31    UIDataSettingsGlobalProxy()
    3232        : m_enmProxyState(UIProxyManager::ProxyState_Auto)
    3333        , m_strProxyHost(QString())
    3434        , m_strProxyPort(QString())
    3535    {}
     36
     37    /** Returns whether the @a other passed data is equal to this one. */
     38    bool equal(const UIDataSettingsGlobalProxy &other) const
     39    {
     40        return true
     41               && (m_enmProxyState == other.m_enmProxyState)
     42               && (m_strProxyHost == other.m_strProxyHost)
     43               && (m_strProxyPort == other.m_strProxyPort)
     44               ;
     45    }
     46
     47    /** Returns whether the @a other passed data is equal to this one. */
     48    bool operator==(const UIDataSettingsGlobalProxy &other) const { return equal(other); }
     49    /** Returns whether the @a other passed data is different from this one. */
     50    bool operator!=(const UIDataSettingsGlobalProxy &other) const { return !equal(other); }
    3651
    3752    /** Holds the proxy state. */
     
    4257    QString m_strProxyPort;
    4358};
     59typedef UISettingsCache<UIDataSettingsGlobalProxy> UISettingsCacheGlobalProxy;
    4460
    4561
Note: See TracChangeset for help on using the changeset viewer.

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