From c32c76114a2bbdd02edd89fd43a5db33bf090edc Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 17 Jul 2015 22:14:03 +0000 Subject: [PATCH] kdeui: drop unused and deprecated KFloatValidator --- kdeui/util/knumvalidator.cpp | 138 +---------------------------------- kdeui/util/knumvalidator.h | 68 ----------------- 2 files changed, 1 insertion(+), 205 deletions(-) diff --git a/kdeui/util/knumvalidator.cpp b/kdeui/util/knumvalidator.cpp index c4268a19..e320a43e 100644 --- a/kdeui/util/knumvalidator.cpp +++ b/kdeui/util/knumvalidator.cpp @@ -1,7 +1,7 @@ /********************************************************************** ** ** -** KIntValidator, KFloatValidator: +** KIntValidator: ** Copyright (C) 1999 Glen Parker ** KDoubleValidator: ** Copyright (c) 2002 Marc Mutz @@ -152,142 +152,6 @@ int KIntValidator::base () const } -/////////////////////////////////////////////////////////////// -// Implementation of KFloatValidator -// - -class KFloatValidator::KFloatValidatorPrivate -{ -public: - KFloatValidatorPrivate() - : acceptLocalizedNumbers(false), _min(0), _max(0) - {} - bool acceptLocalizedNumbers; - double _min; - double _max; -}; - - -KFloatValidator::KFloatValidator ( QWidget * parent ) - : QValidator(parent), d(new KFloatValidatorPrivate) -{ - d->acceptLocalizedNumbers=false; -} - -KFloatValidator::KFloatValidator ( double bottom, double top, QWidget * parent ) - : QValidator(parent), d(new KFloatValidatorPrivate) -{ - d->acceptLocalizedNumbers=false; - setRange(bottom, top); -} - -KFloatValidator::KFloatValidator ( double bottom, double top, bool localeAware, QWidget * parent ) - : QValidator(parent), d(new KFloatValidatorPrivate) -{ - d->acceptLocalizedNumbers = localeAware; - setRange(bottom, top); -} - -KFloatValidator::~KFloatValidator () -{ - delete d; -} - -void KFloatValidator::setAcceptLocalizedNumbers(bool _b) -{ - d->acceptLocalizedNumbers=_b; -} - -bool KFloatValidator::acceptLocalizedNumbers() const -{ - return d->acceptLocalizedNumbers; -} - -QValidator::State KFloatValidator::validate ( QString &str, int & ) const -{ - bool ok; - double val = 0; - QString newStr; - newStr = str.trimmed(); - - if (newStr == QLatin1String("-")) {// a special case - if ((d->_min || d->_max) && d->_min >= 0) - ok = false; - else - return QValidator::Acceptable; - } - else if (newStr == QLatin1String(".") || (d->acceptLocalizedNumbers && newStr==KGlobal::locale()->decimalSymbol())) // another special case - return QValidator::Acceptable; - else if (!newStr.isEmpty()) - { - val = newStr.toDouble(&ok); - if(!ok && d->acceptLocalizedNumbers) - val= KGlobal::locale()->readNumber(newStr,&ok); - } - else { - val = 0; - ok = true; - } - - if (! ok) - return QValidator::Invalid; - - if (( !d->_min && !d->_max) || (val >= d->_min && val <= d->_max)) - return QValidator::Acceptable; - - if (d->_max && d->_min >= 0 && val < 0) - return QValidator::Invalid; - - if ( (d->_min || d->_max) && (val < d->_min || val > d->_max)) - return QValidator::Invalid; - - return QValidator::Intermediate; -} - -void KFloatValidator::fixup ( QString &str ) const -{ - int dummy; - double val; - QValidator::State state; - - state = validate(str, dummy); - - if (state == QValidator::Invalid || state == QValidator::Acceptable) - return; - - if (! d->_min && ! d->_max) - return; - - val = str.toDouble(); - - if (val < d->_min) val = d->_min; - if (val > d->_max) val = d->_max; - - str.setNum(val); -} - -void KFloatValidator::setRange ( double bottom, double top ) -{ - d->_min = bottom; - d->_max = top; - - if (d->_max < d->_min) - d->_max = d->_min; -} - -double KFloatValidator::bottom () const -{ - return d->_min; -} - -double KFloatValidator::top () const -{ - return d->_max; -} - - - - /////////////////////////////////////////////////////////////// // Implementation of KDoubleValidator // diff --git a/kdeui/util/knumvalidator.h b/kdeui/util/knumvalidator.h index 6f92d2f6..0075f865 100644 --- a/kdeui/util/knumvalidator.h +++ b/kdeui/util/knumvalidator.h @@ -89,74 +89,6 @@ class KDEUI_EXPORT KIntValidator : public QValidator { KIntValidatorPrivate * const d; }; -/** - \brief QValidator for floating point entry (Obsolete) - - @obsolete Use KDoubleValidator - - Extends the QValidator class to properly validate double numeric data. - This can be used by QLineEdit or subclass to provide validated - text entry. - - @author Glen Parker - @version 0.0.1 -*/ -class KDEUI_EXPORT_DEPRECATED KFloatValidator : public QValidator { - - public: - /** - * Constructor. - */ - explicit KFloatValidator ( QWidget * parent ); - /** - * Constructor. Also sets the minimum and maximum values. - */ - KFloatValidator ( double bottom, double top, QWidget * parent ); - /** - * Constructor. Sets the validator to be locale aware if @p localeAware is true. - */ - KFloatValidator ( double bottom, double top, bool localeAware, QWidget * parent ); - /** - * Destructs the validator. - */ - virtual ~KFloatValidator (); - /** - * Validates the text, and return the result. Does not modify the parameters. - */ - virtual State validate ( QString &, int & ) const; - /** - * Fixes the text if possible, providing a valid string. The parameter may be modified. - */ - virtual void fixup ( QString & ) const; - /** - * Sets the minimum and maximum value allowed. - */ - virtual void setRange ( double bottom, double top ); - /** - * Returns the current minimum value allowed. - */ - virtual double bottom () const; - /** - * Returns the current maximum value allowed. - */ - virtual double top () const; - /** - * Sets the validator to be locale aware if @p is true. In this case, the - * character KLocale::decimalSymbol() from the global locale is recognized - * as decimal separator. - */ - void setAcceptLocalizedNumbers(bool b); - /** - * Returns true if the validator is locale aware. - * @see setAcceptLocalizedNumbers(). - */ - bool acceptLocalizedNumbers() const; - - private: - class KFloatValidatorPrivate; - KFloatValidatorPrivate * const d; -}; - /** @short A locale-aware QDoubleValidator