Changeset 66623 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 20, 2017 10:46:27 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114671
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/global
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp
r66614 r66623 79 79 QString newName() const { return m_strNewName; } 80 80 81 /** Returns IPv4 port forwarding rules. */ 82 const UIPortForwardingDataList &ipv4rules() const { return m_ipv4rules; } 83 /** Defines IPv4 port forwarding rules. */ 84 void setIpv4rules(const UIPortForwardingDataList &ipv4rules) { m_ipv4rules = ipv4rules; } 85 /** Returns IPv6 port forwarding rules. */ 86 const UIPortForwardingDataList &ipv6rules() const { return m_ipv6rules; } 87 /** Defines IPv6 port forwarding rules. */ 88 void setIpv6rules(const UIPortForwardingDataList &ipv6rules) { m_ipv6rules = ipv6rules; } 89 81 90 protected: 82 91 83 92 /** Returns default text. */ 84 93 virtual QString defaultText() const /* override */; 94 95 private: 96 97 /** Holds IPv4 port forwarding rules. */ 98 UIPortForwardingDataList m_ipv4rules; 99 /** Holds IPv6 port forwarding rules. */ 100 UIPortForwardingDataList m_ipv6rules; 85 101 }; 86 102 … … 415 431 /* Load old network data from the cache: */ 416 432 for (int i = 0; i < m_pCache->childCount1(); ++i) 417 createTreeWidgetItemForNetworkNAT(m_pCache->child1(i) .base());433 createTreeWidgetItemForNetworkNAT(m_pCache->child1(i)); 418 434 m_pTreeNetworkNAT->sortByColumn(1, Qt::AscendingOrder); 419 435 m_pTreeNetworkNAT->setCurrentItem(m_pTreeNetworkNAT->topLevelItem(0)); 420 436 sltHandleCurrentItemChangeNetworkNAT(); 421 437 for (int i = 0; i < m_pCache->childCount2(); ++i) 422 createTreeWidgetItemForNetworkHost(m_pCache->child2(i) .base());438 createTreeWidgetItemForNetworkHost(m_pCache->child2(i)); 423 439 m_pTreeNetworkHost->sortByColumn(0, Qt::AscendingOrder); 424 440 m_pTreeNetworkHost->setCurrentItem(m_pTreeNetworkHost->topLevelItem(0)); … … 439 455 const UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(i)); 440 456 m_pCache->child1(pItem->m_strName).cacheCurrentData(*pItem); 457 foreach (const UIDataPortForwardingRule &rule, pItem->ipv4rules()) 458 m_pCache->child1(pItem->m_strName).child1(rule.name).cacheCurrentData(rule); 459 foreach (const UIDataPortForwardingRule &rule, pItem->ipv6rules()) 460 m_pCache->child1(pItem->m_strName).child2(rule.name).cacheCurrentData(rule); 441 461 } 442 462 for (int i = 0; i < m_pTreeNetworkHost->topLevelItemCount(); ++i) … … 610 630 const QString strCacheKey = network.GetNetworkName(); 611 631 loadToCacheFromNetworkNAT(network, m_pCache->child1(strCacheKey)); 612 createTreeWidgetItemForNetworkNAT(m_pCache->child1(strCacheKey) .base(), true);632 createTreeWidgetItemForNetworkNAT(m_pCache->child1(strCacheKey), true); 613 633 m_pTreeNetworkNAT->sortByColumn(1, Qt::AscendingOrder); 614 634 } … … 622 642 /* Edit current item data: */ 623 643 UIDataSettingsGlobalNetworkNAT data = *pItem; 624 UIGlobalSettingsNetworkDetailsNAT details(this, data); 644 UIPortForwardingDataList ipv4rules = pItem->ipv4rules(); 645 UIPortForwardingDataList ipv6rules = pItem->ipv6rules(); 646 UIGlobalSettingsNetworkDetailsNAT details(this, data, ipv4rules, ipv6rules); 625 647 if (details.exec() == QDialog::Accepted) 626 648 { 627 649 /* Put data back: */ 628 650 pItem->UIDataSettingsGlobalNetworkNAT::operator=(data); 651 pItem->setIpv4rules(ipv4rules); 652 pItem->setIpv6rules(ipv6rules); 629 653 pItem->updateFields(); 630 654 sltHandleCurrentItemChangeNetworkNAT(); … … 727 751 const QString strCacheKey = iface.GetName(); 728 752 loadToCacheFromNetworkHost(iface, m_pCache->child2(strCacheKey)); 729 createTreeWidgetItemForNetworkHost(m_pCache->child2(strCacheKey) .base(), true);753 createTreeWidgetItemForNetworkHost(m_pCache->child2(strCacheKey), true); 730 754 m_pTreeNetworkHost->sortByColumn(0, Qt::AscendingOrder); 731 755 } … … 1037 1061 if (rules.size() != 6) 1038 1062 continue; 1039 oldNATData.m_ipv4rules << UIDataPortForwardingRule(rules[0],1040 gpConverter->fromInternalString<KNATProtocol>(rules[1]),1041 QString(rules[2]).remove('[').remove(']'),1042 rules[3].toUInt(),1043 QString(rules[4]).remove('[').remove(']'),1044 rules[5].toUInt());1063 cache.child1(rules.at(0)).cacheInitialData(UIDataPortForwardingRule(rules.at(0), 1064 gpConverter->fromInternalString<KNATProtocol>(rules.at(1)), 1065 QString(rules.at(2)).remove('[').remove(']'), 1066 rules.at(3).toUInt(), 1067 QString(rules.at(4)).remove('[').remove(']'), 1068 rules.at(5).toUInt())); 1045 1069 } 1046 1070 … … 1065 1089 if (rules.size() != 6) 1066 1090 continue; 1067 oldNATData.m_ipv6rules << UIDataPortForwardingRule(rules[0],1068 gpConverter->fromInternalString<KNATProtocol>(rules[1]),1069 QString(rules[2]).remove('[').remove(']'),1070 rules[3].toUInt(),1071 QString(rules[4]).remove('[').remove(']'),1072 rules[5].toUInt());1091 cache.child2(rules.at(0)).cacheInitialData(UIDataPortForwardingRule(rules.at(0), 1092 gpConverter->fromInternalString<KNATProtocol>(rules.at(1)), 1093 QString(rules.at(2)).remove('[').remove(']'), 1094 rules.at(3).toUInt(), 1095 QString(rules.at(4)).remove('[').remove(']'), 1096 rules.at(5).toUInt())); 1073 1097 } 1074 1098 … … 1153 1177 1154 1178 /* Save IPv4 forwarding rules: */ 1155 if (fSuccess && newNatData.m_ipv4rules != oldNatData.m_ipv4rules) 1156 { 1157 for (int i = 0; fSuccess && i < ipv4rules.size(); ++i) 1179 for (int i = 0; fSuccess && i < cache.childCount1(); ++i) 1180 { 1181 /* Get rule cache: */ 1182 const UISettingsCachePortForwardingRule &ruleCache = cache.child1(i); 1183 1184 /* Remove rule marked for 'remove' or 'update': */ 1185 if (ruleCache.wasRemoved() || ruleCache.wasUpdated()) 1158 1186 { 1159 const QString &strOldRule = ipv4rules.at(i);1160 1187 comNetwork.RemovePortForwardRule(false, 1161 strOldRule.section(':', 0, 0));1188 ruleCache.base().name); 1162 1189 fSuccess = comNetwork.isOk(); 1163 1190 } 1164 for (int i = 0; fSuccess && i < newNatData.m_ipv4rules.size(); ++i) 1191 } 1192 for (int i = 0; fSuccess && i < cache.childCount1(); ++i) 1193 { 1194 /* Get rule cache: */ 1195 const UISettingsCachePortForwardingRule &ruleCache = cache.child1(i); 1196 1197 /* Create rule marked for 'create' or 'update': */ 1198 if (ruleCache.wasCreated() || ruleCache.wasUpdated()) 1165 1199 { 1166 const UIDataPortForwardingRule &newRule = newNatData.m_ipv4rules.at(i);1167 1200 comNetwork.AddPortForwardRule(false, 1168 newRule.name, newRule.protocol,1169 newRule.hostIp, newRule.hostPort.value(),1170 newRule.guestIp, newRule.guestPort.value());1201 ruleCache.data().name, ruleCache.data().protocol, 1202 ruleCache.data().hostIp, ruleCache.data().hostPort.value(), 1203 ruleCache.data().guestIp, ruleCache.data().guestPort.value()); 1171 1204 fSuccess = comNetwork.isOk(); 1172 1205 } … … 1174 1207 1175 1208 /* Save IPv6 forwarding rules: */ 1176 if (fSuccess && newNatData.m_ipv6rules != oldNatData.m_ipv6rules) 1177 { 1178 for (int i = 0; fSuccess && i < ipv6rules.size(); ++i) 1209 for (int i = 0; fSuccess && i < cache.childCount2(); ++i) 1210 { 1211 /* Get rule cache: */ 1212 const UISettingsCachePortForwardingRule &ruleCache = cache.child2(i); 1213 1214 /* Remove rule marked for 'remove' or 'update': */ 1215 if (ruleCache.wasRemoved() || ruleCache.wasUpdated()) 1179 1216 { 1180 const QString &strOldRule = ipv6rules.at(i);1181 1217 comNetwork.RemovePortForwardRule(true, 1182 strOldRule.section(':', 0, 0));1218 ruleCache.base().name); 1183 1219 fSuccess = comNetwork.isOk(); 1184 1220 } 1185 for (int i = 0; fSuccess && i < newNatData.m_ipv6rules.size(); ++i) 1221 } 1222 for (int i = 0; fSuccess && i < cache.childCount2(); ++i) 1223 { 1224 /* Get rule cache: */ 1225 const UISettingsCachePortForwardingRule &ruleCache = cache.child2(i); 1226 1227 /* Create rule marked for 'create' or 'update': */ 1228 if (ruleCache.wasCreated() || ruleCache.wasUpdated()) 1186 1229 { 1187 const UIDataPortForwardingRule &newRule = newNatData.m_ipv6rules.at(i);1188 1230 comNetwork.AddPortForwardRule(true, 1189 newRule.name, newRule.protocol,1190 newRule.hostIp, newRule.hostPort.value(),1191 newRule.guestIp, newRule.guestPort.value());1231 ruleCache.data().name, ruleCache.data().protocol, 1232 ruleCache.data().hostIp, ruleCache.data().hostPort.value(), 1233 ruleCache.data().guestIp, ruleCache.data().guestPort.value()); 1192 1234 fSuccess = comNetwork.isOk(); 1193 1235 } … … 1203 1245 } 1204 1246 1205 void UIGlobalSettingsNetwork::createTreeWidgetItemForNetworkNAT(const UI DataSettingsGlobalNetworkNAT &data, bool fChooseItem)1247 void UIGlobalSettingsNetwork::createTreeWidgetItemForNetworkNAT(const UISettingsCacheGlobalNetworkNAT &cache, bool fChooseItem) 1206 1248 { 1207 1249 /* Add new item to the tree: */ 1208 1250 UIItemNetworkNAT *pItem = new UIItemNetworkNAT; 1209 pItem->UIDataSettingsGlobalNetworkNAT::operator=(data); 1251 pItem->UIDataSettingsGlobalNetworkNAT::operator=(cache.base()); 1252 UIPortForwardingDataList ipv4rules; 1253 UIPortForwardingDataList ipv6rules; 1254 for (int i = 0; i < cache.childCount1(); ++i) 1255 ipv4rules << cache.child1(i).base(); 1256 for (int i = 0; i < cache.childCount2(); ++i) 1257 ipv6rules << cache.child2(i).base(); 1258 pItem->setIpv4rules(ipv4rules); 1259 pItem->setIpv6rules(ipv6rules); 1210 1260 pItem->updateFields(); 1211 1261 m_pTreeNetworkNAT->addTopLevelItem(pItem); … … 1376 1426 } 1377 1427 1378 void UIGlobalSettingsNetwork::createTreeWidgetItemForNetworkHost(const UI DataSettingsGlobalNetworkHost &data, bool fChooseItem)1428 void UIGlobalSettingsNetwork::createTreeWidgetItemForNetworkHost(const UISettingsCacheGlobalNetworkHost &cache, bool fChooseItem) 1379 1429 { 1380 1430 /* Add new item to the tree: */ 1381 1431 UIItemNetworkHost *pItem = new UIItemNetworkHost; 1382 pItem->UIDataSettingsGlobalNetworkHost::operator=( data);1432 pItem->UIDataSettingsGlobalNetworkHost::operator=(cache.base()); 1383 1433 pItem->updateFields(); 1384 1434 m_pTreeNetworkHost->addTopLevelItem(pItem); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h
r66614 r66623 22 22 #include "UISettingsPage.h" 23 23 #include "UIGlobalSettingsNetwork.gen.h" 24 #include "UIPortForwardingTable.h" 24 25 25 26 /* Forward declarations: */ … … 29 30 struct UIDataSettingsGlobalNetworkNAT; 30 31 struct UIDataSettingsGlobalNetworkHost; 31 typedef UISettingsCache<UIDataSettingsGlobalNetworkNAT> UISettingsCacheGlobalNetworkNAT; 32 typedef UISettingsCache<UIDataPortForwardingRule> UISettingsCachePortForwardingRule; 33 typedef UISettingsCachePoolOfTwo<UIDataSettingsGlobalNetworkNAT, UISettingsCachePortForwardingRule, UISettingsCachePortForwardingRule> UISettingsCacheGlobalNetworkNAT; 32 34 typedef UISettingsCache<UIDataSettingsGlobalNetworkHost> UISettingsCacheGlobalNetworkHost; 33 35 typedef UISettingsCachePoolOfTwo<UIDataSettingsGlobalNetwork, UISettingsCacheGlobalNetworkNAT, UISettingsCacheGlobalNetworkHost> UISettingsCacheGlobalNetwork; … … 119 121 bool saveDataNetworkNAT(const UISettingsCacheGlobalNetworkNAT &cache); 120 122 /** Creates a new item in the NAT network tree on the basis of passed @a data, @a fChooseItem if requested. */ 121 void createTreeWidgetItemForNetworkNAT(const UI DataSettingsGlobalNetworkNAT &data, bool fChooseItem = false);123 void createTreeWidgetItemForNetworkNAT(const UISettingsCacheGlobalNetworkNAT &cache, bool fChooseItem = false); 122 124 /** Removes existing @a pItem from the NAT network tree. */ 123 125 void removeTreeWidgetItemOfNetworkNAT(UIItemNetworkNAT *pItem); … … 128 130 bool saveDataNetworkHost(const UISettingsCacheGlobalNetworkHost &cache); 129 131 /** Creates a new item in the host network tree on the basis of passed @a data, @a fChooseItem if requested. */ 130 void createTreeWidgetItemForNetworkHost(const UI DataSettingsGlobalNetworkHost &data, bool fChooseItem = false);132 void createTreeWidgetItemForNetworkHost(const UISettingsCacheGlobalNetworkHost &cache, bool fChooseItem = false); 131 133 /** Removes existing @a pItem from the host network tree. */ 132 134 void removeTreeWidgetItemOfNetworkHost(UIItemNetworkHost *pItem); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsNAT.cpp
r65629 r66623 31 31 32 32 33 UIGlobalSettingsNetworkDetailsNAT::UIGlobalSettingsNetworkDetailsNAT(QWidget *pParent, UIDataSettingsGlobalNetworkNAT &data) 33 UIGlobalSettingsNetworkDetailsNAT::UIGlobalSettingsNetworkDetailsNAT(QWidget *pParent, 34 UIDataSettingsGlobalNetworkNAT &data, 35 UIPortForwardingDataList &ipv4rules, 36 UIPortForwardingDataList &ipv6rules) 34 37 : QIWithRetranslateUI2<QIDialog>(pParent) 35 38 , m_data(data) 39 , m_ipv4rules(ipv4rules) 40 , m_ipv6rules(ipv6rules) 36 41 { 37 42 /* Apply UI decorations: */ … … 71 76 { 72 77 /* Open dialog to edit port-forwarding rules: */ 73 UIGlobalSettingsPortForwardingDlg dlg(this, m_ data.m_ipv4rules, m_data.m_ipv6rules);78 UIGlobalSettingsPortForwardingDlg dlg(this, m_ipv4rules, m_ipv6rules); 74 79 if (dlg.exec() == QDialog::Accepted) 75 80 { 76 m_ data.m_ipv4rules = dlg.ipv4rules();77 m_ data.m_ipv6rules = dlg.ipv6rules();81 m_ipv4rules = dlg.ipv4rules(); 82 m_ipv6rules = dlg.ipv6rules(); 78 83 } 79 84 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsNAT.h
r66562 r66623 38 38 , m_fSupportsIPv6(false) 39 39 , m_fAdvertiseDefaultIPv6Route(false) 40 , m_ipv4rules(QList<UIDataPortForwardingRule>())41 , m_ipv6rules(QList<UIDataPortForwardingRule>())42 40 {} 43 41 … … 53 51 && (m_fSupportsIPv6 == other.m_fSupportsIPv6) 54 52 && (m_fAdvertiseDefaultIPv6Route == other.m_fAdvertiseDefaultIPv6Route) 55 && (m_ipv4rules == other.m_ipv4rules)56 && (m_ipv6rules == other.m_ipv6rules)57 53 ; 58 54 } … … 77 73 /** Holds whether this network advertised as default IPv6 route. */ 78 74 bool m_fAdvertiseDefaultIPv6Route; 79 /** Holds IPv4 port forwarding rules. */80 UIPortForwardingDataList m_ipv4rules;81 /** Holds IPv6 port forwarding rules. */82 UIPortForwardingDataList m_ipv6rules;83 75 }; 84 76 … … 92 84 93 85 /* Constructor: */ 94 UIGlobalSettingsNetworkDetailsNAT(QWidget *pParent, UIDataSettingsGlobalNetworkNAT &data );86 UIGlobalSettingsNetworkDetailsNAT(QWidget *pParent, UIDataSettingsGlobalNetworkNAT &data, UIPortForwardingDataList &ipv4rules, UIPortForwardingDataList &ipv6rules); 95 87 96 88 protected: … … 118 110 /* Variable: External data reference: */ 119 111 UIDataSettingsGlobalNetworkNAT &m_data; 112 113 /** Holds IPv4 port forwarding rules. */ 114 UIPortForwardingDataList &m_ipv4rules; 115 /** Holds IPv6 port forwarding rules. */ 116 UIPortForwardingDataList &m_ipv6rules; 120 117 }; 121 118
Note:
See TracChangeset
for help on using the changeset viewer.