File: speedframe.cpp

package info (click to toggle)
knetdockapp 0.82.3-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 2,920 kB
  • ctags: 367
  • sloc: sh: 9,907; perl: 2,799; cpp: 2,546; makefile: 52
file content (84 lines) | stat: -rw-r--r-- 2,723 bytes parent folder | download
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/***************************************************************************
 *   Copyright (C) 2007 by Todor Gyumyushev   *
 *   yodor@developer.bg   *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "speedframe.h"
#include <math.h>
#include <qlayout.h>

extern double getScaleString(const unsigned long long int value, QString& c);

SpeedFrame::SpeedFrame(QWidget *parent, const char *name)
 : QLabel(parent, name)
{
//	resize(80,40);
setAlignment(Qt::AlignHCenter);


	QHBoxLayout *h = new QHBoxLayout(this,2);

	QVBoxLayout *vlay = new QVBoxLayout(this,2);
	
	label = new QLabel(this);
	label->resize(80,20);
	label->setMinimumSize(label->size());
	label->setMaximumSize(label->size());
	//label->move(3,3);

	vlay->addWidget(label);

	//lcd->move(3,23);
	
	lcd = new QLCDNumber(this);
	lcd->resize(80,20);
	lcd->setMinimumSize(lcd->size());
	lcd->setMaximumSize(lcd->size());
	
	lcd->setFrameShape(QFrame::Panel);
	lcd->setFrameStyle(QFrame::Sunken);
	lcd->setSegmentStyle(QLCDNumber::Flat);
	lcd->setPaletteForegroundColor(Qt::white);
	lcd->setPaletteBackgroundColor(Qt::black);
	lcd->setMidLineWidth(2);
	vlay->addWidget(lcd);
	
	//setMinimumSize(86,46);
	//setMaximumSize(86,46);
	QLabel *l = new QLabel(this);
	h->addWidget(l);
	h->addLayout(vlay);
	h->addWidget(l);	
}


SpeedFrame::~SpeedFrame()
{
}
void SpeedFrame::update(const Q_ULLONG speed, bool bps)
{
		QString c="";
		double ret;
		ret = getScaleString(speed,c);
		lcd->display(ret);
		if (bps)
		label->setText(c+"bps");
		else
		label->setText(c+"Bps");

}