• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdeui
 

kdeui

  • kdeui
klistview.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org>
3  Copyright (C) 2000,2003 Charles Samuels <charles@kde.org>
4  Copyright (C) 2000 Peter Putzer
5  Copyright (C) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License version 2 as published by the Free Software Foundation.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 #include "config.h"
22 
23 #include <tqdragobject.h>
24 #include <tqtimer.h>
25 #include <tqheader.h>
26 #include <tqcursor.h>
27 #include <tqtooltip.h>
28 #include <tqstyle.h>
29 #include <tqpainter.h>
30 
31 #include <kglobalsettings.h>
32 #include <kconfig.h>
33 #include <kcursor.h>
34 #include <kapplication.h>
35 #include <kipc.h>
36 #include <kdebug.h>
37 
38 #include "klistview.h"
39 #include "klistviewlineedit.h"
40 
41 class KListView::Tooltip : public TQToolTip
42 {
43 public:
44  Tooltip (KListView* parent, TQToolTipGroup* group = 0L);
45  virtual ~Tooltip () {}
46 
47 protected:
51  virtual void maybeTip (const TQPoint&);
52 
53 private:
54  KListView* mParent;
55 };
56 
57 KListView::Tooltip::Tooltip (KListView* parent, TQToolTipGroup* group)
58  : TQToolTip (parent, group),
59  mParent (parent)
60 {
61 }
62 
63 void KListView::Tooltip::maybeTip (const TQPoint&)
64 {
65  // FIXME
66 }
67 
68 class KListView::KListViewPrivate
69 {
70 public:
71  KListViewPrivate (KListView* listview)
72  : pCurrentItem (0),
73  autoSelectDelay(0),
74  dragOverItem(0),
75  dragDelay (KGlobalSettings::dndEventDelay()),
76  editor (new KListViewLineEdit (listview)),
77  cursorInExecuteArea(false),
78  itemsMovable (true),
79  selectedBySimpleMove(false),
80  selectedUsingMouse(false),
81  itemsRenameable (false),
82  validDrag (false),
83  dragEnabled (false),
84  autoOpen (true),
85  disableAutoSelection (false),
86  dropVisualizer (true),
87  dropHighlighter (false),
88  createChildren (true),
89  pressedOnSelected (false),
90  wasShiftEvent (false),
91  fullWidth (false),
92  sortAscending(true),
93  tabRename(true),
94  sortColumn(0),
95  selectionDirection(0),
96  selectionRegion(0),
97  tooltipColumn (0),
98  selectionMode (Single),
99  contextMenuKey (KGlobalSettings::contextMenuKey()),
100  showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()),
101  mDropVisualizerWidth (4),
102  paintAbove (0),
103  paintCurrent (0),
104  paintBelow (0),
105  painting (false),
106  shadeSortColumn(KGlobalSettings::shadeSortColumn()),
107  initialFileManagerItem(0)
108  {
109  renameable.append(0);
110  connect(editor, TQT_SIGNAL(done(TQListViewItem*,int)), listview, TQT_SLOT(doneEditing(TQListViewItem*,int)));
111  }
112 
113  ~KListViewPrivate ()
114  {
115  delete editor;
116  }
117 
118  TQListViewItem* pCurrentItem;
119 
120  TQTimer autoSelect;
121  int autoSelectDelay;
122 
123  TQTimer dragExpand;
124  TQListViewItem* dragOverItem;
125  TQPoint dragOverPoint;
126 
127  TQPoint startDragPos;
128  int dragDelay;
129 
130  KListViewLineEdit *editor;
131  TQValueList<int> renameable;
132 
133  bool cursorInExecuteArea:1;
134  bool bUseSingle:1;
135  bool bChangeCursorOverItem:1;
136  bool itemsMovable:1;
137  bool selectedBySimpleMove : 1;
138  bool selectedUsingMouse:1;
139  bool itemsRenameable:1;
140  bool validDrag:1;
141  bool dragEnabled:1;
142  bool autoOpen:1;
143  bool disableAutoSelection:1;
144  bool dropVisualizer:1;
145  bool dropHighlighter:1;
146  bool createChildren:1;
147  bool pressedOnSelected:1;
148  bool wasShiftEvent:1;
149  bool fullWidth:1;
150  bool sortAscending:1;
151  bool tabRename:1;
152 
153  int sortColumn;
154 
155  //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX
156  int selectionDirection;
157  int selectionRegion;
158  int tooltipColumn;
159 
160  SelectionModeExt selectionMode;
161  int contextMenuKey;
162  bool showContextMenusOnPress;
163 
164  TQRect mOldDropVisualizer;
165  int mDropVisualizerWidth;
166  TQRect mOldDropHighlighter;
167  TQListViewItem *afterItemDrop;
168  TQListViewItem *parentItemDrop;
169 
170  TQListViewItem *paintAbove;
171  TQListViewItem *paintCurrent;
172  TQListViewItem *paintBelow;
173  bool painting:1;
174  bool shadeSortColumn:1;
175 
176  TQColor alternateBackground;
177 
178  TQListViewItem *initialFileManagerItem;
179 };
180 
181 
182 KListViewLineEdit::KListViewLineEdit(KListView *parent)
183  : KLineEdit(parent->viewport()), item(0), col(0), p(parent)
184 {
185  setFrame( false );
186  hide();
187  connect( parent, TQT_SIGNAL( selectionChanged() ), TQT_SLOT( slotSelectionChanged() ));
188  connect( parent, TQT_SIGNAL( itemRemoved( TQListViewItem * ) ),
189  TQT_SLOT( slotItemRemoved( TQListViewItem * ) ));
190 }
191 
192 KListViewLineEdit::~KListViewLineEdit()
193 {
194 }
195 
196 TQListViewItem *KListViewLineEdit::currentItem() const
197 {
198  return item;
199 }
200 
201 void KListViewLineEdit::load(TQListViewItem *i, int c)
202 {
203  item=i;
204  col=c;
205 
206  TQRect rect(p->itemRect(i));
207  setText(item->text(c));
208  home( true );
209 
210  int fieldX = rect.x() - 1;
211  int fieldW = p->columnWidth(col) + 2;
212 
213  TQHeader* const pHeader = p->header();
214 
215  const int pos = pHeader->mapToIndex(col);
216  for ( int index = 0; index < pos; ++index )
217  fieldX += p->columnWidth( pHeader->mapToSection( index ));
218 
219  if ( col == 0 ) {
220  int d = i->depth() + (p->rootIsDecorated() ? 1 : 0);
221  d *= p->treeStepSize();
222  fieldX += d;
223  fieldW -= d;
224  }
225 
226  if ( i->pixmap( col ) ) {// add width of pixmap
227  int d = i->pixmap( col )->width();
228  fieldX += d;
229  fieldW -= d;
230  }
231 
232  setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2);
233  show();
234  setFocus();
235 }
236 
237 /* Helper functions to for
238  * tabOrderedRename functionality.
239  */
240 
241 static int nextCol (KListView *pl, TQListViewItem *pi, int start, int dir)
242 {
243  if (pi)
244  {
245  // Find the next renameable column in the current row
246  for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir)
247  if (pl->isRenameable(start))
248  return start;
249  }
250 
251  return -1;
252 }
253 
254 static TQListViewItem *prevItem (TQListViewItem *pi)
255 {
256  TQListViewItem *pa = pi->itemAbove();
257 
258  /* Does what the TQListViewItem::previousSibling()
259  * of my dreams would do.
260  */
261  if (pa && pa->parent() == pi->parent())
262  return pa;
263 
264  return 0;
265 }
266 
267 static TQListViewItem *lastQChild (TQListViewItem *pi)
268 {
269  if (pi)
270  {
271  /* Since there's no TQListViewItem::lastChild().
272  * This finds the last sibling for the given
273  * item.
274  */
275  for (TQListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling())
276  pi = pt;
277  }
278 
279  return pi;
280 }
281 
282 void KListViewLineEdit::selectNextCell (TQListViewItem *pitem, int column, bool forward)
283 {
284  const int ncols = p->columns();
285  const int dir = forward ? +1 : -1;
286  const int restart = forward ? 0 : (ncols - 1);
287  TQListViewItem *top = (pitem && pitem->parent())
288  ? pitem->parent()->firstChild()
289  : p->firstChild();
290  TQListViewItem *pi = pitem;
291 
292  terminate(); // Save current changes
293 
294  do
295  {
296  /* Check the rest of the current row for an editable column,
297  * if that fails, check the entire next/previous row. The
298  * last case goes back to the first item in the current branch
299  * or the last item in the current branch depending on the
300  * direction.
301  */
302  if ((column = nextCol(p, pi, column + dir, dir)) != -1 ||
303  (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 ||
304  (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1)
305  {
306  if (pi)
307  {
308  p->setCurrentItem(pi); // Calls terminate
309  p->rename(pi, column);
310 
311  /* Some listviews may override rename() to
312  * prevent certain items from being renamed,
313  * if this is done, [m_]item will be NULL
314  * after the rename() call... try again.
315  */
316  if (!item)
317  continue;
318 
319  break;
320  }
321  }
322  }
323  while (pi && !item);
324 }
325 
326 #ifdef KeyPress
327 #undef KeyPress
328 #endif
329 
330 bool KListViewLineEdit::event (TQEvent *pe)
331 {
332  if (pe->type() == TQEvent::KeyPress)
333  {
334  TQKeyEvent *k = (TQKeyEvent *) pe;
335 
336  if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) &&
337  p->tabOrderedRenaming() && p->itemsRenameable() &&
338  !(k->state() & ControlButton || k->state() & AltButton))
339  {
340  selectNextCell(item, col,
341  (k->key() == Key_Tab && !(k->state() & ShiftButton)));
342  return true;
343  }
344  }
345 
346  return KLineEdit::event(pe);
347 }
348 
349 void KListViewLineEdit::keyPressEvent(TQKeyEvent *e)
350 {
351  if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
352  terminate(true);
353  else if(e->key() == Qt::Key_Escape)
354  terminate(false);
355  else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up)
356  {
357  terminate(true);
358  KLineEdit::keyPressEvent(e);
359  }
360  else
361  KLineEdit::keyPressEvent(e);
362 }
363 
364 void KListViewLineEdit::terminate()
365 {
366  terminate(true);
367 }
368 
369 void KListViewLineEdit::terminate(bool commit)
370 {
371  if ( item )
372  {
373  //kdDebug() << "KListViewLineEdit::terminate " << commit << endl;
374  if (commit)
375  item->setText(col, text());
376  int c=col;
377  TQListViewItem *i=item;
378  col=0;
379  item=0;
380  p->setFocus();// will call focusOutEvent, that's why we set item=0 before
381  hide();
382  if (commit)
383  emit done(i,c);
384  }
385 }
386 
387 void KListViewLineEdit::focusOutEvent(TQFocusEvent *ev)
388 {
389  TQFocusEvent * focusEv = static_cast<TQFocusEvent*>(ev);
390  // Don't let a RMB close the editor
391  if (focusEv->reason() != TQFocusEvent::Popup && focusEv->reason() != TQFocusEvent::ActiveWindow)
392  terminate(true);
393  else
394  KLineEdit::focusOutEvent(ev);
395 }
396 
397 void KListViewLineEdit::paintEvent( TQPaintEvent *e )
398 {
399  KLineEdit::paintEvent( e );
400 
401  if ( !frame() ) {
402  TQPainter p( this );
403  p.setClipRegion( e->region() );
404  p.drawRect( rect() );
405  }
406 }
407 
408 // selection changed -> terminate. As our "item" can be already deleted,
409 // we can't call terminate(false), because that would emit done() with
410 // a dangling pointer to "item".
411 void KListViewLineEdit::slotSelectionChanged()
412 {
413  item = 0;
414  col = 0;
415  hide();
416 }
417 
418 // if the current item was removed -> terminate. Can't call terminate(false)
419 // due to same reason as slotSelectionChanged().
420 void KListViewLineEdit::slotItemRemoved(TQListViewItem *i)
421 {
422  if (currentItem() != i)
423  return;
424 
425  item = 0;
426  col = 0;
427  hide();
428 }
429 
430 
431 KListView::KListView( TQWidget *parent, const char *name )
432  : TQListView( parent, name ),
433  d (new KListViewPrivate (this))
434 {
435  setDragAutoScroll(true);
436 
437  connect( this, TQT_SIGNAL( onViewport() ),
438  this, TQT_SLOT( slotOnViewport() ) );
439  connect( this, TQT_SIGNAL( onItem( TQListViewItem * ) ),
440  this, TQT_SLOT( slotOnItem( TQListViewItem * ) ) );
441 
442  connect (this, TQT_SIGNAL(contentsMoving(int,int)),
443  this, TQT_SLOT(cleanDropVisualizer()));
444  connect (this, TQT_SIGNAL(contentsMoving(int,int)),
445  this, TQT_SLOT(cleanItemHighlighter()));
446 
447  slotSettingsChanged(KApplication::SETTINGS_MOUSE);
448  if (kapp)
449  {
450  connect( kapp, TQT_SIGNAL( settingsChanged(int) ), TQT_SLOT( slotSettingsChanged(int) ) );
451  kapp->addKipcEventMask( KIPC::SettingsChanged );
452  }
453 
454  connect(&d->autoSelect, TQT_SIGNAL( timeout() ),
455  this, TQT_SLOT( slotAutoSelect() ) );
456  connect(&d->dragExpand, TQT_SIGNAL( timeout() ),
457  this, TQT_SLOT( slotDragExpand() ) );
458 
459  // context menu handling
460  if (d->showContextMenusOnPress)
461  {
462  connect (this, TQT_SIGNAL (rightButtonPressed (TQListViewItem*, const TQPoint&, int)),
463  this, TQT_SLOT (emitContextMenu (TQListViewItem*, const TQPoint&, int)));
464  }
465  else
466  {
467  connect (this, TQT_SIGNAL (rightButtonClicked (TQListViewItem*, const TQPoint&, int)),
468  this, TQT_SLOT (emitContextMenu (TQListViewItem*, const TQPoint&, int)));
469  }
470 
471  connect (this, TQT_SIGNAL (menuShortCutPressed (KListView*, TQListViewItem*)),
472  this, TQT_SLOT (emitContextMenu (KListView*, TQListViewItem*)));
473  d->alternateBackground = KGlobalSettings::alternateBackgroundColor();
474 }
475 
476 KListView::~KListView()
477 {
478  delete d;
479 }
480 
481 bool KListView::isExecuteArea( const TQPoint& point )
482 {
483  TQListViewItem* item = itemAt( point );
484  if ( item ) {
485  return isExecuteArea( point.x(), item );
486  }
487 
488  return false;
489 }
490 
491 bool KListView::isExecuteArea( int x )
492 {
493  return isExecuteArea( x, 0 );
494 }
495 
496 bool KListView::isExecuteArea( int x, TQListViewItem* item )
497 {
498  if ( allColumnsShowFocus() ) {
499  return true;
500  }
501  else {
502  int offset = 0;
503  int width = columnWidth( 0 );
504 
505  TQHeader* const thisHeader = header();
506  const int pos = thisHeader->mapToIndex( 0 );
507 
508  for ( int index = 0; index < pos; ++index ) {
509  offset += columnWidth( thisHeader->mapToSection( index ) );
510  }
511 
512  x += contentsX(); // in case of a horizontal scrollbar
513 
514  // What was this supposed to do???
515  // Just use the column width, as at least one entire column is highlighted on row selection!
516 #if 0
517  if ( item ) {
518  width = treeStepSize()*( item->depth() + ( rootIsDecorated() ? 1 : 0 ) );
519  width += itemMargin();
520  int ca = AlignHorizontal_Mask & columnAlignment( 0 );
521  if ( ca == AlignLeft || ca == AlignAuto ) {
522  width += item->width( fontMetrics(), this, 0 );
523  if ( width > columnWidth( 0 ) ) {
524  width = columnWidth( 0 );
525  }
526  }
527  }
528 #endif
529  if ( item ) {
530  if (!allColumnsShowFocus()) {
531  offset += treeStepSize()*( item->depth() + ( rootIsDecorated() ? 1 : 0 ) );
532  }
533  }
534 
535  return ( x > offset && x < ( offset + width ) );
536  }
537 }
538 
539 void KListView::slotOnItem( TQListViewItem *item )
540 {
541  TQPoint vp = viewport()->mapFromGlobal( TQCursor::pos() );
542  if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) {
543  d->autoSelect.start( d->autoSelectDelay, true );
544  d->pCurrentItem = item;
545  }
546 }
547 
548 void KListView::slotOnViewport()
549 {
550  if ( d->bChangeCursorOverItem )
551  viewport()->unsetCursor();
552 
553  d->autoSelect.stop();
554  d->pCurrentItem = 0L;
555 }
556 
557 void KListView::slotSettingsChanged(int category)
558 {
559  switch (category)
560  {
561  case KApplication::SETTINGS_MOUSE:
562  d->dragDelay = KGlobalSettings::dndEventDelay();
563  d->bUseSingle = KGlobalSettings::singleClick();
564 
565  disconnect(this, TQT_SIGNAL (mouseButtonClicked (int, TQListViewItem*, const TQPoint &, int)),
566  this, TQT_SLOT (slotMouseButtonClicked (int, TQListViewItem*, const TQPoint &, int)));
567 
568  if( d->bUseSingle )
569  connect (this, TQT_SIGNAL (mouseButtonClicked (int, TQListViewItem*, const TQPoint &, int)),
570  this, TQT_SLOT (slotMouseButtonClicked( int, TQListViewItem*, const TQPoint &, int)));
571 
572  d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon();
573  if ( !d->disableAutoSelection )
574  d->autoSelectDelay = KGlobalSettings::autoSelectDelay();
575 
576  if( !d->bUseSingle || !d->bChangeCursorOverItem )
577  viewport()->unsetCursor();
578 
579  break;
580 
581  case KApplication::SETTINGS_POPUPMENU:
582  d->contextMenuKey = KGlobalSettings::contextMenuKey ();
583  d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress ();
584 
585  if (d->showContextMenusOnPress)
586  {
587  disconnect (0L, 0L, this, TQT_SLOT (emitContextMenu (TQListViewItem*, const TQPoint&, int)));
588 
589  connect(this, TQT_SIGNAL (rightButtonPressed (TQListViewItem*, const TQPoint&, int)),
590  this, TQT_SLOT (emitContextMenu (TQListViewItem*, const TQPoint&, int)));
591  }
592  else
593  {
594  disconnect (0L, 0L, this, TQT_SLOT (emitContextMenu (TQListViewItem*, const TQPoint&, int)));
595 
596  connect(this, TQT_SIGNAL (rightButtonClicked (TQListViewItem*, const TQPoint&, int)),
597  this, TQT_SLOT (emitContextMenu (TQListViewItem*, const TQPoint&, int)));
598  }
599  break;
600 
601  default:
602  break;
603  }
604 }
605 
606 void KListView::slotAutoSelect()
607 {
608  // check that the item still exists
609  if( itemIndex( d->pCurrentItem ) == -1 )
610  return;
611 
612  if (!isActiveWindow())
613  {
614  d->autoSelect.stop();
615  return;
616  }
617 
618  //Give this widget the keyboard focus.
619  if( !hasFocus() )
620  setFocus();
621 
622  ButtonState keybstate = KApplication::keyboardMouseState();
623 
624  TQListViewItem* previousItem = currentItem();
625  setCurrentItem( d->pCurrentItem );
626 
627  if( d->pCurrentItem ) {
628  //Shift pressed?
629  if( (keybstate & TQt::ShiftButton) ) {
630  bool block = signalsBlocked();
631  blockSignals( true );
632 
633  //No Ctrl? Then clear before!
634  if( !(keybstate & TQt::ControlButton) )
635  clearSelection();
636 
637  bool select = !d->pCurrentItem->isSelected();
638  bool update = viewport()->isUpdatesEnabled();
639  viewport()->setUpdatesEnabled( false );
640 
641  bool down = previousItem->itemPos() < d->pCurrentItem->itemPos();
642  TQListViewItemIterator lit( down ? previousItem : d->pCurrentItem );
643  for ( ; lit.current(); ++lit ) {
644  if ( down && lit.current() == d->pCurrentItem ) {
645  d->pCurrentItem->setSelected( select );
646  break;
647  }
648  if ( !down && lit.current() == previousItem ) {
649  previousItem->setSelected( select );
650  break;
651  }
652  lit.current()->setSelected( select );
653  }
654 
655  blockSignals( block );
656  viewport()->setUpdatesEnabled( update );
657  triggerUpdate();
658 
659  emit selectionChanged();
660 
661  if( selectionMode() == TQListView::Single )
662  emit selectionChanged( d->pCurrentItem );
663  }
664  else if( (keybstate & KApplication::ControlModifier) )
665  setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() );
666  else {
667  bool block = signalsBlocked();
668  blockSignals( true );
669 
670  if( !d->pCurrentItem->isSelected() )
671  clearSelection();
672 
673  blockSignals( block );
674 
675  setSelected( d->pCurrentItem, true );
676  }
677  }
678  else
679  kdDebug() << "KListView::slotAutoSelect: That�s not supposed to happen!!!!" << endl;
680 }
681 
682 void KListView::slotHeaderChanged()
683 {
684 
685  const int colCount = columns();
686  if (d->fullWidth && colCount)
687  {
688  int w = 0;
689  const int lastColumn = colCount - 1;
690  for (int i = 0; i < lastColumn; ++i) w += columnWidth(i);
691  setColumnWidth( lastColumn, viewport()->width() - w - 1 );
692  }
693 }
694 
695 void KListView::emitExecute( TQListViewItem *item, const TQPoint &pos, int c )
696 {
697  if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) {
698  d->validDrag=false;
699 
700  // Double click mode ?
701  if ( !d->bUseSingle )
702  {
703  viewport()->unsetCursor();
704  emit executed( item );
705  emit executed( item, pos, c );
706  }
707  else
708  {
709  ButtonState keybstate = KApplication::keyboardMouseState();
710 
711  d->autoSelect.stop();
712 
713  //Don't emit executed if in SC mode and Shift or Ctrl are pressed
714  if( !( ((keybstate & TQt::ShiftButton) || (keybstate & TQt::ControlButton)) ) ) {
715  viewport()->unsetCursor();
716  emit executed( item );
717  emit executed( item, pos, c );
718  }
719  }
720  }
721 }
722 
723 void KListView::focusInEvent( TQFocusEvent *fe )
724 {
725  // kdDebug()<<"KListView::focusInEvent()"<<endl;
726  TQListView::focusInEvent( fe );
727  if ((d->selectedBySimpleMove)
728  && (d->selectionMode == FileManager)
729  && (fe->reason()!=TQFocusEvent::Popup)
730  && (fe->reason()!=TQFocusEvent::ActiveWindow)
731  && (currentItem()))
732  {
733  currentItem()->setSelected(true);
734  currentItem()->repaint();
735  emit selectionChanged();
736  };
737 }
738 
739 void KListView::focusOutEvent( TQFocusEvent *fe )
740 {
741  cleanDropVisualizer();
742  cleanItemHighlighter();
743 
744  d->autoSelect.stop();
745 
746  if ((d->selectedBySimpleMove)
747  && (d->selectionMode == FileManager)
748  && (fe->reason()!=TQFocusEvent::Popup)
749  && (fe->reason()!=TQFocusEvent::ActiveWindow)
750  && (currentItem())
751  && (!d->editor->isVisible()))
752  {
753  currentItem()->setSelected(false);
754  currentItem()->repaint();
755  emit selectionChanged();
756  };
757 
758  TQListView::focusOutEvent( fe );
759 }
760 
761 void KListView::leaveEvent( TQEvent *e )
762 {
763  d->autoSelect.stop();
764 
765  TQListView::leaveEvent( e );
766 }
767 
768 bool KListView::event( TQEvent *e )
769 {
770  if (e->type() == TQEvent::ApplicationPaletteChange)
771  d->alternateBackground=KGlobalSettings::alternateBackgroundColor();
772 
773  return TQListView::event(e);
774 }
775 
776 void KListView::contentsMousePressEvent( TQMouseEvent *e )
777 {
778  if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) )
779  {
780  bool block = signalsBlocked();
781  blockSignals( true );
782 
783  clearSelection();
784 
785  blockSignals( block );
786  }
787  else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove))
788  {
789  d->selectedBySimpleMove=false;
790  d->selectedUsingMouse=true;
791  if (currentItem())
792  {
793  currentItem()->setSelected(false);
794  currentItem()->repaint();
795 // emit selectionChanged();
796  }
797  }
798 
799  TQPoint p( contentsToViewport( e->pos() ) );
800  TQListViewItem *at = itemAt (p);
801 
802  // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
803  bool rootDecoClicked = at
804  && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
805  treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
806  && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
807 
808  if (e->button() == Qt::LeftButton && !rootDecoClicked)
809  {
810  //Start a drag
811  d->startDragPos = e->pos();
812 
813  if (at)
814  {
815  d->validDrag = true;
816  d->pressedOnSelected = at->isSelected();
817  }
818  }
819 
820  TQListView::contentsMousePressEvent( e );
821 }
822 
823 void KListView::contentsMouseMoveEvent( TQMouseEvent *e )
824 {
825  if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag)
826  TQListView::contentsMouseMoveEvent (e);
827 
828  TQPoint vp = contentsToViewport(e->pos());
829  TQListViewItem *item = itemAt( vp );
830 
831  //do we process cursor changes at all?
832  if ( item && d->bChangeCursorOverItem && d->bUseSingle )
833  {
834  //Cursor moved on a new item or in/out the execute area
835  if( (item != d->pCurrentItem) ||
836  (isExecuteArea(vp) != d->cursorInExecuteArea) )
837  {
838  d->cursorInExecuteArea = isExecuteArea(vp);
839 
840  if( d->cursorInExecuteArea ) //cursor moved in execute area
841  viewport()->setCursor( KCursor::handCursor() );
842  else //cursor moved out of execute area
843  viewport()->unsetCursor();
844  }
845  }
846 
847  bool dragOn = dragEnabled();
848  TQPoint newPos = e->pos();
849  if (dragOn && d->validDrag &&
850  (newPos.x() > d->startDragPos.x()+d->dragDelay ||
851  newPos.x() < d->startDragPos.x()-d->dragDelay ||
852  newPos.y() > d->startDragPos.y()+d->dragDelay ||
853  newPos.y() < d->startDragPos.y()-d->dragDelay))
854  //(d->startDragPos - e->pos()).manhattanLength() > TQApplication::startDragDistance())
855  {
856  TQListView::contentsMouseReleaseEvent( 0 );
857  startDrag();
858  d->startDragPos = TQPoint();
859  d->validDrag = false;
860  }
861 }
862 
863 void KListView::contentsMouseReleaseEvent( TQMouseEvent *e )
864 {
865  if (e->button() == Qt::LeftButton)
866  {
867  // If the row was already selected, maybe we want to start an in-place editing
868  if ( d->pressedOnSelected && itemsRenameable() )
869  {
870  TQPoint p( contentsToViewport( e->pos() ) );
871  TQListViewItem *at = itemAt (p);
872  if ( at )
873  {
874  // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
875  bool rootDecoClicked =
876  ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
877  treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
878  && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
879 
880  if (!rootDecoClicked)
881  {
882  int col = header()->mapToLogical( header()->cellAt( p.x() ) );
883  if ( d->renameable.contains(col) )
884  rename(at, col);
885  }
886  }
887  }
888 
889  d->pressedOnSelected = false;
890  d->validDrag = false;
891  d->startDragPos = TQPoint();
892  }
893  TQListView::contentsMouseReleaseEvent( e );
894 }
895 
896 void KListView::contentsMouseDoubleClickEvent ( TQMouseEvent *e )
897 {
898  // We don't want to call the parent method because it does setOpen,
899  // whereas we don't do it in single click mode... (David)
900  //TQListView::contentsMouseDoubleClickEvent( e );
901  if ( !e || e->button() != Qt::LeftButton ) {
902  return;
903  }
904 
905  TQPoint vp = contentsToViewport(e->pos());
906  TQListViewItem *item = itemAt( vp );
907  emit TQListView::doubleClicked( item ); // we do it now
908 
909  int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1;
910 
911  if( item ) {
912  emit doubleClicked( item, e->globalPos(), col );
913 
914  if( (e->button() == Qt::LeftButton) && !d->bUseSingle ) {
915  emitExecute( item, e->globalPos(), col );
916  }
917  }
918 }
919 
920 void KListView::slotMouseButtonClicked( int btn, TQListViewItem *item, const TQPoint &pos, int c )
921 {
922  if( (btn == Qt::LeftButton) && item ) {
923  emitExecute(item, pos, c);
924  }
925 }
926 
927 void KListView::contentsDropEvent(TQDropEvent* e)
928 {
929  cleanDropVisualizer();
930  cleanItemHighlighter();
931  d->dragExpand.stop();
932 
933  if (acceptDrag (e))
934  {
935  e->acceptAction();
936  TQListViewItem *afterme;
937  TQListViewItem *parent;
938 
939  findDrop(e->pos(), parent, afterme);
940 
941  if (e->source() == viewport() && itemsMovable())
942  movableDropEvent(parent, afterme);
943  else
944  {
945  emit dropped(e, afterme);
946  emit dropped(this, e, afterme);
947  emit dropped(e, parent, afterme);
948  emit dropped(this, e, parent, afterme);
949  }
950  }
951 }
952 
953 void KListView::movableDropEvent (TQListViewItem* parent, TQListViewItem* afterme)
954 {
955  TQPtrList<TQListViewItem> items, afterFirsts, afterNows;
956  TQListViewItem *current=currentItem();
957  bool hasMoved=false;
958  for (TQListViewItem *i = firstChild(), *iNext=0; i; i = iNext)
959  {
960  iNext=i->itemBelow();
961  if (!i->isSelected())
962  continue;
963 
964  // don't drop an item after itself, or else
965  // it moves to the top of the list
966  if (i==afterme)
967  continue;
968 
969  i->setSelected(false);
970 
971  TQListViewItem *afterFirst = i->itemAbove();
972 
973  if (!hasMoved)
974  {
975  emit aboutToMove();
976  hasMoved=true;
977  }
978 
979  moveItem(i, parent, afterme);
980 
981  // ###### This should include the new parent !!! -> KDE 3.0
982  // If you need this right now, have a look at keditbookmarks.
983  emit moved(i, afterFirst, afterme);
984 
985  items.append (i);
986  afterFirsts.append (afterFirst);
987  afterNows.append (afterme);
988 
989  afterme = i;
990  }
991  clearSelection();
992  for (TQListViewItem *i=items.first(); i; i=items.next() )
993  i->setSelected(true);
994  if (current)
995  setCurrentItem(current);
996 
997  emit moved(items,afterFirsts,afterNows);
998 
999  if (firstChild())
1000  emit moved();
1001 }
1002 
1003 void KListView::contentsDragMoveEvent(TQDragMoveEvent *event)
1004 {
1005  if (acceptDrag(event))
1006  {
1007  event->acceptAction();
1008  //Clean up the view
1009 
1010  findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop);
1011  TQPoint vp = contentsToViewport( event->pos() );
1012  TQListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L;
1013 
1014  if ( item != d->dragOverItem )
1015  {
1016  d->dragExpand.stop();
1017  d->dragOverItem = item;
1018  d->dragOverPoint = vp;
1019  if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() )
1020  d->dragExpand.start( TQApplication::startDragTime(), true );
1021  }
1022  if (dropVisualizer())
1023  {
1024  TQRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop);
1025  if (tmpRect != d->mOldDropVisualizer)
1026  {
1027  cleanDropVisualizer();
1028  d->mOldDropVisualizer=tmpRect;
1029  viewport()->repaint(tmpRect);
1030  }
1031  }
1032  if (dropHighlighter())
1033  {
1034  TQRect tmpRect = drawItemHighlighter(0, itemAt( vp ));
1035  if (tmpRect != d->mOldDropHighlighter)
1036  {
1037  cleanItemHighlighter();
1038  d->mOldDropHighlighter=tmpRect;
1039  viewport()->repaint(tmpRect);
1040  }
1041  }
1042  }
1043  else
1044  event->ignore();
1045 }
1046 
1047 void KListView::slotDragExpand()
1048 {
1049  if ( itemAt( d->dragOverPoint ) == d->dragOverItem )
1050  d->dragOverItem->setOpen( true );
1051 }
1052 
1053 void KListView::contentsDragLeaveEvent (TQDragLeaveEvent*)
1054 {
1055  d->dragExpand.stop();
1056  cleanDropVisualizer();
1057  cleanItemHighlighter();
1058 }
1059 
1060 void KListView::cleanDropVisualizer()
1061 {
1062  if (d->mOldDropVisualizer.isValid())
1063  {
1064  TQRect rect=d->mOldDropVisualizer;
1065  d->mOldDropVisualizer = TQRect();
1066  viewport()->repaint(rect, true);
1067  }
1068 }
1069 
1070 int KListView::depthToPixels( int depth )
1071 {
1072  return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin();
1073 }
1074 
1075 void KListView::findDrop(const TQPoint &pos, TQListViewItem *&parent, TQListViewItem *&after)
1076 {
1077  TQPoint p (contentsToViewport(pos));
1078 
1079  // Get the position to put it in
1080  TQListViewItem *atpos = itemAt(p);
1081 
1082  TQListViewItem *above;
1083  if (!atpos) // put it at the end
1084  above = lastItem();
1085  else
1086  {
1087  // Get the closest item before us ('atpos' or the one above, if any)
1088  if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2))
1089  above = atpos->itemAbove();
1090  else
1091  above = atpos;
1092  }
1093 
1094  if (above)
1095  {
1096  // if above has children, I might need to drop it as the first item there
1097 
1098  if (above->firstChild() && above->isOpen())
1099  {
1100  parent = above;
1101  after = 0;
1102  return;
1103  }
1104 
1105  // Now, we know we want to go after "above". But as a child or as a sibling ?
1106  // We have to ask the "above" item if it accepts children.
1107  if (above->isExpandable())
1108  {
1109  // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children
1110  if (p.x() >= depthToPixels( above->depth() + 1 ) ||
1111  (above->isOpen() && above->childCount() > 0) )
1112  {
1113  parent = above;
1114  after = 0L;
1115  return;
1116  }
1117  }
1118 
1119  // Ok, there's one more level of complexity. We may want to become a new
1120  // sibling, but of an upper-level group, rather than the "above" item
1121  TQListViewItem * betterAbove = above->parent();
1122  TQListViewItem * last = above;
1123  while ( betterAbove )
1124  {
1125  // We are allowed to become a sibling of "betterAbove" only if we are
1126  // after its last child
1127  if ( !last->nextSibling() )
1128  {
1129  if (p.x() < depthToPixels ( betterAbove->depth() + 1 ))
1130  above = betterAbove; // store this one, but don't stop yet, there may be a better one
1131  else
1132  break; // not enough on the left, so stop
1133  last = betterAbove;
1134  betterAbove = betterAbove->parent(); // up one level
1135  } else
1136  break; // we're among the child of betterAbove, not after the last one
1137  }
1138  }
1139  // set as sibling
1140  after = above;
1141  parent = after ? after->parent() : 0L ;
1142 }
1143 
1144 TQListViewItem* KListView::lastChild () const
1145 {
1146  TQListViewItem* lastchild = firstChild();
1147 
1148  if (lastchild)
1149  for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling());
1150 
1151  return lastchild;
1152 }
1153 
1154 TQListViewItem *KListView::lastItem() const
1155 {
1156  TQListViewItem* last = lastChild();
1157 
1158  for (TQListViewItemIterator it (last); it.current(); ++it)
1159  last = it.current();
1160 
1161  return last;
1162 }
1163 
1164 KLineEdit *KListView::renameLineEdit() const
1165 {
1166  return d->editor;
1167 }
1168 
1169 void KListView::startDrag()
1170 {
1171  TQDragObject *drag = dragObject();
1172 
1173  if (!drag)
1174  return;
1175 
1176  if (drag->drag() && drag->target() != viewport())
1177  emit moved();
1178 }
1179 
1180 TQDragObject *KListView::dragObject()
1181 {
1182  if (!currentItem())
1183  return 0;
1184 
1185 
1186  return new TQStoredDrag("application/x-qlistviewitem", viewport());
1187 }
1188 
1189 void KListView::setItemsMovable(bool b)
1190 {
1191  d->itemsMovable=b;
1192 }
1193 
1194 bool KListView::itemsMovable() const
1195 {
1196  return d->itemsMovable;
1197 }
1198 
1199 void KListView::setItemsRenameable(bool b)
1200 {
1201  d->itemsRenameable=b;
1202 }
1203 
1204 bool KListView::itemsRenameable() const
1205 {
1206  return d->itemsRenameable;
1207 }
1208 
1209 
1210 void KListView::setDragEnabled(bool b)
1211 {
1212  d->dragEnabled=b;
1213 }
1214 
1215 bool KListView::dragEnabled() const
1216 {
1217  return d->dragEnabled;
1218 }
1219 
1220 void KListView::setAutoOpen(bool b)
1221 {
1222  d->autoOpen=b;
1223 }
1224 
1225 bool KListView::autoOpen() const
1226 {
1227  return d->autoOpen;
1228 }
1229 
1230 bool KListView::dropVisualizer() const
1231 {
1232  return d->dropVisualizer;
1233 }
1234 
1235 void KListView::setDropVisualizer(bool b)
1236 {
1237  d->dropVisualizer=b;
1238 }
1239 
1240 TQPtrList<TQListViewItem> KListView::selectedItems() const
1241 {
1242  return selectedItems(true);
1243 }
1244 
1245 TQPtrList<TQListViewItem> KListView::selectedItems(bool includeHiddenItems) const
1246 {
1247  TQPtrList<TQListViewItem> list;
1248 
1249  // Using selectionMode() instead of selectionModeExt() since for the cases that
1250  // we're interested in selectionMode() should work for either variety of the
1251  // setSelectionMode().
1252 
1253  switch(selectionMode())
1254  {
1255  case NoSelection:
1256  break;
1257  case Single:
1258  if(selectedItem() && (includeHiddenItems || selectedItem()->isVisible()))
1259  list.append(selectedItem());
1260  break;
1261  default:
1262  {
1263  int flags = TQListViewItemIterator::Selected;
1264  if (!includeHiddenItems)
1265  {
1266  flags |= TQListViewItemIterator::Visible;
1267  }
1268 
1269  TQListViewItemIterator it(const_cast<KListView *>(this), flags);
1270 
1271  for(; it.current(); ++it)
1272  list.append(it.current());
1273 
1274  break;
1275  }
1276  }
1277 
1278  return list;
1279 }
1280 
1281 
1282 void KListView::moveItem(TQListViewItem *item, TQListViewItem *parent, TQListViewItem *after)
1283 {
1284  // sanity check - don't move a item into its own child structure
1285  TQListViewItem *i = parent;
1286  while(i)
1287  {
1288  if(i == item)
1289  return;
1290  i = i->parent();
1291  }
1292 
1293  if (after)
1294  {
1295  item->moveItem(after);
1296  return;
1297  }
1298 
1299  // Basically reimplementing the TQListViewItem(TQListViewItem*, TQListViewItem*) constructor
1300  // in here, without ever deleting the item.
1301  if (item->parent())
1302  item->parent()->takeItem(item);
1303  else
1304  takeItem(item);
1305 
1306  if (parent)
1307  parent->insertItem(item);
1308  else
1309  insertItem(item);
1310 }
1311 
1312 void KListView::contentsDragEnterEvent(TQDragEnterEvent *event)
1313 {
1314  if (acceptDrag (event))
1315  event->accept();
1316 }
1317 
1318 void KListView::setDropVisualizerWidth (int w)
1319 {
1320  d->mDropVisualizerWidth = w > 0 ? w : 1;
1321 }
1322 
1323 TQRect KListView::drawDropVisualizer(TQPainter *p, TQListViewItem *parent,
1324  TQListViewItem *after)
1325 {
1326  TQRect insertmarker;
1327 
1328  if (!after && !parent)
1329  insertmarker = TQRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2);
1330  else
1331  {
1332  int level = 0;
1333  if (after)
1334  {
1335  TQListViewItem* it = 0L;
1336  if (after->isOpen())
1337  {
1338  // Look for the last child (recursively)
1339  it = after->firstChild();
1340  if (it)
1341  while (it->nextSibling() || it->firstChild())
1342  if ( it->nextSibling() )
1343  it = it->nextSibling();
1344  else
1345  it = it->firstChild();
1346  }
1347 
1348  insertmarker = itemRect (it ? it : after);
1349  level = after->depth();
1350  }
1351  else if (parent)
1352  {
1353  insertmarker = itemRect (parent);
1354  level = parent->depth() + 1;
1355  }
1356  insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() );
1357  insertmarker.setRight (viewport()->width());
1358  insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1);
1359  insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2);
1360  }
1361 
1362  // This is not used anymore, at least by KListView itself (see viewportPaintEvent)
1363  // Remove for KDE 4.0.
1364  if (p)
1365  p->fillRect(insertmarker, Dense4Pattern);
1366 
1367  return insertmarker;
1368 }
1369 
1370 TQRect KListView::drawItemHighlighter(TQPainter *painter, TQListViewItem *item)
1371 {
1372  TQRect r;
1373 
1374  if (item)
1375  {
1376  r = itemRect(item);
1377  r.setLeft(r.left()+(item->depth()+(rootIsDecorated() ? 1 : 0))*treeStepSize());
1378  if (painter)
1379  style().tqdrawPrimitive(TQStyle::PE_FocusRect, painter, r, colorGroup(),
1380  TQStyle::Style_FocusAtBorder, colorGroup().highlight());
1381  }
1382 
1383  return r;
1384 }
1385 
1386 void KListView::cleanItemHighlighter ()
1387 {
1388  if (d->mOldDropHighlighter.isValid())
1389  {
1390  TQRect rect=d->mOldDropHighlighter;
1391  d->mOldDropHighlighter = TQRect();
1392  viewport()->repaint(rect, true);
1393  }
1394 }
1395 
1396 void KListView::rename(TQListViewItem *item, int c)
1397 {
1398  if (d->renameable.contains(c))
1399  {
1400  ensureItemVisible(item);
1401  d->editor->load(item,c);
1402  }
1403 }
1404 
1405 bool KListView::isRenameable (int col) const
1406 {
1407  return d->renameable.contains(col);
1408 }
1409 
1410 void KListView::setRenameable (int col, bool renameable)
1411 {
1412  if (col>=header()->count()) return;
1413 
1414  d->renameable.remove(col);
1415  if (renameable)
1416  d->renameable+=col;
1417 }
1418 
1419 void KListView::doneEditing(TQListViewItem *item, int row)
1420 {
1421  emit itemRenamed(item, item->text(row), row);
1422  emit itemRenamed(item);
1423 }
1424 
1425 bool KListView::acceptDrag(TQDropEvent* e) const
1426 {
1427  return acceptDrops() && itemsMovable() && (e->source()==viewport());
1428 }
1429 
1430 void KListView::setCreateChildren(bool b)
1431 {
1432  d->createChildren=b;
1433 }
1434 
1435 bool KListView::createChildren() const
1436 {
1437  return d->createChildren;
1438 }
1439 
1440 
1441 int KListView::tooltipColumn() const
1442 {
1443  return d->tooltipColumn;
1444 }
1445 
1446 void KListView::setTooltipColumn(int column)
1447 {
1448  d->tooltipColumn=column;
1449 }
1450 
1451 void KListView::setDropHighlighter(bool b)
1452 {
1453  d->dropHighlighter=b;
1454 }
1455 
1456 bool KListView::dropHighlighter() const
1457 {
1458  return d->dropHighlighter;
1459 }
1460 
1461 bool KListView::showTooltip(TQListViewItem *item, const TQPoint &, int column) const
1462 {
1463  return ((column==tooltipColumn()) && !tooltip(item, column).isEmpty());
1464 }
1465 
1466 TQString KListView::tooltip(TQListViewItem *item, int column) const
1467 {
1468  return item->text(column);
1469 }
1470 
1471 void KListView::setTabOrderedRenaming(bool b)
1472 {
1473  d->tabRename = b;
1474 }
1475 
1476 bool KListView::tabOrderedRenaming() const
1477 {
1478  return d->tabRename;
1479 }
1480 
1481 void KListView::keyPressEvent (TQKeyEvent* e)
1482 {
1483  //don't we need a contextMenuModifier too ? (aleXXX)
1484  if (e->key() == d->contextMenuKey)
1485  {
1486  emit menuShortCutPressed (this, currentItem());
1487  return;
1488  }
1489 
1490  if (d->selectionMode != FileManager)
1491  TQListView::keyPressEvent (e);
1492  else
1493  fileManagerKeyPressEvent (e);
1494 }
1495 
1496 void KListView::activateAutomaticSelection()
1497 {
1498  d->selectedBySimpleMove=true;
1499  d->selectedUsingMouse=false;
1500  if (currentItem())
1501  {
1502  currentItem()->setSelected(true);
1503  currentItem()->repaint();
1504  emit selectionChanged();
1505  };
1506 }
1507 
1508 void KListView::deactivateAutomaticSelection()
1509 {
1510  d->selectedBySimpleMove=false;
1511 }
1512 
1513 bool KListView::automaticSelection() const
1514 {
1515  return d->selectedBySimpleMove;
1516 }
1517 
1518 void KListView::resetKeyboardSelectionOperation()
1519 {
1520  d->wasShiftEvent = false;
1521  d->selectionDirection = 0;
1522 }
1523 
1524 void KListView::setActiveMultiSelectItem(TQListViewItem *item) {
1525  TQListViewItem* origItem = currentItem();
1526  if (!d->initialFileManagerItem) {
1527  d->initialFileManagerItem = origItem;
1528  }
1529  setCurrentItem(item);
1530 }
1531 
1532 void KListView::fileManagerKeyPressEvent (TQKeyEvent* e)
1533 {
1534  //don't care whether it's on the keypad or not
1535  int e_state=(e->state() & ~Keypad);
1536 
1537  // Handle non-control keypresses
1538  if ((e->key()!=Key_Shift) && (e->key()!=Key_Control)
1539  && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) {
1540  if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) {
1541  selectAll(false);
1542  d->selectionRegion = 0;
1543  d->initialFileManagerItem = NULL;
1544  }
1545  d->selectionDirection=0;
1546  d->wasShiftEvent = (e_state == ShiftButton);
1547  }
1548 
1549  //d->wasShiftEvent = (e_state == ShiftButton);
1550 
1551  TQListViewItem* item = currentItem();
1552  if (!item) {
1553  return;
1554  }
1555 
1556  TQListViewItem* repaintItem1 = item;
1557  TQListViewItem* repaintItem2 = 0L;
1558  TQListViewItem* visItem = 0L;
1559 
1560  TQListViewItem* nextItem = 0L;
1561  int items = 0;
1562 
1563  bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton));
1564  int selectedItems(0);
1565  for (TQListViewItem *tmpItem=firstChild(); tmpItem; tmpItem=tmpItem->nextSibling()) {
1566  if (tmpItem->isSelected()) selectedItems++;
1567  }
1568 
1569  if (((!selectedItems) || ((selectedItems==1) && (d->selectedUsingMouse)))
1570  && (e_state==Qt::NoButton)
1571  && ((e->key()==Key_Down)
1572  || (e->key()==Key_Up)
1573  || (e->key()==Key_Next)
1574  || (e->key()==Key_Prior)
1575  || (e->key()==Key_Home)
1576  || (e->key()==Key_End))) {
1577  d->selectedBySimpleMove=true;
1578  d->selectedUsingMouse=false;
1579  }
1580  else if (selectedItems>1) {
1581  d->selectedBySimpleMove=false;
1582  }
1583 
1584  bool emitSelectionChanged(false);
1585 
1586  switch (e->key()) {
1587  case Key_Escape:
1588  selectAll(false);
1589  emitSelectionChanged=true;
1590  break;
1591 
1592  case Key_Space:
1593  //toggle selection of current item
1594  if (d->selectedBySimpleMove) {
1595  d->selectedBySimpleMove=false;
1596  }
1597  item->setSelected(!item->isSelected());
1598  emitSelectionChanged=true;
1599  break;
1600 
1601  case Key_Insert:
1602  //toggle selection of current item and move to the next item
1603  if (d->selectedBySimpleMove) {
1604  d->selectedBySimpleMove=false;
1605  if (!item->isSelected()) item->setSelected(true);
1606  }
1607  else {
1608  item->setSelected(!item->isSelected());
1609  }
1610 
1611  nextItem=item->itemBelow();
1612 
1613  if (nextItem) {
1614  repaintItem2=nextItem;
1615  visItem=nextItem;
1616  setCurrentItem(nextItem);
1617  }
1618  d->selectionDirection=1;
1619  emitSelectionChanged=true;
1620  break;
1621 
1622  case Key_Down:
1623  nextItem=item->itemBelow();
1624  if (shiftOrCtrl) {
1625  d->selectionDirection=1;
1626  d->selectedBySimpleMove=false;
1627  if (!d->initialFileManagerItem) {
1628  d->initialFileManagerItem = item;
1629  item->setSelected(true);
1630  if (nextItem) {
1631  nextItem->setSelected(true);
1632  }
1633  emitSelectionChanged=true;
1634  d->selectionRegion=1;
1635  }
1636  else {
1637  if (item == d->initialFileManagerItem) {
1638  item->setSelected(true);
1639  if (nextItem) {
1640  nextItem->setSelected(true);
1641  }
1642  emitSelectionChanged=true;
1643  d->selectionRegion=1;
1644  }
1645  else {
1646  if (d->selectionRegion == 1) {
1647  if (nextItem) {
1648  nextItem->setSelected(true);
1649  }
1650  emitSelectionChanged=true;
1651  }
1652  else if (d->selectionRegion == -1) {
1653  item->setSelected(false);
1654  emitSelectionChanged=true;
1655  }
1656  }
1657  }
1658  }
1659  else if ((d->selectedBySimpleMove) && (nextItem)) {
1660  item->setSelected(false);
1661  emitSelectionChanged=true;
1662  }
1663 
1664  if (nextItem) {
1665  if (d->selectedBySimpleMove) {
1666  nextItem->setSelected(true);
1667  }
1668  repaintItem2=nextItem;
1669  visItem=nextItem;
1670  setCurrentItem(nextItem);
1671  }
1672  break;
1673 
1674  case Key_Up:
1675  nextItem=item->itemAbove();
1676  if (shiftOrCtrl) {
1677  d->selectionDirection=-1;
1678  d->selectedBySimpleMove=false;
1679  if (!d->initialFileManagerItem) {
1680  d->initialFileManagerItem = item;
1681  item->setSelected(true);
1682  if (nextItem) {
1683  nextItem->setSelected(true);
1684  }
1685  emitSelectionChanged=true;
1686  d->selectionRegion=-1;
1687  }
1688  else {
1689  if (item == d->initialFileManagerItem) {
1690  item->setSelected(true);
1691  if (nextItem) {
1692  nextItem->setSelected(true);
1693  }
1694  emitSelectionChanged=true;
1695  d->selectionRegion=-1;
1696  }
1697  else {
1698  if (d->selectionRegion == -1) {
1699  if (nextItem) {
1700  nextItem->setSelected(true);
1701  }
1702  emitSelectionChanged=true;
1703  }
1704  else if (d->selectionRegion == 1) {
1705  item->setSelected(false);
1706  emitSelectionChanged=true;
1707  }
1708  }
1709  }
1710  }
1711  else if ((d->selectedBySimpleMove) && (nextItem)) {
1712  item->setSelected(false);
1713  emitSelectionChanged=true;
1714  }
1715 
1716  if (nextItem) {
1717  if (d->selectedBySimpleMove) {
1718  nextItem->setSelected(true);
1719  }
1720  repaintItem2=nextItem;
1721  visItem=nextItem;
1722  setCurrentItem(nextItem);
1723  }
1724  break;
1725 
1726  case Key_End:
1727  // move to the last item and toggle selection of all items in-between
1728  nextItem=item;
1729  if (d->selectedBySimpleMove) {
1730  item->setSelected(false);
1731  }
1732  if (shiftOrCtrl) {
1733  d->selectedBySimpleMove=false;
1734  }
1735 
1736  while (nextItem) {
1737  if (shiftOrCtrl) {
1738  if (!d->initialFileManagerItem) {
1739  d->initialFileManagerItem = nextItem;
1740  nextItem->setSelected(true);
1741  emitSelectionChanged=true;
1742  d->selectionRegion=1;
1743  }
1744  else {
1745  if (nextItem == d->initialFileManagerItem) {
1746  nextItem->setSelected(true);
1747  emitSelectionChanged=true;
1748  d->selectionRegion=1;
1749  }
1750  else {
1751  if (d->selectionRegion == 1) {
1752  nextItem->setSelected(true);
1753  emitSelectionChanged=true;
1754  }
1755  else if (d->selectionRegion == -1) {
1756  nextItem->setSelected(false);
1757  emitSelectionChanged=true;
1758  }
1759  }
1760  }
1761  }
1762  if (!nextItem->itemBelow()) {
1763  if (d->selectedBySimpleMove) {
1764  nextItem->setSelected(true);
1765  }
1766  repaintItem2=nextItem;
1767  visItem=nextItem;
1768  setCurrentItem(nextItem);
1769  }
1770  nextItem=nextItem->itemBelow();
1771  }
1772  emitSelectionChanged=true;
1773  break;
1774 
1775  case Key_Home:
1776  // move to the first item and toggle selection of all items in-between
1777  nextItem=item;
1778  if (d->selectedBySimpleMove) {
1779  item->setSelected(false);
1780  }
1781  if (shiftOrCtrl) {
1782  d->selectedBySimpleMove=false;
1783  }
1784 
1785  while (nextItem) {
1786  if (shiftOrCtrl) {
1787  if (!d->initialFileManagerItem) {
1788  d->initialFileManagerItem = nextItem;
1789  nextItem->setSelected(true);
1790  emitSelectionChanged=true;
1791  d->selectionRegion=-1;
1792  }
1793  else {
1794  if (nextItem == d->initialFileManagerItem) {
1795  nextItem->setSelected(true);
1796  emitSelectionChanged=true;
1797  d->selectionRegion=-1;
1798  }
1799  else {
1800  if (d->selectionRegion == -1) {
1801  nextItem->setSelected(true);
1802  emitSelectionChanged=true;
1803  }
1804  else if (d->selectionRegion == 1) {
1805  nextItem->setSelected(false);
1806  emitSelectionChanged=true;
1807  }
1808  }
1809  }
1810  }
1811  if (!nextItem->itemAbove()) {
1812  if (d->selectedBySimpleMove) {
1813  nextItem->setSelected(true);
1814  }
1815  repaintItem2=nextItem;
1816  visItem=nextItem;
1817  setCurrentItem(nextItem);
1818  }
1819  nextItem=nextItem->itemAbove();
1820  }
1821  emitSelectionChanged=true;
1822  break;
1823 
1824  case Key_Next:
1825  items=visibleHeight()/item->height();
1826  nextItem=item;
1827  if (d->selectedBySimpleMove) {
1828  item->setSelected(false);
1829  }
1830  if (shiftOrCtrl) {
1831  d->selectedBySimpleMove=false;
1832  d->selectionDirection=1;
1833  }
1834 
1835  for (int i=0; i<items; i++) {
1836  if (shiftOrCtrl) {
1837  if (!d->initialFileManagerItem) {
1838  d->initialFileManagerItem = nextItem;
1839  nextItem->setSelected(true);
1840  emitSelectionChanged=true;
1841  d->selectionRegion=1;
1842  }
1843  else {
1844  if (nextItem == d->initialFileManagerItem) {
1845  nextItem->setSelected(true);
1846  emitSelectionChanged=true;
1847  d->selectionRegion=1;
1848  }
1849  else {
1850  if (d->selectionRegion == 1) {
1851  nextItem->setSelected(true);
1852  emitSelectionChanged=true;
1853  }
1854  else if (d->selectionRegion == -1) {
1855  if (i==items-1) {
1856  nextItem->setSelected(true);
1857  }
1858  else {
1859  nextItem->setSelected(false);
1860  }
1861  emitSelectionChanged=true;
1862  }
1863  }
1864  }
1865  }
1866  // last item
1867  if ((i==items-1) || (!nextItem->itemBelow())) {
1868  if (d->selectedBySimpleMove) {
1869  nextItem->setSelected(true);
1870  }
1871  ensureItemVisible(nextItem);
1872  setCurrentItem(nextItem);
1873  update();
1874  if ((shiftOrCtrl) || (d->selectedBySimpleMove)) {
1875  emit selectionChanged();
1876  }
1877  return;
1878  }
1879  nextItem=nextItem->itemBelow();
1880  }
1881  break;
1882 
1883  case Key_Prior:
1884  items=visibleHeight()/item->height();
1885  nextItem=item;
1886  if (d->selectedBySimpleMove) {
1887  item->setSelected(false);
1888  }
1889  if (shiftOrCtrl) {
1890  d->selectionDirection=-1;
1891  d->selectedBySimpleMove=false;
1892  }
1893 
1894  for (int i=0; i<items; i++) {
1895  if (shiftOrCtrl) {
1896  if (!d->initialFileManagerItem) {
1897  d->initialFileManagerItem = nextItem;
1898  nextItem->setSelected(true);
1899  emitSelectionChanged=true;
1900  d->selectionRegion=-1;
1901  }
1902  else {
1903  if (nextItem == d->initialFileManagerItem) {
1904  nextItem->setSelected(true);
1905  emitSelectionChanged=true;
1906  d->selectionRegion=-1;
1907  }
1908  else {
1909  if (d->selectionRegion == -1) {
1910  nextItem->setSelected(true);
1911  emitSelectionChanged=true;
1912  }
1913  else if (d->selectionRegion == 1) {
1914  if (i==items-1) {
1915  nextItem->setSelected(true);
1916  }
1917  else {
1918  nextItem->setSelected(false);
1919  }
1920  emitSelectionChanged=true;
1921  }
1922  }
1923  }
1924  }
1925  // last item
1926  if ((i==items-1) || (!nextItem->itemAbove())) {
1927  if (d->selectedBySimpleMove) {
1928  nextItem->setSelected(true);
1929  }
1930  ensureItemVisible(nextItem);
1931  setCurrentItem(nextItem);
1932  update();
1933  if ((shiftOrCtrl) || (d->selectedBySimpleMove)) {
1934  emit selectionChanged();
1935  }
1936  return;
1937  }
1938  nextItem=nextItem->itemAbove();
1939  }
1940  break;
1941 
1942  case Key_Minus:
1943  if ( item->isOpen() ) {
1944  setOpen( item, false );
1945  }
1946  break;
1947  case Key_Plus:
1948  if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) {
1949  setOpen( item, true );
1950  }
1951  break;
1952  default:
1953  bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control)
1954  && (e->key()!=Key_Meta) && (e->key()!=Key_Alt));
1955 
1956  bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected());
1957  if (realKey && selectCurrentItem) {
1958  item->setSelected(false);
1959  }
1960  //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX)
1961  TQListView::SelectionMode oldSelectionMode = selectionMode();
1962  setSelectionMode (TQListView::Multi);
1963  TQListView::keyPressEvent (e);
1964  setSelectionMode (oldSelectionMode);
1965  if (realKey && selectCurrentItem) {
1966  currentItem()->setSelected(true);
1967  emitSelectionChanged=true;
1968  }
1969  repaintItem2=currentItem();
1970  if (realKey) {
1971  visItem=currentItem();
1972  }
1973  break;
1974  }
1975 
1976  if (visItem) {
1977  ensureItemVisible(visItem);
1978  }
1979 
1980  TQRect ir;
1981  if (repaintItem1) {
1982  ir = ir.unite( itemRect(repaintItem1) );
1983  }
1984  if (repaintItem2) {
1985  ir = ir.unite( itemRect(repaintItem2) );
1986  }
1987 
1988  if ( !ir.isEmpty() ) {
1989  // rectangle to be repainted
1990  if ( ir.x() < 0 ) {
1991  ir.moveBy( -ir.x(), 0 );
1992  }
1993  viewport()->repaint( ir, false );
1994  }
1995  /*if (repaintItem1) {
1996  repaintItem1->repaint();
1997  }
1998  if (repaintItem2) {
1999  repaintItem2->repaint();
2000  }*/
2001 
2002  update();
2003  if (emitSelectionChanged) {
2004  emit selectionChanged();
2005  }
2006 }
2007 
2008 void KListView::setSelectionModeExt (SelectionModeExt mode)
2009 {
2010  d->selectionMode = mode;
2011 
2012  switch (mode)
2013  {
2014  case Single:
2015  case Multi:
2016  case Extended:
2017  case NoSelection:
2018  setSelectionMode (static_cast<TQListView::SelectionMode>(static_cast<int>(mode)));
2019  break;
2020 
2021  case FileManager:
2022  setSelectionMode (TQListView::Extended);
2023  break;
2024 
2025  default:
2026  kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl;
2027  break;
2028  }
2029 }
2030 
2031 KListView::SelectionModeExt KListView::selectionModeExt () const
2032 {
2033  return d->selectionMode;
2034 }
2035 
2036 int KListView::itemIndex( const TQListViewItem *item ) const
2037 {
2038  if ( !item )
2039  return -1;
2040 
2041  if ( item == firstChild() )
2042  return 0;
2043  else {
2044  TQListViewItemIterator it(firstChild());
2045  uint j = 0;
2046  for (; it.current() && it.current() != item; ++it, ++j );
2047 
2048  if( !it.current() )
2049  return -1;
2050 
2051  return j;
2052  }
2053 }
2054 
2055 TQListViewItem* KListView::itemAtIndex(int index)
2056 {
2057  if (index<0)
2058  return 0;
2059 
2060  int j(0);
2061  for (TQListViewItemIterator it=firstChild(); it.current(); ++it)
2062  {
2063  if (j==index)
2064  return it.current();
2065  ++j;
2066  };
2067  return 0;
2068 }
2069 
2070 
2071 void KListView::emitContextMenu (KListView*, TQListViewItem* i)
2072 {
2073  TQPoint p;
2074 
2075  if (i)
2076  p = viewport()->mapToGlobal(itemRect(i).center());
2077  else
2078  p = mapToGlobal(rect().center());
2079 
2080  emit contextMenu (this, i, p);
2081 }
2082 
2083 void KListView::emitContextMenu (TQListViewItem* i, const TQPoint& p, int)
2084 {
2085  emit contextMenu (this, i, p);
2086 }
2087 
2088 void KListView::setAcceptDrops (bool val)
2089 {
2090  TQListView::setAcceptDrops (val);
2091  viewport()->setAcceptDrops (val);
2092 }
2093 
2094 int KListView::dropVisualizerWidth () const
2095 {
2096  return d->mDropVisualizerWidth;
2097 }
2098 
2099 
2100 void KListView::viewportPaintEvent(TQPaintEvent *e)
2101 {
2102  d->paintAbove = 0;
2103  d->paintCurrent = 0;
2104  d->paintBelow = 0;
2105  d->painting = true;
2106 
2107  TQListView::viewportPaintEvent(e);
2108 
2109  if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer))
2110  {
2111  TQPainter painter(viewport());
2112 
2113  // This is where we actually draw the drop-visualizer
2114  painter.fillRect(d->mOldDropVisualizer, Dense4Pattern);
2115  }
2116  if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter))
2117  {
2118  TQPainter painter(viewport());
2119 
2120  // This is where we actually draw the drop-highlighter
2121  style().tqdrawPrimitive(TQStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(),
2122  TQStyle::Style_FocusAtBorder);
2123  }
2124  d->painting = false;
2125 }
2126 
2127 void KListView::setFullWidth()
2128 {
2129  setFullWidth(true);
2130 }
2131 
2132 void KListView::setFullWidth(bool fullWidth)
2133 {
2134  d->fullWidth = fullWidth;
2135  header()->setStretchEnabled(fullWidth, columns()-1);
2136 }
2137 
2138 bool KListView::fullWidth() const
2139 {
2140  return d->fullWidth;
2141 }
2142 
2143 int KListView::addColumn(const TQString& label, int width)
2144 {
2145  int result = TQListView::addColumn(label, width);
2146  if (d->fullWidth) {
2147  header()->setStretchEnabled(false, columns()-2);
2148  header()->setStretchEnabled(true, columns()-1);
2149  }
2150  return result;
2151 }
2152 
2153 int KListView::addColumn(const TQIconSet& iconset, const TQString& label, int width)
2154 {
2155  int result = TQListView::addColumn(iconset, label, width);
2156  if (d->fullWidth) {
2157  header()->setStretchEnabled(false, columns()-2);
2158  header()->setStretchEnabled(true, columns()-1);
2159  }
2160  return result;
2161 }
2162 
2163 void KListView::removeColumn(int index)
2164 {
2165  TQListView::removeColumn(index);
2166  if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1);
2167 }
2168 
2169 void KListView::viewportResizeEvent(TQResizeEvent* e)
2170 {
2171  TQListView::viewportResizeEvent(e);
2172 }
2173 
2174 const TQColor &KListView::alternateBackground() const
2175 {
2176  return d->alternateBackground;
2177 }
2178 
2179 void KListView::setAlternateBackground(const TQColor &c)
2180 {
2181  d->alternateBackground = c;
2182  repaint();
2183 }
2184 
2185 void KListView::setShadeSortColumn(bool shadeSortColumn)
2186 {
2187  d->shadeSortColumn = shadeSortColumn;
2188  repaint();
2189 }
2190 
2191 bool KListView::shadeSortColumn() const
2192 {
2193  return d->shadeSortColumn;
2194 }
2195 
2196 void KListView::saveLayout(KConfig *config, const TQString &group) const
2197 {
2198  KConfigGroupSaver saver(config, group);
2199  TQStringList widths, order;
2200 
2201  const int colCount = columns();
2202  TQHeader* const thisHeader = header();
2203  for (int i = 0; i < colCount; ++i)
2204  {
2205  widths << TQString::number(columnWidth(i));
2206  order << TQString::number(thisHeader->mapToIndex(i));
2207  }
2208  config->writeEntry("ColumnWidths", widths);
2209  config->writeEntry("ColumnOrder", order);
2210  config->writeEntry("SortColumn", d->sortColumn);
2211  config->writeEntry("SortAscending", d->sortAscending);
2212 }
2213 
2214 void KListView::restoreLayout(KConfig *config, const TQString &group)
2215 {
2216  KConfigGroupSaver saver(config, group);
2217  TQStringList cols = config->readListEntry("ColumnWidths");
2218  int i = 0;
2219  { // scope the iterators
2220  TQStringList::ConstIterator it = cols.constBegin();
2221  const TQStringList::ConstIterator itEnd = cols.constEnd();
2222  for (; it != itEnd; ++it)
2223  setColumnWidth(i++, (*it).toInt());
2224  }
2225 
2226  // move sections in the correct sequence: from lowest to highest index position
2227  // otherwise we move a section from an index, which modifies
2228  // all index numbers to the right of the moved one
2229  cols = config->readListEntry("ColumnOrder");
2230  const int colCount = columns();
2231  for (i = 0; i < colCount; ++i) // final index positions from lowest to highest
2232  {
2233  TQStringList::ConstIterator it = cols.constBegin();
2234  const TQStringList::ConstIterator itEnd = cols.constEnd();
2235 
2236  int section = 0;
2237  for (; (it != itEnd) && ((*it).toInt() != i); ++it, ++section) ;
2238 
2239  if ( it != itEnd ) {
2240  // found the section to move to position i
2241  header()->moveSection(section, i);
2242  }
2243  }
2244 
2245  if (config->hasKey("SortColumn"))
2246  setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true));
2247 }
2248 
2249 void KListView::setSorting(int column, bool ascending)
2250 {
2251  TQListViewItem *selected = 0;
2252 
2253  if (selectionMode() == TQListView::Single) {
2254  selected = selectedItem();
2255  if (selected && !selected->isVisible())
2256  selected = 0;
2257  }
2258  else if (selectionMode() != TQListView::NoSelection) {
2259  TQListViewItem *item = firstChild();
2260  while (item && !selected) {
2261  if (item->isSelected() && item->isVisible())
2262  selected = item;
2263  item = item->itemBelow();
2264  }
2265  }
2266 
2267  d->sortColumn = column;
2268  d->sortAscending = ascending;
2269  TQListView::setSorting(column, ascending);
2270 
2271  if (selected)
2272  ensureItemVisible(selected);
2273 
2274  TQListViewItem* item = firstChild();
2275  while ( item ) {
2276  KListViewItem *kItem = dynamic_cast<KListViewItem*>(item);
2277  if (kItem) kItem->m_known = false;
2278  item = item->itemBelow();
2279  }
2280 }
2281 
2282 int KListView::columnSorted(void) const
2283 {
2284  return d->sortColumn;
2285 }
2286 
2287 bool KListView::ascendingSort(void) const
2288 {
2289  return d->sortAscending;
2290 }
2291 
2292 void KListView::takeItem(TQListViewItem *item)
2293 {
2294  if(item && item == d->editor->currentItem())
2295  d->editor->terminate();
2296 
2297  TQListView::takeItem(item);
2298 }
2299 
2300 void KListView::disableAutoSelection()
2301 {
2302  if ( d->disableAutoSelection )
2303  return;
2304 
2305  d->disableAutoSelection = true;
2306  d->autoSelect.stop();
2307  d->autoSelectDelay = -1;
2308 }
2309 
2310 void KListView::resetAutoSelection()
2311 {
2312  if ( !d->disableAutoSelection )
2313  return;
2314 
2315  d->disableAutoSelection = false;
2316  d->autoSelectDelay = KGlobalSettings::autoSelectDelay();
2317 }
2318 
2319 void KListView::doubleClicked( TQListViewItem *item, const TQPoint &pos, int c )
2320 {
2321  emit TQListView::doubleClicked( item, pos, c );
2322 }
2323 
2324 KListViewItem::KListViewItem(TQListView *parent)
2325  : TQListViewItem(parent)
2326 {
2327  init();
2328 }
2329 
2330 KListViewItem::KListViewItem(TQListViewItem *parent)
2331  : TQListViewItem(parent)
2332 {
2333  init();
2334 }
2335 
2336 KListViewItem::KListViewItem(TQListView *parent, TQListViewItem *after)
2337  : TQListViewItem(parent, after)
2338 {
2339  init();
2340 }
2341 
2342 KListViewItem::KListViewItem(TQListViewItem *parent, TQListViewItem *after)
2343  : TQListViewItem(parent, after)
2344 {
2345  init();
2346 }
2347 
2348 KListViewItem::KListViewItem(TQListView *parent,
2349  TQString label1, TQString label2, TQString label3, TQString label4,
2350  TQString label5, TQString label6, TQString label7, TQString label8)
2351  : TQListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
2352 {
2353  init();
2354 }
2355 
2356 KListViewItem::KListViewItem(TQListViewItem *parent,
2357  TQString label1, TQString label2, TQString label3, TQString label4,
2358  TQString label5, TQString label6, TQString label7, TQString label8)
2359  : TQListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
2360 {
2361  init();
2362 }
2363 
2364 KListViewItem::KListViewItem(TQListView *parent, TQListViewItem *after,
2365  TQString label1, TQString label2, TQString label3, TQString label4,
2366  TQString label5, TQString label6, TQString label7, TQString label8)
2367  : TQListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
2368 {
2369  init();
2370 }
2371 
2372 KListViewItem::KListViewItem(TQListViewItem *parent, TQListViewItem *after,
2373  TQString label1, TQString label2, TQString label3, TQString label4,
2374  TQString label5, TQString label6, TQString label7, TQString label8)
2375  : TQListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
2376 {
2377  init();
2378 }
2379 
2380 KListViewItem::~KListViewItem()
2381 {
2382  if(listView())
2383  emit static_cast<KListView *>(listView())->itemRemoved(this);
2384 }
2385 
2386 void KListViewItem::init()
2387 {
2388  m_odd = m_known = false;
2389  KListView *lv = static_cast<KListView *>(listView());
2390  setDragEnabled( dragEnabled() || lv->dragEnabled() );
2391  emit lv->itemAdded(this);
2392 }
2393 
2394 void KListViewItem::insertItem(TQListViewItem *item)
2395 {
2396  TQListViewItem::insertItem(item);
2397  if(listView())
2398  emit static_cast<KListView *>(listView())->itemAdded(item);
2399 }
2400 
2401 void KListViewItem::takeItem(TQListViewItem *item)
2402 {
2403  TQListViewItem::takeItem(item);
2404  if(listView())
2405  emit static_cast<KListView *>(listView())->itemRemoved(item);
2406 }
2407 
2408 const TQColor &KListViewItem::backgroundColor()
2409 {
2410  if (isAlternate())
2411  return static_cast< KListView* >(listView())->alternateBackground();
2412  return listView()->viewport()->colorGroup().base();
2413 }
2414 
2415 TQColor KListViewItem::backgroundColor(int column)
2416 {
2417  KListView* view = static_cast< KListView* >(listView());
2418  TQColor color = isAlternate() ?
2419  view->alternateBackground() :
2420  view->viewport()->colorGroup().base();
2421 
2422  // calculate a different color if the current column is sorted (only if more than 1 column)
2423  if ( (view->columns() > 1) && view->shadeSortColumn() && (column == view->columnSorted()) )
2424  {
2425  if ( color == Qt::black )
2426  color = TQColor(55, 55, 55); // dark gray
2427  else
2428  {
2429  int h,s,v;
2430  color.hsv(&h, &s, &v);
2431  if ( v > 175 )
2432  color = color.dark(104);
2433  else
2434  color = color.light(120);
2435  }
2436  }
2437 
2438  return color;
2439 }
2440 
2441 bool KListViewItem::isAlternate()
2442 {
2443  KListView* const lv = static_cast<KListView *>(listView());
2444  if (lv && lv->alternateBackground().isValid())
2445  {
2446  KListViewItem *above;
2447 
2448  KListView::KListViewPrivate* const lvD = lv->d;
2449 
2450  // Ok, there's some weirdness here that requires explanation as this is a
2451  // speed hack. itemAbove() is a O(n) operation (though this isn't
2452  // immediately clear) so we want to call it as infrequently as possible --
2453  // especially in the case of painting a cell.
2454  //
2455  // So, in the case that we *are* painting a cell: (1) we're assuming that
2456  // said painting is happening top to bottem -- this assumption is present
2457  // elsewhere in the implementation of this class, (2) itemBelow() is fast --
2458  // roughly constant time.
2459  //
2460  // Given these assumptions we can do a mixture of caching and telling the
2461  // next item that the when that item is the current item that the now
2462  // current item will be the item above it.
2463  //
2464  // Ideally this will make checking to see if the item above the current item
2465  // is the alternate color a constant time operation rather than 0(n).
2466 
2467  if (lvD->painting) {
2468  if (lvD->paintCurrent != this)
2469  {
2470  lvD->paintAbove = lvD->paintBelow == this ? lvD->paintCurrent : itemAbove();
2471  lvD->paintCurrent = this;
2472  lvD->paintBelow = itemBelow();
2473  }
2474 
2475  above = dynamic_cast<KListViewItem *>(lvD->paintAbove);
2476  }
2477  else
2478  {
2479  above = dynamic_cast<KListViewItem *>(itemAbove());
2480  }
2481 
2482  m_known = above ? above->m_known : true;
2483  if (m_known)
2484  {
2485  m_odd = above ? !above->m_odd : false;
2486  }
2487  else
2488  {
2489  KListViewItem *item;
2490  bool previous = true;
2491  if (parent())
2492  {
2493  item = dynamic_cast<KListViewItem *>(parent());
2494  if (item)
2495  previous = item->m_odd;
2496  item = dynamic_cast<KListViewItem *>(parent()->firstChild());
2497  }
2498  else
2499  {
2500  item = dynamic_cast<KListViewItem *>(lv->firstChild());
2501  }
2502 
2503  while(item)
2504  {
2505  previous = !previous;
2506  item->m_odd = previous;
2507  item->m_known = true;
2508  item = dynamic_cast<KListViewItem *>(item->nextSibling());
2509  }
2510  }
2511  return m_odd;
2512  }
2513  return false;
2514 }
2515 
2516 void KListViewItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment)
2517 {
2518  TQColorGroup _cg = cg;
2519  TQListView* lv = listView();
2520  const TQPixmap *pm = lv->viewport()->backgroundPixmap();
2521 
2522  if (pm && !pm->isNull())
2523  {
2524  _cg.setBrush(TQColorGroup::Base, TQBrush(backgroundColor(column), *pm));
2525  TQPoint o = p->brushOrigin();
2526  p->setBrushOrigin( o.x()-lv->contentsX(), o.y()-lv->contentsY() );
2527  }
2528  else
2529  {
2530  _cg.setColor((lv->viewport()->backgroundMode() == TQt::FixedColor) ?
2531  TQColorGroup::Background : TQColorGroup::Base,
2532  backgroundColor(column));
2533  }
2534  TQListViewItem::paintCell(p, _cg, column, width, alignment);
2535 }
2536 
2544 void KListView::selectAll( bool select )
2545 {
2546  if ( ((SelectionModeExt)selectionMode() == Multi) || ((SelectionModeExt)selectionMode() == Extended) ) {
2547  bool b = signalsBlocked();
2548  blockSignals( TRUE );
2549  bool anything = FALSE;
2550  TQListViewItemIterator it( this );
2551  while ( it.current() ) {
2552  TQListViewItem *i = it.current();
2553  if ( select == TRUE ) {
2554  if ( (bool)i->isVisible() == TRUE ) {
2555  i->setSelected( TRUE );
2556  anything = TRUE;
2557  }
2558  if ( (bool)i->isVisible() == FALSE ) {
2559  i->setSelected( FALSE );
2560  anything = TRUE;
2561  }
2562  }
2563  else {
2564  if ( (bool)i->isSelected() != select ) {
2565  i->setSelected( select );
2566  anything = TRUE;
2567  }
2568  }
2569  ++it;
2570  }
2571  blockSignals( b );
2572  if ( anything ) {
2573  emit selectionChanged();
2574 // d->useDoubleBuffer = TRUE;
2575  triggerUpdate();
2576  }
2577  } else if ( currentItem() ) {
2578  TQListViewItem * i = currentItem();
2579  setSelected( i, select );
2580  }
2581 }
2582 
2583 void KListView::virtual_hook( int, void* )
2584 { /*BASE::virtual_hook( id, data );*/ }
2585 
2586 #include "klistview.moc"
2587 #include "klistviewlineedit.moc"
2588 
2589 // vim: noet
KListView::dropHighlighter
bool dropHighlighter() const
Definition: klistview.cpp:1456
KListView::leaveEvent
virtual void leaveEvent(TQEvent *e)
Reimplemented for internal reasons.
Definition: klistview.cpp:761
KLineEdit::keyPressEvent
virtual void keyPressEvent(TQKeyEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:440
KListView::setDragEnabled
virtual void setDragEnabled(bool b)
Enable/Disable the dragging of items.
Definition: klistview.cpp:1210
KGlobalSettings::alternateBackgroundColor
static TQColor alternateBackgroundColor()
KListView::activateAutomaticSelection
void activateAutomaticSelection()
In FileManager selection mode: explicitly activate the mode in which the current item is automaticall...
Definition: klistview.cpp:1496
KLineEdit::focusOutEvent
virtual void focusOutEvent(TQFocusEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:1355
KListView::setRenameable
void setRenameable(int column, bool yesno=true)
By default, if you called setItemsRenameable(true), only the first column is renameable.
Definition: klistview.cpp:1410
KListView::renameLineEdit
KLineEdit * renameLineEdit() const
Definition: klistview.cpp:1164
KListView::slotOnViewport
void slotOnViewport()
Accessory slot for AutoSelect/ChangeCursorOverItem.
Definition: klistview.cpp:548
KListView::slotAutoSelect
void slotAutoSelect()
Process AutoSelection.
Definition: klistview.cpp:606
KListView::createChildren
bool createChildren() const KDE_DEPRECATED
For future expansions.
Definition: klistview.cpp:1435
KListView::movableDropEvent
virtual void movableDropEvent(TQListViewItem *parent, TQListViewItem *afterme)
Handle dropEvent when itemsMovable() is set to true.
Definition: klistview.cpp:953
KListViewItem
A listview item with support for alternate background colors.
Definition: klistview.h:1033
KListView::moved
void moved()
This signal is emitted when ever the user moves an item in the list via DnD.
KListView::findDrop
virtual void findDrop(const TQPoint &pos, TQListViewItem *&parent, TQListViewItem *&after)
Where is the nearest TQListViewItem that I'm going to drop?
Definition: klistview.cpp:1075
KGlobalSettings::singleClick
static bool singleClick()
KListView::setActiveMultiSelectItem
void setActiveMultiSelectItem(TQListViewItem *item)
In FileManager selection mode: set the current keyboard cursor selection item; e.g.
Definition: klistview.cpp:1524
KListView::fullWidth
bool fullWidth() const
Returns whether the last column is set to fit the available width.
KListView::setTabOrderedRenaming
void setTabOrderedRenaming(bool b)
Enable/disable tabbing between editable cells.
Definition: klistview.cpp:1471
KListView::alternateBackground
const TQColor & alternateBackground() const
KListView::setFullWidth
void setFullWidth() KDE_DEPRECATED
Definition: klistview.cpp:2127
KListView::tabOrderedRenaming
bool tabOrderedRenaming() const
Returns whether tab ordered renaming is enabled.
Definition: klistview.cpp:1476
KListView::contentsDragLeaveEvent
virtual void contentsDragLeaveEvent(TQDragLeaveEvent *event)
Reimplemented for internal reasons.
Definition: klistview.cpp:1053
KListView::saveLayout
void saveLayout(KConfig *config, const TQString &group) const
Saves the list view's layout (column widtsh, column order, sort column) to a KConfig group...
Definition: klistview.cpp:2196
KListView::drawDropVisualizer
virtual TQRect drawDropVisualizer(TQPainter *p, TQListViewItem *parent, TQListViewItem *after)
Paint the drag line.
Definition: klistview.cpp:1323
KListView::slotHeaderChanged
void slotHeaderChanged()
Reacts to header changes in full width mode.
Definition: klistview.cpp:682
KListView::selectAll
virtual void selectAll(bool select)
Override TQListView selectAll() so that filtered items are not selected.
Definition: klistview.cpp:2544
KConfig::writeEntry
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
KListView::drawItemHighlighter
virtual TQRect drawItemHighlighter(TQPainter *painter, TQListViewItem *item)
Paint the drag rectangle.
Definition: klistview.cpp:1370
KListView::contentsMouseMoveEvent
virtual void contentsMouseMoveEvent(TQMouseEvent *e)
Reimplemented for internal reasons.
Definition: klistview.cpp:823
KListView::setItemsMovable
virtual void setItemsMovable(bool b)
Set whether items in the list view can be moved.
Definition: klistview.cpp:1189
KGlobalSettings::showContextMenusOnPress
static bool showContextMenusOnPress()
kdDebug
kdbgstream kdDebug(int area=0)
KListView::shadeSortColumn
bool shadeSortColumn(void) const
See if the sort column should be drawn shaded.
KListView::showTooltip
virtual bool showTooltip(TQListViewItem *item, const TQPoint &pos, int column) const
Definition: klistview.cpp:1461
KListView::contentsDropEvent
virtual void contentsDropEvent(TQDropEvent *)
Reimplemented for internal reasons.
Definition: klistview.cpp:927
KListView::automaticSelection
bool automaticSelection() const
In FileManager selection mode: return whether it is currently in the mode where the current item is s...
Definition: klistview.cpp:1513
KListView::restoreLayout
void restoreLayout(KConfig *config, const TQString &group)
Reads the list view's layout from a KConfig group as stored with saveLayout.
Definition: klistview.cpp:2214
KListView::~KListView
virtual ~KListView()
Destructor.
Definition: klistview.cpp:476
KListView
This Widget extends the functionality of TQListView to honor the system wide settings for Single Clic...
Definition: klistview.h:53
KListView::setSelectionModeExt
void setSelectionModeExt(SelectionModeExt mode)
Set the selection mode.
Definition: klistview.cpp:2008
KListView::cleanDropVisualizer
void cleanDropVisualizer()
Repaint the rect where I was drawing the drop line.
Definition: klistview.cpp:1060
KListView::setAutoOpen
virtual void setAutoOpen(bool b)
Enable/Disable AutoOpen (not implemented currently).
Definition: klistview.cpp:1220
KListView::lastItem
TQListViewItem * lastItem() const
Definition: klistview.cpp:1154
KListView::slotSettingsChanged
void slotSettingsChanged(int)
Update internal settings whenever the global ones change.
Definition: klistview.cpp:557
KListViewLineEdit::focusOutEvent
virtual void focusOutEvent(TQFocusEvent *)
Re-implemented for internal reasons.
Definition: klistview.cpp:387
KConfig::readBoolEntry
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
KListView::contentsMousePressEvent
virtual void contentsMousePressEvent(TQMouseEvent *e)
Reimplemented for internal reasons.
Definition: klistview.cpp:776
KListView::emitContextMenu
void emitContextMenu(TQListViewItem *, const TQPoint &, int)
Emit the contextMenu signal.
Definition: klistview.cpp:2083
KListView::setAcceptDrops
virtual void setAcceptDrops(bool)
Reimplemented for internal reasons.
Definition: klistview.cpp:2088
KListViewItem::isAlternate
bool isAlternate()
returns true if this item is to be drawn with the alternate background
Definition: klistview.cpp:2441
KListView::viewportResizeEvent
virtual void viewportResizeEvent(TQResizeEvent *e)
Reimplemented for setFullWidth()
Definition: klistview.cpp:2169
KListView::contextMenu
void contextMenu(KListView *l, TQListViewItem *i, const TQPoint &p)
This signal is emitted whenever a context-menu should be shown for item i.
KListView::setDropHighlighter
virtual void setDropHighlighter(bool b)
Enable/Disable the drawing of a drop-highlighter (a rectangle around the item under the mouse cursor)...
Definition: klistview.cpp:1451
kdWarning
kdbgstream kdWarning(int area=0)
KListView::itemIndex
int itemIndex(const TQListViewItem *item) const
Returns the index of item within the item tree or -1 if item doesn't exist in this list view...
Definition: klistview.cpp:2036
KListView::rename
virtual void rename(TQListViewItem *item, int c)
Rename column c of item.
Definition: klistview.cpp:1396
KListView::focusInEvent
virtual void focusInEvent(TQFocusEvent *fe)
Reimplemented for internal reasons.
Definition: klistview.cpp:723
KListView::contentsMouseReleaseEvent
virtual void contentsMouseReleaseEvent(TQMouseEvent *)
Reimplemented for internal reasons.
Definition: klistview.cpp:863
KListView::dropVisualizerWidth
int dropVisualizerWidth() const
The dropVisualizerWidth defaults to 4.
KListView::ascendingSort
bool ascendingSort(void) const
Definition: klistview.cpp:2287
KListView::addColumn
virtual int addColumn(const TQString &label, int width=-1)
Reimplemented for full width support.
Definition: klistview.cpp:2143
KListView::SelectionModeExt
SelectionModeExt
Possible selection modes.
Definition: klistview.h:105
KConfigGroupSaver
KListView::focusOutEvent
virtual void focusOutEvent(TQFocusEvent *fe)
Reimplemented for internal reasons.
Definition: klistview.cpp:739
KListView::tooltip
virtual TQString tooltip(TQListViewItem *item, int column) const
Definition: klistview.cpp:1466
KListView::autoOpen
bool autoOpen() const
KListView::removeColumn
virtual void removeColumn(int index)
Reimplemented for full width support.
Definition: klistview.cpp:2163
KListView::columnSorted
int columnSorted(void) const
Definition: klistview.cpp:2282
KListView::itemsRenameable
bool itemsRenameable() const
KGlobalSettings
KListView::startDrag
virtual void startDrag()
This method calls dragObject() and starts the drag.
Definition: klistview.cpp:1169
KListView::itemsMovable
bool itemsMovable() const
KListView::resetKeyboardSelectionOperation
void resetKeyboardSelectionOperation()
In FileManager selection mode: reset the keyboard selection operation; e.g.
Definition: klistview.cpp:1518
KListView::setSorting
virtual void setSorting(int column, bool ascending=true)
Reimplemented to remember the current sort column and order.
Definition: klistview.cpp:2249
KListView::viewportPaintEvent
virtual void viewportPaintEvent(TQPaintEvent *)
Reimplemented for internal reasons.
Definition: klistview.cpp:2100
KListView::selectedItems
TQPtrList< TQListViewItem > selectedItems() const
Definition: klistview.cpp:1240
KGlobalSettings::changeCursorOverIcon
static bool changeCursorOverIcon()
KListView::resetAutoSelection
void resetAutoSelection()
Reset AutoSelection to the system wide setting.
Definition: klistview.cpp:2310
KListView::acceptDrag
virtual bool acceptDrag(TQDropEvent *event) const
Definition: klistview.cpp:1425
KListView::contentsMouseDoubleClickEvent
virtual void contentsMouseDoubleClickEvent(TQMouseEvent *e)
Reimplemented for internal reasons.
Definition: klistview.cpp:896
KConfig
KListView::lastChild
TQListViewItem * lastChild() const
Definition: klistview.cpp:1144
KLineEdit
An enhanced TQLineEdit widget for inputting text.
Definition: klineedit.h:145
KListView::selectionModeExt
SelectionModeExt selectionModeExt() const
Definition: klistview.cpp:2031
KListView::setShadeSortColumn
void setShadeSortColumn(bool shadeSortColumn)
Set to true if the currently sorted column should be drawn shaded.
Definition: klistview.cpp:2185
KListView::contentsDragMoveEvent
virtual void contentsDragMoveEvent(TQDragMoveEvent *event)
Reimplemented for internal reasons.
Definition: klistview.cpp:1003
KListView::takeItem
virtual void takeItem(TQListViewItem *i)
Reimplemented for internal reasons.
Definition: klistview.cpp:2292
KConfig::hasKey
bool hasKey(const TQString &key) const
KGlobalSettings::contextMenuKey
static int contextMenuKey()
KListView::doubleClicked
void doubleClicked(TQListViewItem *item, const TQPoint &pos, int c)
Definition: klistview.cpp:2319
KListView::deactivateAutomaticSelection
void deactivateAutomaticSelection()
In FileManager selection mode: explicitly deactivate the mode in which the current item is automatica...
Definition: klistview.cpp:1508
KListView::setItemsRenameable
virtual void setItemsRenameable(bool b)
Enables inplace-renaming of items.
Definition: klistview.cpp:1199
KConfig::readNumEntry
int readNumEntry(const TQString &pKey, int nDefault=0) const
KListViewLineEdit::keyPressEvent
virtual void keyPressEvent(TQKeyEvent *e)
Re-implemented for internal reasons.
Definition: klistview.cpp:349
KListViewLineEdit::slotItemRemoved
void slotItemRemoved(TQListViewItem *i)
Definition: klistview.cpp:420
KListView::moveItem
void moveItem(TQListViewItem *item, TQListViewItem *parent, TQListViewItem *after)
Arbitrarily move item to parent, positioned immediately after item after.
Definition: klistview.cpp:1282
KListView::menuShortCutPressed
void menuShortCutPressed(KListView *list, TQListViewItem *item)
This signal is emitted when the shortcut key for popup-menus is pressed.
KListViewItem::backgroundColor
const TQColor & backgroundColor() KDE_DEPRECATED
returns the background color for this item
Definition: klistview.cpp:2408
KListView::setDropVisualizer
virtual void setDropVisualizer(bool b)
Enable/Disable the drawing of a drop-visualizer (a bar that shows where a dropped item would be inser...
Definition: klistview.cpp:1235
KListViewLineEdit
the editor for a KListView.
Definition: klistviewlineedit.h:28
KListView::setCreateChildren
virtual void setCreateChildren(bool b) KDE_DEPRECATED
For future expansions.
Definition: klistview.cpp:1430
KGlobalSettings::autoSelectDelay
static int autoSelectDelay()
KListViewLineEdit::selectNextCell
void selectNextCell(TQListViewItem *pi, int column, bool forward)
Definition: klistview.cpp:282
KCursor::handCursor
static TQCursor handCursor()
Returns the proper hand cursor according to the current GUI style (static function).
Definition: kcursor.cpp:43
KListView::fileManagerKeyPressEvent
void fileManagerKeyPressEvent(TQKeyEvent *)
A special keyPressEvent (for FileManager selection mode).
Definition: klistview.cpp:1532
KStdAccel::home
const KShortcut & home()
KListView::setTooltipColumn
virtual void setTooltipColumn(int column)
Set which column should be used for automatic tooltips.
Definition: klistview.cpp:1446
KListView::contentsDragEnterEvent
virtual void contentsDragEnterEvent(TQDragEnterEvent *)
Reimplemented for internal reasons.
Definition: klistview.cpp:1312
KListView::dropped
void dropped(TQDropEvent *e, TQListViewItem *after)
This signal gets emitted whenever something acceptable is dropped onto the listview.
KListView::cleanItemHighlighter
void cleanItemHighlighter()
Repaint the rect where I was drawing the drop rectangle.
Definition: klistview.cpp:1386
KListView::dragObject
virtual TQDragObject * dragObject()
Definition: klistview.cpp:1180
KListView::itemRenamed
void itemRenamed(TQListViewItem *item, const TQString &str, int col)
This signal gets emitted when an item is renamed via in-place renaming.
KListView::dropVisualizer
bool dropVisualizer() const
KListView::keyPressEvent
virtual void keyPressEvent(TQKeyEvent *)
Reimplemented for internal reasons.
Definition: klistview.cpp:1481
KListView::KListView
KListView(TQWidget *parent=0, const char *name=0)
Constructor.
Definition: klistview.cpp:431
KListView::dragEnabled
bool dragEnabled() const
KListView::aboutToMove
void aboutToMove()
Connect to this signal if you want to do some preprocessing before a move is made, for example, to disable sorting.
endl
kndbgstream & endl(kndbgstream &s)
KListView::isExecuteArea
virtual bool isExecuteArea(const TQPoint &point)
This function determines whether the given coordinates are within the execute area.
Definition: klistview.cpp:481
KListView::isRenameable
bool isRenameable(int column) const
Definition: klistview.cpp:1405
KListView::setAlternateBackground
void setAlternateBackground(const TQColor &c)
sets the alternate background background color.
Definition: klistview.cpp:2179
KListView::depthToPixels
int depthToPixels(int depth)
Convert the depth of an item into its indentation in pixels.
Definition: klistview.cpp:1070
KListView::setDropVisualizerWidth
void setDropVisualizerWidth(int w)
Set the width of the (default) drop-visualizer.
Definition: klistview.cpp:1318
KGlobalSettings::dndEventDelay
static int dndEventDelay()
KListView::disableAutoSelection
void disableAutoSelection()
Disable AutoSelection.
Definition: klistview.cpp:2300
KListViewItem::KListViewItem
KListViewItem(TQListView *parent)
constructors.
Definition: klistview.cpp:2324
KListView::event
virtual bool event(TQEvent *)
Reimplemented to reload the alternate background in palette changes.
Definition: klistview.cpp:768
KListView::tooltipColumn
int tooltipColumn() const
KLineEdit::setText
virtual void setText(const TQString &)
Re-implemented to enable text squeezing.
Definition: klineedit.cpp:310
KListView::slotOnItem
void slotOnItem(TQListViewItem *item)
Accessory slot for AutoSelect.
Definition: klistview.cpp:539
KConfig::readListEntry
int readListEntry(const TQString &pKey, TQStrList &list, char sep= ',') const
KListView::itemAtIndex
TQListViewItem * itemAtIndex(int index)
Returns the item of index within the item tree or 0 if index doesn't exist in this list view...
Definition: klistview.cpp:2055
KListView::executed
void executed(TQListViewItem *item)
This signal is emitted whenever the user executes an listview item.
KApplication::keyboardMouseState
static ButtonState keyboardMouseState()
KListView::emitExecute
void emitExecute(TQListViewItem *item, const TQPoint &pos, int c)
Emit signal executed.
Definition: klistview.cpp:695

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeui

Skip menu "kdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeui by doxygen 1.8.8
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |