Index: sources/view/settings/VNetworkModel.cpp =================================================================== diff -u -r1c18f738693756ca1f0342c2cc158e32bc28f90b -rc306a4de6311e779822e6a2e5e7ac63484513fbe --- sources/view/settings/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision 1c18f738693756ca1f0342c2cc158e32bc28f90b) +++ sources/view/settings/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision c306a4de6311e779822e6a2e5e7ac63484513fbe) @@ -1,5 +1,6 @@ // Qt +#include // Project #include "VNetworkModel.h" @@ -9,6 +10,7 @@ using namespace View; VNetworkModel::VNetworkModel(QAbstractListModel *parent) : QAbstractListModel(parent) { + startTimer(_interval); initConnections(); } @@ -160,7 +162,7 @@ /*! * \brief VNetworkModel::roleNames * Translates how to access specific properties of the data for QML from the NetworkDataRole enum - * \return (QHash) - maps enums to property names + * \return (QHash) - maps enum to property name */ QHash VNetworkModel::roleNames() const { QHash roles; @@ -228,7 +230,7 @@ /*! * \brief VNetworkModel::doJoinNetwork - * Handles request from qml to join a network + * Handles request from QML to join a network * \param vMacAddress - (QString) the mac address of the network to join * \param vPassword - (QString) the password for the network provided by the user */ @@ -248,7 +250,7 @@ /*! * \brief VNetworkModel::doDisconnectNetwork - * Handles request from qml to disconnect from a network + * Handles request from QML to disconnect from a network * \param vMacAddress - (QString) the mac address of the network to disconnect from */ void VNetworkModel::doDisconnectNetwork(const QString &vMacAddress) @@ -304,7 +306,7 @@ /*! * \brief VNetworkModel::onStatusChanged - * Called when the wifi interface status changes + * Called when the WiFi interface status changes * \param vMessage - (QString) the error message */ void VNetworkModel::onStatusChanged(const QString &vMessage) @@ -314,7 +316,7 @@ /*! * \brief VNetworkModel::doSetIPAddress - * \param vIPAddress (QString) the ip address + * \param vIPAddress (QString) the IP address */ void VNetworkModel::doSetIPAddress(const QString &vIPAddress) { @@ -349,7 +351,16 @@ } /*! - * \brief VNetworkModel::clearWifiSettings + * \brief VNetworkModel::timerEvent + * The overload timerEvent of the QObject to handle the internal timer event. + */ +void VNetworkModel::timerEvent(QTimerEvent *) +{ + checkEthernet(); +} + +/*! + * \brief VNetworkModel::clearSelectedNetwork * Clears the selected network settings */ void VNetworkModel::clearSelectedNetwork() @@ -363,7 +374,25 @@ } /*! - * \brief VNetworkModel::onSetIPAddressSuccess + * \brief VNetworkModel::checkEthernet0 + * Checking the Ethernet interface. + */ +void VNetworkModel::checkEthernet() +{ + const QNetworkInterface eth0 = QNetworkInterface::interfaceFromName(_iEthernet); + if ( eth0.isValid() ) { + auto addresses = eth0.allAddresses(); + if ( addresses.count() > 2 ) { + ethernetIP(addresses[2].toString()); + } + else { + ethernetIP(tr("No Ethernet")); + } + } +} + +/*! + * \brief VNetworkModel::onSetStaticIPAddressSuccess * Called when the IP address has been set */ void VNetworkModel::onSetStaticIPAddressSuccess()