summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-30 05:09:00 (UTC)
committer zautrix <zautrix>2005-06-30 05:09:00 (UTC)
commit4e850fa7aa99f92676e49466cfccaa5d5e0ec24c (patch) (side-by-side diff)
tree5f0149a356274f475268df69a09a1a63345e9b22
parentba4a6a95356f9a8044257c45347cee8b15667d0c (diff)
downloadkdepimpi-4e850fa7aa99f92676e49466cfccaa5d5e0ec24c.zip
kdepimpi-4e850fa7aa99f92676e49466cfccaa5d5e0ec24c.tar.gz
kdepimpi-4e850fa7aa99f92676e49466cfccaa5d5e0ec24c.tar.bz2
fix
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdeui/klistview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp
index f7d2187..60f3084 100644
--- a/microkde/kdeui/klistview.cpp
+++ b/microkde/kdeui/klistview.cpp
@@ -291,385 +291,385 @@ void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool f
/*US
if ((column = nextCol(p, pi, column + dir, dir)) != -1 ||
(column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 ||
(column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1)
{
if (pi)
{
p->setCurrentItem(pi); // Calls terminate
p->rename(pi, column);
*/
/* Some listviews may override rename() to
* prevent certain items from being renamed,
* if this is done, [m_]item will be NULL
* after the rename() call... try again.
*/
/*US
if (!item)
continue;
break;
}
}
}
while (pi && !item);
}
*/
/*US
#ifdef KeyPress
#undef KeyPress
#endif
bool KListViewLineEdit::event (QEvent *pe)
{
if (pe->type() == QEvent::KeyPress)
{
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 ,bool emulateRightMouse )
: QListView( parent, name ),
d (new KListViewPrivate (this))
{
#ifndef DESKTOP_VERSION
if ( emulateRightMouse )
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");
d->alternateBackground = KGlobalSettings::alternateBackgroundColor();
}
KListView::~KListView()
{
delete d;
}
bool KListView::isExecuteArea( const QPoint& point )
{
if ( itemAt( point ) )
return isExecuteArea( point.x() );
return false;
}
QSize KListView::sizeHint() const
{
//qDebug("KListView::QSize sizeHint() ");
#ifdef DESKTOP_VERSION
- QListView::sizeHint();
+ return QListView::sizeHint();
#else
return QSize ( 40, 40 );
#endif
}
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");
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;
}
}
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
}