KDE 4.7 PyKDE API Reference

- KDE's Python API

# KStringListValidator Class Reference

`from PyKDE4.kdeui import *`

Inherits: QValidator → QObject

## Detailed Description

A QValidator to (dis)allow certain strings

This validator allows you to accept only certain or to accept all but certain strings.

When used in rejecting mode, accepts only strings not in the stringlist. This mode is the default and comes in handy when asking the user for a name of some listed entity. Set the list of already used names to prevent the user from entering duplicate names.

When used in non-rejecting mode, accepts only strings that appear in the stringlist. Use with care! From a user's point of view this mode is hard to grasp.

This validator can also fix strings. In rejecting mode, a number will be appended to the string until it is Acceptable. E.g. if "foo" and "foo 1" are in the stringlist, then fixup will change "foo" to "foo 2", provided "foo 2" isn't in the list of forbidden strings.

In accepting mode, when the input starts with an Acceptable substring, truncates to the longest Acceptable string. When the input is the start of an Acceptable string, completes to the shortest Acceptable string.

NOTE: fixup isn't yet implemented.

Author:
  Marc Mutz <mutz@kde.org>

## Methods

| __init__ (self, QStringList list=QStringList(), bool rejecting=1, bool fixupEnabled=0, QObject parent=0)
| fixup (self, QString input)
bool | isFixupEnabled (self)
bool | isRejecting (self)
| setFixupEnabled (self, bool fixupEnabled)
| setRejecting (self, bool rejecting)
| setStringList (self, QStringList list)
QStringList | stringList (self)
QValidator::State, int pos | validate (self, QString input)

## Method Documentation

__init__ | ( | self, |
|  | QStringList | list=QStringList(),
|  | bool | rejecting=1,
|  | bool | fixupEnabled=0,
|  | QObject | parent=0
| ) |  |  |

Creates a new string validator.

Parameters:

  | list | The list of strings to (dis)allow.
  | rejecting | Selects the validator's mode (rejecting: true; accepting: false)
  | fixupEnabled | Selects whether to fix strings or not.
  | parent | Passed to lower level constructor.

fixup | ( | self, |
|  | QString | input
| ) |  |  |

Reimplemented from

See also:
  QValidator.

bool isFixupEnabled | ( |  | self ) |

Returns whether the fixup flag is set.

bool isRejecting | ( |  | self ) |

Returns whether the string validator is in rejecting mode.

setFixupEnabled | ( | self, |
|  | bool | fixupEnabled
| ) |  |  |

Sets the fixup flag. If enabled, wrong input is corrected automatically.

setRejecting | ( | self, |
|  | bool | rejecting
| ) |  |  |

Sets whether the string validator is in rejecting mode or not. If in rejecting mode, the strings from

See also:
  stringList are not allowed to appear in the validation string.

setStringList | ( | self, |
|  | QStringList | list
| ) |  |  |

Sets the

Parameters:

  | list | of string which is used as black or white list, depending on the rejecting mode (@see isRejecting()).

QStringList stringList | ( |  | self ) |

Returns the string list of the validator.

QValidator::State, int pos validate | ( | self, |
|  | QString | input
| ) |  |  |

Reimplemented from

See also:
  QValidator.