summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/klistview.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdeui/klistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/klistview.cpp88
1 files changed, 59 insertions, 29 deletions
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp
index 3c809b4..32483bb 100644
--- a/microkde/kdeui/klistview.cpp
+++ b/microkde/kdeui/klistview.cpp
@@ -494,100 +494,117 @@ 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
// FIXME(E): Implement for Qt Embedded
@@ -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);
@@ -962,49 +983,49 @@ void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* 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();
@@ -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