summaryrefslogtreecommitdiffstats
path: root/konquest/int_validator.cc
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitc90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch)
tree6d8391395bce9eaea4ad78958617edb20c6a7573 /konquest/int_validator.cc
downloadtdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz
tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konquest/int_validator.cc')
-rw-r--r--konquest/int_validator.cc53
1 files changed, 53 insertions, 0 deletions
diff --git a/konquest/int_validator.cc b/konquest/int_validator.cc
new file mode 100644
index 00000000..85fd1779
--- /dev/null
+++ b/konquest/int_validator.cc
@@ -0,0 +1,53 @@
+#include <limits.h>
+
+#include "int_validator.h"
+#include "int_validator.moc"
+
+IntValidator::IntValidator( QWidget *parent, const char *name ) :
+ QValidator( 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, QWidget *parent, const char *name ) :
+QValidator( parent, name )
+{
+ v_bottom = bottom;
+ v_top = top;
+}
+
+IntValidator::~IntValidator() {}
+
+QValidator::State
+IntValidator::validate( QString &input, int & ) const
+{
+ if( input.isEmpty() ) {
+ return QValidator::Valid;
+ } else {
+ bool ok;
+
+ int value = input.toInt( &ok );
+
+ if( !ok )
+ return QValidator::Invalid;
+
+ if( value < v_bottom || value > v_top )
+ return QValidator::Valid;
+
+ return QValidator::Acceptable;
+ }
+}
+
+void
+IntValidator::setRange( int b, int t )
+{
+ v_bottom = b;
+ v_top = t;
+}
+
+