]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQMultiLineEdit.h
Duncan, for you
[duncan/yast2-qt4.git] / src / YQMultiLineEdit.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQMultiLineEdit.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQMultiLineEdit_h
21 #define YQMultiLineEdit_h
22
23 #include <QFrame>
24 #include "YMultiLineEdit.h"
25
26 class YQWidgetCaption;
27 class QTextEdit;
28
29
30 /**
31  * MultiLineEdit - an input area for multi-line text.
32  **/
33 class YQMultiLineEdit : public QFrame, public YMultiLineEdit
34 {
35     Q_OBJECT
36
37 public:
38     /**
39      * Constructor.
40      **/
41     YQMultiLineEdit( YWidget * parent, const string & label );
42
43     /**
44      * Destructor.
45      **/
46     virtual ~YQMultiLineEdit();
47
48     /**
49      * Get the current value (the text entered by the user or set from the
50      * outside) of this MultiLineEdit.
51      *
52      * Implemented from YMultiLineEdit.
53      **/
54     virtual string value();
55
56     /**
57      * Set the current value (the text entered by the user or set from the
58      * outside) of this MultiLineEdit.
59      *
60      * Implemented from YMultiLineEdit.
61      **/
62     virtual void setValue( const string & text );
63
64     /**
65      * Set the label (the caption above the MultiLineEdit).
66      *
67      * Reimplemented from YMultiLineEdit.
68      **/
69     virtual void setLabel( const string & label );
70
71     /**
72      * Set the maximum input length, i.e., the maximum number of characters the
73      * user can enter. -1 means no limit.
74      *
75      * Reimplemented from YMultiLineEdit.
76      **/
77     virtual void setInputMaxLength( int numberOfChars );
78
79     /**
80      * Set enabled/disabled state.
81      *
82      * Reimplemented from YWidget.
83      **/
84     virtual void setEnabled( bool enabled );
85
86     /**
87      * Preferred width of the widget.
88      *
89      * Reimplemented from YWidget.
90      **/
91     virtual int preferredWidth();
92
93     /**
94      * Preferred height of the widget.
95      *
96      * Reimplemented from YWidget.
97      **/
98     virtual int preferredHeight();
99
100     /**
101      * Set the new size of the widget.
102      *
103      * Reimplemented from YWidget.
104      **/
105     virtual void setSize( int newWidth, int newHeight );
106
107     /**
108      * Accept the keyboard focus.
109      **/
110     virtual bool setKeyboardFocus();
111
112
113 protected slots:
114
115     /**
116      * Triggered when the text changes.
117      **/
118     void changed();
119
120     /**
121      * Enforce the maximum input length: If the text becomes too long, remove
122      * the just-entered character at the current cursor position.
123      *
124      * Note that this is a lot more user friendly than silently truncating at
125      * the end of the text: In the latter case, chances are that the user never
126      * gets to know that text was truncated. Removing the just-typed character
127      * OTOH is something he will notice very quickly.
128      **/
129     void enforceMaxInputLength();
130
131
132 protected:
133
134     YQWidgetCaption *   _caption;
135     QTextEdit *         _qt_textEdit;
136 };
137
138
139 #endif // YQMultiLineEdit_h