VirtualBox

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
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