blob: 43d902e1d9da6c5530702bbb8a927ce51ea5c0bc (
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
|
/***************************************************************************
wnumber.cpp - description
-------------------
begin : Wed Jun 18 2003
copyright : (C) 2003 by Tue & Ken Haste Andersen
email : haste@diku.dk
***************************************************************************/
/***************************************************************************
* *
* 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 "widget/wnumber.h"
WNumber::WNumber(QWidget* pParent)
: WLabel(pParent),
m_iNoDigits(2) {
}
void WNumber::setup(const QDomNode& node, const SkinContext& context) {
WLabel::setup(node, context);
// Number of digits after the decimal.
context.hasNodeSelectInt(node, "NumberOfDigits", &m_iNoDigits);
setValue(0.);
}
void WNumber::onConnectedControlChanged(double dParameter, double dValue) {
Q_UNUSED(dParameter);
// We show the actual control value instead of its parameter.
setValue(dValue);
}
void WNumber::setValue(double dValue) {
if (m_skinText.contains("%1")) {
setText(m_skinText.arg(QString::number(dValue, 'f', m_iNoDigits)));
} else {
setText(m_skinText + QString::number(dValue, 'f', m_iNoDigits));
}
}
|