kexi
KexiUtils::Validator Class Reference
#include <validator.h>

Detailed Description
A validator extending QValidator with offline-checking for value's validity.The offline-checking for value's validity is provided by Validator::check() method. The validator groups two purposes into one container:
- string validator for line editors (online checking, "on typing");
- offline-checking for QVariant values, reimplementing validate().
It also offers error and warning messages for check() method. You may need to reimplement:
- QValidator::State IdentifierValidator::validate( QString& input, int& pos ) const;
- Result check(const QString &valueName, QVariant v, QString &message, QString &details);
Definition at line 45 of file validator.h.
Public Types | |
enum | Result { Error = 0, Ok = 1, Warning = 2 } |
Public Member Functions | |
Validator (QObject *parent=0, const char *name=0) | |
void | setAcceptsEmptyValue (bool set) |
bool | acceptsEmptyValue () const |
Result | check (const QString &valueName, const QVariant &v, QString &message, QString &details) |
virtual QValidator::State | validate (QString &input, int &pos) const |
void | addChildValidator (Validator *v) |
Static Public Member Functions | |
static const QString | msgColumnNotEmpty () |
Protected Member Functions | |
virtual Result | internalCheck (const QString &valueName, const QVariant &v, QString &message, QString &details) |
Protected Attributes | |
bool | m_acceptsEmptyValue: 1 |
Friends | |
class | MultiValidator |
Member Function Documentation
void KexiUtils::Validator::setAcceptsEmptyValue | ( | bool | set | ) | [inline] |
Sets accepting empty values on (true) or off (false). By default the validator does not accepts empty values.
Definition at line 55 of file validator.h.
bool KexiUtils::Validator::acceptsEmptyValue | ( | ) | const [inline] |
- Returns:
- true if the validator accepts empty values
- See also:
- setAcceptsEmptyValue()
Definition at line 59 of file validator.h.
Validator::Result Validator::check | ( | const QString & | valueName, | |
const QVariant & | v, | |||
QString & | message, | |||
QString & | details | |||
) |
Checks if value v is ok and returns one of Result value:
- Error is returned on error;
- Ok on success;
- Warning if there is something to warn about. In any case except Ok, i18n'ed message will be set in message and (optionally) datails are set in details, e.g. for use in a message box. valueName can be used to contruct message as well, for example: "[valueName] is not a valid login name". Depending on acceptsEmptyValue(), immediately accepts empty values or not.
Definition at line 34 of file validator.cpp.
QValidator::State Validator::validate | ( | QString & | input, | |
int & | pos | |||
) | const [virtual] |
This implementation always returns value QValidator::Acceptable.
Reimplemented in KexiUtils::IdentifierValidator, and KexiUtils::MultiValidator.
Definition at line 53 of file validator.cpp.
static const QString KexiUtils::Validator::msgColumnNotEmpty | ( | ) | [inline, static] |
void KexiUtils::Validator::addChildValidator | ( | Validator * | v | ) |
Adds a child validator v.
The documentation for this class was generated from the following files: