-rw-r--r-- | microkde/kdeui/klistview.cpp | 88 | ||||
-rw-r--r-- | microkde/kdeui/klistview.h | 7 |
2 files changed, 65 insertions, 30 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 @@ -506,76 +506,93 @@ void KListView::slotOnItem( QListViewItem *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; @@ -649,55 +666,47 @@ void KListView::slotAutoSelect() } 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) @@ -733,34 +742,35 @@ void KListView::focusOutEvent( QFocusEvent *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; @@ -806,25 +816,25 @@ void KListView::contentsMouseMoveEvent( QMouseEvent *e ) 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 && @@ -867,46 +877,57 @@ void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) } } 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)) { @@ -974,25 +995,25 @@ void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) i->setSelected(true); if (current) setCurrentItem(current); emit moved(items,afterFirsts,afterNows); if (firstChild()) emit moved(); } void KListView::contentsDragMoveEvent(QDragMoveEvent *event) { -qDebug("KListView::contentsDropEvent drag&drop not supported yet"); + qDebug("KListView::contentsDropEvent drag&drop not supported yet"); /*US if (acceptDrag(event)) { event->acceptAction(); //Clean up the view findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); QPoint vp = contentsToViewport( event->pos() ); QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; if ( item != d->dragOverItem ) { @@ -1879,25 +1900,25 @@ void KListView::emitContextMenu (KListView*, QListViewItem* i) // 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 { @@ -2173,19 +2194,28 @@ void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in 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 @@ -363,24 +363,28 @@ public: 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 ); @@ -674,25 +678,26 @@ protected: } /** * 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. |