-rw-r--r-- | microkde/kdeui/klistview.cpp | 3 | ||||
-rw-r--r-- | microkde/kglobalsettings.cpp | 9 | ||||
-rw-r--r-- | microkde/kglobalsettings.h | 1 |
3 files changed, 11 insertions, 2 deletions
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp index 31e2053..25327aa 100644 --- a/microkde/kdeui/klistview.cpp +++ b/microkde/kdeui/klistview.cpp | |||
@@ -78,770 +78,769 @@ void KListView::Tooltip::maybeTip (const QPoint&) | |||
78 | } | 78 | } |
79 | // */ | 79 | // */ |
80 | 80 | ||
81 | class KListView::KListViewPrivate | 81 | class KListView::KListViewPrivate |
82 | { | 82 | { |
83 | public: | 83 | public: |
84 | KListViewPrivate (KListView* listview) | 84 | KListViewPrivate (KListView* listview) |
85 | : pCurrentItem (0L), | 85 | : pCurrentItem (0L), |
86 | autoSelectDelay(1), | 86 | autoSelectDelay(1), |
87 | //US dragDelay (KGlobalSettings::dndEventDelay()), | 87 | //US dragDelay (KGlobalSettings::dndEventDelay()), |
88 | 88 | ||
89 | dragDelay (10), | 89 | dragDelay (10), |
90 | //US editor (new KListViewLineEdit (listview)), | 90 | //US editor (new KListViewLineEdit (listview)), |
91 | cursorInExecuteArea(false), | 91 | cursorInExecuteArea(false), |
92 | bUseSingle(false), | 92 | bUseSingle(false), |
93 | bChangeCursorOverItem(false), | 93 | bChangeCursorOverItem(false), |
94 | itemsMovable (true), | 94 | itemsMovable (true), |
95 | selectedBySimpleMove(false), | 95 | selectedBySimpleMove(false), |
96 | selectedUsingMouse(false), | 96 | selectedUsingMouse(false), |
97 | itemsRenameable (false), | 97 | itemsRenameable (false), |
98 | validDrag (false), | 98 | validDrag (false), |
99 | dragEnabled (false), | 99 | dragEnabled (false), |
100 | autoOpen (true), | 100 | autoOpen (true), |
101 | dropVisualizer (true), | 101 | dropVisualizer (true), |
102 | dropHighlighter (false), | 102 | dropHighlighter (false), |
103 | createChildren (true), | 103 | createChildren (true), |
104 | pressedOnSelected (false), | 104 | pressedOnSelected (false), |
105 | wasShiftEvent (false), | 105 | wasShiftEvent (false), |
106 | fullWidth (false), | 106 | fullWidth (false), |
107 | sortAscending(true), | 107 | sortAscending(true), |
108 | tabRename(true), | 108 | tabRename(true), |
109 | sortColumn(0), | 109 | sortColumn(0), |
110 | selectionDirection(0), | 110 | selectionDirection(0), |
111 | tooltipColumn (0), | 111 | tooltipColumn (0), |
112 | selectionMode (Single), | 112 | selectionMode (Single), |
113 | contextMenuKey ( Qt::Key_Menu ),//KGlobalSettings::contextMenuKey()), | 113 | contextMenuKey ( Qt::Key_Menu ),//KGlobalSettings::contextMenuKey()), |
114 | showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), | 114 | showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), |
115 | mDropVisualizerWidth (4) | 115 | mDropVisualizerWidth (4) |
116 | { | 116 | { |
117 | renameable += 0; | 117 | renameable += 0; |
118 | //US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); | 118 | //US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); |
119 | } | 119 | } |
120 | 120 | ||
121 | ~KListViewPrivate () | 121 | ~KListViewPrivate () |
122 | { | 122 | { |
123 | //US delete editor; | 123 | //US delete editor; |
124 | } | 124 | } |
125 | 125 | ||
126 | QListViewItem* pCurrentItem; | 126 | QListViewItem* pCurrentItem; |
127 | 127 | ||
128 | QTimer autoSelect; | 128 | QTimer autoSelect; |
129 | int autoSelectDelay; | 129 | int autoSelectDelay; |
130 | 130 | ||
131 | QTimer dragExpand; | 131 | QTimer dragExpand; |
132 | QListViewItem* dragOverItem; | 132 | QListViewItem* dragOverItem; |
133 | QPoint dragOverPoint; | 133 | QPoint dragOverPoint; |
134 | 134 | ||
135 | QPoint startDragPos; | 135 | QPoint startDragPos; |
136 | int dragDelay; | 136 | int dragDelay; |
137 | 137 | ||
138 | //US KListViewLineEdit *editor; | 138 | //US KListViewLineEdit *editor; |
139 | QValueList<int> renameable; | 139 | QValueList<int> renameable; |
140 | 140 | ||
141 | bool cursorInExecuteArea:1; | 141 | bool cursorInExecuteArea:1; |
142 | bool bUseSingle:1; | 142 | bool bUseSingle:1; |
143 | bool bChangeCursorOverItem:1; | 143 | bool bChangeCursorOverItem:1; |
144 | bool itemsMovable:1; | 144 | bool itemsMovable:1; |
145 | bool selectedBySimpleMove : 1; | 145 | bool selectedBySimpleMove : 1; |
146 | bool selectedUsingMouse:1; | 146 | bool selectedUsingMouse:1; |
147 | bool itemsRenameable:1; | 147 | bool itemsRenameable:1; |
148 | bool validDrag:1; | 148 | bool validDrag:1; |
149 | bool dragEnabled:1; | 149 | bool dragEnabled:1; |
150 | bool autoOpen:1; | 150 | bool autoOpen:1; |
151 | bool dropVisualizer:1; | 151 | bool dropVisualizer:1; |
152 | bool dropHighlighter:1; | 152 | bool dropHighlighter:1; |
153 | bool createChildren:1; | 153 | bool createChildren:1; |
154 | bool pressedOnSelected:1; | 154 | bool pressedOnSelected:1; |
155 | bool wasShiftEvent:1; | 155 | bool wasShiftEvent:1; |
156 | bool fullWidth:1; | 156 | bool fullWidth:1; |
157 | bool sortAscending:1; | 157 | bool sortAscending:1; |
158 | bool tabRename:1; | 158 | bool tabRename:1; |
159 | 159 | ||
160 | int sortColumn; | 160 | int sortColumn; |
161 | 161 | ||
162 | //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX | 162 | //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX |
163 | int selectionDirection; | 163 | int selectionDirection; |
164 | int tooltipColumn; | 164 | int tooltipColumn; |
165 | 165 | ||
166 | SelectionModeExt selectionMode; | 166 | SelectionModeExt selectionMode; |
167 | int contextMenuKey; | 167 | int contextMenuKey; |
168 | bool showContextMenusOnPress; | 168 | bool showContextMenusOnPress; |
169 | 169 | ||
170 | QRect mOldDropVisualizer; | 170 | QRect mOldDropVisualizer; |
171 | int mDropVisualizerWidth; | 171 | int mDropVisualizerWidth; |
172 | QRect mOldDropHighlighter; | 172 | QRect mOldDropHighlighter; |
173 | QListViewItem *afterItemDrop; | 173 | QListViewItem *afterItemDrop; |
174 | QListViewItem *parentItemDrop; | 174 | QListViewItem *parentItemDrop; |
175 | 175 | ||
176 | QColor alternateBackground; | 176 | QColor alternateBackground; |
177 | }; | 177 | }; |
178 | 178 | ||
179 | /*US | 179 | /*US |
180 | KListViewLineEdit::KListViewLineEdit(KListView *parent) | 180 | KListViewLineEdit::KListViewLineEdit(KListView *parent) |
181 | : KLineEdit(parent->viewport()), item(0), col(0), p(parent) | 181 | : KLineEdit(parent->viewport()), item(0), col(0), p(parent) |
182 | { | 182 | { |
183 | setFrame( false ); | 183 | setFrame( false ); |
184 | hide(); | 184 | hide(); |
185 | connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); | 185 | connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); |
186 | } | 186 | } |
187 | 187 | ||
188 | KListViewLineEdit::~KListViewLineEdit() | 188 | KListViewLineEdit::~KListViewLineEdit() |
189 | { | 189 | { |
190 | } | 190 | } |
191 | 191 | ||
192 | void KListViewLineEdit::load(QListViewItem *i, int c) | 192 | void KListViewLineEdit::load(QListViewItem *i, int c) |
193 | { | 193 | { |
194 | item=i; | 194 | item=i; |
195 | col=c; | 195 | col=c; |
196 | 196 | ||
197 | QRect rect(p->itemRect(i)); | 197 | QRect rect(p->itemRect(i)); |
198 | setText(item->text(c)); | 198 | setText(item->text(c)); |
199 | 199 | ||
200 | int fieldX = rect.x() - 1; | 200 | int fieldX = rect.x() - 1; |
201 | int fieldW = p->columnWidth(col) + 2; | 201 | int fieldW = p->columnWidth(col) + 2; |
202 | 202 | ||
203 | int pos = p->header()->mapToIndex(col); | 203 | int pos = p->header()->mapToIndex(col); |
204 | for ( int index = 0; index < pos; index++ ) | 204 | for ( int index = 0; index < pos; index++ ) |
205 | fieldX += p->columnWidth( p->header()->mapToSection( index )); | 205 | fieldX += p->columnWidth( p->header()->mapToSection( index )); |
206 | 206 | ||
207 | if ( col == 0 ) { | 207 | if ( col == 0 ) { |
208 | int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); | 208 | int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); |
209 | d *= p->treeStepSize(); | 209 | d *= p->treeStepSize(); |
210 | fieldX += d; | 210 | fieldX += d; |
211 | fieldW -= d; | 211 | fieldW -= d; |
212 | } | 212 | } |
213 | 213 | ||
214 | if ( i->pixmap( col ) ) {// add width of pixmap | 214 | if ( i->pixmap( col ) ) {// add width of pixmap |
215 | int d = i->pixmap( col )->width(); | 215 | int d = i->pixmap( col )->width(); |
216 | fieldX += d; | 216 | fieldX += d; |
217 | fieldW -= d; | 217 | fieldW -= d; |
218 | } | 218 | } |
219 | 219 | ||
220 | setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); | 220 | setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); |
221 | show(); | 221 | show(); |
222 | setFocus(); | 222 | setFocus(); |
223 | } | 223 | } |
224 | */ | 224 | */ |
225 | /*Helper functions to for | 225 | /*Helper functions to for |
226 | *tabOrderedRename functionality. | 226 | *tabOrderedRename functionality. |
227 | */ | 227 | */ |
228 | 228 | ||
229 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) | 229 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) |
230 | { | 230 | { |
231 | if (pi) | 231 | if (pi) |
232 | { | 232 | { |
233 | //Find the next renameable column in the current row | 233 | //Find the next renameable column in the current row |
234 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) | 234 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) |
235 | if (pl->isRenameable(start)) | 235 | if (pl->isRenameable(start)) |
236 | return start; | 236 | return start; |
237 | } | 237 | } |
238 | 238 | ||
239 | return -1; | 239 | return -1; |
240 | } | 240 | } |
241 | 241 | ||
242 | static QListViewItem *prevItem (QListViewItem *pi) | 242 | static QListViewItem *prevItem (QListViewItem *pi) |
243 | { | 243 | { |
244 | QListViewItem *pa = pi->itemAbove(); | 244 | QListViewItem *pa = pi->itemAbove(); |
245 | 245 | ||
246 | /*Does what the QListViewItem::previousSibling() | 246 | /*Does what the QListViewItem::previousSibling() |
247 | *of my dreams would do. | 247 | *of my dreams would do. |
248 | */ | 248 | */ |
249 | if (pa && pa->parent() == pi->parent()) | 249 | if (pa && pa->parent() == pi->parent()) |
250 | return pa; | 250 | return pa; |
251 | 251 | ||
252 | return NULL; | 252 | return NULL; |
253 | } | 253 | } |
254 | 254 | ||
255 | static QListViewItem *lastQChild (QListViewItem *pi) | 255 | static QListViewItem *lastQChild (QListViewItem *pi) |
256 | { | 256 | { |
257 | if (pi) | 257 | if (pi) |
258 | { | 258 | { |
259 | /*Since there's no QListViewItem::lastChild(). | 259 | /*Since there's no QListViewItem::lastChild(). |
260 | *This finds the last sibling for the given | 260 | *This finds the last sibling for the given |
261 | *item. | 261 | *item. |
262 | */ | 262 | */ |
263 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) | 263 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) |
264 | pi = pt; | 264 | pi = pt; |
265 | } | 265 | } |
266 | 266 | ||
267 | return pi; | 267 | return pi; |
268 | } | 268 | } |
269 | /*US | 269 | /*US |
270 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) | 270 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) |
271 | { | 271 | { |
272 | const int ncols = p->columns(); | 272 | const int ncols = p->columns(); |
273 | const int dir = forward ? +1 : -1; | 273 | const int dir = forward ? +1 : -1; |
274 | const int restart = forward ? 0 : (ncols - 1); | 274 | const int restart = forward ? 0 : (ncols - 1); |
275 | QListViewItem *top = (pitem && pitem->parent()) | 275 | QListViewItem *top = (pitem && pitem->parent()) |
276 | ? pitem->parent()->firstChild() | 276 | ? pitem->parent()->firstChild() |
277 | : p->firstChild(); | 277 | : p->firstChild(); |
278 | QListViewItem *pi = pitem; | 278 | QListViewItem *pi = pitem; |
279 | 279 | ||
280 | terminate(); //Save current changes | 280 | terminate(); //Save current changes |
281 | 281 | ||
282 | do | 282 | do |
283 | { | 283 | { |
284 | */ | 284 | */ |
285 | /*Check the rest of the current row for an editable column, | 285 | /*Check the rest of the current row for an editable column, |
286 | *if that fails, check the entire next/previous row. The | 286 | *if that fails, check the entire next/previous row. The |
287 | *last case goes back to the first item in the current branch | 287 | *last case goes back to the first item in the current branch |
288 | *or the last item in the current branch depending on the | 288 | *or the last item in the current branch depending on the |
289 | *direction. | 289 | *direction. |
290 | */ | 290 | */ |
291 | /*US | 291 | /*US |
292 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || | 292 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || |
293 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || | 293 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || |
294 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) | 294 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) |
295 | { | 295 | { |
296 | if (pi) | 296 | if (pi) |
297 | { | 297 | { |
298 | p->setCurrentItem(pi); //Calls terminate | 298 | p->setCurrentItem(pi); //Calls terminate |
299 | p->rename(pi, column); | 299 | p->rename(pi, column); |
300 | */ | 300 | */ |
301 | /*Some listviews may override rename() to | 301 | /*Some listviews may override rename() to |
302 | *prevent certain items from being renamed, | 302 | *prevent certain items from being renamed, |
303 | *if this is done, [m_]item will be NULL | 303 | *if this is done, [m_]item will be NULL |
304 | *after the rename() call... try again. | 304 | *after the rename() call... try again. |
305 | */ | 305 | */ |
306 | /*US | 306 | /*US |
307 | if (!item) | 307 | if (!item) |
308 | continue; | 308 | continue; |
309 | 309 | ||
310 | break; | 310 | break; |
311 | } | 311 | } |
312 | } | 312 | } |
313 | } | 313 | } |
314 | while (pi && !item); | 314 | while (pi && !item); |
315 | } | 315 | } |
316 | */ | 316 | */ |
317 | 317 | ||
318 | /*US | 318 | /*US |
319 | #ifdef KeyPress | 319 | #ifdef KeyPress |
320 | #undef KeyPress | 320 | #undef KeyPress |
321 | #endif | 321 | #endif |
322 | 322 | ||
323 | bool KListViewLineEdit::event (QEvent *pe) | 323 | bool KListViewLineEdit::event (QEvent *pe) |
324 | { | 324 | { |
325 | if (pe->type() == QEvent::KeyPress) | 325 | if (pe->type() == QEvent::KeyPress) |
326 | { | 326 | { |
327 | QKeyEvent *k = (QKeyEvent *) pe; | 327 | QKeyEvent *k = (QKeyEvent *) pe; |
328 | 328 | ||
329 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && | 329 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && |
330 | p->tabOrderedRenaming() && p->itemsRenameable() && | 330 | p->tabOrderedRenaming() && p->itemsRenameable() && |
331 | !(k->state() & ControlButton || k->state() & AltButton)) | 331 | !(k->state() & ControlButton || k->state() & AltButton)) |
332 | { | 332 | { |
333 | selectNextCell(item, col, | 333 | selectNextCell(item, col, |
334 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); | 334 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); |
335 | return true; | 335 | return true; |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | return KLineEdit::event(pe); | 339 | return KLineEdit::event(pe); |
340 | } | 340 | } |
341 | 341 | ||
342 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) | 342 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) |
343 | { | 343 | { |
344 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) | 344 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) |
345 | terminate(true); | 345 | terminate(true); |
346 | else if(e->key() == Qt::Key_Escape) | 346 | else if(e->key() == Qt::Key_Escape) |
347 | terminate(false); | 347 | terminate(false); |
348 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) | 348 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) |
349 | { | 349 | { |
350 | terminate(true); | 350 | terminate(true); |
351 | KLineEdit::keyPressEvent(e); | 351 | KLineEdit::keyPressEvent(e); |
352 | } | 352 | } |
353 | else | 353 | else |
354 | KLineEdit::keyPressEvent(e); | 354 | KLineEdit::keyPressEvent(e); |
355 | } | 355 | } |
356 | 356 | ||
357 | void KListViewLineEdit::terminate() | 357 | void KListViewLineEdit::terminate() |
358 | { | 358 | { |
359 | terminate(true); | 359 | terminate(true); |
360 | } | 360 | } |
361 | 361 | ||
362 | void KListViewLineEdit::terminate(bool commit) | 362 | void KListViewLineEdit::terminate(bool commit) |
363 | { | 363 | { |
364 | if ( item ) | 364 | if ( item ) |
365 | { | 365 | { |
366 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; | 366 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; |
367 | if (commit) | 367 | if (commit) |
368 | item->setText(col, text()); | 368 | item->setText(col, text()); |
369 | int c=col; | 369 | int c=col; |
370 | QListViewItem *i=item; | 370 | QListViewItem *i=item; |
371 | col=0; | 371 | col=0; |
372 | item=0; | 372 | item=0; |
373 | hide(); // will call focusOutEvent, that's why we set item=0 before | 373 | hide(); // will call focusOutEvent, that's why we set item=0 before |
374 | emit done(i,c); | 374 | emit done(i,c); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) | 378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) |
379 | { | 379 | { |
380 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); | 380 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); |
381 | // Don't let a RMB close the editor | 381 | // Don't let a RMB close the editor |
382 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) | 382 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) |
383 | terminate(true); | 383 | terminate(true); |
384 | } | 384 | } |
385 | 385 | ||
386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) | 386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) |
387 | { | 387 | { |
388 | KLineEdit::paintEvent( e ); | 388 | KLineEdit::paintEvent( e ); |
389 | 389 | ||
390 | if ( !frame() ) { | 390 | if ( !frame() ) { |
391 | QPainter p( this ); | 391 | QPainter p( this ); |
392 | p.setClipRegion( e->region() ); | 392 | p.setClipRegion( e->region() ); |
393 | p.drawRect( rect() ); | 393 | p.drawRect( rect() ); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | 396 | ||
397 | // selection changed -> terminate. As our "item" can be already deleted, | 397 | // selection changed -> terminate. As our "item" can be already deleted, |
398 | // we can't call terminate(false), because that would emit done() with | 398 | // we can't call terminate(false), because that would emit done() with |
399 | // a dangling pointer to "item". | 399 | // a dangling pointer to "item". |
400 | void KListViewLineEdit::slotSelectionChanged() | 400 | void KListViewLineEdit::slotSelectionChanged() |
401 | { | 401 | { |
402 | item = 0; | 402 | item = 0; |
403 | col = 0; | 403 | col = 0; |
404 | hide(); | 404 | hide(); |
405 | } | 405 | } |
406 | */ | 406 | */ |
407 | 407 | ||
408 | KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) | 408 | KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) |
409 | : QListView( parent, name ), | 409 | : QListView( parent, name ), |
410 | d (new KListViewPrivate (this)) | 410 | d (new KListViewPrivate (this)) |
411 | { | 411 | { |
412 | #ifndef DESKTOP_VERSION | 412 | #ifndef DESKTOP_VERSION |
413 | if ( emulateRightMouse ) | 413 | if ( emulateRightMouse ) |
414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
415 | #endif | 415 | #endif |
416 | //US setDragAutoScroll(true); | 416 | //US setDragAutoScroll(true); |
417 | 417 | ||
418 | connect( this, SIGNAL( onViewport() ), | 418 | connect( this, SIGNAL( onViewport() ), |
419 | this, SLOT( slotOnViewport() ) ); | 419 | this, SLOT( slotOnViewport() ) ); |
420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), | 420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), |
421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); | 421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); |
422 | 422 | ||
423 | connect (this, SIGNAL(contentsMoving(int,int)), | 423 | connect (this, SIGNAL(contentsMoving(int,int)), |
424 | this, SLOT(cleanDropVisualizer())); | 424 | this, SLOT(cleanDropVisualizer())); |
425 | connect (this, SIGNAL(contentsMoving(int,int)), | 425 | connect (this, SIGNAL(contentsMoving(int,int)), |
426 | this, SLOT(cleanItemHighlighter())); | 426 | this, SLOT(cleanItemHighlighter())); |
427 | 427 | ||
428 | /*US | 428 | /*US |
429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); | 429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); |
430 | 430 | ||
431 | if (kapp) | 431 | if (kapp) |
432 | { | 432 | { |
433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); | 433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); |
434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); | 434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); |
435 | } | 435 | } |
436 | */ | 436 | */ |
437 | slotSettingsChanged(1); //US do this to initialize the connections | 437 | slotSettingsChanged(1); //US do this to initialize the connections |
438 | 438 | ||
439 | 439 | ||
440 | connect(&d->autoSelect, SIGNAL( timeout() ), | 440 | connect(&d->autoSelect, SIGNAL( timeout() ), |
441 | this, SLOT( slotAutoSelect() ) ); | 441 | this, SLOT( slotAutoSelect() ) ); |
442 | connect(&d->dragExpand, SIGNAL( timeout() ), | 442 | connect(&d->dragExpand, SIGNAL( timeout() ), |
443 | this, SLOT( slotDragExpand() ) ); | 443 | this, SLOT( slotDragExpand() ) ); |
444 | 444 | ||
445 | // context menu handling | 445 | // context menu handling |
446 | if (d->showContextMenusOnPress) | 446 | if (d->showContextMenusOnPress) |
447 | { | 447 | { |
448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
450 | } | 450 | } |
451 | else | 451 | else |
452 | { | 452 | { |
453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
455 | } | 455 | } |
456 | 456 | ||
457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), | 457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), |
458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); | 458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); |
459 | 459 | ||
460 | 460 | ||
461 | //qDebug("KListView::KListView make alternate color configurable"); | 461 | //qDebug("KListView::KListView make alternate color configurable"); |
462 | //US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); | 462 | d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); |
463 | d->alternateBackground = QColor(240, 240, 240); | ||
464 | } | 463 | } |
465 | 464 | ||
466 | 465 | ||
467 | 466 | ||
468 | KListView::~KListView() | 467 | KListView::~KListView() |
469 | { | 468 | { |
470 | delete d; | 469 | delete d; |
471 | } | 470 | } |
472 | 471 | ||
473 | bool KListView::isExecuteArea( const QPoint& point ) | 472 | bool KListView::isExecuteArea( const QPoint& point ) |
474 | { | 473 | { |
475 | if ( itemAt( point ) ) | 474 | if ( itemAt( point ) ) |
476 | return isExecuteArea( point.x() ); | 475 | return isExecuteArea( point.x() ); |
477 | 476 | ||
478 | return false; | 477 | return false; |
479 | } | 478 | } |
480 | 479 | ||
481 | bool KListView::isExecuteArea( int x ) | 480 | bool KListView::isExecuteArea( int x ) |
482 | { | 481 | { |
483 | if( allColumnsShowFocus() ) | 482 | if( allColumnsShowFocus() ) |
484 | return true; | 483 | return true; |
485 | else { | 484 | else { |
486 | int offset = 0; | 485 | int offset = 0; |
487 | int width = columnWidth( 0 ); | 486 | int width = columnWidth( 0 ); |
488 | int pos = header()->mapToIndex( 0 ); | 487 | int pos = header()->mapToIndex( 0 ); |
489 | 488 | ||
490 | for ( int index = 0; index < pos; index++ ) | 489 | for ( int index = 0; index < pos; index++ ) |
491 | offset += columnWidth( header()->mapToSection( index ) ); | 490 | offset += columnWidth( header()->mapToSection( index ) ); |
492 | 491 | ||
493 | x += contentsX(); // in case of a horizontal scrollbar | 492 | x += contentsX(); // in case of a horizontal scrollbar |
494 | return ( x > offset && x < ( offset + width ) ); | 493 | return ( x > offset && x < ( offset + width ) ); |
495 | } | 494 | } |
496 | } | 495 | } |
497 | 496 | ||
498 | void KListView::slotOnItem( QListViewItem *item ) | 497 | void KListView::slotOnItem( QListViewItem *item ) |
499 | { | 498 | { |
500 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); | 499 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); |
501 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { | 500 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { |
502 | d->autoSelect.start( d->autoSelectDelay, true ); | 501 | d->autoSelect.start( d->autoSelectDelay, true ); |
503 | d->pCurrentItem = item; | 502 | d->pCurrentItem = item; |
504 | } | 503 | } |
505 | } | 504 | } |
506 | 505 | ||
507 | void KListView::slotOnViewport() | 506 | void KListView::slotOnViewport() |
508 | { | 507 | { |
509 | if ( d->bChangeCursorOverItem ) | 508 | if ( d->bChangeCursorOverItem ) |
510 | viewport()->unsetCursor(); | 509 | viewport()->unsetCursor(); |
511 | 510 | ||
512 | d->autoSelect.stop(); | 511 | d->autoSelect.stop(); |
513 | d->pCurrentItem = 0L; | 512 | d->pCurrentItem = 0L; |
514 | } | 513 | } |
515 | 514 | ||
516 | void KListView::slotSettingsChanged(int category) | 515 | void KListView::slotSettingsChanged(int category) |
517 | { | 516 | { |
518 | //qDebug("KListView::slotSettingsChanged has to be verified"); | 517 | //qDebug("KListView::slotSettingsChanged has to be verified"); |
519 | 518 | ||
520 | 519 | ||
521 | switch (category) | 520 | switch (category) |
522 | { | 521 | { |
523 | //US I create my private category (=1) to set the settings | 522 | //US I create my private category (=1) to set the settings |
524 | case 1: | 523 | case 1: |
525 | d->dragDelay = 2; | 524 | d->dragDelay = 2; |
526 | //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); | 525 | //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); |
527 | // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); | 526 | // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); |
528 | 527 | ||
529 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 528 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
530 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 529 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
531 | 530 | ||
532 | if( d->bUseSingle ) | 531 | if( d->bUseSingle ) |
533 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 532 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
534 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 533 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
535 | 534 | ||
536 | //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 535 | //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
537 | //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 536 | //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
538 | 537 | ||
539 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 538 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
540 | viewport()->unsetCursor(); | 539 | viewport()->unsetCursor(); |
541 | 540 | ||
542 | break; | 541 | break; |
543 | 542 | ||
544 | /*US | 543 | /*US |
545 | case KApplication::SETTINGS_MOUSE: | 544 | case KApplication::SETTINGS_MOUSE: |
546 | d->dragDelay = KGlobalSettings::dndEventDelay(); | 545 | d->dragDelay = KGlobalSettings::dndEventDelay(); |
547 | d->bUseSingle = KGlobalSettings::singleClick(); | 546 | d->bUseSingle = KGlobalSettings::singleClick(); |
548 | 547 | ||
549 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 548 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
550 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 549 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
551 | 550 | ||
552 | if( d->bUseSingle ) | 551 | if( d->bUseSingle ) |
553 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 552 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
554 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 553 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
555 | 554 | ||
556 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 555 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
557 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 556 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
558 | 557 | ||
559 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 558 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
560 | viewport()->unsetCursor(); | 559 | viewport()->unsetCursor(); |
561 | 560 | ||
562 | break; | 561 | break; |
563 | case KApplication::SETTINGS_POPUPMENU: | 562 | case KApplication::SETTINGS_POPUPMENU: |
564 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); | 563 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); |
565 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); | 564 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); |
566 | 565 | ||
567 | if (d->showContextMenusOnPress) | 566 | if (d->showContextMenusOnPress) |
568 | { | 567 | { |
569 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 568 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
570 | 569 | ||
571 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 570 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
572 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 571 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
573 | } | 572 | } |
574 | else | 573 | else |
575 | { | 574 | { |
576 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 575 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
577 | 576 | ||
578 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 577 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
579 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 578 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
580 | } | 579 | } |
581 | break; | 580 | break; |
582 | */ | 581 | */ |
583 | 582 | ||
584 | default: | 583 | default: |
585 | break; | 584 | break; |
586 | } | 585 | } |
587 | 586 | ||
588 | } | 587 | } |
589 | 588 | ||
590 | void KListView::slotAutoSelect() | 589 | void KListView::slotAutoSelect() |
591 | { | 590 | { |
592 | // check that the item still exists | 591 | // check that the item still exists |
593 | if( itemIndex( d->pCurrentItem ) == -1 ) | 592 | if( itemIndex( d->pCurrentItem ) == -1 ) |
594 | return; | 593 | return; |
595 | 594 | ||
596 | if (!isActiveWindow()) | 595 | if (!isActiveWindow()) |
597 | { | 596 | { |
598 | d->autoSelect.stop(); | 597 | d->autoSelect.stop(); |
599 | return; | 598 | return; |
600 | } | 599 | } |
601 | 600 | ||
602 | //Give this widget the keyboard focus. | 601 | //Give this widget the keyboard focus. |
603 | if( !hasFocus() ) | 602 | if( !hasFocus() ) |
604 | setFocus(); | 603 | setFocus(); |
605 | 604 | ||
606 | QListViewItem* previousItem = currentItem(); | 605 | QListViewItem* previousItem = currentItem(); |
607 | setCurrentItem( d->pCurrentItem ); | 606 | setCurrentItem( d->pCurrentItem ); |
608 | 607 | ||
609 | #if 0 | 608 | #if 0 |
610 | #ifndef Q_WS_QWS | 609 | #ifndef Q_WS_QWS |
611 | // FIXME(E): Implement for Qt Embedded | 610 | // FIXME(E): Implement for Qt Embedded |
612 | if( d->pCurrentItem ) { | 611 | if( d->pCurrentItem ) { |
613 | //Shift pressed? | 612 | //Shift pressed? |
614 | if( (keybstate & ShiftMask) ) { | 613 | if( (keybstate & ShiftMask) ) { |
615 | bool block = signalsBlocked(); | 614 | bool block = signalsBlocked(); |
616 | blockSignals( true ); | 615 | blockSignals( true ); |
617 | 616 | ||
618 | //No Ctrl? Then clear before! | 617 | //No Ctrl? Then clear before! |
619 | if( !(keybstate & ControlMask) ) | 618 | if( !(keybstate & ControlMask) ) |
620 | clearSelection(); | 619 | clearSelection(); |
621 | 620 | ||
622 | bool select = !d->pCurrentItem->isSelected(); | 621 | bool select = !d->pCurrentItem->isSelected(); |
623 | bool update = viewport()->isUpdatesEnabled(); | 622 | bool update = viewport()->isUpdatesEnabled(); |
624 | viewport()->setUpdatesEnabled( false ); | 623 | viewport()->setUpdatesEnabled( false ); |
625 | 624 | ||
626 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); | 625 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); |
627 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); | 626 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); |
628 | for ( ; lit.current(); ++lit ) { | 627 | for ( ; lit.current(); ++lit ) { |
629 | if ( down && lit.current() == d->pCurrentItem ) { | 628 | if ( down && lit.current() == d->pCurrentItem ) { |
630 | d->pCurrentItem->setSelected( select ); | 629 | d->pCurrentItem->setSelected( select ); |
631 | break; | 630 | break; |
632 | } | 631 | } |
633 | if ( !down && lit.current() == previousItem ) { | 632 | if ( !down && lit.current() == previousItem ) { |
634 | previousItem->setSelected( select ); | 633 | previousItem->setSelected( select ); |
635 | break; | 634 | break; |
636 | } | 635 | } |
637 | lit.current()->setSelected( select ); | 636 | lit.current()->setSelected( select ); |
638 | } | 637 | } |
639 | 638 | ||
640 | blockSignals( block ); | 639 | blockSignals( block ); |
641 | viewport()->setUpdatesEnabled( update ); | 640 | viewport()->setUpdatesEnabled( update ); |
642 | triggerUpdate(); | 641 | triggerUpdate(); |
643 | 642 | ||
644 | emit selectionChanged(); | 643 | emit selectionChanged(); |
645 | 644 | ||
646 | if( selectionMode() == QListView::Single ) | 645 | if( selectionMode() == QListView::Single ) |
647 | emit selectionChanged( d->pCurrentItem ); | 646 | emit selectionChanged( d->pCurrentItem ); |
648 | } | 647 | } |
649 | else if( (keybstate & ControlMask) ) | 648 | else if( (keybstate & ControlMask) ) |
650 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); | 649 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); |
651 | else { | 650 | else { |
652 | bool block = signalsBlocked(); | 651 | bool block = signalsBlocked(); |
653 | blockSignals( true ); | 652 | blockSignals( true ); |
654 | 653 | ||
655 | if( !d->pCurrentItem->isSelected() ) | 654 | if( !d->pCurrentItem->isSelected() ) |
656 | clearSelection(); | 655 | clearSelection(); |
657 | 656 | ||
658 | blockSignals( block ); | 657 | blockSignals( block ); |
659 | 658 | ||
660 | setSelected( d->pCurrentItem, true ); | 659 | setSelected( d->pCurrentItem, true ); |
661 | } | 660 | } |
662 | } | 661 | } |
663 | else | 662 | else |
664 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; | 663 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; |
665 | #endif | 664 | #endif |
666 | #endif | 665 | #endif |
667 | } | 666 | } |
668 | 667 | ||
669 | void KListView::slotHeaderChanged() | 668 | void KListView::slotHeaderChanged() |
670 | { | 669 | { |
671 | if (d->fullWidth && columns()) | 670 | if (d->fullWidth && columns()) |
672 | { | 671 | { |
673 | int w = 0; | 672 | int w = 0; |
674 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); | 673 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); |
675 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); | 674 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); |
676 | } | 675 | } |
677 | } | 676 | } |
678 | 677 | ||
679 | void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) | 678 | void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) |
680 | { | 679 | { |
681 | // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); | 680 | // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); |
682 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { | 681 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { |
683 | 682 | ||
684 | // Double click mode ? | 683 | // Double click mode ? |
685 | if ( !d->bUseSingle ) | 684 | if ( !d->bUseSingle ) |
686 | { | 685 | { |
687 | emit executed( item ); | 686 | emit executed( item ); |
688 | emit executed( item, pos, c ); | 687 | emit executed( item, pos, c ); |
689 | } | 688 | } |
690 | else | 689 | else |
691 | { | 690 | { |
692 | //US special implementation for embedded systems | 691 | //US special implementation for embedded systems |
693 | d->autoSelect.stop(); | 692 | d->autoSelect.stop(); |
694 | 693 | ||
695 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed | 694 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed |
696 | if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { | 695 | if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { |
697 | // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { | 696 | // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { |
698 | 697 | ||
699 | emit executed( item ); | 698 | emit executed( item ); |
700 | emit executed( item, pos, c ); | 699 | emit executed( item, pos, c ); |
701 | } | 700 | } |
702 | } | 701 | } |
703 | } | 702 | } |
704 | } | 703 | } |
705 | 704 | ||
706 | void KListView::focusInEvent( QFocusEvent *fe ) | 705 | void KListView::focusInEvent( QFocusEvent *fe ) |
707 | { | 706 | { |
708 | // kdDebug()<<"KListView::focusInEvent()"<<endl; | 707 | // kdDebug()<<"KListView::focusInEvent()"<<endl; |
709 | QListView::focusInEvent( fe ); | 708 | QListView::focusInEvent( fe ); |
710 | if ((d->selectedBySimpleMove) | 709 | if ((d->selectedBySimpleMove) |
711 | && (d->selectionMode == FileManager) | 710 | && (d->selectionMode == FileManager) |
712 | && (fe->reason()!=QFocusEvent::Popup) | 711 | && (fe->reason()!=QFocusEvent::Popup) |
713 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 712 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
714 | && (currentItem()!=0)) | 713 | && (currentItem()!=0)) |
715 | { | 714 | { |
716 | currentItem()->setSelected(true); | 715 | currentItem()->setSelected(true); |
717 | currentItem()->repaint(); | 716 | currentItem()->repaint(); |
718 | emit selectionChanged(); | 717 | emit selectionChanged(); |
719 | }; | 718 | }; |
720 | } | 719 | } |
721 | 720 | ||
722 | void KListView::focusOutEvent( QFocusEvent *fe ) | 721 | void KListView::focusOutEvent( QFocusEvent *fe ) |
723 | { | 722 | { |
724 | cleanDropVisualizer(); | 723 | cleanDropVisualizer(); |
725 | cleanItemHighlighter(); | 724 | cleanItemHighlighter(); |
726 | 725 | ||
727 | d->autoSelect.stop(); | 726 | d->autoSelect.stop(); |
728 | 727 | ||
729 | if ((d->selectedBySimpleMove) | 728 | if ((d->selectedBySimpleMove) |
730 | && (d->selectionMode == FileManager) | 729 | && (d->selectionMode == FileManager) |
731 | && (fe->reason()!=QFocusEvent::Popup) | 730 | && (fe->reason()!=QFocusEvent::Popup) |
732 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 731 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
733 | && (currentItem()!=0) | 732 | && (currentItem()!=0) |
734 | /*US && (!d->editor->isVisible()) */ | 733 | /*US && (!d->editor->isVisible()) */ |
735 | ) | 734 | ) |
736 | { | 735 | { |
737 | currentItem()->setSelected(false); | 736 | currentItem()->setSelected(false); |
738 | currentItem()->repaint(); | 737 | currentItem()->repaint(); |
739 | emit selectionChanged(); | 738 | emit selectionChanged(); |
740 | }; | 739 | }; |
741 | 740 | ||
742 | QListView::focusOutEvent( fe ); | 741 | QListView::focusOutEvent( fe ); |
743 | } | 742 | } |
744 | 743 | ||
745 | void KListView::leaveEvent( QEvent *e ) | 744 | void KListView::leaveEvent( QEvent *e ) |
746 | { | 745 | { |
747 | d->autoSelect.stop(); | 746 | d->autoSelect.stop(); |
748 | 747 | ||
749 | QListView::leaveEvent( e ); | 748 | QListView::leaveEvent( e ); |
750 | } | 749 | } |
751 | 750 | ||
752 | bool KListView::event( QEvent *e ) | 751 | bool KListView::event( QEvent *e ) |
753 | { | 752 | { |
754 | if (e->type() == QEvent::ApplicationPaletteChange) { | 753 | if (e->type() == QEvent::ApplicationPaletteChange) { |
755 | //qDebug("KListView::event make alternate color configurable"); | 754 | //qDebug("KListView::event make alternate color configurable"); |
756 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); | 755 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); |
757 | d->alternateBackground = QColor(240, 240, 240); | 756 | d->alternateBackground = QColor(240, 240, 240); |
758 | } | 757 | } |
759 | 758 | ||
760 | return QListView::event(e); | 759 | return QListView::event(e); |
761 | } | 760 | } |
762 | 761 | ||
763 | void KListView::contentsMousePressEvent( QMouseEvent *e ) | 762 | void KListView::contentsMousePressEvent( QMouseEvent *e ) |
764 | { | 763 | { |
765 | //qDebug("KListView::contentsMousePressEvent"); | 764 | //qDebug("KListView::contentsMousePressEvent"); |
766 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) | 765 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) |
767 | { | 766 | { |
768 | bool block = signalsBlocked(); | 767 | bool block = signalsBlocked(); |
769 | blockSignals( true ); | 768 | blockSignals( true ); |
770 | 769 | ||
771 | clearSelection(); | 770 | clearSelection(); |
772 | 771 | ||
773 | blockSignals( block ); | 772 | blockSignals( block ); |
774 | } | 773 | } |
775 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) | 774 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) |
776 | { | 775 | { |
777 | d->selectedBySimpleMove=false; | 776 | d->selectedBySimpleMove=false; |
778 | d->selectedUsingMouse=true; | 777 | d->selectedUsingMouse=true; |
779 | if (currentItem()!=0) | 778 | if (currentItem()!=0) |
780 | { | 779 | { |
781 | currentItem()->setSelected(false); | 780 | currentItem()->setSelected(false); |
782 | currentItem()->repaint(); | 781 | currentItem()->repaint(); |
783 | // emit selectionChanged(); | 782 | // emit selectionChanged(); |
784 | }; | 783 | }; |
785 | }; | 784 | }; |
786 | 785 | ||
787 | QPoint p( contentsToViewport( e->pos() ) ); | 786 | QPoint p( contentsToViewport( e->pos() ) ); |
788 | QListViewItem *at = itemAt (p); | 787 | QListViewItem *at = itemAt (p); |
789 | 788 | ||
790 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 789 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
791 | bool rootDecoClicked = at | 790 | bool rootDecoClicked = at |
792 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 791 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
793 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 792 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
794 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 793 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
795 | 794 | ||
796 | if (e->button() == LeftButton && !rootDecoClicked) | 795 | if (e->button() == LeftButton && !rootDecoClicked) |
797 | { | 796 | { |
798 | //Start a drag | 797 | //Start a drag |
799 | d->startDragPos = e->pos(); | 798 | d->startDragPos = e->pos(); |
800 | 799 | ||
801 | if (at) | 800 | if (at) |
802 | { | 801 | { |
803 | d->validDrag = true; | 802 | d->validDrag = true; |
804 | d->pressedOnSelected = at->isSelected(); | 803 | d->pressedOnSelected = at->isSelected(); |
805 | } | 804 | } |
806 | } | 805 | } |
807 | 806 | ||
808 | QListView::contentsMousePressEvent( e ); | 807 | QListView::contentsMousePressEvent( e ); |
809 | } | 808 | } |
810 | 809 | ||
811 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) | 810 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) |
812 | { | 811 | { |
813 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { | 812 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { |
814 | QListView::contentsMouseMoveEvent (e); | 813 | QListView::contentsMouseMoveEvent (e); |
815 | return; | 814 | return; |
816 | } | 815 | } |
817 | 816 | ||
818 | QPoint vp = contentsToViewport(e->pos()); | 817 | QPoint vp = contentsToViewport(e->pos()); |
819 | QListViewItem *item = itemAt( vp ); | 818 | QListViewItem *item = itemAt( vp ); |
820 | 819 | ||
821 | //do we process cursor changes at all? | 820 | //do we process cursor changes at all? |
822 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) | 821 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) |
823 | { | 822 | { |
824 | //Cursor moved on a new item or in/out the execute area | 823 | //Cursor moved on a new item or in/out the execute area |
825 | if( (item != d->pCurrentItem) || | 824 | if( (item != d->pCurrentItem) || |
826 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) | 825 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) |
827 | { | 826 | { |
828 | d->cursorInExecuteArea = isExecuteArea(vp); | 827 | d->cursorInExecuteArea = isExecuteArea(vp); |
829 | //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); | 828 | //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); |
830 | /*US | 829 | /*US |
831 | if( d->cursorInExecuteArea ) //cursor moved in execute area | 830 | if( d->cursorInExecuteArea ) //cursor moved in execute area |
832 | viewport()->setCursor( KCursor::handCursor() ); | 831 | viewport()->setCursor( KCursor::handCursor() ); |
833 | else //cursor moved out of execute area | 832 | else //cursor moved out of execute area |
834 | viewport()->unsetCursor(); | 833 | viewport()->unsetCursor(); |
835 | */ | 834 | */ |
836 | } | 835 | } |
837 | } | 836 | } |
838 | 837 | ||
839 | bool dragOn = dragEnabled(); | 838 | bool dragOn = dragEnabled(); |
840 | QPoint newPos = e->pos(); | 839 | QPoint newPos = e->pos(); |
841 | if (dragOn && d->validDrag && | 840 | if (dragOn && d->validDrag && |
842 | (newPos.x() > d->startDragPos.x()+d->dragDelay || | 841 | (newPos.x() > d->startDragPos.x()+d->dragDelay || |
843 | newPos.x() < d->startDragPos.x()-d->dragDelay || | 842 | newPos.x() < d->startDragPos.x()-d->dragDelay || |
844 | newPos.y() > d->startDragPos.y()+d->dragDelay || | 843 | newPos.y() > d->startDragPos.y()+d->dragDelay || |
845 | newPos.y() < d->startDragPos.y()-d->dragDelay)) | 844 | newPos.y() < d->startDragPos.y()-d->dragDelay)) |
846 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) | 845 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) |
847 | { | 846 | { |
diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp index b65ce66..92a2b48 100644 --- a/microkde/kglobalsettings.cpp +++ b/microkde/kglobalsettings.cpp | |||
@@ -1,77 +1,86 @@ | |||
1 | #include "kglobalsettings.h" | 1 | #include "kglobalsettings.h" |
2 | #include "kconfig.h" | 2 | #include "kconfig.h" |
3 | #include "kglobal.h" | 3 | #include "kglobal.h" |
4 | #include "kconfigbase.h" | 4 | #include "kconfigbase.h" |
5 | 5 | ||
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | 7 | ||
8 | QFont KGlobalSettings::generalFont() | 8 | QFont KGlobalSettings::generalFont() |
9 | { | 9 | { |
10 | int size = 12; | 10 | int size = 12; |
11 | if (QApplication::desktop()->width() < 480 ) { | 11 | if (QApplication::desktop()->width() < 480 ) { |
12 | size = 10; | 12 | size = 10; |
13 | } | 13 | } |
14 | #ifndef DESKTOP_VERSION | 14 | #ifndef DESKTOP_VERSION |
15 | else | 15 | else |
16 | if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) | 16 | if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) |
17 | size = 18; | 17 | size = 18; |
18 | #endif | 18 | #endif |
19 | QFont f = QApplication::font(); | 19 | QFont f = QApplication::font(); |
20 | //qDebug("pointsize %d %s", f.pointSize(),f.family().latin1()); | 20 | //qDebug("pointsize %d %s", f.pointSize(),f.family().latin1()); |
21 | f.setPointSize( size ); | 21 | f.setPointSize( size ); |
22 | return f; | 22 | return f; |
23 | } | 23 | } |
24 | QFont KGlobalSettings::generalMaxFont() | 24 | QFont KGlobalSettings::generalMaxFont() |
25 | { | 25 | { |
26 | int size = 12; | 26 | int size = 12; |
27 | if (QApplication::desktop()->width() < 480 ) { | 27 | if (QApplication::desktop()->width() < 480 ) { |
28 | size = 10; | 28 | size = 10; |
29 | } | 29 | } |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | else | 31 | else |
32 | if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) | 32 | if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) |
33 | size = 18; | 33 | size = 18; |
34 | #endif | 34 | #endif |
35 | QFont f = QApplication::font(); | 35 | QFont f = QApplication::font(); |
36 | if ( f.pointSize() > size ) | 36 | if ( f.pointSize() > size ) |
37 | f.setPointSize( size ); | 37 | f.setPointSize( size ); |
38 | return f; | 38 | return f; |
39 | } | 39 | } |
40 | 40 | ||
41 | QString KGlobalSettings::timeTrackerDir() | 41 | QString KGlobalSettings::timeTrackerDir() |
42 | { | 42 | { |
43 | static QString dir; | 43 | static QString dir; |
44 | if ( dir.isEmpty() ) { | 44 | if ( dir.isEmpty() ) { |
45 | dir = locateLocal( "data", "timetrackerdir/d.ttl" ); | 45 | dir = locateLocal( "data", "timetrackerdir/d.ttl" ); |
46 | dir = dir.left ( dir.length() - 5); | 46 | dir = dir.left ( dir.length() - 5); |
47 | } | 47 | } |
48 | return dir; | 48 | return dir; |
49 | } | 49 | } |
50 | 50 | ||
51 | QFont KGlobalSettings::toolBarFont() | 51 | QFont KGlobalSettings::toolBarFont() |
52 | { | 52 | { |
53 | return QApplication::font(); | 53 | return QApplication::font(); |
54 | } | 54 | } |
55 | 55 | ||
56 | QColor KGlobalSettings::toolBarHighlightColor() | 56 | QColor KGlobalSettings::toolBarHighlightColor() |
57 | { | 57 | { |
58 | return QColor( "black" ); | 58 | return QColor( "black" ); |
59 | } | 59 | } |
60 | 60 | ||
61 | QColor KGlobalSettings::alternateBackgroundColor() | ||
62 | { | ||
63 | #ifdef DESKTOP_VERSION | ||
64 | return QColor( 235, 235, 235 ); | ||
65 | #else | ||
66 | return QColor( 220, 220, 220 ); | ||
67 | #endif | ||
68 | } | ||
69 | |||
61 | QRect KGlobalSettings::desktopGeometry( QWidget * ) | 70 | QRect KGlobalSettings::desktopGeometry( QWidget * ) |
62 | { | 71 | { |
63 | return QApplication::desktop()->rect(); | 72 | return QApplication::desktop()->rect(); |
64 | } | 73 | } |
65 | 74 | ||
66 | /** | 75 | /** |
67 | * Returns whether KDE runs in single (default) or double click | 76 | * Returns whether KDE runs in single (default) or double click |
68 | * mode. | 77 | * mode. |
69 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html | 78 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html |
70 | * @return true if single click mode, or false if double click mode. | 79 | * @return true if single click mode, or false if double click mode. |
71 | **/ | 80 | **/ |
72 | bool KGlobalSettings::singleClick() | 81 | bool KGlobalSettings::singleClick() |
73 | { | 82 | { |
74 | KConfig *c = KGlobal::config(); | 83 | KConfig *c = KGlobal::config(); |
75 | KConfigGroupSaver cgs( c, "KDE" ); | 84 | KConfigGroupSaver cgs( c, "KDE" ); |
76 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); | 85 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); |
77 | } | 86 | } |
diff --git a/microkde/kglobalsettings.h b/microkde/kglobalsettings.h index 3eeda35..e2620b3 100644 --- a/microkde/kglobalsettings.h +++ b/microkde/kglobalsettings.h | |||
@@ -1,32 +1,33 @@ | |||
1 | #ifndef MICROKDE_KGLOBALSETTINGS_H | 1 | #ifndef MICROKDE_KGLOBALSETTINGS_H |
2 | #define MICROKDE_KGLOBALSETTINGS_H | 2 | #define MICROKDE_KGLOBALSETTINGS_H |
3 | 3 | ||
4 | #include <qfont.h> | 4 | #include <qfont.h> |
5 | #include <qrect.h> | 5 | #include <qrect.h> |
6 | 6 | ||
7 | 7 | ||
8 | #define KDE_DEFAULT_SINGLECLICK true | 8 | #define KDE_DEFAULT_SINGLECLICK true |
9 | 9 | ||
10 | 10 | ||
11 | class KGlobalSettings | 11 | class KGlobalSettings |
12 | { | 12 | { |
13 | public: | 13 | public: |
14 | static QFont generalFont(); | 14 | static QFont generalFont(); |
15 | static QFont generalMaxFont(); | 15 | static QFont generalMaxFont(); |
16 | static QFont toolBarFont(); | 16 | static QFont toolBarFont(); |
17 | 17 | ||
18 | static QColor toolBarHighlightColor(); | 18 | static QColor toolBarHighlightColor(); |
19 | static QColor alternateBackgroundColor(); | ||
19 | static QRect desktopGeometry( QWidget * ); | 20 | static QRect desktopGeometry( QWidget * ); |
20 | static QString timeTrackerDir(); | 21 | static QString timeTrackerDir(); |
21 | 22 | ||
22 | /** | 23 | /** |
23 | * Returns whether KDE runs in single (default) or double click | 24 | * Returns whether KDE runs in single (default) or double click |
24 | * mode. | 25 | * mode. |
25 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html | 26 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html |
26 | * @return true if single click mode, or false if double click mode. | 27 | * @return true if single click mode, or false if double click mode. |
27 | **/ | 28 | **/ |
28 | static bool singleClick(); | 29 | static bool singleClick(); |
29 | 30 | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | #endif | 33 | #endif |