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