author | ulf69 <ulf69> | 2004-10-28 00:07:51 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-28 00:07:51 (UTC) |
commit | 0766b449ccdcc125c18c401d87cc51c277464728 (patch) (side-by-side diff) | |
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 @@ -494,99 +494,116 @@ bool KListView::isExecuteArea( int x ) } } void KListView::slotOnItem( QListViewItem *item ) { QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { d->autoSelect.start( d->autoSelectDelay, true ); d->pCurrentItem = item; } } void KListView::slotOnViewport() { if ( d->bChangeCursorOverItem ) viewport()->unsetCursor(); d->autoSelect.stop(); d->pCurrentItem = 0L; } void KListView::slotSettingsChanged(int category) { //qDebug("KListView::slotSettingsChanged has to be verified"); -/*US + switch (category) { + //US I create my private category (=1) to set the settings + case 1: + d->dragDelay = 2; + //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); + qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); + + disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), + this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); + + if( d->bUseSingle ) + connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), + this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); + + //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); + //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); + + if( !d->bUseSingle || !d->bChangeCursorOverItem ) + viewport()->unsetCursor(); + + break; + + /*US case KApplication::SETTINGS_MOUSE: d->dragDelay = KGlobalSettings::dndEventDelay(); d->bUseSingle = KGlobalSettings::singleClick(); disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); if( d->bUseSingle ) connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); if( !d->bUseSingle || !d->bChangeCursorOverItem ) viewport()->unsetCursor(); break; - case KApplication::SETTINGS_POPUPMENU: d->contextMenuKey = KGlobalSettings::contextMenuKey (); d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); if (d->showContextMenusOnPress) { disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } else { disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } break; + */ default: break; } -*/ - - if( d->bUseSingle ) - connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), - this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); } void KListView::slotAutoSelect() { // check that the item still exists if( itemIndex( d->pCurrentItem ) == -1 ) return; if (!isActiveWindow()) { d->autoSelect.stop(); return; } //Give this widget the keyboard focus. if( !hasFocus() ) setFocus(); QListViewItem* previousItem = currentItem(); setCurrentItem( d->pCurrentItem ); #if 0 #ifndef Q_WS_QWS @@ -637,79 +654,71 @@ void KListView::slotAutoSelect() if( !d->pCurrentItem->isSelected() ) clearSelection(); blockSignals( block ); setSelected( d->pCurrentItem, true ); } } else kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; #endif #endif } void KListView::slotHeaderChanged() { if (d->fullWidth && columns()) { int w = 0; for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); } } -void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c ) +void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) { + // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { // Double click mode ? if ( !d->bUseSingle ) { emit executed( item ); emit executed( item, pos, c ); } else { -#if 0 -#ifndef Q_WS_QWS - // FIXME(E): Implement for Qt Embedded - Window root; - Window child; - int root_x, root_y, win_x, win_y; - uint keybstate; - XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, - &root_x, &root_y, &win_x, &win_y, &keybstate ); - + //US special implementation for embedded systems d->autoSelect.stop(); //Dont emit executed if in SC mode and Shift or Ctrl are pressed - if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { + if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { + // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { + emit executed( item ); emit executed( item, pos, c ); } -#endif -#endif } } } void KListView::focusInEvent( QFocusEvent *fe ) { // kdDebug()<<"KListView::focusInEvent()"<<endl; QListView::focusInEvent( fe ); if ((d->selectedBySimpleMove) && (d->selectionMode == FileManager) && (fe->reason()!=QFocusEvent::Popup) && (fe->reason()!=QFocusEvent::ActiveWindow) && (currentItem()!=0)) { currentItem()->setSelected(true); currentItem()->repaint(); emit selectionChanged(); }; } void KListView::focusOutEvent( QFocusEvent *fe ) { cleanDropVisualizer(); cleanItemHighlighter(); @@ -721,58 +730,59 @@ void KListView::focusOutEvent( QFocusEvent *fe ) && (fe->reason()!=QFocusEvent::Popup) && (fe->reason()!=QFocusEvent::ActiveWindow) && (currentItem()!=0) /*US && (!d->editor->isVisible()) */ ) { currentItem()->setSelected(false); currentItem()->repaint(); emit selectionChanged(); }; QListView::focusOutEvent( fe ); } void KListView::leaveEvent( QEvent *e ) { d->autoSelect.stop(); QListView::leaveEvent( e ); } bool KListView::event( QEvent *e ) { if (e->type() == QEvent::ApplicationPaletteChange) { -qDebug("KListView::event make alternate color configurable"); + //qDebug("KListView::event make alternate color configurable"); //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); d->alternateBackground = QColor(240, 240, 240); } return QListView::event(e); } void KListView::contentsMousePressEvent( QMouseEvent *e ) { + //qDebug("KListView::contentsMousePressEvent"); if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) { bool block = signalsBlocked(); blockSignals( true ); clearSelection(); blockSignals( block ); } else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) { d->selectedBySimpleMove=false; d->selectedUsingMouse=true; if (currentItem()!=0) { currentItem()->setSelected(false); currentItem()->repaint(); // emit selectionChanged(); }; }; QPoint p( contentsToViewport( e->pos() ) ); QListViewItem *at = itemAt (p); @@ -794,49 +804,49 @@ void KListView::contentsMousePressEvent( QMouseEvent *e ) } } QListView::contentsMousePressEvent( e ); } void KListView::contentsMouseMoveEvent( QMouseEvent *e ) { if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { QListView::contentsMouseMoveEvent (e); return; } QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt( vp ); //do we process cursor changes at all? if ( item && d->bChangeCursorOverItem && d->bUseSingle ) { //Cursor moved on a new item or in/out the execute area if( (item != d->pCurrentItem) || (isExecuteArea(vp) != d->cursorInExecuteArea) ) { d->cursorInExecuteArea = isExecuteArea(vp); -qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); + //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); /*US if( d->cursorInExecuteArea ) //cursor moved in execute area viewport()->setCursor( KCursor::handCursor() ); else //cursor moved out of execute area viewport()->unsetCursor(); */ } } bool dragOn = dragEnabled(); QPoint newPos = e->pos(); if (dragOn && d->validDrag && (newPos.x() > d->startDragPos.x()+d->dragDelay || newPos.x() < d->startDragPos.x()-d->dragDelay || newPos.y() > d->startDragPos.y()+d->dragDelay || newPos.y() < d->startDragPos.y()-d->dragDelay)) //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { QListView::contentsMouseReleaseEvent( 0 ); startDrag(); d->startDragPos = QPoint(); d->validDrag = false; } } @@ -855,70 +865,81 @@ void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) bool rootDecoClicked = ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); if (!rootDecoClicked) { int col = header()->mapToLogical( header()->cellAt( p.x() ) ); if ( d->renameable.contains(col) ) rename(at, col); } } } d->pressedOnSelected = false; d->validDrag = false; d->startDragPos = QPoint(); } QListView::contentsMouseReleaseEvent( e ); } void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) { + //qDebug("KListView::contentsMouseDoubleClickEvent"); // We don't want to call the parent method because it does setOpen, // whereas we don't do it in single click mode... (David) //QListView::contentsMouseDoubleClickEvent( e ); QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt( vp ); emit QListView::doubleClicked( item ); // we do it now int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; if( item ) { + //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked"); + emit doubleClicked( item, e->globalPos(), col ); - if( (e->button() == LeftButton) && !d->bUseSingle ) - emitExecute( item, e->globalPos(), col ); + if( (e->button() == LeftButton) && !d->bUseSingle ) { + //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute"); + + emitExecute( e->button(), item, e->globalPos(), col); + } } } void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) { - if( (btn == LeftButton) && item ) - emitExecute(item, pos, c); + //qDebug("KListView::slotMouseButtonClicked"); + + if( (btn == LeftButton) && item ) { + //qDebug("KListView::slotMouseButtonClicked: emitExecute"); + + emitExecute(btn, item, pos, c); + } } void KListView::contentsDropEvent(QDropEvent* e) { qDebug("KListView::contentsDropEvent drag&drop not supported yet"); /*US cleanDropVisualizer(); cleanItemHighlighter(); d->dragExpand.stop(); if (acceptDrag (e)) { e->acceptAction(); QListViewItem *afterme; QListViewItem *parent; findDrop(e->pos(), parent, afterme); if (e->source() == viewport() && itemsMovable()) movableDropEvent(parent, afterme); else { emit dropped(e, afterme); emit dropped(this, e, afterme); @@ -1867,49 +1888,49 @@ QListViewItem* KListView::itemAtIndex(int index) { if (j==index) return it.current(); j++; }; return 0; } void KListView::emitContextMenu (KListView*, QListViewItem* i) { QPoint p; // qDebug("KListView::emitContextMenu "); if (i) p = viewport()->mapToGlobal(itemRect(i).center()); else p = mapToGlobal(rect().center()); emit contextMenu (this, i, p); } void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) { - qDebug("KListView::emitContextMenu col"); + // qDebug("KListView::emitContextMenu col"); emit contextRequest( i, p, col ); emit contextMenu (this, i, p); } void KListView::setAcceptDrops (bool val) { QListView::setAcceptDrops (val); viewport()->setAcceptDrops (val); } int KListView::dropVisualizerWidth () const { return d->mDropVisualizerWidth; } void KListView::viewportPaintEvent(QPaintEvent *e) { QListView::viewportPaintEvent(e); if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) { QPainter painter(viewport()); @@ -2161,31 +2182,40 @@ bool KListViewItem::isAlternate() } return false; } void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup _cg = cg; const QPixmap *pm = listView()->viewport()->backgroundPixmap(); if (pm && !pm->isNull()) { _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); QPoint o = p->brushOrigin(); p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); } else if (isAlternate()) { //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); else _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); } QListViewItem::paintCell(p, _cg, column, width, alignment); } +//US we do not have a "global KDE" variable to setup singleClick functionality +void KListView::setSingleClick(bool s) +{ + d->bUseSingle = s; + slotSettingsChanged(1); + // qDebug("KListView::setSingleClick: single %i", d->bUseSingle); +} + + void KListView::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } //US #include "klistview.moc" //US #include "klistviewlineedit.moc" // vim: ts=2 sw=2 et 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 @@ -351,48 +351,52 @@ public: * @ref #saveLayout * * @param config the @ref KConfig object to read from * @param group the config group to use */ void restoreLayout(KConfig *config, const QString &group); /** * Reimplemented to remember the current sort column and order. * @param column is the column to be sorted, or -1 to sort in order of * insertion * @param whether to sort ascending (or descending) */ virtual void setSorting(int column, bool ascending = true); /** * @return the currently sorted column, or -1 if none is sorted */ int columnSorted(void) const; /** * @return whether the current sort is ascending (or descending) */ bool ascendingSort(void) const; + //US we do not have a "global KDE" variable to setup singleClick functionality + void setSingleClick(bool s); + + signals: /** * This signal is emitted whenever the user executes an listview item. * That means depending on the KDE wide Single Click/Double Click * setting the user clicked or double clicked on that item. * @param item is the pointer to the executed listview item. * * Note that you may not delete any @ref QListViewItem objects in slots * connected to this signal. */ void executed( QListViewItem *item ); /** * This signal is emitted whenever the user executes an listview item. * That means depending on the KDE wide Single Click/Double Click * setting the user clicked or double clicked on that item. * @param item is the pointer to the executed listview item. * @param pos is the position where the user has clicked * @param c is the column into which the user clicked. * * Note that you may not delete any @ref QListViewItem objects in slots * connected to this signal. */ @@ -662,49 +666,50 @@ protected: /** * An overloaded version of below(const QRect&, const QPoint&). * * It differs from the above only in what arguments it takes. * * @param i the item whose rect() is passed to the above function. * @param p is translated from contents coordinates to viewport coordinates * before being passed to the above function. */ inline bool below (QListViewItem* i, const QPoint& p) { return below (itemRect(i), contentsToViewport(p)); } /** * Reimplemented to reload the alternate background in palette changes. * @internal */ virtual bool event( QEvent * ); /** * Emit signal @ref #executed. * @internal */ - void emitExecute( QListViewItem *item, const QPoint &pos, int c ); + //US I added buttonstate to pass the current keyboard status + void emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void focusInEvent(QFocusEvent* fe); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void focusOutEvent( QFocusEvent *fe ); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * |