Skip to content
Permalink
Browse files

define the special text directly with the clear value

  • Loading branch information
3nids committed Dec 4, 2014
1 parent e887d07 commit 1a4b8bb40dd92c18bc55cc75900575798a470d0f
@@ -5,7 +5,7 @@ class QgsDoubleSpinBox : QDoubleSpinBox
%End

public:
enum ClearValue
enum ClearValueMode
{
MinimumValue,
MaximumValue,
@@ -23,10 +23,17 @@ class QgsDoubleSpinBox : QDoubleSpinBox
virtual void clear();

/**
* @brief setClearValue defines if the clear value should be the minimum or maximum values of the widget or a custom value
* @param customValue if type is CustomValue, defines the numerical value used as the clear value
* @brief setClearValue defines the clear value as a custom value and will automatically set the clear value mode to CustomValue
* @param defines the numerical value used as the clear value
* @param clearValueText is the text displayed when the spin box is at the clear value. If not specified, no special value text is used.
*/
void setClearValue( ClearValue type, double customValue = 0 );
void setClearValue( double customValue, QString clearValueText = QString() );
/**
* @brief setClearValueMode defines if the clear value should be the minimum or maximum values of the widget or a custom value
* @param clearValueText is the text displayed when the spin box is at the clear value. If not specified, no special value text is used.
*/
void setClearValueMode( ClearValueMode mode, QString clearValueText = QString() );

//! returns the value used when clear() is called.
double clearValue();

@@ -5,7 +5,7 @@ class QgsSpinBox : QSpinBox
%End

public:
enum ClearValue
enum ClearValueMode
{
MinimumValue,
MaximumValue,
@@ -23,10 +23,17 @@ class QgsSpinBox : QSpinBox
virtual void clear();

/**
* @brief setClearValue defines if the clear value should be the minimum or maximum values of the widget or a custom value
* @param customValue if type is CustomValue, defines the numerical value used as the clear value
* @brief setClearValue defines the clear value as a custom value and will automatically set the clear value mode to CustomValue
* @param defines the numerical value used as the clear value
* @param clearValueText is the text displayed when the spin box is at the clear value. If not specified, no special value text is used.
*/
void setClearValue( ClearValue type, int customValue = 0 );
void setClearValue( int customValue, QString clearValueText = QString() );
/**
* @brief setClearValueMode defines if the clear value should be the minimum or maximum values of the widget or a custom value
* @param clearValueText is the text displayed when the spin box is at the clear value. If not specified, no special value text is used.
*/
void setClearValueMode( ClearValueMode mode, QString clearValueText = QString() );

//! returns the value used when clear() is called.
int clearValue();

@@ -27,7 +27,7 @@
QgsDoubleSpinBox::QgsDoubleSpinBox( QWidget *parent )
: QDoubleSpinBox( parent )
, mShowClearButton( true )
, mClearValueType( MinimumValue )
, mClearValueMode( MinimumValue )
, mCustomClearValue( 0.0 )
{
mClearButton = new QToolButton( this );
@@ -67,17 +67,39 @@ void QgsDoubleSpinBox::clear()
setValue( clearValue() );
}

void QgsDoubleSpinBox::setClearValue( QgsDoubleSpinBox::ClearValue type, double customValue )
void QgsDoubleSpinBox::setClearValue( double customValue , QString specialValueText )
{
mClearValueType = type;
mClearValueMode = CustomValue;
mCustomClearValue = customValue;

if ( !specialValueText.isEmpty() )
{
double v = value();
clear();
setSpecialValueText( specialValueText );
setValue( v );
}
}

void QgsDoubleSpinBox::setClearValueMode(QgsDoubleSpinBox::ClearValueMode mode, QString clearValueText )
{
mClearValueMode = mode;
mCustomClearValue = 0;

if ( !clearValueText.isEmpty() )
{
double v = value();
clear();
setSpecialValueText( clearValueText );
setValue( v );
}
}

double QgsDoubleSpinBox::clearValue()
{
if ( mClearValueType == MinimumValue )
if ( mClearValueMode == MinimumValue )
return minimum() ;
else if ( mClearValueType == MaximumValue )
else if ( mClearValueMode == MaximumValue )
return maximum();
else
return mCustomClearValue;
@@ -30,7 +30,7 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox
Q_PROPERTY( bool showClearButton READ showClearButton WRITE setShowClearButton )

public:
enum ClearValue
enum ClearValueMode
{
MinimumValue,
MaximumValue,
@@ -47,10 +47,17 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox
virtual void clear();

/**
* @brief setClearValue defines if the clear value should be the minimum or maximum values of the widget or a custom value
* @param customValue if type is CustomValue, defines the numerical value used as the clear value
* @brief setClearValue defines the clear value as a custom value and will automatically set the clear value mode to CustomValue
* @param defines the numerical value used as the clear value
* @param clearValueText is the text displayed when the spin box is at the clear value. If not specified, no special value text is used.
*/
void setClearValue( ClearValue type, double customValue = 0 );
void setClearValue( double customValue, QString clearValueText = QString() );
/**
* @brief setClearValueMode defines if the clear value should be the minimum or maximum values of the widget or a custom value
* @param clearValueText is the text displayed when the spin box is at the clear value. If not specified, no special value text is used.
*/
void setClearValueMode( ClearValueMode mode, QString clearValueText = QString() );

//! returns the value used when clear() is called.
double clearValue();

@@ -65,7 +72,7 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox
int frameWidth() const;

bool mShowClearButton;
ClearValue mClearValueType;
ClearValueMode mClearValueMode;
double mCustomClearValue;

QToolButton* mClearButton;
@@ -27,7 +27,7 @@
QgsSpinBox::QgsSpinBox( QWidget *parent )
: QSpinBox( parent )
, mShowClearButton( true )
, mClearValueType( MinimumValue )
, mClearValueMode( MinimumValue )
, mCustomClearValue( 0 )
{
mClearButton = new QToolButton( this );
@@ -67,17 +67,39 @@ void QgsSpinBox::clear()
setValue( clearValue() );
}

void QgsSpinBox::setClearValue( QgsSpinBox::ClearValue type, int customValue )
void QgsSpinBox::setClearValue( int customValue, QString specialValueText )
{
mClearValueType = type;
mClearValueMode = CustomValue;
mCustomClearValue = customValue;

if ( !specialValueText.isEmpty() )
{
int v = value();
clear();
setSpecialValueText( specialValueText );
setValue( v );
}
}

void QgsSpinBox::setClearValueMode(QgsSpinBox::ClearValueMode mode, QString specialValueText )
{
mClearValueMode = mode;
mCustomClearValue = 0;

if ( !specialValueText.isEmpty() )
{
int v = value();
clear();
setSpecialValueText( specialValueText );
setValue( v );
}
}

int QgsSpinBox::clearValue()
{
if ( mClearValueType == MinimumValue )
if ( mClearValueMode == MinimumValue )
return minimum() ;
else if ( mClearValueType == MaximumValue )
else if ( mClearValueMode == MaximumValue )
return maximum();
else
return mCustomClearValue;
@@ -30,7 +30,7 @@ class GUI_EXPORT QgsSpinBox : public QSpinBox
Q_PROPERTY( bool showClearButton READ showClearButton WRITE setShowClearButton )

public:
enum ClearValue
enum ClearValueMode
{
MinimumValue,
MaximumValue,
@@ -47,10 +47,17 @@ class GUI_EXPORT QgsSpinBox : public QSpinBox
virtual void clear();

/**
* @brief setClearValue defines if the clear value should be the minimum or maximum values of the widget or a custom value
* @param customValue if type is CustomValue, defines the numerical value used as the clear value
* @brief setClearValue defines the clear value for the widget and will automatically set the clear value mode to CustomValue
* @param defines the numerical value used as the clear value
* @param clearValueText is the text displayed when the spin box is at the clear value. If not specified, no special value text is used.
*/
void setClearValue( ClearValue type, int customValue = 0 );
void setClearValue( int customValue, QString clearValueText = QString() );
/**
* @brief setClearValueMode defines if the clear value should be the minimum or maximum values of the widget or a custom value
* @param clearValueText is the text displayed when the spin box is at the clear value. If not specified, no special value text is used.
*/
void setClearValueMode( ClearValueMode mode, QString clearValueText = QString() );

//! returns the value used when clear() is called.
int clearValue();

@@ -65,7 +72,7 @@ class GUI_EXPORT QgsSpinBox : public QSpinBox
int frameWidth() const;

bool mShowClearButton;
ClearValue mClearValueType;
ClearValueMode mClearValueMode;
int mCustomClearValue;

QToolButton* mClearButton;

0 comments on commit 1a4b8bb

Please sign in to comment.
You can’t perform that action at this time.