author | ar <ar> | 2005-01-21 20:19:00 (UTC) |
---|---|---|
committer | ar <ar> | 2005-01-21 20:19:00 (UTC) |
commit | 55eccecc08f839878e5743d6e6be25af386b5a3f (patch) (unidiff) | |
tree | fd663ded2a2c097ce53bac6c021ca652ef5b5508 /libopie2/qt3 | |
parent | cd51d382be50bc021739395309e23760f1619759 (diff) | |
download | opie-55eccecc08f839878e5743d6e6be25af386b5a3f.zip opie-55eccecc08f839878e5743d6e6be25af386b5a3f.tar.gz opie-55eccecc08f839878e5743d6e6be25af386b5a3f.tar.bz2 |
- make opie compilable against qte 2.3.10 snapshot
change QT_VERSION > 290 into QT_VERSION <= 0x030000
-rw-r--r-- | libopie2/qt3/opiecore/osortablevaluelist.h | 2 | ||||
-rw-r--r-- | libopie2/qt3/opieui/ocombobox.cpp | 6 | ||||
-rw-r--r-- | libopie2/qt3/opieui/oeditlistbox.cpp | 6 | ||||
-rw-r--r-- | libopie2/qt3/opieui/olineedit.cpp | 6 |
4 files changed, 10 insertions, 10 deletions
diff --git a/libopie2/qt3/opiecore/osortablevaluelist.h b/libopie2/qt3/opiecore/osortablevaluelist.h index f66cf25..a3f75b4 100644 --- a/libopie2/qt3/opiecore/osortablevaluelist.h +++ b/libopie2/qt3/opiecore/osortablevaluelist.h | |||
@@ -1,117 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Originally a part of the KDE Project | 3 | Originally a part of the KDE Project |
4 | (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org> | 4 | (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef OSORTABLEVALUELIST_H | 31 | #ifndef OSORTABLEVALUELIST_H |
32 | #define OSORTABLEVALUELIST_H | 32 | #define OSORTABLEVALUELIST_H |
33 | 33 | ||
34 | #if QT_VERSION > 290 | 34 | #if QT_VERSION >= 0x030000 |
35 | #include <qtl.h> | 35 | #include <qtl.h> |
36 | #include <qpair.h> | 36 | #include <qpair.h> |
37 | #else | 37 | #else |
38 | #include <opie2/otl.h> | 38 | #include <opie2/otl.h> |
39 | #include <opie2/opair.h> | 39 | #include <opie2/opair.h> |
40 | #endif | 40 | #endif |
41 | #include <qvaluelist.h> | 41 | #include <qvaluelist.h> |
42 | 42 | ||
43 | template<class T, class Key = int> class OSortableItem : public QPair<Key,T> | 43 | template<class T, class Key = int> class OSortableItem : public QPair<Key,T> |
44 | { | 44 | { |
45 | public: | 45 | public: |
46 | OSortableItem( Key i, const T& t ) : QPair<Key, T>( i, t ) {} | 46 | OSortableItem( Key i, const T& t ) : QPair<Key, T>( i, t ) {} |
47 | OSortableItem( const OSortableItem<T, Key> &rhs ) | 47 | OSortableItem( const OSortableItem<T, Key> &rhs ) |
48 | : QPair<Key,T>( rhs.first, rhs.second ) {} | 48 | : QPair<Key,T>( rhs.first, rhs.second ) {} |
49 | 49 | ||
50 | OSortableItem() {} | 50 | OSortableItem() {} |
51 | 51 | ||
52 | OSortableItem<T, Key> &operator=( const OSortableItem<T, Key>& i ) { | 52 | OSortableItem<T, Key> &operator=( const OSortableItem<T, Key>& i ) { |
53 | first = i.first; | 53 | first = i.first; |
54 | second = i.second; | 54 | second = i.second; |
55 | return *this; | 55 | return *this; |
56 | } | 56 | } |
57 | 57 | ||
58 | // operators for sorting | 58 | // operators for sorting |
59 | bool operator> ( const OSortableItem<T, Key>& i2 ) const { | 59 | bool operator> ( const OSortableItem<T, Key>& i2 ) const { |
60 | return (i2.first < first); | 60 | return (i2.first < first); |
61 | } | 61 | } |
62 | bool operator< ( const OSortableItem<T, Key>& i2 ) const { | 62 | bool operator< ( const OSortableItem<T, Key>& i2 ) const { |
63 | return (first < i2.first); | 63 | return (first < i2.first); |
64 | } | 64 | } |
65 | bool operator>= ( const OSortableItem<T, Key>& i2 ) const { | 65 | bool operator>= ( const OSortableItem<T, Key>& i2 ) const { |
66 | return (first >= i2.first); | 66 | return (first >= i2.first); |
67 | } | 67 | } |
68 | bool operator<= ( const OSortableItem<T, Key>& i2 ) const { | 68 | bool operator<= ( const OSortableItem<T, Key>& i2 ) const { |
69 | return !(i2.first < first); | 69 | return !(i2.first < first); |
70 | } | 70 | } |
71 | bool operator== ( const OSortableItem<T, Key>& i2 ) const { | 71 | bool operator== ( const OSortableItem<T, Key>& i2 ) const { |
72 | return (first == i2.first); | 72 | return (first == i2.first); |
73 | } | 73 | } |
74 | bool operator!= ( const OSortableItem<T, Key>& i2 ) const { | 74 | bool operator!= ( const OSortableItem<T, Key>& i2 ) const { |
75 | return (first != i2.first); | 75 | return (first != i2.first); |
76 | } | 76 | } |
77 | 77 | ||
78 | T& value() { | 78 | T& value() { |
79 | return second; | 79 | return second; |
80 | } | 80 | } |
81 | const T& value() const { | 81 | const T& value() const { |
82 | return second; | 82 | return second; |
83 | } | 83 | } |
84 | 84 | ||
85 | Key index() const { | 85 | Key index() const { |
86 | return first; | 86 | return first; |
87 | } | 87 | } |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | // convenience | 91 | // convenience |
92 | template <class T, class Key = int> | 92 | template <class T, class Key = int> |
93 | class OSortableValueList : public QValueList<OSortableItem<T, Key> > | 93 | class OSortableValueList : public QValueList<OSortableItem<T, Key> > |
94 | { | 94 | { |
95 | public: | 95 | public: |
96 | void insert( Key i, const T& t ) { | 96 | void insert( Key i, const T& t ) { |
97 | QValueList<OSortableItem<T, Key> >::append( OSortableItem<T, Key>( i, t ) ); | 97 | QValueList<OSortableItem<T, Key> >::append( OSortableItem<T, Key>( i, t ) ); |
98 | } | 98 | } |
99 | // add more as you please... | 99 | // add more as you please... |
100 | 100 | ||
101 | T& operator[]( Key i ) { | 101 | T& operator[]( Key i ) { |
102 | return QValueList<OSortableItem<T, Key> >::operator[]( i ).value(); | 102 | return QValueList<OSortableItem<T, Key> >::operator[]( i ).value(); |
103 | } | 103 | } |
104 | const T& operator[]( Key i ) const { | 104 | const T& operator[]( Key i ) const { |
105 | return QValueList<OSortableItem<T, Key> >::operator[]( i ).value(); | 105 | return QValueList<OSortableItem<T, Key> >::operator[]( i ).value(); |
106 | } | 106 | } |
107 | 107 | ||
108 | void sort() { | 108 | void sort() { |
109 | qHeapSort( *this ); | 109 | qHeapSort( *this ); |
110 | } | 110 | } |
111 | }; | 111 | }; |
112 | 112 | ||
113 | // template <class T> class OSortableValueListIterator : public QValueListIterator<OSortableItem<T> > | 113 | // template <class T> class OSortableValueListIterator : public QValueListIterator<OSortableItem<T> > |
114 | // { | 114 | // { |
115 | // }; | 115 | // }; |
116 | 116 | ||
117 | #endif // OSORTABLEVALUELIST_H | 117 | #endif // OSORTABLEVALUELIST_H |
diff --git a/libopie2/qt3/opieui/ocombobox.cpp b/libopie2/qt3/opieui/ocombobox.cpp index bd330e0..130112c 100644 --- a/libopie2/qt3/opieui/ocombobox.cpp +++ b/libopie2/qt3/opieui/ocombobox.cpp | |||
@@ -225,240 +225,240 @@ bool OComboBox::eventFilter( QObject* o, QEvent* ev ) | |||
225 | 225 | ||
226 | return m_trapReturnKey; | 226 | return m_trapReturnKey; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | // wheel-scrolling changes the current item | 232 | // wheel-scrolling changes the current item |
233 | if ( type == QEvent::Wheel ) { | 233 | if ( type == QEvent::Wheel ) { |
234 | if ( !listBox() || listBox()->isHidden() ) { | 234 | if ( !listBox() || listBox()->isHidden() ) { |
235 | QWheelEvent *e = static_cast<QWheelEvent*>( ev ); | 235 | QWheelEvent *e = static_cast<QWheelEvent*>( ev ); |
236 | static const int WHEEL_DELTA = 120; | 236 | static const int WHEEL_DELTA = 120; |
237 | int skipItems = e->delta() / WHEEL_DELTA; | 237 | int skipItems = e->delta() / WHEEL_DELTA; |
238 | if ( e->state() & ControlButton ) // fast skipping | 238 | if ( e->state() & ControlButton ) // fast skipping |
239 | skipItems *= 10; | 239 | skipItems *= 10; |
240 | 240 | ||
241 | int newItem = currentItem() - skipItems; | 241 | int newItem = currentItem() - skipItems; |
242 | 242 | ||
243 | if ( newItem < 0 ) | 243 | if ( newItem < 0 ) |
244 | newItem = 0; | 244 | newItem = 0; |
245 | else if ( newItem >= count() ) | 245 | else if ( newItem >= count() ) |
246 | newItem = count() -1; | 246 | newItem = count() -1; |
247 | 247 | ||
248 | setCurrentItem( newItem ); | 248 | setCurrentItem( newItem ); |
249 | if ( !text( newItem ).isNull() ) | 249 | if ( !text( newItem ).isNull() ) |
250 | emit activated( text( newItem ) ); | 250 | emit activated( text( newItem ) ); |
251 | emit activated( newItem ); | 251 | emit activated( newItem ); |
252 | e->accept(); | 252 | e->accept(); |
253 | return true; | 253 | return true; |
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
257 | return QComboBox::eventFilter( o, ev ); | 257 | return QComboBox::eventFilter( o, ev ); |
258 | } | 258 | } |
259 | 259 | ||
260 | void OComboBox::setTrapReturnKey( bool grab ) | 260 | void OComboBox::setTrapReturnKey( bool grab ) |
261 | { | 261 | { |
262 | m_trapReturnKey = grab; | 262 | m_trapReturnKey = grab; |
263 | } | 263 | } |
264 | 264 | ||
265 | bool OComboBox::trapReturnKey() const | 265 | bool OComboBox::trapReturnKey() const |
266 | { | 266 | { |
267 | return m_trapReturnKey; | 267 | return m_trapReturnKey; |
268 | } | 268 | } |
269 | 269 | ||
270 | /* | 270 | /* |
271 | void OComboBox::setEditURL( const OURL& url ) | 271 | void OComboBox::setEditURL( const OURL& url ) |
272 | { | 272 | { |
273 | QComboBox::setEditText( url.prettyURL() ); | 273 | QComboBox::setEditText( url.prettyURL() ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void OComboBox::insertURL( const OURL& url, int index ) | 276 | void OComboBox::insertURL( const OURL& url, int index ) |
277 | { | 277 | { |
278 | QComboBox::insertItem( url.prettyURL(), index ); | 278 | QComboBox::insertItem( url.prettyURL(), index ); |
279 | } | 279 | } |
280 | 280 | ||
281 | void OComboBox::insertURL( const QPixmap& pixmap, const OURL& url, int index ) | 281 | void OComboBox::insertURL( const QPixmap& pixmap, const OURL& url, int index ) |
282 | { | 282 | { |
283 | QComboBox::insertItem( pixmap, url.prettyURL(), index ); | 283 | QComboBox::insertItem( pixmap, url.prettyURL(), index ); |
284 | } | 284 | } |
285 | 285 | ||
286 | void OComboBox::changeURL( const OURL& url, int index ) | 286 | void OComboBox::changeURL( const OURL& url, int index ) |
287 | { | 287 | { |
288 | QComboBox::changeItem( url.prettyURL(), index ); | 288 | QComboBox::changeItem( url.prettyURL(), index ); |
289 | } | 289 | } |
290 | 290 | ||
291 | void OComboBox::changeURL( const QPixmap& pixmap, const OURL& url, int index ) | 291 | void OComboBox::changeURL( const QPixmap& pixmap, const OURL& url, int index ) |
292 | { | 292 | { |
293 | QComboBox::changeItem( pixmap, url.prettyURL(), index ); | 293 | QComboBox::changeItem( pixmap, url.prettyURL(), index ); |
294 | } | 294 | } |
295 | */ | 295 | */ |
296 | 296 | ||
297 | 297 | ||
298 | void OComboBox::setCompletedItems( const QStringList& items ) | 298 | void OComboBox::setCompletedItems( const QStringList& items ) |
299 | { | 299 | { |
300 | if ( d->olineEdit ) | 300 | if ( d->olineEdit ) |
301 | d->olineEdit->setCompletedItems( items ); | 301 | d->olineEdit->setCompletedItems( items ); |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | OCompletionBox * OComboBox::completionBox( bool create ) | 305 | OCompletionBox * OComboBox::completionBox( bool create ) |
306 | { | 306 | { |
307 | if ( d->olineEdit ) | 307 | if ( d->olineEdit ) |
308 | return d->olineEdit->completionBox( create ); | 308 | return d->olineEdit->completionBox( create ); |
309 | return 0; | 309 | return 0; |
310 | } | 310 | } |
311 | 311 | ||
312 | // QWidget::create() turns off mouse-Tracking which would break auto-hiding | 312 | // QWidget::create() turns off mouse-Tracking which would break auto-hiding |
313 | void OComboBox::create( WId id, bool initializeWindow, bool destroyOldWindow ) | 313 | void OComboBox::create( WId id, bool initializeWindow, bool destroyOldWindow ) |
314 | { | 314 | { |
315 | QComboBox::create( id, initializeWindow, destroyOldWindow ); | 315 | QComboBox::create( id, initializeWindow, destroyOldWindow ); |
316 | //OCursor::setAutoHideCursor( lineEdit(), true, true ); | 316 | //OCursor::setAutoHideCursor( lineEdit(), true, true ); |
317 | } | 317 | } |
318 | 318 | ||
319 | void OComboBox::setLineEdit( OLineEdit *edit ) | 319 | void OComboBox::setLineEdit( OLineEdit *edit ) |
320 | { | 320 | { |
321 | #if QT_VERSION > 290 | 321 | #if QT_VERSION >= 0x030000 |
322 | QComboBox::setLineEdit( edit ); | 322 | QComboBox::setLineEdit( edit ); |
323 | if ( !edit->inherits( "OLineEdit" ) ) | 323 | if ( !edit->inherits( "OLineEdit" ) ) |
324 | d->olineEdit = 0; | 324 | d->olineEdit = 0; |
325 | else | 325 | else |
326 | d->olineEdit = static_cast<OLineEdit*>( edit ); | 326 | d->olineEdit = static_cast<OLineEdit*>( edit ); |
327 | setDelegate( d->olineEdit ); | 327 | setDelegate( d->olineEdit ); |
328 | 328 | ||
329 | // forward some signals. We only emit returnPressed() ourselves. | 329 | // forward some signals. We only emit returnPressed() ourselves. |
330 | if ( d->olineEdit ) { | 330 | if ( d->olineEdit ) { |
331 | connect( d->olineEdit, SIGNAL( completion(const QString&)), | 331 | connect( d->olineEdit, SIGNAL( completion(const QString&)), |
332 | SIGNAL( completion(const QString&)) ); | 332 | SIGNAL( completion(const QString&)) ); |
333 | connect( d->olineEdit, SIGNAL( substringCompletion(const QString&)), | 333 | connect( d->olineEdit, SIGNAL( substringCompletion(const QString&)), |
334 | SIGNAL( substringCompletion(const QString&)) ); | 334 | SIGNAL( substringCompletion(const QString&)) ); |
335 | connect( d->olineEdit, | 335 | connect( d->olineEdit, |
336 | SIGNAL( textRotation(OCompletionBase::KeyBindingType)), | 336 | SIGNAL( textRotation(OCompletionBase::KeyBindingType)), |
337 | SIGNAL( textRotation(OCompletionBase::KeyBindingType)) ); | 337 | SIGNAL( textRotation(OCompletionBase::KeyBindingType)) ); |
338 | connect( d->olineEdit, | 338 | connect( d->olineEdit, |
339 | SIGNAL( completionModeChanged(OGlobalSettings::Completion)), | 339 | SIGNAL( completionModeChanged(OGlobalSettings::Completion)), |
340 | SIGNAL( completionModeChanged(OGlobalSettings::Completion))); | 340 | SIGNAL( completionModeChanged(OGlobalSettings::Completion))); |
341 | 341 | ||
342 | connect( d->olineEdit, | 342 | connect( d->olineEdit, |
343 | SIGNAL( aboutToShowContextMenu(QPopupMenu*)), | 343 | SIGNAL( aboutToShowContextMenu(QPopupMenu*)), |
344 | SIGNAL( aboutToShowContextMenu(QPopupMenu*)) ); | 344 | SIGNAL( aboutToShowContextMenu(QPopupMenu*)) ); |
345 | } | 345 | } |
346 | #else | 346 | #else |
347 | #warning OComboBox is not fully functional with Qt2 | 347 | #warning OComboBox is not fully functional with Qt2 |
348 | #endif | 348 | #endif |
349 | } | 349 | } |
350 | 350 | ||
351 | // Temporary functions until QT3 appears. - Seth Chaiklin 20 may 2001 | 351 | // Temporary functions until QT3 appears. - Seth Chaiklin 20 may 2001 |
352 | void OComboBox::deleteWordForward() | 352 | void OComboBox::deleteWordForward() |
353 | { | 353 | { |
354 | lineEdit()->cursorWordForward(TRUE); | 354 | lineEdit()->cursorWordForward(TRUE); |
355 | #if QT_VERSION > 290 | 355 | #if QT_VERSION >= 0x030000 |
356 | if ( lineEdit()->hasSelectedText() ) | 356 | if ( lineEdit()->hasSelectedText() ) |
357 | #else | 357 | #else |
358 | if ( lineEdit()->hasMarkedText() ) | 358 | if ( lineEdit()->hasMarkedText() ) |
359 | #endif | 359 | #endif |
360 | { | 360 | { |
361 | lineEdit()->del(); | 361 | lineEdit()->del(); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | void OComboBox::deleteWordBack() | 365 | void OComboBox::deleteWordBack() |
366 | { | 366 | { |
367 | lineEdit()->cursorWordBackward(TRUE); | 367 | lineEdit()->cursorWordBackward(TRUE); |
368 | #if QT_VERSION > 290 | 368 | #if QT_VERSION >= 0x030000 |
369 | if ( lineEdit()->hasSelectedText() ) | 369 | if ( lineEdit()->hasSelectedText() ) |
370 | #else | 370 | #else |
371 | if ( lineEdit()->hasMarkedText() ) | 371 | if ( lineEdit()->hasMarkedText() ) |
372 | #endif | 372 | #endif |
373 | { | 373 | { |
374 | lineEdit()->del(); | 374 | lineEdit()->del(); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | void OComboBox::setCurrentItem( const QString& item, bool insert, int index ) | 378 | void OComboBox::setCurrentItem( const QString& item, bool insert, int index ) |
379 | { | 379 | { |
380 | int sel = -1; | 380 | int sel = -1; |
381 | for (int i = 0; i < count(); ++i) | 381 | for (int i = 0; i < count(); ++i) |
382 | if (text(i) == item) | 382 | if (text(i) == item) |
383 | { | 383 | { |
384 | sel = i; | 384 | sel = i; |
385 | break; | 385 | break; |
386 | } | 386 | } |
387 | if (sel == -1 && insert) | 387 | if (sel == -1 && insert) |
388 | { | 388 | { |
389 | insertItem(item, index); | 389 | insertItem(item, index); |
390 | if (index >= 0) | 390 | if (index >= 0) |
391 | sel = index; | 391 | sel = index; |
392 | else | 392 | else |
393 | sel = count() - 1; | 393 | sel = count() - 1; |
394 | } | 394 | } |
395 | setCurrentItem(sel); | 395 | setCurrentItem(sel); |
396 | } | 396 | } |
397 | 397 | ||
398 | void OComboBox::setCurrentItem(int index) | 398 | void OComboBox::setCurrentItem(int index) |
399 | { | 399 | { |
400 | QComboBox::setCurrentItem(index); | 400 | QComboBox::setCurrentItem(index); |
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
404 | /*====================================================================================== | 404 | /*====================================================================================== |
405 | * OHistoryCombo | 405 | * OHistoryCombo |
406 | *======================================================================================*/ | 406 | *======================================================================================*/ |
407 | 407 | ||
408 | // we are always read-write | 408 | // we are always read-write |
409 | OHistoryCombo::OHistoryCombo( QWidget *parent, const char *name ) | 409 | OHistoryCombo::OHistoryCombo( QWidget *parent, const char *name ) |
410 | : OComboBox( true, parent, name ) | 410 | : OComboBox( true, parent, name ) |
411 | { | 411 | { |
412 | init( true ); // using completion | 412 | init( true ); // using completion |
413 | } | 413 | } |
414 | 414 | ||
415 | // we are always read-write | 415 | // we are always read-write |
416 | OHistoryCombo::OHistoryCombo( bool useCompletion, | 416 | OHistoryCombo::OHistoryCombo( bool useCompletion, |
417 | QWidget *parent, const char *name ) | 417 | QWidget *parent, const char *name ) |
418 | : OComboBox( true, parent, name ) | 418 | : OComboBox( true, parent, name ) |
419 | { | 419 | { |
420 | init( useCompletion ); | 420 | init( useCompletion ); |
421 | } | 421 | } |
422 | 422 | ||
423 | void OHistoryCombo::init( bool useCompletion ) | 423 | void OHistoryCombo::init( bool useCompletion ) |
424 | { | 424 | { |
425 | if ( useCompletion ) | 425 | if ( useCompletion ) |
426 | completionObject()->setOrder( OCompletion::Weighted ); | 426 | completionObject()->setOrder( OCompletion::Weighted ); |
427 | 427 | ||
428 | setInsertionPolicy( NoInsertion ); | 428 | setInsertionPolicy( NoInsertion ); |
429 | myIterateIndex = -1; | 429 | myIterateIndex = -1; |
430 | myRotated = false; | 430 | myRotated = false; |
431 | myPixProvider = 0L; | 431 | myPixProvider = 0L; |
432 | 432 | ||
433 | connect( this, SIGNAL(aboutToShowContextMenu(QPopupMenu*)), | 433 | connect( this, SIGNAL(aboutToShowContextMenu(QPopupMenu*)), |
434 | SLOT(addContextMenuItems(QPopupMenu*)) ); | 434 | SLOT(addContextMenuItems(QPopupMenu*)) ); |
435 | connect( this, SIGNAL( activated(int) ), SLOT( slotReset() )); | 435 | connect( this, SIGNAL( activated(int) ), SLOT( slotReset() )); |
436 | connect( this, SIGNAL( returnPressed(const QString&) ), SLOT(slotReset())); | 436 | connect( this, SIGNAL( returnPressed(const QString&) ), SLOT(slotReset())); |
437 | } | 437 | } |
438 | 438 | ||
439 | OHistoryCombo::~OHistoryCombo() | 439 | OHistoryCombo::~OHistoryCombo() |
440 | { | 440 | { |
441 | delete myPixProvider; | 441 | delete myPixProvider; |
442 | } | 442 | } |
443 | 443 | ||
444 | void OHistoryCombo::setHistoryItems( QStringList items, | 444 | void OHistoryCombo::setHistoryItems( QStringList items, |
445 | bool setCompletionList ) | 445 | bool setCompletionList ) |
446 | { | 446 | { |
447 | OComboBox::clear(); | 447 | OComboBox::clear(); |
448 | 448 | ||
449 | // limit to maxCount() | 449 | // limit to maxCount() |
450 | while ( (int) items.count() > maxCount() && !items.isEmpty() ) | 450 | while ( (int) items.count() > maxCount() && !items.isEmpty() ) |
451 | items.remove( items.begin() ); | 451 | items.remove( items.begin() ); |
452 | 452 | ||
453 | insertItems( items ); | 453 | insertItems( items ); |
454 | 454 | ||
455 | if ( setCompletionList && useCompletion() ) { | 455 | if ( setCompletionList && useCompletion() ) { |
456 | // we don't have any weighting information here ;( | 456 | // we don't have any weighting information here ;( |
457 | OCompletion *comp = completionObject(); | 457 | OCompletion *comp = completionObject(); |
458 | comp->setOrder( OCompletion::Insertion ); | 458 | comp->setOrder( OCompletion::Insertion ); |
459 | comp->setItems( items ); | 459 | comp->setItems( items ); |
460 | comp->setOrder( OCompletion::Weighted ); | 460 | comp->setOrder( OCompletion::Weighted ); |
461 | } | 461 | } |
462 | 462 | ||
463 | clearEdit(); | 463 | clearEdit(); |
464 | } | 464 | } |
diff --git a/libopie2/qt3/opieui/oeditlistbox.cpp b/libopie2/qt3/opieui/oeditlistbox.cpp index 0e95274..dcc697d 100644 --- a/libopie2/qt3/opieui/oeditlistbox.cpp +++ b/libopie2/qt3/opieui/oeditlistbox.cpp | |||
@@ -99,301 +99,301 @@ void OEditListBox::init( bool checkAtEntering, int buttons, | |||
99 | lostButtons += 2; | 99 | lostButtons += 2; |
100 | 100 | ||
101 | 101 | ||
102 | servNewButton = servRemoveButton = servUpButton = servDownButton = 0L; | 102 | servNewButton = servRemoveButton = servUpButton = servDownButton = 0L; |
103 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, | 103 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, |
104 | QSizePolicy::MinimumExpanding)); | 104 | QSizePolicy::MinimumExpanding)); |
105 | 105 | ||
106 | QWidget * gb = this; | 106 | QWidget * gb = this; |
107 | QGridLayout * grid = new QGridLayout(gb, 7 - lostButtons, 2, | 107 | QGridLayout * grid = new QGridLayout(gb, 7 - lostButtons, 2, |
108 | ODialog::marginHint(), | 108 | ODialog::marginHint(), |
109 | ODialog::spacingHint()); | 109 | ODialog::spacingHint()); |
110 | grid->addRowSpacing(0, fontMetrics().lineSpacing()); | 110 | grid->addRowSpacing(0, fontMetrics().lineSpacing()); |
111 | for ( int i = 1; i < 7 - lostButtons; i++ ) | 111 | for ( int i = 1; i < 7 - lostButtons; i++ ) |
112 | grid->setRowStretch(i, 1); | 112 | grid->setRowStretch(i, 1); |
113 | 113 | ||
114 | grid->setMargin(15); | 114 | grid->setMargin(15); |
115 | 115 | ||
116 | if ( representationWidget ) | 116 | if ( representationWidget ) |
117 | representationWidget->reparent( gb, QPoint(0,0) ); | 117 | representationWidget->reparent( gb, QPoint(0,0) ); |
118 | else | 118 | else |
119 | m_lineEdit=new OLineEdit(gb); | 119 | m_lineEdit=new OLineEdit(gb); |
120 | 120 | ||
121 | m_listBox = new QListBox(gb); | 121 | m_listBox = new QListBox(gb); |
122 | 122 | ||
123 | QWidget *editingWidget = representationWidget ? | 123 | QWidget *editingWidget = representationWidget ? |
124 | representationWidget : m_lineEdit; | 124 | representationWidget : m_lineEdit; |
125 | grid->addMultiCellWidget(editingWidget,1,1,0,1); | 125 | grid->addMultiCellWidget(editingWidget,1,1,0,1); |
126 | grid->addMultiCellWidget(m_listBox, 2, 6 - lostButtons, 0, 0); | 126 | grid->addMultiCellWidget(m_listBox, 2, 6 - lostButtons, 0, 0); |
127 | int row = 2; | 127 | int row = 2; |
128 | if ( buttons & Add ) { | 128 | if ( buttons & Add ) { |
129 | servNewButton = new QPushButton(tr("&Add"), gb); | 129 | servNewButton = new QPushButton(tr("&Add"), gb); |
130 | servNewButton->setEnabled(false); | 130 | servNewButton->setEnabled(false); |
131 | connect(servNewButton, SIGNAL(clicked()), SLOT(addItem())); | 131 | connect(servNewButton, SIGNAL(clicked()), SLOT(addItem())); |
132 | 132 | ||
133 | grid->addWidget(servNewButton, row++, 1); | 133 | grid->addWidget(servNewButton, row++, 1); |
134 | } | 134 | } |
135 | 135 | ||
136 | if ( buttons & Remove ) { | 136 | if ( buttons & Remove ) { |
137 | servRemoveButton = new QPushButton(tr("&Remove"), gb); | 137 | servRemoveButton = new QPushButton(tr("&Remove"), gb); |
138 | servRemoveButton->setEnabled(false); | 138 | servRemoveButton->setEnabled(false); |
139 | connect(servRemoveButton, SIGNAL(clicked()), SLOT(removeItem())); | 139 | connect(servRemoveButton, SIGNAL(clicked()), SLOT(removeItem())); |
140 | 140 | ||
141 | grid->addWidget(servRemoveButton, row++, 1); | 141 | grid->addWidget(servRemoveButton, row++, 1); |
142 | } | 142 | } |
143 | 143 | ||
144 | if ( buttons & UpDown ) { | 144 | if ( buttons & UpDown ) { |
145 | servUpButton = new QPushButton(tr("Move &Up"), gb); | 145 | servUpButton = new QPushButton(tr("Move &Up"), gb); |
146 | servUpButton->setEnabled(false); | 146 | servUpButton->setEnabled(false); |
147 | connect(servUpButton, SIGNAL(clicked()), SLOT(moveItemUp())); | 147 | connect(servUpButton, SIGNAL(clicked()), SLOT(moveItemUp())); |
148 | 148 | ||
149 | servDownButton = new QPushButton(tr("Move &Down"), gb); | 149 | servDownButton = new QPushButton(tr("Move &Down"), gb); |
150 | servDownButton->setEnabled(false); | 150 | servDownButton->setEnabled(false); |
151 | connect(servDownButton, SIGNAL(clicked()), SLOT(moveItemDown())); | 151 | connect(servDownButton, SIGNAL(clicked()), SLOT(moveItemDown())); |
152 | 152 | ||
153 | grid->addWidget(servUpButton, row++, 1); | 153 | grid->addWidget(servUpButton, row++, 1); |
154 | grid->addWidget(servDownButton, row++, 1); | 154 | grid->addWidget(servDownButton, row++, 1); |
155 | } | 155 | } |
156 | 156 | ||
157 | connect(m_lineEdit,SIGNAL(textChanged(const QString&)),this,SLOT(typedSomething(const QString&))); | 157 | connect(m_lineEdit,SIGNAL(textChanged(const QString&)),this,SLOT(typedSomething(const QString&))); |
158 | m_lineEdit->setTrapReturnKey(true); | 158 | m_lineEdit->setTrapReturnKey(true); |
159 | connect(m_lineEdit,SIGNAL(returnPressed()),this,SLOT(addItem())); | 159 | connect(m_lineEdit,SIGNAL(returnPressed()),this,SLOT(addItem())); |
160 | connect(m_listBox, SIGNAL(highlighted(int)), SLOT(enableMoveButtons(int))); | 160 | connect(m_listBox, SIGNAL(highlighted(int)), SLOT(enableMoveButtons(int))); |
161 | 161 | ||
162 | // maybe supplied lineedit has some text already | 162 | // maybe supplied lineedit has some text already |
163 | typedSomething( m_lineEdit->text() ); | 163 | typedSomething( m_lineEdit->text() ); |
164 | } | 164 | } |
165 | 165 | ||
166 | void OEditListBox::typedSomething(const QString& text) | 166 | void OEditListBox::typedSomething(const QString& text) |
167 | { | 167 | { |
168 | if(currentItem() >= 0) { | 168 | if(currentItem() >= 0) { |
169 | if(currentText() != m_lineEdit->text()) | 169 | if(currentText() != m_lineEdit->text()) |
170 | { | 170 | { |
171 | // IMHO changeItem() shouldn't do anything with the value | 171 | // IMHO changeItem() shouldn't do anything with the value |
172 | // of currentItem() ... like changing it or emitting signals ... | 172 | // of currentItem() ... like changing it or emitting signals ... |
173 | // but TT disagree with me on this one (it's been that way since ages ... grrr) | 173 | // but TT disagree with me on this one (it's been that way since ages ... grrr) |
174 | bool block = m_listBox->signalsBlocked(); | 174 | bool block = m_listBox->signalsBlocked(); |
175 | m_listBox->blockSignals( true ); | 175 | m_listBox->blockSignals( true ); |
176 | m_listBox->changeItem(text, currentItem()); | 176 | m_listBox->changeItem(text, currentItem()); |
177 | m_listBox->blockSignals( block ); | 177 | m_listBox->blockSignals( block ); |
178 | emit changed(); | 178 | emit changed(); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | if ( !servNewButton ) | 182 | if ( !servNewButton ) |
183 | return; | 183 | return; |
184 | 184 | ||
185 | if (!d->m_checkAtEntering) | 185 | if (!d->m_checkAtEntering) |
186 | servNewButton->setEnabled(!text.isEmpty()); | 186 | servNewButton->setEnabled(!text.isEmpty()); |
187 | else | 187 | else |
188 | { | 188 | { |
189 | if (text.isEmpty()) | 189 | if (text.isEmpty()) |
190 | { | 190 | { |
191 | servNewButton->setEnabled(false); | 191 | servNewButton->setEnabled(false); |
192 | } | 192 | } |
193 | else | 193 | else |
194 | { | 194 | { |
195 | #if QT_VERSION > 290 | 195 | #if QT_VERSION >= 0x030000 |
196 | StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive ); | 196 | StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive ); |
197 | bool enable = (m_listBox->findItem( text, mode ) == 0L); | 197 | bool enable = (m_listBox->findItem( text, mode ) == 0L); |
198 | #else | 198 | #else |
199 | bool enable = (m_listBox->findItem( text ) == 0L); | 199 | bool enable = (m_listBox->findItem( text ) == 0L); |
200 | #endif | 200 | #endif |
201 | servNewButton->setEnabled( enable ); | 201 | servNewButton->setEnabled( enable ); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | void OEditListBox::moveItemUp() | 206 | void OEditListBox::moveItemUp() |
207 | { | 207 | { |
208 | if (!m_listBox->isEnabled()) | 208 | if (!m_listBox->isEnabled()) |
209 | { | 209 | { |
210 | //ONotifyClient::beep(); | 210 | //ONotifyClient::beep(); |
211 | return; | 211 | return; |
212 | } | 212 | } |
213 | 213 | ||
214 | unsigned int selIndex = m_listBox->currentItem(); | 214 | unsigned int selIndex = m_listBox->currentItem(); |
215 | if (selIndex == 0) | 215 | if (selIndex == 0) |
216 | { | 216 | { |
217 | //ONotifyClient::beep(); | 217 | //ONotifyClient::beep(); |
218 | return; | 218 | return; |
219 | } | 219 | } |
220 | 220 | ||
221 | QListBoxItem *selItem = m_listBox->item(selIndex); | 221 | QListBoxItem *selItem = m_listBox->item(selIndex); |
222 | m_listBox->takeItem(selItem); | 222 | m_listBox->takeItem(selItem); |
223 | m_listBox->insertItem(selItem, selIndex-1); | 223 | m_listBox->insertItem(selItem, selIndex-1); |
224 | m_listBox->setCurrentItem(selIndex - 1); | 224 | m_listBox->setCurrentItem(selIndex - 1); |
225 | 225 | ||
226 | emit changed(); | 226 | emit changed(); |
227 | } | 227 | } |
228 | 228 | ||
229 | void OEditListBox::moveItemDown() | 229 | void OEditListBox::moveItemDown() |
230 | { | 230 | { |
231 | if (!m_listBox->isEnabled()) | 231 | if (!m_listBox->isEnabled()) |
232 | { | 232 | { |
233 | //ONotifyClient::beep(); | 233 | //ONotifyClient::beep(); |
234 | return; | 234 | return; |
235 | } | 235 | } |
236 | 236 | ||
237 | unsigned int selIndex = m_listBox->currentItem(); | 237 | unsigned int selIndex = m_listBox->currentItem(); |
238 | if (selIndex == m_listBox->count() - 1) | 238 | if (selIndex == m_listBox->count() - 1) |
239 | { | 239 | { |
240 | //ONotifyClient::beep(); | 240 | //ONotifyClient::beep(); |
241 | return; | 241 | return; |
242 | } | 242 | } |
243 | 243 | ||
244 | QListBoxItem *selItem = m_listBox->item(selIndex); | 244 | QListBoxItem *selItem = m_listBox->item(selIndex); |
245 | m_listBox->takeItem(selItem); | 245 | m_listBox->takeItem(selItem); |
246 | m_listBox->insertItem(selItem, selIndex+1); | 246 | m_listBox->insertItem(selItem, selIndex+1); |
247 | m_listBox->setCurrentItem(selIndex + 1); | 247 | m_listBox->setCurrentItem(selIndex + 1); |
248 | 248 | ||
249 | emit changed(); | 249 | emit changed(); |
250 | } | 250 | } |
251 | 251 | ||
252 | void OEditListBox::addItem() | 252 | void OEditListBox::addItem() |
253 | { | 253 | { |
254 | // when m_checkAtEntering is true, the add-button is disabled, but this | 254 | // when m_checkAtEntering is true, the add-button is disabled, but this |
255 | // slot can still be called through Key_Return/Key_Enter. So we guard | 255 | // slot can still be called through Key_Return/Key_Enter. So we guard |
256 | // against this. | 256 | // against this. |
257 | if ( !servNewButton || !servNewButton->isEnabled() ) | 257 | if ( !servNewButton || !servNewButton->isEnabled() ) |
258 | return; | 258 | return; |
259 | 259 | ||
260 | const QString& currentTextLE=m_lineEdit->text(); | 260 | const QString& currentTextLE=m_lineEdit->text(); |
261 | bool alreadyInList(false); | 261 | bool alreadyInList(false); |
262 | //if we didn't check for dupes at the inserting we have to do it now | 262 | //if we didn't check for dupes at the inserting we have to do it now |
263 | if (!d->m_checkAtEntering) | 263 | if (!d->m_checkAtEntering) |
264 | { | 264 | { |
265 | // first check current item instead of dumb iterating the entire list | 265 | // first check current item instead of dumb iterating the entire list |
266 | if ( m_listBox->currentText() == currentTextLE ) | 266 | if ( m_listBox->currentText() == currentTextLE ) |
267 | alreadyInList = true; | 267 | alreadyInList = true; |
268 | else | 268 | else |
269 | { | 269 | { |
270 | #if QT_VERSION > 290 | 270 | #if QT_VERSION >= 0x030000 |
271 | StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive ); | 271 | StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive ); |
272 | alreadyInList =(m_listBox->findItem(currentTextLE, mode) != 0); | 272 | alreadyInList =(m_listBox->findItem(currentTextLE, mode) != 0); |
273 | #else | 273 | #else |
274 | alreadyInList =(m_listBox->findItem(currentTextLE) != 0); | 274 | alreadyInList =(m_listBox->findItem(currentTextLE) != 0); |
275 | #endif | 275 | #endif |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | if ( servNewButton ) | 279 | if ( servNewButton ) |
280 | servNewButton->setEnabled(false); | 280 | servNewButton->setEnabled(false); |
281 | 281 | ||
282 | bool block = m_lineEdit->signalsBlocked(); | 282 | bool block = m_lineEdit->signalsBlocked(); |
283 | m_lineEdit->blockSignals(true); | 283 | m_lineEdit->blockSignals(true); |
284 | m_lineEdit->clear(); | 284 | m_lineEdit->clear(); |
285 | m_lineEdit->blockSignals(block); | 285 | m_lineEdit->blockSignals(block); |
286 | 286 | ||
287 | m_listBox->setSelected(currentItem(), false); | 287 | m_listBox->setSelected(currentItem(), false); |
288 | 288 | ||
289 | if (!alreadyInList) | 289 | if (!alreadyInList) |
290 | { | 290 | { |
291 | block = m_listBox->signalsBlocked(); | 291 | block = m_listBox->signalsBlocked(); |
292 | m_listBox->blockSignals( true ); | 292 | m_listBox->blockSignals( true ); |
293 | m_listBox->insertItem(currentTextLE); | 293 | m_listBox->insertItem(currentTextLE); |
294 | m_listBox->blockSignals( block ); | 294 | m_listBox->blockSignals( block ); |
295 | emit changed(); | 295 | emit changed(); |
296 | emit added( currentTextLE ); | 296 | emit added( currentTextLE ); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | 299 | ||
300 | int OEditListBox::currentItem() const | 300 | int OEditListBox::currentItem() const |
301 | { | 301 | { |
302 | int nr = m_listBox->currentItem(); | 302 | int nr = m_listBox->currentItem(); |
303 | #if QT_VERSION > 290 | 303 | #if QT_VERSION >= 0x030000 |
304 | if(nr >= 0 && !m_listBox->item(nr)->isSelected()) return -1; | 304 | if(nr >= 0 && !m_listBox->item(nr)->isSelected()) return -1; |
305 | #else | 305 | #else |
306 | if(nr >= 0 && !m_listBox->isSelected(m_listBox->item(nr))) return -1; | 306 | if(nr >= 0 && !m_listBox->isSelected(m_listBox->item(nr))) return -1; |
307 | #endif | 307 | #endif |
308 | return nr; | 308 | return nr; |
309 | } | 309 | } |
310 | 310 | ||
311 | void OEditListBox::removeItem() | 311 | void OEditListBox::removeItem() |
312 | { | 312 | { |
313 | int selected = m_listBox->currentItem(); | 313 | int selected = m_listBox->currentItem(); |
314 | 314 | ||
315 | if ( selected >= 0 ) | 315 | if ( selected >= 0 ) |
316 | { | 316 | { |
317 | QString removedText = m_listBox->currentText(); | 317 | QString removedText = m_listBox->currentText(); |
318 | 318 | ||
319 | m_listBox->removeItem( selected ); | 319 | m_listBox->removeItem( selected ); |
320 | if ( count() > 0 ) | 320 | if ( count() > 0 ) |
321 | m_listBox->setSelected( QMIN( selected, count() - 1 ), true ); | 321 | m_listBox->setSelected( QMIN( selected, count() - 1 ), true ); |
322 | 322 | ||
323 | emit changed(); | 323 | emit changed(); |
324 | emit removed( removedText ); | 324 | emit removed( removedText ); |
325 | } | 325 | } |
326 | 326 | ||
327 | if ( servRemoveButton && m_listBox->currentItem() == -1 ) | 327 | if ( servRemoveButton && m_listBox->currentItem() == -1 ) |
328 | servRemoveButton->setEnabled(false); | 328 | servRemoveButton->setEnabled(false); |
329 | } | 329 | } |
330 | 330 | ||
331 | void OEditListBox::enableMoveButtons(int index) | 331 | void OEditListBox::enableMoveButtons(int index) |
332 | { | 332 | { |
333 | // Update the lineEdit when we select a different line. | 333 | // Update the lineEdit when we select a different line. |
334 | if(currentText() != m_lineEdit->text()) | 334 | if(currentText() != m_lineEdit->text()) |
335 | m_lineEdit->setText(currentText()); | 335 | m_lineEdit->setText(currentText()); |
336 | 336 | ||
337 | bool moveEnabled = servUpButton && servDownButton; | 337 | bool moveEnabled = servUpButton && servDownButton; |
338 | 338 | ||
339 | if (moveEnabled ) | 339 | if (moveEnabled ) |
340 | { | 340 | { |
341 | if (m_listBox->count() <= 1) | 341 | if (m_listBox->count() <= 1) |
342 | { | 342 | { |
343 | servUpButton->setEnabled(false); | 343 | servUpButton->setEnabled(false); |
344 | servDownButton->setEnabled(false); | 344 | servDownButton->setEnabled(false); |
345 | } | 345 | } |
346 | else if ((uint) index == (m_listBox->count() - 1)) | 346 | else if ((uint) index == (m_listBox->count() - 1)) |
347 | { | 347 | { |
348 | servUpButton->setEnabled(true); | 348 | servUpButton->setEnabled(true); |
349 | servDownButton->setEnabled(false); | 349 | servDownButton->setEnabled(false); |
350 | } | 350 | } |
351 | else if (index == 0) | 351 | else if (index == 0) |
352 | { | 352 | { |
353 | servUpButton->setEnabled(false); | 353 | servUpButton->setEnabled(false); |
354 | servDownButton->setEnabled(true); | 354 | servDownButton->setEnabled(true); |
355 | } | 355 | } |
356 | else | 356 | else |
357 | { | 357 | { |
358 | servUpButton->setEnabled(true); | 358 | servUpButton->setEnabled(true); |
359 | servDownButton->setEnabled(true); | 359 | servDownButton->setEnabled(true); |
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | if ( servRemoveButton ) | 363 | if ( servRemoveButton ) |
364 | servRemoveButton->setEnabled(true); | 364 | servRemoveButton->setEnabled(true); |
365 | } | 365 | } |
366 | 366 | ||
367 | void OEditListBox::clear() | 367 | void OEditListBox::clear() |
368 | { | 368 | { |
369 | m_lineEdit->clear(); | 369 | m_lineEdit->clear(); |
370 | m_listBox->clear(); | 370 | m_listBox->clear(); |
371 | emit changed(); | 371 | emit changed(); |
372 | } | 372 | } |
373 | 373 | ||
374 | void OEditListBox::insertStringList(const QStringList& list, int index) | 374 | void OEditListBox::insertStringList(const QStringList& list, int index) |
375 | { | 375 | { |
376 | m_listBox->insertStringList(list,index); | 376 | m_listBox->insertStringList(list,index); |
377 | } | 377 | } |
378 | 378 | ||
379 | void OEditListBox::insertStrList(const QStrList* list, int index) | 379 | void OEditListBox::insertStrList(const QStrList* list, int index) |
380 | { | 380 | { |
381 | m_listBox->insertStrList(list,index); | 381 | m_listBox->insertStrList(list,index); |
382 | } | 382 | } |
383 | 383 | ||
384 | void OEditListBox::insertStrList(const QStrList& list, int index) | 384 | void OEditListBox::insertStrList(const QStrList& list, int index) |
385 | { | 385 | { |
386 | m_listBox->insertStrList(list,index); | 386 | m_listBox->insertStrList(list,index); |
387 | } | 387 | } |
388 | 388 | ||
389 | void OEditListBox::insertStrList(const char ** list, int numStrings, int index) | 389 | void OEditListBox::insertStrList(const char ** list, int numStrings, int index) |
390 | { | 390 | { |
391 | m_listBox->insertStrList(list,numStrings,index); | 391 | m_listBox->insertStrList(list,numStrings,index); |
392 | } | 392 | } |
393 | 393 | ||
394 | QStringList OEditListBox::items() const | 394 | QStringList OEditListBox::items() const |
395 | { | 395 | { |
396 | QStringList list; | 396 | QStringList list; |
397 | for ( uint i = 0; i < m_listBox->count(); i++ ) | 397 | for ( uint i = 0; i < m_listBox->count(); i++ ) |
398 | list.append( m_listBox->text( i )); | 398 | list.append( m_listBox->text( i )); |
399 | 399 | ||
diff --git a/libopie2/qt3/opieui/olineedit.cpp b/libopie2/qt3/opieui/olineedit.cpp index 6f66fc7..b150987 100644 --- a/libopie2/qt3/opieui/olineedit.cpp +++ b/libopie2/qt3/opieui/olineedit.cpp | |||
@@ -52,484 +52,484 @@ typedef QString KURL; //FIXME: Revise for Opie | |||
52 | class OLineEdit::OLineEditPrivate | 52 | class OLineEdit::OLineEditPrivate |
53 | { | 53 | { |
54 | public: | 54 | public: |
55 | OLineEditPrivate() | 55 | OLineEditPrivate() |
56 | { | 56 | { |
57 | grabReturnKeyEvents = false; | 57 | grabReturnKeyEvents = false; |
58 | handleURLDrops = true; | 58 | handleURLDrops = true; |
59 | completionBox = 0L; | 59 | completionBox = 0L; |
60 | } | 60 | } |
61 | ~OLineEditPrivate() | 61 | ~OLineEditPrivate() |
62 | { | 62 | { |
63 | delete completionBox; | 63 | delete completionBox; |
64 | } | 64 | } |
65 | 65 | ||
66 | bool grabReturnKeyEvents; | 66 | bool grabReturnKeyEvents; |
67 | bool handleURLDrops; | 67 | bool handleURLDrops; |
68 | OCompletionBox *completionBox; | 68 | OCompletionBox *completionBox; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | 71 | ||
72 | /*====================================================================================== | 72 | /*====================================================================================== |
73 | * OLineEdit | 73 | * OLineEdit |
74 | *======================================================================================*/ | 74 | *======================================================================================*/ |
75 | 75 | ||
76 | OLineEdit::OLineEdit( const QString &string, QWidget *parent, const char *name ) | 76 | OLineEdit::OLineEdit( const QString &string, QWidget *parent, const char *name ) |
77 | : QLineEdit( string, parent, name ) | 77 | : QLineEdit( string, parent, name ) |
78 | { | 78 | { |
79 | init(); | 79 | init(); |
80 | } | 80 | } |
81 | 81 | ||
82 | OLineEdit::OLineEdit( QWidget *parent, const char *name ) | 82 | OLineEdit::OLineEdit( QWidget *parent, const char *name ) |
83 | : QLineEdit( parent, name ) | 83 | : QLineEdit( parent, name ) |
84 | { | 84 | { |
85 | init(); | 85 | init(); |
86 | } | 86 | } |
87 | 87 | ||
88 | OLineEdit::~OLineEdit () | 88 | OLineEdit::~OLineEdit () |
89 | { | 89 | { |
90 | delete d; | 90 | delete d; |
91 | } | 91 | } |
92 | 92 | ||
93 | void OLineEdit::init() | 93 | void OLineEdit::init() |
94 | { | 94 | { |
95 | d = new OLineEditPrivate; | 95 | d = new OLineEditPrivate; |
96 | possibleTripleClick = false; | 96 | possibleTripleClick = false; |
97 | // Enable the context menu by default. | 97 | // Enable the context menu by default. |
98 | setContextMenuEnabled( true ); | 98 | setContextMenuEnabled( true ); |
99 | //OCursor::setAutoHideCursor( this, true, true ); | 99 | //OCursor::setAutoHideCursor( this, true, true ); |
100 | installEventFilter( this ); | 100 | installEventFilter( this ); |
101 | } | 101 | } |
102 | 102 | ||
103 | void OLineEdit::setCompletionMode( OGlobalSettings::Completion mode ) | 103 | void OLineEdit::setCompletionMode( OGlobalSettings::Completion mode ) |
104 | { | 104 | { |
105 | OGlobalSettings::Completion oldMode = completionMode(); | 105 | OGlobalSettings::Completion oldMode = completionMode(); |
106 | if ( oldMode != mode && oldMode == OGlobalSettings::CompletionPopup && | 106 | if ( oldMode != mode && oldMode == OGlobalSettings::CompletionPopup && |
107 | d->completionBox && d->completionBox->isVisible() ) | 107 | d->completionBox && d->completionBox->isVisible() ) |
108 | d->completionBox->hide(); | 108 | d->completionBox->hide(); |
109 | 109 | ||
110 | // If the widgets echo mode is not Normal, no completion | 110 | // If the widgets echo mode is not Normal, no completion |
111 | // feature will be enabled even if one is requested. | 111 | // feature will be enabled even if one is requested. |
112 | if ( echoMode() != QLineEdit::Normal ) | 112 | if ( echoMode() != QLineEdit::Normal ) |
113 | mode = OGlobalSettings::CompletionNone; // Override the request. | 113 | mode = OGlobalSettings::CompletionNone; // Override the request. |
114 | 114 | ||
115 | OCompletionBase::setCompletionMode( mode ); | 115 | OCompletionBase::setCompletionMode( mode ); |
116 | } | 116 | } |
117 | 117 | ||
118 | void OLineEdit::setCompletedText( const QString& t, bool marked ) | 118 | void OLineEdit::setCompletedText( const QString& t, bool marked ) |
119 | { | 119 | { |
120 | QString txt = text(); | 120 | QString txt = text(); |
121 | if ( t != txt ) | 121 | if ( t != txt ) |
122 | { | 122 | { |
123 | int curpos = marked ? txt.length() : t.length(); | 123 | int curpos = marked ? txt.length() : t.length(); |
124 | validateAndSet( t, curpos, curpos, t.length() ); | 124 | validateAndSet( t, curpos, curpos, t.length() ); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | void OLineEdit::setCompletedText( const QString& text ) | 128 | void OLineEdit::setCompletedText( const QString& text ) |
129 | { | 129 | { |
130 | OGlobalSettings::Completion mode = completionMode(); | 130 | OGlobalSettings::Completion mode = completionMode(); |
131 | bool marked = ( mode == OGlobalSettings::CompletionAuto || | 131 | bool marked = ( mode == OGlobalSettings::CompletionAuto || |
132 | mode == OGlobalSettings::CompletionMan || | 132 | mode == OGlobalSettings::CompletionMan || |
133 | mode == OGlobalSettings::CompletionPopup ); | 133 | mode == OGlobalSettings::CompletionPopup ); |
134 | setCompletedText( text, marked ); | 134 | setCompletedText( text, marked ); |
135 | } | 135 | } |
136 | 136 | ||
137 | void OLineEdit::rotateText( OCompletionBase::KeyBindingType type ) | 137 | void OLineEdit::rotateText( OCompletionBase::KeyBindingType type ) |
138 | { | 138 | { |
139 | OCompletion* comp = compObj(); | 139 | OCompletion* comp = compObj(); |
140 | if ( comp && | 140 | if ( comp && |
141 | (type == OCompletionBase::PrevCompletionMatch || | 141 | (type == OCompletionBase::PrevCompletionMatch || |
142 | type == OCompletionBase::NextCompletionMatch ) ) | 142 | type == OCompletionBase::NextCompletionMatch ) ) |
143 | { | 143 | { |
144 | QString input = (type == OCompletionBase::PrevCompletionMatch) ? comp->previousMatch() : comp->nextMatch(); | 144 | QString input = (type == OCompletionBase::PrevCompletionMatch) ? comp->previousMatch() : comp->nextMatch(); |
145 | // Skip rotation if previous/next match is null or the same text | 145 | // Skip rotation if previous/next match is null or the same text |
146 | if ( input.isNull() || input == displayText() ) | 146 | if ( input.isNull() || input == displayText() ) |
147 | return; | 147 | return; |
148 | #if QT_VERSION > 290 | 148 | #if QT_VERSION >= 0x030000 |
149 | setCompletedText( input, hasSelectedText() ); | 149 | setCompletedText( input, hasSelectedText() ); |
150 | #else | 150 | #else |
151 | setCompletedText( input, hasMarkedText() ); | 151 | setCompletedText( input, hasMarkedText() ); |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | void OLineEdit::makeCompletion( const QString& text ) | 156 | void OLineEdit::makeCompletion( const QString& text ) |
157 | { | 157 | { |
158 | OCompletion *comp = compObj(); | 158 | OCompletion *comp = compObj(); |
159 | if ( !comp ) | 159 | if ( !comp ) |
160 | return; // No completion object... | 160 | return; // No completion object... |
161 | 161 | ||
162 | QString match = comp->makeCompletion( text ); | 162 | QString match = comp->makeCompletion( text ); |
163 | OGlobalSettings::Completion mode = completionMode(); | 163 | OGlobalSettings::Completion mode = completionMode(); |
164 | if ( mode == OGlobalSettings::CompletionPopup ) | 164 | if ( mode == OGlobalSettings::CompletionPopup ) |
165 | { | 165 | { |
166 | if ( match.isNull() ) | 166 | if ( match.isNull() ) |
167 | { | 167 | { |
168 | if ( d->completionBox ) { | 168 | if ( d->completionBox ) { |
169 | d->completionBox->hide(); | 169 | d->completionBox->hide(); |
170 | d->completionBox->clear(); | 170 | d->completionBox->clear(); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | else | 173 | else |
174 | setCompletedItems( comp->allMatches() ); | 174 | setCompletedItems( comp->allMatches() ); |
175 | } | 175 | } |
176 | else | 176 | else |
177 | { | 177 | { |
178 | // all other completion modes | 178 | // all other completion modes |
179 | // If no match or the same match, simply return without completing. | 179 | // If no match or the same match, simply return without completing. |
180 | if ( match.isNull() || match == text ) | 180 | if ( match.isNull() || match == text ) |
181 | return; | 181 | return; |
182 | 182 | ||
183 | setCompletedText( match ); | 183 | setCompletedText( match ); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | void OLineEdit::setReadOnly(bool readOnly) | 187 | void OLineEdit::setReadOnly(bool readOnly) |
188 | { | 188 | { |
189 | QPalette p = palette(); | 189 | QPalette p = palette(); |
190 | if (readOnly) | 190 | if (readOnly) |
191 | { | 191 | { |
192 | QColor color = p.color(QPalette::Disabled, QColorGroup::Background); | 192 | QColor color = p.color(QPalette::Disabled, QColorGroup::Background); |
193 | p.setColor(QColorGroup::Base, color); | 193 | p.setColor(QColorGroup::Base, color); |
194 | p.setColor(QColorGroup::Background, color); | 194 | p.setColor(QColorGroup::Background, color); |
195 | } | 195 | } |
196 | else | 196 | else |
197 | { | 197 | { |
198 | QColor color = p.color(QPalette::Normal, QColorGroup::Base); | 198 | QColor color = p.color(QPalette::Normal, QColorGroup::Base); |
199 | p.setColor(QColorGroup::Base, color); | 199 | p.setColor(QColorGroup::Base, color); |
200 | p.setColor(QColorGroup::Background, color); | 200 | p.setColor(QColorGroup::Background, color); |
201 | } | 201 | } |
202 | setPalette(p); | 202 | setPalette(p); |
203 | 203 | ||
204 | QLineEdit::setReadOnly (readOnly); | 204 | QLineEdit::setReadOnly (readOnly); |
205 | } | 205 | } |
206 | 206 | ||
207 | void OLineEdit::keyPressEvent( QKeyEvent *e ) | 207 | void OLineEdit::keyPressEvent( QKeyEvent *e ) |
208 | { | 208 | { |
209 | qDebug( "OLineEdit::keyPressEvent()" ); | 209 | qDebug( "OLineEdit::keyPressEvent()" ); |
210 | 210 | ||
211 | /* | 211 | /* |
212 | 212 | ||
213 | KKey key( e ); | 213 | KKey key( e ); |
214 | 214 | ||
215 | if ( KStdAccel::copy().contains( key ) ) { | 215 | if ( KStdAccel::copy().contains( key ) ) { |
216 | copy(); | 216 | copy(); |
217 | return; | 217 | return; |
218 | } | 218 | } |
219 | else if ( KStdAccel::paste().contains( key ) ) { | 219 | else if ( KStdAccel::paste().contains( key ) ) { |
220 | paste(); | 220 | paste(); |
221 | return; | 221 | return; |
222 | } | 222 | } |
223 | else if ( KStdAccel::cut().contains( key ) ) { | 223 | else if ( KStdAccel::cut().contains( key ) ) { |
224 | cut(); | 224 | cut(); |
225 | return; | 225 | return; |
226 | } | 226 | } |
227 | else if ( KStdAccel::undo().contains( key ) ) { | 227 | else if ( KStdAccel::undo().contains( key ) ) { |
228 | undo(); | 228 | undo(); |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | else if ( KStdAccel::redo().contains( key ) ) { | 231 | else if ( KStdAccel::redo().contains( key ) ) { |
232 | redo(); | 232 | redo(); |
233 | return; | 233 | return; |
234 | } | 234 | } |
235 | else if ( KStdAccel::deleteWordBack().contains( key ) ) | 235 | else if ( KStdAccel::deleteWordBack().contains( key ) ) |
236 | { | 236 | { |
237 | cursorWordBackward(TRUE); | 237 | cursorWordBackward(TRUE); |
238 | if ( hasSelectedText() ) | 238 | if ( hasSelectedText() ) |
239 | del(); | 239 | del(); |
240 | 240 | ||
241 | e->accept(); | 241 | e->accept(); |
242 | return; | 242 | return; |
243 | } | 243 | } |
244 | else if ( KStdAccel::deleteWordForward().contains( key ) ) | 244 | else if ( KStdAccel::deleteWordForward().contains( key ) ) |
245 | { | 245 | { |
246 | // Workaround for QT bug where | 246 | // Workaround for QT bug where |
247 | cursorWordForward(TRUE); | 247 | cursorWordForward(TRUE); |
248 | if ( hasSelectedText() ) | 248 | if ( hasSelectedText() ) |
249 | del(); | 249 | del(); |
250 | 250 | ||
251 | e->accept(); | 251 | e->accept(); |
252 | return; | 252 | return; |
253 | } | 253 | } |
254 | */ | 254 | */ |
255 | 255 | ||
256 | // Filter key-events if EchoMode is normal & | 256 | // Filter key-events if EchoMode is normal & |
257 | // completion mode is not set to CompletionNone | 257 | // completion mode is not set to CompletionNone |
258 | if ( echoMode() == QLineEdit::Normal && | 258 | if ( echoMode() == QLineEdit::Normal && |
259 | completionMode() != OGlobalSettings::CompletionNone ) | 259 | completionMode() != OGlobalSettings::CompletionNone ) |
260 | { | 260 | { |
261 | KeyBindingMap keys = getKeyBindings(); | 261 | KeyBindingMap keys = getKeyBindings(); |
262 | OGlobalSettings::Completion mode = completionMode(); | 262 | OGlobalSettings::Completion mode = completionMode(); |
263 | bool noModifier = (e->state() == NoButton || e->state()== ShiftButton); | 263 | bool noModifier = (e->state() == NoButton || e->state()== ShiftButton); |
264 | 264 | ||
265 | if ( (mode == OGlobalSettings::CompletionAuto || | 265 | if ( (mode == OGlobalSettings::CompletionAuto || |
266 | mode == OGlobalSettings::CompletionMan) && noModifier ) | 266 | mode == OGlobalSettings::CompletionMan) && noModifier ) |
267 | { | 267 | { |
268 | QString keycode = e->text(); | 268 | QString keycode = e->text(); |
269 | if ( !keycode.isNull() && keycode.unicode()->isPrint() ) | 269 | if ( !keycode.isNull() && keycode.unicode()->isPrint() ) |
270 | { | 270 | { |
271 | QLineEdit::keyPressEvent ( e ); | 271 | QLineEdit::keyPressEvent ( e ); |
272 | QString txt = text(); | 272 | QString txt = text(); |
273 | int len = txt.length(); | 273 | int len = txt.length(); |
274 | #if QT_VERSION > 290 | 274 | #if QT_VERSION >= 0x030000 |
275 | if ( !hasSelectedText() && len && cursorPosition() == len ) | 275 | if ( !hasSelectedText() && len && cursorPosition() == len ) |
276 | #else | 276 | #else |
277 | if ( !hasMarkedText() && len && cursorPosition() == len ) | 277 | if ( !hasMarkedText() && len && cursorPosition() == len ) |
278 | #endif | 278 | #endif |
279 | { | 279 | { |
280 | if ( emitSignals() ) | 280 | if ( emitSignals() ) |
281 | emit completion( txt ); | 281 | emit completion( txt ); |
282 | if ( handleSignals() ) | 282 | if ( handleSignals() ) |
283 | makeCompletion( txt ); | 283 | makeCompletion( txt ); |
284 | e->accept(); | 284 | e->accept(); |
285 | } | 285 | } |
286 | return; | 286 | return; |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | else if ( mode == OGlobalSettings::CompletionPopup && noModifier ) | 290 | else if ( mode == OGlobalSettings::CompletionPopup && noModifier ) |
291 | { | 291 | { |
292 | qDebug( "OLineEdit::keyPressEvent() - global settings = CompletionPopup & noModifier" ); | 292 | qDebug( "OLineEdit::keyPressEvent() - global settings = CompletionPopup & noModifier" ); |
293 | 293 | ||
294 | QString old_txt = text(); | 294 | QString old_txt = text(); |
295 | QLineEdit::keyPressEvent ( e ); | 295 | QLineEdit::keyPressEvent ( e ); |
296 | QString txt = text(); | 296 | QString txt = text(); |
297 | int len = txt.length(); | 297 | int len = txt.length(); |
298 | QString keycode = e->text(); | 298 | QString keycode = e->text(); |
299 | 299 | ||
300 | 300 | ||
301 | if ( txt != old_txt && len && cursorPosition() == len && | 301 | if ( txt != old_txt && len && cursorPosition() == len && |
302 | ( (!keycode.isNull() && keycode.unicode()->isPrint()) || | 302 | ( (!keycode.isNull() && keycode.unicode()->isPrint()) || |
303 | e->key() == Key_Backspace ) ) | 303 | e->key() == Key_Backspace ) ) |
304 | { | 304 | { |
305 | if ( emitSignals() ) | 305 | if ( emitSignals() ) |
306 | emit completion( txt ); // emit when requested... | 306 | emit completion( txt ); // emit when requested... |
307 | if ( handleSignals() ) | 307 | if ( handleSignals() ) |
308 | makeCompletion( txt ); // handle when requested... | 308 | makeCompletion( txt ); // handle when requested... |
309 | e->accept(); | 309 | e->accept(); |
310 | } | 310 | } |
311 | else if (!len && d->completionBox && d->completionBox->isVisible()) | 311 | else if (!len && d->completionBox && d->completionBox->isVisible()) |
312 | d->completionBox->hide(); | 312 | d->completionBox->hide(); |
313 | 313 | ||
314 | return; | 314 | return; |
315 | } | 315 | } |
316 | 316 | ||
317 | /*else if ( mode == OGlobalSettings::CompletionShell ) | 317 | /*else if ( mode == OGlobalSettings::CompletionShell ) |
318 | { | 318 | { |
319 | // Handles completion. | 319 | // Handles completion. |
320 | KShortcut cut; | 320 | KShortcut cut; |
321 | if ( keys[TextCompletion].isNull() ) | 321 | if ( keys[TextCompletion].isNull() ) |
322 | cut = KStdAccel::shortcut(KStdAccel::TextCompletion); | 322 | cut = KStdAccel::shortcut(KStdAccel::TextCompletion); |
323 | else | 323 | else |
324 | cut = keys[TextCompletion]; | 324 | cut = keys[TextCompletion]; |
325 | 325 | ||
326 | if ( cut.contains( key ) ) | 326 | if ( cut.contains( key ) ) |
327 | { | 327 | { |
328 | // Emit completion if the completion mode is CompletionShell | 328 | // Emit completion if the completion mode is CompletionShell |
329 | // and the cursor is at the end of the string. | 329 | // and the cursor is at the end of the string. |
330 | QString txt = text(); | 330 | QString txt = text(); |
331 | int len = txt.length(); | 331 | int len = txt.length(); |
332 | if ( cursorPosition() == len && len != 0 ) | 332 | if ( cursorPosition() == len && len != 0 ) |
333 | { | 333 | { |
334 | if ( emitSignals() ) | 334 | if ( emitSignals() ) |
335 | emit completion( txt ); | 335 | emit completion( txt ); |
336 | if ( handleSignals() ) | 336 | if ( handleSignals() ) |
337 | makeCompletion( txt ); | 337 | makeCompletion( txt ); |
338 | return; | 338 | return; |
339 | } | 339 | } |
340 | } | 340 | } |
341 | else if ( d->completionBox ) | 341 | else if ( d->completionBox ) |
342 | d->completionBox->hide(); | 342 | d->completionBox->hide(); |
343 | } | 343 | } |
344 | 344 | ||
345 | // handle rotation | 345 | // handle rotation |
346 | if ( mode != OGlobalSettings::CompletionNone ) | 346 | if ( mode != OGlobalSettings::CompletionNone ) |
347 | { | 347 | { |
348 | // Handles previous match | 348 | // Handles previous match |
349 | KShortcut cut; | 349 | KShortcut cut; |
350 | if ( keys[PrevCompletionMatch].isNull() ) | 350 | if ( keys[PrevCompletionMatch].isNull() ) |
351 | cut = KStdAccel::shortcut(KStdAccel::PrevCompletion); | 351 | cut = KStdAccel::shortcut(KStdAccel::PrevCompletion); |
352 | else | 352 | else |
353 | cut = keys[PrevCompletionMatch]; | 353 | cut = keys[PrevCompletionMatch]; |
354 | 354 | ||
355 | if ( cut.contains( key ) ) | 355 | if ( cut.contains( key ) ) |
356 | { | 356 | { |
357 | if ( emitSignals() ) | 357 | if ( emitSignals() ) |
358 | emit textRotation( OCompletionBase::PrevCompletionMatch ); | 358 | emit textRotation( OCompletionBase::PrevCompletionMatch ); |
359 | if ( handleSignals() ) | 359 | if ( handleSignals() ) |
360 | rotateText( OCompletionBase::PrevCompletionMatch ); | 360 | rotateText( OCompletionBase::PrevCompletionMatch ); |
361 | return; | 361 | return; |
362 | } | 362 | } |
363 | 363 | ||
364 | // Handles next match | 364 | // Handles next match |
365 | if ( keys[NextCompletionMatch].isNull() ) | 365 | if ( keys[NextCompletionMatch].isNull() ) |
366 | cut = KStdAccel::key(KStdAccel::NextCompletion); | 366 | cut = KStdAccel::key(KStdAccel::NextCompletion); |
367 | else | 367 | else |
368 | cut = keys[NextCompletionMatch]; | 368 | cut = keys[NextCompletionMatch]; |
369 | 369 | ||
370 | if ( cut.contains( key ) ) | 370 | if ( cut.contains( key ) ) |
371 | { | 371 | { |
372 | if ( emitSignals() ) | 372 | if ( emitSignals() ) |
373 | emit textRotation( OCompletionBase::NextCompletionMatch ); | 373 | emit textRotation( OCompletionBase::NextCompletionMatch ); |
374 | if ( handleSignals() ) | 374 | if ( handleSignals() ) |
375 | rotateText( OCompletionBase::NextCompletionMatch ); | 375 | rotateText( OCompletionBase::NextCompletionMatch ); |
376 | return; | 376 | return; |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | // substring completion | 380 | // substring completion |
381 | if ( compObj() ) | 381 | if ( compObj() ) |
382 | { | 382 | { |
383 | KShortcut cut; | 383 | KShortcut cut; |
384 | if ( keys[SubstringCompletion].isNull() ) | 384 | if ( keys[SubstringCompletion].isNull() ) |
385 | cut = KStdAccel::shortcut(KStdAccel::SubstringCompletion); | 385 | cut = KStdAccel::shortcut(KStdAccel::SubstringCompletion); |
386 | else | 386 | else |
387 | cut = keys[SubstringCompletion]; | 387 | cut = keys[SubstringCompletion]; |
388 | 388 | ||
389 | if ( cut.contains( key ) ) | 389 | if ( cut.contains( key ) ) |
390 | { | 390 | { |
391 | if ( emitSignals() ) | 391 | if ( emitSignals() ) |
392 | emit substringCompletion( text() ); | 392 | emit substringCompletion( text() ); |
393 | if ( handleSignals() ) | 393 | if ( handleSignals() ) |
394 | { | 394 | { |
395 | setCompletedItems( compObj()->substringCompletion(text())); | 395 | setCompletedItems( compObj()->substringCompletion(text())); |
396 | e->accept(); | 396 | e->accept(); |
397 | } | 397 | } |
398 | return; | 398 | return; |
399 | } | 399 | } |
400 | } */ | 400 | } */ |
401 | } | 401 | } |
402 | 402 | ||
403 | // Let QLineEdit handle any other keys events. | 403 | // Let QLineEdit handle any other keys events. |
404 | QLineEdit::keyPressEvent ( e ); | 404 | QLineEdit::keyPressEvent ( e ); |
405 | } | 405 | } |
406 | 406 | ||
407 | void OLineEdit::mouseDoubleClickEvent( QMouseEvent* e ) | 407 | void OLineEdit::mouseDoubleClickEvent( QMouseEvent* e ) |
408 | { | 408 | { |
409 | if ( e->button() == Qt::LeftButton ) | 409 | if ( e->button() == Qt::LeftButton ) |
410 | { | 410 | { |
411 | possibleTripleClick=true; | 411 | possibleTripleClick=true; |
412 | QTimer::singleShot( QApplication::doubleClickInterval(),this, | 412 | QTimer::singleShot( QApplication::doubleClickInterval(),this, |
413 | SLOT(tripleClickTimeout()) ); | 413 | SLOT(tripleClickTimeout()) ); |
414 | } | 414 | } |
415 | QLineEdit::mouseDoubleClickEvent( e ); | 415 | QLineEdit::mouseDoubleClickEvent( e ); |
416 | } | 416 | } |
417 | 417 | ||
418 | void OLineEdit::mousePressEvent( QMouseEvent* e ) | 418 | void OLineEdit::mousePressEvent( QMouseEvent* e ) |
419 | { | 419 | { |
420 | if ( possibleTripleClick && e->button() == Qt::LeftButton ) | 420 | if ( possibleTripleClick && e->button() == Qt::LeftButton ) |
421 | { | 421 | { |
422 | selectAll(); | 422 | selectAll(); |
423 | return; | 423 | return; |
424 | } | 424 | } |
425 | QLineEdit::mousePressEvent( e ); | 425 | QLineEdit::mousePressEvent( e ); |
426 | } | 426 | } |
427 | 427 | ||
428 | void OLineEdit::tripleClickTimeout() | 428 | void OLineEdit::tripleClickTimeout() |
429 | { | 429 | { |
430 | possibleTripleClick=false; | 430 | possibleTripleClick=false; |
431 | } | 431 | } |
432 | 432 | ||
433 | QPopupMenu *OLineEdit::createPopupMenu() | 433 | QPopupMenu *OLineEdit::createPopupMenu() |
434 | { | 434 | { |
435 | // Return if popup menu is not enabled !! | 435 | // Return if popup menu is not enabled !! |
436 | if ( !m_bEnableMenu ) | 436 | if ( !m_bEnableMenu ) |
437 | return 0; | 437 | return 0; |
438 | 438 | ||
439 | #if QT_VERSION > 290 | 439 | #if QT_VERSION >= 0x030000 |
440 | QPopupMenu *popup = QLineEdit::createPopupMenu(); | 440 | QPopupMenu *popup = QLineEdit::createPopupMenu(); |
441 | #else | 441 | #else |
442 | QPopupMenu *popup = new QPopupMenu(); | 442 | QPopupMenu *popup = new QPopupMenu(); |
443 | #warning OLineEdit is not fully functional on Qt2 | 443 | #warning OLineEdit is not fully functional on Qt2 |
444 | #endif | 444 | #endif |
445 | 445 | ||
446 | // completion object is present. | 446 | // completion object is present. |
447 | if ( compObj() ) | 447 | if ( compObj() ) |
448 | { | 448 | { |
449 | QPopupMenu *subMenu = new QPopupMenu( popup ); | 449 | QPopupMenu *subMenu = new QPopupMenu( popup ); |
450 | connect( subMenu, SIGNAL( activated(int) ), | 450 | connect( subMenu, SIGNAL( activated(int) ), |
451 | this, SLOT( completionMenuActivated(int) ) ); | 451 | this, SLOT( completionMenuActivated(int) ) ); |
452 | 452 | ||
453 | popup->insertSeparator(); | 453 | popup->insertSeparator(); |
454 | //popup->insertItem( SmallIconSet("completion"), i18n("Text Completion"), | 454 | //popup->insertItem( SmallIconSet("completion"), i18n("Text Completion"), |
455 | // subMenu ); | 455 | // subMenu ); |
456 | 456 | ||
457 | popup->insertItem( tr("Text Completion"), subMenu ); | 457 | popup->insertItem( tr("Text Completion"), subMenu ); |
458 | 458 | ||
459 | subMenu->insertItem( tr("None"), NoCompletion ); | 459 | subMenu->insertItem( tr("None"), NoCompletion ); |
460 | subMenu->insertItem( tr("Manual"), ShellCompletion ); | 460 | subMenu->insertItem( tr("Manual"), ShellCompletion ); |
461 | subMenu->insertItem( tr("Automatic"), AutoCompletion ); | 461 | subMenu->insertItem( tr("Automatic"), AutoCompletion ); |
462 | subMenu->insertItem( tr("Dropdown List"), PopupCompletion ); | 462 | subMenu->insertItem( tr("Dropdown List"), PopupCompletion ); |
463 | subMenu->insertItem( tr("Short Automatic"), SemiAutoCompletion ); | 463 | subMenu->insertItem( tr("Short Automatic"), SemiAutoCompletion ); |
464 | 464 | ||
465 | //subMenu->setAccel( KStdAccel::completion(), ShellCompletion ); | 465 | //subMenu->setAccel( KStdAccel::completion(), ShellCompletion ); |
466 | subMenu->setAccel( Key_Tab, ShellCompletion ); | 466 | subMenu->setAccel( Key_Tab, ShellCompletion ); |
467 | 467 | ||
468 | OGlobalSettings::Completion mode = completionMode(); | 468 | OGlobalSettings::Completion mode = completionMode(); |
469 | subMenu->setItemChecked( NoCompletion, | 469 | subMenu->setItemChecked( NoCompletion, |
470 | mode == OGlobalSettings::CompletionNone ); | 470 | mode == OGlobalSettings::CompletionNone ); |
471 | subMenu->setItemChecked( ShellCompletion, | 471 | subMenu->setItemChecked( ShellCompletion, |
472 | mode == OGlobalSettings::CompletionShell ); | 472 | mode == OGlobalSettings::CompletionShell ); |
473 | subMenu->setItemChecked( PopupCompletion, | 473 | subMenu->setItemChecked( PopupCompletion, |
474 | mode == OGlobalSettings::CompletionPopup ); | 474 | mode == OGlobalSettings::CompletionPopup ); |
475 | subMenu->setItemChecked( AutoCompletion, | 475 | subMenu->setItemChecked( AutoCompletion, |
476 | mode == OGlobalSettings::CompletionAuto ); | 476 | mode == OGlobalSettings::CompletionAuto ); |
477 | subMenu->setItemChecked( SemiAutoCompletion, | 477 | subMenu->setItemChecked( SemiAutoCompletion, |
478 | mode == OGlobalSettings::CompletionMan ); | 478 | mode == OGlobalSettings::CompletionMan ); |
479 | if ( mode != OGlobalSettings::completionMode() ) | 479 | if ( mode != OGlobalSettings::completionMode() ) |
480 | { | 480 | { |
481 | subMenu->insertSeparator(); | 481 | subMenu->insertSeparator(); |
482 | subMenu->insertItem( tr("Default"), Default ); | 482 | subMenu->insertItem( tr("Default"), Default ); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | // ### do we really need this? Yes, Please do not remove! This | 485 | // ### do we really need this? Yes, Please do not remove! This |
486 | // allows applications to extend the popup menu without having to | 486 | // allows applications to extend the popup menu without having to |
487 | // inherit from this class! (DA) | 487 | // inherit from this class! (DA) |
488 | emit aboutToShowContextMenu( popup ); | 488 | emit aboutToShowContextMenu( popup ); |
489 | 489 | ||
490 | return popup; | 490 | return popup; |
491 | } | 491 | } |
492 | 492 | ||
493 | void OLineEdit::completionMenuActivated( int id ) | 493 | void OLineEdit::completionMenuActivated( int id ) |
494 | { | 494 | { |
495 | OGlobalSettings::Completion oldMode = completionMode(); | 495 | OGlobalSettings::Completion oldMode = completionMode(); |
496 | 496 | ||
497 | switch ( id ) | 497 | switch ( id ) |
498 | { | 498 | { |
499 | case Default: | 499 | case Default: |
500 | setCompletionMode( OGlobalSettings::completionMode() ); break; | 500 | setCompletionMode( OGlobalSettings::completionMode() ); break; |
501 | case NoCompletion: | 501 | case NoCompletion: |
502 | setCompletionMode( OGlobalSettings::CompletionNone ); break; | 502 | setCompletionMode( OGlobalSettings::CompletionNone ); break; |
503 | case AutoCompletion: | 503 | case AutoCompletion: |
504 | setCompletionMode( OGlobalSettings::CompletionAuto ); break; | 504 | setCompletionMode( OGlobalSettings::CompletionAuto ); break; |
505 | case SemiAutoCompletion: | 505 | case SemiAutoCompletion: |
506 | setCompletionMode( OGlobalSettings::CompletionMan ); break; | 506 | setCompletionMode( OGlobalSettings::CompletionMan ); break; |
507 | case ShellCompletion: | 507 | case ShellCompletion: |
508 | setCompletionMode( OGlobalSettings::CompletionShell ); break; | 508 | setCompletionMode( OGlobalSettings::CompletionShell ); break; |
509 | case PopupCompletion: | 509 | case PopupCompletion: |
510 | setCompletionMode( OGlobalSettings::CompletionPopup ); break; | 510 | setCompletionMode( OGlobalSettings::CompletionPopup ); break; |
511 | default: return; | 511 | default: return; |
512 | } | 512 | } |
513 | 513 | ||
514 | if ( oldMode != completionMode() ) | 514 | if ( oldMode != completionMode() ) |
515 | { | 515 | { |
516 | if ( oldMode == OGlobalSettings::CompletionPopup && | 516 | if ( oldMode == OGlobalSettings::CompletionPopup && |
517 | d->completionBox && d->completionBox->isVisible() ) | 517 | d->completionBox && d->completionBox->isVisible() ) |
518 | d->completionBox->hide(); | 518 | d->completionBox->hide(); |
519 | emit completionModeChanged( completionMode() ); | 519 | emit completionModeChanged( completionMode() ); |
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | /*void OLineEdit::dropEvent(QDropEvent *e) | 523 | /*void OLineEdit::dropEvent(QDropEvent *e) |
524 | { | 524 | { |
525 | KURL::List urlList; | 525 | KURL::List urlList; |
526 | if( d->handleURLDrops && KURLDrag::decode( e, urlList ) ) | 526 | if( d->handleURLDrops && KURLDrag::decode( e, urlList ) ) |
527 | { | 527 | { |
528 | QString dropText = text(); | 528 | QString dropText = text(); |
529 | KURL::List::ConstIterator it; | 529 | KURL::List::ConstIterator it; |
530 | for( it = urlList.begin() ; it != urlList.end() ; ++it ) | 530 | for( it = urlList.begin() ; it != urlList.end() ; ++it ) |
531 | { | 531 | { |
532 | if(!dropText.isEmpty()) | 532 | if(!dropText.isEmpty()) |
533 | dropText+=' '; | 533 | dropText+=' '; |
534 | 534 | ||
535 | dropText += (*it).prettyURL(); | 535 | dropText += (*it).prettyURL(); |