diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-12-11 16:15:55 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-12-11 16:15:55 +0900 |
commit | 931f81f9fe49f3fe339bb3cb23501393bfbb2d0a (patch) | |
tree | a9a654a2acd2bd8ddfc026fee8c1f9ea18ea8deb /konquest/int_validator.cpp | |
parent | eb03b1cb9c58427f256e50b857df40aae0db940e (diff) | |
download | tdegames-931f81f9fe49f3fe339bb3cb23501393bfbb2d0a.tar.gz tdegames-931f81f9fe49f3fe339bb3cb23501393bfbb2d0a.zip |
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'konquest/int_validator.cpp')
-rw-r--r-- | konquest/int_validator.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/konquest/int_validator.cpp b/konquest/int_validator.cpp new file mode 100644 index 00000000..dd96ca82 --- /dev/null +++ b/konquest/int_validator.cpp @@ -0,0 +1,53 @@ +#include <limits.h> + +#include "int_validator.h" +#include "int_validator.moc" + +IntValidator::IntValidator( TQWidget *parent, const char *name ) : + TQValidator( TQT_TQOBJECT(parent), name ) +{ +#ifdef INT_MIN + v_bottom = INT_MIN; +#else + v_bottom = ~INT_MAX; +#endif + v_top = INT_MIN; +} + +IntValidator::IntValidator( int bottom, int top, TQWidget *parent, const char *name ) : +TQValidator( TQT_TQOBJECT(parent), name ) +{ + v_bottom = bottom; + v_top = top; +} + +IntValidator::~IntValidator() {} + +TQValidator::State +IntValidator::validate( TQString &input, int & ) const +{ + if( input.isEmpty() ) { + return TQValidator::Valid; + } else { + bool ok; + + int value = input.toInt( &ok ); + + if( !ok ) + return TQValidator::Invalid; + + if( value < v_bottom || value > v_top ) + return TQValidator::Valid; + + return TQValidator::Acceptable; + } +} + +void +IntValidator::setRange( int b, int t ) +{ + v_bottom = b; + v_top = t; +} + + |