VirtualBox

Changeset 87295 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jan 18, 2021 11:16:06 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9871: Network Manager: When applying NAT network changes or toggling availability, - port forwarding table should try to keep current position intact.

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

Legend:

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

    r87276 r87295  
    5656    , m_pForwardingTableIPv6(0)
    5757    , m_pButtonBoxForwarding(0)
     58    , m_fHoldPosition(false)
    5859{
    5960    prepare();
    6061}
    6162
    62 void UIDetailsWidgetNATNetwork::setData(const UIDataNATNetwork &data)
     63void UIDetailsWidgetNATNetwork::setData(const UIDataNATNetwork &data, bool fHoldPosition /* = false */)
    6364{
    6465    /* Cache old/new data: */
    6566    m_oldData = data;
    6667    m_newData = m_oldData;
     68    m_fHoldPosition = fHoldPosition;
    6769
    6870    /* Load 'Options' data: */
     
    495497
    496498    /* Load 'Forwarding' fields: */
    497     m_pForwardingTableIPv4->setRules(m_newData.m_rules4);
    498     m_pForwardingTableIPv6->setRules(m_newData.m_rules6);
     499    m_pForwardingTableIPv4->setRules(m_newData.m_rules4, m_fHoldPosition);
     500    m_pForwardingTableIPv6->setRules(m_newData.m_rules6, m_fHoldPosition);
     501    m_fHoldPosition = false;
    499502}
    500503
  • trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetNATNetwork.h

    r87277 r87295  
    120120    /** Returns the host network data. */
    121121    const UIDataNATNetwork &data() const { return m_newData; }
    122     /** Defines the host network @a data. */
    123     void setData(const UIDataNATNetwork &data);
     122    /** Defines the host network @a data.
     123      * @param  fHoldPosition  Holds whether we should try to keep
     124      *                        port forwarding rule position intact. */
     125    void setData(const UIDataNATNetwork &data, bool fHoldPosition = false);
    124126
    125127protected:
     
    236238        /** Holds the 'Forwarding' button-box instance. */
    237239        QIDialogButtonBox     *m_pButtonBoxForwarding;
     240        /** Holds whether we should try to keep
     241          * port forwarding rule position intact. */
     242        bool                   m_fHoldPosition;
    238243    /** @} */
    239244};
  • trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.cpp

    r87276 r87295  
    10371037            updateItemForNATNetwork(data, true, pChangedItem);
    10381038
    1039             /* Make sure current item fetched: */
    1040             sltHandleCurrentItemChangeNATNetwork();
     1039            /* Make sure current item fetched, trying to hold chosen position: */
     1040            sltHandleCurrentItemChangeNATNetworkHoldingPosition(true /* hold position? */);
    10411041
    10421042            /* Adjust tree-widgets: */
     
    10461046}
    10471047
    1048 void UINetworkManagerWidget::sltHandleCurrentItemChangeNATNetwork()
     1048void UINetworkManagerWidget::sltHandleCurrentItemChangeNATNetworkHoldingPosition(bool fHoldPosition)
    10491049{
    10501050    /* Check NAT network tree-widget: */
     
    10631063    /* If there is an item => update details data: */
    10641064    if (pItem)
    1065         m_pDetailsWidgetNATNetwork->setData(*pItem);
     1065        m_pDetailsWidgetNATNetwork->setData(*pItem, fHoldPosition);
    10661066    /* Otherwise => clear details: */
    10671067    else
    10681068        m_pDetailsWidgetNATNetwork->setData(UIDataNATNetwork());
     1069}
     1070
     1071void UINetworkManagerWidget::sltHandleCurrentItemChangeNATNetwork()
     1072{
     1073    sltHandleCurrentItemChangeNATNetworkHoldingPosition(false /* hold position? */);
    10691074}
    10701075
     
    11911196            updateItemForNATNetwork(data, true, pItem);
    11921197
    1193             /* Make sure current item fetched: */
    1194             sltHandleCurrentItemChangeNATNetwork();
     1198            /* Make sure current item fetched, trying to hold chosen position: */
     1199            sltHandleCurrentItemChangeNATNetworkHoldingPosition(true /* hold position? */);
    11951200
    11961201            /* Adjust tree-widgets: */
  • trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.h

    r87276 r87295  
    142142        /** Handles NAT network tree-widget @a pItem change. */
    143143        void sltHandleItemChangeNATNetwork(QTreeWidgetItem *pItem);
     144        /** Handles NAT network tree-widget current item change.
     145          * @param  fHoldPosition  Holds whether we should try to keep
     146          *                        port forwarding rule position intact. */
     147        void sltHandleCurrentItemChangeNATNetworkHoldingPosition(bool fHoldPosition);
    144148        /** Handles NAT network tree-widget current item change. */
    145149        void sltHandleCurrentItemChangeNATNetwork();
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.cpp

    r87274 r87295  
    795795}
    796796
    797 void UIPortForwardingTable::setRules(const UIPortForwardingDataList &newRules)
    798 {
     797void UIPortForwardingTable::setRules(const UIPortForwardingDataList &newRules,
     798                                     bool fHoldPosition /* = false */)
     799{
     800    /* Remember last chosen item: */
     801    const QModelIndex currentIndex = m_pTableView->currentIndex();
     802    QITableViewRow *pCurrentItem = currentIndex.isValid() ? m_pTableModel->childItem(currentIndex.row()) : 0;
     803    const QString strCurrentName = pCurrentItem ? pCurrentItem->childItem(0)->text() : QString();
     804
     805    /* Update the list of rules: */
    799806    m_rules = newRules;
    800807    m_pTableModel->setRules(m_rules);
    801808    sltAdjustTable();
     809
     810    /* Restore last chosen item: */
     811    if (fHoldPosition && !strCurrentName.isEmpty())
     812    {
     813        for (int i = 0; i < m_pTableModel->childCount(); ++i)
     814        {
     815            QITableViewRow *pItem = m_pTableModel->childItem(i);
     816            const QString strName = pItem ? pItem->childItem(0)->text() : QString();
     817            if (strName == strCurrentName)
     818                m_pTableView->setCurrentIndex(m_pTableModel->index(i, 0));
     819        }
     820    }
    802821}
    803822
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.h

    r87247 r87295  
    216216    /** Returns the list of port forwarding rules. */
    217217    UIPortForwardingDataList rules() const;
    218     /** Defines the list of port forwarding @a newRules. */
    219     void setRules(const UIPortForwardingDataList &newRules);
     218    /** Defines the list of port forwarding @a newRules.
     219      * @param  fHoldPosition  Holds whether we should try to keep
     220      *                        port forwarding rule position intact. */
     221    void setRules(const UIPortForwardingDataList &newRules,
     222                  bool fHoldPosition = false);
    220223
    221224    /** Validates the table. */
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