home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / krestrictedline.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  2.7 KB  |  96 lines

  1. /*
  2.  *
  3.  * $Id: krestrictedline.h 465272 2005-09-29 09:47:40Z mueller $
  4.  *
  5.  * Definition of KRestrictedLine
  6.  *
  7.  * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de>
  8.  *
  9.  * This library is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU Library General Public
  11.  * License as published by the Free Software Foundation; either
  12.  * version 2 of the License, or (at your option) any later version.
  13.  *
  14.  * This library is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.  * Library General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU Library General Public
  20.  * License along with this library; if not, write to the Free
  21.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  22.  *
  23.  */
  24.  
  25. #ifndef KRESTRICTEDLINE_H
  26. #define KRESTRICTEDLINE_H
  27.  
  28. #include <klineedit.h>
  29.  
  30. /**
  31.  * @short A line editor for restricted character sets.
  32.  *
  33.  * The KRestrictedLine widget is a variant of QLineEdit which
  34.  * accepts only a restricted set of characters as input.
  35.  * All other characters will be discarded and the signal invalidChar()
  36.  * will be emitted for each of them.
  37.  *
  38.  * Valid characters can be passed as a QString to the constructor
  39.  * or set afterwards via setValidChars().
  40.  * The default key bindings of QLineEdit are still in effect.
  41.  *
  42.  * @author Michael Wiedmann <mw@miwie.in-berlin.de>
  43.  */
  44. class KDEUI_EXPORT KRestrictedLine : public KLineEdit
  45. {
  46.   Q_OBJECT
  47.   Q_PROPERTY( QString validChars READ validChars WRITE setValidChars )
  48.  
  49. public:
  50.  
  51.   /**
  52.    * Constructor: This contructor takes three - optional - arguments.
  53.    *  The first two parameters are simply passed on to QLineEdit.
  54.    *  @param parent   pointer to the parent widget
  55.    *  @param name     pointer to the name of this widget
  56.    *  @param valid    pointer to set of valid characters
  57.    */
  58.   KRestrictedLine( QWidget *parent=0, const char *name=0,
  59.            const QString& valid = QString::null);
  60.  
  61.   /**
  62.    * Destructs the restricted line editor.
  63.    */
  64.   ~KRestrictedLine();
  65.  
  66.   /**
  67.    * All characters in the string valid are treated as
  68.    * acceptable characters.
  69.    */
  70.   void setValidChars(const QString& valid);
  71.   /**
  72.    * @return the string of acceptable characters.
  73.    */
  74.   QString validChars() const;
  75.  
  76. signals:
  77.  
  78.   /**
  79.    * Emitted when an invalid character was typed.
  80.    */
  81.   void    invalidChar(int);
  82.  
  83. protected:
  84.   void    keyPressEvent( QKeyEvent *e );
  85.  
  86. private:
  87.   /// QString of valid characters for this line
  88.   QString    qsValidChars;
  89. protected:
  90.   virtual void virtual_hook( int id, void* data );
  91. private:
  92.   class KRestrictedLinePrivate* d;
  93. };
  94.  
  95. #endif // KRESTRICTEDLINE_H
  96.