krestrictedline.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#include <qkeycode.h>
00025
00026
#include "krestrictedline.h"
00027
00028 KRestrictedLine::KRestrictedLine(
QWidget *parent,
00029
const char *name,
00030
const QString& valid )
00031 :
KLineEdit( parent, name )
00032 {
00033 qsValidChars = valid;
00034 }
00035
00036 KRestrictedLine::~KRestrictedLine()
00037 {
00038 ;
00039 }
00040
00041
00042 void KRestrictedLine::keyPressEvent(
QKeyEvent *e )
00043 {
00044
00045
00046
if (e->
key() == Key_Enter || e->
key() == Key_Return || e->
key() == Key_Delete || e->
ascii() < 32)
00047 {
00048 QLineEdit::keyPressEvent(e);
00049
return;
00050 }
00051
00052
00053
00054
if (!qsValidChars.
isEmpty() && !qsValidChars.
contains(e->
ascii()))
00055 {
00056
00057 emit (
invalidChar(e->
key()));
00058
return;
00059 }
00060
else
00061
00062 QLineEdit::keyPressEvent(e);
00063
00064
return;
00065 }
00066
00067
00068 void KRestrictedLine::setValidChars(
const QString& valid)
00069 {
00070 qsValidChars = valid;
00071 }
00072
00073
QString KRestrictedLine::validChars()
const
00074
{
00075
return qsValidChars;
00076 }
00077
00078
void KRestrictedLine::virtual_hook(
int id,
void* data )
00079 { KLineEdit::virtual_hook(
id, data ); }
00080
00081
#include "krestrictedline.moc"
This file is part of the documentation for kdeui Library Version 3.4.0.