Changeset 50368 in vbox
- Timestamp:
- Feb 7, 2014 3:58:41 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
r50363 r50368 326 326 repopulateTreeWidgets(); 327 327 328 /* Update current tab: */329 sltHandleCurrentTabChanged();328 /* Re-fetch all current medium-items: */ 329 refetchCurrentMediumItems(); 330 330 } 331 331 … … 359 359 m_pActionRefresh->setEnabled(true); 360 360 361 /* Update current tab: */362 sltHandleCurrentTabChanged();361 /* Re-fetch all current medium-items: */ 362 refetchCurrentMediumItems(); 363 363 } 364 364 … … 515 515 { 516 516 /* This may happen if medium was already released by a third party, 517 * update the details and silently return. */ 518 sltHandleCurrentItemChanged(pMediumItem); 519 return; 517 * re-fetch currently chosen medium-item and silently return. */ 518 return refetchCurrentChosenMediumItem(); 520 519 } 521 520 … … 551 550 pTree->setFocus(); 552 551 553 /* Make sure current medium-item is selected: */ 554 sltHandleCurrentItemChanged(pTree->currentItem()); 555 } 556 557 void UIMediumManager::sltHandleCurrentItemChanged(QTreeWidgetItem *pItem) 558 { 559 /* If item set => make sure it's of valid type: */ 560 UIMediumItem *pMediumItem = toMediumItem(pItem); 561 AssertReturnVoid(!pItem || pMediumItem); 562 563 /* If medium-item set: */ 564 if (pMediumItem) 565 { 566 /* Set the file for the proxy icon: */ 567 setFileForProxyIcon(pMediumItem->location()); 568 /* Make sure current medium-item visible: */ 569 pMediumItem->treeWidget()->scrollToItem(pMediumItem, QAbstractItemView::EnsureVisible); 570 } 571 572 /* Update actions: */ 573 updateActions(); 574 575 /* Update current information-panes: */ 576 updateInformationPanes(currentMediumType()); 552 /* Re-fetch currently chosen medium-item: */ 553 refetchCurrentChosenMediumItem(); 554 } 555 556 void UIMediumManager::sltHandleCurrentItemChanged() 557 { 558 /* Determine tree-widget sender: */ 559 QTreeWidget *pTreeWidget = qobject_cast<QTreeWidget*>(sender()); 560 AssertMsgReturnVoid(pTreeWidget, ("This slot should be called by tree-widget only!\n")); 561 562 /* Re-fetch current medium-item of required type: */ 563 refetchCurrentMediumItem(mediumType(pTreeWidget)); 577 564 } 578 565 … … 866 853 prepareTreeWidgetFD(); 867 854 868 /* Focus current tree : */855 /* Focus current tree-widget: */ 869 856 currentTreeWidget()->setFocus(); 870 857 } … … 883 870 mTwHD->setSortingEnabled(true); 884 871 connect(mTwHD, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 885 this, SLOT(sltHandleCurrentItemChanged( QTreeWidgetItem*)));872 this, SLOT(sltHandleCurrentItemChanged())); 886 873 connect(mTwHD, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 887 874 this, SLOT(sltHandleDoubleClick())); … … 907 894 mTwCD->setSortingEnabled(true); 908 895 connect(mTwCD, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 909 this, SLOT(sltHandleCurrentItemChanged( QTreeWidgetItem*)));896 this, SLOT(sltHandleCurrentItemChanged())); 910 897 connect(mTwCD, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 911 898 this, SLOT(sltHandleDoubleClick())); … … 931 918 mTwFD->setSortingEnabled(true); 932 919 connect(mTwFD, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 933 this, SLOT(sltHandleCurrentItemChanged( QTreeWidgetItem*)));920 this, SLOT(sltHandleCurrentItemChanged())); 934 921 connect(mTwFD, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 935 922 this, SLOT(sltHandleDoubleClick())); … … 1020 1007 if (QTreeWidgetItem *pItem = pTreeWidgetFD->topLevelItem(0)) 1021 1008 setCurrentItem(pTreeWidgetFD, pItem); 1009 } 1010 1011 void UIMediumManager::refetchCurrentMediumItem(UIMediumType type) 1012 { 1013 /* Get corresponding medium-item: */ 1014 UIMediumItem *pMediumItem = mediumItem(type); 1015 1016 /* If medium-item set: */ 1017 if (pMediumItem) 1018 { 1019 /* Set the file for the proxy icon: */ 1020 setFileForProxyIcon(pMediumItem->location()); 1021 /* Make sure current medium-item visible: */ 1022 treeWidget(type)->scrollToItem(pMediumItem, QAbstractItemView::EnsureVisible); 1023 } 1024 1025 /* Update actions: */ 1026 updateActions(); 1027 1028 /* Update corresponding information-panes: */ 1029 updateInformationPanes(type); 1030 } 1031 1032 void UIMediumManager::refetchCurrentChosenMediumItem() 1033 { 1034 refetchCurrentMediumItem(currentMediumType()); 1035 } 1036 1037 void UIMediumManager::refetchCurrentMediumItems() 1038 { 1039 refetchCurrentMediumItem(UIMediumType_HardDisk); 1040 refetchCurrentMediumItem(UIMediumType_DVD); 1041 refetchCurrentMediumItem(UIMediumType_Floppy); 1022 1042 } 1023 1043 … … 1388 1408 1389 1409 /* If medium-enumeration is not currently in progress or 1390 * if there is no 'current'medium-item yet selected1391 * we have to choose newly added medium-item as 'current'one: */1410 * if there is no current medium-item yet selected 1411 * we have to choose newly added medium-item as current one: */ 1392 1412 if ( !vboxGlobal().isMediumEnumerationInProgress() 1393 1413 || !pTreeWidget->currentItem()) 1394 1414 setCurrentItem(pTreeWidget, pMediumItem); 1395 1415 1396 /* Update linked stuff if that was current medium-itemcreated: */1397 if (pMediumItem == currentMediumItem())1398 sltHandleCurrentItemChanged(pMediumItem);1416 /* Re-fetch medium-item if it is current one created: */ 1417 if (pMediumItem == mediumItem(type)) 1418 refetchCurrentMediumItem(type); 1399 1419 } 1400 1420 1401 1421 void UIMediumManager::updateMediumItem(const UIMedium &medium) 1402 1422 { 1423 /* Get medium type: */ 1424 UIMediumType type = medium.type(); 1425 1403 1426 /* Search for existing medium-item: */ 1404 UIMediumItem *pMediumItem = searchItem(treeWidget( medium.type()), CheckIfSuitableByID(medium.id()));1427 UIMediumItem *pMediumItem = searchItem(treeWidget(type), CheckIfSuitableByID(medium.id())); 1405 1428 1406 1429 /* Create medium-item (if it was not found): */ … … 1415 1438 updateTabIcons(pMediumItem, ItemAction_Updated); 1416 1439 1417 /* Update linked stuff if that was current medium-itemupdated: */1418 if (pMediumItem == currentMediumItem())1419 sltHandleCurrentItemChanged(pMediumItem);1440 /* Re-fetch medium-item if it is current one updated: */ 1441 if (pMediumItem == mediumItem(type)) 1442 refetchCurrentMediumItem(type); 1420 1443 } 1421 1444 … … 1448 1471 LogRel2(("UIMediumManager: Medium-item with ID={%s} deleted.\n", strMediumID.toAscii().constData())); 1449 1472 1450 /* If there is no 'current'medium-item now selected1451 * we have to choose first-available medium-item as 'current'one: */1473 /* If there is no current medium-item now selected 1474 * we have to choose first-available medium-item as current one: */ 1452 1475 if (!pTreeWidget->currentItem()) 1453 1476 setCurrentItem(pTreeWidget, pTreeWidget->topLevelItem(0)); … … 1596 1619 } 1597 1620 1621 UIMediumType UIMediumManager::mediumType(QTreeWidget *pTreeWidget) const 1622 { 1623 /* Hard-drive tree-widget: */ 1624 if (pTreeWidget == mTwHD) return UIMediumType_HardDisk; 1625 /* Optical-image tree-widget: */ 1626 if (pTreeWidget == mTwCD) return UIMediumType_DVD; 1627 /* Floppy-image tree-widget: */ 1628 if (pTreeWidget == mTwFD) return UIMediumType_Floppy; 1629 /* Invalid by default: */ 1630 AssertFailedReturn(UIMediumType_Invalid); 1631 } 1632 1598 1633 UIMediumType UIMediumManager::currentMediumType() const 1599 1634 { … … 1649 1684 AssertPtrReturnVoid(pTreeWidget); 1650 1685 1651 /* Make passed item 'current'for passed tree-widget: */1686 /* Make passed item current for passed tree-widget: */ 1652 1687 pTreeWidget->setCurrentItem(pItem); 1653 1688 … … 1660 1695 } 1661 1696 1662 /* Update linked stuff: */1663 sltHandleCurrentItemChanged(pItem);1697 /* Re-fetch currently chosen medium-item: */ 1698 refetchCurrentChosenMediumItem(); 1664 1699 } 1665 1700 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r50363 r50368 87 87 /* Handlers: Navigation stuff: */ 88 88 void sltHandleCurrentTabChanged(); 89 void sltHandleCurrentItemChanged( QTreeWidgetItem *pItem);89 void sltHandleCurrentItemChanged(); 90 90 void sltHandleDoubleClick(); 91 91 void sltHandleContextMenuCall(const QPoint &position); … … 119 119 void repopulateTreeWidgets(); 120 120 121 /** Updates details according latest changes in current medium-item of predefined @a type. */ 122 void refetchCurrentMediumItem(UIMediumType type); 123 /** Updates details according latest changes in current medium-item of chosen type. */ 124 void refetchCurrentChosenMediumItem(); 125 /** Updates details according latest changes in all current medium-items. */ 126 void refetchCurrentMediumItems(); 127 121 128 /** Update actions according currently chosen medium-item. */ 122 129 void updateActions(); … … 154 161 bool releaseFloppyDiskFrom(const UIMedium &medium, CMachine &machine); 155 162 163 /** Determines medium type for passed @a pTreeWidget. */ 164 UIMediumType mediumType(QTreeWidget *pTreeWidget) const; 165 156 166 /** Returns current medium type. */ 157 167 UIMediumType currentMediumType() const;
Note:
See TracChangeset
for help on using the changeset viewer.