author | zautrix <zautrix> | 2005-06-30 04:58:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-30 04:58:35 (UTC) |
commit | ba4a6a95356f9a8044257c45347cee8b15667d0c (patch) (unidiff) | |
tree | 63ffa2000426f06cae7ec5be7d1847b5f9fb4e26 | |
parent | 63147898391dbeabca2dc8f48730b324c15a7498 (diff) | |
download | kdepimpi-ba4a6a95356f9a8044257c45347cee8b15667d0c.zip kdepimpi-ba4a6a95356f9a8044257c45347cee8b15667d0c.tar.gz kdepimpi-ba4a6a95356f9a8044257c45347cee8b15667d0c.tar.bz2 |
fixxx
-rw-r--r-- | microkde/kdeui/klistview.cpp | 9 | ||||
-rw-r--r-- | microkde/kdeui/klistview.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp index 25327aa..f7d2187 100644 --- a/microkde/kdeui/klistview.cpp +++ b/microkde/kdeui/klistview.cpp | |||
@@ -1,2015 +1,2024 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> | 2 | Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> |
3 | Copyright (C) 2000 Charles Samuels <charles@kde.org> | 3 | Copyright (C) 2000 Charles Samuels <charles@kde.org> |
4 | Copyright (C) 2000 Peter Putzer | 4 | Copyright (C) 2000 Peter Putzer |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License version 2 as published by the Free Software Foundation. | 8 | License version 2 as published by the Free Software Foundation. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qdragobject.h> | 21 | #include <qdragobject.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qheader.h> | 23 | #include <qheader.h> |
24 | #include <qcursor.h> | 24 | #include <qcursor.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qstyle.h> | 26 | #include <qstyle.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | 28 | ||
29 | #include <kglobalsettings.h> | 29 | #include <kglobalsettings.h> |
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | #include <kconfigbase.h> | 31 | #include <kconfigbase.h> |
32 | //US #include <kcursor.h> | 32 | //US #include <kcursor.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | //US #include <kipc.h> | 34 | //US #include <kipc.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #ifdef _WIN32_ | 36 | #ifdef _WIN32_ |
37 | #define Q_WS_QWS | 37 | #define Q_WS_QWS |
38 | #endif | 38 | #endif |
39 | #ifndef _WIN32_ | 39 | #ifndef _WIN32_ |
40 | #define private public | 40 | #define private public |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | #undef private | 42 | #undef private |
43 | #endif | 43 | #endif |
44 | #include "klistview.h" | 44 | #include "klistview.h" |
45 | //US #include "klistviewlineedit.h" | 45 | //US #include "klistviewlineedit.h" |
46 | #ifndef DESKTOP_VERSION | 46 | #ifndef DESKTOP_VERSION |
47 | #include <qpe/qpeapplication.h> | 47 | #include <qpe/qpeapplication.h> |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | // /*US | 50 | // /*US |
51 | class KListView::Tooltip : public QToolTip | 51 | class KListView::Tooltip : public QToolTip |
52 | { | 52 | { |
53 | public: | 53 | public: |
54 | Tooltip (KListView* parent, QToolTipGroup* group = 0L); | 54 | Tooltip (KListView* parent, QToolTipGroup* group = 0L); |
55 | virtual ~Tooltip () {} | 55 | virtual ~Tooltip () {} |
56 | 56 | ||
57 | protected: | 57 | protected: |
58 | // */ | 58 | // */ |
59 | /** | 59 | /** |
60 | * Reimplemented from QToolTip for internal reasons. | 60 | * Reimplemented from QToolTip for internal reasons. |
61 | */ | 61 | */ |
62 | // /*US | 62 | // /*US |
63 | virtual void maybeTip (const QPoint&); | 63 | virtual void maybeTip (const QPoint&); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | KListView* mParent; | 66 | KListView* mParent; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) | 69 | KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) |
70 | : QToolTip (parent, group), | 70 | : QToolTip (parent, group), |
71 | mParent (parent) | 71 | mParent (parent) |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void KListView::Tooltip::maybeTip (const QPoint&) | 75 | void KListView::Tooltip::maybeTip (const QPoint&) |
76 | { | 76 | { |
77 | // FIXME | 77 | // FIXME |
78 | } | 78 | } |
79 | // */ | 79 | // */ |
80 | 80 | ||
81 | class KListView::KListViewPrivate | 81 | class KListView::KListViewPrivate |
82 | { | 82 | { |
83 | public: | 83 | public: |
84 | KListViewPrivate (KListView* listview) | 84 | KListViewPrivate (KListView* listview) |
85 | : pCurrentItem (0L), | 85 | : pCurrentItem (0L), |
86 | autoSelectDelay(1), | 86 | autoSelectDelay(1), |
87 | //US dragDelay (KGlobalSettings::dndEventDelay()), | 87 | //US dragDelay (KGlobalSettings::dndEventDelay()), |
88 | 88 | ||
89 | dragDelay (10), | 89 | dragDelay (10), |
90 | //US editor (new KListViewLineEdit (listview)), | 90 | //US editor (new KListViewLineEdit (listview)), |
91 | cursorInExecuteArea(false), | 91 | cursorInExecuteArea(false), |
92 | bUseSingle(false), | 92 | bUseSingle(false), |
93 | bChangeCursorOverItem(false), | 93 | bChangeCursorOverItem(false), |
94 | itemsMovable (true), | 94 | itemsMovable (true), |
95 | selectedBySimpleMove(false), | 95 | selectedBySimpleMove(false), |
96 | selectedUsingMouse(false), | 96 | selectedUsingMouse(false), |
97 | itemsRenameable (false), | 97 | itemsRenameable (false), |
98 | validDrag (false), | 98 | validDrag (false), |
99 | dragEnabled (false), | 99 | dragEnabled (false), |
100 | autoOpen (true), | 100 | autoOpen (true), |
101 | dropVisualizer (true), | 101 | dropVisualizer (true), |
102 | dropHighlighter (false), | 102 | dropHighlighter (false), |
103 | createChildren (true), | 103 | createChildren (true), |
104 | pressedOnSelected (false), | 104 | pressedOnSelected (false), |
105 | wasShiftEvent (false), | 105 | wasShiftEvent (false), |
106 | fullWidth (false), | 106 | fullWidth (false), |
107 | sortAscending(true), | 107 | sortAscending(true), |
108 | tabRename(true), | 108 | tabRename(true), |
109 | sortColumn(0), | 109 | sortColumn(0), |
110 | selectionDirection(0), | 110 | selectionDirection(0), |
111 | tooltipColumn (0), | 111 | tooltipColumn (0), |
112 | selectionMode (Single), | 112 | selectionMode (Single), |
113 | contextMenuKey ( Qt::Key_Menu ),//KGlobalSettings::contextMenuKey()), | 113 | contextMenuKey ( Qt::Key_Menu ),//KGlobalSettings::contextMenuKey()), |
114 | showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), | 114 | showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), |
115 | mDropVisualizerWidth (4) | 115 | mDropVisualizerWidth (4) |
116 | { | 116 | { |
117 | renameable += 0; | 117 | renameable += 0; |
118 | //US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); | 118 | //US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); |
119 | } | 119 | } |
120 | 120 | ||
121 | ~KListViewPrivate () | 121 | ~KListViewPrivate () |
122 | { | 122 | { |
123 | //US delete editor; | 123 | //US delete editor; |
124 | } | 124 | } |
125 | 125 | ||
126 | QListViewItem* pCurrentItem; | 126 | QListViewItem* pCurrentItem; |
127 | 127 | ||
128 | QTimer autoSelect; | 128 | QTimer autoSelect; |
129 | int autoSelectDelay; | 129 | int autoSelectDelay; |
130 | 130 | ||
131 | QTimer dragExpand; | 131 | QTimer dragExpand; |
132 | QListViewItem* dragOverItem; | 132 | QListViewItem* dragOverItem; |
133 | QPoint dragOverPoint; | 133 | QPoint dragOverPoint; |
134 | 134 | ||
135 | QPoint startDragPos; | 135 | QPoint startDragPos; |
136 | int dragDelay; | 136 | int dragDelay; |
137 | 137 | ||
138 | //US KListViewLineEdit *editor; | 138 | //US KListViewLineEdit *editor; |
139 | QValueList<int> renameable; | 139 | QValueList<int> renameable; |
140 | 140 | ||
141 | bool cursorInExecuteArea:1; | 141 | bool cursorInExecuteArea:1; |
142 | bool bUseSingle:1; | 142 | bool bUseSingle:1; |
143 | bool bChangeCursorOverItem:1; | 143 | bool bChangeCursorOverItem:1; |
144 | bool itemsMovable:1; | 144 | bool itemsMovable:1; |
145 | bool selectedBySimpleMove : 1; | 145 | bool selectedBySimpleMove : 1; |
146 | bool selectedUsingMouse:1; | 146 | bool selectedUsingMouse:1; |
147 | bool itemsRenameable:1; | 147 | bool itemsRenameable:1; |
148 | bool validDrag:1; | 148 | bool validDrag:1; |
149 | bool dragEnabled:1; | 149 | bool dragEnabled:1; |
150 | bool autoOpen:1; | 150 | bool autoOpen:1; |
151 | bool dropVisualizer:1; | 151 | bool dropVisualizer:1; |
152 | bool dropHighlighter:1; | 152 | bool dropHighlighter:1; |
153 | bool createChildren:1; | 153 | bool createChildren:1; |
154 | bool pressedOnSelected:1; | 154 | bool pressedOnSelected:1; |
155 | bool wasShiftEvent:1; | 155 | bool wasShiftEvent:1; |
156 | bool fullWidth:1; | 156 | bool fullWidth:1; |
157 | bool sortAscending:1; | 157 | bool sortAscending:1; |
158 | bool tabRename:1; | 158 | bool tabRename:1; |
159 | 159 | ||
160 | int sortColumn; | 160 | int sortColumn; |
161 | 161 | ||
162 | //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX | 162 | //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX |
163 | int selectionDirection; | 163 | int selectionDirection; |
164 | int tooltipColumn; | 164 | int tooltipColumn; |
165 | 165 | ||
166 | SelectionModeExt selectionMode; | 166 | SelectionModeExt selectionMode; |
167 | int contextMenuKey; | 167 | int contextMenuKey; |
168 | bool showContextMenusOnPress; | 168 | bool showContextMenusOnPress; |
169 | 169 | ||
170 | QRect mOldDropVisualizer; | 170 | QRect mOldDropVisualizer; |
171 | int mDropVisualizerWidth; | 171 | int mDropVisualizerWidth; |
172 | QRect mOldDropHighlighter; | 172 | QRect mOldDropHighlighter; |
173 | QListViewItem *afterItemDrop; | 173 | QListViewItem *afterItemDrop; |
174 | QListViewItem *parentItemDrop; | 174 | QListViewItem *parentItemDrop; |
175 | 175 | ||
176 | QColor alternateBackground; | 176 | QColor alternateBackground; |
177 | }; | 177 | }; |
178 | 178 | ||
179 | /*US | 179 | /*US |
180 | KListViewLineEdit::KListViewLineEdit(KListView *parent) | 180 | KListViewLineEdit::KListViewLineEdit(KListView *parent) |
181 | : KLineEdit(parent->viewport()), item(0), col(0), p(parent) | 181 | : KLineEdit(parent->viewport()), item(0), col(0), p(parent) |
182 | { | 182 | { |
183 | setFrame( false ); | 183 | setFrame( false ); |
184 | hide(); | 184 | hide(); |
185 | connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); | 185 | connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); |
186 | } | 186 | } |
187 | 187 | ||
188 | KListViewLineEdit::~KListViewLineEdit() | 188 | KListViewLineEdit::~KListViewLineEdit() |
189 | { | 189 | { |
190 | } | 190 | } |
191 | 191 | ||
192 | void KListViewLineEdit::load(QListViewItem *i, int c) | 192 | void KListViewLineEdit::load(QListViewItem *i, int c) |
193 | { | 193 | { |
194 | item=i; | 194 | item=i; |
195 | col=c; | 195 | col=c; |
196 | 196 | ||
197 | QRect rect(p->itemRect(i)); | 197 | QRect rect(p->itemRect(i)); |
198 | setText(item->text(c)); | 198 | setText(item->text(c)); |
199 | 199 | ||
200 | int fieldX = rect.x() - 1; | 200 | int fieldX = rect.x() - 1; |
201 | int fieldW = p->columnWidth(col) + 2; | 201 | int fieldW = p->columnWidth(col) + 2; |
202 | 202 | ||
203 | int pos = p->header()->mapToIndex(col); | 203 | int pos = p->header()->mapToIndex(col); |
204 | for ( int index = 0; index < pos; index++ ) | 204 | for ( int index = 0; index < pos; index++ ) |
205 | fieldX += p->columnWidth( p->header()->mapToSection( index )); | 205 | fieldX += p->columnWidth( p->header()->mapToSection( index )); |
206 | 206 | ||
207 | if ( col == 0 ) { | 207 | if ( col == 0 ) { |
208 | int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); | 208 | int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); |
209 | d *= p->treeStepSize(); | 209 | d *= p->treeStepSize(); |
210 | fieldX += d; | 210 | fieldX += d; |
211 | fieldW -= d; | 211 | fieldW -= d; |
212 | } | 212 | } |
213 | 213 | ||
214 | if ( i->pixmap( col ) ) {// add width of pixmap | 214 | if ( i->pixmap( col ) ) {// add width of pixmap |
215 | int d = i->pixmap( col )->width(); | 215 | int d = i->pixmap( col )->width(); |
216 | fieldX += d; | 216 | fieldX += d; |
217 | fieldW -= d; | 217 | fieldW -= d; |
218 | } | 218 | } |
219 | 219 | ||
220 | setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); | 220 | setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); |
221 | show(); | 221 | show(); |
222 | setFocus(); | 222 | setFocus(); |
223 | } | 223 | } |
224 | */ | 224 | */ |
225 | /*Helper functions to for | 225 | /*Helper functions to for |
226 | *tabOrderedRename functionality. | 226 | *tabOrderedRename functionality. |
227 | */ | 227 | */ |
228 | 228 | ||
229 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) | 229 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) |
230 | { | 230 | { |
231 | if (pi) | 231 | if (pi) |
232 | { | 232 | { |
233 | //Find the next renameable column in the current row | 233 | //Find the next renameable column in the current row |
234 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) | 234 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) |
235 | if (pl->isRenameable(start)) | 235 | if (pl->isRenameable(start)) |
236 | return start; | 236 | return start; |
237 | } | 237 | } |
238 | 238 | ||
239 | return -1; | 239 | return -1; |
240 | } | 240 | } |
241 | 241 | ||
242 | static QListViewItem *prevItem (QListViewItem *pi) | 242 | static QListViewItem *prevItem (QListViewItem *pi) |
243 | { | 243 | { |
244 | QListViewItem *pa = pi->itemAbove(); | 244 | QListViewItem *pa = pi->itemAbove(); |
245 | 245 | ||
246 | /*Does what the QListViewItem::previousSibling() | 246 | /*Does what the QListViewItem::previousSibling() |
247 | *of my dreams would do. | 247 | *of my dreams would do. |
248 | */ | 248 | */ |
249 | if (pa && pa->parent() == pi->parent()) | 249 | if (pa && pa->parent() == pi->parent()) |
250 | return pa; | 250 | return pa; |
251 | 251 | ||
252 | return NULL; | 252 | return NULL; |
253 | } | 253 | } |
254 | 254 | ||
255 | static QListViewItem *lastQChild (QListViewItem *pi) | 255 | static QListViewItem *lastQChild (QListViewItem *pi) |
256 | { | 256 | { |
257 | if (pi) | 257 | if (pi) |
258 | { | 258 | { |
259 | /*Since there's no QListViewItem::lastChild(). | 259 | /*Since there's no QListViewItem::lastChild(). |
260 | *This finds the last sibling for the given | 260 | *This finds the last sibling for the given |
261 | *item. | 261 | *item. |
262 | */ | 262 | */ |
263 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) | 263 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) |
264 | pi = pt; | 264 | pi = pt; |
265 | } | 265 | } |
266 | 266 | ||
267 | return pi; | 267 | return pi; |
268 | } | 268 | } |
269 | /*US | 269 | /*US |
270 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) | 270 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) |
271 | { | 271 | { |
272 | const int ncols = p->columns(); | 272 | const int ncols = p->columns(); |
273 | const int dir = forward ? +1 : -1; | 273 | const int dir = forward ? +1 : -1; |
274 | const int restart = forward ? 0 : (ncols - 1); | 274 | const int restart = forward ? 0 : (ncols - 1); |
275 | QListViewItem *top = (pitem && pitem->parent()) | 275 | QListViewItem *top = (pitem && pitem->parent()) |
276 | ? pitem->parent()->firstChild() | 276 | ? pitem->parent()->firstChild() |
277 | : p->firstChild(); | 277 | : p->firstChild(); |
278 | QListViewItem *pi = pitem; | 278 | QListViewItem *pi = pitem; |
279 | 279 | ||
280 | terminate(); //Save current changes | 280 | terminate(); //Save current changes |
281 | 281 | ||
282 | do | 282 | do |
283 | { | 283 | { |
284 | */ | 284 | */ |
285 | /*Check the rest of the current row for an editable column, | 285 | /*Check the rest of the current row for an editable column, |
286 | *if that fails, check the entire next/previous row. The | 286 | *if that fails, check the entire next/previous row. The |
287 | *last case goes back to the first item in the current branch | 287 | *last case goes back to the first item in the current branch |
288 | *or the last item in the current branch depending on the | 288 | *or the last item in the current branch depending on the |
289 | *direction. | 289 | *direction. |
290 | */ | 290 | */ |
291 | /*US | 291 | /*US |
292 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || | 292 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || |
293 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || | 293 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || |
294 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) | 294 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) |
295 | { | 295 | { |
296 | if (pi) | 296 | if (pi) |
297 | { | 297 | { |
298 | p->setCurrentItem(pi); //Calls terminate | 298 | p->setCurrentItem(pi); //Calls terminate |
299 | p->rename(pi, column); | 299 | p->rename(pi, column); |
300 | */ | 300 | */ |
301 | /*Some listviews may override rename() to | 301 | /*Some listviews may override rename() to |
302 | *prevent certain items from being renamed, | 302 | *prevent certain items from being renamed, |
303 | *if this is done, [m_]item will be NULL | 303 | *if this is done, [m_]item will be NULL |
304 | *after the rename() call... try again. | 304 | *after the rename() call... try again. |
305 | */ | 305 | */ |
306 | /*US | 306 | /*US |
307 | if (!item) | 307 | if (!item) |
308 | continue; | 308 | continue; |
309 | 309 | ||
310 | break; | 310 | break; |
311 | } | 311 | } |
312 | } | 312 | } |
313 | } | 313 | } |
314 | while (pi && !item); | 314 | while (pi && !item); |
315 | } | 315 | } |
316 | */ | 316 | */ |
317 | 317 | ||
318 | /*US | 318 | /*US |
319 | #ifdef KeyPress | 319 | #ifdef KeyPress |
320 | #undef KeyPress | 320 | #undef KeyPress |
321 | #endif | 321 | #endif |
322 | 322 | ||
323 | bool KListViewLineEdit::event (QEvent *pe) | 323 | bool KListViewLineEdit::event (QEvent *pe) |
324 | { | 324 | { |
325 | if (pe->type() == QEvent::KeyPress) | 325 | if (pe->type() == QEvent::KeyPress) |
326 | { | 326 | { |
327 | QKeyEvent *k = (QKeyEvent *) pe; | 327 | QKeyEvent *k = (QKeyEvent *) pe; |
328 | 328 | ||
329 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && | 329 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && |
330 | p->tabOrderedRenaming() && p->itemsRenameable() && | 330 | p->tabOrderedRenaming() && p->itemsRenameable() && |
331 | !(k->state() & ControlButton || k->state() & AltButton)) | 331 | !(k->state() & ControlButton || k->state() & AltButton)) |
332 | { | 332 | { |
333 | selectNextCell(item, col, | 333 | selectNextCell(item, col, |
334 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); | 334 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); |
335 | return true; | 335 | return true; |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | return KLineEdit::event(pe); | 339 | return KLineEdit::event(pe); |
340 | } | 340 | } |
341 | 341 | ||
342 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) | 342 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) |
343 | { | 343 | { |
344 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) | 344 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) |
345 | terminate(true); | 345 | terminate(true); |
346 | else if(e->key() == Qt::Key_Escape) | 346 | else if(e->key() == Qt::Key_Escape) |
347 | terminate(false); | 347 | terminate(false); |
348 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) | 348 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) |
349 | { | 349 | { |
350 | terminate(true); | 350 | terminate(true); |
351 | KLineEdit::keyPressEvent(e); | 351 | KLineEdit::keyPressEvent(e); |
352 | } | 352 | } |
353 | else | 353 | else |
354 | KLineEdit::keyPressEvent(e); | 354 | KLineEdit::keyPressEvent(e); |
355 | } | 355 | } |
356 | 356 | ||
357 | void KListViewLineEdit::terminate() | 357 | void KListViewLineEdit::terminate() |
358 | { | 358 | { |
359 | terminate(true); | 359 | terminate(true); |
360 | } | 360 | } |
361 | 361 | ||
362 | void KListViewLineEdit::terminate(bool commit) | 362 | void KListViewLineEdit::terminate(bool commit) |
363 | { | 363 | { |
364 | if ( item ) | 364 | if ( item ) |
365 | { | 365 | { |
366 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; | 366 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; |
367 | if (commit) | 367 | if (commit) |
368 | item->setText(col, text()); | 368 | item->setText(col, text()); |
369 | int c=col; | 369 | int c=col; |
370 | QListViewItem *i=item; | 370 | QListViewItem *i=item; |
371 | col=0; | 371 | col=0; |
372 | item=0; | 372 | item=0; |
373 | hide(); // will call focusOutEvent, that's why we set item=0 before | 373 | hide(); // will call focusOutEvent, that's why we set item=0 before |
374 | emit done(i,c); | 374 | emit done(i,c); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) | 378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) |
379 | { | 379 | { |
380 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); | 380 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); |
381 | // Don't let a RMB close the editor | 381 | // Don't let a RMB close the editor |
382 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) | 382 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) |
383 | terminate(true); | 383 | terminate(true); |
384 | } | 384 | } |
385 | 385 | ||
386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) | 386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) |
387 | { | 387 | { |
388 | KLineEdit::paintEvent( e ); | 388 | KLineEdit::paintEvent( e ); |
389 | 389 | ||
390 | if ( !frame() ) { | 390 | if ( !frame() ) { |
391 | QPainter p( this ); | 391 | QPainter p( this ); |
392 | p.setClipRegion( e->region() ); | 392 | p.setClipRegion( e->region() ); |
393 | p.drawRect( rect() ); | 393 | p.drawRect( rect() ); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | 396 | ||
397 | // selection changed -> terminate. As our "item" can be already deleted, | 397 | // selection changed -> terminate. As our "item" can be already deleted, |
398 | // we can't call terminate(false), because that would emit done() with | 398 | // we can't call terminate(false), because that would emit done() with |
399 | // a dangling pointer to "item". | 399 | // a dangling pointer to "item". |
400 | void KListViewLineEdit::slotSelectionChanged() | 400 | void KListViewLineEdit::slotSelectionChanged() |
401 | { | 401 | { |
402 | item = 0; | 402 | item = 0; |
403 | col = 0; | 403 | col = 0; |
404 | hide(); | 404 | hide(); |
405 | } | 405 | } |
406 | */ | 406 | */ |
407 | 407 | ||
408 | KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) | 408 | KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) |
409 | : QListView( parent, name ), | 409 | : QListView( parent, name ), |
410 | d (new KListViewPrivate (this)) | 410 | d (new KListViewPrivate (this)) |
411 | { | 411 | { |
412 | #ifndef DESKTOP_VERSION | 412 | #ifndef DESKTOP_VERSION |
413 | if ( emulateRightMouse ) | 413 | if ( emulateRightMouse ) |
414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
415 | #endif | 415 | #endif |
416 | //US setDragAutoScroll(true); | 416 | //US setDragAutoScroll(true); |
417 | 417 | ||
418 | connect( this, SIGNAL( onViewport() ), | 418 | connect( this, SIGNAL( onViewport() ), |
419 | this, SLOT( slotOnViewport() ) ); | 419 | this, SLOT( slotOnViewport() ) ); |
420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), | 420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), |
421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); | 421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); |
422 | 422 | ||
423 | connect (this, SIGNAL(contentsMoving(int,int)), | 423 | connect (this, SIGNAL(contentsMoving(int,int)), |
424 | this, SLOT(cleanDropVisualizer())); | 424 | this, SLOT(cleanDropVisualizer())); |
425 | connect (this, SIGNAL(contentsMoving(int,int)), | 425 | connect (this, SIGNAL(contentsMoving(int,int)), |
426 | this, SLOT(cleanItemHighlighter())); | 426 | this, SLOT(cleanItemHighlighter())); |
427 | 427 | ||
428 | /*US | 428 | /*US |
429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); | 429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); |
430 | 430 | ||
431 | if (kapp) | 431 | if (kapp) |
432 | { | 432 | { |
433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); | 433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); |
434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); | 434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); |
435 | } | 435 | } |
436 | */ | 436 | */ |
437 | slotSettingsChanged(1); //US do this to initialize the connections | 437 | slotSettingsChanged(1); //US do this to initialize the connections |
438 | 438 | ||
439 | 439 | ||
440 | connect(&d->autoSelect, SIGNAL( timeout() ), | 440 | connect(&d->autoSelect, SIGNAL( timeout() ), |
441 | this, SLOT( slotAutoSelect() ) ); | 441 | this, SLOT( slotAutoSelect() ) ); |
442 | connect(&d->dragExpand, SIGNAL( timeout() ), | 442 | connect(&d->dragExpand, SIGNAL( timeout() ), |
443 | this, SLOT( slotDragExpand() ) ); | 443 | this, SLOT( slotDragExpand() ) ); |
444 | 444 | ||
445 | // context menu handling | 445 | // context menu handling |
446 | if (d->showContextMenusOnPress) | 446 | if (d->showContextMenusOnPress) |
447 | { | 447 | { |
448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
450 | } | 450 | } |
451 | else | 451 | else |
452 | { | 452 | { |
453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
455 | } | 455 | } |
456 | 456 | ||
457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), | 457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), |
458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); | 458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); |
459 | 459 | ||
460 | 460 | ||
461 | //qDebug("KListView::KListView make alternate color configurable"); | 461 | //qDebug("KListView::KListView make alternate color configurable"); |
462 | d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); | 462 | d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | 466 | ||
467 | KListView::~KListView() | 467 | KListView::~KListView() |
468 | { | 468 | { |
469 | delete d; | 469 | delete d; |
470 | } | 470 | } |
471 | 471 | ||
472 | bool KListView::isExecuteArea( const QPoint& point ) | 472 | bool KListView::isExecuteArea( const QPoint& point ) |
473 | { | 473 | { |
474 | if ( itemAt( point ) ) | 474 | if ( itemAt( point ) ) |
475 | return isExecuteArea( point.x() ); | 475 | return isExecuteArea( point.x() ); |
476 | 476 | ||
477 | return false; | 477 | return false; |
478 | } | 478 | } |
479 | QSize KListView::sizeHint() const | ||
480 | { | ||
481 | //qDebug("KListView::QSize sizeHint() "); | ||
482 | #ifdef DESKTOP_VERSION | ||
483 | QListView::sizeHint(); | ||
484 | #else | ||
485 | return QSize ( 40, 40 ); | ||
486 | #endif | ||
479 | 487 | ||
488 | } | ||
480 | bool KListView::isExecuteArea( int x ) | 489 | bool KListView::isExecuteArea( int x ) |
481 | { | 490 | { |
482 | if( allColumnsShowFocus() ) | 491 | if( allColumnsShowFocus() ) |
483 | return true; | 492 | return true; |
484 | else { | 493 | else { |
485 | int offset = 0; | 494 | int offset = 0; |
486 | int width = columnWidth( 0 ); | 495 | int width = columnWidth( 0 ); |
487 | int pos = header()->mapToIndex( 0 ); | 496 | int pos = header()->mapToIndex( 0 ); |
488 | 497 | ||
489 | for ( int index = 0; index < pos; index++ ) | 498 | for ( int index = 0; index < pos; index++ ) |
490 | offset += columnWidth( header()->mapToSection( index ) ); | 499 | offset += columnWidth( header()->mapToSection( index ) ); |
491 | 500 | ||
492 | x += contentsX(); // in case of a horizontal scrollbar | 501 | x += contentsX(); // in case of a horizontal scrollbar |
493 | return ( x > offset && x < ( offset + width ) ); | 502 | return ( x > offset && x < ( offset + width ) ); |
494 | } | 503 | } |
495 | } | 504 | } |
496 | 505 | ||
497 | void KListView::slotOnItem( QListViewItem *item ) | 506 | void KListView::slotOnItem( QListViewItem *item ) |
498 | { | 507 | { |
499 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); | 508 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); |
500 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { | 509 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { |
501 | d->autoSelect.start( d->autoSelectDelay, true ); | 510 | d->autoSelect.start( d->autoSelectDelay, true ); |
502 | d->pCurrentItem = item; | 511 | d->pCurrentItem = item; |
503 | } | 512 | } |
504 | } | 513 | } |
505 | 514 | ||
506 | void KListView::slotOnViewport() | 515 | void KListView::slotOnViewport() |
507 | { | 516 | { |
508 | if ( d->bChangeCursorOverItem ) | 517 | if ( d->bChangeCursorOverItem ) |
509 | viewport()->unsetCursor(); | 518 | viewport()->unsetCursor(); |
510 | 519 | ||
511 | d->autoSelect.stop(); | 520 | d->autoSelect.stop(); |
512 | d->pCurrentItem = 0L; | 521 | d->pCurrentItem = 0L; |
513 | } | 522 | } |
514 | 523 | ||
515 | void KListView::slotSettingsChanged(int category) | 524 | void KListView::slotSettingsChanged(int category) |
516 | { | 525 | { |
517 | //qDebug("KListView::slotSettingsChanged has to be verified"); | 526 | //qDebug("KListView::slotSettingsChanged has to be verified"); |
518 | 527 | ||
519 | 528 | ||
520 | switch (category) | 529 | switch (category) |
521 | { | 530 | { |
522 | //US I create my private category (=1) to set the settings | 531 | //US I create my private category (=1) to set the settings |
523 | case 1: | 532 | case 1: |
524 | d->dragDelay = 2; | 533 | d->dragDelay = 2; |
525 | //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); | 534 | //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); |
526 | // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); | 535 | // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); |
527 | 536 | ||
528 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 537 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
529 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 538 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
530 | 539 | ||
531 | if( d->bUseSingle ) | 540 | if( d->bUseSingle ) |
532 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 541 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
533 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 542 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
534 | 543 | ||
535 | //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 544 | //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
536 | //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 545 | //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
537 | 546 | ||
538 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 547 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
539 | viewport()->unsetCursor(); | 548 | viewport()->unsetCursor(); |
540 | 549 | ||
541 | break; | 550 | break; |
542 | 551 | ||
543 | /*US | 552 | /*US |
544 | case KApplication::SETTINGS_MOUSE: | 553 | case KApplication::SETTINGS_MOUSE: |
545 | d->dragDelay = KGlobalSettings::dndEventDelay(); | 554 | d->dragDelay = KGlobalSettings::dndEventDelay(); |
546 | d->bUseSingle = KGlobalSettings::singleClick(); | 555 | d->bUseSingle = KGlobalSettings::singleClick(); |
547 | 556 | ||
548 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 557 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
549 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 558 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
550 | 559 | ||
551 | if( d->bUseSingle ) | 560 | if( d->bUseSingle ) |
552 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 561 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
553 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 562 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
554 | 563 | ||
555 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 564 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
556 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 565 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
557 | 566 | ||
558 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 567 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
559 | viewport()->unsetCursor(); | 568 | viewport()->unsetCursor(); |
560 | 569 | ||
561 | break; | 570 | break; |
562 | case KApplication::SETTINGS_POPUPMENU: | 571 | case KApplication::SETTINGS_POPUPMENU: |
563 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); | 572 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); |
564 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); | 573 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); |
565 | 574 | ||
566 | if (d->showContextMenusOnPress) | 575 | if (d->showContextMenusOnPress) |
567 | { | 576 | { |
568 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 577 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
569 | 578 | ||
570 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 579 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
571 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 580 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
572 | } | 581 | } |
573 | else | 582 | else |
574 | { | 583 | { |
575 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 584 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
576 | 585 | ||
577 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 586 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
578 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 587 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
579 | } | 588 | } |
580 | break; | 589 | break; |
581 | */ | 590 | */ |
582 | 591 | ||
583 | default: | 592 | default: |
584 | break; | 593 | break; |
585 | } | 594 | } |
586 | 595 | ||
587 | } | 596 | } |
588 | 597 | ||
589 | void KListView::slotAutoSelect() | 598 | void KListView::slotAutoSelect() |
590 | { | 599 | { |
591 | // check that the item still exists | 600 | // check that the item still exists |
592 | if( itemIndex( d->pCurrentItem ) == -1 ) | 601 | if( itemIndex( d->pCurrentItem ) == -1 ) |
593 | return; | 602 | return; |
594 | 603 | ||
595 | if (!isActiveWindow()) | 604 | if (!isActiveWindow()) |
596 | { | 605 | { |
597 | d->autoSelect.stop(); | 606 | d->autoSelect.stop(); |
598 | return; | 607 | return; |
599 | } | 608 | } |
600 | 609 | ||
601 | //Give this widget the keyboard focus. | 610 | //Give this widget the keyboard focus. |
602 | if( !hasFocus() ) | 611 | if( !hasFocus() ) |
603 | setFocus(); | 612 | setFocus(); |
604 | 613 | ||
605 | QListViewItem* previousItem = currentItem(); | 614 | QListViewItem* previousItem = currentItem(); |
606 | setCurrentItem( d->pCurrentItem ); | 615 | setCurrentItem( d->pCurrentItem ); |
607 | 616 | ||
608 | #if 0 | 617 | #if 0 |
609 | #ifndef Q_WS_QWS | 618 | #ifndef Q_WS_QWS |
610 | // FIXME(E): Implement for Qt Embedded | 619 | // FIXME(E): Implement for Qt Embedded |
611 | if( d->pCurrentItem ) { | 620 | if( d->pCurrentItem ) { |
612 | //Shift pressed? | 621 | //Shift pressed? |
613 | if( (keybstate & ShiftMask) ) { | 622 | if( (keybstate & ShiftMask) ) { |
614 | bool block = signalsBlocked(); | 623 | bool block = signalsBlocked(); |
615 | blockSignals( true ); | 624 | blockSignals( true ); |
616 | 625 | ||
617 | //No Ctrl? Then clear before! | 626 | //No Ctrl? Then clear before! |
618 | if( !(keybstate & ControlMask) ) | 627 | if( !(keybstate & ControlMask) ) |
619 | clearSelection(); | 628 | clearSelection(); |
620 | 629 | ||
621 | bool select = !d->pCurrentItem->isSelected(); | 630 | bool select = !d->pCurrentItem->isSelected(); |
622 | bool update = viewport()->isUpdatesEnabled(); | 631 | bool update = viewport()->isUpdatesEnabled(); |
623 | viewport()->setUpdatesEnabled( false ); | 632 | viewport()->setUpdatesEnabled( false ); |
624 | 633 | ||
625 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); | 634 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); |
626 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); | 635 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); |
627 | for ( ; lit.current(); ++lit ) { | 636 | for ( ; lit.current(); ++lit ) { |
628 | if ( down && lit.current() == d->pCurrentItem ) { | 637 | if ( down && lit.current() == d->pCurrentItem ) { |
629 | d->pCurrentItem->setSelected( select ); | 638 | d->pCurrentItem->setSelected( select ); |
630 | break; | 639 | break; |
631 | } | 640 | } |
632 | if ( !down && lit.current() == previousItem ) { | 641 | if ( !down && lit.current() == previousItem ) { |
633 | previousItem->setSelected( select ); | 642 | previousItem->setSelected( select ); |
634 | break; | 643 | break; |
635 | } | 644 | } |
636 | lit.current()->setSelected( select ); | 645 | lit.current()->setSelected( select ); |
637 | } | 646 | } |
638 | 647 | ||
639 | blockSignals( block ); | 648 | blockSignals( block ); |
640 | viewport()->setUpdatesEnabled( update ); | 649 | viewport()->setUpdatesEnabled( update ); |
641 | triggerUpdate(); | 650 | triggerUpdate(); |
642 | 651 | ||
643 | emit selectionChanged(); | 652 | emit selectionChanged(); |
644 | 653 | ||
645 | if( selectionMode() == QListView::Single ) | 654 | if( selectionMode() == QListView::Single ) |
646 | emit selectionChanged( d->pCurrentItem ); | 655 | emit selectionChanged( d->pCurrentItem ); |
647 | } | 656 | } |
648 | else if( (keybstate & ControlMask) ) | 657 | else if( (keybstate & ControlMask) ) |
649 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); | 658 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); |
650 | else { | 659 | else { |
651 | bool block = signalsBlocked(); | 660 | bool block = signalsBlocked(); |
652 | blockSignals( true ); | 661 | blockSignals( true ); |
653 | 662 | ||
654 | if( !d->pCurrentItem->isSelected() ) | 663 | if( !d->pCurrentItem->isSelected() ) |
655 | clearSelection(); | 664 | clearSelection(); |
656 | 665 | ||
657 | blockSignals( block ); | 666 | blockSignals( block ); |
658 | 667 | ||
659 | setSelected( d->pCurrentItem, true ); | 668 | setSelected( d->pCurrentItem, true ); |
660 | } | 669 | } |
661 | } | 670 | } |
662 | else | 671 | else |
663 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; | 672 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; |
664 | #endif | 673 | #endif |
665 | #endif | 674 | #endif |
666 | } | 675 | } |
667 | 676 | ||
668 | void KListView::slotHeaderChanged() | 677 | void KListView::slotHeaderChanged() |
669 | { | 678 | { |
670 | if (d->fullWidth && columns()) | 679 | if (d->fullWidth && columns()) |
671 | { | 680 | { |
672 | int w = 0; | 681 | int w = 0; |
673 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); | 682 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); |
674 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); | 683 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); |
675 | } | 684 | } |
676 | } | 685 | } |
677 | 686 | ||
678 | void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) | 687 | void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) |
679 | { | 688 | { |
680 | // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); | 689 | // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); |
681 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { | 690 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { |
682 | 691 | ||
683 | // Double click mode ? | 692 | // Double click mode ? |
684 | if ( !d->bUseSingle ) | 693 | if ( !d->bUseSingle ) |
685 | { | 694 | { |
686 | emit executed( item ); | 695 | emit executed( item ); |
687 | emit executed( item, pos, c ); | 696 | emit executed( item, pos, c ); |
688 | } | 697 | } |
689 | else | 698 | else |
690 | { | 699 | { |
691 | //US special implementation for embedded systems | 700 | //US special implementation for embedded systems |
692 | d->autoSelect.stop(); | 701 | d->autoSelect.stop(); |
693 | 702 | ||
694 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed | 703 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed |
695 | if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { | 704 | if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { |
696 | // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { | 705 | // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { |
697 | 706 | ||
698 | emit executed( item ); | 707 | emit executed( item ); |
699 | emit executed( item, pos, c ); | 708 | emit executed( item, pos, c ); |
700 | } | 709 | } |
701 | } | 710 | } |
702 | } | 711 | } |
703 | } | 712 | } |
704 | 713 | ||
705 | void KListView::focusInEvent( QFocusEvent *fe ) | 714 | void KListView::focusInEvent( QFocusEvent *fe ) |
706 | { | 715 | { |
707 | // kdDebug()<<"KListView::focusInEvent()"<<endl; | 716 | // kdDebug()<<"KListView::focusInEvent()"<<endl; |
708 | QListView::focusInEvent( fe ); | 717 | QListView::focusInEvent( fe ); |
709 | if ((d->selectedBySimpleMove) | 718 | if ((d->selectedBySimpleMove) |
710 | && (d->selectionMode == FileManager) | 719 | && (d->selectionMode == FileManager) |
711 | && (fe->reason()!=QFocusEvent::Popup) | 720 | && (fe->reason()!=QFocusEvent::Popup) |
712 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 721 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
713 | && (currentItem()!=0)) | 722 | && (currentItem()!=0)) |
714 | { | 723 | { |
715 | currentItem()->setSelected(true); | 724 | currentItem()->setSelected(true); |
716 | currentItem()->repaint(); | 725 | currentItem()->repaint(); |
717 | emit selectionChanged(); | 726 | emit selectionChanged(); |
718 | }; | 727 | }; |
719 | } | 728 | } |
720 | 729 | ||
721 | void KListView::focusOutEvent( QFocusEvent *fe ) | 730 | void KListView::focusOutEvent( QFocusEvent *fe ) |
722 | { | 731 | { |
723 | cleanDropVisualizer(); | 732 | cleanDropVisualizer(); |
724 | cleanItemHighlighter(); | 733 | cleanItemHighlighter(); |
725 | 734 | ||
726 | d->autoSelect.stop(); | 735 | d->autoSelect.stop(); |
727 | 736 | ||
728 | if ((d->selectedBySimpleMove) | 737 | if ((d->selectedBySimpleMove) |
729 | && (d->selectionMode == FileManager) | 738 | && (d->selectionMode == FileManager) |
730 | && (fe->reason()!=QFocusEvent::Popup) | 739 | && (fe->reason()!=QFocusEvent::Popup) |
731 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 740 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
732 | && (currentItem()!=0) | 741 | && (currentItem()!=0) |
733 | /*US && (!d->editor->isVisible()) */ | 742 | /*US && (!d->editor->isVisible()) */ |
734 | ) | 743 | ) |
735 | { | 744 | { |
736 | currentItem()->setSelected(false); | 745 | currentItem()->setSelected(false); |
737 | currentItem()->repaint(); | 746 | currentItem()->repaint(); |
738 | emit selectionChanged(); | 747 | emit selectionChanged(); |
739 | }; | 748 | }; |
740 | 749 | ||
741 | QListView::focusOutEvent( fe ); | 750 | QListView::focusOutEvent( fe ); |
742 | } | 751 | } |
743 | 752 | ||
744 | void KListView::leaveEvent( QEvent *e ) | 753 | void KListView::leaveEvent( QEvent *e ) |
745 | { | 754 | { |
746 | d->autoSelect.stop(); | 755 | d->autoSelect.stop(); |
747 | 756 | ||
748 | QListView::leaveEvent( e ); | 757 | QListView::leaveEvent( e ); |
749 | } | 758 | } |
750 | 759 | ||
751 | bool KListView::event( QEvent *e ) | 760 | bool KListView::event( QEvent *e ) |
752 | { | 761 | { |
753 | if (e->type() == QEvent::ApplicationPaletteChange) { | 762 | if (e->type() == QEvent::ApplicationPaletteChange) { |
754 | //qDebug("KListView::event make alternate color configurable"); | 763 | //qDebug("KListView::event make alternate color configurable"); |
755 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); | 764 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); |
756 | d->alternateBackground = QColor(240, 240, 240); | 765 | d->alternateBackground = QColor(240, 240, 240); |
757 | } | 766 | } |
758 | 767 | ||
759 | return QListView::event(e); | 768 | return QListView::event(e); |
760 | } | 769 | } |
761 | 770 | ||
762 | void KListView::contentsMousePressEvent( QMouseEvent *e ) | 771 | void KListView::contentsMousePressEvent( QMouseEvent *e ) |
763 | { | 772 | { |
764 | //qDebug("KListView::contentsMousePressEvent"); | 773 | //qDebug("KListView::contentsMousePressEvent"); |
765 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) | 774 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) |
766 | { | 775 | { |
767 | bool block = signalsBlocked(); | 776 | bool block = signalsBlocked(); |
768 | blockSignals( true ); | 777 | blockSignals( true ); |
769 | 778 | ||
770 | clearSelection(); | 779 | clearSelection(); |
771 | 780 | ||
772 | blockSignals( block ); | 781 | blockSignals( block ); |
773 | } | 782 | } |
774 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) | 783 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) |
775 | { | 784 | { |
776 | d->selectedBySimpleMove=false; | 785 | d->selectedBySimpleMove=false; |
777 | d->selectedUsingMouse=true; | 786 | d->selectedUsingMouse=true; |
778 | if (currentItem()!=0) | 787 | if (currentItem()!=0) |
779 | { | 788 | { |
780 | currentItem()->setSelected(false); | 789 | currentItem()->setSelected(false); |
781 | currentItem()->repaint(); | 790 | currentItem()->repaint(); |
782 | // emit selectionChanged(); | 791 | // emit selectionChanged(); |
783 | }; | 792 | }; |
784 | }; | 793 | }; |
785 | 794 | ||
786 | QPoint p( contentsToViewport( e->pos() ) ); | 795 | QPoint p( contentsToViewport( e->pos() ) ); |
787 | QListViewItem *at = itemAt (p); | 796 | QListViewItem *at = itemAt (p); |
788 | 797 | ||
789 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 798 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
790 | bool rootDecoClicked = at | 799 | bool rootDecoClicked = at |
791 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 800 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
792 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 801 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
793 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 802 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
794 | 803 | ||
795 | if (e->button() == LeftButton && !rootDecoClicked) | 804 | if (e->button() == LeftButton && !rootDecoClicked) |
796 | { | 805 | { |
797 | //Start a drag | 806 | //Start a drag |
798 | d->startDragPos = e->pos(); | 807 | d->startDragPos = e->pos(); |
799 | 808 | ||
800 | if (at) | 809 | if (at) |
801 | { | 810 | { |
802 | d->validDrag = true; | 811 | d->validDrag = true; |
803 | d->pressedOnSelected = at->isSelected(); | 812 | d->pressedOnSelected = at->isSelected(); |
804 | } | 813 | } |
805 | } | 814 | } |
806 | 815 | ||
807 | QListView::contentsMousePressEvent( e ); | 816 | QListView::contentsMousePressEvent( e ); |
808 | } | 817 | } |
809 | 818 | ||
810 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) | 819 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) |
811 | { | 820 | { |
812 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { | 821 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { |
813 | QListView::contentsMouseMoveEvent (e); | 822 | QListView::contentsMouseMoveEvent (e); |
814 | return; | 823 | return; |
815 | } | 824 | } |
816 | 825 | ||
817 | QPoint vp = contentsToViewport(e->pos()); | 826 | QPoint vp = contentsToViewport(e->pos()); |
818 | QListViewItem *item = itemAt( vp ); | 827 | QListViewItem *item = itemAt( vp ); |
819 | 828 | ||
820 | //do we process cursor changes at all? | 829 | //do we process cursor changes at all? |
821 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) | 830 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) |
822 | { | 831 | { |
823 | //Cursor moved on a new item or in/out the execute area | 832 | //Cursor moved on a new item or in/out the execute area |
824 | if( (item != d->pCurrentItem) || | 833 | if( (item != d->pCurrentItem) || |
825 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) | 834 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) |
826 | { | 835 | { |
827 | d->cursorInExecuteArea = isExecuteArea(vp); | 836 | d->cursorInExecuteArea = isExecuteArea(vp); |
828 | //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); | 837 | //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); |
829 | /*US | 838 | /*US |
830 | if( d->cursorInExecuteArea ) //cursor moved in execute area | 839 | if( d->cursorInExecuteArea ) //cursor moved in execute area |
831 | viewport()->setCursor( KCursor::handCursor() ); | 840 | viewport()->setCursor( KCursor::handCursor() ); |
832 | else //cursor moved out of execute area | 841 | else //cursor moved out of execute area |
833 | viewport()->unsetCursor(); | 842 | viewport()->unsetCursor(); |
834 | */ | 843 | */ |
835 | } | 844 | } |
836 | } | 845 | } |
837 | 846 | ||
838 | bool dragOn = dragEnabled(); | 847 | bool dragOn = dragEnabled(); |
839 | QPoint newPos = e->pos(); | 848 | QPoint newPos = e->pos(); |
840 | if (dragOn && d->validDrag && | 849 | if (dragOn && d->validDrag && |
841 | (newPos.x() > d->startDragPos.x()+d->dragDelay || | 850 | (newPos.x() > d->startDragPos.x()+d->dragDelay || |
842 | newPos.x() < d->startDragPos.x()-d->dragDelay || | 851 | newPos.x() < d->startDragPos.x()-d->dragDelay || |
843 | newPos.y() > d->startDragPos.y()+d->dragDelay || | 852 | newPos.y() > d->startDragPos.y()+d->dragDelay || |
844 | newPos.y() < d->startDragPos.y()-d->dragDelay)) | 853 | newPos.y() < d->startDragPos.y()-d->dragDelay)) |
845 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) | 854 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) |
846 | { | 855 | { |
847 | QListView::contentsMouseReleaseEvent( 0 ); | 856 | QListView::contentsMouseReleaseEvent( 0 ); |
848 | startDrag(); | 857 | startDrag(); |
849 | d->startDragPos = QPoint(); | 858 | d->startDragPos = QPoint(); |
850 | d->validDrag = false; | 859 | d->validDrag = false; |
851 | } | 860 | } |
852 | } | 861 | } |
853 | 862 | ||
854 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) | 863 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) |
855 | { | 864 | { |
856 | if (e->button() == LeftButton) | 865 | if (e->button() == LeftButton) |
857 | { | 866 | { |
858 | // If the row was already selected, maybe we want to start an in-place editing | 867 | // If the row was already selected, maybe we want to start an in-place editing |
859 | if ( d->pressedOnSelected && itemsRenameable() ) | 868 | if ( d->pressedOnSelected && itemsRenameable() ) |
860 | { | 869 | { |
861 | QPoint p( contentsToViewport( e->pos() ) ); | 870 | QPoint p( contentsToViewport( e->pos() ) ); |
862 | QListViewItem *at = itemAt (p); | 871 | QListViewItem *at = itemAt (p); |
863 | if ( at ) | 872 | if ( at ) |
864 | { | 873 | { |
865 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 874 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
866 | bool rootDecoClicked = | 875 | bool rootDecoClicked = |
867 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 876 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
868 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 877 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
869 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 878 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
870 | 879 | ||
871 | if (!rootDecoClicked) | 880 | if (!rootDecoClicked) |
872 | { | 881 | { |
873 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); | 882 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); |
874 | if ( d->renameable.contains(col) ) | 883 | if ( d->renameable.contains(col) ) |
875 | rename(at, col); | 884 | rename(at, col); |
876 | } | 885 | } |
877 | } | 886 | } |
878 | } | 887 | } |
879 | 888 | ||
880 | d->pressedOnSelected = false; | 889 | d->pressedOnSelected = false; |
881 | d->validDrag = false; | 890 | d->validDrag = false; |
882 | d->startDragPos = QPoint(); | 891 | d->startDragPos = QPoint(); |
883 | } | 892 | } |
884 | QListView::contentsMouseReleaseEvent( e ); | 893 | QListView::contentsMouseReleaseEvent( e ); |
885 | } | 894 | } |
886 | 895 | ||
887 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) | 896 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) |
888 | { | 897 | { |
889 | //qDebug("KListView::contentsMouseDoubleClickEvent"); | 898 | //qDebug("KListView::contentsMouseDoubleClickEvent"); |
890 | // We don't want to call the parent method because it does setOpen, | 899 | // We don't want to call the parent method because it does setOpen, |
891 | // whereas we don't do it in single click mode... (David) | 900 | // whereas we don't do it in single click mode... (David) |
892 | //QListView::contentsMouseDoubleClickEvent( e ); | 901 | //QListView::contentsMouseDoubleClickEvent( e ); |
893 | 902 | ||
894 | QPoint vp = contentsToViewport(e->pos()); | 903 | QPoint vp = contentsToViewport(e->pos()); |
895 | QListViewItem *item = itemAt( vp ); | 904 | QListViewItem *item = itemAt( vp ); |
896 | emit QListView::doubleClicked( item ); // we do it now | 905 | emit QListView::doubleClicked( item ); // we do it now |
897 | 906 | ||
898 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; | 907 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; |
899 | 908 | ||
900 | if( item ) { | 909 | if( item ) { |
901 | //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked"); | 910 | //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked"); |
902 | 911 | ||
903 | emit doubleClicked( item, e->globalPos(), col ); | 912 | emit doubleClicked( item, e->globalPos(), col ); |
904 | 913 | ||
905 | if( (e->button() == LeftButton) && !d->bUseSingle ) { | 914 | if( (e->button() == LeftButton) && !d->bUseSingle ) { |
906 | //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute"); | 915 | //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute"); |
907 | 916 | ||
908 | emitExecute( e->button(), item, e->globalPos(), col); | 917 | emitExecute( e->button(), item, e->globalPos(), col); |
909 | } | 918 | } |
910 | } | 919 | } |
911 | } | 920 | } |
912 | 921 | ||
913 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) | 922 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) |
914 | { | 923 | { |
915 | //qDebug("KListView::slotMouseButtonClicked"); | 924 | //qDebug("KListView::slotMouseButtonClicked"); |
916 | 925 | ||
917 | if( (btn == LeftButton) && item ) { | 926 | if( (btn == LeftButton) && item ) { |
918 | //qDebug("KListView::slotMouseButtonClicked: emitExecute"); | 927 | //qDebug("KListView::slotMouseButtonClicked: emitExecute"); |
919 | 928 | ||
920 | emitExecute(btn, item, pos, c); | 929 | emitExecute(btn, item, pos, c); |
921 | } | 930 | } |
922 | } | 931 | } |
923 | 932 | ||
924 | void KListView::contentsDropEvent(QDropEvent* e) | 933 | void KListView::contentsDropEvent(QDropEvent* e) |
925 | { | 934 | { |
926 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 935 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
927 | /*US | 936 | /*US |
928 | cleanDropVisualizer(); | 937 | cleanDropVisualizer(); |
929 | cleanItemHighlighter(); | 938 | cleanItemHighlighter(); |
930 | d->dragExpand.stop(); | 939 | d->dragExpand.stop(); |
931 | 940 | ||
932 | if (acceptDrag (e)) | 941 | if (acceptDrag (e)) |
933 | { | 942 | { |
934 | e->acceptAction(); | 943 | e->acceptAction(); |
935 | QListViewItem *afterme; | 944 | QListViewItem *afterme; |
936 | QListViewItem *parent; | 945 | QListViewItem *parent; |
937 | findDrop(e->pos(), parent, afterme); | 946 | findDrop(e->pos(), parent, afterme); |
938 | 947 | ||
939 | if (e->source() == viewport() && itemsMovable()) | 948 | if (e->source() == viewport() && itemsMovable()) |
940 | movableDropEvent(parent, afterme); | 949 | movableDropEvent(parent, afterme); |
941 | else | 950 | else |
942 | { | 951 | { |
943 | 952 | ||
944 | emit dropped(e, afterme); | 953 | emit dropped(e, afterme); |
945 | emit dropped(this, e, afterme); | 954 | emit dropped(this, e, afterme); |
946 | emit dropped(e, parent, afterme); | 955 | emit dropped(e, parent, afterme); |
947 | emit dropped(this, e, parent, afterme); | 956 | emit dropped(this, e, parent, afterme); |
948 | 957 | ||
949 | } | 958 | } |
950 | } | 959 | } |
951 | */ | 960 | */ |
952 | 961 | ||
953 | } | 962 | } |
954 | 963 | ||
955 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) | 964 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) |
956 | { | 965 | { |
957 | QPtrList<QListViewItem> items, afterFirsts, afterNows; | 966 | QPtrList<QListViewItem> items, afterFirsts, afterNows; |
958 | QListViewItem *current=currentItem(); | 967 | QListViewItem *current=currentItem(); |
959 | bool hasMoved=false; | 968 | bool hasMoved=false; |
960 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) | 969 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) |
961 | { | 970 | { |
962 | iNext=i->itemBelow(); | 971 | iNext=i->itemBelow(); |
963 | if (!i->isSelected()) | 972 | if (!i->isSelected()) |
964 | continue; | 973 | continue; |
965 | 974 | ||
966 | // don't drop an item after itself, or else | 975 | // don't drop an item after itself, or else |
967 | // it moves to the top of the list | 976 | // it moves to the top of the list |
968 | if (i==afterme) | 977 | if (i==afterme) |
969 | continue; | 978 | continue; |
970 | 979 | ||
971 | i->setSelected(false); | 980 | i->setSelected(false); |
972 | 981 | ||
973 | QListViewItem *afterFirst = i->itemAbove(); | 982 | QListViewItem *afterFirst = i->itemAbove(); |
974 | 983 | ||
975 | if (!hasMoved) | 984 | if (!hasMoved) |
976 | { | 985 | { |
977 | emit aboutToMove(); | 986 | emit aboutToMove(); |
978 | hasMoved=true; | 987 | hasMoved=true; |
979 | } | 988 | } |
980 | 989 | ||
981 | moveItem(i, parent, afterme); | 990 | moveItem(i, parent, afterme); |
982 | 991 | ||
983 | // ###### This should include the new parent !!! -> KDE 3.0 | 992 | // ###### This should include the new parent !!! -> KDE 3.0 |
984 | // If you need this right now, have a look at keditbookmarks. | 993 | // If you need this right now, have a look at keditbookmarks. |
985 | emit moved(i, afterFirst, afterme); | 994 | emit moved(i, afterFirst, afterme); |
986 | 995 | ||
987 | items.append (i); | 996 | items.append (i); |
988 | afterFirsts.append (afterFirst); | 997 | afterFirsts.append (afterFirst); |
989 | afterNows.append (afterme); | 998 | afterNows.append (afterme); |
990 | 999 | ||
991 | afterme = i; | 1000 | afterme = i; |
992 | } | 1001 | } |
993 | clearSelection(); | 1002 | clearSelection(); |
994 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) | 1003 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) |
995 | i->setSelected(true); | 1004 | i->setSelected(true); |
996 | if (current) | 1005 | if (current) |
997 | setCurrentItem(current); | 1006 | setCurrentItem(current); |
998 | 1007 | ||
999 | emit moved(items,afterFirsts,afterNows); | 1008 | emit moved(items,afterFirsts,afterNows); |
1000 | 1009 | ||
1001 | if (firstChild()) | 1010 | if (firstChild()) |
1002 | emit moved(); | 1011 | emit moved(); |
1003 | } | 1012 | } |
1004 | 1013 | ||
1005 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) | 1014 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) |
1006 | { | 1015 | { |
1007 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 1016 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
1008 | /*US | 1017 | /*US |
1009 | if (acceptDrag(event)) | 1018 | if (acceptDrag(event)) |
1010 | { | 1019 | { |
1011 | event->acceptAction(); | 1020 | event->acceptAction(); |
1012 | //Clean up the view | 1021 | //Clean up the view |
1013 | 1022 | ||
1014 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); | 1023 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); |
1015 | QPoint vp = contentsToViewport( event->pos() ); | 1024 | QPoint vp = contentsToViewport( event->pos() ); |
1016 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; | 1025 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; |
1017 | 1026 | ||
1018 | if ( item != d->dragOverItem ) | 1027 | if ( item != d->dragOverItem ) |
1019 | { | 1028 | { |
1020 | d->dragExpand.stop(); | 1029 | d->dragExpand.stop(); |
1021 | d->dragOverItem = item; | 1030 | d->dragOverItem = item; |
1022 | d->dragOverPoint = vp; | 1031 | d->dragOverPoint = vp; |
1023 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) | 1032 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) |
1024 | d->dragExpand.start( QApplication::startDragTime(), true ); | 1033 | d->dragExpand.start( QApplication::startDragTime(), true ); |
1025 | } | 1034 | } |
1026 | if (dropVisualizer()) | 1035 | if (dropVisualizer()) |
1027 | { | 1036 | { |
1028 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); | 1037 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); |
1029 | if (tmpRect != d->mOldDropVisualizer) | 1038 | if (tmpRect != d->mOldDropVisualizer) |
1030 | { | 1039 | { |
1031 | cleanDropVisualizer(); | 1040 | cleanDropVisualizer(); |
1032 | d->mOldDropVisualizer=tmpRect; | 1041 | d->mOldDropVisualizer=tmpRect; |
1033 | viewport()->repaint(tmpRect); | 1042 | viewport()->repaint(tmpRect); |
1034 | } | 1043 | } |
1035 | } | 1044 | } |
1036 | if (dropHighlighter()) | 1045 | if (dropHighlighter()) |
1037 | { | 1046 | { |
1038 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); | 1047 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); |
1039 | if (tmpRect != d->mOldDropHighlighter) | 1048 | if (tmpRect != d->mOldDropHighlighter) |
1040 | { | 1049 | { |
1041 | cleanItemHighlighter(); | 1050 | cleanItemHighlighter(); |
1042 | d->mOldDropHighlighter=tmpRect; | 1051 | d->mOldDropHighlighter=tmpRect; |
1043 | viewport()->repaint(tmpRect); | 1052 | viewport()->repaint(tmpRect); |
1044 | } | 1053 | } |
1045 | } | 1054 | } |
1046 | } | 1055 | } |
1047 | else | 1056 | else |
1048 | event->ignore(); | 1057 | event->ignore(); |
1049 | */ | 1058 | */ |
1050 | } | 1059 | } |
1051 | 1060 | ||
1052 | void KListView::slotDragExpand() | 1061 | void KListView::slotDragExpand() |
1053 | { | 1062 | { |
1054 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) | 1063 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) |
1055 | d->dragOverItem->setOpen( true ); | 1064 | d->dragOverItem->setOpen( true ); |
1056 | } | 1065 | } |
1057 | 1066 | ||
1058 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) | 1067 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) |
1059 | { | 1068 | { |
1060 | d->dragExpand.stop(); | 1069 | d->dragExpand.stop(); |
1061 | cleanDropVisualizer(); | 1070 | cleanDropVisualizer(); |
1062 | cleanItemHighlighter(); | 1071 | cleanItemHighlighter(); |
1063 | } | 1072 | } |
1064 | 1073 | ||
1065 | void KListView::cleanDropVisualizer() | 1074 | void KListView::cleanDropVisualizer() |
1066 | { | 1075 | { |
1067 | if (d->mOldDropVisualizer.isValid()) | 1076 | if (d->mOldDropVisualizer.isValid()) |
1068 | { | 1077 | { |
1069 | QRect rect=d->mOldDropVisualizer; | 1078 | QRect rect=d->mOldDropVisualizer; |
1070 | d->mOldDropVisualizer = QRect(); | 1079 | d->mOldDropVisualizer = QRect(); |
1071 | viewport()->repaint(rect, true); | 1080 | viewport()->repaint(rect, true); |
1072 | } | 1081 | } |
1073 | } | 1082 | } |
1074 | 1083 | ||
1075 | int KListView::depthToPixels( int depth ) | 1084 | int KListView::depthToPixels( int depth ) |
1076 | { | 1085 | { |
1077 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); | 1086 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); |
1078 | } | 1087 | } |
1079 | 1088 | ||
1080 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) | 1089 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) |
1081 | { | 1090 | { |
1082 | QPoint p (contentsToViewport(pos)); | 1091 | QPoint p (contentsToViewport(pos)); |
1083 | 1092 | ||
1084 | // Get the position to put it in | 1093 | // Get the position to put it in |
1085 | QListViewItem *atpos = itemAt(p); | 1094 | QListViewItem *atpos = itemAt(p); |
1086 | 1095 | ||
1087 | QListViewItem *above; | 1096 | QListViewItem *above; |
1088 | if (!atpos) // put it at the end | 1097 | if (!atpos) // put it at the end |
1089 | above = lastItem(); | 1098 | above = lastItem(); |
1090 | else | 1099 | else |
1091 | { | 1100 | { |
1092 | // Get the closest item before us ('atpos' or the one above, if any) | 1101 | // Get the closest item before us ('atpos' or the one above, if any) |
1093 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) | 1102 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) |
1094 | above = atpos->itemAbove(); | 1103 | above = atpos->itemAbove(); |
1095 | else | 1104 | else |
1096 | above = atpos; | 1105 | above = atpos; |
1097 | } | 1106 | } |
1098 | 1107 | ||
1099 | if (above) | 1108 | if (above) |
1100 | { | 1109 | { |
1101 | // Now, we know we want to go after "above". But as a child or as a sibling ? | 1110 | // Now, we know we want to go after "above". But as a child or as a sibling ? |
1102 | // We have to ask the "above" item if it accepts children. | 1111 | // We have to ask the "above" item if it accepts children. |
1103 | if (above->isExpandable()) | 1112 | if (above->isExpandable()) |
1104 | { | 1113 | { |
1105 | // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children | 1114 | // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children |
1106 | if (p.x() >= depthToPixels( above->depth() + 1 ) || | 1115 | if (p.x() >= depthToPixels( above->depth() + 1 ) || |
1107 | (above->isOpen() && above->childCount() > 0) ) | 1116 | (above->isOpen() && above->childCount() > 0) ) |
1108 | { | 1117 | { |
1109 | parent = above; | 1118 | parent = above; |
1110 | after = 0L; | 1119 | after = 0L; |
1111 | return; | 1120 | return; |
1112 | } | 1121 | } |
1113 | } | 1122 | } |
1114 | 1123 | ||
1115 | // Ok, there's one more level of complexity. We may want to become a new | 1124 | // Ok, there's one more level of complexity. We may want to become a new |
1116 | // sibling, but of an upper-level group, rather than the "above" item | 1125 | // sibling, but of an upper-level group, rather than the "above" item |
1117 | QListViewItem * betterAbove = above->parent(); | 1126 | QListViewItem * betterAbove = above->parent(); |
1118 | QListViewItem * last = above; | 1127 | QListViewItem * last = above; |
1119 | while ( betterAbove ) | 1128 | while ( betterAbove ) |
1120 | { | 1129 | { |
1121 | // We are allowed to become a sibling of "betterAbove" only if we are | 1130 | // We are allowed to become a sibling of "betterAbove" only if we are |
1122 | // after its last child | 1131 | // after its last child |
1123 | if ( last->nextSibling() == 0 ) | 1132 | if ( last->nextSibling() == 0 ) |
1124 | { | 1133 | { |
1125 | if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) | 1134 | if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) |
1126 | above = betterAbove; // store this one, but don't stop yet, there may be a better one | 1135 | above = betterAbove; // store this one, but don't stop yet, there may be a better one |
1127 | else | 1136 | else |
1128 | break; // not enough on the left, so stop | 1137 | break; // not enough on the left, so stop |
1129 | last = betterAbove; | 1138 | last = betterAbove; |
1130 | betterAbove = betterAbove->parent(); // up one level | 1139 | betterAbove = betterAbove->parent(); // up one level |
1131 | } else | 1140 | } else |
1132 | break; // we're among the child of betterAbove, not after the last one | 1141 | break; // we're among the child of betterAbove, not after the last one |
1133 | } | 1142 | } |
1134 | } | 1143 | } |
1135 | // set as sibling | 1144 | // set as sibling |
1136 | after = above; | 1145 | after = above; |
1137 | parent = after ? after->parent() : 0L ; | 1146 | parent = after ? after->parent() : 0L ; |
1138 | } | 1147 | } |
1139 | 1148 | ||
1140 | QListViewItem* KListView::lastChild () const | 1149 | QListViewItem* KListView::lastChild () const |
1141 | { | 1150 | { |
1142 | QListViewItem* lastchild = firstChild(); | 1151 | QListViewItem* lastchild = firstChild(); |
1143 | 1152 | ||
1144 | if (lastchild) | 1153 | if (lastchild) |
1145 | for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); | 1154 | for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); |
1146 | 1155 | ||
1147 | return lastchild; | 1156 | return lastchild; |
1148 | } | 1157 | } |
1149 | 1158 | ||
1150 | QListViewItem *KListView::lastItem() const | 1159 | QListViewItem *KListView::lastItem() const |
1151 | { | 1160 | { |
1152 | QListViewItem* last = lastChild(); | 1161 | QListViewItem* last = lastChild(); |
1153 | 1162 | ||
1154 | for (QListViewItemIterator it (last); it.current(); ++it) | 1163 | for (QListViewItemIterator it (last); it.current(); ++it) |
1155 | last = it.current(); | 1164 | last = it.current(); |
1156 | 1165 | ||
1157 | return last; | 1166 | return last; |
1158 | } | 1167 | } |
1159 | 1168 | ||
1160 | KLineEdit *KListView::renameLineEdit() const | 1169 | KLineEdit *KListView::renameLineEdit() const |
1161 | { | 1170 | { |
1162 | //US return d->editor; | 1171 | //US return d->editor; |
1163 | qDebug("KListView::renameLineEdit returns 0. Might crash"); | 1172 | qDebug("KListView::renameLineEdit returns 0. Might crash"); |
1164 | return 0; | 1173 | return 0; |
1165 | } | 1174 | } |
1166 | 1175 | ||
1167 | void KListView::startDrag() | 1176 | void KListView::startDrag() |
1168 | { | 1177 | { |
1169 | qDebug("KListView::startDrag drag&drop not supported yet."); | 1178 | qDebug("KListView::startDrag drag&drop not supported yet."); |
1170 | /*US | 1179 | /*US |
1171 | QDragObject *drag = dragObject(); | 1180 | QDragObject *drag = dragObject(); |
1172 | 1181 | ||
1173 | if (!drag) | 1182 | if (!drag) |
1174 | return; | 1183 | return; |
1175 | 1184 | ||
1176 | if (drag->drag() && drag->target() != viewport()) | 1185 | if (drag->drag() && drag->target() != viewport()) |
1177 | emit moved(); | 1186 | emit moved(); |
1178 | */ | 1187 | */ |
1179 | } | 1188 | } |
1180 | 1189 | ||
1181 | QDragObject *KListView::dragObject() | 1190 | QDragObject *KListView::dragObject() |
1182 | { | 1191 | { |
1183 | if (!currentItem()) | 1192 | if (!currentItem()) |
1184 | return 0; | 1193 | return 0; |
1185 | 1194 | ||
1186 | return new QStoredDrag("application/x-qlistviewitem", viewport()); | 1195 | return new QStoredDrag("application/x-qlistviewitem", viewport()); |
1187 | } | 1196 | } |
1188 | 1197 | ||
1189 | void KListView::setItemsMovable(bool b) | 1198 | void KListView::setItemsMovable(bool b) |
1190 | { | 1199 | { |
1191 | d->itemsMovable=b; | 1200 | d->itemsMovable=b; |
1192 | } | 1201 | } |
1193 | 1202 | ||
1194 | bool KListView::itemsMovable() const | 1203 | bool KListView::itemsMovable() const |
1195 | { | 1204 | { |
1196 | return d->itemsMovable; | 1205 | return d->itemsMovable; |
1197 | } | 1206 | } |
1198 | 1207 | ||
1199 | void KListView::setItemsRenameable(bool b) | 1208 | void KListView::setItemsRenameable(bool b) |
1200 | { | 1209 | { |
1201 | d->itemsRenameable=b; | 1210 | d->itemsRenameable=b; |
1202 | } | 1211 | } |
1203 | 1212 | ||
1204 | bool KListView::itemsRenameable() const | 1213 | bool KListView::itemsRenameable() const |
1205 | { | 1214 | { |
1206 | return d->itemsRenameable; | 1215 | return d->itemsRenameable; |
1207 | } | 1216 | } |
1208 | 1217 | ||
1209 | 1218 | ||
1210 | void KListView::setDragEnabled(bool b) | 1219 | void KListView::setDragEnabled(bool b) |
1211 | { | 1220 | { |
1212 | d->dragEnabled=b; | 1221 | d->dragEnabled=b; |
1213 | } | 1222 | } |
1214 | 1223 | ||
1215 | bool KListView::dragEnabled() const | 1224 | bool KListView::dragEnabled() const |
1216 | { | 1225 | { |
1217 | return d->dragEnabled; | 1226 | return d->dragEnabled; |
1218 | } | 1227 | } |
1219 | 1228 | ||
1220 | void KListView::setAutoOpen(bool b) | 1229 | void KListView::setAutoOpen(bool b) |
1221 | { | 1230 | { |
1222 | d->autoOpen=b; | 1231 | d->autoOpen=b; |
1223 | } | 1232 | } |
1224 | 1233 | ||
1225 | bool KListView::autoOpen() const | 1234 | bool KListView::autoOpen() const |
1226 | { | 1235 | { |
1227 | return d->autoOpen; | 1236 | return d->autoOpen; |
1228 | } | 1237 | } |
1229 | 1238 | ||
1230 | bool KListView::dropVisualizer() const | 1239 | bool KListView::dropVisualizer() const |
1231 | { | 1240 | { |
1232 | return d->dropVisualizer; | 1241 | return d->dropVisualizer; |
1233 | } | 1242 | } |
1234 | 1243 | ||
1235 | void KListView::setDropVisualizer(bool b) | 1244 | void KListView::setDropVisualizer(bool b) |
1236 | { | 1245 | { |
1237 | d->dropVisualizer=b; | 1246 | d->dropVisualizer=b; |
1238 | } | 1247 | } |
1239 | 1248 | ||
1240 | QPtrList<QListViewItem> KListView::selectedItems() const | 1249 | QPtrList<QListViewItem> KListView::selectedItems() const |
1241 | { | 1250 | { |
1242 | QPtrList<QListViewItem> list; | 1251 | QPtrList<QListViewItem> list; |
1243 | for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) | 1252 | for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) |
1244 | if (i->isSelected()) list.append(i); | 1253 | if (i->isSelected()) list.append(i); |
1245 | return list; | 1254 | return list; |
1246 | } | 1255 | } |
1247 | 1256 | ||
1248 | 1257 | ||
1249 | void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) | 1258 | void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) |
1250 | { | 1259 | { |
1251 | // sanity check - don't move a item into it's own child structure | 1260 | // sanity check - don't move a item into it's own child structure |
1252 | QListViewItem *i = parent; | 1261 | QListViewItem *i = parent; |
1253 | while(i) | 1262 | while(i) |
1254 | { | 1263 | { |
1255 | if(i == item) | 1264 | if(i == item) |
1256 | return; | 1265 | return; |
1257 | i = i->parent(); | 1266 | i = i->parent(); |
1258 | } | 1267 | } |
1259 | 1268 | ||
1260 | // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor | 1269 | // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor |
1261 | // in here, without ever deleting the item. | 1270 | // in here, without ever deleting the item. |
1262 | if (item->parent()) | 1271 | if (item->parent()) |
1263 | item->parent()->takeItem(item); | 1272 | item->parent()->takeItem(item); |
1264 | else | 1273 | else |
1265 | takeItem(item); | 1274 | takeItem(item); |
1266 | 1275 | ||
1267 | if (parent) | 1276 | if (parent) |
1268 | parent->insertItem(item); | 1277 | parent->insertItem(item); |
1269 | else | 1278 | else |
1270 | insertItem(item); | 1279 | insertItem(item); |
1271 | 1280 | ||
1272 | if (after) | 1281 | if (after) |
1273 | ;//item->moveToJustAfter(after); | 1282 | ;//item->moveToJustAfter(after); |
1274 | } | 1283 | } |
1275 | 1284 | ||
1276 | void KListView::contentsDragEnterEvent(QDragEnterEvent *event) | 1285 | void KListView::contentsDragEnterEvent(QDragEnterEvent *event) |
1277 | { | 1286 | { |
1278 | qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); | 1287 | qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); |
1279 | /*US | 1288 | /*US |
1280 | if (acceptDrag (event)) | 1289 | if (acceptDrag (event)) |
1281 | event->accept(); | 1290 | event->accept(); |
1282 | */ | 1291 | */ |
1283 | } | 1292 | } |
1284 | 1293 | ||
1285 | void KListView::setDropVisualizerWidth (int w) | 1294 | void KListView::setDropVisualizerWidth (int w) |
1286 | { | 1295 | { |
1287 | d->mDropVisualizerWidth = w > 0 ? w : 1; | 1296 | d->mDropVisualizerWidth = w > 0 ? w : 1; |
1288 | } | 1297 | } |
1289 | 1298 | ||
1290 | QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, | 1299 | QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, |
1291 | QListViewItem *after) | 1300 | QListViewItem *after) |
1292 | { | 1301 | { |
1293 | QRect insertmarker; | 1302 | QRect insertmarker; |
1294 | 1303 | ||
1295 | if (!after && !parent) | 1304 | if (!after && !parent) |
1296 | insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); | 1305 | insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); |
1297 | else | 1306 | else |
1298 | { | 1307 | { |
1299 | int level = 0; | 1308 | int level = 0; |
1300 | if (after) | 1309 | if (after) |
1301 | { | 1310 | { |
1302 | QListViewItem* it = 0L; | 1311 | QListViewItem* it = 0L; |
1303 | if (after->isOpen()) | 1312 | if (after->isOpen()) |
1304 | { | 1313 | { |
1305 | // Look for the last child (recursively) | 1314 | // Look for the last child (recursively) |
1306 | it = after->firstChild(); | 1315 | it = after->firstChild(); |
1307 | if (it) | 1316 | if (it) |
1308 | while (it->nextSibling() || it->firstChild()) | 1317 | while (it->nextSibling() || it->firstChild()) |
1309 | if ( it->nextSibling() ) | 1318 | if ( it->nextSibling() ) |
1310 | it = it->nextSibling(); | 1319 | it = it->nextSibling(); |
1311 | else | 1320 | else |
1312 | it = it->firstChild(); | 1321 | it = it->firstChild(); |
1313 | } | 1322 | } |
1314 | 1323 | ||
1315 | insertmarker = itemRect (it ? it : after); | 1324 | insertmarker = itemRect (it ? it : after); |
1316 | level = after->depth(); | 1325 | level = after->depth(); |
1317 | } | 1326 | } |
1318 | else if (parent) | 1327 | else if (parent) |
1319 | { | 1328 | { |
1320 | insertmarker = itemRect (parent); | 1329 | insertmarker = itemRect (parent); |
1321 | level = parent->depth() + 1; | 1330 | level = parent->depth() + 1; |
1322 | } | 1331 | } |
1323 | insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); | 1332 | insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); |
1324 | insertmarker.setRight (viewport()->width()); | 1333 | insertmarker.setRight (viewport()->width()); |
1325 | insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); | 1334 | insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); |
1326 | insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); | 1335 | insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); |
1327 | } | 1336 | } |
1328 | 1337 | ||
1329 | // This is not used anymore, at least by KListView itself (see viewportPaintEvent) | 1338 | // This is not used anymore, at least by KListView itself (see viewportPaintEvent) |
1330 | // Remove for KDE 3.0. | 1339 | // Remove for KDE 3.0. |
1331 | if (p) | 1340 | if (p) |
1332 | p->fillRect(insertmarker, Dense4Pattern); | 1341 | p->fillRect(insertmarker, Dense4Pattern); |
1333 | 1342 | ||
1334 | return insertmarker; | 1343 | return insertmarker; |
1335 | } | 1344 | } |
1336 | 1345 | ||
1337 | QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) | 1346 | QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) |
1338 | { | 1347 | { |
1339 | QRect r; | 1348 | QRect r; |
1340 | 1349 | ||
1341 | if (item) | 1350 | if (item) |
1342 | { | 1351 | { |
1343 | r = itemRect(item); | 1352 | r = itemRect(item); |
1344 | r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); | 1353 | r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); |
1345 | if (painter) { | 1354 | if (painter) { |
1346 | //US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), | 1355 | //US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), |
1347 | //US QStyle::Style_FocusAtBorder, colorGroup().highlight()); | 1356 | //US QStyle::Style_FocusAtBorder, colorGroup().highlight()); |
1348 | const QColor* pHighl = &(colorGroup().highlight()); | 1357 | const QColor* pHighl = &(colorGroup().highlight()); |
1349 | //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); | 1358 | //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); |
1350 | 1359 | ||
1351 | qDebug("KListView::drawItemHighlighter has to be verified"); | 1360 | qDebug("KListView::drawItemHighlighter has to be verified"); |
1352 | 1361 | ||
1353 | } | 1362 | } |
1354 | 1363 | ||
1355 | } | 1364 | } |
1356 | 1365 | ||
1357 | return r; | 1366 | return r; |
1358 | } | 1367 | } |
1359 | 1368 | ||
1360 | void KListView::cleanItemHighlighter () | 1369 | void KListView::cleanItemHighlighter () |
1361 | { | 1370 | { |
1362 | if (d->mOldDropHighlighter.isValid()) | 1371 | if (d->mOldDropHighlighter.isValid()) |
1363 | { | 1372 | { |
1364 | QRect rect=d->mOldDropHighlighter; | 1373 | QRect rect=d->mOldDropHighlighter; |
1365 | d->mOldDropHighlighter = QRect(); | 1374 | d->mOldDropHighlighter = QRect(); |
1366 | viewport()->repaint(rect, true); | 1375 | viewport()->repaint(rect, true); |
1367 | } | 1376 | } |
1368 | } | 1377 | } |
1369 | 1378 | ||
1370 | void KListView::rename(QListViewItem *item, int c) | 1379 | void KListView::rename(QListViewItem *item, int c) |
1371 | { | 1380 | { |
1372 | if (d->renameable.contains(c)) | 1381 | if (d->renameable.contains(c)) |
1373 | { | 1382 | { |
1374 | ensureItemVisible(item); | 1383 | ensureItemVisible(item); |
1375 | //US d->editor->load(item,c); | 1384 | //US d->editor->load(item,c); |
1376 | qDebug("KListView::rename has to be verified"); | 1385 | qDebug("KListView::rename has to be verified"); |
1377 | 1386 | ||
1378 | } | 1387 | } |
1379 | } | 1388 | } |
1380 | 1389 | ||
1381 | bool KListView::isRenameable (int col) const | 1390 | bool KListView::isRenameable (int col) const |
1382 | { | 1391 | { |
1383 | return d->renameable.contains(col); | 1392 | return d->renameable.contains(col); |
1384 | } | 1393 | } |
1385 | 1394 | ||
1386 | void KListView::setRenameable (int col, bool yesno) | 1395 | void KListView::setRenameable (int col, bool yesno) |
1387 | { | 1396 | { |
1388 | if (col>=header()->count()) return; | 1397 | if (col>=header()->count()) return; |
1389 | 1398 | ||
1390 | d->renameable.remove(col); | 1399 | d->renameable.remove(col); |
1391 | if (yesno && d->renameable.find(col)==d->renameable.end()) | 1400 | if (yesno && d->renameable.find(col)==d->renameable.end()) |
1392 | d->renameable+=col; | 1401 | d->renameable+=col; |
1393 | else if (!yesno && d->renameable.find(col)!=d->renameable.end()) | 1402 | else if (!yesno && d->renameable.find(col)!=d->renameable.end()) |
1394 | d->renameable.remove(col); | 1403 | d->renameable.remove(col); |
1395 | } | 1404 | } |
1396 | 1405 | ||
1397 | void KListView::doneEditing(QListViewItem *item, int row) | 1406 | void KListView::doneEditing(QListViewItem *item, int row) |
1398 | { | 1407 | { |
1399 | emit itemRenamed(item, item->text(row), row); | 1408 | emit itemRenamed(item, item->text(row), row); |
1400 | emit itemRenamed(item); | 1409 | emit itemRenamed(item); |
1401 | } | 1410 | } |
1402 | 1411 | ||
1403 | bool KListView::acceptDrag(QDropEvent* e) const | 1412 | bool KListView::acceptDrag(QDropEvent* e) const |
1404 | { | 1413 | { |
1405 | qDebug("KListView::acceptDrag drag&drop not supported yet"); | 1414 | qDebug("KListView::acceptDrag drag&drop not supported yet"); |
1406 | //US return acceptDrops() && itemsMovable() && (e->source()==viewport()); | 1415 | //US return acceptDrops() && itemsMovable() && (e->source()==viewport()); |
1407 | return false; | 1416 | return false; |
1408 | } | 1417 | } |
1409 | 1418 | ||
1410 | void KListView::setCreateChildren(bool b) | 1419 | void KListView::setCreateChildren(bool b) |
1411 | { | 1420 | { |
1412 | d->createChildren=b; | 1421 | d->createChildren=b; |
1413 | } | 1422 | } |
1414 | 1423 | ||
1415 | bool KListView::createChildren() const | 1424 | bool KListView::createChildren() const |
1416 | { | 1425 | { |
1417 | return d->createChildren; | 1426 | return d->createChildren; |
1418 | } | 1427 | } |
1419 | 1428 | ||
1420 | 1429 | ||
1421 | int KListView::tooltipColumn() const | 1430 | int KListView::tooltipColumn() const |
1422 | { | 1431 | { |
1423 | return d->tooltipColumn; | 1432 | return d->tooltipColumn; |
1424 | } | 1433 | } |
1425 | 1434 | ||
1426 | void KListView::setTooltipColumn(int column) | 1435 | void KListView::setTooltipColumn(int column) |
1427 | { | 1436 | { |
1428 | d->tooltipColumn=column; | 1437 | d->tooltipColumn=column; |
1429 | } | 1438 | } |
1430 | 1439 | ||
1431 | void KListView::setDropHighlighter(bool b) | 1440 | void KListView::setDropHighlighter(bool b) |
1432 | { | 1441 | { |
1433 | d->dropHighlighter=b; | 1442 | d->dropHighlighter=b; |
1434 | } | 1443 | } |
1435 | 1444 | ||
1436 | bool KListView::dropHighlighter() const | 1445 | bool KListView::dropHighlighter() const |
1437 | { | 1446 | { |
1438 | return d->dropHighlighter; | 1447 | return d->dropHighlighter; |
1439 | } | 1448 | } |
1440 | 1449 | ||
1441 | bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const | 1450 | bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const |
1442 | { | 1451 | { |
1443 | return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); | 1452 | return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); |
1444 | } | 1453 | } |
1445 | 1454 | ||
1446 | QString KListView::tooltip(QListViewItem *item, int column) const | 1455 | QString KListView::tooltip(QListViewItem *item, int column) const |
1447 | { | 1456 | { |
1448 | return item->text(column); | 1457 | return item->text(column); |
1449 | } | 1458 | } |
1450 | 1459 | ||
1451 | void KListView::setTabOrderedRenaming(bool b) | 1460 | void KListView::setTabOrderedRenaming(bool b) |
1452 | { | 1461 | { |
1453 | d->tabRename = b; | 1462 | d->tabRename = b; |
1454 | } | 1463 | } |
1455 | 1464 | ||
1456 | bool KListView::tabOrderedRenaming() const | 1465 | bool KListView::tabOrderedRenaming() const |
1457 | { | 1466 | { |
1458 | return d->tabRename; | 1467 | return d->tabRename; |
1459 | } | 1468 | } |
1460 | 1469 | ||
1461 | void KListView::keyPressEvent (QKeyEvent* e) | 1470 | void KListView::keyPressEvent (QKeyEvent* e) |
1462 | { | 1471 | { |
1463 | //don't we need a contextMenuModifier too ? (aleXXX) | 1472 | //don't we need a contextMenuModifier too ? (aleXXX) |
1464 | if (e->key() == d->contextMenuKey) | 1473 | if (e->key() == d->contextMenuKey) |
1465 | { | 1474 | { |
1466 | emit menuShortCutPressed (this, currentItem()); | 1475 | emit menuShortCutPressed (this, currentItem()); |
1467 | return; | 1476 | return; |
1468 | } | 1477 | } |
1469 | if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) | 1478 | if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) |
1470 | { | 1479 | { |
1471 | emit signalDelete ( ); | 1480 | emit signalDelete ( ); |
1472 | return; | 1481 | return; |
1473 | } | 1482 | } |
1474 | 1483 | ||
1475 | if (d->selectionMode != FileManager) | 1484 | if (d->selectionMode != FileManager) |
1476 | QListView::keyPressEvent (e); | 1485 | QListView::keyPressEvent (e); |
1477 | else | 1486 | else |
1478 | fileManagerKeyPressEvent (e); | 1487 | fileManagerKeyPressEvent (e); |
1479 | } | 1488 | } |
1480 | 1489 | ||
1481 | void KListView::activateAutomaticSelection() | 1490 | void KListView::activateAutomaticSelection() |
1482 | { | 1491 | { |
1483 | d->selectedBySimpleMove=true; | 1492 | d->selectedBySimpleMove=true; |
1484 | d->selectedUsingMouse=false; | 1493 | d->selectedUsingMouse=false; |
1485 | if (currentItem()!=0) | 1494 | if (currentItem()!=0) |
1486 | { | 1495 | { |
1487 | selectAll(false); | 1496 | selectAll(false); |
1488 | currentItem()->setSelected(true); | 1497 | currentItem()->setSelected(true); |
1489 | currentItem()->repaint(); | 1498 | currentItem()->repaint(); |
1490 | emit selectionChanged(); | 1499 | emit selectionChanged(); |
1491 | }; | 1500 | }; |
1492 | } | 1501 | } |
1493 | 1502 | ||
1494 | void KListView::deactivateAutomaticSelection() | 1503 | void KListView::deactivateAutomaticSelection() |
1495 | { | 1504 | { |
1496 | d->selectedBySimpleMove=false; | 1505 | d->selectedBySimpleMove=false; |
1497 | } | 1506 | } |
1498 | 1507 | ||
1499 | bool KListView::automaticSelection() const | 1508 | bool KListView::automaticSelection() const |
1500 | { | 1509 | { |
1501 | return d->selectedBySimpleMove; | 1510 | return d->selectedBySimpleMove; |
1502 | } | 1511 | } |
1503 | 1512 | ||
1504 | void KListView::fileManagerKeyPressEvent (QKeyEvent* e) | 1513 | void KListView::fileManagerKeyPressEvent (QKeyEvent* e) |
1505 | { | 1514 | { |
1506 | //don't care whether it's on the keypad or not | 1515 | //don't care whether it's on the keypad or not |
1507 | int e_state=(e->state() & ~Keypad); | 1516 | int e_state=(e->state() & ~Keypad); |
1508 | 1517 | ||
1509 | int oldSelectionDirection(d->selectionDirection); | 1518 | int oldSelectionDirection(d->selectionDirection); |
1510 | 1519 | ||
1511 | if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) | 1520 | if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) |
1512 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) | 1521 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) |
1513 | { | 1522 | { |
1514 | if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) | 1523 | if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) |
1515 | selectAll(FALSE); | 1524 | selectAll(FALSE); |
1516 | d->selectionDirection=0; | 1525 | d->selectionDirection=0; |
1517 | d->wasShiftEvent = (e_state == ShiftButton); | 1526 | d->wasShiftEvent = (e_state == ShiftButton); |
1518 | }; | 1527 | }; |
1519 | 1528 | ||
1520 | //d->wasShiftEvent = (e_state == ShiftButton); | 1529 | //d->wasShiftEvent = (e_state == ShiftButton); |
1521 | 1530 | ||
1522 | 1531 | ||
1523 | QListViewItem* item = currentItem(); | 1532 | QListViewItem* item = currentItem(); |
1524 | if (item==0) return; | 1533 | if (item==0) return; |
1525 | 1534 | ||
1526 | QListViewItem* repaintItem1 = item; | 1535 | QListViewItem* repaintItem1 = item; |
1527 | QListViewItem* repaintItem2 = 0L; | 1536 | QListViewItem* repaintItem2 = 0L; |
1528 | QListViewItem* visItem = 0L; | 1537 | QListViewItem* visItem = 0L; |
1529 | 1538 | ||
1530 | QListViewItem* nextItem = 0L; | 1539 | QListViewItem* nextItem = 0L; |
1531 | int items = 0; | 1540 | int items = 0; |
1532 | 1541 | ||
1533 | bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); | 1542 | bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); |
1534 | int selectedItems(0); | 1543 | int selectedItems(0); |
1535 | for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) | 1544 | for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) |
1536 | if (tmpItem->isSelected()) selectedItems++; | 1545 | if (tmpItem->isSelected()) selectedItems++; |
1537 | 1546 | ||
1538 | if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) | 1547 | if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) |
1539 | && (e_state==NoButton) | 1548 | && (e_state==NoButton) |
1540 | && ((e->key()==Key_Down) | 1549 | && ((e->key()==Key_Down) |
1541 | || (e->key()==Key_Up) | 1550 | || (e->key()==Key_Up) |
1542 | || (e->key()==Key_Next) | 1551 | || (e->key()==Key_Next) |
1543 | || (e->key()==Key_Prior) | 1552 | || (e->key()==Key_Prior) |
1544 | || (e->key()==Key_Home) | 1553 | || (e->key()==Key_Home) |
1545 | || (e->key()==Key_End))) | 1554 | || (e->key()==Key_End))) |
1546 | { | 1555 | { |
1547 | d->selectedBySimpleMove=true; | 1556 | d->selectedBySimpleMove=true; |
1548 | d->selectedUsingMouse=false; | 1557 | d->selectedUsingMouse=false; |
1549 | } | 1558 | } |
1550 | else if (selectedItems>1) | 1559 | else if (selectedItems>1) |
1551 | d->selectedBySimpleMove=false; | 1560 | d->selectedBySimpleMove=false; |
1552 | 1561 | ||
1553 | bool emitSelectionChanged(false); | 1562 | bool emitSelectionChanged(false); |
1554 | 1563 | ||
1555 | switch (e->key()) | 1564 | switch (e->key()) |
1556 | { | 1565 | { |
1557 | case Key_Escape: | 1566 | case Key_Escape: |
1558 | selectAll(FALSE); | 1567 | selectAll(FALSE); |
1559 | emitSelectionChanged=TRUE; | 1568 | emitSelectionChanged=TRUE; |
1560 | break; | 1569 | break; |
1561 | 1570 | ||
1562 | case Key_Space: | 1571 | case Key_Space: |
1563 | //toggle selection of current item | 1572 | //toggle selection of current item |
1564 | if (d->selectedBySimpleMove) | 1573 | if (d->selectedBySimpleMove) |
1565 | d->selectedBySimpleMove=false; | 1574 | d->selectedBySimpleMove=false; |
1566 | item->setSelected(!item->isSelected()); | 1575 | item->setSelected(!item->isSelected()); |
1567 | emitSelectionChanged=TRUE; | 1576 | emitSelectionChanged=TRUE; |
1568 | break; | 1577 | break; |
1569 | 1578 | ||
1570 | case Key_Insert: | 1579 | case Key_Insert: |
1571 | //toggle selection of current item and move to the next item | 1580 | //toggle selection of current item and move to the next item |
1572 | if (d->selectedBySimpleMove) | 1581 | if (d->selectedBySimpleMove) |
1573 | { | 1582 | { |
1574 | d->selectedBySimpleMove=false; | 1583 | d->selectedBySimpleMove=false; |
1575 | if (!item->isSelected()) item->setSelected(TRUE); | 1584 | if (!item->isSelected()) item->setSelected(TRUE); |
1576 | } | 1585 | } |
1577 | else | 1586 | else |
1578 | { | 1587 | { |
1579 | item->setSelected(!item->isSelected()); | 1588 | item->setSelected(!item->isSelected()); |
1580 | }; | 1589 | }; |
1581 | 1590 | ||
1582 | nextItem=item->itemBelow(); | 1591 | nextItem=item->itemBelow(); |
1583 | 1592 | ||
1584 | if (nextItem!=0) | 1593 | if (nextItem!=0) |
1585 | { | 1594 | { |
1586 | repaintItem2=nextItem; | 1595 | repaintItem2=nextItem; |
1587 | visItem=nextItem; | 1596 | visItem=nextItem; |
1588 | setCurrentItem(nextItem); | 1597 | setCurrentItem(nextItem); |
1589 | }; | 1598 | }; |
1590 | d->selectionDirection=1; | 1599 | d->selectionDirection=1; |
1591 | emitSelectionChanged=TRUE; | 1600 | emitSelectionChanged=TRUE; |
1592 | break; | 1601 | break; |
1593 | 1602 | ||
1594 | case Key_Down: | 1603 | case Key_Down: |
1595 | nextItem=item->itemBelow(); | 1604 | nextItem=item->itemBelow(); |
1596 | //toggle selection of current item and move to the next item | 1605 | //toggle selection of current item and move to the next item |
1597 | if (shiftOrCtrl) | 1606 | if (shiftOrCtrl) |
1598 | { | 1607 | { |
1599 | d->selectionDirection=1; | 1608 | d->selectionDirection=1; |
1600 | if (d->selectedBySimpleMove) | 1609 | if (d->selectedBySimpleMove) |
1601 | d->selectedBySimpleMove=false; | 1610 | d->selectedBySimpleMove=false; |
1602 | else | 1611 | else |
1603 | { | 1612 | { |
1604 | if (oldSelectionDirection!=-1) | 1613 | if (oldSelectionDirection!=-1) |
1605 | { | 1614 | { |
1606 | item->setSelected(!item->isSelected()); | 1615 | item->setSelected(!item->isSelected()); |
1607 | emitSelectionChanged=TRUE; | 1616 | emitSelectionChanged=TRUE; |
1608 | }; | 1617 | }; |
1609 | }; | 1618 | }; |
1610 | } | 1619 | } |
1611 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) | 1620 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) |
1612 | { | 1621 | { |
1613 | item->setSelected(false); | 1622 | item->setSelected(false); |
1614 | emitSelectionChanged=TRUE; | 1623 | emitSelectionChanged=TRUE; |
1615 | }; | 1624 | }; |
1616 | 1625 | ||
1617 | if (nextItem!=0) | 1626 | if (nextItem!=0) |
1618 | { | 1627 | { |
1619 | if (d->selectedBySimpleMove) | 1628 | if (d->selectedBySimpleMove) |
1620 | nextItem->setSelected(true); | 1629 | nextItem->setSelected(true); |
1621 | repaintItem2=nextItem; | 1630 | repaintItem2=nextItem; |
1622 | visItem=nextItem; | 1631 | visItem=nextItem; |
1623 | setCurrentItem(nextItem); | 1632 | setCurrentItem(nextItem); |
1624 | }; | 1633 | }; |
1625 | break; | 1634 | break; |
1626 | 1635 | ||
1627 | case Key_Up: | 1636 | case Key_Up: |
1628 | nextItem=item->itemAbove(); | 1637 | nextItem=item->itemAbove(); |
1629 | d->selectionDirection=-1; | 1638 | d->selectionDirection=-1; |
1630 | //move to the prev. item and toggle selection of this one | 1639 | //move to the prev. item and toggle selection of this one |
1631 | // => No, can't select the last item, with this. For symmetry, let's | 1640 | // => No, can't select the last item, with this. For symmetry, let's |
1632 | // toggle selection and THEN move up, just like we do in down (David) | 1641 | // toggle selection and THEN move up, just like we do in down (David) |
1633 | if (shiftOrCtrl) | 1642 | if (shiftOrCtrl) |
1634 | { | 1643 | { |
1635 | if (d->selectedBySimpleMove) | 1644 | if (d->selectedBySimpleMove) |
1636 | d->selectedBySimpleMove=false; | 1645 | d->selectedBySimpleMove=false; |
1637 | else | 1646 | else |
1638 | { | 1647 | { |
1639 | if (oldSelectionDirection!=1) | 1648 | if (oldSelectionDirection!=1) |
1640 | { | 1649 | { |
1641 | item->setSelected(!item->isSelected()); | 1650 | item->setSelected(!item->isSelected()); |
1642 | emitSelectionChanged=TRUE; | 1651 | emitSelectionChanged=TRUE; |
1643 | }; | 1652 | }; |
1644 | } | 1653 | } |
1645 | } | 1654 | } |
1646 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) | 1655 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) |
1647 | { | 1656 | { |
1648 | item->setSelected(false); | 1657 | item->setSelected(false); |
1649 | emitSelectionChanged=TRUE; | 1658 | emitSelectionChanged=TRUE; |
1650 | }; | 1659 | }; |
1651 | 1660 | ||
1652 | if (nextItem!=0) | 1661 | if (nextItem!=0) |
1653 | { | 1662 | { |
1654 | if (d->selectedBySimpleMove) | 1663 | if (d->selectedBySimpleMove) |
1655 | nextItem->setSelected(true); | 1664 | nextItem->setSelected(true); |
1656 | repaintItem2=nextItem; | 1665 | repaintItem2=nextItem; |
1657 | visItem=nextItem; | 1666 | visItem=nextItem; |
1658 | setCurrentItem(nextItem); | 1667 | setCurrentItem(nextItem); |
1659 | }; | 1668 | }; |
1660 | break; | 1669 | break; |
1661 | 1670 | ||
1662 | case Key_End: | 1671 | case Key_End: |
1663 | //move to the last item and toggle selection of all items inbetween | 1672 | //move to the last item and toggle selection of all items inbetween |
1664 | nextItem=item; | 1673 | nextItem=item; |
1665 | if (d->selectedBySimpleMove) | 1674 | if (d->selectedBySimpleMove) |
1666 | item->setSelected(false); | 1675 | item->setSelected(false); |
1667 | if (shiftOrCtrl) | 1676 | if (shiftOrCtrl) |
1668 | d->selectedBySimpleMove=false; | 1677 | d->selectedBySimpleMove=false; |
1669 | 1678 | ||
1670 | while(nextItem!=0) | 1679 | while(nextItem!=0) |
1671 | { | 1680 | { |
1672 | if (shiftOrCtrl) | 1681 | if (shiftOrCtrl) |
1673 | nextItem->setSelected(!nextItem->isSelected()); | 1682 | nextItem->setSelected(!nextItem->isSelected()); |
1674 | if (nextItem->itemBelow()==0) | 1683 | if (nextItem->itemBelow()==0) |
1675 | { | 1684 | { |
1676 | if (d->selectedBySimpleMove) | 1685 | if (d->selectedBySimpleMove) |
1677 | nextItem->setSelected(true); | 1686 | nextItem->setSelected(true); |
1678 | repaintItem2=nextItem; | 1687 | repaintItem2=nextItem; |
1679 | visItem=nextItem; | 1688 | visItem=nextItem; |
1680 | setCurrentItem(nextItem); | 1689 | setCurrentItem(nextItem); |
1681 | } | 1690 | } |
1682 | nextItem=nextItem->itemBelow(); | 1691 | nextItem=nextItem->itemBelow(); |
1683 | } | 1692 | } |
1684 | emitSelectionChanged=TRUE; | 1693 | emitSelectionChanged=TRUE; |
1685 | break; | 1694 | break; |
1686 | 1695 | ||
1687 | case Key_Home: | 1696 | case Key_Home: |
1688 | // move to the first item and toggle selection of all items inbetween | 1697 | // move to the first item and toggle selection of all items inbetween |
1689 | nextItem = firstChild(); | 1698 | nextItem = firstChild(); |
1690 | visItem = nextItem; | 1699 | visItem = nextItem; |
1691 | repaintItem2 = visItem; | 1700 | repaintItem2 = visItem; |
1692 | if (d->selectedBySimpleMove) | 1701 | if (d->selectedBySimpleMove) |
1693 | item->setSelected(false); | 1702 | item->setSelected(false); |
1694 | if (shiftOrCtrl) | 1703 | if (shiftOrCtrl) |
1695 | { | 1704 | { |
1696 | d->selectedBySimpleMove=false; | 1705 | d->selectedBySimpleMove=false; |
1697 | 1706 | ||
1698 | while ( nextItem != item ) | 1707 | while ( nextItem != item ) |
1699 | { | 1708 | { |
1700 | nextItem->setSelected( !nextItem->isSelected() ); | 1709 | nextItem->setSelected( !nextItem->isSelected() ); |
1701 | nextItem = nextItem->itemBelow(); | 1710 | nextItem = nextItem->itemBelow(); |
1702 | } | 1711 | } |
1703 | item->setSelected( !item->isSelected() ); | 1712 | item->setSelected( !item->isSelected() ); |
1704 | } | 1713 | } |
1705 | setCurrentItem( firstChild() ); | 1714 | setCurrentItem( firstChild() ); |
1706 | emitSelectionChanged=TRUE; | 1715 | emitSelectionChanged=TRUE; |
1707 | break; | 1716 | break; |
1708 | 1717 | ||
1709 | case Key_Next: | 1718 | case Key_Next: |
1710 | items=visibleHeight()/item->height(); | 1719 | items=visibleHeight()/item->height(); |
1711 | nextItem=item; | 1720 | nextItem=item; |
1712 | if (d->selectedBySimpleMove) | 1721 | if (d->selectedBySimpleMove) |
1713 | item->setSelected(false); | 1722 | item->setSelected(false); |
1714 | if (shiftOrCtrl) | 1723 | if (shiftOrCtrl) |
1715 | { | 1724 | { |
1716 | d->selectedBySimpleMove=false; | 1725 | d->selectedBySimpleMove=false; |
1717 | d->selectionDirection=1; | 1726 | d->selectionDirection=1; |
1718 | }; | 1727 | }; |
1719 | 1728 | ||
1720 | for (int i=0; i<items; i++) | 1729 | for (int i=0; i<items; i++) |
1721 | { | 1730 | { |
1722 | if (shiftOrCtrl) | 1731 | if (shiftOrCtrl) |
1723 | nextItem->setSelected(!nextItem->isSelected()); | 1732 | nextItem->setSelected(!nextItem->isSelected()); |
1724 | //the end | 1733 | //the end |
1725 | if ((i==items-1) || (nextItem->itemBelow()==0)) | 1734 | if ((i==items-1) || (nextItem->itemBelow()==0)) |
1726 | 1735 | ||
1727 | { | 1736 | { |
1728 | if (shiftOrCtrl) | 1737 | if (shiftOrCtrl) |
1729 | nextItem->setSelected(!nextItem->isSelected()); | 1738 | nextItem->setSelected(!nextItem->isSelected()); |
1730 | if (d->selectedBySimpleMove) | 1739 | if (d->selectedBySimpleMove) |
1731 | nextItem->setSelected(true); | 1740 | nextItem->setSelected(true); |
1732 | ensureItemVisible(nextItem); | 1741 | ensureItemVisible(nextItem); |
1733 | setCurrentItem(nextItem); | 1742 | setCurrentItem(nextItem); |
1734 | update(); | 1743 | update(); |
1735 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) | 1744 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) |
1736 | { | 1745 | { |
1737 | emit selectionChanged(); | 1746 | emit selectionChanged(); |
1738 | } | 1747 | } |
1739 | return; | 1748 | return; |
1740 | } | 1749 | } |
1741 | nextItem=nextItem->itemBelow(); | 1750 | nextItem=nextItem->itemBelow(); |
1742 | } | 1751 | } |
1743 | break; | 1752 | break; |
1744 | 1753 | ||
1745 | case Key_Prior: | 1754 | case Key_Prior: |
1746 | items=visibleHeight()/item->height(); | 1755 | items=visibleHeight()/item->height(); |
1747 | nextItem=item; | 1756 | nextItem=item; |
1748 | if (d->selectedBySimpleMove) | 1757 | if (d->selectedBySimpleMove) |
1749 | item->setSelected(false); | 1758 | item->setSelected(false); |
1750 | if (shiftOrCtrl) | 1759 | if (shiftOrCtrl) |
1751 | { | 1760 | { |
1752 | d->selectionDirection=-1; | 1761 | d->selectionDirection=-1; |
1753 | d->selectedBySimpleMove=false; | 1762 | d->selectedBySimpleMove=false; |
1754 | }; | 1763 | }; |
1755 | 1764 | ||
1756 | for (int i=0; i<items; i++) | 1765 | for (int i=0; i<items; i++) |
1757 | { | 1766 | { |
1758 | if ((nextItem!=item) &&(shiftOrCtrl)) | 1767 | if ((nextItem!=item) &&(shiftOrCtrl)) |
1759 | nextItem->setSelected(!nextItem->isSelected()); | 1768 | nextItem->setSelected(!nextItem->isSelected()); |
1760 | //the end | 1769 | //the end |
1761 | if ((i==items-1) || (nextItem->itemAbove()==0)) | 1770 | if ((i==items-1) || (nextItem->itemAbove()==0)) |
1762 | 1771 | ||
1763 | { | 1772 | { |
1764 | if (d->selectedBySimpleMove) | 1773 | if (d->selectedBySimpleMove) |
1765 | nextItem->setSelected(true); | 1774 | nextItem->setSelected(true); |
1766 | ensureItemVisible(nextItem); | 1775 | ensureItemVisible(nextItem); |
1767 | setCurrentItem(nextItem); | 1776 | setCurrentItem(nextItem); |
1768 | update(); | 1777 | update(); |
1769 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) | 1778 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) |
1770 | { | 1779 | { |
1771 | emit selectionChanged(); | 1780 | emit selectionChanged(); |
1772 | } | 1781 | } |
1773 | return; | 1782 | return; |
1774 | } | 1783 | } |
1775 | nextItem=nextItem->itemAbove(); | 1784 | nextItem=nextItem->itemAbove(); |
1776 | } | 1785 | } |
1777 | break; | 1786 | break; |
1778 | 1787 | ||
1779 | case Key_Minus: | 1788 | case Key_Minus: |
1780 | if ( item->isOpen() ) | 1789 | if ( item->isOpen() ) |
1781 | setOpen( item, FALSE ); | 1790 | setOpen( item, FALSE ); |
1782 | break; | 1791 | break; |
1783 | case Key_Plus: | 1792 | case Key_Plus: |
1784 | if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) | 1793 | if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) |
1785 | setOpen( item, TRUE ); | 1794 | setOpen( item, TRUE ); |
1786 | break; | 1795 | break; |
1787 | default: | 1796 | default: |
1788 | bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) | 1797 | bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) |
1789 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); | 1798 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); |
1790 | 1799 | ||
1791 | bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); | 1800 | bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); |
1792 | if (realKey && selectCurrentItem) | 1801 | if (realKey && selectCurrentItem) |
1793 | item->setSelected(false); | 1802 | item->setSelected(false); |
1794 | //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) | 1803 | //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) |
1795 | QListView::SelectionMode oldSelectionMode = selectionMode(); | 1804 | QListView::SelectionMode oldSelectionMode = selectionMode(); |
1796 | setSelectionMode (QListView::Multi); | 1805 | setSelectionMode (QListView::Multi); |
1797 | QListView::keyPressEvent (e); | 1806 | QListView::keyPressEvent (e); |
1798 | setSelectionMode (oldSelectionMode); | 1807 | setSelectionMode (oldSelectionMode); |
1799 | if (realKey && selectCurrentItem) | 1808 | if (realKey && selectCurrentItem) |
1800 | { | 1809 | { |
1801 | currentItem()->setSelected(true); | 1810 | currentItem()->setSelected(true); |
1802 | emitSelectionChanged=TRUE; | 1811 | emitSelectionChanged=TRUE; |
1803 | } | 1812 | } |
1804 | repaintItem2=currentItem(); | 1813 | repaintItem2=currentItem(); |
1805 | if (realKey) | 1814 | if (realKey) |
1806 | visItem=currentItem(); | 1815 | visItem=currentItem(); |
1807 | break; | 1816 | break; |
1808 | } | 1817 | } |
1809 | 1818 | ||
1810 | if (visItem) | 1819 | if (visItem) |
1811 | ensureItemVisible(visItem); | 1820 | ensureItemVisible(visItem); |
1812 | 1821 | ||
1813 | QRect ir; | 1822 | QRect ir; |
1814 | if (repaintItem1) | 1823 | if (repaintItem1) |
1815 | ir = ir.unite( itemRect(repaintItem1) ); | 1824 | ir = ir.unite( itemRect(repaintItem1) ); |
1816 | if (repaintItem2) | 1825 | if (repaintItem2) |
1817 | ir = ir.unite( itemRect(repaintItem2) ); | 1826 | ir = ir.unite( itemRect(repaintItem2) ); |
1818 | 1827 | ||
1819 | if ( !ir.isEmpty() ) | 1828 | if ( !ir.isEmpty() ) |
1820 | { // rectangle to be repainted | 1829 | { // rectangle to be repainted |
1821 | if ( ir.x() < 0 ) | 1830 | if ( ir.x() < 0 ) |
1822 | ir.moveBy( -ir.x(), 0 ); | 1831 | ir.moveBy( -ir.x(), 0 ); |
1823 | viewport()->repaint( ir, FALSE ); | 1832 | viewport()->repaint( ir, FALSE ); |
1824 | } | 1833 | } |
1825 | /*if (repaintItem1) | 1834 | /*if (repaintItem1) |
1826 | repaintItem1->repaint(); | 1835 | repaintItem1->repaint(); |
1827 | if (repaintItem2) | 1836 | if (repaintItem2) |
1828 | repaintItem2->repaint();*/ | 1837 | repaintItem2->repaint();*/ |
1829 | update(); | 1838 | update(); |
1830 | if (emitSelectionChanged) | 1839 | if (emitSelectionChanged) |
1831 | emit selectionChanged(); | 1840 | emit selectionChanged(); |
1832 | } | 1841 | } |
1833 | 1842 | ||
1834 | void KListView::setSelectionModeExt (SelectionModeExt mode) | 1843 | void KListView::setSelectionModeExt (SelectionModeExt mode) |
1835 | { | 1844 | { |
1836 | d->selectionMode = mode; | 1845 | d->selectionMode = mode; |
1837 | 1846 | ||
1838 | switch (mode) | 1847 | switch (mode) |
1839 | { | 1848 | { |
1840 | case Single: | 1849 | case Single: |
1841 | case Multi: | 1850 | case Multi: |
1842 | case Extended: | 1851 | case Extended: |
1843 | case NoSelection: | 1852 | case NoSelection: |
1844 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); | 1853 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); |
1845 | break; | 1854 | break; |
1846 | 1855 | ||
1847 | case FileManager: | 1856 | case FileManager: |
1848 | setSelectionMode (QListView::Extended); | 1857 | setSelectionMode (QListView::Extended); |
1849 | break; | 1858 | break; |
1850 | 1859 | ||
1851 | default: | 1860 | default: |
1852 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; | 1861 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; |
1853 | break; | 1862 | break; |
1854 | } | 1863 | } |
1855 | } | 1864 | } |
1856 | 1865 | ||
1857 | KListView::SelectionModeExt KListView::selectionModeExt () const | 1866 | KListView::SelectionModeExt KListView::selectionModeExt () const |
1858 | { | 1867 | { |
1859 | return d->selectionMode; | 1868 | return d->selectionMode; |
1860 | } | 1869 | } |
1861 | 1870 | ||
1862 | int KListView::itemIndex( const QListViewItem *item ) const | 1871 | int KListView::itemIndex( const QListViewItem *item ) const |
1863 | { | 1872 | { |
1864 | if ( !item ) | 1873 | if ( !item ) |
1865 | return -1; | 1874 | return -1; |
1866 | 1875 | ||
1867 | if ( item == firstChild() ) | 1876 | if ( item == firstChild() ) |
1868 | return 0; | 1877 | return 0; |
1869 | else { | 1878 | else { |
1870 | QListViewItemIterator it(firstChild()); | 1879 | QListViewItemIterator it(firstChild()); |
1871 | uint j = 0; | 1880 | uint j = 0; |
1872 | for (; it.current() && it.current() != item; ++it, ++j ); | 1881 | for (; it.current() && it.current() != item; ++it, ++j ); |
1873 | 1882 | ||
1874 | if( !it.current() ) | 1883 | if( !it.current() ) |
1875 | return -1; | 1884 | return -1; |
1876 | 1885 | ||
1877 | return j; | 1886 | return j; |
1878 | } | 1887 | } |
1879 | } | 1888 | } |
1880 | 1889 | ||
1881 | QListViewItem* KListView::itemAtIndex(int index) | 1890 | QListViewItem* KListView::itemAtIndex(int index) |
1882 | { | 1891 | { |
1883 | if (index<0) | 1892 | if (index<0) |
1884 | return 0; | 1893 | return 0; |
1885 | 1894 | ||
1886 | int j(0); | 1895 | int j(0); |
1887 | for (QListViewItemIterator it=firstChild(); it.current(); it++) | 1896 | for (QListViewItemIterator it=firstChild(); it.current(); it++) |
1888 | { | 1897 | { |
1889 | if (j==index) | 1898 | if (j==index) |
1890 | return it.current(); | 1899 | return it.current(); |
1891 | j++; | 1900 | j++; |
1892 | }; | 1901 | }; |
1893 | return 0; | 1902 | return 0; |
1894 | } | 1903 | } |
1895 | 1904 | ||
1896 | 1905 | ||
1897 | void KListView::emitContextMenu (KListView*, QListViewItem* i) | 1906 | void KListView::emitContextMenu (KListView*, QListViewItem* i) |
1898 | { | 1907 | { |
1899 | QPoint p; | 1908 | QPoint p; |
1900 | // qDebug("KListView::emitContextMenu "); | 1909 | // qDebug("KListView::emitContextMenu "); |
1901 | 1910 | ||
1902 | if (i) | 1911 | if (i) |
1903 | p = viewport()->mapToGlobal(itemRect(i).center()); | 1912 | p = viewport()->mapToGlobal(itemRect(i).center()); |
1904 | else | 1913 | else |
1905 | p = mapToGlobal(rect().center()); | 1914 | p = mapToGlobal(rect().center()); |
1906 | 1915 | ||
1907 | emit contextMenu (this, i, p); | 1916 | emit contextMenu (this, i, p); |
1908 | } | 1917 | } |
1909 | 1918 | ||
1910 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) | 1919 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) |
1911 | { | 1920 | { |
1912 | QListViewItem* item = i; | 1921 | QListViewItem* item = i; |
1913 | int c = col; | 1922 | int c = col; |
1914 | // do not trust the values for QListViewItem* i and int col; | 1923 | // do not trust the values for QListViewItem* i and int col; |
1915 | // qDebug("KListView::emitContextMenu col"); | 1924 | // qDebug("KListView::emitContextMenu col"); |
1916 | if ( col == -1 ) { | 1925 | if ( col == -1 ) { |
1917 | QPoint pp = viewport()->mapFromGlobal(p); | 1926 | QPoint pp = viewport()->mapFromGlobal(p); |
1918 | item = itemAt( pp); | 1927 | item = itemAt( pp); |
1919 | c = header()->sectionAt(pp.x() ); | 1928 | c = header()->sectionAt(pp.x() ); |
1920 | } | 1929 | } |
1921 | emit contextRequest( item, p, c ); | 1930 | emit contextRequest( item, p, c ); |
1922 | emit contextMenu (this, item, p); | 1931 | emit contextMenu (this, item, p); |
1923 | } | 1932 | } |
1924 | 1933 | ||
1925 | void KListView::setAcceptDrops (bool val) | 1934 | void KListView::setAcceptDrops (bool val) |
1926 | { | 1935 | { |
1927 | QListView::setAcceptDrops (val); | 1936 | QListView::setAcceptDrops (val); |
1928 | viewport()->setAcceptDrops (val); | 1937 | viewport()->setAcceptDrops (val); |
1929 | } | 1938 | } |
1930 | 1939 | ||
1931 | int KListView::dropVisualizerWidth () const | 1940 | int KListView::dropVisualizerWidth () const |
1932 | { | 1941 | { |
1933 | return d->mDropVisualizerWidth; | 1942 | return d->mDropVisualizerWidth; |
1934 | } | 1943 | } |
1935 | 1944 | ||
1936 | 1945 | ||
1937 | void KListView::viewportPaintEvent(QPaintEvent *e) | 1946 | void KListView::viewportPaintEvent(QPaintEvent *e) |
1938 | { | 1947 | { |
1939 | QListView::viewportPaintEvent(e); | 1948 | QListView::viewportPaintEvent(e); |
1940 | 1949 | ||
1941 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) | 1950 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) |
1942 | { | 1951 | { |
1943 | QPainter painter(viewport()); | 1952 | QPainter painter(viewport()); |
1944 | 1953 | ||
1945 | // This is where we actually draw the drop-visualizer | 1954 | // This is where we actually draw the drop-visualizer |
1946 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); | 1955 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); |
1947 | } | 1956 | } |
1948 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) | 1957 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) |
1949 | { | 1958 | { |
1950 | QPainter painter(viewport()); | 1959 | QPainter painter(viewport()); |
1951 | 1960 | ||
1952 | qDebug("KListView::viewportPaintEvent has to be verified"); | 1961 | qDebug("KListView::viewportPaintEvent has to be verified"); |
1953 | 1962 | ||
1954 | // This is where we actually draw the drop-highlighter | 1963 | // This is where we actually draw the drop-highlighter |
1955 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), | 1964 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), |
1956 | //US QStyle::Style_FocusAtBorder); | 1965 | //US QStyle::Style_FocusAtBorder); |
1957 | 1966 | ||
1958 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); | 1967 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); |
1959 | 1968 | ||
1960 | 1969 | ||
1961 | } | 1970 | } |
1962 | } | 1971 | } |
1963 | 1972 | ||
1964 | void KListView::setFullWidth() | 1973 | void KListView::setFullWidth() |
1965 | { | 1974 | { |
1966 | setFullWidth(true); | 1975 | setFullWidth(true); |
1967 | } | 1976 | } |
1968 | 1977 | ||
1969 | void KListView::setFullWidth(bool fullWidth) | 1978 | void KListView::setFullWidth(bool fullWidth) |
1970 | { | 1979 | { |
1971 | d->fullWidth = fullWidth; | 1980 | d->fullWidth = fullWidth; |
1972 | //US header()->setStretchEnabled(fullWidth, columns()-1); | 1981 | //US header()->setStretchEnabled(fullWidth, columns()-1); |
1973 | } | 1982 | } |
1974 | 1983 | ||
1975 | bool KListView::fullWidth() const | 1984 | bool KListView::fullWidth() const |
1976 | { | 1985 | { |
1977 | return d->fullWidth; | 1986 | return d->fullWidth; |
1978 | } | 1987 | } |
1979 | 1988 | ||
1980 | int KListView::addColumn(const QString& label, int width) | 1989 | int KListView::addColumn(const QString& label, int width) |
1981 | { | 1990 | { |
1982 | int result = QListView::addColumn(label, width); | 1991 | int result = QListView::addColumn(label, width); |
1983 | if (d->fullWidth) { | 1992 | if (d->fullWidth) { |
1984 | //US header()->setStretchEnabled(false, columns()-2); | 1993 | //US header()->setStretchEnabled(false, columns()-2); |
1985 | //US header()->setStretchEnabled(true, columns()-1); | 1994 | //US header()->setStretchEnabled(true, columns()-1); |
1986 | } | 1995 | } |
1987 | return result; | 1996 | return result; |
1988 | } | 1997 | } |
1989 | 1998 | ||
1990 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) | 1999 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) |
1991 | { | 2000 | { |
1992 | int result = QListView::addColumn(iconset, label, width); | 2001 | int result = QListView::addColumn(iconset, label, width); |
1993 | if (d->fullWidth) { | 2002 | if (d->fullWidth) { |
1994 | //US header()->setStretchEnabled(false, columns()-2); | 2003 | //US header()->setStretchEnabled(false, columns()-2); |
1995 | //US header()->setStretchEnabled(true, columns()-1); | 2004 | //US header()->setStretchEnabled(true, columns()-1); |
1996 | } | 2005 | } |
1997 | return result; | 2006 | return result; |
1998 | } | 2007 | } |
1999 | 2008 | ||
2000 | void KListView::removeColumn(int index) | 2009 | void KListView::removeColumn(int index) |
2001 | { | 2010 | { |
2002 | QListView::removeColumn(index); | 2011 | QListView::removeColumn(index); |
2003 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); | 2012 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); |
2004 | } | 2013 | } |
2005 | 2014 | ||
2006 | void KListView::viewportResizeEvent(QResizeEvent* e) | 2015 | void KListView::viewportResizeEvent(QResizeEvent* e) |
2007 | { | 2016 | { |
2008 | QListView::viewportResizeEvent(e); | 2017 | QListView::viewportResizeEvent(e); |
2009 | } | 2018 | } |
2010 | 2019 | ||
2011 | const QColor &KListView::alternateBackground() const | 2020 | const QColor &KListView::alternateBackground() const |
2012 | { | 2021 | { |
2013 | return d->alternateBackground; | 2022 | return d->alternateBackground; |
2014 | } | 2023 | } |
2015 | 2024 | ||
diff --git a/microkde/kdeui/klistview.h b/microkde/kdeui/klistview.h index 0058416..9f0d9fd 100644 --- a/microkde/kdeui/klistview.h +++ b/microkde/kdeui/klistview.h | |||
@@ -1,1039 +1,1040 @@ | |||
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 <putzer@kde.org> | 4 | Copyright (C) 2000 Peter Putzer <putzer@kde.org> |
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 | #ifndef KLISTVIEW_H | 20 | #ifndef KLISTVIEW_H |
21 | #define KLISTVIEW_H | 21 | #define KLISTVIEW_H |
22 | 22 | ||
23 | #include <qlistview.h> | 23 | #include <qlistview.h> |
24 | 24 | ||
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | //US | 27 | //US |
28 | class QDropEvent; | 28 | class QDropEvent; |
29 | class QDragLeaveEvent; | 29 | class QDragLeaveEvent; |
30 | class QDragMoveEvent; | 30 | class QDragMoveEvent; |
31 | class QDragEnterEvent; | 31 | class QDragEnterEvent; |
32 | 32 | ||
33 | class QDragObject; | 33 | class QDragObject; |
34 | class KConfig; | 34 | class KConfig; |
35 | class KLineEdit; | 35 | class KLineEdit; |
36 | /** | 36 | /** |
37 | * This Widget extends the functionality of QListView to honor the system | 37 | * This Widget extends the functionality of QListView to honor the system |
38 | * wide settings for Single Click/Double Click mode, AutoSelection and | 38 | * wide settings for Single Click/Double Click mode, AutoSelection and |
39 | * ChangeCursorOverLink (TM). | 39 | * ChangeCursorOverLink (TM). |
40 | * | 40 | * |
41 | * There is a new signal executed(). It gets connected to either | 41 | * There is a new signal executed(). It gets connected to either |
42 | * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE | 42 | * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE |
43 | * wide Single Click/Double Click settings. It is strongly recommended that | 43 | * wide Single Click/Double Click settings. It is strongly recommended that |
44 | * you use this signal instead of the above mentioned. This way you dont | 44 | * you use this signal instead of the above mentioned. This way you dont |
45 | * need to care about the current settings. | 45 | * need to care about the current settings. |
46 | * If you want to get informed when the user selects something connect to the | 46 | * If you want to get informed when the user selects something connect to the |
47 | * QListView::selectionChanged() signal. | 47 | * QListView::selectionChanged() signal. |
48 | * | 48 | * |
49 | * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true) | 49 | * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true) |
50 | * and connect it to a suitable slot. | 50 | * and connect it to a suitable slot. |
51 | * To see where you are dropping, @ref setDropVisualizer(true). | 51 | * To see where you are dropping, @ref setDropVisualizer(true). |
52 | * And also you'll need @ref acceptDrag(QDropEvent*) | 52 | * And also you'll need @ref acceptDrag(QDropEvent*) |
53 | * | 53 | * |
54 | * KListView is drag-enabled, too: to benefit from that you've got derive from it. | 54 | * KListView is drag-enabled, too: to benefit from that you've got derive from it. |
55 | * Reimplement @ref dragObject() and (possibly) @ref startDrag(), | 55 | * Reimplement @ref dragObject() and (possibly) @ref startDrag(), |
56 | * and @ref setDragEnabled(true). | 56 | * and @ref setDragEnabled(true). |
57 | * | 57 | * |
58 | * @version $Id$ | 58 | * @version $Id$ |
59 | */ | 59 | */ |
60 | class KListView : public QListView | 60 | class KListView : public QListView |
61 | { | 61 | { |
62 | Q_OBJECT | 62 | Q_OBJECT |
63 | Q_ENUMS( SelectionModeExt ) | 63 | Q_ENUMS( SelectionModeExt ) |
64 | Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) | 64 | Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) |
65 | Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) | 65 | Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) |
66 | Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) | 66 | Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) |
67 | Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) | 67 | Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) |
68 | Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) | 68 | Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) |
69 | Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) | 69 | Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) |
70 | //US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) | 70 | //US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) |
71 | Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) | 71 | Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) |
72 | Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) | 72 | Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) |
73 | 73 | ||
74 | Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) | 74 | Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) |
75 | 75 | ||
76 | public: | 76 | public: |
77 | /** | 77 | /** |
78 | * Possible selection modes. | 78 | * Possible selection modes. |
79 | * | 79 | * |
80 | * The first four correspond directly to QListView::SelectionMode, while | 80 | * The first four correspond directly to QListView::SelectionMode, while |
81 | * the FileManager selection mode is defined as follows: | 81 | * the FileManager selection mode is defined as follows: |
82 | * @li home: move to the first | 82 | * @li home: move to the first |
83 | * @li end: move to the last | 83 | * @li end: move to the last |
84 | * @li PgUp/PgDn: move one page up/down | 84 | * @li PgUp/PgDn: move one page up/down |
85 | * @li up/down: move one item up/down | 85 | * @li up/down: move one item up/down |
86 | * @li insert: toggle selection of current and move to the next | 86 | * @li insert: toggle selection of current and move to the next |
87 | * @li space: toggle selection of the current | 87 | * @li space: toggle selection of the current |
88 | * @li CTRL+up: move to the previous item and toggle selection of this one | 88 | * @li CTRL+up: move to the previous item and toggle selection of this one |
89 | * @li CTRL+down: toggle selection of the current item and move to the next | 89 | * @li CTRL+down: toggle selection of the current item and move to the next |
90 | * @li CTRL+end: toggle selection from (including) the current | 90 | * @li CTRL+end: toggle selection from (including) the current |
91 | * item to (including) the last item | 91 | * item to (including) the last item |
92 | * @li CTRL+home: toggle selection from (including) the current | 92 | * @li CTRL+home: toggle selection from (including) the current |
93 | * item to the (including) the first item | 93 | * item to the (including) the first item |
94 | * @li CTRL+PgDn: toggle selection from (including) the current | 94 | * @li CTRL+PgDn: toggle selection from (including) the current |
95 | * item to (excluding) the item one page down | 95 | * item to (excluding) the item one page down |
96 | * @li CTRL+PgUp: toggle selection from (excluding) the current | 96 | * @li CTRL+PgUp: toggle selection from (excluding) the current |
97 | * item to (including) the item one page up | 97 | * item to (including) the item one page up |
98 | * | 98 | * |
99 | * The combinations work the same with SHIFT instead of CTRL, except | 99 | * The combinations work the same with SHIFT instead of CTRL, except |
100 | * that if you start selecting something using SHIFT everything selected | 100 | * that if you start selecting something using SHIFT everything selected |
101 | * before will be deselected first. | 101 | * before will be deselected first. |
102 | * | 102 | * |
103 | * Additionally the current item is always selected automatically when | 103 | * Additionally the current item is always selected automatically when |
104 | * navigating using the keyboard, except other items were selected explicitely. | 104 | * navigating using the keyboard, except other items were selected explicitely. |
105 | * | 105 | * |
106 | * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected | 106 | * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected |
107 | */ | 107 | */ |
108 | enum SelectionModeExt { | 108 | enum SelectionModeExt { |
109 | Single = QListView::Single, | 109 | Single = QListView::Single, |
110 | Multi = QListView::Multi, | 110 | Multi = QListView::Multi, |
111 | Extended = QListView::Extended, | 111 | Extended = QListView::Extended, |
112 | NoSelection = QListView::NoSelection, | 112 | NoSelection = QListView::NoSelection, |
113 | FileManager | 113 | FileManager |
114 | }; | 114 | }; |
115 | void repaintContents( bool erase = true ) | 115 | void repaintContents( bool erase = true ) |
116 | { | 116 | { |
117 | QScrollView::repaintContents( contentsX(), contentsY(), | 117 | QScrollView::repaintContents( contentsX(), contentsY(), |
118 | visibleWidth(), visibleHeight(), erase ); | 118 | visibleWidth(), visibleHeight(), erase ); |
119 | }; | 119 | }; |
120 | /** | 120 | /** |
121 | * Constructor. | 121 | * Constructor. |
122 | * | 122 | * |
123 | * The parameters @p parent and @p name are handled by | 123 | * The parameters @p parent and @p name are handled by |
124 | * @ref QListView, as usual. | 124 | * @ref QListView, as usual. |
125 | */ | 125 | */ |
126 | KListView (QWidget *parent = 0, const char *name = 0, bool emulateRightMouse = true ); | 126 | KListView (QWidget *parent = 0, const char *name = 0, bool emulateRightMouse = true ); |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Destructor. | 129 | * Destructor. |
130 | */ | 130 | */ |
131 | virtual ~KListView(); | 131 | virtual ~KListView(); |
132 | 132 | ||
133 | virtual QSize sizeHint() const; | ||
133 | /** | 134 | /** |
134 | * Reimplemented for internal reasons. | 135 | * Reimplemented for internal reasons. |
135 | * Further reimplementations should call this function or else | 136 | * Further reimplementations should call this function or else |
136 | * some features may not work correctly. | 137 | * some features may not work correctly. |
137 | * | 138 | * |
138 | * The API is unaffected. | 139 | * The API is unaffected. |
139 | */ | 140 | */ |
140 | virtual void setAcceptDrops (bool); | 141 | virtual void setAcceptDrops (bool); |
141 | 142 | ||
142 | /** | 143 | /** |
143 | * This function determines whether the given coordinates are within the | 144 | * This function determines whether the given coordinates are within the |
144 | * execute area. The execute area is the part of a @ref QListViewItem where mouse | 145 | * execute area. The execute area is the part of a @ref QListViewItem where mouse |
145 | * clicks or double clicks respectively generate a @ref #executed() signal. | 146 | * clicks or double clicks respectively generate a @ref #executed() signal. |
146 | * Depending on @ref QListView::allColumnsShowFocus() this is either the | 147 | * Depending on @ref QListView::allColumnsShowFocus() this is either the |
147 | * whole item or only the first column. | 148 | * whole item or only the first column. |
148 | * @return true if point is inside execute area of an item, false in all | 149 | * @return true if point is inside execute area of an item, false in all |
149 | * other cases including the case that it is over the viewport. | 150 | * other cases including the case that it is over the viewport. |
150 | */ | 151 | */ |
151 | virtual bool isExecuteArea( const QPoint& point ); | 152 | virtual bool isExecuteArea( const QPoint& point ); |
152 | 153 | ||
153 | /** | 154 | /** |
154 | * Same thing, but from an x coordinate only. This only checks if x is in | 155 | * Same thing, but from an x coordinate only. This only checks if x is in |
155 | * the first column (if all columns don't show focus), without testing if | 156 | * the first column (if all columns don't show focus), without testing if |
156 | * the y coordinate is over an item or not. | 157 | * the y coordinate is over an item or not. |
157 | */ | 158 | */ |
158 | bool isExecuteArea( int x ); | 159 | bool isExecuteArea( int x ); |
159 | 160 | ||
160 | /** | 161 | /** |
161 | * @return a list containing the currently selected items. | 162 | * @return a list containing the currently selected items. |
162 | */ | 163 | */ |
163 | QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) | 164 | QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) |
164 | 165 | ||
165 | /** | 166 | /** |
166 | * Arbitrarily move @p item to @p parent, positioned immediately after item @p after. | 167 | * Arbitrarily move @p item to @p parent, positioned immediately after item @p after. |
167 | */ | 168 | */ |
168 | void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after); | 169 | void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after); |
169 | 170 | ||
170 | /** | 171 | /** |
171 | * @return the last item (not child!) of this listview. | 172 | * @return the last item (not child!) of this listview. |
172 | * | 173 | * |
173 | * @see lastChild() | 174 | * @see lastChild() |
174 | */ | 175 | */ |
175 | QListViewItem *lastItem() const; | 176 | QListViewItem *lastItem() const; |
176 | 177 | ||
177 | /** | 178 | /** |
178 | * @return the last child of this listview. | 179 | * @return the last child of this listview. |
179 | * | 180 | * |
180 | * @see lastItem() | 181 | * @see lastItem() |
181 | */ | 182 | */ |
182 | QListViewItem* lastChild () const; | 183 | QListViewItem* lastChild () const; |
183 | 184 | ||
184 | /** | 185 | /** |
185 | * @return the lineedit used for inline renaming. | 186 | * @return the lineedit used for inline renaming. |
186 | * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit | 187 | * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit |
187 | * | 188 | * |
188 | * @since 3.2 | 189 | * @since 3.2 |
189 | */ | 190 | */ |
190 | KLineEdit* renameLineEdit() const; | 191 | KLineEdit* renameLineEdit() const; |
191 | 192 | ||
192 | /** | 193 | /** |
193 | * @returns if it is legal to move items in the list view. True by default. | 194 | * @returns if it is legal to move items in the list view. True by default. |
194 | * | 195 | * |
195 | * @see #setDragEnabled() | 196 | * @see #setDragEnabled() |
196 | * @see #setItemsMovable() | 197 | * @see #setItemsMovable() |
197 | */ | 198 | */ |
198 | bool itemsMovable() const; | 199 | bool itemsMovable() const; |
199 | 200 | ||
200 | /** | 201 | /** |
201 | * @return whether inplace-renaming has been enabled. False by default. | 202 | * @return whether inplace-renaming has been enabled. False by default. |
202 | * | 203 | * |
203 | * @see #setItemsRenameable() | 204 | * @see #setItemsRenameable() |
204 | */ | 205 | */ |
205 | bool itemsRenameable() const; | 206 | bool itemsRenameable() const; |
206 | 207 | ||
207 | /** | 208 | /** |
208 | * @return whether dragging is enabled. False by default. | 209 | * @return whether dragging is enabled. False by default. |
209 | * | 210 | * |
210 | * @see #setDragEnabled() | 211 | * @see #setDragEnabled() |
211 | */ | 212 | */ |
212 | bool dragEnabled() const; | 213 | bool dragEnabled() const; |
213 | 214 | ||
214 | /** | 215 | /** |
215 | * @return true if AutoOpen is enabled (not implemented currently). | 216 | * @return true if AutoOpen is enabled (not implemented currently). |
216 | * | 217 | * |
217 | * @see #setAutoOpen() | 218 | * @see #setAutoOpen() |
218 | */ | 219 | */ |
219 | bool autoOpen() const; | 220 | bool autoOpen() const; |
220 | 221 | ||
221 | /** | 222 | /** |
222 | * @return true if @p column is renamable. | 223 | * @return true if @p column is renamable. |
223 | * | 224 | * |
224 | * @see #setRenameable() | 225 | * @see #setRenameable() |
225 | */ | 226 | */ |
226 | bool isRenameable (int column) const; | 227 | bool isRenameable (int column) const; |
227 | 228 | ||
228 | /** | 229 | /** |
229 | * @return true if drawing of the drop-visualizer has been enabled. True by default. | 230 | * @return true if drawing of the drop-visualizer has been enabled. True by default. |
230 | * | 231 | * |
231 | * @see #setDropVisualizer() | 232 | * @see #setDropVisualizer() |
232 | */ | 233 | */ |
233 | bool dropVisualizer() const; | 234 | bool dropVisualizer() const; |
234 | 235 | ||
235 | /** | 236 | /** |
236 | * @return the column for which tooltips are displayed (or -1 if none set). | 237 | * @return the column for which tooltips are displayed (or -1 if none set). |
237 | * | 238 | * |
238 | * @see #setTooltipColumn() | 239 | * @see #setTooltipColumn() |
239 | */ | 240 | */ |
240 | int tooltipColumn() const; | 241 | int tooltipColumn() const; |
241 | 242 | ||
242 | /** | 243 | /** |
243 | * For future expansions. | 244 | * For future expansions. |
244 | * | 245 | * |
245 | * Do not use. | 246 | * Do not use. |
246 | * @deprecated | 247 | * @deprecated |
247 | */ | 248 | */ |
248 | bool createChildren() const; | 249 | bool createChildren() const; |
249 | 250 | ||
250 | /** | 251 | /** |
251 | * @return true if drawing of the drop-highlighter has been enabled. False by default. | 252 | * @return true if drawing of the drop-highlighter has been enabled. False by default. |
252 | * | 253 | * |
253 | * @see #setDropHighlighter() | 254 | * @see #setDropHighlighter() |
254 | */ | 255 | */ |
255 | bool dropHighlighter() const; | 256 | bool dropHighlighter() const; |
256 | 257 | ||
257 | /** | 258 | /** |
258 | * The dropVisualizerWidth defaults to 4. | 259 | * The dropVisualizerWidth defaults to 4. |
259 | * | 260 | * |
260 | * @see #setDropVisualizerWidth() | 261 | * @see #setDropVisualizerWidth() |
261 | * @return the current width of the drop-visualizer. | 262 | * @return the current width of the drop-visualizer. |
262 | */ | 263 | */ |
263 | int dropVisualizerWidth () const; | 264 | int dropVisualizerWidth () const; |
264 | 265 | ||
265 | /** | 266 | /** |
266 | * @return the "extended" selection mode of this listview. | 267 | * @return the "extended" selection mode of this listview. |
267 | * | 268 | * |
268 | * @see SelectionModeExt | 269 | * @see SelectionModeExt |
269 | * @see setSelectionModeExt | 270 | * @see setSelectionModeExt |
270 | */ | 271 | */ |
271 | SelectionModeExt selectionModeExt () const; | 272 | SelectionModeExt selectionModeExt () const; |
272 | 273 | ||
273 | /** | 274 | /** |
274 | * Returns the index of @p item within the item tree or -1 if | 275 | * Returns the index of @p item within the item tree or -1 if |
275 | * @p item doesn't exist in this list view. This function takes | 276 | * @p item doesn't exist in this list view. This function takes |
276 | * all items into account not only the visible ones. | 277 | * all items into account not only the visible ones. |
277 | */ | 278 | */ |
278 | int itemIndex( const QListViewItem *item ) const; | 279 | int itemIndex( const QListViewItem *item ) const; |
279 | 280 | ||
280 | /** | 281 | /** |
281 | * Returns the item of @p index within the item tree or 0 if | 282 | * Returns the item of @p index within the item tree or 0 if |
282 | * @p index doesn't exist in this list view. This function takes | 283 | * @p index doesn't exist in this list view. This function takes |
283 | * all items into account not only the visible ones. | 284 | * all items into account not only the visible ones. |
284 | */ | 285 | */ |
285 | QListViewItem* itemAtIndex(int index); | 286 | QListViewItem* itemAtIndex(int index); |
286 | 287 | ||
287 | /** | 288 | /** |
288 | * @deprecated | 289 | * @deprecated |
289 | * @see #setFullWidth() | 290 | * @see #setFullWidth() |
290 | */ | 291 | */ |
291 | void setFullWidth(); | 292 | void setFullWidth(); |
292 | 293 | ||
293 | /** | 294 | /** |
294 | * Let the last column fit exactly all the available width. | 295 | * Let the last column fit exactly all the available width. |
295 | * | 296 | * |
296 | * @see #fullWidth() | 297 | * @see #fullWidth() |
297 | */ | 298 | */ |
298 | void setFullWidth(bool fullWidth); | 299 | void setFullWidth(bool fullWidth); |
299 | 300 | ||
300 | /** | 301 | /** |
301 | * Returns whether the last column is set to fit the available width. | 302 | * Returns whether the last column is set to fit the available width. |
302 | * | 303 | * |
303 | * @see #setFullWidth() | 304 | * @see #setFullWidth() |
304 | */ | 305 | */ |
305 | bool fullWidth() const; | 306 | bool fullWidth() const; |
306 | 307 | ||
307 | /** | 308 | /** |
308 | * Reimplemented for full width support | 309 | * Reimplemented for full width support |
309 | * | 310 | * |
310 | * @see #removeColumn() | 311 | * @see #removeColumn() |
311 | */ | 312 | */ |
312 | virtual int addColumn(const QString& label, int width = -1); | 313 | virtual int addColumn(const QString& label, int width = -1); |
313 | /** | 314 | /** |
314 | * Reimplemented for full width support | 315 | * Reimplemented for full width support |
315 | */ | 316 | */ |
316 | virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1); | 317 | virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1); |
317 | /** | 318 | /** |
318 | * Reimplemented for full width support | 319 | * Reimplemented for full width support |
319 | * | 320 | * |
320 | * @see #addColumn() | 321 | * @see #addColumn() |
321 | */ | 322 | */ |
322 | virtual void removeColumn(int index); | 323 | virtual void removeColumn(int index); |
323 | 324 | ||
324 | /** | 325 | /** |
325 | * sets the alternate background background color. | 326 | * sets the alternate background background color. |
326 | * This only has an effect if the items are KListViewItems | 327 | * This only has an effect if the items are KListViewItems |
327 | * | 328 | * |
328 | * @param c the color to use for every other item. Set to an invalid | 329 | * @param c the color to use for every other item. Set to an invalid |
329 | * colour to disable alternate colours. | 330 | * colour to disable alternate colours. |
330 | * | 331 | * |
331 | * @see #alternateBackground() | 332 | * @see #alternateBackground() |
332 | **/ | 333 | **/ |
333 | void setAlternateBackground(const QColor &c); | 334 | void setAlternateBackground(const QColor &c); |
334 | /** | 335 | /** |
335 | * @return the alternate background color | 336 | * @return the alternate background color |
336 | * | 337 | * |
337 | * @see #setAlternateBackground() | 338 | * @see #setAlternateBackground() |
338 | */ | 339 | */ |
339 | const QColor &alternateBackground() const; | 340 | const QColor &alternateBackground() const; |
340 | 341 | ||
341 | /** | 342 | /** |
342 | * Saves the list view's layout (column widtsh, column order, sort column) | 343 | * Saves the list view's layout (column widtsh, column order, sort column) |
343 | * to a KConfig group | 344 | * to a KConfig group |
344 | * | 345 | * |
345 | * @param config the @ref KConfig object to write to | 346 | * @param config the @ref KConfig object to write to |
346 | * @param group the config group to use | 347 | * @param group the config group to use |
347 | */ | 348 | */ |
348 | void saveLayout(KConfig *config, const QString &group) const; | 349 | void saveLayout(KConfig *config, const QString &group) const; |
349 | /** | 350 | /** |
350 | * Reads the list view's layout from a KConfig group as stored with | 351 | * Reads the list view's layout from a KConfig group as stored with |
351 | * @ref #saveLayout | 352 | * @ref #saveLayout |
352 | * | 353 | * |
353 | * @param config the @ref KConfig object to read from | 354 | * @param config the @ref KConfig object to read from |
354 | * @param group the config group to use | 355 | * @param group the config group to use |
355 | */ | 356 | */ |
356 | void restoreLayout(KConfig *config, const QString &group); | 357 | void restoreLayout(KConfig *config, const QString &group); |
357 | /** | 358 | /** |
358 | * Reimplemented to remember the current sort column and order. | 359 | * Reimplemented to remember the current sort column and order. |
359 | * @param column is the column to be sorted, or -1 to sort in order of | 360 | * @param column is the column to be sorted, or -1 to sort in order of |
360 | * insertion | 361 | * insertion |
361 | * @param whether to sort ascending (or descending) | 362 | * @param whether to sort ascending (or descending) |
362 | */ | 363 | */ |
363 | virtual void setSorting(int column, bool ascending = true); | 364 | virtual void setSorting(int column, bool ascending = true); |
364 | 365 | ||
365 | /** | 366 | /** |
366 | * @return the currently sorted column, or -1 if none is sorted | 367 | * @return the currently sorted column, or -1 if none is sorted |
367 | */ | 368 | */ |
368 | int columnSorted(void) const; | 369 | int columnSorted(void) const; |
369 | 370 | ||
370 | /** | 371 | /** |
371 | * @return whether the current sort is ascending (or descending) | 372 | * @return whether the current sort is ascending (or descending) |
372 | */ | 373 | */ |
373 | bool ascendingSort(void) const; | 374 | bool ascendingSort(void) const; |
374 | 375 | ||
375 | //US we do not have a "global KDE" variable to setup singleClick functionality | 376 | //US we do not have a "global KDE" variable to setup singleClick functionality |
376 | void setSingleClick(bool s); | 377 | void setSingleClick(bool s); |
377 | 378 | ||
378 | 379 | ||
379 | signals: | 380 | signals: |
380 | 381 | ||
381 | /** | 382 | /** |
382 | * This signal is emitted whenever the user executes an listview item. | 383 | * This signal is emitted whenever the user executes an listview item. |
383 | * That means depending on the KDE wide Single Click/Double Click | 384 | * That means depending on the KDE wide Single Click/Double Click |
384 | * setting the user clicked or double clicked on that item. | 385 | * setting the user clicked or double clicked on that item. |
385 | * @param item is the pointer to the executed listview item. | 386 | * @param item is the pointer to the executed listview item. |
386 | * | 387 | * |
387 | * Note that you may not delete any @ref QListViewItem objects in slots | 388 | * Note that you may not delete any @ref QListViewItem objects in slots |
388 | * connected to this signal. | 389 | * connected to this signal. |
389 | */ | 390 | */ |
390 | void executed( QListViewItem *item ); | 391 | void executed( QListViewItem *item ); |
391 | 392 | ||
392 | /** | 393 | /** |
393 | * This signal is emitted whenever the user executes an listview item. | 394 | * This signal is emitted whenever the user executes an listview item. |
394 | * That means depending on the KDE wide Single Click/Double Click | 395 | * That means depending on the KDE wide Single Click/Double Click |
395 | * setting the user clicked or double clicked on that item. | 396 | * setting the user clicked or double clicked on that item. |
396 | * @param item is the pointer to the executed listview item. | 397 | * @param item is the pointer to the executed listview item. |
397 | * @param pos is the position where the user has clicked | 398 | * @param pos is the position where the user has clicked |
398 | * @param c is the column into which the user clicked. | 399 | * @param c is the column into which the user clicked. |
399 | * | 400 | * |
400 | * Note that you may not delete any @ref QListViewItem objects in slots | 401 | * Note that you may not delete any @ref QListViewItem objects in slots |
401 | * connected to this signal. | 402 | * connected to this signal. |
402 | */ | 403 | */ |
403 | void executed( QListViewItem *item, const QPoint &pos, int c ); | 404 | void executed( QListViewItem *item, const QPoint &pos, int c ); |
404 | 405 | ||
405 | /** | 406 | /** |
406 | * This signal gets emitted whenever the user double clicks into the | 407 | * This signal gets emitted whenever the user double clicks into the |
407 | * listview. | 408 | * listview. |
408 | * @param item is the pointer to the clicked listview item. | 409 | * @param item is the pointer to the clicked listview item. |
409 | * @param pos is the position where the user has clicked, and | 410 | * @param pos is the position where the user has clicked, and |
410 | * @param c is the column into which the user clicked. | 411 | * @param c is the column into which the user clicked. |
411 | * | 412 | * |
412 | * Note that you may not delete any @ref QListViewItem objects in slots | 413 | * Note that you may not delete any @ref QListViewItem objects in slots |
413 | * connected to this signal. | 414 | * connected to this signal. |
414 | * | 415 | * |
415 | * This signal is more or less here for the sake of completeness. | 416 | * This signal is more or less here for the sake of completeness. |
416 | * You should normally not need to use this. In most cases its better | 417 | * You should normally not need to use this. In most cases its better |
417 | * to use @ref #executed() instead. | 418 | * to use @ref #executed() instead. |
418 | */ | 419 | */ |
419 | void doubleClicked( QListViewItem *item, const QPoint &pos, int c ); | 420 | void doubleClicked( QListViewItem *item, const QPoint &pos, int c ); |
420 | void contextRequest( QListViewItem *item, const QPoint &pos, int c ); | 421 | void contextRequest( QListViewItem *item, const QPoint &pos, int c ); |
421 | 422 | ||
422 | /** | 423 | /** |
423 | * This signal gets emitted whenever something acceptable is | 424 | * This signal gets emitted whenever something acceptable is |
424 | * dropped onto the listview. | 425 | * dropped onto the listview. |
425 | * | 426 | * |
426 | * @param e is the drop event itself (it has already been accepted) | 427 | * @param e is the drop event itself (it has already been accepted) |
427 | * @param after is the item after which the drop occured (or 0L, if | 428 | * @param after is the item after which the drop occured (or 0L, if |
428 | * the drop was above all items) | 429 | * the drop was above all items) |
429 | * | 430 | * |
430 | * @see #acceptDrop() | 431 | * @see #acceptDrop() |
431 | */ | 432 | */ |
432 | void dropped (QDropEvent * e, QListViewItem *after); | 433 | void dropped (QDropEvent * e, QListViewItem *after); |
433 | 434 | ||
434 | /** | 435 | /** |
435 | * This signal gets emitted whenever something acceptable is | 436 | * This signal gets emitted whenever something acceptable is |
436 | * dropped onto the listview. | 437 | * dropped onto the listview. |
437 | * | 438 | * |
438 | * This is an overloaded version of the above (provided to simplify | 439 | * This is an overloaded version of the above (provided to simplify |
439 | * processing drops outside of the class). | 440 | * processing drops outside of the class). |
440 | * | 441 | * |
441 | * @param list is the listview | 442 | * @param list is the listview |
442 | * @param e is the drop event itself (it has already been accepted) | 443 | * @param e is the drop event itself (it has already been accepted) |
443 | * @param after is the item after which the drop occured (or 0L, if | 444 | * @param after is the item after which the drop occured (or 0L, if |
444 | * the drop was above all items | 445 | * the drop was above all items |
445 | */ | 446 | */ |
446 | void dropped (KListView* list, QDropEvent* e, QListViewItem* after); | 447 | void dropped (KListView* list, QDropEvent* e, QListViewItem* after); |
447 | 448 | ||
448 | /** | 449 | /** |
449 | * This signal gets emitted whenever something acceptable is | 450 | * This signal gets emitted whenever something acceptable is |
450 | * dropped onto the listview. | 451 | * dropped onto the listview. |
451 | * | 452 | * |
452 | * This function also provides a parent, in the event that your listview | 453 | * This function also provides a parent, in the event that your listview |
453 | * is a tree | 454 | * is a tree |
454 | * @param list is the listview | 455 | * @param list is the listview |
455 | * @param e is the drop event itself (it has already been accepted) | 456 | * @param e is the drop event itself (it has already been accepted) |
456 | * @param parent the item that is to be the parent of the new item | 457 | * @param parent the item that is to be the parent of the new item |
457 | * @param after is the item after which the drop occured (or 0L, if | 458 | * @param after is the item after which the drop occured (or 0L, if |
458 | * the drop was above all items | 459 | * the drop was above all items |
459 | */ | 460 | */ |
460 | void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after); | 461 | void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after); |
461 | 462 | ||
462 | /** | 463 | /** |
463 | * This signal gets emitted whenever something acceptable is | 464 | * This signal gets emitted whenever something acceptable is |
464 | * dropped onto the listview. | 465 | * dropped onto the listview. |
465 | * | 466 | * |
466 | * This function also provides a parent, in the event that your listview | 467 | * This function also provides a parent, in the event that your listview |
467 | * is a tree | 468 | * is a tree |
468 | * @param e is the drop event itself (it has already been accepted) | 469 | * @param e is the drop event itself (it has already been accepted) |
469 | * @param parent the item that is to be the parent of the new item | 470 | * @param parent the item that is to be the parent of the new item |
470 | * @param after is the item after which the drop occured (or 0L, if | 471 | * @param after is the item after which the drop occured (or 0L, if |
471 | * the drop was above all items | 472 | * the drop was above all items |
472 | */ | 473 | */ |
473 | void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after); | 474 | void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after); |
474 | 475 | ||
475 | /** | 476 | /** |
476 | * This signal is emitted when ever the user moves an item in the list via | 477 | * This signal is emitted when ever the user moves an item in the list via |
477 | * DnD. | 478 | * DnD. |
478 | * If more than one item is moved at the same time, this signal is only emitted | 479 | * If more than one item is moved at the same time, this signal is only emitted |
479 | * once. | 480 | * once. |
480 | */ | 481 | */ |
481 | void moved(); | 482 | void moved(); |
482 | 483 | ||
483 | /** | 484 | /** |
484 | * Connect to this signal if you want to do some preprocessing before | 485 | * Connect to this signal if you want to do some preprocessing before |
485 | * a move is made, for example, to disable sorting | 486 | * a move is made, for example, to disable sorting |
486 | * | 487 | * |
487 | * This is sent only once per each groups of moves. That is, for each | 488 | * This is sent only once per each groups of moves. That is, for each |
488 | * drop that is a move this will be emitted once, before KListView calls | 489 | * drop that is a move this will be emitted once, before KListView calls |
489 | * @see moveItem() | 490 | * @see moveItem() |
490 | */ | 491 | */ |
491 | void aboutToMove(); | 492 | void aboutToMove(); |
492 | 493 | ||
493 | /** | 494 | /** |
494 | * This signal is emitted when ever the user moves an item in the list via | 495 | * This signal is emitted when ever the user moves an item in the list via |
495 | * DnD. | 496 | * DnD. |
496 | * If more than one item is moved at the same time, @p afterFirst and | 497 | * If more than one item is moved at the same time, @p afterFirst and |
497 | * @p afterNow will reflect what was true before the move. | 498 | * @p afterNow will reflect what was true before the move. |
498 | * This differs from @ref moved(), so be careful. All the items will have been | 499 | * This differs from @ref moved(), so be careful. All the items will have been |
499 | * moved before @ref moved() is emitted, which is not true in this method. // FIXME | 500 | * moved before @ref moved() is emitted, which is not true in this method. // FIXME |
500 | * @param item the item that was moved | 501 | * @param item the item that was moved |
501 | * @param afterFirst the item that parameter item was in before the move, in the list | 502 | * @param afterFirst the item that parameter item was in before the move, in the list |
502 | * @param afterNow the item it's currently after. | 503 | * @param afterNow the item it's currently after. |
503 | */ | 504 | */ |
504 | void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow); | 505 | void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow); |
505 | 506 | ||
506 | 507 | ||
507 | /** | 508 | /** |
508 | * This signal is emitted after all the items have been moved. It reports info for | 509 | * This signal is emitted after all the items have been moved. It reports info for |
509 | * each and every item moved, in order. The first element in @p items associates | 510 | * each and every item moved, in order. The first element in @p items associates |
510 | * with the first of afterFirst and afterNow. | 511 | * with the first of afterFirst and afterNow. |
511 | */ | 512 | */ |
512 | void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); | 513 | void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); |
513 | 514 | ||
514 | /** | 515 | /** |
515 | * This signal gets emitted when an item is renamed via in-place renaming. | 516 | * This signal gets emitted when an item is renamed via in-place renaming. |
516 | * | 517 | * |
517 | * @param item is the renamed item. | 518 | * @param item is the renamed item. |
518 | * @param str is the new value of column @p col. | 519 | * @param str is the new value of column @p col. |
519 | * @param col is the renamed column. | 520 | * @param col is the renamed column. |
520 | */ | 521 | */ |
521 | void itemRenamed(QListViewItem* item, const QString &str, int col); | 522 | void itemRenamed(QListViewItem* item, const QString &str, int col); |
522 | 523 | ||
523 | /** | 524 | /** |
524 | * Same as above, but without the extra information. | 525 | * Same as above, but without the extra information. |
525 | */ | 526 | */ |
526 | void itemRenamed(QListViewItem* item); | 527 | void itemRenamed(QListViewItem* item); |
527 | void signalDelete(); | 528 | void signalDelete(); |
528 | 529 | ||
529 | /** | 530 | /** |
530 | * This signal is emitted when the shortcut key for popup-menus is pressed. | 531 | * This signal is emitted when the shortcut key for popup-menus is pressed. |
531 | * | 532 | * |
532 | * Normally you should not use this, just connect a slot to signal | 533 | * Normally you should not use this, just connect a slot to signal |
533 | * @ref contextMenu (KListView*, QListViewItem*, const QPoint&) to correctly | 534 | * @ref contextMenu (KListView*, QListViewItem*, const QPoint&) to correctly |
534 | * handle showing context menus regardless of settings. | 535 | * handle showing context menus regardless of settings. |
535 | * | 536 | * |
536 | * @param list is this listview. | 537 | * @param list is this listview. |
537 | * @param item is the @ref currentItem() at the time the key was pressed. May be 0L. | 538 | * @param item is the @ref currentItem() at the time the key was pressed. May be 0L. |
538 | */ | 539 | */ |
539 | void menuShortCutPressed (KListView* list, QListViewItem* item); | 540 | void menuShortCutPressed (KListView* list, QListViewItem* item); |
540 | 541 | ||
541 | /** | 542 | /** |
542 | * This signal is emitted whenever a context-menu should be shown for item @p i. | 543 | * This signal is emitted whenever a context-menu should be shown for item @p i. |
543 | * It automatically adjusts for all settings involved (Menu key, showMenuOnPress/Click). | 544 | * It automatically adjusts for all settings involved (Menu key, showMenuOnPress/Click). |
544 | * | 545 | * |
545 | * @param l is this listview. | 546 | * @param l is this listview. |
546 | * @param i is the item for which the menu should be shown. May be 0L. | 547 | * @param i is the item for which the menu should be shown. May be 0L. |
547 | * @param p is the point at which the menu should be shown. | 548 | * @param p is the point at which the menu should be shown. |
548 | */ | 549 | */ |
549 | void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); | 550 | void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); |
550 | 551 | ||
551 | public slots: | 552 | public slots: |
552 | /** | 553 | /** |
553 | * Rename column @p c of @p item. | 554 | * Rename column @p c of @p item. |
554 | */ | 555 | */ |
555 | virtual void rename(QListViewItem *item, int c); | 556 | virtual void rename(QListViewItem *item, int c); |
556 | 557 | ||
557 | /** | 558 | /** |
558 | * By default, if you called setItemsRenameable(true), | 559 | * By default, if you called setItemsRenameable(true), |
559 | * only the first column is renameable. | 560 | * only the first column is renameable. |
560 | * Use this function to enable the feature on other columns. | 561 | * Use this function to enable the feature on other columns. |
561 | * | 562 | * |
562 | * If you want more intelligent (dynamic) selection, | 563 | * If you want more intelligent (dynamic) selection, |
563 | * you'll have to derive from KListView, | 564 | * you'll have to derive from KListView, |
564 | * and override @ref rename() and call only call it | 565 | * and override @ref rename() and call only call it |
565 | * if you want the item to be renamed. | 566 | * if you want the item to be renamed. |
566 | */ | 567 | */ |
567 | void setRenameable (int column, bool yesno=true); | 568 | void setRenameable (int column, bool yesno=true); |
568 | 569 | ||
569 | /** | 570 | /** |
570 | * Set whether items in the list view can be moved. | 571 | * Set whether items in the list view can be moved. |
571 | * It is enabled by default. | 572 | * It is enabled by default. |
572 | * | 573 | * |
573 | * @see itemsMovable() | 574 | * @see itemsMovable() |
574 | */ | 575 | */ |
575 | virtual void setItemsMovable(bool b); | 576 | virtual void setItemsMovable(bool b); |
576 | 577 | ||
577 | /** | 578 | /** |
578 | * Enables inplace-renaming of items. | 579 | * Enables inplace-renaming of items. |
579 | * It is disabled by default. | 580 | * It is disabled by default. |
580 | * | 581 | * |
581 | * @see itemsRenameable() | 582 | * @see itemsRenameable() |
582 | * @see setRenameable() | 583 | * @see setRenameable() |
583 | */ | 584 | */ |
584 | virtual void setItemsRenameable(bool b); | 585 | virtual void setItemsRenameable(bool b); |
585 | 586 | ||
586 | /** | 587 | /** |
587 | * Enable/Disable the dragging of items. | 588 | * Enable/Disable the dragging of items. |
588 | * It is disabled by default. | 589 | * It is disabled by default. |
589 | */ | 590 | */ |
590 | virtual void setDragEnabled(bool b); | 591 | virtual void setDragEnabled(bool b); |
591 | 592 | ||
592 | /** | 593 | /** |
593 | * Enable/Disable AutoOpen (not implemented currently). | 594 | * Enable/Disable AutoOpen (not implemented currently). |
594 | */ | 595 | */ |
595 | virtual void setAutoOpen(bool b); | 596 | virtual void setAutoOpen(bool b); |
596 | 597 | ||
597 | /** | 598 | /** |
598 | * Enable/Disable the drawing of a drop-visualizer | 599 | * Enable/Disable the drawing of a drop-visualizer |
599 | * (a bar that shows where a dropped item would be inserted). | 600 | * (a bar that shows where a dropped item would be inserted). |
600 | * It is enabled by default, if dragging is enabled | 601 | * It is enabled by default, if dragging is enabled |
601 | */ | 602 | */ |
602 | virtual void setDropVisualizer(bool b); | 603 | virtual void setDropVisualizer(bool b); |
603 | 604 | ||
604 | /** | 605 | /** |
605 | * Set the width of the (default) drop-visualizer. | 606 | * Set the width of the (default) drop-visualizer. |
606 | * If you don't call this method, the width is set to 4. | 607 | * If you don't call this method, the width is set to 4. |
607 | */ | 608 | */ |
608 | void setDropVisualizerWidth (int w); | 609 | void setDropVisualizerWidth (int w); |
609 | 610 | ||
610 | /** | 611 | /** |
611 | * Set which column should be used for automatic tooltips. | 612 | * Set which column should be used for automatic tooltips. |
612 | * | 613 | * |
613 | * @param column is the column for which tooltips will be shown. | 614 | * @param column is the column for which tooltips will be shown. |
614 | * Set -1 to disable this feature. | 615 | * Set -1 to disable this feature. |
615 | */ | 616 | */ |
616 | virtual void setTooltipColumn(int column); | 617 | virtual void setTooltipColumn(int column); |
617 | 618 | ||
618 | /** | 619 | /** |
619 | * Enable/Disable the drawing of a drop-highlighter | 620 | * Enable/Disable the drawing of a drop-highlighter |
620 | * (a rectangle around the item under the mouse cursor). | 621 | * (a rectangle around the item under the mouse cursor). |
621 | * It is disabled by default. | 622 | * It is disabled by default. |
622 | */ | 623 | */ |
623 | virtual void setDropHighlighter(bool b); | 624 | virtual void setDropHighlighter(bool b); |
624 | 625 | ||
625 | /** | 626 | /** |
626 | * For future expansions. | 627 | * For future expansions. |
627 | * | 628 | * |
628 | * Do not use. | 629 | * Do not use. |
629 | * @deprecated | 630 | * @deprecated |
630 | */ | 631 | */ |
631 | virtual void setCreateChildren(bool b); | 632 | virtual void setCreateChildren(bool b); |
632 | 633 | ||
633 | /** | 634 | /** |
634 | * Set the selection mode. | 635 | * Set the selection mode. |
635 | * | 636 | * |
636 | * A different name was chosen to avoid API-clashes with @ref QListView::setSelectionMode(). | 637 | * A different name was chosen to avoid API-clashes with @ref QListView::setSelectionMode(). |
637 | */ | 638 | */ |
638 | void setSelectionModeExt (SelectionModeExt mode); | 639 | void setSelectionModeExt (SelectionModeExt mode); |
639 | 640 | ||
640 | /** | 641 | /** |
641 | * Enable/disable tabbing between editable cells | 642 | * Enable/disable tabbing between editable cells |
642 | * @since 3.1 | 643 | * @since 3.1 |
643 | */ | 644 | */ |
644 | void setTabOrderedRenaming(bool b); | 645 | void setTabOrderedRenaming(bool b); |
645 | 646 | ||
646 | /** | 647 | /** |
647 | * Returns whether tab ordered renaming is enabled | 648 | * Returns whether tab ordered renaming is enabled |
648 | * @since 3.1 | 649 | * @since 3.1 |
649 | */ | 650 | */ |
650 | bool tabOrderedRenaming() const; | 651 | bool tabOrderedRenaming() const; |
651 | 652 | ||
652 | protected: | 653 | protected: |
653 | /** | 654 | /** |
654 | * Determine whether a drop on position @p p would count as | 655 | * Determine whether a drop on position @p p would count as |
655 | * being above or below the QRect @p rect. | 656 | * being above or below the QRect @p rect. |
656 | * | 657 | * |
657 | * @param rect is the rectangle we examine. | 658 | * @param rect is the rectangle we examine. |
658 | * @param p is the point located in the rectangle, p is assumed to be in | 659 | * @param p is the point located in the rectangle, p is assumed to be in |
659 | * viewport coordinates. | 660 | * viewport coordinates. |
660 | */ | 661 | */ |
661 | inline bool below (const QRect& rect, const QPoint& p) | 662 | inline bool below (const QRect& rect, const QPoint& p) |
662 | { | 663 | { |
663 | return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); | 664 | return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); |
664 | } | 665 | } |
665 | 666 | ||
666 | /** | 667 | /** |
667 | * An overloaded version of below(const QRect&, const QPoint&). | 668 | * An overloaded version of below(const QRect&, const QPoint&). |
668 | * | 669 | * |
669 | * It differs from the above only in what arguments it takes. | 670 | * It differs from the above only in what arguments it takes. |
670 | * | 671 | * |
671 | * @param i the item whose rect() is passed to the above function. | 672 | * @param i the item whose rect() is passed to the above function. |
672 | * @param p is translated from contents coordinates to viewport coordinates | 673 | * @param p is translated from contents coordinates to viewport coordinates |
673 | * before being passed to the above function. | 674 | * before being passed to the above function. |
674 | */ | 675 | */ |
675 | inline bool below (QListViewItem* i, const QPoint& p) | 676 | inline bool below (QListViewItem* i, const QPoint& p) |
676 | { | 677 | { |
677 | return below (itemRect(i), contentsToViewport(p)); | 678 | return below (itemRect(i), contentsToViewport(p)); |
678 | } | 679 | } |
679 | 680 | ||
680 | /** | 681 | /** |
681 | * Reimplemented to reload the alternate background in palette changes. | 682 | * Reimplemented to reload the alternate background in palette changes. |
682 | * @internal | 683 | * @internal |
683 | */ | 684 | */ |
684 | virtual bool event( QEvent * ); | 685 | virtual bool event( QEvent * ); |
685 | 686 | ||
686 | /** | 687 | /** |
687 | * Emit signal @ref #executed. | 688 | * Emit signal @ref #executed. |
688 | * @internal | 689 | * @internal |
689 | */ | 690 | */ |
690 | //US I added buttonstate to pass the current keyboard status | 691 | //US I added buttonstate to pass the current keyboard status |
691 | void emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c); | 692 | void emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c); |
692 | 693 | ||
693 | /** | 694 | /** |
694 | * Reimplemented for internal reasons. | 695 | * Reimplemented for internal reasons. |
695 | * Further reimplementations should call this function or else | 696 | * Further reimplementations should call this function or else |
696 | * some features may not work correctly. | 697 | * some features may not work correctly. |
697 | * | 698 | * |
698 | * The API is unaffected. | 699 | * The API is unaffected. |
699 | */ | 700 | */ |
700 | virtual void focusInEvent(QFocusEvent* fe); | 701 | virtual void focusInEvent(QFocusEvent* fe); |
701 | 702 | ||
702 | /** | 703 | /** |
703 | * Reimplemented for internal reasons. | 704 | * Reimplemented for internal reasons. |
704 | * Further reimplementations should call this function or else | 705 | * Further reimplementations should call this function or else |
705 | * some features may not work correctly. | 706 | * some features may not work correctly. |
706 | * | 707 | * |
707 | * The API is unaffected. | 708 | * The API is unaffected. |
708 | */ | 709 | */ |
709 | virtual void focusOutEvent( QFocusEvent *fe ); | 710 | virtual void focusOutEvent( QFocusEvent *fe ); |
710 | 711 | ||
711 | /** | 712 | /** |
712 | * Reimplemented for internal reasons. | 713 | * Reimplemented for internal reasons. |
713 | * Further reimplementations should call this function or else | 714 | * Further reimplementations should call this function or else |
714 | * some features may not work correctly. | 715 | * some features may not work correctly. |
715 | * | 716 | * |
716 | * The API is unaffected. | 717 | * The API is unaffected. |
717 | */ | 718 | */ |
718 | virtual void leaveEvent( QEvent *e ); | 719 | virtual void leaveEvent( QEvent *e ); |
719 | 720 | ||
720 | /** | 721 | /** |
721 | * @return the tooltip for @p column of @p item. | 722 | * @return the tooltip for @p column of @p item. |
722 | */ | 723 | */ |
723 | virtual QString tooltip(QListViewItem* item, int column) const; | 724 | virtual QString tooltip(QListViewItem* item, int column) const; |
724 | 725 | ||
725 | /** | 726 | /** |
726 | * @return whether the tooltip for @p column of @p item shall be shown at point @p pos. | 727 | * @return whether the tooltip for @p column of @p item shall be shown at point @p pos. |
727 | */ | 728 | */ |
728 | virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; | 729 | virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; |
729 | 730 | ||
730 | /** | 731 | /** |
731 | * Reimplemented for internal reasons. | 732 | * Reimplemented for internal reasons. |
732 | * Further reimplementations should call this function or else | 733 | * Further reimplementations should call this function or else |
733 | * some features may not work correctly. | 734 | * some features may not work correctly. |
734 | * | 735 | * |
735 | * The API is unaffected. | 736 | * The API is unaffected. |
736 | */ | 737 | */ |
737 | virtual void contentsDragMoveEvent (QDragMoveEvent *event); | 738 | virtual void contentsDragMoveEvent (QDragMoveEvent *event); |
738 | 739 | ||
739 | /** | 740 | /** |
740 | * Reimplemented for internal reasons. | 741 | * Reimplemented for internal reasons. |
741 | * Further reimplementations should call this function or else | 742 | * Further reimplementations should call this function or else |
742 | * some features may not work correctly. | 743 | * some features may not work correctly. |
743 | * | 744 | * |
744 | * The API is unaffected. | 745 | * The API is unaffected. |
745 | */ | 746 | */ |
746 | virtual void contentsMousePressEvent( QMouseEvent *e ); | 747 | virtual void contentsMousePressEvent( QMouseEvent *e ); |
747 | 748 | ||
748 | /** | 749 | /** |
749 | * Reimplemented for internal reasons. | 750 | * Reimplemented for internal reasons. |
750 | * Further reimplementations should call this function or else | 751 | * Further reimplementations should call this function or else |
751 | * some features may not work correctly. | 752 | * some features may not work correctly. |
752 | * | 753 | * |
753 | * The API is unaffected. | 754 | * The API is unaffected. |
754 | */ | 755 | */ |
755 | virtual void contentsMouseMoveEvent( QMouseEvent *e ); | 756 | virtual void contentsMouseMoveEvent( QMouseEvent *e ); |
756 | 757 | ||
757 | /** | 758 | /** |
758 | * Reimplemented for internal reasons. | 759 | * Reimplemented for internal reasons. |
759 | * Further reimplementations should call this function or else | 760 | * Further reimplementations should call this function or else |
760 | * some features may not work correctly. | 761 | * some features may not work correctly. |
761 | * | 762 | * |
762 | * The API is unaffected. | 763 | * The API is unaffected. |
763 | */ | 764 | */ |
764 | virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); | 765 | virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); |
765 | 766 | ||
766 | /** | 767 | /** |
767 | * Reimplemented for internal reasons. | 768 | * Reimplemented for internal reasons. |
768 | * Further reimplementations should call this function or else | 769 | * Further reimplementations should call this function or else |
769 | * some features may not work correctly. | 770 | * some features may not work correctly. |
770 | * | 771 | * |
771 | * The API is unaffected. | 772 | * The API is unaffected. |
772 | */ | 773 | */ |
773 | virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); | 774 | virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); |
774 | 775 | ||
775 | /** | 776 | /** |
776 | * Reimplemented for internal reasons. | 777 | * Reimplemented for internal reasons. |
777 | * Further reimplementations should call this function or else | 778 | * Further reimplementations should call this function or else |
778 | * some features may not work correctly. | 779 | * some features may not work correctly. |
779 | * | 780 | * |
780 | * The API is unaffected. | 781 | * The API is unaffected. |
781 | */ | 782 | */ |
782 | virtual void contentsMouseReleaseEvent (QMouseEvent*); | 783 | virtual void contentsMouseReleaseEvent (QMouseEvent*); |
783 | 784 | ||
784 | /** | 785 | /** |
785 | * Reimplemented for internal reasons. | 786 | * Reimplemented for internal reasons. |
786 | * Further reimplementations should call this function or else | 787 | * Further reimplementations should call this function or else |
787 | * some features may not work correctly. | 788 | * some features may not work correctly. |
788 | * | 789 | * |
789 | * The API is unaffected. | 790 | * The API is unaffected. |
790 | */ | 791 | */ |
791 | virtual void contentsDropEvent (QDropEvent*); | 792 | virtual void contentsDropEvent (QDropEvent*); |
792 | 793 | ||
793 | /** | 794 | /** |
794 | * Reimplemented for internal reasons. | 795 | * Reimplemented for internal reasons. |
795 | * Further reimplementations should call this function or else | 796 | * Further reimplementations should call this function or else |
796 | * some features may not work correctly. | 797 | * some features may not work correctly. |
797 | * | 798 | * |
798 | * The API is unaffected. | 799 | * The API is unaffected. |
799 | */ | 800 | */ |
800 | virtual void contentsDragEnterEvent (QDragEnterEvent *); | 801 | virtual void contentsDragEnterEvent (QDragEnterEvent *); |
801 | 802 | ||
802 | /** | 803 | /** |
803 | * @return a dragobject encoding the current selection. | 804 | * @return a dragobject encoding the current selection. |
804 | * | 805 | * |
805 | * @see setDragEnabled() | 806 | * @see setDragEnabled() |
806 | */ | 807 | */ |
807 | virtual QDragObject *dragObject(); | 808 | virtual QDragObject *dragObject(); |
808 | 809 | ||
809 | /** | 810 | /** |
810 | * @return true if the @p event provides some acceptable | 811 | * @return true if the @p event provides some acceptable |
811 | * format. | 812 | * format. |
812 | * A common mistake is to forget the "const" in your reimplementation | 813 | * A common mistake is to forget the "const" in your reimplementation |
813 | */ | 814 | */ |
814 | virtual bool acceptDrag (QDropEvent* event) const; | 815 | virtual bool acceptDrag (QDropEvent* event) const; |
815 | 816 | ||
816 | /** | 817 | /** |
817 | * Paint the drag line. If painter is null, don't try to :) | 818 | * Paint the drag line. If painter is null, don't try to :) |
818 | * | 819 | * |
819 | * If after == 0 then the marker should be drawn at the top. | 820 | * If after == 0 then the marker should be drawn at the top. |
820 | * | 821 | * |
821 | * @return the rectangle that you painted to. | 822 | * @return the rectangle that you painted to. |
822 | */ | 823 | */ |
823 | virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); | 824 | virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); |
824 | 825 | ||
825 | /** | 826 | /** |
826 | * Paint the drag rectangle. If painter is null, don't try to :) | 827 | * Paint the drag rectangle. If painter is null, don't try to :) |
827 | * | 828 | * |
828 | * | 829 | * |
829 | * @return the rectangle that you painted to. | 830 | * @return the rectangle that you painted to. |
830 | */ | 831 | */ |
831 | virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); | 832 | virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); |
832 | 833 | ||
833 | /** | 834 | /** |
834 | * This method calls @ref dragObject() and starts the drag. | 835 | * This method calls @ref dragObject() and starts the drag. |
835 | * | 836 | * |
836 | * Reimplement it to do fancy stuff like setting a pixmap or | 837 | * Reimplement it to do fancy stuff like setting a pixmap or |
837 | * using a non-default DragMode | 838 | * using a non-default DragMode |
838 | */ | 839 | */ |
839 | virtual void startDrag(); | 840 | virtual void startDrag(); |
840 | 841 | ||
841 | /** | 842 | /** |
842 | * Reimplemented for internal reasons. | 843 | * Reimplemented for internal reasons. |
843 | * Further reimplementations should call this function or else | 844 | * Further reimplementations should call this function or else |
844 | * some features may not work correctly. | 845 | * some features may not work correctly. |
845 | * | 846 | * |
846 | * The API is unaffected. | 847 | * The API is unaffected. |
847 | */ | 848 | */ |
848 | virtual void keyPressEvent (QKeyEvent*); | 849 | virtual void keyPressEvent (QKeyEvent*); |
849 | 850 | ||
850 | /** | 851 | /** |
851 | * Reimplemented for internal reasons. | 852 | * Reimplemented for internal reasons. |
852 | * Further reimplementations should call this function or else | 853 | * Further reimplementations should call this function or else |
853 | * some features may not work correctly. | 854 | * some features may not work correctly. |
854 | * | 855 | * |
855 | * The API is unaffected. | 856 | * The API is unaffected. |
856 | */ | 857 | */ |
857 | virtual void viewportPaintEvent(QPaintEvent*); | 858 | virtual void viewportPaintEvent(QPaintEvent*); |
858 | 859 | ||
859 | /** | 860 | /** |
860 | * In FileManager selection mode: explicitely activate the mode | 861 | * In FileManager selection mode: explicitely activate the mode |
861 | * in which the current item is automatically selected. | 862 | * in which the current item is automatically selected. |
862 | */ | 863 | */ |
863 | void activateAutomaticSelection(); | 864 | void activateAutomaticSelection(); |
864 | /** | 865 | /** |
865 | * In FileManager selection mode: explicitely deactivate the mode | 866 | * In FileManager selection mode: explicitely deactivate the mode |
866 | * in which the current item is automatically selected. | 867 | * in which the current item is automatically selected. |
867 | */ | 868 | */ |
868 | void deactivateAutomaticSelection(); | 869 | void deactivateAutomaticSelection(); |
869 | /** | 870 | /** |
870 | * In FileManager selection mode: return whether it is currently in the mode | 871 | * In FileManager selection mode: return whether it is currently in the mode |
871 | * where the current item is selected automatically. | 872 | * where the current item is selected automatically. |
872 | * Returns false if items were selected explicitely, e.g. using the mouse. | 873 | * Returns false if items were selected explicitely, e.g. using the mouse. |
873 | */ | 874 | */ |
874 | bool automaticSelection() const; | 875 | bool automaticSelection() const; |
875 | 876 | ||
876 | /** | 877 | /** |
877 | * Reimplemented for setFullWidth() | 878 | * Reimplemented for setFullWidth() |
878 | */ | 879 | */ |
879 | virtual void viewportResizeEvent(QResizeEvent* e); | 880 | virtual void viewportResizeEvent(QResizeEvent* e); |
880 | 881 | ||
881 | protected slots: | 882 | protected slots: |
882 | /** | 883 | /** |
883 | * Update internal settings whenever the global ones change. | 884 | * Update internal settings whenever the global ones change. |
884 | * @internal | 885 | * @internal |
885 | */ | 886 | */ |
886 | void slotSettingsChanged(int); | 887 | void slotSettingsChanged(int); |
887 | 888 | ||
888 | void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ); | 889 | void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ); |
889 | void doneEditing(QListViewItem *item, int row); | 890 | void doneEditing(QListViewItem *item, int row); |
890 | 891 | ||
891 | /** | 892 | /** |
892 | * Repaint the rect where I was drawing the drop line. | 893 | * Repaint the rect where I was drawing the drop line. |
893 | */ | 894 | */ |
894 | void cleanDropVisualizer(); | 895 | void cleanDropVisualizer(); |
895 | 896 | ||
896 | /** | 897 | /** |
897 | * Repaint the rect where I was drawing the drop rectangle. | 898 | * Repaint the rect where I was drawing the drop rectangle. |
898 | */ | 899 | */ |
899 | void cleanItemHighlighter(); | 900 | void cleanItemHighlighter(); |
900 | 901 | ||
901 | /** | 902 | /** |
902 | * Emit the @ref contextMenu signal. This slot is for mouse actions. | 903 | * Emit the @ref contextMenu signal. This slot is for mouse actions. |
903 | */ | 904 | */ |
904 | void emitContextMenu (QListViewItem*, const QPoint&, int); | 905 | void emitContextMenu (QListViewItem*, const QPoint&, int); |
905 | 906 | ||
906 | /** | 907 | /** |
907 | * Emit the @ref #contextMenu signal. This slot is for key presses. | 908 | * Emit the @ref #contextMenu signal. This slot is for key presses. |
908 | */ | 909 | */ |
909 | void emitContextMenu (KListView*, QListViewItem*); | 910 | void emitContextMenu (KListView*, QListViewItem*); |
910 | 911 | ||
911 | /** | 912 | /** |
912 | * Accessory slot for AutoSelect | 913 | * Accessory slot for AutoSelect |
913 | * @internal | 914 | * @internal |
914 | */ | 915 | */ |
915 | void slotOnItem( QListViewItem *item ); | 916 | void slotOnItem( QListViewItem *item ); |
916 | 917 | ||
917 | /** | 918 | /** |
918 | * Accessory slot for AutoSelect/ChangeCursorOverItem | 919 | * Accessory slot for AutoSelect/ChangeCursorOverItem |
919 | * @internal | 920 | * @internal |
920 | */ | 921 | */ |
921 | void slotOnViewport(); | 922 | void slotOnViewport(); |
922 | 923 | ||
923 | /** | 924 | /** |
924 | * Process AutoSelection. | 925 | * Process AutoSelection. |
925 | * @internal | 926 | * @internal |
926 | */ | 927 | */ |
927 | void slotAutoSelect(); | 928 | void slotAutoSelect(); |
928 | 929 | ||
929 | void slotDragExpand(); | 930 | void slotDragExpand(); |
930 | 931 | ||
931 | /** | 932 | /** |
932 | * Reacts to header changes in full width mode | 933 | * Reacts to header changes in full width mode |
933 | * @internal | 934 | * @internal |
934 | */ | 935 | */ |
935 | void slotHeaderChanged(); | 936 | void slotHeaderChanged(); |
936 | 937 | ||
937 | protected: | 938 | protected: |
938 | /** | 939 | /** |
939 | * Handle dropEvent when itemsMovable() is set to true. | 940 | * Handle dropEvent when itemsMovable() is set to true. |
940 | */ | 941 | */ |
941 | virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme); | 942 | virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme); |
942 | 943 | ||
943 | /** | 944 | /** |
944 | * Where is the nearest QListViewItem that I'm going to drop? | 945 | * Where is the nearest QListViewItem that I'm going to drop? |
945 | * | 946 | * |
946 | * FIXME KDE 4.0: Make this method const so it can be called from an | 947 | * FIXME KDE 4.0: Make this method const so it can be called from an |
947 | * acceptDrag method without ugly casts | 948 | * acceptDrag method without ugly casts |
948 | */ | 949 | */ |
949 | virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after); | 950 | virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after); |
950 | 951 | ||
951 | /** | 952 | /** |
952 | * A special keyPressEvent (for FileManager selection mode). | 953 | * A special keyPressEvent (for FileManager selection mode). |
953 | */ | 954 | */ |
954 | void fileManagerKeyPressEvent (QKeyEvent*); | 955 | void fileManagerKeyPressEvent (QKeyEvent*); |
955 | 956 | ||
956 | /** | 957 | /** |
957 | * Convert the depth of an item into its indentation in pixels | 958 | * Convert the depth of an item into its indentation in pixels |
958 | */ | 959 | */ |
959 | int depthToPixels( int depth ); | 960 | int depthToPixels( int depth ); |
960 | 961 | ||
961 | private: | 962 | private: |
962 | class Tooltip; | 963 | class Tooltip; |
963 | protected: | 964 | protected: |
964 | virtual void virtual_hook( int id, void* data ); | 965 | virtual void virtual_hook( int id, void* data ); |
965 | private: | 966 | private: |
966 | class KListViewPrivate; | 967 | class KListViewPrivate; |
967 | KListViewPrivate *d; | 968 | KListViewPrivate *d; |
968 | }; | 969 | }; |
969 | 970 | ||
970 | /** | 971 | /** |
971 | * A listview item with support for alternate background colours. It is | 972 | * A listview item with support for alternate background colours. It is |
972 | * a drop-in replacement for @ref QListViewItem | 973 | * a drop-in replacement for @ref QListViewItem |
973 | * | 974 | * |
974 | * @short listview item with alternate background colour support | 975 | * @short listview item with alternate background colour support |
975 | */ | 976 | */ |
976 | class KListViewItem : public QListViewItem | 977 | class KListViewItem : public QListViewItem |
977 | { | 978 | { |
978 | public: | 979 | public: |
979 | /** | 980 | /** |
980 | * constructors. The semantics remain as in @ref QListViewItem. | 981 | * constructors. The semantics remain as in @ref QListViewItem. |
981 | * Although they accept a @ref QListViewItem as parent, please | 982 | * Although they accept a @ref QListViewItem as parent, please |
982 | * don't mix KListViewItem (or subclasses) with QListViewItem | 983 | * don't mix KListViewItem (or subclasses) with QListViewItem |
983 | * (or subclasses). | 984 | * (or subclasses). |
984 | */ | 985 | */ |
985 | KListViewItem(QListView *parent); | 986 | KListViewItem(QListView *parent); |
986 | KListViewItem(QListViewItem *parent); | 987 | KListViewItem(QListViewItem *parent); |
987 | KListViewItem(QListView *parent, QListViewItem *after); | 988 | KListViewItem(QListView *parent, QListViewItem *after); |
988 | KListViewItem(QListViewItem *parent, QListViewItem *after); | 989 | KListViewItem(QListViewItem *parent, QListViewItem *after); |
989 | 990 | ||
990 | KListViewItem(QListView *parent, | 991 | KListViewItem(QListView *parent, |
991 | QString, QString = QString::null, | 992 | QString, QString = QString::null, |
992 | QString = QString::null, QString = QString::null, | 993 | QString = QString::null, QString = QString::null, |
993 | QString = QString::null, QString = QString::null, | 994 | QString = QString::null, QString = QString::null, |
994 | QString = QString::null, QString = QString::null); | 995 | QString = QString::null, QString = QString::null); |
995 | 996 | ||
996 | KListViewItem(QListViewItem *parent, | 997 | KListViewItem(QListViewItem *parent, |
997 | QString, QString = QString::null, | 998 | QString, QString = QString::null, |
998 | QString = QString::null, QString = QString::null, | 999 | QString = QString::null, QString = QString::null, |
999 | QString = QString::null, QString = QString::null, | 1000 | QString = QString::null, QString = QString::null, |
1000 | QString = QString::null, QString = QString::null); | 1001 | QString = QString::null, QString = QString::null); |
1001 | 1002 | ||
1002 | KListViewItem(QListView *parent, QListViewItem *after, | 1003 | KListViewItem(QListView *parent, QListViewItem *after, |
1003 | QString, QString = QString::null, | 1004 | QString, QString = QString::null, |
1004 | QString = QString::null, QString = QString::null, | 1005 | QString = QString::null, QString = QString::null, |
1005 | QString = QString::null, QString = QString::null, | 1006 | QString = QString::null, QString = QString::null, |
1006 | QString = QString::null, QString = QString::null); | 1007 | QString = QString::null, QString = QString::null); |
1007 | 1008 | ||
1008 | KListViewItem(QListViewItem *parent, QListViewItem *after, | 1009 | KListViewItem(QListViewItem *parent, QListViewItem *after, |
1009 | QString, QString = QString::null, | 1010 | QString, QString = QString::null, |
1010 | QString = QString::null, QString = QString::null, | 1011 | QString = QString::null, QString = QString::null, |
1011 | QString = QString::null, QString = QString::null, | 1012 | QString = QString::null, QString = QString::null, |
1012 | QString = QString::null, QString = QString::null); | 1013 | QString = QString::null, QString = QString::null); |
1013 | 1014 | ||
1014 | virtual ~KListViewItem(); | 1015 | virtual ~KListViewItem(); |
1015 | 1016 | ||
1016 | /** | 1017 | /** |
1017 | * retuns true if this item is to be drawn with the alternate background | 1018 | * retuns true if this item is to be drawn with the alternate background |
1018 | */ | 1019 | */ |
1019 | bool isAlternate(); | 1020 | bool isAlternate(); |
1020 | /** | 1021 | /** |
1021 | * returns the background colour for this item | 1022 | * returns the background colour for this item |
1022 | */ | 1023 | */ |
1023 | const QColor &backgroundColor(); | 1024 | const QColor &backgroundColor(); |
1024 | 1025 | ||
1025 | virtual void paintCell(QPainter *p, const QColorGroup &cg, | 1026 | virtual void paintCell(QPainter *p, const QColorGroup &cg, |
1026 | int column, int width, int alignment); | 1027 | int column, int width, int alignment); |
1027 | 1028 | ||
1028 | private: | 1029 | private: |
1029 | void init(); | 1030 | void init(); |
1030 | 1031 | ||
1031 | private: | 1032 | private: |
1032 | uint m_odd : 1; | 1033 | uint m_odd : 1; |
1033 | uint m_known : 1; | 1034 | uint m_known : 1; |
1034 | uint m_unused : 30; | 1035 | uint m_unused : 30; |
1035 | }; | 1036 | }; |
1036 | 1037 | ||
1037 | #endif | 1038 | #endif |
1038 | 1039 | ||
1039 | // vim: ts=2 sw=2 et | 1040 | // vim: ts=2 sw=2 et |