From 10628947d5ab1cfcd571ada10c0eab4b7f1f02ac Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 8 Feb 2010 10:16:34 +1000 Subject: Display session statistics. --- examples/network/bearermonitor/sessionwidget.cpp | 18 ++++++++- examples/network/bearermonitor/sessionwidget.h | 5 ++- 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 @@ 0 0 340 - 286 + 276 @@ -215,6 +215,54 @@ + + + + + 0 + + + Qt::AlignCenter + + + + + + + 0 + + + Qt::AlignCenter + + + + + + + + + + + Active Time: + + + + + + + + 0 + 0 + + + + 0 seconds + + + + + + -- cgit v0.12