Changeset 65689 in vbox
- Timestamp:
- Feb 8, 2017 4:08:34 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 113392
- 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 30 30 UIGlobalSettingsUpdate::UIGlobalSettingsUpdate() 31 31 : m_pLastChosenRadio(0) 32 , m_fChanged(false)33 32 { 34 33 /* Apply UI decorations: */ … … 38 37 connect(m_pCheckBoxUpdate, SIGNAL(toggled(bool)), this, SLOT(sltUpdaterToggled(bool))); 39 38 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()));43 39 44 40 /* Apply language settings: */ … … 51 47 UISettingsPageGlobal::fetchData(data); 52 48 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: */ 54 56 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); 59 64 60 65 /* Upload properties & settings to data: */ … … 64 69 void UIGlobalSettingsUpdate::getFromCache() 65 70 { 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); 68 76 if (m_pCheckBoxUpdate->isChecked()) 69 77 { 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) 72 80 m_pRadioUpdateFilterBetas->setChecked(true); 73 else if ( m_cache.m_branchIndex == VBoxUpdateData::BranchAllRelease)81 else if (oldData.m_branchIndex == VBoxUpdateData::BranchAllRelease) 74 82 m_pRadioUpdateFilterEvery->setChecked(true); 75 83 else 76 84 m_pRadioUpdateFilterStable->setChecked(true); 77 85 } 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); 83 88 } 84 89 85 90 void UIGlobalSettingsUpdate::putToCache() 86 91 { 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); 90 101 } 91 102 92 103 void UIGlobalSettingsUpdate::saveFromCacheTo(QVariant &data) 93 104 { 94 /* Test settings altering flag: */95 if (!m_fChanged)96 return;97 98 105 /* Fetch data to properties & settings: */ 99 106 UISettingsPageGlobal::fetchData(data); 100 107 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 } 104 115 105 116 /* Upload properties & settings to data: */ … … 154 165 VBoxUpdateData data(periodType(), branchType()); 155 166 m_pUpdateDateText->setText(data.date()); 156 m_fChanged = true;157 }158 159 void UIGlobalSettingsUpdate::sltBranchToggled()160 {161 m_fChanged = true;162 167 } 163 168 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsUpdate.h
r65678 r65689 25 25 26 26 27 /** Global settings: Update page cachestructure. */28 struct UI SettingsCacheGlobalUpdate27 /** Global settings: Update page data structure. */ 28 struct UIDataSettingsGlobalUpdate 29 29 { 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 30 54 /** Holds whether the update check is enabled. */ 31 55 bool m_fCheckEnabled; … … 37 61 QString m_strDate; 38 62 }; 63 typedef UISettingsCache<UIDataSettingsGlobalUpdate> UISettingsCacheGlobalUpdate; 39 64 40 65 … … 76 101 void sltUpdaterToggled(bool fEnabled); 77 102 void sltPeriodActivated(); 78 void sltBranchToggled();79 103 80 104 private: … … 86 110 /* Variables: */ 87 111 QRadioButton *m_pLastChosenRadio; 88 bool m_fChanged;89 112 90 113 /* Cache: */
Note:
See TracChangeset
for help on using the changeset viewer.