|
27 | 27 | QgsDoubleSpinBox::QgsDoubleSpinBox( QWidget *parent )
|
28 | 28 | : QDoubleSpinBox( parent )
|
29 | 29 | , mShowClearButton( true )
|
30 |
| - , mClearValueType( MinimumValue ) |
| 30 | + , mClearValueMode( MinimumValue ) |
31 | 31 | , mCustomClearValue( 0.0 )
|
32 | 32 | {
|
33 | 33 | mClearButton = new QToolButton( this );
|
@@ -67,17 +67,39 @@ void QgsDoubleSpinBox::clear()
|
67 | 67 | setValue( clearValue() );
|
68 | 68 | }
|
69 | 69 |
|
70 |
| -void QgsDoubleSpinBox::setClearValue( QgsDoubleSpinBox::ClearValue type, double customValue ) |
| 70 | +void QgsDoubleSpinBox::setClearValue( double customValue , QString specialValueText ) |
71 | 71 | {
|
72 |
| - mClearValueType = type; |
| 72 | + mClearValueMode = CustomValue; |
73 | 73 | mCustomClearValue = customValue;
|
| 74 | + |
| 75 | + if ( !specialValueText.isEmpty() ) |
| 76 | + { |
| 77 | + double v = value(); |
| 78 | + clear(); |
| 79 | + setSpecialValueText( specialValueText ); |
| 80 | + setValue( v ); |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +void QgsDoubleSpinBox::setClearValueMode(QgsDoubleSpinBox::ClearValueMode mode, QString clearValueText ) |
| 85 | +{ |
| 86 | + mClearValueMode = mode; |
| 87 | + mCustomClearValue = 0; |
| 88 | + |
| 89 | + if ( !clearValueText.isEmpty() ) |
| 90 | + { |
| 91 | + double v = value(); |
| 92 | + clear(); |
| 93 | + setSpecialValueText( clearValueText ); |
| 94 | + setValue( v ); |
| 95 | + } |
74 | 96 | }
|
75 | 97 |
|
76 | 98 | double QgsDoubleSpinBox::clearValue()
|
77 | 99 | {
|
78 |
| - if ( mClearValueType == MinimumValue ) |
| 100 | + if ( mClearValueMode == MinimumValue ) |
79 | 101 | return minimum() ;
|
80 |
| - else if ( mClearValueType == MaximumValue ) |
| 102 | + else if ( mClearValueMode == MaximumValue ) |
81 | 103 | return maximum();
|
82 | 104 | else
|
83 | 105 | return mCustomClearValue;
|
|
0 commit comments