Changeset 50363 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 7, 2014 1:33:58 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
r50353 r50363 273 273 } 274 274 275 void UIMediumManager:: refreshAll()275 void UIMediumManager::sltRefreshAll() 276 276 { 277 277 /* Start medium-enumeration: */ … … 293 293 return; 294 294 295 /* Create UIMediumItem for corresponding UIMedium: */295 /* Create UIMediumItem for corresponding 'medium': */ 296 296 createMediumItem(medium); 297 297 } … … 299 299 void UIMediumManager::sltHandleMediumDeleted(const QString &strMediumID) 300 300 { 301 /* Get tree-widget / medium-item: */ 302 QList<UIMediumType> types; 303 types << UIMediumType_HardDisk << UIMediumType_DVD << UIMediumType_Floppy; 304 QTreeWidget *pTreeWidget = 0; 305 UIMediumItem *pMediumItem = 0; 306 foreach (UIMediumType type, types) 307 { 308 pTreeWidget = treeWidget(type); 309 pMediumItem = searchItem(pTreeWidget, CheckIfSuitableByID(strMediumID)); 310 if (pMediumItem) 311 break; 312 } 313 314 /* Skip further actions if medium-item was not found: */ 315 if (!pMediumItem) 316 return; 317 318 /* Update tab-icons: */ 319 updateTabIcons(pMediumItem, ItemAction_Removed); 320 321 /* Delete medium-item: */ 322 delete pMediumItem; 323 324 /* Make sure 'current' or at least 'first available' medium-item is currently selected, if any: */ 325 setCurrentItem(pTreeWidget, pTreeWidget->currentItem() ? pTreeWidget->currentItem() : pTreeWidget->topLevelItem(0)); 301 /* Delete UIMediumItem for corresponding 'strMediumID': */ 302 deleteMediumItem(strMediumID); 326 303 } 327 304 … … 367 344 return; 368 345 369 /* Update UIMediumItem for corresponding UIMedium: */346 /* Update UIMediumItem for corresponding 'medium': */ 370 347 updateMediumItem(medium); 371 348 … … 801 778 ":/refresh_22px.png", ":/refresh_16px.png", 802 779 ":/refresh_disabled_22px.png", ":/refresh_disabled_16px.png")); 803 connect(m_pActionRefresh, SIGNAL(triggered()), this, SLOT( refreshAll()));780 connect(m_pActionRefresh, SIGNAL(triggered()), this, SLOT(sltRefreshAll())); 804 781 } 805 782 } … … 1351 1328 /* Full refresh if there is at least one item present: */ 1352 1329 if (mTwHD->topLevelItemCount() || mTwCD->topLevelItemCount() || mTwFD->topLevelItemCount()) 1353 refreshAll();1330 sltRefreshAll(); 1354 1331 } 1355 1332 1356 1333 void UIMediumManager::createMediumItem(const UIMedium &medium) 1357 1334 { 1335 /* Get medium type: */ 1336 UIMediumType type = medium.type(); 1337 /* Get corresponding tree-widget: */ 1338 QTreeWidget *pTreeWidget = treeWidget(type); 1339 1358 1340 /* Prepare medium-item: */ 1359 1341 UIMediumItem *pMediumItem = 0; 1360 switch ( medium.type())1342 switch (type) 1361 1343 { 1362 1344 /* Of hard-drive type: */ … … 1398 1380 break; 1399 1381 } 1400 default: Assert Failed();1382 default: AssertMsgFailed(("Medium-type unknown: %d\n", type)); break; 1401 1383 } 1402 1384 AssertPtrReturnVoid(pMediumItem); … … 1405 1387 updateTabIcons(pMediumItem, ItemAction_Added); 1406 1388 1407 /* If medium-enumeration is not currently in progress we have to select the 1408 * newly added item as the 'current-item' (it seems new image was added): */ 1409 if (!vboxGlobal().isMediumEnumerationInProgress()) 1410 setCurrentItem(treeWidget(medium.type()), pMediumItem); 1411 1412 /* If no 'current-item' yet selected 1413 * we have to choose newly added as the 'current-item': */ 1414 if (!treeWidget(medium.type())->currentItem()) 1415 setCurrentItem(treeWidget(medium.type()), pMediumItem); 1416 1417 /* Update linked stuff if that was 'current-item' added: */ 1418 if (pMediumItem == currentTreeWidget()->currentItem()) 1389 /* If medium-enumeration is not currently in progress or 1390 * if there is no 'current' medium-item yet selected 1391 * we have to choose newly added medium-item as 'current' one: */ 1392 if ( !vboxGlobal().isMediumEnumerationInProgress() 1393 || !pTreeWidget->currentItem()) 1394 setCurrentItem(pTreeWidget, pMediumItem); 1395 1396 /* Update linked stuff if that was current medium-item created: */ 1397 if (pMediumItem == currentMediumItem()) 1419 1398 sltHandleCurrentItemChanged(pMediumItem); 1420 1399 } … … 1422 1401 void UIMediumManager::updateMediumItem(const UIMedium &medium) 1423 1402 { 1424 /* Search for theexisting medium-item: */1403 /* Search for existing medium-item: */ 1425 1404 UIMediumItem *pMediumItem = searchItem(treeWidget(medium.type()), CheckIfSuitableByID(medium.id())); 1426 1405 1427 /* Create new if was not found: */1406 /* Create medium-item (if it was not found): */ 1428 1407 if (!pMediumItem) 1429 1408 return createMediumItem(medium); 1430 1409 1431 /* Update otherwise: */1410 /* Update medium-item: */ 1432 1411 pMediumItem->setMedium(medium); 1433 1412 LogRel2(("UIMediumManager: Medium-item with ID={%s} updated.\n", medium.id().toAscii().constData())); … … 1436 1415 updateTabIcons(pMediumItem, ItemAction_Updated); 1437 1416 1438 /* Update linked stuff if that was 'current-item'updated: */1439 if (pMediumItem == current TreeWidget()->currentItem())1417 /* Update linked stuff if that was current medium-item updated: */ 1418 if (pMediumItem == currentMediumItem()) 1440 1419 sltHandleCurrentItemChanged(pMediumItem); 1420 } 1421 1422 void UIMediumManager::deleteMediumItem(const QString &strMediumID) 1423 { 1424 /* Search for corresponding tree-widget: */ 1425 QList<UIMediumType> types; 1426 types << UIMediumType_HardDisk << UIMediumType_DVD << UIMediumType_Floppy; 1427 QTreeWidget *pTreeWidget = 0; 1428 UIMediumItem *pMediumItem = 0; 1429 foreach (UIMediumType type, types) 1430 { 1431 /* Get iterated tree-widget: */ 1432 pTreeWidget = treeWidget(type); 1433 /* Search for existing medium-item: */ 1434 pMediumItem = searchItem(pTreeWidget, CheckIfSuitableByID(strMediumID)); 1435 if (pMediumItem) 1436 break; 1437 } 1438 1439 /* Ignore medium-item (if it was not found): */ 1440 if (!pMediumItem) 1441 return; 1442 1443 /* Update tab-icons: */ 1444 updateTabIcons(pMediumItem, ItemAction_Removed); 1445 1446 /* Delete medium-item: */ 1447 delete pMediumItem; 1448 LogRel2(("UIMediumManager: Medium-item with ID={%s} deleted.\n", strMediumID.toAscii().constData())); 1449 1450 /* If there is no 'current' medium-item now selected 1451 * we have to choose first-available medium-item as 'current' one: */ 1452 if (!pTreeWidget->currentItem()) 1453 setCurrentItem(pTreeWidget, pTreeWidget->topLevelItem(0)); 1441 1454 } 1442 1455 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r50353 r50363 65 65 static void showModeless(QWidget *pCenterWidget, bool fRefresh = true); 66 66 67 public slots:68 69 /* Handler: Refresh stuff: */70 void refreshAll();71 72 67 private slots: 68 69 /** Fully refreshes medium manager contents. */ 70 void sltRefreshAll(); 73 71 74 72 /* Handlers: Medium-processing stuff: */ … … 143 141 void retranslateUi(); 144 142 145 /** Creates UIMediumItem for corresponding UIMedium. */143 /** Creates UIMediumItem for corresponding @a medium. */ 146 144 void createMediumItem(const UIMedium &medium); 147 /** Updates UIMediumItem for corresponding UIMedium. */145 /** Updates UIMediumItem for corresponding @a medium. */ 148 146 void updateMediumItem(const UIMedium &medium); 147 /** Deletes UIMediumItem for corresponding @a strMediumID. */ 148 void deleteMediumItem(const QString &strMediumID); 149 149 150 150 /* Helpers: Medium-modification stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.