VirtualBox

Changeset 87220 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 12, 2021 7:56:08 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9871: Network Manager: A bit of cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.cpp

    r87219 r87220  
    4848
    4949
    50 /** Tree-widget column tags. */
    51 enum
    52 {
    53     Column_Name,
    54     Column_IPv4,
    55     Column_IPv6,
    56     Column_DHCP,
    57     Column_Max,
     50/** Host network tree-widget column indexes. */
     51enum HostNetworkColumn
     52{
     53    HostNetworkColumn_Name,
     54    HostNetworkColumn_IPv4,
     55    HostNetworkColumn_IPv6,
     56    HostNetworkColumn_DHCP,
     57    HostNetworkColumn_Max,
    5858};
    5959
     
    8686{
    8787    /* Compose item fields: */
    88     setText(Column_Name, m_interface.m_strName);
    89     setText(Column_IPv4, m_interface.m_strAddress.isEmpty() ? QString() :
    90                          QString("%1/%2").arg(m_interface.m_strAddress).arg(maskToCidr(m_interface.m_strMask)));
    91     setText(Column_IPv6, m_interface.m_strAddress6.isEmpty() || !m_interface.m_fSupportedIPv6 ? QString() :
    92                          QString("%1/%2").arg(m_interface.m_strAddress6).arg(m_interface.m_strPrefixLength6.toInt()));
    93     setText(Column_DHCP, tr("Enable", "DHCP Server"));
    94     setCheckState(Column_DHCP, m_dhcpserver.m_fEnabled ? Qt::Checked : Qt::Unchecked);
     88    setText(HostNetworkColumn_Name, m_interface.m_strName);
     89    setText(HostNetworkColumn_IPv4, m_interface.m_strAddress.isEmpty() ? QString() :
     90                                    QString("%1/%2").arg(m_interface.m_strAddress).arg(maskToCidr(m_interface.m_strMask)));
     91    setText(HostNetworkColumn_IPv6, m_interface.m_strAddress6.isEmpty() || !m_interface.m_fSupportedIPv6 ? QString() :
     92                                    QString("%1/%2").arg(m_interface.m_strAddress6).arg(m_interface.m_strPrefixLength6.toInt()));
     93    setText(HostNetworkColumn_DHCP, tr("Enable", "DHCP Server"));
     94    setCheckState(HostNetworkColumn_DHCP, m_dhcpserver.m_fEnabled ? Qt::Checked : Qt::Unchecked);
    9595
    9696    /* Compose item tool-tip: */
     
    151151
    152152    /* Assign tool-tip finally: */
    153     setToolTip(Column_Name, strTable.arg(strToolTip));
     153    setToolTip(HostNetworkColumn_Name, strTable.arg(strToolTip));
    154154}
    155155
     
    302302    /* Create interface: */
    303303    CHostNetworkInterface comInterface;
    304     CProgress progress = comHost.CreateHostOnlyNetworkInterface(comInterface);
     304    CProgress comProgress = comHost.CreateHostOnlyNetworkInterface(comInterface);
    305305
    306306    /* Show error message if necessary: */
    307     if (!comHost.isOk() || progress.isNull())
     307    if (!comHost.isOk() || comProgress.isNull())
    308308        msgCenter().cannotCreateHostNetworkInterface(comHost, this);
    309309    else
    310310    {
    311311        /* Show interface creation progress: */
    312         msgCenter().showModalProgressDialog(progress, UINetworkManager::tr("Adding network ..."), ":/progress_network_interface_90px.png", this, 0);
     312        msgCenter().showModalProgressDialog(comProgress, UINetworkManager::tr("Adding network ..."), ":/progress_network_interface_90px.png", this, 0);
    313313
    314314        /* Show error message if necessary: */
    315         if (!progress.isOk() || progress.GetResultCode() != 0)
    316             msgCenter().cannotCreateHostNetworkInterface(progress, this);
     315        if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     316            msgCenter().cannotCreateHostNetworkInterface(comProgress, this);
    317317        else
    318318        {
     
    406406
    407407            /* Remove interface finally: */
    408             CProgress progress = comHost.RemoveHostOnlyNetworkInterface(uInterfaceId);
     408            CProgress comProgress = comHost.RemoveHostOnlyNetworkInterface(uInterfaceId);
    409409
    410410            /* Show error message if necessary: */
    411             if (!comHost.isOk() || progress.isNull())
     411            if (!comHost.isOk() || comProgress.isNull())
    412412                msgCenter().cannotRemoveHostNetworkInterface(comHost, strInterfaceName, this);
    413413            else
    414414            {
    415415                /* Show interface removal progress: */
    416                 msgCenter().showModalProgressDialog(progress, UINetworkManager::tr("Removing network ..."), ":/progress_network_interface_90px.png", this, 0);
     416                msgCenter().showModalProgressDialog(comProgress, UINetworkManager::tr("Removing network ..."), ":/progress_network_interface_90px.png", this, 0);
    417417
    418418                /* Show error message if necessary: */
    419                 if (!progress.isOk() || progress.GetResultCode() != 0)
    420                     return msgCenter().cannotRemoveHostNetworkInterface(progress, strInterfaceName, this);
     419                if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     420                    return msgCenter().cannotRemoveHostNetworkInterface(comProgress, strInterfaceName, this);
    421421                else
    422422                {
     
    432432}
    433433
    434 void UINetworkManagerWidget::sltToggleDetailsVisibilityHostNetwork(bool fVisible)
     434void UINetworkManagerWidget::sltToggleDetailsVisibility(bool fVisible)
    435435{
    436436    /* Save the setting: */
     
    440440        m_pDetailsWidgetHostNetwork->setVisible(fVisible);
    441441    /* Notify external listeners: */
    442     emit sigDetailsVisibilityChangedHostNetwork(fVisible);
    443 }
    444 
    445 void UINetworkManagerWidget::sltRefreshHostNetworks()
    446 {
    447     // Not implemented.
    448     AssertMsgFailed(("Not implemented!"));
     442    emit sigDetailsVisibilityChanged(fVisible);
    449443}
    450444
     
    462456        const int iTotal = m_pTreeWidgetHostNetwork->viewport()->width();
    463457        /* Look for a minimum width hints for non-important columns: */
    464         const int iMinWidth1 = qMax(pItemView->sizeHintForColumn(Column_IPv4), pItemHeader->sectionSizeHint(Column_IPv4));
    465         const int iMinWidth2 = qMax(pItemView->sizeHintForColumn(Column_IPv6), pItemHeader->sectionSizeHint(Column_IPv6));
    466         const int iMinWidth3 = qMax(pItemView->sizeHintForColumn(Column_DHCP), pItemHeader->sectionSizeHint(Column_DHCP));
     458        const int iMinWidth1 = qMax(pItemView->sizeHintForColumn(HostNetworkColumn_IPv4), pItemHeader->sectionSizeHint(HostNetworkColumn_IPv4));
     459        const int iMinWidth2 = qMax(pItemView->sizeHintForColumn(HostNetworkColumn_IPv6), pItemHeader->sectionSizeHint(HostNetworkColumn_IPv6));
     460        const int iMinWidth3 = qMax(pItemView->sizeHintForColumn(HostNetworkColumn_DHCP), pItemHeader->sectionSizeHint(HostNetworkColumn_DHCP));
    467461        /* Propose suitable width hints for non-important columns: */
    468         const int iWidth1 = iMinWidth1 < iTotal / Column_Max ? iMinWidth1 : iTotal / Column_Max;
    469         const int iWidth2 = iMinWidth2 < iTotal / Column_Max ? iMinWidth2 : iTotal / Column_Max;
    470         const int iWidth3 = iMinWidth3 < iTotal / Column_Max ? iMinWidth3 : iTotal / Column_Max;
     462        const int iWidth1 = iMinWidth1 < iTotal / HostNetworkColumn_Max ? iMinWidth1 : iTotal / HostNetworkColumn_Max;
     463        const int iWidth2 = iMinWidth2 < iTotal / HostNetworkColumn_Max ? iMinWidth2 : iTotal / HostNetworkColumn_Max;
     464        const int iWidth3 = iMinWidth3 < iTotal / HostNetworkColumn_Max ? iMinWidth3 : iTotal / HostNetworkColumn_Max;
    471465        /* Apply the proposal: */
    472         m_pTreeWidgetHostNetwork->setColumnWidth(Column_IPv4, iWidth1);
    473         m_pTreeWidgetHostNetwork->setColumnWidth(Column_IPv6, iWidth2);
    474         m_pTreeWidgetHostNetwork->setColumnWidth(Column_DHCP, iWidth3);
    475         m_pTreeWidgetHostNetwork->setColumnWidth(Column_Name, iTotal - iWidth1 - iWidth2 - iWidth3);
     466        m_pTreeWidgetHostNetwork->setColumnWidth(HostNetworkColumn_IPv4, iWidth1);
     467        m_pTreeWidgetHostNetwork->setColumnWidth(HostNetworkColumn_IPv6, iWidth2);
     468        m_pTreeWidgetHostNetwork->setColumnWidth(HostNetworkColumn_DHCP, iWidth3);
     469        m_pTreeWidgetHostNetwork->setColumnWidth(HostNetworkColumn_Name, iTotal - iWidth1 - iWidth2 - iWidth3);
    476470    }
    477471}
     
    488482    /* Make sure dhcp server status changed: */
    489483    if (   (   oldData.m_dhcpserver.m_fEnabled
    490             && pChangedItem->checkState(Column_DHCP) == Qt::Checked)
     484            && pChangedItem->checkState(HostNetworkColumn_DHCP) == Qt::Checked)
    491485        || (   !oldData.m_dhcpserver.m_fEnabled
    492             && pChangedItem->checkState(Column_DHCP) == Qt::Unchecked))
     486            && pChangedItem->checkState(HostNetworkColumn_DHCP) == Qt::Unchecked))
    493487        return;
    494488
     
    583577        /* Otherwise => clear details and close the area: */
    584578        m_pDetailsWidgetHostNetwork->setData(UIDataHostNetwork());
    585         sltToggleDetailsVisibilityHostNetwork(false);
     579        sltToggleDetailsVisibility(false);
    586580    }
    587581}
     
    767761            this, &UINetworkManagerWidget::sltRemoveHostNetwork);
    768762    connect(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details), &QAction::toggled,
    769             this, &UINetworkManagerWidget::sltToggleDetailsVisibilityHostNetwork);
    770     connect(m_pActionPool->action(UIActionIndexMN_M_Network_S_Refresh), &QAction::triggered,
    771             this, &UINetworkManagerWidget::sltRefreshHostNetworks);
     763            this, &UINetworkManagerWidget::sltToggleDetailsVisibility);
    772764}
    773765
     
    810802        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexMN_M_Network_S_Remove));
    811803        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details));
    812 //        m_pToolBar->addSeparator();
    813 //        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexMN_M_Network_S_Refresh));
    814804
    815805#ifdef VBOX_WS_MAC
     
    869859        m_pTreeWidgetHostNetwork->setContextMenuPolicy(Qt::CustomContextMenu);
    870860        m_pTreeWidgetHostNetwork->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    871         m_pTreeWidgetHostNetwork->setColumnCount(Column_Max);
     861        m_pTreeWidgetHostNetwork->setColumnCount(HostNetworkColumn_Max);
    872862        m_pTreeWidgetHostNetwork->setSortingEnabled(true);
    873         m_pTreeWidgetHostNetwork->sortByColumn(Column_Name, Qt::AscendingOrder);
     863        m_pTreeWidgetHostNetwork->sortByColumn(HostNetworkColumn_Name, Qt::AscendingOrder);
    874864        m_pTreeWidgetHostNetwork->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
    875865        connect(m_pTreeWidgetHostNetwork, &QITreeWidget::currentItemChanged,
     
    913903    {
    914904        m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->setChecked(gEDataManager->hostNetworkManagerDetailsExpanded());
    915         sltToggleDetailsVisibilityHostNetwork(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->isChecked());
     905        sltToggleDetailsVisibility(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->isChecked());
    916906    }
    917907}
     
    11381128{
    11391129    /* Configure button-box: */
    1140     connect(widget(), &UINetworkManagerWidget::sigDetailsVisibilityChangedHostNetwork,
     1130    connect(widget(), &UINetworkManagerWidget::sigDetailsVisibilityChanged,
    11411131            button(ButtonType_Apply), &QPushButton::setVisible);
    1142     connect(widget(), &UINetworkManagerWidget::sigDetailsVisibilityChangedHostNetwork,
     1132    connect(widget(), &UINetworkManagerWidget::sigDetailsVisibilityChanged,
    11431133            button(ButtonType_Reset), &QPushButton::setVisible);
    11441134    connect(widget(), &UINetworkManagerWidget::sigDetailsDataChangedHostNetwork,
  • trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.h

    r87219 r87220  
    5151signals:
    5252
    53     /** Notifies listeners about host network details-widget @a fVisible. */
    54     void sigDetailsVisibilityChangedHostNetwork(bool fVisible);
     53    /** Notifies listeners about details-widget @a fVisible. */
     54    void sigDetailsVisibilityChanged(bool fVisible);
     55
    5556    /** Notifies listeners about host network details data @a fDiffers. */
    5657    void sigDetailsDataChangedHostNetwork(bool fDiffers);
     
    105106        /** Handles command to remove host network. */
    106107        void sltRemoveHostNetwork();
    107         /** Handles command to make host network details @a fVisible. */
    108         void sltToggleDetailsVisibilityHostNetwork(bool fVisible);
    109         /** Handles command to refresh host networks. */
    110         void sltRefreshHostNetworks();
     108
     109        /** Handles command to make details @a fVisible. */
     110        void sltToggleDetailsVisibility(bool fVisible);
    111111    /** @} */
    112112
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