2
* wpa_gui - SignalBar class
3
* Copyright (c) 2011, Kel Modderman <kel@otaku42.de>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation.
9
* Alternatively, this software may be distributed under the terms of BSD
12
* See README and COPYING for more details.
16
#include <qapplication.h>
18
#include "signalbar.h"
21
SignalBar::SignalBar(QObject *parent)
22
: QStyledItemDelegate(parent)
27
SignalBar::~SignalBar()
32
void SignalBar::paint(QPainter *painter,
33
const QStyleOptionViewItem &option,
34
const QModelIndex &index) const
36
QStyleOptionProgressBar opts;
39
if (index.column() != 3) {
40
QStyledItemDelegate::paint(painter, option, index);
44
if (index.data().toInt() > 0)
45
signal = 0 - (256 - index.data().toInt());
47
signal = index.data().toInt();
51
if (signal < opts.minimum)
52
opts.progress = opts.minimum;
53
else if (signal > opts.maximum)
54
opts.progress = opts.maximum;
56
opts.progress = signal;
58
opts.text = QString::number(signal) + " dBm";
59
opts.textVisible = true;
60
opts.rect = option.rect;
62
QApplication::style()->drawControl(QStyle::CE_ProgressBar,