Changeset 50960 in vbox
- Timestamp:
- Apr 3, 2014 11:31:10 AM (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
r50959 r50960 22 22 /* Qt includes: */ 23 23 #include <QLabel> 24 #include <QProgressBar>25 24 #include <QMenuBar> 26 25 #include <QHeaderView> 27 26 #include <QPushButton> 27 #include <QProgressBar> 28 28 29 29 /* GUI includes: */ … … 33 33 #include "UIMessageCenter.h" 34 34 #include "UIToolBar.h" 35 #include "QILabel.h"36 35 #include "UIIconPool.h" 37 36 #include "UIMediumTypeChangeDialog.h" … … 594 593 595 594 /** Constructor on the basis of passed @a pParent. */ 596 UIEnumerationProgressBar(QWidget *pParent )595 UIEnumerationProgressBar(QWidget *pParent = 0) 597 596 : QWidget(pParent) 598 597 { … … 657 656 , m_iconCD(UIIconPool::iconSet(":/cd_16px.png", ":/cd_disabled_16px.png")) 658 657 , m_iconFD(UIIconPool::iconSet(":/fd_16px.png", ":/fd_disabled_16px.png")) 658 , m_pToolBar(0) 659 , m_pContextMenu(0) 660 , m_pMenu(0) 661 , m_pActionCopy(0), m_pActionModify(0) 662 , m_pActionRemove(0), m_pActionRelease(0) 663 , m_pActionRefresh(0) 664 , m_pProgressBar(0) 659 665 { 660 666 /* Prepare: */ … … 1046 1052 void UIMediumManager::prepareMenuBar() 1047 1053 { 1048 /* Create actions-menu for menu-bar: */1054 /* Create menu-bar-menu: */ 1049 1055 m_pMenu = menuBar()->addMenu(QString()); 1050 1056 { 1051 /* Configure menu-bar 1057 /* Configure menu-bar-menu: */ 1052 1058 m_pMenu->addAction(m_pActionCopy); 1053 1059 m_pMenu->addAction(m_pActionModify); … … 1098 1104 /* Integrate tool-bar into dialog: */ 1099 1105 QVBoxLayout *pMainLayout = qobject_cast<QVBoxLayout*>(centralWidget()->layout()); 1100 Assert(pMainLayout);1101 1106 #if MAC_LEOPARD_STYLE 1102 1107 /* Enable unified tool-bars on Mac OS X. Available on Qt >= 4.3: */ … … 1112 1117 pMainLayout->setSpacing(5); 1113 1118 pMainLayout->setContentsMargins(5, 5, 5, 5); 1114 #endif /* MAC_LEOPARD_STYLE */1119 #endif /* !MAC_LEOPARD_STYLE */ 1115 1120 } 1116 1121 } … … 1120 1125 /* Tab-widget created in .ui file. */ 1121 1126 { 1127 /* Prepare tabs: */ 1128 for (int i = (int)UIMediumType_HardDisk; i <= (int)UIMediumType_Floppy; ++i) 1129 prepareTab((UIMediumType)i); 1122 1130 /* Configure tab-widget: */ 1123 1131 mTabWidget->setFocusPolicy(Qt::TabFocus); … … 1126 1134 mTabWidget->setTabIcon(TabIndex_FD, m_iconFD); 1127 1135 connect(mTabWidget, SIGNAL(currentChanged(int)), this, SLOT(sltHandleCurrentTabChanged())); 1128 /* Prepare tree-widgets: */ 1129 prepareTreeWidgets(); 1130 /* Prepare information-panes: */ 1131 prepareInformationPanes(); 1132 } 1133 } 1134 1135 void UIMediumManager::prepareTreeWidgets() 1136 { 1137 /* Prepare tree-widget HD: */ 1138 prepareTreeWidgetHD(); 1139 /* Prepare tree-widget CD: */ 1140 prepareTreeWidgetCD(); 1141 /* Prepare tree-widget FD: */ 1142 prepareTreeWidgetFD(); 1143 1144 /* Focus current tree-widget: */ 1145 currentTreeWidget()->setFocus(); 1146 } 1147 1148 void UIMediumManager::prepareTreeWidgetHD() 1149 { 1150 /* HD tree-widget created in .ui file. */ 1151 { 1152 /* Configure HD tree-widget: */ 1153 QTreeWidget *pTreeWidget = treeWidget(UIMediumType_HardDisk); 1154 pTreeWidget->setColumnCount(3); 1136 /* Focus current tree-widget: */ 1137 if (currentTreeWidget()) 1138 currentTreeWidget()->setFocus(); 1139 /* Update other widgets according chosen tab: */ 1140 sltHandleCurrentTabChanged(); 1141 } 1142 } 1143 1144 void UIMediumManager::prepareTab(UIMediumType type) 1145 { 1146 /* Tab created in .ui file. */ 1147 { 1148 /* Tab layout created in .ui file. */ 1149 { 1150 /* Prepare tree-widget: */ 1151 prepareTreeWidget(type, type == UIMediumType_HardDisk ? 3 : 2); 1152 /* Prepare information-container: */ 1153 prepareInformationContainer(type, type == UIMediumType_HardDisk ? 5 : 2); 1154 } 1155 } 1156 } 1157 1158 void UIMediumManager::prepareTreeWidget(UIMediumType type, int iColumns) 1159 { 1160 /* Tree-widget created in .ui file. */ 1161 { 1162 /* Configure tree-widget: */ 1163 QTreeWidget *pTreeWidget = treeWidget(type); 1164 pTreeWidget->setColumnCount(iColumns); 1155 1165 pTreeWidget->sortItems(0, Qt::AscendingOrder); 1156 pTreeWidget->header()->setResizeMode(0, QHeaderView::Fixed); 1157 pTreeWidget->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1158 pTreeWidget->header()->setResizeMode(2, QHeaderView::ResizeToContents); 1166 if (iColumns > 0) 1167 pTreeWidget->header()->setResizeMode(0, QHeaderView::Fixed); 1168 if (iColumns > 1) 1169 pTreeWidget->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1170 if (iColumns > 2) 1171 pTreeWidget->header()->setResizeMode(2, QHeaderView::ResizeToContents); 1159 1172 pTreeWidget->header()->setStretchLastSection(false); 1160 1173 pTreeWidget->setSortingEnabled(true); … … 1172 1185 } 1173 1186 1174 void UIMediumManager::prepareTreeWidgetCD() 1175 { 1176 /* CD tree-widget created in .ui file. */ 1177 { 1178 /* Configure CD tree-widget: */ 1179 QTreeWidget *pTreeWidget = treeWidget(UIMediumType_DVD); 1180 pTreeWidget->setColumnCount(2); 1181 pTreeWidget->sortItems(0, Qt::AscendingOrder); 1182 pTreeWidget->header()->setResizeMode(0, QHeaderView::Fixed); 1183 pTreeWidget->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1184 pTreeWidget->header()->setStretchLastSection(false); 1185 pTreeWidget->setSortingEnabled(true); 1186 connect(pTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 1187 this, SLOT(sltHandleCurrentItemChanged())); 1188 connect(pTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 1189 this, SLOT(sltHandleDoubleClick())); 1190 connect(pTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), 1191 this, SLOT(sltHandleContextMenuCall(const QPoint&))); 1192 connect(pTreeWidget, SIGNAL(resized(const QSize&, const QSize&)), 1193 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1194 connect(pTreeWidget->header(), SIGNAL(sectionResized(int, int, int)), 1195 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1196 } 1197 } 1198 1199 void UIMediumManager::prepareTreeWidgetFD() 1200 { 1201 /* FD tree-widget created in .ui file. */ 1202 { 1203 /* Configure FD tree-widget: */ 1204 QTreeWidget *pTreeWidget = treeWidget(UIMediumType_Floppy); 1205 pTreeWidget->setColumnCount(2); 1206 pTreeWidget->sortItems(0, Qt::AscendingOrder); 1207 pTreeWidget->header()->setResizeMode(0, QHeaderView::Fixed); 1208 pTreeWidget->header()->setResizeMode(1, QHeaderView::ResizeToContents); 1209 pTreeWidget->header()->setStretchLastSection(false); 1210 pTreeWidget->setSortingEnabled(true); 1211 connect(pTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 1212 this, SLOT(sltHandleCurrentItemChanged())); 1213 connect(pTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 1214 this, SLOT(sltHandleDoubleClick())); 1215 connect(pTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), 1216 this, SLOT(sltHandleContextMenuCall(const QPoint&))); 1217 connect(pTreeWidget, SIGNAL(resized(const QSize&, const QSize&)), 1218 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1219 connect(pTreeWidget->header(), SIGNAL(sectionResized(int, int, int)), 1220 this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection); 1221 } 1222 } 1223 1224 void UIMediumManager::prepareInformationPanes() 1187 void UIMediumManager::prepareInformationContainer(UIMediumType, int) 1225 1188 { 1226 1189 /* Information-panes created in .ui file. */ … … 1239 1202 /* Configure button-box: */ 1240 1203 mButtonBox->button(QDialogButtonBox::Ok)->setDefault(true); 1204 connect(mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); 1241 1205 connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept())); 1242 connect(mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));1243 1206 /* Prepare progress-bar: */ 1244 1207 prepareProgressBar(); … … 1249 1212 { 1250 1213 /* Create progress-bar: */ 1251 m_pProgressBar = new UIEnumerationProgressBar (this);1214 m_pProgressBar = new UIEnumerationProgressBar; 1252 1215 { 1253 1216 /* Configure progress-bar: */ 1254 1217 m_pProgressBar->hide(); 1218 /* Add progress-bar into button-box layout: */ 1255 1219 mButtonBox->addExtraWidget(m_pProgressBar); 1256 1220 } … … 1855 1819 } 1856 1820 1821 QTreeWidget* UIMediumManager::treeWidget(UIMediumType type) const 1822 { 1823 /* Return corresponding tree-widget for known medium types: */ 1824 switch (type) 1825 { 1826 case UIMediumType_HardDisk: return mTwHD; 1827 case UIMediumType_DVD: return mTwCD; 1828 case UIMediumType_Floppy: return mTwFD; 1829 default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break; 1830 } 1831 /* Null by default: */ 1832 return 0; 1833 } 1834 1835 UIMediumItem* UIMediumManager::mediumItem(UIMediumType type) const 1836 { 1837 /* Get corresponding tree-widget: */ 1838 QTreeWidget *pTreeWidget = treeWidget(type); 1839 /* Return corresponding medium-item: */ 1840 return pTreeWidget ? toMediumItem(pTreeWidget->currentItem()) : 0; 1841 } 1842 1857 1843 UIMediumType UIMediumManager::mediumType(QTreeWidget *pTreeWidget) const 1858 1844 { … … 1865 1851 /* Invalid by default: */ 1866 1852 AssertFailedReturn(UIMediumType_Invalid); 1867 }1868 1869 QTreeWidget* UIMediumManager::treeWidget(UIMediumType type) const1870 {1871 /* Return corresponding tree-widget for known medium types: */1872 switch (type)1873 {1874 case UIMediumType_HardDisk: return mTwHD;1875 case UIMediumType_DVD: return mTwCD;1876 case UIMediumType_Floppy: return mTwFD;1877 default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break;1878 }1879 /* Null by default: */1880 return 0;1881 }1882 1883 UIMediumItem* UIMediumManager::mediumItem(UIMediumType type) const1884 {1885 /* Get corresponding tree-widget: */1886 QTreeWidget *pTreeWidget = treeWidget(type);1887 /* Return corresponding medium-item: */1888 return pTreeWidget ? toMediumItem(pTreeWidget->currentItem()) : 0;1889 1853 } 1890 1854 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r50959 r50960 118 118 /** Prepare tab-widget. */ 119 119 void prepareTabWidget(); 120 /** Prepare tree-widgets. */ 121 void prepareTreeWidgets(); 122 /** Prepare hard-drive tree-widget. */ 123 void prepareTreeWidgetHD(); 124 /** Prepare optical-disk tree-widget. */ 125 void prepareTreeWidgetCD(); 126 /** Prepare floppy-disk tree-widget. */ 127 void prepareTreeWidgetFD(); 128 /** Prepare information-panes. */ 129 void prepareInformationPanes(); 120 /** Prepare tab-widget's tab. */ 121 void prepareTab(UIMediumType type); 122 /** Prepare tab-widget's tree-widget. */ 123 void prepareTreeWidget(UIMediumType type, int iColumns); 124 /** Prepare tab-widget's information-container. */ 125 void prepareInformationContainer(UIMediumType type, int iFields); 130 126 /** Prepare button-box. */ 131 127 void prepareButtonBox(); … … 181 177 void deleteMediumItem(const QString &strMediumID); 182 178 183 /** Returns medium type for passed @a pTreeWidget. */184 UIMediumType mediumType(QTreeWidget *pTreeWidget) const;185 179 /** Returns tree-widget for passed medium @a type. */ 186 180 QTreeWidget* treeWidget(UIMediumType type) const; 187 181 /** Returns item for passed medium @a type. */ 188 182 UIMediumItem* mediumItem(UIMediumType type) const; 183 184 /** Returns medium type for passed @a pTreeWidget. */ 185 UIMediumType mediumType(QTreeWidget *pTreeWidget) const; 189 186 190 187 /** Returns current medium type. */
Note:
See TracChangeset
for help on using the changeset viewer.