Changeset 50325 in vbox
- Timestamp:
- Feb 5, 2014 12:09:34 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r49658 r50325 289 289 return; 290 290 291 /* Prepare medium-item: */ 292 UIMediumItem *pMediumItem = 0; 293 switch (medium.type()) 294 { 295 case UIMediumType_HardDisk: 296 { 297 pMediumItem = createHardDiskItem(mTwHD, medium); 298 AssertReturnVoid(pMediumItem); 299 if (pMediumItem->id() == m_strSelectedIdHD) 300 { 301 setCurrentItem(mTwHD, pMediumItem); 302 m_strSelectedIdHD = QString(); 303 } 304 break; 305 } 306 case UIMediumType_DVD: 307 { 308 pMediumItem = new UIMediumItem(medium, mTwCD); 309 AssertReturnVoid(pMediumItem); 310 if (pMediumItem->id() == m_strSelectedIdCD) 311 { 312 setCurrentItem(mTwCD, pMediumItem); 313 m_strSelectedIdCD = QString(); 314 } 315 break; 316 } 317 case UIMediumType_Floppy: 318 { 319 pMediumItem = new UIMediumItem(medium, mTwFD); 320 AssertReturnVoid(pMediumItem); 321 if (pMediumItem->id() == m_strSelectedIdFD) 322 { 323 setCurrentItem(mTwFD, pMediumItem); 324 m_strSelectedIdFD = QString(); 325 } 326 break; 327 } 328 default: AssertFailed(); 329 } 330 AssertPtrReturnVoid(pMediumItem); 331 332 /* Update tab-icons: */ 333 updateTabIcons(pMediumItem, ItemAction_Added); 334 335 /* If the media enumeration process is not started we have to select the 336 * newly added item as the current one for the case of new image was added or created */ 337 if (!vboxGlobal().isMediumEnumerationInProgress()) 338 setCurrentItem(treeWidget(medium.type()), pMediumItem); 339 340 /* Update stuff if that was current-item added: */ 341 if (pMediumItem == currentTreeWidget()->currentItem()) 342 sltHandleCurrentItemChanged(pMediumItem); 291 /* Create UIMediumItem for corresponding UIMedium: */ 292 createMediumItem(medium); 343 293 } 344 294 … … 424 374 return; 425 375 426 /* Search for corresponding medium-item: */ 427 UIMediumItem *pMediumItem = 0; 428 switch (medium.type()) 429 { 430 case UIMediumType_HardDisk: pMediumItem = searchItem(mTwHD, CheckIfSuitableByID(medium.id())); break; 431 case UIMediumType_DVD: pMediumItem = searchItem(mTwCD, CheckIfSuitableByID(medium.id())); break; 432 case UIMediumType_Floppy: pMediumItem = searchItem(mTwFD, CheckIfSuitableByID(medium.id())); break; 433 default: AssertFailed(); 434 } 435 436 /* If medium-item was not found it's time to create it: */ 437 if (!pMediumItem) 438 return sltHandleMediumCreated(strMediumID); 439 440 /* Update medium-item: */ 441 pMediumItem->setMedium(medium); 442 443 /* Update tab-icons: */ 444 updateTabIcons(pMediumItem, ItemAction_Updated); 445 446 /* Update stuff if that was current-item updated: */ 447 if (pMediumItem == currentTreeWidget()->currentItem()) 448 sltHandleCurrentItemChanged(pMediumItem); 376 /* Update UIMediumItem for corresponding UIMedium: */ 377 updateMediumItem(medium); 449 378 450 379 /* Advance progress-bar: */ … … 1253 1182 } 1254 1183 1184 void UIMediumManager::createMediumItem(const UIMedium &medium) 1185 { 1186 /* Prepare medium-item: */ 1187 UIMediumItem *pMediumItem = 0; 1188 switch (medium.type()) 1189 { 1190 /* Of hard-drive type: */ 1191 case UIMediumType_HardDisk: 1192 { 1193 pMediumItem = createHardDiskItem(mTwHD, medium); 1194 AssertPtrReturnVoid(pMediumItem); 1195 if (pMediumItem->id() == m_strSelectedIdHD) 1196 { 1197 setCurrentItem(mTwHD, pMediumItem); 1198 m_strSelectedIdHD = QString(); 1199 } 1200 break; 1201 } 1202 /* Of optical-image type: */ 1203 case UIMediumType_DVD: 1204 { 1205 pMediumItem = new UIMediumItem(medium, mTwCD); 1206 LogRel2(("UIMediumManager: Optical medium-item with ID={%s} created.\n", medium.id().toAscii().constData())); 1207 AssertPtrReturnVoid(pMediumItem); 1208 if (pMediumItem->id() == m_strSelectedIdCD) 1209 { 1210 setCurrentItem(mTwCD, pMediumItem); 1211 m_strSelectedIdCD = QString(); 1212 } 1213 break; 1214 } 1215 /* Of floppy-image type: */ 1216 case UIMediumType_Floppy: 1217 { 1218 pMediumItem = new UIMediumItem(medium, mTwFD); 1219 LogRel2(("UIMediumManager: Floppy medium-item with ID={%s} created.\n", medium.id().toAscii().constData())); 1220 AssertPtrReturnVoid(pMediumItem); 1221 if (pMediumItem->id() == m_strSelectedIdFD) 1222 { 1223 setCurrentItem(mTwFD, pMediumItem); 1224 m_strSelectedIdFD = QString(); 1225 } 1226 break; 1227 } 1228 default: AssertFailed(); 1229 } 1230 AssertPtrReturnVoid(pMediumItem); 1231 1232 /* Update tab-icons: */ 1233 updateTabIcons(pMediumItem, ItemAction_Added); 1234 1235 /* If medium-enumeration is not currently in progress we have to select the 1236 * newly added item as the 'current-item' (it seems new image was added): */ 1237 if (!vboxGlobal().isMediumEnumerationInProgress()) 1238 setCurrentItem(treeWidget(medium.type()), pMediumItem); 1239 1240 /* Update linked stuff if that was 'current-item' added: */ 1241 if (pMediumItem == currentTreeWidget()->currentItem()) 1242 sltHandleCurrentItemChanged(pMediumItem); 1243 } 1244 1245 void UIMediumManager::updateMediumItem(const UIMedium &medium) 1246 { 1247 /* Search for the existing medium-item: */ 1248 UIMediumItem *pMediumItem = searchItem(treeWidget(medium.type()), CheckIfSuitableByID(medium.id())); 1249 1250 /* Create new if was not found: */ 1251 if (!pMediumItem) 1252 return createMediumItem(medium); 1253 1254 /* Update otherwise: */ 1255 pMediumItem->setMedium(medium); 1256 LogRel2(("UIMediumManager: Medium-item with ID={%s} updated.\n", medium.id().toAscii().constData())); 1257 1258 /* Update tab-icons: */ 1259 updateTabIcons(pMediumItem, ItemAction_Updated); 1260 1261 /* Update linked stuff if that was 'current-item' updated: */ 1262 if (pMediumItem == currentTreeWidget()->currentItem()) 1263 sltHandleCurrentItemChanged(pMediumItem); 1264 } 1265 1255 1266 bool UIMediumManager::releaseMediumFrom(const UIMedium &medium, const QString &strMachineId) 1256 1267 { … … 1510 1521 /* If parent medium-item was found: */ 1511 1522 if (pParentMediumItem) 1523 { 1512 1524 pMediumItem = new UIMediumItem(medium, pParentMediumItem); 1525 LogRel2(("UIMediumManager: Child hard-drive medium-item with ID={%s} created.\n", medium.id().toAscii().constData())); 1526 } 1513 1527 } 1514 1528 /* Else just create item as top-level one: */ 1515 1529 if (!pMediumItem) 1530 { 1516 1531 pMediumItem = new UIMediumItem(medium, pTree); 1532 LogRel2(("UIMediumManager: Root hard-drive medium-item with ID={%s} created.\n", medium.id().toAscii().constData())); 1533 } 1517 1534 } 1518 1535 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r49657 r50325 130 130 void retranslateUi(); 131 131 132 /** Creates UIMediumItem for corresponding UIMedium. */ 133 void createMediumItem(const UIMedium &medium); 134 /** Updates UIMediumItem for corresponding UIMedium. */ 135 void updateMediumItem(const UIMedium &medium); 136 132 137 /* Helpers: Medium-modification stuff: */ 133 138 bool releaseMediumFrom(const UIMedium &medium, const QString &strMachineId);
Note:
See TracChangeset
for help on using the changeset viewer.