Changeset 66410 in vbox
- Timestamp:
- Apr 3, 2017 4:22:05 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp
r66345 r66410 71 71 , m_strPort(QString()) 72 72 , m_strRemote(QString()) 73 , m_action(KUSBDeviceFilterAction_Null) 73 , m_enmAction(KUSBDeviceFilterAction_Null) 74 , m_enmHostUSBDeviceState(KUSBDeviceState_NotSupported) 74 75 , m_fHostUSBDevice(false) 75 , m_hostUSBDeviceState(KUSBDeviceState_NotSupported)76 76 {} 77 77 … … 90 90 && (m_strPort == other.m_strPort) 91 91 && (m_strRemote == other.m_strRemote) 92 && (m_ action == other.m_action)93 && (m_ hostUSBDeviceState == other.m_hostUSBDeviceState)92 && (m_enmAction == other.m_enmAction) 93 && (m_enmHostUSBDeviceState == other.m_enmHostUSBDeviceState) 94 94 ; 95 95 } … … 122 122 123 123 /** Holds the USB filter action. */ 124 KUSBDeviceFilterAction m_action; 124 KUSBDeviceFilterAction m_enmAction; 125 /** Holds the USB device state. */ 126 KUSBDeviceState m_enmHostUSBDeviceState; 125 127 /** Holds whether the USB filter is host USB device. */ 126 128 bool m_fHostUSBDevice; 127 /** Holds the USB device state. */128 KUSBDeviceState m_hostUSBDeviceState;129 129 }; 130 130 … … 256 256 257 257 /** QITreeWidgetItem extension representing USB filter item. */ 258 class UIUSBFilterItem : public QITreeWidgetItem 258 class UIUSBFilterItem : public QITreeWidgetItem, public UIDataSettingsMachineUSBFilter 259 259 { 260 260 public: … … 262 262 /** Constructs USB filter item. */ 263 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; 281 } 264 282 265 283 protected: … … 304 322 void UIMachineSettingsUSB::loadToCacheFrom(QVariant &data) 305 323 { 306 /* Fetch data to properties & settings ormachine: */307 fetchData(data);324 /* Fetch data to machine: */ 325 UISettingsPageMachine::fetchData(data); 308 326 309 327 /* Clear cache initially: */ 310 328 m_pCache->clear(); 311 329 312 /* Prepare USB data: */313 UIDataSettingsMachineUSB usbData;330 /* Prepare initial USB data: */ 331 UIDataSettingsMachineUSB initialUsbData; 314 332 315 333 /* Gather USB values: */ 316 usbData.m_fUSBEnabled = !m_machine.GetUSBControllers().isEmpty();317 usbData.m_USBControllerType = m_machine.GetUSBControllerCountByType(KUSBControllerType_XHCI) > 0 ? KUSBControllerType_XHCI :318 m_machine.GetUSBControllerCountByType(KUSBControllerType_EHCI) > 0 ? KUSBControllerType_EHCI :319 m_machine.GetUSBControllerCountByType(KUSBControllerType_OHCI) > 0 ? KUSBControllerType_OHCI :320 KUSBControllerType_Null;334 initialUsbData.m_fUSBEnabled = !m_machine.GetUSBControllers().isEmpty(); 335 initialUsbData.m_USBControllerType = m_machine.GetUSBControllerCountByType(KUSBControllerType_XHCI) > 0 ? KUSBControllerType_XHCI : 336 m_machine.GetUSBControllerCountByType(KUSBControllerType_EHCI) > 0 ? KUSBControllerType_EHCI : 337 m_machine.GetUSBControllerCountByType(KUSBControllerType_OHCI) > 0 ? KUSBControllerType_OHCI : 338 KUSBControllerType_Null; 321 339 322 340 /* Check if controller is valid: */ 323 const CUSBDeviceFilters &filters = m_machine.GetUSBDeviceFilters();324 if (!filters .isNull())341 const CUSBDeviceFilters &filtersObject = m_machine.GetUSBDeviceFilters(); 342 if (!filtersObject.isNull()) 325 343 { 326 344 /* For each USB filter: */ 327 const CUSBDeviceFilterVector & coll = filters.GetDeviceFilters();328 for (int iFilterIndex = 0; iFilterIndex < coll.size(); ++iFilterIndex)345 const CUSBDeviceFilterVector &filters = filtersObject.GetDeviceFilters(); 346 for (int iFilterIndex = 0; iFilterIndex < filters.size(); ++iFilterIndex) 329 347 { 330 348 /* Prepare USB filter data: */ 331 UIDataSettingsMachineUSBFilter usbFilterData;349 UIDataSettingsMachineUSBFilter initialUsbFilterData; 332 350 333 351 /* Check if filter is valid: */ 334 const CUSBDeviceFilter &filter = coll[iFilterIndex];352 const CUSBDeviceFilter &filter = filters.at(iFilterIndex); 335 353 if (!filter.isNull()) 336 354 { 337 usbFilterData.m_fActive = filter.GetActive(); 338 usbFilterData.m_strName = filter.GetName(); 339 usbFilterData.m_strVendorId = filter.GetVendorId(); 340 usbFilterData.m_strProductId = filter.GetProductId(); 341 usbFilterData.m_strRevision = filter.GetRevision(); 342 usbFilterData.m_strManufacturer = filter.GetManufacturer(); 343 usbFilterData.m_strProduct = filter.GetProduct(); 344 usbFilterData.m_strSerialNumber = filter.GetSerialNumber(); 345 usbFilterData.m_strPort = filter.GetPort(); 346 usbFilterData.m_strRemote = filter.GetRemote(); 355 /* Gather USB filter values: */ 356 initialUsbFilterData.m_fActive = filter.GetActive(); 357 initialUsbFilterData.m_strName = filter.GetName(); 358 initialUsbFilterData.m_strVendorId = filter.GetVendorId(); 359 initialUsbFilterData.m_strProductId = filter.GetProductId(); 360 initialUsbFilterData.m_strRevision = filter.GetRevision(); 361 initialUsbFilterData.m_strManufacturer = filter.GetManufacturer(); 362 initialUsbFilterData.m_strProduct = filter.GetProduct(); 363 initialUsbFilterData.m_strSerialNumber = filter.GetSerialNumber(); 364 initialUsbFilterData.m_strPort = filter.GetPort(); 365 initialUsbFilterData.m_strRemote = filter.GetRemote(); 347 366 } 348 367 349 /* Cache USB filter data: */350 m_pCache->child(iFilterIndex).cacheInitialData( usbFilterData);368 /* Cache initial USB filter data: */ 369 m_pCache->child(iFilterIndex).cacheInitialData(initialUsbFilterData); 351 370 } 352 371 } 353 372 354 /* Cache USB data: */355 m_pCache->cacheInitialData( usbData);356 357 /* Upload properties & settings ormachine to data: */358 uploadData(data);373 /* Cache initial USB data: */ 374 m_pCache->cacheInitialData(initialUsbData); 375 376 /* Upload machine to data: */ 377 UISettingsPageMachine::uploadData(data); 359 378 } 360 379 … … 363 382 /* Clear list initially: */ 364 383 mTwFilters->clear(); 365 m_filters.clear();366 384 367 385 /* Get USB data from cache: */ 368 386 const UIDataSettingsMachineUSB &usbData = m_pCache->base(); 387 369 388 /* Load USB data to page: */ 370 389 mGbUSB->setChecked(usbData.m_fUSBEnabled); … … 396 415 void UIMachineSettingsUSB::putToCache() 397 416 { 398 /* Prepare USB data: */ 399 UIDataSettingsMachineUSB usbData = m_pCache->base(); 400 401 /* Is USB controller enabled? */ 402 usbData.m_fUSBEnabled = mGbUSB->isChecked(); 403 /* Of which type? */ 404 if (!usbData.m_fUSBEnabled) 405 usbData.m_USBControllerType = KUSBControllerType_Null; 417 /* Prepare current USB data: */ 418 UIDataSettingsMachineUSB currentUsbData; 419 420 /* Gather current USB data: */ 421 currentUsbData.m_fUSBEnabled = mGbUSB->isChecked(); 422 if (!currentUsbData.m_fUSBEnabled) 423 currentUsbData.m_USBControllerType = KUSBControllerType_Null; 406 424 else 407 425 { 408 426 if (mRbUSB1->isChecked()) 409 usbData.m_USBControllerType = KUSBControllerType_OHCI;427 currentUsbData.m_USBControllerType = KUSBControllerType_OHCI; 410 428 else if (mRbUSB2->isChecked()) 411 usbData.m_USBControllerType = KUSBControllerType_EHCI;429 currentUsbData.m_USBControllerType = KUSBControllerType_EHCI; 412 430 else if (mRbUSB3->isChecked()) 413 usbData.m_USBControllerType = KUSBControllerType_XHCI; 414 } 415 416 /* Update USB cache: */ 417 m_pCache->cacheCurrentData(usbData); 418 419 /* For each USB filter => recache USB filter data: */ 420 for (int iFilterIndex = 0; iFilterIndex < m_filters.size(); ++iFilterIndex) 421 m_pCache->child(iFilterIndex).cacheCurrentData(m_filters[iFilterIndex]); 431 currentUsbData.m_USBControllerType = KUSBControllerType_XHCI; 432 } 433 434 /* For each USB filter => cache current USB filter data: */ 435 QTreeWidgetItem *pMainRootItem = mTwFilters->invisibleRootItem(); 436 for (int iFilterIndex = 0; iFilterIndex < pMainRootItem->childCount(); ++iFilterIndex) 437 m_pCache->child(iFilterIndex).cacheCurrentData(*static_cast<UIUSBFilterItem*>(pMainRootItem->child(iFilterIndex))); 438 439 /* Cache current USB data: */ 440 m_pCache->cacheCurrentData(currentUsbData); 422 441 } 423 442 424 443 void UIMachineSettingsUSB::saveFromCacheTo(QVariant &data) 425 444 { 426 /* Fetch data to properties & settings ormachine: */427 fetchData(data);428 429 /* Check if USB data reallychanged: */445 /* Fetch data to machine: */ 446 UISettingsPageMachine::fetchData(data); 447 448 /* Check if USB data was changed: */ 430 449 if (m_pCache->wasChanged()) 431 450 { 432 451 /* Check if controller is valid: */ 433 CUSBDeviceFilters filters = m_machine.GetUSBDeviceFilters();434 if (!filters .isNull())452 CUSBDeviceFilters filtersObject = m_machine.GetUSBDeviceFilters(); 453 if (!filtersObject.isNull()) 435 454 { 436 455 /* Get USB data from cache: */ … … 439 458 if (isMachineOffline()) 440 459 { 441 ULONG cOhciCtls = m_machine.GetUSBControllerCountByType(KUSBControllerType_OHCI);442 ULONG cEhciCtls = m_machine.GetUSBControllerCountByType(KUSBControllerType_EHCI);443 ULONG cXhciCtls = m_machine.GetUSBControllerCountByType(KUSBControllerType_XHCI);460 const ULONG cOhciCtls = m_machine.GetUSBControllerCountByType(KUSBControllerType_OHCI); 461 const ULONG cEhciCtls = m_machine.GetUSBControllerCountByType(KUSBControllerType_EHCI); 462 const ULONG cXhciCtls = m_machine.GetUSBControllerCountByType(KUSBControllerType_XHCI); 444 463 445 464 /* Removing USB controllers: */ … … 447 466 { 448 467 if (cXhciCtls || cEhciCtls || cOhciCtls) 449 { 450 CUSBControllerVector ctlvec = m_machine.GetUSBControllers(); 451 for (int i = 0; i < ctlvec.size(); ++i) 452 { 453 CUSBController ctl = ctlvec[i]; 454 QString strName = ctl.GetName(); 455 m_machine.RemoveUSBController(strName); 456 } 457 } 468 foreach (const CUSBController &controller, m_machine.GetUSBControllers()) 469 m_machine.RemoveUSBController(controller.GetName()); 458 470 } 459 471 /* Creating/replacing USB controllers: */ … … 466 478 if (cXhciCtls || cEhciCtls) 467 479 { 468 CUSBControllerVector ctlvec = m_machine.GetUSBControllers(); 469 for (int i = 0; i < ctlvec.size(); ++i) 480 foreach (const CUSBController &controller, m_machine.GetUSBControllers()) 470 481 { 471 CUSBController ctl = ctlvec[i]; 472 KUSBControllerType enmType = ctl.GetType(); 482 const KUSBControllerType enmType = controller.GetType(); 473 483 if (enmType == KUSBControllerType_XHCI || enmType == KUSBControllerType_EHCI) 474 { 475 QString strName = ctl.GetName(); 476 m_machine.RemoveUSBController(strName); 477 } 484 m_machine.RemoveUSBController(controller.GetName()); 478 485 } 479 486 } … … 486 493 if (cXhciCtls) 487 494 { 488 CUSBControllerVector ctlvec = m_machine.GetUSBControllers(); 489 for (int i = 0; i < ctlvec.size(); ++i) 495 foreach (const CUSBController &controller, m_machine.GetUSBControllers()) 490 496 { 491 CUSBController ctl = ctlvec[i]; 492 KUSBControllerType enmType = ctl.GetType(); 497 const KUSBControllerType enmType = controller.GetType(); 493 498 if (enmType == KUSBControllerType_XHCI) 494 { 495 QString strName = ctl.GetName(); 496 m_machine.RemoveUSBController(strName); 497 } 499 m_machine.RemoveUSBController(controller.GetName()); 498 500 } 499 501 } … … 508 510 if (cEhciCtls || cOhciCtls) 509 511 { 510 CUSBControllerVector ctlvec = m_machine.GetUSBControllers(); 511 for (int i = 0; i < ctlvec.size(); ++i) 512 foreach (const CUSBController &controller, m_machine.GetUSBControllers()) 512 513 { 513 CUSBController ctl = ctlvec[i]; 514 KUSBControllerType enmType = ctl.GetType(); 514 const KUSBControllerType enmType = controller.GetType(); 515 515 if (enmType == KUSBControllerType_EHCI || enmType == KUSBControllerType_OHCI) 516 { 517 QString strName = ctl.GetName(); 518 m_machine.RemoveUSBController(strName); 519 } 516 m_machine.RemoveUSBController(controller.GetName()); 520 517 } 521 518 } … … 543 540 if (usbFilterCache.wasRemoved() || usbFilterCache.wasUpdated()) 544 541 { 545 filters .RemoveDeviceFilter(iOperationPosition);542 filtersObject.RemoveDeviceFilter(iOperationPosition); 546 543 if (usbFilterCache.wasRemoved()) 547 544 --iOperationPosition; … … 551 548 if (usbFilterCache.wasCreated() || usbFilterCache.wasUpdated()) 552 549 { 553 /* Get USB filter data from cache: */550 /* Get USB filter data from the cache: */ 554 551 const UIDataSettingsMachineUSBFilter &usbFilterData = usbFilterCache.data(); 555 552 /* Store USB filter data: */ 556 CUSBDeviceFilter filter = filters .CreateDeviceFilter(usbFilterData.m_strName);553 CUSBDeviceFilter filter = filtersObject.CreateDeviceFilter(usbFilterData.m_strName); 557 554 filter.SetActive(usbFilterData.m_fActive); 558 555 filter.SetVendorId(usbFilterData.m_strVendorId); … … 564 561 filter.SetPort(usbFilterData.m_strPort); 565 562 filter.SetRemote(usbFilterData.m_strRemote); 566 filters .InsertDeviceFilter(iOperationPosition, filter);563 filtersObject.InsertDeviceFilter(iOperationPosition, filter); 567 564 } 568 565 } … … 575 572 } 576 573 577 /* Upload properties & settings ormachine to data: */578 uploadData(data);574 /* Upload machine to data: */ 575 UISettingsPageMachine::uploadData(data); 579 576 } 580 577 … … 721 718 { 722 719 /* Check changed USB filter item: */ 723 Assert(pChangedItem);724 725 /* Delete corresponding items: */ 726 UIDataSettingsMachineUSBFilter &data = m_filters[mTwFilters->indexOfTopLevelItem(pChangedItem)];727 data.m_fActive = pChangedItem->checkState(0) == Qt::Checked;720 UIUSBFilterItem *pItem = static_cast<UIUSBFilterItem*>(pChangedItem); 721 AssertPtrReturnVoid(pItem); 722 723 /* Update corresponding item: */ 724 pItem->m_fActive = pItem->checkState(0) == Qt::Checked; 728 725 } 729 726 … … 798 795 void UIMachineSettingsUSB::sltEditFilter() 799 796 { 800 /* Get current USB filter item: */ 801 QTreeWidgetItem *pItem = mTwFilters->currentItem(); 802 Assert(pItem); 803 UIDataSettingsMachineUSBFilter &usbFilterData = m_filters[mTwFilters->indexOfTopLevelItem(pItem)]; 797 /* Check current USB filter item: */ 798 UIUSBFilterItem *pItem = static_cast<UIUSBFilterItem*>(mTwFilters->currentItem()); 799 AssertPtrReturnVoid(pItem); 804 800 805 801 /* Configure USB filter details dialog: */ 806 802 UIMachineSettingsUSBFilterDetails dlgFilterDetails(this); 807 dlgFilterDetails.mLeName->setText( usbFilterData.m_strName);808 dlgFilterDetails.mLeVendorID->setText( usbFilterData.m_strVendorId);809 dlgFilterDetails.mLeProductID->setText( usbFilterData.m_strProductId);810 dlgFilterDetails.mLeRevision->setText( usbFilterData.m_strRevision);811 dlgFilterDetails.mLePort->setText( usbFilterData.m_strPort);812 dlgFilterDetails.mLeManufacturer->setText( usbFilterData.m_strManufacturer);813 dlgFilterDetails.mLeProduct->setText( usbFilterData.m_strProduct);814 dlgFilterDetails.mLeSerialNo->setText( usbFilterData.m_strSerialNumber);815 QString strRemote = usbFilterData.m_strRemote.toLower();803 dlgFilterDetails.mLeName->setText(pItem->m_strName); 804 dlgFilterDetails.mLeVendorID->setText(pItem->m_strVendorId); 805 dlgFilterDetails.mLeProductID->setText(pItem->m_strProductId); 806 dlgFilterDetails.mLeRevision->setText(pItem->m_strRevision); 807 dlgFilterDetails.mLePort->setText(pItem->m_strPort); 808 dlgFilterDetails.mLeManufacturer->setText(pItem->m_strManufacturer); 809 dlgFilterDetails.mLeProduct->setText(pItem->m_strProduct); 810 dlgFilterDetails.mLeSerialNo->setText(pItem->m_strSerialNumber); 811 const QString strRemote = pItem->m_strRemote.toLower(); 816 812 if (strRemote == "yes" || strRemote == "true" || strRemote == "1") 817 813 dlgFilterDetails.mCbRemote->setCurrentIndex(ModeOn); … … 824 820 if (dlgFilterDetails.exec() == QDialog::Accepted) 825 821 { 826 usbFilterData.m_strName = dlgFilterDetails.mLeName->text().isEmpty() ? QString::null : dlgFilterDetails.mLeName->text();827 usbFilterData.m_strVendorId = dlgFilterDetails.mLeVendorID->text().isEmpty() ? QString::null : dlgFilterDetails.mLeVendorID->text();828 usbFilterData.m_strProductId = dlgFilterDetails.mLeProductID->text().isEmpty() ? QString::null : dlgFilterDetails.mLeProductID->text();829 usbFilterData.m_strRevision = dlgFilterDetails.mLeRevision->text().isEmpty() ? QString::null : dlgFilterDetails.mLeRevision->text();830 usbFilterData.m_strManufacturer = dlgFilterDetails.mLeManufacturer->text().isEmpty() ? QString::null : dlgFilterDetails.mLeManufacturer->text();831 usbFilterData.m_strProduct = dlgFilterDetails.mLeProduct->text().isEmpty() ? QString::null : dlgFilterDetails.mLeProduct->text();832 usbFilterData.m_strSerialNumber = dlgFilterDetails.mLeSerialNo->text().isEmpty() ? QString::null : dlgFilterDetails.mLeSerialNo->text();833 usbFilterData.m_strPort = dlgFilterDetails.mLePort->text().isEmpty() ? QString::null : dlgFilterDetails.mLePort->text();822 pItem->m_strName = dlgFilterDetails.mLeName->text().isEmpty() ? QString::null : dlgFilterDetails.mLeName->text(); 823 pItem->m_strVendorId = dlgFilterDetails.mLeVendorID->text().isEmpty() ? QString::null : dlgFilterDetails.mLeVendorID->text(); 824 pItem->m_strProductId = dlgFilterDetails.mLeProductID->text().isEmpty() ? QString::null : dlgFilterDetails.mLeProductID->text(); 825 pItem->m_strRevision = dlgFilterDetails.mLeRevision->text().isEmpty() ? QString::null : dlgFilterDetails.mLeRevision->text(); 826 pItem->m_strManufacturer = dlgFilterDetails.mLeManufacturer->text().isEmpty() ? QString::null : dlgFilterDetails.mLeManufacturer->text(); 827 pItem->m_strProduct = dlgFilterDetails.mLeProduct->text().isEmpty() ? QString::null : dlgFilterDetails.mLeProduct->text(); 828 pItem->m_strSerialNumber = dlgFilterDetails.mLeSerialNo->text().isEmpty() ? QString::null : dlgFilterDetails.mLeSerialNo->text(); 829 pItem->m_strPort = dlgFilterDetails.mLePort->text().isEmpty() ? QString::null : dlgFilterDetails.mLePort->text(); 834 830 switch (dlgFilterDetails.mCbRemote->currentIndex()) 835 831 { 836 case ModeAny: usbFilterData.m_strRemote = QString(); break;837 case ModeOn: usbFilterData.m_strRemote = QString::number(1); break;838 case ModeOff: usbFilterData.m_strRemote = QString::number(0); break;832 case ModeAny: pItem->m_strRemote = QString(); break; 833 case ModeOn: pItem->m_strRemote = QString::number(1); break; 834 case ModeOff: pItem->m_strRemote = QString::number(0); break; 839 835 default: AssertMsgFailed(("Invalid combo box index")); 840 836 } 841 pItem->setText(0, usbFilterData.m_strName);842 pItem->setToolTip(0, toolTipFor( usbFilterData));837 pItem->setText(0, pItem->m_strName); 838 pItem->setToolTip(0, toolTipFor(*pItem)); 843 839 } 844 840 } … … 846 842 void UIMachineSettingsUSB::sltRemoveFilter() 847 843 { 848 /* Getcurrent USB filter item: */844 /* Check current USB filter item: */ 849 845 QTreeWidgetItem *pItem = mTwFilters->currentItem(); 850 Assert (pItem);846 AssertPtrReturnVoid(pItem); 851 847 852 848 /* Delete corresponding items: */ 853 m_filters.removeAt(mTwFilters->indexOfTopLevelItem(pItem));854 849 delete pItem; 855 850 … … 863 858 void UIMachineSettingsUSB::sltMoveFilterUp() 864 859 { 860 /* Check current USB filter item: */ 865 861 QTreeWidgetItem *pItem = mTwFilters->currentItem(); 866 Assert(pItem); 867 868 const int index = mTwFilters->indexOfTopLevelItem(pItem); 869 QTreeWidgetItem *takenItem = mTwFilters->takeTopLevelItem(index); 870 Assert(pItem == takenItem); 871 mTwFilters->insertTopLevelItem(index - 1, takenItem); 872 m_filters.swap(index, index - 1); 873 874 mTwFilters->setCurrentItem(takenItem); 862 AssertPtrReturnVoid(pItem); 863 864 /* Move the item up: */ 865 const int iIndex = mTwFilters->indexOfTopLevelItem(pItem); 866 QTreeWidgetItem *pTakenItem = mTwFilters->takeTopLevelItem(iIndex); 867 Assert(pItem == pTakenItem); 868 mTwFilters->insertTopLevelItem(iIndex - 1, pTakenItem); 869 870 /* Make sure moved item still chosen: */ 871 mTwFilters->setCurrentItem(pTakenItem); 875 872 } 876 873 877 874 void UIMachineSettingsUSB::sltMoveFilterDown() 878 875 { 876 /* Check current USB filter item: */ 879 877 QTreeWidgetItem *pItem = mTwFilters->currentItem(); 880 Assert(pItem); 881 882 const int index = mTwFilters->indexOfTopLevelItem(pItem); 883 QTreeWidgetItem *takenItem = mTwFilters->takeTopLevelItem(index); 884 Assert(pItem == takenItem); 885 mTwFilters->insertTopLevelItem(index + 1, takenItem); 886 m_filters.swap(index, index + 1); 887 888 mTwFilters->setCurrentItem(takenItem); 878 AssertPtrReturnVoid(pItem); 879 880 /* Move the item down: */ 881 const int iIndex = mTwFilters->indexOfTopLevelItem(pItem); 882 QTreeWidgetItem *pTakenItem = mTwFilters->takeTopLevelItem(iIndex); 883 Assert(pItem == pTakenItem); 884 mTwFilters->insertTopLevelItem(iIndex + 1, pTakenItem); 885 886 /* Make sure moved item still chosen: */ 887 mTwFilters->setCurrentItem(pTakenItem); 889 888 } 890 889 … … 1036 1035 void UIMachineSettingsUSB::addUSBFilter(const UIDataSettingsMachineUSBFilter &usbFilterData, bool fChoose) 1037 1036 { 1038 /* Append internal list with data: */ 1039 m_filters << usbFilterData; 1040 1041 /* Append tree-widget with item: */ 1037 /* Create USB filter item: */ 1042 1038 UIUSBFilterItem *pItem = new UIUSBFilterItem; 1043 pItem->setCheckState(0, usbFilterData.m_fActive ? Qt::Checked : Qt::Unchecked); 1044 pItem->setText(0, usbFilterData.m_strName); 1045 pItem->setToolTip(0, toolTipFor(usbFilterData)); 1046 mTwFilters->addTopLevelItem(pItem); 1047 1048 /* Select this item if its new: */ 1049 if (fChoose) 1050 mTwFilters->setCurrentItem(pItem); 1039 AssertPtrReturnVoid(pItem); 1040 { 1041 /* 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); 1049 1050 /* Select this item if it's new: */ 1051 if (fChoose) 1052 mTwFilters->setCurrentItem(pItem); 1053 } 1051 1054 } 1052 1055 … … 1089 1092 { 1090 1093 strToolTip += strToolTip.isEmpty() ? "":"<br/>" + tr("<nobr>State: %1</nobr>", "USB filter tooltip") 1091 .arg(gpConverter->toString(usbFilterData.m_ hostUSBDeviceState));1094 .arg(gpConverter->toString(usbFilterData.m_enmHostUSBDeviceState)); 1092 1095 } 1093 1096 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.h
r66345 r66410 148 148 QString m_strTrUSBFilterName; 149 149 150 /** Holds the list of all USB filters. */151 QList<UIDataSettingsMachineUSBFilter> m_filters;152 153 150 /** Holds the page data cache instance. */ 154 151 UISettingsCacheMachineUSB *m_pCache;
Note:
See TracChangeset
for help on using the changeset viewer.