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 | |
parent | 5afbc6ae0908ce12fd5abb1c4eadf9c61a01503c (diff) | |
download | kdepimpi-0766b449ccdcc125c18c401d87cc51c277464728.zip kdepimpi-0766b449ccdcc125c18c401d87cc51c277464728.tar.gz kdepimpi-0766b449ccdcc125c18c401d87cc51c277464728.tar.bz2 |
bugfix: KListView did not recognize singleclicks
-rw-r--r-- | microkde/kdeui/klistview.cpp | 86 | ||||
-rw-r--r-- | microkde/kdeui/klistview.h | 7 |
2 files changed, 64 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 | |||
@@ -515,10 +515,32 @@ void KListView::slotOnViewport() | |||
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(); |
@@ -537,7 +559,6 @@ void KListView::slotSettingsChanged(int category) | |||
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 (); |
@@ -557,15 +578,11 @@ void KListView::slotSettingsChanged(int category) | |||
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 | |||
566 | if( d->bUseSingle ) | ||
567 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | ||
568 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | ||
569 | 586 | ||
570 | } | 587 | } |
571 | 588 | ||
@@ -658,8 +675,9 @@ void KListView::slotHeaderChanged() | |||
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 ? |
@@ -670,25 +688,16 @@ void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int 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 | } |
@@ -742,7 +751,7 @@ void KListView::leaveEvent( QEvent *e ) | |||
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 | } |
@@ -752,6 +761,7 @@ qDebug("KListView::event make alternate color configurable"); | |||
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(); |
@@ -815,7 +825,7 @@ void KListView::contentsMouseMoveEvent( QMouseEvent *e ) | |||
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() ); |
@@ -876,6 +886,7 @@ void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) | |||
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 ); |
@@ -887,17 +898,27 @@ void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) | |||
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) |
@@ -1888,7 +1909,7 @@ void KListView::emitContextMenu (KListView*, QListViewItem* i) | |||
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 | } |
@@ -2182,6 +2203,15 @@ void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in | |||
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 | ||
diff --git a/microkde/kdeui/klistview.h b/microkde/kdeui/klistview.h index 8d933f6..d559ce7 100644 --- a/microkde/kdeui/klistview.h +++ b/microkde/kdeui/klistview.h | |||
@@ -372,6 +372,10 @@ public: | |||
372 | */ | 372 | */ |
373 | bool ascendingSort(void) const; | 373 | bool ascendingSort(void) const; |
374 | 374 | ||
375 | //US we do not have a "global KDE" variable to setup singleClick functionality | ||
376 | void setSingleClick(bool s); | ||
377 | |||
378 | |||
375 | signals: | 379 | signals: |
376 | 380 | ||
377 | /** | 381 | /** |
@@ -683,7 +687,8 @@ protected: | |||
683 | * Emit signal @ref #executed. | 687 | * Emit signal @ref #executed. |
684 | * @internal | 688 | * @internal |
685 | */ | 689 | */ |
686 | void emitExecute( QListViewItem *item, const QPoint &pos, int c ); | 690 | //US I added buttonstate to pass the current keyboard status |
691 | void emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c); | ||
687 | 692 | ||
688 | /** | 693 | /** |
689 | * Reimplemented for internal reasons. | 694 | * Reimplemented for internal reasons. |