Changeset 60182 in vbox for trunk/src/VBox
- Timestamp:
- Mar 24, 2016 3:13:06 PM (9 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
r59985 r60182 1965 1965 hotloadMachineExtraDataMap(strID); 1966 1966 1967 /* Read-only accesscorresponding map: */1967 /* Make a read-only copy of the corresponding map: */ 1968 1968 const ExtraDataMap data = m_data.value(strID); 1969 1969 … … 1974 1974 /* Returns corresponding value: */ 1975 1975 return data[strKey]; 1976 } 1977 1978 QString UIExtraDataManager::extraDataStringUnion(const QString &strKey, const QString &strID) 1979 { 1980 /* Machine extra-data first: */ 1981 if (strID != GlobalID) 1982 { 1983 MapOfExtraDataMaps::const_iterator itMap = m_data.constFind(strID); 1984 1985 /* Hot-load machine extra-data map if necessary: */ 1986 if (itMap == m_data.constEnd()) 1987 { 1988 hotloadMachineExtraDataMap(strID); 1989 itMap = m_data.constFind(strID); 1990 } 1991 if (itMap != m_data.constEnd()) 1992 { 1993 /* Return string if present in the map: */ 1994 ExtraDataMap::const_iterator itValue = itMap->constFind(strKey); 1995 if (itValue != itMap->constEnd()) 1996 return *itValue; 1997 } 1998 } 1999 2000 /* Global extra-data: */ 2001 MapOfExtraDataMaps::const_iterator itMap = m_data.constFind(GlobalID); 2002 if (itMap != m_data.constEnd()) 2003 { 2004 ExtraDataMap::const_iterator itValue = itMap->constFind(strKey); 2005 if (itValue != itMap->constEnd()) 2006 return *itValue; 2007 } 2008 2009 /* Not found, return null string: */ 2010 return QString(); 1976 2011 } 1977 2012 … … 4044 4079 bool UIExtraDataManager::isFeatureAllowed(const QString &strKey, const QString &strID /* = GlobalID */) 4045 4080 { 4046 /* Hot-load machine extra-data map if necessary: */ 4047 if (strID != GlobalID && !m_data.contains(strID)) 4048 hotloadMachineExtraDataMap(strID); 4049 4050 /* Read-only access corresponding map: */ 4051 const ExtraDataMap data = m_data.value(strID); 4052 4053 /* 'false' if value was not set: */ 4054 if (!data.contains(strKey)) 4081 /* Get the value. Return 'false' if not found: */ 4082 const QString strValue = extraDataStringUnion(strKey, strID); 4083 if (strValue.isNull()) 4055 4084 return false; 4056 4085 4057 4086 /* Check corresponding value: */ 4058 const QString &strValue = data[strKey];4059 4087 return strValue.compare("true", Qt::CaseInsensitive) == 0 4060 4088 || strValue.compare("yes", Qt::CaseInsensitive) == 0 … … 4065 4093 bool UIExtraDataManager::isFeatureRestricted(const QString &strKey, const QString &strID /* = GlobalID */) 4066 4094 { 4067 /* Hot-load machine extra-data map if necessary: */ 4068 if (strID != GlobalID && !m_data.contains(strID)) 4069 hotloadMachineExtraDataMap(strID); 4070 4071 /* Read-only access corresponding map: */ 4072 const ExtraDataMap data = m_data.value(strID); 4073 4074 /* 'false' if value was not set: */ 4075 if (!data.contains(strKey)) 4095 /* Get the value. Return 'false' if not found: */ 4096 const QString strValue = extraDataStringUnion(strKey, strID); 4097 if (strValue.isNull()) 4076 4098 return false; 4077 4099 4078 4100 /* Check corresponding value: */ 4079 const QString &strValue = data[strKey];4080 4101 return strValue.compare("false", Qt::CaseInsensitive) == 0 4081 4102 || strValue.compare("no", Qt::CaseInsensitive) == 0 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r58689 r60182 592 592 #endif /* DEBUG */ 593 593 594 /** 595 * Retrieves an extra-data key from both machine and global sources. 596 * 597 * If @a strID isn't #GlobalID, this will first check the extra-data associated 598 * with the machine given by @a strID then fallback on the global extra-data. 599 * 600 * @returns String value if found, null string if not. 601 * @param strKey The extra-data key to get. 602 * @param strID Machine UUID or #GlobalID. 603 * @param strValue Where to return the value when found. 604 */ 605 QString extraDataStringUnion(const QString &strKey, const QString &strID); 594 606 /** Determines whether feature corresponding to passed @a strKey is allowed. 595 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */ 607 * If valid @a strID is set => applies to machine extra-data and global, 608 * otherwise => only to global one. */ 596 609 bool isFeatureAllowed(const QString &strKey, const QString &strID = GlobalID); 597 610 /** Determines whether feature corresponding to passed @a strKey is restricted. 598 * If valid @a strID is set => applies to machine extra-data, otherwise => to global one. */ 611 * If valid @a strID is set => applies to machine extra-data and global, 612 * otherwise => only to global one. */ 599 613 bool isFeatureRestricted(const QString &strKey, const QString &strID = GlobalID); 600 614 … … 616 630 UIExtraDataEventHandler *m_pHandler; 617 631 632 /** Maps of extra data maps. The index is a UUID string. */ 633 typedef QMap<QString, ExtraDataMap> MapOfExtraDataMaps; 618 634 /** Holds extra-data map instance. */ 619 QMap<QString, ExtraDataMap>m_data;635 MapOfExtraDataMaps m_data; 620 636 621 637 #ifdef DEBUG
Note:
See TracChangeset
for help on using the changeset viewer.