VirtualBox

Changeset 65689 in vbox


Ignore:
Timestamp:
Feb 8, 2017 4:08:34 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
113392
Message:

FE/Qt: Global preferences: Update 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/UIGlobalSettingsUpdate.cpp

    r65678 r65689  
    3030UIGlobalSettingsUpdate::UIGlobalSettingsUpdate()
    3131    : m_pLastChosenRadio(0)
    32     , m_fChanged(false)
    3332{
    3433    /* Apply UI decorations: */
     
    3837    connect(m_pCheckBoxUpdate, SIGNAL(toggled(bool)), this, SLOT(sltUpdaterToggled(bool)));
    3938    connect(m_pComboBoxUpdatePeriod, SIGNAL(activated(int)), this, SLOT(sltPeriodActivated()));
    40     connect(m_pRadioUpdateFilterStable, SIGNAL(toggled(bool)), this, SLOT(sltBranchToggled()));
    41     connect(m_pRadioUpdateFilterEvery, SIGNAL(toggled(bool)), this, SLOT(sltBranchToggled()));
    42     connect(m_pRadioUpdateFilterBetas, SIGNAL(toggled(bool)), this, SLOT(sltBranchToggled()));
    4339
    4440    /* Apply language settings: */
     
    5147    UISettingsPageGlobal::fetchData(data);
    5248
    53     /* Load to cache: */
     49    /* Clear cache initially: */
     50    m_cache.clear();
     51
     52    /* Prepare old data: */
     53    UIDataSettingsGlobalUpdate oldData;
     54
     55    /* Gather old data: */
    5456    VBoxUpdateData updateData(gEDataManager->applicationUpdateData());
    55     m_cache.m_fCheckEnabled = !updateData.isNoNeedToCheck();
    56     m_cache.m_periodIndex = updateData.periodIndex();
    57     m_cache.m_branchIndex = updateData.branchIndex();
    58     m_cache.m_strDate = updateData.date();
     57    oldData.m_fCheckEnabled = !updateData.isNoNeedToCheck();
     58    oldData.m_periodIndex = updateData.periodIndex();
     59    oldData.m_branchIndex = updateData.branchIndex();
     60    oldData.m_strDate = updateData.date();
     61
     62    /* Cache old data: */
     63    m_cache.cacheInitialData(oldData);
    5964
    6065    /* Upload properties & settings to data: */
     
    6469void UIGlobalSettingsUpdate::getFromCache()
    6570{
    66     /* Fetch from cache: */
    67     m_pCheckBoxUpdate->setChecked(m_cache.m_fCheckEnabled);
     71    /* Get old data from cache: */
     72    const UIDataSettingsGlobalUpdate &oldData = m_cache.base();
     73
     74    /* Load old data from cache: */
     75    m_pCheckBoxUpdate->setChecked(oldData.m_fCheckEnabled);
    6876    if (m_pCheckBoxUpdate->isChecked())
    6977    {
    70         m_pComboBoxUpdatePeriod->setCurrentIndex(m_cache.m_periodIndex);
    71         if (m_cache.m_branchIndex == VBoxUpdateData::BranchWithBetas)
     78        m_pComboBoxUpdatePeriod->setCurrentIndex(oldData.m_periodIndex);
     79        if (oldData.m_branchIndex == VBoxUpdateData::BranchWithBetas)
    7280            m_pRadioUpdateFilterBetas->setChecked(true);
    73         else if (m_cache.m_branchIndex == VBoxUpdateData::BranchAllRelease)
     81        else if (oldData.m_branchIndex == VBoxUpdateData::BranchAllRelease)
    7482            m_pRadioUpdateFilterEvery->setChecked(true);
    7583        else
    7684            m_pRadioUpdateFilterStable->setChecked(true);
    7785    }
    78     m_pUpdateDateText->setText(m_cache.m_strDate);
    79     sltUpdaterToggled(m_cache.m_fCheckEnabled);
    80 
    81     /* Mark page as *not changed*: */
    82     m_fChanged = false;
     86    m_pUpdateDateText->setText(oldData.m_strDate);
     87    sltUpdaterToggled(oldData.m_fCheckEnabled);
    8388}
    8489
    8590void UIGlobalSettingsUpdate::putToCache()
    8691{
    87     /* Upload to cache: */
    88     m_cache.m_periodIndex = periodType();
    89     m_cache.m_branchIndex = branchType();
     92    /* Prepare new data: */
     93    UIDataSettingsGlobalUpdate newData = m_cache.base();
     94
     95    /* Gather new data: */
     96    newData.m_periodIndex = periodType();
     97    newData.m_branchIndex = branchType();
     98
     99    /* Cache new data: */
     100    m_cache.cacheCurrentData(newData);
    90101}
    91102
    92103void UIGlobalSettingsUpdate::saveFromCacheTo(QVariant &data)
    93104{
    94     /* Test settings altering flag: */
    95     if (!m_fChanged)
    96         return;
    97 
    98105    /* Fetch data to properties & settings: */
    99106    UISettingsPageGlobal::fetchData(data);
    100107
    101     /* Save from cache: */
    102     VBoxUpdateData newData(m_cache.m_periodIndex, m_cache.m_branchIndex);
    103     gEDataManager->setApplicationUpdateData(newData.data());
     108    /* Save new data from cache: */
     109    if (m_cache.wasChanged())
     110    {
     111        /* Gather corresponding values from internal variables: */
     112        VBoxUpdateData newData(m_cache.data().m_periodIndex, m_cache.data().m_branchIndex);
     113        gEDataManager->setApplicationUpdateData(newData.data());
     114    }
    104115
    105116    /* Upload properties & settings to data: */
     
    154165    VBoxUpdateData data(periodType(), branchType());
    155166    m_pUpdateDateText->setText(data.date());
    156     m_fChanged = true;
    157 }
    158 
    159 void UIGlobalSettingsUpdate::sltBranchToggled()
    160 {
    161     m_fChanged = true;
    162167}
    163168
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.h

    r65678 r65689  
    2525
    2626
    27 /** Global settings: Update page cache structure. */
    28 struct UISettingsCacheGlobalUpdate
     27/** Global settings: Update page data structure. */
     28struct UIDataSettingsGlobalUpdate
    2929{
     30    /** Constructs data. */
     31    UIDataSettingsGlobalUpdate()
     32        : m_fCheckEnabled(false)
     33        , m_periodIndex(VBoxUpdateData::PeriodUndefined)
     34        , m_branchIndex(VBoxUpdateData::BranchStable)
     35        , m_strDate(QString())
     36    {}
     37
     38    /** Returns whether the @a other passed data is equal to this one. */
     39    bool equal(const UIDataSettingsGlobalUpdate &other) const
     40    {
     41        return true
     42               && (m_fCheckEnabled == other.m_fCheckEnabled)
     43               && (m_periodIndex == other.m_periodIndex)
     44               && (m_branchIndex == other.m_branchIndex)
     45               && (m_strDate == other.m_strDate)
     46               ;
     47    }
     48
     49    /** Returns whether the @a other passed data is equal to this one. */
     50    bool operator==(const UIDataSettingsGlobalUpdate &other) const { return equal(other); }
     51    /** Returns whether the @a other passed data is different from this one. */
     52    bool operator!=(const UIDataSettingsGlobalUpdate &other) const { return !equal(other); }
     53
    3054    /** Holds whether the update check is enabled. */
    3155    bool m_fCheckEnabled;
     
    3761    QString m_strDate;
    3862};
     63typedef UISettingsCache<UIDataSettingsGlobalUpdate> UISettingsCacheGlobalUpdate;
    3964
    4065
     
    76101    void sltUpdaterToggled(bool fEnabled);
    77102    void sltPeriodActivated();
    78     void sltBranchToggled();
    79103
    80104private:
     
    86110    /* Variables: */
    87111    QRadioButton *m_pLastChosenRadio;
    88     bool m_fChanged;
    89112
    90113    /* Cache: */
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