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

tdeui

  • tdeui
krestrictedline.cpp
1/*
2 *
3 *
4 * Implementation of KRestrictedLine
5 *
6 * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 */
23
24#include <tqkeycode.h>
25
26#include "krestrictedline.h"
27
28KRestrictedLine::KRestrictedLine( TQWidget *parent,
29 const char *name,
30 const TQString& valid )
31 : KLineEdit( parent, name )
32{
33 qsValidChars = valid;
34}
35
36KRestrictedLine::~KRestrictedLine()
37{
38 ;
39}
40
41
42void KRestrictedLine::keyPressEvent( TQKeyEvent *e )
43{
44 // let TQLineEdit process "special" keys and return/enter
45 // so that we still can use the default key binding
46 if (e->key() == Key_Enter || e->key() == Key_Return || e->key() == Key_Delete || e->ascii() < 32)
47 {
48 TQLineEdit::keyPressEvent(e);
49 return;
50 }
51
52 // do we have a list of valid chars &&
53 // is the pressed key in the list of valid chars?
54 if (!qsValidChars.isEmpty() && !qsValidChars.contains(e->ascii()))
55 {
56 // invalid char, emit signal and return
57 emit (invalidChar(e->key()));
58 return;
59 }
60 else
61 // valid char: let TQLineEdit process this key as usual
62 TQLineEdit::keyPressEvent(e);
63
64 return;
65}
66
67
68void KRestrictedLine::setValidChars( const TQString& valid)
69{
70 qsValidChars = valid;
71}
72
73TQString KRestrictedLine::validChars() const
74{
75 return qsValidChars;
76}
77
78void KRestrictedLine::virtual_hook( int id, void* data )
79{ KLineEdit::virtual_hook( id, data ); }
80
81#include "krestrictedline.moc"
KLineEdit
An enhanced TQLineEdit widget for inputting text.
Definition: klineedit.h:146
KRestrictedLine::keyPressEvent
void keyPressEvent(TQKeyEvent *e)
Re-implemented for internal reasons.
Definition: krestrictedline.cpp:42
KRestrictedLine::setValidChars
void setValidChars(const TQString &valid)
All characters in the string valid are treated as acceptable characters.
Definition: krestrictedline.cpp:68
KRestrictedLine::invalidChar
void invalidChar(int)
Emitted when an invalid character was typed.
KRestrictedLine::validChars
TQString validChars() const
Definition: krestrictedline.cpp:73
KRestrictedLine::KRestrictedLine
KRestrictedLine(TQWidget *parent=0, const char *name=0, const TQString &valid=TQString::null)
Constructor: This contructor takes three - optional - arguments.
Definition: krestrictedline.cpp:28
KRestrictedLine::~KRestrictedLine
~KRestrictedLine()
Destructs the restricted line editor.
Definition: krestrictedline.cpp:36

tdeui

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

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.