Changeset 66444 in vbox
- Timestamp:
- Apr 5, 2017 3:12:54 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r66345 r66444 2150 2150 /* Update chipset type value: */ 2151 2151 m_pModelStorage->setChipsetType(enmType); 2152 sltUpdateAction sState();2152 sltUpdateActionStates(); 2153 2153 2154 2154 /* Revalidate: */ … … 2169 2169 m_pCache->clear(); 2170 2170 2171 /* Gather storage data: */ 2171 /* Prepare old storage data: */ 2172 UIDataSettingsMachineStorage oldStorageData; 2173 2174 /* Gather old common data: */ 2172 2175 m_strMachineId = m_machine.GetId(); 2173 2176 m_strMachineSettingsFilePath = m_machine.GetSettingsFilePath(); … … 2178 2181 for (int iControllerIndex = 0; iControllerIndex < controllers.size(); ++iControllerIndex) 2179 2182 { 2180 /* Prepare storagecontroller data: */2181 UIDataSettingsMachineStorageController storageControllerData;2182 2183 /* Check ifcontroller is valid: */2184 const CStorageController &co ntroller = controllers[iControllerIndex];2185 if (!co ntroller.isNull())2186 { 2187 /* Gather storagecontroller data: */2188 storageControllerData.m_strControllerName = controller.GetName();2189 storageControllerData.m_controllerBus = controller.GetBus();2190 storageControllerData.m_controllerType = controller.GetControllerType();2191 storageControllerData.m_uPortCount = controller.GetPortCount();2192 storageControllerData.m_fUseHostIOCache = controller.GetUseHostIOCache();2183 /* Prepare old controller data: */ 2184 UIDataSettingsMachineStorageController oldControllerData; 2185 2186 /* Check whether controller is valid: */ 2187 const CStorageController &comController = controllers.at(iControllerIndex); 2188 if (!comController.isNull()) 2189 { 2190 /* Gather old controller data: */ 2191 oldControllerData.m_strControllerName = comController.GetName(); 2192 oldControllerData.m_controllerBus = comController.GetBus(); 2193 oldControllerData.m_controllerType = comController.GetControllerType(); 2194 oldControllerData.m_uPortCount = comController.GetPortCount(); 2195 oldControllerData.m_fUseHostIOCache = comController.GetUseHostIOCache(); 2193 2196 2194 2197 /* Sort attachments before caching/fetching: */ 2195 2198 const CMediumAttachmentVector &attachmentVector = 2196 m_machine.GetMediumAttachmentsOfController(storageControllerData.m_strControllerName);2199 m_machine.GetMediumAttachmentsOfController(oldControllerData.m_strControllerName); 2197 2200 QMap<StorageSlot, CMediumAttachment> attachmentMap; 2198 foreach (const CMediumAttachment & attachment, attachmentVector)2201 foreach (const CMediumAttachment &comAttachment, attachmentVector) 2199 2202 { 2200 StorageSlot storageSlot(storageControllerData.m_controllerBus,2201 attachment.GetPort(), attachment.GetDevice());2202 attachmentMap.insert(storageSlot, attachment);2203 const StorageSlot storageSlot(oldControllerData.m_controllerBus, 2204 comAttachment.GetPort(), comAttachment.GetDevice()); 2205 attachmentMap.insert(storageSlot, comAttachment); 2203 2206 } 2204 2207 const QList<CMediumAttachment> &attachments = attachmentMap.values(); … … 2207 2210 for (int iAttachmentIndex = 0; iAttachmentIndex < attachments.size(); ++iAttachmentIndex) 2208 2211 { 2209 /* Prepare storageattachment data: */2210 UIDataSettingsMachineStorageAttachment storageAttachmentData;2211 2212 /* Check ifattachment is valid: */2213 const CMediumAttachment & attachment = attachments[iAttachmentIndex];2214 if (! attachment.isNull())2212 /* Prepare old attachment data: */ 2213 UIDataSettingsMachineStorageAttachment oldAttachmentData; 2214 2215 /* Check whether attachment is valid: */ 2216 const CMediumAttachment &comAttachment = attachments.at(iAttachmentIndex); 2217 if (!comAttachment.isNull()) 2215 2218 { 2216 /* Gather storageattachment data: */2217 storageAttachmentData.m_attachmentType = attachment.GetType();2218 storageAttachmentData.m_iAttachmentPort = attachment.GetPort();2219 storageAttachmentData.m_iAttachmentDevice = attachment.GetDevice();2220 storageAttachmentData.m_fAttachmentPassthrough = attachment.GetPassthrough();2221 storageAttachmentData.m_fAttachmentTempEject = attachment.GetTemporaryEject();2222 storageAttachmentData.m_fAttachmentNonRotational = attachment.GetNonRotational();2223 storageAttachmentData.m_fAttachmentHotPluggable = attachment.GetHotPluggable();2224 const CMedium c medium = attachment.GetMedium();2225 storageAttachmentData.m_strAttachmentMediumId = cmedium.isNull() ? UIMedium::nullID() : cmedium.GetId();2219 /* Gather old attachment data: */ 2220 oldAttachmentData.m_attachmentType = comAttachment.GetType(); 2221 oldAttachmentData.m_iAttachmentPort = comAttachment.GetPort(); 2222 oldAttachmentData.m_iAttachmentDevice = comAttachment.GetDevice(); 2223 oldAttachmentData.m_fAttachmentPassthrough = comAttachment.GetPassthrough(); 2224 oldAttachmentData.m_fAttachmentTempEject = comAttachment.GetTemporaryEject(); 2225 oldAttachmentData.m_fAttachmentNonRotational = comAttachment.GetNonRotational(); 2226 oldAttachmentData.m_fAttachmentHotPluggable = comAttachment.GetHotPluggable(); 2227 const CMedium comMedium = comAttachment.GetMedium(); 2228 oldAttachmentData.m_strAttachmentMediumId = comMedium.isNull() ? UIMedium::nullID() : comMedium.GetId(); 2226 2229 } 2227 2230 2228 /* Cache storageattachment data: */2229 m_pCache->child(iControllerIndex).child(iAttachmentIndex).cacheInitialData( storageAttachmentData);2231 /* Cache old attachment data: */ 2232 m_pCache->child(iControllerIndex).child(iAttachmentIndex).cacheInitialData(oldAttachmentData); 2230 2233 } 2231 2234 } 2232 2235 2233 /* Cache storage controller data: */ 2234 m_pCache->child(iControllerIndex).cacheInitialData(storageControllerData); 2235 } 2236 /* Cache old controller data: */ 2237 m_pCache->child(iControllerIndex).cacheInitialData(oldControllerData); 2238 } 2239 2240 /* Cache old storage data: */ 2241 m_pCache->cacheInitialData(oldStorageData); 2236 2242 2237 2243 /* Upload machine to data: */ … … 2244 2250 m_pModelStorage->clear(); 2245 2251 2246 /* Load storage data topage: */2252 /* Load old common data to the page: */ 2247 2253 m_pModelStorage->setMachineId(m_strMachineId); 2248 2254 2249 /* For each storagecontroller: */2255 /* For each controller: */ 2250 2256 for (int iControllerIndex = 0; iControllerIndex < m_pCache->childCount(); ++iControllerIndex) 2251 2257 { 2252 /* Get storagecontroller cache: */2258 /* Get controller cache: */ 2253 2259 const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex); 2254 /* Get storage controller data fromcache: */2255 const UIDataSettingsMachineStorageController & controllerData = controllerCache.base();2256 2257 /* Load storage controller data topage: */2258 QModelIndex controllerIndex = m_pModelStorage->addController(controllerData.m_strControllerName,2259 controllerData.m_controllerBus,2260 controllerData.m_controllerType);2261 QUuid controllerId = QUuid(m_pModelStorage->data(controllerIndex, StorageModel::R_ItemId).toString());2262 m_pModelStorage->setData(controllerIndex, controllerData.m_uPortCount, StorageModel::R_CtrPortCount);2263 m_pModelStorage->setData(controllerIndex, controllerData.m_fUseHostIOCache, StorageModel::R_CtrIoCache);2264 2265 /* For each storageattachment: */2260 /* Get old controller data from the cache: */ 2261 const UIDataSettingsMachineStorageController &oldControllerData = controllerCache.base(); 2262 2263 /* Load old controller data to the page: */ 2264 const QModelIndex controllerIndex = m_pModelStorage->addController(oldControllerData.m_strControllerName, 2265 oldControllerData.m_controllerBus, 2266 oldControllerData.m_controllerType); 2267 const QUuid controllerId = QUuid(m_pModelStorage->data(controllerIndex, StorageModel::R_ItemId).toString()); 2268 m_pModelStorage->setData(controllerIndex, oldControllerData.m_uPortCount, StorageModel::R_CtrPortCount); 2269 m_pModelStorage->setData(controllerIndex, oldControllerData.m_fUseHostIOCache, StorageModel::R_CtrIoCache); 2270 2271 /* For each attachment: */ 2266 2272 for (int iAttachmentIndex = 0; iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) 2267 2273 { 2268 /* Get storageattachment cache: */2274 /* Get attachment cache: */ 2269 2275 const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex); 2270 /* Get storage controller data from cache: */ 2271 const UIDataSettingsMachineStorageAttachment &attachmentData = attachmentCache.base(); 2272 2273 /* Load storage attachment data to page: */ 2274 QModelIndex attachmentIndex = m_pModelStorage->addAttachment(controllerId, attachmentData.m_attachmentType, attachmentData.m_strAttachmentMediumId); 2275 StorageSlot attachmentStorageSlot(controllerData.m_controllerBus, 2276 attachmentData.m_iAttachmentPort, 2277 attachmentData.m_iAttachmentDevice); 2276 /* Get old attachment data from the cache: */ 2277 const UIDataSettingsMachineStorageAttachment &oldAttachmentData = attachmentCache.base(); 2278 2279 /* Load old attachment data to the page: */ 2280 const QModelIndex attachmentIndex = m_pModelStorage->addAttachment(controllerId, 2281 oldAttachmentData.m_attachmentType, 2282 oldAttachmentData.m_strAttachmentMediumId); 2283 const StorageSlot attachmentStorageSlot(oldControllerData.m_controllerBus, 2284 oldAttachmentData.m_iAttachmentPort, 2285 oldAttachmentData.m_iAttachmentDevice); 2278 2286 m_pModelStorage->setData(attachmentIndex, QVariant::fromValue(attachmentStorageSlot), StorageModel::R_AttSlot); 2279 m_pModelStorage->setData(attachmentIndex, attachmentData.m_fAttachmentPassthrough, StorageModel::R_AttIsPassthrough); 2280 m_pModelStorage->setData(attachmentIndex, attachmentData.m_fAttachmentTempEject, StorageModel::R_AttIsTempEject); 2281 m_pModelStorage->setData(attachmentIndex, attachmentData.m_fAttachmentNonRotational, StorageModel::R_AttIsNonRotational); 2282 m_pModelStorage->setData(attachmentIndex, attachmentData.m_fAttachmentHotPluggable, StorageModel::R_AttIsHotPluggable); 2283 } 2284 } 2285 /* Set the first controller as current if present */ 2287 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_fAttachmentPassthrough, StorageModel::R_AttIsPassthrough); 2288 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_fAttachmentTempEject, StorageModel::R_AttIsTempEject); 2289 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_fAttachmentNonRotational, StorageModel::R_AttIsNonRotational); 2290 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_fAttachmentHotPluggable, StorageModel::R_AttIsHotPluggable); 2291 } 2292 } 2293 2294 /* Choose first controller as current: */ 2286 2295 if (m_pModelStorage->rowCount(m_pModelStorage->root()) > 0) 2287 2296 m_pTreeStorage->setCurrentIndex(m_pModelStorage->index(0, 0, m_pModelStorage->root())); 2288 2297 2289 /* Update action s: */2290 sltUpdateAction sState();2298 /* Update action states: */ 2299 sltUpdateActionStates(); 2291 2300 2292 2301 /* Polish page finally: */ … … 2299 2308 void UIMachineSettingsStorage::putToCache() 2300 2309 { 2301 /* Prepare storage data: */2302 UIDataSettingsMachineStorage storageData = m_pCache->base();2303 2304 /* For each storagecontroller: */2305 QModelIndex rootIndex = m_pModelStorage->root();2310 /* Prepare new storage data: */ 2311 UIDataSettingsMachineStorage newStorageData; 2312 2313 /* For each controller: */ 2314 const QModelIndex rootIndex = m_pModelStorage->root(); 2306 2315 for (int iControllerIndex = 0; iControllerIndex < m_pModelStorage->rowCount(rootIndex); ++iControllerIndex) 2307 2316 { 2308 /* Prepare storagecontroller data & key: */2309 UIDataSettingsMachineStorageController controllerData;2310 2311 /* Gather storage controller data: */2312 QModelIndex controllerIndex = m_pModelStorage->index(iControllerIndex, 0, rootIndex);2313 controllerData.m_strControllerName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString();2314 controllerData.m_controllerBus = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrBusType).value<KStorageBus>();2315 controllerData.m_controllerType = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrType).value<KStorageControllerType>();2316 controllerData.m_uPortCount = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrPortCount).toUInt();2317 controllerData.m_fUseHostIOCache = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrIoCache).toBool();2318 2319 /* For each storageattachment: */2317 /* Prepare new controller data & key: */ 2318 UIDataSettingsMachineStorageController newControllerData; 2319 2320 /* Gather new controller data from model: */ 2321 const QModelIndex controllerIndex = m_pModelStorage->index(iControllerIndex, 0, rootIndex); 2322 newControllerData.m_strControllerName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString(); 2323 newControllerData.m_controllerBus = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrBusType).value<KStorageBus>(); 2324 newControllerData.m_controllerType = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrType).value<KStorageControllerType>(); 2325 newControllerData.m_uPortCount = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrPortCount).toUInt(); 2326 newControllerData.m_fUseHostIOCache = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrIoCache).toBool(); 2327 2328 /* For each attachment: */ 2320 2329 for (int iAttachmentIndex = 0; iAttachmentIndex < m_pModelStorage->rowCount(controllerIndex); ++iAttachmentIndex) 2321 2330 { 2322 /* Prepare storageattachment data & key: */2323 UIDataSettingsMachineStorageAttachment attachmentData;2324 2325 /* Gather storage controller data: */2326 QModelIndex attachmentIndex = m_pModelStorage->index(iAttachmentIndex, 0, controllerIndex);2327 attachmentData.m_attachmentType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>();2328 StorageSlot attachmentSlot = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttSlot).value<StorageSlot>();2329 attachmentData.m_iAttachmentPort = attachmentSlot.port;2330 attachmentData.m_iAttachmentDevice = attachmentSlot.device;2331 attachmentData.m_fAttachmentPassthrough = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsPassthrough).toBool();2332 attachmentData.m_fAttachmentTempEject = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsTempEject).toBool();2333 attachmentData.m_fAttachmentNonRotational = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsNonRotational).toBool();2334 attachmentData.m_fAttachmentHotPluggable = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsHotPluggable).toBool();2335 attachmentData.m_strAttachmentMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString();2336 2337 /* Recache storageattachment data: */2338 m_pCache->child(iControllerIndex).child(iAttachmentIndex).cacheCurrentData( attachmentData);2339 } 2340 2341 /* Recache storagecontroller data: */2342 m_pCache->child(iControllerIndex).cacheCurrentData( controllerData);2343 } 2344 2345 /* Recachestorage data: */2346 m_pCache->cacheCurrentData( storageData);2331 /* Prepare new attachment data & key: */ 2332 UIDataSettingsMachineStorageAttachment newAttachmentData; 2333 2334 /* Gather new controller data from model: */ 2335 const QModelIndex attachmentIndex = m_pModelStorage->index(iAttachmentIndex, 0, controllerIndex); 2336 newAttachmentData.m_attachmentType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>(); 2337 const StorageSlot attachmentSlot = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttSlot).value<StorageSlot>(); 2338 newAttachmentData.m_iAttachmentPort = attachmentSlot.port; 2339 newAttachmentData.m_iAttachmentDevice = attachmentSlot.device; 2340 newAttachmentData.m_fAttachmentPassthrough = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsPassthrough).toBool(); 2341 newAttachmentData.m_fAttachmentTempEject = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsTempEject).toBool(); 2342 newAttachmentData.m_fAttachmentNonRotational = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsNonRotational).toBool(); 2343 newAttachmentData.m_fAttachmentHotPluggable = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsHotPluggable).toBool(); 2344 newAttachmentData.m_strAttachmentMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString(); 2345 2346 /* Cache new attachment data: */ 2347 m_pCache->child(iControllerIndex).child(iAttachmentIndex).cacheCurrentData(newAttachmentData); 2348 } 2349 2350 /* Cache new controller data: */ 2351 m_pCache->child(iControllerIndex).cacheCurrentData(newControllerData); 2352 } 2353 2354 /* Cache new storage data: */ 2355 m_pCache->cacheCurrentData(newStorageData); 2347 2356 } 2348 2357 … … 2554 2563 2555 2564 /* Update action states: */ 2556 sltUpdateAction sState();2565 sltUpdateActionStates(); 2557 2566 } 2558 2567 … … 3093 3102 } 3094 3103 3095 void UIMachineSettingsStorage::sltUpdateAction sState()3104 void UIMachineSettingsStorage::sltUpdateActionStates() 3096 3105 { 3097 3106 const QModelIndex index = m_pTreeStorage->currentIndex(); … … 3159 3168 } 3160 3169 3161 sltUpdateAction sState();3170 sltUpdateActionStates(); 3162 3171 sltGetInformation(); 3163 3172 } … … 3168 3177 m_pTreeStorage->setCurrentIndex (m_pModelStorage->root()); 3169 3178 3170 sltUpdateAction sState();3179 sltUpdateActionStates(); 3171 3180 sltGetInformation(); 3172 3181 } … … 3174 3183 void UIMachineSettingsStorage::sltHandleCurrentItemChange() 3175 3184 { 3176 sltUpdateAction sState();3185 sltUpdateActionStates(); 3177 3186 sltGetInformation(); 3178 3187 } … … 4133 4142 if (fSuccess) 4134 4143 { 4135 /* Get storage controller data from cache: */4144 /* Get storage controller data from the cache: */ 4136 4145 const UIDataSettingsMachineStorageController &controllerData = controllerCache.base(); 4137 /* Get storage attachment data from cache: */4146 /* Get storage attachment data from the cache: */ 4138 4147 const UIDataSettingsMachineStorageAttachment &attachmentData = attachmentCache.base(); 4139 4148 … … 4168 4177 if (fSuccess) 4169 4178 { 4170 /* Get storage controller data from cache: */4179 /* Get storage controller data from the cache: */ 4171 4180 const UIDataSettingsMachineStorageController &controllerData = controllerCache.data(); 4172 /* Get storage attachment data from cache: */4181 /* Get storage attachment data from the cache: */ 4173 4182 const UIDataSettingsMachineStorageAttachment &attachmentData = attachmentCache.data(); 4174 4183 … … 4257 4266 if (fSuccess) 4258 4267 { 4259 /* Get storage controller data from cache: */4268 /* Get storage controller data from the cache: */ 4260 4269 const UIDataSettingsMachineStorageController &controllerData = controllerCache.data(); 4261 /* Get current storage attachment data from cache: */4270 /* Get current storage attachment data from the cache: */ 4262 4271 const UIDataSettingsMachineStorageAttachment &attachmentData = attachmentCache.data(); 4263 4272 … … 4357 4366 * KDeviceType_Floppy or KDeviceType_DVD. 4358 4367 * For other cases we will recreate attachment fully: */ 4359 const UIDataSettingsMachineStorageAttachment & initialAttachmentData = attachmentCache.base();4360 const UIDataSettingsMachineStorageAttachment & currentAttachmentData = attachmentCache.data();4361 const KDeviceType enmInitialAttachmentDeviceType = initialAttachmentData.m_attachmentType;4362 const KDeviceType enmCurrentAttachmentDeviceType = currentAttachmentData.m_attachmentType;4363 const LONG iInitialAttachmentDevice = initialAttachmentData.m_iAttachmentDevice;4364 const LONG iCurrentAttachmentDevice = currentAttachmentData.m_iAttachmentDevice;4365 const LONG iInitialAttachmentPort = initialAttachmentData.m_iAttachmentPort;4366 const LONG iCurrentAttachmentPort = currentAttachmentData.m_iAttachmentPort;4368 const UIDataSettingsMachineStorageAttachment &oldAttachmentData = attachmentCache.base(); 4369 const UIDataSettingsMachineStorageAttachment &newAttachmentData = attachmentCache.data(); 4370 const KDeviceType enmInitialAttachmentDeviceType = oldAttachmentData.m_attachmentType; 4371 const KDeviceType enmCurrentAttachmentDeviceType = newAttachmentData.m_attachmentType; 4372 const LONG iInitialAttachmentDevice = oldAttachmentData.m_iAttachmentDevice; 4373 const LONG iCurrentAttachmentDevice = newAttachmentData.m_iAttachmentDevice; 4374 const LONG iInitialAttachmentPort = oldAttachmentData.m_iAttachmentPort; 4375 const LONG iCurrentAttachmentPort = newAttachmentData.m_iAttachmentPort; 4367 4376 return (enmCurrentAttachmentDeviceType == enmInitialAttachmentDeviceType) && 4368 4377 (iCurrentAttachmentDevice == iInitialAttachmentDevice) && -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h
r66345 r66444 705 705 706 706 /** Updates action states. */ 707 void sltUpdateAction sState();707 void sltUpdateActionStates(); 708 708 709 709 /** Handles row insertion into @a parent on @a iPosition. */
Note:
See TracChangeset
for help on using the changeset viewer.