Changeset 50967 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 3, 2014 3:17:29 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 93125
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r50966 r50967 1216 1216 } 1217 1217 1218 void UIMediumManager::prepareInformationContainer(UIMediumType , int)1218 void UIMediumManager::prepareInformationContainer(UIMediumType type, int iFields) 1219 1219 { 1220 1220 /* Information-panes created in .ui file. */ 1221 1221 { 1222 1222 /* Configure information-panes: */ 1223 QList<QILabel*> panes = findChildren<QILabel*>(); 1224 foreach (QILabel *pPane, panes) 1225 pPane->setFullSizeSelection(true); 1223 for (int i = 0; i < iFields; ++i) 1224 { 1225 QILabel *pField = infoField(type, i); 1226 if (pField) 1227 pField->setFullSizeSelection(true); 1228 } 1226 1229 } 1227 1230 } … … 1535 1538 { 1536 1539 /* Just clear information panes: */ 1537 if (m_pTypePane) 1538 m_pTypePane->clear(); 1539 if (m_pLocationPane) 1540 m_pLocationPane->clear(); 1541 if (m_pFormatPane) 1542 m_pFormatPane->clear(); 1543 if (m_pDetailsPane) 1544 m_pDetailsPane->clear(); 1545 if (m_pUsagePane) 1546 m_pUsagePane->clear(); 1540 for (int i = 0; i < 5; ++i) 1541 infoField(UIMediumType_HardDisk, i)->clear(); 1547 1542 } 1548 1543 /* If current item is set: */ … … 1554 1549 formatPaneText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not Attached</i>"), false) : 1555 1550 formatPaneText(pCurrentItem->usage()); 1556 if ( m_pTypePane)1557 m_pTypePane->setText(pCurrentItem->hardDiskType());1558 if ( m_pLocationPane)1559 m_pLocationPane->setText(formatPaneText(pCurrentItem->location(), true, "end"));1560 if ( m_pFormatPane)1561 m_pFormatPane->setText(pCurrentItem->hardDiskFormat());1562 if ( m_pDetailsPane)1563 m_pDetailsPane->setText(strDetails);1564 if ( m_pUsagePane)1565 m_pUsagePane->setText(strUsage);1551 if (infoField(UIMediumType_HardDisk, 0)) 1552 infoField(UIMediumType_HardDisk, 0)->setText(pCurrentItem->hardDiskType()); 1553 if (infoField(UIMediumType_HardDisk, 1)) 1554 infoField(UIMediumType_HardDisk, 1)->setText(formatPaneText(pCurrentItem->location(), true, "end")); 1555 if (infoField(UIMediumType_HardDisk, 2)) 1556 infoField(UIMediumType_HardDisk, 2)->setText(pCurrentItem->hardDiskFormat()); 1557 if (infoField(UIMediumType_HardDisk, 3)) 1558 infoField(UIMediumType_HardDisk, 3)->setText(strDetails); 1559 if (infoField(UIMediumType_HardDisk, 4)) 1560 infoField(UIMediumType_HardDisk, 4)->setText(strUsage); 1566 1561 } 1567 1562 1568 1563 /* Enable/disable information-panes container: */ 1569 if ( mHDContainer)1570 mHDContainer->setEnabled(pCurrentItem);1564 if (infoContainer(UIMediumType_HardDisk)) 1565 infoContainer(UIMediumType_HardDisk)->setEnabled(pCurrentItem); 1571 1566 } 1572 1567 … … 1580 1575 { 1581 1576 /* Just clear information panes: */ 1582 if (mIpCD1) 1583 mIpCD1->clear(); 1584 if (mIpCD2) 1585 mIpCD2->clear(); 1577 for (int i = 0; i < 2; ++i) 1578 infoField(UIMediumType_DVD, i)->clear(); 1586 1579 } 1587 1580 /* If current item is set: */ … … 1592 1585 formatPaneText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not Attached</i>"), false) : 1593 1586 formatPaneText(pCurrentItem->usage()); 1594 if ( mIpCD1)1595 mIpCD1->setText(formatPaneText(pCurrentItem->location(), true, "end"));1596 if ( mIpCD2)1597 mIpCD2->setText(strUsage);1587 if (infoField(UIMediumType_DVD, 0)) 1588 infoField(UIMediumType_DVD, 0)->setText(formatPaneText(pCurrentItem->location(), true, "end")); 1589 if (infoField(UIMediumType_DVD, 1)) 1590 infoField(UIMediumType_DVD, 1)->setText(strUsage); 1598 1591 } 1599 1592 1600 1593 /* Enable/disable information-panes container: */ 1601 if ( mCDContainer)1602 mCDContainer->setEnabled(pCurrentItem);1594 if (infoContainer(UIMediumType_DVD)) 1595 infoContainer(UIMediumType_DVD)->setEnabled(pCurrentItem); 1603 1596 } 1604 1597 … … 1612 1605 { 1613 1606 /* Just clear information panes: */ 1614 if (mIpFD1) 1615 mIpFD1->clear(); 1616 if (mIpFD2) 1617 mIpFD2->clear(); 1607 for (int i = 0; i < 2; ++i) 1608 infoField(UIMediumType_Floppy, i)->clear(); 1618 1609 } 1619 1610 /* If current item is set: */ … … 1624 1615 formatPaneText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not Attached</i>"), false) : 1625 1616 formatPaneText(pCurrentItem->usage()); 1626 if ( mIpFD1)1627 mIpFD1->setText(formatPaneText(pCurrentItem->location(), true, "end"));1628 if ( mIpFD2)1629 mIpFD2->setText(strUsage);1617 if (infoField(UIMediumType_Floppy, 0)) 1618 infoField(UIMediumType_Floppy, 0)->setText(formatPaneText(pCurrentItem->location(), true, "end")); 1619 if (infoField(UIMediumType_Floppy, 1)) 1620 infoField(UIMediumType_Floppy, 1)->setText(strUsage); 1630 1621 } 1631 1622 1632 1623 /* Enable/disable information-panes container: */ 1633 if ( mFDContainer)1634 mFDContainer->setEnabled(pCurrentItem);1624 if (infoContainer(UIMediumType_Floppy)) 1625 infoContainer(UIMediumType_Floppy)->setEnabled(pCurrentItem); 1635 1626 } 1636 1627 … … 1727 1718 1728 1719 /* Translate HD information-labels: */ 1729 if ( m_pTypeLabel)1730 m_pTypeLabel->setText(QApplication::translate("VBoxMediaManagerDlg", "Type:"));1731 if ( m_pLocationLabel)1732 m_pLocationLabel->setText(QApplication::translate("VBoxMediaManagerDlg", "Location:"));1733 if ( m_pFormatLabel)1734 m_pFormatLabel->setText(QApplication::translate("VBoxMediaManagerDlg", "Format:"));1735 if ( m_pDetailsLabel)1736 m_pDetailsLabel->setText(QApplication::translate("VBoxMediaManagerDlg", "Storage details:"));1737 if ( m_pUsageLabel)1738 m_pUsageLabel->setText(QApplication::translate("VBoxMediaManagerDlg", "Attached to:"));1720 if (infoLabel(UIMediumType_HardDisk, 0)) 1721 infoLabel(UIMediumType_HardDisk, 0)->setText(QApplication::translate("VBoxMediaManagerDlg", "Type:")); 1722 if (infoLabel(UIMediumType_HardDisk, 1)) 1723 infoLabel(UIMediumType_HardDisk, 1)->setText(QApplication::translate("VBoxMediaManagerDlg", "Location:")); 1724 if (infoLabel(UIMediumType_HardDisk, 2)) 1725 infoLabel(UIMediumType_HardDisk, 2)->setText(QApplication::translate("VBoxMediaManagerDlg", "Format:")); 1726 if (infoLabel(UIMediumType_HardDisk, 3)) 1727 infoLabel(UIMediumType_HardDisk, 3)->setText(QApplication::translate("VBoxMediaManagerDlg", "Storage details:")); 1728 if (infoLabel(UIMediumType_HardDisk, 4)) 1729 infoLabel(UIMediumType_HardDisk, 4)->setText(QApplication::translate("VBoxMediaManagerDlg", "Attached to:")); 1739 1730 1740 1731 /* Translate CD tree-widget: */ … … 1747 1738 1748 1739 /* Translate CD information-labels: */ 1749 if ( mLbCD1)1750 mLbCD1->setText(QApplication::translate("VBoxMediaManagerDlg", "Location:"));1751 if ( mLbCD2)1752 mLbCD2->setText(QApplication::translate("VBoxMediaManagerDlg", "Attached to:"));1740 if (infoLabel(UIMediumType_DVD, 0)) 1741 infoLabel(UIMediumType_DVD, 0)->setText(QApplication::translate("VBoxMediaManagerDlg", "Location:")); 1742 if (infoLabel(UIMediumType_DVD, 1)) 1743 infoLabel(UIMediumType_DVD, 1)->setText(QApplication::translate("VBoxMediaManagerDlg", "Attached to:")); 1753 1744 1754 1745 /* Translate FD tree-widget: */ … … 1761 1752 1762 1753 /* Translate FD information-labels: */ 1763 if ( mLbFD1)1764 mLbFD1->setText(QApplication::translate("VBoxMediaManagerDlg", "Location:"));1765 if ( mLbFD2)1766 mLbFD2->setText(QApplication::translate("VBoxMediaManagerDlg", "Attached to:"));1754 if (infoLabel(UIMediumType_Floppy, 0)) 1755 infoLabel(UIMediumType_Floppy, 0)->setText(QApplication::translate("VBoxMediaManagerDlg", "Location:")); 1756 if (infoLabel(UIMediumType_Floppy, 1)) 1757 infoLabel(UIMediumType_Floppy, 1)->setText(QApplication::translate("VBoxMediaManagerDlg", "Attached to:")); 1767 1758 1768 1759 /* Translate progress-bar: */ … … 2014 2005 } 2015 2006 2007 QFrame* UIMediumManager::infoContainer(UIMediumType type) const 2008 { 2009 /* Return corresponding tree-widget for known medium types: */ 2010 switch (type) 2011 { 2012 case UIMediumType_HardDisk: return mHDContainer; 2013 case UIMediumType_DVD: return mCDContainer; 2014 case UIMediumType_Floppy: return mFDContainer; 2015 default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break; 2016 } 2017 /* Null by default: */ 2018 return 0; 2019 } 2020 2021 QLabel* UIMediumManager::infoLabel(UIMediumType type, int iLabelIndex) const 2022 { 2023 /* Return corresponding tree-widget for known medium types: */ 2024 switch (type) 2025 { 2026 case UIMediumType_HardDisk: 2027 { 2028 switch (iLabelIndex) 2029 { 2030 case 0: return m_pTypeLabel; 2031 case 1: return m_pLocationLabel; 2032 case 2: return m_pFormatLabel; 2033 case 3: return m_pDetailsLabel; 2034 case 4: return m_pUsageLabel; 2035 default: AssertMsgFailed(("Label index out of bounds: %d\n", iLabelIndex)); break; 2036 } 2037 break; 2038 } 2039 case UIMediumType_DVD: 2040 { 2041 switch (iLabelIndex) 2042 { 2043 case 0: return mLbCD1; 2044 case 1: return mLbCD2; 2045 default: AssertMsgFailed(("Label index out of bounds: %d\n", iLabelIndex)); break; 2046 } 2047 break; 2048 } 2049 case UIMediumType_Floppy: 2050 { 2051 switch (iLabelIndex) 2052 { 2053 case 0: return mLbFD1; 2054 case 1: return mLbFD2; 2055 default: AssertMsgFailed(("Label index out of bounds: %d\n", iLabelIndex)); break; 2056 } 2057 break; 2058 } 2059 default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break; 2060 } 2061 /* Null by default: */ 2062 return 0; 2063 } 2064 2065 QILabel* UIMediumManager::infoField(UIMediumType type, int iFieldIndex) const 2066 { 2067 /* Return corresponding tree-widget for known medium types: */ 2068 switch (type) 2069 { 2070 case UIMediumType_HardDisk: 2071 { 2072 switch (iFieldIndex) 2073 { 2074 case 0: return m_pTypePane; 2075 case 1: return m_pLocationPane; 2076 case 2: return m_pFormatPane; 2077 case 3: return m_pDetailsPane; 2078 case 4: return m_pUsagePane; 2079 default: AssertMsgFailed(("Field index out of bounds: %d\n", iFieldIndex)); break; 2080 } 2081 break; 2082 } 2083 case UIMediumType_DVD: 2084 { 2085 switch (iFieldIndex) 2086 { 2087 case 0: return mIpCD1; 2088 case 1: return mIpCD2; 2089 default: AssertMsgFailed(("Field index out of bounds: %d\n", iFieldIndex)); break; 2090 } 2091 break; 2092 } 2093 case UIMediumType_Floppy: 2094 { 2095 switch (iFieldIndex) 2096 { 2097 case 0: return mIpFD1; 2098 case 1: return mIpFD2; 2099 default: AssertMsgFailed(("Field index out of bounds: %d\n", iFieldIndex)); break; 2100 } 2101 break; 2102 } 2103 default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break; 2104 } 2105 /* Null by default: */ 2106 return 0; 2107 } 2108 2016 2109 UIMediumType UIMediumManager::mediumType(QTreeWidget *pTreeWidget) const 2017 2110 { -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r50966 r50967 178 178 /** Returns item for passed medium @a type. */ 179 179 UIMediumItem* mediumItem(UIMediumType type) const; 180 /** Returns information-container for passed medium @a type. */ 181 QFrame* infoContainer(UIMediumType type) const; 182 /** Returns information-label for passed medium @a type and @a iLabelIndex. */ 183 QLabel* infoLabel(UIMediumType type, int iLabelIndex) const; 184 /** Returns information-field for passed medium @a type and @a iFieldIndex. */ 185 QILabel* infoField(UIMediumType type, int iFieldIndex) const; 180 186 181 187 /** Returns medium type for passed @a pTreeWidget. */
Note:
See TracChangeset
for help on using the changeset viewer.