Changeset 65603 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 3, 2017 3:54:38 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/global
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsHost.cpp
r62493 r65603 163 163 if (fIsManual) 164 164 { 165 /* Load values from COM wrappers: */ 165 166 m_pDhcpAddressEditor->setText(m_data.m_dhcpserver.m_strDhcpServerAddress); 166 167 m_pDhcpMaskEditor->setText(m_data.m_dhcpserver.m_strDhcpServerMask); 167 168 m_pDhcpLowerAddressEditor->setText(m_data.m_dhcpserver.m_strDhcpLowerAddress); 168 169 m_pDhcpUpperAddressEditor->setText(m_data.m_dhcpserver.m_strDhcpUpperAddress); 170 171 /* Invent default values where necessary: */ 172 const quint32 uAddr = ipv4FromQStringToQuint32(m_data.m_interface.m_strInterfaceAddress); 173 const quint32 uMask = ipv4FromQStringToQuint32(m_data.m_interface.m_strInterfaceMask); 174 const quint32 uProp = uAddr & uMask; 175 const QString strMask = ipv4FromQuint32ToQString(uMask); 176 const QString strProp = ipv4FromQuint32ToQString(uProp); 177 //printf("Proposal is = %s x %s\n", 178 // strProp.toUtf8().constData(), 179 // strMask.toUtf8().constData()); 180 if ( m_data.m_dhcpserver.m_strDhcpServerAddress.isEmpty() 181 || m_data.m_dhcpserver.m_strDhcpServerAddress == "0.0.0.0") 182 m_pDhcpAddressEditor->setText(strProp); 183 if ( m_data.m_dhcpserver.m_strDhcpServerMask.isEmpty() 184 || m_data.m_dhcpserver.m_strDhcpServerMask == "0.0.0.0") 185 m_pDhcpMaskEditor->setText(strMask); 186 if ( m_data.m_dhcpserver.m_strDhcpLowerAddress.isEmpty() 187 || m_data.m_dhcpserver.m_strDhcpLowerAddress == "0.0.0.0") 188 m_pDhcpLowerAddressEditor->setText(strProp); 189 if ( m_data.m_dhcpserver.m_strDhcpUpperAddress.isEmpty() 190 || m_data.m_dhcpserver.m_strDhcpUpperAddress == "0.0.0.0") 191 m_pDhcpUpperAddressEditor->setText(strProp); 169 192 } 170 193 } … … 196 219 } 197 220 221 /* static */ 222 quint32 UIGlobalSettingsNetworkDetailsHost::ipv4FromQStringToQuint32(const QString &strAddress) 223 { 224 quint32 uAddress = 0; 225 foreach (const QString &strPart, strAddress.split('.')) 226 { 227 uAddress = uAddress << 8; 228 bool fOk = false; 229 uint uPart = strPart.toUInt(&fOk); 230 if (fOk) 231 uAddress += uPart; 232 } 233 return uAddress; 234 } 235 236 /* static */ 237 QString UIGlobalSettingsNetworkDetailsHost::ipv4FromQuint32ToQString(quint32 uAddress) 238 { 239 QStringList address; 240 while (uAddress) 241 { 242 uint uPart = uAddress & 0xFF; 243 address.prepend(QString::number(uPart)); 244 uAddress = uAddress >> 8; 245 } 246 return address.join('.'); 247 } 248 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsHost.h
r62493 r65603 59 59 void save(); 60 60 61 /** Converts IPv4 address from QString to quint32. */ 62 static quint32 ipv4FromQStringToQuint32(const QString &strAddress); 63 /** Converts IPv4 address from quint32 to QString. */ 64 static QString ipv4FromQuint32ToQString(quint32 uAddress); 65 61 66 /* Variable: External data reference: */ 62 67 UIDataNetworkHost &m_data;
Note:
See TracChangeset
for help on using the changeset viewer.