summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/klistview.cpp
Unidiff
Diffstat (limited to 'microkde/kdeui/klistview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdeui/klistview.cpp337
1 files changed, 176 insertions, 161 deletions
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp
index 60f3084..0e98160 100644
--- a/microkde/kdeui/klistview.cpp
+++ b/microkde/kdeui/klistview.cpp
@@ -9,74 +9,89 @@
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qdragobject.h> 21#include <q3dragobject.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qheader.h> 23#include <q3header.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qstyle.h> 26#include <qstyle.h>
27#include <qpainter.h> 27#include <qpainter.h>
28//Added by qt3to4:
29#include <QDragLeaveEvent>
30#include <QKeyEvent>
31#include <Q3ValueList>
32#include <Q3PtrList>
33#include <QPixmap>
34#include <QDragEnterEvent>
35#include <QDragMoveEvent>
36#include <QDropEvent>
37#include <QResizeEvent>
38#include <QFocusEvent>
39#include <QMouseEvent>
40#include <QEvent>
41#include <QPaintEvent>
28 42
29#include <kglobalsettings.h> 43#include <kglobalsettings.h>
30#include <kconfig.h> 44#include <kconfig.h>
31#include <kconfigbase.h> 45#include <kconfigbase.h>
32//US #include <kcursor.h> 46//US #include <kcursor.h>
33#include <kapplication.h> 47#include <kapplication.h>
34//US #include <kipc.h> 48//US #include <kipc.h>
35#include <kdebug.h> 49#include <kdebug.h>
36#ifdef _WIN32_ 50#ifdef _WIN32_
37#define Q_WS_QWS 51#define Q_WS_QWS
38#endif 52#endif
39#ifndef _WIN32_ 53#ifndef _WIN32_
40#define private public 54#define private public
41#include <qlistview.h> 55#include <q3listview.h>
42#undef private 56#undef private
43#endif 57#endif
44#include "klistview.h" 58#include "klistview.h"
45//US #include "klistviewlineedit.h" 59//US #include "klistviewlineedit.h"
46#ifndef DESKTOP_VERSION 60#ifndef DESKTOP_VERSION
47#include <qpe/qpeapplication.h> 61#include <qpe/qpeapplication.h>
48#endif 62#endif
63#include <Q3Action>
49 64
50// /*US 65// /*US
51class KListView::Tooltip : public QToolTip 66class KListView::Tooltip /* TODO:hacker:TODO: : public QToolTip */
52{ 67{
53public: 68public:
54 Tooltip (KListView* parent, QToolTipGroup* group = 0L); 69 Tooltip (KListView* parent, QToolTipGroup* group = 0L);
55 virtual ~Tooltip () {} 70 virtual ~Tooltip () {}
56 71
57protected: 72protected:
58 // */ 73 // */
59 /** 74 /**
60 * Reimplemented from QToolTip for internal reasons. 75 * Reimplemented from QToolTip for internal reasons.
61 */ 76 */
62 // /*US 77 // /*US
63 virtual void maybeTip (const QPoint&); 78 virtual void maybeTip (const QPoint&);
64 79
65private: 80private:
66 KListView* mParent; 81 KListView* mParent;
67}; 82};
68 83
69KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) 84KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group)
70 : QToolTip (parent, group), 85 : /* XXX:hacker:XXX: QToolTip (parent, group), */
71 mParent (parent) 86 mParent (parent)
72{ 87{
73} 88}
74 89
75void KListView::Tooltip::maybeTip (const QPoint&) 90void KListView::Tooltip::maybeTip (const QPoint&)
76{ 91{
77 // FIXME 92 // FIXME
78} 93}
79// */ 94// */
80 95
81class KListView::KListViewPrivate 96class KListView::KListViewPrivate
82{ 97{
@@ -114,38 +129,38 @@ public:
114 showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), 129 showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()),
115 mDropVisualizerWidth (4) 130 mDropVisualizerWidth (4)
116 { 131 {
117 renameable += 0; 132 renameable += 0;
118//US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); 133//US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int)));
119 } 134 }
120 135
121 ~KListViewPrivate () 136 ~KListViewPrivate ()
122 { 137 {
123//US delete editor; 138//US delete editor;
124 } 139 }
125 140
126 QListViewItem* pCurrentItem; 141 Q3ListViewItem* pCurrentItem;
127 142
128 QTimer autoSelect; 143 QTimer autoSelect;
129 int autoSelectDelay; 144 int autoSelectDelay;
130 145
131 QTimer dragExpand; 146 QTimer dragExpand;
132 QListViewItem* dragOverItem; 147 Q3ListViewItem* dragOverItem;
133 QPoint dragOverPoint; 148 QPoint dragOverPoint;
134 149
135 QPoint startDragPos; 150 QPoint startDragPos;
136 int dragDelay; 151 int dragDelay;
137 152
138//US KListViewLineEdit *editor; 153//US KListViewLineEdit *editor;
139 QValueList<int> renameable; 154 Q3ValueList<int> renameable;
140 155
141 bool cursorInExecuteArea:1; 156 bool cursorInExecuteArea:1;
142 bool bUseSingle:1; 157 bool bUseSingle:1;
143 bool bChangeCursorOverItem:1; 158 bool bChangeCursorOverItem:1;
144 bool itemsMovable:1; 159 bool itemsMovable:1;
145 bool selectedBySimpleMove : 1; 160 bool selectedBySimpleMove : 1;
146 bool selectedUsingMouse:1; 161 bool selectedUsingMouse:1;
147 bool itemsRenameable:1; 162 bool itemsRenameable:1;
148 bool validDrag:1; 163 bool validDrag:1;
149 bool dragEnabled:1; 164 bool dragEnabled:1;
150 bool autoOpen:1; 165 bool autoOpen:1;
151 bool dropVisualizer:1; 166 bool dropVisualizer:1;
@@ -161,26 +176,26 @@ public:
161 176
162 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX 177 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX
163 int selectionDirection; 178 int selectionDirection;
164 int tooltipColumn; 179 int tooltipColumn;
165 180
166 SelectionModeExt selectionMode; 181 SelectionModeExt selectionMode;
167 int contextMenuKey; 182 int contextMenuKey;
168 bool showContextMenusOnPress; 183 bool showContextMenusOnPress;
169 184
170 QRect mOldDropVisualizer; 185 QRect mOldDropVisualizer;
171 int mDropVisualizerWidth; 186 int mDropVisualizerWidth;
172 QRect mOldDropHighlighter; 187 QRect mOldDropHighlighter;
173 QListViewItem *afterItemDrop; 188 Q3ListViewItem *afterItemDrop;
174 QListViewItem *parentItemDrop; 189 Q3ListViewItem *parentItemDrop;
175 190
176 QColor alternateBackground; 191 QColor alternateBackground;
177}; 192};
178 193
179/*US 194/*US
180KListViewLineEdit::KListViewLineEdit(KListView *parent) 195KListViewLineEdit::KListViewLineEdit(KListView *parent)
181 : KLineEdit(parent->viewport()), item(0), col(0), p(parent) 196 : KLineEdit(parent->viewport()), item(0), col(0), p(parent)
182{ 197{
183 setFrame( false ); 198 setFrame( false );
184 hide(); 199 hide();
185 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); 200 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() ));
186} 201}
@@ -217,59 +232,59 @@ void KListViewLineEdit::load(QListViewItem *i, int c)
217 fieldW -= d; 232 fieldW -= d;
218 } 233 }
219 234
220 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); 235 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2);
221 show(); 236 show();
222 setFocus(); 237 setFocus();
223} 238}
224*/ 239*/
225 /*Helper functions to for 240 /*Helper functions to for
226 *tabOrderedRename functionality. 241 *tabOrderedRename functionality.
227 */ 242 */
228 243
229static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) 244static int nextCol (KListView *pl, Q3ListViewItem *pi, int start, int dir)
230{ 245{
231 if (pi) 246 if (pi)
232 { 247 {
233 //Find the next renameable column in the current row 248 //Find the next renameable column in the current row
234 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) 249 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir)
235 if (pl->isRenameable(start)) 250 if (pl->isRenameable(start))
236 return start; 251 return start;
237 } 252 }
238 253
239 return -1; 254 return -1;
240} 255}
241 256
242static QListViewItem *prevItem (QListViewItem *pi) 257static Q3ListViewItem *prevItem (Q3ListViewItem *pi)
243{ 258{
244 QListViewItem *pa = pi->itemAbove(); 259 Q3ListViewItem *pa = pi->itemAbove();
245 260
246 /*Does what the QListViewItem::previousSibling() 261 /*Does what the QListViewItem::previousSibling()
247 *of my dreams would do. 262 *of my dreams would do.
248 */ 263 */
249 if (pa && pa->parent() == pi->parent()) 264 if (pa && pa->parent() == pi->parent())
250 return pa; 265 return pa;
251 266
252 return NULL; 267 return NULL;
253} 268}
254 269
255static QListViewItem *lastQChild (QListViewItem *pi) 270static Q3ListViewItem *lastQChild (Q3ListViewItem *pi)
256{ 271{
257 if (pi) 272 if (pi)
258 { 273 {
259 /*Since there's no QListViewItem::lastChild(). 274 /*Since there's no QListViewItem::lastChild().
260 *This finds the last sibling for the given 275 *This finds the last sibling for the given
261 *item. 276 *item.
262 */ 277 */
263 for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) 278 for (Q3ListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling())
264 pi = pt; 279 pi = pt;
265 } 280 }
266 281
267 return pi; 282 return pi;
268} 283}
269/*US 284/*US
270void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) 285void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward)
271{ 286{
272 const int ncols = p->columns(); 287 const int ncols = p->columns();
273 const int dir = forward ? +1 : -1; 288 const int dir = forward ? +1 : -1;
274 const int restart = forward ? 0 : (ncols - 1); 289 const int restart = forward ? 0 : (ncols - 1);
275 QListViewItem *top = (pitem && pitem->parent()) 290 QListViewItem *top = (pitem && pitem->parent())
@@ -319,28 +334,28 @@ void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool f
319#ifdef KeyPress 334#ifdef KeyPress
320#undef KeyPress 335#undef KeyPress
321#endif 336#endif
322 337
323bool KListViewLineEdit::event (QEvent *pe) 338bool KListViewLineEdit::event (QEvent *pe)
324{ 339{
325 if (pe->type() == QEvent::KeyPress) 340 if (pe->type() == QEvent::KeyPress)
326 { 341 {
327 QKeyEvent *k = (QKeyEvent *) pe; 342 QKeyEvent *k = (QKeyEvent *) pe;
328 343
329 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && 344 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) &&
330 p->tabOrderedRenaming() && p->itemsRenameable() && 345 p->tabOrderedRenaming() && p->itemsRenameable() &&
331 !(k->state() & ControlButton || k->state() & AltButton)) 346 !(k->state() & Qt::ControlButton || k->state() & AltButton))
332 { 347 {
333 selectNextCell(item, col, 348 selectNextCell(item, col,
334 (k->key() == Key_Tab && !(k->state() & ShiftButton))); 349 (k->key() == Key_Tab && !(k->state() & Qt::ShiftButton)));
335 return true; 350 return true;
336 } 351 }
337 } 352 }
338 353
339 return KLineEdit::event(pe); 354 return KLineEdit::event(pe);
340} 355}
341 356
342void KListViewLineEdit::keyPressEvent(QKeyEvent *e) 357void KListViewLineEdit::keyPressEvent(QKeyEvent *e)
343{ 358{
344 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) 359 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
345 terminate(true); 360 terminate(true);
346 else if(e->key() == Qt::Key_Escape) 361 else if(e->key() == Qt::Key_Escape)
@@ -397,37 +412,37 @@ void KListViewLineEdit::paintEvent( QPaintEvent *e )
397// selection changed -> terminate. As our "item" can be already deleted, 412// selection changed -> terminate. As our "item" can be already deleted,
398// we can't call terminate(false), because that would emit done() with 413// we can't call terminate(false), because that would emit done() with
399// a dangling pointer to "item". 414// a dangling pointer to "item".
400void KListViewLineEdit::slotSelectionChanged() 415void KListViewLineEdit::slotSelectionChanged()
401{ 416{
402 item = 0; 417 item = 0;
403 col = 0; 418 col = 0;
404 hide(); 419 hide();
405} 420}
406*/ 421*/
407 422
408KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) 423KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse )
409 : QListView( parent, name ), 424 : Q3ListView( parent, name ),
410 d (new KListViewPrivate (this)) 425 d (new KListViewPrivate (this))
411{ 426{
412#ifndef DESKTOP_VERSION 427#ifndef DESKTOP_VERSION
413 if ( emulateRightMouse ) 428 if ( emulateRightMouse )
414 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 429 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
415#endif 430#endif
416//US setDragAutoScroll(true); 431//US setDragAutoScroll(true);
417 432
418 connect( this, SIGNAL( onViewport() ), 433 connect( this, SIGNAL( onViewport() ),
419 this, SLOT( slotOnViewport() ) ); 434 this, SLOT( slotOnViewport() ) );
420 connect( this, SIGNAL( onItem( QListViewItem * ) ), 435 connect( this, SIGNAL( onItem( Q3ListViewItem * ) ),
421 this, SLOT( slotOnItem( QListViewItem * ) ) ); 436 this, SLOT( slotOnItem( Q3ListViewItem * ) ) );
422 437
423 connect (this, SIGNAL(contentsMoving(int,int)), 438 connect (this, SIGNAL(contentsMoving(int,int)),
424 this, SLOT(cleanDropVisualizer())); 439 this, SLOT(cleanDropVisualizer()));
425 connect (this, SIGNAL(contentsMoving(int,int)), 440 connect (this, SIGNAL(contentsMoving(int,int)),
426 this, SLOT(cleanItemHighlighter())); 441 this, SLOT(cleanItemHighlighter()));
427 442
428/*US 443/*US
429 slotSettingsChanged(KApplication::SETTINGS_MOUSE); 444 slotSettingsChanged(KApplication::SETTINGS_MOUSE);
430 445
431 if (kapp) 446 if (kapp)
432 { 447 {
433 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); 448 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) );
@@ -436,83 +451,83 @@ KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse
436*/ 451*/
437 slotSettingsChanged(1); //US do this to initialize the connections 452 slotSettingsChanged(1); //US do this to initialize the connections
438 453
439 454
440 connect(&d->autoSelect, SIGNAL( timeout() ), 455 connect(&d->autoSelect, SIGNAL( timeout() ),
441 this, SLOT( slotAutoSelect() ) ); 456 this, SLOT( slotAutoSelect() ) );
442 connect(&d->dragExpand, SIGNAL( timeout() ), 457 connect(&d->dragExpand, SIGNAL( timeout() ),
443 this, SLOT( slotDragExpand() ) ); 458 this, SLOT( slotDragExpand() ) );
444 459
445 // context menu handling 460 // context menu handling
446 if (d->showContextMenusOnPress) 461 if (d->showContextMenusOnPress)
447 { 462 {
448 connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), 463 connect (this, SIGNAL (rightButtonPressed (Q3ListViewItem*, const QPoint&, int)),
449 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 464 this, SLOT (emitContextMenu (Q3ListViewItem*, const QPoint&, int)));
450 } 465 }
451 else 466 else
452 { 467 {
453 connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), 468 connect (this, SIGNAL (rightButtonClicked (Q3ListViewItem*, const QPoint&, int)),
454 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 469 this, SLOT (emitContextMenu (Q3ListViewItem*, const QPoint&, int)));
455 } 470 }
456 471
457 connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), 472 connect (this, SIGNAL (menuShortCutPressed (KListView*, Q3ListViewItem*)),
458 this, SLOT (emitContextMenu (KListView*, QListViewItem*))); 473 this, SLOT (emitContextMenu (KListView*, Q3ListViewItem*)));
459 474
460 475
461 //qDebug("KListView::KListView make alternate color configurable"); 476 //qDebug("KListView::KListView make alternate color configurable");
462 d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); 477 d->alternateBackground = KGlobalSettings::alternateBackgroundColor();
463} 478}
464 479
465 480
466 481
467KListView::~KListView() 482KListView::~KListView()
468{ 483{
469 delete d; 484 delete d;
470} 485}
471 486
472bool KListView::isExecuteArea( const QPoint& point ) 487bool KListView::isExecuteArea( const QPoint& point )
473{ 488{
474 if ( itemAt( point ) ) 489 if ( itemAt( point ) )
475 return isExecuteArea( point.x() ); 490 return isExecuteArea( point.x() );
476 491
477 return false; 492 return false;
478} 493}
479QSize KListView::sizeHint() const 494QSize KListView::sizeHint() const
480{ 495{
481 //qDebug("KListView::QSize sizeHint() "); 496 //qDebug("KListView::QSize sizeHint() ");
482#ifdef DESKTOP_VERSION 497#ifdef DESKTOP_VERSION
483 return QListView::sizeHint(); 498 return Q3ListView::sizeHint();
484#else 499#else
485 return QSize ( 40, 40 ); 500 return QSize ( 40, 40 );
486#endif 501#endif
487 502
488} 503}
489bool KListView::isExecuteArea( int x ) 504bool KListView::isExecuteArea( int x )
490{ 505{
491 if( allColumnsShowFocus() ) 506 if( allColumnsShowFocus() )
492 return true; 507 return true;
493 else { 508 else {
494 int offset = 0; 509 int offset = 0;
495 int width = columnWidth( 0 ); 510 int width = columnWidth( 0 );
496 int pos = header()->mapToIndex( 0 ); 511 int pos = header()->mapToIndex( 0 );
497 512
498 for ( int index = 0; index < pos; index++ ) 513 for ( int index = 0; index < pos; index++ )
499 offset += columnWidth( header()->mapToSection( index ) ); 514 offset += columnWidth( header()->mapToSection( index ) );
500 515
501 x += contentsX(); // in case of a horizontal scrollbar 516 x += contentsX(); // in case of a horizontal scrollbar
502 return ( x > offset && x < ( offset + width ) ); 517 return ( x > offset && x < ( offset + width ) );
503 } 518 }
504} 519}
505 520
506void KListView::slotOnItem( QListViewItem *item ) 521void KListView::slotOnItem( Q3ListViewItem *item )
507{ 522{
508 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); 523 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() );
509 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { 524 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) {
510 d->autoSelect.start( d->autoSelectDelay, true ); 525 d->autoSelect.start( d->autoSelectDelay, true );
511 d->pCurrentItem = item; 526 d->pCurrentItem = item;
512 } 527 }
513} 528}
514 529
515void KListView::slotOnViewport() 530void KListView::slotOnViewport()
516{ 531{
517 if ( d->bChangeCursorOverItem ) 532 if ( d->bChangeCursorOverItem )
518 viewport()->unsetCursor(); 533 viewport()->unsetCursor();
@@ -525,30 +540,30 @@ void KListView::slotSettingsChanged(int category)
525{ 540{
526 //qDebug("KListView::slotSettingsChanged has to be verified"); 541 //qDebug("KListView::slotSettingsChanged has to be verified");
527 542
528 543
529 switch (category) 544 switch (category)
530 { 545 {
531 //US I create my private category (=1) to set the settings 546 //US I create my private category (=1) to set the settings
532 case 1: 547 case 1:
533 d->dragDelay = 2; 548 d->dragDelay = 2;
534 //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); 549 //US set explicitly d->bUseSingle = KGlobalSettings::singleClick();
535 // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); 550 // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle);
536 551
537 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 552 disconnect(this, SIGNAL (mouseButtonClicked (int, Q3ListViewItem*, const QPoint &, int)),
538 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); 553 this, SLOT (slotMouseButtonClicked (int, Q3ListViewItem*, const QPoint &, int)));
539 554
540 if( d->bUseSingle ) 555 if( d->bUseSingle )
541 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 556 connect (this, SIGNAL (mouseButtonClicked (int, Q3ListViewItem*, const QPoint &, int)),
542 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); 557 this, SLOT (slotMouseButtonClicked( int, Q3ListViewItem*, const QPoint &, int)));
543 558
544 //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); 559 //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon();
545 //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); 560 //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay();
546 561
547 if( !d->bUseSingle || !d->bChangeCursorOverItem ) 562 if( !d->bUseSingle || !d->bChangeCursorOverItem )
548 viewport()->unsetCursor(); 563 viewport()->unsetCursor();
549 564
550 break; 565 break;
551 566
552 /*US 567 /*US
553 case KApplication::SETTINGS_MOUSE: 568 case KApplication::SETTINGS_MOUSE:
554 d->dragDelay = KGlobalSettings::dndEventDelay(); 569 d->dragDelay = KGlobalSettings::dndEventDelay();
@@ -602,65 +617,65 @@ void KListView::slotAutoSelect()
602 return; 617 return;
603 618
604 if (!isActiveWindow()) 619 if (!isActiveWindow())
605 { 620 {
606 d->autoSelect.stop(); 621 d->autoSelect.stop();
607 return; 622 return;
608 } 623 }
609 624
610 //Give this widget the keyboard focus. 625 //Give this widget the keyboard focus.
611 if( !hasFocus() ) 626 if( !hasFocus() )
612 setFocus(); 627 setFocus();
613 628
614 QListViewItem* previousItem = currentItem(); 629 Q3ListViewItem* previousItem = currentItem();
615 setCurrentItem( d->pCurrentItem ); 630 setCurrentItem( d->pCurrentItem );
616 631
617#if 0 632#if 0
618#ifndef Q_WS_QWS 633#ifndef Q_WS_QWS
619 // FIXME(E): Implement for Qt Embedded 634 // FIXME(E): Implement for Qt Embedded
620 if( d->pCurrentItem ) { 635 if( d->pCurrentItem ) {
621 //Shift pressed? 636 //Shift pressed?
622 if( (keybstate & ShiftMask) ) { 637 if( (keybstate & ShiftMask) ) {
623 bool block = signalsBlocked(); 638 bool block = signalsBlocked();
624 blockSignals( true ); 639 blockSignals( true );
625 640
626 //No Ctrl? Then clear before! 641 //No Ctrl? Then clear before!
627 if( !(keybstate & ControlMask) ) 642 if( !(keybstate & ControlMask) )
628 clearSelection(); 643 clearSelection();
629 644
630 bool select = !d->pCurrentItem->isSelected(); 645 bool select = !d->pCurrentItem->isSelected();
631 bool update = viewport()->isUpdatesEnabled(); 646 bool update = viewport()->isUpdatesEnabled();
632 viewport()->setUpdatesEnabled( false ); 647 viewport()->setUpdatesEnabled( false );
633 648
634 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); 649 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos();
635 QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); 650 Q3ListViewItemIterator lit( down ? previousItem : d->pCurrentItem );
636 for ( ; lit.current(); ++lit ) { 651 for ( ; lit.current(); ++lit ) {
637 if ( down && lit.current() == d->pCurrentItem ) { 652 if ( down && lit.current() == d->pCurrentItem ) {
638 d->pCurrentItem->setSelected( select ); 653 d->pCurrentItem->setSelected( select );
639 break; 654 break;
640 } 655 }
641 if ( !down && lit.current() == previousItem ) { 656 if ( !down && lit.current() == previousItem ) {
642 previousItem->setSelected( select ); 657 previousItem->setSelected( select );
643 break; 658 break;
644 } 659 }
645 lit.current()->setSelected( select ); 660 lit.current()->setSelected( select );
646 } 661 }
647 662
648 blockSignals( block ); 663 blockSignals( block );
649 viewport()->setUpdatesEnabled( update ); 664 viewport()->setUpdatesEnabled( update );
650 triggerUpdate(); 665 triggerUpdate();
651 666
652 emit selectionChanged(); 667 emit selectionChanged();
653 668
654 if( selectionMode() == QListView::Single ) 669 if( selectionMode() == Q3ListView::Single )
655 emit selectionChanged( d->pCurrentItem ); 670 emit selectionChanged( d->pCurrentItem );
656 } 671 }
657 else if( (keybstate & ControlMask) ) 672 else if( (keybstate & ControlMask) )
658 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); 673 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() );
659 else { 674 else {
660 bool block = signalsBlocked(); 675 bool block = signalsBlocked();
661 blockSignals( true ); 676 blockSignals( true );
662 677
663 if( !d->pCurrentItem->isSelected() ) 678 if( !d->pCurrentItem->isSelected() )
664 clearSelection(); 679 clearSelection();
665 680
666 blockSignals( block ); 681 blockSignals( block );
@@ -675,55 +690,55 @@ void KListView::slotAutoSelect()
675} 690}
676 691
677void KListView::slotHeaderChanged() 692void KListView::slotHeaderChanged()
678{ 693{
679 if (d->fullWidth && columns()) 694 if (d->fullWidth && columns())
680 { 695 {
681 int w = 0; 696 int w = 0;
682 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); 697 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i);
683 setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); 698 setColumnWidth( columns() - 1, viewport()->width() - w - 1 );
684 } 699 }
685} 700}
686 701
687void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) 702void KListView::emitExecute( int buttonstate, Q3ListViewItem *item, const QPoint &pos, int c)
688{ 703{
689 // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); 704 // qDebug("KListView::emitExecute buttonstate=%i", buttonstate);
690 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { 705 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) {
691 706
692 // Double click mode ? 707 // Double click mode ?
693 if ( !d->bUseSingle ) 708 if ( !d->bUseSingle )
694 { 709 {
695 emit executed( item ); 710 emit executed( item );
696 emit executed( item, pos, c ); 711 emit executed( item, pos, c );
697 } 712 }
698 else 713 else
699 { 714 {
700 //US special implementation for embedded systems 715 //US special implementation for embedded systems
701 d->autoSelect.stop(); 716 d->autoSelect.stop();
702 717
703 //Dont emit executed if in SC mode and Shift or Ctrl are pressed 718 //Dont emit executed if in SC mode and Shift or Ctrl are pressed
704 if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { 719 if( !( (buttonstate==Qt::ShiftButton) || (buttonstate==Qt::ControlButton) )) {
705 // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { 720 // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) {
706 721
707 emit executed( item ); 722 emit executed( item );
708 emit executed( item, pos, c ); 723 emit executed( item, pos, c );
709 } 724 }
710 } 725 }
711 } 726 }
712} 727}
713 728
714void KListView::focusInEvent( QFocusEvent *fe ) 729void KListView::focusInEvent( QFocusEvent *fe )
715{ 730{
716 // kdDebug()<<"KListView::focusInEvent()"<<endl; 731 // kdDebug()<<"KListView::focusInEvent()"<<endl;
717 QListView::focusInEvent( fe ); 732 Q3ListView::focusInEvent( fe );
718 if ((d->selectedBySimpleMove) 733 if ((d->selectedBySimpleMove)
719 && (d->selectionMode == FileManager) 734 && (d->selectionMode == FileManager)
720 && (fe->reason()!=QFocusEvent::Popup) 735 && (fe->reason()!=QFocusEvent::Popup)
721 && (fe->reason()!=QFocusEvent::ActiveWindow) 736 && (fe->reason()!=QFocusEvent::ActiveWindow)
722 && (currentItem()!=0)) 737 && (currentItem()!=0))
723 { 738 {
724 currentItem()->setSelected(true); 739 currentItem()->setSelected(true);
725 currentItem()->repaint(); 740 currentItem()->repaint();
726 emit selectionChanged(); 741 emit selectionChanged();
727 }; 742 };
728} 743}
729 744
@@ -738,102 +753,102 @@ void KListView::focusOutEvent( QFocusEvent *fe )
738 && (d->selectionMode == FileManager) 753 && (d->selectionMode == FileManager)
739 && (fe->reason()!=QFocusEvent::Popup) 754 && (fe->reason()!=QFocusEvent::Popup)
740 && (fe->reason()!=QFocusEvent::ActiveWindow) 755 && (fe->reason()!=QFocusEvent::ActiveWindow)
741 && (currentItem()!=0) 756 && (currentItem()!=0)
742/*US && (!d->editor->isVisible()) */ 757/*US && (!d->editor->isVisible()) */
743 ) 758 )
744 { 759 {
745 currentItem()->setSelected(false); 760 currentItem()->setSelected(false);
746 currentItem()->repaint(); 761 currentItem()->repaint();
747 emit selectionChanged(); 762 emit selectionChanged();
748 }; 763 };
749 764
750 QListView::focusOutEvent( fe ); 765 Q3ListView::focusOutEvent( fe );
751} 766}
752 767
753void KListView::leaveEvent( QEvent *e ) 768void KListView::leaveEvent( QEvent *e )
754{ 769{
755 d->autoSelect.stop(); 770 d->autoSelect.stop();
756 771
757 QListView::leaveEvent( e ); 772 Q3ListView::leaveEvent( e );
758} 773}
759 774
760bool KListView::event( QEvent *e ) 775bool KListView::event( QEvent *e )
761{ 776{
762 if (e->type() == QEvent::ApplicationPaletteChange) { 777 if (e->type() == QEvent::ApplicationPaletteChange) {
763 //qDebug("KListView::event make alternate color configurable"); 778 //qDebug("KListView::event make alternate color configurable");
764//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); 779//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor();
765 d->alternateBackground = QColor(240, 240, 240); 780 d->alternateBackground = QColor(240, 240, 240);
766 } 781 }
767 782
768 return QListView::event(e); 783 return Q3ListView::event(e);
769} 784}
770 785
771void KListView::contentsMousePressEvent( QMouseEvent *e ) 786void KListView::contentsMousePressEvent( QMouseEvent *e )
772{ 787{
773 //qDebug("KListView::contentsMousePressEvent"); 788 //qDebug("KListView::contentsMousePressEvent");
774 if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) 789 if( (selectionModeExt() == Extended) && (e->state() & Qt::ShiftButton) && !(e->state() & Qt::ControlButton) )
775 { 790 {
776 bool block = signalsBlocked(); 791 bool block = signalsBlocked();
777 blockSignals( true ); 792 blockSignals( true );
778 793
779 clearSelection(); 794 clearSelection();
780 795
781 blockSignals( block ); 796 blockSignals( block );
782 } 797 }
783 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) 798 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove))
784 { 799 {
785 d->selectedBySimpleMove=false; 800 d->selectedBySimpleMove=false;
786 d->selectedUsingMouse=true; 801 d->selectedUsingMouse=true;
787 if (currentItem()!=0) 802 if (currentItem()!=0)
788 { 803 {
789 currentItem()->setSelected(false); 804 currentItem()->setSelected(false);
790 currentItem()->repaint(); 805 currentItem()->repaint();
791// emit selectionChanged(); 806// emit selectionChanged();
792 }; 807 };
793 }; 808 };
794 809
795 QPoint p( contentsToViewport( e->pos() ) ); 810 QPoint p( contentsToViewport( e->pos() ) );
796 QListViewItem *at = itemAt (p); 811 Q3ListViewItem *at = itemAt (p);
797 812
798 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) 813 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
799 bool rootDecoClicked = at 814 bool rootDecoClicked = at
800 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + 815 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
801 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) 816 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
802 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); 817 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
803 818
804 if (e->button() == LeftButton && !rootDecoClicked) 819 if (e->button() == Qt::LeftButton && !rootDecoClicked)
805 { 820 {
806 //Start a drag 821 //Start a drag
807 d->startDragPos = e->pos(); 822 d->startDragPos = e->pos();
808 823
809 if (at) 824 if (at)
810 { 825 {
811 d->validDrag = true; 826 d->validDrag = true;
812 d->pressedOnSelected = at->isSelected(); 827 d->pressedOnSelected = at->isSelected();
813 } 828 }
814 } 829 }
815 830
816 QListView::contentsMousePressEvent( e ); 831 Q3ListView::contentsMousePressEvent( e );
817} 832}
818 833
819void KListView::contentsMouseMoveEvent( QMouseEvent *e ) 834void KListView::contentsMouseMoveEvent( QMouseEvent *e )
820{ 835{
821 if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { 836 if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) {
822 QListView::contentsMouseMoveEvent (e); 837 Q3ListView::contentsMouseMoveEvent (e);
823 return; 838 return;
824 } 839 }
825 840
826 QPoint vp = contentsToViewport(e->pos()); 841 QPoint vp = contentsToViewport(e->pos());
827 QListViewItem *item = itemAt( vp ); 842 Q3ListViewItem *item = itemAt( vp );
828 843
829 //do we process cursor changes at all? 844 //do we process cursor changes at all?
830 if ( item && d->bChangeCursorOverItem && d->bUseSingle ) 845 if ( item && d->bChangeCursorOverItem && d->bUseSingle )
831 { 846 {
832 //Cursor moved on a new item or in/out the execute area 847 //Cursor moved on a new item or in/out the execute area
833 if( (item != d->pCurrentItem) || 848 if( (item != d->pCurrentItem) ||
834 (isExecuteArea(vp) != d->cursorInExecuteArea) ) 849 (isExecuteArea(vp) != d->cursorInExecuteArea) )
835 { 850 {
836 d->cursorInExecuteArea = isExecuteArea(vp); 851 d->cursorInExecuteArea = isExecuteArea(vp);
837 //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); 852 //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet");
838/*US 853/*US
839 if( d->cursorInExecuteArea ) //cursor moved in execute area 854 if( d->cursorInExecuteArea ) //cursor moved in execute area
@@ -844,95 +859,95 @@ void KListView::contentsMouseMoveEvent( QMouseEvent *e )
844 } 859 }
845 } 860 }
846 861
847 bool dragOn = dragEnabled(); 862 bool dragOn = dragEnabled();
848 QPoint newPos = e->pos(); 863 QPoint newPos = e->pos();
849 if (dragOn && d->validDrag && 864 if (dragOn && d->validDrag &&
850 (newPos.x() > d->startDragPos.x()+d->dragDelay || 865 (newPos.x() > d->startDragPos.x()+d->dragDelay ||
851 newPos.x() < d->startDragPos.x()-d->dragDelay || 866 newPos.x() < d->startDragPos.x()-d->dragDelay ||
852 newPos.y() > d->startDragPos.y()+d->dragDelay || 867 newPos.y() > d->startDragPos.y()+d->dragDelay ||
853 newPos.y() < d->startDragPos.y()-d->dragDelay)) 868 newPos.y() < d->startDragPos.y()-d->dragDelay))
854 //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) 869 //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance())
855 { 870 {
856 QListView::contentsMouseReleaseEvent( 0 ); 871 Q3ListView::contentsMouseReleaseEvent( 0 );
857 startDrag(); 872 startDrag();
858 d->startDragPos = QPoint(); 873 d->startDragPos = QPoint();
859 d->validDrag = false; 874 d->validDrag = false;
860 } 875 }
861} 876}
862 877
863void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) 878void KListView::contentsMouseReleaseEvent( QMouseEvent *e )
864{ 879{
865 if (e->button() == LeftButton) 880 if (e->button() == Qt::LeftButton)
866 { 881 {
867 // If the row was already selected, maybe we want to start an in-place editing 882 // If the row was already selected, maybe we want to start an in-place editing
868 if ( d->pressedOnSelected && itemsRenameable() ) 883 if ( d->pressedOnSelected && itemsRenameable() )
869 { 884 {
870 QPoint p( contentsToViewport( e->pos() ) ); 885 QPoint p( contentsToViewport( e->pos() ) );
871 QListViewItem *at = itemAt (p); 886 Q3ListViewItem *at = itemAt (p);
872 if ( at ) 887 if ( at )
873 { 888 {
874 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) 889 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
875 bool rootDecoClicked = 890 bool rootDecoClicked =
876 ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + 891 ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
877 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) 892 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
878 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); 893 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
879 894
880 if (!rootDecoClicked) 895 if (!rootDecoClicked)
881 { 896 {
882 int col = header()->mapToLogical( header()->cellAt( p.x() ) ); 897 int col = header()->mapToLogical( header()->cellAt( p.x() ) );
883 if ( d->renameable.contains(col) ) 898 if ( d->renameable.contains(col) )
884 rename(at, col); 899 rename(at, col);
885 } 900 }
886 } 901 }
887 } 902 }
888 903
889 d->pressedOnSelected = false; 904 d->pressedOnSelected = false;
890 d->validDrag = false; 905 d->validDrag = false;
891 d->startDragPos = QPoint(); 906 d->startDragPos = QPoint();
892 } 907 }
893 QListView::contentsMouseReleaseEvent( e ); 908 Q3ListView::contentsMouseReleaseEvent( e );
894} 909}
895 910
896void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) 911void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e )
897{ 912{
898 //qDebug("KListView::contentsMouseDoubleClickEvent"); 913 //qDebug("KListView::contentsMouseDoubleClickEvent");
899 // We don't want to call the parent method because it does setOpen, 914 // We don't want to call the parent method because it does setOpen,
900 // whereas we don't do it in single click mode... (David) 915 // whereas we don't do it in single click mode... (David)
901 //QListView::contentsMouseDoubleClickEvent( e ); 916 //QListView::contentsMouseDoubleClickEvent( e );
902 917
903 QPoint vp = contentsToViewport(e->pos()); 918 QPoint vp = contentsToViewport(e->pos());
904 QListViewItem *item = itemAt( vp ); 919 Q3ListViewItem *item = itemAt( vp );
905 emit QListView::doubleClicked( item ); // we do it now 920 emit Q3ListView::doubleClicked( item ); // we do it now
906 921
907 int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; 922 int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1;
908 923
909 if( item ) { 924 if( item ) {
910 //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked"); 925 //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked");
911 926
912 emit doubleClicked( item, e->globalPos(), col ); 927 emit doubleClicked( item, e->globalPos(), col );
913 928
914 if( (e->button() == LeftButton) && !d->bUseSingle ) { 929 if( (e->button() == Qt::LeftButton) && !d->bUseSingle ) {
915 //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute"); 930 //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute");
916 931
917 emitExecute( e->button(), item, e->globalPos(), col); 932 emitExecute( e->button(), item, e->globalPos(), col);
918 } 933 }
919 } 934 }
920} 935}
921 936
922void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) 937void KListView::slotMouseButtonClicked( int btn, Q3ListViewItem *item, const QPoint &pos, int c )
923{ 938{
924 //qDebug("KListView::slotMouseButtonClicked"); 939 //qDebug("KListView::slotMouseButtonClicked");
925 940
926 if( (btn == LeftButton) && item ) { 941 if( (btn == Qt::LeftButton) && item ) {
927 //qDebug("KListView::slotMouseButtonClicked: emitExecute"); 942 //qDebug("KListView::slotMouseButtonClicked: emitExecute");
928 943
929 emitExecute(btn, item, pos, c); 944 emitExecute(btn, item, pos, c);
930 } 945 }
931} 946}
932 947
933void KListView::contentsDropEvent(QDropEvent* e) 948void KListView::contentsDropEvent(QDropEvent* e)
934{ 949{
935qDebug("KListView::contentsDropEvent drag&drop not supported yet"); 950qDebug("KListView::contentsDropEvent drag&drop not supported yet");
936/*US 951/*US
937 cleanDropVisualizer(); 952 cleanDropVisualizer();
938 cleanItemHighlighter(); 953 cleanItemHighlighter();
@@ -952,64 +967,64 @@ qDebug("KListView::contentsDropEvent drag&drop not supported yet");
952 967
953 emit dropped(e, afterme); 968 emit dropped(e, afterme);
954 emit dropped(this, e, afterme); 969 emit dropped(this, e, afterme);
955 emit dropped(e, parent, afterme); 970 emit dropped(e, parent, afterme);
956 emit dropped(this, e, parent, afterme); 971 emit dropped(this, e, parent, afterme);
957 972
958 } 973 }
959 } 974 }
960*/ 975*/
961 976
962} 977}
963 978
964void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) 979void KListView::movableDropEvent (Q3ListViewItem* parent, Q3ListViewItem* afterme)
965{ 980{
966 QPtrList<QListViewItem> items, afterFirsts, afterNows; 981 Q3PtrList<Q3ListViewItem> items, afterFirsts, afterNows;
967 QListViewItem *current=currentItem(); 982 Q3ListViewItem *current=currentItem();
968 bool hasMoved=false; 983 bool hasMoved=false;
969 for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) 984 for (Q3ListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext)
970 { 985 {
971 iNext=i->itemBelow(); 986 iNext=i->itemBelow();
972 if (!i->isSelected()) 987 if (!i->isSelected())
973 continue; 988 continue;
974 989
975 // don't drop an item after itself, or else 990 // don't drop an item after itself, or else
976 // it moves to the top of the list 991 // it moves to the top of the list
977 if (i==afterme) 992 if (i==afterme)
978 continue; 993 continue;
979 994
980 i->setSelected(false); 995 i->setSelected(false);
981 996
982 QListViewItem *afterFirst = i->itemAbove(); 997 Q3ListViewItem *afterFirst = i->itemAbove();
983 998
984 if (!hasMoved) 999 if (!hasMoved)
985 { 1000 {
986 emit aboutToMove(); 1001 emit aboutToMove();
987 hasMoved=true; 1002 hasMoved=true;
988 } 1003 }
989 1004
990 moveItem(i, parent, afterme); 1005 moveItem(i, parent, afterme);
991 1006
992 // ###### This should include the new parent !!! -> KDE 3.0 1007 // ###### This should include the new parent !!! -> KDE 3.0
993 // If you need this right now, have a look at keditbookmarks. 1008 // If you need this right now, have a look at keditbookmarks.
994 emit moved(i, afterFirst, afterme); 1009 emit moved(i, afterFirst, afterme);
995 1010
996 items.append (i); 1011 items.append (i);
997 afterFirsts.append (afterFirst); 1012 afterFirsts.append (afterFirst);
998 afterNows.append (afterme); 1013 afterNows.append (afterme);
999 1014
1000 afterme = i; 1015 afterme = i;
1001 } 1016 }
1002 clearSelection(); 1017 clearSelection();
1003 for (QListViewItem *i=items.first(); i != 0; i=items.next() ) 1018 for (Q3ListViewItem *i=items.first(); i != 0; i=items.next() )
1004 i->setSelected(true); 1019 i->setSelected(true);
1005 if (current) 1020 if (current)
1006 setCurrentItem(current); 1021 setCurrentItem(current);
1007 1022
1008 emit moved(items,afterFirsts,afterNows); 1023 emit moved(items,afterFirsts,afterNows);
1009 1024
1010 if (firstChild()) 1025 if (firstChild())
1011 emit moved(); 1026 emit moved();
1012} 1027}
1013 1028
1014void KListView::contentsDragMoveEvent(QDragMoveEvent *event) 1029void KListView::contentsDragMoveEvent(QDragMoveEvent *event)
1015{ 1030{
@@ -1077,32 +1092,32 @@ void KListView::cleanDropVisualizer()
1077 { 1092 {
1078 QRect rect=d->mOldDropVisualizer; 1093 QRect rect=d->mOldDropVisualizer;
1079 d->mOldDropVisualizer = QRect(); 1094 d->mOldDropVisualizer = QRect();
1080 viewport()->repaint(rect, true); 1095 viewport()->repaint(rect, true);
1081 } 1096 }
1082} 1097}
1083 1098
1084int KListView::depthToPixels( int depth ) 1099int KListView::depthToPixels( int depth )
1085{ 1100{
1086 return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); 1101 return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin();
1087} 1102}
1088 1103
1089void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) 1104void KListView::findDrop(const QPoint &pos, Q3ListViewItem *&parent, Q3ListViewItem *&after)
1090{ 1105{
1091 QPoint p (contentsToViewport(pos)); 1106 QPoint p (contentsToViewport(pos));
1092 1107
1093 // Get the position to put it in 1108 // Get the position to put it in
1094 QListViewItem *atpos = itemAt(p); 1109 Q3ListViewItem *atpos = itemAt(p);
1095 1110
1096 QListViewItem *above; 1111 Q3ListViewItem *above;
1097 if (!atpos) // put it at the end 1112 if (!atpos) // put it at the end
1098 above = lastItem(); 1113 above = lastItem();
1099 else 1114 else
1100 { 1115 {
1101 // Get the closest item before us ('atpos' or the one above, if any) 1116 // Get the closest item before us ('atpos' or the one above, if any)
1102 if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) 1117 if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2))
1103 above = atpos->itemAbove(); 1118 above = atpos->itemAbove();
1104 else 1119 else
1105 above = atpos; 1120 above = atpos;
1106 } 1121 }
1107 1122
1108 if (above) 1123 if (above)
@@ -1114,62 +1129,62 @@ void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewIte
1114 // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children 1129 // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children
1115 if (p.x() >= depthToPixels( above->depth() + 1 ) || 1130 if (p.x() >= depthToPixels( above->depth() + 1 ) ||
1116 (above->isOpen() && above->childCount() > 0) ) 1131 (above->isOpen() && above->childCount() > 0) )
1117 { 1132 {
1118 parent = above; 1133 parent = above;
1119 after = 0L; 1134 after = 0L;
1120 return; 1135 return;
1121 } 1136 }
1122 } 1137 }
1123 1138
1124 // Ok, there's one more level of complexity. We may want to become a new 1139 // Ok, there's one more level of complexity. We may want to become a new
1125 // sibling, but of an upper-level group, rather than the "above" item 1140 // sibling, but of an upper-level group, rather than the "above" item
1126 QListViewItem * betterAbove = above->parent(); 1141 Q3ListViewItem * betterAbove = above->parent();
1127 QListViewItem * last = above; 1142 Q3ListViewItem * last = above;
1128 while ( betterAbove ) 1143 while ( betterAbove )
1129 { 1144 {
1130 // We are allowed to become a sibling of "betterAbove" only if we are 1145 // We are allowed to become a sibling of "betterAbove" only if we are
1131 // after its last child 1146 // after its last child
1132 if ( last->nextSibling() == 0 ) 1147 if ( last->nextSibling() == 0 )
1133 { 1148 {
1134 if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) 1149 if (p.x() < depthToPixels ( betterAbove->depth() + 1 ))
1135 above = betterAbove; // store this one, but don't stop yet, there may be a better one 1150 above = betterAbove; // store this one, but don't stop yet, there may be a better one
1136 else 1151 else
1137 break; // not enough on the left, so stop 1152 break; // not enough on the left, so stop
1138 last = betterAbove; 1153 last = betterAbove;
1139 betterAbove = betterAbove->parent(); // up one level 1154 betterAbove = betterAbove->parent(); // up one level
1140 } else 1155 } else
1141 break; // we're among the child of betterAbove, not after the last one 1156 break; // we're among the child of betterAbove, not after the last one
1142 } 1157 }
1143 } 1158 }
1144 // set as sibling 1159 // set as sibling
1145 after = above; 1160 after = above;
1146 parent = after ? after->parent() : 0L ; 1161 parent = after ? after->parent() : 0L ;
1147} 1162}
1148 1163
1149QListViewItem* KListView::lastChild () const 1164Q3ListViewItem* KListView::lastChild () const
1150{ 1165{
1151 QListViewItem* lastchild = firstChild(); 1166 Q3ListViewItem* lastchild = firstChild();
1152 1167
1153 if (lastchild) 1168 if (lastchild)
1154 for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); 1169 for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling());
1155 1170
1156 return lastchild; 1171 return lastchild;
1157} 1172}
1158 1173
1159QListViewItem *KListView::lastItem() const 1174Q3ListViewItem *KListView::lastItem() const
1160{ 1175{
1161 QListViewItem* last = lastChild(); 1176 Q3ListViewItem* last = lastChild();
1162 1177
1163 for (QListViewItemIterator it (last); it.current(); ++it) 1178 for (Q3ListViewItemIterator it (last); it.current(); ++it)
1164 last = it.current(); 1179 last = it.current();
1165 1180
1166 return last; 1181 return last;
1167} 1182}
1168 1183
1169KLineEdit *KListView::renameLineEdit() const 1184KLineEdit *KListView::renameLineEdit() const
1170{ 1185{
1171//US return d->editor; 1186//US return d->editor;
1172qDebug("KListView::renameLineEdit returns 0. Might crash"); 1187qDebug("KListView::renameLineEdit returns 0. Might crash");
1173return 0; 1188return 0;
1174} 1189}
1175 1190
@@ -1178,30 +1193,30 @@ void KListView::startDrag()
1178qDebug("KListView::startDrag drag&drop not supported yet."); 1193qDebug("KListView::startDrag drag&drop not supported yet.");
1179/*US 1194/*US
1180 QDragObject *drag = dragObject(); 1195 QDragObject *drag = dragObject();
1181 1196
1182 if (!drag) 1197 if (!drag)
1183 return; 1198 return;
1184 1199
1185 if (drag->drag() && drag->target() != viewport()) 1200 if (drag->drag() && drag->target() != viewport())
1186 emit moved(); 1201 emit moved();
1187*/ 1202*/
1188} 1203}
1189 1204
1190QDragObject *KListView::dragObject() 1205Q3DragObject *KListView::dragObject()
1191{ 1206{
1192 if (!currentItem()) 1207 if (!currentItem())
1193 return 0; 1208 return 0;
1194 1209
1195 return new QStoredDrag("application/x-qlistviewitem", viewport()); 1210 return new Q3StoredDrag("application/x-qlistviewitem", viewport());
1196} 1211}
1197 1212
1198void KListView::setItemsMovable(bool b) 1213void KListView::setItemsMovable(bool b)
1199{ 1214{
1200 d->itemsMovable=b; 1215 d->itemsMovable=b;
1201} 1216}
1202 1217
1203bool KListView::itemsMovable() const 1218bool KListView::itemsMovable() const
1204{ 1219{
1205 return d->itemsMovable; 1220 return d->itemsMovable;
1206} 1221}
1207 1222
@@ -1237,37 +1252,37 @@ bool KListView::autoOpen() const
1237} 1252}
1238 1253
1239bool KListView::dropVisualizer() const 1254bool KListView::dropVisualizer() const
1240{ 1255{
1241 return d->dropVisualizer; 1256 return d->dropVisualizer;
1242} 1257}
1243 1258
1244void KListView::setDropVisualizer(bool b) 1259void KListView::setDropVisualizer(bool b)
1245{ 1260{
1246 d->dropVisualizer=b; 1261 d->dropVisualizer=b;
1247} 1262}
1248 1263
1249QPtrList<QListViewItem> KListView::selectedItems() const 1264Q3PtrList<Q3ListViewItem> KListView::selectedItems() const
1250{ 1265{
1251 QPtrList<QListViewItem> list; 1266 Q3PtrList<Q3ListViewItem> list;
1252 for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) 1267 for (Q3ListViewItem *i=firstChild(); i!=0; i=i->itemBelow())
1253 if (i->isSelected()) list.append(i); 1268 if (i->isSelected()) list.append(i);
1254 return list; 1269 return list;
1255} 1270}
1256 1271
1257 1272
1258void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) 1273void KListView::moveItem(Q3ListViewItem *item, Q3ListViewItem *parent, Q3ListViewItem *after)
1259{ 1274{
1260 // sanity check - don't move a item into it's own child structure 1275 // sanity check - don't move a item into it's own child structure
1261 QListViewItem *i = parent; 1276 Q3ListViewItem *i = parent;
1262 while(i) 1277 while(i)
1263 { 1278 {
1264 if(i == item) 1279 if(i == item)
1265 return; 1280 return;
1266 i = i->parent(); 1281 i = i->parent();
1267 } 1282 }
1268 1283
1269 // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor 1284 // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor
1270 // in here, without ever deleting the item. 1285 // in here, without ever deleting the item.
1271 if (item->parent()) 1286 if (item->parent())
1272 item->parent()->takeItem(item); 1287 item->parent()->takeItem(item);
1273 else 1288 else
@@ -1287,37 +1302,37 @@ void KListView::contentsDragEnterEvent(QDragEnterEvent *event)
1287qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); 1302qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet.");
1288/*US 1303/*US
1289 if (acceptDrag (event)) 1304 if (acceptDrag (event))
1290 event->accept(); 1305 event->accept();
1291*/ 1306*/
1292} 1307}
1293 1308
1294void KListView::setDropVisualizerWidth (int w) 1309void KListView::setDropVisualizerWidth (int w)
1295{ 1310{
1296 d->mDropVisualizerWidth = w > 0 ? w : 1; 1311 d->mDropVisualizerWidth = w > 0 ? w : 1;
1297} 1312}
1298 1313
1299QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, 1314QRect KListView::drawDropVisualizer(QPainter *p, Q3ListViewItem *parent,
1300 QListViewItem *after) 1315 Q3ListViewItem *after)
1301{ 1316{
1302 QRect insertmarker; 1317 QRect insertmarker;
1303 1318
1304 if (!after && !parent) 1319 if (!after && !parent)
1305 insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); 1320 insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2);
1306 else 1321 else
1307 { 1322 {
1308 int level = 0; 1323 int level = 0;
1309 if (after) 1324 if (after)
1310 { 1325 {
1311 QListViewItem* it = 0L; 1326 Q3ListViewItem* it = 0L;
1312 if (after->isOpen()) 1327 if (after->isOpen())
1313 { 1328 {
1314 // Look for the last child (recursively) 1329 // Look for the last child (recursively)
1315 it = after->firstChild(); 1330 it = after->firstChild();
1316 if (it) 1331 if (it)
1317 while (it->nextSibling() || it->firstChild()) 1332 while (it->nextSibling() || it->firstChild())
1318 if ( it->nextSibling() ) 1333 if ( it->nextSibling() )
1319 it = it->nextSibling(); 1334 it = it->nextSibling();
1320 else 1335 else
1321 it = it->firstChild(); 1336 it = it->firstChild();
1322 } 1337 }
1323 1338
@@ -1329,30 +1344,30 @@ QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent,
1329 insertmarker = itemRect (parent); 1344 insertmarker = itemRect (parent);
1330 level = parent->depth() + 1; 1345 level = parent->depth() + 1;
1331 } 1346 }
1332 insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); 1347 insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() );
1333 insertmarker.setRight (viewport()->width()); 1348 insertmarker.setRight (viewport()->width());
1334 insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); 1349 insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1);
1335 insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); 1350 insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2);
1336 } 1351 }
1337 1352
1338 // This is not used anymore, at least by KListView itself (see viewportPaintEvent) 1353 // This is not used anymore, at least by KListView itself (see viewportPaintEvent)
1339 // Remove for KDE 3.0. 1354 // Remove for KDE 3.0.
1340 if (p) 1355 if (p)
1341 p->fillRect(insertmarker, Dense4Pattern); 1356 p->fillRect(insertmarker, Qt::Dense4Pattern);
1342 1357
1343 return insertmarker; 1358 return insertmarker;
1344} 1359}
1345 1360
1346QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) 1361QRect KListView::drawItemHighlighter(QPainter *painter, Q3ListViewItem *item)
1347{ 1362{
1348 QRect r; 1363 QRect r;
1349 1364
1350 if (item) 1365 if (item)
1351 { 1366 {
1352 r = itemRect(item); 1367 r = itemRect(item);
1353 r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); 1368 r.setLeft(r.left()+(item->depth()+1)*treeStepSize());
1354 if (painter) { 1369 if (painter) {
1355//US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), 1370//US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(),
1356//US QStyle::Style_FocusAtBorder, colorGroup().highlight()); 1371//US QStyle::Style_FocusAtBorder, colorGroup().highlight());
1357 const QColor* pHighl = &(colorGroup().highlight()); 1372 const QColor* pHighl = &(colorGroup().highlight());
1358 //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); 1373 //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true);
@@ -1367,25 +1382,25 @@ qDebug("KListView::drawItemHighlighter has to be verified");
1367} 1382}
1368 1383
1369void KListView::cleanItemHighlighter () 1384void KListView::cleanItemHighlighter ()
1370{ 1385{
1371 if (d->mOldDropHighlighter.isValid()) 1386 if (d->mOldDropHighlighter.isValid())
1372 { 1387 {
1373 QRect rect=d->mOldDropHighlighter; 1388 QRect rect=d->mOldDropHighlighter;
1374 d->mOldDropHighlighter = QRect(); 1389 d->mOldDropHighlighter = QRect();
1375 viewport()->repaint(rect, true); 1390 viewport()->repaint(rect, true);
1376 } 1391 }
1377} 1392}
1378 1393
1379void KListView::rename(QListViewItem *item, int c) 1394void KListView::rename(Q3ListViewItem *item, int c)
1380{ 1395{
1381 if (d->renameable.contains(c)) 1396 if (d->renameable.contains(c))
1382 { 1397 {
1383 ensureItemVisible(item); 1398 ensureItemVisible(item);
1384//US d->editor->load(item,c); 1399//US d->editor->load(item,c);
1385qDebug("KListView::rename has to be verified"); 1400qDebug("KListView::rename has to be verified");
1386 1401
1387 } 1402 }
1388} 1403}
1389 1404
1390bool KListView::isRenameable (int col) const 1405bool KListView::isRenameable (int col) const
1391{ 1406{
@@ -1394,25 +1409,25 @@ bool KListView::isRenameable (int col) const
1394 1409
1395void KListView::setRenameable (int col, bool yesno) 1410void KListView::setRenameable (int col, bool yesno)
1396{ 1411{
1397 if (col>=header()->count()) return; 1412 if (col>=header()->count()) return;
1398 1413
1399 d->renameable.remove(col); 1414 d->renameable.remove(col);
1400 if (yesno && d->renameable.find(col)==d->renameable.end()) 1415 if (yesno && d->renameable.find(col)==d->renameable.end())
1401 d->renameable+=col; 1416 d->renameable+=col;
1402 else if (!yesno && d->renameable.find(col)!=d->renameable.end()) 1417 else if (!yesno && d->renameable.find(col)!=d->renameable.end())
1403 d->renameable.remove(col); 1418 d->renameable.remove(col);
1404} 1419}
1405 1420
1406void KListView::doneEditing(QListViewItem *item, int row) 1421void KListView::doneEditing(Q3ListViewItem *item, int row)
1407{ 1422{
1408 emit itemRenamed(item, item->text(row), row); 1423 emit itemRenamed(item, item->text(row), row);
1409 emit itemRenamed(item); 1424 emit itemRenamed(item);
1410} 1425}
1411 1426
1412bool KListView::acceptDrag(QDropEvent* e) const 1427bool KListView::acceptDrag(QDropEvent* e) const
1413{ 1428{
1414qDebug("KListView::acceptDrag drag&drop not supported yet"); 1429qDebug("KListView::acceptDrag drag&drop not supported yet");
1415//US return acceptDrops() && itemsMovable() && (e->source()==viewport()); 1430//US return acceptDrops() && itemsMovable() && (e->source()==viewport());
1416return false; 1431return false;
1417} 1432}
1418 1433
@@ -1438,30 +1453,30 @@ void KListView::setTooltipColumn(int column)
1438} 1453}
1439 1454
1440void KListView::setDropHighlighter(bool b) 1455void KListView::setDropHighlighter(bool b)
1441{ 1456{
1442 d->dropHighlighter=b; 1457 d->dropHighlighter=b;
1443} 1458}
1444 1459
1445bool KListView::dropHighlighter() const 1460bool KListView::dropHighlighter() const
1446{ 1461{
1447 return d->dropHighlighter; 1462 return d->dropHighlighter;
1448} 1463}
1449 1464
1450bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const 1465bool KListView::showTooltip(Q3ListViewItem *item, const QPoint &, int column) const
1451{ 1466{
1452 return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); 1467 return ((tooltip(item, column).length()>0) && (column==tooltipColumn()));
1453} 1468}
1454 1469
1455QString KListView::tooltip(QListViewItem *item, int column) const 1470QString KListView::tooltip(Q3ListViewItem *item, int column) const
1456{ 1471{
1457 return item->text(column); 1472 return item->text(column);
1458} 1473}
1459 1474
1460void KListView::setTabOrderedRenaming(bool b) 1475void KListView::setTabOrderedRenaming(bool b)
1461{ 1476{
1462 d->tabRename = b; 1477 d->tabRename = b;
1463} 1478}
1464 1479
1465bool KListView::tabOrderedRenaming() const 1480bool KListView::tabOrderedRenaming() const
1466{ 1481{
1467 return d->tabRename; 1482 return d->tabRename;
@@ -1473,25 +1488,25 @@ void KListView::keyPressEvent (QKeyEvent* e)
1473 if (e->key() == d->contextMenuKey) 1488 if (e->key() == d->contextMenuKey)
1474 { 1489 {
1475 emit menuShortCutPressed (this, currentItem()); 1490 emit menuShortCutPressed (this, currentItem());
1476 return; 1491 return;
1477 } 1492 }
1478 if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) 1493 if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace)
1479 { 1494 {
1480 emit signalDelete ( ); 1495 emit signalDelete ( );
1481 return; 1496 return;
1482 } 1497 }
1483 1498
1484 if (d->selectionMode != FileManager) 1499 if (d->selectionMode != FileManager)
1485 QListView::keyPressEvent (e); 1500 Q3ListView::keyPressEvent (e);
1486 else 1501 else
1487 fileManagerKeyPressEvent (e); 1502 fileManagerKeyPressEvent (e);
1488} 1503}
1489 1504
1490void KListView::activateAutomaticSelection() 1505void KListView::activateAutomaticSelection()
1491{ 1506{
1492 d->selectedBySimpleMove=true; 1507 d->selectedBySimpleMove=true;
1493 d->selectedUsingMouse=false; 1508 d->selectedUsingMouse=false;
1494 if (currentItem()!=0) 1509 if (currentItem()!=0)
1495 { 1510 {
1496 selectAll(false); 1511 selectAll(false);
1497 currentItem()->setSelected(true); 1512 currentItem()->setSelected(true);
@@ -1504,112 +1519,112 @@ void KListView::deactivateAutomaticSelection()
1504{ 1519{
1505 d->selectedBySimpleMove=false; 1520 d->selectedBySimpleMove=false;
1506} 1521}
1507 1522
1508bool KListView::automaticSelection() const 1523bool KListView::automaticSelection() const
1509{ 1524{
1510 return d->selectedBySimpleMove; 1525 return d->selectedBySimpleMove;
1511} 1526}
1512 1527
1513void KListView::fileManagerKeyPressEvent (QKeyEvent* e) 1528void KListView::fileManagerKeyPressEvent (QKeyEvent* e)
1514{ 1529{
1515 //don't care whether it's on the keypad or not 1530 //don't care whether it's on the keypad or not
1516 int e_state=(e->state() & ~Keypad); 1531 int e_state=(e->state() & ~Qt::Keypad);
1517 1532
1518 int oldSelectionDirection(d->selectionDirection); 1533 int oldSelectionDirection(d->selectionDirection);
1519 1534
1520 if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) 1535 if ((e->key()!=Qt::Key_Shift) && (e->key()!=Qt::Key_Control)
1521 && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) 1536 && (e->key()!=Qt::Key_Meta) && (e->key()!=Qt::Key_Alt))
1522 { 1537 {
1523 if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) 1538 if ((e_state==Qt::ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove))
1524 selectAll(FALSE); 1539 selectAll(FALSE);
1525 d->selectionDirection=0; 1540 d->selectionDirection=0;
1526 d->wasShiftEvent = (e_state == ShiftButton); 1541 d->wasShiftEvent = (e_state == Qt::ShiftButton);
1527 }; 1542 };
1528 1543
1529 //d->wasShiftEvent = (e_state == ShiftButton); 1544 //d->wasShiftEvent = (e_state == Qt::ShiftButton);
1530 1545
1531 1546
1532 QListViewItem* item = currentItem(); 1547 Q3ListViewItem* item = currentItem();
1533 if (item==0) return; 1548 if (item==0) return;
1534 1549
1535 QListViewItem* repaintItem1 = item; 1550 Q3ListViewItem* repaintItem1 = item;
1536 QListViewItem* repaintItem2 = 0L; 1551 Q3ListViewItem* repaintItem2 = 0L;
1537 QListViewItem* visItem = 0L; 1552 Q3ListViewItem* visItem = 0L;
1538 1553
1539 QListViewItem* nextItem = 0L; 1554 Q3ListViewItem* nextItem = 0L;
1540 int items = 0; 1555 int items = 0;
1541 1556
1542 bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); 1557 bool shiftOrCtrl((e_state==Qt::ControlButton) || (e_state==Qt::ShiftButton));
1543 int selectedItems(0); 1558 int selectedItems(0);
1544 for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) 1559 for (Q3ListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling())
1545 if (tmpItem->isSelected()) selectedItems++; 1560 if (tmpItem->isSelected()) selectedItems++;
1546 1561
1547 if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) 1562 if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse)))
1548 && (e_state==NoButton) 1563 && (e_state==Qt::NoButton)
1549 && ((e->key()==Key_Down) 1564 && ((e->key()==Qt::Key_Down)
1550 || (e->key()==Key_Up) 1565 || (e->key()==Qt::Key_Up)
1551 || (e->key()==Key_Next) 1566 || (e->key()==Qt::Key_Next)
1552 || (e->key()==Key_Prior) 1567 || (e->key()==Qt::Key_Prior)
1553 || (e->key()==Key_Home) 1568 || (e->key()==Qt::Key_Home)
1554 || (e->key()==Key_End))) 1569 || (e->key()==Qt::Key_End)))
1555 { 1570 {
1556 d->selectedBySimpleMove=true; 1571 d->selectedBySimpleMove=true;
1557 d->selectedUsingMouse=false; 1572 d->selectedUsingMouse=false;
1558 } 1573 }
1559 else if (selectedItems>1) 1574 else if (selectedItems>1)
1560 d->selectedBySimpleMove=false; 1575 d->selectedBySimpleMove=false;
1561 1576
1562 bool emitSelectionChanged(false); 1577 bool emitSelectionChanged(false);
1563 1578
1564 switch (e->key()) 1579 switch (e->key())
1565 { 1580 {
1566 case Key_Escape: 1581 case Qt::Key_Escape:
1567 selectAll(FALSE); 1582 selectAll(FALSE);
1568 emitSelectionChanged=TRUE; 1583 emitSelectionChanged=TRUE;
1569 break; 1584 break;
1570 1585
1571 case Key_Space: 1586 case Qt::Key_Space:
1572 //toggle selection of current item 1587 //toggle selection of current item
1573 if (d->selectedBySimpleMove) 1588 if (d->selectedBySimpleMove)
1574 d->selectedBySimpleMove=false; 1589 d->selectedBySimpleMove=false;
1575 item->setSelected(!item->isSelected()); 1590 item->setSelected(!item->isSelected());
1576 emitSelectionChanged=TRUE; 1591 emitSelectionChanged=TRUE;
1577 break; 1592 break;
1578 1593
1579 case Key_Insert: 1594 case Qt::Key_Insert:
1580 //toggle selection of current item and move to the next item 1595 //toggle selection of current item and move to the next item
1581 if (d->selectedBySimpleMove) 1596 if (d->selectedBySimpleMove)
1582 { 1597 {
1583 d->selectedBySimpleMove=false; 1598 d->selectedBySimpleMove=false;
1584 if (!item->isSelected()) item->setSelected(TRUE); 1599 if (!item->isSelected()) item->setSelected(TRUE);
1585 } 1600 }
1586 else 1601 else
1587 { 1602 {
1588 item->setSelected(!item->isSelected()); 1603 item->setSelected(!item->isSelected());
1589 }; 1604 };
1590 1605
1591 nextItem=item->itemBelow(); 1606 nextItem=item->itemBelow();
1592 1607
1593 if (nextItem!=0) 1608 if (nextItem!=0)
1594 { 1609 {
1595 repaintItem2=nextItem; 1610 repaintItem2=nextItem;
1596 visItem=nextItem; 1611 visItem=nextItem;
1597 setCurrentItem(nextItem); 1612 setCurrentItem(nextItem);
1598 }; 1613 };
1599 d->selectionDirection=1; 1614 d->selectionDirection=1;
1600 emitSelectionChanged=TRUE; 1615 emitSelectionChanged=TRUE;
1601 break; 1616 break;
1602 1617
1603 case Key_Down: 1618 case Qt::Key_Down:
1604 nextItem=item->itemBelow(); 1619 nextItem=item->itemBelow();
1605 //toggle selection of current item and move to the next item 1620 //toggle selection of current item and move to the next item
1606 if (shiftOrCtrl) 1621 if (shiftOrCtrl)
1607 { 1622 {
1608 d->selectionDirection=1; 1623 d->selectionDirection=1;
1609 if (d->selectedBySimpleMove) 1624 if (d->selectedBySimpleMove)
1610 d->selectedBySimpleMove=false; 1625 d->selectedBySimpleMove=false;
1611 else 1626 else
1612 { 1627 {
1613 if (oldSelectionDirection!=-1) 1628 if (oldSelectionDirection!=-1)
1614 { 1629 {
1615 item->setSelected(!item->isSelected()); 1630 item->setSelected(!item->isSelected());
@@ -1624,25 +1639,25 @@ void KListView::fileManagerKeyPressEvent (QKeyEvent* e)
1624 }; 1639 };
1625 1640
1626 if (nextItem!=0) 1641 if (nextItem!=0)
1627 { 1642 {
1628 if (d->selectedBySimpleMove) 1643 if (d->selectedBySimpleMove)
1629 nextItem->setSelected(true); 1644 nextItem->setSelected(true);
1630 repaintItem2=nextItem; 1645 repaintItem2=nextItem;
1631 visItem=nextItem; 1646 visItem=nextItem;
1632 setCurrentItem(nextItem); 1647 setCurrentItem(nextItem);
1633 }; 1648 };
1634 break; 1649 break;
1635 1650
1636 case Key_Up: 1651 case Qt::Key_Up:
1637 nextItem=item->itemAbove(); 1652 nextItem=item->itemAbove();
1638 d->selectionDirection=-1; 1653 d->selectionDirection=-1;
1639 //move to the prev. item and toggle selection of this one 1654 //move to the prev. item and toggle selection of this one
1640 // => No, can't select the last item, with this. For symmetry, let's 1655 // => No, can't select the last item, with this. For symmetry, let's
1641 // toggle selection and THEN move up, just like we do in down (David) 1656 // toggle selection and THEN move up, just like we do in down (David)
1642 if (shiftOrCtrl) 1657 if (shiftOrCtrl)
1643 { 1658 {
1644 if (d->selectedBySimpleMove) 1659 if (d->selectedBySimpleMove)
1645 d->selectedBySimpleMove=false; 1660 d->selectedBySimpleMove=false;
1646 else 1661 else
1647 { 1662 {
1648 if (oldSelectionDirection!=1) 1663 if (oldSelectionDirection!=1)
@@ -1659,72 +1674,72 @@ void KListView::fileManagerKeyPressEvent (QKeyEvent* e)
1659 }; 1674 };
1660 1675
1661 if (nextItem!=0) 1676 if (nextItem!=0)
1662 { 1677 {
1663 if (d->selectedBySimpleMove) 1678 if (d->selectedBySimpleMove)
1664 nextItem->setSelected(true); 1679 nextItem->setSelected(true);
1665 repaintItem2=nextItem; 1680 repaintItem2=nextItem;
1666 visItem=nextItem; 1681 visItem=nextItem;
1667 setCurrentItem(nextItem); 1682 setCurrentItem(nextItem);
1668 }; 1683 };
1669 break; 1684 break;
1670 1685
1671 case Key_End: 1686 case Qt::Key_End:
1672 //move to the last item and toggle selection of all items inbetween 1687 //move to the last item and toggle selection of all items inbetween
1673 nextItem=item; 1688 nextItem=item;
1674 if (d->selectedBySimpleMove) 1689 if (d->selectedBySimpleMove)
1675 item->setSelected(false); 1690 item->setSelected(false);
1676 if (shiftOrCtrl) 1691 if (shiftOrCtrl)
1677 d->selectedBySimpleMove=false; 1692 d->selectedBySimpleMove=false;
1678 1693
1679 while(nextItem!=0) 1694 while(nextItem!=0)
1680 { 1695 {
1681 if (shiftOrCtrl) 1696 if (shiftOrCtrl)
1682 nextItem->setSelected(!nextItem->isSelected()); 1697 nextItem->setSelected(!nextItem->isSelected());
1683 if (nextItem->itemBelow()==0) 1698 if (nextItem->itemBelow()==0)
1684 { 1699 {
1685 if (d->selectedBySimpleMove) 1700 if (d->selectedBySimpleMove)
1686 nextItem->setSelected(true); 1701 nextItem->setSelected(true);
1687 repaintItem2=nextItem; 1702 repaintItem2=nextItem;
1688 visItem=nextItem; 1703 visItem=nextItem;
1689 setCurrentItem(nextItem); 1704 setCurrentItem(nextItem);
1690 } 1705 }
1691 nextItem=nextItem->itemBelow(); 1706 nextItem=nextItem->itemBelow();
1692 } 1707 }
1693 emitSelectionChanged=TRUE; 1708 emitSelectionChanged=TRUE;
1694 break; 1709 break;
1695 1710
1696 case Key_Home: 1711 case Qt::Key_Home:
1697 // move to the first item and toggle selection of all items inbetween 1712 // move to the first item and toggle selection of all items inbetween
1698 nextItem = firstChild(); 1713 nextItem = firstChild();
1699 visItem = nextItem; 1714 visItem = nextItem;
1700 repaintItem2 = visItem; 1715 repaintItem2 = visItem;
1701 if (d->selectedBySimpleMove) 1716 if (d->selectedBySimpleMove)
1702 item->setSelected(false); 1717 item->setSelected(false);
1703 if (shiftOrCtrl) 1718 if (shiftOrCtrl)
1704 { 1719 {
1705 d->selectedBySimpleMove=false; 1720 d->selectedBySimpleMove=false;
1706 1721
1707 while ( nextItem != item ) 1722 while ( nextItem != item )
1708 { 1723 {
1709 nextItem->setSelected( !nextItem->isSelected() ); 1724 nextItem->setSelected( !nextItem->isSelected() );
1710 nextItem = nextItem->itemBelow(); 1725 nextItem = nextItem->itemBelow();
1711 } 1726 }
1712 item->setSelected( !item->isSelected() ); 1727 item->setSelected( !item->isSelected() );
1713 } 1728 }
1714 setCurrentItem( firstChild() ); 1729 setCurrentItem( firstChild() );
1715 emitSelectionChanged=TRUE; 1730 emitSelectionChanged=TRUE;
1716 break; 1731 break;
1717 1732
1718 case Key_Next: 1733 case Qt::Key_Next:
1719 items=visibleHeight()/item->height(); 1734 items=visibleHeight()/item->height();
1720 nextItem=item; 1735 nextItem=item;
1721 if (d->selectedBySimpleMove) 1736 if (d->selectedBySimpleMove)
1722 item->setSelected(false); 1737 item->setSelected(false);
1723 if (shiftOrCtrl) 1738 if (shiftOrCtrl)
1724 { 1739 {
1725 d->selectedBySimpleMove=false; 1740 d->selectedBySimpleMove=false;
1726 d->selectionDirection=1; 1741 d->selectionDirection=1;
1727 }; 1742 };
1728 1743
1729 for (int i=0; i<items; i++) 1744 for (int i=0; i<items; i++)
1730 { 1745 {
@@ -1742,25 +1757,25 @@ void KListView::fileManagerKeyPressEvent (QKeyEvent* e)
1742 setCurrentItem(nextItem); 1757 setCurrentItem(nextItem);
1743 update(); 1758 update();
1744 if ((shiftOrCtrl) || (d->selectedBySimpleMove)) 1759 if ((shiftOrCtrl) || (d->selectedBySimpleMove))
1745 { 1760 {
1746 emit selectionChanged(); 1761 emit selectionChanged();
1747 } 1762 }
1748 return; 1763 return;
1749 } 1764 }
1750 nextItem=nextItem->itemBelow(); 1765 nextItem=nextItem->itemBelow();
1751 } 1766 }
1752 break; 1767 break;
1753 1768
1754 case Key_Prior: 1769 case Qt::Key_Prior:
1755 items=visibleHeight()/item->height(); 1770 items=visibleHeight()/item->height();
1756 nextItem=item; 1771 nextItem=item;
1757 if (d->selectedBySimpleMove) 1772 if (d->selectedBySimpleMove)
1758 item->setSelected(false); 1773 item->setSelected(false);
1759 if (shiftOrCtrl) 1774 if (shiftOrCtrl)
1760 { 1775 {
1761 d->selectionDirection=-1; 1776 d->selectionDirection=-1;
1762 d->selectedBySimpleMove=false; 1777 d->selectedBySimpleMove=false;
1763 }; 1778 };
1764 1779
1765 for (int i=0; i<items; i++) 1780 for (int i=0; i<items; i++)
1766 { 1781 {
@@ -1776,43 +1791,43 @@ void KListView::fileManagerKeyPressEvent (QKeyEvent* e)
1776 setCurrentItem(nextItem); 1791 setCurrentItem(nextItem);
1777 update(); 1792 update();
1778 if ((shiftOrCtrl) || (d->selectedBySimpleMove)) 1793 if ((shiftOrCtrl) || (d->selectedBySimpleMove))
1779 { 1794 {
1780 emit selectionChanged(); 1795 emit selectionChanged();
1781 } 1796 }
1782 return; 1797 return;
1783 } 1798 }
1784 nextItem=nextItem->itemAbove(); 1799 nextItem=nextItem->itemAbove();
1785 } 1800 }
1786 break; 1801 break;
1787 1802
1788 case Key_Minus: 1803 case Qt::Key_Minus:
1789 if ( item->isOpen() ) 1804 if ( item->isOpen() )
1790 setOpen( item, FALSE ); 1805 setOpen( item, FALSE );
1791 break; 1806 break;
1792 case Key_Plus: 1807 case Qt::Key_Plus:
1793 if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) 1808 if ( !item->isOpen() && (item->isExpandable() || item->childCount()) )
1794 setOpen( item, TRUE ); 1809 setOpen( item, TRUE );
1795 break; 1810 break;
1796 default: 1811 default:
1797 bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) 1812 bool realKey = ((e->key()!=Qt::Key_Shift) && (e->key()!=Qt::Key_Control)
1798 && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); 1813 && (e->key()!=Qt::Key_Meta) && (e->key()!=Qt::Key_Alt));
1799 1814
1800 bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); 1815 bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected());
1801 if (realKey && selectCurrentItem) 1816 if (realKey && selectCurrentItem)
1802 item->setSelected(false); 1817 item->setSelected(false);
1803 //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) 1818 //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX)
1804 QListView::SelectionMode oldSelectionMode = selectionMode(); 1819 Q3ListView::SelectionMode oldSelectionMode = selectionMode();
1805 setSelectionMode (QListView::Multi); 1820 setSelectionMode (Q3ListView::Multi);
1806 QListView::keyPressEvent (e); 1821 Q3ListView::keyPressEvent (e);
1807 setSelectionMode (oldSelectionMode); 1822 setSelectionMode (oldSelectionMode);
1808 if (realKey && selectCurrentItem) 1823 if (realKey && selectCurrentItem)
1809 { 1824 {
1810 currentItem()->setSelected(true); 1825 currentItem()->setSelected(true);
1811 emitSelectionChanged=TRUE; 1826 emitSelectionChanged=TRUE;
1812 } 1827 }
1813 repaintItem2=currentItem(); 1828 repaintItem2=currentItem();
1814 if (realKey) 1829 if (realKey)
1815 visItem=currentItem(); 1830 visItem=currentItem();
1816 break; 1831 break;
1817 } 1832 }
1818 1833
@@ -1841,127 +1856,127 @@ void KListView::fileManagerKeyPressEvent (QKeyEvent* e)
1841} 1856}
1842 1857
1843void KListView::setSelectionModeExt (SelectionModeExt mode) 1858void KListView::setSelectionModeExt (SelectionModeExt mode)
1844{ 1859{
1845 d->selectionMode = mode; 1860 d->selectionMode = mode;
1846 1861
1847 switch (mode) 1862 switch (mode)
1848 { 1863 {
1849 case Single: 1864 case Single:
1850 case Multi: 1865 case Multi:
1851 case Extended: 1866 case Extended:
1852 case NoSelection: 1867 case NoSelection:
1853 setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); 1868 setSelectionMode (static_cast<Q3ListView::SelectionMode>(static_cast<int>(mode)));
1854 break; 1869 break;
1855 1870
1856 case FileManager: 1871 case FileManager:
1857 setSelectionMode (QListView::Extended); 1872 setSelectionMode (Q3ListView::Extended);
1858 break; 1873 break;
1859 1874
1860 default: 1875 default:
1861 kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; 1876 kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl;
1862 break; 1877 break;
1863 } 1878 }
1864} 1879}
1865 1880
1866KListView::SelectionModeExt KListView::selectionModeExt () const 1881KListView::SelectionModeExt KListView::selectionModeExt () const
1867{ 1882{
1868 return d->selectionMode; 1883 return d->selectionMode;
1869} 1884}
1870 1885
1871int KListView::itemIndex( const QListViewItem *item ) const 1886int KListView::itemIndex( const Q3ListViewItem *item ) const
1872{ 1887{
1873 if ( !item ) 1888 if ( !item )
1874 return -1; 1889 return -1;
1875 1890
1876 if ( item == firstChild() ) 1891 if ( item == firstChild() )
1877 return 0; 1892 return 0;
1878 else { 1893 else {
1879 QListViewItemIterator it(firstChild()); 1894 Q3ListViewItemIterator it(firstChild());
1880 uint j = 0; 1895 uint j = 0;
1881 for (; it.current() && it.current() != item; ++it, ++j ); 1896 for (; it.current() && it.current() != item; ++it, ++j );
1882 1897
1883 if( !it.current() ) 1898 if( !it.current() )
1884 return -1; 1899 return -1;
1885 1900
1886 return j; 1901 return j;
1887 } 1902 }
1888} 1903}
1889 1904
1890QListViewItem* KListView::itemAtIndex(int index) 1905Q3ListViewItem* KListView::itemAtIndex(int index)
1891{ 1906{
1892 if (index<0) 1907 if (index<0)
1893 return 0; 1908 return 0;
1894 1909
1895 int j(0); 1910 int j(0);
1896 for (QListViewItemIterator it=firstChild(); it.current(); it++) 1911 for (Q3ListViewItemIterator it=firstChild(); it.current(); it++)
1897 { 1912 {
1898 if (j==index) 1913 if (j==index)
1899 return it.current(); 1914 return it.current();
1900 j++; 1915 j++;
1901 }; 1916 };
1902 return 0; 1917 return 0;
1903} 1918}
1904 1919
1905 1920
1906void KListView::emitContextMenu (KListView*, QListViewItem* i) 1921void KListView::emitContextMenu (KListView*, Q3ListViewItem* i)
1907{ 1922{
1908 QPoint p; 1923 QPoint p;
1909 // qDebug("KListView::emitContextMenu "); 1924 // qDebug("KListView::emitContextMenu ");
1910 1925
1911 if (i) 1926 if (i)
1912 p = viewport()->mapToGlobal(itemRect(i).center()); 1927 p = viewport()->mapToGlobal(itemRect(i).center());
1913 else 1928 else
1914 p = mapToGlobal(rect().center()); 1929 p = mapToGlobal(rect().center());
1915 1930
1916 emit contextMenu (this, i, p); 1931 emit contextMenu (this, i, p);
1917} 1932}
1918 1933
1919void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) 1934void KListView::emitContextMenu (Q3ListViewItem* i, const QPoint& p, int col)
1920{ 1935{
1921 QListViewItem* item = i; 1936 Q3ListViewItem* item = i;
1922 int c = col; 1937 int c = col;
1923 // do not trust the values for QListViewItem* i and int col; 1938 // do not trust the values for QListViewItem* i and int col;
1924 // qDebug("KListView::emitContextMenu col"); 1939 // qDebug("KListView::emitContextMenu col");
1925 if ( col == -1 ) { 1940 if ( col == -1 ) {
1926 QPoint pp = viewport()->mapFromGlobal(p); 1941 QPoint pp = viewport()->mapFromGlobal(p);
1927 item = itemAt( pp); 1942 item = itemAt( pp);
1928 c = header()->sectionAt(pp.x() ); 1943 c = header()->sectionAt(pp.x() );
1929 } 1944 }
1930 emit contextRequest( item, p, c ); 1945 emit contextRequest( item, p, c );
1931 emit contextMenu (this, item, p); 1946 emit contextMenu (this, item, p);
1932} 1947}
1933 1948
1934void KListView::setAcceptDrops (bool val) 1949void KListView::setAcceptDrops (bool val)
1935{ 1950{
1936 QListView::setAcceptDrops (val); 1951 Q3ListView::setAcceptDrops (val);
1937 viewport()->setAcceptDrops (val); 1952 viewport()->setAcceptDrops (val);
1938} 1953}
1939 1954
1940int KListView::dropVisualizerWidth () const 1955int KListView::dropVisualizerWidth () const
1941{ 1956{
1942 return d->mDropVisualizerWidth; 1957 return d->mDropVisualizerWidth;
1943} 1958}
1944 1959
1945 1960
1946void KListView::viewportPaintEvent(QPaintEvent *e) 1961void KListView::viewportPaintEvent(QPaintEvent *e)
1947{ 1962{
1948 QListView::viewportPaintEvent(e); 1963 Q3ListView::viewportPaintEvent(e);
1949 1964
1950 if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) 1965 if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer))
1951 { 1966 {
1952 QPainter painter(viewport()); 1967 QPainter painter(viewport());
1953 1968
1954 // This is where we actually draw the drop-visualizer 1969 // This is where we actually draw the drop-visualizer
1955 painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); 1970 painter.fillRect(d->mOldDropVisualizer, Qt::Dense4Pattern);
1956 } 1971 }
1957 if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) 1972 if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter))
1958 { 1973 {
1959 QPainter painter(viewport()); 1974 QPainter painter(viewport());
1960 1975
1961qDebug("KListView::viewportPaintEvent has to be verified"); 1976qDebug("KListView::viewportPaintEvent has to be verified");
1962 1977
1963 // This is where we actually draw the drop-highlighter 1978 // This is where we actually draw the drop-highlighter
1964//US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), 1979//US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(),
1965//US QStyle::Style_FocusAtBorder); 1980//US QStyle::Style_FocusAtBorder);
1966 1981
1967//LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); 1982//LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true);
@@ -1979,51 +1994,51 @@ void KListView::setFullWidth(bool fullWidth)
1979{ 1994{
1980 d->fullWidth = fullWidth; 1995 d->fullWidth = fullWidth;
1981//US header()->setStretchEnabled(fullWidth, columns()-1); 1996//US header()->setStretchEnabled(fullWidth, columns()-1);
1982} 1997}
1983 1998
1984bool KListView::fullWidth() const 1999bool KListView::fullWidth() const
1985{ 2000{
1986 return d->fullWidth; 2001 return d->fullWidth;
1987} 2002}
1988 2003
1989int KListView::addColumn(const QString& label, int width) 2004int KListView::addColumn(const QString& label, int width)
1990{ 2005{
1991 int result = QListView::addColumn(label, width); 2006 int result = Q3ListView::addColumn(label, width);
1992 if (d->fullWidth) { 2007 if (d->fullWidth) {
1993//US header()->setStretchEnabled(false, columns()-2); 2008//US header()->setStretchEnabled(false, columns()-2);
1994//US header()->setStretchEnabled(true, columns()-1); 2009//US header()->setStretchEnabled(true, columns()-1);
1995 } 2010 }
1996 return result; 2011 return result;
1997} 2012}
1998 2013
1999int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) 2014int KListView::addColumn(const QIcon& iconset, const QString& label, int width)
2000{ 2015{
2001 int result = QListView::addColumn(iconset, label, width); 2016 int result = Q3ListView::addColumn(iconset, label, width);
2002 if (d->fullWidth) { 2017 if (d->fullWidth) {
2003//US header()->setStretchEnabled(false, columns()-2); 2018//US header()->setStretchEnabled(false, columns()-2);
2004//US header()->setStretchEnabled(true, columns()-1); 2019//US header()->setStretchEnabled(true, columns()-1);
2005 } 2020 }
2006 return result; 2021 return result;
2007} 2022}
2008 2023
2009void KListView::removeColumn(int index) 2024void KListView::removeColumn(int index)
2010{ 2025{
2011 QListView::removeColumn(index); 2026 Q3ListView::removeColumn(index);
2012//US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); 2027//US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1);
2013} 2028}
2014 2029
2015void KListView::viewportResizeEvent(QResizeEvent* e) 2030void KListView::viewportResizeEvent(QResizeEvent* e)
2016{ 2031{
2017 QListView::viewportResizeEvent(e); 2032 Q3ListView::viewportResizeEvent(e);
2018} 2033}
2019 2034
2020const QColor &KListView::alternateBackground() const 2035const QColor &KListView::alternateBackground() const
2021{ 2036{
2022 return d->alternateBackground; 2037 return d->alternateBackground;
2023} 2038}
2024 2039
2025void KListView::setAlternateBackground(const QColor &c) 2040void KListView::setAlternateBackground(const QColor &c)
2026{ 2041{
2027 d->alternateBackground = c; 2042 d->alternateBackground = c;
2028 repaint(); 2043 repaint();
2029} 2044}
@@ -2061,89 +2076,89 @@ void KListView::restoreLayout(KConfig *config, const QString &group)
2061 if (config->hasKey("SortColumn")) 2076 if (config->hasKey("SortColumn"))
2062 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); 2077 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true));
2063*/ 2078*/
2064 QStringList langLst = config->readListEntry( "SortColumn" ); 2079 QStringList langLst = config->readListEntry( "SortColumn" );
2065 if (!langLst.isEmpty()) 2080 if (!langLst.isEmpty())
2066 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); 2081 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true));
2067} 2082}
2068 2083
2069void KListView::setSorting(int column, bool ascending) 2084void KListView::setSorting(int column, bool ascending)
2070{ 2085{
2071 d->sortColumn = column; 2086 d->sortColumn = column;
2072 d->sortAscending = ascending; 2087 d->sortAscending = ascending;
2073 QListView::setSorting(column, ascending); 2088 Q3ListView::setSorting(column, ascending);
2074} 2089}
2075 2090
2076int KListView::columnSorted(void) const 2091int KListView::columnSorted(void) const
2077{ 2092{
2078 return d->sortColumn; 2093 return d->sortColumn;
2079} 2094}
2080 2095
2081bool KListView::ascendingSort(void) const 2096bool KListView::ascendingSort(void) const
2082{ 2097{
2083 return d->sortAscending; 2098 return d->sortAscending;
2084} 2099}
2085 2100
2086KListViewItem::KListViewItem(QListView *parent) 2101KListViewItem::KListViewItem(Q3ListView *parent)
2087 : QListViewItem(parent) 2102 : Q3ListViewItem(parent)
2088{ 2103{
2089 init(); 2104 init();
2090} 2105}
2091 2106
2092KListViewItem::KListViewItem(QListViewItem *parent) 2107KListViewItem::KListViewItem(Q3ListViewItem *parent)
2093 : QListViewItem(parent) 2108 : Q3ListViewItem(parent)
2094{ 2109{
2095 init(); 2110 init();
2096} 2111}
2097 2112
2098KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) 2113KListViewItem::KListViewItem(Q3ListView *parent, Q3ListViewItem *after)
2099 : QListViewItem(parent, after) 2114 : Q3ListViewItem(parent, after)
2100{ 2115{
2101 init(); 2116 init();
2102} 2117}
2103 2118
2104KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) 2119KListViewItem::KListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after)
2105 : QListViewItem(parent, after) 2120 : Q3ListViewItem(parent, after)
2106{ 2121{
2107 init(); 2122 init();
2108} 2123}
2109 2124
2110KListViewItem::KListViewItem(QListView *parent, 2125KListViewItem::KListViewItem(Q3ListView *parent,
2111 QString label1, QString label2, QString label3, QString label4, 2126 QString label1, QString label2, QString label3, QString label4,
2112 QString label5, QString label6, QString label7, QString label8) 2127 QString label5, QString label6, QString label7, QString label8)
2113 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 2128 : Q3ListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
2114{ 2129{
2115 init(); 2130 init();
2116} 2131}
2117 2132
2118KListViewItem::KListViewItem(QListViewItem *parent, 2133KListViewItem::KListViewItem(Q3ListViewItem *parent,
2119 QString label1, QString label2, QString label3, QString label4, 2134 QString label1, QString label2, QString label3, QString label4,
2120 QString label5, QString label6, QString label7, QString label8) 2135 QString label5, QString label6, QString label7, QString label8)
2121 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 2136 : Q3ListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
2122{ 2137{
2123 init(); 2138 init();
2124} 2139}
2125 2140
2126KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, 2141KListViewItem::KListViewItem(Q3ListView *parent, Q3ListViewItem *after,
2127 QString label1, QString label2, QString label3, QString label4, 2142 QString label1, QString label2, QString label3, QString label4,
2128 QString label5, QString label6, QString label7, QString label8) 2143 QString label5, QString label6, QString label7, QString label8)
2129 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 2144 : Q3ListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
2130{ 2145{
2131 init(); 2146 init();
2132} 2147}
2133 2148
2134KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, 2149KListViewItem::KListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after,
2135 QString label1, QString label2, QString label3, QString label4, 2150 QString label1, QString label2, QString label3, QString label4,
2136 QString label5, QString label6, QString label7, QString label8) 2151 QString label5, QString label6, QString label7, QString label8)
2137 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 2152 : Q3ListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
2138{ 2153{
2139 init(); 2154 init();
2140} 2155}
2141 2156
2142KListViewItem::~KListViewItem() 2157KListViewItem::~KListViewItem()
2143{ 2158{
2144} 2159}
2145 2160
2146void KListViewItem::init() 2161void KListViewItem::init()
2147{ 2162{
2148 m_known = false; 2163 m_known = false;
2149} 2164}
@@ -2203,30 +2218,30 @@ bool KListViewItem::isAlternate()
2203void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 2218void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
2204{ 2219{
2205 QColorGroup _cg = cg; 2220 QColorGroup _cg = cg;
2206 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 2221 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
2207 if (pm && !pm->isNull()) 2222 if (pm && !pm->isNull())
2208 { 2223 {
2209 _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); 2224 _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm));
2210 QPoint o = p->brushOrigin(); 2225 QPoint o = p->brushOrigin();
2211 p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); 2226 p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() );
2212 } 2227 }
2213 else if (isAlternate()) { 2228 else if (isAlternate()) {
2214//US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) 2229//US if (listView()->viewport()->backgroundMode()==Qt::FixedColor)
2215 if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) 2230 if (listView()->viewport()->backgroundMode()==Qt::PaletteBackground)
2216 _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); 2231 _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground());
2217 else 2232 else
2218 _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); 2233 _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground());
2219 } 2234 }
2220 QListViewItem::paintCell(p, _cg, column, width, alignment); 2235 Q3ListViewItem::paintCell(p, _cg, column, width, alignment);
2221} 2236}
2222 2237
2223//US we do not have a "global KDE" variable to setup singleClick functionality 2238//US we do not have a "global KDE" variable to setup singleClick functionality
2224void KListView::setSingleClick(bool s) 2239void KListView::setSingleClick(bool s)
2225{ 2240{
2226 d->bUseSingle = s; 2241 d->bUseSingle = s;
2227 slotSettingsChanged(1); 2242 slotSettingsChanged(1);
2228 // qDebug("KListView::setSingleClick: single %i", d->bUseSingle); 2243 // qDebug("KListView::setSingleClick: single %i", d->bUseSingle);
2229} 2244}
2230 2245
2231 2246
2232void KListView::virtual_hook( int, void* ) 2247void KListView::virtual_hook( int, void* )