Changeset 65686 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 8, 2017 3:57:18 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/global
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsLanguage.cpp
r65678 r65686 181 181 UIGlobalSettingsLanguage::UIGlobalSettingsLanguage() 182 182 : m_fPolished(false) 183 , m_fIsLanguageChanged(false)184 183 { 185 184 /* Apply UI decorations: */ … … 210 209 UISettingsPageGlobal::fetchData(data); 211 210 212 /* Load to cache: */ 213 m_cache.m_strLanguageId = m_settings.languageId(); 211 /* Clear cache initially: */ 212 m_cache.clear(); 213 214 /* Prepare old data: */ 215 UIDataSettingsGlobalLanguage oldData; 216 217 /* Gather old data: */ 218 oldData.m_strLanguageId = m_settings.languageId(); 219 220 /* Cache old data: */ 221 m_cache.cacheInitialData(oldData); 214 222 215 223 /* Upload properties & settings to data: */ … … 219 227 void UIGlobalSettingsLanguage::getFromCache() 220 228 { 221 /* Fetch from cache: */ 222 reload(m_cache.m_strLanguageId); 229 /* Get old data from cache: */ 230 const UIDataSettingsGlobalLanguage &oldData = m_cache.base(); 231 232 /* Load old data from cache: */ 233 reload(oldData.m_strLanguageId); 223 234 } 224 235 225 236 void UIGlobalSettingsLanguage::putToCache() 226 237 { 227 /* Upload to cache: */ 238 /* Prepare new data: */ 239 UIDataSettingsGlobalLanguage newData = m_cache.base(); 240 241 /* Gather new data: */ 228 242 QTreeWidgetItem *pCurrentItem = m_pLanguageTree->currentItem(); 229 243 Assert(pCurrentItem); 230 244 if (pCurrentItem) 231 m_cache.m_strLanguageId = pCurrentItem->text(1); 245 newData.m_strLanguageId = pCurrentItem->text(1); 246 247 /* Cache new data: */ 248 m_cache.cacheCurrentData(newData); 232 249 } 233 250 … … 239 256 UISettingsPageGlobal::fetchData(data); 240 257 241 /* Save from cache: */ 242 if (m_fIsLanguageChanged) 243 m_settings.setLanguageId(m_cache.m_strLanguageId); 258 /* Save new data from cache: */ 259 if (m_cache.wasChanged()) 260 { 261 /* Save from cache: */ 262 if (m_cache.data().m_strLanguageId != m_cache.base().m_strLanguageId) 263 m_settings.setLanguageId(m_cache.data().m_strLanguageId); 264 } 244 265 245 266 /* Upload properties & settings to data: */ … … 339 360 m_pLanguageTree->sortItems(0, Qt::AscendingOrder); 340 361 m_pLanguageTree->scrollToItem(pItem); 341 m_fIsLanguageChanged = false;342 362 } 343 363 … … 373 393 .arg(tr("Author(s):")) 374 394 .arg(pItem->text(3))); 375 376 m_fIsLanguageChanged = true; 377 } 378 395 } 396 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsLanguage.h
r65678 r65686 24 24 25 25 26 /** Global settings: Language page cachestructure. */27 struct UI SettingsCacheGlobalLanguage26 /** Global settings: Language page data structure. */ 27 struct UIDataSettingsGlobalLanguage 28 28 { 29 /** Constructs data. */ 30 UIDataSettingsGlobalLanguage() 31 : m_strLanguageId(QString()) 32 {} 33 34 /** Returns whether the @a other passed data is equal to this one. */ 35 bool equal(const UIDataSettingsGlobalLanguage &other) const 36 { 37 return true 38 && (m_strLanguageId == other.m_strLanguageId) 39 ; 40 } 41 42 /** Returns whether the @a other passed data is equal to this one. */ 43 bool operator==(const UIDataSettingsGlobalLanguage &other) const { return equal(other); } 44 /** Returns whether the @a other passed data is different from this one. */ 45 bool operator!=(const UIDataSettingsGlobalLanguage &other) const { return !equal(other); } 46 29 47 /** Holds the current language id. */ 30 48 QString m_strLanguageId; 31 49 }; 50 typedef UISettingsCache<UIDataSettingsGlobalLanguage> UISettingsCacheGlobalLanguage; 32 51 33 52 … … 83 102 /* Variables: */ 84 103 bool m_fPolished; 85 bool m_fIsLanguageChanged;86 104 87 105 /* Cache: */
Note:
See TracChangeset
for help on using the changeset viewer.