20#include "pdoublenuminput.h"
25#include "tqfloatinput.h"
34PDoubleNumInput::PDoubleNumInput(MultiProperty *property, TQWidget *parent,
const char *name)
35 :PropertyWidget(property, parent, name)
37 TQHBoxLayout *l =
new TQHBoxLayout(
this, 0, 0);
39 m_edit =
new KDoubleNumInput(-999999.0, 999999.0, 0.0, 0.01, 2,
this);
40 m_edit->setLabel(TQString());
41 connect(m_edit, TQ_SIGNAL(valueChanged(
double)),
this, TQ_SLOT(updateProperty(
double)));
43 m_edit =
new TQFloatInput(-999999, 999999, 0.01, 2,
this );
44 connect(m_edit, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(updateProperty(
int)));
46 m_edit->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding);
54TQVariant PDoubleNumInput::value()
const
56 return TQVariant(m_edit->value());
59void PDoubleNumInput::setValue(
const TQVariant &value,
bool emitChange)
62 disconnect(m_edit, TQ_SIGNAL(valueChanged(
double)),
this, TQ_SLOT(updateProperty(
double)));
63 m_edit->setValue(value.toDouble());
64 connect(m_edit, TQ_SIGNAL(valueChanged(
double)),
this, TQ_SLOT(updateProperty(
double)));
66 disconnect(m_edit, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(updateProperty(
int)));
67 m_edit->setValue(
int(value.toDouble()*pow(m_edit->digits(),10)));
68 connect(m_edit, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(updateProperty(
int)));
71 emit propertyChanged(m_property, value);
74void PDoubleNumInput::updateProperty(
double val)
76 emit propertyChanged(m_property, TQVariant(val));
78void PDoubleNumInput::updateProperty(
int val)
81 TQString format = TQString(
"%.%1f").arg( m_edit->digits() );
82 TQString strVal = TQString().sprintf(format.latin1(),
83 (val/(
float)pow(m_edit->digits(),10)) );
84 emit propertyChanged(m_property, TQVariant(strVal));
93#include "pdoublenuminput.moc"
Namespace which contain property editing classes.