Changeset 50769 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 13, 2014 2:45:41 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r50768 r50769 862 862 void UIMediumManager::sltHandleDoubleClick() 863 863 { 864 /* Call for modify-action if hard-drive medium-item double-clicked: */ 865 if (currentMediumType() == UIMediumType_HardDisk) 866 sltModifyMedium(); 864 /* Skip for non-hard-drives: */ 865 if (currentMediumType() != UIMediumType_HardDisk) 866 return; 867 868 /* Call for modify-action: */ 869 sltModifyMedium(); 867 870 } 868 871 … … 886 889 { 887 890 /* Get all the tree-widgets: */ 888 QList<Q ITreeWidget*> trees;889 trees << mTwHD;890 trees << mTwCD;891 trees << mTwFD;891 QList<QTreeWidget*> trees; 892 trees << treeWidget(UIMediumType_HardDisk); 893 trees << treeWidget(UIMediumType_DVD); 894 trees << treeWidget(UIMediumType_Floppy); 892 895 893 896 /* Calculate deduction for every header: */ … … 1147 1150 { 1148 1151 /* Configure HD tree-widget: */ 1149 mTwHD->setColumnCount(3); 1150 mTwHD->sortItems(0, Qt::AscendingOrder); 1151 mTwHD->header()->setResizeMode(0, QHeaderView::Fixed); 1152 mTwHD->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1153 mTwHD->header()->setResizeMode(2, QHeaderView::ResizeToContents); 1154 mTwHD->header()->setStretchLastSection(false); 1155 mTwHD->setSortingEnabled(true); 1156 connect(mTwHD, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 1152 QTreeWidget *pTreeWidget = treeWidget(UIMediumType_HardDisk); 1153 pTreeWidget->setColumnCount(3); 1154 pTreeWidget->sortItems(0, Qt::AscendingOrder); 1155 pTreeWidget->header()->setResizeMode(0, QHeaderView::Fixed); 1156 pTreeWidget->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1157 pTreeWidget->header()->setResizeMode(2, QHeaderView::ResizeToContents); 1158 pTreeWidget->header()->setStretchLastSection(false); 1159 pTreeWidget->setSortingEnabled(true); 1160 connect(pTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 1157 1161 this, SLOT(sltHandleCurrentItemChanged())); 1158 connect( mTwHD, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),1162 connect(pTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 1159 1163 this, SLOT(sltHandleDoubleClick())); 1160 connect( mTwHD, SIGNAL(customContextMenuRequested(const QPoint&)),1164 connect(pTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), 1161 1165 this, SLOT(sltHandleContextMenuCall(const QPoint&))); 1162 connect( mTwHD, SIGNAL(resized(const QSize&, const QSize&)),1166 connect(pTreeWidget, SIGNAL(resized(const QSize&, const QSize&)), 1163 1167 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1164 connect( mTwHD->header(), SIGNAL(sectionResized(int, int, int)),1168 connect(pTreeWidget->header(), SIGNAL(sectionResized(int, int, int)), 1165 1169 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1166 1170 } … … 1172 1176 { 1173 1177 /* Configure CD tree-widget: */ 1174 mTwCD->setColumnCount(2); 1175 mTwCD->sortItems(0, Qt::AscendingOrder); 1176 mTwCD->header()->setResizeMode(0, QHeaderView::Fixed); 1177 mTwCD->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1178 mTwCD->header()->setStretchLastSection(false); 1179 mTwCD->setSortingEnabled(true); 1180 connect(mTwCD, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 1178 QTreeWidget *pTreeWidget = treeWidget(UIMediumType_DVD); 1179 pTreeWidget->setColumnCount(2); 1180 pTreeWidget->sortItems(0, Qt::AscendingOrder); 1181 pTreeWidget->header()->setResizeMode(0, QHeaderView::Fixed); 1182 pTreeWidget->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1183 pTreeWidget->header()->setStretchLastSection(false); 1184 pTreeWidget->setSortingEnabled(true); 1185 connect(pTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 1181 1186 this, SLOT(sltHandleCurrentItemChanged())); 1182 connect( mTwCD, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),1187 connect(pTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 1183 1188 this, SLOT(sltHandleDoubleClick())); 1184 connect( mTwCD, SIGNAL(customContextMenuRequested(const QPoint&)),1189 connect(pTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), 1185 1190 this, SLOT(sltHandleContextMenuCall(const QPoint&))); 1186 connect( mTwCD, SIGNAL(resized(const QSize&, const QSize&)),1191 connect(pTreeWidget, SIGNAL(resized(const QSize&, const QSize&)), 1187 1192 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1188 connect( mTwCD->header(), SIGNAL(sectionResized(int, int, int)),1193 connect(pTreeWidget->header(), SIGNAL(sectionResized(int, int, int)), 1189 1194 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1190 1195 } … … 1196 1201 { 1197 1202 /* Configure FD tree-widget: */ 1198 mTwFD->setColumnCount(2); 1199 mTwFD->sortItems(0, Qt::AscendingOrder); 1200 mTwFD->header()->setResizeMode(0, QHeaderView::Fixed); 1201 mTwFD->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1202 mTwFD->header()->setStretchLastSection(false); 1203 mTwFD->setSortingEnabled(true); 1204 connect(mTwFD, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 1203 QTreeWidget *pTreeWidget = treeWidget(UIMediumType_Floppy); 1204 pTreeWidget->setColumnCount(2); 1205 pTreeWidget->sortItems(0, Qt::AscendingOrder); 1206 pTreeWidget->header()->setResizeMode(0, QHeaderView::Fixed); 1207 pTreeWidget->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1208 pTreeWidget->header()->setStretchLastSection(false); 1209 pTreeWidget->setSortingEnabled(true); 1210 connect(pTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 1205 1211 this, SLOT(sltHandleCurrentItemChanged())); 1206 connect( mTwFD, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),1212 connect(pTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 1207 1213 this, SLOT(sltHandleDoubleClick())); 1208 connect( mTwFD, SIGNAL(customContextMenuRequested(const QPoint&)),1214 connect(pTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), 1209 1215 this, SLOT(sltHandleContextMenuCall(const QPoint&))); 1210 connect( mTwFD, SIGNAL(resized(const QSize&, const QSize&)),1216 connect(pTreeWidget, SIGNAL(resized(const QSize&, const QSize&)), 1211 1217 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1212 connect( mTwFD->header(), SIGNAL(sectionResized(int, int, int)),1218 connect(pTreeWidget->header(), SIGNAL(sectionResized(int, int, int)), 1213 1219 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1214 1220 } … … 1602 1608 setWindowTitle(QApplication::translate("VBoxMediaManagerDlg", "Virtual Media Manager")); 1603 1609 mTabWidget->setTabText(0, tr("&Hard drives")); 1604 mTwHD->headerItem()->setText(0, QApplication::translate("VBoxMediaManagerDlg", "Name")); 1605 mTwHD->headerItem()->setText(1, QApplication::translate("VBoxMediaManagerDlg", "Virtual Size")); 1606 mTwHD->headerItem()->setText(2, QApplication::translate("VBoxMediaManagerDlg", "Actual Size")); 1610 QTreeWidget *pTreeWidgetHD = treeWidget(UIMediumType_HardDisk); 1611 pTreeWidgetHD->headerItem()->setText(0, QApplication::translate("VBoxMediaManagerDlg", "Name")); 1612 pTreeWidgetHD->headerItem()->setText(1, QApplication::translate("VBoxMediaManagerDlg", "Virtual Size")); 1613 pTreeWidgetHD->headerItem()->setText(2, QApplication::translate("VBoxMediaManagerDlg", "Actual Size")); 1607 1614 m_pTypeLabel->setText(QApplication::translate("VBoxMediaManagerDlg", "Type:")); 1608 1615 m_pLocationLabel->setText(QApplication::translate("VBoxMediaManagerDlg", "Location:")); … … 1611 1618 m_pUsageLabel->setText(QApplication::translate("VBoxMediaManagerDlg", "Attached to:")); 1612 1619 mTabWidget->setTabText(1, tr("&Optical disks")); 1613 mTwCD->headerItem()->setText(0, QApplication::translate("VBoxMediaManagerDlg", "Name")); 1614 mTwCD->headerItem()->setText(1, QApplication::translate("VBoxMediaManagerDlg", "Size")); 1620 QTreeWidget *pTreeWidgetCD = treeWidget(UIMediumType_DVD); 1621 pTreeWidgetCD->headerItem()->setText(0, QApplication::translate("VBoxMediaManagerDlg", "Name")); 1622 pTreeWidgetCD->headerItem()->setText(1, QApplication::translate("VBoxMediaManagerDlg", "Size")); 1615 1623 mLbCD1->setText(QApplication::translate("VBoxMediaManagerDlg", "Location:")); 1616 1624 mLbCD2->setText(QApplication::translate("VBoxMediaManagerDlg", "Attached to:")); 1617 1625 mTabWidget->setTabText(2, tr("&Floppy disks")); 1618 mTwFD->headerItem()->setText(0, QApplication::translate("VBoxMediaManagerDlg", "Name")); 1619 mTwFD->headerItem()->setText(1, QApplication::translate("VBoxMediaManagerDlg", "Size")); 1626 QTreeWidget *pTreeWidgetFD = treeWidget(UIMediumType_Floppy); 1627 pTreeWidgetFD->headerItem()->setText(0, QApplication::translate("VBoxMediaManagerDlg", "Name")); 1628 pTreeWidgetFD->headerItem()->setText(1, QApplication::translate("VBoxMediaManagerDlg", "Size")); 1620 1629 mLbFD1->setText(QApplication::translate("VBoxMediaManagerDlg", "Location:")); 1621 1630 mLbFD2->setText(QApplication::translate("VBoxMediaManagerDlg", "Attached to:")); … … 1635 1644 1636 1645 /* Full refresh if there is at least one item present: */ 1637 if ( mTwHD->topLevelItemCount() || mTwCD->topLevelItemCount() || mTwFD->topLevelItemCount())1646 if (pTreeWidgetHD->topLevelItemCount() || pTreeWidgetCD->topLevelItemCount() || pTreeWidgetFD->topLevelItemCount()) 1638 1647 sltRefreshAll(); 1639 1648 } … … 1655 1664 if (pMediumItem->id() == m_strCurrentIdHD) 1656 1665 { 1657 setCurrentItem( mTwHD, pMediumItem);1666 setCurrentItem(treeWidget(UIMediumType_HardDisk), pMediumItem); 1658 1667 m_strCurrentIdHD = QString(); 1659 1668 } … … 1663 1672 case UIMediumType_DVD: 1664 1673 { 1665 pMediumItem = new UIMediumItemCD(medium, mTwCD);1674 pMediumItem = new UIMediumItemCD(medium, treeWidget(UIMediumType_DVD)); 1666 1675 LogRel2(("UIMediumManager: Optical medium-item with ID={%s} created.\n", medium.id().toAscii().constData())); 1667 1676 AssertPtrReturn(pMediumItem, 0); 1668 1677 if (pMediumItem->id() == m_strCurrentIdCD) 1669 1678 { 1670 setCurrentItem( mTwCD, pMediumItem);1679 setCurrentItem(treeWidget(UIMediumType_DVD), pMediumItem); 1671 1680 m_strCurrentIdCD = QString(); 1672 1681 } … … 1676 1685 case UIMediumType_Floppy: 1677 1686 { 1678 pMediumItem = new UIMediumItemFD(medium, mTwFD);1687 pMediumItem = new UIMediumItemFD(medium, treeWidget(UIMediumType_Floppy)); 1679 1688 LogRel2(("UIMediumManager: Floppy medium-item with ID={%s} created.\n", medium.id().toAscii().constData())); 1680 1689 AssertPtrReturn(pMediumItem, 0); 1681 1690 if (pMediumItem->id() == m_strCurrentIdFD) 1682 1691 { 1683 setCurrentItem( mTwFD, pMediumItem);1692 setCurrentItem(treeWidget(UIMediumType_Floppy), pMediumItem); 1684 1693 m_strCurrentIdFD = QString(); 1685 1694 } … … 1706 1715 AssertReturn(!medium.medium().isNull(), 0); 1707 1716 1717 /* Get corresponding tree-widget: */ 1718 QTreeWidget *pTreeWidget = treeWidget(UIMediumType_HardDisk); 1719 1708 1720 /* Search for existing medium-item: */ 1709 UIMediumItem *pMediumItem = searchItem( mTwHD, CheckIfSuitableByID(medium.id()));1721 UIMediumItem *pMediumItem = searchItem(pTreeWidget, CheckIfSuitableByID(medium.id())); 1710 1722 1711 1723 /* If medium-item do not exists: */ … … 1716 1728 { 1717 1729 /* Try to find parent medium-item: */ 1718 UIMediumItem *pParentMediumItem = searchItem( mTwHD, CheckIfSuitableByID(medium.parentID()));1730 UIMediumItem *pParentMediumItem = searchItem(pTreeWidget, CheckIfSuitableByID(medium.parentID())); 1719 1731 /* If parent medium-item was not found: */ 1720 1732 if (!pParentMediumItem) … … 1738 1750 if (!pMediumItem) 1739 1751 { 1740 pMediumItem = new UIMediumItemHD(medium, mTwHD);1752 pMediumItem = new UIMediumItemHD(medium, pTreeWidget); 1741 1753 LogRel2(("UIMediumManager: Root hard-drive medium-item with ID={%s} created.\n", medium.id().toAscii().constData())); 1742 1754 } … … 1806 1818 { 1807 1819 /* Hard-drive tree-widget: */ 1808 if (pTreeWidget == mTwHD) return UIMediumType_HardDisk;1820 if (pTreeWidget == treeWidget(UIMediumType_HardDisk)) return UIMediumType_HardDisk; 1809 1821 /* Optical-image tree-widget: */ 1810 if (pTreeWidget == mTwCD) return UIMediumType_DVD;1822 if (pTreeWidget == treeWidget(UIMediumType_DVD)) return UIMediumType_DVD; 1811 1823 /* Floppy-image tree-widget: */ 1812 if (pTreeWidget == mTwFD) return UIMediumType_Floppy;1824 if (pTreeWidget == treeWidget(UIMediumType_Floppy)) return UIMediumType_Floppy; 1813 1825 /* Invalid by default: */ 1814 1826 AssertFailedReturn(UIMediumType_Invalid);
Note:
See TracChangeset
for help on using the changeset viewer.