Changeset 50966 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 3, 2014 2:54:55 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 93124
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r50964 r50966 749 749 if (mTabWidget) 750 750 { 751 mTabWidget->setTabIcon( TabIndex_HD, m_iconHD);752 mTabWidget->setTabIcon( TabIndex_CD, m_iconCD);753 mTabWidget->setTabIcon( TabIndex_FD, m_iconFD);751 mTabWidget->setTabIcon(tabIndex(UIMediumType_HardDisk), m_iconHD); 752 mTabWidget->setTabIcon(tabIndex(UIMediumType_DVD), m_iconCD); 753 mTabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD); 754 754 } 755 755 … … 1161 1161 /* Configure tab-widget: */ 1162 1162 mTabWidget->setFocusPolicy(Qt::TabFocus); 1163 mTabWidget->setTabIcon( TabIndex_HD, m_iconHD);1164 mTabWidget->setTabIcon( TabIndex_CD, m_iconCD);1165 mTabWidget->setTabIcon( TabIndex_FD, m_iconFD);1163 mTabWidget->setTabIcon(tabIndex(UIMediumType_HardDisk), m_iconHD); 1164 mTabWidget->setTabIcon(tabIndex(UIMediumType_DVD), m_iconCD); 1165 mTabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD); 1166 1166 connect(mTabWidget, SIGNAL(currentChanged(int)), this, SLOT(sltHandleCurrentTabChanged())); 1167 1167 /* Focus current tree-widget: */ … … 1425 1425 1426 1426 /* Prepare data for tab: */ 1427 int iTab = -1;1428 1427 const QIcon *pIcon = 0; 1429 1428 bool *pfInaccessible = 0; 1430 switch (pMediumItem->mediumType()) 1429 const UIMediumType mediumType = pMediumItem->mediumType(); 1430 switch (mediumType) 1431 1431 { 1432 1432 case UIMediumType_HardDisk: 1433 iTab = TabIndex_HD;1434 1433 pIcon = &m_iconHD; 1435 1434 pfInaccessible = &m_fInaccessibleHD; 1436 1435 break; 1437 1436 case UIMediumType_DVD: 1438 iTab = TabIndex_CD;1439 1437 pIcon = &m_iconCD; 1440 1438 pfInaccessible = &m_fInaccessibleCD; 1441 1439 break; 1442 1440 case UIMediumType_Floppy: 1443 iTab = TabIndex_FD;1444 1441 pIcon = &m_iconFD; 1445 1442 pfInaccessible = &m_fInaccessibleFD; … … 1448 1445 AssertFailed(); 1449 1446 } 1450 AssertReturnVoid( iTab != -1 &&pIcon && pfInaccessible);1447 AssertReturnVoid(pIcon && pfInaccessible); 1451 1448 1452 1449 switch (action) … … 1461 1458 1462 1459 if (mTabWidget) 1463 mTabWidget->setTabIcon( iTab, vboxGlobal().warningIcon());1460 mTabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon()); 1464 1461 1465 1462 break; … … 1498 1495 { 1499 1496 if (*pfInaccessible) 1500 mTabWidget->setTabIcon( iTab, vboxGlobal().warningIcon());1497 mTabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon()); 1501 1498 else 1502 mTabWidget->setTabIcon( iTab, *pIcon);1499 mTabWidget->setTabIcon(tabIndex(mediumType), *pIcon); 1503 1500 } 1504 1501 … … 1715 1712 if (mTabWidget) 1716 1713 { 1717 mTabWidget->setTabText( TabIndex_HD, tr("&Hard drives"));1718 mTabWidget->setTabText( TabIndex_CD, tr("&Optical disks"));1719 mTabWidget->setTabText( TabIndex_FD, tr("&Floppy disks"));1714 mTabWidget->setTabText(tabIndex(UIMediumType_HardDisk), tr("&Hard drives")); 1715 mTabWidget->setTabText(tabIndex(UIMediumType_DVD), tr("&Optical disks")); 1716 mTabWidget->setTabText(tabIndex(UIMediumType_Floppy), tr("&Floppy disks")); 1720 1717 } 1721 1718 … … 2036 2033 2037 2034 /* Return current medium type: */ 2038 switch (mTabWidget->currentIndex()) 2039 { 2040 case TabIndex_HD: return UIMediumType_HardDisk; 2041 case TabIndex_CD: return UIMediumType_DVD; 2042 case TabIndex_FD: return UIMediumType_Floppy; 2043 default: AssertMsgFailed(("Unknown page type: %d\n", mTabWidget->currentIndex())); break; 2044 } 2045 /* Invalid by default: */ 2046 return UIMediumType_Invalid; 2035 return mediumType(mTabWidget->currentIndex()); 2047 2036 } 2048 2037 … … 2077 2066 /* Re-fetch currently chosen medium-item: */ 2078 2067 refetchCurrentChosenMediumItem(); 2068 } 2069 2070 /* static */ 2071 int UIMediumManager::tabIndex(UIMediumType type) 2072 { 2073 /* Return tab index corresponding to known medium type: */ 2074 switch (type) 2075 { 2076 case UIMediumType_HardDisk: return 0; 2077 case UIMediumType_DVD: return 1; 2078 case UIMediumType_Floppy: return 2; 2079 default: break; 2080 } 2081 2082 /* -1 by default: */ 2083 return -1; 2084 } 2085 2086 /* static */ 2087 UIMediumType UIMediumManager::mediumType(int iIndex) 2088 { 2089 /* Return medium type corresponding to known tab index: */ 2090 switch (iIndex) 2091 { 2092 case 0: return UIMediumType_HardDisk; 2093 case 1: return UIMediumType_DVD; 2094 case 2: return UIMediumType_Floppy; 2095 default: break; 2096 } 2097 2098 /* Invalid by default: */ 2099 return UIMediumType_Invalid; 2079 2100 } 2080 2101 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r50960 r50966 42 42 { 43 43 Q_OBJECT; 44 45 /** Tab index enumerator. */46 enum TabIndex { TabIndex_HD = 0, TabIndex_CD, TabIndex_FD };47 44 48 45 /** Item action enumerator. */ … … 195 192 void setCurrentItem(QTreeWidget *pTreeWidget, QTreeWidgetItem *pItem); 196 193 194 /** Returns tab index for passed UIMediumType. */ 195 static int tabIndex(UIMediumType type); 196 /** Returns UIMediumType for passed tab index. */ 197 static UIMediumType mediumType(int iIndex); 198 197 199 /** Performs search for the @a pTree child which corresponds to the @a condition but not @a pException. */ 198 200 static UIMediumItem* searchItem(QTreeWidget *pTree, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException = 0);
Note:
See TracChangeset
for help on using the changeset viewer.