libyui-qt
YQInputField.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQInputField.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQInputField_h
27 #define YQInputField_h
28 
29 #include <QFrame>
30 #include <qlineedit.h>
31 
32 #include <yui/YInputField.h>
33 
34 typedef union _XEvent XEvent;
35 class QString;
36 class QY2CharValidator;
37 class YQWidgetCaption;
38 class YQRawLineEdit;
39 
40 using std::string;
41 
42 
43 class YQInputField : public QFrame, public YInputField
44 {
45  Q_OBJECT
46 
47 public:
51  YQInputField( YWidget * parent,
52  const std::string & label,
53  bool passwordMode = false );
54 
61  virtual std::string value();
62 
69  virtual void setValue( const std::string & text );
70 
76  virtual void setLabel( const std::string & label );
77 
84  virtual void setValidChars( const std::string & validChars );
85 
91  virtual void setInputMaxLength( int numberOfChars );
92 
96  bool isValidText( const QString & text ) const;
97 
103  virtual void setEnabled( bool enabled );
104 
110  virtual int preferredWidth();
111 
117  virtual int preferredHeight();
118 
124  virtual void setSize( int newWidth, int newHeight );
125 
131  virtual bool setKeyboardFocus();
132 
133 
134 protected slots:
139  void changed( const QString & );
140 
145  void displayCapsLockWarning();
146 
150  void clearCapsLockWarning();
151 
152 
153 protected:
154 
155  YQWidgetCaption * _caption;
156  YQRawLineEdit * _qt_lineEdit;
157  QY2CharValidator * _validator;
158  bool _shrinkable;
159  bool _displayingCapsLockWarning;
160 };
161 
162 
167 class YQRawLineEdit: public QLineEdit
168 {
169  Q_OBJECT
170 
171 public:
172 
176  YQRawLineEdit( QWidget * parent )
177  : QLineEdit( parent )
178  , _capsLockActive( false )
179  {}
180 
184  virtual ~YQRawLineEdit() {};
185 
190  bool isCapsLockActive() const { return _capsLockActive; }
191 
192 
193 signals:
194  void capsLockActivated();
195  void capsLockDeactivated();
196 
197 protected:
198 
205  bool x11Event( XEvent * event ) ;
206 
207 private:
208 
209  bool _capsLockActive;
210 };
211 
212 #endif // YQInputField_h
virtual void setEnabled(bool enabled)
Definition: YQInputField.cc:118
virtual void setValue(const std::string &text)
Definition: YQInputField.cc:102
YQInputField(YWidget *parent, const std::string &label, bool passwordMode=false)
Definition: YQInputField.cc:54
Definition: YQInputField.h:167
Definition: YQInputField.h:43
YQRawLineEdit(QWidget *parent)
Definition: YQInputField.h:176
bool x11Event(XEvent *event)
Definition: YQInputField.cc:256
bool isValidText(const QString &text) const
Definition: YQInputField.cc:156
virtual void setSize(int newWidth, int newHeight)
Definition: YQInputField.cc:143
virtual void setInputMaxLength(int numberOfChars)
Definition: YQInputField.cc:196
virtual void setLabel(const std::string &label)
Definition: YQInputField.cc:149
virtual int preferredWidth()
Definition: YQInputField.cc:126
virtual bool setKeyboardFocus()
Definition: YQInputField.cc:202
virtual ~YQRawLineEdit()
Definition: YQInputField.h:184
virtual void setValidChars(const std::string &validChars)
Definition: YQInputField.cc:168
void displayCapsLockWarning()
Definition: YQInputField.cc:218
virtual int preferredHeight()
Definition: YQInputField.cc:137
bool isCapsLockActive() const
Definition: YQInputField.h:190
Definition: YQWidgetCaption.h:38
void clearCapsLockWarning()
Definition: YQInputField.cc:242
Definition: QY2CharValidator.h:34
virtual std::string value()
Definition: YQInputField.cc:96
void changed(const QString &)
Definition: YQInputField.cc:211