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