Kexi API Documentation (2.0 alpha)

KexiUtils::Validator Class Reference

#include <validator.h>

Inheritance diagram for KexiUtils::Validator:

QValidator KexiDB::ObjectNameValidator KexiUtils::IdentifierValidator KexiUtils::MultiValidator KexiDB::FieldValidator List of all members.

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:

It also offers error and warning messages for check() method. You may need to reimplement:

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)
virtual ~Validator ()
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)
 Adds a child validator v.

Static Public Member Functions

static const QString msgColumnNotEmpty ()
 A generic error/warning message.

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 Enumeration Documentation

enum KexiUtils::Validator::Result
 

Enumeration values:
Error 
Ok 
Warning 

Definition at line 48 of file validator.h.


Constructor & Destructor Documentation

Validator::Validator QObject *  parent = 0,
const char *  name = 0
 

Definition at line 24 of file validator.cpp.

Validator::~Validator  )  [virtual]
 

Definition at line 30 of file validator.cpp.


Member Function Documentation

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.

Referenced by KexiNameWidget::isNameRequired().

void KexiUtils::Validator::addChildValidator Validator v  ) 
 

Adds a child validator v.

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.

References Error, internalCheck(), m_acceptsEmptyValue, msgColumnNotEmpty(), and Ok.

Referenced by KexiNameWidget::checkValidity().

Validator::Result Validator::internalCheck const QString valueName,
const QVariant &  v,
QString message,
QString details
[protected, virtual]
 

Reimplemented in KexiDB::ObjectNameValidator, and KexiUtils::IdentifierValidator.

Definition at line 47 of file validator.cpp.

References Error.

Referenced by check().

static const QString KexiUtils::Validator::msgColumnNotEmpty  )  [inline, static]
 

A generic error/warning message.

Definition at line 77 of file validator.h.

Referenced by check().

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.

Referenced by KexiNameWidget::setNameRequired().

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.


Friends And Related Function Documentation

friend class MultiValidator [friend]
 

Definition at line 91 of file validator.h.


Member Data Documentation

bool KexiUtils::Validator::m_acceptsEmptyValue [protected]
 

Definition at line 89 of file validator.h.

Referenced by check().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:50:55 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003