summaryrefslogtreecommitdiff
path: root/libopie2/qt3
authorclem <clem>2004-10-07 19:36:30 (UTC)
committer clem <clem>2004-10-07 19:36:30 (UTC)
commitb2e0fd018e1122f65dbbf8ab564e992988f35385 (patch) (unidiff)
treed47db77ff4ba1e9d397bc682f5d65b05b049dd02 /libopie2/qt3
parent33c90b7be9d675e8e5b39cfd569997bfcbb5decf (diff)
downloadopie-b2e0fd018e1122f65dbbf8ab564e992988f35385.zip
opie-b2e0fd018e1122f65dbbf8ab564e992988f35385.tar.gz
opie-b2e0fd018e1122f65dbbf8ab564e992988f35385.tar.bz2
small documentation format fixes
Diffstat (limited to 'libopie2/qt3') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/qt3/opieui/ocombobox.h4
-rw-r--r--libopie2/qt3/opieui/olineedit.h6
2 files changed, 5 insertions, 5 deletions
diff --git a/libopie2/qt3/opieui/ocombobox.h b/libopie2/qt3/opieui/ocombobox.h
index 4e35b61..3f60f54 100644
--- a/libopie2/qt3/opieui/ocombobox.h
+++ b/libopie2/qt3/opieui/ocombobox.h
@@ -1,790 +1,790 @@
1/* 1/*
2 This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 2 This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
3 is part of the Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org> 3 is part of the Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org>
4 Opie Project Copyright (C) 2000 Dawit Alemayehu <adawit@kde.org> 4 Opie Project Copyright (C) 2000 Dawit Alemayehu <adawit@kde.org>
5 5
6 =. Originally part of the KDE projects 6 =. Originally part of the KDE projects
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#ifndef OCOMBOBOX_H 33#ifndef OCOMBOBOX_H
34#define OCOMBOBOX_H 34#define OCOMBOBOX_H
35 35
36/* QT */ 36/* QT */
37 37
38#include <qcombobox.h> 38#include <qcombobox.h>
39 39
40/* OPIE */ 40/* OPIE */
41 41
42#include <opie2/olineedit.h> 42#include <opie2/olineedit.h>
43#include <opie2/ocompletion.h> 43#include <opie2/ocompletion.h>
44#include <opie2/ocompletionbase.h> 44#include <opie2/ocompletionbase.h>
45 45
46/* FORWARDS */ 46/* FORWARDS */
47 47
48class QListBoxItem; 48class QListBoxItem;
49class QPopupMenu; 49class QPopupMenu;
50class OCompletionBox; 50class OCompletionBox;
51typedef QString OURL; 51typedef QString OURL;
52 52
53/** 53/**
54 * A combined button, line-edit and a popup list widget. 54 * A combined button, line-edit and a popup list widget.
55 * 55 *
56 * @sect Detail 56 * @par Detail
57 * 57 *
58 * This widget inherits from @ref QComboBox and implements 58 * This widget inherits from @ref QComboBox and implements
59 * the following additional functionalities: a completion 59 * the following additional functionalities: a completion
60 * object that provides both automatic and manual text 60 * object that provides both automatic and manual text
61 * completion as well as text rotation features, configurable 61 * completion as well as text rotation features, configurable
62 * key-bindings to activate these features, and a popup-menu 62 * key-bindings to activate these features, and a popup-menu
63 * item that can be used to allow the user to set text completion 63 * item that can be used to allow the user to set text completion
64 * modes on the fly based on their preference. 64 * modes on the fly based on their preference.
65 * 65 *
66 * To support these new features OComboBox also emits a few 66 * To support these new features OComboBox also emits a few
67 * more additional signals as well. The main ones are the 67 * more additional signals as well. The main ones are the
68 * @ref completion( const QString& ) and @ref textRotation( KeyBindingType ) 68 * @ref completion( const QString& ) and @ref textRotation( KeyBindingType )
69 * signals. The completion signal is intended to be connected to a slot 69 * signals. The completion signal is intended to be connected to a slot
70 * that will assist the user in filling out the remaining text while 70 * that will assist the user in filling out the remaining text while
71 * the rotation signals is intended to be used to traverse through all 71 * the rotation signals is intended to be used to traverse through all
72 * possible matches whenever text completion results in multiple matches. 72 * possible matches whenever text completion results in multiple matches.
73 * The @ref returnPressed() and @ref returnPressed( const QString& ) 73 * The @ref returnPressed() and @ref returnPressed( const QString& )
74 * signal is emitted when the user presses the Enter/Return key. 74 * signal is emitted when the user presses the Enter/Return key.
75 * 75 *
76 * This widget by default creates a completion object when you invoke 76 * This widget by default creates a completion object when you invoke
77 * the @ref completionObject( bool ) member function for the first time 77 * the @ref completionObject( bool ) member function for the first time
78 * or use @ref setCompletionObject( OCompletion*, bool ) to assign your 78 * or use @ref setCompletionObject( OCompletion*, bool ) to assign your
79 * own completion object. Additionally, to make this widget more functional, 79 * own completion object. Additionally, to make this widget more functional,
80 * OComboBox will by default handle the text rotation and completion 80 * OComboBox will by default handle the text rotation and completion
81 * events internally whenever a completion object is created through either 81 * events internally whenever a completion object is created through either
82 * one of the methods mentioned above. If you do not need this functionality, 82 * one of the methods mentioned above. If you do not need this functionality,
83 * simply use @ref OCompletionBase::setHandleSignals( bool ) or alternatively 83 * simply use @ref OCompletionBase::setHandleSignals( bool ) or alternatively
84 * set the boolean parameter in the above methods to FALSE. 84 * set the boolean parameter in the above methods to FALSE.
85 * 85 *
86 * The default key-bindings for completion and rotation is determined 86 * The default key-bindings for completion and rotation is determined
87 * from the global settings in @ref OStdAccel. These values, however, 87 * from the global settings in @ref OStdAccel. These values, however,
88 * can be overriden locally by invoking @ref OCompletionBase::setKeyBinding(). 88 * can be overriden locally by invoking @ref OCompletionBase::setKeyBinding().
89 * The values can easily be reverted back to the default setting, by simply 89 * The values can easily be reverted back to the default setting, by simply
90 * calling @ref useGlobalSettings(). An alternate method would be to default 90 * calling @ref useGlobalSettings(). An alternate method would be to default
91 * individual key-bindings by usning @ref setKeyBinding() with the default 91 * individual key-bindings by usning @ref setKeyBinding() with the default
92 * second argument. 92 * second argument.
93 * 93 *
94 * Note that if this widget is not editable ( i.e. select-only ), then only 94 * Note that if this widget is not editable ( i.e. select-only ), then only
95 * one completion mode, @p CompletionAuto, will work. All the other modes are 95 * one completion mode, @p CompletionAuto, will work. All the other modes are
96 * simply ignored. The @p CompletionAuto mode in this case allows you to 96 * simply ignored. The @p CompletionAuto mode in this case allows you to
97 * automatically select an item from the list by trying to match the pressed 97 * automatically select an item from the list by trying to match the pressed
98 * keycode with the first letter of the enteries in the combo box. 98 * keycode with the first letter of the enteries in the combo box.
99 * 99 *
100 * @sect Useage 100 * @par Usage
101 * 101 *
102 * To enable the basic completion feature: 102 * To enable the basic completion feature:
103 * 103 *
104 * <pre> 104 * <pre>
105 * OComboBox *combo = new OComboBox( true, this, "mywidget" ); 105 * OComboBox *combo = new OComboBox( true, this, "mywidget" );
106 * OCompletion *comp = combo->completionObject(); 106 * OCompletion *comp = combo->completionObject();
107 * // Connect to the return pressed signal - optional 107 * // Connect to the return pressed signal - optional
108 * connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&)); 108 * connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
109 * </pre> 109 * </pre>
110 * 110 *
111 * To use your own completion object: 111 * To use your own completion object:
112 * 112 *
113 * <pre> 113 * <pre>
114 * OComboBox *combo = new OComboBox( this,"mywidget" ); 114 * OComboBox *combo = new OComboBox( this,"mywidget" );
115 * OURLCompletion *comp = new OURLCompletion(); 115 * OURLCompletion *comp = new OURLCompletion();
116 * combo->setCompletionObject( comp ); 116 * combo->setCompletionObject( comp );
117 * // Connect to the return pressed signal - optional 117 * // Connect to the return pressed signal - optional
118 * connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&)); 118 * connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
119 * </pre> 119 * </pre>
120 * 120 *
121 * Note that you have to either delete the allocated completion object 121 * Note that you have to either delete the allocated completion object
122 * when you don't need it anymore, or call 122 * when you don't need it anymore, or call
123 * setAutoDeleteCompletionObject( true ); 123 * setAutoDeleteCompletionObject( true );
124 * 124 *
125 * Miscellaneous function calls: 125 * Miscellaneous function calls:
126 * 126 *
127 * <pre> 127 * <pre>
128 * // Tell the widget not to handle completion and rotation 128 * // Tell the widget not to handle completion and rotation
129 * combo->setHandleSignals( false ); 129 * combo->setHandleSignals( false );
130 * // Set your own completion key for manual completions. 130 * // Set your own completion key for manual completions.
131 * combo->setKeyBinding( OCompletionBase::TextCompletion, Qt::End ); 131 * combo->setKeyBinding( OCompletionBase::TextCompletion, Qt::End );
132 * // Hide the context (popup) menu 132 * // Hide the context (popup) menu
133 * combo->setContextMenuEnabled( false ); 133 * combo->setContextMenuEnabled( false );
134 * // Temporarly disable signal emition 134 * // Temporarly disable signal emition
135 * combo->disableSignals(); 135 * combo->disableSignals();
136 * // Default the all key-bindings to their system-wide settings. 136 * // Default the all key-bindings to their system-wide settings.
137 * combo->useGlobalKeyBindings(); 137 * combo->useGlobalKeyBindings();
138 * </pre> 138 * </pre>
139 * 139 *
140 * @short An enhanced combo box. 140 * @short An enhanced combo box.
141 * @author Dawit Alemayehu <adawit@kde.org> 141 * @author Dawit Alemayehu <adawit@kde.org>
142 */ 142 */
143class OComboBox : public QComboBox, public OCompletionBase 143class OComboBox : public QComboBox, public OCompletionBase
144{ 144{
145 Q_OBJECT 145 Q_OBJECT
146 146
147 //Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion ) 147 //Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
148 //Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled ) 148 //Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
149 //Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled ) 149 //Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
150 150
151public: 151public:
152 152
153 /** 153 /**
154 * Constructs a read-only or rather select-only combo box with a 154 * Constructs a read-only or rather select-only combo box with a
155 * parent object and a name. 155 * parent object and a name.
156 * 156 *
157 * @param parent The parent object of this widget 157 * @param parent The parent object of this widget
158 * @param name The name of this widget 158 * @param name The name of this widget
159 */ 159 */
160 OComboBox( QWidget *parent=0, const char *name=0 ); 160 OComboBox( QWidget *parent=0, const char *name=0 );
161 161
162 /** 162 /**
163 * Constructs a "read-write" or "read-only" combo box depending on 163 * Constructs a "read-write" or "read-only" combo box depending on
164 * the value of the first argument( @p rw ) with a parent, a 164 * the value of the first argument( @p rw ) with a parent, a
165 * name. 165 * name.
166 * 166 *
167 * @param rw When @p true, widget will be editable. 167 * @param rw When @p true, widget will be editable.
168 * @param parent The parent object of this widget. 168 * @param parent The parent object of this widget.
169 * @param name The name of this widget. 169 * @param name The name of this widget.
170 */ 170 */
171 OComboBox( bool rw, QWidget *parent=0, const char *name=0 ); 171 OComboBox( bool rw, QWidget *parent=0, const char *name=0 );
172 172
173 /** 173 /**
174 * Destructor. 174 * Destructor.
175 */ 175 */
176 virtual ~OComboBox(); 176 virtual ~OComboBox();
177 177
178 /** 178 /**
179 * Sets @p url into the edit field of the combobox. It uses 179 * Sets @p url into the edit field of the combobox. It uses
180 * @ref OURL::prettyURL() so that the url is properly decoded for 180 * @ref OURL::prettyURL() so that the url is properly decoded for
181 * displaying. 181 * displaying.
182 */ 182 */
183 //void setEditURL( const OURL& url ); 183 //void setEditURL( const OURL& url );
184 184
185 /** 185 /**
186 * Inserts @p url at position @p index into the combobox. The item will 186 * Inserts @p url at position @p index into the combobox. The item will
187 * be appended if @p index is negative. @ref OURL::prettyURL() is used 187 * be appended if @p index is negative. @ref OURL::prettyURL() is used
188 * so that the url is properly decoded for displaying. 188 * so that the url is properly decoded for displaying.
189 */ 189 */
190 //void insertURL( const OURL& url, int index = -1 ); 190 //void insertURL( const OURL& url, int index = -1 );
191 191
192 /** 192 /**
193 * Inserts @p url with the pixmap &p pixmap at position @p index into 193 * Inserts @p url with the pixmap &p pixmap at position @p index into
194 * the combobox. The item will be appended if @p index is negative. 194 * the combobox. The item will be appended if @p index is negative.
195 * @ref OURL::prettyURL() is used so that the url is properly decoded 195 * @ref OURL::prettyURL() is used so that the url is properly decoded
196 * for displaying. 196 * for displaying.
197 */ 197 */
198 //void insertURL( const QPixmap& pixmap, const OURL& url, int index = -1 ); 198 //void insertURL( const QPixmap& pixmap, const OURL& url, int index = -1 );
199 199
200 /** 200 /**
201 * Replaces the item at position @p index with @p url. 201 * Replaces the item at position @p index with @p url.
202 * @ref OURL::prettyURL() is used so that the url is properly decoded 202 * @ref OURL::prettyURL() is used so that the url is properly decoded
203 * for displaying. 203 * for displaying.
204 */ 204 */
205 //void changeURL( const OURL& url, int index ); 205 //void changeURL( const OURL& url, int index );
206 206
207 /** 207 /**
208 * Replaces the item at position @p index with @p url and pixmap @p pixmap. 208 * Replaces the item at position @p index with @p url and pixmap @p pixmap.
209 * @ref OURL::prettyURL() is used so that the url is properly decoded 209 * @ref OURL::prettyURL() is used so that the url is properly decoded
210 * for displaying. 210 * for displaying.
211 */ 211 */
212 //void changeURL( const QPixmap& pixmap, const OURL& url, int index ); 212 //void changeURL( const QPixmap& pixmap, const OURL& url, int index );
213 213
214 /** 214 /**
215 * Returns the current cursor position. 215 * Returns the current cursor position.
216 * 216 *
217 * This method always returns a -1 if the combo-box is @em not 217 * This method always returns a -1 if the combo-box is @em not
218 * editable (read-write). 218 * editable (read-write).
219 * 219 *
220 * @return Current cursor position. 220 * @return Current cursor position.
221 */ 221 */
222 int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; } 222 int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
223 223
224 /** 224 /**
225 * Re-implemented from @ref QComboBox. 225 * Re-implemented from @ref QComboBox.
226 * 226 *
227 * If @p true, the completion mode will be set to automatic. 227 * If @p true, the completion mode will be set to automatic.
228 * Otherwise, it is defaulted to the global setting. This 228 * Otherwise, it is defaulted to the global setting. This
229 * method has been replaced by the more comprehensive 229 * method has been replaced by the more comprehensive
230 * @ref setCompletionMode(). 230 * @ref setCompletionMode().
231 * 231 *
232 * @param autocomplete Flag to enable/disable automatic completion mode. 232 * @param autocomplete Flag to enable/disable automatic completion mode.
233 */ 233 */
234 virtual void setAutoCompletion( bool autocomplete ); 234 virtual void setAutoCompletion( bool autocomplete );
235 235
236 /** 236 /**
237 * Re-implemented from QComboBox. 237 * Re-implemented from QComboBox.
238 * 238 *
239 * Returns @p true if the current completion mode is set 239 * Returns @p true if the current completion mode is set
240 * to automatic. See its more comprehensive replacement 240 * to automatic. See its more comprehensive replacement
241 * @ref completionMode(). 241 * @ref completionMode().
242 * 242 *
243 * @return @p true when completion mode is automatic. 243 * @return @p true when completion mode is automatic.
244 */ 244 */
245 bool autoCompletion() const { 245 bool autoCompletion() const {
246 return completionMode() == OGlobalSettings::CompletionAuto; 246 return completionMode() == OGlobalSettings::CompletionAuto;
247 } 247 }
248 248
249 /** 249 /**
250 * Enables or disable the popup (context) menu. 250 * Enables or disable the popup (context) menu.
251 * 251 *
252 * This method only works if this widget is editable, i.e. 252 * This method only works if this widget is editable, i.e.
253 * read-write and allows you to enable/disable the context 253 * read-write and allows you to enable/disable the context
254 * menu. It does nothing if invoked for a none-editable 254 * menu. It does nothing if invoked for a none-editable
255 * combo-box. Note that by default the mode changer item 255 * combo-box. Note that by default the mode changer item
256 * is made visiable whenever the context menu is enabled. 256 * is made visiable whenever the context menu is enabled.
257 * Use @ref hideModechanger() if you want to hide this 257 * Use @ref hideModechanger() if you want to hide this
258 * item. Also by default, the context menu is created if 258 * item. Also by default, the context menu is created if
259 * this widget is editable. Call this function with the 259 * this widget is editable. Call this function with the
260 * argument set to false to disable the popup menu. 260 * argument set to false to disable the popup menu.
261 * 261 *
262 * @param showMenu If @p true, show the context menu. 262 * @param showMenu If @p true, show the context menu.
263 * @param showMode If @p true, show the mode changer. 263 * @param showMode If @p true, show the mode changer.
264 */ 264 */
265 virtual void setContextMenuEnabled( bool showMenu ); 265 virtual void setContextMenuEnabled( bool showMenu );
266 266
267 /** 267 /**
268 * Returns @p true when the context menu is enabled. 268 * Returns @p true when the context menu is enabled.
269 */ 269 */
270 bool isContextMenuEnabled() const { return m_bEnableMenu; } 270 bool isContextMenuEnabled() const { return m_bEnableMenu; }
271 271
272 /** 272 /**
273 * Enables/Disables handling of URL drops. If enabled and the user 273 * Enables/Disables handling of URL drops. If enabled and the user
274 * drops an URL, the decoded URL will be inserted. Otherwise the default 274 * drops an URL, the decoded URL will be inserted. Otherwise the default
275 * behaviour of QComboBox is used, which inserts the encoded URL. 275 * behaviour of QComboBox is used, which inserts the encoded URL.
276 * 276 *
277 * @param enable If @p true, insert decoded URLs 277 * @param enable If @p true, insert decoded URLs
278 */ 278 */
279 //void setURLDropsEnabled( bool enable ); 279 //void setURLDropsEnabled( bool enable );
280 280
281 /** 281 /**
282 * Returns @p true when decoded URL drops are enabled 282 * Returns @p true when decoded URL drops are enabled
283 */ 283 */
284 //bool isURLDropsEnabled() const; 284 //bool isURLDropsEnabled() const;
285 285
286 /** 286 /**
287 * Convenience method which iterates over all items and checks if 287 * Convenience method which iterates over all items and checks if
288 * any of them is equal to @p text. 288 * any of them is equal to @p text.
289 * 289 *
290 * If @p text is an empty string, @p false 290 * If @p text is an empty string, @p false
291 * is returned. 291 * is returned.
292 * 292 *
293 * @return @p true if an item with the string @p text is in the combobox. 293 * @return @p true if an item with the string @p text is in the combobox.
294 */ 294 */
295 bool contains( const QString& text ) const; 295 bool contains( const QString& text ) const;
296 296
297 /** 297 /**
298 * By default, OComboBox recognizes Key_Return and Key_Enter 298 * By default, OComboBox recognizes Key_Return and Key_Enter
299 * and emits 299 * and emits
300 * the @ref returnPressed() signals, but it also lets the event pass, 300 * the @ref returnPressed() signals, but it also lets the event pass,
301 * for example causing a dialog's default-button to be called. 301 * for example causing a dialog's default-button to be called.
302 * 302 *
303 * Call this method with @p trap equal to true to make OComboBox 303 * Call this method with @p trap equal to true to make OComboBox
304 * stop these 304 * stop these
305 * events. The signals will still be emitted of course. 305 * events. The signals will still be emitted of course.
306 * 306 *
307 * Only affects read-writable comboboxes. 307 * Only affects read-writable comboboxes.
308 * 308 *
309 * @see setTrapReturnKey() 309 * @see setTrapReturnKey()
310 */ 310 */
311 void setTrapReturnKey( bool trap ); 311 void setTrapReturnKey( bool trap );
312 312
313 /** 313 /**
314 * @return @p true if keyevents of Key_Return or Key_Enter will 314 * @return @p true if keyevents of Key_Return or Key_Enter will
315 * be stopped or if they will be propagated. 315 * be stopped or if they will be propagated.
316 * 316 *
317 * @see setTrapReturnKey () 317 * @see setTrapReturnKey ()
318 */ 318 */
319 bool trapReturnKey() const; 319 bool trapReturnKey() const;
320 320
321 /** 321 /**
322 * Re-implemented for internal reasons. API not affected. 322 * Re-implemented for internal reasons. API not affected.
323 * 323 *
324 * @reimplemented 324 * @reimplemented
325 */ 325 */
326 virtual bool eventFilter( QObject *, QEvent * ); 326 virtual bool eventFilter( QObject *, QEvent * );
327 327
328 /** 328 /**
329 * @returns the completion-box, that is used in completion mode 329 * @returns the completion-box, that is used in completion mode
330 * @ref OGlobalSettings::CompletionPopup and @ref OGlobalSettings::CompletionPopupAuto. 330 * @ref OGlobalSettings::CompletionPopup and @ref OGlobalSettings::CompletionPopupAuto.
331 * This method will create a completion-box by calling 331 * This method will create a completion-box by calling
332 * @ref OLineEdit::completionBox, if none is there, yet. 332 * @ref OLineEdit::completionBox, if none is there, yet.
333 * 333 *
334 * @param create Set this to false if you don't want the box to be created 334 * @param create Set this to false if you don't want the box to be created
335 * i.e. to test if it is available. 335 * i.e. to test if it is available.
336 */ 336 */
337 OCompletionBox * completionBox( bool create = true ); 337 OCompletionBox * completionBox( bool create = true );
338 338
339 virtual void setLineEdit( OLineEdit * ); 339 virtual void setLineEdit( OLineEdit * );
340 340
341signals: 341signals:
342 /** 342 /**
343 * Emitted when the user presses the Enter key. 343 * Emitted when the user presses the Enter key.
344 * 344 *
345 * Note that this signal is only 345 * Note that this signal is only
346 * emitted if this widget is editable. 346 * emitted if this widget is editable.
347 */ 347 */
348 void returnPressed(); 348 void returnPressed();
349 349
350 /** 350 /**
351 * Emitted when the user presses 351 * Emitted when the user presses
352 * the Enter key. 352 * the Enter key.
353 * 353 *
354 * The argument is the current 354 * The argument is the current
355 * text being edited. This signal is just like 355 * text being edited. This signal is just like
356 * @ref returnPressed() except it contains the 356 * @ref returnPressed() except it contains the
357 * current text as its argument. 357 * current text as its argument.
358 * 358 *
359 * Note that this signal is only emitted if this 359 * Note that this signal is only emitted if this
360 * widget is editable. 360 * widget is editable.
361 */ 361 */
362 void returnPressed( const QString& ); 362 void returnPressed( const QString& );
363 363
364 /** 364 /**
365 * This signal is emitted when the completion key 365 * This signal is emitted when the completion key
366 * is pressed. 366 * is pressed.
367 * 367 *
368 * The argument is the current text 368 * The argument is the current text
369 * being edited. 369 * being edited.
370 * 370 *
371 * Note that this signal is @em not available if this 371 * Note that this signal is @em not available if this
372 * widget is non-editable or the completion mode is 372 * widget is non-editable or the completion mode is
373 * set to @p OGlobalSettings::CompletionNone. 373 * set to @p OGlobalSettings::CompletionNone.
374 */ 374 */
375 void completion( const QString& ); 375 void completion( const QString& );
376 376
377 /** 377 /**
378 * Emitted when the shortcut for substring completion is pressed. 378 * Emitted when the shortcut for substring completion is pressed.
379 */ 379 */
380 void substringCompletion( const QString& ); 380 void substringCompletion( const QString& );
381 381
382 /** 382 /**
383 * Emitted when the text rotation key-bindings are pressed. 383 * Emitted when the text rotation key-bindings are pressed.
384 * 384 *
385 * The argument indicates which key-binding was pressed. 385 * The argument indicates which key-binding was pressed.
386 * In this case this can be either one of four values: 386 * In this case this can be either one of four values:
387 * @p PrevCompletionMatch, @p NextCompletionMatch, @p RotateUp or 387 * @p PrevCompletionMatch, @p NextCompletionMatch, @p RotateUp or
388 * @p RotateDown. See @ref OCompletionBase::setKeyBinding() for 388 * @p RotateDown. See @ref OCompletionBase::setKeyBinding() for
389 * details. 389 * details.
390 * 390 *
391 * Note that this signal is @em NOT emitted if the completion 391 * Note that this signal is @em NOT emitted if the completion
392 * mode is set to CompletionNone. 392 * mode is set to CompletionNone.
393 */ 393 */
394 void textRotation( OCompletionBase::KeyBindingType ); 394 void textRotation( OCompletionBase::KeyBindingType );
395 395
396 /** 396 /**
397 * Emitted when the user changed the completion mode by using the 397 * Emitted when the user changed the completion mode by using the
398 * popupmenu. 398 * popupmenu.
399 */ 399 */
400 void completionModeChanged( OGlobalSettings::Completion ); 400 void completionModeChanged( OGlobalSettings::Completion );
401 401
402 /** 402 /**
403 * Emitted before the context menu is displayed. 403 * Emitted before the context menu is displayed.
404 * 404 *
405 * The signal allows you to add your own entries into the 405 * The signal allows you to add your own entries into the
406 * the context menu that is created on demand. 406 * the context menu that is created on demand.
407 * 407 *
408 * NOTE: Do not store the pointer to the QPopupMenu 408 * NOTE: Do not store the pointer to the QPopupMenu
409 * provided through since it is created and deleted 409 * provided through since it is created and deleted
410 * on demand. 410 * on demand.
411 * 411 *
412 * @param the context menu about to be displayed 412 * @param the context menu about to be displayed
413 */ 413 */
414 void aboutToShowContextMenu( QPopupMenu * ); 414 void aboutToShowContextMenu( QPopupMenu * );
415 415
416public slots: 416public slots:
417 417
418 /** 418 /**
419 * Iterates through all possible matches of the completed text 419 * Iterates through all possible matches of the completed text
420 * or the history list. 420 * or the history list.
421 * 421 *
422 * Depending on the value of the argument, this function either 422 * Depending on the value of the argument, this function either
423 * iterates through the history list of this widget or the all 423 * iterates through the history list of this widget or the all
424 * possible matches in whenever multiple matches result from a 424 * possible matches in whenever multiple matches result from a
425 * text completion request. Note that the all-possible-match 425 * text completion request. Note that the all-possible-match
426 * iteration will not work if there are no previous matches, i.e. 426 * iteration will not work if there are no previous matches, i.e.
427 * no text has been completed and the *nix shell history list 427 * no text has been completed and the *nix shell history list
428 * rotation is only available if the insertion policy for this 428 * rotation is only available if the insertion policy for this
429 * widget is set either @p QComobBox::AtTop or @p QComboBox::AtBottom. 429 * widget is set either @p QComobBox::AtTop or @p QComboBox::AtBottom.
430 * For other insertion modes whatever has been typed by the user 430 * For other insertion modes whatever has been typed by the user
431 * when the rotation event was initiated will be lost. 431 * when the rotation event was initiated will be lost.
432 * 432 *
433 * @param type The key-binding invoked. 433 * @param type The key-binding invoked.
434 */ 434 */
435 void rotateText( OCompletionBase::KeyBindingType /* type */ ); 435 void rotateText( OCompletionBase::KeyBindingType /* type */ );
436 436
437 /** 437 /**
438 * Sets the completed text in the line-edit appropriately. 438 * Sets the completed text in the line-edit appropriately.
439 * 439 *
440 * This function is an implementation for 440 * This function is an implementation for
441 * @ref OCompletionBase::setCompletedText. 441 * @ref OCompletionBase::setCompletedText.
442 */ 442 */
443 virtual void setCompletedText( const QString& ); 443 virtual void setCompletedText( const QString& );
444 444
445 /** 445 /**
446 * Sets @p items into the completion-box if @ref completionMode() is 446 * Sets @p items into the completion-box if @ref completionMode() is
447 * CompletionPopup. The popup will be shown immediately. 447 * CompletionPopup. The popup will be shown immediately.
448 */ 448 */
449 void setCompletedItems( const QStringList& items ); 449 void setCompletedItems( const QStringList& items );
450 450
451 public: 451 public:
452 /** 452 /**
453 * Selects the first item that matches @p item. If there is no such item, 453 * Selects the first item that matches @p item. If there is no such item,
454 * it is inserted at position @p index if @p insert is true. Otherwise, 454 * it is inserted at position @p index if @p insert is true. Otherwise,
455 * no item is selected. 455 * no item is selected.
456 */ 456 */
457 void setCurrentItem( const QString& item, bool insert = false, int index = -1 ); 457 void setCurrentItem( const QString& item, bool insert = false, int index = -1 );
458 void setCurrentItem(int index); 458 void setCurrentItem(int index);
459 459
460protected slots: 460protected slots:
461 461
462 /** 462 /**
463 * @deprecated. 463 * @deprecated.
464 */ 464 */
465 virtual void itemSelected( QListBoxItem* ) {}; 465 virtual void itemSelected( QListBoxItem* ) {};
466 466
467 /** 467 /**
468 * Completes text according to the completion mode. 468 * Completes text according to the completion mode.
469 * 469 *
470 * Note: this method is @p not invoked if the completion mode is 470 * Note: this method is @p not invoked if the completion mode is
471 * set to CompletionNone. Also if the mode is set to @p CompletionShell 471 * set to CompletionNone. Also if the mode is set to @p CompletionShell
472 * and multiple matches are found, this method will complete the 472 * and multiple matches are found, this method will complete the
473 * text to the first match with a beep to inidicate that there are 473 * text to the first match with a beep to inidicate that there are
474 * more matches. Then any successive completion key event iterates 474 * more matches. Then any successive completion key event iterates
475 * through the remaining matches. This way the rotation functionality 475 * through the remaining matches. This way the rotation functionality
476 * is left to iterate through the list as usual. 476 * is left to iterate through the list as usual.
477 */ 477 */
478 virtual void makeCompletion( const QString& ); 478 virtual void makeCompletion( const QString& );
479 479
480protected: 480protected:
481 /* 481 /*
482 * This function simply sets the lineedit text and 482 * This function simply sets the lineedit text and
483 * highlights the text appropriately if the boolean 483 * highlights the text appropriately if the boolean
484 * value is set to true. 484 * value is set to true.
485 * 485 *
486 * @param 486 * @param
487 * @param 487 * @param
488 */ 488 */
489 virtual void setCompletedText( const QString& /* */, bool /*marked*/ ); 489 virtual void setCompletedText( const QString& /* */, bool /*marked*/ );
490 490
491 /** 491 /**
492 * Reimplemented for internal reasons, the API is not affected. 492 * Reimplemented for internal reasons, the API is not affected.
493 */ 493 */
494 virtual void create( WId = 0, bool initializeWindow = true, 494 virtual void create( WId = 0, bool initializeWindow = true,
495 bool destroyOldWindow = true ); 495 bool destroyOldWindow = true );
496 496
497private: 497private:
498 // Constants that represent the ID's of the popup menu. 498 // Constants that represent the ID's of the popup menu.
499 // TODO: See if we can replace this mess with OActionMenu 499 // TODO: See if we can replace this mess with OActionMenu
500 // in the future though this is working lovely. 500 // in the future though this is working lovely.
501 enum MenuID { 501 enum MenuID {
502 Default=0, 502 Default=0,
503 Cut, 503 Cut,
504 Copy, 504 Copy,
505 Paste, 505 Paste,
506 Clear, 506 Clear,
507 Unselect, 507 Unselect,
508 SelectAll, 508 SelectAll,
509 NoCompletion, 509 NoCompletion,
510 AutoCompletion, 510 AutoCompletion,
511 ShellCompletion, 511 ShellCompletion,
512 PopupCompletion, 512 PopupCompletion,
513 SemiAutoCompletion 513 SemiAutoCompletion
514 }; 514 };
515 515
516 /** 516 /**
517 * Initializes the variables upon construction. 517 * Initializes the variables upon construction.
518 */ 518 */
519 void init(); 519 void init();
520 /** 520 /**
521 * Temporary functions to delete words back and foward until 521 * Temporary functions to delete words back and foward until
522 * alternatives are available in QT3 (Seth Chaiklin, 21 may 2001) 522 * alternatives are available in QT3 (Seth Chaiklin, 21 may 2001)
523 */ 523 */
524 void deleteWordBack(); 524 void deleteWordBack();
525 void deleteWordForward(); 525 void deleteWordForward();
526 526
527 bool m_bEnableMenu; 527 bool m_bEnableMenu;
528 528
529 // indicating if we should stop return-key events from propagating 529 // indicating if we should stop return-key events from propagating
530 bool m_trapReturnKey; 530 bool m_trapReturnKey;
531 531
532//protected: 532//protected:
533// virtual void virtual_hook( int id, void* data ); 533// virtual void virtual_hook( int id, void* data );
534private: 534private:
535 class OComboBoxPrivate; 535 class OComboBoxPrivate;
536 OComboBoxPrivate *d; 536 OComboBoxPrivate *d;
537}; 537};
538 538
539 539
540class OPixmapProvider; 540class OPixmapProvider;
541 541
542/** 542/**
543 * A combobox which implements a history like a unix shell. You can navigate 543 * A combobox which implements a history like a unix shell. You can navigate
544 * through all the items by using the Up or Down arrows (configurable of 544 * through all the items by using the Up or Down arrows (configurable of
545 * course). Additionally, weighted completion is available. So you should 545 * course). Additionally, weighted completion is available. So you should
546 * load and save the completion list to preserve the weighting between 546 * load and save the completion list to preserve the weighting between
547 * sessions. 547 * sessions.
548 * 548 *
549 * @author Carsten Pfeiffer <pfeiffer@kde.org> 549 * @author Carsten Pfeiffer <pfeiffer@kde.org>
550 * @short A combobox for offering a history and completion 550 * @short A combobox for offering a history and completion
551 */ 551 */
552class OHistoryCombo : public OComboBox 552class OHistoryCombo : public OComboBox
553{ 553{
554 Q_OBJECT 554 Q_OBJECT
555 Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems ) 555 Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems )
556 556
557public: 557public:
558 /** 558 /**
559 * Constructs a "read-write" combobox. A read-only history combobox 559 * Constructs a "read-write" combobox. A read-only history combobox
560 * doesn't make much sense, so it is only available as read-write. 560 * doesn't make much sense, so it is only available as read-write.
561 * Completion will be used automatically for the items in the combo. 561 * Completion will be used automatically for the items in the combo.
562 * 562 *
563 * The insertion-policy is set to NoInsertion, you have to add the items 563 * The insertion-policy is set to NoInsertion, you have to add the items
564 * yourself via the slot @ref addToHistory. If you want every item added, 564 * yourself via the slot @ref addToHistory. If you want every item added,
565 * use 565 * use
566 * 566 *
567 * <pre> 567 * <pre>
568 * connect( combo, SIGNAL( activated( const QString& )), 568 * connect( combo, SIGNAL( activated( const QString& )),
569 * combo, SLOT( addToHistory( const QString& ))); 569 * combo, SLOT( addToHistory( const QString& )));
570 * </pre> 570 * </pre>
571 * 571 *
572 * Use @ref QComboBox::setMaxCount() to limit the history. 572 * Use @ref QComboBox::setMaxCount() to limit the history.
573 * 573 *
574 * @p parent the parent object of this widget. 574 * @p parent the parent object of this widget.
575 * @p name the name of this widget. 575 * @p name the name of this widget.
576 */ 576 */
577 OHistoryCombo( QWidget *parent = 0L, const char *name = 0L ); 577 OHistoryCombo( QWidget *parent = 0L, const char *name = 0L );
578 578
579 // ### merge these two constructors 579 // ### merge these two constructors
580 /** 580 /**
581 * Same as the previous constructor, but additionally has the option 581 * Same as the previous constructor, but additionally has the option
582 * to specify whether you want to let OHistoryCombo handle completion 582 * to specify whether you want to let OHistoryCombo handle completion
583 * or not. If set to @p true, OHistoryCombo will sync the completion to the 583 * or not. If set to @p true, OHistoryCombo will sync the completion to the
584 * contents of the combobox. 584 * contents of the combobox.
585 */ 585 */
586 OHistoryCombo( bool useCompletion, 586 OHistoryCombo( bool useCompletion,
587 QWidget *parent = 0L, const char *name = 0L ); 587 QWidget *parent = 0L, const char *name = 0L );
588 588
589 /** 589 /**
590 * Destructs the combo, the completion-object and the pixmap-provider 590 * Destructs the combo, the completion-object and the pixmap-provider
591 */ 591 */
592 ~OHistoryCombo(); 592 ~OHistoryCombo();
593 593
594 /** 594 /**
595 * Inserts @p items into the combobox. @p items might get 595 * Inserts @p items into the combobox. @p items might get
596 * truncated if it is longer than @ref maxCount() 596 * truncated if it is longer than @ref maxCount()
597 * 597 *
598 * @see #historyItems 598 * @see #historyItems
599 */ 599 */
600 inline void setHistoryItems( QStringList items ) { 600 inline void setHistoryItems( QStringList items ) {
601 setHistoryItems(items, false); 601 setHistoryItems(items, false);
602 } 602 }
603 603
604 /** 604 /**
605 * Inserts @p items into the combobox. @p items might get 605 * Inserts @p items into the combobox. @p items might get
606 * truncated if it is longer than @ref maxCount() 606 * truncated if it is longer than @ref maxCount()
607 * 607 *
608 * Set @p setCompletionList to true, if you don't have a list of 608 * Set @p setCompletionList to true, if you don't have a list of
609 * completions. This tells OHistoryCombo to use all the items for the 609 * completions. This tells OHistoryCombo to use all the items for the
610 * completion object as well. 610 * completion object as well.
611 * You won't have the benefit of weighted completion though, so normally 611 * You won't have the benefit of weighted completion though, so normally
612 * you should do something like 612 * you should do something like
613 * <pre> 613 * <pre>
614 * OConfig *config = kapp->config(); 614 * OConfig *config = kapp->config();
615 * QStringList list; 615 * QStringList list;
616 * 616 *
617 * // load the history and completion list after creating the history combo 617 * // load the history and completion list after creating the history combo
618 * list = config->readListEntry( "Completion list" ); 618 * list = config->readListEntry( "Completion list" );
619 * combo->completionObject()->setItems( list ); 619 * combo->completionObject()->setItems( list );
620 * list = config->readListEntry( "History list" ); 620 * list = config->readListEntry( "History list" );
621 * combo->setHistoryItems( list ); 621 * combo->setHistoryItems( list );
622 * 622 *
623 * [...] 623 * [...]
624 * 624 *
625 * // save the history and completion list when the history combo is 625 * // save the history and completion list when the history combo is
626 * // destroyed 626 * // destroyed
627 * list = combo->completionObject()->items() 627 * list = combo->completionObject()->items()
628 * config->writeEntry( "Completion list", list ); 628 * config->writeEntry( "Completion list", list );
629 * list = combo->historyItems(); 629 * list = combo->historyItems();
630 * config->writeEntry( "History list", list ); 630 * config->writeEntry( "History list", list );
631 * </pre> 631 * </pre>
632 * 632 *
633 * Be sure to use different names for saving with OConfig if you have more 633 * Be sure to use different names for saving with OConfig if you have more
634 * than one OHistoryCombo. 634 * than one OHistoryCombo.
635 * 635 *
636 * Note: When @p setCompletionList is true, the items are inserted into the 636 * Note: When @p setCompletionList is true, the items are inserted into the
637 * OCompletion object with mode OCompletion::Insertion and the mode is set 637 * OCompletion object with mode OCompletion::Insertion and the mode is set
638 * to OCompletion::Weighted afterwards. 638 * to OCompletion::Weighted afterwards.
639 * 639 *
640 * @see #historyItems 640 * @see #historyItems
641 * @see OComboBox::completionObject 641 * @see OComboBox::completionObject
642 * @see OCompletion::setItems 642 * @see OCompletion::setItems
643 * @see OCompletion::items 643 * @see OCompletion::items
644 */ 644 */
645 void setHistoryItems( QStringList items, bool setCompletionList ); 645 void setHistoryItems( QStringList items, bool setCompletionList );
646 646
647 /** 647 /**
648 * Returns the list of history items. Empty, when this is not a read-write 648 * Returns the list of history items. Empty, when this is not a read-write
649 * combobox. 649 * combobox.
650 * 650 *
651 * @see #setHistoryItems 651 * @see #setHistoryItems
652 */ 652 */
653 QStringList historyItems() const; 653 QStringList historyItems() const;
654 654
655 /** 655 /**
656 * Removes all items named @p item. 656 * Removes all items named @p item.
657 * 657 *
658 * @return @p true if at least one item was removed. 658 * @return @p true if at least one item was removed.
659 * 659 *
660 * @see #addToHistory 660 * @see #addToHistory
661 */ 661 */
662 bool removeFromHistory( const QString& item ); 662 bool removeFromHistory( const QString& item );
663 663
664 /** 664 /**
665 * Sets a pixmap provider, so that items in the combobox can have a pixmap. 665 * Sets a pixmap provider, so that items in the combobox can have a pixmap.
666 * @ref OPixmapProvider is just an abstract class with the one pure virtual 666 * @ref OPixmapProvider is just an abstract class with the one pure virtual
667 * method @ref OPixmapProvider::pixmapFor(). This method is called whenever 667 * method @ref OPixmapProvider::pixmapFor(). This method is called whenever
668 * an item is added to the OHistoryComboBox. Implement it to return your 668 * an item is added to the OHistoryComboBox. Implement it to return your
669 * own custom pixmaps, or use the @ref OURLPixmapProvider from libkio, 669 * own custom pixmaps, or use the @ref OURLPixmapProvider from libkio,
670 * which uses @ref OMimeType::pixmapForURL to resolve icons. 670 * which uses @ref OMimeType::pixmapForURL to resolve icons.
671 * 671 *
672 * Set @p prov to 0L if you want to disable pixmaps. Default no pixmaps. 672 * Set @p prov to 0L if you want to disable pixmaps. Default no pixmaps.
673 * 673 *
674 * @see #pixmapProvider 674 * @see #pixmapProvider
675 */ 675 */
676 void setPixmapProvider( OPixmapProvider *prov ); 676 void setPixmapProvider( OPixmapProvider *prov );
677 677
678 /** 678 /**
679 * @returns the current pixmap provider. 679 * @returns the current pixmap provider.
680 * @see #setPixmapProvider 680 * @see #setPixmapProvider
681 * @see OPixmapProvider 681 * @see OPixmapProvider
682 */ 682 */
683 OPixmapProvider * pixmapProvider() const { return myPixProvider; } 683 OPixmapProvider * pixmapProvider() const { return myPixProvider; }
684 684
685 /** 685 /**
686 * Resets the current position of the up/down history. Call this 686 * Resets the current position of the up/down history. Call this
687 * when you manually call @ref setCurrentItem() or @ref clearEdit(). 687 * when you manually call @ref setCurrentItem() or @ref clearEdit().
688 */ 688 */
689 void reset() { slotReset(); } 689 void reset() { slotReset(); }
690 690
691public slots: 691public slots:
692 /** 692 /**
693 * Adds an item to the end of the history list and to the completion list. 693 * Adds an item to the end of the history list and to the completion list.
694 * If @ref maxCount() is reached, the first item of the list will be 694 * If @ref maxCount() is reached, the first item of the list will be
695 * removed. 695 * removed.
696 * 696 *
697 * If the last inserted item is the same as @p item, it will not be 697 * If the last inserted item is the same as @p item, it will not be
698 * inserted again. 698 * inserted again.
699 * 699 *
700 * If @ref duplicatesEnabled() is false, any equal existing item will be 700 * If @ref duplicatesEnabled() is false, any equal existing item will be
701 * removed before @p item is added. 701 * removed before @p item is added.
702 * 702 *
703 * Note: By using this method and not the Q and OComboBox insertItem() 703 * Note: By using this method and not the Q and OComboBox insertItem()
704 * methods, you make sure that the combobox stays in sync with the 704 * methods, you make sure that the combobox stays in sync with the
705 * completion. It would be annoying if completion would give an item 705 * completion. It would be annoying if completion would give an item
706 * not in the combobox, and vice versa. 706 * not in the combobox, and vice versa.
707 * 707 *
708 * @see #removeFromHistory 708 * @see #removeFromHistory
709 * @see QComboBox::setDuplicatesEnabled 709 * @see QComboBox::setDuplicatesEnabled
710 */ 710 */
711 void addToHistory( const QString& item ); 711 void addToHistory( const QString& item );
712 712
713 /** 713 /**
714 * Clears the history and the completion list. 714 * Clears the history and the completion list.
715 */ 715 */
716 void clearHistory(); 716 void clearHistory();
717 717
718signals: 718signals:
719 /** 719 /**
720 * Emitted when the history was cleared by the entry in the popup menu. 720 * Emitted when the history was cleared by the entry in the popup menu.
721 */ 721 */
722 void cleared(); 722 void cleared();
723 723
724protected: 724protected:
725 /** 725 /**
726 * Handling key-events, the shortcuts to rotate the items. 726 * Handling key-events, the shortcuts to rotate the items.
727 */ 727 */
728 virtual void keyPressEvent( QKeyEvent * ); 728 virtual void keyPressEvent( QKeyEvent * );
729 729
730 730
731 /** 731 /**
732 * Inserts @p items into the combo, honouring @ref pixmapProvider() 732 * Inserts @p items into the combo, honouring @ref pixmapProvider()
733 * Does not update the completionObject. 733 * Does not update the completionObject.
734 * 734 *
735 * Note: @ref duplicatesEnabled() is not honored here. 735 * Note: @ref duplicatesEnabled() is not honored here.
736 * 736 *
737 * Called from @ref setHistoryItems() and @ref setPixmapProvider() 737 * Called from @ref setHistoryItems() and @ref setPixmapProvider()
738 */ 738 */
739 void insertItems( const QStringList& items ); 739 void insertItems( const QStringList& items );
740 740
741 /** 741 /**
742 * @returns if we can modify the completion object or not. 742 * @returns if we can modify the completion object or not.
743 */ 743 */
744 bool useCompletion() const { return compObj() != 0L; } 744 bool useCompletion() const { return compObj() != 0L; }
745 745
746private slots: 746private slots:
747 /** 747 /**
748 * Resets the iterate index to -1 748 * Resets the iterate index to -1
749 */ 749 */
750 void slotReset(); 750 void slotReset();
751 751
752 /** 752 /**
753 * Called from the popupmenu, 753 * Called from the popupmenu,
754 * calls clearHistory() and emits cleared() 754 * calls clearHistory() and emits cleared()
755 */ 755 */
756 void slotClear(); 756 void slotClear();
757 757
758 /** 758 /**
759 * Appends our own context menu entry. 759 * Appends our own context menu entry.
760 */ 760 */
761 void addContextMenuItems( QPopupMenu* ); 761 void addContextMenuItems( QPopupMenu* );
762 762
763private: 763private:
764 void init( bool useCompletion ); 764 void init( bool useCompletion );
765 765
766 /** 766 /**
767 * The current position (index) in the combobox, used for Up and Down 767 * The current position (index) in the combobox, used for Up and Down
768 */ 768 */
769 int myIterateIndex; 769 int myIterateIndex;
770 770
771 /** 771 /**
772 * The text typed before Up or Down was pressed. 772 * The text typed before Up or Down was pressed.
773 */ 773 */
774 QString myText; 774 QString myText;
775 775
776 /** 776 /**
777 * Indicates that the user at least once rotated Up through the entire list 777 * Indicates that the user at least once rotated Up through the entire list
778 * Needed to allow going back after rotation. 778 * Needed to allow going back after rotation.
779 */ 779 */
780 bool myRotated; 780 bool myRotated;
781 OPixmapProvider *myPixProvider; 781 OPixmapProvider *myPixProvider;
782 782
783private: 783private:
784 class OHistoryComboPrivate; 784 class OHistoryComboPrivate;
785 OHistoryComboPrivate *d; 785 OHistoryComboPrivate *d;
786}; 786};
787 787
788 788
789#endif 789#endif
790 790
diff --git a/libopie2/qt3/opieui/olineedit.h b/libopie2/qt3/opieui/olineedit.h
index ecfca27..db3d7ef 100644
--- a/libopie2/qt3/opieui/olineedit.h
+++ b/libopie2/qt3/opieui/olineedit.h
@@ -1,498 +1,498 @@
1/* 1/*
2 This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 2 This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
3 is part of the Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>, Dawit Alemayehu <adawit@kde.org> 3 is part of the Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>, Dawit Alemayehu <adawit@kde.org>
4 Opie Project Copyright (C) 1999 Preston Brown <pbrown@kde.org>, Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com> 4 Opie Project Copyright (C) 1999 Preston Brown <pbrown@kde.org>, Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com>
5 Copyright (C) 1997 Sven Radej (sven.radej@iname.com) 5 Copyright (C) 1997 Sven Radej (sven.radej@iname.com)
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#ifndef OLINEEDIT_H 33#ifndef OLINEEDIT_H
34#define OLINEEDIT_H 34#define OLINEEDIT_H
35 35
36/* QT */ 36/* QT */
37 37
38#include <qlineedit.h> 38#include <qlineedit.h>
39 39
40/* OPIE */ 40/* OPIE */
41 41
42#include <opie2/ocompletion.h> 42#include <opie2/ocompletion.h>
43#include <opie2/ocompletionbase.h> 43#include <opie2/ocompletionbase.h>
44 44
45class QPopupMenu; 45class QPopupMenu;
46 46
47class OCompletionBox; 47class OCompletionBox;
48typedef QString KURL; //class KURL; 48typedef QString KURL; //class KURL;
49 49
50/** 50/**
51 * An enhanced QLineEdit widget for inputting text. 51 * An enhanced QLineEdit widget for inputting text.
52 * 52 *
53 * @sect Detail 53 * @par Detail
54 * 54 *
55 * This widget inherits from @ref QLineEdit and implements the following 55 * This widget inherits from @ref QLineEdit and implements the following
56 * additional functionalities: q completion object that provides both 56 * additional functionalities: q completion object that provides both
57 * automatic and manual text completion as well as multiple match iteration 57 * automatic and manual text completion as well as multiple match iteration
58 * features, configurable key-bindings to activate these features and a 58 * features, configurable key-bindings to activate these features and a
59 * popup-menu item that can be used to allow the user to set text completion 59 * popup-menu item that can be used to allow the user to set text completion
60 * modes on the fly based on their preference. 60 * modes on the fly based on their preference.
61 * 61 *
62 * To support these new features OLineEdit also emits a few more 62 * To support these new features OLineEdit also emits a few more
63 * additional signals. These are: @ref completion( const QString& ), 63 * additional signals. These are: @ref completion( const QString& ),
64 * textRotation( KeyBindingType ), and @ref returnPressed( const QString& ). 64 * textRotation( KeyBindingType ), and @ref returnPressed( const QString& ).
65 * The completion signal can be connected to a slot that will assist the 65 * The completion signal can be connected to a slot that will assist the
66 * user in filling out the remaining text. The text rotation signal is 66 * user in filling out the remaining text. The text rotation signal is
67 * intended to be used to iterate through the list of all possible matches 67 * intended to be used to iterate through the list of all possible matches
68 * whenever there is more than one match for the entered text. The 68 * whenever there is more than one match for the entered text. The
69 * @p returnPressed( const QString& ) signals are the same as QLineEdit's 69 * @p returnPressed( const QString& ) signals are the same as QLineEdit's
70 * except it provides the current text in the widget as its argument whenever 70 * except it provides the current text in the widget as its argument whenever
71 * appropriate. 71 * appropriate.
72 * 72 *
73 * This widget by default creates a completion object when you invoke 73 * This widget by default creates a completion object when you invoke
74 * the @ref completionObject( bool ) member function for the first time or 74 * the @ref completionObject( bool ) member function for the first time or
75 * use @ref setCompletionObject( OCompletion*, bool ) to assign your own 75 * use @ref setCompletionObject( OCompletion*, bool ) to assign your own
76 * completion object. Additionally, to make this widget more functional, 76 * completion object. Additionally, to make this widget more functional,
77 * OLineEdit will by default handle the text rotation and completion 77 * OLineEdit will by default handle the text rotation and completion
78 * events internally when a completion object is created through either one 78 * events internally when a completion object is created through either one
79 * of the methods mentioned above. If you do not need this functionality, 79 * of the methods mentioned above. If you do not need this functionality,
80 * simply use @ref OCompletionBase::setHandleSignals( bool ) or set the 80 * simply use @ref OCompletionBase::setHandleSignals( bool ) or set the
81 * boolean parameter in the above functions to FALSE. 81 * boolean parameter in the above functions to FALSE.
82 * 82 *
83 * The default key-bindings for completion and rotation is determined 83 * The default key-bindings for completion and rotation is determined
84 * from the global settings in @ref OStdAccel. These values, however, 84 * from the global settings in @ref OStdAccel. These values, however,
85 * can be overriden locally by invoking @ref OCompletionBase::setKeyBinding(). 85 * can be overriden locally by invoking @ref OCompletionBase::setKeyBinding().
86 * The values can easily be reverted back to the default setting, by simply 86 * The values can easily be reverted back to the default setting, by simply
87 * calling @ref useGlobalSettings(). An alternate method would be to default 87 * calling @ref useGlobalSettings(). An alternate method would be to default
88 * individual key-bindings by usning @ref setKeyBinding() with the default 88 * individual key-bindings by usning @ref setKeyBinding() with the default
89 * second argument. 89 * second argument.
90 * 90 *
91 * NOTE that if the @p EchoMode for this widget is set to something other 91 * NOTE that if the @p EchoMode for this widget is set to something other
92 * than @p QLineEdit::Normal, the completion mode will always be defaulted 92 * than @p QLineEdit::Normal, the completion mode will always be defaulted
93 * to @ref PGlobalSettings::CompletionNone. This is done purposefully to guard 93 * to @ref PGlobalSettings::CompletionNone. This is done purposefully to guard
94 * against protected entries such as passwords being cached in @ref OCompletion's 94 * against protected entries such as passwords being cached in @ref OCompletion's
95 * list. Hence, if the @p EchoMode is not @ref QLineEdit::Normal, the completion 95 * list. Hence, if the @p EchoMode is not @ref QLineEdit::Normal, the completion
96 * mode is automatically disabled. 96 * mode is automatically disabled.
97 * 97 *
98 * @sect Useage 98 * @par Usage
99 * 99 *
100 * To enable the basic completion feature : 100 * To enable the basic completion feature :
101 * 101 *
102 * <pre> 102 * <pre>
103 * OLineEdit *edit = new OLineEdit( this, "mywidget" ); 103 * OLineEdit *edit = new OLineEdit( this, "mywidget" );
104 * OCompletion *comp = edit->completionObject(); 104 * OCompletion *comp = edit->completionObject();
105 * // Fill the completion object with a list of possible matches 105 * // Fill the completion object with a list of possible matches
106 * QStringList list; 106 * QStringList list;
107 * list << "mickeyl@handhelds.org" << "mickey@tm.informatik.uni-frankfurt.de>" << "mickey@Vanille.de"; 107 * list << "mickeyl@handhelds.org" << "mickey@tm.informatik.uni-frankfurt.de>" << "mickey@Vanille.de";
108 * comp->setItems( list ); 108 * comp->setItems( list );
109 * // Connect to the return pressed signal (optional) 109 * // Connect to the return pressed signal (optional)
110 * connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&)); 110 * connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
111 * </pre> 111 * </pre>
112 * 112 *
113 * To use a customized completion objects or your 113 * To use a customized completion objects or your
114 * own completion object : 114 * own completion object :
115 * 115 *
116 * <pre> 116 * <pre>
117 * OLineEdit *edit = new OLineEdit( this,"mywidget" ); 117 * OLineEdit *edit = new OLineEdit( this,"mywidget" );
118 * KURLCompletion *comp = new KURLCompletion(); 118 * KURLCompletion *comp = new KURLCompletion();
119 * edit->setCompletionObject( comp ); 119 * edit->setCompletionObject( comp );
120 * // Connect to the return pressed signal - optional 120 * // Connect to the return pressed signal - optional
121 * connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&)); 121 * connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
122 * </pre> 122 * </pre>
123 * 123 *
124 * Note that you have to either delete the allocated completion object 124 * Note that you have to either delete the allocated completion object
125 * when you don't need it anymore, or call 125 * when you don't need it anymore, or call
126 * setAutoDeleteCompletionObject( true ); 126 * setAutoDeleteCompletionObject( true );
127 * 127 *
128 * @sect Miscellaneous function calls : 128 * @par Miscellaneous function calls :
129 * 129 *
130 * <pre> 130 * <pre>
131 * // Tell the widget not to handle completion and 131 * // Tell the widget not to handle completion and
132 * // iteration internally. 132 * // iteration internally.
133 * edit->setHandleSignals( false ); 133 * edit->setHandleSignals( false );
134 * // Set your own completion key for manual completions. 134 * // Set your own completion key for manual completions.
135 * edit->setKeyBinding( OCompletionBase::TextCompletion, Qt::End ); 135 * edit->setKeyBinding( OCompletionBase::TextCompletion, Qt::End );
136 * // Hide the context (popup) menu 136 * // Hide the context (popup) menu
137 * edit->setContextMenuEnabled( false ); 137 * edit->setContextMenuEnabled( false );
138 * // Temporarly disable signal emitions 138 * // Temporarly disable signal emitions
139 * // (both completion & iteration signals) 139 * // (both completion & iteration signals)
140 * edit->disableSignals(); 140 * edit->disableSignals();
141 * // Default the key-bindings to system settings. 141 * // Default the key-bindings to system settings.
142 * edit->useGlobalKeyBindings(); 142 * edit->useGlobalKeyBindings();
143 * </pre> 143 * </pre>
144 * 144 *
145 * @short An enhanced single line input widget. 145 * @short An enhanced single line input widget.
146 * @author Dawit Alemayehu <adawit@kde.org> 146 * @author Dawit Alemayehu <adawit@kde.org>
147 * @author Opie adaption by Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 147 * @author Opie adaption by Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
148 */ 148 */
149 149
150class OLineEdit : public QLineEdit, public OCompletionBase 150class OLineEdit : public QLineEdit, public OCompletionBase
151{ 151{
152 friend class OComboBox; 152 friend class OComboBox;
153 153
154 Q_OBJECT 154 Q_OBJECT
155 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled ) 155 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
156 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled ) 156 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
157 157
158public: 158public:
159 159
160 /** 160 /**
161 * Constructs a OLineEdit object with a default text, a parent, 161 * Constructs a OLineEdit object with a default text, a parent,
162 * and a name. 162 * and a name.
163 * 163 *
164 * @param string Text to be shown in the edit widget. 164 * @param string Text to be shown in the edit widget.
165 * @param parent The parent object of this widget. 165 * @param parent The parent object of this widget.
166 * @param name the name of this widget 166 * @param name the name of this widget
167 */ 167 */
168 OLineEdit( const QString &string, QWidget *parent, const char *name = 0 ); 168 OLineEdit( const QString &string, QWidget *parent, const char *name = 0 );
169 169
170 /** 170 /**
171 * Constructs a OLineEdit object with a parent and a name. 171 * Constructs a OLineEdit object with a parent and a name.
172 * 172 *
173 * @param string Text to be shown in the edit widget. 173 * @param string Text to be shown in the edit widget.
174 * @param parent The parent object of this widget. 174 * @param parent The parent object of this widget.
175 * @param name The name of this widget. 175 * @param name The name of this widget.
176 */ 176 */
177 OLineEdit ( QWidget *parent=0, const char *name=0 ); 177 OLineEdit ( QWidget *parent=0, const char *name=0 );
178 178
179 /** 179 /**
180 * Destructor. 180 * Destructor.
181 */ 181 */
182 virtual ~OLineEdit (); 182 virtual ~OLineEdit ();
183 183
184 /** 184 /**
185 * Sets @p url into the lineedit. It uses @ref KURL::prettyURL() so 185 * Sets @p url into the lineedit. It uses @ref KURL::prettyURL() so
186 * that the url is properly decoded for displaying. 186 * that the url is properly decoded for displaying.
187 */ 187 */
188 void setURL( const KURL& url ); 188 void setURL( const KURL& url );
189 189
190 /** 190 /**
191 * Puts the text cursor at the end of the string. 191 * Puts the text cursor at the end of the string.
192 * 192 *
193 * This method is deprecated. Use @ref QLineEdit::end() 193 * This method is deprecated. Use @ref QLineEdit::end()
194 * instead. 194 * instead.
195 * 195 *
196 * @deprecated 196 * @deprecated
197 * @ref QLineEdit::end() 197 * @ref QLineEdit::end()
198 */ 198 */
199 void cursorAtEnd() { end( false ); } 199 void cursorAtEnd() { end( false ); }
200 200
201 /** 201 /**
202 * Re-implemented from @ref OCompletionBase for internal reasons. 202 * Re-implemented from @ref OCompletionBase for internal reasons.
203 * 203 *
204 * This function is re-implemented in order to make sure that 204 * This function is re-implemented in order to make sure that
205 * the EchoMode is acceptable before we set the completion mode. 205 * the EchoMode is acceptable before we set the completion mode.
206 * 206 *
207 * See @ref OCompletionBase::setCompletionMode 207 * See @ref OCompletionBase::setCompletionMode
208 */ 208 */
209 virtual void setCompletionMode( OGlobalSettings::Completion mode ); 209 virtual void setCompletionMode( OGlobalSettings::Completion mode );
210 210
211 /** 211 /**
212 * Enables/disables the popup (context) menu. 212 * Enables/disables the popup (context) menu.
213 * 213 *
214 * Note that when this function is invoked with its argument 214 * Note that when this function is invoked with its argument
215 * set to @p true, then both the context menu and the completion 215 * set to @p true, then both the context menu and the completion
216 * menu item are enabled. If you do not want to the completion 216 * menu item are enabled. If you do not want to the completion
217 * item to be visible simply invoke @ref hideModechanger() right 217 * item to be visible simply invoke @ref hideModechanger() right
218 * after calling this method. Also by default, the context 218 * after calling this method. Also by default, the context
219 * menu is automatically created if this widget is editable. Thus 219 * menu is automatically created if this widget is editable. Thus
220 * you need to call this function with the argument set to false 220 * you need to call this function with the argument set to false
221 * if you do not want this behaviour. 221 * if you do not want this behaviour.
222 * 222 *
223 * @param showMenu If @p true, show the context menu. 223 * @param showMenu If @p true, show the context menu.
224 */ 224 */
225 virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; } 225 virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; }
226 226
227 /** 227 /**
228 * Returns @p true when the context menu is enabled. 228 * Returns @p true when the context menu is enabled.
229 */ 229 */
230 bool isContextMenuEnabled() const { return m_bEnableMenu; } 230 bool isContextMenuEnabled() const { return m_bEnableMenu; }
231 231
232 /** 232 /**
233 * Enables/Disables handling of URL drops. If enabled and the user 233 * Enables/Disables handling of URL drops. If enabled and the user
234 * drops an URL, the decoded URL will be inserted. Otherwise the default 234 * drops an URL, the decoded URL will be inserted. Otherwise the default
235 * behaviour of QLineEdit is used, which inserts the encoded URL. 235 * behaviour of QLineEdit is used, which inserts the encoded URL.
236 * 236 *
237 * @param enable If @p true, insert decoded URLs 237 * @param enable If @p true, insert decoded URLs
238 */ 238 */
239 void setURLDropsEnabled( bool enable ); 239 void setURLDropsEnabled( bool enable );
240 240
241 /** 241 /**
242 * Returns @p true when decoded URL drops are enabled 242 * Returns @p true when decoded URL drops are enabled
243 */ 243 */
244 bool isURLDropsEnabled() const; 244 bool isURLDropsEnabled() const;
245 245
246 /** 246 /**
247 * By default, OLineEdit recognizes @p Key_Return and @p Key_Enter and emits 247 * By default, OLineEdit recognizes @p Key_Return and @p Key_Enter and emits
248 * the @ref returnPressed() signals, but it also lets the event pass, 248 * the @ref returnPressed() signals, but it also lets the event pass,
249 * for example causing a dialog's default-button to be called. 249 * for example causing a dialog's default-button to be called.
250 * 250 *
251 * Call this method with @p trap = @p true to make @p OLineEdit stop these 251 * Call this method with @p trap = @p true to make @p OLineEdit stop these
252 * events. The signals will still be emitted of course. 252 * events. The signals will still be emitted of course.
253 * 253 *
254 * @see trapReturnKey() 254 * @see trapReturnKey()
255 */ 255 */
256 void setTrapReturnKey( bool trap ); 256 void setTrapReturnKey( bool trap );
257 257
258 /** 258 /**
259 * @returns @p true if keyevents of @p Key_Return or 259 * @returns @p true if keyevents of @p Key_Return or
260 * @p Key_Enter will be stopped or if they will be propagated. 260 * @p Key_Enter will be stopped or if they will be propagated.
261 * 261 *
262 * @see setTrapReturnKey () 262 * @see setTrapReturnKey ()
263 */ 263 */
264 bool trapReturnKey() const; 264 bool trapReturnKey() const;
265 265
266 /** 266 /**
267 * Re-implemented for internal reasons. API not affected. 267 * Re-implemented for internal reasons. API not affected.
268 * 268 *
269 * @reimplemented 269 * @reimplemented
270 */ 270 */
271 virtual bool eventFilter( QObject *, QEvent * ); 271 virtual bool eventFilter( QObject *, QEvent * );
272 272
273 /** 273 /**
274 * @returns the completion-box, that is used in completion mode 274 * @returns the completion-box, that is used in completion mode
275 * @ref KGlobalSettings::CompletionPopup. 275 * @ref KGlobalSettings::CompletionPopup.
276 * This method will create a completion-box if none is there, yet. 276 * This method will create a completion-box if none is there, yet.
277 * 277 *
278 * @param create Set this to false if you don't want the box to be created 278 * @param create Set this to false if you don't want the box to be created
279 * i.e. to test if it is available. 279 * i.e. to test if it is available.
280 */ 280 */
281 OCompletionBox * completionBox( bool create = true ); 281 OCompletionBox * completionBox( bool create = true );
282 282
283 /** 283 /**
284 * Reimplemented for internal reasons, the API is not affected. 284 * Reimplemented for internal reasons, the API is not affected.
285 */ 285 */
286 virtual void setCompletionObject( OCompletion *, bool hsig = true ); 286 virtual void setCompletionObject( OCompletion *, bool hsig = true );
287 287
288 288
289signals: 289signals:
290 290
291 /** 291 /**
292 * Emitted when the user presses the return key. 292 * Emitted when the user presses the return key.
293 * 293 *
294 * The argument is the current text. Note that this 294 * The argument is the current text. Note that this
295 * signal is @em not emitted if the widget's @p EchoMode is set to 295 * signal is @em not emitted if the widget's @p EchoMode is set to
296 * @ref QLineEdit::EchoMode. 296 * @ref QLineEdit::EchoMode.
297 */ 297 */
298 void returnPressed( const QString& ); 298 void returnPressed( const QString& );
299 299
300 /** 300 /**
301 * Emitted when the completion key is pressed. 301 * Emitted when the completion key is pressed.
302 * 302 *
303 * Please note that this signal is @em not emitted if the 303 * Please note that this signal is @em not emitted if the
304 * completion mode is set to @p CompletionNone or @p EchoMode is 304 * completion mode is set to @p CompletionNone or @p EchoMode is
305 * @em normal. 305 * @em normal.
306 */ 306 */
307 void completion( const QString& ); 307 void completion( const QString& );
308 308
309 /** 309 /**
310 * Emitted when the shortcut for substring completion is pressed. 310 * Emitted when the shortcut for substring completion is pressed.
311 */ 311 */
312 void substringCompletion( const QString& ); 312 void substringCompletion( const QString& );
313 313
314 /** 314 /**
315 * Emitted when the text rotation key-bindings are pressed. 315 * Emitted when the text rotation key-bindings are pressed.
316 * 316 *
317 * The argument indicates which key-binding was pressed. 317 * The argument indicates which key-binding was pressed.
318 * In OLineEdit's case this can be either one of two values: 318 * In OLineEdit's case this can be either one of two values:
319 * @ref PrevCompletionMatch or @ref NextCompletionMatch. See 319 * @ref PrevCompletionMatch or @ref NextCompletionMatch. See
320 * @ref OCompletionBase::setKeyBinding for details. 320 * @ref OCompletionBase::setKeyBinding for details.
321 * 321 *
322 * Note that this signal is @em not emitted if the completion 322 * Note that this signal is @em not emitted if the completion
323 * mode is set to @p KGlobalSettings::CompletionNone or @p echoMode() is @em not normal. 323 * mode is set to @p KGlobalSettings::CompletionNone or @p echoMode() is @em not normal.
324 */ 324 */
325 void textRotation( OCompletionBase::KeyBindingType ); 325 void textRotation( OCompletionBase::KeyBindingType );
326 326
327 /** 327 /**
328 * Emitted when the user changed the completion mode by using the 328 * Emitted when the user changed the completion mode by using the
329 * popupmenu. 329 * popupmenu.
330 */ 330 */
331 void completionModeChanged( OGlobalSettings::Completion ); 331 void completionModeChanged( OGlobalSettings::Completion );
332 332
333 /** 333 /**
334 * Emitted before the context menu is displayed. 334 * Emitted before the context menu is displayed.
335 * 335 *
336 * The signal allows you to add your own entries into the 336 * The signal allows you to add your own entries into the
337 * the context menu that is created on demand. 337 * the context menu that is created on demand.
338 * 338 *
339 * NOTE: Do not store the pointer to the QPopupMenu 339 * NOTE: Do not store the pointer to the QPopupMenu
340 * provided through since it is created and deleted 340 * provided through since it is created and deleted
341 * on demand. 341 * on demand.
342 * 342 *
343 * @param the context menu about to be displayed 343 * @param the context menu about to be displayed
344 */ 344 */
345 void aboutToShowContextMenu( QPopupMenu* ); 345 void aboutToShowContextMenu( QPopupMenu* );
346 346
347public slots: 347public slots:
348 348
349 /** 349 /**
350 * Re-implemented for internal reasons. API not changed. 350 * Re-implemented for internal reasons. API not changed.
351 */ 351 */
352 virtual void setReadOnly(bool); 352 virtual void setReadOnly(bool);
353 353
354 /** 354 /**
355 * Iterates through all possible matches of the completed text or 355 * Iterates through all possible matches of the completed text or
356 * the history list. 356 * the history list.
357 * 357 *
358 * This function simply iterates over all possible matches in case 358 * This function simply iterates over all possible matches in case
359 * multimple matches are found as a result of a text completion request. 359 * multimple matches are found as a result of a text completion request.
360 * It will have no effect if only a single match is found. 360 * It will have no effect if only a single match is found.
361 * 361 *
362 * @param type The key-binding invoked. 362 * @param type The key-binding invoked.
363 */ 363 */
364 void rotateText( OCompletionBase::KeyBindingType /* type */ ); 364 void rotateText( OCompletionBase::KeyBindingType /* type */ );
365 365
366 /** 366 /**
367 * See @ref OCompletionBase::setCompletedText. 367 * See @ref OCompletionBase::setCompletedText.
368 */ 368 */
369 virtual void setCompletedText( const QString& ); 369 virtual void setCompletedText( const QString& );
370 370
371 /** 371 /**
372 * Sets @p items into the completion-box if @ref completionMode() is 372 * Sets @p items into the completion-box if @ref completionMode() is
373 * CompletionPopup. The popup will be shown immediately. 373 * CompletionPopup. The popup will be shown immediately.
374 */ 374 */
375 void setCompletedItems( const QStringList& items ); 375 void setCompletedItems( const QStringList& items );
376 376
377 /** 377 /**
378 * Reimplemented to workaround a buggy QLineEdit::clear() 378 * Reimplemented to workaround a buggy QLineEdit::clear()
379 * (changing the clipboard to the text we just had in the lineedit) 379 * (changing the clipboard to the text we just had in the lineedit)
380 */ 380 */
381 virtual void clear(); 381 virtual void clear();
382 382
383protected slots: 383protected slots:
384 384
385 /** 385 /**
386 * Completes the remaining text with a matching one from 386 * Completes the remaining text with a matching one from
387 * a given list. 387 * a given list.
388 */ 388 */
389 virtual void makeCompletion( const QString& ); 389 virtual void makeCompletion( const QString& );
390 390
391 /** 391 /**
392 * @deprecated. Will be removed in the next major release! 392 * @deprecated. Will be removed in the next major release!
393 */ 393 */
394 void slotAboutToShow() {} 394 void slotAboutToShow() {}
395 395
396 /** 396 /**
397 * @deprecated. Will be removed in the next major release! 397 * @deprecated. Will be removed in the next major release!
398 */ 398 */
399 void slotCancelled() {} 399 void slotCancelled() {}
400 400
401protected: 401protected:
402 402
403 /** 403 /**
404 * Re-implemented for internal reasons. API not affected. 404 * Re-implemented for internal reasons. API not affected.
405 * 405 *
406 * See @ref QLineEdit::keyPressEvent(). 406 * See @ref QLineEdit::keyPressEvent().
407 */ 407 */
408 virtual void keyPressEvent( QKeyEvent * ); 408 virtual void keyPressEvent( QKeyEvent * );
409 409
410 /** 410 /**
411 * Re-implemented for internal reasons. API not affected. 411 * Re-implemented for internal reasons. API not affected.
412 * 412 *
413 * See @ref QLineEdit::mousePressEvent(). 413 * See @ref QLineEdit::mousePressEvent().
414 */ 414 */
415 virtual void mousePressEvent( QMouseEvent * ); 415 virtual void mousePressEvent( QMouseEvent * );
416 416
417 /** 417 /**
418 * Re-implemented for internal reasons. API not affected. 418 * Re-implemented for internal reasons. API not affected.
419 * 419 *
420 * See @ref QWidget::mouseDoubleClickEvent(). 420 * See @ref QWidget::mouseDoubleClickEvent().
421 */ 421 */
422 virtual void mouseDoubleClickEvent( QMouseEvent * ); 422 virtual void mouseDoubleClickEvent( QMouseEvent * );
423 423
424 /** 424 /**
425 * Re-implemented for internal reasons. API not affected. 425 * Re-implemented for internal reasons. API not affected.
426 * 426 *
427 * See @ref QLineEdit::createPopupMenu(). 427 * See @ref QLineEdit::createPopupMenu().
428 */ 428 */
429 virtual QPopupMenu *createPopupMenu(); 429 virtual QPopupMenu *createPopupMenu();
430 430
431 /** 431 /**
432 * Re-implemented to handle URI drops. 432 * Re-implemented to handle URI drops.
433 * 433 *
434 * See @ref QLineEdit::dropEvent(). 434 * See @ref QLineEdit::dropEvent().
435 */ 435 */
436 //virtual void dropEvent( QDropEvent * ); 436 //virtual void dropEvent( QDropEvent * );
437 437
438 /* 438 /*
439 * This function simply sets the lineedit text and 439 * This function simply sets the lineedit text and
440 * highlights the text appropriately if the boolean 440 * highlights the text appropriately if the boolean
441 * value is set to true. 441 * value is set to true.
442 * 442 *
443 * @param text 443 * @param text
444 * @param marked 444 * @param marked
445 */ 445 */
446 virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ ); 446 virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ );
447 447
448 /** 448 /**
449 * Reimplemented for internal reasons, the API is not affected. 449 * Reimplemented for internal reasons, the API is not affected.
450 */ 450 */
451 virtual void create( WId = 0, bool initializeWindow = true, 451 virtual void create( WId = 0, bool initializeWindow = true,
452 bool destroyOldWindow = true ); 452 bool destroyOldWindow = true );
453 453
454private slots: 454private slots:
455 void completionMenuActivated( int id ); 455 void completionMenuActivated( int id );
456 void tripleClickTimeout(); // resets possibleTripleClick 456 void tripleClickTimeout(); // resets possibleTripleClick
457 457
458private: 458private:
459 // Constants that represent the ID's of the popup menu. 459 // Constants that represent the ID's of the popup menu.
460 // TODO: See if we can replace this mess with KActionMenu 460 // TODO: See if we can replace this mess with KActionMenu
461 // in the future though it's working lovely. 461 // in the future though it's working lovely.
462 enum MenuID { 462 enum MenuID {
463 Default = 42, 463 Default = 42,
464 NoCompletion, 464 NoCompletion,
465 AutoCompletion, 465 AutoCompletion,
466 ShellCompletion, 466 ShellCompletion,
467 PopupCompletion, 467 PopupCompletion,
468 SemiAutoCompletion 468 SemiAutoCompletion
469 }; 469 };
470 470
471 /** 471 /**
472 * Initializes variables. Called from the constructors. 472 * Initializes variables. Called from the constructors.
473 */ 473 */
474 void init(); 474 void init();
475 475
476 /** 476 /**
477 * Creates the completion box 477 * Creates the completion box
478 */ 478 */
479 void makeCompletionBox(); 479 void makeCompletionBox();
480 480
481 /** 481 /**
482 * Checks whether we should/should not consume a key used as 482 * Checks whether we should/should not consume a key used as
483 * an accelerator. 483 * an accelerator.
484 */ 484 */
485 //bool overrideAccel (const QKeyEvent* e); 485 //bool overrideAccel (const QKeyEvent* e);
486 486
487 bool m_bEnableMenu; 487 bool m_bEnableMenu;
488 488
489 bool possibleTripleClick; // set in mousePressEvent, deleted in tripleClickTimeout 489 bool possibleTripleClick; // set in mousePressEvent, deleted in tripleClickTimeout
490 490
491protected: 491protected:
492 //virtual void virtual_hook( int id, void* data ); 492 //virtual void virtual_hook( int id, void* data );
493private: 493private:
494 class OLineEditPrivate; 494 class OLineEditPrivate;
495 OLineEditPrivate *d; 495 OLineEditPrivate *d;
496}; 496};
497 497
498#endif 498#endif