Changeset 36919 in vbox
- Timestamp:
- May 3, 2011 6:58:25 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 71501
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp
r36918 r36919 170 170 UISettingsPageMachine::fetchData(data); 171 171 172 /* Fill internal variables with corresponding values: */ 172 /* Prepare system data: */ 173 UIDataSettingsMachineSystem systemData; 174 173 175 /* Load boot-items of current VM: */ 174 176 QList<KDeviceType> usedBootItems; … … 182 184 data.m_type = type; 183 185 data.m_fEnabled = true; 184 m_cache.m_bootItems << data;186 systemData.m_bootItems << data; 185 187 } 186 188 } … … 194 196 data.m_type = type; 195 197 data.m_fEnabled = false; 196 m_cache.m_bootItems << data;198 systemData.m_bootItems << data; 197 199 } 198 200 } 199 m_cache.m_fPFHwVirtExSupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx); 200 m_cache.m_fPFPAESupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_PAE); 201 m_cache.m_fIoApicEnabled = m_machine.GetBIOSSettings().GetIOAPICEnabled(); 202 m_cache.m_fEFIEnabled = m_machine.GetFirmwareType() >= KFirmwareType_EFI && m_machine.GetFirmwareType() <= KFirmwareType_EFIDUAL; 203 m_cache.m_fUTCEnabled = m_machine.GetRTCUseUTC(); 204 m_cache.m_fUseAbsHID = m_machine.GetPointingHidType() == KPointingHidType_USBTablet; 205 m_cache.m_fPAEEnabled = m_machine.GetCPUProperty(KCPUPropertyType_PAE); 206 m_cache.m_fHwVirtExEnabled = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled); 207 m_cache.m_fNestedPagingEnabled = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging); 208 m_cache.m_iRAMSize = m_machine.GetMemorySize(); 209 m_cache.m_cCPUCount = m_cache.m_fPFHwVirtExSupported ? m_machine.GetCPUCount() : 1; 210 m_cache.m_chipsetType = m_machine.GetChipsetType(); 201 /* Gather other system data: */ 202 systemData.m_fPFHwVirtExSupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx); 203 systemData.m_fPFPAESupported = vboxGlobal().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_PAE); 204 systemData.m_fIoApicEnabled = m_machine.GetBIOSSettings().GetIOAPICEnabled(); 205 systemData.m_fEFIEnabled = m_machine.GetFirmwareType() >= KFirmwareType_EFI && m_machine.GetFirmwareType() <= KFirmwareType_EFIDUAL; 206 systemData.m_fUTCEnabled = m_machine.GetRTCUseUTC(); 207 systemData.m_fUseAbsHID = m_machine.GetPointingHidType() == KPointingHidType_USBTablet; 208 systemData.m_fPAEEnabled = m_machine.GetCPUProperty(KCPUPropertyType_PAE); 209 systemData.m_fHwVirtExEnabled = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled); 210 systemData.m_fNestedPagingEnabled = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging); 211 systemData.m_iRAMSize = m_machine.GetMemorySize(); 212 systemData.m_cCPUCount = systemData.m_fPFHwVirtExSupported ? m_machine.GetCPUCount() : 1; 213 systemData.m_chipsetType = m_machine.GetChipsetType(); 214 215 /* Cache system data: */ 216 m_cache.cacheInitialData(systemData); 211 217 212 218 /* Upload machine to data: */ … … 218 224 void UIMachineSettingsSystem::getFromCache() 219 225 { 220 /* Remove any old data in the boot view. */ 226 /* Get system data from cache: */ 227 const UIDataSettingsMachineSystem &systemData = m_cache.base(); 228 229 /* Remove any old data in the boot view: */ 221 230 QAbstractItemView *iv = qobject_cast <QAbstractItemView*> (mTwBootOrder); 222 231 iv->model()->removeRows(0, iv->model()->rowCount()); 223 232 /* Apply internal variables data to QWidget(s): */ 224 for (int i = 0; i < m_cache.m_bootItems.size(); ++i)225 { 226 UIBootItemData data = m_cache.m_bootItems[i];233 for (int i = 0; i < systemData.m_bootItems.size(); ++i) 234 { 235 UIBootItemData data = systemData.m_bootItems[i]; 227 236 QListWidgetItem *pItem = new UIBootTableItem(data.m_type); 228 237 pItem->setCheckState(data.m_fEnabled ? Qt::Checked : Qt::Unchecked); 229 238 mTwBootOrder->addItem(pItem); 230 239 } 231 mCbApic->setChecked(m_cache.m_fIoApicEnabled); 232 mCbEFI->setChecked(m_cache.m_fEFIEnabled); 233 mCbTCUseUTC->setChecked(m_cache.m_fUTCEnabled); 234 mCbUseAbsHID->setChecked(m_cache.m_fUseAbsHID); 235 mSlCPU->setEnabled(m_cache.m_fPFHwVirtExSupported); 236 mLeCPU->setEnabled(m_cache.m_fPFHwVirtExSupported); 237 mCbPae->setEnabled(m_cache.m_fPFPAESupported); 238 mCbPae->setChecked(m_cache.m_fPAEEnabled); 239 mCbVirt->setEnabled(m_cache.m_fPFHwVirtExSupported); 240 mCbVirt->setChecked(m_cache.m_fHwVirtExEnabled); 241 mCbNestedPaging->setEnabled(m_cache.m_fPFHwVirtExSupported && m_cache.m_fHwVirtExEnabled); 242 mCbNestedPaging->setChecked(m_cache.m_fNestedPagingEnabled); 243 mSlMemory->setValue(m_cache.m_iRAMSize); 244 mSlCPU->setValue(m_cache.m_cCPUCount); 245 int iChipsetPositionPos = mCbChipset->findData(m_cache.m_chipsetType); 240 /* Load other system data to page: */ 241 mCbApic->setChecked(systemData.m_fIoApicEnabled); 242 mCbEFI->setChecked(systemData.m_fEFIEnabled); 243 mCbTCUseUTC->setChecked(systemData.m_fUTCEnabled); 244 mCbUseAbsHID->setChecked(systemData.m_fUseAbsHID); 245 mSlCPU->setEnabled(systemData.m_fPFHwVirtExSupported); 246 mLeCPU->setEnabled(systemData.m_fPFHwVirtExSupported); 247 mCbPae->setEnabled(systemData.m_fPFPAESupported); 248 mCbPae->setChecked(systemData.m_fPAEEnabled); 249 mCbVirt->setEnabled(systemData.m_fPFHwVirtExSupported); 250 mCbVirt->setChecked(systemData.m_fHwVirtExEnabled); 251 mCbNestedPaging->setEnabled(systemData.m_fPFHwVirtExSupported && systemData.m_fHwVirtExEnabled); 252 mCbNestedPaging->setChecked(systemData.m_fNestedPagingEnabled); 253 mSlMemory->setValue(systemData.m_iRAMSize); 254 mSlCPU->setValue(systemData.m_cCPUCount); 255 int iChipsetPositionPos = mCbChipset->findData(systemData.m_chipsetType); 246 256 mCbChipset->setCurrentIndex(iChipsetPositionPos == -1 ? 0 : iChipsetPositionPos); 247 if (! m_cache.m_fPFHwVirtExSupported)257 if (!systemData.m_fPFHwVirtExSupported) 248 258 mTwSystem->removeTab(2); 249 259 … … 256 266 void UIMachineSettingsSystem::putToCache() 257 267 { 258 /* Gather internal variables data from QWidget(s): */ 259 m_cache.m_bootItems.clear(); 268 /* Prepare system data: */ 269 UIDataSettingsMachineSystem systemData = m_cache.base(); 270 271 /* Gather system data: */ 272 systemData.m_bootItems.clear(); 260 273 for (int i = 0; i < mTwBootOrder->count(); ++i) 261 274 { … … 264 277 data.m_type = static_cast<UIBootTableItem*>(pItem)->type(); 265 278 data.m_fEnabled = pItem->checkState() == Qt::Checked; 266 m_cache.m_bootItems << data; 267 } 268 m_cache.m_fIoApicEnabled = mCbApic->isChecked() || mSlCPU->value() > 1 || 269 (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt() == KChipsetType_ICH9; 270 m_cache.m_fEFIEnabled = mCbEFI->isChecked(); 271 m_cache.m_fUTCEnabled = mCbTCUseUTC->isChecked(); 272 m_cache.m_fUseAbsHID = mCbUseAbsHID->isChecked(); 273 m_cache.m_fPAEEnabled = mCbPae->isChecked(); 274 m_cache.m_fHwVirtExEnabled = mCbVirt->checkState() == Qt::Checked || mSlCPU->value() > 1; 275 m_cache.m_fNestedPagingEnabled = mCbNestedPaging->isChecked(); 276 m_cache.m_iRAMSize = mSlMemory->value(); 277 m_cache.m_cCPUCount = mSlCPU->value(); 278 m_cache.m_chipsetType = (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt(); 279 systemData.m_bootItems << data; 280 } 281 systemData.m_fIoApicEnabled = mCbApic->isChecked() || mSlCPU->value() > 1 || 282 (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt() == KChipsetType_ICH9; 283 systemData.m_fEFIEnabled = mCbEFI->isChecked(); 284 systemData.m_fUTCEnabled = mCbTCUseUTC->isChecked(); 285 systemData.m_fUseAbsHID = mCbUseAbsHID->isChecked(); 286 systemData.m_fPAEEnabled = mCbPae->isChecked(); 287 systemData.m_fHwVirtExEnabled = mCbVirt->checkState() == Qt::Checked || mSlCPU->value() > 1; 288 systemData.m_fNestedPagingEnabled = mCbNestedPaging->isChecked(); 289 systemData.m_iRAMSize = mSlMemory->value(); 290 systemData.m_cCPUCount = mSlCPU->value(); 291 systemData.m_chipsetType = (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt(); 292 293 /* Cache system data: */ 294 m_cache.cacheCurrentData(systemData); 279 295 } 280 296 … … 286 302 UISettingsPageMachine::fetchData(data); 287 303 288 if (isMachineOffline()) 289 { 290 /* Motherboard tab: */ 291 m_machine.SetMemorySize(m_cache.m_iRAMSize); 292 int iBootIndex = 0; 293 /* Save boot-items of current VM: */ 294 for (int i = 0; i < m_cache.m_bootItems.size(); ++i) 304 /* Check if system data was changed: */ 305 if (m_cache.wasChanged()) 306 { 307 /* Get system data from cache: */ 308 const UIDataSettingsMachineSystem &systemData = m_cache.data(); 309 310 /* Store system data: */ 311 if (isMachineOffline()) 295 312 { 296 if (m_cache.m_bootItems[i].m_fEnabled) 297 m_machine.SetBootOrder(++iBootIndex, m_cache.m_bootItems[i].m_type); 313 /* Motherboard tab: */ 314 m_machine.SetMemorySize(systemData.m_iRAMSize); 315 int iBootIndex = 0; 316 /* Save boot-items of current VM: */ 317 for (int i = 0; i < systemData.m_bootItems.size(); ++i) 318 { 319 if (systemData.m_bootItems[i].m_fEnabled) 320 m_machine.SetBootOrder(++iBootIndex, systemData.m_bootItems[i].m_type); 321 } 322 /* Save other unique boot-items: */ 323 for (int i = 0; i < systemData.m_bootItems.size(); ++i) 324 { 325 if (!systemData.m_bootItems[i].m_fEnabled) 326 m_machine.SetBootOrder(++iBootIndex, KDeviceType_Null); 327 } 328 m_machine.SetChipsetType(systemData.m_chipsetType); 329 m_machine.GetBIOSSettings().SetIOAPICEnabled(systemData.m_fIoApicEnabled); 330 m_machine.SetFirmwareType(systemData.m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS); 331 m_machine.SetRTCUseUTC(systemData.m_fUTCEnabled); 332 m_machine.SetPointingHidType(systemData.m_fUseAbsHID ? KPointingHidType_USBTablet : KPointingHidType_PS2Mouse); 333 /* Processor tab: */ 334 m_machine.SetCPUCount(systemData.m_cCPUCount); 335 m_machine.SetCPUProperty(KCPUPropertyType_PAE, systemData.m_fPAEEnabled); 336 /* Acceleration tab: */ 337 m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_Enabled, systemData.m_fHwVirtExEnabled); 338 m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, systemData.m_fNestedPagingEnabled); 298 339 } 299 /* Save other unique boot-items: */300 for (int i = 0; i < m_cache.m_bootItems.size(); ++i)301 {302 if (!m_cache.m_bootItems[i].m_fEnabled)303 m_machine.SetBootOrder(++iBootIndex, KDeviceType_Null);304 }305 m_machine.SetChipsetType(m_cache.m_chipsetType);306 m_machine.GetBIOSSettings().SetIOAPICEnabled(m_cache.m_fIoApicEnabled);307 m_machine.SetFirmwareType(m_cache.m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS);308 m_machine.SetRTCUseUTC(m_cache.m_fUTCEnabled);309 m_machine.SetPointingHidType(m_cache.m_fUseAbsHID ? KPointingHidType_USBTablet : KPointingHidType_PS2Mouse);310 /* Processor tab: */311 m_machine.SetCPUCount(m_cache.m_cCPUCount);312 m_machine.SetCPUProperty(KCPUPropertyType_PAE, m_cache.m_fPAEEnabled);313 /* Acceleration tab: */314 m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_Enabled, m_cache.m_fHwVirtExEnabled);315 m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, m_cache.m_fNestedPagingEnabled);316 340 } 317 341 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h
r36357 r36919 27 27 struct UIBootItemData 28 28 { 29 /* Default constructor: */ 30 UIBootItemData() : m_type(KDeviceType_Null), m_fEnabled(false) {} 31 /* Operator==: */ 32 bool operator==(const UIBootItemData &other) const 33 { 34 return (m_type == other.m_type) && 35 (m_fEnabled == other.m_fEnabled); 36 } 37 /* Variables: */ 29 38 KDeviceType m_type; 30 39 bool m_fEnabled; 31 40 }; 32 41 33 /* Machine settings / System page / Cache: */34 struct UI SettingsCacheMachineSystem42 /* Machine settings / System page / Data: */ 43 struct UIDataSettingsMachineSystem 35 44 { 45 /* Default constructor: */ 46 UIDataSettingsMachineSystem() 47 : m_bootItems(QList<UIBootItemData>()) 48 , m_chipsetType(KChipsetType_Null) 49 , m_fPFHwVirtExSupported(false) 50 , m_fPFPAESupported(false) 51 , m_fIoApicEnabled(false) 52 , m_fEFIEnabled(false) 53 , m_fUTCEnabled(false) 54 , m_fUseAbsHID(false) 55 , m_fPAEEnabled(false) 56 , m_fHwVirtExEnabled(false) 57 , m_fNestedPagingEnabled(false) 58 , m_iRAMSize(-1) 59 , m_cCPUCount(-1) {} 60 /* Functions: */ 61 bool equal(const UIDataSettingsMachineSystem &other) const 62 { 63 return (m_bootItems == other.m_bootItems) && 64 (m_chipsetType == other.m_chipsetType) && 65 (m_fPFHwVirtExSupported == other.m_fPFHwVirtExSupported) && 66 (m_fPFPAESupported == other.m_fPFPAESupported) && 67 (m_fIoApicEnabled == other.m_fIoApicEnabled) && 68 (m_fEFIEnabled == other.m_fEFIEnabled) && 69 (m_fUTCEnabled == other.m_fUTCEnabled) && 70 (m_fUseAbsHID == other.m_fUseAbsHID) && 71 (m_fPAEEnabled == other.m_fPAEEnabled) && 72 (m_fHwVirtExEnabled == other.m_fHwVirtExEnabled) && 73 (m_fNestedPagingEnabled == other.m_fNestedPagingEnabled) && 74 (m_iRAMSize == other.m_iRAMSize) && 75 (m_cCPUCount == other.m_cCPUCount); 76 } 77 /* Operators: */ 78 bool operator==(const UIDataSettingsMachineSystem &other) const { return equal(other); } 79 bool operator!=(const UIDataSettingsMachineSystem &other) const { return !equal(other); } 80 /* Variables: */ 36 81 QList<UIBootItemData> m_bootItems; 37 82 KChipsetType m_chipsetType; … … 48 93 int m_cCPUCount; 49 94 }; 95 typedef UISettingsCache<UIDataSettingsMachineSystem> UICacheSettingsMachineSystem; 50 96 51 97 /* Machine settings / System page: */ … … 117 163 118 164 /* Cache: */ 119 UI SettingsCacheMachineSystem m_cache;165 UICacheSettingsMachineSystem m_cache; 120 166 }; 121 167
Note:
See TracChangeset
for help on using the changeset viewer.