Changeset 51363 in vbox
- Timestamp:
- May 23, 2014 12:52:48 AM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/extradata
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r51216 r51363 115 115 /* static */ 116 116 UIExtraDataManager *UIExtraDataManager::m_pInstance = 0; 117 QString UIExtraDataManager::m_sstrGlobalID = QUuid().toString().remove(QRegExp("[{}]")); 117 118 118 119 /* static */ … … 560 561 561 562 /* Global extra-data 'change' event: */ 562 if ( QUuid(strMachineID).isNull())563 if (strMachineID == m_sstrGlobalID) 563 564 { 564 565 if (strKey.startsWith("GUI/")) … … 610 611 611 612 /* Make sure at least empty map is created: */ 612 m_data[ QString()] = ExtraDataMap();613 m_data[m_sstrGlobalID] = ExtraDataMap(); 613 614 614 615 /* Load global extra-data map: */ 615 616 foreach (const QString &strKey, vbox.GetExtraDataKeys()) 616 m_data[ QString()][strKey] = vbox.GetExtraData(strKey);617 m_data[m_sstrGlobalID][strKey] = vbox.GetExtraData(strKey); 617 618 } 618 619 … … 674 675 void UIExtraDataManager::hotloadMachineExtraDataMap(const QString &strID) const 675 676 { 676 /* Make sure it is not yet loaded: */ 677 AssertReturnVoid(!strID.isNull() && !m_data.contains(strID)); 677 /* Make sure it is valid ID: */ 678 AssertReturnVoid(!strID.isNull() && strID != m_sstrGlobalID); 679 /* Which is not loaded yet: */ 680 AssertReturnVoid(!m_data.contains(strID)); 678 681 679 682 /* Search for corresponding machine: */ … … 694 697 } 695 698 696 bool UIExtraDataManager::isFeatureAllowed(const QString &strKey, const QString &strID /* = QString()*/) const699 bool UIExtraDataManager::isFeatureAllowed(const QString &strKey, const QString &strID /* = m_sstrGlobalID */) const 697 700 { 698 701 /* Hot-load machine extra-data map if necessary: */ 699 if ( !strID.isNull()&& !m_data.contains(strID))702 if (strID != m_sstrGlobalID && !m_data.contains(strID)) 700 703 hotloadMachineExtraDataMap(strID); 701 704 … … 715 718 } 716 719 717 bool UIExtraDataManager::isFeatureRestricted(const QString &strKey, const QString &strID /* = QString()*/) const720 bool UIExtraDataManager::isFeatureRestricted(const QString &strKey, const QString &strID /* = m_sstrGlobalID */) const 718 721 { 719 722 /* Hot-load machine extra-data map if necessary: */ 720 if ( !strID.isNull()&& !m_data.contains(strID))723 if (strID != m_sstrGlobalID && !m_data.contains(strID)) 721 724 hotloadMachineExtraDataMap(strID); 722 725 … … 746 749 } 747 750 748 QString UIExtraDataManager::extraDataString(const QString &strKey, const QString &strID /* = QString()*/) const751 QString UIExtraDataManager::extraDataString(const QString &strKey, const QString &strID /* = m_sstrGlobalID */) const 749 752 { 750 753 /* Hot-load machine extra-data map if necessary: */ 751 if ( !strID.isNull()&& !m_data.contains(strID))754 if (strID != m_sstrGlobalID && !m_data.contains(strID)) 752 755 hotloadMachineExtraDataMap(strID); 753 756 … … 763 766 } 764 767 765 void UIExtraDataManager::setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID /* = QString()*/)768 void UIExtraDataManager::setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID /* = m_sstrGlobalID */) 766 769 { 767 770 /* Hot-load machine extra-data map if necessary: */ 768 if ( !strID.isNull()&& !m_data.contains(strID))771 if (strID != m_sstrGlobalID && !m_data.contains(strID)) 769 772 hotloadMachineExtraDataMap(strID); 770 773 … … 776 779 777 780 /* Global extra-data: */ 778 if (strID .isNull())781 if (strID == m_sstrGlobalID) 779 782 { 780 783 /* Get global object: */ … … 795 798 } 796 799 797 QStringList UIExtraDataManager::extraDataStringList(const QString &strKey, const QString &strID /* = QString()*/) const800 QStringList UIExtraDataManager::extraDataStringList(const QString &strKey, const QString &strID /* = m_sstrGlobalID */) const 798 801 { 799 802 /* Hot-load machine extra-data map if necessary: */ 800 if ( !strID.isNull()&& !m_data.contains(strID))803 if (strID != m_sstrGlobalID && !m_data.contains(strID)) 801 804 hotloadMachineExtraDataMap(strID); 802 805 … … 813 816 } 814 817 815 void UIExtraDataManager::setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID /* = QString()*/)818 void UIExtraDataManager::setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID /* = m_sstrGlobalID */) 816 819 { 817 820 /* Hot-load machine extra-data map if necessary: */ 818 if ( !strID.isNull()&& !m_data.contains(strID))821 if (strID != m_sstrGlobalID && !m_data.contains(strID)) 819 822 hotloadMachineExtraDataMap(strID); 820 823 … … 826 829 827 830 /* Global extra-data: */ 828 if (strID .isNull())831 if (strID == m_sstrGlobalID) 829 832 { 830 833 /* Get global object: */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r51216 r51363 227 227 /** Determines whether feature corresponding to passed @a strKey is allowed. 228 228 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */ 229 bool isFeatureAllowed(const QString &strKey, const QString &strID = QString()) const;229 bool isFeatureAllowed(const QString &strKey, const QString &strID = m_sstrGlobalID) const; 230 230 /** Determines whether feature corresponding to passed @a strKey is restricted. 231 231 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */ 232 bool isFeatureRestricted(const QString &strKey, const QString &strID = QString()) const;232 bool isFeatureRestricted(const QString &strKey, const QString &strID = m_sstrGlobalID) const; 233 233 234 234 /** Translates bool flag into 'allowed' value. */ … … 239 239 /** Returns extra-data value corresponding to passed @a strKey as QString. 240 240 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */ 241 QString extraDataString(const QString &strKey, const QString &strID = QString()) const;241 QString extraDataString(const QString &strKey, const QString &strID = m_sstrGlobalID) const; 242 242 /** Defines extra-data value corresponding to passed @a strKey as strValue. 243 243 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */ 244 void setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID = QString());244 void setExtraDataString(const QString &strKey, const QString &strValue, const QString &strID = m_sstrGlobalID); 245 245 246 246 /** Returns extra-data value corresponding to passed @a strKey as QStringList. 247 247 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */ 248 QStringList extraDataStringList(const QString &strKey, const QString &strID = QString()) const;248 QStringList extraDataStringList(const QString &strKey, const QString &strID = m_sstrGlobalID) const; 249 249 /** Defines extra-data value corresponding to passed @a strKey as strValue. 250 250 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */ 251 void setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID = QString());251 void setExtraDataStringList(const QString &strKey, const QStringList &strValue, const QString &strID = m_sstrGlobalID); 252 252 253 253 /** Singleton Extra-data Manager instance. */ 254 254 static UIExtraDataManager *m_pInstance; 255 256 /** Global extra-data ID. */ 257 static QString m_sstrGlobalID; 255 258 256 259 /** Main event-listener instance. */
Note:
See TracChangeset
for help on using the changeset viewer.