- Timestamp:
- Apr 6, 2017 10:02:40 AM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
-
UIMachineSettingsUSB.cpp (modified) (7 diffs)
-
UIMachineSettingsUSB.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp
r66410 r66455 255 255 256 256 257 /** QITreeWidgetItem extension representing USB filteritem. */257 /** Machine settings: USB Filter tree-widget item. */ 258 258 class UIUSBFilterItem : public QITreeWidgetItem, public UIDataSettingsMachineUSBFilter 259 259 { 260 260 public: 261 261 262 /** Constructs USB filter item. */ 263 UIUSBFilterItem() {} 264 265 /** Loads USB filter @a data. */ 266 void loadUSBFilterData(const UIDataSettingsMachineUSBFilter &data) 267 { 268 m_fActive = data.m_fActive; 269 m_strName = data.m_strName; 270 m_strVendorId = data.m_strVendorId; 271 m_strProductId = data.m_strProductId; 272 m_strRevision = data.m_strRevision; 273 m_strManufacturer = data.m_strManufacturer; 274 m_strProduct = data.m_strProduct; 275 m_strSerialNumber = data.m_strSerialNumber; 276 m_strPort = data.m_strPort; 277 m_strRemote = data.m_strRemote; 278 m_enmAction = data.m_enmAction; 279 m_fHostUSBDevice = data.m_fHostUSBDevice; 280 m_enmHostUSBDeviceState = data.m_enmHostUSBDeviceState; 262 /** Constructs USB filter (root) item. 263 * @param pParent Brings the item parent. */ 264 UIUSBFilterItem(QITreeWidget *pParent) 265 : QITreeWidgetItem(pParent) 266 { 267 } 268 269 /** Updates item fields. */ 270 void updateFields() 271 { 272 setText(0, m_strName); 273 setToolTip(0, toolTipFor()); 281 274 } 282 275 … … 289 282 tr("%1, Active", "col.1 text, col.1 state").arg(text(0)) : 290 283 tr("%1", "col.1 text") .arg(text(0)); 284 } 285 286 private: 287 288 /** Returns tool-tip generated from item data. */ 289 QString toolTipFor() 290 { 291 /* Prepare tool-tip: */ 292 QString strToolTip; 293 294 const QString strVendorId = m_strVendorId; 295 if (!strVendorId.isEmpty()) 296 strToolTip += UIMachineSettingsUSB::tr("<nobr>Vendor ID: %1</nobr>", "USB filter tooltip").arg(strVendorId); 297 298 const QString strProductId = m_strProductId; 299 if (!strProductId.isEmpty()) 300 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + UIMachineSettingsUSB::tr("<nobr>Product ID: %2</nobr>", "USB filter tooltip").arg(strProductId); 301 302 const QString strRevision = m_strRevision; 303 if (!strRevision.isEmpty()) 304 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + UIMachineSettingsUSB::tr("<nobr>Revision: %3</nobr>", "USB filter tooltip").arg(strRevision); 305 306 const QString strProduct = m_strProduct; 307 if (!strProduct.isEmpty()) 308 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + UIMachineSettingsUSB::tr("<nobr>Product: %4</nobr>", "USB filter tooltip").arg(strProduct); 309 310 const QString strManufacturer = m_strManufacturer; 311 if (!strManufacturer.isEmpty()) 312 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + UIMachineSettingsUSB::tr("<nobr>Manufacturer: %5</nobr>", "USB filter tooltip").arg(strManufacturer); 313 314 const QString strSerial = m_strSerialNumber; 315 if (!strSerial.isEmpty()) 316 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + UIMachineSettingsUSB::tr("<nobr>Serial No.: %1</nobr>", "USB filter tooltip").arg(strSerial); 317 318 const QString strPort = m_strPort; 319 if (!strPort.isEmpty()) 320 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + UIMachineSettingsUSB::tr("<nobr>Port: %1</nobr>", "USB filter tooltip").arg(strPort); 321 322 /* Add the state field if it's a host USB device: */ 323 if (m_fHostUSBDevice) 324 { 325 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + UIMachineSettingsUSB::tr("<nobr>State: %1</nobr>", "USB filter tooltip") 326 .arg(gpConverter->toString(m_enmHostUSBDeviceState)); 327 } 328 329 /* Return tool-tip: */ 330 return strToolTip; 291 331 } 292 332 }; … … 398 438 /* For each USB filter => load it to the page: */ 399 439 for (int iFilterIndex = 0; iFilterIndex < m_pCache->childCount(); ++iFilterIndex) 400 addUSBFilter (m_pCache->child(iFilterIndex).base(), false /* its new? */);440 addUSBFilterItem(m_pCache->child(iFilterIndex).base(), false /* its new? */); 401 441 402 442 /* Choose first filter as current: */ … … 747 787 usbFilterData.m_fHostUSBDevice = false; 748 788 749 /* Add new USB filter data: */750 addUSBFilter (usbFilterData, true /* its new? */);789 /* Add new USB filter item: */ 790 addUSBFilterItem(usbFilterData, true /* its new? */); 751 791 752 792 /* Revalidate: */ … … 786 826 usbFilterData.m_strRemote = QString::number(usb.GetRemote()); 787 827 788 /* Add new USB filter data: */789 addUSBFilter (usbFilterData, true /* its new? */);828 /* Add new USB filter item: */ 829 addUSBFilterItem(usbFilterData, true /* its new? */); 790 830 791 831 /* Revalidate: */ … … 835 875 default: AssertMsgFailed(("Invalid combo box index")); 836 876 } 837 pItem->setText(0, pItem->m_strName); 838 pItem->setToolTip(0, toolTipFor(*pItem)); 877 pItem->updateFields(); 839 878 } 840 879 } … … 1033 1072 } 1034 1073 1035 void UIMachineSettingsUSB::addUSBFilter (const UIDataSettingsMachineUSBFilter &usbFilterData, bool fChoose)1074 void UIMachineSettingsUSB::addUSBFilterItem(const UIDataSettingsMachineUSBFilter &filterData, bool fChoose) 1036 1075 { 1037 1076 /* Create USB filter item: */ 1038 UIUSBFilterItem *pItem = new UIUSBFilterItem ;1077 UIUSBFilterItem *pItem = new UIUSBFilterItem(mTwFilters); 1039 1078 AssertPtrReturnVoid(pItem); 1040 1079 { 1041 1080 /* Configure item: */ 1042 pItem->setCheckState(0, usbFilterData.m_fActive ? Qt::Checked : Qt::Unchecked); 1043 pItem->setText(0, usbFilterData.m_strName); 1044 pItem->setToolTip(0, toolTipFor(usbFilterData)); 1045 pItem->loadUSBFilterData(usbFilterData); 1046 1047 /* Append tree-widget with item: */ 1048 mTwFilters->addTopLevelItem(pItem); 1081 pItem->setCheckState(0, filterData.m_fActive ? Qt::Checked : Qt::Unchecked); 1082 pItem->m_strName = filterData.m_strName; 1083 pItem->m_strVendorId = filterData.m_strVendorId; 1084 pItem->m_strProductId = filterData.m_strProductId; 1085 pItem->m_strRevision = filterData.m_strRevision; 1086 pItem->m_strManufacturer = filterData.m_strManufacturer; 1087 pItem->m_strProduct = filterData.m_strProduct; 1088 pItem->m_strSerialNumber = filterData.m_strSerialNumber; 1089 pItem->m_strPort = filterData.m_strPort; 1090 pItem->m_strRemote = filterData.m_strRemote; 1091 pItem->m_enmAction = filterData.m_enmAction; 1092 pItem->m_fHostUSBDevice = filterData.m_fHostUSBDevice; 1093 pItem->m_enmHostUSBDeviceState = filterData.m_enmHostUSBDeviceState; 1094 pItem->updateFields(); 1049 1095 1050 1096 /* Select this item if it's new: */ 1051 1097 if (fChoose) 1098 { 1099 mTwFilters->scrollToItem(pItem); 1052 1100 mTwFilters->setCurrentItem(pItem); 1053 } 1054 } 1055 1056 /* static */ 1057 QString UIMachineSettingsUSB::toolTipFor(const UIDataSettingsMachineUSBFilter &usbFilterData) 1058 { 1059 /* Prepare tool-tip: */ 1060 QString strToolTip; 1061 1062 const QString strVendorId = usbFilterData.m_strVendorId; 1063 if (!strVendorId.isEmpty()) 1064 strToolTip += tr("<nobr>Vendor ID: %1</nobr>", "USB filter tooltip").arg(strVendorId); 1065 1066 const QString strProductId = usbFilterData.m_strProductId; 1067 if (!strProductId.isEmpty()) 1068 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + tr("<nobr>Product ID: %2</nobr>", "USB filter tooltip").arg(strProductId); 1069 1070 const QString strRevision = usbFilterData.m_strRevision; 1071 if (!strRevision.isEmpty()) 1072 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + tr("<nobr>Revision: %3</nobr>", "USB filter tooltip").arg(strRevision); 1073 1074 const QString strProduct = usbFilterData.m_strProduct; 1075 if (!strProduct.isEmpty()) 1076 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + tr("<nobr>Product: %4</nobr>", "USB filter tooltip").arg(strProduct); 1077 1078 const QString strManufacturer = usbFilterData.m_strManufacturer; 1079 if (!strManufacturer.isEmpty()) 1080 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + tr("<nobr>Manufacturer: %5</nobr>", "USB filter tooltip").arg(strManufacturer); 1081 1082 const QString strSerial = usbFilterData.m_strSerialNumber; 1083 if (!strSerial.isEmpty()) 1084 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + tr("<nobr>Serial No.: %1</nobr>", "USB filter tooltip").arg(strSerial); 1085 1086 const QString strPort = usbFilterData.m_strPort; 1087 if (!strPort.isEmpty()) 1088 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + tr("<nobr>Port: %1</nobr>", "USB filter tooltip").arg(strPort); 1089 1090 /* Add the state field if it's a host USB device: */ 1091 if (usbFilterData.m_fHostUSBDevice) 1092 { 1093 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + tr("<nobr>State: %1</nobr>", "USB filter tooltip") 1094 .arg(gpConverter->toString(usbFilterData.m_enmHostUSBDeviceState)); 1095 } 1096 1097 return strToolTip; 1101 sltHandleCurrentItemChange(pItem); 1102 } 1103 } 1098 1104 } 1099 1105 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.h
r66410 r66455 94 94 void sltHandleActivityStateChange(QTreeWidgetItem *pChangedItem); 95 95 96 /** Handles command to add new filter. */96 /** Handles command to add new USB filter. */ 97 97 void sltNewFilter(); 98 /** Handles command to add existing filter. */98 /** Handles command to add existing USB filter. */ 99 99 void sltAddFilter(); 100 /** Handles command to edit filter. */100 /** Handles command to edit USB filter. */ 101 101 void sltEditFilter(); 102 /** Handles command to confirm add of existing filter defined by @a pAction. */102 /** Handles command to confirm add of existing USB filter defined by @a pAction. */ 103 103 void sltAddFilterConfirmed(QAction *pAction); 104 /** Handles command to remove chosen filter. */104 /** Handles command to remove chosen USB filter. */ 105 105 void sltRemoveFilter(); 106 /** Handles command to move chosen filter up. */106 /** Handles command to move chosen USB filter up. */ 107 107 void sltMoveFilterUp(); 108 /** Handles command to move chosen filter down. */108 /** Handles command to move chosen USB filter down. */ 109 109 void sltMoveFilterDown(); 110 110 … … 122 122 void cleanup(); 123 123 124 /** Adds USB filter item based on a given @a usbFilterData, fChoose if requested. */125 void addUSBFilter (const UIDataSettingsMachineUSBFilter &usbFilterData, bool fChoose);124 /** Adds USB filter item based on a given @a filterData, fChoose if requested. */ 125 void addUSBFilterItem(const UIDataSettingsMachineUSBFilter &filterData, bool fChoose); 126 126 127 127 /** Returns the multi-line description of the given USB filter. */
Note:
See TracChangeset
for help on using the changeset viewer.

