Changeset 87312 in vbox
- Timestamp:
- Jan 20, 2021 8:58:56 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r87306 r87312 1973 1973 } 1974 1974 1975 void UIMessageCenter::warnAboutNoNameSpecified(const QString &strName, QWidget *pParent /* = 0 */) 1976 { 1977 alert(pParent, MessageType_Error, 1978 tr("No new name specified for the NAT network previously called <b>%1</b>.").arg(strName)); 1979 } 1980 1981 void UIMessageCenter::warnAboutNameAlreadyBusy(const QString &strName, QWidget *pParent /* = 0 */) 1982 { 1983 alert(pParent, MessageType_Error, 1984 tr("The name <b>%1</b> is being used for several NAT networks.").arg(strName)); 1985 } 1986 1987 void UIMessageCenter::warnAboutNoCIDRSpecified(const QString &strName, QWidget *pParent /* = 0 */) 1988 { 1989 alert(pParent, MessageType_Error, 1990 tr("No CIDR specified for the NAT network <b>%1</b>.").arg(strName)); 1991 } 1992 1993 void UIMessageCenter::warnAboutInvalidCIDRSpecified(const QString &strCIDR, const QString &strName, QWidget *pParent /* = 0 */) 1994 { 1995 alert(pParent, MessageType_Error, 1996 tr("Invalid CIDR specified (<i>%1</i>) for the NAT network <b>%2</b>.").arg(strCIDR, strName)); 1997 } 1998 1975 1999 void UIMessageCenter::cannotAcquireCloudProviderManager(const CVirtualBox &comVBox, QWidget *pParent /* = 0 */) const 1976 2000 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r87306 r87312 409 409 void cannotFindNATNetwork(const CVirtualBox &comVBox, const QString &strNetworkName, QWidget *pParent = 0) const; 410 410 void cannotRemoveNATNetwork(const CVirtualBox &comVBox, const QString &strNetworkName, QWidget *pParent = 0) const; 411 void warnAboutNoNameSpecified(const QString &strName, QWidget *pParent = 0); 412 void warnAboutNameAlreadyBusy(const QString &strName, QWidget *pParent = 0); 413 void warnAboutNoCIDRSpecified(const QString &strName, QWidget *pParent = 0); 414 void warnAboutInvalidCIDRSpecified(const QString &strCIDR, const QString &strName, QWidget *pParent = 0); 411 415 412 416 /* API: Cloud Profile Manager warnings: */ -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetNATNetwork.cpp
r87306 r87312 31 31 #include "UIIconPool.h" 32 32 #include "UIDetailsWidgetNATNetwork.h" 33 #include "UIMessageCenter.h" 33 34 #include "UINetworkManagerUtils.h" 34 35 … … 61 62 } 62 63 63 void UIDetailsWidgetNATNetwork::setData(const UIDataNATNetwork &data, bool fHoldPosition /* = false */) 64 void UIDetailsWidgetNATNetwork::setData(const UIDataNATNetwork &data, 65 const QStringList &busyNames /* = QStringList() */, 66 bool fHoldPosition /* = false */) 64 67 { 65 68 /* Cache old/new data: */ 66 69 m_oldData = data; 67 70 m_newData = m_oldData; 71 m_busyNames = busyNames; 68 72 m_fHoldPosition = fHoldPosition; 69 73 … … 76 80 bool UIDetailsWidgetNATNetwork::revalidate() const 77 81 { 82 /* Make sure network name isn't empty: */ 83 if (m_newData.m_strName.isEmpty()) 84 { 85 msgCenter().warnAboutNoNameSpecified(m_oldData.m_strName); 86 return false; 87 } 88 else 89 { 90 /* Make sure item names are unique: */ 91 if (m_busyNames.contains(m_newData.m_strName)) 92 { 93 msgCenter().warnAboutNameAlreadyBusy(m_newData.m_strName); 94 return false; 95 } 96 } 97 98 /* Make sure network CIDR isn't empty: */ 99 if (m_newData.m_strCIDR.isEmpty()) 100 { 101 msgCenter().warnAboutNoCIDRSpecified(m_newData.m_strName); 102 return false; 103 } 104 else 105 { 106 /* Make sure network CIDR is valid: */ 107 RTNETADDRIPV4 network, mask; 108 const int rc = RTCidrStrToIPv4(m_newData.m_strCIDR.toUtf8().constData(), &network, &mask); 109 if (RT_FAILURE(rc)) 110 { 111 msgCenter().warnAboutInvalidCIDRSpecified(m_newData.m_strCIDR, m_newData.m_strName); 112 return false; 113 } 114 } 115 116 /* Validate 'Forwarding' tab content: */ 78 117 return m_pForwardingTableIPv4->validate() && m_pForwardingTableIPv6->validate(); 79 118 } -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetNATNetwork.h
r87306 r87312 121 121 const UIDataNATNetwork &data() const { return m_newData; } 122 122 /** Defines the host network @a data. 123 * @param busyNames Holds the list of names busy by other 124 * NAT networks. 123 125 * @param fHoldPosition Holds whether we should try to keep 124 126 * port forwarding rule position intact. */ 125 void setData(const UIDataNATNetwork &data, bool fHoldPosition = false); 127 void setData(const UIDataNATNetwork &data, 128 const QStringList &busyNames = QStringList(), 129 bool fHoldPosition = false); 126 130 127 131 /** @name Change handling stuff. … … 237 241 /** Holds the 'Forwarding' button-box instance. */ 238 242 QIDialogButtonBox *m_pButtonBoxForwarding; 243 /** Holds the list of names busy by other 244 * NAT networks. */ 245 QStringList m_busyNames; 239 246 /** Holds whether we should try to keep 240 247 * port forwarding rule position intact. */ -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.cpp
r87306 r87312 1069 1069 /* If there is an item => update details data: */ 1070 1070 if (pItem) 1071 m_pDetailsWidgetNATNetwork->setData(*pItem, fHoldPosition); 1071 { 1072 QStringList busyNamesForItem = busyNames(); 1073 busyNamesForItem.removeAll(pItem->name()); 1074 m_pDetailsWidgetNATNetwork->setData(*pItem, busyNamesForItem, fHoldPosition); 1075 } 1072 1076 /* Otherwise => clear details: */ 1073 1077 else … … 1737 1741 } 1738 1742 1743 QStringList UINetworkManagerWidget::busyNames() const 1744 { 1745 QStringList names; 1746 for (int i = 0; i < m_pTreeWidgetNATNetwork->topLevelItemCount(); ++i) 1747 { 1748 UIItemNATNetwork *pItem = qobject_cast<UIItemNATNetwork*>(m_pTreeWidgetNATNetwork->childItem(i)); 1749 const QString strItemName(pItem->name()); 1750 if (!strItemName.isEmpty() && !names.contains(strItemName)) 1751 names << strItemName; 1752 } 1753 return names; 1754 } 1755 1739 1756 1740 1757 /********************************************************************************************************************************* -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.h
r87295 r87312 208 208 /** Updates passed NAT network tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */ 209 209 void updateItemForNATNetwork(const UIDataNATNetwork &data, bool fChooseItem, UIItemNATNetwork *pItem); 210 211 /** Returns a list of busy NAT network names. */ 212 QStringList busyNames() const; 210 213 /** @} */ 211 214
Note:
See TracChangeset
for help on using the changeset viewer.