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
00025
#include <qkeycode.h>
00026
00027
#include "krestrictedline.h"
00028
00029 KRestrictedLine::KRestrictedLine(
QWidget *parent,
00030
const char *name,
00031
const QString& valid )
00032 :
KLineEdit( parent, name )
00033 {
00034 qsValidChars = valid;
00035 }
00036
00037 KRestrictedLine::~KRestrictedLine()
00038 {
00039 ;
00040 }
00041
00042
00043 void KRestrictedLine::keyPressEvent(
QKeyEvent *e )
00044 {
00045
00046
00047
if (e->
key() == Key_Enter || e->
key() == Key_Return || e->
key() == Key_Delete || e->
ascii() < 32)
00048 {
00049 QLineEdit::keyPressEvent(e);
00050
return;
00051 }
00052
00053
00054
00055
if (!qsValidChars.
isEmpty() && !qsValidChars.
contains(e->
ascii()))
00056 {
00057
00058 emit (
invalidChar(e->
key()));
00059
return;
00060 }
00061
else
00062
00063 QLineEdit::keyPressEvent(e);
00064
00065
return;
00066 }
00067
00068
00069 void KRestrictedLine::setValidChars(
const QString& valid)
00070 {
00071 qsValidChars = valid;
00072 }
00073
00074
QString KRestrictedLine::validChars()
const
00075
{
00076
return qsValidChars;
00077 }
00078
00079
void KRestrictedLine::virtual_hook(
int id,
void* data )
00080 { KLineEdit::virtual_hook(
id, data ); }
00081
00082
#include "krestrictedline.moc"
This file is part of the documentation for kdeui Library Version 3.2.3.