Changeset 50712 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 6, 2014 2:00:01 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
r50706 r50712 422 422 , m_pCenterWidget(pCenterWidget) 423 423 , m_fRefresh(fRefresh) 424 , m_fPreventChangeCurrentItem(false) 424 425 , m_fInaccessibleHD(false) 425 426 , m_fInaccessibleCD(false) … … 475 476 return; 476 477 477 /* Create UIMediumItem for corresponding 'medium': */ 478 createMediumItem(medium); 478 /* Create medium-item for corresponding medium: */ 479 UIMediumItem *pMediumItem = createMediumItem(medium); 480 AssertPtrReturnVoid(pMediumItem); 481 482 /* If medium-item change allowed and 483 * 1. medium-enumeration is not currently in progress or 484 * 2. if there is no currently medium-item selected 485 * we have to choose newly added medium-item as current one: */ 486 if ( !m_fPreventChangeCurrentItem 487 && ( !vboxGlobal().isMediumEnumerationInProgress() 488 || !mediumItem(medium.type()))) 489 setCurrentItem(treeWidget(medium.type()), pMediumItem); 479 490 } 480 491 … … 1087 1098 pTreeWidgetFD->clear(); 1088 1099 1089 /* Create medium-items: */ 1100 /* Create medium-items (do not change current one): */ 1101 m_fPreventChangeCurrentItem = true; 1090 1102 foreach (const QString &strMediumID, vboxGlobal().mediumIDs()) 1091 1103 sltHandleMediumCreated(strMediumID); 1104 m_fPreventChangeCurrentItem = false; 1092 1105 1093 1106 /* Select first item as current one if nothing selected: */ … … 1445 1458 } 1446 1459 1447 voidUIMediumManager::createMediumItem(const UIMedium &medium)1460 UIMediumItem* UIMediumManager::createMediumItem(const UIMedium &medium) 1448 1461 { 1449 1462 /* Get medium type: */ 1450 1463 UIMediumType type = medium.type(); 1451 /* Get corresponding tree-widget: */ 1452 QTreeWidget *pTreeWidget = treeWidget(type); 1453 1454 /* Prepare medium-item: */ 1464 1465 /* Create medium-item: */ 1455 1466 UIMediumItem *pMediumItem = 0; 1456 1467 switch (type) … … 1460 1471 { 1461 1472 pMediumItem = createHardDiskItem(mTwHD, medium); 1462 AssertPtrReturn Void(pMediumItem);1473 AssertPtrReturn(pMediumItem, 0); 1463 1474 if (pMediumItem->id() == m_strSelectedIdHD) 1464 1475 { … … 1473 1484 pMediumItem = new UIMediumItemCD(medium, mTwCD); 1474 1485 LogRel2(("UIMediumManager: Optical medium-item with ID={%s} created.\n", medium.id().toAscii().constData())); 1475 AssertPtrReturn Void(pMediumItem);1486 AssertPtrReturn(pMediumItem, 0); 1476 1487 if (pMediumItem->id() == m_strSelectedIdCD) 1477 1488 { … … 1486 1497 pMediumItem = new UIMediumItemFD(medium, mTwFD); 1487 1498 LogRel2(("UIMediumManager: Floppy medium-item with ID={%s} created.\n", medium.id().toAscii().constData())); 1488 AssertPtrReturn Void(pMediumItem);1499 AssertPtrReturn(pMediumItem, 0); 1489 1500 if (pMediumItem->id() == m_strSelectedIdFD) 1490 1501 { … … 1496 1507 default: AssertMsgFailed(("Medium-type unknown: %d\n", type)); break; 1497 1508 } 1498 AssertPtrReturn Void(pMediumItem);1509 AssertPtrReturn(pMediumItem, 0); 1499 1510 1500 1511 /* Update tab-icons: */ 1501 1512 updateTabIcons(pMediumItem, Action_Add); 1502 1503 /* If medium-enumeration is not currently in progress or1504 * if there is no current medium-item yet selected1505 * we have to choose newly added medium-item as current one: */1506 if ( !vboxGlobal().isMediumEnumerationInProgress()1507 || !pTreeWidget->currentItem())1508 setCurrentItem(pTreeWidget, pMediumItem);1509 1513 1510 1514 /* Re-fetch medium-item if it is current one created: */ 1511 1515 if (pMediumItem == mediumItem(type)) 1512 1516 refetchCurrentMediumItem(type); 1517 1518 /* Return created medium-item: */ 1519 return pMediumItem; 1513 1520 } 1514 1521 … … 1518 1525 UIMediumType type = medium.type(); 1519 1526 1520 /* Search for existing medium-item : */1527 /* Search for existing medium-item, create if was not found: */ 1521 1528 UIMediumItem *pMediumItem = searchItem(treeWidget(type), CheckIfSuitableByID(medium.id())); 1522 1523 /* Create medium-item (if it was not found): */ 1524 if (!pMediumItem) 1525 return createMediumItem(medium); 1529 if (!pMediumItem) pMediumItem = createMediumItem(medium); 1530 AssertPtrReturnVoid(pMediumItem); 1526 1531 1527 1532 /* Update medium-item: */ -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r50704 r50712 158 158 159 159 /** Creates UIMediumItem for corresponding @a medium. */ 160 voidcreateMediumItem(const UIMedium &medium);160 UIMediumItem* createMediumItem(const UIMedium &medium); 161 161 /** Updates UIMediumItem for corresponding @a medium. */ 162 162 void updateMediumItem(const UIMedium &medium); … … 212 212 QWidget *m_pCenterWidget; 213 213 bool m_fRefresh; 214 bool m_fPreventChangeCurrentItem; 214 215 215 216 /* Variables: Tab-widget stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.