-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 @@ -326,853 +326,874 @@ bool KListViewLineEdit::event (QEvent *pe) { QKeyEvent *k = (QKeyEvent *) pe; if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && p->tabOrderedRenaming() && p->itemsRenameable() && !(k->state() & ControlButton || k->state() & AltButton)) { selectNextCell(item, col, (k->key() == Key_Tab && !(k->state() & ShiftButton))); return true; } } return KLineEdit::event(pe); } void KListViewLineEdit::keyPressEvent(QKeyEvent *e) { if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) terminate(true); else if(e->key() == Qt::Key_Escape) terminate(false); else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) { terminate(true); KLineEdit::keyPressEvent(e); } else KLineEdit::keyPressEvent(e); } void KListViewLineEdit::terminate() { terminate(true); } void KListViewLineEdit::terminate(bool commit) { if ( item ) { //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; if (commit) item->setText(col, text()); int c=col; QListViewItem *i=item; col=0; item=0; hide(); // will call focusOutEvent, that's why we set item=0 before emit done(i,c); } } void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) { QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); // Don't let a RMB close the editor if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) terminate(true); } void KListViewLineEdit::paintEvent( QPaintEvent *e ) { KLineEdit::paintEvent( e ); if ( !frame() ) { QPainter p( this ); p.setClipRegion( e->region() ); p.drawRect( rect() ); } } // selection changed -> terminate. As our "item" can be already deleted, // we can't call terminate(false), because that would emit done() with // a dangling pointer to "item". void KListViewLineEdit::slotSelectionChanged() { item = 0; col = 0; hide(); } */ KListView::KListView( QWidget *parent, const char *name ) : QListView( parent, name ), d (new KListViewPrivate (this)) { #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif //US setDragAutoScroll(true); connect( this, SIGNAL( onViewport() ), this, SLOT( slotOnViewport() ) ); connect( this, SIGNAL( onItem( QListViewItem * ) ), this, SLOT( slotOnItem( QListViewItem * ) ) ); connect (this, SIGNAL(contentsMoving(int,int)), this, SLOT(cleanDropVisualizer())); connect (this, SIGNAL(contentsMoving(int,int)), this, SLOT(cleanItemHighlighter())); /*US slotSettingsChanged(KApplication::SETTINGS_MOUSE); if (kapp) { connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); kapp->addKipcEventMask( KIPC::SettingsChanged ); } */ slotSettingsChanged(1); //US do this to initialize the connections connect(&d->autoSelect, SIGNAL( timeout() ), this, SLOT( slotAutoSelect() ) ); connect(&d->dragExpand, SIGNAL( timeout() ), this, SLOT( slotDragExpand() ) ); // context menu handling if (d->showContextMenusOnPress) { connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } else { connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), this, SLOT (emitContextMenu (KListView*, QListViewItem*))); //qDebug("KListView::KListView make alternate color configurable"); //US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); d->alternateBackground = QColor(240, 240, 240); } KListView::~KListView() { delete d; } bool KListView::isExecuteArea( const QPoint& point ) { if ( itemAt( point ) ) return isExecuteArea( point.x() ); return false; } bool KListView::isExecuteArea( int x ) { if( allColumnsShowFocus() ) return true; else { int offset = 0; int width = columnWidth( 0 ); int pos = header()->mapToIndex( 0 ); for ( int index = 0; index < pos; index++ ) offset += columnWidth( header()->mapToSection( index ) ); x += contentsX(); // in case of a horizontal scrollbar return ( x > offset && x < ( offset + width ) ); } } 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 // FIXME(E): Implement for Qt Embedded if( d->pCurrentItem ) { //Shift pressed? if( (keybstate & ShiftMask) ) { bool block = signalsBlocked(); blockSignals( true ); //No Ctrl? Then clear before! if( !(keybstate & ControlMask) ) clearSelection(); bool select = !d->pCurrentItem->isSelected(); bool update = viewport()->isUpdatesEnabled(); viewport()->setUpdatesEnabled( false ); bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); for ( ; lit.current(); ++lit ) { if ( down && lit.current() == d->pCurrentItem ) { d->pCurrentItem->setSelected( select ); break; } if ( !down && lit.current() == previousItem ) { previousItem->setSelected( select ); break; } lit.current()->setSelected( select ); } blockSignals( block ); viewport()->setUpdatesEnabled( update ); triggerUpdate(); emit selectionChanged(); if( selectionMode() == QListView::Single ) emit selectionChanged( d->pCurrentItem ); } else if( (keybstate & ControlMask) ) setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); else { bool block = signalsBlocked(); blockSignals( true ); 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(); d->autoSelect.stop(); if ((d->selectedBySimpleMove) && (d->selectionMode == FileManager) && (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); // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) bool rootDecoClicked = at && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); if (e->button() == LeftButton && !rootDecoClicked) { //Start a drag d->startDragPos = e->pos(); if (at) { d->validDrag = true; d->pressedOnSelected = at->isSelected(); } } 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; } } void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) { if (e->button() == LeftButton) { // If the row was already selected, maybe we want to start an in-place editing if ( d->pressedOnSelected && itemsRenameable() ) { QPoint p( contentsToViewport( e->pos() ) ); QListViewItem *at = itemAt (p); if ( at ) { // 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); emit dropped(e, parent, afterme); emit dropped(this, e, parent, afterme); } } */ } void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) { QPtrList<QListViewItem> items, afterFirsts, afterNows; QListViewItem *current=currentItem(); bool hasMoved=false; for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) { iNext=i->itemBelow(); if (!i->isSelected()) continue; // don't drop an item after itself, or else // it moves to the top of the list if (i==afterme) continue; i->setSelected(false); QListViewItem *afterFirst = i->itemAbove(); if (!hasMoved) { emit aboutToMove(); hasMoved=true; } moveItem(i, parent, afterme); // ###### This should include the new parent !!! -> KDE 3.0 // If you need this right now, have a look at keditbookmarks. emit moved(i, afterFirst, afterme); items.append (i); afterFirsts.append (afterFirst); afterNows.append (afterme); afterme = i; } clearSelection(); for (QListViewItem *i=items.first(); i != 0; i=items.next() ) 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 ) { d->dragExpand.stop(); d->dragOverItem = item; d->dragOverPoint = vp; if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) d->dragExpand.start( QApplication::startDragTime(), true ); } if (dropVisualizer()) { QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); if (tmpRect != d->mOldDropVisualizer) { cleanDropVisualizer(); d->mOldDropVisualizer=tmpRect; viewport()->repaint(tmpRect); } } if (dropHighlighter()) { QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); if (tmpRect != d->mOldDropHighlighter) { cleanItemHighlighter(); d->mOldDropHighlighter=tmpRect; viewport()->repaint(tmpRect); } } } else event->ignore(); */ } void KListView::slotDragExpand() { if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) d->dragOverItem->setOpen( true ); } void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) { d->dragExpand.stop(); cleanDropVisualizer(); cleanItemHighlighter(); } void KListView::cleanDropVisualizer() { if (d->mOldDropVisualizer.isValid()) { QRect rect=d->mOldDropVisualizer; d->mOldDropVisualizer = QRect(); viewport()->repaint(rect, true); } } int KListView::depthToPixels( int depth ) { return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); } void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) { QPoint p (contentsToViewport(pos)); // Get the position to put it in QListViewItem *atpos = itemAt(p); QListViewItem *above; if (!atpos) // put it at the end above = lastItem(); else { // Get the closest item before us ('atpos' or the one above, if any) if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) above = atpos->itemAbove(); else above = atpos; } if (above) { // Now, we know we want to go after "above". But as a child or as a sibling ? // We have to ask the "above" item if it accepts children. if (above->isExpandable()) { // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children if (p.x() >= depthToPixels( above->depth() + 1 ) || (above->isOpen() && above->childCount() > 0) ) { parent = above; after = 0L; return; } } // Ok, there's one more level of complexity. We may want to become a new // sibling, but of an upper-level group, rather than the "above" item QListViewItem * betterAbove = above->parent(); QListViewItem * last = above; while ( betterAbove ) { // We are allowed to become a sibling of "betterAbove" only if we are // after its last child if ( last->nextSibling() == 0 ) { if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) above = betterAbove; // store this one, but don't stop yet, there may be a better one else break; // not enough on the left, so stop last = betterAbove; betterAbove = betterAbove->parent(); // up one level } else break; // we're among the child of betterAbove, not after the last one } } // set as sibling after = above; parent = after ? after->parent() : 0L ; } QListViewItem* KListView::lastChild () const { QListViewItem* lastchild = firstChild(); if (lastchild) for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); return lastchild; } QListViewItem *KListView::lastItem() const { QListViewItem* last = lastChild(); for (QListViewItemIterator it (last); it.current(); ++it) last = it.current(); return last; } KLineEdit *KListView::renameLineEdit() const { //US return d->editor; qDebug("KListView::renameLineEdit returns 0. Might crash"); return 0; } void KListView::startDrag() { qDebug("KListView::startDrag drag&drop not supported yet."); /*US QDragObject *drag = dragObject(); if (!drag) return; if (drag->drag() && drag->target() != viewport()) emit moved(); */ } QDragObject *KListView::dragObject() { if (!currentItem()) return 0; return new QStoredDrag("application/x-qlistviewitem", viewport()); } void KListView::setItemsMovable(bool b) { d->itemsMovable=b; } bool KListView::itemsMovable() const { return d->itemsMovable; } void KListView::setItemsRenameable(bool b) @@ -1699,493 +1720,502 @@ void KListView::fileManagerKeyPressEvent (QKeyEvent* e) for (int i=0; i<items; i++) { if (shiftOrCtrl) nextItem->setSelected(!nextItem->isSelected()); //the end if ((i==items-1) || (nextItem->itemBelow()==0)) { if (shiftOrCtrl) nextItem->setSelected(!nextItem->isSelected()); if (d->selectedBySimpleMove) nextItem->setSelected(true); ensureItemVisible(nextItem); setCurrentItem(nextItem); update(); if ((shiftOrCtrl) || (d->selectedBySimpleMove)) { emit selectionChanged(); } return; } nextItem=nextItem->itemBelow(); } break; case Key_Prior: items=visibleHeight()/item->height(); nextItem=item; if (d->selectedBySimpleMove) item->setSelected(false); if (shiftOrCtrl) { d->selectionDirection=-1; d->selectedBySimpleMove=false; }; for (int i=0; i<items; i++) { if ((nextItem!=item) &&(shiftOrCtrl)) nextItem->setSelected(!nextItem->isSelected()); //the end if ((i==items-1) || (nextItem->itemAbove()==0)) { if (d->selectedBySimpleMove) nextItem->setSelected(true); ensureItemVisible(nextItem); setCurrentItem(nextItem); update(); if ((shiftOrCtrl) || (d->selectedBySimpleMove)) { emit selectionChanged(); } return; } nextItem=nextItem->itemAbove(); } break; case Key_Minus: if ( item->isOpen() ) setOpen( item, FALSE ); break; case Key_Plus: if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) setOpen( item, TRUE ); break; default: bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); if (realKey && selectCurrentItem) item->setSelected(false); //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) QListView::SelectionMode oldSelectionMode = selectionMode(); setSelectionMode (QListView::Multi); QListView::keyPressEvent (e); setSelectionMode (oldSelectionMode); if (realKey && selectCurrentItem) { currentItem()->setSelected(true); emitSelectionChanged=TRUE; } repaintItem2=currentItem(); if (realKey) visItem=currentItem(); break; } if (visItem) ensureItemVisible(visItem); QRect ir; if (repaintItem1) ir = ir.unite( itemRect(repaintItem1) ); if (repaintItem2) ir = ir.unite( itemRect(repaintItem2) ); if ( !ir.isEmpty() ) { // rectangle to be repainted if ( ir.x() < 0 ) ir.moveBy( -ir.x(), 0 ); viewport()->repaint( ir, FALSE ); } /*if (repaintItem1) repaintItem1->repaint(); if (repaintItem2) repaintItem2->repaint();*/ update(); if (emitSelectionChanged) emit selectionChanged(); } void KListView::setSelectionModeExt (SelectionModeExt mode) { d->selectionMode = mode; switch (mode) { case Single: case Multi: case Extended: case NoSelection: setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); break; case FileManager: setSelectionMode (QListView::Extended); break; default: kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; break; } } KListView::SelectionModeExt KListView::selectionModeExt () const { return d->selectionMode; } int KListView::itemIndex( const QListViewItem *item ) const { if ( !item ) return -1; if ( item == firstChild() ) return 0; else { QListViewItemIterator it(firstChild()); uint j = 0; for (; it.current() && it.current() != item; ++it, ++j ); if( !it.current() ) return -1; return j; } } QListViewItem* KListView::itemAtIndex(int index) { if (index<0) return 0; int j(0); for (QListViewItemIterator it=firstChild(); it.current(); it++) { 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()); // This is where we actually draw the drop-visualizer painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); } if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) { QPainter painter(viewport()); qDebug("KListView::viewportPaintEvent has to be verified"); // This is where we actually draw the drop-highlighter //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), //US QStyle::Style_FocusAtBorder); //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); } } void KListView::setFullWidth() { setFullWidth(true); } void KListView::setFullWidth(bool fullWidth) { d->fullWidth = fullWidth; //US header()->setStretchEnabled(fullWidth, columns()-1); } bool KListView::fullWidth() const { return d->fullWidth; } int KListView::addColumn(const QString& label, int width) { int result = QListView::addColumn(label, width); if (d->fullWidth) { //US header()->setStretchEnabled(false, columns()-2); //US header()->setStretchEnabled(true, columns()-1); } return result; } int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) { int result = QListView::addColumn(iconset, label, width); if (d->fullWidth) { //US header()->setStretchEnabled(false, columns()-2); //US header()->setStretchEnabled(true, columns()-1); } return result; } void KListView::removeColumn(int index) { QListView::removeColumn(index); //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); } void KListView::viewportResizeEvent(QResizeEvent* e) { QListView::viewportResizeEvent(e); } const QColor &KListView::alternateBackground() const { return d->alternateBackground; } void KListView::setAlternateBackground(const QColor &c) { d->alternateBackground = c; repaint(); } void KListView::saveLayout(KConfig *config, const QString &group) const { KConfigGroupSaver saver(config, group); QStringList widths, order; for (int i = 0; i < columns(); ++i) { widths << QString::number(columnWidth(i)); order << QString::number(header()->mapToIndex(i)); } config->writeEntry("ColumnWidths", widths); config->writeEntry("ColumnOrder", order); config->writeEntry("SortColumn", d->sortColumn); config->writeEntry("SortAscending", d->sortAscending); } void KListView::restoreLayout(KConfig *config, const QString &group) { KConfigGroupSaver saver(config, group); QStringList cols = config->readListEntry("ColumnWidths"); int i = 0; for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) setColumnWidth(i++, (*it).toInt()); cols = config->readListEntry("ColumnOrder"); i = 0; for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) header()->moveSection(i++, (*it).toInt()); /*US I changed the following code, because hasKey is not available. !!! check if my version is correct if (config->hasKey("SortColumn")) setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); */ QStringList langLst = config->readListEntry( "SortColumn" ); if (!langLst.isEmpty()) setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); } void KListView::setSorting(int column, bool ascending) { d->sortColumn = column; d->sortAscending = ascending; QListView::setSorting(column, ascending); } int KListView::columnSorted(void) const { return d->sortColumn; } bool KListView::ascendingSort(void) const { return d->sortAscending; } KListViewItem::KListViewItem(QListView *parent) : QListViewItem(parent) { init(); } KListViewItem::KListViewItem(QListViewItem *parent) : QListViewItem(parent) { init(); } KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) : QListViewItem(parent, after) { init(); } KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) : QListViewItem(parent, after) { init(); } KListViewItem::KListViewItem(QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } KListViewItem::KListViewItem(QListViewItem *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } KListViewItem::~KListViewItem() { } void KListViewItem::init() { m_known = false; } const QColor &KListViewItem::backgroundColor() { if (isAlternate()) return static_cast< KListView* >(listView())->alternateBackground(); return listView()->viewport()->colorGroup().base(); } bool KListViewItem::isAlternate() { KListView *lv = static_cast<KListView *>(listView()); if (lv && lv->alternateBackground().isValid()) { KListViewItem *above = 0; //US above = dynamic_cast<KListViewItem *>(itemAbove()); above = (KListViewItem *)(itemAbove()); m_known = above ? above->m_known : true; if (m_known) { m_odd = above ? !above->m_odd : false; } else { KListViewItem *item; bool previous = true; if (parent()) { //US item = dynamic_cast<KListViewItem *>(parent()); item = (KListViewItem *)(parent()); if (item) previous = item->m_odd; //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); item = (KListViewItem *)(parent()->firstChild()); } else { //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); item = (KListViewItem *)(lv->firstChild()); } while(item) { item->m_odd = previous = !previous; item->m_known = true; //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); item = (KListViewItem *)(item->nextSibling()); } } return m_odd; } 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 @@ -183,696 +183,701 @@ public: /** * @return the lineedit used for inline renaming. * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit * * @since 3.2 */ KLineEdit* renameLineEdit() const; /** * @returns if it is legal to move items in the list view. True by default. * * @see #setDragEnabled() * @see #setItemsMovable() */ bool itemsMovable() const; /** * @return whether inplace-renaming has been enabled. False by default. * * @see #setItemsRenameable() */ bool itemsRenameable() const; /** * @return whether dragging is enabled. False by default. * * @see #setDragEnabled() */ bool dragEnabled() const; /** * @return true if AutoOpen is enabled (not implemented currently). * * @see #setAutoOpen() */ bool autoOpen() const; /** * @return true if @p column is renamable. * * @see #setRenameable() */ bool isRenameable (int column) const; /** * @return true if drawing of the drop-visualizer has been enabled. True by default. * * @see #setDropVisualizer() */ bool dropVisualizer() const; /** * @return the column for which tooltips are displayed (or -1 if none set). * * @see #setTooltipColumn() */ int tooltipColumn() const; /** * For future expansions. * * Do not use. * @deprecated */ bool createChildren() const; /** * @return true if drawing of the drop-highlighter has been enabled. False by default. * * @see #setDropHighlighter() */ bool dropHighlighter() const; /** * The dropVisualizerWidth defaults to 4. * * @see #setDropVisualizerWidth() * @return the current width of the drop-visualizer. */ int dropVisualizerWidth () const; /** * @return the "extended" selection mode of this listview. * * @see SelectionModeExt * @see setSelectionModeExt */ SelectionModeExt selectionModeExt () const; /** * Returns the index of @p item within the item tree or -1 if * @p item doesn't exist in this list view. This function takes * all items into account not only the visible ones. */ int itemIndex( const QListViewItem *item ) const; /** * Returns the item of @p index within the item tree or 0 if * @p index doesn't exist in this list view. This function takes * all items into account not only the visible ones. */ QListViewItem* itemAtIndex(int index); /** * @deprecated * @see #setFullWidth() */ void setFullWidth(); /** * Let the last column fit exactly all the available width. * * @see #fullWidth() */ void setFullWidth(bool fullWidth); /** * Returns whether the last column is set to fit the available width. * * @see #setFullWidth() */ bool fullWidth() const; /** * Reimplemented for full width support * * @see #removeColumn() */ virtual int addColumn(const QString& label, int width = -1); /** * Reimplemented for full width support */ virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1); /** * Reimplemented for full width support * * @see #addColumn() */ virtual void removeColumn(int index); /** * sets the alternate background background color. * This only has an effect if the items are KListViewItems * * @param c the color to use for every other item. Set to an invalid * colour to disable alternate colours. * * @see #alternateBackground() **/ void setAlternateBackground(const QColor &c); /** * @return the alternate background color * * @see #setAlternateBackground() */ const QColor &alternateBackground() const; /** * Saves the list view's layout (column widtsh, column order, sort column) * to a KConfig group * * @param config the @ref KConfig object to write to * @param group the config group to use */ void saveLayout(KConfig *config, const QString &group) const; /** * Reads the list view's layout from a KConfig group as stored with * @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. */ void executed( QListViewItem *item, const QPoint &pos, int c ); /** * This signal gets emitted whenever the user double clicks into the * listview. * @param item is the pointer to the clicked listview item. * @param pos is the position where the user has clicked, and * @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. * * This signal is more or less here for the sake of completeness. * You should normally not need to use this. In most cases its better * to use @ref #executed() instead. */ void doubleClicked( QListViewItem *item, const QPoint &pos, int c ); void contextRequest( QListViewItem *item, const QPoint &pos, int c ); /** * This signal gets emitted whenever something acceptable is * dropped onto the listview. * * @param e is the drop event itself (it has already been accepted) * @param after is the item after which the drop occured (or 0L, if * the drop was above all items) * * @see #acceptDrop() */ void dropped (QDropEvent * e, QListViewItem *after); /** * This signal gets emitted whenever something acceptable is * dropped onto the listview. * * This is an overloaded version of the above (provided to simplify * processing drops outside of the class). * * @param list is the listview * @param e is the drop event itself (it has already been accepted) * @param after is the item after which the drop occured (or 0L, if * the drop was above all items */ void dropped (KListView* list, QDropEvent* e, QListViewItem* after); /** * This signal gets emitted whenever something acceptable is * dropped onto the listview. * * This function also provides a parent, in the event that your listview * is a tree * @param list is the listview * @param e is the drop event itself (it has already been accepted) * @param parent the item that is to be the parent of the new item * @param after is the item after which the drop occured (or 0L, if * the drop was above all items */ void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after); /** * This signal gets emitted whenever something acceptable is * dropped onto the listview. * * This function also provides a parent, in the event that your listview * is a tree * @param e is the drop event itself (it has already been accepted) * @param parent the item that is to be the parent of the new item * @param after is the item after which the drop occured (or 0L, if * the drop was above all items */ void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after); /** * This signal is emitted when ever the user moves an item in the list via * DnD. * If more than one item is moved at the same time, this signal is only emitted * once. */ void moved(); /** * Connect to this signal if you want to do some preprocessing before * a move is made, for example, to disable sorting * * This is sent only once per each groups of moves. That is, for each * drop that is a move this will be emitted once, before KListView calls * @see moveItem() */ void aboutToMove(); /** * This signal is emitted when ever the user moves an item in the list via * DnD. * If more than one item is moved at the same time, @p afterFirst and * @p afterNow will reflect what was true before the move. * This differs from @ref moved(), so be careful. All the items will have been * moved before @ref moved() is emitted, which is not true in this method. // FIXME * @param item the item that was moved * @param afterFirst the item that parameter item was in before the move, in the list * @param afterNow the item it's currently after. */ void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow); /** * This signal is emitted after all the items have been moved. It reports info for * each and every item moved, in order. The first element in @p items associates * with the first of afterFirst and afterNow. */ void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); /** * This signal gets emitted when an item is renamed via in-place renaming. * * @param item is the renamed item. * @param str is the new value of column @p col. * @param col is the renamed column. */ void itemRenamed(QListViewItem* item, const QString &str, int col); /** * Same as above, but without the extra information. */ void itemRenamed(QListViewItem* item); void signalDelete(); /** * This signal is emitted when the shortcut key for popup-menus is pressed. * * Normally you should not use this, just connect a slot to signal * @ref contextMenu (KListView*, QListViewItem*, const QPoint&) to correctly * handle showing context menus regardless of settings. * * @param list is this listview. * @param item is the @ref currentItem() at the time the key was pressed. May be 0L. */ void menuShortCutPressed (KListView* list, QListViewItem* item); /** * This signal is emitted whenever a context-menu should be shown for item @p i. * It automatically adjusts for all settings involved (Menu key, showMenuOnPress/Click). * * @param l is this listview. * @param i is the item for which the menu should be shown. May be 0L. * @param p is the point at which the menu should be shown. */ void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); public slots: /** * Rename column @p c of @p item. */ virtual void rename(QListViewItem *item, int c); /** * By default, if you called setItemsRenameable(true), * only the first column is renameable. * Use this function to enable the feature on other columns. * * If you want more intelligent (dynamic) selection, * you'll have to derive from KListView, * and override @ref rename() and call only call it * if you want the item to be renamed. */ void setRenameable (int column, bool yesno=true); /** * Set whether items in the list view can be moved. * It is enabled by default. * * @see itemsMovable() */ virtual void setItemsMovable(bool b); /** * Enables inplace-renaming of items. * It is disabled by default. * * @see itemsRenameable() * @see setRenameable() */ virtual void setItemsRenameable(bool b); /** * Enable/Disable the dragging of items. * It is disabled by default. */ virtual void setDragEnabled(bool b); /** * Enable/Disable AutoOpen (not implemented currently). */ virtual void setAutoOpen(bool b); /** * Enable/Disable the drawing of a drop-visualizer * (a bar that shows where a dropped item would be inserted). * It is enabled by default, if dragging is enabled */ virtual void setDropVisualizer(bool b); /** * Set the width of the (default) drop-visualizer. * If you don't call this method, the width is set to 4. */ void setDropVisualizerWidth (int w); /** * Set which column should be used for automatic tooltips. * * @param column is the column for which tooltips will be shown. * Set -1 to disable this feature. */ virtual void setTooltipColumn(int column); /** * Enable/Disable the drawing of a drop-highlighter * (a rectangle around the item under the mouse cursor). * It is disabled by default. */ virtual void setDropHighlighter(bool b); /** * For future expansions. * * Do not use. * @deprecated */ virtual void setCreateChildren(bool b); /** * Set the selection mode. * * A different name was chosen to avoid API-clashes with @ref QListView::setSelectionMode(). */ void setSelectionModeExt (SelectionModeExt mode); /** * Enable/disable tabbing between editable cells * @since 3.1 */ void setTabOrderedRenaming(bool b); /** * Returns whether tab ordered renaming is enabled * @since 3.1 */ bool tabOrderedRenaming() const; protected: /** * Determine whether a drop on position @p p would count as * being above or below the QRect @p rect. * * @param rect is the rectangle we examine. * @param p is the point located in the rectangle, p is assumed to be in * viewport coordinates. */ inline bool below (const QRect& rect, const QPoint& p) { return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); } /** * 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. * * The API is unaffected. */ virtual void leaveEvent( QEvent *e ); /** * @return the tooltip for @p column of @p item. */ virtual QString tooltip(QListViewItem* item, int column) const; /** * @return whether the tooltip for @p column of @p item shall be shown at point @p pos. */ virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void contentsDragMoveEvent (QDragMoveEvent *event); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void contentsMousePressEvent( QMouseEvent *e ); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void contentsMouseMoveEvent( QMouseEvent *e ); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void contentsMouseReleaseEvent (QMouseEvent*); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void contentsDropEvent (QDropEvent*); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void contentsDragEnterEvent (QDragEnterEvent *); /** * @return a dragobject encoding the current selection. * * @see setDragEnabled() */ virtual QDragObject *dragObject(); /** * @return true if the @p event provides some acceptable * format. * A common mistake is to forget the "const" in your reimplementation */ virtual bool acceptDrag (QDropEvent* event) const; /** * Paint the drag line. If painter is null, don't try to :) * * If after == 0 then the marker should be drawn at the top. * * @return the rectangle that you painted to. */ virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); /** * Paint the drag rectangle. If painter is null, don't try to :) * * * @return the rectangle that you painted to. */ virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); /** * This method calls @ref dragObject() and starts the drag. * * Reimplement it to do fancy stuff like setting a pixmap or * using a non-default DragMode */ virtual void startDrag(); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void keyPressEvent (QKeyEvent*); /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void viewportPaintEvent(QPaintEvent*); /** * In FileManager selection mode: explicitely activate the mode * in which the current item is automatically selected. */ void activateAutomaticSelection(); /** * In FileManager selection mode: explicitely deactivate the mode * in which the current item is automatically selected. */ void deactivateAutomaticSelection(); /** * In FileManager selection mode: return whether it is currently in the mode * where the current item is selected automatically. * Returns false if items were selected explicitely, e.g. using the mouse. */ bool automaticSelection() const; /** * Reimplemented for setFullWidth() */ virtual void viewportResizeEvent(QResizeEvent* e); protected slots: /** * Update internal settings whenever the global ones change. |