diff --git a/include/lcd_spinbox.h b/include/lcd_spinbox.h index 43ce4a32d..757c301d8 100644 --- a/include/lcd_spinbox.h +++ b/include/lcd_spinbox.h @@ -46,6 +46,19 @@ public: update(); } + /*! Sets an offset which is always added to value of model so we can + display values in a user-friendly way if they internally start at 0 */ + void setDisplayOffset( int offset ) + { + m_displayOffset = offset; + } + + /*! \brief Returns internal offset for displaying values */ + int displayOffset() const + { + return m_displayOffset; + } + public slots: virtual void update(); @@ -60,6 +73,7 @@ protected: private: QPoint m_origMousePos; + int m_displayOffset; signals: diff --git a/src/gui/widgets/lcd_spinbox.cpp b/src/gui/widgets/lcd_spinbox.cpp index dcc1ebd09..18bfcb5dc 100644 --- a/src/gui/widgets/lcd_spinbox.cpp +++ b/src/gui/widgets/lcd_spinbox.cpp @@ -43,7 +43,8 @@ lcdSpinBox::lcdSpinBox( int numDigits, QWidget* parent, const QString& name ) : LcdWidget( numDigits, parent, name ), IntModelView( new IntModel( 0, 0, 0, NULL, name, true ), this ), - m_origMousePos() + m_origMousePos(), + m_displayOffset( 0 ) { } @@ -53,7 +54,8 @@ lcdSpinBox::lcdSpinBox( int numDigits, QWidget* parent, const QString& name ) : lcdSpinBox::lcdSpinBox( int numDigits, const QString& style, QWidget* parent, const QString& name ) : LcdWidget( numDigits, parent, name ), IntModelView( new IntModel( 0, 0, 0, NULL, name, true ), this ), - m_origMousePos() + m_origMousePos(), + m_displayOffset( 0 ) { } @@ -67,7 +69,7 @@ lcdSpinBox::~lcdSpinBox() void lcdSpinBox::update() { - setValue( model()->value() ); + setValue( model()->value() + m_displayOffset ); QWidget::update(); }