-rw-r--r-- | microkde/kdeui/klistview.cpp | 2 |
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 | |||
@@ -227,513 +227,513 @@ void KListViewLineEdit::load(QListViewItem *i, int c) | |||
227 | */ | 227 | */ |
228 | 228 | ||
229 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) | 229 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) |
230 | { | 230 | { |
231 | if (pi) | 231 | if (pi) |
232 | { | 232 | { |
233 | //Find the next renameable column in the current row | 233 | //Find the next renameable column in the current row |
234 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) | 234 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) |
235 | if (pl->isRenameable(start)) | 235 | if (pl->isRenameable(start)) |
236 | return start; | 236 | return start; |
237 | } | 237 | } |
238 | 238 | ||
239 | return -1; | 239 | return -1; |
240 | } | 240 | } |
241 | 241 | ||
242 | static QListViewItem *prevItem (QListViewItem *pi) | 242 | static QListViewItem *prevItem (QListViewItem *pi) |
243 | { | 243 | { |
244 | QListViewItem *pa = pi->itemAbove(); | 244 | QListViewItem *pa = pi->itemAbove(); |
245 | 245 | ||
246 | /*Does what the QListViewItem::previousSibling() | 246 | /*Does what the QListViewItem::previousSibling() |
247 | *of my dreams would do. | 247 | *of my dreams would do. |
248 | */ | 248 | */ |
249 | if (pa && pa->parent() == pi->parent()) | 249 | if (pa && pa->parent() == pi->parent()) |
250 | return pa; | 250 | return pa; |
251 | 251 | ||
252 | return NULL; | 252 | return NULL; |
253 | } | 253 | } |
254 | 254 | ||
255 | static QListViewItem *lastQChild (QListViewItem *pi) | 255 | static QListViewItem *lastQChild (QListViewItem *pi) |
256 | { | 256 | { |
257 | if (pi) | 257 | if (pi) |
258 | { | 258 | { |
259 | /*Since there's no QListViewItem::lastChild(). | 259 | /*Since there's no QListViewItem::lastChild(). |
260 | *This finds the last sibling for the given | 260 | *This finds the last sibling for the given |
261 | *item. | 261 | *item. |
262 | */ | 262 | */ |
263 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) | 263 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) |
264 | pi = pt; | 264 | pi = pt; |
265 | } | 265 | } |
266 | 266 | ||
267 | return pi; | 267 | return pi; |
268 | } | 268 | } |
269 | /*US | 269 | /*US |
270 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) | 270 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) |
271 | { | 271 | { |
272 | const int ncols = p->columns(); | 272 | const int ncols = p->columns(); |
273 | const int dir = forward ? +1 : -1; | 273 | const int dir = forward ? +1 : -1; |
274 | const int restart = forward ? 0 : (ncols - 1); | 274 | const int restart = forward ? 0 : (ncols - 1); |
275 | QListViewItem *top = (pitem && pitem->parent()) | 275 | QListViewItem *top = (pitem && pitem->parent()) |
276 | ? pitem->parent()->firstChild() | 276 | ? pitem->parent()->firstChild() |
277 | : p->firstChild(); | 277 | : p->firstChild(); |
278 | QListViewItem *pi = pitem; | 278 | QListViewItem *pi = pitem; |
279 | 279 | ||
280 | terminate(); //Save current changes | 280 | terminate(); //Save current changes |
281 | 281 | ||
282 | do | 282 | do |
283 | { | 283 | { |
284 | */ | 284 | */ |
285 | /*Check the rest of the current row for an editable column, | 285 | /*Check the rest of the current row for an editable column, |
286 | *if that fails, check the entire next/previous row. The | 286 | *if that fails, check the entire next/previous row. The |
287 | *last case goes back to the first item in the current branch | 287 | *last case goes back to the first item in the current branch |
288 | *or the last item in the current branch depending on the | 288 | *or the last item in the current branch depending on the |
289 | *direction. | 289 | *direction. |
290 | */ | 290 | */ |
291 | /*US | 291 | /*US |
292 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || | 292 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || |
293 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || | 293 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || |
294 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) | 294 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) |
295 | { | 295 | { |
296 | if (pi) | 296 | if (pi) |
297 | { | 297 | { |
298 | p->setCurrentItem(pi); //Calls terminate | 298 | p->setCurrentItem(pi); //Calls terminate |
299 | p->rename(pi, column); | 299 | p->rename(pi, column); |
300 | */ | 300 | */ |
301 | /*Some listviews may override rename() to | 301 | /*Some listviews may override rename() to |
302 | *prevent certain items from being renamed, | 302 | *prevent certain items from being renamed, |
303 | *if this is done, [m_]item will be NULL | 303 | *if this is done, [m_]item will be NULL |
304 | *after the rename() call... try again. | 304 | *after the rename() call... try again. |
305 | */ | 305 | */ |
306 | /*US | 306 | /*US |
307 | if (!item) | 307 | if (!item) |
308 | continue; | 308 | continue; |
309 | 309 | ||
310 | break; | 310 | break; |
311 | } | 311 | } |
312 | } | 312 | } |
313 | } | 313 | } |
314 | while (pi && !item); | 314 | while (pi && !item); |
315 | } | 315 | } |
316 | */ | 316 | */ |
317 | 317 | ||
318 | /*US | 318 | /*US |
319 | #ifdef KeyPress | 319 | #ifdef KeyPress |
320 | #undef KeyPress | 320 | #undef KeyPress |
321 | #endif | 321 | #endif |
322 | 322 | ||
323 | bool KListViewLineEdit::event (QEvent *pe) | 323 | bool KListViewLineEdit::event (QEvent *pe) |
324 | { | 324 | { |
325 | if (pe->type() == QEvent::KeyPress) | 325 | if (pe->type() == QEvent::KeyPress) |
326 | { | 326 | { |
327 | QKeyEvent *k = (QKeyEvent *) pe; | 327 | QKeyEvent *k = (QKeyEvent *) pe; |
328 | 328 | ||
329 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && | 329 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && |
330 | p->tabOrderedRenaming() && p->itemsRenameable() && | 330 | p->tabOrderedRenaming() && p->itemsRenameable() && |
331 | !(k->state() & ControlButton || k->state() & AltButton)) | 331 | !(k->state() & ControlButton || k->state() & AltButton)) |
332 | { | 332 | { |
333 | selectNextCell(item, col, | 333 | selectNextCell(item, col, |
334 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); | 334 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); |
335 | return true; | 335 | return true; |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | return KLineEdit::event(pe); | 339 | return KLineEdit::event(pe); |
340 | } | 340 | } |
341 | 341 | ||
342 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) | 342 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) |
343 | { | 343 | { |
344 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) | 344 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) |
345 | terminate(true); | 345 | terminate(true); |
346 | else if(e->key() == Qt::Key_Escape) | 346 | else if(e->key() == Qt::Key_Escape) |
347 | terminate(false); | 347 | terminate(false); |
348 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) | 348 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) |
349 | { | 349 | { |
350 | terminate(true); | 350 | terminate(true); |
351 | KLineEdit::keyPressEvent(e); | 351 | KLineEdit::keyPressEvent(e); |
352 | } | 352 | } |
353 | else | 353 | else |
354 | KLineEdit::keyPressEvent(e); | 354 | KLineEdit::keyPressEvent(e); |
355 | } | 355 | } |
356 | 356 | ||
357 | void KListViewLineEdit::terminate() | 357 | void KListViewLineEdit::terminate() |
358 | { | 358 | { |
359 | terminate(true); | 359 | terminate(true); |
360 | } | 360 | } |
361 | 361 | ||
362 | void KListViewLineEdit::terminate(bool commit) | 362 | void KListViewLineEdit::terminate(bool commit) |
363 | { | 363 | { |
364 | if ( item ) | 364 | if ( item ) |
365 | { | 365 | { |
366 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; | 366 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; |
367 | if (commit) | 367 | if (commit) |
368 | item->setText(col, text()); | 368 | item->setText(col, text()); |
369 | int c=col; | 369 | int c=col; |
370 | QListViewItem *i=item; | 370 | QListViewItem *i=item; |
371 | col=0; | 371 | col=0; |
372 | item=0; | 372 | item=0; |
373 | hide(); // will call focusOutEvent, that's why we set item=0 before | 373 | hide(); // will call focusOutEvent, that's why we set item=0 before |
374 | emit done(i,c); | 374 | emit done(i,c); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) | 378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) |
379 | { | 379 | { |
380 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); | 380 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); |
381 | // Don't let a RMB close the editor | 381 | // Don't let a RMB close the editor |
382 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) | 382 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) |
383 | terminate(true); | 383 | terminate(true); |
384 | } | 384 | } |
385 | 385 | ||
386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) | 386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) |
387 | { | 387 | { |
388 | KLineEdit::paintEvent( e ); | 388 | KLineEdit::paintEvent( e ); |
389 | 389 | ||
390 | if ( !frame() ) { | 390 | if ( !frame() ) { |
391 | QPainter p( this ); | 391 | QPainter p( this ); |
392 | p.setClipRegion( e->region() ); | 392 | p.setClipRegion( e->region() ); |
393 | p.drawRect( rect() ); | 393 | p.drawRect( rect() ); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | 396 | ||
397 | // selection changed -> terminate. As our "item" can be already deleted, | 397 | // selection changed -> terminate. As our "item" can be already deleted, |
398 | // we can't call terminate(false), because that would emit done() with | 398 | // we can't call terminate(false), because that would emit done() with |
399 | // a dangling pointer to "item". | 399 | // a dangling pointer to "item". |
400 | void KListViewLineEdit::slotSelectionChanged() | 400 | void KListViewLineEdit::slotSelectionChanged() |
401 | { | 401 | { |
402 | item = 0; | 402 | item = 0; |
403 | col = 0; | 403 | col = 0; |
404 | hide(); | 404 | hide(); |
405 | } | 405 | } |
406 | */ | 406 | */ |
407 | 407 | ||
408 | KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) | 408 | KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) |
409 | : QListView( parent, name ), | 409 | : QListView( parent, name ), |
410 | d (new KListViewPrivate (this)) | 410 | d (new KListViewPrivate (this)) |
411 | { | 411 | { |
412 | #ifndef DESKTOP_VERSION | 412 | #ifndef DESKTOP_VERSION |
413 | if ( emulateRightMouse ) | 413 | if ( emulateRightMouse ) |
414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
415 | #endif | 415 | #endif |
416 | //US setDragAutoScroll(true); | 416 | //US setDragAutoScroll(true); |
417 | 417 | ||
418 | connect( this, SIGNAL( onViewport() ), | 418 | connect( this, SIGNAL( onViewport() ), |
419 | this, SLOT( slotOnViewport() ) ); | 419 | this, SLOT( slotOnViewport() ) ); |
420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), | 420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), |
421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); | 421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); |
422 | 422 | ||
423 | connect (this, SIGNAL(contentsMoving(int,int)), | 423 | connect (this, SIGNAL(contentsMoving(int,int)), |
424 | this, SLOT(cleanDropVisualizer())); | 424 | this, SLOT(cleanDropVisualizer())); |
425 | connect (this, SIGNAL(contentsMoving(int,int)), | 425 | connect (this, SIGNAL(contentsMoving(int,int)), |
426 | this, SLOT(cleanItemHighlighter())); | 426 | this, SLOT(cleanItemHighlighter())); |
427 | 427 | ||
428 | /*US | 428 | /*US |
429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); | 429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); |
430 | 430 | ||
431 | if (kapp) | 431 | if (kapp) |
432 | { | 432 | { |
433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); | 433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); |
434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); | 434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); |
435 | } | 435 | } |
436 | */ | 436 | */ |
437 | slotSettingsChanged(1); //US do this to initialize the connections | 437 | slotSettingsChanged(1); //US do this to initialize the connections |
438 | 438 | ||
439 | 439 | ||
440 | connect(&d->autoSelect, SIGNAL( timeout() ), | 440 | connect(&d->autoSelect, SIGNAL( timeout() ), |
441 | this, SLOT( slotAutoSelect() ) ); | 441 | this, SLOT( slotAutoSelect() ) ); |
442 | connect(&d->dragExpand, SIGNAL( timeout() ), | 442 | connect(&d->dragExpand, SIGNAL( timeout() ), |
443 | this, SLOT( slotDragExpand() ) ); | 443 | this, SLOT( slotDragExpand() ) ); |
444 | 444 | ||
445 | // context menu handling | 445 | // context menu handling |
446 | if (d->showContextMenusOnPress) | 446 | if (d->showContextMenusOnPress) |
447 | { | 447 | { |
448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
450 | } | 450 | } |
451 | else | 451 | else |
452 | { | 452 | { |
453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
455 | } | 455 | } |
456 | 456 | ||
457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), | 457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), |
458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); | 458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); |
459 | 459 | ||
460 | 460 | ||
461 | //qDebug("KListView::KListView make alternate color configurable"); | 461 | //qDebug("KListView::KListView make alternate color configurable"); |
462 | d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); | 462 | d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | 466 | ||
467 | KListView::~KListView() | 467 | KListView::~KListView() |
468 | { | 468 | { |
469 | delete d; | 469 | delete d; |
470 | } | 470 | } |
471 | 471 | ||
472 | bool KListView::isExecuteArea( const QPoint& point ) | 472 | bool KListView::isExecuteArea( const QPoint& point ) |
473 | { | 473 | { |
474 | if ( itemAt( point ) ) | 474 | if ( itemAt( point ) ) |
475 | return isExecuteArea( point.x() ); | 475 | return isExecuteArea( point.x() ); |
476 | 476 | ||
477 | return false; | 477 | return false; |
478 | } | 478 | } |
479 | QSize KListView::sizeHint() const | 479 | QSize KListView::sizeHint() const |
480 | { | 480 | { |
481 | //qDebug("KListView::QSize sizeHint() "); | 481 | //qDebug("KListView::QSize sizeHint() "); |
482 | #ifdef DESKTOP_VERSION | 482 | #ifdef DESKTOP_VERSION |
483 | QListView::sizeHint(); | 483 | return QListView::sizeHint(); |
484 | #else | 484 | #else |
485 | return QSize ( 40, 40 ); | 485 | return QSize ( 40, 40 ); |
486 | #endif | 486 | #endif |
487 | 487 | ||
488 | } | 488 | } |
489 | bool KListView::isExecuteArea( int x ) | 489 | bool KListView::isExecuteArea( int x ) |
490 | { | 490 | { |
491 | if( allColumnsShowFocus() ) | 491 | if( allColumnsShowFocus() ) |
492 | return true; | 492 | return true; |
493 | else { | 493 | else { |
494 | int offset = 0; | 494 | int offset = 0; |
495 | int width = columnWidth( 0 ); | 495 | int width = columnWidth( 0 ); |
496 | int pos = header()->mapToIndex( 0 ); | 496 | int pos = header()->mapToIndex( 0 ); |
497 | 497 | ||
498 | for ( int index = 0; index < pos; index++ ) | 498 | for ( int index = 0; index < pos; index++ ) |
499 | offset += columnWidth( header()->mapToSection( index ) ); | 499 | offset += columnWidth( header()->mapToSection( index ) ); |
500 | 500 | ||
501 | x += contentsX(); // in case of a horizontal scrollbar | 501 | x += contentsX(); // in case of a horizontal scrollbar |
502 | return ( x > offset && x < ( offset + width ) ); | 502 | return ( x > offset && x < ( offset + width ) ); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | void KListView::slotOnItem( QListViewItem *item ) | 506 | void KListView::slotOnItem( QListViewItem *item ) |
507 | { | 507 | { |
508 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); | 508 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); |
509 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { | 509 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { |
510 | d->autoSelect.start( d->autoSelectDelay, true ); | 510 | d->autoSelect.start( d->autoSelectDelay, true ); |
511 | d->pCurrentItem = item; | 511 | d->pCurrentItem = item; |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | void KListView::slotOnViewport() | 515 | void KListView::slotOnViewport() |
516 | { | 516 | { |
517 | if ( d->bChangeCursorOverItem ) | 517 | if ( d->bChangeCursorOverItem ) |
518 | viewport()->unsetCursor(); | 518 | viewport()->unsetCursor(); |
519 | 519 | ||
520 | d->autoSelect.stop(); | 520 | d->autoSelect.stop(); |
521 | d->pCurrentItem = 0L; | 521 | d->pCurrentItem = 0L; |
522 | } | 522 | } |
523 | 523 | ||
524 | void KListView::slotSettingsChanged(int category) | 524 | void KListView::slotSettingsChanged(int category) |
525 | { | 525 | { |
526 | //qDebug("KListView::slotSettingsChanged has to be verified"); | 526 | //qDebug("KListView::slotSettingsChanged has to be verified"); |
527 | 527 | ||
528 | 528 | ||
529 | switch (category) | 529 | switch (category) |
530 | { | 530 | { |
531 | //US I create my private category (=1) to set the settings | 531 | //US I create my private category (=1) to set the settings |
532 | case 1: | 532 | case 1: |
533 | d->dragDelay = 2; | 533 | d->dragDelay = 2; |
534 | //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); | 534 | //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); |
535 | // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); | 535 | // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); |
536 | 536 | ||
537 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 537 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
538 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 538 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
539 | 539 | ||
540 | if( d->bUseSingle ) | 540 | if( d->bUseSingle ) |
541 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 541 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
542 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 542 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
543 | 543 | ||
544 | //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 544 | //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
545 | //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 545 | //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
546 | 546 | ||
547 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 547 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
548 | viewport()->unsetCursor(); | 548 | viewport()->unsetCursor(); |
549 | 549 | ||
550 | break; | 550 | break; |
551 | 551 | ||
552 | /*US | 552 | /*US |
553 | case KApplication::SETTINGS_MOUSE: | 553 | case KApplication::SETTINGS_MOUSE: |
554 | d->dragDelay = KGlobalSettings::dndEventDelay(); | 554 | d->dragDelay = KGlobalSettings::dndEventDelay(); |
555 | d->bUseSingle = KGlobalSettings::singleClick(); | 555 | d->bUseSingle = KGlobalSettings::singleClick(); |
556 | 556 | ||
557 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 557 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
558 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 558 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
559 | 559 | ||
560 | if( d->bUseSingle ) | 560 | if( d->bUseSingle ) |
561 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 561 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
562 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 562 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
563 | 563 | ||
564 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 564 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
565 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 565 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
566 | 566 | ||
567 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 567 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
568 | viewport()->unsetCursor(); | 568 | viewport()->unsetCursor(); |
569 | 569 | ||
570 | break; | 570 | break; |
571 | case KApplication::SETTINGS_POPUPMENU: | 571 | case KApplication::SETTINGS_POPUPMENU: |
572 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); | 572 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); |
573 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); | 573 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); |
574 | 574 | ||
575 | if (d->showContextMenusOnPress) | 575 | if (d->showContextMenusOnPress) |
576 | { | 576 | { |
577 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 577 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
578 | 578 | ||
579 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 579 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
580 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 580 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
581 | } | 581 | } |
582 | else | 582 | else |
583 | { | 583 | { |
584 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 584 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
585 | 585 | ||
586 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 586 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
587 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 587 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
588 | } | 588 | } |
589 | break; | 589 | break; |
590 | */ | 590 | */ |
591 | 591 | ||
592 | default: | 592 | default: |
593 | break; | 593 | break; |
594 | } | 594 | } |
595 | 595 | ||
596 | } | 596 | } |
597 | 597 | ||
598 | void KListView::slotAutoSelect() | 598 | void KListView::slotAutoSelect() |
599 | { | 599 | { |
600 | // check that the item still exists | 600 | // check that the item still exists |
601 | if( itemIndex( d->pCurrentItem ) == -1 ) | 601 | if( itemIndex( d->pCurrentItem ) == -1 ) |
602 | return; | 602 | return; |
603 | 603 | ||
604 | if (!isActiveWindow()) | 604 | if (!isActiveWindow()) |
605 | { | 605 | { |
606 | d->autoSelect.stop(); | 606 | d->autoSelect.stop(); |
607 | return; | 607 | return; |
608 | } | 608 | } |
609 | 609 | ||
610 | //Give this widget the keyboard focus. | 610 | //Give this widget the keyboard focus. |
611 | if( !hasFocus() ) | 611 | if( !hasFocus() ) |
612 | setFocus(); | 612 | setFocus(); |
613 | 613 | ||
614 | QListViewItem* previousItem = currentItem(); | 614 | QListViewItem* previousItem = currentItem(); |
615 | setCurrentItem( d->pCurrentItem ); | 615 | setCurrentItem( d->pCurrentItem ); |
616 | 616 | ||
617 | #if 0 | 617 | #if 0 |
618 | #ifndef Q_WS_QWS | 618 | #ifndef Q_WS_QWS |
619 | // FIXME(E): Implement for Qt Embedded | 619 | // FIXME(E): Implement for Qt Embedded |
620 | if( d->pCurrentItem ) { | 620 | if( d->pCurrentItem ) { |
621 | //Shift pressed? | 621 | //Shift pressed? |
622 | if( (keybstate & ShiftMask) ) { | 622 | if( (keybstate & ShiftMask) ) { |
623 | bool block = signalsBlocked(); | 623 | bool block = signalsBlocked(); |
624 | blockSignals( true ); | 624 | blockSignals( true ); |
625 | 625 | ||
626 | //No Ctrl? Then clear before! | 626 | //No Ctrl? Then clear before! |
627 | if( !(keybstate & ControlMask) ) | 627 | if( !(keybstate & ControlMask) ) |
628 | clearSelection(); | 628 | clearSelection(); |
629 | 629 | ||
630 | bool select = !d->pCurrentItem->isSelected(); | 630 | bool select = !d->pCurrentItem->isSelected(); |
631 | bool update = viewport()->isUpdatesEnabled(); | 631 | bool update = viewport()->isUpdatesEnabled(); |
632 | viewport()->setUpdatesEnabled( false ); | 632 | viewport()->setUpdatesEnabled( false ); |
633 | 633 | ||
634 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); | 634 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); |
635 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); | 635 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); |
636 | for ( ; lit.current(); ++lit ) { | 636 | for ( ; lit.current(); ++lit ) { |
637 | if ( down && lit.current() == d->pCurrentItem ) { | 637 | if ( down && lit.current() == d->pCurrentItem ) { |
638 | d->pCurrentItem->setSelected( select ); | 638 | d->pCurrentItem->setSelected( select ); |
639 | break; | 639 | break; |
640 | } | 640 | } |
641 | if ( !down && lit.current() == previousItem ) { | 641 | if ( !down && lit.current() == previousItem ) { |
642 | previousItem->setSelected( select ); | 642 | previousItem->setSelected( select ); |
643 | break; | 643 | break; |
644 | } | 644 | } |
645 | lit.current()->setSelected( select ); | 645 | lit.current()->setSelected( select ); |
646 | } | 646 | } |
647 | 647 | ||
648 | blockSignals( block ); | 648 | blockSignals( block ); |
649 | viewport()->setUpdatesEnabled( update ); | 649 | viewport()->setUpdatesEnabled( update ); |
650 | triggerUpdate(); | 650 | triggerUpdate(); |
651 | 651 | ||
652 | emit selectionChanged(); | 652 | emit selectionChanged(); |
653 | 653 | ||
654 | if( selectionMode() == QListView::Single ) | 654 | if( selectionMode() == QListView::Single ) |
655 | emit selectionChanged( d->pCurrentItem ); | 655 | emit selectionChanged( d->pCurrentItem ); |
656 | } | 656 | } |
657 | else if( (keybstate & ControlMask) ) | 657 | else if( (keybstate & ControlMask) ) |
658 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); | 658 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); |
659 | else { | 659 | else { |
660 | bool block = signalsBlocked(); | 660 | bool block = signalsBlocked(); |
661 | blockSignals( true ); | 661 | blockSignals( true ); |
662 | 662 | ||
663 | if( !d->pCurrentItem->isSelected() ) | 663 | if( !d->pCurrentItem->isSelected() ) |
664 | clearSelection(); | 664 | clearSelection(); |
665 | 665 | ||
666 | blockSignals( block ); | 666 | blockSignals( block ); |
667 | 667 | ||
668 | setSelected( d->pCurrentItem, true ); | 668 | setSelected( d->pCurrentItem, true ); |
669 | } | 669 | } |
670 | } | 670 | } |
671 | else | 671 | else |
672 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; | 672 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; |
673 | #endif | 673 | #endif |
674 | #endif | 674 | #endif |
675 | } | 675 | } |
676 | 676 | ||
677 | void KListView::slotHeaderChanged() | 677 | void KListView::slotHeaderChanged() |
678 | { | 678 | { |
679 | if (d->fullWidth && columns()) | 679 | if (d->fullWidth && columns()) |
680 | { | 680 | { |
681 | int w = 0; | 681 | int w = 0; |
682 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); | 682 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); |
683 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); | 683 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); |
684 | } | 684 | } |
685 | } | 685 | } |
686 | 686 | ||
687 | void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) | 687 | void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) |
688 | { | 688 | { |
689 | // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); | 689 | // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); |
690 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { | 690 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { |
691 | 691 | ||
692 | // Double click mode ? | 692 | // Double click mode ? |
693 | if ( !d->bUseSingle ) | 693 | if ( !d->bUseSingle ) |
694 | { | 694 | { |
695 | emit executed( item ); | 695 | emit executed( item ); |
696 | emit executed( item, pos, c ); | 696 | emit executed( item, pos, c ); |
697 | } | 697 | } |
698 | else | 698 | else |
699 | { | 699 | { |
700 | //US special implementation for embedded systems | 700 | //US special implementation for embedded systems |
701 | d->autoSelect.stop(); | 701 | d->autoSelect.stop(); |
702 | 702 | ||
703 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed | 703 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed |
704 | if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { | 704 | if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { |
705 | // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { | 705 | // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { |
706 | 706 | ||
707 | emit executed( item ); | 707 | emit executed( item ); |
708 | emit executed( item, pos, c ); | 708 | emit executed( item, pos, c ); |
709 | } | 709 | } |
710 | } | 710 | } |
711 | } | 711 | } |
712 | } | 712 | } |
713 | 713 | ||
714 | void KListView::focusInEvent( QFocusEvent *fe ) | 714 | void KListView::focusInEvent( QFocusEvent *fe ) |
715 | { | 715 | { |
716 | // kdDebug()<<"KListView::focusInEvent()"<<endl; | 716 | // kdDebug()<<"KListView::focusInEvent()"<<endl; |
717 | QListView::focusInEvent( fe ); | 717 | QListView::focusInEvent( fe ); |
718 | if ((d->selectedBySimpleMove) | 718 | if ((d->selectedBySimpleMove) |
719 | && (d->selectionMode == FileManager) | 719 | && (d->selectionMode == FileManager) |
720 | && (fe->reason()!=QFocusEvent::Popup) | 720 | && (fe->reason()!=QFocusEvent::Popup) |
721 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 721 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
722 | && (currentItem()!=0)) | 722 | && (currentItem()!=0)) |
723 | { | 723 | { |
724 | currentItem()->setSelected(true); | 724 | currentItem()->setSelected(true); |
725 | currentItem()->repaint(); | 725 | currentItem()->repaint(); |
726 | emit selectionChanged(); | 726 | emit selectionChanged(); |
727 | }; | 727 | }; |
728 | } | 728 | } |
729 | 729 | ||
730 | void KListView::focusOutEvent( QFocusEvent *fe ) | 730 | void KListView::focusOutEvent( QFocusEvent *fe ) |
731 | { | 731 | { |
732 | cleanDropVisualizer(); | 732 | cleanDropVisualizer(); |
733 | cleanItemHighlighter(); | 733 | cleanItemHighlighter(); |
734 | 734 | ||
735 | d->autoSelect.stop(); | 735 | d->autoSelect.stop(); |
736 | 736 | ||
737 | if ((d->selectedBySimpleMove) | 737 | if ((d->selectedBySimpleMove) |
738 | && (d->selectionMode == FileManager) | 738 | && (d->selectionMode == FileManager) |
739 | && (fe->reason()!=QFocusEvent::Popup) | 739 | && (fe->reason()!=QFocusEvent::Popup) |