2 * wpa_gui - SignalBar class
3 * Copyright (c) 2011, Kel Modderman <kel@otaku42.de>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
10 #include <qapplication.h>
12 #include "signalbar.h"
15 SignalBar::SignalBar(QObject *parent)
16 : QStyledItemDelegate(parent)
21 SignalBar::~SignalBar()
26 void SignalBar::paint(QPainter *painter,
27 const QStyleOptionViewItem &option,
28 const QModelIndex &index) const
30 QStyleOptionProgressBar opts;
33 if (index.column() != 3) {
34 QStyledItemDelegate::paint(painter, option, index);
38 if (index.data().toInt() > 0)
39 signal = 0 - (256 - index.data().toInt());
41 signal = index.data().toInt();
45 if (signal < opts.minimum)
46 opts.progress = opts.minimum;
47 else if (signal > opts.maximum)
48 opts.progress = opts.maximum;
50 opts.progress = signal;
52 opts.text = QString::number(signal) + " dBm";
53 opts.textVisible = true;
54 opts.rect = option.rect;
56 QApplication::style()->drawControl(QStyle::CE_ProgressBar,