00001 /*************************************************************************** 00002 * Copyright (C) 2003-2004 by David Saxton * 00003 * david@bluehaze.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 ***************************************************************************/ 00010 00011 #ifndef DOUBLESPINBOX_H 00012 #define DOUBLESPINBOX_H 00013 00014 #include <qspinbox.h> 00015 00023 class DoubleSpinBox : public QSpinBox 00024 { 00025 Q_OBJECT 00026 public: 00027 DoubleSpinBox( double lower, double upper, double minAbs, double value, const QString & unit, QWidget * parent = 0 ); 00028 virtual ~DoubleSpinBox(); 00029 00033 double minValue() const { return m_minValue; } 00037 void setMinValue( double minValue ) { m_minValue = minValue; } 00041 void setMinValue( int minValue ) { m_minValue = minValue; } 00045 double maxValue() const { return m_maxValue; } 00049 void setMaxValue( double maxValue ) { m_maxValue = maxValue; } 00053 void setMaxValue( int maxValue ) { m_maxValue = maxValue; } 00058 void setMinAbsValue( double minAbsValue ) { m_minAbsValue = minAbsValue; } 00063 double value(); 00068 void setValue( double value ); 00072 void setUnit( const QString & unit ); 00073 00074 public slots: 00075 virtual void stepUp(); 00076 virtual void stepDown(); 00077 00078 signals: 00082 void valueChanged( double value ); 00083 00084 protected slots: 00089 void checkIfChanged(); 00094 void setQueuedSuffix(); 00095 00096 protected: 00100 void updateSuffix( double value ); 00105 double getMult(); 00109 double getDisplayedNumber( bool * ok ); 00113 virtual int mapTextToValue( bool * ok ); 00117 virtual QString mapValueToText( int v ); 00121 double roundToOneSF( double value ); 00122 00123 QString m_queuedSuffix; 00124 QString m_unit; 00125 double m_minValue; 00126 double m_maxValue; 00127 double m_minAbsValue; 00128 double m_lastEmittedValue; 00129 }; 00130 00131 #endif
1.5.1