]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQComboBox.h
clicking packages work! so the package selector is now
[duncan/yast2-qt4.git] / src / YQComboBox.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQComboBox.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQComboBox_h
21 #define YQComboBox_h
22
23 #include <QFrame>
24 #include "YComboBox.h"
25
26 class YQWidgetCaption;
27 class QComboBox;
28 class QY2CharValidator;
29
30
31 class YQComboBox : public QFrame, public YComboBox
32 {
33     Q_OBJECT
34
35 public:
36     /**
37      * Constructor.
38      **/
39     YQComboBox( YWidget * parent, const string & label, bool editable );
40
41     /**
42      * Destructor.
43      **/
44     ~YQComboBox();
45
46     /**
47      * Add one item. This widget assumes ownership of the item object and will
48      * delete it in its destructor.
49      *
50      * Reimplemented from YComboBox.
51      **/
52     virtual void addItem( YItem * item );
53
54     /**
55      * Delete all items.
56      *
57      * Reimplemented from YSelectionWidget.
58      **/
59     virtual void deleteAllItems();
60
61     /**
62      * Change the label text.
63      *
64      * Reimplemented from YSelectionWidget.
65      **/
66     virtual void setLabel( const string & label );
67
68     /**
69      * Change the valid input characters.
70      *
71      * Reimplemented from YComboBox.
72      **/
73     virtual void setValidChars( const string & validChars );
74
75     /**
76      * Specify the amount of characters which can be inserted.
77      *
78      * Reimplemented from YComboBox.
79      **/
80     virtual void setInputMaxLength( int numberOfChars );
81
82     /**
83      * Returns 'true' if the given text is valid according to the current
84      * setting of ValidChars.
85      **/
86     bool isValidText( const QString & txt ) const;
87
88     /**
89      * Set enabled / disabled state.
90      *
91      * Reimplemented from YWidget.
92      **/
93     virtual void setEnabled( bool enabled );
94
95     /**
96      * Preferred width of the widget.
97      *
98      * Reimplemented from YWidget.
99      **/
100     virtual int preferredWidth();
101
102     /**
103      * Preferred height of the widget.
104      *
105      * Reimplemented from YWidget.
106      **/
107     virtual int preferredHeight();
108
109     /**
110      * Set the new size of the widget.
111      *
112      * Reimplemented from YWidget.
113      **/
114     virtual void setSize( int newWidth, int newHeight );
115
116     /**
117      * Accept the keyboard focus.
118      **/
119     virtual bool setKeyboardFocus();
120
121
122 protected slots:
123
124     /**
125      * Tells the ui that an item has been selected. This is only
126      * interesting if the `notify option is set.
127      **/
128     void slotSelected( int i );
129
130     /**
131      * Tells the ui that the user has edited the text ( if the
132      * 'editable' option is set ).
133      * This is only interesting if the `notify option is set.
134      **/
135     void textChanged( QString );
136
137
138 protected:
139
140     /**
141      * Return this ComboBox's current value as text.
142      *
143      * Called internally from value(), selectedItem() and related.
144      *
145      * Implemented from YComboBox.
146      **/
147     virtual string text();
148
149     /**
150      *
151      * Set this ComboBox's current value as text.
152      *
153      * Called internally whenever the content is to change
154      * programmatically. Don't call setValue() or selectItem() from here.
155      *
156      * Implemented from YComboBox.
157      **/
158     virtual void setText( const string & newText );
159
160
161     //
162     // Data members
163     //
164
165     YQWidgetCaption *   _caption;
166     QComboBox *         _qt_comboBox;
167     QY2CharValidator *  _validator;
168 };
169
170
171 #endif // YQLabel_h