Changeset 87295 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 18, 2021 11:16:06 AM (4 years ago)
- 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 56 56 , m_pForwardingTableIPv6(0) 57 57 , m_pButtonBoxForwarding(0) 58 , m_fHoldPosition(false) 58 59 { 59 60 prepare(); 60 61 } 61 62 62 void UIDetailsWidgetNATNetwork::setData(const UIDataNATNetwork &data )63 void UIDetailsWidgetNATNetwork::setData(const UIDataNATNetwork &data, bool fHoldPosition /* = false */) 63 64 { 64 65 /* Cache old/new data: */ 65 66 m_oldData = data; 66 67 m_newData = m_oldData; 68 m_fHoldPosition = fHoldPosition; 67 69 68 70 /* Load 'Options' data: */ … … 495 497 496 498 /* 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; 499 502 } 500 503 -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetNATNetwork.h
r87277 r87295 120 120 /** Returns the host network data. */ 121 121 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); 124 126 125 127 protected: … … 236 238 /** Holds the 'Forwarding' button-box instance. */ 237 239 QIDialogButtonBox *m_pButtonBoxForwarding; 240 /** Holds whether we should try to keep 241 * port forwarding rule position intact. */ 242 bool m_fHoldPosition; 238 243 /** @} */ 239 244 }; -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.cpp
r87276 r87295 1037 1037 updateItemForNATNetwork(data, true, pChangedItem); 1038 1038 1039 /* Make sure current item fetched : */1040 sltHandleCurrentItemChangeNATNetwork ();1039 /* Make sure current item fetched, trying to hold chosen position: */ 1040 sltHandleCurrentItemChangeNATNetworkHoldingPosition(true /* hold position? */); 1041 1041 1042 1042 /* Adjust tree-widgets: */ … … 1046 1046 } 1047 1047 1048 void UINetworkManagerWidget::sltHandleCurrentItemChangeNATNetwork ()1048 void UINetworkManagerWidget::sltHandleCurrentItemChangeNATNetworkHoldingPosition(bool fHoldPosition) 1049 1049 { 1050 1050 /* Check NAT network tree-widget: */ … … 1063 1063 /* If there is an item => update details data: */ 1064 1064 if (pItem) 1065 m_pDetailsWidgetNATNetwork->setData(*pItem );1065 m_pDetailsWidgetNATNetwork->setData(*pItem, fHoldPosition); 1066 1066 /* Otherwise => clear details: */ 1067 1067 else 1068 1068 m_pDetailsWidgetNATNetwork->setData(UIDataNATNetwork()); 1069 } 1070 1071 void UINetworkManagerWidget::sltHandleCurrentItemChangeNATNetwork() 1072 { 1073 sltHandleCurrentItemChangeNATNetworkHoldingPosition(false /* hold position? */); 1069 1074 } 1070 1075 … … 1191 1196 updateItemForNATNetwork(data, true, pItem); 1192 1197 1193 /* Make sure current item fetched : */1194 sltHandleCurrentItemChangeNATNetwork ();1198 /* Make sure current item fetched, trying to hold chosen position: */ 1199 sltHandleCurrentItemChangeNATNetworkHoldingPosition(true /* hold position? */); 1195 1200 1196 1201 /* Adjust tree-widgets: */ -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.h
r87276 r87295 142 142 /** Handles NAT network tree-widget @a pItem change. */ 143 143 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); 144 148 /** Handles NAT network tree-widget current item change. */ 145 149 void sltHandleCurrentItemChangeNATNetwork(); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.cpp
r87274 r87295 795 795 } 796 796 797 void UIPortForwardingTable::setRules(const UIPortForwardingDataList &newRules) 798 { 797 void 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: */ 799 806 m_rules = newRules; 800 807 m_pTableModel->setRules(m_rules); 801 808 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 } 802 821 } 803 822 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.h
r87247 r87295 216 216 /** Returns the list of port forwarding rules. */ 217 217 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); 220 223 221 224 /** Validates the table. */
Note:
See TracChangeset
for help on using the changeset viewer.