- Timestamp:
- Feb 8, 2017 2:47:56 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/global
- Files:
-
- 2 edited
-
UIGlobalSettingsExtension.cpp (modified) (8 diffs)
-
UIGlobalSettingsExtension.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.cpp
r65678 r65682 45 45 46 46 /* Extension package item constructor: */ 47 UIExtensionPackageItem(QITreeWidget *pParent, const UI SettingsCacheGlobalExtensionItem &data)47 UIExtensionPackageItem(QITreeWidget *pParent, const UIDataSettingsGlobalExtensionItem &data) 48 48 : QITreeWidgetItem(pParent) 49 49 , m_data(data) … … 94 94 private: 95 95 96 UI SettingsCacheGlobalExtensionItem m_data;96 UIDataSettingsGlobalExtensionItem m_data; 97 97 }; 98 98 … … 242 242 UISettingsPageGlobal::fetchData(data); 243 243 244 /* Load to cache: */ 244 /* Clear cache initially: */ 245 m_cache.clear(); 246 247 /* Prepare old data: */ 248 UIDataSettingsGlobalExtension oldData; 249 250 /* Gather old data: */ 245 251 const CExtPackManager &manager = vboxGlobal().virtualBox().GetExtensionPackManager(); 246 252 const CExtPackVector &packages = manager.GetInstalledExtPacks(); 247 253 for (int i = 0; i < packages.size(); ++i) 248 m_cache.m_items << fetchData(packages[i]); 254 oldData.m_items << fetchData(packages[i]); 255 256 /* Cache old data: */ 257 m_cache.cacheInitialData(oldData); 249 258 250 259 /* Upload properties & settings to data: */ … … 254 263 void UIGlobalSettingsExtension::getFromCache() 255 264 { 256 /* Fetch from cache: */ 257 for (int i = 0; i < m_cache.m_items.size(); ++i) 258 new UIExtensionPackageItem(m_pPackagesTree, m_cache.m_items[i]); 265 /* Get old/new data from cache: */ 266 m_data = m_cache.base(); 267 268 /* Load old data from cache: */ 269 for (int i = 0; i < m_data.m_items.size(); ++i) 270 new UIExtensionPackageItem(m_pPackagesTree, m_data.m_items[i]); 259 271 /* If at least one item present: */ 260 272 if (m_pPackagesTree->topLevelItemCount()) … … 366 378 { 367 379 /* Remove it from the cache. */ 368 for (int i = 0; i < m_ cache.m_items.size(); i++)369 if (!strExtPackName.compare(m_ cache.m_items[i].m_strName, Qt::CaseInsensitive))380 for (int i = 0; i < m_data.m_items.size(); i++) 381 if (!strExtPackName.compare(m_data.m_items[i].m_strName, Qt::CaseInsensitive)) 370 382 { 371 m_ cache.m_items.removeAt(i);383 m_data.m_items.removeAt(i); 372 384 break; 373 385 } … … 390 402 if (package.isOk()) 391 403 { 392 m_ cache.m_items << fetchData(package);393 394 UIExtensionPackageItem *pItem = new UIExtensionPackageItem(m_pPackagesTree, m_ cache.m_items.last());404 m_data.m_items << fetchData(package); 405 406 UIExtensionPackageItem *pItem = new UIExtensionPackageItem(m_pPackagesTree, m_data.m_items.last()); 395 407 m_pPackagesTree->setCurrentItem(pItem); 396 408 m_pPackagesTree->sortByColumn(1, Qt::AscendingOrder); … … 433 445 { 434 446 /* Remove selected package from cache: */ 435 for (int i = 0; i < m_ cache.m_items.size(); ++i)447 for (int i = 0; i < m_data.m_items.size(); ++i) 436 448 { 437 if (!strSelectedPackageName.compare(m_ cache.m_items[i].m_strName, Qt::CaseInsensitive))449 if (!strSelectedPackageName.compare(m_data.m_items[i].m_strName, Qt::CaseInsensitive)) 438 450 { 439 m_ cache.m_items.removeAt(i);451 m_data.m_items.removeAt(i); 440 452 break; 441 453 } … … 453 465 } 454 466 455 UI SettingsCacheGlobalExtensionItem UIGlobalSettingsExtension::fetchData(const CExtPack &package) const456 { 457 UI SettingsCacheGlobalExtensionItem item;467 UIDataSettingsGlobalExtensionItem UIGlobalSettingsExtension::fetchData(const CExtPack &package) const 468 { 469 UIDataSettingsGlobalExtensionItem item; 458 470 item.m_strName = package.GetName(); 459 471 item.m_strDescription = package.GetDescription(); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.h
r65678 r65682 24 24 25 25 26 /** Global settings: Extension page item cachestructure. */27 struct UI SettingsCacheGlobalExtensionItem26 /** Global settings: Extension page item data structure. */ 27 struct UIDataSettingsGlobalExtensionItem 28 28 { 29 /** Constructs data. */ 30 UIDataSettingsGlobalExtensionItem() 31 : m_strName(QString()) 32 , m_strDescription(QString()) 33 , m_strVersion(QString()) 34 , m_uRevision(0) 35 , m_fIsUsable(false) 36 , m_strWhyUnusable(QString()) 37 {} 38 39 /** Returns whether the @a other passed data is equal to this one. */ 40 bool equal(const UIDataSettingsGlobalExtensionItem &other) const 41 { 42 return true 43 && (m_strName == other.m_strName) 44 && (m_strDescription == other.m_strDescription) 45 && (m_strVersion == other.m_strVersion) 46 && (m_uRevision == other.m_uRevision) 47 && (m_fIsUsable == other.m_fIsUsable) 48 && (m_strWhyUnusable == other.m_strWhyUnusable) 49 ; 50 } 51 52 /** Returns whether the @a other passed data is equal to this one. */ 53 bool operator==(const UIDataSettingsGlobalExtensionItem &other) const { return equal(other); } 54 /** Returns whether the @a other passed data is different from this one. */ 55 bool operator!=(const UIDataSettingsGlobalExtensionItem &other) const { return !equal(other); } 56 29 57 /** Holds the extension item name. */ 30 58 QString m_strName; … … 42 70 43 71 44 /** Global settings: Extension page cachestructure. */45 struct UI SettingsCacheGlobalExtension72 /** Global settings: Extension page data structure. */ 73 struct UIDataSettingsGlobalExtension 46 74 { 75 /** Constructs data. */ 76 UIDataSettingsGlobalExtension() 77 : m_items(QList<UIDataSettingsGlobalExtensionItem>()) 78 {} 79 80 /** Returns whether the @a other passed data is equal to this one. */ 81 bool equal(const UIDataSettingsGlobalExtension &other) const 82 { 83 return true 84 && (m_items == other.m_items) 85 ; 86 } 87 88 /** Returns whether the @a other passed data is equal to this one. */ 89 bool operator==(const UIDataSettingsGlobalExtension &other) const { return equal(other); } 90 /** Returns whether the @a other passed data is different from this one. */ 91 bool operator!=(const UIDataSettingsGlobalExtension &other) const { return !equal(other); } 92 47 93 /** Holds the extension items. */ 48 QList<UI SettingsCacheGlobalExtensionItem> m_items;94 QList<UIDataSettingsGlobalExtensionItem> m_items; 49 95 }; 96 typedef UISettingsCache<UIDataSettingsGlobalExtension> UISettingsCacheGlobalExtension; 50 97 51 98 … … 96 143 private: 97 144 98 /* Prepare UI SettingsCacheGlobalExtensionItem basing on CExtPack: */99 UI SettingsCacheGlobalExtensionItem fetchData(const CExtPack &package) const;145 /* Prepare UIDataSettingsGlobalExtensionItem basing on CExtPack: */ 146 UIDataSettingsGlobalExtensionItem fetchData(const CExtPack &package) const; 100 147 101 148 /* Variables: Actions: */ … … 105 152 /* Cache: */ 106 153 UISettingsCacheGlobalExtension m_cache; 154 UIDataSettingsGlobalExtension m_data; 107 155 }; 108 156
Note:
See TracChangeset
for help on using the changeset viewer.

