author | mickeyl <mickeyl> | 2003-03-30 02:54:37 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-30 02:54:37 (UTC) |
commit | 15ee85466704072173296ff4f0f446cd8fe81d1e (patch) (unidiff) | |
tree | d497cb855ee8ee6533f2efd5b064cef4dc2bb16b | |
parent | 1d5a00fa8db662c4a5f6490d26d4e2ef1836f118 (diff) | |
download | opie-15ee85466704072173296ff4f0f446cd8fe81d1e.zip opie-15ee85466704072173296ff4f0f446cd8fe81d1e.tar.gz opie-15ee85466704072173296ff4f0f446cd8fe81d1e.tar.bz2 |
convert dynamic_cast<> to using QObject::inherits
-rw-r--r-- | libopie2/qt3/opieui/ocombobox.cpp | 5 | ||||
-rw-r--r-- | libopie2/qt3/opieui/oeditlistbox.cpp | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/libopie2/qt3/opieui/ocombobox.cpp b/libopie2/qt3/opieui/ocombobox.cpp index a1dd5f5..8dbda8f 100644 --- a/libopie2/qt3/opieui/ocombobox.cpp +++ b/libopie2/qt3/opieui/ocombobox.cpp | |||
@@ -227,193 +227,196 @@ bool OComboBox::eventFilter( QObject* o, QEvent* ev ) | |||
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 > 290 |
322 | QComboBox::setLineEdit( edit ); | 322 | QComboBox::setLineEdit( edit ); |
323 | d->olineEdit = dynamic_cast<OLineEdit*>( edit ); | 323 | if ( !edit->inherits( "OLineEdit" ) ) |
324 | d->olineEdit = 0; | ||
325 | else | ||
326 | d->olineEdit = static_cast<OLineEdit*>( edit ); | ||
324 | setDelegate( d->olineEdit ); | 327 | setDelegate( d->olineEdit ); |
325 | 328 | ||
326 | // forward some signals. We only emit returnPressed() ourselves. | 329 | // forward some signals. We only emit returnPressed() ourselves. |
327 | if ( d->olineEdit ) { | 330 | if ( d->olineEdit ) { |
328 | connect( d->olineEdit, SIGNAL( completion( const QString& )), | 331 | connect( d->olineEdit, SIGNAL( completion( const QString& )), |
329 | SIGNAL( completion( const QString& )) ); | 332 | SIGNAL( completion( const QString& )) ); |
330 | connect( d->olineEdit, SIGNAL( substringCompletion( const QString& )), | 333 | connect( d->olineEdit, SIGNAL( substringCompletion( const QString& )), |
331 | SIGNAL( substringCompletion( const QString& )) ); | 334 | SIGNAL( substringCompletion( const QString& )) ); |
332 | connect( d->olineEdit, | 335 | connect( d->olineEdit, |
333 | SIGNAL( textRotation( OCompletionBase::KeyBindingType )), | 336 | SIGNAL( textRotation( OCompletionBase::KeyBindingType )), |
334 | SIGNAL( textRotation( OCompletionBase::KeyBindingType )) ); | 337 | SIGNAL( textRotation( OCompletionBase::KeyBindingType )) ); |
335 | connect( d->olineEdit, | 338 | connect( d->olineEdit, |
336 | SIGNAL( completionModeChanged( OGlobalSettings::Completion )), | 339 | SIGNAL( completionModeChanged( OGlobalSettings::Completion )), |
337 | SIGNAL( completionModeChanged( OGlobalSettings::Completion))); | 340 | SIGNAL( completionModeChanged( OGlobalSettings::Completion))); |
338 | 341 | ||
339 | connect( d->olineEdit, | 342 | connect( d->olineEdit, |
340 | SIGNAL( aboutToShowContextMenu( QPopupMenu * )), | 343 | SIGNAL( aboutToShowContextMenu( QPopupMenu * )), |
341 | SIGNAL( aboutToShowContextMenu( QPopupMenu * )) ); | 344 | SIGNAL( aboutToShowContextMenu( QPopupMenu * )) ); |
342 | } | 345 | } |
343 | #else | 346 | #else |
344 | #warning OComboBox is not fully functional with Qt2 | 347 | #warning OComboBox is not fully functional with Qt2 |
345 | #endif | 348 | #endif |
346 | } | 349 | } |
347 | 350 | ||
348 | // Temporary functions until QT3 appears. - Seth Chaiklin 20 may 2001 | 351 | // Temporary functions until QT3 appears. - Seth Chaiklin 20 may 2001 |
349 | void OComboBox::deleteWordForward() | 352 | void OComboBox::deleteWordForward() |
350 | { | 353 | { |
351 | lineEdit()->cursorWordForward(TRUE); | 354 | lineEdit()->cursorWordForward(TRUE); |
352 | #if QT_VERSION > 290 | 355 | #if QT_VERSION > 290 |
353 | if ( lineEdit()->hasSelectedText() ) | 356 | if ( lineEdit()->hasSelectedText() ) |
354 | #else | 357 | #else |
355 | if ( lineEdit()->hasMarkedText() ) | 358 | if ( lineEdit()->hasMarkedText() ) |
356 | #endif | 359 | #endif |
357 | { | 360 | { |
358 | lineEdit()->del(); | 361 | lineEdit()->del(); |
359 | } | 362 | } |
360 | } | 363 | } |
361 | 364 | ||
362 | void OComboBox::deleteWordBack() | 365 | void OComboBox::deleteWordBack() |
363 | { | 366 | { |
364 | lineEdit()->cursorWordBackward(TRUE); | 367 | lineEdit()->cursorWordBackward(TRUE); |
365 | #if QT_VERSION > 290 | 368 | #if QT_VERSION > 290 |
366 | if ( lineEdit()->hasSelectedText() ) | 369 | if ( lineEdit()->hasSelectedText() ) |
367 | #else | 370 | #else |
368 | if ( lineEdit()->hasMarkedText() ) | 371 | if ( lineEdit()->hasMarkedText() ) |
369 | #endif | 372 | #endif |
370 | { | 373 | { |
371 | lineEdit()->del(); | 374 | lineEdit()->del(); |
372 | } | 375 | } |
373 | } | 376 | } |
374 | 377 | ||
375 | void OComboBox::setCurrentItem( const QString& item, bool insert, int index ) | 378 | void OComboBox::setCurrentItem( const QString& item, bool insert, int index ) |
376 | { | 379 | { |
377 | int sel = -1; | 380 | int sel = -1; |
378 | for (int i = 0; i < count(); ++i) | 381 | for (int i = 0; i < count(); ++i) |
379 | if (text(i) == item) | 382 | if (text(i) == item) |
380 | { | 383 | { |
381 | sel = i; | 384 | sel = i; |
382 | break; | 385 | break; |
383 | } | 386 | } |
384 | if (sel == -1 && insert) | 387 | if (sel == -1 && insert) |
385 | { | 388 | { |
386 | insertItem(item, index); | 389 | insertItem(item, index); |
387 | if (index >= 0) | 390 | if (index >= 0) |
388 | sel = index; | 391 | sel = index; |
389 | else | 392 | else |
390 | sel = count() - 1; | 393 | sel = count() - 1; |
391 | } | 394 | } |
392 | setCurrentItem(sel); | 395 | setCurrentItem(sel); |
393 | } | 396 | } |
394 | 397 | ||
395 | void OComboBox::setCurrentItem(int index) | 398 | void OComboBox::setCurrentItem(int index) |
396 | { | 399 | { |
397 | QComboBox::setCurrentItem(index); | 400 | QComboBox::setCurrentItem(index); |
398 | } | 401 | } |
399 | 402 | ||
400 | 403 | ||
401 | /*====================================================================================== | 404 | /*====================================================================================== |
402 | * OHistoryCombo | 405 | * OHistoryCombo |
403 | *======================================================================================*/ | 406 | *======================================================================================*/ |
404 | 407 | ||
405 | // we are always read-write | 408 | // we are always read-write |
406 | OHistoryCombo::OHistoryCombo( QWidget *parent, const char *name ) | 409 | OHistoryCombo::OHistoryCombo( QWidget *parent, const char *name ) |
407 | : OComboBox( true, parent, name ) | 410 | : OComboBox( true, parent, name ) |
408 | { | 411 | { |
409 | init( true ); // using completion | 412 | init( true ); // using completion |
410 | } | 413 | } |
411 | 414 | ||
412 | // we are always read-write | 415 | // we are always read-write |
413 | OHistoryCombo::OHistoryCombo( bool useCompletion, | 416 | OHistoryCombo::OHistoryCombo( bool useCompletion, |
414 | QWidget *parent, const char *name ) | 417 | QWidget *parent, const char *name ) |
415 | : OComboBox( true, parent, name ) | 418 | : OComboBox( true, parent, name ) |
416 | { | 419 | { |
417 | init( useCompletion ); | 420 | init( useCompletion ); |
418 | } | 421 | } |
419 | 422 | ||
diff --git a/libopie2/qt3/opieui/oeditlistbox.cpp b/libopie2/qt3/opieui/oeditlistbox.cpp index 3c53552..0e95274 100644 --- a/libopie2/qt3/opieui/oeditlistbox.cpp +++ b/libopie2/qt3/opieui/oeditlistbox.cpp | |||
@@ -318,99 +318,100 @@ void OEditListBox::removeItem() | |||
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 | ||
400 | return list; | 400 | return list; |
401 | } | 401 | } |
402 | 402 | ||
403 | void OEditListBox::virtual_hook( int, void* ) | 403 | void OEditListBox::virtual_hook( int, void* ) |
404 | { /*BASE::virtual_hook( id, data );*/ } | 404 | { /*BASE::virtual_hook( id, data );*/ } |
405 | 405 | ||
406 | 406 | ||
407 | /*====================================================================================== | 407 | /*====================================================================================== |
408 | * CustomEditor | 408 | * CustomEditor |
409 | *======================================================================================*/ | 409 | *======================================================================================*/ |
410 | 410 | ||
411 | OEditListBox::CustomEditor::CustomEditor( OComboBox *combo ) | 411 | OEditListBox::CustomEditor::CustomEditor( OComboBox *combo ) |
412 | { | 412 | { |
413 | m_representationWidget = combo; | 413 | m_representationWidget = combo; |
414 | m_lineEdit = dynamic_cast<OLineEdit*>( combo->lineEdit() ); | 414 | assert( combo->lineEdit()->inherits( "OLineEdit" ) ); |
415 | assert( m_lineEdit ); | 415 | m_lineEdit = static_cast<OLineEdit*>( combo->lineEdit() ); |
416 | |||
416 | } | 417 | } |