- Timestamp:
- Apr 27, 2007 2:42:49 PM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/ui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui
r2354 r2400 1223 1223 <variable access="private">QString warningString;</variable> 1224 1224 <variable access="private">QWidgetStack *wstUSBFilters;</variable> 1225 <variable access="private">ulong mLastUSBFilterNum;</variable>1226 1225 <variable access="private">bool mUSBFilterListModified;</variable> 1227 1226 <variable access="private">VBoxUSBMenu *usbDevicesMenu;</variable> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui.h
r2354 r2400 386 386 usbDevicesMenu = new VBoxUSBMenu (this); 387 387 connect (usbDevicesMenu, SIGNAL(activated(int)), this, SLOT(menuAddUSBFilterFrom_activated(int))); 388 mLastUSBFilterNum = 0;389 388 mUSBFilterListModified = false; 390 389 … … 863 862 void VBoxGlobalSettingsDlg::tbAddUSBFilter_clicked() 864 863 { 865 CHost host = vboxGlobal().virtualBox().GetHost(); 864 /* search for the max available filter index */ 865 int maxFilterIndex = 0; 866 QString usbFilterName = tr ("New Filter %1", "usb"); 867 QRegExp regExp (QString ("^") + usbFilterName.arg ("([0-9]+)") + QString ("$")); 868 QListViewItemIterator iterator (lvUSBFilters); 869 while (*iterator) 870 { 871 QString filterName = (*iterator)->text (lvUSBFilters_Name); 872 int pos = regExp.search (filterName); 873 if (pos != -1) 874 maxFilterIndex = regExp.cap (1).toInt() > maxFilterIndex ? 875 regExp.cap (1).toInt() : maxFilterIndex; 876 ++ iterator; 877 } 878 879 /* creating new usb filter */ 866 880 CHostUSBDeviceFilter hostFilter; 867 host.CreateUSBDeviceFilter (tr ("New Filter %1", "usb")868 .arg (++ mLastUSBFilterNum), hostFilter);881 vboxGlobal().virtualBox().GetHost().CreateUSBDeviceFilter ( 882 usbFilterName.arg (maxFilterIndex + 1), hostFilter); 869 883 hostFilter.SetAction (CEnums::USBDeviceFilterHold); 870 884 -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMNetworkSettings.ui
r2394 r2400 769 769 <variables> 770 770 <variable access="private">CNetworkAdapter cadapter;</variable> 771 <variable access="private">int mInterfaceNumber;</variable>772 771 <variable access="private">QIWidgetValidator *mWalidator;</variable> 773 772 <variable access="private">QString mNoInterfaces;</variable> … … 788 787 <functions> 789 788 <function access="private" specifier="non virtual">init()</function> 790 <function>loadList( const QStringList & , int)</function>789 <function>loadList( const QStringList & )</function> 791 790 <function>getFromAdapter( const CNetworkAdapter & )</function> 792 791 <function>putBackToAdapter()</function> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMNetworkSettings.ui.h
r2394 r2400 104 104 void VBoxVMNetworkSettings::init() 105 105 { 106 mInterfaceNumber = 0;107 106 mNoInterfaces = tr ("<No suitable interfaces>"); 108 107 … … 171 170 } 172 171 173 void VBoxVMNetworkSettings::loadList (const QStringList &aList, 174 int aInterfaceNumber) 175 { 176 #if defined Q_WS_WIN 177 mInterfaceNumber = aInterfaceNumber; 172 void VBoxVMNetworkSettings::loadList (const QStringList &aList) 173 { 174 #if defined Q_WS_WIN 178 175 /* save current list item name */ 179 176 QString currentListItemName = leHostInterfaceName->text(); … … 190 187 #else 191 188 NOREF (aList); 192 NOREF (aInterfaceNumber);193 189 #endif 194 190 } … … 394 390 AllowSetForegroundWindow (ASFW_ANY); 395 391 392 /* search for the max available interface index */ 393 int ifaceNumber = 0; 394 QString ifaceName = tr ("VirtualBox Host Interface %1"); 395 QRegExp regExp (QString ("^") + ifaceName.arg ("([0-9]+)") + QString ("$")); 396 for (uint index = 0; index < lbHostInterface->count(); ++ index) 397 { 398 QString iface = lbHostInterface->text (index); 399 int pos = regExp.search (iface); 400 if (pos != -1) 401 ifaceNumber = regExp.cap (1).toInt() > ifaceNumber ? 402 regExp.cap (1).toInt() : ifaceNumber; 403 } 404 396 405 /* creating add host interface dialog */ 397 VBoxAddNIDialog dlg (this, lbHostInterface->currentItem() != -1 ? 398 tr ("VirtualBox Host Interface %1").arg (mInterfaceNumber) : 399 leHostInterfaceName->text()); 406 VBoxAddNIDialog dlg (this, ifaceName.arg (ifaceNumber + 1)); 400 407 if (dlg.exec() != QDialog::Accepted) 401 408 return; … … 411 418 if (progress.GetResultCode() == 0) 412 419 { 413 ++ mInterfaceNumber;414 420 /* add&select newly created created interface */ 415 421 delete lbHostInterface->findItem (mNoInterfaces); 416 422 lbHostInterface->insertItem (iName); 417 423 selectListItem (iName); 424 pbHostRemove->setEnabled (true); 418 425 emit listChanged (this); 419 426 } … … 469 476 { 470 477 if (lbHostInterface->count() == 1) 478 { 471 479 lbHostInterface->insertItem (mNoInterfaces); 480 pbHostRemove->setEnabled (false); 481 } 472 482 delete lbHostInterface->findItem (iName); 473 483 emit listChanged (this); -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui
r2394 r2400 2771 2771 <variable access="private">CMachine cmachine;</variable> 2772 2772 <variable access="private">QStringList mInterfaceList;</variable> 2773 <variable access="private">int mInterfaceNumber;</variable>2774 2773 <variable access="private">QWidgetStack *wstUSBFilters;</variable> 2775 <variable access="private">ulong mLastUSBFilterNum;</variable>2776 2774 <variable access="private">bool mUSBFilterListModified;</variable> 2777 <variable access="private">QString mUSBFilterNamePrefix;</variable>2778 2775 <variable access="private">QTabWidget* tbwNetwork;</variable> 2779 2776 <variable access="private">VBoxSharedFoldersSettings* mSharedFolders;</variable> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h
r2394 r2400 628 628 usbDevicesMenu = new VBoxUSBMenu (this); 629 629 connect (usbDevicesMenu, SIGNAL(activated(int)), this, SLOT(menuAddUSBFilterFrom_activated(int))); 630 mLastUSBFilterNum = 0;631 630 mUSBFilterListModified = false; 632 mUSBFilterNamePrefix = tr ("New Filter ", "usb");633 631 634 632 /* VRDP Page */ … … 851 849 set->revalidate(); 852 850 } 853 /* searching for max interface index */854 QString interfacePrefix = tr ("VirtualBox Host Interface ");855 QRegExp regExp (QString ("%1(\\d+)").arg (interfacePrefix));856 QStringList list = mInterfaceList.grep (regExp);857 int max = 0;858 for (QStringList::Iterator it = list.begin(); it != list.end(); ++ it)859 {860 int pos = regExp.search (*it);861 if (pos != -1)862 max = regExp.cap (1).toInt() > max ? regExp.cap (1).toInt() : max;863 }864 mInterfaceNumber = ++ max;865 851 #else 866 852 NOREF (aWidget); … … 874 860 updateInterfaces (0); 875 861 VBoxVMNetworkSettings *set = static_cast<VBoxVMNetworkSettings*> (aWidget); 876 set->loadList (mInterfaceList , mInterfaceNumber);862 set->loadList (mInterfaceList); 877 863 set->revalidate(); 878 864 #endif … … 1477 1463 1478 1464 CUSBDeviceFilterEnumerator en = ctl.GetDeviceFilters().Enumerate(); 1479 /* loading filters & searching for max filter index */1480 int max = 0;1481 1465 while (en.HasMore()) 1482 { 1483 const CUSBDeviceFilter &filter = en.GetNext(); 1484 QRegExp regExp (QString ("%1(\\d+)").arg (mUSBFilterNamePrefix)); 1485 int pos = regExp.search (filter.GetName()); 1486 if (pos != -1) 1487 max = regExp.cap (1).toInt() > max ? 1488 regExp.cap (1).toInt() : max; 1489 addUSBFilter (filter, false /* isNew */); 1490 } 1491 mLastUSBFilterNum = max; 1466 addUSBFilter (en.GetNext(), false /* isNew */); 1492 1467 1493 1468 lvUSBFilters->setCurrentItem (lvUSBFilters->firstChild()); … … 1807 1782 { 1808 1783 VBoxVMNetworkSettings *page = new VBoxVMNetworkSettings(); 1809 page->loadList (mInterfaceList , mInterfaceNumber);1784 page->loadList (mInterfaceList); 1810 1785 page->getFromAdapter (aAdapter); 1811 1786 tbwNetwork->addTab (page, QString (tr ("Adapter %1", "network")) … … 1981 1956 void VBoxVMSettingsDlg::tbAddUSBFilter_clicked() 1982 1957 { 1958 /* search for the max available filter index */ 1959 int maxFilterIndex = 0; 1960 QString usbFilterName = tr ("New Filter %1", "usb"); 1961 QRegExp regExp (QString ("^") + usbFilterName.arg ("([0-9]+)") + QString ("$")); 1962 QListViewItemIterator iterator (lvUSBFilters); 1963 while (*iterator) 1964 { 1965 QString filterName = (*iterator)->text (lvUSBFilters_Name); 1966 int pos = regExp.search (filterName); 1967 if (pos != -1) 1968 maxFilterIndex = regExp.cap (1).toInt() > maxFilterIndex ? 1969 regExp.cap (1).toInt() : maxFilterIndex; 1970 ++ iterator; 1971 } 1972 1973 /* creating new usb filter */ 1983 1974 CUSBDeviceFilter filter = cmachine.GetUSBController() 1984 .CreateDeviceFilter (QString ("%1%2") 1985 .arg (mUSBFilterNamePrefix).arg (++ mLastUSBFilterNum)); 1975 .CreateDeviceFilter (usbFilterName.arg (maxFilterIndex + 1)); 1986 1976 1987 1977 filter.SetActive (true);
Note:
See TracChangeset
for help on using the changeset viewer.