summaryrefslogtreecommitdiffstats
path: root/wifi/speed.cpp
blob: 9c0a10625b727b85b6b7cf7223a06236bb3140e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/***************************************************************************
                          speed.cpp  -  description
                             -------------------
    begin                : Mon Aug 19 2002
    copyright            : (C) 2002 by Stefan Winter
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <tqpainter.h>
#include <tdelocale.h>
#include <kdebug.h>
#include "speed.h"
#include "interface_wireless.h"

Speed::Speed (TQWidget * parent, Interface_wireless * device):TQWidget (parent,
	 "KWiFiManager")
{
  this->device = device;
}

void
Speed::paintEvent (TQPaintEvent *)
{
  TQPainter speedpainter (this);
  TQColor farbe;
  farbe.setRgb (0, 255, 0);
  if (device->get_bitrate () < 6000000)
    farbe.setRgb (0, 200, 0);
  if (device->get_bitrate () < 2500000)
    farbe.setRgb (255, 255, 0);
  if (device->get_bitrate () < 1500000)
    farbe.setRgb (255, 128, 0);
  speedpainter.drawText (20, 20, i18n ("Connection speed [MBit/s]:"));
  speedpainter.drawRect (19, 29, 222, 12);
  if (device->get_bitrate () <= 11000000.)
    {
      speedpainter.fillRect (20, 30, (int) device->get_bitrate () / 50000,
			      10, farbe);
      speedpainter.drawText (16, 52, TQString("0"));
      speedpainter.drawText (35, 52, TQString("1"));
      speedpainter.drawText (55, 52, TQString("2"));
      speedpainter.drawText (120, 52, TQString("5.5"));
      speedpainter.drawText (230, 52, TQString("11"));
    }
  else
    {
      speedpainter.fillRect (20, 30, (int) device->get_bitrate () / 500000,
			      10, farbe);
      speedpainter.drawText (16, 52, TQString("0"));
      speedpainter.drawText (33, 52, TQString("11"));
      speedpainter.drawText (56, 52, TQString("22"));
      speedpainter.drawText (120, 52, TQString("54"));
      speedpainter.drawText (220, 52, TQString("108"));
    };
}