• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdeui
 

kdeui

krestrictedline.cpp
00001 /*
00002  *
00003  *
00004  * Implementation of KRestrictedLine
00005  *
00006  * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Library General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Library General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Library General Public
00019  * License along with this library; if not, write to the Free
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021  *
00022  */
00023 
00024 #include <tqkeycode.h>
00025 
00026 #include "krestrictedline.h"
00027 
00028 KRestrictedLine::KRestrictedLine( TQWidget *parent,
00029                   const char *name,
00030                   const TQString& valid )
00031   : KLineEdit( parent, name )
00032 {
00033     qsValidChars = valid;
00034 }
00035 
00036 KRestrictedLine::~KRestrictedLine()
00037 {
00038   ;
00039 }
00040 
00041 
00042 void KRestrictedLine::keyPressEvent( TQKeyEvent *e )
00043 {
00044   // let TQLineEdit process "special" keys and return/enter
00045   // so that we still can use the default key binding
00046   if (e->key() == Key_Enter || e->key() == Key_Return || e->key() == Key_Delete || e->ascii() < 32)
00047     {
00048       TQLineEdit::keyPressEvent(e);
00049       return;
00050     }
00051 
00052   // do we have a list of valid chars &&
00053   // is the pressed key in the list of valid chars?
00054   if (!qsValidChars.isEmpty() && !qsValidChars.contains(e->ascii()))
00055     {
00056       // invalid char, emit signal and return
00057       emit (invalidChar(e->key()));
00058       return;
00059     }
00060   else
00061     // valid char: let TQLineEdit process this key as usual
00062     TQLineEdit::keyPressEvent(e);
00063 
00064   return;
00065 }
00066 
00067 
00068 void KRestrictedLine::setValidChars( const TQString& valid)
00069 {
00070   qsValidChars = valid;
00071 }
00072 
00073 TQString 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"

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeui

Skip menu "kdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeui by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |