author | ulf69 <ulf69> | 2004-10-28 00:07:51 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-28 00:07:51 (UTC) |
commit | 0766b449ccdcc125c18c401d87cc51c277464728 (patch) (unidiff) | |
tree | 5279c7c3f441f448ecb82f1400439e4a7498dde3 /microkde/kdeui/klistview.cpp | |
parent | 5afbc6ae0908ce12fd5abb1c4eadf9c61a01503c (diff) | |
download | kdepimpi-0766b449ccdcc125c18c401d87cc51c277464728.zip kdepimpi-0766b449ccdcc125c18c401d87cc51c277464728.tar.gz kdepimpi-0766b449ccdcc125c18c401d87cc51c277464728.tar.bz2 |
bugfix: KListView did not recognize singleclicks
Diffstat (limited to 'microkde/kdeui/klistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/klistview.cpp | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp index 3c809b4..32483bb 100644 --- a/microkde/kdeui/klistview.cpp +++ b/microkde/kdeui/klistview.cpp | |||
@@ -422,661 +422,682 @@ KListView::KListView( QWidget *parent, const char *name ) | |||
422 | connect (this, SIGNAL(contentsMoving(int,int)), | 422 | connect (this, SIGNAL(contentsMoving(int,int)), |
423 | this, SLOT(cleanDropVisualizer())); | 423 | this, SLOT(cleanDropVisualizer())); |
424 | connect (this, SIGNAL(contentsMoving(int,int)), | 424 | connect (this, SIGNAL(contentsMoving(int,int)), |
425 | this, SLOT(cleanItemHighlighter())); | 425 | this, SLOT(cleanItemHighlighter())); |
426 | 426 | ||
427 | /*US | 427 | /*US |
428 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); | 428 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); |
429 | 429 | ||
430 | if (kapp) | 430 | if (kapp) |
431 | { | 431 | { |
432 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); | 432 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); |
433 | kapp->addKipcEventMask( KIPC::SettingsChanged ); | 433 | kapp->addKipcEventMask( KIPC::SettingsChanged ); |
434 | } | 434 | } |
435 | */ | 435 | */ |
436 | slotSettingsChanged(1); //US do this to initialize the connections | 436 | slotSettingsChanged(1); //US do this to initialize the connections |
437 | 437 | ||
438 | 438 | ||
439 | connect(&d->autoSelect, SIGNAL( timeout() ), | 439 | connect(&d->autoSelect, SIGNAL( timeout() ), |
440 | this, SLOT( slotAutoSelect() ) ); | 440 | this, SLOT( slotAutoSelect() ) ); |
441 | connect(&d->dragExpand, SIGNAL( timeout() ), | 441 | connect(&d->dragExpand, SIGNAL( timeout() ), |
442 | this, SLOT( slotDragExpand() ) ); | 442 | this, SLOT( slotDragExpand() ) ); |
443 | 443 | ||
444 | // context menu handling | 444 | // context menu handling |
445 | if (d->showContextMenusOnPress) | 445 | if (d->showContextMenusOnPress) |
446 | { | 446 | { |
447 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 447 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
448 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 448 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
449 | } | 449 | } |
450 | else | 450 | else |
451 | { | 451 | { |
452 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 452 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
453 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 453 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
454 | } | 454 | } |
455 | 455 | ||
456 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), | 456 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), |
457 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); | 457 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); |
458 | 458 | ||
459 | 459 | ||
460 | //qDebug("KListView::KListView make alternate color configurable"); | 460 | //qDebug("KListView::KListView make alternate color configurable"); |
461 | //US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); | 461 | //US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); |
462 | d->alternateBackground = QColor(240, 240, 240); | 462 | d->alternateBackground = QColor(240, 240, 240); |
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 | 479 | ||
480 | bool KListView::isExecuteArea( int x ) | 480 | bool KListView::isExecuteArea( int x ) |
481 | { | 481 | { |
482 | if( allColumnsShowFocus() ) | 482 | if( allColumnsShowFocus() ) |
483 | return true; | 483 | return true; |
484 | else { | 484 | else { |
485 | int offset = 0; | 485 | int offset = 0; |
486 | int width = columnWidth( 0 ); | 486 | int width = columnWidth( 0 ); |
487 | int pos = header()->mapToIndex( 0 ); | 487 | int pos = header()->mapToIndex( 0 ); |
488 | 488 | ||
489 | for ( int index = 0; index < pos; index++ ) | 489 | for ( int index = 0; index < pos; index++ ) |
490 | offset += columnWidth( header()->mapToSection( index ) ); | 490 | offset += columnWidth( header()->mapToSection( index ) ); |
491 | 491 | ||
492 | x += contentsX(); // in case of a horizontal scrollbar | 492 | x += contentsX(); // in case of a horizontal scrollbar |
493 | return ( x > offset && x < ( offset + width ) ); | 493 | return ( x > offset && x < ( offset + width ) ); |
494 | } | 494 | } |
495 | } | 495 | } |
496 | 496 | ||
497 | void KListView::slotOnItem( QListViewItem *item ) | 497 | void KListView::slotOnItem( QListViewItem *item ) |
498 | { | 498 | { |
499 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); | 499 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); |
500 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { | 500 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { |
501 | d->autoSelect.start( d->autoSelectDelay, true ); | 501 | d->autoSelect.start( d->autoSelectDelay, true ); |
502 | d->pCurrentItem = item; | 502 | d->pCurrentItem = item; |
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | void KListView::slotOnViewport() | 506 | void KListView::slotOnViewport() |
507 | { | 507 | { |
508 | if ( d->bChangeCursorOverItem ) | 508 | if ( d->bChangeCursorOverItem ) |
509 | viewport()->unsetCursor(); | 509 | viewport()->unsetCursor(); |
510 | 510 | ||
511 | d->autoSelect.stop(); | 511 | d->autoSelect.stop(); |
512 | d->pCurrentItem = 0L; | 512 | d->pCurrentItem = 0L; |
513 | } | 513 | } |
514 | 514 | ||
515 | void KListView::slotSettingsChanged(int category) | 515 | void KListView::slotSettingsChanged(int category) |
516 | { | 516 | { |
517 | //qDebug("KListView::slotSettingsChanged has to be verified"); | 517 | //qDebug("KListView::slotSettingsChanged has to be verified"); |
518 | /*US | 518 | |
519 | 519 | ||
520 | switch (category) | 520 | switch (category) |
521 | { | 521 | { |
522 | //US I create my private category (=1) to set the settings | ||
523 | case 1: | ||
524 | d->dragDelay = 2; | ||
525 | //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); | ||
526 | qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); | ||
527 | |||
528 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | ||
529 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | ||
530 | |||
531 | if( d->bUseSingle ) | ||
532 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | ||
533 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | ||
534 | |||
535 | //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | ||
536 | //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | ||
537 | |||
538 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | ||
539 | viewport()->unsetCursor(); | ||
540 | |||
541 | break; | ||
542 | |||
543 | /*US | ||
522 | case KApplication::SETTINGS_MOUSE: | 544 | case KApplication::SETTINGS_MOUSE: |
523 | d->dragDelay = KGlobalSettings::dndEventDelay(); | 545 | d->dragDelay = KGlobalSettings::dndEventDelay(); |
524 | d->bUseSingle = KGlobalSettings::singleClick(); | 546 | d->bUseSingle = KGlobalSettings::singleClick(); |
525 | 547 | ||
526 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 548 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
527 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 549 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
528 | 550 | ||
529 | if( d->bUseSingle ) | 551 | if( d->bUseSingle ) |
530 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 552 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
531 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 553 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
532 | 554 | ||
533 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 555 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
534 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 556 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
535 | 557 | ||
536 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 558 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
537 | viewport()->unsetCursor(); | 559 | viewport()->unsetCursor(); |
538 | 560 | ||
539 | break; | 561 | break; |
540 | |||
541 | case KApplication::SETTINGS_POPUPMENU: | 562 | case KApplication::SETTINGS_POPUPMENU: |
542 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); | 563 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); |
543 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); | 564 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); |
544 | 565 | ||
545 | if (d->showContextMenusOnPress) | 566 | if (d->showContextMenusOnPress) |
546 | { | 567 | { |
547 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 568 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
548 | 569 | ||
549 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 570 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
550 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 571 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
551 | } | 572 | } |
552 | else | 573 | else |
553 | { | 574 | { |
554 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 575 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
555 | 576 | ||
556 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 577 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
557 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 578 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
558 | } | 579 | } |
559 | break; | 580 | break; |
581 | */ | ||
560 | 582 | ||
561 | default: | 583 | default: |
562 | break; | 584 | break; |
563 | } | 585 | } |
564 | */ | ||
565 | 586 | ||
566 | if( d->bUseSingle ) | ||
567 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | ||
568 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | ||
569 | |||
570 | } | 587 | } |
571 | 588 | ||
572 | void KListView::slotAutoSelect() | 589 | void KListView::slotAutoSelect() |
573 | { | 590 | { |
574 | // check that the item still exists | 591 | // check that the item still exists |
575 | if( itemIndex( d->pCurrentItem ) == -1 ) | 592 | if( itemIndex( d->pCurrentItem ) == -1 ) |
576 | return; | 593 | return; |
577 | 594 | ||
578 | if (!isActiveWindow()) | 595 | if (!isActiveWindow()) |
579 | { | 596 | { |
580 | d->autoSelect.stop(); | 597 | d->autoSelect.stop(); |
581 | return; | 598 | return; |
582 | } | 599 | } |
583 | 600 | ||
584 | //Give this widget the keyboard focus. | 601 | //Give this widget the keyboard focus. |
585 | if( !hasFocus() ) | 602 | if( !hasFocus() ) |
586 | setFocus(); | 603 | setFocus(); |
587 | 604 | ||
588 | QListViewItem* previousItem = currentItem(); | 605 | QListViewItem* previousItem = currentItem(); |
589 | setCurrentItem( d->pCurrentItem ); | 606 | setCurrentItem( d->pCurrentItem ); |
590 | 607 | ||
591 | #if 0 | 608 | #if 0 |
592 | #ifndef Q_WS_QWS | 609 | #ifndef Q_WS_QWS |
593 | // FIXME(E): Implement for Qt Embedded | 610 | // FIXME(E): Implement for Qt Embedded |
594 | if( d->pCurrentItem ) { | 611 | if( d->pCurrentItem ) { |
595 | //Shift pressed? | 612 | //Shift pressed? |
596 | if( (keybstate & ShiftMask) ) { | 613 | if( (keybstate & ShiftMask) ) { |
597 | bool block = signalsBlocked(); | 614 | bool block = signalsBlocked(); |
598 | blockSignals( true ); | 615 | blockSignals( true ); |
599 | 616 | ||
600 | //No Ctrl? Then clear before! | 617 | //No Ctrl? Then clear before! |
601 | if( !(keybstate & ControlMask) ) | 618 | if( !(keybstate & ControlMask) ) |
602 | clearSelection(); | 619 | clearSelection(); |
603 | 620 | ||
604 | bool select = !d->pCurrentItem->isSelected(); | 621 | bool select = !d->pCurrentItem->isSelected(); |
605 | bool update = viewport()->isUpdatesEnabled(); | 622 | bool update = viewport()->isUpdatesEnabled(); |
606 | viewport()->setUpdatesEnabled( false ); | 623 | viewport()->setUpdatesEnabled( false ); |
607 | 624 | ||
608 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); | 625 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); |
609 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); | 626 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); |
610 | for ( ; lit.current(); ++lit ) { | 627 | for ( ; lit.current(); ++lit ) { |
611 | if ( down && lit.current() == d->pCurrentItem ) { | 628 | if ( down && lit.current() == d->pCurrentItem ) { |
612 | d->pCurrentItem->setSelected( select ); | 629 | d->pCurrentItem->setSelected( select ); |
613 | break; | 630 | break; |
614 | } | 631 | } |
615 | if ( !down && lit.current() == previousItem ) { | 632 | if ( !down && lit.current() == previousItem ) { |
616 | previousItem->setSelected( select ); | 633 | previousItem->setSelected( select ); |
617 | break; | 634 | break; |
618 | } | 635 | } |
619 | lit.current()->setSelected( select ); | 636 | lit.current()->setSelected( select ); |
620 | } | 637 | } |
621 | 638 | ||
622 | blockSignals( block ); | 639 | blockSignals( block ); |
623 | viewport()->setUpdatesEnabled( update ); | 640 | viewport()->setUpdatesEnabled( update ); |
624 | triggerUpdate(); | 641 | triggerUpdate(); |
625 | 642 | ||
626 | emit selectionChanged(); | 643 | emit selectionChanged(); |
627 | 644 | ||
628 | if( selectionMode() == QListView::Single ) | 645 | if( selectionMode() == QListView::Single ) |
629 | emit selectionChanged( d->pCurrentItem ); | 646 | emit selectionChanged( d->pCurrentItem ); |
630 | } | 647 | } |
631 | else if( (keybstate & ControlMask) ) | 648 | else if( (keybstate & ControlMask) ) |
632 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); | 649 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); |
633 | else { | 650 | else { |
634 | bool block = signalsBlocked(); | 651 | bool block = signalsBlocked(); |
635 | blockSignals( true ); | 652 | blockSignals( true ); |
636 | 653 | ||
637 | if( !d->pCurrentItem->isSelected() ) | 654 | if( !d->pCurrentItem->isSelected() ) |
638 | clearSelection(); | 655 | clearSelection(); |
639 | 656 | ||
640 | blockSignals( block ); | 657 | blockSignals( block ); |
641 | 658 | ||
642 | setSelected( d->pCurrentItem, true ); | 659 | setSelected( d->pCurrentItem, true ); |
643 | } | 660 | } |
644 | } | 661 | } |
645 | else | 662 | else |
646 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; | 663 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; |
647 | #endif | 664 | #endif |
648 | #endif | 665 | #endif |
649 | } | 666 | } |
650 | 667 | ||
651 | void KListView::slotHeaderChanged() | 668 | void KListView::slotHeaderChanged() |
652 | { | 669 | { |
653 | if (d->fullWidth && columns()) | 670 | if (d->fullWidth && columns()) |
654 | { | 671 | { |
655 | int w = 0; | 672 | int w = 0; |
656 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); | 673 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); |
657 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); | 674 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); |
658 | } | 675 | } |
659 | } | 676 | } |
660 | 677 | ||
661 | void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c ) | 678 | void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) |
662 | { | 679 | { |
680 | // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); | ||
663 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { | 681 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { |
664 | 682 | ||
665 | // Double click mode ? | 683 | // Double click mode ? |
666 | if ( !d->bUseSingle ) | 684 | if ( !d->bUseSingle ) |
667 | { | 685 | { |
668 | emit executed( item ); | 686 | emit executed( item ); |
669 | emit executed( item, pos, c ); | 687 | emit executed( item, pos, c ); |
670 | } | 688 | } |
671 | else | 689 | else |
672 | { | 690 | { |
673 | #if 0 | 691 | //US special implementation for embedded systems |
674 | #ifndef Q_WS_QWS | ||
675 | // FIXME(E): Implement for Qt Embedded | ||
676 | Window root; | ||
677 | Window child; | ||
678 | int root_x, root_y, win_x, win_y; | ||
679 | uint keybstate; | ||
680 | XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, | ||
681 | &root_x, &root_y, &win_x, &win_y, &keybstate ); | ||
682 | |||
683 | d->autoSelect.stop(); | 692 | d->autoSelect.stop(); |
684 | 693 | ||
685 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed | 694 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed |
686 | if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { | 695 | if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { |
696 | // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { | ||
697 | |||
687 | emit executed( item ); | 698 | emit executed( item ); |
688 | emit executed( item, pos, c ); | 699 | emit executed( item, pos, c ); |
689 | } | 700 | } |
690 | #endif | ||
691 | #endif | ||
692 | } | 701 | } |
693 | } | 702 | } |
694 | } | 703 | } |
695 | 704 | ||
696 | void KListView::focusInEvent( QFocusEvent *fe ) | 705 | void KListView::focusInEvent( QFocusEvent *fe ) |
697 | { | 706 | { |
698 | // kdDebug()<<"KListView::focusInEvent()"<<endl; | 707 | // kdDebug()<<"KListView::focusInEvent()"<<endl; |
699 | QListView::focusInEvent( fe ); | 708 | QListView::focusInEvent( fe ); |
700 | if ((d->selectedBySimpleMove) | 709 | if ((d->selectedBySimpleMove) |
701 | && (d->selectionMode == FileManager) | 710 | && (d->selectionMode == FileManager) |
702 | && (fe->reason()!=QFocusEvent::Popup) | 711 | && (fe->reason()!=QFocusEvent::Popup) |
703 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 712 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
704 | && (currentItem()!=0)) | 713 | && (currentItem()!=0)) |
705 | { | 714 | { |
706 | currentItem()->setSelected(true); | 715 | currentItem()->setSelected(true); |
707 | currentItem()->repaint(); | 716 | currentItem()->repaint(); |
708 | emit selectionChanged(); | 717 | emit selectionChanged(); |
709 | }; | 718 | }; |
710 | } | 719 | } |
711 | 720 | ||
712 | void KListView::focusOutEvent( QFocusEvent *fe ) | 721 | void KListView::focusOutEvent( QFocusEvent *fe ) |
713 | { | 722 | { |
714 | cleanDropVisualizer(); | 723 | cleanDropVisualizer(); |
715 | cleanItemHighlighter(); | 724 | cleanItemHighlighter(); |
716 | 725 | ||
717 | d->autoSelect.stop(); | 726 | d->autoSelect.stop(); |
718 | 727 | ||
719 | if ((d->selectedBySimpleMove) | 728 | if ((d->selectedBySimpleMove) |
720 | && (d->selectionMode == FileManager) | 729 | && (d->selectionMode == FileManager) |
721 | && (fe->reason()!=QFocusEvent::Popup) | 730 | && (fe->reason()!=QFocusEvent::Popup) |
722 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 731 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
723 | && (currentItem()!=0) | 732 | && (currentItem()!=0) |
724 | /*US && (!d->editor->isVisible()) */ | 733 | /*US && (!d->editor->isVisible()) */ |
725 | ) | 734 | ) |
726 | { | 735 | { |
727 | currentItem()->setSelected(false); | 736 | currentItem()->setSelected(false); |
728 | currentItem()->repaint(); | 737 | currentItem()->repaint(); |
729 | emit selectionChanged(); | 738 | emit selectionChanged(); |
730 | }; | 739 | }; |
731 | 740 | ||
732 | QListView::focusOutEvent( fe ); | 741 | QListView::focusOutEvent( fe ); |
733 | } | 742 | } |
734 | 743 | ||
735 | void KListView::leaveEvent( QEvent *e ) | 744 | void KListView::leaveEvent( QEvent *e ) |
736 | { | 745 | { |
737 | d->autoSelect.stop(); | 746 | d->autoSelect.stop(); |
738 | 747 | ||
739 | QListView::leaveEvent( e ); | 748 | QListView::leaveEvent( e ); |
740 | } | 749 | } |
741 | 750 | ||
742 | bool KListView::event( QEvent *e ) | 751 | bool KListView::event( QEvent *e ) |
743 | { | 752 | { |
744 | if (e->type() == QEvent::ApplicationPaletteChange) { | 753 | if (e->type() == QEvent::ApplicationPaletteChange) { |
745 | qDebug("KListView::event make alternate color configurable"); | 754 | //qDebug("KListView::event make alternate color configurable"); |
746 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); | 755 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); |
747 | d->alternateBackground = QColor(240, 240, 240); | 756 | d->alternateBackground = QColor(240, 240, 240); |
748 | } | 757 | } |
749 | 758 | ||
750 | return QListView::event(e); | 759 | return QListView::event(e); |
751 | } | 760 | } |
752 | 761 | ||
753 | void KListView::contentsMousePressEvent( QMouseEvent *e ) | 762 | void KListView::contentsMousePressEvent( QMouseEvent *e ) |
754 | { | 763 | { |
764 | //qDebug("KListView::contentsMousePressEvent"); | ||
755 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) | 765 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) |
756 | { | 766 | { |
757 | bool block = signalsBlocked(); | 767 | bool block = signalsBlocked(); |
758 | blockSignals( true ); | 768 | blockSignals( true ); |
759 | 769 | ||
760 | clearSelection(); | 770 | clearSelection(); |
761 | 771 | ||
762 | blockSignals( block ); | 772 | blockSignals( block ); |
763 | } | 773 | } |
764 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) | 774 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) |
765 | { | 775 | { |
766 | d->selectedBySimpleMove=false; | 776 | d->selectedBySimpleMove=false; |
767 | d->selectedUsingMouse=true; | 777 | d->selectedUsingMouse=true; |
768 | if (currentItem()!=0) | 778 | if (currentItem()!=0) |
769 | { | 779 | { |
770 | currentItem()->setSelected(false); | 780 | currentItem()->setSelected(false); |
771 | currentItem()->repaint(); | 781 | currentItem()->repaint(); |
772 | // emit selectionChanged(); | 782 | // emit selectionChanged(); |
773 | }; | 783 | }; |
774 | }; | 784 | }; |
775 | 785 | ||
776 | QPoint p( contentsToViewport( e->pos() ) ); | 786 | QPoint p( contentsToViewport( e->pos() ) ); |
777 | QListViewItem *at = itemAt (p); | 787 | QListViewItem *at = itemAt (p); |
778 | 788 | ||
779 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 789 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
780 | bool rootDecoClicked = at | 790 | bool rootDecoClicked = at |
781 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 791 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
782 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 792 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
783 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 793 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
784 | 794 | ||
785 | if (e->button() == LeftButton && !rootDecoClicked) | 795 | if (e->button() == LeftButton && !rootDecoClicked) |
786 | { | 796 | { |
787 | //Start a drag | 797 | //Start a drag |
788 | d->startDragPos = e->pos(); | 798 | d->startDragPos = e->pos(); |
789 | 799 | ||
790 | if (at) | 800 | if (at) |
791 | { | 801 | { |
792 | d->validDrag = true; | 802 | d->validDrag = true; |
793 | d->pressedOnSelected = at->isSelected(); | 803 | d->pressedOnSelected = at->isSelected(); |
794 | } | 804 | } |
795 | } | 805 | } |
796 | 806 | ||
797 | QListView::contentsMousePressEvent( e ); | 807 | QListView::contentsMousePressEvent( e ); |
798 | } | 808 | } |
799 | 809 | ||
800 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) | 810 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) |
801 | { | 811 | { |
802 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { | 812 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { |
803 | QListView::contentsMouseMoveEvent (e); | 813 | QListView::contentsMouseMoveEvent (e); |
804 | return; | 814 | return; |
805 | } | 815 | } |
806 | 816 | ||
807 | QPoint vp = contentsToViewport(e->pos()); | 817 | QPoint vp = contentsToViewport(e->pos()); |
808 | QListViewItem *item = itemAt( vp ); | 818 | QListViewItem *item = itemAt( vp ); |
809 | 819 | ||
810 | //do we process cursor changes at all? | 820 | //do we process cursor changes at all? |
811 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) | 821 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) |
812 | { | 822 | { |
813 | //Cursor moved on a new item or in/out the execute area | 823 | //Cursor moved on a new item or in/out the execute area |
814 | if( (item != d->pCurrentItem) || | 824 | if( (item != d->pCurrentItem) || |
815 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) | 825 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) |
816 | { | 826 | { |
817 | d->cursorInExecuteArea = isExecuteArea(vp); | 827 | d->cursorInExecuteArea = isExecuteArea(vp); |
818 | qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); | 828 | //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); |
819 | /*US | 829 | /*US |
820 | if( d->cursorInExecuteArea ) //cursor moved in execute area | 830 | if( d->cursorInExecuteArea ) //cursor moved in execute area |
821 | viewport()->setCursor( KCursor::handCursor() ); | 831 | viewport()->setCursor( KCursor::handCursor() ); |
822 | else //cursor moved out of execute area | 832 | else //cursor moved out of execute area |
823 | viewport()->unsetCursor(); | 833 | viewport()->unsetCursor(); |
824 | */ | 834 | */ |
825 | } | 835 | } |
826 | } | 836 | } |
827 | 837 | ||
828 | bool dragOn = dragEnabled(); | 838 | bool dragOn = dragEnabled(); |
829 | QPoint newPos = e->pos(); | 839 | QPoint newPos = e->pos(); |
830 | if (dragOn && d->validDrag && | 840 | if (dragOn && d->validDrag && |
831 | (newPos.x() > d->startDragPos.x()+d->dragDelay || | 841 | (newPos.x() > d->startDragPos.x()+d->dragDelay || |
832 | newPos.x() < d->startDragPos.x()-d->dragDelay || | 842 | newPos.x() < d->startDragPos.x()-d->dragDelay || |
833 | newPos.y() > d->startDragPos.y()+d->dragDelay || | 843 | newPos.y() > d->startDragPos.y()+d->dragDelay || |
834 | newPos.y() < d->startDragPos.y()-d->dragDelay)) | 844 | newPos.y() < d->startDragPos.y()-d->dragDelay)) |
835 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) | 845 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) |
836 | { | 846 | { |
837 | QListView::contentsMouseReleaseEvent( 0 ); | 847 | QListView::contentsMouseReleaseEvent( 0 ); |
838 | startDrag(); | 848 | startDrag(); |
839 | d->startDragPos = QPoint(); | 849 | d->startDragPos = QPoint(); |
840 | d->validDrag = false; | 850 | d->validDrag = false; |
841 | } | 851 | } |
842 | } | 852 | } |
843 | 853 | ||
844 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) | 854 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) |
845 | { | 855 | { |
846 | if (e->button() == LeftButton) | 856 | if (e->button() == LeftButton) |
847 | { | 857 | { |
848 | // If the row was already selected, maybe we want to start an in-place editing | 858 | // If the row was already selected, maybe we want to start an in-place editing |
849 | if ( d->pressedOnSelected && itemsRenameable() ) | 859 | if ( d->pressedOnSelected && itemsRenameable() ) |
850 | { | 860 | { |
851 | QPoint p( contentsToViewport( e->pos() ) ); | 861 | QPoint p( contentsToViewport( e->pos() ) ); |
852 | QListViewItem *at = itemAt (p); | 862 | QListViewItem *at = itemAt (p); |
853 | if ( at ) | 863 | if ( at ) |
854 | { | 864 | { |
855 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 865 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
856 | bool rootDecoClicked = | 866 | bool rootDecoClicked = |
857 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 867 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
858 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 868 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
859 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 869 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
860 | 870 | ||
861 | if (!rootDecoClicked) | 871 | if (!rootDecoClicked) |
862 | { | 872 | { |
863 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); | 873 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); |
864 | if ( d->renameable.contains(col) ) | 874 | if ( d->renameable.contains(col) ) |
865 | rename(at, col); | 875 | rename(at, col); |
866 | } | 876 | } |
867 | } | 877 | } |
868 | } | 878 | } |
869 | 879 | ||
870 | d->pressedOnSelected = false; | 880 | d->pressedOnSelected = false; |
871 | d->validDrag = false; | 881 | d->validDrag = false; |
872 | d->startDragPos = QPoint(); | 882 | d->startDragPos = QPoint(); |
873 | } | 883 | } |
874 | QListView::contentsMouseReleaseEvent( e ); | 884 | QListView::contentsMouseReleaseEvent( e ); |
875 | } | 885 | } |
876 | 886 | ||
877 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) | 887 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) |
878 | { | 888 | { |
889 | //qDebug("KListView::contentsMouseDoubleClickEvent"); | ||
879 | // We don't want to call the parent method because it does setOpen, | 890 | // We don't want to call the parent method because it does setOpen, |
880 | // whereas we don't do it in single click mode... (David) | 891 | // whereas we don't do it in single click mode... (David) |
881 | //QListView::contentsMouseDoubleClickEvent( e ); | 892 | //QListView::contentsMouseDoubleClickEvent( e ); |
882 | 893 | ||
883 | QPoint vp = contentsToViewport(e->pos()); | 894 | QPoint vp = contentsToViewport(e->pos()); |
884 | QListViewItem *item = itemAt( vp ); | 895 | QListViewItem *item = itemAt( vp ); |
885 | emit QListView::doubleClicked( item ); // we do it now | 896 | emit QListView::doubleClicked( item ); // we do it now |
886 | 897 | ||
887 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; | 898 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; |
888 | 899 | ||
889 | if( item ) { | 900 | if( item ) { |
901 | //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked"); | ||
902 | |||
890 | emit doubleClicked( item, e->globalPos(), col ); | 903 | emit doubleClicked( item, e->globalPos(), col ); |
891 | 904 | ||
892 | if( (e->button() == LeftButton) && !d->bUseSingle ) | 905 | if( (e->button() == LeftButton) && !d->bUseSingle ) { |
893 | emitExecute( item, e->globalPos(), col ); | 906 | //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute"); |
907 | |||
908 | emitExecute( e->button(), item, e->globalPos(), col); | ||
909 | } | ||
894 | } | 910 | } |
895 | } | 911 | } |
896 | 912 | ||
897 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) | 913 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) |
898 | { | 914 | { |
899 | if( (btn == LeftButton) && item ) | 915 | //qDebug("KListView::slotMouseButtonClicked"); |
900 | emitExecute(item, pos, c); | 916 | |
917 | if( (btn == LeftButton) && item ) { | ||
918 | //qDebug("KListView::slotMouseButtonClicked: emitExecute"); | ||
919 | |||
920 | emitExecute(btn, item, pos, c); | ||
921 | } | ||
901 | } | 922 | } |
902 | 923 | ||
903 | void KListView::contentsDropEvent(QDropEvent* e) | 924 | void KListView::contentsDropEvent(QDropEvent* e) |
904 | { | 925 | { |
905 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 926 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
906 | /*US | 927 | /*US |
907 | cleanDropVisualizer(); | 928 | cleanDropVisualizer(); |
908 | cleanItemHighlighter(); | 929 | cleanItemHighlighter(); |
909 | d->dragExpand.stop(); | 930 | d->dragExpand.stop(); |
910 | 931 | ||
911 | if (acceptDrag (e)) | 932 | if (acceptDrag (e)) |
912 | { | 933 | { |
913 | e->acceptAction(); | 934 | e->acceptAction(); |
914 | QListViewItem *afterme; | 935 | QListViewItem *afterme; |
915 | QListViewItem *parent; | 936 | QListViewItem *parent; |
916 | findDrop(e->pos(), parent, afterme); | 937 | findDrop(e->pos(), parent, afterme); |
917 | 938 | ||
918 | if (e->source() == viewport() && itemsMovable()) | 939 | if (e->source() == viewport() && itemsMovable()) |
919 | movableDropEvent(parent, afterme); | 940 | movableDropEvent(parent, afterme); |
920 | else | 941 | else |
921 | { | 942 | { |
922 | 943 | ||
923 | emit dropped(e, afterme); | 944 | emit dropped(e, afterme); |
924 | emit dropped(this, e, afterme); | 945 | emit dropped(this, e, afterme); |
925 | emit dropped(e, parent, afterme); | 946 | emit dropped(e, parent, afterme); |
926 | emit dropped(this, e, parent, afterme); | 947 | emit dropped(this, e, parent, afterme); |
927 | 948 | ||
928 | } | 949 | } |
929 | } | 950 | } |
930 | */ | 951 | */ |
931 | 952 | ||
932 | } | 953 | } |
933 | 954 | ||
934 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) | 955 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) |
935 | { | 956 | { |
936 | QPtrList<QListViewItem> items, afterFirsts, afterNows; | 957 | QPtrList<QListViewItem> items, afterFirsts, afterNows; |
937 | QListViewItem *current=currentItem(); | 958 | QListViewItem *current=currentItem(); |
938 | bool hasMoved=false; | 959 | bool hasMoved=false; |
939 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) | 960 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) |
940 | { | 961 | { |
941 | iNext=i->itemBelow(); | 962 | iNext=i->itemBelow(); |
942 | if (!i->isSelected()) | 963 | if (!i->isSelected()) |
943 | continue; | 964 | continue; |
944 | 965 | ||
945 | // don't drop an item after itself, or else | 966 | // don't drop an item after itself, or else |
946 | // it moves to the top of the list | 967 | // it moves to the top of the list |
947 | if (i==afterme) | 968 | if (i==afterme) |
948 | continue; | 969 | continue; |
949 | 970 | ||
950 | i->setSelected(false); | 971 | i->setSelected(false); |
951 | 972 | ||
952 | QListViewItem *afterFirst = i->itemAbove(); | 973 | QListViewItem *afterFirst = i->itemAbove(); |
953 | 974 | ||
954 | if (!hasMoved) | 975 | if (!hasMoved) |
955 | { | 976 | { |
956 | emit aboutToMove(); | 977 | emit aboutToMove(); |
957 | hasMoved=true; | 978 | hasMoved=true; |
958 | } | 979 | } |
959 | 980 | ||
960 | moveItem(i, parent, afterme); | 981 | moveItem(i, parent, afterme); |
961 | 982 | ||
962 | // ###### This should include the new parent !!! -> KDE 3.0 | 983 | // ###### This should include the new parent !!! -> KDE 3.0 |
963 | // If you need this right now, have a look at keditbookmarks. | 984 | // If you need this right now, have a look at keditbookmarks. |
964 | emit moved(i, afterFirst, afterme); | 985 | emit moved(i, afterFirst, afterme); |
965 | 986 | ||
966 | items.append (i); | 987 | items.append (i); |
967 | afterFirsts.append (afterFirst); | 988 | afterFirsts.append (afterFirst); |
968 | afterNows.append (afterme); | 989 | afterNows.append (afterme); |
969 | 990 | ||
970 | afterme = i; | 991 | afterme = i; |
971 | } | 992 | } |
972 | clearSelection(); | 993 | clearSelection(); |
973 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) | 994 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) |
974 | i->setSelected(true); | 995 | i->setSelected(true); |
975 | if (current) | 996 | if (current) |
976 | setCurrentItem(current); | 997 | setCurrentItem(current); |
977 | 998 | ||
978 | emit moved(items,afterFirsts,afterNows); | 999 | emit moved(items,afterFirsts,afterNows); |
979 | 1000 | ||
980 | if (firstChild()) | 1001 | if (firstChild()) |
981 | emit moved(); | 1002 | emit moved(); |
982 | } | 1003 | } |
983 | 1004 | ||
984 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) | 1005 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) |
985 | { | 1006 | { |
986 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 1007 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
987 | /*US | 1008 | /*US |
988 | if (acceptDrag(event)) | 1009 | if (acceptDrag(event)) |
989 | { | 1010 | { |
990 | event->acceptAction(); | 1011 | event->acceptAction(); |
991 | //Clean up the view | 1012 | //Clean up the view |
992 | 1013 | ||
993 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); | 1014 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); |
994 | QPoint vp = contentsToViewport( event->pos() ); | 1015 | QPoint vp = contentsToViewport( event->pos() ); |
995 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; | 1016 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; |
996 | 1017 | ||
997 | if ( item != d->dragOverItem ) | 1018 | if ( item != d->dragOverItem ) |
998 | { | 1019 | { |
999 | d->dragExpand.stop(); | 1020 | d->dragExpand.stop(); |
1000 | d->dragOverItem = item; | 1021 | d->dragOverItem = item; |
1001 | d->dragOverPoint = vp; | 1022 | d->dragOverPoint = vp; |
1002 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) | 1023 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) |
1003 | d->dragExpand.start( QApplication::startDragTime(), true ); | 1024 | d->dragExpand.start( QApplication::startDragTime(), true ); |
1004 | } | 1025 | } |
1005 | if (dropVisualizer()) | 1026 | if (dropVisualizer()) |
1006 | { | 1027 | { |
1007 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); | 1028 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); |
1008 | if (tmpRect != d->mOldDropVisualizer) | 1029 | if (tmpRect != d->mOldDropVisualizer) |
1009 | { | 1030 | { |
1010 | cleanDropVisualizer(); | 1031 | cleanDropVisualizer(); |
1011 | d->mOldDropVisualizer=tmpRect; | 1032 | d->mOldDropVisualizer=tmpRect; |
1012 | viewport()->repaint(tmpRect); | 1033 | viewport()->repaint(tmpRect); |
1013 | } | 1034 | } |
1014 | } | 1035 | } |
1015 | if (dropHighlighter()) | 1036 | if (dropHighlighter()) |
1016 | { | 1037 | { |
1017 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); | 1038 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); |
1018 | if (tmpRect != d->mOldDropHighlighter) | 1039 | if (tmpRect != d->mOldDropHighlighter) |
1019 | { | 1040 | { |
1020 | cleanItemHighlighter(); | 1041 | cleanItemHighlighter(); |
1021 | d->mOldDropHighlighter=tmpRect; | 1042 | d->mOldDropHighlighter=tmpRect; |
1022 | viewport()->repaint(tmpRect); | 1043 | viewport()->repaint(tmpRect); |
1023 | } | 1044 | } |
1024 | } | 1045 | } |
1025 | } | 1046 | } |
1026 | else | 1047 | else |
1027 | event->ignore(); | 1048 | event->ignore(); |
1028 | */ | 1049 | */ |
1029 | } | 1050 | } |
1030 | 1051 | ||
1031 | void KListView::slotDragExpand() | 1052 | void KListView::slotDragExpand() |
1032 | { | 1053 | { |
1033 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) | 1054 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) |
1034 | d->dragOverItem->setOpen( true ); | 1055 | d->dragOverItem->setOpen( true ); |
1035 | } | 1056 | } |
1036 | 1057 | ||
1037 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) | 1058 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) |
1038 | { | 1059 | { |
1039 | d->dragExpand.stop(); | 1060 | d->dragExpand.stop(); |
1040 | cleanDropVisualizer(); | 1061 | cleanDropVisualizer(); |
1041 | cleanItemHighlighter(); | 1062 | cleanItemHighlighter(); |
1042 | } | 1063 | } |
1043 | 1064 | ||
1044 | void KListView::cleanDropVisualizer() | 1065 | void KListView::cleanDropVisualizer() |
1045 | { | 1066 | { |
1046 | if (d->mOldDropVisualizer.isValid()) | 1067 | if (d->mOldDropVisualizer.isValid()) |
1047 | { | 1068 | { |
1048 | QRect rect=d->mOldDropVisualizer; | 1069 | QRect rect=d->mOldDropVisualizer; |
1049 | d->mOldDropVisualizer = QRect(); | 1070 | d->mOldDropVisualizer = QRect(); |
1050 | viewport()->repaint(rect, true); | 1071 | viewport()->repaint(rect, true); |
1051 | } | 1072 | } |
1052 | } | 1073 | } |
1053 | 1074 | ||
1054 | int KListView::depthToPixels( int depth ) | 1075 | int KListView::depthToPixels( int depth ) |
1055 | { | 1076 | { |
1056 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); | 1077 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); |
1057 | } | 1078 | } |
1058 | 1079 | ||
1059 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) | 1080 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) |
1060 | { | 1081 | { |
1061 | QPoint p (contentsToViewport(pos)); | 1082 | QPoint p (contentsToViewport(pos)); |
1062 | 1083 | ||
1063 | // Get the position to put it in | 1084 | // Get the position to put it in |
1064 | QListViewItem *atpos = itemAt(p); | 1085 | QListViewItem *atpos = itemAt(p); |
1065 | 1086 | ||
1066 | QListViewItem *above; | 1087 | QListViewItem *above; |
1067 | if (!atpos) // put it at the end | 1088 | if (!atpos) // put it at the end |
1068 | above = lastItem(); | 1089 | above = lastItem(); |
1069 | else | 1090 | else |
1070 | { | 1091 | { |
1071 | // Get the closest item before us ('atpos' or the one above, if any) | 1092 | // Get the closest item before us ('atpos' or the one above, if any) |
1072 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) | 1093 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) |
1073 | above = atpos->itemAbove(); | 1094 | above = atpos->itemAbove(); |
1074 | else | 1095 | else |
1075 | above = atpos; | 1096 | above = atpos; |
1076 | } | 1097 | } |
1077 | 1098 | ||
1078 | if (above) | 1099 | if (above) |
1079 | { | 1100 | { |
1080 | // Now, we know we want to go after "above". But as a child or as a sibling ? | 1101 | // Now, we know we want to go after "above". But as a child or as a sibling ? |
1081 | // We have to ask the "above" item if it accepts children. | 1102 | // We have to ask the "above" item if it accepts children. |
1082 | if (above->isExpandable()) | 1103 | if (above->isExpandable()) |
@@ -1795,193 +1816,193 @@ void KListView::fileManagerKeyPressEvent (QKeyEvent* e) | |||
1795 | if (repaintItem2) | 1816 | if (repaintItem2) |
1796 | ir = ir.unite( itemRect(repaintItem2) ); | 1817 | ir = ir.unite( itemRect(repaintItem2) ); |
1797 | 1818 | ||
1798 | if ( !ir.isEmpty() ) | 1819 | if ( !ir.isEmpty() ) |
1799 | { // rectangle to be repainted | 1820 | { // rectangle to be repainted |
1800 | if ( ir.x() < 0 ) | 1821 | if ( ir.x() < 0 ) |
1801 | ir.moveBy( -ir.x(), 0 ); | 1822 | ir.moveBy( -ir.x(), 0 ); |
1802 | viewport()->repaint( ir, FALSE ); | 1823 | viewport()->repaint( ir, FALSE ); |
1803 | } | 1824 | } |
1804 | /*if (repaintItem1) | 1825 | /*if (repaintItem1) |
1805 | repaintItem1->repaint(); | 1826 | repaintItem1->repaint(); |
1806 | if (repaintItem2) | 1827 | if (repaintItem2) |
1807 | repaintItem2->repaint();*/ | 1828 | repaintItem2->repaint();*/ |
1808 | update(); | 1829 | update(); |
1809 | if (emitSelectionChanged) | 1830 | if (emitSelectionChanged) |
1810 | emit selectionChanged(); | 1831 | emit selectionChanged(); |
1811 | } | 1832 | } |
1812 | 1833 | ||
1813 | void KListView::setSelectionModeExt (SelectionModeExt mode) | 1834 | void KListView::setSelectionModeExt (SelectionModeExt mode) |
1814 | { | 1835 | { |
1815 | d->selectionMode = mode; | 1836 | d->selectionMode = mode; |
1816 | 1837 | ||
1817 | switch (mode) | 1838 | switch (mode) |
1818 | { | 1839 | { |
1819 | case Single: | 1840 | case Single: |
1820 | case Multi: | 1841 | case Multi: |
1821 | case Extended: | 1842 | case Extended: |
1822 | case NoSelection: | 1843 | case NoSelection: |
1823 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); | 1844 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); |
1824 | break; | 1845 | break; |
1825 | 1846 | ||
1826 | case FileManager: | 1847 | case FileManager: |
1827 | setSelectionMode (QListView::Extended); | 1848 | setSelectionMode (QListView::Extended); |
1828 | break; | 1849 | break; |
1829 | 1850 | ||
1830 | default: | 1851 | default: |
1831 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; | 1852 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; |
1832 | break; | 1853 | break; |
1833 | } | 1854 | } |
1834 | } | 1855 | } |
1835 | 1856 | ||
1836 | KListView::SelectionModeExt KListView::selectionModeExt () const | 1857 | KListView::SelectionModeExt KListView::selectionModeExt () const |
1837 | { | 1858 | { |
1838 | return d->selectionMode; | 1859 | return d->selectionMode; |
1839 | } | 1860 | } |
1840 | 1861 | ||
1841 | int KListView::itemIndex( const QListViewItem *item ) const | 1862 | int KListView::itemIndex( const QListViewItem *item ) const |
1842 | { | 1863 | { |
1843 | if ( !item ) | 1864 | if ( !item ) |
1844 | return -1; | 1865 | return -1; |
1845 | 1866 | ||
1846 | if ( item == firstChild() ) | 1867 | if ( item == firstChild() ) |
1847 | return 0; | 1868 | return 0; |
1848 | else { | 1869 | else { |
1849 | QListViewItemIterator it(firstChild()); | 1870 | QListViewItemIterator it(firstChild()); |
1850 | uint j = 0; | 1871 | uint j = 0; |
1851 | for (; it.current() && it.current() != item; ++it, ++j ); | 1872 | for (; it.current() && it.current() != item; ++it, ++j ); |
1852 | 1873 | ||
1853 | if( !it.current() ) | 1874 | if( !it.current() ) |
1854 | return -1; | 1875 | return -1; |
1855 | 1876 | ||
1856 | return j; | 1877 | return j; |
1857 | } | 1878 | } |
1858 | } | 1879 | } |
1859 | 1880 | ||
1860 | QListViewItem* KListView::itemAtIndex(int index) | 1881 | QListViewItem* KListView::itemAtIndex(int index) |
1861 | { | 1882 | { |
1862 | if (index<0) | 1883 | if (index<0) |
1863 | return 0; | 1884 | return 0; |
1864 | 1885 | ||
1865 | int j(0); | 1886 | int j(0); |
1866 | for (QListViewItemIterator it=firstChild(); it.current(); it++) | 1887 | for (QListViewItemIterator it=firstChild(); it.current(); it++) |
1867 | { | 1888 | { |
1868 | if (j==index) | 1889 | if (j==index) |
1869 | return it.current(); | 1890 | return it.current(); |
1870 | j++; | 1891 | j++; |
1871 | }; | 1892 | }; |
1872 | return 0; | 1893 | return 0; |
1873 | } | 1894 | } |
1874 | 1895 | ||
1875 | 1896 | ||
1876 | void KListView::emitContextMenu (KListView*, QListViewItem* i) | 1897 | void KListView::emitContextMenu (KListView*, QListViewItem* i) |
1877 | { | 1898 | { |
1878 | QPoint p; | 1899 | QPoint p; |
1879 | // qDebug("KListView::emitContextMenu "); | 1900 | // qDebug("KListView::emitContextMenu "); |
1880 | 1901 | ||
1881 | if (i) | 1902 | if (i) |
1882 | p = viewport()->mapToGlobal(itemRect(i).center()); | 1903 | p = viewport()->mapToGlobal(itemRect(i).center()); |
1883 | else | 1904 | else |
1884 | p = mapToGlobal(rect().center()); | 1905 | p = mapToGlobal(rect().center()); |
1885 | 1906 | ||
1886 | emit contextMenu (this, i, p); | 1907 | emit contextMenu (this, i, p); |
1887 | } | 1908 | } |
1888 | 1909 | ||
1889 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) | 1910 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) |
1890 | { | 1911 | { |
1891 | qDebug("KListView::emitContextMenu col"); | 1912 | // qDebug("KListView::emitContextMenu col"); |
1892 | emit contextRequest( i, p, col ); | 1913 | emit contextRequest( i, p, col ); |
1893 | emit contextMenu (this, i, p); | 1914 | emit contextMenu (this, i, p); |
1894 | } | 1915 | } |
1895 | 1916 | ||
1896 | void KListView::setAcceptDrops (bool val) | 1917 | void KListView::setAcceptDrops (bool val) |
1897 | { | 1918 | { |
1898 | QListView::setAcceptDrops (val); | 1919 | QListView::setAcceptDrops (val); |
1899 | viewport()->setAcceptDrops (val); | 1920 | viewport()->setAcceptDrops (val); |
1900 | } | 1921 | } |
1901 | 1922 | ||
1902 | int KListView::dropVisualizerWidth () const | 1923 | int KListView::dropVisualizerWidth () const |
1903 | { | 1924 | { |
1904 | return d->mDropVisualizerWidth; | 1925 | return d->mDropVisualizerWidth; |
1905 | } | 1926 | } |
1906 | 1927 | ||
1907 | 1928 | ||
1908 | void KListView::viewportPaintEvent(QPaintEvent *e) | 1929 | void KListView::viewportPaintEvent(QPaintEvent *e) |
1909 | { | 1930 | { |
1910 | QListView::viewportPaintEvent(e); | 1931 | QListView::viewportPaintEvent(e); |
1911 | 1932 | ||
1912 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) | 1933 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) |
1913 | { | 1934 | { |
1914 | QPainter painter(viewport()); | 1935 | QPainter painter(viewport()); |
1915 | 1936 | ||
1916 | // This is where we actually draw the drop-visualizer | 1937 | // This is where we actually draw the drop-visualizer |
1917 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); | 1938 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); |
1918 | } | 1939 | } |
1919 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) | 1940 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) |
1920 | { | 1941 | { |
1921 | QPainter painter(viewport()); | 1942 | QPainter painter(viewport()); |
1922 | 1943 | ||
1923 | qDebug("KListView::viewportPaintEvent has to be verified"); | 1944 | qDebug("KListView::viewportPaintEvent has to be verified"); |
1924 | 1945 | ||
1925 | // This is where we actually draw the drop-highlighter | 1946 | // This is where we actually draw the drop-highlighter |
1926 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), | 1947 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), |
1927 | //US QStyle::Style_FocusAtBorder); | 1948 | //US QStyle::Style_FocusAtBorder); |
1928 | 1949 | ||
1929 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); | 1950 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); |
1930 | 1951 | ||
1931 | 1952 | ||
1932 | } | 1953 | } |
1933 | } | 1954 | } |
1934 | 1955 | ||
1935 | void KListView::setFullWidth() | 1956 | void KListView::setFullWidth() |
1936 | { | 1957 | { |
1937 | setFullWidth(true); | 1958 | setFullWidth(true); |
1938 | } | 1959 | } |
1939 | 1960 | ||
1940 | void KListView::setFullWidth(bool fullWidth) | 1961 | void KListView::setFullWidth(bool fullWidth) |
1941 | { | 1962 | { |
1942 | d->fullWidth = fullWidth; | 1963 | d->fullWidth = fullWidth; |
1943 | //US header()->setStretchEnabled(fullWidth, columns()-1); | 1964 | //US header()->setStretchEnabled(fullWidth, columns()-1); |
1944 | } | 1965 | } |
1945 | 1966 | ||
1946 | bool KListView::fullWidth() const | 1967 | bool KListView::fullWidth() const |
1947 | { | 1968 | { |
1948 | return d->fullWidth; | 1969 | return d->fullWidth; |
1949 | } | 1970 | } |
1950 | 1971 | ||
1951 | int KListView::addColumn(const QString& label, int width) | 1972 | int KListView::addColumn(const QString& label, int width) |
1952 | { | 1973 | { |
1953 | int result = QListView::addColumn(label, width); | 1974 | int result = QListView::addColumn(label, width); |
1954 | if (d->fullWidth) { | 1975 | if (d->fullWidth) { |
1955 | //US header()->setStretchEnabled(false, columns()-2); | 1976 | //US header()->setStretchEnabled(false, columns()-2); |
1956 | //US header()->setStretchEnabled(true, columns()-1); | 1977 | //US header()->setStretchEnabled(true, columns()-1); |
1957 | } | 1978 | } |
1958 | return result; | 1979 | return result; |
1959 | } | 1980 | } |
1960 | 1981 | ||
1961 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) | 1982 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) |
1962 | { | 1983 | { |
1963 | int result = QListView::addColumn(iconset, label, width); | 1984 | int result = QListView::addColumn(iconset, label, width); |
1964 | if (d->fullWidth) { | 1985 | if (d->fullWidth) { |
1965 | //US header()->setStretchEnabled(false, columns()-2); | 1986 | //US header()->setStretchEnabled(false, columns()-2); |
1966 | //US header()->setStretchEnabled(true, columns()-1); | 1987 | //US header()->setStretchEnabled(true, columns()-1); |
1967 | } | 1988 | } |
1968 | return result; | 1989 | return result; |
1969 | } | 1990 | } |
1970 | 1991 | ||
1971 | void KListView::removeColumn(int index) | 1992 | void KListView::removeColumn(int index) |
1972 | { | 1993 | { |
1973 | QListView::removeColumn(index); | 1994 | QListView::removeColumn(index); |
1974 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); | 1995 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); |
1975 | } | 1996 | } |
1976 | 1997 | ||
1977 | void KListView::viewportResizeEvent(QResizeEvent* e) | 1998 | void KListView::viewportResizeEvent(QResizeEvent* e) |
1978 | { | 1999 | { |
1979 | QListView::viewportResizeEvent(e); | 2000 | QListView::viewportResizeEvent(e); |
1980 | } | 2001 | } |
1981 | 2002 | ||
1982 | const QColor &KListView::alternateBackground() const | 2003 | const QColor &KListView::alternateBackground() const |
1983 | { | 2004 | { |
1984 | return d->alternateBackground; | 2005 | return d->alternateBackground; |
1985 | } | 2006 | } |
1986 | 2007 | ||
1987 | void KListView::setAlternateBackground(const QColor &c) | 2008 | void KListView::setAlternateBackground(const QColor &c) |
@@ -2089,103 +2110,112 @@ KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, | |||
2089 | QString label1, QString label2, QString label3, QString label4, | 2110 | QString label1, QString label2, QString label3, QString label4, |
2090 | QString label5, QString label6, QString label7, QString label8) | 2111 | QString label5, QString label6, QString label7, QString label8) |
2091 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 2112 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
2092 | { | 2113 | { |
2093 | init(); | 2114 | init(); |
2094 | } | 2115 | } |
2095 | 2116 | ||
2096 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, | 2117 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, |
2097 | QString label1, QString label2, QString label3, QString label4, | 2118 | QString label1, QString label2, QString label3, QString label4, |
2098 | QString label5, QString label6, QString label7, QString label8) | 2119 | QString label5, QString label6, QString label7, QString label8) |
2099 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 2120 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
2100 | { | 2121 | { |
2101 | init(); | 2122 | init(); |
2102 | } | 2123 | } |
2103 | 2124 | ||
2104 | KListViewItem::~KListViewItem() | 2125 | KListViewItem::~KListViewItem() |
2105 | { | 2126 | { |
2106 | } | 2127 | } |
2107 | 2128 | ||
2108 | void KListViewItem::init() | 2129 | void KListViewItem::init() |
2109 | { | 2130 | { |
2110 | m_known = false; | 2131 | m_known = false; |
2111 | } | 2132 | } |
2112 | 2133 | ||
2113 | const QColor &KListViewItem::backgroundColor() | 2134 | const QColor &KListViewItem::backgroundColor() |
2114 | { | 2135 | { |
2115 | if (isAlternate()) | 2136 | if (isAlternate()) |
2116 | return static_cast< KListView* >(listView())->alternateBackground(); | 2137 | return static_cast< KListView* >(listView())->alternateBackground(); |
2117 | return listView()->viewport()->colorGroup().base(); | 2138 | return listView()->viewport()->colorGroup().base(); |
2118 | } | 2139 | } |
2119 | 2140 | ||
2120 | bool KListViewItem::isAlternate() | 2141 | bool KListViewItem::isAlternate() |
2121 | { | 2142 | { |
2122 | KListView *lv = static_cast<KListView *>(listView()); | 2143 | KListView *lv = static_cast<KListView *>(listView()); |
2123 | if (lv && lv->alternateBackground().isValid()) | 2144 | if (lv && lv->alternateBackground().isValid()) |
2124 | { | 2145 | { |
2125 | KListViewItem *above = 0; | 2146 | KListViewItem *above = 0; |
2126 | //US above = dynamic_cast<KListViewItem *>(itemAbove()); | 2147 | //US above = dynamic_cast<KListViewItem *>(itemAbove()); |
2127 | above = (KListViewItem *)(itemAbove()); | 2148 | above = (KListViewItem *)(itemAbove()); |
2128 | m_known = above ? above->m_known : true; | 2149 | m_known = above ? above->m_known : true; |
2129 | if (m_known) | 2150 | if (m_known) |
2130 | { | 2151 | { |
2131 | m_odd = above ? !above->m_odd : false; | 2152 | m_odd = above ? !above->m_odd : false; |
2132 | } | 2153 | } |
2133 | else | 2154 | else |
2134 | { | 2155 | { |
2135 | KListViewItem *item; | 2156 | KListViewItem *item; |
2136 | bool previous = true; | 2157 | bool previous = true; |
2137 | if (parent()) | 2158 | if (parent()) |
2138 | { | 2159 | { |
2139 | //US item = dynamic_cast<KListViewItem *>(parent()); | 2160 | //US item = dynamic_cast<KListViewItem *>(parent()); |
2140 | item = (KListViewItem *)(parent()); | 2161 | item = (KListViewItem *)(parent()); |
2141 | if (item) | 2162 | if (item) |
2142 | previous = item->m_odd; | 2163 | previous = item->m_odd; |
2143 | //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); | 2164 | //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); |
2144 | item = (KListViewItem *)(parent()->firstChild()); | 2165 | item = (KListViewItem *)(parent()->firstChild()); |
2145 | } | 2166 | } |
2146 | else | 2167 | else |
2147 | { | 2168 | { |
2148 | //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); | 2169 | //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); |
2149 | item = (KListViewItem *)(lv->firstChild()); | 2170 | item = (KListViewItem *)(lv->firstChild()); |
2150 | } | 2171 | } |
2151 | 2172 | ||
2152 | while(item) | 2173 | while(item) |
2153 | { | 2174 | { |
2154 | item->m_odd = previous = !previous; | 2175 | item->m_odd = previous = !previous; |
2155 | item->m_known = true; | 2176 | item->m_known = true; |
2156 | //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); | 2177 | //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); |
2157 | item = (KListViewItem *)(item->nextSibling()); | 2178 | item = (KListViewItem *)(item->nextSibling()); |
2158 | } | 2179 | } |
2159 | } | 2180 | } |
2160 | return m_odd; | 2181 | return m_odd; |
2161 | } | 2182 | } |
2162 | return false; | 2183 | return false; |
2163 | } | 2184 | } |
2164 | 2185 | ||
2165 | void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 2186 | void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
2166 | { | 2187 | { |
2167 | QColorGroup _cg = cg; | 2188 | QColorGroup _cg = cg; |
2168 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 2189 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
2169 | if (pm && !pm->isNull()) | 2190 | if (pm && !pm->isNull()) |
2170 | { | 2191 | { |
2171 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); | 2192 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); |
2172 | QPoint o = p->brushOrigin(); | 2193 | QPoint o = p->brushOrigin(); |
2173 | p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); | 2194 | p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); |
2174 | } | 2195 | } |
2175 | else if (isAlternate()) { | 2196 | else if (isAlternate()) { |
2176 | //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) | 2197 | //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) |
2177 | if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) | 2198 | if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) |
2178 | _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); | 2199 | _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); |
2179 | else | 2200 | else |
2180 | _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); | 2201 | _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); |
2181 | } | 2202 | } |
2182 | QListViewItem::paintCell(p, _cg, column, width, alignment); | 2203 | QListViewItem::paintCell(p, _cg, column, width, alignment); |
2183 | } | 2204 | } |
2184 | 2205 | ||
2206 | //US we do not have a "global KDE" variable to setup singleClick functionality | ||
2207 | void KListView::setSingleClick(bool s) | ||
2208 | { | ||
2209 | d->bUseSingle = s; | ||
2210 | slotSettingsChanged(1); | ||
2211 | // qDebug("KListView::setSingleClick: single %i", d->bUseSingle); | ||
2212 | } | ||
2213 | |||
2214 | |||
2185 | void KListView::virtual_hook( int, void* ) | 2215 | void KListView::virtual_hook( int, void* ) |
2186 | { /*BASE::virtual_hook( id, data );*/ } | 2216 | { /*BASE::virtual_hook( id, data );*/ } |
2187 | 2217 | ||
2188 | //US #include "klistview.moc" | 2218 | //US #include "klistview.moc" |
2189 | //US #include "klistviewlineedit.moc" | 2219 | //US #include "klistviewlineedit.moc" |
2190 | 2220 | ||
2191 | // vim: ts=2 sw=2 et | 2221 | // vim: ts=2 sw=2 et |