![]() |
Mixxx
|
00001 // 00002 // C++ Implementation: wnumberrate 00003 // 00004 // Description: 00005 // 00006 // 00007 // Author: Tue Haste Andersen <haste@diku.dk>, (C) 2003 00008 // 00009 // Copyright: See COPYING file that comes with this distribution 00010 // 00011 // 00012 #include <math.h> 00013 #include "wnumberrate.h" 00014 #include "controlobject.h" 00015 #include "controlobjectthreadmain.h" 00016 00017 WNumberRate::WNumberRate(const char * group, QWidget * parent) : WNumber(parent) 00018 { 00019 m_pRateRangeControl = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey(group, "rateRange"))); 00020 connect(m_pRateRangeControl, SIGNAL(valueChanged(double)), 00021 this, SLOT(setValue(double))); 00022 m_pRateDirControl = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey(group, "rate_dir"))); 00023 connect(m_pRateDirControl, SIGNAL(valueChanged(double)), 00024 this, SLOT(setValue(double))); 00025 m_pRateControl = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey(group, "rate"))); 00026 connect(m_pRateControl, SIGNAL(valueChanged(double)), 00027 this, SLOT(setValue(double))); 00028 // Initialize the widget. 00029 setValue(0); 00030 } 00031 00032 WNumberRate::~WNumberRate() 00033 { 00034 delete m_pRateControl; 00035 delete m_pRateDirControl; 00036 delete m_pRateRangeControl; 00037 } 00038 00039 void WNumberRate::setValue(double) 00040 { 00041 double vsign = m_pRateControl->get()*m_pRateRangeControl->get()*m_pRateDirControl->get(); 00042 00043 char sign = '+'; 00044 if (vsign < -0.00000001) { 00045 sign = '-'; 00046 } 00047 00048 m_pLabel->setText(QString(m_qsText).append(sign).append("%1").arg(fabs(vsign)*100., 0, 'f', 2)); 00049 }