/*************************************************************************** kuintspinbox.cpp - description ------------------- begin : Sun Apr 13 2003 copyright : (C) 2003 by German Martinez email : german.martinez@cern.ch ***************************************************************************/ //#include #ifdef HAVE_LIMITS_H #include #endif #include #include "uspinbox.h" #include #include #include #include #include //#include #include #include #include #include //#include > //#include > //#include "knumvalidator.h " //" USpinBox::USpinBox(QWidget *parent, const char *name) : QSpinBox (-2147483648,2147483647, 4, parent, name) { // editor()->setAlignment(AlignRight); val_base = 16; setUValue(0); // setValidator(0); } USpinBox::~USpinBox() { } USpinBox::USpinBox(unsigned long lower, unsigned long upper, int step, unsigned long value, int base, QWidget* parent, const char* name) : QSpinBox (UtoI(lower), UtoI(upper), step, parent, name) { // editor()->setAlignment(AlignRight); val_base = base; // if(base!=10) setValidator(0); setUValue(value); } void USpinBox::setBase(int base) { val_base = base; } int USpinBox::base() const { return val_base; } // ----------------------------------------------------------------------------- QString USpinBox::textFromValue(int val) const { return QString::number(ItoU(val), val_base); } // ----------------------------------------------------------------------------- int USpinBox::valueFromText(const QString &text) const { bool ok; int retVal= UtoI(text.toUInt(&ok, val_base)); if(ok) return retVal; else return 0; } unsigned long USpinBox::UValue() { m_val=ItoU(value()); return m_val; } void USpinBox::setUValue(unsigned long v) { m_val=v; setValue(UtoI(m_val)); } QValidator::State USpinBox::validate ( QString & input, int &) const { bool ok; input.toUInt(&ok, val_base); return ok?QValidator::Acceptable:QValidator::Invalid; }