1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the Qt3Support module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef Q3COMBOBOX_H
|
---|
43 | #define Q3COMBOBOX_H
|
---|
44 |
|
---|
45 | #include <QtGui/qwidget.h>
|
---|
46 |
|
---|
47 | QT_BEGIN_HEADER
|
---|
48 |
|
---|
49 | QT_BEGIN_NAMESPACE
|
---|
50 |
|
---|
51 | QT_MODULE(Qt3SupportLight)
|
---|
52 |
|
---|
53 | #ifndef QT_NO_COMBOBOX
|
---|
54 |
|
---|
55 | class Q3StrList;
|
---|
56 | class QStringList;
|
---|
57 | class QLineEdit;
|
---|
58 | class QValidator;
|
---|
59 | class Q3ListBox;
|
---|
60 | class Q3ComboBoxData;
|
---|
61 | class QWheelEvent;
|
---|
62 |
|
---|
63 | class Q_COMPAT_EXPORT Q3ComboBox : public QWidget
|
---|
64 | {
|
---|
65 | Q_OBJECT
|
---|
66 | Q_ENUMS( Policy )
|
---|
67 | Q_PROPERTY( bool editable READ editable WRITE setEditable )
|
---|
68 | Q_PROPERTY( int count READ count )
|
---|
69 | Q_PROPERTY( QString currentText READ currentText WRITE setCurrentText DESIGNABLE false )
|
---|
70 | Q_PROPERTY( int currentItem READ currentItem WRITE setCurrentItem )
|
---|
71 | Q_PROPERTY( bool autoResize READ autoResize WRITE setAutoResize DESIGNABLE false )
|
---|
72 | Q_PROPERTY( int sizeLimit READ sizeLimit WRITE setSizeLimit )
|
---|
73 | Q_PROPERTY( int maxCount READ maxCount WRITE setMaxCount )
|
---|
74 | Q_PROPERTY( Policy insertionPolicy READ insertionPolicy WRITE setInsertionPolicy )
|
---|
75 | Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
|
---|
76 | Q_PROPERTY( bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled )
|
---|
77 |
|
---|
78 | public:
|
---|
79 | Q3ComboBox( QWidget* parent=0, const char* name=0 );
|
---|
80 | Q3ComboBox( bool rw, QWidget* parent=0, const char* name=0 );
|
---|
81 | ~Q3ComboBox();
|
---|
82 |
|
---|
83 | int count() const;
|
---|
84 |
|
---|
85 | void insertStringList( const QStringList &, int index=-1 );
|
---|
86 | void insertStrList( const Q3StrList &, int index=-1 );
|
---|
87 | void insertStrList( const Q3StrList *, int index=-1 );
|
---|
88 | void insertStrList( const char **, int numStrings=-1, int index=-1);
|
---|
89 |
|
---|
90 | void insertItem( const QString &text, int index=-1 );
|
---|
91 | void insertItem( const QPixmap &pixmap, int index=-1 );
|
---|
92 | void insertItem( const QPixmap &pixmap, const QString &text, int index=-1 );
|
---|
93 |
|
---|
94 | void removeItem( int index );
|
---|
95 |
|
---|
96 | int currentItem() const;
|
---|
97 | virtual void setCurrentItem( int index );
|
---|
98 |
|
---|
99 | QString currentText() const;
|
---|
100 | virtual void setCurrentText( const QString& );
|
---|
101 |
|
---|
102 | QString text( int index ) const;
|
---|
103 | const QPixmap *pixmap( int index ) const;
|
---|
104 |
|
---|
105 | void changeItem( const QString &text, int index );
|
---|
106 | void changeItem( const QPixmap &pixmap, int index );
|
---|
107 | void changeItem( const QPixmap &pixmap, const QString &text, int index );
|
---|
108 |
|
---|
109 | bool autoResize() const;
|
---|
110 | virtual void setAutoResize( bool );
|
---|
111 | QSize sizeHint() const;
|
---|
112 |
|
---|
113 | void setPalette( const QPalette & );
|
---|
114 | void setFont( const QFont & );
|
---|
115 | void setEnabled( bool );
|
---|
116 |
|
---|
117 | virtual void setSizeLimit( int );
|
---|
118 | int sizeLimit() const;
|
---|
119 |
|
---|
120 | virtual void setMaxCount( int );
|
---|
121 | int maxCount() const;
|
---|
122 |
|
---|
123 | enum Policy { NoInsertion,
|
---|
124 | AtTop,
|
---|
125 | AtCurrent,
|
---|
126 | AtBottom,
|
---|
127 | AfterCurrent,
|
---|
128 | BeforeCurrent,
|
---|
129 | NoInsert = NoInsertion,
|
---|
130 | InsertAtTop = AtTop,
|
---|
131 | InsertAtCurrent = AtCurrent,
|
---|
132 | InsertAtBottom = AtBottom,
|
---|
133 | InsertAfterCurrent = AfterCurrent,
|
---|
134 | InsertBeforeCurrent = BeforeCurrent
|
---|
135 | };
|
---|
136 |
|
---|
137 | virtual void setInsertionPolicy( Policy policy );
|
---|
138 | Policy insertionPolicy() const;
|
---|
139 |
|
---|
140 | virtual void setValidator( const QValidator * );
|
---|
141 | const QValidator * validator() const;
|
---|
142 |
|
---|
143 | virtual void setListBox( Q3ListBox * );
|
---|
144 | Q3ListBox * listBox() const;
|
---|
145 |
|
---|
146 | virtual void setLineEdit( QLineEdit *edit );
|
---|
147 | QLineEdit* lineEdit() const;
|
---|
148 |
|
---|
149 | virtual void setAutoCompletion( bool );
|
---|
150 | bool autoCompletion() const;
|
---|
151 |
|
---|
152 | bool eventFilter( QObject *object, QEvent *event );
|
---|
153 |
|
---|
154 | void setDuplicatesEnabled( bool enable );
|
---|
155 | bool duplicatesEnabled() const;
|
---|
156 |
|
---|
157 | bool editable() const;
|
---|
158 | void setEditable( bool );
|
---|
159 |
|
---|
160 | virtual void popup();
|
---|
161 |
|
---|
162 | void hide();
|
---|
163 |
|
---|
164 | public Q_SLOTS:
|
---|
165 | void clear();
|
---|
166 | void clearValidator();
|
---|
167 | void clearEdit();
|
---|
168 | virtual void setEditText( const QString &);
|
---|
169 |
|
---|
170 | Q_SIGNALS:
|
---|
171 | void activated( int index );
|
---|
172 | void highlighted( int index );
|
---|
173 | void activated( const QString &);
|
---|
174 | void highlighted( const QString &);
|
---|
175 | void textChanged( const QString &);
|
---|
176 |
|
---|
177 | private Q_SLOTS:
|
---|
178 | void internalActivate( int );
|
---|
179 | void internalHighlight( int );
|
---|
180 | void internalClickTimeout();
|
---|
181 | void returnPressed();
|
---|
182 |
|
---|
183 | protected:
|
---|
184 | void paintEvent( QPaintEvent * );
|
---|
185 | void resizeEvent( QResizeEvent * );
|
---|
186 | void mousePressEvent( QMouseEvent * );
|
---|
187 | void mouseMoveEvent( QMouseEvent * );
|
---|
188 | void mouseReleaseEvent( QMouseEvent * );
|
---|
189 | void mouseDoubleClickEvent( QMouseEvent * );
|
---|
190 | void keyPressEvent( QKeyEvent *e );
|
---|
191 | void focusInEvent( QFocusEvent *e );
|
---|
192 | void focusOutEvent( QFocusEvent *e );
|
---|
193 | #ifndef QT_NO_WHEELEVENT
|
---|
194 | void wheelEvent( QWheelEvent *e );
|
---|
195 | #endif
|
---|
196 | void styleChange( QStyle& );
|
---|
197 |
|
---|
198 | void updateMask();
|
---|
199 |
|
---|
200 | private:
|
---|
201 | void setUpListBox();
|
---|
202 | void setUpLineEdit();
|
---|
203 | void popDownListBox();
|
---|
204 | void reIndex();
|
---|
205 | void currentChanged();
|
---|
206 | int completionIndex( const QString &, int ) const;
|
---|
207 |
|
---|
208 | Q3ComboBoxData *d;
|
---|
209 |
|
---|
210 | private: // Disabled copy constructor and operator=
|
---|
211 | #if defined(Q_DISABLE_COPY)
|
---|
212 | Q3ComboBox( const Q3ComboBox & );
|
---|
213 | Q3ComboBox &operator=( const Q3ComboBox & );
|
---|
214 | #endif
|
---|
215 | };
|
---|
216 |
|
---|
217 |
|
---|
218 | #endif // QT_NO_COMBOBOX
|
---|
219 |
|
---|
220 | QT_END_NAMESPACE
|
---|
221 |
|
---|
222 | QT_END_HEADER
|
---|
223 |
|
---|
224 | #endif // Q3COMBOBOX_H
|
---|