Changeset 24395 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Nov 5, 2009 3:52:25 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsHD.h
r24161 r24395 143 143 void setCtrType (KStorageControllerType aCtrType); 144 144 145 virtual DeviceTypeList deviceTypeList() const = 0;145 DeviceTypeList deviceTypeList() const; 146 146 147 147 protected: … … 164 164 private: 165 165 166 DeviceTypeList deviceTypeList() const;167 168 166 KStorageControllerType first() const; 169 167 uint size() const; … … 179 177 private: 180 178 181 DeviceTypeList deviceTypeList() const;182 183 179 KStorageControllerType first() const; 184 180 uint size() const; … … 194 190 private: 195 191 196 DeviceTypeList deviceTypeList() const;197 198 192 KStorageControllerType first() const; 199 193 uint size() const; … … 208 202 209 203 private: 210 211 DeviceTypeList deviceTypeList() const;212 204 213 205 KStorageControllerType first() const; … … 421 413 R_AttSlots, 422 414 R_AttDevice, 423 R_AttDevices,424 415 R_AttMediumId, 425 416 R_AttIsShowDiffs, … … 504 495 public: 505 496 506 StorageDelegate (QObject *aParent , bool aDisableStaticControls);497 StorageDelegate (QObject *aParent); 507 498 508 499 private: … … 524 515 public: 525 516 526 VBoxVMSettingsHD (bool aDisableStaticControls = false);517 VBoxVMSettingsHD(); 527 518 528 519 signals: -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r24304 r24395 54 54 #include "VBoxTakeSnapshotDlg.h" 55 55 #include "VBoxVMFirstRunWzd.h" 56 #include "VBoxVMSettingsHD.h"57 56 #include "VBoxVMSettingsNetwork.h" 58 57 #include "VBoxVMSettingsSF.h" -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsHD.cpp
r24175 r24395 226 226 } 227 227 228 DeviceTypeList AbstractControllerType::deviceTypeList() const 229 { 230 return vboxGlobal().virtualBox().GetSystemProperties().GetDeviceTypesForStorageBus (mBusType).toList(); 231 } 232 228 233 /* IDE Controller Type */ 229 234 IDEControllerType::IDEControllerType (KStorageControllerType aSubType) … … 232 237 } 233 238 234 DeviceTypeList IDEControllerType::deviceTypeList() const235 {236 return DeviceTypeList() << KDeviceType_HardDisk << KDeviceType_DVD;237 }238 239 239 KStorageControllerType IDEControllerType::first() const 240 240 { … … 253 253 } 254 254 255 DeviceTypeList SATAControllerType::deviceTypeList() const256 {257 return DeviceTypeList() << KDeviceType_HardDisk << KDeviceType_DVD;258 }259 260 255 KStorageControllerType SATAControllerType::first() const 261 256 { … … 274 269 } 275 270 276 DeviceTypeList SCSIControllerType::deviceTypeList() const277 {278 return DeviceTypeList() << KDeviceType_HardDisk << KDeviceType_DVD;279 }280 281 271 KStorageControllerType SCSIControllerType::first() const 282 272 { … … 293 283 : AbstractControllerType (KStorageBus_Floppy, aSubType) 294 284 { 295 }296 297 DeviceTypeList FloppyControllerType::deviceTypeList() const298 {299 return DeviceTypeList() << KDeviceType_Floppy;300 285 } 301 286 … … 1132 1117 return result; 1133 1118 } 1134 case R_AttDevices:1135 {1136 QVariant result (QVariant::fromValue (DeviceTypeList()));1137 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer()))1138 if (item->rtti() == AbstractItem::Type_AttachmentItem)1139 result.setValue (static_cast <AttachmentItem*> (item)->attDeviceTypes());1140 return result;1141 }1142 1119 case R_AttMediumId: 1143 1120 { … … 1254 1231 } 1255 1232 case R_HDPixmapRect: 1233 { 1234 int margin = data (aIndex, R_Margin).toInt(); 1235 int width = data (aIndex, R_IconSize).toInt(); 1236 return QRect (0 - width - margin, margin, width, width); 1237 } 1238 case R_CDPixmapRect: 1256 1239 { 1257 1240 int margin = data (aIndex, R_Margin).toInt(); … … 1259 1242 int width = data (aIndex, R_IconSize).toInt(); 1260 1243 return QRect (0 - width - spacing - width - margin, margin, width, width); 1261 }1262 case R_CDPixmapRect:1263 {1264 int margin = data (aIndex, R_Margin).toInt();1265 int width = data (aIndex, R_IconSize).toInt();1266 return QRect (0 - width - margin, margin, width, width);1267 1244 } 1268 1245 case R_FDPixmapRect: … … 1436 1413 1437 1414 /* Storage Delegate */ 1438 StorageDelegate::StorageDelegate (QObject *aParent , bool aDisableStaticControls)1415 StorageDelegate::StorageDelegate (QObject *aParent) 1439 1416 : QItemDelegate (aParent) 1440 , mDisableStaticControls (aDisableStaticControls)1441 1417 { 1442 1418 } … … 1495 1471 1496 1472 /* Draw Controller Additions */ 1497 if ( !mDisableStaticControls &&model->data (aIndex, StorageModel::R_IsController).toBool() && state & QStyle::State_Selected)1473 if (model->data (aIndex, StorageModel::R_IsController).toBool() && state & QStyle::State_Selected) 1498 1474 { 1499 1475 DeviceTypeList devicesList (model->data (aIndex, StorageModel::R_CtrDevices).value <DeviceTypeList>()); … … 1547 1523 * Used as HD Settings widget. 1548 1524 */ 1549 VBoxVMSettingsHD::VBoxVMSettingsHD (bool aDisableStaticControls /* = false */)1525 VBoxVMSettingsHD::VBoxVMSettingsHD() 1550 1526 : mValidator (0) 1551 1527 , mIsPolished (false) 1552 , mDisableStaticControls (aDisableStaticControls)1553 1528 { 1554 1529 /* Apply UI decorations */ … … 1609 1584 /* Storage Model/View */ 1610 1585 mStorageModel = new StorageModel (mTwStorageTree); 1611 StorageDelegate *storageDelegate = new StorageDelegate (mTwStorageTree , mDisableStaticControls);1586 StorageDelegate *storageDelegate = new StorageDelegate (mTwStorageTree); 1612 1587 mTwStorageTree->setMouseTracking (true); 1613 1588 mTwStorageTree->setContextMenuPolicy (Qt::CustomContextMenu); … … 1623 1598 mTbStorageBar->addAction (mAddCtrAction); 1624 1599 mTbStorageBar->addAction (mDelCtrAction); 1625 mTbStorageBar->setHidden (mDisableStaticControls);1626 1600 1627 1601 #ifdef Q_WS_MAC … … 1736 1710 void VBoxVMSettingsHD::putBackTo() 1737 1711 { 1738 if (mDisableStaticControls) 1739 { 1740 /* Just search for the currently present CD/DVD & Floppy devices to update */ 1741 QModelIndex rootIndex = mStorageModel->root(); 1742 for (int i = 0; i < mStorageModel->rowCount (rootIndex); ++ i) 1743 { 1744 QModelIndex ctrIndex = rootIndex.child (i, 0); 1745 QString ctrName = mStorageModel->data (ctrIndex, StorageModel::R_CtrName).toString(); 1746 for (int j = 0; j < mStorageModel->rowCount (ctrIndex); ++ j) 1747 { 1748 QModelIndex attIndex = ctrIndex.child (j, 0); 1749 KDeviceType attDeviceType = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>(); 1750 if (attDeviceType != KDeviceType_DVD && attDeviceType != KDeviceType_Floppy) continue; 1751 StorageSlot attStorageSlot = mStorageModel->data (attIndex, StorageModel::R_AttSlot).value <StorageSlot>(); 1752 QString attMediumId = mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString(); 1753 const CMedium &medium = mMachine.GetMedium (ctrName, attStorageSlot.port, attStorageSlot.device); 1754 if ((medium.isNull() && !QUuid (attMediumId).isNull()) || 1755 (!medium.isNull() && medium.GetId() != attMediumId)) 1756 mMachine.MountMedium (ctrName, attStorageSlot.port, attStorageSlot.device, attMediumId); 1757 } 1758 } 1759 } 1760 else 1761 { 1762 /* Remove currently present controllers & attachments */ 1763 CStorageControllerVector controllers = mMachine.GetStorageControllers(); 1764 foreach (const CStorageController &controller, controllers) 1765 { 1766 QString controllerName (controller.GetName()); 1767 CMediumAttachmentVector attachments = mMachine.GetMediumAttachmentsOfController (controllerName); 1768 foreach (const CMediumAttachment &attachment, attachments) 1769 mMachine.DetachDevice (controllerName, attachment.GetPort(), attachment.GetDevice()); 1770 mMachine.RemoveStorageController (controllerName); 1771 } 1772 1773 /* Save created controllers & attachments */ 1774 QModelIndex rootIndex = mStorageModel->root(); 1775 for (int i = 0; i < mStorageModel->rowCount (rootIndex); ++ i) 1776 { 1777 QModelIndex ctrIndex = rootIndex.child (i, 0); 1778 QString ctrName = mStorageModel->data (ctrIndex, StorageModel::R_CtrName).toString(); 1779 KStorageBus ctrBusType = mStorageModel->data (ctrIndex, StorageModel::R_CtrBusType).value <KStorageBus>(); 1780 KStorageControllerType ctrType = mStorageModel->data (ctrIndex, StorageModel::R_CtrType).value <KStorageControllerType>(); 1781 CStorageController ctr = mMachine.AddStorageController (ctrName, ctrBusType); 1782 ctr.SetControllerType (ctrType); 1783 int maxUsedPort = -1; 1784 for (int j = 0; j < mStorageModel->rowCount (ctrIndex); ++ j) 1785 { 1786 QModelIndex attIndex = ctrIndex.child (j, 0); 1787 StorageSlot attStorageSlot = mStorageModel->data (attIndex, StorageModel::R_AttSlot).value <StorageSlot>(); 1788 KDeviceType attDeviceType = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>(); 1789 QString attMediumId = mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString(); 1790 mMachine.AttachDevice (ctrName, attStorageSlot.port, attStorageSlot.device, attDeviceType, attMediumId); 1791 if (attDeviceType == KDeviceType_DVD) 1792 mMachine.PassthroughDevice (ctrName, attStorageSlot.port, attStorageSlot.device, 1793 mStorageModel->data (attIndex, StorageModel::R_AttIsPassthrough).toBool()); 1794 maxUsedPort = attStorageSlot.port > maxUsedPort ? attStorageSlot.port : maxUsedPort; 1795 } 1796 if (ctrBusType == KStorageBus_SATA) 1797 { 1798 ULONG sataPortsCount = maxUsedPort + 1; 1799 sataPortsCount = qMax (sataPortsCount, ctr.GetMinPortCount()); 1800 sataPortsCount = qMin (sataPortsCount, ctr.GetMaxPortCount()); 1801 ctr.SetPortCount (sataPortsCount); 1802 } 1712 /* Remove currently present controllers & attachments */ 1713 CStorageControllerVector controllers = mMachine.GetStorageControllers(); 1714 foreach (const CStorageController &controller, controllers) 1715 { 1716 QString controllerName (controller.GetName()); 1717 CMediumAttachmentVector attachments = mMachine.GetMediumAttachmentsOfController (controllerName); 1718 foreach (const CMediumAttachment &attachment, attachments) 1719 mMachine.DetachDevice (controllerName, attachment.GetPort(), attachment.GetDevice()); 1720 mMachine.RemoveStorageController (controllerName); 1721 } 1722 1723 /* Save created controllers & attachments */ 1724 QModelIndex rootIndex = mStorageModel->root(); 1725 for (int i = 0; i < mStorageModel->rowCount (rootIndex); ++ i) 1726 { 1727 QModelIndex ctrIndex = rootIndex.child (i, 0); 1728 QString ctrName = mStorageModel->data (ctrIndex, StorageModel::R_CtrName).toString(); 1729 KStorageBus ctrBusType = mStorageModel->data (ctrIndex, StorageModel::R_CtrBusType).value <KStorageBus>(); 1730 KStorageControllerType ctrType = mStorageModel->data (ctrIndex, StorageModel::R_CtrType).value <KStorageControllerType>(); 1731 CStorageController ctr = mMachine.AddStorageController (ctrName, ctrBusType); 1732 ctr.SetControllerType (ctrType); 1733 int maxUsedPort = -1; 1734 for (int j = 0; j < mStorageModel->rowCount (ctrIndex); ++ j) 1735 { 1736 QModelIndex attIndex = ctrIndex.child (j, 0); 1737 StorageSlot attStorageSlot = mStorageModel->data (attIndex, StorageModel::R_AttSlot).value <StorageSlot>(); 1738 KDeviceType attDeviceType = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>(); 1739 QString attMediumId = mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString(); 1740 mMachine.AttachDevice (ctrName, attStorageSlot.port, attStorageSlot.device, attDeviceType, attMediumId); 1741 if (attDeviceType == KDeviceType_DVD) 1742 mMachine.PassthroughDevice (ctrName, attStorageSlot.port, attStorageSlot.device, 1743 mStorageModel->data (attIndex, StorageModel::R_AttIsPassthrough).toBool()); 1744 maxUsedPort = attStorageSlot.port > maxUsedPort ? attStorageSlot.port : maxUsedPort; 1745 } 1746 if (ctrBusType == KStorageBus_SATA) 1747 { 1748 ULONG sataPortsCount = maxUsedPort + 1; 1749 sataPortsCount = qMax (sataPortsCount, ctr.GetMinPortCount()); 1750 sataPortsCount = qMin (sataPortsCount, ctr.GetMaxPortCount()); 1751 ctr.SetPortCount (sataPortsCount); 1803 1752 } 1804 1753 } … … 1998 1947 Assert (mStorageModel->data (index, StorageModel::R_IsController).toBool()); 1999 1948 2000 if (mStorageModel->data (index, StorageModel::R_CtrBusType).value <KStorageBus>() == KStorageBus_Floppy) 2001 { 2002 Assert (mAddFDAttAction->isEnabled()); 2003 mAddFDAttAction->trigger(); 2004 } 2005 else 2006 { 2007 QMenu menu; 2008 menu.addAction (mAddHDAttAction); 2009 menu.addAction (mAddCDAttAction); 1949 DeviceTypeList deviceTypeList (mStorageModel->data (index, StorageModel::R_CtrDevices).value <DeviceTypeList>()); 1950 bool justTrigger = deviceTypeList.size() == 1; 1951 bool showMenu = deviceTypeList.size() > 1; 1952 QMenu menu; 1953 foreach (const KDeviceType &deviceType, deviceTypeList) 1954 { 1955 switch (deviceType) 1956 { 1957 case KDeviceType_HardDisk: 1958 if (justTrigger) 1959 mAddHDAttAction->trigger(); 1960 if (showMenu) 1961 menu.addAction (mAddHDAttAction); 1962 break; 1963 case KDeviceType_DVD: 1964 if (justTrigger) 1965 mAddCDAttAction->trigger(); 1966 if (showMenu) 1967 menu.addAction (mAddCDAttAction); 1968 break; 1969 case KDeviceType_Floppy: 1970 if (justTrigger) 1971 mAddFDAttAction->trigger(); 1972 if (showMenu) 1973 menu.addAction (mAddFDAttAction); 1974 break; 1975 default: 1976 break; 1977 } 1978 } 1979 if (showMenu) 2010 1980 menu.exec (QCursor::pos()); 2011 }2012 1981 } 2013 1982 … … 2060 2029 /* Getting Controller Name */ 2061 2030 mLeName->setText (mStorageModel->data (index, StorageModel::R_CtrName).toString()); 2062 mLbName->setEnabled (!mDisableStaticControls);2063 mLeName->setEnabled (!mDisableStaticControls);2064 2031 2065 2032 /* Getting Controller Sub type */ … … 2071 2038 int ctrPos = mCbType->findText (vboxGlobal().toString (type)); 2072 2039 mCbType->setCurrentIndex (ctrPos == -1 ? 0 : ctrPos); 2073 mLbType->setEnabled (!mDisableStaticControls);2074 mCbType->setEnabled (!mDisableStaticControls);2075 2040 2076 2041 /* Showing Controller Page */ … … 2089 2054 mCbSlot->setCurrentIndex (attSlotPos == -1 ? 0 : attSlotPos); 2090 2055 mCbSlot->setToolTip (mCbSlot->itemText (mCbSlot->currentIndex())); 2091 mLbSlot->setEnabled (!mDisableStaticControls);2092 mCbSlot->setEnabled (!mDisableStaticControls);2093 2056 2094 2057 /* Getting Show Diffs state */ 2095 2058 bool isShowDiffs = mStorageModel->data (index, StorageModel::R_AttIsShowDiffs).toBool(); 2096 2059 mCbShowDiffs->setChecked (isShowDiffs); 2097 mCbShowDiffs->setEnabled (!mDisableStaticControls);2098 2060 2099 2061 /* Getting Attachment Medium */ … … 2103 2065 case KDeviceType_HardDisk: 2104 2066 mLbVdi->setText (tr ("Hard &Disk:")); 2105 mLbVdi->setEnabled (!mDisableStaticControls);2106 mCbVdi->setEnabled (!mDisableStaticControls);2107 mTbVmm->setEnabled (!mDisableStaticControls);2108 2067 break; 2109 2068 case KDeviceType_DVD: 2110 2069 mLbVdi->setText (tr ("&CD/DVD Device:")); 2111 mLbVdi->setEnabled (true);2112 mCbVdi->setEnabled (true);2113 mTbVmm->setEnabled (true);2114 2070 break; 2115 2071 case KDeviceType_Floppy: 2116 2072 mLbVdi->setText (tr ("&Floppy Device:")); 2117 mLbVdi->setEnabled (true);2118 mCbVdi->setEnabled (true);2119 mTbVmm->setEnabled (true);2120 2073 break; 2121 2074 default: … … 2129 2082 /* Getting Passthrough state */ 2130 2083 bool isHostDrive = mStorageModel->data (index, StorageModel::R_AttIsHostDrive).toBool(); 2131 mCbPassthrough->setEnabled ( !mDisableStaticControls &&isHostDrive);2084 mCbPassthrough->setEnabled (isHostDrive); 2132 2085 mCbPassthrough->setChecked (isHostDrive && mStorageModel->data (index, StorageModel::R_AttIsPassthrough).toBool()); 2133 2086 … … 2222 2175 bool isAttachmentsPossible = mStorageModel->data (index, StorageModel::R_IsMoreAttachmentsPossible).toBool(); 2223 2176 2224 mAddCtrAction->setEnabled ( !mDisableStaticControls && (isIDEPossible || isSATAPossible || isSCSIPossible || isFloppyPossible));2225 mAddIDECtrAction->setEnabled ( !mDisableStaticControls &&isIDEPossible);2226 mAddSATACtrAction->setEnabled ( !mDisableStaticControls &&isSATAPossible);2227 mAddSCSICtrAction->setEnabled ( !mDisableStaticControls &&isSCSIPossible);2228 mAddFloppyCtrAction->setEnabled ( !mDisableStaticControls &&isFloppyPossible);2229 2230 mAddAttAction->setEnabled ( !mDisableStaticControls &&isController && isAttachmentsPossible);2231 mAddHDAttAction->setEnabled ( !mDisableStaticControls &&isController && isAttachmentsPossible);2232 mAddCDAttAction->setEnabled ( !mDisableStaticControls &&isController && isAttachmentsPossible);2233 mAddFDAttAction->setEnabled ( !mDisableStaticControls &&isController && isAttachmentsPossible);2234 2235 mDelCtrAction->setEnabled ( !mDisableStaticControls &&isController);2236 mDelAttAction->setEnabled ( !mDisableStaticControls &&isAttachment);2177 mAddCtrAction->setEnabled (isIDEPossible || isSATAPossible || isSCSIPossible || isFloppyPossible); 2178 mAddIDECtrAction->setEnabled (isIDEPossible); 2179 mAddSATACtrAction->setEnabled (isSATAPossible); 2180 mAddSCSICtrAction->setEnabled (isSCSIPossible); 2181 mAddFloppyCtrAction->setEnabled (isFloppyPossible); 2182 2183 mAddAttAction->setEnabled (isController && isAttachmentsPossible); 2184 mAddHDAttAction->setEnabled (isController && isAttachmentsPossible); 2185 mAddCDAttAction->setEnabled (isController && isAttachmentsPossible); 2186 mAddFDAttAction->setEnabled (isController && isAttachmentsPossible); 2187 2188 mDelCtrAction->setEnabled (isController); 2189 mDelAttAction->setEnabled (isAttachment); 2237 2190 } 2238 2191
Note:
See TracChangeset
for help on using the changeset viewer.