summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-20 00:14:50 (UTC)
committer ulf69 <ulf69>2004-10-20 00:14:50 (UTC)
commit675831e02387f0f838f63c3ea9d51d9679d070c5 (patch) (unidiff)
tree760bdc02ea21a49a1ef39c9875e345dc9cd09fde
parenta9119c4edc272815121ddc863963b5289bb95b13 (diff)
downloadkdepimpi-675831e02387f0f838f63c3ea9d51d9679d070c5.zip
kdepimpi-675831e02387f0f838f63c3ea9d51d9679d070c5.tar.gz
kdepimpi-675831e02387f0f838f63c3ea9d51d9679d070c5.tar.bz2
removed some debugoutput.
removed configsettings for some unneeded operations in pwmanager config
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/klistview.cpp2
-rw-r--r--pwmanager/pwmanager/globalstuff.h4
-rw-r--r--pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp7
-rw-r--r--pwmanager/pwmanager/pwmprefs.h4
4 files changed, 9 insertions, 8 deletions
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp
index 6477d11..5b50ba9 100644
--- a/microkde/kdeui/klistview.cpp
+++ b/microkde/kdeui/klistview.cpp
@@ -1,2192 +1,2192 @@
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 showContextMenusOnPress(true), 97 showContextMenusOnPress(true),
98 itemsRenameable (false), 98 itemsRenameable (false),
99 validDrag (false), 99 validDrag (false),
100 dragEnabled (false), 100 dragEnabled (false),
101 autoOpen (true), 101 autoOpen (true),
102 dropVisualizer (true), 102 dropVisualizer (true),
103 dropHighlighter (false), 103 dropHighlighter (false),
104 createChildren (true), 104 createChildren (true),
105 pressedOnSelected (false), 105 pressedOnSelected (false),
106 wasShiftEvent (false), 106 wasShiftEvent (false),
107 fullWidth (false), 107 fullWidth (false),
108 sortAscending(true), 108 sortAscending(true),
109 tabRename(true), 109 tabRename(true),
110 sortColumn(0), 110 sortColumn(0),
111 selectionDirection(0), 111 selectionDirection(0),
112 tooltipColumn (0), 112 tooltipColumn (0),
113 selectionMode (Single), 113 selectionMode (Single),
114//US contextMenuKey (KGlobalSettings::contextMenuKey()), 114//US contextMenuKey (KGlobalSettings::contextMenuKey()),
115//US showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), 115//US showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()),
116 mDropVisualizerWidth (4) 116 mDropVisualizerWidth (4)
117 { 117 {
118 renameable += 0; 118 renameable += 0;
119//US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); 119//US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int)));
120 } 120 }
121 121
122 ~KListViewPrivate () 122 ~KListViewPrivate ()
123 { 123 {
124//US delete editor; 124//US delete editor;
125 } 125 }
126 126
127 QListViewItem* pCurrentItem; 127 QListViewItem* pCurrentItem;
128 128
129 QTimer autoSelect; 129 QTimer autoSelect;
130 int autoSelectDelay; 130 int autoSelectDelay;
131 131
132 QTimer dragExpand; 132 QTimer dragExpand;
133 QListViewItem* dragOverItem; 133 QListViewItem* dragOverItem;
134 QPoint dragOverPoint; 134 QPoint dragOverPoint;
135 135
136 QPoint startDragPos; 136 QPoint startDragPos;
137 int dragDelay; 137 int dragDelay;
138 138
139//US KListViewLineEdit *editor; 139//US KListViewLineEdit *editor;
140 QValueList<int> renameable; 140 QValueList<int> renameable;
141 141
142 bool cursorInExecuteArea:1; 142 bool cursorInExecuteArea:1;
143 bool bUseSingle:1; 143 bool bUseSingle:1;
144 bool bChangeCursorOverItem:1; 144 bool bChangeCursorOverItem:1;
145 bool itemsMovable:1; 145 bool itemsMovable:1;
146 bool selectedBySimpleMove : 1; 146 bool selectedBySimpleMove : 1;
147 bool selectedUsingMouse:1; 147 bool selectedUsingMouse:1;
148 bool itemsRenameable:1; 148 bool itemsRenameable:1;
149 bool validDrag:1; 149 bool validDrag:1;
150 bool dragEnabled:1; 150 bool dragEnabled:1;
151 bool autoOpen:1; 151 bool autoOpen:1;
152 bool dropVisualizer:1; 152 bool dropVisualizer:1;
153 bool dropHighlighter:1; 153 bool dropHighlighter:1;
154 bool createChildren:1; 154 bool createChildren:1;
155 bool pressedOnSelected:1; 155 bool pressedOnSelected:1;
156 bool wasShiftEvent:1; 156 bool wasShiftEvent:1;
157 bool fullWidth:1; 157 bool fullWidth:1;
158 bool sortAscending:1; 158 bool sortAscending:1;
159 bool tabRename:1; 159 bool tabRename:1;
160 160
161 int sortColumn; 161 int sortColumn;
162 162
163 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX 163 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX
164 int selectionDirection; 164 int selectionDirection;
165 int tooltipColumn; 165 int tooltipColumn;
166 166
167 SelectionModeExt selectionMode; 167 SelectionModeExt selectionMode;
168 int contextMenuKey; 168 int contextMenuKey;
169 bool showContextMenusOnPress; 169 bool showContextMenusOnPress;
170 170
171 QRect mOldDropVisualizer; 171 QRect mOldDropVisualizer;
172 int mDropVisualizerWidth; 172 int mDropVisualizerWidth;
173 QRect mOldDropHighlighter; 173 QRect mOldDropHighlighter;
174 QListViewItem *afterItemDrop; 174 QListViewItem *afterItemDrop;
175 QListViewItem *parentItemDrop; 175 QListViewItem *parentItemDrop;
176 176
177 QColor alternateBackground; 177 QColor alternateBackground;
178}; 178};
179 179
180/*US 180/*US
181KListViewLineEdit::KListViewLineEdit(KListView *parent) 181KListViewLineEdit::KListViewLineEdit(KListView *parent)
182 : KLineEdit(parent->viewport()), item(0), col(0), p(parent) 182 : KLineEdit(parent->viewport()), item(0), col(0), p(parent)
183{ 183{
184 setFrame( false ); 184 setFrame( false );
185 hide(); 185 hide();
186 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); 186 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() ));
187} 187}
188 188
189KListViewLineEdit::~KListViewLineEdit() 189KListViewLineEdit::~KListViewLineEdit()
190{ 190{
191} 191}
192 192
193void KListViewLineEdit::load(QListViewItem *i, int c) 193void KListViewLineEdit::load(QListViewItem *i, int c)
194{ 194{
195 item=i; 195 item=i;
196 col=c; 196 col=c;
197 197
198 QRect rect(p->itemRect(i)); 198 QRect rect(p->itemRect(i));
199 setText(item->text(c)); 199 setText(item->text(c));
200 200
201 int fieldX = rect.x() - 1; 201 int fieldX = rect.x() - 1;
202 int fieldW = p->columnWidth(col) + 2; 202 int fieldW = p->columnWidth(col) + 2;
203 203
204 int pos = p->header()->mapToIndex(col); 204 int pos = p->header()->mapToIndex(col);
205 for ( int index = 0; index < pos; index++ ) 205 for ( int index = 0; index < pos; index++ )
206 fieldX += p->columnWidth( p->header()->mapToSection( index )); 206 fieldX += p->columnWidth( p->header()->mapToSection( index ));
207 207
208 if ( col == 0 ) { 208 if ( col == 0 ) {
209 int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); 209 int d = i->depth() + (p->rootIsDecorated() ? 1 : 0);
210 d *= p->treeStepSize(); 210 d *= p->treeStepSize();
211 fieldX += d; 211 fieldX += d;
212 fieldW -= d; 212 fieldW -= d;
213 } 213 }
214 214
215 if ( i->pixmap( col ) ) {// add width of pixmap 215 if ( i->pixmap( col ) ) {// add width of pixmap
216 int d = i->pixmap( col )->width(); 216 int d = i->pixmap( col )->width();
217 fieldX += d; 217 fieldX += d;
218 fieldW -= d; 218 fieldW -= d;
219 } 219 }
220 220
221 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); 221 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2);
222 show(); 222 show();
223 setFocus(); 223 setFocus();
224} 224}
225*/ 225*/
226 /*Helper functions to for 226 /*Helper functions to for
227 *tabOrderedRename functionality. 227 *tabOrderedRename functionality.
228 */ 228 */
229 229
230static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) 230static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir)
231{ 231{
232 if (pi) 232 if (pi)
233 { 233 {
234 //Find the next renameable column in the current row 234 //Find the next renameable column in the current row
235 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) 235 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir)
236 if (pl->isRenameable(start)) 236 if (pl->isRenameable(start))
237 return start; 237 return start;
238 } 238 }
239 239
240 return -1; 240 return -1;
241} 241}
242 242
243static QListViewItem *prevItem (QListViewItem *pi) 243static QListViewItem *prevItem (QListViewItem *pi)
244{ 244{
245 QListViewItem *pa = pi->itemAbove(); 245 QListViewItem *pa = pi->itemAbove();
246 246
247 /*Does what the QListViewItem::previousSibling() 247 /*Does what the QListViewItem::previousSibling()
248 *of my dreams would do. 248 *of my dreams would do.
249 */ 249 */
250 if (pa && pa->parent() == pi->parent()) 250 if (pa && pa->parent() == pi->parent())
251 return pa; 251 return pa;
252 252
253 return NULL; 253 return NULL;
254} 254}
255 255
256static QListViewItem *lastQChild (QListViewItem *pi) 256static QListViewItem *lastQChild (QListViewItem *pi)
257{ 257{
258 if (pi) 258 if (pi)
259 { 259 {
260 /*Since there's no QListViewItem::lastChild(). 260 /*Since there's no QListViewItem::lastChild().
261 *This finds the last sibling for the given 261 *This finds the last sibling for the given
262 *item. 262 *item.
263 */ 263 */
264 for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) 264 for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling())
265 pi = pt; 265 pi = pt;
266 } 266 }
267 267
268 return pi; 268 return pi;
269} 269}
270/*US 270/*US
271void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) 271void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward)
272{ 272{
273 const int ncols = p->columns(); 273 const int ncols = p->columns();
274 const int dir = forward ? +1 : -1; 274 const int dir = forward ? +1 : -1;
275 const int restart = forward ? 0 : (ncols - 1); 275 const int restart = forward ? 0 : (ncols - 1);
276 QListViewItem *top = (pitem && pitem->parent()) 276 QListViewItem *top = (pitem && pitem->parent())
277 ? pitem->parent()->firstChild() 277 ? pitem->parent()->firstChild()
278 : p->firstChild(); 278 : p->firstChild();
279 QListViewItem *pi = pitem; 279 QListViewItem *pi = pitem;
280 280
281 terminate(); //Save current changes 281 terminate(); //Save current changes
282 282
283 do 283 do
284 { 284 {
285*/ 285*/
286 /*Check the rest of the current row for an editable column, 286 /*Check the rest of the current row for an editable column,
287 *if that fails, check the entire next/previous row. The 287 *if that fails, check the entire next/previous row. The
288 *last case goes back to the first item in the current branch 288 *last case goes back to the first item in the current branch
289 *or the last item in the current branch depending on the 289 *or the last item in the current branch depending on the
290 *direction. 290 *direction.
291 */ 291 */
292/*US 292/*US
293 if ((column = nextCol(p, pi, column + dir, dir)) != -1 || 293 if ((column = nextCol(p, pi, column + dir, dir)) != -1 ||
294 (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || 294 (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 ||
295 (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) 295 (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1)
296 { 296 {
297 if (pi) 297 if (pi)
298 { 298 {
299 p->setCurrentItem(pi); //Calls terminate 299 p->setCurrentItem(pi); //Calls terminate
300 p->rename(pi, column); 300 p->rename(pi, column);
301*/ 301*/
302 /*Some listviews may override rename() to 302 /*Some listviews may override rename() to
303 *prevent certain items from being renamed, 303 *prevent certain items from being renamed,
304 *if this is done, [m_]item will be NULL 304 *if this is done, [m_]item will be NULL
305 *after the rename() call... try again. 305 *after the rename() call... try again.
306 */ 306 */
307/*US 307/*US
308 if (!item) 308 if (!item)
309 continue; 309 continue;
310 310
311 break; 311 break;
312 } 312 }
313 } 313 }
314 } 314 }
315 while (pi && !item); 315 while (pi && !item);
316} 316}
317*/ 317*/
318 318
319/*US 319/*US
320#ifdef KeyPress 320#ifdef KeyPress
321#undef KeyPress 321#undef KeyPress
322#endif 322#endif
323 323
324bool KListViewLineEdit::event (QEvent *pe) 324bool KListViewLineEdit::event (QEvent *pe)
325{ 325{
326 if (pe->type() == QEvent::KeyPress) 326 if (pe->type() == QEvent::KeyPress)
327 { 327 {
328 QKeyEvent *k = (QKeyEvent *) pe; 328 QKeyEvent *k = (QKeyEvent *) pe;
329 329
330 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && 330 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) &&
331 p->tabOrderedRenaming() && p->itemsRenameable() && 331 p->tabOrderedRenaming() && p->itemsRenameable() &&
332 !(k->state() & ControlButton || k->state() & AltButton)) 332 !(k->state() & ControlButton || k->state() & AltButton))
333 { 333 {
334 selectNextCell(item, col, 334 selectNextCell(item, col,
335 (k->key() == Key_Tab && !(k->state() & ShiftButton))); 335 (k->key() == Key_Tab && !(k->state() & ShiftButton)));
336 return true; 336 return true;
337 } 337 }
338 } 338 }
339 339
340 return KLineEdit::event(pe); 340 return KLineEdit::event(pe);
341} 341}
342 342
343void KListViewLineEdit::keyPressEvent(QKeyEvent *e) 343void KListViewLineEdit::keyPressEvent(QKeyEvent *e)
344{ 344{
345 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) 345 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
346 terminate(true); 346 terminate(true);
347 else if(e->key() == Qt::Key_Escape) 347 else if(e->key() == Qt::Key_Escape)
348 terminate(false); 348 terminate(false);
349 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) 349 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up)
350 { 350 {
351 terminate(true); 351 terminate(true);
352 KLineEdit::keyPressEvent(e); 352 KLineEdit::keyPressEvent(e);
353 } 353 }
354 else 354 else
355 KLineEdit::keyPressEvent(e); 355 KLineEdit::keyPressEvent(e);
356} 356}
357 357
358void KListViewLineEdit::terminate() 358void KListViewLineEdit::terminate()
359{ 359{
360 terminate(true); 360 terminate(true);
361} 361}
362 362
363void KListViewLineEdit::terminate(bool commit) 363void KListViewLineEdit::terminate(bool commit)
364{ 364{
365 if ( item ) 365 if ( item )
366 { 366 {
367 //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; 367 //kdDebug() << "KListViewLineEdit::terminate " << commit << endl;
368 if (commit) 368 if (commit)
369 item->setText(col, text()); 369 item->setText(col, text());
370 int c=col; 370 int c=col;
371 QListViewItem *i=item; 371 QListViewItem *i=item;
372 col=0; 372 col=0;
373 item=0; 373 item=0;
374 hide(); // will call focusOutEvent, that's why we set item=0 before 374 hide(); // will call focusOutEvent, that's why we set item=0 before
375 emit done(i,c); 375 emit done(i,c);
376 } 376 }
377} 377}
378 378
379void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) 379void KListViewLineEdit::focusOutEvent(QFocusEvent *ev)
380{ 380{
381 QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); 381 QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev);
382 // Don't let a RMB close the editor 382 // Don't let a RMB close the editor
383 if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) 383 if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow)
384 terminate(true); 384 terminate(true);
385} 385}
386 386
387void KListViewLineEdit::paintEvent( QPaintEvent *e ) 387void KListViewLineEdit::paintEvent( QPaintEvent *e )
388{ 388{
389 KLineEdit::paintEvent( e ); 389 KLineEdit::paintEvent( e );
390 390
391 if ( !frame() ) { 391 if ( !frame() ) {
392 QPainter p( this ); 392 QPainter p( this );
393 p.setClipRegion( e->region() ); 393 p.setClipRegion( e->region() );
394 p.drawRect( rect() ); 394 p.drawRect( rect() );
395 } 395 }
396} 396}
397 397
398// selection changed -> terminate. As our "item" can be already deleted, 398// selection changed -> terminate. As our "item" can be already deleted,
399// we can't call terminate(false), because that would emit done() with 399// we can't call terminate(false), because that would emit done() with
400// a dangling pointer to "item". 400// a dangling pointer to "item".
401void KListViewLineEdit::slotSelectionChanged() 401void KListViewLineEdit::slotSelectionChanged()
402{ 402{
403 item = 0; 403 item = 0;
404 col = 0; 404 col = 0;
405 hide(); 405 hide();
406} 406}
407*/ 407*/
408 408
409KListView::KListView( QWidget *parent, const char *name ) 409KListView::KListView( QWidget *parent, const char *name )
410 : QListView( parent, name ), 410 : QListView( parent, name ),
411 d (new KListViewPrivate (this)) 411 d (new KListViewPrivate (this))
412{ 412{
413#ifndef DESKTOP_VERSION 413#ifndef DESKTOP_VERSION
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//US d->alternateBackground = KGlobalSettings::alternateBackgroundColor();
463 d->alternateBackground = QColor(240, 240, 240); 463 d->alternateBackground = QColor(240, 240, 240);
464} 464}
465 465
466 466
467 467
468KListView::~KListView() 468KListView::~KListView()
469{ 469{
470 delete d; 470 delete d;
471} 471}
472 472
473bool KListView::isExecuteArea( const QPoint& point ) 473bool KListView::isExecuteArea( const QPoint& point )
474{ 474{
475 if ( itemAt( point ) ) 475 if ( itemAt( point ) )
476 return isExecuteArea( point.x() ); 476 return isExecuteArea( point.x() );
477 477
478 return false; 478 return false;
479} 479}
480 480
481bool KListView::isExecuteArea( int x ) 481bool KListView::isExecuteArea( int x )
482{ 482{
483 if( allColumnsShowFocus() ) 483 if( allColumnsShowFocus() )
484 return true; 484 return true;
485 else { 485 else {
486 int offset = 0; 486 int offset = 0;
487 int width = columnWidth( 0 ); 487 int width = columnWidth( 0 );
488 int pos = header()->mapToIndex( 0 ); 488 int pos = header()->mapToIndex( 0 );
489 489
490 for ( int index = 0; index < pos; index++ ) 490 for ( int index = 0; index < pos; index++ )
491 offset += columnWidth( header()->mapToSection( index ) ); 491 offset += columnWidth( header()->mapToSection( index ) );
492 492
493 x += contentsX(); // in case of a horizontal scrollbar 493 x += contentsX(); // in case of a horizontal scrollbar
494 return ( x > offset && x < ( offset + width ) ); 494 return ( x > offset && x < ( offset + width ) );
495 } 495 }
496} 496}
497 497
498void KListView::slotOnItem( QListViewItem *item ) 498void KListView::slotOnItem( QListViewItem *item )
499{ 499{
500 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); 500 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() );
501 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { 501 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) {
502 d->autoSelect.start( d->autoSelectDelay, true ); 502 d->autoSelect.start( d->autoSelectDelay, true );
503 d->pCurrentItem = item; 503 d->pCurrentItem = item;
504 } 504 }
505} 505}
506 506
507void KListView::slotOnViewport() 507void KListView::slotOnViewport()
508{ 508{
509 if ( d->bChangeCursorOverItem ) 509 if ( d->bChangeCursorOverItem )
510 viewport()->unsetCursor(); 510 viewport()->unsetCursor();
511 511
512 d->autoSelect.stop(); 512 d->autoSelect.stop();
513 d->pCurrentItem = 0L; 513 d->pCurrentItem = 0L;
514} 514}
515 515
516void KListView::slotSettingsChanged(int category) 516void KListView::slotSettingsChanged(int category)
517{ 517{
518 //qDebug("KListView::slotSettingsChanged has to be verified"); 518 //qDebug("KListView::slotSettingsChanged has to be verified");
519/*US 519/*US
520 520
521 switch (category) 521 switch (category)
522 { 522 {
523 case KApplication::SETTINGS_MOUSE: 523 case KApplication::SETTINGS_MOUSE:
524 d->dragDelay = KGlobalSettings::dndEventDelay(); 524 d->dragDelay = KGlobalSettings::dndEventDelay();
525 d->bUseSingle = KGlobalSettings::singleClick(); 525 d->bUseSingle = KGlobalSettings::singleClick();
526 526
527 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 527 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
528 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); 528 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int)));
529 529
530 if( d->bUseSingle ) 530 if( d->bUseSingle )
531 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 531 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
532 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); 532 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int)));
533 533
534 d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); 534 d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon();
535 d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); 535 d->autoSelectDelay = KGlobalSettings::autoSelectDelay();
536 536
537 if( !d->bUseSingle || !d->bChangeCursorOverItem ) 537 if( !d->bUseSingle || !d->bChangeCursorOverItem )
538 viewport()->unsetCursor(); 538 viewport()->unsetCursor();
539 539
540 break; 540 break;
541 541
542 case KApplication::SETTINGS_POPUPMENU: 542 case KApplication::SETTINGS_POPUPMENU:
543 d->contextMenuKey = KGlobalSettings::contextMenuKey (); 543 d->contextMenuKey = KGlobalSettings::contextMenuKey ();
544 d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); 544 d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress ();
545 545
546 if (d->showContextMenusOnPress) 546 if (d->showContextMenusOnPress)
547 { 547 {
548 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 548 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
549 549
550 connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), 550 connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)),
551 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 551 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
552 } 552 }
553 else 553 else
554 { 554 {
555 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 555 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
556 556
557 connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), 557 connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)),
558 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 558 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
559 } 559 }
560 break; 560 break;
561 561
562 default: 562 default:
563 break; 563 break;
564 } 564 }
565*/ 565*/
566 566
567 if( d->bUseSingle ) 567 if( d->bUseSingle )
568 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 568 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
569 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); 569 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int)));
570 570
571} 571}
572 572
573void KListView::slotAutoSelect() 573void KListView::slotAutoSelect()
574{ 574{
575 // check that the item still exists 575 // check that the item still exists
576 if( itemIndex( d->pCurrentItem ) == -1 ) 576 if( itemIndex( d->pCurrentItem ) == -1 )
577 return; 577 return;
578 578
579 if (!isActiveWindow()) 579 if (!isActiveWindow())
580 { 580 {
581 d->autoSelect.stop(); 581 d->autoSelect.stop();
582 return; 582 return;
583 } 583 }
584 584
585 //Give this widget the keyboard focus. 585 //Give this widget the keyboard focus.
586 if( !hasFocus() ) 586 if( !hasFocus() )
587 setFocus(); 587 setFocus();
588 588
589 QListViewItem* previousItem = currentItem(); 589 QListViewItem* previousItem = currentItem();
590 setCurrentItem( d->pCurrentItem ); 590 setCurrentItem( d->pCurrentItem );
591 591
592#if 0 592#if 0
593#ifndef Q_WS_QWS 593#ifndef Q_WS_QWS
594 // FIXME(E): Implement for Qt Embedded 594 // FIXME(E): Implement for Qt Embedded
595 if( d->pCurrentItem ) { 595 if( d->pCurrentItem ) {
596 //Shift pressed? 596 //Shift pressed?
597 if( (keybstate & ShiftMask) ) { 597 if( (keybstate & ShiftMask) ) {
598 bool block = signalsBlocked(); 598 bool block = signalsBlocked();
599 blockSignals( true ); 599 blockSignals( true );
600 600
601 //No Ctrl? Then clear before! 601 //No Ctrl? Then clear before!
602 if( !(keybstate & ControlMask) ) 602 if( !(keybstate & ControlMask) )
603 clearSelection(); 603 clearSelection();
604 604
605 bool select = !d->pCurrentItem->isSelected(); 605 bool select = !d->pCurrentItem->isSelected();
606 bool update = viewport()->isUpdatesEnabled(); 606 bool update = viewport()->isUpdatesEnabled();
607 viewport()->setUpdatesEnabled( false ); 607 viewport()->setUpdatesEnabled( false );
608 608
609 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); 609 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos();
610 QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); 610 QListViewItemIterator lit( down ? previousItem : d->pCurrentItem );
611 for ( ; lit.current(); ++lit ) { 611 for ( ; lit.current(); ++lit ) {
612 if ( down && lit.current() == d->pCurrentItem ) { 612 if ( down && lit.current() == d->pCurrentItem ) {
613 d->pCurrentItem->setSelected( select ); 613 d->pCurrentItem->setSelected( select );
614 break; 614 break;
615 } 615 }
616 if ( !down && lit.current() == previousItem ) { 616 if ( !down && lit.current() == previousItem ) {
617 previousItem->setSelected( select ); 617 previousItem->setSelected( select );
618 break; 618 break;
619 } 619 }
620 lit.current()->setSelected( select ); 620 lit.current()->setSelected( select );
621 } 621 }
622 622
623 blockSignals( block ); 623 blockSignals( block );
624 viewport()->setUpdatesEnabled( update ); 624 viewport()->setUpdatesEnabled( update );
625 triggerUpdate(); 625 triggerUpdate();
626 626
627 emit selectionChanged(); 627 emit selectionChanged();
628 628
629 if( selectionMode() == QListView::Single ) 629 if( selectionMode() == QListView::Single )
630 emit selectionChanged( d->pCurrentItem ); 630 emit selectionChanged( d->pCurrentItem );
631 } 631 }
632 else if( (keybstate & ControlMask) ) 632 else if( (keybstate & ControlMask) )
633 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); 633 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() );
634 else { 634 else {
635 bool block = signalsBlocked(); 635 bool block = signalsBlocked();
636 blockSignals( true ); 636 blockSignals( true );
637 637
638 if( !d->pCurrentItem->isSelected() ) 638 if( !d->pCurrentItem->isSelected() )
639 clearSelection(); 639 clearSelection();
640 640
641 blockSignals( block ); 641 blockSignals( block );
642 642
643 setSelected( d->pCurrentItem, true ); 643 setSelected( d->pCurrentItem, true );
644 } 644 }
645 } 645 }
646 else 646 else
647 kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; 647 kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl;
648#endif 648#endif
649#endif 649#endif
650} 650}
651 651
652void KListView::slotHeaderChanged() 652void KListView::slotHeaderChanged()
653{ 653{
654 if (d->fullWidth && columns()) 654 if (d->fullWidth && columns())
655 { 655 {
656 int w = 0; 656 int w = 0;
657 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); 657 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i);
658 setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); 658 setColumnWidth( columns() - 1, viewport()->width() - w - 1 );
659 } 659 }
660} 660}
661 661
662void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c ) 662void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c )
663{ 663{
664 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { 664 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) {
665 665
666 // Double click mode ? 666 // Double click mode ?
667 if ( !d->bUseSingle ) 667 if ( !d->bUseSingle )
668 { 668 {
669 emit executed( item ); 669 emit executed( item );
670 emit executed( item, pos, c ); 670 emit executed( item, pos, c );
671 } 671 }
672 else 672 else
673 { 673 {
674#if 0 674#if 0
675#ifndef Q_WS_QWS 675#ifndef Q_WS_QWS
676 // FIXME(E): Implement for Qt Embedded 676 // FIXME(E): Implement for Qt Embedded
677 Window root; 677 Window root;
678 Window child; 678 Window child;
679 int root_x, root_y, win_x, win_y; 679 int root_x, root_y, win_x, win_y;
680 uint keybstate; 680 uint keybstate;
681 XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, 681 XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child,
682 &root_x, &root_y, &win_x, &win_y, &keybstate ); 682 &root_x, &root_y, &win_x, &win_y, &keybstate );
683 683
684 d->autoSelect.stop(); 684 d->autoSelect.stop();
685 685
686 //Dont emit executed if in SC mode and Shift or Ctrl are pressed 686 //Dont emit executed if in SC mode and Shift or Ctrl are pressed
687 if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { 687 if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) {
688 emit executed( item ); 688 emit executed( item );
689 emit executed( item, pos, c ); 689 emit executed( item, pos, c );
690 } 690 }
691#endif 691#endif
692#endif 692#endif
693 } 693 }
694 } 694 }
695} 695}
696 696
697void KListView::focusInEvent( QFocusEvent *fe ) 697void KListView::focusInEvent( QFocusEvent *fe )
698{ 698{
699 // kdDebug()<<"KListView::focusInEvent()"<<endl; 699 // kdDebug()<<"KListView::focusInEvent()"<<endl;
700 QListView::focusInEvent( fe ); 700 QListView::focusInEvent( fe );
701 if ((d->selectedBySimpleMove) 701 if ((d->selectedBySimpleMove)
702 && (d->selectionMode == FileManager) 702 && (d->selectionMode == FileManager)
703 && (fe->reason()!=QFocusEvent::Popup) 703 && (fe->reason()!=QFocusEvent::Popup)
704 && (fe->reason()!=QFocusEvent::ActiveWindow) 704 && (fe->reason()!=QFocusEvent::ActiveWindow)
705 && (currentItem()!=0)) 705 && (currentItem()!=0))
706 { 706 {
707 currentItem()->setSelected(true); 707 currentItem()->setSelected(true);
708 currentItem()->repaint(); 708 currentItem()->repaint();
709 emit selectionChanged(); 709 emit selectionChanged();
710 }; 710 };
711} 711}
712 712
713void KListView::focusOutEvent( QFocusEvent *fe ) 713void KListView::focusOutEvent( QFocusEvent *fe )
714{ 714{
715 cleanDropVisualizer(); 715 cleanDropVisualizer();
716 cleanItemHighlighter(); 716 cleanItemHighlighter();
717 717
718 d->autoSelect.stop(); 718 d->autoSelect.stop();
719 719
720 if ((d->selectedBySimpleMove) 720 if ((d->selectedBySimpleMove)
721 && (d->selectionMode == FileManager) 721 && (d->selectionMode == FileManager)
722 && (fe->reason()!=QFocusEvent::Popup) 722 && (fe->reason()!=QFocusEvent::Popup)
723 && (fe->reason()!=QFocusEvent::ActiveWindow) 723 && (fe->reason()!=QFocusEvent::ActiveWindow)
724 && (currentItem()!=0) 724 && (currentItem()!=0)
725/*US && (!d->editor->isVisible()) */ 725/*US && (!d->editor->isVisible()) */
726 ) 726 )
727 { 727 {
728 currentItem()->setSelected(false); 728 currentItem()->setSelected(false);
729 currentItem()->repaint(); 729 currentItem()->repaint();
730 emit selectionChanged(); 730 emit selectionChanged();
731 }; 731 };
732 732
733 QListView::focusOutEvent( fe ); 733 QListView::focusOutEvent( fe );
734} 734}
735 735
736void KListView::leaveEvent( QEvent *e ) 736void KListView::leaveEvent( QEvent *e )
737{ 737{
738 d->autoSelect.stop(); 738 d->autoSelect.stop();
739 739
740 QListView::leaveEvent( e ); 740 QListView::leaveEvent( e );
741} 741}
742 742
743bool KListView::event( QEvent *e ) 743bool KListView::event( QEvent *e )
744{ 744{
745 if (e->type() == QEvent::ApplicationPaletteChange) { 745 if (e->type() == QEvent::ApplicationPaletteChange) {
746qDebug("KListView::event make alternate color configurable"); 746qDebug("KListView::event make alternate color configurable");
747//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); 747//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor();
748 d->alternateBackground = QColor(240, 240, 240); 748 d->alternateBackground = QColor(240, 240, 240);
749 } 749 }
750 750
751 return QListView::event(e); 751 return QListView::event(e);
752} 752}
753 753
754void KListView::contentsMousePressEvent( QMouseEvent *e ) 754void KListView::contentsMousePressEvent( QMouseEvent *e )
755{ 755{
756 if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) 756 if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) )
757 { 757 {
758 bool block = signalsBlocked(); 758 bool block = signalsBlocked();
759 blockSignals( true ); 759 blockSignals( true );
760 760
761 clearSelection(); 761 clearSelection();
762 762
763 blockSignals( block ); 763 blockSignals( block );
764 } 764 }
765 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) 765 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove))
766 { 766 {
767 d->selectedBySimpleMove=false; 767 d->selectedBySimpleMove=false;
768 d->selectedUsingMouse=true; 768 d->selectedUsingMouse=true;
769 if (currentItem()!=0) 769 if (currentItem()!=0)
770 { 770 {
771 currentItem()->setSelected(false); 771 currentItem()->setSelected(false);
772 currentItem()->repaint(); 772 currentItem()->repaint();
773// emit selectionChanged(); 773// emit selectionChanged();
774 }; 774 };
775 }; 775 };
776 776
777 QPoint p( contentsToViewport( e->pos() ) ); 777 QPoint p( contentsToViewport( e->pos() ) );
778 QListViewItem *at = itemAt (p); 778 QListViewItem *at = itemAt (p);
779 779
780 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) 780 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
781 bool rootDecoClicked = at 781 bool rootDecoClicked = at
782 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + 782 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
783 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) 783 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
784 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); 784 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
785 785
786 if (e->button() == LeftButton && !rootDecoClicked) 786 if (e->button() == LeftButton && !rootDecoClicked)
787 { 787 {
788 //Start a drag 788 //Start a drag
789 d->startDragPos = e->pos(); 789 d->startDragPos = e->pos();
790 790
791 if (at) 791 if (at)
792 { 792 {
793 d->validDrag = true; 793 d->validDrag = true;
794 d->pressedOnSelected = at->isSelected(); 794 d->pressedOnSelected = at->isSelected();
795 } 795 }
796 } 796 }
797 797
798 QListView::contentsMousePressEvent( e ); 798 QListView::contentsMousePressEvent( e );
799} 799}
800 800
801void KListView::contentsMouseMoveEvent( QMouseEvent *e ) 801void KListView::contentsMouseMoveEvent( QMouseEvent *e )
802{ 802{
803 if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { 803 if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) {
804 QListView::contentsMouseMoveEvent (e); 804 QListView::contentsMouseMoveEvent (e);
805 return; 805 return;
806 } 806 }
807 807
808 QPoint vp = contentsToViewport(e->pos()); 808 QPoint vp = contentsToViewport(e->pos());
809 QListViewItem *item = itemAt( vp ); 809 QListViewItem *item = itemAt( vp );
810 810
811 //do we process cursor changes at all? 811 //do we process cursor changes at all?
812 if ( item && d->bChangeCursorOverItem && d->bUseSingle ) 812 if ( item && d->bChangeCursorOverItem && d->bUseSingle )
813 { 813 {
814 //Cursor moved on a new item or in/out the execute area 814 //Cursor moved on a new item or in/out the execute area
815 if( (item != d->pCurrentItem) || 815 if( (item != d->pCurrentItem) ||
816 (isExecuteArea(vp) != d->cursorInExecuteArea) ) 816 (isExecuteArea(vp) != d->cursorInExecuteArea) )
817 { 817 {
818 d->cursorInExecuteArea = isExecuteArea(vp); 818 d->cursorInExecuteArea = isExecuteArea(vp);
819qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); 819qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet");
820/*US 820/*US
821 if( d->cursorInExecuteArea ) //cursor moved in execute area 821 if( d->cursorInExecuteArea ) //cursor moved in execute area
822 viewport()->setCursor( KCursor::handCursor() ); 822 viewport()->setCursor( KCursor::handCursor() );
823 else //cursor moved out of execute area 823 else //cursor moved out of execute area
824 viewport()->unsetCursor(); 824 viewport()->unsetCursor();
825*/ 825*/
826 } 826 }
827 } 827 }
828 828
829 bool dragOn = dragEnabled(); 829 bool dragOn = dragEnabled();
830 QPoint newPos = e->pos(); 830 QPoint newPos = e->pos();
831 if (dragOn && d->validDrag && 831 if (dragOn && d->validDrag &&
832 (newPos.x() > d->startDragPos.x()+d->dragDelay || 832 (newPos.x() > d->startDragPos.x()+d->dragDelay ||
833 newPos.x() < d->startDragPos.x()-d->dragDelay || 833 newPos.x() < d->startDragPos.x()-d->dragDelay ||
834 newPos.y() > d->startDragPos.y()+d->dragDelay || 834 newPos.y() > d->startDragPos.y()+d->dragDelay ||
835 newPos.y() < d->startDragPos.y()-d->dragDelay)) 835 newPos.y() < d->startDragPos.y()-d->dragDelay))
836 //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) 836 //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance())
837 { 837 {
838 QListView::contentsMouseReleaseEvent( 0 ); 838 QListView::contentsMouseReleaseEvent( 0 );
839 startDrag(); 839 startDrag();
840 d->startDragPos = QPoint(); 840 d->startDragPos = QPoint();
841 d->validDrag = false; 841 d->validDrag = false;
842 } 842 }
843} 843}
844 844
845void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) 845void KListView::contentsMouseReleaseEvent( QMouseEvent *e )
846{ 846{
847 if (e->button() == LeftButton) 847 if (e->button() == LeftButton)
848 { 848 {
849 // If the row was already selected, maybe we want to start an in-place editing 849 // If the row was already selected, maybe we want to start an in-place editing
850 if ( d->pressedOnSelected && itemsRenameable() ) 850 if ( d->pressedOnSelected && itemsRenameable() )
851 { 851 {
852 QPoint p( contentsToViewport( e->pos() ) ); 852 QPoint p( contentsToViewport( e->pos() ) );
853 QListViewItem *at = itemAt (p); 853 QListViewItem *at = itemAt (p);
854 if ( at ) 854 if ( at )
855 { 855 {
856 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) 856 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
857 bool rootDecoClicked = 857 bool rootDecoClicked =
858 ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + 858 ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
859 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) 859 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
860 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); 860 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
861 861
862 if (!rootDecoClicked) 862 if (!rootDecoClicked)
863 { 863 {
864 int col = header()->mapToLogical( header()->cellAt( p.x() ) ); 864 int col = header()->mapToLogical( header()->cellAt( p.x() ) );
865 if ( d->renameable.contains(col) ) 865 if ( d->renameable.contains(col) )
866 rename(at, col); 866 rename(at, col);
867 } 867 }
868 } 868 }
869 } 869 }
870 870
871 d->pressedOnSelected = false; 871 d->pressedOnSelected = false;
872 d->validDrag = false; 872 d->validDrag = false;
873 d->startDragPos = QPoint(); 873 d->startDragPos = QPoint();
874 } 874 }
875 QListView::contentsMouseReleaseEvent( e ); 875 QListView::contentsMouseReleaseEvent( e );
876} 876}
877 877
878void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) 878void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e )
879{ 879{
880 // We don't want to call the parent method because it does setOpen, 880 // We don't want to call the parent method because it does setOpen,
881 // whereas we don't do it in single click mode... (David) 881 // whereas we don't do it in single click mode... (David)
882 //QListView::contentsMouseDoubleClickEvent( e ); 882 //QListView::contentsMouseDoubleClickEvent( e );
883 883
884 QPoint vp = contentsToViewport(e->pos()); 884 QPoint vp = contentsToViewport(e->pos());
885 QListViewItem *item = itemAt( vp ); 885 QListViewItem *item = itemAt( vp );
886 emit QListView::doubleClicked( item ); // we do it now 886 emit QListView::doubleClicked( item ); // we do it now
887 887
888 int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; 888 int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1;
889 889
890 if( item ) { 890 if( item ) {
891 emit doubleClicked( item, e->globalPos(), col ); 891 emit doubleClicked( item, e->globalPos(), col );
892 892
893 if( (e->button() == LeftButton) && !d->bUseSingle ) 893 if( (e->button() == LeftButton) && !d->bUseSingle )
894 emitExecute( item, e->globalPos(), col ); 894 emitExecute( item, e->globalPos(), col );
895 } 895 }
896} 896}
897 897
898void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) 898void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c )
899{ 899{
900 if( (btn == LeftButton) && item ) 900 if( (btn == LeftButton) && item )
901 emitExecute(item, pos, c); 901 emitExecute(item, pos, c);
902} 902}
903 903
904void KListView::contentsDropEvent(QDropEvent* e) 904void KListView::contentsDropEvent(QDropEvent* e)
905{ 905{
906qDebug("KListView::contentsDropEvent drag&drop not supported yet"); 906qDebug("KListView::contentsDropEvent drag&drop not supported yet");
907/*US 907/*US
908 cleanDropVisualizer(); 908 cleanDropVisualizer();
909 cleanItemHighlighter(); 909 cleanItemHighlighter();
910 d->dragExpand.stop(); 910 d->dragExpand.stop();
911 911
912 if (acceptDrag (e)) 912 if (acceptDrag (e))
913 { 913 {
914 e->acceptAction(); 914 e->acceptAction();
915 QListViewItem *afterme; 915 QListViewItem *afterme;
916 QListViewItem *parent; 916 QListViewItem *parent;
917 findDrop(e->pos(), parent, afterme); 917 findDrop(e->pos(), parent, afterme);
918 918
919 if (e->source() == viewport() && itemsMovable()) 919 if (e->source() == viewport() && itemsMovable())
920 movableDropEvent(parent, afterme); 920 movableDropEvent(parent, afterme);
921 else 921 else
922 { 922 {
923 923
924 emit dropped(e, afterme); 924 emit dropped(e, afterme);
925 emit dropped(this, e, afterme); 925 emit dropped(this, e, afterme);
926 emit dropped(e, parent, afterme); 926 emit dropped(e, parent, afterme);
927 emit dropped(this, e, parent, afterme); 927 emit dropped(this, e, parent, afterme);
928 928
929 } 929 }
930 } 930 }
931*/ 931*/
932 932
933} 933}
934 934
935void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) 935void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme)
936{ 936{
937 QPtrList<QListViewItem> items, afterFirsts, afterNows; 937 QPtrList<QListViewItem> items, afterFirsts, afterNows;
938 QListViewItem *current=currentItem(); 938 QListViewItem *current=currentItem();
939 bool hasMoved=false; 939 bool hasMoved=false;
940 for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) 940 for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext)
941 { 941 {
942 iNext=i->itemBelow(); 942 iNext=i->itemBelow();
943 if (!i->isSelected()) 943 if (!i->isSelected())
944 continue; 944 continue;
945 945
946 // don't drop an item after itself, or else 946 // don't drop an item after itself, or else
947 // it moves to the top of the list 947 // it moves to the top of the list
948 if (i==afterme) 948 if (i==afterme)
949 continue; 949 continue;
950 950
951 i->setSelected(false); 951 i->setSelected(false);
952 952
953 QListViewItem *afterFirst = i->itemAbove(); 953 QListViewItem *afterFirst = i->itemAbove();
954 954
955 if (!hasMoved) 955 if (!hasMoved)
956 { 956 {
957 emit aboutToMove(); 957 emit aboutToMove();
958 hasMoved=true; 958 hasMoved=true;
959 } 959 }
960 960
961 moveItem(i, parent, afterme); 961 moveItem(i, parent, afterme);
962 962
963 // ###### This should include the new parent !!! -> KDE 3.0 963 // ###### This should include the new parent !!! -> KDE 3.0
964 // If you need this right now, have a look at keditbookmarks. 964 // If you need this right now, have a look at keditbookmarks.
965 emit moved(i, afterFirst, afterme); 965 emit moved(i, afterFirst, afterme);
966 966
967 items.append (i); 967 items.append (i);
968 afterFirsts.append (afterFirst); 968 afterFirsts.append (afterFirst);
969 afterNows.append (afterme); 969 afterNows.append (afterme);
970 970
971 afterme = i; 971 afterme = i;
972 } 972 }
973 clearSelection(); 973 clearSelection();
974 for (QListViewItem *i=items.first(); i != 0; i=items.next() ) 974 for (QListViewItem *i=items.first(); i != 0; i=items.next() )
975 i->setSelected(true); 975 i->setSelected(true);
976 if (current) 976 if (current)
977 setCurrentItem(current); 977 setCurrentItem(current);
978 978
979 emit moved(items,afterFirsts,afterNows); 979 emit moved(items,afterFirsts,afterNows);
980 980
981 if (firstChild()) 981 if (firstChild())
982 emit moved(); 982 emit moved();
983} 983}
984 984
985void KListView::contentsDragMoveEvent(QDragMoveEvent *event) 985void KListView::contentsDragMoveEvent(QDragMoveEvent *event)
986{ 986{
987qDebug("KListView::contentsDropEvent drag&drop not supported yet"); 987qDebug("KListView::contentsDropEvent drag&drop not supported yet");
988/*US 988/*US
989 if (acceptDrag(event)) 989 if (acceptDrag(event))
990 { 990 {
991 event->acceptAction(); 991 event->acceptAction();
992 //Clean up the view 992 //Clean up the view
993 993
994 findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); 994 findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop);
995 QPoint vp = contentsToViewport( event->pos() ); 995 QPoint vp = contentsToViewport( event->pos() );
996 QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; 996 QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L;
997 997
998 if ( item != d->dragOverItem ) 998 if ( item != d->dragOverItem )
999 { 999 {
1000 d->dragExpand.stop(); 1000 d->dragExpand.stop();
1001 d->dragOverItem = item; 1001 d->dragOverItem = item;
1002 d->dragOverPoint = vp; 1002 d->dragOverPoint = vp;
1003 if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) 1003 if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() )
1004 d->dragExpand.start( QApplication::startDragTime(), true ); 1004 d->dragExpand.start( QApplication::startDragTime(), true );
1005 } 1005 }
1006 if (dropVisualizer()) 1006 if (dropVisualizer())
1007 { 1007 {
1008 QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); 1008 QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop);
1009 if (tmpRect != d->mOldDropVisualizer) 1009 if (tmpRect != d->mOldDropVisualizer)
1010 { 1010 {
1011 cleanDropVisualizer(); 1011 cleanDropVisualizer();
1012 d->mOldDropVisualizer=tmpRect; 1012 d->mOldDropVisualizer=tmpRect;
1013 viewport()->repaint(tmpRect); 1013 viewport()->repaint(tmpRect);
1014 } 1014 }
1015 } 1015 }
1016 if (dropHighlighter()) 1016 if (dropHighlighter())
1017 { 1017 {
1018 QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); 1018 QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop);
1019 if (tmpRect != d->mOldDropHighlighter) 1019 if (tmpRect != d->mOldDropHighlighter)
1020 { 1020 {
1021 cleanItemHighlighter(); 1021 cleanItemHighlighter();
1022 d->mOldDropHighlighter=tmpRect; 1022 d->mOldDropHighlighter=tmpRect;
1023 viewport()->repaint(tmpRect); 1023 viewport()->repaint(tmpRect);
1024 } 1024 }
1025 } 1025 }
1026 } 1026 }
1027 else 1027 else
1028 event->ignore(); 1028 event->ignore();
1029*/ 1029*/
1030} 1030}
1031 1031
1032void KListView::slotDragExpand() 1032void KListView::slotDragExpand()
1033{ 1033{
1034 if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) 1034 if ( itemAt( d->dragOverPoint ) == d->dragOverItem )
1035 d->dragOverItem->setOpen( true ); 1035 d->dragOverItem->setOpen( true );
1036} 1036}
1037 1037
1038void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) 1038void KListView::contentsDragLeaveEvent (QDragLeaveEvent*)
1039{ 1039{
1040 d->dragExpand.stop(); 1040 d->dragExpand.stop();
1041 cleanDropVisualizer(); 1041 cleanDropVisualizer();
1042 cleanItemHighlighter(); 1042 cleanItemHighlighter();
1043} 1043}
1044 1044
1045void KListView::cleanDropVisualizer() 1045void KListView::cleanDropVisualizer()
1046{ 1046{
1047 if (d->mOldDropVisualizer.isValid()) 1047 if (d->mOldDropVisualizer.isValid())
1048 { 1048 {
1049 QRect rect=d->mOldDropVisualizer; 1049 QRect rect=d->mOldDropVisualizer;
1050 d->mOldDropVisualizer = QRect(); 1050 d->mOldDropVisualizer = QRect();
1051 viewport()->repaint(rect, true); 1051 viewport()->repaint(rect, true);
1052 } 1052 }
1053} 1053}
1054 1054
1055int KListView::depthToPixels( int depth ) 1055int KListView::depthToPixels( int depth )
1056{ 1056{
1057 return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); 1057 return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin();
1058} 1058}
1059 1059
1060void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) 1060void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after)
1061{ 1061{
1062 QPoint p (contentsToViewport(pos)); 1062 QPoint p (contentsToViewport(pos));
1063 1063
1064 // Get the position to put it in 1064 // Get the position to put it in
1065 QListViewItem *atpos = itemAt(p); 1065 QListViewItem *atpos = itemAt(p);
1066 1066
1067 QListViewItem *above; 1067 QListViewItem *above;
1068 if (!atpos) // put it at the end 1068 if (!atpos) // put it at the end
1069 above = lastItem(); 1069 above = lastItem();
1070 else 1070 else
1071 { 1071 {
1072 // Get the closest item before us ('atpos' or the one above, if any) 1072 // Get the closest item before us ('atpos' or the one above, if any)
1073 if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) 1073 if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2))
1074 above = atpos->itemAbove(); 1074 above = atpos->itemAbove();
1075 else 1075 else
1076 above = atpos; 1076 above = atpos;
1077 } 1077 }
1078 1078
1079 if (above) 1079 if (above)
1080 { 1080 {
1081 // Now, we know we want to go after "above". But as a child or as a sibling ? 1081 // Now, we know we want to go after "above". But as a child or as a sibling ?
1082 // We have to ask the "above" item if it accepts children. 1082 // We have to ask the "above" item if it accepts children.
1083 if (above->isExpandable()) 1083 if (above->isExpandable())
1084 { 1084 {
1085 // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children 1085 // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children
1086 if (p.x() >= depthToPixels( above->depth() + 1 ) || 1086 if (p.x() >= depthToPixels( above->depth() + 1 ) ||
1087 (above->isOpen() && above->childCount() > 0) ) 1087 (above->isOpen() && above->childCount() > 0) )
1088 { 1088 {
1089 parent = above; 1089 parent = above;
1090 after = 0L; 1090 after = 0L;
1091 return; 1091 return;
1092 } 1092 }
1093 } 1093 }
1094 1094
1095 // Ok, there's one more level of complexity. We may want to become a new 1095 // Ok, there's one more level of complexity. We may want to become a new
1096 // sibling, but of an upper-level group, rather than the "above" item 1096 // sibling, but of an upper-level group, rather than the "above" item
1097 QListViewItem * betterAbove = above->parent(); 1097 QListViewItem * betterAbove = above->parent();
1098 QListViewItem * last = above; 1098 QListViewItem * last = above;
1099 while ( betterAbove ) 1099 while ( betterAbove )
1100 { 1100 {
1101 // We are allowed to become a sibling of "betterAbove" only if we are 1101 // We are allowed to become a sibling of "betterAbove" only if we are
1102 // after its last child 1102 // after its last child
1103 if ( last->nextSibling() == 0 ) 1103 if ( last->nextSibling() == 0 )
1104 { 1104 {
1105 if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) 1105 if (p.x() < depthToPixels ( betterAbove->depth() + 1 ))
1106 above = betterAbove; // store this one, but don't stop yet, there may be a better one 1106 above = betterAbove; // store this one, but don't stop yet, there may be a better one
1107 else 1107 else
1108 break; // not enough on the left, so stop 1108 break; // not enough on the left, so stop
1109 last = betterAbove; 1109 last = betterAbove;
1110 betterAbove = betterAbove->parent(); // up one level 1110 betterAbove = betterAbove->parent(); // up one level
1111 } else 1111 } else
1112 break; // we're among the child of betterAbove, not after the last one 1112 break; // we're among the child of betterAbove, not after the last one
1113 } 1113 }
1114 } 1114 }
1115 // set as sibling 1115 // set as sibling
1116 after = above; 1116 after = above;
1117 parent = after ? after->parent() : 0L ; 1117 parent = after ? after->parent() : 0L ;
1118} 1118}
1119 1119
1120QListViewItem* KListView::lastChild () const 1120QListViewItem* KListView::lastChild () const
1121{ 1121{
1122 QListViewItem* lastchild = firstChild(); 1122 QListViewItem* lastchild = firstChild();
1123 1123
1124 if (lastchild) 1124 if (lastchild)
1125 for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); 1125 for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling());
1126 1126
1127 return lastchild; 1127 return lastchild;
1128} 1128}
1129 1129
1130QListViewItem *KListView::lastItem() const 1130QListViewItem *KListView::lastItem() const
1131{ 1131{
1132 QListViewItem* last = lastChild(); 1132 QListViewItem* last = lastChild();
1133 1133
1134 for (QListViewItemIterator it (last); it.current(); ++it) 1134 for (QListViewItemIterator it (last); it.current(); ++it)
1135 last = it.current(); 1135 last = it.current();
1136 1136
1137 return last; 1137 return last;
1138} 1138}
1139 1139
1140KLineEdit *KListView::renameLineEdit() const 1140KLineEdit *KListView::renameLineEdit() const
1141{ 1141{
1142//US return d->editor; 1142//US return d->editor;
1143qDebug("KListView::renameLineEdit returns 0. Might crash"); 1143qDebug("KListView::renameLineEdit returns 0. Might crash");
1144return 0; 1144return 0;
1145} 1145}
1146 1146
1147void KListView::startDrag() 1147void KListView::startDrag()
1148{ 1148{
1149qDebug("KListView::startDrag drag&drop not supported yet."); 1149qDebug("KListView::startDrag drag&drop not supported yet.");
1150/*US 1150/*US
1151 QDragObject *drag = dragObject(); 1151 QDragObject *drag = dragObject();
1152 1152
1153 if (!drag) 1153 if (!drag)
1154 return; 1154 return;
1155 1155
1156 if (drag->drag() && drag->target() != viewport()) 1156 if (drag->drag() && drag->target() != viewport())
1157 emit moved(); 1157 emit moved();
1158*/ 1158*/
1159} 1159}
1160 1160
1161QDragObject *KListView::dragObject() 1161QDragObject *KListView::dragObject()
1162{ 1162{
1163 if (!currentItem()) 1163 if (!currentItem())
1164 return 0; 1164 return 0;
1165 1165
1166 return new QStoredDrag("application/x-qlistviewitem", viewport()); 1166 return new QStoredDrag("application/x-qlistviewitem", viewport());
1167} 1167}
1168 1168
1169void KListView::setItemsMovable(bool b) 1169void KListView::setItemsMovable(bool b)
1170{ 1170{
1171 d->itemsMovable=b; 1171 d->itemsMovable=b;
1172} 1172}
1173 1173
1174bool KListView::itemsMovable() const 1174bool KListView::itemsMovable() const
1175{ 1175{
1176 return d->itemsMovable; 1176 return d->itemsMovable;
1177} 1177}
1178 1178
1179void KListView::setItemsRenameable(bool b) 1179void KListView::setItemsRenameable(bool b)
1180{ 1180{
1181 d->itemsRenameable=b; 1181 d->itemsRenameable=b;
1182} 1182}
1183 1183
1184bool KListView::itemsRenameable() const 1184bool KListView::itemsRenameable() const
1185{ 1185{
1186 return d->itemsRenameable; 1186 return d->itemsRenameable;
1187} 1187}
1188 1188
1189 1189
1190void KListView::setDragEnabled(bool b) 1190void KListView::setDragEnabled(bool b)
1191{ 1191{
1192 d->dragEnabled=b; 1192 d->dragEnabled=b;
1193} 1193}
1194 1194
1195bool KListView::dragEnabled() const 1195bool KListView::dragEnabled() const
1196{ 1196{
1197 return d->dragEnabled; 1197 return d->dragEnabled;
1198} 1198}
1199 1199
1200void KListView::setAutoOpen(bool b) 1200void KListView::setAutoOpen(bool b)
1201{ 1201{
1202 d->autoOpen=b; 1202 d->autoOpen=b;
1203} 1203}
1204 1204
1205bool KListView::autoOpen() const 1205bool KListView::autoOpen() const
1206{ 1206{
1207 return d->autoOpen; 1207 return d->autoOpen;
1208} 1208}
1209 1209
1210bool KListView::dropVisualizer() const 1210bool KListView::dropVisualizer() const
1211{ 1211{
1212 return d->dropVisualizer; 1212 return d->dropVisualizer;
1213} 1213}
1214 1214
1215void KListView::setDropVisualizer(bool b) 1215void KListView::setDropVisualizer(bool b)
1216{ 1216{
1217 d->dropVisualizer=b; 1217 d->dropVisualizer=b;
1218} 1218}
1219 1219
1220QPtrList<QListViewItem> KListView::selectedItems() const 1220QPtrList<QListViewItem> KListView::selectedItems() const
1221{ 1221{
1222 QPtrList<QListViewItem> list; 1222 QPtrList<QListViewItem> list;
1223 for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) 1223 for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow())
1224 if (i->isSelected()) list.append(i); 1224 if (i->isSelected()) list.append(i);
1225 return list; 1225 return list;
1226} 1226}
1227 1227
1228 1228
1229void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) 1229void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after)
1230{ 1230{
1231 // sanity check - don't move a item into it's own child structure 1231 // sanity check - don't move a item into it's own child structure
1232 QListViewItem *i = parent; 1232 QListViewItem *i = parent;
1233 while(i) 1233 while(i)
1234 { 1234 {
1235 if(i == item) 1235 if(i == item)
1236 return; 1236 return;
1237 i = i->parent(); 1237 i = i->parent();
1238 } 1238 }
1239 1239
1240 // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor 1240 // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor
1241 // in here, without ever deleting the item. 1241 // in here, without ever deleting the item.
1242 if (item->parent()) 1242 if (item->parent())
1243 item->parent()->takeItem(item); 1243 item->parent()->takeItem(item);
1244 else 1244 else
1245 takeItem(item); 1245 takeItem(item);
1246 1246
1247 if (parent) 1247 if (parent)
1248 parent->insertItem(item); 1248 parent->insertItem(item);
1249 else 1249 else
1250 insertItem(item); 1250 insertItem(item);
1251 1251
1252 if (after) 1252 if (after)
1253 ;//item->moveToJustAfter(after); 1253 ;//item->moveToJustAfter(after);
1254} 1254}
1255 1255
1256void KListView::contentsDragEnterEvent(QDragEnterEvent *event) 1256void KListView::contentsDragEnterEvent(QDragEnterEvent *event)
1257{ 1257{
1258qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); 1258qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet.");
1259/*US 1259/*US
1260 if (acceptDrag (event)) 1260 if (acceptDrag (event))
1261 event->accept(); 1261 event->accept();
1262*/ 1262*/
1263} 1263}
1264 1264
1265void KListView::setDropVisualizerWidth (int w) 1265void KListView::setDropVisualizerWidth (int w)
1266{ 1266{
1267 d->mDropVisualizerWidth = w > 0 ? w : 1; 1267 d->mDropVisualizerWidth = w > 0 ? w : 1;
1268} 1268}
1269 1269
1270QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, 1270QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent,
1271 QListViewItem *after) 1271 QListViewItem *after)
1272{ 1272{
1273 QRect insertmarker; 1273 QRect insertmarker;
1274 1274
1275 if (!after && !parent) 1275 if (!after && !parent)
1276 insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); 1276 insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2);
1277 else 1277 else
1278 { 1278 {
1279 int level = 0; 1279 int level = 0;
1280 if (after) 1280 if (after)
1281 { 1281 {
1282 QListViewItem* it = 0L; 1282 QListViewItem* it = 0L;
1283 if (after->isOpen()) 1283 if (after->isOpen())
1284 { 1284 {
1285 // Look for the last child (recursively) 1285 // Look for the last child (recursively)
1286 it = after->firstChild(); 1286 it = after->firstChild();
1287 if (it) 1287 if (it)
1288 while (it->nextSibling() || it->firstChild()) 1288 while (it->nextSibling() || it->firstChild())
1289 if ( it->nextSibling() ) 1289 if ( it->nextSibling() )
1290 it = it->nextSibling(); 1290 it = it->nextSibling();
1291 else 1291 else
1292 it = it->firstChild(); 1292 it = it->firstChild();
1293 } 1293 }
1294 1294
1295 insertmarker = itemRect (it ? it : after); 1295 insertmarker = itemRect (it ? it : after);
1296 level = after->depth(); 1296 level = after->depth();
1297 } 1297 }
1298 else if (parent) 1298 else if (parent)
1299 { 1299 {
1300 insertmarker = itemRect (parent); 1300 insertmarker = itemRect (parent);
1301 level = parent->depth() + 1; 1301 level = parent->depth() + 1;
1302 } 1302 }
1303 insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); 1303 insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() );
1304 insertmarker.setRight (viewport()->width()); 1304 insertmarker.setRight (viewport()->width());
1305 insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); 1305 insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1);
1306 insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); 1306 insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2);
1307 } 1307 }
1308 1308
1309 // This is not used anymore, at least by KListView itself (see viewportPaintEvent) 1309 // This is not used anymore, at least by KListView itself (see viewportPaintEvent)
1310 // Remove for KDE 3.0. 1310 // Remove for KDE 3.0.
1311 if (p) 1311 if (p)
1312 p->fillRect(insertmarker, Dense4Pattern); 1312 p->fillRect(insertmarker, Dense4Pattern);
1313 1313
1314 return insertmarker; 1314 return insertmarker;
1315} 1315}
1316 1316
1317QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) 1317QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item)
1318{ 1318{
1319 QRect r; 1319 QRect r;
1320 1320
1321 if (item) 1321 if (item)
1322 { 1322 {
1323 r = itemRect(item); 1323 r = itemRect(item);
1324 r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); 1324 r.setLeft(r.left()+(item->depth()+1)*treeStepSize());
1325 if (painter) { 1325 if (painter) {
1326//US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), 1326//US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(),
1327//US QStyle::Style_FocusAtBorder, colorGroup().highlight()); 1327//US QStyle::Style_FocusAtBorder, colorGroup().highlight());
1328 const QColor* pHighl = &(colorGroup().highlight()); 1328 const QColor* pHighl = &(colorGroup().highlight());
1329 //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); 1329 //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true);
1330 1330
1331qDebug("KListView::drawItemHighlighter has to be verified"); 1331qDebug("KListView::drawItemHighlighter has to be verified");
1332 1332
1333 } 1333 }
1334 1334
1335 } 1335 }
1336 1336
1337 return r; 1337 return r;
1338} 1338}
1339 1339
1340void KListView::cleanItemHighlighter () 1340void KListView::cleanItemHighlighter ()
1341{ 1341{
1342 if (d->mOldDropHighlighter.isValid()) 1342 if (d->mOldDropHighlighter.isValid())
1343 { 1343 {
1344 QRect rect=d->mOldDropHighlighter; 1344 QRect rect=d->mOldDropHighlighter;
1345 d->mOldDropHighlighter = QRect(); 1345 d->mOldDropHighlighter = QRect();
1346 viewport()->repaint(rect, true); 1346 viewport()->repaint(rect, true);
1347 } 1347 }
1348} 1348}
1349 1349
1350void KListView::rename(QListViewItem *item, int c) 1350void KListView::rename(QListViewItem *item, int c)
1351{ 1351{
1352 if (d->renameable.contains(c)) 1352 if (d->renameable.contains(c))
1353 { 1353 {
1354 ensureItemVisible(item); 1354 ensureItemVisible(item);
1355//US d->editor->load(item,c); 1355//US d->editor->load(item,c);
1356qDebug("KListView::rename has to be verified"); 1356qDebug("KListView::rename has to be verified");
1357 1357
1358 } 1358 }
1359} 1359}
1360 1360
1361bool KListView::isRenameable (int col) const 1361bool KListView::isRenameable (int col) const
1362{ 1362{
1363 return d->renameable.contains(col); 1363 return d->renameable.contains(col);
1364} 1364}
1365 1365
1366void KListView::setRenameable (int col, bool yesno) 1366void KListView::setRenameable (int col, bool yesno)
1367{ 1367{
1368 if (col>=header()->count()) return; 1368 if (col>=header()->count()) return;
1369 1369
1370 d->renameable.remove(col); 1370 d->renameable.remove(col);
1371 if (yesno && d->renameable.find(col)==d->renameable.end()) 1371 if (yesno && d->renameable.find(col)==d->renameable.end())
1372 d->renameable+=col; 1372 d->renameable+=col;
1373 else if (!yesno && d->renameable.find(col)!=d->renameable.end()) 1373 else if (!yesno && d->renameable.find(col)!=d->renameable.end())
1374 d->renameable.remove(col); 1374 d->renameable.remove(col);
1375} 1375}
1376 1376
1377void KListView::doneEditing(QListViewItem *item, int row) 1377void KListView::doneEditing(QListViewItem *item, int row)
1378{ 1378{
1379 emit itemRenamed(item, item->text(row), row); 1379 emit itemRenamed(item, item->text(row), row);
1380 emit itemRenamed(item); 1380 emit itemRenamed(item);
1381} 1381}
1382 1382
1383bool KListView::acceptDrag(QDropEvent* e) const 1383bool KListView::acceptDrag(QDropEvent* e) const
1384{ 1384{
1385qDebug("KListView::acceptDrag drag&drop not supported yet"); 1385qDebug("KListView::acceptDrag drag&drop not supported yet");
1386//US return acceptDrops() && itemsMovable() && (e->source()==viewport()); 1386//US return acceptDrops() && itemsMovable() && (e->source()==viewport());
1387return false; 1387return false;
1388} 1388}
1389 1389
1390void KListView::setCreateChildren(bool b) 1390void KListView::setCreateChildren(bool b)
1391{ 1391{
1392 d->createChildren=b; 1392 d->createChildren=b;
1393} 1393}
1394 1394
1395bool KListView::createChildren() const 1395bool KListView::createChildren() const
1396{ 1396{
1397 return d->createChildren; 1397 return d->createChildren;
1398} 1398}
1399 1399
1400 1400
1401int KListView::tooltipColumn() const 1401int KListView::tooltipColumn() const
1402{ 1402{
1403 return d->tooltipColumn; 1403 return d->tooltipColumn;
1404} 1404}
1405 1405
1406void KListView::setTooltipColumn(int column) 1406void KListView::setTooltipColumn(int column)
1407{ 1407{
1408 d->tooltipColumn=column; 1408 d->tooltipColumn=column;
1409} 1409}
1410 1410
1411void KListView::setDropHighlighter(bool b) 1411void KListView::setDropHighlighter(bool b)
1412{ 1412{
1413 d->dropHighlighter=b; 1413 d->dropHighlighter=b;
1414} 1414}
1415 1415
1416bool KListView::dropHighlighter() const 1416bool KListView::dropHighlighter() const
1417{ 1417{
1418 return d->dropHighlighter; 1418 return d->dropHighlighter;
1419} 1419}
1420 1420
1421bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const 1421bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const
1422{ 1422{
1423 return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); 1423 return ((tooltip(item, column).length()>0) && (column==tooltipColumn()));
1424} 1424}
1425 1425
1426QString KListView::tooltip(QListViewItem *item, int column) const 1426QString KListView::tooltip(QListViewItem *item, int column) const
1427{ 1427{
1428 return item->text(column); 1428 return item->text(column);
1429} 1429}
1430 1430
1431void KListView::setTabOrderedRenaming(bool b) 1431void KListView::setTabOrderedRenaming(bool b)
1432{ 1432{
1433 d->tabRename = b; 1433 d->tabRename = b;
1434} 1434}
1435 1435
1436bool KListView::tabOrderedRenaming() const 1436bool KListView::tabOrderedRenaming() const
1437{ 1437{
1438 return d->tabRename; 1438 return d->tabRename;
1439} 1439}
1440 1440
1441void KListView::keyPressEvent (QKeyEvent* e) 1441void KListView::keyPressEvent (QKeyEvent* e)
1442{ 1442{
1443 //don't we need a contextMenuModifier too ? (aleXXX) 1443 //don't we need a contextMenuModifier too ? (aleXXX)
1444 if (e->key() == d->contextMenuKey) 1444 if (e->key() == d->contextMenuKey)
1445 { 1445 {
1446 emit menuShortCutPressed (this, currentItem()); 1446 emit menuShortCutPressed (this, currentItem());
1447 return; 1447 return;
1448 } 1448 }
1449 if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) 1449 if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace)
1450 { 1450 {
1451 emit signalDelete ( ); 1451 emit signalDelete ( );
1452 return; 1452 return;
1453 } 1453 }
1454 1454
1455 if (d->selectionMode != FileManager) 1455 if (d->selectionMode != FileManager)
1456 QListView::keyPressEvent (e); 1456 QListView::keyPressEvent (e);
1457 else 1457 else
1458 fileManagerKeyPressEvent (e); 1458 fileManagerKeyPressEvent (e);
1459} 1459}
1460 1460
1461void KListView::activateAutomaticSelection() 1461void KListView::activateAutomaticSelection()
1462{ 1462{
1463 d->selectedBySimpleMove=true; 1463 d->selectedBySimpleMove=true;
1464 d->selectedUsingMouse=false; 1464 d->selectedUsingMouse=false;
1465 if (currentItem()!=0) 1465 if (currentItem()!=0)
1466 { 1466 {
1467 selectAll(false); 1467 selectAll(false);
1468 currentItem()->setSelected(true); 1468 currentItem()->setSelected(true);
1469 currentItem()->repaint(); 1469 currentItem()->repaint();
1470 emit selectionChanged(); 1470 emit selectionChanged();
1471 }; 1471 };
1472} 1472}
1473 1473
1474void KListView::deactivateAutomaticSelection() 1474void KListView::deactivateAutomaticSelection()
1475{ 1475{
1476 d->selectedBySimpleMove=false; 1476 d->selectedBySimpleMove=false;
1477} 1477}
1478 1478
1479bool KListView::automaticSelection() const 1479bool KListView::automaticSelection() const
1480{ 1480{
1481 return d->selectedBySimpleMove; 1481 return d->selectedBySimpleMove;
1482} 1482}
1483 1483
1484void KListView::fileManagerKeyPressEvent (QKeyEvent* e) 1484void KListView::fileManagerKeyPressEvent (QKeyEvent* e)
1485{ 1485{
1486 //don't care whether it's on the keypad or not 1486 //don't care whether it's on the keypad or not
1487 int e_state=(e->state() & ~Keypad); 1487 int e_state=(e->state() & ~Keypad);
1488 1488
1489 int oldSelectionDirection(d->selectionDirection); 1489 int oldSelectionDirection(d->selectionDirection);
1490 1490
1491 if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) 1491 if ((e->key()!=Key_Shift) && (e->key()!=Key_Control)
1492 && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) 1492 && (e->key()!=Key_Meta) && (e->key()!=Key_Alt))
1493 { 1493 {
1494 if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) 1494 if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove))
1495 selectAll(FALSE); 1495 selectAll(FALSE);
1496 d->selectionDirection=0; 1496 d->selectionDirection=0;
1497 d->wasShiftEvent = (e_state == ShiftButton); 1497 d->wasShiftEvent = (e_state == ShiftButton);
1498 }; 1498 };
1499 1499
1500 //d->wasShiftEvent = (e_state == ShiftButton); 1500 //d->wasShiftEvent = (e_state == ShiftButton);
1501 1501
1502 1502
1503 QListViewItem* item = currentItem(); 1503 QListViewItem* item = currentItem();
1504 if (item==0) return; 1504 if (item==0) return;
1505 1505
1506 QListViewItem* repaintItem1 = item; 1506 QListViewItem* repaintItem1 = item;
1507 QListViewItem* repaintItem2 = 0L; 1507 QListViewItem* repaintItem2 = 0L;
1508 QListViewItem* visItem = 0L; 1508 QListViewItem* visItem = 0L;
1509 1509
1510 QListViewItem* nextItem = 0L; 1510 QListViewItem* nextItem = 0L;
1511 int items = 0; 1511 int items = 0;
1512 1512
1513 bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); 1513 bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton));
1514 int selectedItems(0); 1514 int selectedItems(0);
1515 for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) 1515 for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling())
1516 if (tmpItem->isSelected()) selectedItems++; 1516 if (tmpItem->isSelected()) selectedItems++;
1517 1517
1518 if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) 1518 if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse)))
1519 && (e_state==NoButton) 1519 && (e_state==NoButton)
1520 && ((e->key()==Key_Down) 1520 && ((e->key()==Key_Down)
1521 || (e->key()==Key_Up) 1521 || (e->key()==Key_Up)
1522 || (e->key()==Key_Next) 1522 || (e->key()==Key_Next)
1523 || (e->key()==Key_Prior) 1523 || (e->key()==Key_Prior)
1524 || (e->key()==Key_Home) 1524 || (e->key()==Key_Home)
1525 || (e->key()==Key_End))) 1525 || (e->key()==Key_End)))
1526 { 1526 {
1527 d->selectedBySimpleMove=true; 1527 d->selectedBySimpleMove=true;
1528 d->selectedUsingMouse=false; 1528 d->selectedUsingMouse=false;
1529 } 1529 }
1530 else if (selectedItems>1) 1530 else if (selectedItems>1)
1531 d->selectedBySimpleMove=false; 1531 d->selectedBySimpleMove=false;
1532 1532
1533 bool emitSelectionChanged(false); 1533 bool emitSelectionChanged(false);
1534 1534
1535 switch (e->key()) 1535 switch (e->key())
1536 { 1536 {
1537 case Key_Escape: 1537 case Key_Escape:
1538 selectAll(FALSE); 1538 selectAll(FALSE);
1539 emitSelectionChanged=TRUE; 1539 emitSelectionChanged=TRUE;
1540 break; 1540 break;
1541 1541
1542 case Key_Space: 1542 case Key_Space:
1543 //toggle selection of current item 1543 //toggle selection of current item
1544 if (d->selectedBySimpleMove) 1544 if (d->selectedBySimpleMove)
1545 d->selectedBySimpleMove=false; 1545 d->selectedBySimpleMove=false;
1546 item->setSelected(!item->isSelected()); 1546 item->setSelected(!item->isSelected());
1547 emitSelectionChanged=TRUE; 1547 emitSelectionChanged=TRUE;
1548 break; 1548 break;
1549 1549
1550 case Key_Insert: 1550 case Key_Insert:
1551 //toggle selection of current item and move to the next item 1551 //toggle selection of current item and move to the next item
1552 if (d->selectedBySimpleMove) 1552 if (d->selectedBySimpleMove)
1553 { 1553 {
1554 d->selectedBySimpleMove=false; 1554 d->selectedBySimpleMove=false;
1555 if (!item->isSelected()) item->setSelected(TRUE); 1555 if (!item->isSelected()) item->setSelected(TRUE);
1556 } 1556 }
1557 else 1557 else
1558 { 1558 {
1559 item->setSelected(!item->isSelected()); 1559 item->setSelected(!item->isSelected());
1560 }; 1560 };
1561 1561
1562 nextItem=item->itemBelow(); 1562 nextItem=item->itemBelow();
1563 1563
1564 if (nextItem!=0) 1564 if (nextItem!=0)
1565 { 1565 {
1566 repaintItem2=nextItem; 1566 repaintItem2=nextItem;
1567 visItem=nextItem; 1567 visItem=nextItem;
1568 setCurrentItem(nextItem); 1568 setCurrentItem(nextItem);
1569 }; 1569 };
1570 d->selectionDirection=1; 1570 d->selectionDirection=1;
1571 emitSelectionChanged=TRUE; 1571 emitSelectionChanged=TRUE;
1572 break; 1572 break;
1573 1573
1574 case Key_Down: 1574 case Key_Down:
1575 nextItem=item->itemBelow(); 1575 nextItem=item->itemBelow();
1576 //toggle selection of current item and move to the next item 1576 //toggle selection of current item and move to the next item
1577 if (shiftOrCtrl) 1577 if (shiftOrCtrl)
1578 { 1578 {
1579 d->selectionDirection=1; 1579 d->selectionDirection=1;
1580 if (d->selectedBySimpleMove) 1580 if (d->selectedBySimpleMove)
1581 d->selectedBySimpleMove=false; 1581 d->selectedBySimpleMove=false;
1582 else 1582 else
1583 { 1583 {
1584 if (oldSelectionDirection!=-1) 1584 if (oldSelectionDirection!=-1)
1585 { 1585 {
1586 item->setSelected(!item->isSelected()); 1586 item->setSelected(!item->isSelected());
1587 emitSelectionChanged=TRUE; 1587 emitSelectionChanged=TRUE;
1588 }; 1588 };
1589 }; 1589 };
1590 } 1590 }
1591 else if ((d->selectedBySimpleMove) && (nextItem!=0)) 1591 else if ((d->selectedBySimpleMove) && (nextItem!=0))
1592 { 1592 {
1593 item->setSelected(false); 1593 item->setSelected(false);
1594 emitSelectionChanged=TRUE; 1594 emitSelectionChanged=TRUE;
1595 }; 1595 };
1596 1596
1597 if (nextItem!=0) 1597 if (nextItem!=0)
1598 { 1598 {
1599 if (d->selectedBySimpleMove) 1599 if (d->selectedBySimpleMove)
1600 nextItem->setSelected(true); 1600 nextItem->setSelected(true);
1601 repaintItem2=nextItem; 1601 repaintItem2=nextItem;
1602 visItem=nextItem; 1602 visItem=nextItem;
1603 setCurrentItem(nextItem); 1603 setCurrentItem(nextItem);
1604 }; 1604 };
1605 break; 1605 break;
1606 1606
1607 case Key_Up: 1607 case Key_Up:
1608 nextItem=item->itemAbove(); 1608 nextItem=item->itemAbove();
1609 d->selectionDirection=-1; 1609 d->selectionDirection=-1;
1610 //move to the prev. item and toggle selection of this one 1610 //move to the prev. item and toggle selection of this one
1611 // => No, can't select the last item, with this. For symmetry, let's 1611 // => No, can't select the last item, with this. For symmetry, let's
1612 // toggle selection and THEN move up, just like we do in down (David) 1612 // toggle selection and THEN move up, just like we do in down (David)
1613 if (shiftOrCtrl) 1613 if (shiftOrCtrl)
1614 { 1614 {
1615 if (d->selectedBySimpleMove) 1615 if (d->selectedBySimpleMove)
1616 d->selectedBySimpleMove=false; 1616 d->selectedBySimpleMove=false;
1617 else 1617 else
1618 { 1618 {
1619 if (oldSelectionDirection!=1) 1619 if (oldSelectionDirection!=1)
1620 { 1620 {
1621 item->setSelected(!item->isSelected()); 1621 item->setSelected(!item->isSelected());
1622 emitSelectionChanged=TRUE; 1622 emitSelectionChanged=TRUE;
1623 }; 1623 };
1624 } 1624 }
1625 } 1625 }
1626 else if ((d->selectedBySimpleMove) && (nextItem!=0)) 1626 else if ((d->selectedBySimpleMove) && (nextItem!=0))
1627 { 1627 {
1628 item->setSelected(false); 1628 item->setSelected(false);
1629 emitSelectionChanged=TRUE; 1629 emitSelectionChanged=TRUE;
1630 }; 1630 };
1631 1631
1632 if (nextItem!=0) 1632 if (nextItem!=0)
1633 { 1633 {
1634 if (d->selectedBySimpleMove) 1634 if (d->selectedBySimpleMove)
1635 nextItem->setSelected(true); 1635 nextItem->setSelected(true);
1636 repaintItem2=nextItem; 1636 repaintItem2=nextItem;
1637 visItem=nextItem; 1637 visItem=nextItem;
1638 setCurrentItem(nextItem); 1638 setCurrentItem(nextItem);
1639 }; 1639 };
1640 break; 1640 break;
1641 1641
1642 case Key_End: 1642 case Key_End:
1643 //move to the last item and toggle selection of all items inbetween 1643 //move to the last item and toggle selection of all items inbetween
1644 nextItem=item; 1644 nextItem=item;
1645 if (d->selectedBySimpleMove) 1645 if (d->selectedBySimpleMove)
1646 item->setSelected(false); 1646 item->setSelected(false);
1647 if (shiftOrCtrl) 1647 if (shiftOrCtrl)
1648 d->selectedBySimpleMove=false; 1648 d->selectedBySimpleMove=false;
1649 1649
1650 while(nextItem!=0) 1650 while(nextItem!=0)
1651 { 1651 {
1652 if (shiftOrCtrl) 1652 if (shiftOrCtrl)
1653 nextItem->setSelected(!nextItem->isSelected()); 1653 nextItem->setSelected(!nextItem->isSelected());
1654 if (nextItem->itemBelow()==0) 1654 if (nextItem->itemBelow()==0)
1655 { 1655 {
1656 if (d->selectedBySimpleMove) 1656 if (d->selectedBySimpleMove)
1657 nextItem->setSelected(true); 1657 nextItem->setSelected(true);
1658 repaintItem2=nextItem; 1658 repaintItem2=nextItem;
1659 visItem=nextItem; 1659 visItem=nextItem;
1660 setCurrentItem(nextItem); 1660 setCurrentItem(nextItem);
1661 } 1661 }
1662 nextItem=nextItem->itemBelow(); 1662 nextItem=nextItem->itemBelow();
1663 } 1663 }
1664 emitSelectionChanged=TRUE; 1664 emitSelectionChanged=TRUE;
1665 break; 1665 break;
1666 1666
1667 case Key_Home: 1667 case Key_Home:
1668 // move to the first item and toggle selection of all items inbetween 1668 // move to the first item and toggle selection of all items inbetween
1669 nextItem = firstChild(); 1669 nextItem = firstChild();
1670 visItem = nextItem; 1670 visItem = nextItem;
1671 repaintItem2 = visItem; 1671 repaintItem2 = visItem;
1672 if (d->selectedBySimpleMove) 1672 if (d->selectedBySimpleMove)
1673 item->setSelected(false); 1673 item->setSelected(false);
1674 if (shiftOrCtrl) 1674 if (shiftOrCtrl)
1675 { 1675 {
1676 d->selectedBySimpleMove=false; 1676 d->selectedBySimpleMove=false;
1677 1677
1678 while ( nextItem != item ) 1678 while ( nextItem != item )
1679 { 1679 {
1680 nextItem->setSelected( !nextItem->isSelected() ); 1680 nextItem->setSelected( !nextItem->isSelected() );
1681 nextItem = nextItem->itemBelow(); 1681 nextItem = nextItem->itemBelow();
1682 } 1682 }
1683 item->setSelected( !item->isSelected() ); 1683 item->setSelected( !item->isSelected() );
1684 } 1684 }
1685 setCurrentItem( firstChild() ); 1685 setCurrentItem( firstChild() );
1686 emitSelectionChanged=TRUE; 1686 emitSelectionChanged=TRUE;
1687 break; 1687 break;
1688 1688
1689 case Key_Next: 1689 case Key_Next:
1690 items=visibleHeight()/item->height(); 1690 items=visibleHeight()/item->height();
1691 nextItem=item; 1691 nextItem=item;
1692 if (d->selectedBySimpleMove) 1692 if (d->selectedBySimpleMove)
1693 item->setSelected(false); 1693 item->setSelected(false);
1694 if (shiftOrCtrl) 1694 if (shiftOrCtrl)
1695 { 1695 {
1696 d->selectedBySimpleMove=false; 1696 d->selectedBySimpleMove=false;
1697 d->selectionDirection=1; 1697 d->selectionDirection=1;
1698 }; 1698 };
1699 1699
1700 for (int i=0; i<items; i++) 1700 for (int i=0; i<items; i++)
1701 { 1701 {
1702 if (shiftOrCtrl) 1702 if (shiftOrCtrl)
1703 nextItem->setSelected(!nextItem->isSelected()); 1703 nextItem->setSelected(!nextItem->isSelected());
1704 //the end 1704 //the end
1705 if ((i==items-1) || (nextItem->itemBelow()==0)) 1705 if ((i==items-1) || (nextItem->itemBelow()==0))
1706 1706
1707 { 1707 {
1708 if (shiftOrCtrl) 1708 if (shiftOrCtrl)
1709 nextItem->setSelected(!nextItem->isSelected()); 1709 nextItem->setSelected(!nextItem->isSelected());
1710 if (d->selectedBySimpleMove) 1710 if (d->selectedBySimpleMove)
1711 nextItem->setSelected(true); 1711 nextItem->setSelected(true);
1712 ensureItemVisible(nextItem); 1712 ensureItemVisible(nextItem);
1713 setCurrentItem(nextItem); 1713 setCurrentItem(nextItem);
1714 update(); 1714 update();
1715 if ((shiftOrCtrl) || (d->selectedBySimpleMove)) 1715 if ((shiftOrCtrl) || (d->selectedBySimpleMove))
1716 { 1716 {
1717 emit selectionChanged(); 1717 emit selectionChanged();
1718 } 1718 }
1719 return; 1719 return;
1720 } 1720 }
1721 nextItem=nextItem->itemBelow(); 1721 nextItem=nextItem->itemBelow();
1722 } 1722 }
1723 break; 1723 break;
1724 1724
1725 case Key_Prior: 1725 case Key_Prior:
1726 items=visibleHeight()/item->height(); 1726 items=visibleHeight()/item->height();
1727 nextItem=item; 1727 nextItem=item;
1728 if (d->selectedBySimpleMove) 1728 if (d->selectedBySimpleMove)
1729 item->setSelected(false); 1729 item->setSelected(false);
1730 if (shiftOrCtrl) 1730 if (shiftOrCtrl)
1731 { 1731 {
1732 d->selectionDirection=-1; 1732 d->selectionDirection=-1;
1733 d->selectedBySimpleMove=false; 1733 d->selectedBySimpleMove=false;
1734 }; 1734 };
1735 1735
1736 for (int i=0; i<items; i++) 1736 for (int i=0; i<items; i++)
1737 { 1737 {
1738 if ((nextItem!=item) &&(shiftOrCtrl)) 1738 if ((nextItem!=item) &&(shiftOrCtrl))
1739 nextItem->setSelected(!nextItem->isSelected()); 1739 nextItem->setSelected(!nextItem->isSelected());
1740 //the end 1740 //the end
1741 if ((i==items-1) || (nextItem->itemAbove()==0)) 1741 if ((i==items-1) || (nextItem->itemAbove()==0))
1742 1742
1743 { 1743 {
1744 if (d->selectedBySimpleMove) 1744 if (d->selectedBySimpleMove)
1745 nextItem->setSelected(true); 1745 nextItem->setSelected(true);
1746 ensureItemVisible(nextItem); 1746 ensureItemVisible(nextItem);
1747 setCurrentItem(nextItem); 1747 setCurrentItem(nextItem);
1748 update(); 1748 update();
1749 if ((shiftOrCtrl) || (d->selectedBySimpleMove)) 1749 if ((shiftOrCtrl) || (d->selectedBySimpleMove))
1750 { 1750 {
1751 emit selectionChanged(); 1751 emit selectionChanged();
1752 } 1752 }
1753 return; 1753 return;
1754 } 1754 }
1755 nextItem=nextItem->itemAbove(); 1755 nextItem=nextItem->itemAbove();
1756 } 1756 }
1757 break; 1757 break;
1758 1758
1759 case Key_Minus: 1759 case Key_Minus:
1760 if ( item->isOpen() ) 1760 if ( item->isOpen() )
1761 setOpen( item, FALSE ); 1761 setOpen( item, FALSE );
1762 break; 1762 break;
1763 case Key_Plus: 1763 case Key_Plus:
1764 if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) 1764 if ( !item->isOpen() && (item->isExpandable() || item->childCount()) )
1765 setOpen( item, TRUE ); 1765 setOpen( item, TRUE );
1766 break; 1766 break;
1767 default: 1767 default:
1768 bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) 1768 bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control)
1769 && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); 1769 && (e->key()!=Key_Meta) && (e->key()!=Key_Alt));
1770 1770
1771 bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); 1771 bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected());
1772 if (realKey && selectCurrentItem) 1772 if (realKey && selectCurrentItem)
1773 item->setSelected(false); 1773 item->setSelected(false);
1774 //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) 1774 //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX)
1775 QListView::SelectionMode oldSelectionMode = selectionMode(); 1775 QListView::SelectionMode oldSelectionMode = selectionMode();
1776 setSelectionMode (QListView::Multi); 1776 setSelectionMode (QListView::Multi);
1777 QListView::keyPressEvent (e); 1777 QListView::keyPressEvent (e);
1778 setSelectionMode (oldSelectionMode); 1778 setSelectionMode (oldSelectionMode);
1779 if (realKey && selectCurrentItem) 1779 if (realKey && selectCurrentItem)
1780 { 1780 {
1781 currentItem()->setSelected(true); 1781 currentItem()->setSelected(true);
1782 emitSelectionChanged=TRUE; 1782 emitSelectionChanged=TRUE;
1783 } 1783 }
1784 repaintItem2=currentItem(); 1784 repaintItem2=currentItem();
1785 if (realKey) 1785 if (realKey)
1786 visItem=currentItem(); 1786 visItem=currentItem();
1787 break; 1787 break;
1788 } 1788 }
1789 1789
1790 if (visItem) 1790 if (visItem)
1791 ensureItemVisible(visItem); 1791 ensureItemVisible(visItem);
1792 1792
1793 QRect ir; 1793 QRect ir;
1794 if (repaintItem1) 1794 if (repaintItem1)
1795 ir = ir.unite( itemRect(repaintItem1) ); 1795 ir = ir.unite( itemRect(repaintItem1) );
1796 if (repaintItem2) 1796 if (repaintItem2)
1797 ir = ir.unite( itemRect(repaintItem2) ); 1797 ir = ir.unite( itemRect(repaintItem2) );
1798 1798
1799 if ( !ir.isEmpty() ) 1799 if ( !ir.isEmpty() )
1800 { // rectangle to be repainted 1800 { // rectangle to be repainted
1801 if ( ir.x() < 0 ) 1801 if ( ir.x() < 0 )
1802 ir.moveBy( -ir.x(), 0 ); 1802 ir.moveBy( -ir.x(), 0 );
1803 viewport()->repaint( ir, FALSE ); 1803 viewport()->repaint( ir, FALSE );
1804 } 1804 }
1805 /*if (repaintItem1) 1805 /*if (repaintItem1)
1806 repaintItem1->repaint(); 1806 repaintItem1->repaint();
1807 if (repaintItem2) 1807 if (repaintItem2)
1808 repaintItem2->repaint();*/ 1808 repaintItem2->repaint();*/
1809 update(); 1809 update();
1810 if (emitSelectionChanged) 1810 if (emitSelectionChanged)
1811 emit selectionChanged(); 1811 emit selectionChanged();
1812} 1812}
1813 1813
1814void KListView::setSelectionModeExt (SelectionModeExt mode) 1814void KListView::setSelectionModeExt (SelectionModeExt mode)
1815{ 1815{
1816 d->selectionMode = mode; 1816 d->selectionMode = mode;
1817 1817
1818 switch (mode) 1818 switch (mode)
1819 { 1819 {
1820 case Single: 1820 case Single:
1821 case Multi: 1821 case Multi:
1822 case Extended: 1822 case Extended:
1823 case NoSelection: 1823 case NoSelection:
1824 setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); 1824 setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode)));
1825 break; 1825 break;
1826 1826
1827 case FileManager: 1827 case FileManager:
1828 setSelectionMode (QListView::Extended); 1828 setSelectionMode (QListView::Extended);
1829 break; 1829 break;
1830 1830
1831 default: 1831 default:
1832 kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; 1832 kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl;
1833 break; 1833 break;
1834 } 1834 }
1835} 1835}
1836 1836
1837KListView::SelectionModeExt KListView::selectionModeExt () const 1837KListView::SelectionModeExt KListView::selectionModeExt () const
1838{ 1838{
1839 return d->selectionMode; 1839 return d->selectionMode;
1840} 1840}
1841 1841
1842int KListView::itemIndex( const QListViewItem *item ) const 1842int KListView::itemIndex( const QListViewItem *item ) const
1843{ 1843{
1844 if ( !item ) 1844 if ( !item )
1845 return -1; 1845 return -1;
1846 1846
1847 if ( item == firstChild() ) 1847 if ( item == firstChild() )
1848 return 0; 1848 return 0;
1849 else { 1849 else {
1850 QListViewItemIterator it(firstChild()); 1850 QListViewItemIterator it(firstChild());
1851 uint j = 0; 1851 uint j = 0;
1852 for (; it.current() && it.current() != item; ++it, ++j ); 1852 for (; it.current() && it.current() != item; ++it, ++j );
1853 1853
1854 if( !it.current() ) 1854 if( !it.current() )
1855 return -1; 1855 return -1;
1856 1856
1857 return j; 1857 return j;
1858 } 1858 }
1859} 1859}
1860 1860
1861QListViewItem* KListView::itemAtIndex(int index) 1861QListViewItem* KListView::itemAtIndex(int index)
1862{ 1862{
1863 if (index<0) 1863 if (index<0)
1864 return 0; 1864 return 0;
1865 1865
1866 int j(0); 1866 int j(0);
1867 for (QListViewItemIterator it=firstChild(); it.current(); it++) 1867 for (QListViewItemIterator it=firstChild(); it.current(); it++)
1868 { 1868 {
1869 if (j==index) 1869 if (j==index)
1870 return it.current(); 1870 return it.current();
1871 j++; 1871 j++;
1872 }; 1872 };
1873 return 0; 1873 return 0;
1874} 1874}
1875 1875
1876 1876
1877void KListView::emitContextMenu (KListView*, QListViewItem* i) 1877void KListView::emitContextMenu (KListView*, QListViewItem* i)
1878{ 1878{
1879 QPoint p; 1879 QPoint p;
1880 qDebug("KListView::emitContextMenu "); 1880 // qDebug("KListView::emitContextMenu ");
1881 1881
1882 if (i) 1882 if (i)
1883 p = viewport()->mapToGlobal(itemRect(i).center()); 1883 p = viewport()->mapToGlobal(itemRect(i).center());
1884 else 1884 else
1885 p = mapToGlobal(rect().center()); 1885 p = mapToGlobal(rect().center());
1886 1886
1887 emit contextMenu (this, i, p); 1887 emit contextMenu (this, i, p);
1888} 1888}
1889 1889
1890void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) 1890void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col)
1891{ 1891{
1892 qDebug("KListView::emitContextMenu col"); 1892 qDebug("KListView::emitContextMenu col");
1893 emit contextRequest( i, p, col ); 1893 emit contextRequest( i, p, col );
1894 emit contextMenu (this, i, p); 1894 emit contextMenu (this, i, p);
1895} 1895}
1896 1896
1897void KListView::setAcceptDrops (bool val) 1897void KListView::setAcceptDrops (bool val)
1898{ 1898{
1899 QListView::setAcceptDrops (val); 1899 QListView::setAcceptDrops (val);
1900 viewport()->setAcceptDrops (val); 1900 viewport()->setAcceptDrops (val);
1901} 1901}
1902 1902
1903int KListView::dropVisualizerWidth () const 1903int KListView::dropVisualizerWidth () const
1904{ 1904{
1905 return d->mDropVisualizerWidth; 1905 return d->mDropVisualizerWidth;
1906} 1906}
1907 1907
1908 1908
1909void KListView::viewportPaintEvent(QPaintEvent *e) 1909void KListView::viewportPaintEvent(QPaintEvent *e)
1910{ 1910{
1911 QListView::viewportPaintEvent(e); 1911 QListView::viewportPaintEvent(e);
1912 1912
1913 if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) 1913 if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer))
1914 { 1914 {
1915 QPainter painter(viewport()); 1915 QPainter painter(viewport());
1916 1916
1917 // This is where we actually draw the drop-visualizer 1917 // This is where we actually draw the drop-visualizer
1918 painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); 1918 painter.fillRect(d->mOldDropVisualizer, Dense4Pattern);
1919 } 1919 }
1920 if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) 1920 if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter))
1921 { 1921 {
1922 QPainter painter(viewport()); 1922 QPainter painter(viewport());
1923 1923
1924qDebug("KListView::viewportPaintEvent has to be verified"); 1924qDebug("KListView::viewportPaintEvent has to be verified");
1925 1925
1926 // This is where we actually draw the drop-highlighter 1926 // This is where we actually draw the drop-highlighter
1927//US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), 1927//US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(),
1928//US QStyle::Style_FocusAtBorder); 1928//US QStyle::Style_FocusAtBorder);
1929 1929
1930//LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); 1930//LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true);
1931 1931
1932 1932
1933 } 1933 }
1934} 1934}
1935 1935
1936void KListView::setFullWidth() 1936void KListView::setFullWidth()
1937{ 1937{
1938 setFullWidth(true); 1938 setFullWidth(true);
1939} 1939}
1940 1940
1941void KListView::setFullWidth(bool fullWidth) 1941void KListView::setFullWidth(bool fullWidth)
1942{ 1942{
1943 d->fullWidth = fullWidth; 1943 d->fullWidth = fullWidth;
1944//US header()->setStretchEnabled(fullWidth, columns()-1); 1944//US header()->setStretchEnabled(fullWidth, columns()-1);
1945} 1945}
1946 1946
1947bool KListView::fullWidth() const 1947bool KListView::fullWidth() const
1948{ 1948{
1949 return d->fullWidth; 1949 return d->fullWidth;
1950} 1950}
1951 1951
1952int KListView::addColumn(const QString& label, int width) 1952int KListView::addColumn(const QString& label, int width)
1953{ 1953{
1954 int result = QListView::addColumn(label, width); 1954 int result = QListView::addColumn(label, width);
1955 if (d->fullWidth) { 1955 if (d->fullWidth) {
1956//US header()->setStretchEnabled(false, columns()-2); 1956//US header()->setStretchEnabled(false, columns()-2);
1957//US header()->setStretchEnabled(true, columns()-1); 1957//US header()->setStretchEnabled(true, columns()-1);
1958 } 1958 }
1959 return result; 1959 return result;
1960} 1960}
1961 1961
1962int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) 1962int KListView::addColumn(const QIconSet& iconset, const QString& label, int width)
1963{ 1963{
1964 int result = QListView::addColumn(iconset, label, width); 1964 int result = QListView::addColumn(iconset, label, width);
1965 if (d->fullWidth) { 1965 if (d->fullWidth) {
1966//US header()->setStretchEnabled(false, columns()-2); 1966//US header()->setStretchEnabled(false, columns()-2);
1967//US header()->setStretchEnabled(true, columns()-1); 1967//US header()->setStretchEnabled(true, columns()-1);
1968 } 1968 }
1969 return result; 1969 return result;
1970} 1970}
1971 1971
1972void KListView::removeColumn(int index) 1972void KListView::removeColumn(int index)
1973{ 1973{
1974 QListView::removeColumn(index); 1974 QListView::removeColumn(index);
1975//US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); 1975//US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1);
1976} 1976}
1977 1977
1978void KListView::viewportResizeEvent(QResizeEvent* e) 1978void KListView::viewportResizeEvent(QResizeEvent* e)
1979{ 1979{
1980 QListView::viewportResizeEvent(e); 1980 QListView::viewportResizeEvent(e);
1981} 1981}
1982 1982
1983const QColor &KListView::alternateBackground() const 1983const QColor &KListView::alternateBackground() const
1984{ 1984{
1985 return d->alternateBackground; 1985 return d->alternateBackground;
1986} 1986}
1987 1987
1988void KListView::setAlternateBackground(const QColor &c) 1988void KListView::setAlternateBackground(const QColor &c)
1989{ 1989{
1990 d->alternateBackground = c; 1990 d->alternateBackground = c;
1991 repaint(); 1991 repaint();
1992} 1992}
1993 1993
1994void KListView::saveLayout(KConfig *config, const QString &group) const 1994void KListView::saveLayout(KConfig *config, const QString &group) const
1995{ 1995{
1996 KConfigGroupSaver saver(config, group); 1996 KConfigGroupSaver saver(config, group);
1997 QStringList widths, order; 1997 QStringList widths, order;
1998 for (int i = 0; i < columns(); ++i) 1998 for (int i = 0; i < columns(); ++i)
1999 { 1999 {
2000 widths << QString::number(columnWidth(i)); 2000 widths << QString::number(columnWidth(i));
2001 order << QString::number(header()->mapToIndex(i)); 2001 order << QString::number(header()->mapToIndex(i));
2002 } 2002 }
2003 config->writeEntry("ColumnWidths", widths); 2003 config->writeEntry("ColumnWidths", widths);
2004 config->writeEntry("ColumnOrder", order); 2004 config->writeEntry("ColumnOrder", order);
2005 config->writeEntry("SortColumn", d->sortColumn); 2005 config->writeEntry("SortColumn", d->sortColumn);
2006 config->writeEntry("SortAscending", d->sortAscending); 2006 config->writeEntry("SortAscending", d->sortAscending);
2007} 2007}
2008 2008
2009void KListView::restoreLayout(KConfig *config, const QString &group) 2009void KListView::restoreLayout(KConfig *config, const QString &group)
2010{ 2010{
2011 KConfigGroupSaver saver(config, group); 2011 KConfigGroupSaver saver(config, group);
2012 QStringList cols = config->readListEntry("ColumnWidths"); 2012 QStringList cols = config->readListEntry("ColumnWidths");
2013 int i = 0; 2013 int i = 0;
2014 for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) 2014 for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it)
2015 setColumnWidth(i++, (*it).toInt()); 2015 setColumnWidth(i++, (*it).toInt());
2016 2016
2017 cols = config->readListEntry("ColumnOrder"); 2017 cols = config->readListEntry("ColumnOrder");
2018 i = 0; 2018 i = 0;
2019 for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) 2019 for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it)
2020 header()->moveSection(i++, (*it).toInt()); 2020 header()->moveSection(i++, (*it).toInt());
2021 2021
2022/*US I changed the following code, because hasKey is not available. 2022/*US I changed the following code, because hasKey is not available.
2023!!! check if my version is correct 2023!!! check if my version is correct
2024 if (config->hasKey("SortColumn")) 2024 if (config->hasKey("SortColumn"))
2025 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); 2025 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true));
2026*/ 2026*/
2027 QStringList langLst = config->readListEntry( "SortColumn" ); 2027 QStringList langLst = config->readListEntry( "SortColumn" );
2028 if (!langLst.isEmpty()) 2028 if (!langLst.isEmpty())
2029 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); 2029 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true));
2030} 2030}
2031 2031
2032void KListView::setSorting(int column, bool ascending) 2032void KListView::setSorting(int column, bool ascending)
2033{ 2033{
2034 d->sortColumn = column; 2034 d->sortColumn = column;
2035 d->sortAscending = ascending; 2035 d->sortAscending = ascending;
2036 QListView::setSorting(column, ascending); 2036 QListView::setSorting(column, ascending);
2037} 2037}
2038 2038
2039int KListView::columnSorted(void) const 2039int KListView::columnSorted(void) const
2040{ 2040{
2041 return d->sortColumn; 2041 return d->sortColumn;
2042} 2042}
2043 2043
2044bool KListView::ascendingSort(void) const 2044bool KListView::ascendingSort(void) const
2045{ 2045{
2046 return d->sortAscending; 2046 return d->sortAscending;
2047} 2047}
2048 2048
2049KListViewItem::KListViewItem(QListView *parent) 2049KListViewItem::KListViewItem(QListView *parent)
2050 : QListViewItem(parent) 2050 : QListViewItem(parent)
2051{ 2051{
2052 init(); 2052 init();
2053} 2053}
2054 2054
2055KListViewItem::KListViewItem(QListViewItem *parent) 2055KListViewItem::KListViewItem(QListViewItem *parent)
2056 : QListViewItem(parent) 2056 : QListViewItem(parent)
2057{ 2057{
2058 init(); 2058 init();
2059} 2059}
2060 2060
2061KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) 2061KListViewItem::KListViewItem(QListView *parent, QListViewItem *after)
2062 : QListViewItem(parent, after) 2062 : QListViewItem(parent, after)
2063{ 2063{
2064 init(); 2064 init();
2065} 2065}
2066 2066
2067KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) 2067KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after)
2068 : QListViewItem(parent, after) 2068 : QListViewItem(parent, after)
2069{ 2069{
2070 init(); 2070 init();
2071} 2071}
2072 2072
2073KListViewItem::KListViewItem(QListView *parent, 2073KListViewItem::KListViewItem(QListView *parent,
2074 QString label1, QString label2, QString label3, QString label4, 2074 QString label1, QString label2, QString label3, QString label4,
2075 QString label5, QString label6, QString label7, QString label8) 2075 QString label5, QString label6, QString label7, QString label8)
2076 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 2076 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
2077{ 2077{
2078 init(); 2078 init();
2079} 2079}
2080 2080
2081KListViewItem::KListViewItem(QListViewItem *parent, 2081KListViewItem::KListViewItem(QListViewItem *parent,
2082 QString label1, QString label2, QString label3, QString label4, 2082 QString label1, QString label2, QString label3, QString label4,
2083 QString label5, QString label6, QString label7, QString label8) 2083 QString label5, QString label6, QString label7, QString label8)
2084 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 2084 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
2085{ 2085{
2086 init(); 2086 init();
2087} 2087}
2088 2088
2089KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, 2089KListViewItem::KListViewItem(QListView *parent, QListViewItem *after,
2090 QString label1, QString label2, QString label3, QString label4, 2090 QString label1, QString label2, QString label3, QString label4,
2091 QString label5, QString label6, QString label7, QString label8) 2091 QString label5, QString label6, QString label7, QString label8)
2092 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 2092 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
2093{ 2093{
2094 init(); 2094 init();
2095} 2095}
2096 2096
2097KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, 2097KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after,
2098 QString label1, QString label2, QString label3, QString label4, 2098 QString label1, QString label2, QString label3, QString label4,
2099 QString label5, QString label6, QString label7, QString label8) 2099 QString label5, QString label6, QString label7, QString label8)
2100 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 2100 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
2101{ 2101{
2102 init(); 2102 init();
2103} 2103}
2104 2104
2105KListViewItem::~KListViewItem() 2105KListViewItem::~KListViewItem()
2106{ 2106{
2107} 2107}
2108 2108
2109void KListViewItem::init() 2109void KListViewItem::init()
2110{ 2110{
2111 m_known = false; 2111 m_known = false;
2112} 2112}
2113 2113
2114const QColor &KListViewItem::backgroundColor() 2114const QColor &KListViewItem::backgroundColor()
2115{ 2115{
2116 if (isAlternate()) 2116 if (isAlternate())
2117 return static_cast< KListView* >(listView())->alternateBackground(); 2117 return static_cast< KListView* >(listView())->alternateBackground();
2118 return listView()->viewport()->colorGroup().base(); 2118 return listView()->viewport()->colorGroup().base();
2119} 2119}
2120 2120
2121bool KListViewItem::isAlternate() 2121bool KListViewItem::isAlternate()
2122{ 2122{
2123 KListView *lv = static_cast<KListView *>(listView()); 2123 KListView *lv = static_cast<KListView *>(listView());
2124 if (lv && lv->alternateBackground().isValid()) 2124 if (lv && lv->alternateBackground().isValid())
2125 { 2125 {
2126 KListViewItem *above = 0; 2126 KListViewItem *above = 0;
2127//US above = dynamic_cast<KListViewItem *>(itemAbove()); 2127//US above = dynamic_cast<KListViewItem *>(itemAbove());
2128 above = (KListViewItem *)(itemAbove()); 2128 above = (KListViewItem *)(itemAbove());
2129 m_known = above ? above->m_known : true; 2129 m_known = above ? above->m_known : true;
2130 if (m_known) 2130 if (m_known)
2131 { 2131 {
2132 m_odd = above ? !above->m_odd : false; 2132 m_odd = above ? !above->m_odd : false;
2133 } 2133 }
2134 else 2134 else
2135 { 2135 {
2136 KListViewItem *item; 2136 KListViewItem *item;
2137 bool previous = true; 2137 bool previous = true;
2138 if (parent()) 2138 if (parent())
2139 { 2139 {
2140//US item = dynamic_cast<KListViewItem *>(parent()); 2140//US item = dynamic_cast<KListViewItem *>(parent());
2141 item = (KListViewItem *)(parent()); 2141 item = (KListViewItem *)(parent());
2142 if (item) 2142 if (item)
2143 previous = item->m_odd; 2143 previous = item->m_odd;
2144//US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); 2144//US item = dynamic_cast<KListViewItem *>(parent()->firstChild());
2145 item = (KListViewItem *)(parent()->firstChild()); 2145 item = (KListViewItem *)(parent()->firstChild());
2146 } 2146 }
2147 else 2147 else
2148 { 2148 {
2149//US item = dynamic_cast<KListViewItem *>(lv->firstChild()); 2149//US item = dynamic_cast<KListViewItem *>(lv->firstChild());
2150 item = (KListViewItem *)(lv->firstChild()); 2150 item = (KListViewItem *)(lv->firstChild());
2151 } 2151 }
2152 2152
2153 while(item) 2153 while(item)
2154 { 2154 {
2155 item->m_odd = previous = !previous; 2155 item->m_odd = previous = !previous;
2156 item->m_known = true; 2156 item->m_known = true;
2157//US item = dynamic_cast<KListViewItem *>(item->nextSibling()); 2157//US item = dynamic_cast<KListViewItem *>(item->nextSibling());
2158 item = (KListViewItem *)(item->nextSibling()); 2158 item = (KListViewItem *)(item->nextSibling());
2159 } 2159 }
2160 } 2160 }
2161 return m_odd; 2161 return m_odd;
2162 } 2162 }
2163 return false; 2163 return false;
2164} 2164}
2165 2165
2166void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 2166void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
2167{ 2167{
2168 QColorGroup _cg = cg; 2168 QColorGroup _cg = cg;
2169 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 2169 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
2170 if (pm && !pm->isNull()) 2170 if (pm && !pm->isNull())
2171 { 2171 {
2172 _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); 2172 _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm));
2173 QPoint o = p->brushOrigin(); 2173 QPoint o = p->brushOrigin();
2174 p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); 2174 p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() );
2175 } 2175 }
2176 else if (isAlternate()) { 2176 else if (isAlternate()) {
2177//US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) 2177//US if (listView()->viewport()->backgroundMode()==Qt::FixedColor)
2178 if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) 2178 if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground)
2179 _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); 2179 _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground());
2180 else 2180 else
2181 _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); 2181 _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground());
2182 } 2182 }
2183 QListViewItem::paintCell(p, _cg, column, width, alignment); 2183 QListViewItem::paintCell(p, _cg, column, width, alignment);
2184} 2184}
2185 2185
2186void KListView::virtual_hook( int, void* ) 2186void KListView::virtual_hook( int, void* )
2187{ /*BASE::virtual_hook( id, data );*/ } 2187{ /*BASE::virtual_hook( id, data );*/ }
2188 2188
2189//US #include "klistview.moc" 2189//US #include "klistview.moc"
2190//US #include "klistviewlineedit.moc" 2190//US #include "klistviewlineedit.moc"
2191 2191
2192// vim: ts=2 sw=2 et 2192// vim: ts=2 sw=2 et
diff --git a/pwmanager/pwmanager/globalstuff.h b/pwmanager/pwmanager/globalstuff.h
index 4f70f68..090fcda 100644
--- a/pwmanager/pwmanager/globalstuff.h
+++ b/pwmanager/pwmanager/globalstuff.h
@@ -1,134 +1,134 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef __GLOBALSTUFF_H 20#ifndef __GLOBALSTUFF_H
21#define __GLOBALSTUFF_H 21#define __GLOBALSTUFF_H
22 22
23#ifndef PWM_EMBEDDED 23#ifndef PWM_EMBEDDED
24#include "config.h" 24#include "config.h"
25#endif 25#endif
26 26
27#include "compiler.h" 27#include "compiler.h"
28 28
29 //US BUG: the following code caused compile errors with certain gcccompilers (2.95). 29 //US BUG: the following code caused compile errors with certain gcccompilers (2.95).
30 // Because of that I replaced it with a Qt version, which should do the same. 30 // Because of that I replaced it with a Qt version, which should do the same.
31#include <string> 31#include <string>
32 32
33#ifndef PWM_EMBEDDED 33#ifndef PWM_EMBEDDED
34#include <sstream> 34#include <sstream>
35#else 35#else
36#include <qstring.h> 36#include <qstring.h>
37#include <qtextstream.h> 37#include <qtextstream.h>
38#endif 38#endif
39 39
40#ifndef CONFIG_KEYCARD 40#ifndef CONFIG_KEYCARD
41class QWidget; 41class QWidget;
42void no_keycard_support_msg_box(QWidget *parentWidget); 42void no_keycard_support_msg_box(QWidget *parentWidget);
43#endif // CONFIG_KEYCARD 43#endif // CONFIG_KEYCARD
44 44
45#ifdef PROG_NAME 45#ifdef PROG_NAME
46# undef PROG_NAME 46# undef PROG_NAME
47#endif 47#endif
48 #define PROG_NAME"PwManager-MicroKDE" 48 #define PROG_NAME"PwM/Pi"
49 49
50#ifdef PACKAGE_NAME 50#ifdef PACKAGE_NAME
51# undef PACKAGE_NAME 51# undef PACKAGE_NAME
52#endif 52#endif
53 #define PACKAGE_NAME"pwmanager-microkde" 53 #define PACKAGE_NAME"pwm-pi"
54 54
55#ifdef PACKAGE_VER 55#ifdef PACKAGE_VER
56# undef PACKAGE_VER 56# undef PACKAGE_VER
57#endif 57#endif
58 #define PACKAGE_VER"1.0.1" 58 #define PACKAGE_VER"1.0.1"
59 59
60#ifdef CONFIG_DEBUG 60#ifdef CONFIG_DEBUG
61# define PWM_DEBUG 61# define PWM_DEBUG
62#else 62#else
63# undef PWM_DEBUG 63# undef PWM_DEBUG
64#endif 64#endif
65 65
66#ifdef QT_MAKE_VERSION 66#ifdef QT_MAKE_VERSION
67# undef QT_MAKE_VERSION 67# undef QT_MAKE_VERSION
68#endif 68#endif
69 #define QT_MAKE_VERSION(a,b,c)(((a) << 16) | ((b) << 8) | (c)) 69 #define QT_MAKE_VERSION(a,b,c)(((a) << 16) | ((b) << 8) | (c))
70 70
71/** remove "unused parameter" warnings */ 71/** remove "unused parameter" warnings */
72#ifdef PARAM_UNUSED 72#ifdef PARAM_UNUSED
73# undef PARAM_UNUSED 73# undef PARAM_UNUSED
74#endif 74#endif
75 #define PARAM_UNUSED(x)(void)x 75 #define PARAM_UNUSED(x)(void)x
76 76
77/** return the number of elements in an array */ 77/** return the number of elements in an array */
78#ifdef array_size 78#ifdef array_size
79# undef array_size 79# undef array_size
80#endif 80#endif
81 #define array_size(x)(sizeof(x) / sizeof((x)[0])) 81 #define array_size(x)(sizeof(x) / sizeof((x)[0]))
82 82
83//US BUG: the following code caused compile errors with certain gcccompilers (2.95). 83//US BUG: the following code caused compile errors with certain gcccompilers (2.95).
84// Because of that I replaced it with a Qt version, which should do the same. 84// Because of that I replaced it with a Qt version, which should do the same.
85#ifndef PWM_EMBEDDED 85#ifndef PWM_EMBEDDED
86/** convert something to string using ostringstream */ 86/** convert something to string using ostringstream */
87template <class T> inline 87template <class T> inline
88std::string tostr(const T &t) 88std::string tostr(const T &t)
89{ 89{
90 std::ostringstream s; 90 std::ostringstream s;
91 s << t; 91 s << t;
92 return s.str(); 92 return s.str();
93} 93}
94#else 94#else
95/** convert something to string using ostringstream */ 95/** convert something to string using ostringstream */
96template <class T> inline 96template <class T> inline
97std::string tostr(const T &t) 97std::string tostr(const T &t)
98{ 98{
99 QString result; 99 QString result;
100 QTextOStream(&result) << t; 100 QTextOStream(&result) << t;
101 return result.latin1(); 101 return result.latin1();
102} 102}
103#endif 103#endif
104 104
105/** delete the memory and NULL the pointer */ 105/** delete the memory and NULL the pointer */
106template<class T> inline 106template<class T> inline
107void delete_and_null(T *&p) 107void delete_and_null(T *&p)
108{ 108{
109 delete p; 109 delete p;
110 p = 0; 110 p = 0;
111} 111}
112/** delete the memory if the pointer isn't a NULL pointer */ 112/** delete the memory if the pointer isn't a NULL pointer */
113template<class T> inline 113template<class T> inline
114void delete_ifnot_null(T *&p) 114void delete_ifnot_null(T *&p)
115{ 115{
116 if (p) 116 if (p)
117 delete_and_null(p); 117 delete_and_null(p);
118} 118}
119 119
120template<class T> inline 120template<class T> inline
121void delete_and_null_array(T *&p) 121void delete_and_null_array(T *&p)
122{ 122{
123 delete [] p; 123 delete [] p;
124 p = 0; 124 p = 0;
125} 125}
126 126
127template<class T> inline 127template<class T> inline
128void delete_ifnot_null_array(T *&p) 128void delete_ifnot_null_array(T *&p)
129{ 129{
130 if (p) 130 if (p)
131 delete_and_null_array(p); 131 delete_and_null_array(p);
132} 132}
133 133
134#endif // GLOBALSTUFF_H 134#endif // GLOBALSTUFF_H
diff --git a/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp b/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp
index 720dfcc..26b9708 100644
--- a/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp
+++ b/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp
@@ -1,350 +1,351 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
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 <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qspinbox.h> 32#include <qspinbox.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qvbox.h> 35#include <qvbox.h>
36 36
37#include <kconfig.h> 37#include <kconfig.h>
38#include <kdebug.h> 38#include <kdebug.h>
39#include <kdialog.h> 39#include <kdialog.h>
40#include <klistview.h> 40#include <klistview.h>
41#include <klocale.h> 41#include <klocale.h>
42#include <kglobal.h> 42#include <kglobal.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44#include <kstandarddirs.h> 44#include <kstandarddirs.h>
45#include <kio/kfile/kurlrequester.h> 45#include <kio/kfile/kurlrequester.h>
46 46
47#include "pwmprefs.h" 47#include "pwmprefs.h"
48 48
49#include "pwmconfigwidget.h" 49#include "pwmconfigwidget.h"
50#include "pwmexception.h" 50#include "pwmexception.h"
51 51
52PWMConfigWidget::PWMConfigWidget(PWMPrefs *prefs, QWidget *parent, const char *name ) 52PWMConfigWidget::PWMConfigWidget(PWMPrefs *prefs, QWidget *parent, const char *name )
53 : KPrefsWidget(prefs, parent, name ) 53 : KPrefsWidget(prefs, parent, name )
54{ 54{
55 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 55 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
56 KDialog::spacingHint() ); 56 KDialog::spacingHint() );
57 57
58 QTabWidget *tabWidget = new QTabWidget( this ); 58 QTabWidget *tabWidget = new QTabWidget( this );
59 topLayout->addWidget( tabWidget ); 59 topLayout->addWidget( tabWidget );
60 60
61 // windowsStyle page 61 // windowsStyle page
62 ////////////////////////////////////////////////////// 62 //////////////////////////////////////////////////////
63 QWidget *windowStylePage = new QWidget( this ); 63 QWidget *windowStylePage = new QWidget( this );
64 QGridLayout *windowStyleLayout = new QGridLayout( windowStylePage, 3, 3); 64 QGridLayout *windowStyleLayout = new QGridLayout( windowStylePage, 3, 3);
65 65
66 int i = 0; 66 int i = 0;
67 KPrefsWidRadios * windowStyle = addWidRadios(i18n("Window-style:") ,&(prefs->mMainViewStyle), windowStylePage); 67 KPrefsWidRadios * windowStyle = addWidRadios(i18n("Window-style:") ,&(prefs->mMainViewStyle), windowStylePage);
68 windowStyle->addRadio(i18n("Category on top")); 68 windowStyle->addRadio(i18n("Category on top"));
69 windowStyle->addRadio(i18n("Category-list left/top")); 69 windowStyle->addRadio(i18n("Category-list left/top"));
70 windowStyleLayout->addMultiCellWidget( (QWidget*)windowStyle->groupBox(),i,i,0,2); 70 windowStyleLayout->addMultiCellWidget( (QWidget*)windowStyle->groupBox(),i,i,0,2);
71 ++i; 71 ++i;
72 72
73 QLabel* lab = new QLabel(i18n("<b>Font for Password entries:</b>"), windowStylePage); 73 QLabel* lab = new QLabel(i18n("<b>Font for Password entries:</b>"), windowStylePage);
74 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2); 74 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2);
75 75
76 76
77 ++i; 77 ++i;
78 78
79 KPrefsWidFont *selEntrFont = 79 KPrefsWidFont *selEntrFont =
80 addWidFont(i18n("Password"),i18n("Font:"), 80 addWidFont(i18n("Password"),i18n("Font:"),
81 &(prefs->mEntryFont),windowStylePage); 81 &(prefs->mEntryFont),windowStylePage);
82 windowStyleLayout->addWidget(selEntrFont->label(),i,0); 82 windowStyleLayout->addWidget(selEntrFont->label(),i,0);
83 windowStyleLayout->addWidget(selEntrFont->preview(),i,1); 83 windowStyleLayout->addWidget(selEntrFont->preview(),i,1);
84 windowStyleLayout->addWidget(selEntrFont->button(),i,2); 84 windowStyleLayout->addWidget(selEntrFont->button(),i,2);
85 ++i; 85 ++i;
86 lab = new QLabel(i18n(""), windowStylePage); 86 lab = new QLabel(i18n(""), windowStylePage);
87 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2); 87 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2);
88 88
89 // File page 89 // File page
90 ////////////////////////////////////////////////////// 90 //////////////////////////////////////////////////////
91 QWidget *filePage = new QWidget( this ); 91 QWidget *filePage = new QWidget( this );
92 QGridLayout *fileLayout = new QGridLayout( filePage, 3, 2); 92 QGridLayout *fileLayout = new QGridLayout( filePage, 3, 2);
93 93
94 i = 0; 94 i = 0;
95 QLabel* kcfg_compression_label = new QLabel(i18n("Compression:"), filePage); 95 QLabel* kcfg_compression_label = new QLabel(i18n("Compression:"), filePage);
96 fileLayout->addWidget(kcfg_compression_label,i,0); 96 fileLayout->addWidget(kcfg_compression_label,i,0);
97 kcfg_compression = new QComboBox(filePage, "kcfg_compression"); 97 kcfg_compression = new QComboBox(filePage, "kcfg_compression");
98 kcfg_compression->insertItem(i18n("None")); 98 kcfg_compression->insertItem(i18n("None"));
99 kcfg_compression->insertItem(i18n("gzip")); 99 kcfg_compression->insertItem(i18n("gzip"));
100 //US not yet supported: kcfg_compression->insertItem(i18n("bzip2")); 100 //US not yet supported: kcfg_compression->insertItem(i18n("bzip2"));
101 fileLayout->addWidget( kcfg_compression,i,1); 101 fileLayout->addWidget( kcfg_compression,i,1);
102 ++i; 102 ++i;
103 103
104 QLabel* kcfg_crypt_label = new QLabel(i18n("Encryption:"), filePage); 104 QLabel* kcfg_crypt_label = new QLabel(i18n("Encryption:"), filePage);
105 fileLayout->addWidget(kcfg_crypt_label,i,0); 105 fileLayout->addWidget(kcfg_crypt_label,i,0);
106 kcfg_cryptAlgo = new QComboBox(filePage, "kcfg_cryptAlgo"); 106 kcfg_cryptAlgo = new QComboBox(filePage, "kcfg_cryptAlgo");
107 kcfg_cryptAlgo->insertItem(i18n("Blowfish (128 bit)")); 107 kcfg_cryptAlgo->insertItem(i18n("Blowfish (128 bit)"));
108#ifdef CONFIG_PWMANAGER_GCRY 108#ifdef CONFIG_PWMANAGER_GCRY
109 kcfg_cryptAlgo->insertItem(i18n("AES-128, Rijndael (128 bit)")); 109 kcfg_cryptAlgo->insertItem(i18n("AES-128, Rijndael (128 bit)"));
110 kcfg_cryptAlgo->insertItem(i18n("AES-192, Rijndael (192 bit)")); 110 kcfg_cryptAlgo->insertItem(i18n("AES-192, Rijndael (192 bit)"));
111 kcfg_cryptAlgo->insertItem(i18n("AES-256, Rijndael (256 bit)")); 111 kcfg_cryptAlgo->insertItem(i18n("AES-256, Rijndael (256 bit)"));
112 kcfg_cryptAlgo->insertItem(i18n("Triple-DES (168 bit)")); 112 kcfg_cryptAlgo->insertItem(i18n("Triple-DES (168 bit)"));
113 kcfg_cryptAlgo->insertItem(i18n("Twofish (256 bit)")); 113 kcfg_cryptAlgo->insertItem(i18n("Twofish (256 bit)"));
114 kcfg_cryptAlgo->insertItem(i18n("Twofish-128 (128 bit)")); 114 kcfg_cryptAlgo->insertItem(i18n("Twofish-128 (128 bit)"));
115#endif // CONFIG_PWMANAGER_GCRY 115#endif // CONFIG_PWMANAGER_GCRY
116 fileLayout->addWidget( kcfg_cryptAlgo,i,1); 116 fileLayout->addWidget( kcfg_cryptAlgo,i,1);
117 ++i; 117 ++i;
118 118
119 QLabel* kcfg_hash_label = new QLabel(i18n("Hashing:"), filePage); 119 QLabel* kcfg_hash_label = new QLabel(i18n("Hashing:"), filePage);
120 fileLayout->addWidget(kcfg_hash_label,i,0); 120 fileLayout->addWidget(kcfg_hash_label,i,0);
121 kcfg_hashAlgo = new QComboBox(filePage, "kcfg_hashAlgo"); 121 kcfg_hashAlgo = new QComboBox(filePage, "kcfg_hashAlgo");
122 kcfg_hashAlgo->insertItem(i18n("SHA-160, SHA1 (160 bit)")); 122 kcfg_hashAlgo->insertItem(i18n("SHA-160, SHA1 (160 bit)"));
123#ifdef CONFIG_PWMANAGER_GCRY 123#ifdef CONFIG_PWMANAGER_GCRY
124 kcfg_hashAlgo->insertItem(i18n("SHA-256 (256 bit)")); 124 kcfg_hashAlgo->insertItem(i18n("SHA-256 (256 bit)"));
125 kcfg_hashAlgo->insertItem(i18n("SHA-384 (384 bit)")); 125 kcfg_hashAlgo->insertItem(i18n("SHA-384 (384 bit)"));
126 kcfg_hashAlgo->insertItem(i18n("SHA-512 (512 bit)")); 126 kcfg_hashAlgo->insertItem(i18n("SHA-512 (512 bit)"));
127 kcfg_hashAlgo->insertItem(i18n("MD5 (128 bit)")); 127 kcfg_hashAlgo->insertItem(i18n("MD5 (128 bit)"));
128 kcfg_hashAlgo->insertItem(i18n("RIPE-MD-160 (160 bit)")); 128 kcfg_hashAlgo->insertItem(i18n("RIPE-MD-160 (160 bit)"));
129 kcfg_hashAlgo->insertItem(i18n("Tiger (192 bit)")); 129 kcfg_hashAlgo->insertItem(i18n("Tiger (192 bit)"));
130#endif // CONFIG_PWMANAGER_GCRY 130#endif // CONFIG_PWMANAGER_GCRY
131 fileLayout->addWidget( kcfg_hashAlgo,i,1); 131 fileLayout->addWidget( kcfg_hashAlgo,i,1);
132 ++i; 132 ++i;
133 133
134 permissionLineEdit = new QLineEdit(filePage); 134 permissionLineEdit = new QLineEdit(filePage);
135 QLabel* permissionLineLabel = new QLabel(permissionLineEdit, i18n("Permissions:"), filePage); 135 QLabel* permissionLineLabel = new QLabel(permissionLineEdit, i18n("Permissions:"), filePage);
136 fileLayout->addWidget(permissionLineLabel,i,0); 136 fileLayout->addWidget(permissionLineLabel,i,0);
137 fileLayout->addWidget(permissionLineEdit,i,1); 137 fileLayout->addWidget(permissionLineEdit,i,1);
138 ++i; 138 ++i;
139 139
140 KPrefsWidBool *sb = addWidBool(i18n("Make backup before saving"), 140 KPrefsWidBool *sb = addWidBool(i18n("Make backup before saving"),
141 &(prefs->mMakeFileBackup),filePage); 141 &(prefs->mMakeFileBackup),filePage);
142 fileLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 142 fileLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
143 ++i; 143 ++i;
144 144
145 // Timeout page 145 // Timeout page
146 ////////////////////////////////////////////////////// 146 //////////////////////////////////////////////////////
147 QWidget *timeoutPage = new QWidget( this ); 147 QWidget *timeoutPage = new QWidget( this );
148 QGridLayout *timeoutLayout = new QGridLayout( timeoutPage, 3, 2); 148 QGridLayout *timeoutLayout = new QGridLayout( timeoutPage, 3, 2);
149 149
150 i = 0; 150 i = 0;
151 pwTimeoutSpinBox = new QSpinBox( timeoutPage, "pwTimeoutSpinBox" ); 151 pwTimeoutSpinBox = new QSpinBox( timeoutPage, "pwTimeoutSpinBox" );
152 QLabel* timeoutLabel = new QLabel(pwTimeoutSpinBox, i18n("Password timeout\n(timeout to hold password in\nmemory,so you don't have to\nre-enter it,if you\nalready have entered it)\n[set to 0 to disable]:"), timeoutPage); 152 QLabel* timeoutLabel = new QLabel(pwTimeoutSpinBox, i18n("Password timeout\n(timeout to hold password in\nmemory,so you don't have to\nre-enter it,if you\nalready have entered it)\n[set to 0 to disable]:"), timeoutPage);
153 timeoutLayout->addMultiCellWidget(timeoutLabel,i, i, 0 ,0); 153 timeoutLayout->addMultiCellWidget(timeoutLabel,i, i, 0 ,0);
154 timeoutLayout->addWidget(pwTimeoutSpinBox,i,1); 154 timeoutLayout->addWidget(pwTimeoutSpinBox,i,1);
155 ++i; 155 ++i;
156 156
157 lockTimeoutSpinBox = new QSpinBox( timeoutPage, "lockTimeoutSpinBox" ); 157 lockTimeoutSpinBox = new QSpinBox( timeoutPage, "lockTimeoutSpinBox" );
158 QLabel* lockTimeoutLabel = new QLabel(lockTimeoutSpinBox, i18n("Auto-lock timeout\n(auto lock document after this\namount of seconds)\n[set to 0 to disable]:"), timeoutPage); 158 QLabel* lockTimeoutLabel = new QLabel(lockTimeoutSpinBox, i18n("Auto-lock timeout\n(auto lock document after this\namount of seconds)\n[set to 0 to disable]:"), timeoutPage);
159 timeoutLayout->addMultiCellWidget(lockTimeoutLabel,i, i, 0 ,0); 159 timeoutLayout->addMultiCellWidget(lockTimeoutLabel,i, i, 0 ,0);
160 timeoutLayout->addWidget(lockTimeoutSpinBox,i,1); 160 timeoutLayout->addWidget(lockTimeoutSpinBox,i,1);
161 ++i; 161 ++i;
162 162
163 sb = addWidBool(i18n("deep-lock on autolock"), 163 sb = addWidBool(i18n("deep-lock on autolock"),
164 &(prefs->mAutoDeeplock),timeoutPage); 164 &(prefs->mAutoDeeplock),timeoutPage);
165 timeoutLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 165 timeoutLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
166 ++i; 166 ++i;
167 167
168 168
169 // Autostart page 169 // Autostart page
170 ////////////////////////////////////////////////////// 170 //////////////////////////////////////////////////////
171 QWidget *autostartPage = new QWidget( this ); 171 QWidget *autostartPage = new QWidget( this );
172 QGridLayout *autostartLayout = new QGridLayout( autostartPage, 3, 2); 172 QGridLayout *autostartLayout = new QGridLayout( autostartPage, 3, 2);
173 173
174 i = 0; 174 i = 0;
175 175
176 autostartLineEdit = new KURLRequester(autostartPage, "autoStartLineEdit"); 176 autostartLineEdit = new KURLRequester(autostartPage, "autoStartLineEdit");
177 QLabel* autostartLineLabel = new QLabel(autostartLineEdit, "Open this file automatically on startup:",autostartPage); 177 QLabel* autostartLineLabel = new QLabel(autostartLineEdit, "Open this file automatically on startup:",autostartPage);
178 autostartLayout->addMultiCellWidget(autostartLineLabel,i,i,0,1); 178 autostartLayout->addMultiCellWidget(autostartLineLabel,i,i,0,1);
179 ++i; 179 ++i;
180 autostartLayout->addMultiCellWidget(autostartLineEdit,i,i,0,1); 180 autostartLayout->addMultiCellWidget(autostartLineEdit,i,i,0,1);
181 ++i; 181 ++i;
182 182
183 sb = addWidBool(i18n("open deeplocked"), 183 sb = addWidBool(i18n("open deeplocked"),
184 &(prefs->mAutostartDeeplocked),autostartPage); 184 &(prefs->mAutostartDeeplocked),autostartPage);
185 autostartLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 185 autostartLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
186 ++i; 186 ++i;
187 187
188 188
189 // external app page 189 // external app page
190 ////////////////////////////////////////////////////// 190 //////////////////////////////////////////////////////
191 QWidget *externalappPage = new QWidget( this ); 191 QWidget *externalappPage = new QWidget( this );
192 QGridLayout *externalappLayout = new QGridLayout( externalappPage, 3, 2); 192 QGridLayout *externalappLayout = new QGridLayout( externalappPage, 3, 2);
193 193
194 i = 0; 194 i = 0;
195 195
196 browserLineEdit = new QLineEdit(externalappPage); 196 browserLineEdit = new QLineEdit(externalappPage);
197 QLabel* browserLineLabel = new QLabel(browserLineEdit, i18n("Favourite browser:"), externalappPage); 197 QLabel* browserLineLabel = new QLabel(browserLineEdit, i18n("Favourite browser:"), externalappPage);
198 externalappLayout->addWidget(browserLineLabel,i,0); 198 externalappLayout->addWidget(browserLineLabel,i,0);
199 externalappLayout->addWidget(browserLineEdit,i,1); 199 externalappLayout->addWidget(browserLineEdit,i,1);
200 ++i; 200 ++i;
201 201
202 xtermLineEdit = new QLineEdit(externalappPage); 202 xtermLineEdit = new QLineEdit(externalappPage);
203 QLabel* xtermLineLabel = new QLabel(xtermLineEdit, i18n("Favourite x-terminal:"), externalappPage); 203 QLabel* xtermLineLabel = new QLabel(xtermLineEdit, i18n("Favourite x-terminal:"), externalappPage);
204 externalappLayout->addWidget(xtermLineLabel,i,0); 204 externalappLayout->addWidget(xtermLineLabel,i,0);
205 externalappLayout->addWidget(xtermLineEdit,i,1); 205 externalappLayout->addWidget(xtermLineEdit,i,1);
206 ++i; 206 ++i;
207 207
208 208
209 // miscelaneous page 209 // miscelaneous page
210 ////////////////////////////////////////////////////// 210 //////////////////////////////////////////////////////
211 QWidget *miscPage = new QWidget( this ); 211 QWidget *miscPage = new QWidget( this );
212 QGridLayout *miscLayout = new QGridLayout( miscPage, 3, 2); 212 QGridLayout *miscLayout = new QGridLayout( miscPage, 3, 2);
213 213
214 i = 0; 214 i = 0;
215 215
216 /*US ENH: PWM/Pi has no tray and con be minimized
216 sb = addWidBool(i18n("Show icon in system-tray"),&(prefs->mTray),miscPage); 217 sb = addWidBool(i18n("Show icon in system-tray"),&(prefs->mTray),miscPage);
217 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 218 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
218 ++i; 219 ++i;
219 220 */
220 221
221 sb = addWidBool(i18n("Open document with passwords unlocked"),&(prefs->mUnlockOnOpen),miscPage); 222 sb = addWidBool(i18n("Open document with passwords unlocked"),&(prefs->mUnlockOnOpen),miscPage);
222 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 223 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
223 ++i; 224 ++i;
224 225
226 /*US ENH: PWM/Pi has no tray and con be minimized
225 sb = addWidBool(i18n("auto-minimize to tray on startup"),&(prefs->mAutoMinimizeOnStart),miscPage); 227 sb = addWidBool(i18n("auto-minimize to tray on startup"),&(prefs->mAutoMinimizeOnStart),miscPage);
226 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 228 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
227 sb->checkBox()->setEnabled (FALSE);
228 ++i; 229 ++i;
229 230
230 KPrefsWidRadios * minimizeRadio = addWidRadios(i18n("auto-lock on minimize:") ,&(prefs->mMinimizeLock), miscPage); 231 KPrefsWidRadios * minimizeRadio = addWidRadios(i18n("auto-lock on minimize:") ,&(prefs->mMinimizeLock), miscPage);
231 minimizeRadio->addRadio(i18n("don't lock")); 232 minimizeRadio->addRadio(i18n("don't lock"));
232 minimizeRadio->addRadio(i18n("normal lock")); 233 minimizeRadio->addRadio(i18n("normal lock"));
233 minimizeRadio->addRadio(i18n("deep-lock")); 234 minimizeRadio->addRadio(i18n("deep-lock"));
234 miscLayout->addMultiCellWidget( (QWidget*)minimizeRadio->groupBox(),i,i,0,2); 235 miscLayout->addMultiCellWidget( (QWidget*)minimizeRadio->groupBox(),i,i,0,2);
235 ++i; 236 ++i;
236 237
237 sb = addWidBool(i18n("KWallet emulation"),&(prefs->mKWalletEmu),miscPage); 238 sb = addWidBool(i18n("KWallet emulation"),&(prefs->mKWalletEmu),miscPage);
238 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 239 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
239 ++i; 240 ++i;
240 241
241 sb = addWidBool(i18n("Close instead Minimize into tray"),&(prefs->mClose),miscPage); 242 sb = addWidBool(i18n("Close instead Minimize into tray"),&(prefs->mClose),miscPage);
242 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 243 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
243 ++i; 244 ++i;
244 245 */
245 246
246 247
247 tabWidget->addTab( windowStylePage, i18n( "Look && feel" ) ); 248 tabWidget->addTab( windowStylePage, i18n( "Look && feel" ) );
248 tabWidget->addTab( filePage, i18n( "File" ) ); 249 tabWidget->addTab( filePage, i18n( "File" ) );
249 tabWidget->addTab( timeoutPage, i18n( "Timeout" ) ); 250 tabWidget->addTab( timeoutPage, i18n( "Timeout" ) );
250 tabWidget->addTab( autostartPage, i18n( "Autostart" ) ); 251 tabWidget->addTab( autostartPage, i18n( "Autostart" ) );
251 tabWidget->addTab( externalappPage, i18n( "External apps" ) ); 252 tabWidget->addTab( externalappPage, i18n( "External apps" ) );
252 tabWidget->addTab( miscPage, i18n( "Miscellaneous" ) ); 253 tabWidget->addTab( miscPage, i18n( "Miscellaneous" ) );
253 254
254 255
255 connect( permissionLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 256 connect( permissionLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
256 connect( pwTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) ); 257 connect( pwTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) );
257 connect( lockTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) ); 258 connect( lockTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) );
258 connect( autostartLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 259 connect( autostartLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
259 connect( browserLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 260 connect( browserLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
260 connect( xtermLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 261 connect( xtermLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
261 262
262} 263}
263 264
264 265
265void PWMConfigWidget::usrReadConfig() 266void PWMConfigWidget::usrReadConfig()
266{ 267{
267 PWMPrefs* prefs = PWMPrefs::instance(); 268 PWMPrefs* prefs = PWMPrefs::instance();
268 269
269 270
270 setFilePermissions(prefs->mFilePermissions); 271 setFilePermissions(prefs->mFilePermissions);
271 272
272 pwTimeoutSpinBox->setValue(prefs->mPwTimeout); 273 pwTimeoutSpinBox->setValue(prefs->mPwTimeout);
273 lockTimeoutSpinBox->setValue(prefs->mLockTimeout); 274 lockTimeoutSpinBox->setValue(prefs->mLockTimeout);
274 autostartLineEdit->setURL(prefs->mAutoStart); 275 autostartLineEdit->setURL(prefs->mAutoStart);
275 browserLineEdit->setText(prefs->mBrowserCommand); 276 browserLineEdit->setText(prefs->mBrowserCommand);
276 xtermLineEdit->setText(prefs->mXTermCommand); 277 xtermLineEdit->setText(prefs->mXTermCommand);
277 278
278 kcfg_compression->setCurrentItem(prefs->mCompression); 279 kcfg_compression->setCurrentItem(prefs->mCompression);
279 kcfg_cryptAlgo->setCurrentItem(prefs->mCryptAlgo); 280 kcfg_cryptAlgo->setCurrentItem(prefs->mCryptAlgo);
280 kcfg_hashAlgo->setCurrentItem(prefs->mHashAlgo); 281 kcfg_hashAlgo->setCurrentItem(prefs->mHashAlgo);
281} 282}
282 283
283void PWMConfigWidget::usrWriteConfig() 284void PWMConfigWidget::usrWriteConfig()
284{ 285{
285 PWMPrefs* prefs = PWMPrefs::instance(); 286 PWMPrefs* prefs = PWMPrefs::instance();
286 287
287 prefs->mFilePermissions = getFilePermissions(); 288 prefs->mFilePermissions = getFilePermissions();
288 289
289 prefs->mPwTimeout = pwTimeoutSpinBox->value(); 290 prefs->mPwTimeout = pwTimeoutSpinBox->value();
290 prefs->mLockTimeout = lockTimeoutSpinBox->value(); 291 prefs->mLockTimeout = lockTimeoutSpinBox->value();
291 prefs->mAutoStart = autostartLineEdit->url(); 292 prefs->mAutoStart = autostartLineEdit->url();
292 293
293 prefs->mBrowserCommand = browserLineEdit->text(); 294 prefs->mBrowserCommand = browserLineEdit->text();
294 prefs->mXTermCommand = xtermLineEdit->text(); 295 prefs->mXTermCommand = xtermLineEdit->text();
295 296
296 prefs->mCompression = kcfg_compression->currentItem(); 297 prefs->mCompression = kcfg_compression->currentItem();
297 prefs->mCryptAlgo = kcfg_cryptAlgo->currentItem(); 298 prefs->mCryptAlgo = kcfg_cryptAlgo->currentItem();
298 prefs->mHashAlgo = kcfg_hashAlgo->currentItem(); 299 prefs->mHashAlgo = kcfg_hashAlgo->currentItem();
299 300
300} 301}
301 302
302int PWMConfigWidget::getFilePermissions() 303int PWMConfigWidget::getFilePermissions()
303{ 304{
304 char octalDigits[] = "01234567"; 305 char octalDigits[] = "01234567";
305 bool isOctal; 306 bool isOctal;
306 QString permString(permissionLineEdit->text()); 307 QString permString(permissionLineEdit->text());
307 int i, j, length = permString.length(); 308 int i, j, length = permString.length();
308 if (length != 3) { 309 if (length != 3) {
309 printWarn("Wrong permission string length! Please enter " 310 printWarn("Wrong permission string length! Please enter "
310 "the string like the following example: 600"); 311 "the string like the following example: 600");
311 return CONF_DEFAULT_FILEPERMISSIONS; 312 return CONF_DEFAULT_FILEPERMISSIONS;
312 } 313 }
313 for (i = 0; i < length; ++i) { 314 for (i = 0; i < length; ++i) {
314 isOctal = false; 315 isOctal = false;
315 for (j = 0; j < 8; ++j) { 316 for (j = 0; j < 8; ++j) {
316 if (permString.at(i) == octalDigits[j]) { 317 if (permString.at(i) == octalDigits[j]) {
317 isOctal = true; 318 isOctal = true;
318 break; 319 break;
319 } 320 }
320 } 321 }
321 if (!isOctal) { 322 if (!isOctal) {
322 printWarn("CONFIG: File-permissions: This is " 323 printWarn("CONFIG: File-permissions: This is "
323 "not an octal number "); 324 "not an octal number ");
324 return CONF_DEFAULT_FILEPERMISSIONS; 325 return CONF_DEFAULT_FILEPERMISSIONS;
325 } 326 }
326 } 327 }
327 328
328 int ret = strtol(permString.latin1(), 0, 8); 329 int ret = strtol(permString.latin1(), 0, 8);
329 if (ret == 0) { 330 if (ret == 0) {
330 /* either an error occured, or the user did really type 000 */ 331 /* either an error occured, or the user did really type 000 */
331 printWarn("CONFIG: File-permissions: Hm, either conversion error, " 332 printWarn("CONFIG: File-permissions: Hm, either conversion error, "
332 "or you really typed 000. 8-)"); 333 "or you really typed 000. 8-)");
333 return CONF_DEFAULT_FILEPERMISSIONS; 334 return CONF_DEFAULT_FILEPERMISSIONS;
334 } 335 }
335 return ret; 336 return ret;
336} 337}
337 338
338void PWMConfigWidget::setFilePermissions(int perm) 339void PWMConfigWidget::setFilePermissions(int perm)
339{ 340{
340 char tmpBuf[30]; 341 char tmpBuf[30];
341 sprintf(tmpBuf, "%o", perm); 342 sprintf(tmpBuf, "%o", perm);
342 permissionLineEdit->setText(tmpBuf); 343 permissionLineEdit->setText(tmpBuf);
343} 344}
344 345
345 346
346 347
347#ifndef PWM_EMBEDDED 348#ifndef PWM_EMBEDDED
348#include "pwmconfigwidget.moc" 349#include "pwmconfigwidget.moc"
349#endif //PWM_EMBEDDED 350#endif //PWM_EMBEDDED
350 351
diff --git a/pwmanager/pwmanager/pwmprefs.h b/pwmanager/pwmanager/pwmprefs.h
index 1c8b982..5b8f9d8 100644
--- a/pwmanager/pwmanager/pwmprefs.h
+++ b/pwmanager/pwmanager/pwmprefs.h
@@ -1,163 +1,163 @@
1/* 1/*
2 This file is part of PwManager/Pi 2 This file is part of PwManager/Pi
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
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 $Id$ 23 $Id$
24*/ 24*/
25 25
26#ifndef PWMPREFS_H 26#ifndef PWMPREFS_H
27#define PWMPREFS_H 27#define PWMPREFS_H
28 28
29#include <qstringlist.h> 29#include <qstringlist.h>
30#include <qsize.h> 30#include <qsize.h>
31 31
32#include <kpimprefs.h> 32#include <kpimprefs.h>
33 33
34class KConfig; 34class KConfig;
35 35
36#define conf() PWMPrefs::instance() 36#define conf() PWMPrefs::instance()
37 37
38 38
39 39
40 40
41#define CONF_DEFAULT_PWTIMEOUT 10/* 10 sec */ 41#define CONF_DEFAULT_PWTIMEOUT 10/* 10 sec */
42#define CONF_DEFAULT_LOCKTIMEOUT 0/* 0 == disable */ 42#define CONF_DEFAULT_LOCKTIMEOUT 0/* 0 == disable */
43#define CONF_DEFAULT_TRAY true 43#define CONF_DEFAULT_TRAY false
44#define CONF_DEFAULT_UNLOCKONOPEN true 44#define CONF_DEFAULT_UNLOCKONOPEN true
45#define CONF_DEFAULT_MAINVIEWSTYLE 1/* Category List Left */ 45#define CONF_DEFAULT_MAINVIEWSTYLE 1/* Category List Left */
46#define CONF_DEFAULT_COMPRESSION 0x01/* gzip */ 46#define CONF_DEFAULT_COMPRESSION 0x01/* gzip */
47#define CONF_DEFAULT_CRYPTALGO (0x01 - 1)/* blowfish */ 47#define CONF_DEFAULT_CRYPTALGO (0x01 - 1)/* blowfish */
48#define CONF_DEFAULT_HASHALGO (0x01 - 1)/* sha1 */ 48#define CONF_DEFAULT_HASHALGO (0x01 - 1)/* sha1 */
49#define CONF_DEFAULT_AUTOMINIMIZE false 49#define CONF_DEFAULT_AUTOMINIMIZE false
50#define CONF_DEFAULT_BROWSERCOMMAND "" 50#define CONF_DEFAULT_BROWSERCOMMAND ""
51#define CONF_DEFAULT_XTERMCOMMAND "konsole -e" 51#define CONF_DEFAULT_XTERMCOMMAND "konsole -e"
52#define CONF_DEFAULT_FILEPERMISSIONS 0600 52#define CONF_DEFAULT_FILEPERMISSIONS 0600
53#define CONF_DEFAULT_MAKEFILEBACKUP false 53#define CONF_DEFAULT_MAKEFILEBACKUP false
54#define CONF_DEFAULT_AUTOSTART_DEEPL true 54#define CONF_DEFAULT_AUTOSTART_DEEPL true
55#define CONF_DEFAULT_AUTODEEPLOCK true 55#define CONF_DEFAULT_AUTODEEPLOCK true
56#define CONF_DEFAULT_KWALLETEMU true 56#define CONF_DEFAULT_KWALLETEMU false
57#define CONF_DEFAULT_MINIMIZELOCK 2/* deep-lock */ 57#define CONF_DEFAULT_MINIMIZELOCK 2/* deep-lock */
58#define CONF_DEFAULT_NEWENTRLOCKSTAT false/* new entries unlocked */ 58#define CONF_DEFAULT_NEWENTRLOCKSTAT false/* new entries unlocked */
59#define CONF_DEFAULT_WNDCLOSE true/* don't minimize to tray */ 59#define CONF_DEFAULT_WNDCLOSE true/* don't minimize to tray */
60 60
61 61
62class PWMPrefs : public KPimPrefs 62class PWMPrefs : public KPimPrefs
63{ 63{
64 public: 64 public:
65 virtual ~PWMPrefs(); 65 virtual ~PWMPrefs();
66 66
67 static PWMPrefs *instance(); 67 static PWMPrefs *instance();
68 68
69public: 69public:
70 /* functions for reading the configuration settings */ 70 /* functions for reading the configuration settings */
71 /* GLOBAL */ 71 /* GLOBAL */
72 QString confGlobAutoStart(); 72 QString confGlobAutoStart();
73 QString confGlobBrowserCommand(); 73 QString confGlobBrowserCommand();
74 QString confGlobXtermCommand(); 74 QString confGlobXtermCommand();
75 QFont confGlobEntryFont(); 75 QFont confGlobEntryFont();
76 int confGlobPwTimeout(); 76 int confGlobPwTimeout();
77 int confGlobLockTimeout(); 77 int confGlobLockTimeout();
78 int confGlobCompression(); 78 int confGlobCompression();
79 int confGlobCryptAlgo(); 79 int confGlobCryptAlgo();
80 int confGlobHashAlgo(); 80 int confGlobHashAlgo();
81 int confGlobFilePermissions(); 81 int confGlobFilePermissions();
82 int confGlobMinimizeLock(); 82 int confGlobMinimizeLock();
83 bool confGlobUnlockOnOpen(); 83 bool confGlobUnlockOnOpen();
84 bool confGlobTray(); 84 bool confGlobTray();
85 bool confGlobMakeFileBackup(); 85 bool confGlobMakeFileBackup();
86 bool confGlobAutostartDeepLocked(); 86 bool confGlobAutostartDeepLocked();
87 bool confGlobAutoDeepLock(); 87 bool confGlobAutoDeepLock();
88 bool confGlobKwalletEmu(); 88 bool confGlobKwalletEmu();
89 bool confGlobNewEntrLockStat(); 89 bool confGlobNewEntrLockStat();
90 /* WND */ 90 /* WND */
91 QSize confWndMainWndSize(); 91 QSize confWndMainWndSize();
92 int confWndMainViewStyle(); 92 int confWndMainViewStyle();
93 bool confWndAutoMinimizeOnStart(); 93 bool confWndAutoMinimizeOnStart();
94 bool confWndClose(); 94 bool confWndClose();
95 95
96public: 96public:
97 /* functions for writing the configuration settings */ 97 /* functions for writing the configuration settings */
98 /* GLOBAL */ 98 /* GLOBAL */
99 void confGlobAutoStart(const QString &e); 99 void confGlobAutoStart(const QString &e);
100 void confGlobBrowserCommand(const QString &e); 100 void confGlobBrowserCommand(const QString &e);
101 void confGlobXtermCommand(const QString &e); 101 void confGlobXtermCommand(const QString &e);
102 void confGlobEntryFont(const QFont &e); 102 void confGlobEntryFont(const QFont &e);
103 void confGlobPwTimeout(int e); 103 void confGlobPwTimeout(int e);
104 void confGlobLockTimeout(int e); 104 void confGlobLockTimeout(int e);
105 void confGlobCompression(int e); 105 void confGlobCompression(int e);
106 void confGlobCryptAlgo(int e); 106 void confGlobCryptAlgo(int e);
107 void confGlobHashAlgo(int e); 107 void confGlobHashAlgo(int e);
108 108
109 void confGlobFilePermissions(int e); 109 void confGlobFilePermissions(int e);
110 void confGlobMinimizeLock(int e); 110 void confGlobMinimizeLock(int e);
111 void confGlobUnlockOnOpen(bool e); 111 void confGlobUnlockOnOpen(bool e);
112 void confGlobTray(bool e); 112 void confGlobTray(bool e);
113 void confGlobMakeFileBackup(bool e); 113 void confGlobMakeFileBackup(bool e);
114 void confGlobAutostartDeepLocked(bool e); 114 void confGlobAutostartDeepLocked(bool e);
115 void confGlobAutoDeepLock(bool e); 115 void confGlobAutoDeepLock(bool e);
116 void confGlobKwalletEmu(bool e); 116 void confGlobKwalletEmu(bool e);
117 void confGlobNewEntrLockStat(bool e); 117 void confGlobNewEntrLockStat(bool e);
118 /* WND */ 118 /* WND */
119 void confWndMainWndSize(const QSize &e); 119 void confWndMainWndSize(const QSize &e);
120 void confWndMainViewStyle(int e); 120 void confWndMainViewStyle(int e);
121 void confWndAutoMinimizeOnStart(bool e); 121 void confWndAutoMinimizeOnStart(bool e);
122 void confWndClose(bool e); 122 void confWndClose(bool e);
123 123
124 124
125 125
126 QString mAutoStart; 126 QString mAutoStart;
127 QString mBrowserCommand; 127 QString mBrowserCommand;
128 QString mXTermCommand; 128 QString mXTermCommand;
129 QFont mEntryFont; 129 QFont mEntryFont;
130 int mPwTimeout; 130 int mPwTimeout;
131 int mLockTimeout; 131 int mLockTimeout;
132 int mCompression; 132 int mCompression;
133 int mCryptAlgo; 133 int mCryptAlgo;
134 int mHashAlgo; 134 int mHashAlgo;
135 int mFilePermissions; 135 int mFilePermissions;
136 int mMinimizeLock; 136 int mMinimizeLock;
137 bool mUnlockOnOpen; 137 bool mUnlockOnOpen;
138 bool mTray; 138 bool mTray;
139 bool mMakeFileBackup; 139 bool mMakeFileBackup;
140 bool mAutostartDeeplocked; 140 bool mAutostartDeeplocked;
141 bool mAutoDeeplock; 141 bool mAutoDeeplock;
142 bool mKWalletEmu; 142 bool mKWalletEmu;
143 bool mNewEntrLockStat; 143 bool mNewEntrLockStat;
144 QSize mMainWndSize; 144 QSize mMainWndSize;
145 int mMainViewStyle; 145 int mMainViewStyle;
146 bool mAutoMinimizeOnStart; 146 bool mAutoMinimizeOnStart;
147 bool mClose; 147 bool mClose;
148 148
149 //US ENH 149 //US ENH
150 QValueList<int> mCommentSplitter; 150 QValueList<int> mCommentSplitter;
151 QValueList<int> mCategorySplitter; 151 QValueList<int> mCategorySplitter;
152 152
153 153
154 // US introduce a nonconst way to return the config object. 154 // US introduce a nonconst way to return the config object.
155 KConfig* getConfig(); 155 KConfig* getConfig();
156 156
157 private: 157 private:
158 PWMPrefs(); 158 PWMPrefs();
159 159
160 static PWMPrefs *sInstance; 160 static PWMPrefs *sInstance;
161}; 161};
162 162
163#endif 163#endif