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