changeset 27:6e8cd5ffa4df

merge.
author Jari Korhonen <jtkorhonen@gmail.com>
date Thu, 20 May 2010 23:03:49 +0300
parents eba979148fb3 (current diff) ee34bd26751e (diff)
children 90ffef5f0494
files mainwindow.cpp
diffstat 2 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mainwindow.cpp	Wed May 19 23:08:42 2010 +0300
+++ b/mainwindow.cpp	Thu May 20 23:03:49 2010 +0300
@@ -547,9 +547,35 @@
 }
 
 
+
+void MainWindow::listAllUpAddresses()
+{
+    QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
+
+    for (int i = 0; i < ifaces.count(); i++)
+    {
+        QNetworkInterface iface = ifaces.at(i);
+
+        QString msg;
+
+        QTextStream(&msg) <<  "name: " << iface.name() << endl << "mac: " << iface.hardwareAddress() << endl;
+        QMessageBox::information(this,  "interface", msg);
+
+        if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack))
+        {
+            // this loop is important
+            for (int j=0; j<iface.addressEntries().count(); j++)
+            {
+                QMessageBox::information(this, iface.name(), iface.addressEntries().at(j).ip().toString());
+            }
+        }
+    }
+}
+
+
 QString MainWindow::findMyIp()
 {
-    QString ipAddr;
+    listAllUpAddresses();
 
     QList <QHostAddress> ipList = QNetworkInterface::allAddresses();
 
--- a/mainwindow.h	Wed May 19 23:08:42 2010 +0300
+++ b/mainwindow.h	Thu May 20 23:03:49 2010 +0300
@@ -153,6 +153,7 @@
     bool isSelectedDeletable(QListWidget *workList);
     bool areAllSelectedCommitable(QListWidget *workList);
     QString findMyIp();
+    void listAllUpAddresses();
 
 
     //Actions enabled flags