Changeset 50968 in vbox
- Timestamp:
- Apr 3, 2014 3:53:37 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro
r48622 r50968 26 26 src/VBoxTakeSnapshotDlg.ui \ 27 27 src/UIVMLogViewer.ui \ 28 src/medium/UIMediumManager.ui \29 28 src/settings/UISettingsDialog.ui \ 30 29 src/settings/global/UIGlobalSettingsGeneral.ui \ -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r50967 r50968 21 21 22 22 /* Qt includes: */ 23 #include <QFrame> 23 24 #include <QLabel> 24 25 #include <QMenuBar> … … 32 33 #include "UIWizardCloneVD.h" 33 34 #include "UIMessageCenter.h" 35 #include "QITabWidget.h" 36 #include "QITreeWidget.h" 37 #include "QILabel.h" 38 #include "QIDialogButtonBox.h" 34 39 #include "UIToolBar.h" 35 40 #include "UIIconPool.h" … … 650 655 , m_fRefresh(fRefresh) 651 656 , m_fPreventChangeCurrentItem(false) 657 , m_pTabWidget(0) 658 , m_iTabCount(3) 652 659 , m_fInaccessibleHD(false) 653 660 , m_fInaccessibleCD(false) … … 662 669 , m_pActionRemove(0), m_pActionRelease(0) 663 670 , m_pActionRefresh(0) 671 , m_pButtonBox(0) 664 672 , m_pProgressBar(0) 665 673 { … … 747 755 748 756 /* Reset tab-widget icons: */ 749 if (m TabWidget)750 { 751 m TabWidget->setTabIcon(tabIndex(UIMediumType_HardDisk), m_iconHD);752 m TabWidget->setTabIcon(tabIndex(UIMediumType_DVD), m_iconCD);753 m TabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD);757 if (m_pTabWidget) 758 { 759 m_pTabWidget->setTabIcon(tabIndex(UIMediumType_HardDisk), m_iconHD); 760 m_pTabWidget->setTabIcon(tabIndex(UIMediumType_DVD), m_iconCD); 761 m_pTabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD); 754 762 } 755 763 … … 820 828 /* Update HD information-panes: */ 821 829 if (fResult) 822 updateInformation PanesHD();830 updateInformationFieldsHD(); 823 831 } 824 832 … … 916 924 { 917 925 /* Get all the tree-widgets: */ 918 QList<QTreeWidget*> trees; 919 trees << treeWidget(UIMediumType_HardDisk); 920 trees << treeWidget(UIMediumType_DVD); 921 trees << treeWidget(UIMediumType_Floppy); 926 const QList<QTreeWidget*> trees = m_trees.values(); 922 927 923 928 /* Calculate deduction for every header: */ … … 959 964 960 965 /* Initialize information-panes: */ 961 updateInformation Panes(UIMediumType_All);966 updateInformationFields(UIMediumType_All); 962 967 963 968 /* Start medium-enumeration (if necessary): */ … … 978 983 void UIMediumManager::prepareThis() 979 984 { 985 /* Initial size: */ 986 resize(620, 460); 987 980 988 /* Dialog should delete itself on 'close': */ 981 989 setAttribute(Qt::WA_DeleteOnClose); … … 988 996 setWindowIcon(UIIconPool::iconSetFull(QSize(32, 32), QSize(16, 16), 989 997 ":/diskimage_32px.png", ":/diskimage_16px.png")); 990 991 /* Apply UI decorations: */992 Ui::UIMediumManager::setupUi(this);993 998 994 999 /* Prepare connections: */ … … 1104 1109 void UIMediumManager::prepareCentralWidget() 1105 1110 { 1106 /* Prepare tool-bar: */ 1107 prepareToolBar(); 1108 /* Prepare tab-widget: */ 1109 prepareTabWidget(); 1110 /* Prepare button-box: */ 1111 prepareButtonBox(); 1111 /* Create central-widget: */ 1112 setCentralWidget(new QWidget); 1113 AssertPtrReturnVoid(centralWidget()); 1114 { 1115 /* Create main-layout: */ 1116 new QVBoxLayout(centralWidget()); 1117 AssertPtrReturnVoid(centralWidget()->layout()); 1118 { 1119 /* Prepare tool-bar: */ 1120 prepareToolBar(); 1121 /* Prepare tab-widget: */ 1122 prepareTabWidget(); 1123 /* Prepare button-box: */ 1124 prepareButtonBox(); 1125 } 1126 } 1112 1127 } 1113 1128 … … 1154 1169 void UIMediumManager::prepareTabWidget() 1155 1170 { 1156 /* Tab-widget created in .ui file. */ 1157 { 1158 /* Prepare tabs: */ 1159 for (int i = (int)UIMediumType_HardDisk; i <= (int)UIMediumType_Floppy; ++i) 1160 prepareTab((UIMediumType)i); 1171 /* Create tab-widget: */ 1172 m_pTabWidget = new QITabWidget; 1173 AssertPtrReturnVoid(m_pTabWidget); 1174 { 1175 /* Create tabs: */ 1176 for (int i = 0; i < m_iTabCount; ++i) 1177 prepareTab(mediumType(i)); 1161 1178 /* Configure tab-widget: */ 1162 mTabWidget->setFocusPolicy(Qt::TabFocus); 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 connect(mTabWidget, SIGNAL(currentChanged(int)), this, SLOT(sltHandleCurrentTabChanged())); 1179 m_pTabWidget->setFocusPolicy(Qt::TabFocus); 1180 m_pTabWidget->setTabIcon(tabIndex(UIMediumType_HardDisk), m_iconHD); 1181 m_pTabWidget->setTabIcon(tabIndex(UIMediumType_DVD), m_iconCD); 1182 m_pTabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD); 1183 connect(m_pTabWidget, SIGNAL(currentChanged(int)), this, SLOT(sltHandleCurrentTabChanged())); 1184 /* Add tab-widget into central layout: */ 1185 centralWidget()->layout()->addWidget(m_pTabWidget); 1167 1186 /* Focus current tree-widget: */ 1168 1187 if (currentTreeWidget()) … … 1175 1194 void UIMediumManager::prepareTab(UIMediumType type) 1176 1195 { 1177 /* Tab created in .ui file. */ 1178 { 1179 /* Tab layout created in .ui file. */ 1196 /* Create tab: */ 1197 m_pTabWidget->addTab(new QWidget, QString()); 1198 QWidget *pTab = tab(type); 1199 AssertPtrReturnVoid(pTab); 1200 { 1201 /* Create tab layout: */ 1202 new QVBoxLayout(pTab); 1203 AssertPtrReturnVoid(pTab->layout()); 1180 1204 { 1181 1205 /* Prepare tree-widget: */ … … 1189 1213 void UIMediumManager::prepareTreeWidget(UIMediumType type, int iColumns) 1190 1214 { 1191 /* Tree-widget created in .ui file. */ 1215 /* Create tree-widget: */ 1216 m_trees.insert(tabIndex(type), new QITreeWidget); 1217 QTreeWidget *pTreeWidget = treeWidget(type); 1218 AssertPtrReturnVoid(pTreeWidget); 1192 1219 { 1193 1220 /* Configure tree-widget: */ 1194 QTreeWidget *pTreeWidget = treeWidget(type); 1221 pTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 1222 pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); 1223 pTreeWidget->setAlternatingRowColors(true); 1224 pTreeWidget->setAllColumnsShowFocus(true); 1225 pTreeWidget->setAcceptDrops(true); 1195 1226 pTreeWidget->setColumnCount(iColumns); 1196 1227 pTreeWidget->sortItems(0, Qt::AscendingOrder); … … 1213 1244 connect(pTreeWidget->header(), SIGNAL(sectionResized(int, int, int)), 1214 1245 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1246 /* Add tree-widget into tab layout: */ 1247 tab(type)->layout()->addWidget(pTreeWidget); 1215 1248 } 1216 1249 } … … 1218 1251 void UIMediumManager::prepareInformationContainer(UIMediumType type, int iFields) 1219 1252 { 1220 /* Information-panes created in .ui file. */ 1221 { 1222 /* Configure information-panes: */ 1223 for (int i = 0; i < iFields; ++i) 1224 { 1225 QILabel *pField = infoField(type, i); 1226 if (pField) 1227 pField->setFullSizeSelection(true); 1228 } 1253 /* Create information-container: */ 1254 int iIndex = tabIndex(type); 1255 m_containers.insert(iIndex, new QFrame); 1256 QFrame *pInformationContainer = infoContainer(type); 1257 AssertPtrReturnVoid(pInformationContainer); 1258 { 1259 /* Configure information-container: */ 1260 pInformationContainer->setFrameShape(QFrame::Box); 1261 pInformationContainer->setFrameShadow(QFrame::Sunken); 1262 /* Create information-container layout: */ 1263 new QGridLayout(pInformationContainer); 1264 QGridLayout *pInformationContainerLayout = qobject_cast<QGridLayout*>(pInformationContainer->layout()); 1265 AssertPtrReturnVoid(pInformationContainerLayout); 1266 { 1267 /* Configure information-container layout: */ 1268 pInformationContainerLayout->setVerticalSpacing(0); 1269 pInformationContainerLayout->setContentsMargins(5, 5, 5, 5); 1270 pInformationContainerLayout->setColumnStretch(1, 1); 1271 /* Create information-container labels & fields: */ 1272 for (int i = 0; i < iFields; ++i) 1273 { 1274 /* Create information-label: */ 1275 m_labels[iIndex] << new QLabel; 1276 QLabel *pLabel = infoLabel(type, i); 1277 AssertPtrReturnVoid(pLabel); 1278 /* Create information-field: */ 1279 m_fields[iIndex] << new QILabel; 1280 QILabel *pField = infoField(type, i); 1281 AssertPtrReturnVoid(pField); 1282 { 1283 /* Configure information-field: */ 1284 pField->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed)); 1285 pField->setFullSizeSelection(true); 1286 } 1287 /* Add information-container labels & fields into container layout: */ 1288 pInformationContainerLayout->addWidget(pLabel, i, 0); 1289 pInformationContainerLayout->addWidget(pField, i, 1); 1290 } 1291 } 1292 /* Add information-container into tab layout: */ 1293 tab(type)->layout()->addWidget(pInformationContainer); 1229 1294 } 1230 1295 } … … 1232 1297 void UIMediumManager::prepareButtonBox() 1233 1298 { 1234 /* Button-box created in .ui file. */ 1299 /* Create button-box: */ 1300 m_pButtonBox = new QIDialogButtonBox; 1301 AssertPtrReturnVoid(m_pButtonBox); 1235 1302 { 1236 1303 /* Configure button-box: */ 1237 mButtonBox->button(QDialogButtonBox::Ok)->setDefault(true); 1238 connect(mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); 1239 connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept())); 1304 m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Close); 1305 m_pButtonBox->button(QDialogButtonBox::Close)->setDefault(true); 1306 connect(m_pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); 1307 connect(m_pButtonBox, SIGNAL(rejected()), this, SLOT(close())); 1308 /* Add button-box into central layout: */ 1309 centralWidget()->layout()->addWidget(m_pButtonBox); 1240 1310 /* Prepare progress-bar: */ 1241 1311 prepareProgressBar(); … … 1252 1322 m_pProgressBar->hide(); 1253 1323 /* Add progress-bar into button-box layout: */ 1254 m ButtonBox->addExtraWidget(m_pProgressBar);1324 m_pButtonBox->addExtraWidget(m_pProgressBar); 1255 1325 } 1256 1326 } … … 1331 1401 1332 1402 /* Update corresponding information-panes: */ 1333 updateInformation Panes(type);1403 updateInformationFields(type); 1334 1404 } 1335 1405 … … 1382 1452 { 1383 1453 QString strPrefix = "hd"; 1384 if (m TabWidget)1454 if (m_pTabWidget) 1385 1455 { 1386 1456 switch (currentMediumType()) … … 1460 1530 *pfInaccessible = true; 1461 1531 1462 if (m TabWidget)1463 m TabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon());1532 if (m_pTabWidget) 1533 m_pTabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon()); 1464 1534 1465 1535 break; … … 1495 1565 } 1496 1566 1497 if (m TabWidget)1567 if (m_pTabWidget) 1498 1568 { 1499 1569 if (*pfInaccessible) 1500 m TabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon());1570 m_pTabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon()); 1501 1571 else 1502 m TabWidget->setTabIcon(tabIndex(mediumType), *pIcon);1572 m_pTabWidget->setTabIcon(tabIndex(mediumType), *pIcon); 1503 1573 } 1504 1574 … … 1508 1578 } 1509 1579 1510 void UIMediumManager::updateInformation Panes(UIMediumType type /* = UIMediumType_Invalid */)1580 void UIMediumManager::updateInformationFields(UIMediumType type /* = UIMediumType_Invalid */) 1511 1581 { 1512 1582 /* Make sure type is valid: */ … … 1517 1587 switch (type) 1518 1588 { 1519 case UIMediumType_HardDisk: updateInformation PanesHD(); break;1520 case UIMediumType_DVD: updateInformation PanesCD(); break;1521 case UIMediumType_Floppy: updateInformation PanesFD(); break;1589 case UIMediumType_HardDisk: updateInformationFieldsHD(); break; 1590 case UIMediumType_DVD: updateInformationFieldsCD(); break; 1591 case UIMediumType_Floppy: updateInformationFieldsFD(); break; 1522 1592 case UIMediumType_All: 1523 updateInformation PanesHD();1524 updateInformation PanesCD();1525 updateInformation PanesFD();1593 updateInformationFieldsHD(); 1594 updateInformationFieldsCD(); 1595 updateInformationFieldsFD(); 1526 1596 break; 1527 1597 default: break; … … 1529 1599 } 1530 1600 1531 void UIMediumManager::updateInformation PanesHD()1601 void UIMediumManager::updateInformationFieldsHD() 1532 1602 { 1533 1603 /* Get current hard-drive medium-item: */ … … 1538 1608 { 1539 1609 /* Just clear information panes: */ 1540 for (int i = 0; i < 5; ++i)1610 for (int i = 0; i < m_fields[tabIndex(UIMediumType_HardDisk)].size(); ++i) 1541 1611 infoField(UIMediumType_HardDisk, i)->clear(); 1542 1612 } … … 1547 1617 QString strDetails = pCurrentItem->details(); 1548 1618 QString strUsage = pCurrentItem->usage().isNull() ? 1549 format PaneText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not Attached</i>"), false) :1550 format PaneText(pCurrentItem->usage());1619 formatFieldText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not Attached</i>"), false) : 1620 formatFieldText(pCurrentItem->usage()); 1551 1621 if (infoField(UIMediumType_HardDisk, 0)) 1552 1622 infoField(UIMediumType_HardDisk, 0)->setText(pCurrentItem->hardDiskType()); 1553 1623 if (infoField(UIMediumType_HardDisk, 1)) 1554 infoField(UIMediumType_HardDisk, 1)->setText(format PaneText(pCurrentItem->location(), true, "end"));1624 infoField(UIMediumType_HardDisk, 1)->setText(formatFieldText(pCurrentItem->location(), true, "end")); 1555 1625 if (infoField(UIMediumType_HardDisk, 2)) 1556 1626 infoField(UIMediumType_HardDisk, 2)->setText(pCurrentItem->hardDiskFormat()); … … 1566 1636 } 1567 1637 1568 void UIMediumManager::updateInformation PanesCD()1638 void UIMediumManager::updateInformationFieldsCD() 1569 1639 { 1570 1640 /* Get current optical medium-item: */ … … 1575 1645 { 1576 1646 /* Just clear information panes: */ 1577 for (int i = 0; i < 2; ++i)1647 for (int i = 0; i < m_fields[tabIndex(UIMediumType_DVD)].size(); ++i) 1578 1648 infoField(UIMediumType_DVD, i)->clear(); 1579 1649 } … … 1583 1653 /* Update required details: */ 1584 1654 QString strUsage = pCurrentItem->usage().isNull() ? 1585 format PaneText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not Attached</i>"), false) :1586 format PaneText(pCurrentItem->usage());1655 formatFieldText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not Attached</i>"), false) : 1656 formatFieldText(pCurrentItem->usage()); 1587 1657 if (infoField(UIMediumType_DVD, 0)) 1588 infoField(UIMediumType_DVD, 0)->setText(format PaneText(pCurrentItem->location(), true, "end"));1658 infoField(UIMediumType_DVD, 0)->setText(formatFieldText(pCurrentItem->location(), true, "end")); 1589 1659 if (infoField(UIMediumType_DVD, 1)) 1590 1660 infoField(UIMediumType_DVD, 1)->setText(strUsage); … … 1596 1666 } 1597 1667 1598 void UIMediumManager::updateInformation PanesFD()1668 void UIMediumManager::updateInformationFieldsFD() 1599 1669 { 1600 1670 /* Get current floppy medium-item: */ … … 1605 1675 { 1606 1676 /* Just clear information panes: */ 1607 for (int i = 0; i < 2; ++i)1677 for (int i = 0; i < m_fields[tabIndex(UIMediumType_Floppy)].size(); ++i) 1608 1678 infoField(UIMediumType_Floppy, i)->clear(); 1609 1679 } … … 1613 1683 /* Update required details: */ 1614 1684 QString strUsage = pCurrentItem->usage().isNull() ? 1615 format PaneText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not Attached</i>"), false) :1616 format PaneText(pCurrentItem->usage());1685 formatFieldText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not Attached</i>"), false) : 1686 formatFieldText(pCurrentItem->usage()); 1617 1687 if (infoField(UIMediumType_Floppy, 0)) 1618 infoField(UIMediumType_Floppy, 0)->setText(format PaneText(pCurrentItem->location(), true, "end"));1688 infoField(UIMediumType_Floppy, 0)->setText(formatFieldText(pCurrentItem->location(), true, "end")); 1619 1689 if (infoField(UIMediumType_Floppy, 1)) 1620 1690 infoField(UIMediumType_Floppy, 1)->setText(strUsage); … … 1701 1771 1702 1772 /* Translate tab-widget: */ 1703 if (m TabWidget)1704 { 1705 m TabWidget->setTabText(tabIndex(UIMediumType_HardDisk), tr("&Hard drives"));1706 m TabWidget->setTabText(tabIndex(UIMediumType_DVD), tr("&Optical disks"));1707 m TabWidget->setTabText(tabIndex(UIMediumType_Floppy), tr("&Floppy disks"));1773 if (m_pTabWidget) 1774 { 1775 m_pTabWidget->setTabText(tabIndex(UIMediumType_HardDisk), tr("&Hard drives")); 1776 m_pTabWidget->setTabText(tabIndex(UIMediumType_DVD), tr("&Optical disks")); 1777 m_pTabWidget->setTabText(tabIndex(UIMediumType_Floppy), tr("&Floppy disks")); 1708 1778 } 1709 1779 … … 1766 1836 m_pProgressBar->adjustSize(); 1767 1837 int h = m_pProgressBar->height(); 1768 if (m ButtonBox)1769 m ButtonBox->setMinimumHeight(h + 12);1838 if (m_pButtonBox) 1839 m_pButtonBox->setMinimumHeight(h + 12); 1770 1840 #endif /* Q_WS_MAC */ 1771 1841 } … … 1983 2053 } 1984 2054 2055 QWidget* UIMediumManager::tab(UIMediumType type) const 2056 { 2057 /* Determine tab index for passed medium type: */ 2058 int iIndex = tabIndex(type); 2059 2060 /* Return tab for known tab index: */ 2061 if (iIndex >= 0 && iIndex < m_iTabCount) 2062 return iIndex < m_pTabWidget->count() ? m_pTabWidget->widget(iIndex) : 0; 2063 2064 /* Null by default: */ 2065 return 0; 2066 } 2067 1985 2068 QTreeWidget* UIMediumManager::treeWidget(UIMediumType type) const 1986 2069 { 1987 /* Return corresponding tree-widget for known medium types: */ 1988 switch (type) 1989 { 1990 case UIMediumType_HardDisk: return mTwHD; 1991 case UIMediumType_DVD: return mTwCD; 1992 case UIMediumType_Floppy: return mTwFD; 1993 default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break; 1994 } 2070 /* Determine tab index for passed medium type: */ 2071 int iIndex = tabIndex(type); 2072 2073 /* Return tree-widget for known tab index: */ 2074 if (iIndex >= 0 && iIndex < m_iTabCount) 2075 return m_trees.value(iIndex, 0); 2076 1995 2077 /* Null by default: */ 1996 2078 return 0; … … 2007 2089 QFrame* UIMediumManager::infoContainer(UIMediumType type) const 2008 2090 { 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 } 2091 /* Determine tab index for passed medium type: */ 2092 int iIndex = tabIndex(type); 2093 2094 /* Return information-container for known tab index: */ 2095 if (iIndex >= 0 && iIndex < m_iTabCount) 2096 return m_containers.value(iIndex, 0); 2097 2017 2098 /* Null by default: */ 2018 2099 return 0; … … 2021 2102 QLabel* UIMediumManager::infoLabel(UIMediumType type, int iLabelIndex) const 2022 2103 { 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 } 2104 /* Determine tab index for passed medium type: */ 2105 int iIndex = tabIndex(type); 2106 2107 /* Look for corresponding information-label list for known tab index: */ 2108 if (iIndex >= 0 && iIndex < m_iTabCount) 2109 { 2110 const QList<QLabel*> labels = m_labels.value(iIndex, QList<QLabel*>()); 2111 2112 /* Return information-label for known index: */ 2113 return labels.value(iLabelIndex, 0); 2114 } 2115 2061 2116 /* Null by default: */ 2062 2117 return 0; … … 2065 2120 QILabel* UIMediumManager::infoField(UIMediumType type, int iFieldIndex) const 2066 2121 { 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 } 2122 /* Determine tab index for passed medium type: */ 2123 int iIndex = tabIndex(type); 2124 2125 /* Look for corresponding information-field list for known tab index: */ 2126 if (iIndex >= 0 && iIndex < m_iTabCount) 2127 { 2128 const QList<QILabel*> fields = m_fields.value(iIndex, QList<QILabel*>()); 2129 2130 /* Return information-field for known index: */ 2131 return fields.value(iFieldIndex, 0); 2132 } 2133 2105 2134 /* Null by default: */ 2106 2135 return 0; … … 2109 2138 UIMediumType UIMediumManager::mediumType(QTreeWidget *pTreeWidget) const 2110 2139 { 2111 /* Hard-drive tree-widget: */ 2112 if (pTreeWidget == treeWidget(UIMediumType_HardDisk)) return UIMediumType_HardDisk; 2113 /* Optical-image tree-widget: */ 2114 if (pTreeWidget == treeWidget(UIMediumType_DVD)) return UIMediumType_DVD; 2115 /* Floppy-image tree-widget: */ 2116 if (pTreeWidget == treeWidget(UIMediumType_Floppy)) return UIMediumType_Floppy; 2140 /* Determine tab index of passed tree-widget: */ 2141 int iIndex = m_trees.key(pTreeWidget, -1); 2142 2143 /* Return medium type for known tab index: */ 2144 if (iIndex >= 0 && iIndex < m_iTabCount) 2145 return mediumType(iIndex); 2146 2117 2147 /* Invalid by default: */ 2118 2148 AssertFailedReturn(UIMediumType_Invalid); … … 2122 2152 { 2123 2153 /* Invalid if tab-widget doesn't exists: */ 2124 if (!m TabWidget)2154 if (!m_pTabWidget) 2125 2155 return UIMediumType_Invalid; 2126 2156 2127 2157 /* Return current medium type: */ 2128 return mediumType(m TabWidget->currentIndex());2158 return mediumType(m_pTabWidget->currentIndex()); 2129 2159 } 2130 2160 … … 2284 2314 2285 2315 /* static */ 2286 QString UIMediumManager::format PaneText(const QString &strText, bool fCompact /* = true */,2287 const QString &strElipsis /* = "middle" */)2316 QString UIMediumManager::formatFieldText(const QString &strText, bool fCompact /* = true */, 2317 const QString &strElipsis /* = "middle" */) 2288 2318 { 2289 2319 QString compactString = QString("<compact elipsis=\"%1\">").arg(strElipsis); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r50967 r50968 19 19 20 20 /* GUI includes: */ 21 #include "UIMediumManager.gen.h" 21 22 22 #include "QIWithRetranslateUI.h" 23 23 #include "QIMainDialog.h" … … 29 29 class UIToolBar; 30 30 class UIEnumerationProgressBar; 31 class QTabWidget; 32 class QTreeWidget; 33 class QTreeWidgetItem; 34 class QFrame; 35 class QLabel; 36 class QILabel; 37 class QIDialogButtonBox; 31 38 32 39 /** Functor interface allowing to check if passed UIMediumItem is suitable. */ … … 39 46 40 47 /** Medium Manager dialog. */ 41 class UIMediumManager : public QIWithRetranslateUI2<QIMainDialog> , public Ui::UIMediumManager48 class UIMediumManager : public QIWithRetranslateUI2<QIMainDialog> 42 49 { 43 50 Q_OBJECT; … … 146 153 /** Update tab icons according last @a action happened with @a pItem. */ 147 154 void updateTabIcons(UIMediumItem *pItem, Action action); 148 /** Update information paneof passed medium @a type. */149 void updateInformation Panes(UIMediumType type = UIMediumType_Invalid);150 /** Update information panefor hard-drive tab. */151 void updateInformation PanesHD();152 /** Update information panefor optical-disk tab. */153 void updateInformation PanesCD();154 /** Update information panefor floppy-disk tab. */155 void updateInformation PanesFD();155 /** Update information fields of passed medium @a type. */ 156 void updateInformationFields(UIMediumType type = UIMediumType_Invalid); 157 /** Update information fields for hard-drive tab. */ 158 void updateInformationFieldsHD(); 159 /** Update information fields for optical-disk tab. */ 160 void updateInformationFieldsCD(); 161 /** Update information fields for floppy-disk tab. */ 162 void updateInformationFieldsFD(); 156 163 157 164 #ifdef Q_WS_MAC … … 174 181 void deleteMediumItem(const QString &strMediumID); 175 182 183 /** Returns tab for passed medium @a type. */ 184 QWidget* tab(UIMediumType type) const; 176 185 /** Returns tree-widget for passed medium @a type. */ 177 186 QTreeWidget* treeWidget(UIMediumType type) const; … … 214 223 static UIMediumItem* toMediumItem(QTreeWidgetItem *pItem); 215 224 216 /** Format information- panecontent. */217 static QString format PaneText(const QString &strText, bool fCompact = true, const QString &strElipsis = "middle");225 /** Format information-field content. */ 226 static QString formatFieldText(const QString &strText, bool fCompact = true, const QString &strElipsis = "middle"); 218 227 219 228 /** Determines if passed @a medium attached to hidden machines only. */ … … 235 244 /** @name Tab-widget variables. 236 245 * @{ */ 246 /** Tab-widget itself. */ 247 QTabWidget *m_pTabWidget; 248 /** Tab-widget tab-count. */ 249 const int m_iTabCount; 250 /** Tree-widgets. */ 251 QMap<int, QTreeWidget*> m_trees; 252 /** Information-containers. */ 253 QMap<int, QFrame*> m_containers; 254 /** Information-container labels. */ 255 QMap<int, QList<QLabel*> > m_labels; 256 /** Information-container fields. */ 257 QMap<int, QList<QILabel*> > m_fields; 237 258 /** Holds whether hard-drive tab-widget have inaccessible item. */ 238 259 bool m_fInaccessibleHD; … … 275 296 /** @} */ 276 297 277 /** @name Progress-barvariables.298 /** @name Button-box variables. 278 299 * @{ */ 300 /** Dialog button-box. */ 301 QIDialogButtonBox *m_pButtonBox; 279 302 /** Progress-bar widget. */ 280 303 UIEnumerationProgressBar *m_pProgressBar; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r50907 r50968 26 26 #include <QDesktopServices> 27 27 #include <QMenuBar> 28 #include <QStatusBar> 28 29 #include <QResizeEvent> 29 30 #include <QStackedWidget>
Note:
See TracChangeset
for help on using the changeset viewer.