diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-08 00:16:34 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-08 07:48:55 (GMT) |
commit | 10628947d5ab1cfcd571ada10c0eab4b7f1f02ac (patch) | |
tree | 3918a47cf04be69930348bd98f406e41e41edf54 | |
parent | c470f8d1523ec974a7f0e1cb61ef13f0e953c500 (diff) | |
download | Qt-10628947d5ab1cfcd571ada10c0eab4b7f1f02ac.zip Qt-10628947d5ab1cfcd571ada10c0eab4b7f1f02ac.tar.gz Qt-10628947d5ab1cfcd571ada10c0eab4b7f1f02ac.tar.bz2 |
Display session statistics.
-rw-r--r-- | examples/network/bearermonitor/sessionwidget.cpp | 18 | ||||
-rw-r--r-- | examples/network/bearermonitor/sessionwidget.h | 5 | ||||
-rw-r--r-- | examples/network/bearermonitor/sessionwidget.ui | 50 |
3 files changed, 69 insertions, 4 deletions
diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp index d03c5bf..46ffb20 100644 --- a/examples/network/bearermonitor/sessionwidget.cpp +++ b/examples/network/bearermonitor/sessionwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -43,7 +43,7 @@ #include "qnetworkconfigmanager.h" SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent) -: QWidget(parent) +: QWidget(parent), statsTimer(-1) { setupUi(this); @@ -75,11 +75,25 @@ SessionWidget::~SessionWidget() delete session; } +void SessionWidget::timerEvent(QTimerEvent *e) +{ + if (e->timerId() == statsTimer) { + rxData->setText(QString::number(session->bytesReceived())); + txData->setText(QString::number(session->bytesWritten())); + activeTime->setText(QString::number(session->activeTime())); + } +} + void SessionWidget::updateSession() { updateSessionState(session->state()); updateSessionError(session->error()); + if (session->state() == QNetworkSession::Connected) + statsTimer = startTimer(1000); + else + killTimer(statsTimer); + if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint) bearer->setText(session->configuration().bearerName()); else { diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h index 868de3a..cc9c067 100644 --- a/examples/network/bearermonitor/sessionwidget.h +++ b/examples/network/bearermonitor/sessionwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -56,6 +56,8 @@ public: SessionWidget(const QNetworkConfiguration &config, QWidget *parent = 0); ~SessionWidget(); + void timerEvent(QTimerEvent *); + private: void updateSessionState(QNetworkSession::State state); void updateSessionError(QNetworkSession::SessionError error); @@ -69,6 +71,7 @@ private Q_SLOTS: private: QNetworkSession *session; + int statsTimer; }; #endif diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui index 65ca43b..45135f5 100644 --- a/examples/network/bearermonitor/sessionwidget.ui +++ b/examples/network/bearermonitor/sessionwidget.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>340</width> - <height>286</height> + <height>276</height> </rect> </property> <property name="windowTitle"> @@ -215,6 +215,54 @@ </layout> </item> <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="rxData"> + <property name="text"> + <string>0</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="txData"> + <property name="text"> + <string>0</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Active Time:</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="activeTime"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>0 seconds</string> + </property> + </widget> + </item> + </layout> + </item> + <item> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QPushButton" name="openSessionButton"> |