VirtualBox

Changeset 2400 in vbox for trunk


Ignore:
Timestamp:
Apr 27, 2007 2:42:49 PM (18 years ago)
Author:
vboxsync
Message:

1942: Improve automatic naming for "Add New..." UIs
Corrections taken into account.

Location:
trunk/src/VBox/Frontends/VirtualBox/ui
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui

    r2354 r2400  
    12231223    <variable access="private">QString warningString;</variable>
    12241224    <variable access="private">QWidgetStack *wstUSBFilters;</variable>
    1225     <variable access="private">ulong mLastUSBFilterNum;</variable>
    12261225    <variable access="private">bool mUSBFilterListModified;</variable>
    12271226    <variable access="private">VBoxUSBMenu *usbDevicesMenu;</variable>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui.h

    r2354 r2400  
    386386    usbDevicesMenu = new VBoxUSBMenu (this);
    387387    connect (usbDevicesMenu, SIGNAL(activated(int)), this, SLOT(menuAddUSBFilterFrom_activated(int)));
    388     mLastUSBFilterNum = 0;
    389388    mUSBFilterListModified = false;
    390389
     
    863862void VBoxGlobalSettingsDlg::tbAddUSBFilter_clicked()
    864863{
    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 */
    866880    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);
    869883    hostFilter.SetAction (CEnums::USBDeviceFilterHold);
    870884
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMNetworkSettings.ui

    r2394 r2400  
    769769<variables>
    770770    <variable access="private">CNetworkAdapter cadapter;</variable>
    771     <variable access="private">int mInterfaceNumber;</variable>
    772771    <variable access="private">QIWidgetValidator *mWalidator;</variable>
    773772    <variable access="private">QString mNoInterfaces;</variable>
     
    788787<functions>
    789788    <function access="private" specifier="non virtual">init()</function>
    790     <function>loadList( const QStringList &amp;, int )</function>
     789    <function>loadList( const QStringList &amp; )</function>
    791790    <function>getFromAdapter( const CNetworkAdapter &amp; )</function>
    792791    <function>putBackToAdapter()</function>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMNetworkSettings.ui.h

    r2394 r2400  
    104104void VBoxVMNetworkSettings::init()
    105105{
    106     mInterfaceNumber = 0;
    107106    mNoInterfaces = tr ("<No suitable interfaces>");
    108107
     
    171170}
    172171
    173 void VBoxVMNetworkSettings::loadList (const QStringList &aList,
    174                                       int aInterfaceNumber)
    175 {
    176 #if defined Q_WS_WIN
    177     mInterfaceNumber = aInterfaceNumber;
     172void VBoxVMNetworkSettings::loadList (const QStringList &aList)
     173{
     174#if defined Q_WS_WIN
    178175    /* save current list item name */
    179176    QString currentListItemName = leHostInterfaceName->text();
     
    190187#else
    191188    NOREF (aList);
    192     NOREF (aInterfaceNumber);
    193189#endif
    194190}
     
    394390    AllowSetForegroundWindow (ASFW_ANY);
    395391
     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
    396405    /* 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));
    400407    if (dlg.exec() != QDialog::Accepted)
    401408        return;
     
    411418        if (progress.GetResultCode() == 0)
    412419        {
    413             ++ mInterfaceNumber;
    414420            /* add&select newly created created interface */
    415421            delete lbHostInterface->findItem (mNoInterfaces);
    416422            lbHostInterface->insertItem (iName);
    417423            selectListItem (iName);
     424            pbHostRemove->setEnabled (true);
    418425            emit listChanged (this);
    419426        }
     
    469476            {
    470477                if (lbHostInterface->count() == 1)
     478                {
    471479                    lbHostInterface->insertItem (mNoInterfaces);
     480                    pbHostRemove->setEnabled (false);
     481                }
    472482                delete lbHostInterface->findItem (iName);
    473483                emit listChanged (this);
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui

    r2394 r2400  
    27712771    <variable access="private">CMachine cmachine;</variable>
    27722772    <variable access="private">QStringList mInterfaceList;</variable>
    2773     <variable access="private">int mInterfaceNumber;</variable>
    27742773    <variable access="private">QWidgetStack *wstUSBFilters;</variable>
    2775     <variable access="private">ulong mLastUSBFilterNum;</variable>
    27762774    <variable access="private">bool mUSBFilterListModified;</variable>
    2777     <variable access="private">QString mUSBFilterNamePrefix;</variable>
    27782775    <variable access="private">QTabWidget* tbwNetwork;</variable>
    27792776    <variable access="private">VBoxSharedFoldersSettings* mSharedFolders;</variable>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r2394 r2400  
    628628    usbDevicesMenu = new VBoxUSBMenu (this);
    629629    connect (usbDevicesMenu, SIGNAL(activated(int)), this, SLOT(menuAddUSBFilterFrom_activated(int)));
    630     mLastUSBFilterNum = 0;
    631630    mUSBFilterListModified = false;
    632     mUSBFilterNamePrefix = tr ("New Filter ", "usb");
    633631
    634632    /* VRDP Page */
     
    851849        set->revalidate();
    852850    }
    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;
    865851#else
    866852    NOREF (aWidget);
     
    874860    updateInterfaces (0);
    875861    VBoxVMNetworkSettings *set = static_cast<VBoxVMNetworkSettings*> (aWidget);
    876     set->loadList (mInterfaceList, mInterfaceNumber);
     862    set->loadList (mInterfaceList);
    877863    set->revalidate();
    878864#endif
     
    14771463
    14781464            CUSBDeviceFilterEnumerator en = ctl.GetDeviceFilters().Enumerate();
    1479             /* loading filters & searching for max filter index */
    1480             int max = 0;
    14811465            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 */);
    14921467
    14931468            lvUSBFilters->setCurrentItem (lvUSBFilters->firstChild());
     
    18071782{
    18081783    VBoxVMNetworkSettings *page = new VBoxVMNetworkSettings();
    1809     page->loadList (mInterfaceList, mInterfaceNumber);
     1784    page->loadList (mInterfaceList);
    18101785    page->getFromAdapter (aAdapter);
    18111786    tbwNetwork->addTab (page, QString (tr ("Adapter %1", "network"))
     
    19811956void VBoxVMSettingsDlg::tbAddUSBFilter_clicked()
    19821957{
     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 */
    19831974    CUSBDeviceFilter filter = cmachine.GetUSBController()
    1984         .CreateDeviceFilter (QString ("%1%2")
    1985         .arg (mUSBFilterNamePrefix).arg (++ mLastUSBFilterNum));
     1975        .CreateDeviceFilter (usbFilterName.arg (maxFilterIndex + 1));
    19861976
    19871977    filter.SetActive (true);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette