author | zautrix <zautrix> | 2005-06-30 04:58:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-30 04:58:35 (UTC) |
commit | ba4a6a95356f9a8044257c45347cee8b15667d0c (patch) (unidiff) | |
tree | 63ffa2000426f06cae7ec5be7d1847b5f9fb4e26 | |
parent | 63147898391dbeabca2dc8f48730b324c15a7498 (diff) | |
download | kdepimpi-ba4a6a95356f9a8044257c45347cee8b15667d0c.zip kdepimpi-ba4a6a95356f9a8044257c45347cee8b15667d0c.tar.gz kdepimpi-ba4a6a95356f9a8044257c45347cee8b15667d0c.tar.bz2 |
fixxx
-rw-r--r-- | microkde/kdeui/klistview.cpp | 9 | ||||
-rw-r--r-- | microkde/kdeui/klistview.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp index 25327aa..f7d2187 100644 --- a/microkde/kdeui/klistview.cpp +++ b/microkde/kdeui/klistview.cpp | |||
@@ -351,257 +351,266 @@ void KListViewLineEdit::keyPressEvent(QKeyEvent *e) | |||
351 | KLineEdit::keyPressEvent(e); | 351 | KLineEdit::keyPressEvent(e); |
352 | } | 352 | } |
353 | else | 353 | else |
354 | KLineEdit::keyPressEvent(e); | 354 | KLineEdit::keyPressEvent(e); |
355 | } | 355 | } |
356 | 356 | ||
357 | void KListViewLineEdit::terminate() | 357 | void KListViewLineEdit::terminate() |
358 | { | 358 | { |
359 | terminate(true); | 359 | terminate(true); |
360 | } | 360 | } |
361 | 361 | ||
362 | void KListViewLineEdit::terminate(bool commit) | 362 | void KListViewLineEdit::terminate(bool commit) |
363 | { | 363 | { |
364 | if ( item ) | 364 | if ( item ) |
365 | { | 365 | { |
366 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; | 366 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; |
367 | if (commit) | 367 | if (commit) |
368 | item->setText(col, text()); | 368 | item->setText(col, text()); |
369 | int c=col; | 369 | int c=col; |
370 | QListViewItem *i=item; | 370 | QListViewItem *i=item; |
371 | col=0; | 371 | col=0; |
372 | item=0; | 372 | item=0; |
373 | hide(); // will call focusOutEvent, that's why we set item=0 before | 373 | hide(); // will call focusOutEvent, that's why we set item=0 before |
374 | emit done(i,c); | 374 | emit done(i,c); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) | 378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) |
379 | { | 379 | { |
380 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); | 380 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); |
381 | // Don't let a RMB close the editor | 381 | // Don't let a RMB close the editor |
382 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) | 382 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) |
383 | terminate(true); | 383 | terminate(true); |
384 | } | 384 | } |
385 | 385 | ||
386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) | 386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) |
387 | { | 387 | { |
388 | KLineEdit::paintEvent( e ); | 388 | KLineEdit::paintEvent( e ); |
389 | 389 | ||
390 | if ( !frame() ) { | 390 | if ( !frame() ) { |
391 | QPainter p( this ); | 391 | QPainter p( this ); |
392 | p.setClipRegion( e->region() ); | 392 | p.setClipRegion( e->region() ); |
393 | p.drawRect( rect() ); | 393 | p.drawRect( rect() ); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | 396 | ||
397 | // selection changed -> terminate. As our "item" can be already deleted, | 397 | // selection changed -> terminate. As our "item" can be already deleted, |
398 | // we can't call terminate(false), because that would emit done() with | 398 | // we can't call terminate(false), because that would emit done() with |
399 | // a dangling pointer to "item". | 399 | // a dangling pointer to "item". |
400 | void KListViewLineEdit::slotSelectionChanged() | 400 | void KListViewLineEdit::slotSelectionChanged() |
401 | { | 401 | { |
402 | item = 0; | 402 | item = 0; |
403 | col = 0; | 403 | col = 0; |
404 | hide(); | 404 | hide(); |
405 | } | 405 | } |
406 | */ | 406 | */ |
407 | 407 | ||
408 | KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) | 408 | KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) |
409 | : QListView( parent, name ), | 409 | : QListView( parent, name ), |
410 | d (new KListViewPrivate (this)) | 410 | d (new KListViewPrivate (this)) |
411 | { | 411 | { |
412 | #ifndef DESKTOP_VERSION | 412 | #ifndef DESKTOP_VERSION |
413 | if ( emulateRightMouse ) | 413 | if ( emulateRightMouse ) |
414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
415 | #endif | 415 | #endif |
416 | //US setDragAutoScroll(true); | 416 | //US setDragAutoScroll(true); |
417 | 417 | ||
418 | connect( this, SIGNAL( onViewport() ), | 418 | connect( this, SIGNAL( onViewport() ), |
419 | this, SLOT( slotOnViewport() ) ); | 419 | this, SLOT( slotOnViewport() ) ); |
420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), | 420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), |
421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); | 421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); |
422 | 422 | ||
423 | connect (this, SIGNAL(contentsMoving(int,int)), | 423 | connect (this, SIGNAL(contentsMoving(int,int)), |
424 | this, SLOT(cleanDropVisualizer())); | 424 | this, SLOT(cleanDropVisualizer())); |
425 | connect (this, SIGNAL(contentsMoving(int,int)), | 425 | connect (this, SIGNAL(contentsMoving(int,int)), |
426 | this, SLOT(cleanItemHighlighter())); | 426 | this, SLOT(cleanItemHighlighter())); |
427 | 427 | ||
428 | /*US | 428 | /*US |
429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); | 429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); |
430 | 430 | ||
431 | if (kapp) | 431 | if (kapp) |
432 | { | 432 | { |
433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); | 433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); |
434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); | 434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); |
435 | } | 435 | } |
436 | */ | 436 | */ |
437 | slotSettingsChanged(1); //US do this to initialize the connections | 437 | slotSettingsChanged(1); //US do this to initialize the connections |
438 | 438 | ||
439 | 439 | ||
440 | connect(&d->autoSelect, SIGNAL( timeout() ), | 440 | connect(&d->autoSelect, SIGNAL( timeout() ), |
441 | this, SLOT( slotAutoSelect() ) ); | 441 | this, SLOT( slotAutoSelect() ) ); |
442 | connect(&d->dragExpand, SIGNAL( timeout() ), | 442 | connect(&d->dragExpand, SIGNAL( timeout() ), |
443 | this, SLOT( slotDragExpand() ) ); | 443 | this, SLOT( slotDragExpand() ) ); |
444 | 444 | ||
445 | // context menu handling | 445 | // context menu handling |
446 | if (d->showContextMenusOnPress) | 446 | if (d->showContextMenusOnPress) |
447 | { | 447 | { |
448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
450 | } | 450 | } |
451 | else | 451 | else |
452 | { | 452 | { |
453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
455 | } | 455 | } |
456 | 456 | ||
457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), | 457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), |
458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); | 458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); |
459 | 459 | ||
460 | 460 | ||
461 | //qDebug("KListView::KListView make alternate color configurable"); | 461 | //qDebug("KListView::KListView make alternate color configurable"); |
462 | d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); | 462 | d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | 466 | ||
467 | KListView::~KListView() | 467 | KListView::~KListView() |
468 | { | 468 | { |
469 | delete d; | 469 | delete d; |
470 | } | 470 | } |
471 | 471 | ||
472 | bool KListView::isExecuteArea( const QPoint& point ) | 472 | bool KListView::isExecuteArea( const QPoint& point ) |
473 | { | 473 | { |
474 | if ( itemAt( point ) ) | 474 | if ( itemAt( point ) ) |
475 | return isExecuteArea( point.x() ); | 475 | return isExecuteArea( point.x() ); |
476 | 476 | ||
477 | return false; | 477 | return false; |
478 | } | 478 | } |
479 | QSize KListView::sizeHint() const | ||
480 | { | ||
481 | //qDebug("KListView::QSize sizeHint() "); | ||
482 | #ifdef DESKTOP_VERSION | ||
483 | QListView::sizeHint(); | ||
484 | #else | ||
485 | return QSize ( 40, 40 ); | ||
486 | #endif | ||
479 | 487 | ||
488 | } | ||
480 | bool KListView::isExecuteArea( int x ) | 489 | bool KListView::isExecuteArea( int x ) |
481 | { | 490 | { |
482 | if( allColumnsShowFocus() ) | 491 | if( allColumnsShowFocus() ) |
483 | return true; | 492 | return true; |
484 | else { | 493 | else { |
485 | int offset = 0; | 494 | int offset = 0; |
486 | int width = columnWidth( 0 ); | 495 | int width = columnWidth( 0 ); |
487 | int pos = header()->mapToIndex( 0 ); | 496 | int pos = header()->mapToIndex( 0 ); |
488 | 497 | ||
489 | for ( int index = 0; index < pos; index++ ) | 498 | for ( int index = 0; index < pos; index++ ) |
490 | offset += columnWidth( header()->mapToSection( index ) ); | 499 | offset += columnWidth( header()->mapToSection( index ) ); |
491 | 500 | ||
492 | x += contentsX(); // in case of a horizontal scrollbar | 501 | x += contentsX(); // in case of a horizontal scrollbar |
493 | return ( x > offset && x < ( offset + width ) ); | 502 | return ( x > offset && x < ( offset + width ) ); |
494 | } | 503 | } |
495 | } | 504 | } |
496 | 505 | ||
497 | void KListView::slotOnItem( QListViewItem *item ) | 506 | void KListView::slotOnItem( QListViewItem *item ) |
498 | { | 507 | { |
499 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); | 508 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); |
500 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { | 509 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { |
501 | d->autoSelect.start( d->autoSelectDelay, true ); | 510 | d->autoSelect.start( d->autoSelectDelay, true ); |
502 | d->pCurrentItem = item; | 511 | d->pCurrentItem = item; |
503 | } | 512 | } |
504 | } | 513 | } |
505 | 514 | ||
506 | void KListView::slotOnViewport() | 515 | void KListView::slotOnViewport() |
507 | { | 516 | { |
508 | if ( d->bChangeCursorOverItem ) | 517 | if ( d->bChangeCursorOverItem ) |
509 | viewport()->unsetCursor(); | 518 | viewport()->unsetCursor(); |
510 | 519 | ||
511 | d->autoSelect.stop(); | 520 | d->autoSelect.stop(); |
512 | d->pCurrentItem = 0L; | 521 | d->pCurrentItem = 0L; |
513 | } | 522 | } |
514 | 523 | ||
515 | void KListView::slotSettingsChanged(int category) | 524 | void KListView::slotSettingsChanged(int category) |
516 | { | 525 | { |
517 | //qDebug("KListView::slotSettingsChanged has to be verified"); | 526 | //qDebug("KListView::slotSettingsChanged has to be verified"); |
518 | 527 | ||
519 | 528 | ||
520 | switch (category) | 529 | switch (category) |
521 | { | 530 | { |
522 | //US I create my private category (=1) to set the settings | 531 | //US I create my private category (=1) to set the settings |
523 | case 1: | 532 | case 1: |
524 | d->dragDelay = 2; | 533 | d->dragDelay = 2; |
525 | //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); | 534 | //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); |
526 | // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); | 535 | // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); |
527 | 536 | ||
528 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 537 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
529 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 538 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
530 | 539 | ||
531 | if( d->bUseSingle ) | 540 | if( d->bUseSingle ) |
532 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 541 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
533 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 542 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
534 | 543 | ||
535 | //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 544 | //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
536 | //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 545 | //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
537 | 546 | ||
538 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 547 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
539 | viewport()->unsetCursor(); | 548 | viewport()->unsetCursor(); |
540 | 549 | ||
541 | break; | 550 | break; |
542 | 551 | ||
543 | /*US | 552 | /*US |
544 | case KApplication::SETTINGS_MOUSE: | 553 | case KApplication::SETTINGS_MOUSE: |
545 | d->dragDelay = KGlobalSettings::dndEventDelay(); | 554 | d->dragDelay = KGlobalSettings::dndEventDelay(); |
546 | d->bUseSingle = KGlobalSettings::singleClick(); | 555 | d->bUseSingle = KGlobalSettings::singleClick(); |
547 | 556 | ||
548 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 557 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
549 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 558 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
550 | 559 | ||
551 | if( d->bUseSingle ) | 560 | if( d->bUseSingle ) |
552 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 561 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
553 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 562 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
554 | 563 | ||
555 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 564 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
556 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 565 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
557 | 566 | ||
558 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 567 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
559 | viewport()->unsetCursor(); | 568 | viewport()->unsetCursor(); |
560 | 569 | ||
561 | break; | 570 | break; |
562 | case KApplication::SETTINGS_POPUPMENU: | 571 | case KApplication::SETTINGS_POPUPMENU: |
563 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); | 572 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); |
564 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); | 573 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); |
565 | 574 | ||
566 | if (d->showContextMenusOnPress) | 575 | if (d->showContextMenusOnPress) |
567 | { | 576 | { |
568 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 577 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
569 | 578 | ||
570 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 579 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
571 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 580 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
572 | } | 581 | } |
573 | else | 582 | else |
574 | { | 583 | { |
575 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 584 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
576 | 585 | ||
577 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 586 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
578 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 587 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
579 | } | 588 | } |
580 | break; | 589 | break; |
581 | */ | 590 | */ |
582 | 591 | ||
583 | default: | 592 | default: |
584 | break; | 593 | break; |
585 | } | 594 | } |
586 | 595 | ||
587 | } | 596 | } |
588 | 597 | ||
589 | void KListView::slotAutoSelect() | 598 | void KListView::slotAutoSelect() |
590 | { | 599 | { |
591 | // check that the item still exists | 600 | // check that the item still exists |
592 | if( itemIndex( d->pCurrentItem ) == -1 ) | 601 | if( itemIndex( d->pCurrentItem ) == -1 ) |
593 | return; | 602 | return; |
594 | 603 | ||
595 | if (!isActiveWindow()) | 604 | if (!isActiveWindow()) |
596 | { | 605 | { |
597 | d->autoSelect.stop(); | 606 | d->autoSelect.stop(); |
598 | return; | 607 | return; |
599 | } | 608 | } |
600 | 609 | ||
601 | //Give this widget the keyboard focus. | 610 | //Give this widget the keyboard focus. |
602 | if( !hasFocus() ) | 611 | if( !hasFocus() ) |
603 | setFocus(); | 612 | setFocus(); |
604 | 613 | ||
605 | QListViewItem* previousItem = currentItem(); | 614 | QListViewItem* previousItem = currentItem(); |
606 | setCurrentItem( d->pCurrentItem ); | 615 | setCurrentItem( d->pCurrentItem ); |
607 | 616 | ||
diff --git a/microkde/kdeui/klistview.h b/microkde/kdeui/klistview.h index 0058416..9f0d9fd 100644 --- a/microkde/kdeui/klistview.h +++ b/microkde/kdeui/klistview.h | |||
@@ -5,256 +5,257 @@ | |||
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License version 2 as published by the Free Software Foundation. | 8 | License version 2 as published by the Free Software Foundation. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef KLISTVIEW_H | 20 | #ifndef KLISTVIEW_H |
21 | #define KLISTVIEW_H | 21 | #define KLISTVIEW_H |
22 | 22 | ||
23 | #include <qlistview.h> | 23 | #include <qlistview.h> |
24 | 24 | ||
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | //US | 27 | //US |
28 | class QDropEvent; | 28 | class QDropEvent; |
29 | class QDragLeaveEvent; | 29 | class QDragLeaveEvent; |
30 | class QDragMoveEvent; | 30 | class QDragMoveEvent; |
31 | class QDragEnterEvent; | 31 | class QDragEnterEvent; |
32 | 32 | ||
33 | class QDragObject; | 33 | class QDragObject; |
34 | class KConfig; | 34 | class KConfig; |
35 | class KLineEdit; | 35 | class KLineEdit; |
36 | /** | 36 | /** |
37 | * This Widget extends the functionality of QListView to honor the system | 37 | * This Widget extends the functionality of QListView to honor the system |
38 | * wide settings for Single Click/Double Click mode, AutoSelection and | 38 | * wide settings for Single Click/Double Click mode, AutoSelection and |
39 | * ChangeCursorOverLink (TM). | 39 | * ChangeCursorOverLink (TM). |
40 | * | 40 | * |
41 | * There is a new signal executed(). It gets connected to either | 41 | * There is a new signal executed(). It gets connected to either |
42 | * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE | 42 | * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE |
43 | * wide Single Click/Double Click settings. It is strongly recommended that | 43 | * wide Single Click/Double Click settings. It is strongly recommended that |
44 | * you use this signal instead of the above mentioned. This way you dont | 44 | * you use this signal instead of the above mentioned. This way you dont |
45 | * need to care about the current settings. | 45 | * need to care about the current settings. |
46 | * If you want to get informed when the user selects something connect to the | 46 | * If you want to get informed when the user selects something connect to the |
47 | * QListView::selectionChanged() signal. | 47 | * QListView::selectionChanged() signal. |
48 | * | 48 | * |
49 | * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true) | 49 | * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true) |
50 | * and connect it to a suitable slot. | 50 | * and connect it to a suitable slot. |
51 | * To see where you are dropping, @ref setDropVisualizer(true). | 51 | * To see where you are dropping, @ref setDropVisualizer(true). |
52 | * And also you'll need @ref acceptDrag(QDropEvent*) | 52 | * And also you'll need @ref acceptDrag(QDropEvent*) |
53 | * | 53 | * |
54 | * KListView is drag-enabled, too: to benefit from that you've got derive from it. | 54 | * KListView is drag-enabled, too: to benefit from that you've got derive from it. |
55 | * Reimplement @ref dragObject() and (possibly) @ref startDrag(), | 55 | * Reimplement @ref dragObject() and (possibly) @ref startDrag(), |
56 | * and @ref setDragEnabled(true). | 56 | * and @ref setDragEnabled(true). |
57 | * | 57 | * |
58 | * @version $Id$ | 58 | * @version $Id$ |
59 | */ | 59 | */ |
60 | class KListView : public QListView | 60 | class KListView : public QListView |
61 | { | 61 | { |
62 | Q_OBJECT | 62 | Q_OBJECT |
63 | Q_ENUMS( SelectionModeExt ) | 63 | Q_ENUMS( SelectionModeExt ) |
64 | Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) | 64 | Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) |
65 | Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) | 65 | Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) |
66 | Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) | 66 | Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) |
67 | Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) | 67 | Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) |
68 | Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) | 68 | Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) |
69 | Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) | 69 | Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) |
70 | //US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) | 70 | //US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) |
71 | Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) | 71 | Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) |
72 | Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) | 72 | Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) |
73 | 73 | ||
74 | Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) | 74 | Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) |
75 | 75 | ||
76 | public: | 76 | public: |
77 | /** | 77 | /** |
78 | * Possible selection modes. | 78 | * Possible selection modes. |
79 | * | 79 | * |
80 | * The first four correspond directly to QListView::SelectionMode, while | 80 | * The first four correspond directly to QListView::SelectionMode, while |
81 | * the FileManager selection mode is defined as follows: | 81 | * the FileManager selection mode is defined as follows: |
82 | * @li home: move to the first | 82 | * @li home: move to the first |
83 | * @li end: move to the last | 83 | * @li end: move to the last |
84 | * @li PgUp/PgDn: move one page up/down | 84 | * @li PgUp/PgDn: move one page up/down |
85 | * @li up/down: move one item up/down | 85 | * @li up/down: move one item up/down |
86 | * @li insert: toggle selection of current and move to the next | 86 | * @li insert: toggle selection of current and move to the next |
87 | * @li space: toggle selection of the current | 87 | * @li space: toggle selection of the current |
88 | * @li CTRL+up: move to the previous item and toggle selection of this one | 88 | * @li CTRL+up: move to the previous item and toggle selection of this one |
89 | * @li CTRL+down: toggle selection of the current item and move to the next | 89 | * @li CTRL+down: toggle selection of the current item and move to the next |
90 | * @li CTRL+end: toggle selection from (including) the current | 90 | * @li CTRL+end: toggle selection from (including) the current |
91 | * item to (including) the last item | 91 | * item to (including) the last item |
92 | * @li CTRL+home: toggle selection from (including) the current | 92 | * @li CTRL+home: toggle selection from (including) the current |
93 | * item to the (including) the first item | 93 | * item to the (including) the first item |
94 | * @li CTRL+PgDn: toggle selection from (including) the current | 94 | * @li CTRL+PgDn: toggle selection from (including) the current |
95 | * item to (excluding) the item one page down | 95 | * item to (excluding) the item one page down |
96 | * @li CTRL+PgUp: toggle selection from (excluding) the current | 96 | * @li CTRL+PgUp: toggle selection from (excluding) the current |
97 | * item to (including) the item one page up | 97 | * item to (including) the item one page up |
98 | * | 98 | * |
99 | * The combinations work the same with SHIFT instead of CTRL, except | 99 | * The combinations work the same with SHIFT instead of CTRL, except |
100 | * that if you start selecting something using SHIFT everything selected | 100 | * that if you start selecting something using SHIFT everything selected |
101 | * before will be deselected first. | 101 | * before will be deselected first. |
102 | * | 102 | * |
103 | * Additionally the current item is always selected automatically when | 103 | * Additionally the current item is always selected automatically when |
104 | * navigating using the keyboard, except other items were selected explicitely. | 104 | * navigating using the keyboard, except other items were selected explicitely. |
105 | * | 105 | * |
106 | * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected | 106 | * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected |
107 | */ | 107 | */ |
108 | enum SelectionModeExt { | 108 | enum SelectionModeExt { |
109 | Single = QListView::Single, | 109 | Single = QListView::Single, |
110 | Multi = QListView::Multi, | 110 | Multi = QListView::Multi, |
111 | Extended = QListView::Extended, | 111 | Extended = QListView::Extended, |
112 | NoSelection = QListView::NoSelection, | 112 | NoSelection = QListView::NoSelection, |
113 | FileManager | 113 | FileManager |
114 | }; | 114 | }; |
115 | void repaintContents( bool erase = true ) | 115 | void repaintContents( bool erase = true ) |
116 | { | 116 | { |
117 | QScrollView::repaintContents( contentsX(), contentsY(), | 117 | QScrollView::repaintContents( contentsX(), contentsY(), |
118 | visibleWidth(), visibleHeight(), erase ); | 118 | visibleWidth(), visibleHeight(), erase ); |
119 | }; | 119 | }; |
120 | /** | 120 | /** |
121 | * Constructor. | 121 | * Constructor. |
122 | * | 122 | * |
123 | * The parameters @p parent and @p name are handled by | 123 | * The parameters @p parent and @p name are handled by |
124 | * @ref QListView, as usual. | 124 | * @ref QListView, as usual. |
125 | */ | 125 | */ |
126 | KListView (QWidget *parent = 0, const char *name = 0, bool emulateRightMouse = true ); | 126 | KListView (QWidget *parent = 0, const char *name = 0, bool emulateRightMouse = true ); |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Destructor. | 129 | * Destructor. |
130 | */ | 130 | */ |
131 | virtual ~KListView(); | 131 | virtual ~KListView(); |
132 | 132 | ||
133 | virtual QSize sizeHint() const; | ||
133 | /** | 134 | /** |
134 | * Reimplemented for internal reasons. | 135 | * Reimplemented for internal reasons. |
135 | * Further reimplementations should call this function or else | 136 | * Further reimplementations should call this function or else |
136 | * some features may not work correctly. | 137 | * some features may not work correctly. |
137 | * | 138 | * |
138 | * The API is unaffected. | 139 | * The API is unaffected. |
139 | */ | 140 | */ |
140 | virtual void setAcceptDrops (bool); | 141 | virtual void setAcceptDrops (bool); |
141 | 142 | ||
142 | /** | 143 | /** |
143 | * This function determines whether the given coordinates are within the | 144 | * This function determines whether the given coordinates are within the |
144 | * execute area. The execute area is the part of a @ref QListViewItem where mouse | 145 | * execute area. The execute area is the part of a @ref QListViewItem where mouse |
145 | * clicks or double clicks respectively generate a @ref #executed() signal. | 146 | * clicks or double clicks respectively generate a @ref #executed() signal. |
146 | * Depending on @ref QListView::allColumnsShowFocus() this is either the | 147 | * Depending on @ref QListView::allColumnsShowFocus() this is either the |
147 | * whole item or only the first column. | 148 | * whole item or only the first column. |
148 | * @return true if point is inside execute area of an item, false in all | 149 | * @return true if point is inside execute area of an item, false in all |
149 | * other cases including the case that it is over the viewport. | 150 | * other cases including the case that it is over the viewport. |
150 | */ | 151 | */ |
151 | virtual bool isExecuteArea( const QPoint& point ); | 152 | virtual bool isExecuteArea( const QPoint& point ); |
152 | 153 | ||
153 | /** | 154 | /** |
154 | * Same thing, but from an x coordinate only. This only checks if x is in | 155 | * Same thing, but from an x coordinate only. This only checks if x is in |
155 | * the first column (if all columns don't show focus), without testing if | 156 | * the first column (if all columns don't show focus), without testing if |
156 | * the y coordinate is over an item or not. | 157 | * the y coordinate is over an item or not. |
157 | */ | 158 | */ |
158 | bool isExecuteArea( int x ); | 159 | bool isExecuteArea( int x ); |
159 | 160 | ||
160 | /** | 161 | /** |
161 | * @return a list containing the currently selected items. | 162 | * @return a list containing the currently selected items. |
162 | */ | 163 | */ |
163 | QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) | 164 | QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) |
164 | 165 | ||
165 | /** | 166 | /** |
166 | * Arbitrarily move @p item to @p parent, positioned immediately after item @p after. | 167 | * Arbitrarily move @p item to @p parent, positioned immediately after item @p after. |
167 | */ | 168 | */ |
168 | void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after); | 169 | void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after); |
169 | 170 | ||
170 | /** | 171 | /** |
171 | * @return the last item (not child!) of this listview. | 172 | * @return the last item (not child!) of this listview. |
172 | * | 173 | * |
173 | * @see lastChild() | 174 | * @see lastChild() |
174 | */ | 175 | */ |
175 | QListViewItem *lastItem() const; | 176 | QListViewItem *lastItem() const; |
176 | 177 | ||
177 | /** | 178 | /** |
178 | * @return the last child of this listview. | 179 | * @return the last child of this listview. |
179 | * | 180 | * |
180 | * @see lastItem() | 181 | * @see lastItem() |
181 | */ | 182 | */ |
182 | QListViewItem* lastChild () const; | 183 | QListViewItem* lastChild () const; |
183 | 184 | ||
184 | /** | 185 | /** |
185 | * @return the lineedit used for inline renaming. | 186 | * @return the lineedit used for inline renaming. |
186 | * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit | 187 | * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit |
187 | * | 188 | * |
188 | * @since 3.2 | 189 | * @since 3.2 |
189 | */ | 190 | */ |
190 | KLineEdit* renameLineEdit() const; | 191 | KLineEdit* renameLineEdit() const; |
191 | 192 | ||
192 | /** | 193 | /** |
193 | * @returns if it is legal to move items in the list view. True by default. | 194 | * @returns if it is legal to move items in the list view. True by default. |
194 | * | 195 | * |
195 | * @see #setDragEnabled() | 196 | * @see #setDragEnabled() |
196 | * @see #setItemsMovable() | 197 | * @see #setItemsMovable() |
197 | */ | 198 | */ |
198 | bool itemsMovable() const; | 199 | bool itemsMovable() const; |
199 | 200 | ||
200 | /** | 201 | /** |
201 | * @return whether inplace-renaming has been enabled. False by default. | 202 | * @return whether inplace-renaming has been enabled. False by default. |
202 | * | 203 | * |
203 | * @see #setItemsRenameable() | 204 | * @see #setItemsRenameable() |
204 | */ | 205 | */ |
205 | bool itemsRenameable() const; | 206 | bool itemsRenameable() const; |
206 | 207 | ||
207 | /** | 208 | /** |
208 | * @return whether dragging is enabled. False by default. | 209 | * @return whether dragging is enabled. False by default. |
209 | * | 210 | * |
210 | * @see #setDragEnabled() | 211 | * @see #setDragEnabled() |
211 | */ | 212 | */ |
212 | bool dragEnabled() const; | 213 | bool dragEnabled() const; |
213 | 214 | ||
214 | /** | 215 | /** |
215 | * @return true if AutoOpen is enabled (not implemented currently). | 216 | * @return true if AutoOpen is enabled (not implemented currently). |
216 | * | 217 | * |
217 | * @see #setAutoOpen() | 218 | * @see #setAutoOpen() |
218 | */ | 219 | */ |
219 | bool autoOpen() const; | 220 | bool autoOpen() const; |
220 | 221 | ||
221 | /** | 222 | /** |
222 | * @return true if @p column is renamable. | 223 | * @return true if @p column is renamable. |
223 | * | 224 | * |
224 | * @see #setRenameable() | 225 | * @see #setRenameable() |
225 | */ | 226 | */ |
226 | bool isRenameable (int column) const; | 227 | bool isRenameable (int column) const; |
227 | 228 | ||
228 | /** | 229 | /** |
229 | * @return true if drawing of the drop-visualizer has been enabled. True by default. | 230 | * @return true if drawing of the drop-visualizer has been enabled. True by default. |
230 | * | 231 | * |
231 | * @see #setDropVisualizer() | 232 | * @see #setDropVisualizer() |
232 | */ | 233 | */ |
233 | bool dropVisualizer() const; | 234 | bool dropVisualizer() const; |
234 | 235 | ||
235 | /** | 236 | /** |
236 | * @return the column for which tooltips are displayed (or -1 if none set). | 237 | * @return the column for which tooltips are displayed (or -1 if none set). |
237 | * | 238 | * |
238 | * @see #setTooltipColumn() | 239 | * @see #setTooltipColumn() |
239 | */ | 240 | */ |
240 | int tooltipColumn() const; | 241 | int tooltipColumn() const; |
241 | 242 | ||
242 | /** | 243 | /** |
243 | * For future expansions. | 244 | * For future expansions. |
244 | * | 245 | * |
245 | * Do not use. | 246 | * Do not use. |
246 | * @deprecated | 247 | * @deprecated |
247 | */ | 248 | */ |
248 | bool createChildren() const; | 249 | bool createChildren() const; |
249 | 250 | ||
250 | /** | 251 | /** |
251 | * @return true if drawing of the drop-highlighter has been enabled. False by default. | 252 | * @return true if drawing of the drop-highlighter has been enabled. False by default. |
252 | * | 253 | * |
253 | * @see #setDropHighlighter() | 254 | * @see #setDropHighlighter() |
254 | */ | 255 | */ |
255 | bool dropHighlighter() const; | 256 | bool dropHighlighter() const; |
256 | 257 | ||
257 | /** | 258 | /** |
258 | * The dropVisualizerWidth defaults to 4. | 259 | * The dropVisualizerWidth defaults to 4. |
259 | * | 260 | * |
260 | * @see #setDropVisualizerWidth() | 261 | * @see #setDropVisualizerWidth() |