--- a/wpa_supplicant/wpa_gui-qt4/scanresults.cpp +++ b/wpa_supplicant/wpa_gui-qt4/scanresults.cpp @@ -15,6 +15,7 @@ #include #include "scanresults.h" +#include "signalbar.h" #include "wpagui.h" #include "networkconfig.h" @@ -33,6 +34,7 @@ ScanResults::ScanResults(QWidget *parent wpagui = NULL; scanResultsWidget->setItemsExpandable(FALSE); scanResultsWidget->setRootIsDecorated(FALSE); + scanResultsWidget->setItemDelegate(new SignalBar(scanResultsWidget)); } @@ -91,7 +93,7 @@ void ScanResults::updateResults() bssid = (*it).mid(pos); else if ((*it).startsWith("freq=")) freq = (*it).mid(pos); - else if ((*it).startsWith("qual=")) + else if ((*it).startsWith("level=")) signal = (*it).mid(pos); else if ((*it).startsWith("flags=")) flags = (*it).mid(pos); --- /dev/null +++ b/wpa_supplicant/wpa_gui-qt4/signalbar.h @@ -0,0 +1,34 @@ +/* + * wpa_gui - SignalBar class + * Copyright (c) 2011, Kel Modderman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + * See README and COPYING for more details. + */ + +#ifndef SIGNALBAR_H +#define SIGNALBAR_H + +#include +#include + +class SignalBar : public QStyledItemDelegate +{ + Q_OBJECT + +public: + SignalBar(QObject *parent = 0); + ~SignalBar(); + + virtual void paint(QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const ; +}; + +#endif /* SIGNALBAR_H */ --- /dev/null +++ b/wpa_supplicant/wpa_gui-qt4/signalbar.cpp @@ -0,0 +1,64 @@ +/* + * wpa_gui - SignalBar class + * Copyright (c) 2011, Kel Modderman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + * See README and COPYING for more details. + */ + +#include +#include + +#include "signalbar.h" + + +SignalBar::SignalBar(QObject *parent) + : QStyledItemDelegate(parent) +{ +} + + +SignalBar::~SignalBar() +{ +} + + +void SignalBar::paint(QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + QStyleOptionProgressBar opts; + int signal; + + if (index.column() != 3) { + QStyledItemDelegate::paint(painter, option, index); + return; + } + + if (index.data().toInt() > 0) + signal = 0 - (256 - index.data().toInt()); + else + signal = index.data().toInt(); + + opts.minimum = -95; + opts.maximum = -35; + if (signal < opts.minimum) + opts.progress = opts.minimum; + else if (signal > opts.maximum) + opts.progress = opts.maximum; + else + opts.progress = signal; + + opts.text = QString::number(signal) + " dBm"; + opts.textVisible = true; + opts.rect = option.rect; + + QApplication::style()->drawControl(QStyle::CE_ProgressBar, + &opts, painter); +} --- a/wpa_supplicant/wpa_gui-qt4/wpa_gui.pro +++ b/wpa_supplicant/wpa_gui-qt4/wpa_gui.pro @@ -34,6 +34,7 @@ HEADERS += wpamsg.h \ wpagui.h \ eventhistory.h \ scanresults.h \ + signalbar.h \ userdatarequest.h \ networkconfig.h \ addinterface.h \ @@ -44,6 +45,7 @@ SOURCES += main.cpp \ wpagui.cpp \ eventhistory.cpp \ scanresults.cpp \ + signalbar.cpp \ userdatarequest.cpp \ networkconfig.cpp \ addinterface.cpp \