Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qlistview.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); | - | ||||||||||||||||||||||||
9 | QListView::QListView(QWidget *parent) | - | ||||||||||||||||||||||||
10 | : QAbstractItemView(*new QListViewPrivate, parent) | - | ||||||||||||||||||||||||
11 | { | - | ||||||||||||||||||||||||
12 | setViewMode(ListMode); | - | ||||||||||||||||||||||||
13 | setSelectionMode(SingleSelection); | - | ||||||||||||||||||||||||
14 | setAttribute(Qt::WA_MacShowFocusRect); | - | ||||||||||||||||||||||||
15 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
16 | d->updateStyledFrameWidths(); | - | ||||||||||||||||||||||||
17 | } never executed: end of block | 0 | ||||||||||||||||||||||||
18 | - | |||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||
20 | - | |||||||||||||||||||||||||
21 | - | |||||||||||||||||||||||||
22 | QListView::QListView(QListViewPrivate &dd, QWidget *parent) | - | ||||||||||||||||||||||||
23 | : QAbstractItemView(dd, parent) | - | ||||||||||||||||||||||||
24 | { | - | ||||||||||||||||||||||||
25 | setViewMode(ListMode); | - | ||||||||||||||||||||||||
26 | setSelectionMode(SingleSelection); | - | ||||||||||||||||||||||||
27 | setAttribute(Qt::WA_MacShowFocusRect); | - | ||||||||||||||||||||||||
28 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
29 | d->updateStyledFrameWidths(); | - | ||||||||||||||||||||||||
30 | } never executed: end of block | 0 | ||||||||||||||||||||||||
31 | - | |||||||||||||||||||||||||
32 | - | |||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||
35 | QListView::~QListView() | - | ||||||||||||||||||||||||
36 | { | - | ||||||||||||||||||||||||
37 | } | - | ||||||||||||||||||||||||
38 | void QListView::setMovement(Movement movement) | - | ||||||||||||||||||||||||
39 | { | - | ||||||||||||||||||||||||
40 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
41 | d->modeProperties |= uint(QListViewPrivate::Movement); | - | ||||||||||||||||||||||||
42 | d->movement = movement; | - | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||
45 | bool movable = (movement != Static); | - | ||||||||||||||||||||||||
46 | setDragEnabled(movable); | - | ||||||||||||||||||||||||
47 | d->viewport->setAcceptDrops(movable); | - | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
50 | } never executed: end of block | 0 | ||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | QListView::Movement QListView::movement() const | - | ||||||||||||||||||||||||
53 | { | - | ||||||||||||||||||||||||
54 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
55 | return never executed: d->movement;return d->movement; never executed: return d->movement; | 0 | ||||||||||||||||||||||||
56 | } | - | ||||||||||||||||||||||||
57 | void QListView::setFlow(Flow flow) | - | ||||||||||||||||||||||||
58 | { | - | ||||||||||||||||||||||||
59 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
60 | d->modeProperties |= uint(QListViewPrivate::Flow); | - | ||||||||||||||||||||||||
61 | d->flow = flow; | - | ||||||||||||||||||||||||
62 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
63 | } never executed: end of block | 0 | ||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||
65 | QListView::Flow QListView::flow() const | - | ||||||||||||||||||||||||
66 | { | - | ||||||||||||||||||||||||
67 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
68 | return never executed: d->flow;return d->flow; never executed: return d->flow; | 0 | ||||||||||||||||||||||||
69 | } | - | ||||||||||||||||||||||||
70 | void QListView::setWrapping(bool enable) | - | ||||||||||||||||||||||||
71 | { | - | ||||||||||||||||||||||||
72 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
73 | d->modeProperties |= uint(QListViewPrivate::Wrap); | - | ||||||||||||||||||||||||
74 | d->setWrapping(enable); | - | ||||||||||||||||||||||||
75 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
76 | } never executed: end of block | 0 | ||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | bool QListView::isWrapping() const | - | ||||||||||||||||||||||||
79 | { | - | ||||||||||||||||||||||||
80 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
81 | return never executed: d->isWrapping();return d->isWrapping(); never executed: return d->isWrapping(); | 0 | ||||||||||||||||||||||||
82 | } | - | ||||||||||||||||||||||||
83 | void QListView::setResizeMode(ResizeMode mode) | - | ||||||||||||||||||||||||
84 | { | - | ||||||||||||||||||||||||
85 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
86 | d->modeProperties |= uint(QListViewPrivate::ResizeMode); | - | ||||||||||||||||||||||||
87 | d->resizeMode = mode; | - | ||||||||||||||||||||||||
88 | } never executed: end of block | 0 | ||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | QListView::ResizeMode QListView::resizeMode() const | - | ||||||||||||||||||||||||
91 | { | - | ||||||||||||||||||||||||
92 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
93 | return never executed: d->resizeMode;return d->resizeMode; never executed: return d->resizeMode; | 0 | ||||||||||||||||||||||||
94 | } | - | ||||||||||||||||||||||||
95 | void QListView::setLayoutMode(LayoutMode mode) | - | ||||||||||||||||||||||||
96 | { | - | ||||||||||||||||||||||||
97 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
98 | d->layoutMode = mode; | - | ||||||||||||||||||||||||
99 | } never executed: end of block | 0 | ||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||
101 | QListView::LayoutMode QListView::layoutMode() const | - | ||||||||||||||||||||||||
102 | { | - | ||||||||||||||||||||||||
103 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
104 | return never executed: d->layoutMode;return d->layoutMode; never executed: return d->layoutMode; | 0 | ||||||||||||||||||||||||
105 | } | - | ||||||||||||||||||||||||
106 | void QListView::setSpacing(int space) | - | ||||||||||||||||||||||||
107 | { | - | ||||||||||||||||||||||||
108 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
109 | d->modeProperties |= uint(QListViewPrivate::Spacing); | - | ||||||||||||||||||||||||
110 | d->setSpacing(space); | - | ||||||||||||||||||||||||
111 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
112 | } never executed: end of block | 0 | ||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||
114 | int QListView::spacing() const | - | ||||||||||||||||||||||||
115 | { | - | ||||||||||||||||||||||||
116 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
117 | return never executed: d->spacing();return d->spacing(); never executed: return d->spacing(); | 0 | ||||||||||||||||||||||||
118 | } | - | ||||||||||||||||||||||||
119 | void QListView::setBatchSize(int batchSize) | - | ||||||||||||||||||||||||
120 | { | - | ||||||||||||||||||||||||
121 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
122 | if (batchSize <= 0
| 0 | ||||||||||||||||||||||||
123 | QMessageLogger(__FILE__, 396, __PRETTY_FUNCTION__).warning("Invalid batchSize (%d)", batchSize); | - | ||||||||||||||||||||||||
124 | return; never executed: return; | 0 | ||||||||||||||||||||||||
125 | } | - | ||||||||||||||||||||||||
126 | d->batchSize = batchSize; | - | ||||||||||||||||||||||||
127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||
129 | int QListView::batchSize() const | - | ||||||||||||||||||||||||
130 | { | - | ||||||||||||||||||||||||
131 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
132 | return never executed: d->batchSize;return d->batchSize; never executed: return d->batchSize; | 0 | ||||||||||||||||||||||||
133 | } | - | ||||||||||||||||||||||||
134 | void QListView::setGridSize(const QSize &size) | - | ||||||||||||||||||||||||
135 | { | - | ||||||||||||||||||||||||
136 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
137 | d->modeProperties |= uint(QListViewPrivate::GridSize); | - | ||||||||||||||||||||||||
138 | d->setGridSize(size); | - | ||||||||||||||||||||||||
139 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
140 | } never executed: end of block | 0 | ||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | QSize QListView::gridSize() const | - | ||||||||||||||||||||||||
143 | { | - | ||||||||||||||||||||||||
144 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
145 | return never executed: d->gridSize();return d->gridSize(); never executed: return d->gridSize(); | 0 | ||||||||||||||||||||||||
146 | } | - | ||||||||||||||||||||||||
147 | void QListView::setViewMode(ViewMode mode) | - | ||||||||||||||||||||||||
148 | { | - | ||||||||||||||||||||||||
149 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
150 | if (d->commonListView
| 0 | ||||||||||||||||||||||||
151 | return; never executed: return; | 0 | ||||||||||||||||||||||||
152 | d->viewMode = mode; | - | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | delete d->commonListView; | - | ||||||||||||||||||||||||
155 | if (mode == ListMode
| 0 | ||||||||||||||||||||||||
156 | d->commonListView = new QListModeViewBase(this, d); | - | ||||||||||||||||||||||||
157 | if (!(d->modeProperties & QListViewPrivate::Wrap)
| 0 | ||||||||||||||||||||||||
158 | d->setWrapping(false); never executed: d->setWrapping(false); | 0 | ||||||||||||||||||||||||
159 | if (!(d->modeProperties & QListViewPrivate::Spacing)
| 0 | ||||||||||||||||||||||||
160 | d->setSpacing(0); never executed: d->setSpacing(0); | 0 | ||||||||||||||||||||||||
161 | if (!(d->modeProperties & QListViewPrivate::GridSize)
| 0 | ||||||||||||||||||||||||
162 | d->setGridSize(QSize()); never executed: d->setGridSize(QSize()); | 0 | ||||||||||||||||||||||||
163 | if (!(d->modeProperties & QListViewPrivate::Flow)
| 0 | ||||||||||||||||||||||||
164 | d->flow = TopToBottom; never executed: d->flow = TopToBottom; | 0 | ||||||||||||||||||||||||
165 | if (!(d->modeProperties & QListViewPrivate::Movement)
| 0 | ||||||||||||||||||||||||
166 | d->movement = Static; never executed: d->movement = Static; | 0 | ||||||||||||||||||||||||
167 | if (!(d->modeProperties & QListViewPrivate::ResizeMode)
| 0 | ||||||||||||||||||||||||
168 | d->resizeMode = Fixed; never executed: d->resizeMode = Fixed; | 0 | ||||||||||||||||||||||||
169 | if (!(d->modeProperties & QListViewPrivate::SelectionRectVisible)
| 0 | ||||||||||||||||||||||||
170 | d->showElasticBand = false; never executed: d->showElasticBand = false; | 0 | ||||||||||||||||||||||||
171 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
172 | d->commonListView = new QIconModeViewBase(this, d); | - | ||||||||||||||||||||||||
173 | if (!(d->modeProperties & QListViewPrivate::Wrap)
| 0 | ||||||||||||||||||||||||
174 | d->setWrapping(true); never executed: d->setWrapping(true); | 0 | ||||||||||||||||||||||||
175 | if (!(d->modeProperties & QListViewPrivate::Spacing)
| 0 | ||||||||||||||||||||||||
176 | d->setSpacing(0); never executed: d->setSpacing(0); | 0 | ||||||||||||||||||||||||
177 | if (!(d->modeProperties & QListViewPrivate::GridSize)
| 0 | ||||||||||||||||||||||||
178 | d->setGridSize(QSize()); never executed: d->setGridSize(QSize()); | 0 | ||||||||||||||||||||||||
179 | if (!(d->modeProperties & QListViewPrivate::Flow)
| 0 | ||||||||||||||||||||||||
180 | d->flow = LeftToRight; never executed: d->flow = LeftToRight; | 0 | ||||||||||||||||||||||||
181 | if (!(d->modeProperties & QListViewPrivate::Movement)
| 0 | ||||||||||||||||||||||||
182 | d->movement = Free; never executed: d->movement = Free; | 0 | ||||||||||||||||||||||||
183 | if (!(d->modeProperties & QListViewPrivate::ResizeMode)
| 0 | ||||||||||||||||||||||||
184 | d->resizeMode = Fixed; never executed: d->resizeMode = Fixed; | 0 | ||||||||||||||||||||||||
185 | if (!(d->modeProperties & QListViewPrivate::SelectionRectVisible)
| 0 | ||||||||||||||||||||||||
186 | d->showElasticBand = true; never executed: d->showElasticBand = true; | 0 | ||||||||||||||||||||||||
187 | } never executed: end of block | 0 | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | - | |||||||||||||||||||||||||
190 | bool movable = (d->movement != Static); | - | ||||||||||||||||||||||||
191 | setDragEnabled(movable); | - | ||||||||||||||||||||||||
192 | setAcceptDrops(movable); | - | ||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||
194 | d->clear(); | - | ||||||||||||||||||||||||
195 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||
198 | QListView::ViewMode QListView::viewMode() const | - | ||||||||||||||||||||||||
199 | { | - | ||||||||||||||||||||||||
200 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
201 | return never executed: d->viewMode;return d->viewMode; never executed: return d->viewMode; | 0 | ||||||||||||||||||||||||
202 | } | - | ||||||||||||||||||||||||
203 | void QListView::clearPropertyFlags() | - | ||||||||||||||||||||||||
204 | { | - | ||||||||||||||||||||||||
205 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
206 | d->modeProperties = 0; | - | ||||||||||||||||||||||||
207 | } never executed: end of block | 0 | ||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||
209 | - | |||||||||||||||||||||||||
210 | - | |||||||||||||||||||||||||
211 | - | |||||||||||||||||||||||||
212 | bool QListView::isRowHidden(int row) const | - | ||||||||||||||||||||||||
213 | { | - | ||||||||||||||||||||||||
214 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
215 | return never executed: d->isHidden(row);return d->isHidden(row); never executed: return d->isHidden(row); | 0 | ||||||||||||||||||||||||
216 | } | - | ||||||||||||||||||||||||
217 | - | |||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||
219 | - | |||||||||||||||||||||||||
220 | - | |||||||||||||||||||||||||
221 | - | |||||||||||||||||||||||||
222 | void QListView::setRowHidden(int row, bool hide) | - | ||||||||||||||||||||||||
223 | { | - | ||||||||||||||||||||||||
224 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
225 | const bool hidden = d->isHidden(row); | - | ||||||||||||||||||||||||
226 | if (hide
| 0 | ||||||||||||||||||||||||
227 | d->commonListView->appendHiddenRow(row); never executed: d->commonListView->appendHiddenRow(row); | 0 | ||||||||||||||||||||||||
228 | else if (!hide
| 0 | ||||||||||||||||||||||||
229 | d->commonListView->removeHiddenRow(row); never executed: d->commonListView->removeHiddenRow(row); | 0 | ||||||||||||||||||||||||
230 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
231 | d->viewport->update(); | - | ||||||||||||||||||||||||
232 | } never executed: end of block | 0 | ||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | QRect QListView::visualRect(const QModelIndex &index) const | - | ||||||||||||||||||||||||
238 | { | - | ||||||||||||||||||||||||
239 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
240 | return never executed: d->mapToViewport(rectForIndex(index));return d->mapToViewport(rectForIndex(index)); never executed: return d->mapToViewport(rectForIndex(index)); | 0 | ||||||||||||||||||||||||
241 | } | - | ||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | void QListView::scrollTo(const QModelIndex &index, ScrollHint hint) | - | ||||||||||||||||||||||||
247 | { | - | ||||||||||||||||||||||||
248 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||
250 | if (index.parent() != d->root
| 0 | ||||||||||||||||||||||||
251 | return; never executed: return; | 0 | ||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||
253 | const QRect rect = visualRect(index); | - | ||||||||||||||||||||||||
254 | if (hint == EnsureVisible
| 0 | ||||||||||||||||||||||||
255 | d->viewport->update(rect); | - | ||||||||||||||||||||||||
256 | return; never executed: return; | 0 | ||||||||||||||||||||||||
257 | } | - | ||||||||||||||||||||||||
258 | - | |||||||||||||||||||||||||
259 | if (d->flow == QListView::TopToBottom
| 0 | ||||||||||||||||||||||||
260 | verticalScrollBar()->setValue(d->verticalScrollToValue(index, rect, hint)); never executed: verticalScrollBar()->setValue(d->verticalScrollToValue(index, rect, hint)); | 0 | ||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||
262 | if (d->flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
263 | horizontalScrollBar()->setValue(d->horizontalScrollToValue(index, rect, hint)); never executed: horizontalScrollBar()->setValue(d->horizontalScrollToValue(index, rect, hint)); | 0 | ||||||||||||||||||||||||
264 | } never executed: end of block | 0 | ||||||||||||||||||||||||
265 | - | |||||||||||||||||||||||||
266 | int QListViewPrivate::horizontalScrollToValue(const QModelIndex &index, const QRect &rect, | - | ||||||||||||||||||||||||
267 | QListView::ScrollHint hint) const | - | ||||||||||||||||||||||||
268 | { | - | ||||||||||||||||||||||||
269 | const QListView * const q = q_func(); | - | ||||||||||||||||||||||||
270 | const QRect area = viewport->rect(); | - | ||||||||||||||||||||||||
271 | const bool leftOf = q->isRightToLeft()
| 0 | ||||||||||||||||||||||||
272 | ? (
| 0 | ||||||||||||||||||||||||
273 | : rect.left() < area.left(); | - | ||||||||||||||||||||||||
274 | const bool rightOf = q->isRightToLeft()
| 0 | ||||||||||||||||||||||||
275 | ? rect.right() > area.right() | - | ||||||||||||||||||||||||
276 | : (
| 0 | ||||||||||||||||||||||||
277 | return never executed: commonListView->horizontalScrollToValue(q->visualIndex(index), hint, leftOf, rightOf, area, rect);return commonListView->horizontalScrollToValue(q->visualIndex(index), hint, leftOf, rightOf, area, rect); never executed: return commonListView->horizontalScrollToValue(q->visualIndex(index), hint, leftOf, rightOf, area, rect); | 0 | ||||||||||||||||||||||||
278 | } | - | ||||||||||||||||||||||||
279 | - | |||||||||||||||||||||||||
280 | int QListViewPrivate::verticalScrollToValue(const QModelIndex &index, const QRect &rect, | - | ||||||||||||||||||||||||
281 | QListView::ScrollHint hint) const | - | ||||||||||||||||||||||||
282 | { | - | ||||||||||||||||||||||||
283 | const QListView * const q = q_func(); | - | ||||||||||||||||||||||||
284 | const QRect area = viewport->rect(); | - | ||||||||||||||||||||||||
285 | const bool above = (hint == QListView::EnsureVisible
| 0 | ||||||||||||||||||||||||
286 | const bool below = (hint == QListView::EnsureVisible
| 0 | ||||||||||||||||||||||||
287 | return never executed: commonListView->verticalScrollToValue(q->visualIndex(index), hint, above, below, area, rect);return commonListView->verticalScrollToValue(q->visualIndex(index), hint, above, below, area, rect); never executed: return commonListView->verticalScrollToValue(q->visualIndex(index), hint, above, below, area, rect); | 0 | ||||||||||||||||||||||||
288 | } | - | ||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||
290 | void QListViewPrivate::selectAll(QItemSelectionModel::SelectionFlags command) | - | ||||||||||||||||||||||||
291 | { | - | ||||||||||||||||||||||||
292 | if (!selectionModel
| 0 | ||||||||||||||||||||||||
293 | return; never executed: return; | 0 | ||||||||||||||||||||||||
294 | - | |||||||||||||||||||||||||
295 | QItemSelection selection; | - | ||||||||||||||||||||||||
296 | QModelIndex topLeft; | - | ||||||||||||||||||||||||
297 | int row = 0; | - | ||||||||||||||||||||||||
298 | const int colCount = model->columnCount(root); | - | ||||||||||||||||||||||||
299 | for(; row < model->rowCount(root)
| 0 | ||||||||||||||||||||||||
300 | if (isHidden(row)
| 0 | ||||||||||||||||||||||||
301 | - | |||||||||||||||||||||||||
302 | if (topLeft.isValid()
| 0 | ||||||||||||||||||||||||
303 | QModelIndex bottomRight = model->index(row - 1, colCount - 1, root); | - | ||||||||||||||||||||||||
304 | selection.append(QItemSelectionRange(topLeft, bottomRight)); | - | ||||||||||||||||||||||||
305 | topLeft = QModelIndex(); | - | ||||||||||||||||||||||||
306 | } never executed: end of block | 0 | ||||||||||||||||||||||||
307 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
308 | } | - | ||||||||||||||||||||||||
309 | - | |||||||||||||||||||||||||
310 | if (!topLeft.isValid()
| 0 | ||||||||||||||||||||||||
311 | topLeft = model->index(row, 0, root); never executed: topLeft = model->index(row, 0, root); | 0 | ||||||||||||||||||||||||
312 | } never executed: end of block | 0 | ||||||||||||||||||||||||
313 | - | |||||||||||||||||||||||||
314 | if (topLeft.isValid()
| 0 | ||||||||||||||||||||||||
315 | - | |||||||||||||||||||||||||
316 | QModelIndex bottomRight = model->index(row - 1, colCount - 1, root); | - | ||||||||||||||||||||||||
317 | selection.append(QItemSelectionRange(topLeft, bottomRight)); | - | ||||||||||||||||||||||||
318 | } never executed: end of block | 0 | ||||||||||||||||||||||||
319 | - | |||||||||||||||||||||||||
320 | if (!selection.isEmpty()
| 0 | ||||||||||||||||||||||||
321 | selectionModel->select(selection, command); never executed: selectionModel->select(selection, command); | 0 | ||||||||||||||||||||||||
322 | } never executed: end of block | 0 | ||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||
325 | - | |||||||||||||||||||||||||
326 | - | |||||||||||||||||||||||||
327 | - | |||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||
330 | QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const | - | ||||||||||||||||||||||||
331 | { | - | ||||||||||||||||||||||||
332 | ((!(r)) ? qt_assert("r",__FILE__,647) : qt_noop()); | - | ||||||||||||||||||||||||
333 | const QListView * const q = q_func(); | - | ||||||||||||||||||||||||
334 | QRect &rect = *r; | - | ||||||||||||||||||||||||
335 | const QRect viewportRect = viewport->rect(); | - | ||||||||||||||||||||||||
336 | QItemViewPaintPairs ret; | - | ||||||||||||||||||||||||
337 | const QSet<QModelIndex> visibleIndexes = intersectingSet(viewportRect.translated(q->horizontalOffset(), q->verticalOffset())).toList().toSet(); | - | ||||||||||||||||||||||||
338 | for (int i = 0; i < indexes.count()
| 0 | ||||||||||||||||||||||||
339 | const QModelIndex &index = indexes.at(i); | - | ||||||||||||||||||||||||
340 | if (visibleIndexes.contains(index)
| 0 | ||||||||||||||||||||||||
341 | const QRect current = q->visualRect(index); | - | ||||||||||||||||||||||||
342 | ret += qMakePair(current, index); | - | ||||||||||||||||||||||||
343 | rect |= current; | - | ||||||||||||||||||||||||
344 | } never executed: end of block | 0 | ||||||||||||||||||||||||
345 | } never executed: end of block | 0 | ||||||||||||||||||||||||
346 | rect &= viewportRect; | - | ||||||||||||||||||||||||
347 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
348 | } | - | ||||||||||||||||||||||||
349 | - | |||||||||||||||||||||||||
350 | - | |||||||||||||||||||||||||
351 | - | |||||||||||||||||||||||||
352 | - | |||||||||||||||||||||||||
353 | void QListView::reset() | - | ||||||||||||||||||||||||
354 | { | - | ||||||||||||||||||||||||
355 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
356 | d->clear(); | - | ||||||||||||||||||||||||
357 | d->hiddenRows.clear(); | - | ||||||||||||||||||||||||
358 | QAbstractItemView::reset(); | - | ||||||||||||||||||||||||
359 | } never executed: end of block | 0 | ||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||
361 | - | |||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | - | |||||||||||||||||||||||||
364 | void QListView::setRootIndex(const QModelIndex &index) | - | ||||||||||||||||||||||||
365 | { | - | ||||||||||||||||||||||||
366 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
367 | d->column = qBound(0, d->column, d->model->columnCount(index) - 1); | - | ||||||||||||||||||||||||
368 | QAbstractItemView::setRootIndex(index); | - | ||||||||||||||||||||||||
369 | - | |||||||||||||||||||||||||
370 | d->clear(); | - | ||||||||||||||||||||||||
371 | d->hiddenRows.clear(); | - | ||||||||||||||||||||||||
372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
373 | - | |||||||||||||||||||||||||
374 | - | |||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | - | |||||||||||||||||||||||||
377 | - | |||||||||||||||||||||||||
378 | - | |||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | void QListView::scrollContentsBy(int dx, int dy) | - | ||||||||||||||||||||||||
381 | { | - | ||||||||||||||||||||||||
382 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
383 | d->delayedAutoScroll.stop(); | - | ||||||||||||||||||||||||
384 | d->commonListView->scrollContentsBy(dx, dy, d->state == QListView::DragSelectingState); | - | ||||||||||||||||||||||||
385 | } never executed: end of block | 0 | ||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | - | |||||||||||||||||||||||||
389 | - | |||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | void QListView::resizeContents(int width, int height) | - | ||||||||||||||||||||||||
394 | { | - | ||||||||||||||||||||||||
395 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
396 | d->setContentsSize(width, height); | - | ||||||||||||||||||||||||
397 | } never executed: end of block | 0 | ||||||||||||||||||||||||
398 | - | |||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||
400 | - | |||||||||||||||||||||||||
401 | - | |||||||||||||||||||||||||
402 | QSize QListView::contentsSize() const | - | ||||||||||||||||||||||||
403 | { | - | ||||||||||||||||||||||||
404 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
405 | return never executed: d->contentsSize();return d->contentsSize(); never executed: return d->contentsSize(); | 0 | ||||||||||||||||||||||||
406 | } | - | ||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | - | |||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||
410 | - | |||||||||||||||||||||||||
411 | void QListView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) | - | ||||||||||||||||||||||||
412 | { | - | ||||||||||||||||||||||||
413 | d_func()->commonListView->dataChanged(topLeft, bottomRight); | - | ||||||||||||||||||||||||
414 | QAbstractItemView::dataChanged(topLeft, bottomRight, roles); | - | ||||||||||||||||||||||||
415 | } never executed: end of block | 0 | ||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | - | |||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | - | |||||||||||||||||||||||||
420 | void QListView::rowsInserted(const QModelIndex &parent, int start, int end) | - | ||||||||||||||||||||||||
421 | { | - | ||||||||||||||||||||||||
422 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | d->clear(); | - | ||||||||||||||||||||||||
425 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
426 | QAbstractItemView::rowsInserted(parent, start, end); | - | ||||||||||||||||||||||||
427 | } never executed: end of block | 0 | ||||||||||||||||||||||||
428 | - | |||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||
431 | - | |||||||||||||||||||||||||
432 | void QListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) | - | ||||||||||||||||||||||||
433 | { | - | ||||||||||||||||||||||||
434 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | QAbstractItemView::rowsAboutToBeRemoved(parent, start, end); | - | ||||||||||||||||||||||||
437 | if (parent == d->root
| 0 | ||||||||||||||||||||||||
438 | QSet<QPersistentModelIndex>::iterator it = d->hiddenRows.begin(); | - | ||||||||||||||||||||||||
439 | while (it != d->hiddenRows.end()
| 0 | ||||||||||||||||||||||||
440 | int hiddenRow = it->row(); | - | ||||||||||||||||||||||||
441 | if (hiddenRow >= start
| 0 | ||||||||||||||||||||||||
442 | it = d->hiddenRows.erase(it); | - | ||||||||||||||||||||||||
443 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
444 | ++it; | - | ||||||||||||||||||||||||
445 | } never executed: end of block | 0 | ||||||||||||||||||||||||
446 | } | - | ||||||||||||||||||||||||
447 | } never executed: end of block | 0 | ||||||||||||||||||||||||
448 | d->clear(); | - | ||||||||||||||||||||||||
449 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
450 | } never executed: end of block | 0 | ||||||||||||||||||||||||
451 | - | |||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||
453 | - | |||||||||||||||||||||||||
454 | - | |||||||||||||||||||||||||
455 | void QListView::mouseMoveEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
456 | { | - | ||||||||||||||||||||||||
457 | if (!isVisible()
| 0 | ||||||||||||||||||||||||
458 | return; never executed: return; | 0 | ||||||||||||||||||||||||
459 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
460 | QAbstractItemView::mouseMoveEvent(e); | - | ||||||||||||||||||||||||
461 | if (state() == DragSelectingState
| 0 | ||||||||||||||||||||||||
462 | && d->showElasticBand
| 0 | ||||||||||||||||||||||||
463 | && d->selectionMode != SingleSelection
| 0 | ||||||||||||||||||||||||
464 | && d->selectionMode != NoSelection
| 0 | ||||||||||||||||||||||||
465 | QRect rect(d->pressedPosition, e->pos() + QPoint(horizontalOffset(), verticalOffset())); | - | ||||||||||||||||||||||||
466 | rect = rect.normalized(); | - | ||||||||||||||||||||||||
467 | d->viewport->update(d->mapToViewport(rect.united(d->elasticBand))); | - | ||||||||||||||||||||||||
468 | d->elasticBand = rect; | - | ||||||||||||||||||||||||
469 | } never executed: end of block | 0 | ||||||||||||||||||||||||
470 | } never executed: end of block | 0 | ||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||
472 | - | |||||||||||||||||||||||||
473 | - | |||||||||||||||||||||||||
474 | - | |||||||||||||||||||||||||
475 | void QListView::mouseReleaseEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
476 | { | - | ||||||||||||||||||||||||
477 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
478 | QAbstractItemView::mouseReleaseEvent(e); | - | ||||||||||||||||||||||||
479 | - | |||||||||||||||||||||||||
480 | if (d->showElasticBand
| 0 | ||||||||||||||||||||||||
481 | d->viewport->update(d->mapToViewport(d->elasticBand)); | - | ||||||||||||||||||||||||
482 | d->elasticBand = QRect(); | - | ||||||||||||||||||||||||
483 | } never executed: end of block | 0 | ||||||||||||||||||||||||
484 | } never executed: end of block | 0 | ||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||
487 | - | |||||||||||||||||||||||||
488 | - | |||||||||||||||||||||||||
489 | - | |||||||||||||||||||||||||
490 | void QListView::wheelEvent(QWheelEvent *e) | - | ||||||||||||||||||||||||
491 | { | - | ||||||||||||||||||||||||
492 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
493 | if (e->orientation() == Qt::Vertical
| 0 | ||||||||||||||||||||||||
494 | if (e->angleDelta().x() == 0
| 0 | ||||||||||||||||||||||||
495 | && ((d->flow == TopToBottom
| 0 | ||||||||||||||||||||||||
496 | && d->vbar->minimum() == 0
| 0 | ||||||||||||||||||||||||
497 | QPoint pixelDelta(e->pixelDelta().y(), e->pixelDelta().x()); | - | ||||||||||||||||||||||||
498 | QPoint angleDelta(e->angleDelta().y(), e->angleDelta().x()); | - | ||||||||||||||||||||||||
499 | QWheelEvent hwe(e->pos(), e->globalPos(), pixelDelta, angleDelta, e->delta(), | - | ||||||||||||||||||||||||
500 | Qt::Horizontal, e->buttons(), e->modifiers(), e->phase(), e->source()); | - | ||||||||||||||||||||||||
501 | if (e->spontaneous()
| 0 | ||||||||||||||||||||||||
502 | qt_sendSpontaneousEvent(d->hbar, &hwe); never executed: qt_sendSpontaneousEvent(d->hbar, &hwe); | 0 | ||||||||||||||||||||||||
503 | else | - | ||||||||||||||||||||||||
504 | QApplication::sendEvent(d->hbar, &hwe); never executed: QApplication::sendEvent(d->hbar, &hwe); | 0 | ||||||||||||||||||||||||
505 | e->setAccepted(hwe.isAccepted()); | - | ||||||||||||||||||||||||
506 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
507 | QApplication::sendEvent(d->vbar, e); | - | ||||||||||||||||||||||||
508 | } never executed: end of block | 0 | ||||||||||||||||||||||||
509 | } else { | - | ||||||||||||||||||||||||
510 | QApplication::sendEvent(d->hbar, e); | - | ||||||||||||||||||||||||
511 | } never executed: end of block | 0 | ||||||||||||||||||||||||
512 | } | - | ||||||||||||||||||||||||
513 | - | |||||||||||||||||||||||||
514 | - | |||||||||||||||||||||||||
515 | - | |||||||||||||||||||||||||
516 | - | |||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | void QListView::timerEvent(QTimerEvent *e) | - | ||||||||||||||||||||||||
519 | { | - | ||||||||||||||||||||||||
520 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
521 | if (e->timerId() == d->batchLayoutTimer.timerId()
| 0 | ||||||||||||||||||||||||
522 | if (d->doItemsLayout(d->batchSize)
| 0 | ||||||||||||||||||||||||
523 | d->batchLayoutTimer.stop(); | - | ||||||||||||||||||||||||
524 | updateGeometries(); | - | ||||||||||||||||||||||||
525 | d->viewport->update(); | - | ||||||||||||||||||||||||
526 | } never executed: end of block | 0 | ||||||||||||||||||||||||
527 | } never executed: end of block | 0 | ||||||||||||||||||||||||
528 | QAbstractItemView::timerEvent(e); | - | ||||||||||||||||||||||||
529 | } never executed: end of block | 0 | ||||||||||||||||||||||||
530 | - | |||||||||||||||||||||||||
531 | - | |||||||||||||||||||||||||
532 | - | |||||||||||||||||||||||||
533 | - | |||||||||||||||||||||||||
534 | void QListView::resizeEvent(QResizeEvent *e) | - | ||||||||||||||||||||||||
535 | { | - | ||||||||||||||||||||||||
536 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
537 | if (d->delayedPendingLayout
| 0 | ||||||||||||||||||||||||
538 | return; never executed: return; | 0 | ||||||||||||||||||||||||
539 | - | |||||||||||||||||||||||||
540 | QSize delta = e->size() - e->oldSize(); | - | ||||||||||||||||||||||||
541 | - | |||||||||||||||||||||||||
542 | if (delta.isNull()
| 0 | ||||||||||||||||||||||||
543 | return; never executed: return; | 0 | ||||||||||||||||||||||||
544 | - | |||||||||||||||||||||||||
545 | bool listWrap = (
| 0 | ||||||||||||||||||||||||
546 | bool flowDimensionChanged = (d->flow == LeftToRight
| 0 | ||||||||||||||||||||||||
547 | || (d->flow == TopToBottom
| 0 | ||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||
549 | - | |||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||
551 | - | |||||||||||||||||||||||||
552 | if (listWrap
| 0 | ||||||||||||||||||||||||
553 | || (state() == NoState
| 0 | ||||||||||||||||||||||||
554 | d->doDelayedItemsLayout(100); | - | ||||||||||||||||||||||||
555 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
556 | QAbstractItemView::resizeEvent(e); | - | ||||||||||||||||||||||||
557 | } never executed: end of block | 0 | ||||||||||||||||||||||||
558 | } | - | ||||||||||||||||||||||||
559 | - | |||||||||||||||||||||||||
560 | - | |||||||||||||||||||||||||
561 | - | |||||||||||||||||||||||||
562 | - | |||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | void QListView::dragMoveEvent(QDragMoveEvent *e) | - | ||||||||||||||||||||||||
566 | { | - | ||||||||||||||||||||||||
567 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
568 | if (!d->commonListView->filterDragMoveEvent(e)
| 0 | ||||||||||||||||||||||||
569 | if (viewMode() == QListView::ListMode
| 0 | ||||||||||||||||||||||||
570 | static_cast< never executed: QListModeViewBase *>(d->commonListView)->dragMoveEvent(e);static_cast<QListModeViewBase *>(d->commonListView)->dragMoveEvent(e); never executed: static_cast<QListModeViewBase *>(d->commonListView)->dragMoveEvent(e); | 0 | ||||||||||||||||||||||||
571 | else | - | ||||||||||||||||||||||||
572 | QAbstractItemView::dragMoveEvent(e); never executed: QAbstractItemView::dragMoveEvent(e); | 0 | ||||||||||||||||||||||||
573 | } | - | ||||||||||||||||||||||||
574 | } never executed: end of block | 0 | ||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | - | |||||||||||||||||||||||||
577 | - | |||||||||||||||||||||||||
578 | - | |||||||||||||||||||||||||
579 | - | |||||||||||||||||||||||||
580 | void QListView::dragLeaveEvent(QDragLeaveEvent *e) | - | ||||||||||||||||||||||||
581 | { | - | ||||||||||||||||||||||||
582 | if (!d_func()->commonListView->filterDragLeaveEvent(e)
| 0 | ||||||||||||||||||||||||
583 | QAbstractItemView::dragLeaveEvent(e); never executed: QAbstractItemView::dragLeaveEvent(e); | 0 | ||||||||||||||||||||||||
584 | } never executed: end of block | 0 | ||||||||||||||||||||||||
585 | - | |||||||||||||||||||||||||
586 | - | |||||||||||||||||||||||||
587 | - | |||||||||||||||||||||||||
588 | - | |||||||||||||||||||||||||
589 | void QListView::dropEvent(QDropEvent *e) | - | ||||||||||||||||||||||||
590 | { | - | ||||||||||||||||||||||||
591 | if (!d_func()->commonListView->filterDropEvent(e)
| 0 | ||||||||||||||||||||||||
592 | QAbstractItemView::dropEvent(e); never executed: QAbstractItemView::dropEvent(e); | 0 | ||||||||||||||||||||||||
593 | } never executed: end of block | 0 | ||||||||||||||||||||||||
594 | - | |||||||||||||||||||||||||
595 | - | |||||||||||||||||||||||||
596 | - | |||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||
598 | void QListView::startDrag(Qt::DropActions supportedActions) | - | ||||||||||||||||||||||||
599 | { | - | ||||||||||||||||||||||||
600 | if (!d_func()->commonListView->filterStartDrag(supportedActions)
| 0 | ||||||||||||||||||||||||
601 | QAbstractItemView::startDrag(supportedActions); never executed: QAbstractItemView::startDrag(supportedActions); | 0 | ||||||||||||||||||||||||
602 | } never executed: end of block | 0 | ||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||
604 | - | |||||||||||||||||||||||||
605 | - | |||||||||||||||||||||||||
606 | - | |||||||||||||||||||||||||
607 | - | |||||||||||||||||||||||||
608 | - | |||||||||||||||||||||||||
609 | QStyleOptionViewItem QListView::viewOptions() const | - | ||||||||||||||||||||||||
610 | { | - | ||||||||||||||||||||||||
611 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
612 | QStyleOptionViewItem option = QAbstractItemView::viewOptions(); | - | ||||||||||||||||||||||||
613 | if (!d->iconSize.isValid()
| 0 | ||||||||||||||||||||||||
614 | int pm = (d->viewMode == QListView::ListMode
| 0 | ||||||||||||||||||||||||
615 | ? style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, this) | - | ||||||||||||||||||||||||
616 | : style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, this)); | - | ||||||||||||||||||||||||
617 | option.decorationSize = QSize(pm, pm); | - | ||||||||||||||||||||||||
618 | } never executed: end of block | 0 | ||||||||||||||||||||||||
619 | if (d->viewMode == QListView::IconMode
| 0 | ||||||||||||||||||||||||
620 | option.showDecorationSelected = false; | - | ||||||||||||||||||||||||
621 | option.decorationPosition = QStyleOptionViewItem::Top; | - | ||||||||||||||||||||||||
622 | option.displayAlignment = Qt::AlignCenter; | - | ||||||||||||||||||||||||
623 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
624 | option.decorationPosition = QStyleOptionViewItem::Left; | - | ||||||||||||||||||||||||
625 | } never executed: end of block | 0 | ||||||||||||||||||||||||
626 | - | |||||||||||||||||||||||||
627 | if (d->gridSize().isValid()
| 0 | ||||||||||||||||||||||||
628 | option.rect.setSize(d->gridSize()); | - | ||||||||||||||||||||||||
629 | } never executed: end of block | 0 | ||||||||||||||||||||||||
630 | - | |||||||||||||||||||||||||
631 | return never executed: option;return option; never executed: return option; | 0 | ||||||||||||||||||||||||
632 | } | - | ||||||||||||||||||||||||
633 | - | |||||||||||||||||||||||||
634 | - | |||||||||||||||||||||||||
635 | - | |||||||||||||||||||||||||
636 | - | |||||||||||||||||||||||||
637 | - | |||||||||||||||||||||||||
638 | void QListView::paintEvent(QPaintEvent *e) | - | ||||||||||||||||||||||||
639 | { | - | ||||||||||||||||||||||||
640 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
641 | if (!d->itemDelegate
| 0 | ||||||||||||||||||||||||
642 | return; never executed: return; | 0 | ||||||||||||||||||||||||
643 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||||||||
644 | QPainter painter(d->viewport); | - | ||||||||||||||||||||||||
645 | - | |||||||||||||||||||||||||
646 | const QVector<QModelIndex> toBeRendered = d->intersectingSet(e->rect().translated(horizontalOffset(), verticalOffset()), false); | - | ||||||||||||||||||||||||
647 | - | |||||||||||||||||||||||||
648 | const QModelIndex current = currentIndex(); | - | ||||||||||||||||||||||||
649 | const QModelIndex hover = d->hover; | - | ||||||||||||||||||||||||
650 | const QAbstractItemModel *itemModel = d->model; | - | ||||||||||||||||||||||||
651 | const QItemSelectionModel *selections = d->selectionModel; | - | ||||||||||||||||||||||||
652 | const bool focus = (hasFocus()
| 0 | ||||||||||||||||||||||||
653 | const bool alternate = d->alternatingColors; | - | ||||||||||||||||||||||||
654 | const QStyle::State state = option.state; | - | ||||||||||||||||||||||||
655 | const QAbstractItemView::State viewState = this->state(); | - | ||||||||||||||||||||||||
656 | const bool enabled = (state & QStyle::State_Enabled) != 0; | - | ||||||||||||||||||||||||
657 | - | |||||||||||||||||||||||||
658 | bool alternateBase = false; | - | ||||||||||||||||||||||||
659 | int previousRow = -2; | - | ||||||||||||||||||||||||
660 | - | |||||||||||||||||||||||||
661 | int maxSize = (
| 0 | ||||||||||||||||||||||||
662 | ? qMax(viewport()->size().width(), d->contentsSize().width()) - 2 * d->spacing() | - | ||||||||||||||||||||||||
663 | : qMax(viewport()->size().height(), d->contentsSize().height()) - 2 * d->spacing(); | - | ||||||||||||||||||||||||
664 | - | |||||||||||||||||||||||||
665 | QVector<QModelIndex>::const_iterator end = toBeRendered.constEnd(); | - | ||||||||||||||||||||||||
666 | for (QVector<QModelIndex>::const_iterator it = toBeRendered.constBegin(); it != end
| 0 | ||||||||||||||||||||||||
667 | ((!((*it).isValid())) ? qt_assert("(*it).isValid()",__FILE__,982) : qt_noop()); | - | ||||||||||||||||||||||||
668 | option.rect = visualRect(*it); | - | ||||||||||||||||||||||||
669 | - | |||||||||||||||||||||||||
670 | if (flow() == TopToBottom
| 0 | ||||||||||||||||||||||||
671 | option.rect.setWidth(qMin(maxSize, option.rect.width())); never executed: option.rect.setWidth(qMin(maxSize, option.rect.width())); | 0 | ||||||||||||||||||||||||
672 | else | - | ||||||||||||||||||||||||
673 | option.rect.setHeight(qMin(maxSize, option.rect.height())); never executed: option.rect.setHeight(qMin(maxSize, option.rect.height())); | 0 | ||||||||||||||||||||||||
674 | - | |||||||||||||||||||||||||
675 | option.state = state; | - | ||||||||||||||||||||||||
676 | if (selections
| 0 | ||||||||||||||||||||||||
677 | option.state |= QStyle::State_Selected; never executed: option.state |= QStyle::State_Selected; | 0 | ||||||||||||||||||||||||
678 | if (enabled
| 0 | ||||||||||||||||||||||||
679 | QPalette::ColorGroup cg; | - | ||||||||||||||||||||||||
680 | if ((
| 0 | ||||||||||||||||||||||||
681 | option.state &= ~QStyle::State_Enabled; | - | ||||||||||||||||||||||||
682 | cg = QPalette::Disabled; | - | ||||||||||||||||||||||||
683 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
684 | cg = QPalette::Normal; | - | ||||||||||||||||||||||||
685 | } never executed: end of block | 0 | ||||||||||||||||||||||||
686 | option.palette.setCurrentColorGroup(cg); | - | ||||||||||||||||||||||||
687 | } never executed: end of block | 0 | ||||||||||||||||||||||||
688 | if (focus
| 0 | ||||||||||||||||||||||||
689 | option.state |= QStyle::State_HasFocus; | - | ||||||||||||||||||||||||
690 | if (viewState == EditingState
| 0 | ||||||||||||||||||||||||
691 | option.state |= QStyle::State_Editing; never executed: option.state |= QStyle::State_Editing; | 0 | ||||||||||||||||||||||||
692 | } never executed: end of block | 0 | ||||||||||||||||||||||||
693 | if (*
| 0 | ||||||||||||||||||||||||
694 | option.state |= QStyle::State_MouseOver; never executed: option.state |= QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
695 | else | - | ||||||||||||||||||||||||
696 | option.state &= ~QStyle::State_MouseOver; never executed: option.state &= ~QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
697 | - | |||||||||||||||||||||||||
698 | if (alternate
| 0 | ||||||||||||||||||||||||
699 | int row = (*it).row(); | - | ||||||||||||||||||||||||
700 | if (row != previousRow + 1
| 0 | ||||||||||||||||||||||||
701 | - | |||||||||||||||||||||||||
702 | if (!d->hiddenRows.isEmpty()
| 0 | ||||||||||||||||||||||||
703 | for (int r = qMax(previousRow + 1, 0); r < row
| 0 | ||||||||||||||||||||||||
704 | if (!d->isHidden(r)
| 0 | ||||||||||||||||||||||||
705 | alternateBase = !alternateBase; never executed: alternateBase = !alternateBase; | 0 | ||||||||||||||||||||||||
706 | } never executed: end of block | 0 | ||||||||||||||||||||||||
707 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
708 | alternateBase = (row & 1) != 0; | - | ||||||||||||||||||||||||
709 | } never executed: end of block | 0 | ||||||||||||||||||||||||
710 | } | - | ||||||||||||||||||||||||
711 | if (alternateBase
| 0 | ||||||||||||||||||||||||
712 | option.features |= QStyleOptionViewItem::Alternate; | - | ||||||||||||||||||||||||
713 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
714 | option.features &= ~QStyleOptionViewItem::Alternate; | - | ||||||||||||||||||||||||
715 | } never executed: end of block | 0 | ||||||||||||||||||||||||
716 | - | |||||||||||||||||||||||||
717 | - | |||||||||||||||||||||||||
718 | - | |||||||||||||||||||||||||
719 | QStyle::State oldState = option.state; | - | ||||||||||||||||||||||||
720 | option.state &= ~QStyle::State_Selected; | - | ||||||||||||||||||||||||
721 | style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &option, &painter, this); | - | ||||||||||||||||||||||||
722 | option.state = oldState; | - | ||||||||||||||||||||||||
723 | - | |||||||||||||||||||||||||
724 | alternateBase = !alternateBase; | - | ||||||||||||||||||||||||
725 | previousRow = row; | - | ||||||||||||||||||||||||
726 | } never executed: end of block | 0 | ||||||||||||||||||||||||
727 | - | |||||||||||||||||||||||||
728 | d->delegateForIndex(*it)->paint(&painter, option, *it); | - | ||||||||||||||||||||||||
729 | } never executed: end of block | 0 | ||||||||||||||||||||||||
730 | - | |||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||
732 | d->commonListView->paintDragDrop(&painter); | - | ||||||||||||||||||||||||
733 | - | |||||||||||||||||||||||||
734 | - | |||||||||||||||||||||||||
735 | - | |||||||||||||||||||||||||
736 | - | |||||||||||||||||||||||||
737 | if (d->showElasticBand
| 0 | ||||||||||||||||||||||||
738 | QStyleOptionRubberBand opt; | - | ||||||||||||||||||||||||
739 | opt.initFrom(this); | - | ||||||||||||||||||||||||
740 | opt.shape = QRubberBand::Rectangle; | - | ||||||||||||||||||||||||
741 | opt.opaque = false; | - | ||||||||||||||||||||||||
742 | opt.rect = d->mapToViewport(d->elasticBand, false).intersected( | - | ||||||||||||||||||||||||
743 | d->viewport->rect().adjusted(-16, -16, 16, 16)); | - | ||||||||||||||||||||||||
744 | painter.save(); | - | ||||||||||||||||||||||||
745 | style()->drawControl(QStyle::CE_RubberBand, &opt, &painter); | - | ||||||||||||||||||||||||
746 | painter.restore(); | - | ||||||||||||||||||||||||
747 | } never executed: end of block | 0 | ||||||||||||||||||||||||
748 | - | |||||||||||||||||||||||||
749 | } never executed: end of block | 0 | ||||||||||||||||||||||||
750 | - | |||||||||||||||||||||||||
751 | - | |||||||||||||||||||||||||
752 | - | |||||||||||||||||||||||||
753 | - | |||||||||||||||||||||||||
754 | QModelIndex QListView::indexAt(const QPoint &p) const | - | ||||||||||||||||||||||||
755 | { | - | ||||||||||||||||||||||||
756 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
757 | QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); | - | ||||||||||||||||||||||||
758 | const QVector<QModelIndex> intersectVector = d->intersectingSet(rect); | - | ||||||||||||||||||||||||
759 | QModelIndex index = intersectVector.count() > 0
| 0 | ||||||||||||||||||||||||
760 | ? intersectVector.last() : QModelIndex(); | - | ||||||||||||||||||||||||
761 | if (index.isValid()
| 0 | ||||||||||||||||||||||||
762 | return never executed: index;return index; never executed: return index; | 0 | ||||||||||||||||||||||||
763 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
764 | } | - | ||||||||||||||||||||||||
765 | - | |||||||||||||||||||||||||
766 | - | |||||||||||||||||||||||||
767 | - | |||||||||||||||||||||||||
768 | - | |||||||||||||||||||||||||
769 | int QListView::horizontalOffset() const | - | ||||||||||||||||||||||||
770 | { | - | ||||||||||||||||||||||||
771 | return never executed: d_func()->commonListView->horizontalOffset();return d_func()->commonListView->horizontalOffset(); never executed: return d_func()->commonListView->horizontalOffset(); | 0 | ||||||||||||||||||||||||
772 | } | - | ||||||||||||||||||||||||
773 | - | |||||||||||||||||||||||||
774 | - | |||||||||||||||||||||||||
775 | - | |||||||||||||||||||||||||
776 | - | |||||||||||||||||||||||||
777 | int QListView::verticalOffset() const | - | ||||||||||||||||||||||||
778 | { | - | ||||||||||||||||||||||||
779 | return never executed: d_func()->commonListView->verticalOffset();return d_func()->commonListView->verticalOffset(); never executed: return d_func()->commonListView->verticalOffset(); | 0 | ||||||||||||||||||||||||
780 | } | - | ||||||||||||||||||||||||
781 | - | |||||||||||||||||||||||||
782 | - | |||||||||||||||||||||||||
783 | - | |||||||||||||||||||||||||
784 | - | |||||||||||||||||||||||||
785 | QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) | - | ||||||||||||||||||||||||
786 | { | - | ||||||||||||||||||||||||
787 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
788 | (void)modifiers;; | - | ||||||||||||||||||||||||
789 | - | |||||||||||||||||||||||||
790 | QModelIndex current = currentIndex(); | - | ||||||||||||||||||||||||
791 | if (!current.isValid()
| 0 | ||||||||||||||||||||||||
792 | int rowCount = d->model->rowCount(d->root); | - | ||||||||||||||||||||||||
793 | if (!rowCount
| 0 | ||||||||||||||||||||||||
794 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
795 | int row = 0; | - | ||||||||||||||||||||||||
796 | while (row < rowCount
| 0 | ||||||||||||||||||||||||
797 | ++ never executed: row;++row; never executed: ++row; | 0 | ||||||||||||||||||||||||
798 | if (row >= rowCount
| 0 | ||||||||||||||||||||||||
799 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
800 | return never executed: d->model->index(row, d->column, d->root);return d->model->index(row, d->column, d->root); never executed: return d->model->index(row, d->column, d->root); | 0 | ||||||||||||||||||||||||
801 | } | - | ||||||||||||||||||||||||
802 | - | |||||||||||||||||||||||||
803 | const QRect initialRect = rectForIndex(current); | - | ||||||||||||||||||||||||
804 | QRect rect = initialRect; | - | ||||||||||||||||||||||||
805 | if (rect.isEmpty()
| 0 | ||||||||||||||||||||||||
806 | return never executed: d->model->index(0, d->column, d->root);return d->model->index(0, d->column, d->root); never executed: return d->model->index(0, d->column, d->root); | 0 | ||||||||||||||||||||||||
807 | } | - | ||||||||||||||||||||||||
808 | if (d->gridSize().isValid()
never executed: rect.setSize(d->gridSize()); | 0 | ||||||||||||||||||||||||
809 | - | |||||||||||||||||||||||||
810 | QSize contents = d->contentsSize(); | - | ||||||||||||||||||||||||
811 | QVector<QModelIndex> intersectVector; | - | ||||||||||||||||||||||||
812 | - | |||||||||||||||||||||||||
813 | switch (cursorAction) { | - | ||||||||||||||||||||||||
814 | case never executed: MoveLeft:case MoveLeft: never executed: case MoveLeft: | 0 | ||||||||||||||||||||||||
815 | while (intersectVector.isEmpty()
| 0 | ||||||||||||||||||||||||
816 | rect.translate(-rect.width(), 0); | - | ||||||||||||||||||||||||
817 | if (rect.right() <= 0
| 0 | ||||||||||||||||||||||||
818 | return never executed: current;return current; never executed: return current; | 0 | ||||||||||||||||||||||||
819 | if (rect.left() < 0
| 0 | ||||||||||||||||||||||||
820 | rect.setLeft(0); never executed: rect.setLeft(0); | 0 | ||||||||||||||||||||||||
821 | intersectVector = d->intersectingSet(rect); | - | ||||||||||||||||||||||||
822 | d->removeCurrentAndDisabled(&intersectVector, current); | - | ||||||||||||||||||||||||
823 | } never executed: end of block | 0 | ||||||||||||||||||||||||
824 | return never executed: d->closestIndex(initialRect, intersectVector);return d->closestIndex(initialRect, intersectVector); never executed: return d->closestIndex(initialRect, intersectVector); | 0 | ||||||||||||||||||||||||
825 | case never executed: MoveRight:case MoveRight: never executed: case MoveRight: | 0 | ||||||||||||||||||||||||
826 | while (intersectVector.isEmpty()
| 0 | ||||||||||||||||||||||||
827 | rect.translate(rect.width(), 0); | - | ||||||||||||||||||||||||
828 | if (rect.left() >= contents.width()
| 0 | ||||||||||||||||||||||||
829 | return never executed: current;return current; never executed: return current; | 0 | ||||||||||||||||||||||||
830 | if (rect.right() > contents.width()
| 0 | ||||||||||||||||||||||||
831 | rect.setRight(contents.width()); never executed: rect.setRight(contents.width()); | 0 | ||||||||||||||||||||||||
832 | intersectVector = d->intersectingSet(rect); | - | ||||||||||||||||||||||||
833 | d->removeCurrentAndDisabled(&intersectVector, current); | - | ||||||||||||||||||||||||
834 | } never executed: end of block | 0 | ||||||||||||||||||||||||
835 | return never executed: d->closestIndex(initialRect, intersectVector);return d->closestIndex(initialRect, intersectVector); never executed: return d->closestIndex(initialRect, intersectVector); | 0 | ||||||||||||||||||||||||
836 | case never executed: MovePageUp:case MovePageUp: never executed: case MovePageUp: | 0 | ||||||||||||||||||||||||
837 | - | |||||||||||||||||||||||||
838 | - | |||||||||||||||||||||||||
839 | rect.moveTop(rect.top() - d->viewport->height() + 2 * rect.height()); | - | ||||||||||||||||||||||||
840 | if (rect.top() < rect.height()
| 0 | ||||||||||||||||||||||||
841 | rect.moveTop(rect.height()); never executed: rect.moveTop(rect.height()); | 0 | ||||||||||||||||||||||||
842 | case never executed: MovePrevious:case MovePrevious: never executed: case MovePrevious: code before this statement never executed: case MovePrevious: | 0 | ||||||||||||||||||||||||
843 | case never executed: MoveUp:case MoveUp: never executed: case MoveUp: | 0 | ||||||||||||||||||||||||
844 | while (intersectVector.isEmpty()
| 0 | ||||||||||||||||||||||||
845 | rect.translate(0, -rect.height()); | - | ||||||||||||||||||||||||
846 | if (rect.bottom() <= 0
| 0 | ||||||||||||||||||||||||
847 | return never executed: current;return current; never executed: return current; | 0 | ||||||||||||||||||||||||
848 | } | - | ||||||||||||||||||||||||
849 | if (rect.top() < 0
| 0 | ||||||||||||||||||||||||
850 | rect.setTop(0); never executed: rect.setTop(0); | 0 | ||||||||||||||||||||||||
851 | intersectVector = d->intersectingSet(rect); | - | ||||||||||||||||||||||||
852 | d->removeCurrentAndDisabled(&intersectVector, current); | - | ||||||||||||||||||||||||
853 | } never executed: end of block | 0 | ||||||||||||||||||||||||
854 | return never executed: d->closestIndex(initialRect, intersectVector);return d->closestIndex(initialRect, intersectVector); never executed: return d->closestIndex(initialRect, intersectVector); | 0 | ||||||||||||||||||||||||
855 | case never executed: MovePageDown:case MovePageDown: never executed: case MovePageDown: | 0 | ||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||
857 | - | |||||||||||||||||||||||||
858 | rect.moveTop(rect.top() + d->viewport->height() - 2 * rect.height()); | - | ||||||||||||||||||||||||
859 | if (rect.bottom() > contents.height() - rect.height()
| 0 | ||||||||||||||||||||||||
860 | rect.moveBottom(contents.height() - rect.height()); never executed: rect.moveBottom(contents.height() - rect.height()); | 0 | ||||||||||||||||||||||||
861 | case never executed: MoveNext:case MoveNext: never executed: case MoveNext: code before this statement never executed: case MoveNext: | 0 | ||||||||||||||||||||||||
862 | case never executed: MoveDown:case MoveDown: never executed: case MoveDown: | 0 | ||||||||||||||||||||||||
863 | while (intersectVector.isEmpty()
| 0 | ||||||||||||||||||||||||
864 | rect.translate(0, rect.height()); | - | ||||||||||||||||||||||||
865 | if (rect.top() >= contents.height()
| 0 | ||||||||||||||||||||||||
866 | return never executed: current;return current; never executed: return current; | 0 | ||||||||||||||||||||||||
867 | } | - | ||||||||||||||||||||||||
868 | if (rect.bottom() > contents.height()
| 0 | ||||||||||||||||||||||||
869 | rect.setBottom(contents.height()); never executed: rect.setBottom(contents.height()); | 0 | ||||||||||||||||||||||||
870 | intersectVector = d->intersectingSet(rect); | - | ||||||||||||||||||||||||
871 | d->removeCurrentAndDisabled(&intersectVector, current); | - | ||||||||||||||||||||||||
872 | } never executed: end of block | 0 | ||||||||||||||||||||||||
873 | return never executed: d->closestIndex(initialRect, intersectVector);return d->closestIndex(initialRect, intersectVector); never executed: return d->closestIndex(initialRect, intersectVector); | 0 | ||||||||||||||||||||||||
874 | case never executed: MoveHome:case MoveHome: never executed: case MoveHome: | 0 | ||||||||||||||||||||||||
875 | return never executed: d->model->index(0, d->column, d->root);return d->model->index(0, d->column, d->root); never executed: return d->model->index(0, d->column, d->root); | 0 | ||||||||||||||||||||||||
876 | case never executed: MoveEnd:case MoveEnd: never executed: case MoveEnd: | 0 | ||||||||||||||||||||||||
877 | return never executed: d->model->index(d->batchStartRow() - 1, d->column, d->root);return d->model->index(d->batchStartRow() - 1, d->column, d->root); never executed: }return d->model->index(d->batchStartRow() - 1, d->column, d->root); | 0 | ||||||||||||||||||||||||
878 | - | |||||||||||||||||||||||||
879 | return never executed: current;return current; never executed: return current; | 0 | ||||||||||||||||||||||||
880 | } | - | ||||||||||||||||||||||||
881 | - | |||||||||||||||||||||||||
882 | - | |||||||||||||||||||||||||
883 | - | |||||||||||||||||||||||||
884 | - | |||||||||||||||||||||||||
885 | - | |||||||||||||||||||||||||
886 | - | |||||||||||||||||||||||||
887 | - | |||||||||||||||||||||||||
888 | QRect QListView::rectForIndex(const QModelIndex &index) const | - | ||||||||||||||||||||||||
889 | { | - | ||||||||||||||||||||||||
890 | return never executed: d_func()->rectForIndex(index);return d_func()->rectForIndex(index); never executed: return d_func()->rectForIndex(index); | 0 | ||||||||||||||||||||||||
891 | } | - | ||||||||||||||||||||||||
892 | void QListView::setPositionForIndex(const QPoint &position, const QModelIndex &index) | - | ||||||||||||||||||||||||
893 | { | - | ||||||||||||||||||||||||
894 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
895 | if (d->movement == Static
| 0 | ||||||||||||||||||||||||
896 | || !d->isIndexValid(index)
| 0 | ||||||||||||||||||||||||
897 | || index.parent() != d->root
| 0 | ||||||||||||||||||||||||
898 | || index.column() != d->column
| 0 | ||||||||||||||||||||||||
899 | return; never executed: return; | 0 | ||||||||||||||||||||||||
900 | - | |||||||||||||||||||||||||
901 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
902 | d->commonListView->setPositionForIndex(position, index); | - | ||||||||||||||||||||||||
903 | } never executed: end of block | 0 | ||||||||||||||||||||||||
904 | - | |||||||||||||||||||||||||
905 | - | |||||||||||||||||||||||||
906 | - | |||||||||||||||||||||||||
907 | - | |||||||||||||||||||||||||
908 | void QListView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) | - | ||||||||||||||||||||||||
909 | { | - | ||||||||||||||||||||||||
910 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
911 | if (!d->selectionModel
| 0 | ||||||||||||||||||||||||
912 | return; never executed: return; | 0 | ||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||
914 | - | |||||||||||||||||||||||||
915 | int w = qMax(d->contentsSize().width(), d->viewport->width()); | - | ||||||||||||||||||||||||
916 | int h = qMax(d->contentsSize().height(), d->viewport->height()); | - | ||||||||||||||||||||||||
917 | if (d->wrap
| 0 | ||||||||||||||||||||||||
918 | return; never executed: return; | 0 | ||||||||||||||||||||||||
919 | - | |||||||||||||||||||||||||
920 | QItemSelection selection; | - | ||||||||||||||||||||||||
921 | - | |||||||||||||||||||||||||
922 | if (rect.width() == 1
| 0 | ||||||||||||||||||||||||
923 | const QVector<QModelIndex> intersectVector = d->intersectingSet(rect.translated(horizontalOffset(), verticalOffset())); | - | ||||||||||||||||||||||||
924 | QModelIndex tl; | - | ||||||||||||||||||||||||
925 | if (!intersectVector.isEmpty()
| 0 | ||||||||||||||||||||||||
926 | tl = intersectVector.last(); never executed: tl = intersectVector.last(); | 0 | ||||||||||||||||||||||||
927 | if (tl.isValid()
| 0 | ||||||||||||||||||||||||
928 | selection.select(tl, tl); never executed: selection.select(tl, tl); | 0 | ||||||||||||||||||||||||
929 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
930 | if (state() == DragSelectingState
| 0 | ||||||||||||||||||||||||
931 | selection = d->selection(rect.translated(horizontalOffset(), verticalOffset())); | - | ||||||||||||||||||||||||
932 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
933 | QModelIndex tl, br; | - | ||||||||||||||||||||||||
934 | - | |||||||||||||||||||||||||
935 | const QRect topLeft(rect.left() + horizontalOffset(), rect.top() + verticalOffset(), 1, 1); | - | ||||||||||||||||||||||||
936 | QVector<QModelIndex> intersectVector = d->intersectingSet(topLeft); | - | ||||||||||||||||||||||||
937 | if (!intersectVector.isEmpty()
| 0 | ||||||||||||||||||||||||
938 | tl = intersectVector.last(); never executed: tl = intersectVector.last(); | 0 | ||||||||||||||||||||||||
939 | - | |||||||||||||||||||||||||
940 | const QRect bottomRight(rect.right() + horizontalOffset(), rect.bottom() + verticalOffset(), 1, 1); | - | ||||||||||||||||||||||||
941 | intersectVector = d->intersectingSet(bottomRight); | - | ||||||||||||||||||||||||
942 | if (!intersectVector.isEmpty()
| 0 | ||||||||||||||||||||||||
943 | br = intersectVector.last(); never executed: br = intersectVector.last(); | 0 | ||||||||||||||||||||||||
944 | - | |||||||||||||||||||||||||
945 | - | |||||||||||||||||||||||||
946 | if (tl.isValid()
| 0 | ||||||||||||||||||||||||
947 | && d->isIndexEnabled(tl)
| 0 | ||||||||||||||||||||||||
948 | && d->isIndexEnabled(br)
| 0 | ||||||||||||||||||||||||
949 | QRect first = rectForIndex(tl); | - | ||||||||||||||||||||||||
950 | QRect last = rectForIndex(br); | - | ||||||||||||||||||||||||
951 | QRect middle; | - | ||||||||||||||||||||||||
952 | if (d->flow == LeftToRight
| 0 | ||||||||||||||||||||||||
953 | QRect &top = first; | - | ||||||||||||||||||||||||
954 | QRect &bottom = last; | - | ||||||||||||||||||||||||
955 | - | |||||||||||||||||||||||||
956 | if (top.center().y() > bottom.center().y()
| 0 | ||||||||||||||||||||||||
957 | QRect tmp = top; | - | ||||||||||||||||||||||||
958 | top = bottom; | - | ||||||||||||||||||||||||
959 | bottom = tmp; | - | ||||||||||||||||||||||||
960 | } never executed: end of block | 0 | ||||||||||||||||||||||||
961 | - | |||||||||||||||||||||||||
962 | if (top.top() != bottom.top()
| 0 | ||||||||||||||||||||||||
963 | - | |||||||||||||||||||||||||
964 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
965 | top.setLeft(0); never executed: top.setLeft(0); | 0 | ||||||||||||||||||||||||
966 | else | - | ||||||||||||||||||||||||
967 | top.setRight(contentsSize().width()); never executed: top.setRight(contentsSize().width()); | 0 | ||||||||||||||||||||||||
968 | - | |||||||||||||||||||||||||
969 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
970 | bottom.setRight(contentsSize().width()); never executed: bottom.setRight(contentsSize().width()); | 0 | ||||||||||||||||||||||||
971 | else | - | ||||||||||||||||||||||||
972 | bottom.setLeft(0); never executed: bottom.setLeft(0); | 0 | ||||||||||||||||||||||||
973 | } else if (top.left() > bottom.right()
| 0 | ||||||||||||||||||||||||
974 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
975 | bottom.setLeft(top.right()); never executed: bottom.setLeft(top.right()); | 0 | ||||||||||||||||||||||||
976 | else | - | ||||||||||||||||||||||||
977 | bottom.setRight(top.left()); never executed: bottom.setRight(top.left()); | 0 | ||||||||||||||||||||||||
978 | } else { | - | ||||||||||||||||||||||||
979 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
980 | top.setLeft(bottom.right()); never executed: top.setLeft(bottom.right()); | 0 | ||||||||||||||||||||||||
981 | else | - | ||||||||||||||||||||||||
982 | top.setRight(bottom.left()); never executed: top.setRight(bottom.left()); | 0 | ||||||||||||||||||||||||
983 | } | - | ||||||||||||||||||||||||
984 | - | |||||||||||||||||||||||||
985 | if (top.bottom() < bottom.top()
| 0 | ||||||||||||||||||||||||
986 | if (gridSize().isValid()
| 0 | ||||||||||||||||||||||||
987 | middle.setTop(top.top() + gridSize().height()); never executed: middle.setTop(top.top() + gridSize().height()); | 0 | ||||||||||||||||||||||||
988 | else | - | ||||||||||||||||||||||||
989 | middle.setTop(top.bottom() + 1); never executed: middle.setTop(top.bottom() + 1); | 0 | ||||||||||||||||||||||||
990 | middle.setLeft(qMin(top.left(), bottom.left())); | - | ||||||||||||||||||||||||
991 | middle.setBottom(bottom.top() - 1); | - | ||||||||||||||||||||||||
992 | middle.setRight(qMax(top.right(), bottom.right())); | - | ||||||||||||||||||||||||
993 | } never executed: end of block | 0 | ||||||||||||||||||||||||
994 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
995 | QRect &left = first; | - | ||||||||||||||||||||||||
996 | QRect &right = last; | - | ||||||||||||||||||||||||
997 | if (left.center().x() > right.center().x()
| 0 | ||||||||||||||||||||||||
998 | qSwap(left, right); never executed: qSwap(left, right); | 0 | ||||||||||||||||||||||||
999 | - | |||||||||||||||||||||||||
1000 | int ch = contentsSize().height(); | - | ||||||||||||||||||||||||
1001 | if (left.left() != right.left()
| 0 | ||||||||||||||||||||||||
1002 | - | |||||||||||||||||||||||||
1003 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
1004 | left.setTop(0); never executed: left.setTop(0); | 0 | ||||||||||||||||||||||||
1005 | else | - | ||||||||||||||||||||||||
1006 | left.setBottom(ch); never executed: left.setBottom(ch); | 0 | ||||||||||||||||||||||||
1007 | - | |||||||||||||||||||||||||
1008 | - | |||||||||||||||||||||||||
1009 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
1010 | right.setBottom(ch); never executed: right.setBottom(ch); | 0 | ||||||||||||||||||||||||
1011 | else | - | ||||||||||||||||||||||||
1012 | right.setTop(0); never executed: right.setTop(0); | 0 | ||||||||||||||||||||||||
1013 | - | |||||||||||||||||||||||||
1014 | middle.setTop(0); | - | ||||||||||||||||||||||||
1015 | middle.setBottom(ch); | - | ||||||||||||||||||||||||
1016 | if (gridSize().isValid()
| 0 | ||||||||||||||||||||||||
1017 | middle.setLeft(left.left() + gridSize().width()); never executed: middle.setLeft(left.left() + gridSize().width()); | 0 | ||||||||||||||||||||||||
1018 | else | - | ||||||||||||||||||||||||
1019 | middle.setLeft(left.right() + 1); never executed: middle.setLeft(left.right() + 1); | 0 | ||||||||||||||||||||||||
1020 | middle.setRight(right.left() - 1); | - | ||||||||||||||||||||||||
1021 | } never executed: else if (left.bottom() < right.top()end of block
| 0 | ||||||||||||||||||||||||
1022 | left.setBottom(right.top() - 1); | - | ||||||||||||||||||||||||
1023 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1024 | right.setBottom(left.top() - 1); | - | ||||||||||||||||||||||||
1025 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1026 | } | - | ||||||||||||||||||||||||
1027 | - | |||||||||||||||||||||||||
1028 | - | |||||||||||||||||||||||||
1029 | QItemSelection topSelection = d->selection(first); | - | ||||||||||||||||||||||||
1030 | QItemSelection middleSelection = d->selection(middle); | - | ||||||||||||||||||||||||
1031 | QItemSelection bottomSelection = d->selection(last); | - | ||||||||||||||||||||||||
1032 | - | |||||||||||||||||||||||||
1033 | selection.merge(topSelection, QItemSelectionModel::Select); | - | ||||||||||||||||||||||||
1034 | selection.merge(middleSelection, QItemSelectionModel::Select); | - | ||||||||||||||||||||||||
1035 | selection.merge(bottomSelection, QItemSelectionModel::Select); | - | ||||||||||||||||||||||||
1036 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1037 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1038 | } | - | ||||||||||||||||||||||||
1039 | - | |||||||||||||||||||||||||
1040 | d->selectionModel->select(selection, command); | - | ||||||||||||||||||||||||
1041 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1042 | - | |||||||||||||||||||||||||
1043 | - | |||||||||||||||||||||||||
1044 | - | |||||||||||||||||||||||||
1045 | - | |||||||||||||||||||||||||
1046 | - | |||||||||||||||||||||||||
1047 | - | |||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||
1049 | QRegion QListView::visualRegionForSelection(const QItemSelection &selection) const | - | ||||||||||||||||||||||||
1050 | { | - | ||||||||||||||||||||||||
1051 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1052 | - | |||||||||||||||||||||||||
1053 | int c = d->column; | - | ||||||||||||||||||||||||
1054 | QRegion selectionRegion; | - | ||||||||||||||||||||||||
1055 | const QRect &viewportRect = d->viewport->rect(); | - | ||||||||||||||||||||||||
1056 | for (int i = 0; i < selection.count()
| 0 | ||||||||||||||||||||||||
1057 | if (!selection.at(i).isValid()
| 0 | ||||||||||||||||||||||||
1058 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1059 | QModelIndex parent = selection.at(i).topLeft().parent(); | - | ||||||||||||||||||||||||
1060 | - | |||||||||||||||||||||||||
1061 | - | |||||||||||||||||||||||||
1062 | if (parent != d->root
| 0 | ||||||||||||||||||||||||
1063 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1064 | int t = selection.at(i).topLeft().row(); | - | ||||||||||||||||||||||||
1065 | int b = selection.at(i).bottomRight().row(); | - | ||||||||||||||||||||||||
1066 | if (d->viewMode == IconMode
| 0 | ||||||||||||||||||||||||
1067 | for (int r = t; r <= b
| 0 | ||||||||||||||||||||||||
1068 | const QRect &rect = visualRect(d->model->index(r, c, parent)); | - | ||||||||||||||||||||||||
1069 | if (viewportRect.intersects(rect)
| 0 | ||||||||||||||||||||||||
1070 | selectionRegion += rect; never executed: selectionRegion += rect; | 0 | ||||||||||||||||||||||||
1071 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1072 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1073 | while (t <= b
never executed: t;++t; never executed: ++t; | 0 | ||||||||||||||||||||||||
1074 | while (b >= t
never executed: b;--b; never executed: --b; | 0 | ||||||||||||||||||||||||
1075 | const QModelIndex top = d->model->index(t, c, parent); | - | ||||||||||||||||||||||||
1076 | const QModelIndex bottom = d->model->index(b, c, parent); | - | ||||||||||||||||||||||||
1077 | QRect rect(visualRect(top).topLeft(), | - | ||||||||||||||||||||||||
1078 | visualRect(bottom).bottomRight()); | - | ||||||||||||||||||||||||
1079 | if (viewportRect.intersects(rect)
| 0 | ||||||||||||||||||||||||
1080 | selectionRegion += rect; never executed: selectionRegion += rect; | 0 | ||||||||||||||||||||||||
1081 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1082 | } | - | ||||||||||||||||||||||||
1083 | - | |||||||||||||||||||||||||
1084 | return never executed: selectionRegion;return selectionRegion; never executed: return selectionRegion; | 0 | ||||||||||||||||||||||||
1085 | } | - | ||||||||||||||||||||||||
1086 | - | |||||||||||||||||||||||||
1087 | - | |||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||
1089 | - | |||||||||||||||||||||||||
1090 | QModelIndexList QListView::selectedIndexes() const | - | ||||||||||||||||||||||||
1091 | { | - | ||||||||||||||||||||||||
1092 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1093 | if (!d->selectionModel
| 0 | ||||||||||||||||||||||||
1094 | return never executed: QModelIndexList();return QModelIndexList(); never executed: return QModelIndexList(); | 0 | ||||||||||||||||||||||||
1095 | - | |||||||||||||||||||||||||
1096 | QModelIndexList viewSelected = d->selectionModel->selectedIndexes(); | - | ||||||||||||||||||||||||
1097 | for (int i = 0; i < viewSelected.count()
| 0 | ||||||||||||||||||||||||
1098 | const QModelIndex &index = viewSelected.at(i); | - | ||||||||||||||||||||||||
1099 | if (!isIndexHidden(index)
| 0 | ||||||||||||||||||||||||
1100 | ++ never executed: i;++i; never executed: ++i; | 0 | ||||||||||||||||||||||||
1101 | else | - | ||||||||||||||||||||||||
1102 | viewSelected.removeAt(i); never executed: viewSelected.removeAt(i); | 0 | ||||||||||||||||||||||||
1103 | } | - | ||||||||||||||||||||||||
1104 | return never executed: viewSelected;return viewSelected; never executed: return viewSelected; | 0 | ||||||||||||||||||||||||
1105 | } | - | ||||||||||||||||||||||||
1106 | - | |||||||||||||||||||||||||
1107 | - | |||||||||||||||||||||||||
1108 | - | |||||||||||||||||||||||||
1109 | - | |||||||||||||||||||||||||
1110 | - | |||||||||||||||||||||||||
1111 | - | |||||||||||||||||||||||||
1112 | void QListView::doItemsLayout() | - | ||||||||||||||||||||||||
1113 | { | - | ||||||||||||||||||||||||
1114 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1115 | - | |||||||||||||||||||||||||
1116 | - | |||||||||||||||||||||||||
1117 | - | |||||||||||||||||||||||||
1118 | QAbstractItemView::State oldState = state(); | - | ||||||||||||||||||||||||
1119 | setState(ExpandingState); | - | ||||||||||||||||||||||||
1120 | if (d->model->columnCount(d->root) > 0
| 0 | ||||||||||||||||||||||||
1121 | d->resetBatchStartRow(); | - | ||||||||||||||||||||||||
1122 | if (layoutMode() == SinglePass
| 0 | ||||||||||||||||||||||||
1123 | d->doItemsLayout(d->model->rowCount(d->root)); never executed: d->doItemsLayout(d->model->rowCount(d->root)); | 0 | ||||||||||||||||||||||||
1124 | else if (!d->batchLayoutTimer.isActive()
| 0 | ||||||||||||||||||||||||
1125 | if (!d->doItemsLayout(d->batchSize)
| 0 | ||||||||||||||||||||||||
1126 | d->batchLayoutTimer.start(0, this); never executed: d->batchLayoutTimer.start(0, this); | 0 | ||||||||||||||||||||||||
1127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1128 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1129 | QAbstractItemView::doItemsLayout(); | - | ||||||||||||||||||||||||
1130 | setState(oldState); | - | ||||||||||||||||||||||||
1131 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1132 | - | |||||||||||||||||||||||||
1133 | - | |||||||||||||||||||||||||
1134 | - | |||||||||||||||||||||||||
1135 | - | |||||||||||||||||||||||||
1136 | void QListView::updateGeometries() | - | ||||||||||||||||||||||||
1137 | { | - | ||||||||||||||||||||||||
1138 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1139 | if (geometry().isEmpty()
| 0 | ||||||||||||||||||||||||
1140 | horizontalScrollBar()->setRange(0, 0); | - | ||||||||||||||||||||||||
1141 | verticalScrollBar()->setRange(0, 0); | - | ||||||||||||||||||||||||
1142 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1143 | QModelIndex index = d->model->index(0, d->column, d->root); | - | ||||||||||||||||||||||||
1144 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||||||||
1145 | QSize step = d->itemSize(option, index); | - | ||||||||||||||||||||||||
1146 | d->commonListView->updateHorizontalScrollBar(step); | - | ||||||||||||||||||||||||
1147 | d->commonListView->updateVerticalScrollBar(step); | - | ||||||||||||||||||||||||
1148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1149 | - | |||||||||||||||||||||||||
1150 | QAbstractItemView::updateGeometries(); | - | ||||||||||||||||||||||||
1151 | - | |||||||||||||||||||||||||
1152 | - | |||||||||||||||||||||||||
1153 | if (d->movement == Static
| 0 | ||||||||||||||||||||||||
1154 | d->layoutChildren(); | - | ||||||||||||||||||||||||
1155 | if (d->flow == TopToBottom
| 0 | ||||||||||||||||||||||||
1156 | if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff
| 0 | ||||||||||||||||||||||||
1157 | d->setContentsSize(viewport()->width(), contentsSize().height()); | - | ||||||||||||||||||||||||
1158 | horizontalScrollBar()->setRange(0, 0); | - | ||||||||||||||||||||||||
1159 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1160 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1161 | if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff
| 0 | ||||||||||||||||||||||||
1162 | d->setContentsSize(contentsSize().width(), viewport()->height()); | - | ||||||||||||||||||||||||
1163 | verticalScrollBar()->setRange(0, 0); | - | ||||||||||||||||||||||||
1164 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1165 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1166 | } | - | ||||||||||||||||||||||||
1167 | - | |||||||||||||||||||||||||
1168 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1169 | - | |||||||||||||||||||||||||
1170 | - | |||||||||||||||||||||||||
1171 | - | |||||||||||||||||||||||||
1172 | - | |||||||||||||||||||||||||
1173 | bool QListView::isIndexHidden(const QModelIndex &index) const | - | ||||||||||||||||||||||||
1174 | { | - | ||||||||||||||||||||||||
1175 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1176 | return never executed: (d->isHidden(index.row())return (d->isHidden(index.row()) && (index.parent() == d->root) && index.column() == d->column);
never executed: return (d->isHidden(index.row()) && (index.parent() == d->root) && index.column() == d->column); | 0 | ||||||||||||||||||||||||
1177 | && (
never executed: return (d->isHidden(index.row()) && (index.parent() == d->root) && index.column() == d->column); | 0 | ||||||||||||||||||||||||
1178 | && index.column() == d->column
never executed: return (d->isHidden(index.row()) && (index.parent() == d->root) && index.column() == d->column); | 0 | ||||||||||||||||||||||||
1179 | } | - | ||||||||||||||||||||||||
1180 | void QListView::setModelColumn(int column) | - | ||||||||||||||||||||||||
1181 | { | - | ||||||||||||||||||||||||
1182 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1183 | if (column < 0
| 0 | ||||||||||||||||||||||||
1184 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1185 | d->column = column; | - | ||||||||||||||||||||||||
1186 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
1187 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1188 | - | |||||||||||||||||||||||||
1189 | int QListView::modelColumn() const | - | ||||||||||||||||||||||||
1190 | { | - | ||||||||||||||||||||||||
1191 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1192 | return never executed: d->column;return d->column; never executed: return d->column; | 0 | ||||||||||||||||||||||||
1193 | } | - | ||||||||||||||||||||||||
1194 | void QListView::setUniformItemSizes(bool enable) | - | ||||||||||||||||||||||||
1195 | { | - | ||||||||||||||||||||||||
1196 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1197 | d->uniformItemSizes = enable; | - | ||||||||||||||||||||||||
1198 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1199 | - | |||||||||||||||||||||||||
1200 | bool QListView::uniformItemSizes() const | - | ||||||||||||||||||||||||
1201 | { | - | ||||||||||||||||||||||||
1202 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1203 | return never executed: d->uniformItemSizes;return d->uniformItemSizes; never executed: return d->uniformItemSizes; | 0 | ||||||||||||||||||||||||
1204 | } | - | ||||||||||||||||||||||||
1205 | void QListView::setWordWrap(bool on) | - | ||||||||||||||||||||||||
1206 | { | - | ||||||||||||||||||||||||
1207 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1208 | if (d->wrapItemText == on
| 0 | ||||||||||||||||||||||||
1209 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1210 | d->wrapItemText = on; | - | ||||||||||||||||||||||||
1211 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
1212 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1213 | - | |||||||||||||||||||||||||
1214 | bool QListView::wordWrap() const | - | ||||||||||||||||||||||||
1215 | { | - | ||||||||||||||||||||||||
1216 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1217 | return never executed: d->wrapItemText;return d->wrapItemText; never executed: return d->wrapItemText; | 0 | ||||||||||||||||||||||||
1218 | } | - | ||||||||||||||||||||||||
1219 | void QListView::setSelectionRectVisible(bool show) | - | ||||||||||||||||||||||||
1220 | { | - | ||||||||||||||||||||||||
1221 | QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1222 | d->modeProperties |= uint(QListViewPrivate::SelectionRectVisible); | - | ||||||||||||||||||||||||
1223 | d->setSelectionRectVisible(show); | - | ||||||||||||||||||||||||
1224 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1225 | - | |||||||||||||||||||||||||
1226 | bool QListView::isSelectionRectVisible() const | - | ||||||||||||||||||||||||
1227 | { | - | ||||||||||||||||||||||||
1228 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1229 | return never executed: d->isSelectionRectVisible();return d->isSelectionRectVisible(); never executed: return d->isSelectionRectVisible(); | 0 | ||||||||||||||||||||||||
1230 | } | - | ||||||||||||||||||||||||
1231 | - | |||||||||||||||||||||||||
1232 | - | |||||||||||||||||||||||||
1233 | - | |||||||||||||||||||||||||
1234 | - | |||||||||||||||||||||||||
1235 | bool QListView::event(QEvent *e) | - | ||||||||||||||||||||||||
1236 | { | - | ||||||||||||||||||||||||
1237 | return never executed: QAbstractItemView::event(e);return QAbstractItemView::event(e); never executed: return QAbstractItemView::event(e); | 0 | ||||||||||||||||||||||||
1238 | } | - | ||||||||||||||||||||||||
1239 | - | |||||||||||||||||||||||||
1240 | - | |||||||||||||||||||||||||
1241 | - | |||||||||||||||||||||||||
1242 | - | |||||||||||||||||||||||||
1243 | - | |||||||||||||||||||||||||
1244 | QListViewPrivate::QListViewPrivate() | - | ||||||||||||||||||||||||
1245 | : QAbstractItemViewPrivate(), | - | ||||||||||||||||||||||||
1246 | commonListView(0), | - | ||||||||||||||||||||||||
1247 | wrap(false), | - | ||||||||||||||||||||||||
1248 | space(0), | - | ||||||||||||||||||||||||
1249 | flow(QListView::TopToBottom), | - | ||||||||||||||||||||||||
1250 | movement(QListView::Static), | - | ||||||||||||||||||||||||
1251 | resizeMode(QListView::Fixed), | - | ||||||||||||||||||||||||
1252 | layoutMode(QListView::SinglePass), | - | ||||||||||||||||||||||||
1253 | viewMode(QListView::ListMode), | - | ||||||||||||||||||||||||
1254 | modeProperties(0), | - | ||||||||||||||||||||||||
1255 | column(0), | - | ||||||||||||||||||||||||
1256 | uniformItemSizes(false), | - | ||||||||||||||||||||||||
1257 | batchSize(100), | - | ||||||||||||||||||||||||
1258 | showElasticBand(false) | - | ||||||||||||||||||||||||
1259 | { | - | ||||||||||||||||||||||||
1260 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1261 | - | |||||||||||||||||||||||||
1262 | QListViewPrivate::~QListViewPrivate() | - | ||||||||||||||||||||||||
1263 | { | - | ||||||||||||||||||||||||
1264 | delete commonListView; | - | ||||||||||||||||||||||||
1265 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1266 | - | |||||||||||||||||||||||||
1267 | void QListViewPrivate::clear() | - | ||||||||||||||||||||||||
1268 | { | - | ||||||||||||||||||||||||
1269 | - | |||||||||||||||||||||||||
1270 | cachedItemSize = QSize(); | - | ||||||||||||||||||||||||
1271 | commonListView->clear(); | - | ||||||||||||||||||||||||
1272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1273 | - | |||||||||||||||||||||||||
1274 | void QListViewPrivate::prepareItemsLayout() | - | ||||||||||||||||||||||||
1275 | { | - | ||||||||||||||||||||||||
1276 | QListView * const q = q_func(); | - | ||||||||||||||||||||||||
1277 | clear(); | - | ||||||||||||||||||||||||
1278 | - | |||||||||||||||||||||||||
1279 | - | |||||||||||||||||||||||||
1280 | layoutBounds = QRect(QPoint(), q->maximumViewportSize()); | - | ||||||||||||||||||||||||
1281 | - | |||||||||||||||||||||||||
1282 | int frameAroundContents = 0; | - | ||||||||||||||||||||||||
1283 | if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents)
| 0 | ||||||||||||||||||||||||
1284 | frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2; never executed: frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2; | 0 | ||||||||||||||||||||||||
1285 | - | |||||||||||||||||||||||||
1286 | - | |||||||||||||||||||||||||
1287 | - | |||||||||||||||||||||||||
1288 | - | |||||||||||||||||||||||||
1289 | int verticalMargin = vbarpolicy==Qt::ScrollBarAsNeeded
| 0 | ||||||||||||||||||||||||
1290 | ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, vbar) + frameAroundContents | - | ||||||||||||||||||||||||
1291 | : 0; | - | ||||||||||||||||||||||||
1292 | int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded
| 0 | ||||||||||||||||||||||||
1293 | ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, hbar) + frameAroundContents | - | ||||||||||||||||||||||||
1294 | : 0; | - | ||||||||||||||||||||||||
1295 | - | |||||||||||||||||||||||||
1296 | layoutBounds.adjust(0, 0, -verticalMargin, -horizontalMargin); | - | ||||||||||||||||||||||||
1297 | - | |||||||||||||||||||||||||
1298 | int rowCount = model->columnCount(root) <= 0
| 0 | ||||||||||||||||||||||||
1299 | commonListView->setRowCount(rowCount); | - | ||||||||||||||||||||||||
1300 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1301 | - | |||||||||||||||||||||||||
1302 | - | |||||||||||||||||||||||||
1303 | - | |||||||||||||||||||||||||
1304 | - | |||||||||||||||||||||||||
1305 | bool QListViewPrivate::doItemsLayout(int delta) | - | ||||||||||||||||||||||||
1306 | { | - | ||||||||||||||||||||||||
1307 | int max = model->rowCount(root) - 1; | - | ||||||||||||||||||||||||
1308 | int first = batchStartRow(); | - | ||||||||||||||||||||||||
1309 | int last = qMin(first + delta - 1, max); | - | ||||||||||||||||||||||||
1310 | - | |||||||||||||||||||||||||
1311 | if (first == 0
| 0 | ||||||||||||||||||||||||
1312 | layoutChildren(); | - | ||||||||||||||||||||||||
1313 | prepareItemsLayout(); | - | ||||||||||||||||||||||||
1314 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1315 | - | |||||||||||||||||||||||||
1316 | if (max < 0
| 0 | ||||||||||||||||||||||||
1317 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1318 | } | - | ||||||||||||||||||||||||
1319 | - | |||||||||||||||||||||||||
1320 | QListViewLayoutInfo info; | - | ||||||||||||||||||||||||
1321 | info.bounds = layoutBounds; | - | ||||||||||||||||||||||||
1322 | info.grid = gridSize(); | - | ||||||||||||||||||||||||
1323 | info.spacing = (info.grid.isValid()
| 0 | ||||||||||||||||||||||||
1324 | info.first = first; | - | ||||||||||||||||||||||||
1325 | info.last = last; | - | ||||||||||||||||||||||||
1326 | info.wrap = isWrapping(); | - | ||||||||||||||||||||||||
1327 | info.flow = flow; | - | ||||||||||||||||||||||||
1328 | info.max = max; | - | ||||||||||||||||||||||||
1329 | - | |||||||||||||||||||||||||
1330 | return never executed: commonListView->doBatchedItemLayout(info, max);return commonListView->doBatchedItemLayout(info, max); never executed: return commonListView->doBatchedItemLayout(info, max); | 0 | ||||||||||||||||||||||||
1331 | } | - | ||||||||||||||||||||||||
1332 | - | |||||||||||||||||||||||||
1333 | QListViewItem QListViewPrivate::indexToListViewItem(const QModelIndex &index) const | - | ||||||||||||||||||||||||
1334 | { | - | ||||||||||||||||||||||||
1335 | if (!index.isValid()
| 0 | ||||||||||||||||||||||||
1336 | return never executed: QListViewItem();return QListViewItem(); never executed: return QListViewItem(); | 0 | ||||||||||||||||||||||||
1337 | - | |||||||||||||||||||||||||
1338 | return never executed: commonListView->indexToListViewItem(index);return commonListView->indexToListViewItem(index); never executed: return commonListView->indexToListViewItem(index); | 0 | ||||||||||||||||||||||||
1339 | } | - | ||||||||||||||||||||||||
1340 | - | |||||||||||||||||||||||||
1341 | QRect QListViewPrivate::mapToViewport(const QRect &rect, bool extend) const | - | ||||||||||||||||||||||||
1342 | { | - | ||||||||||||||||||||||||
1343 | const QListView * const q = q_func(); | - | ||||||||||||||||||||||||
1344 | if (!rect.isValid()
| 0 | ||||||||||||||||||||||||
1345 | return never executed: rect;return rect; never executed: return rect; | 0 | ||||||||||||||||||||||||
1346 | - | |||||||||||||||||||||||||
1347 | QRect result = extend
| 0 | ||||||||||||||||||||||||
1348 | int dx = -q->horizontalOffset(); | - | ||||||||||||||||||||||||
1349 | int dy = -q->verticalOffset(); | - | ||||||||||||||||||||||||
1350 | return never executed: result.adjusted(dx, dy, dx, dy);return result.adjusted(dx, dy, dx, dy); never executed: return result.adjusted(dx, dy, dx, dy); | 0 | ||||||||||||||||||||||||
1351 | } | - | ||||||||||||||||||||||||
1352 | - | |||||||||||||||||||||||||
1353 | QModelIndex QListViewPrivate::closestIndex(const QRect &target, | - | ||||||||||||||||||||||||
1354 | const QVector<QModelIndex> &candidates) const | - | ||||||||||||||||||||||||
1355 | { | - | ||||||||||||||||||||||||
1356 | int distance = 0; | - | ||||||||||||||||||||||||
1357 | int shortest = 2147483647; | - | ||||||||||||||||||||||||
1358 | QModelIndex closest; | - | ||||||||||||||||||||||||
1359 | QVector<QModelIndex>::const_iterator it = candidates.begin(); | - | ||||||||||||||||||||||||
1360 | - | |||||||||||||||||||||||||
1361 | for (; it != candidates.end()
| 0 | ||||||||||||||||||||||||
1362 | if (!(*it).isValid()
| 0 | ||||||||||||||||||||||||
1363 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1364 | - | |||||||||||||||||||||||||
1365 | const QRect indexRect = indexToListViewItem(*it).rect(); | - | ||||||||||||||||||||||||
1366 | - | |||||||||||||||||||||||||
1367 | - | |||||||||||||||||||||||||
1368 | - | |||||||||||||||||||||||||
1369 | - | |||||||||||||||||||||||||
1370 | if ((target.center().x() >= indexRect.x()
| 0 | ||||||||||||||||||||||||
1371 | || (indexRect.center().x() >= target.x()
| 0 | ||||||||||||||||||||||||
1372 | - | |||||||||||||||||||||||||
1373 | distance = qAbs(indexRect.center().y() - target.center().y()); | - | ||||||||||||||||||||||||
1374 | } never executed: else if ((target.center().y() >= indexRect.y()end of block
| 0 | ||||||||||||||||||||||||
1375 | || (indexRect.center().y() >= target.y()
| 0 | ||||||||||||||||||||||||
1376 | - | |||||||||||||||||||||||||
1377 | distance = qAbs(indexRect.center().x() - target.center().x()); | - | ||||||||||||||||||||||||
1378 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1379 | distance = (indexRect.center() - target.center()).manhattanLength(); | - | ||||||||||||||||||||||||
1380 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1381 | if (distance < shortest
| 0 | ||||||||||||||||||||||||
1382 | shortest = distance; | - | ||||||||||||||||||||||||
1383 | closest = *it; | - | ||||||||||||||||||||||||
1384 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1385 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1386 | return never executed: closest;return closest; never executed: return closest; | 0 | ||||||||||||||||||||||||
1387 | } | - | ||||||||||||||||||||||||
1388 | - | |||||||||||||||||||||||||
1389 | QSize QListViewPrivate::itemSize(const QStyleOptionViewItem &option, const QModelIndex &index) const | - | ||||||||||||||||||||||||
1390 | { | - | ||||||||||||||||||||||||
1391 | if (!uniformItemSizes
| 0 | ||||||||||||||||||||||||
1392 | const QAbstractItemDelegate *delegate = delegateForIndex(index); | - | ||||||||||||||||||||||||
1393 | return never executed: delegatereturn delegate ? delegate->sizeHint(option, index) : QSize();
never executed: return delegate ? delegate->sizeHint(option, index) : QSize(); | 0 | ||||||||||||||||||||||||
1394 | } | - | ||||||||||||||||||||||||
1395 | if (!cachedItemSize.isValid()
| 0 | ||||||||||||||||||||||||
1396 | int row = model->rowCount(root) - 1; | - | ||||||||||||||||||||||||
1397 | QModelIndex sample = model->index(row, column, root); | - | ||||||||||||||||||||||||
1398 | const QAbstractItemDelegate *delegate = delegateForIndex(sample); | - | ||||||||||||||||||||||||
1399 | cachedItemSize = delegate
| 0 | ||||||||||||||||||||||||
1400 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1401 | return never executed: cachedItemSize;return cachedItemSize; never executed: return cachedItemSize; | 0 | ||||||||||||||||||||||||
1402 | } | - | ||||||||||||||||||||||||
1403 | - | |||||||||||||||||||||||||
1404 | QItemSelection QListViewPrivate::selection(const QRect &rect) const | - | ||||||||||||||||||||||||
1405 | { | - | ||||||||||||||||||||||||
1406 | QItemSelection selection; | - | ||||||||||||||||||||||||
1407 | QModelIndex tl, br; | - | ||||||||||||||||||||||||
1408 | const QVector<QModelIndex> intersectVector = intersectingSet(rect); | - | ||||||||||||||||||||||||
1409 | QVector<QModelIndex>::const_iterator it = intersectVector.begin(); | - | ||||||||||||||||||||||||
1410 | for (; it != intersectVector.end()
| 0 | ||||||||||||||||||||||||
1411 | if (!tl.isValid()
| 0 | ||||||||||||||||||||||||
1412 | tl = br = *it; | - | ||||||||||||||||||||||||
1413 | } never executed: else if ((*end of block
| 0 | ||||||||||||||||||||||||
1414 | tl = *it; | - | ||||||||||||||||||||||||
1415 | } never executed: else if ((*end of block
| 0 | ||||||||||||||||||||||||
1416 | br = (*it); | - | ||||||||||||||||||||||||
1417 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1418 | selection.select(tl, br); | - | ||||||||||||||||||||||||
1419 | tl = br = *it; | - | ||||||||||||||||||||||||
1420 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1421 | } | - | ||||||||||||||||||||||||
1422 | - | |||||||||||||||||||||||||
1423 | if (tl.isValid()
| 0 | ||||||||||||||||||||||||
1424 | selection.select(tl, br); never executed: selection.select(tl, br); | 0 | ||||||||||||||||||||||||
1425 | else if (tl.isValid()
| 0 | ||||||||||||||||||||||||
1426 | selection.select(tl, tl); never executed: selection.select(tl, tl); | 0 | ||||||||||||||||||||||||
1427 | else if (br.isValid()
| 0 | ||||||||||||||||||||||||
1428 | selection.select(br, br); never executed: selection.select(br, br); | 0 | ||||||||||||||||||||||||
1429 | - | |||||||||||||||||||||||||
1430 | return never executed: selection;return selection; never executed: return selection; | 0 | ||||||||||||||||||||||||
1431 | } | - | ||||||||||||||||||||||||
1432 | - | |||||||||||||||||||||||||
1433 | - | |||||||||||||||||||||||||
1434 | QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const | - | ||||||||||||||||||||||||
1435 | { | - | ||||||||||||||||||||||||
1436 | if (viewMode == QListView::ListMode
| 0 | ||||||||||||||||||||||||
1437 | return never executed: static_cast<QListModeViewBase *>(commonListView)->position(pos, rect, idx);return static_cast<QListModeViewBase *>(commonListView)->position(pos, rect, idx); never executed: return static_cast<QListModeViewBase *>(commonListView)->position(pos, rect, idx); | 0 | ||||||||||||||||||||||||
1438 | else | - | ||||||||||||||||||||||||
1439 | return never executed: QAbstractItemViewPrivate::position(pos, rect, idx);return QAbstractItemViewPrivate::position(pos, rect, idx); never executed: return QAbstractItemViewPrivate::position(pos, rect, idx); | 0 | ||||||||||||||||||||||||
1440 | } | - | ||||||||||||||||||||||||
1441 | - | |||||||||||||||||||||||||
1442 | bool QListViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex) | - | ||||||||||||||||||||||||
1443 | { | - | ||||||||||||||||||||||||
1444 | if (viewMode == QListView::ListMode
| 0 | ||||||||||||||||||||||||
1445 | return never executed: static_cast<QListModeViewBase *>(commonListView)->dropOn(event, dropRow, dropCol, dropIndex);return static_cast<QListModeViewBase *>(commonListView)->dropOn(event, dropRow, dropCol, dropIndex); never executed: return static_cast<QListModeViewBase *>(commonListView)->dropOn(event, dropRow, dropCol, dropIndex); | 0 | ||||||||||||||||||||||||
1446 | else | - | ||||||||||||||||||||||||
1447 | return never executed: QAbstractItemViewPrivate::dropOn(event, dropRow, dropCol, dropIndex);return QAbstractItemViewPrivate::dropOn(event, dropRow, dropCol, dropIndex); never executed: return QAbstractItemViewPrivate::dropOn(event, dropRow, dropCol, dropIndex); | 0 | ||||||||||||||||||||||||
1448 | } | - | ||||||||||||||||||||||||
1449 | - | |||||||||||||||||||||||||
1450 | - | |||||||||||||||||||||||||
1451 | - | |||||||||||||||||||||||||
1452 | - | |||||||||||||||||||||||||
1453 | - | |||||||||||||||||||||||||
1454 | - | |||||||||||||||||||||||||
1455 | void QCommonListViewBase::appendHiddenRow(int row) | - | ||||||||||||||||||||||||
1456 | { | - | ||||||||||||||||||||||||
1457 | dd->hiddenRows.insert(dd->model->index(row, 0, qq->rootIndex())); | - | ||||||||||||||||||||||||
1458 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1459 | - | |||||||||||||||||||||||||
1460 | void QCommonListViewBase::removeHiddenRow(int row) | - | ||||||||||||||||||||||||
1461 | { | - | ||||||||||||||||||||||||
1462 | dd->hiddenRows.remove(dd->model->index(row, 0, qq->rootIndex())); | - | ||||||||||||||||||||||||
1463 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1464 | - | |||||||||||||||||||||||||
1465 | - | |||||||||||||||||||||||||
1466 | void QCommonListViewBase::paintDragDrop(QPainter *painter) | - | ||||||||||||||||||||||||
1467 | { | - | ||||||||||||||||||||||||
1468 | - | |||||||||||||||||||||||||
1469 | - | |||||||||||||||||||||||||
1470 | dd->paintDropIndicator(painter); | - | ||||||||||||||||||||||||
1471 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1472 | - | |||||||||||||||||||||||||
1473 | - | |||||||||||||||||||||||||
1474 | void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) | - | ||||||||||||||||||||||||
1475 | { | - | ||||||||||||||||||||||||
1476 | horizontalScrollBar()->setSingleStep(step.width() + spacing()); | - | ||||||||||||||||||||||||
1477 | horizontalScrollBar()->setPageStep(viewport()->width()); | - | ||||||||||||||||||||||||
1478 | - | |||||||||||||||||||||||||
1479 | - | |||||||||||||||||||||||||
1480 | - | |||||||||||||||||||||||||
1481 | - | |||||||||||||||||||||||||
1482 | - | |||||||||||||||||||||||||
1483 | const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded
| 0 | ||||||||||||||||||||||||
1484 | qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded
| 0 | ||||||||||||||||||||||||
1485 | - | |||||||||||||||||||||||||
1486 | const QSize viewportSize = qq->contentsRect().size(); | - | ||||||||||||||||||||||||
1487 | - | |||||||||||||||||||||||||
1488 | bool verticalWantsToShow = contentsSize.height() > viewportSize.height(); | - | ||||||||||||||||||||||||
1489 | bool horizontalWantsToShow; | - | ||||||||||||||||||||||||
1490 | if (verticalWantsToShow
| 0 | ||||||||||||||||||||||||
1491 | horizontalWantsToShow = contentsSize.width() > viewportSize.width() - qq->verticalScrollBar()->width(); never executed: horizontalWantsToShow = contentsSize.width() > viewportSize.width() - qq->verticalScrollBar()->width(); | 0 | ||||||||||||||||||||||||
1492 | else | - | ||||||||||||||||||||||||
1493 | horizontalWantsToShow = contentsSize.width() > viewportSize.width(); never executed: horizontalWantsToShow = contentsSize.width() > viewportSize.width(); | 0 | ||||||||||||||||||||||||
1494 | - | |||||||||||||||||||||||||
1495 | if (bothScrollBarsAuto
| 0 | ||||||||||||||||||||||||
1496 | - | |||||||||||||||||||||||||
1497 | - | |||||||||||||||||||||||||
1498 | horizontalScrollBar()->setRange(0, 0); | - | ||||||||||||||||||||||||
1499 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1500 | horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width()); | - | ||||||||||||||||||||||||
1501 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1502 | } | - | ||||||||||||||||||||||||
1503 | - | |||||||||||||||||||||||||
1504 | void QCommonListViewBase::updateVerticalScrollBar(const QSize &step) | - | ||||||||||||||||||||||||
1505 | { | - | ||||||||||||||||||||||||
1506 | verticalScrollBar()->setSingleStep(step.height() + spacing()); | - | ||||||||||||||||||||||||
1507 | verticalScrollBar()->setPageStep(viewport()->height()); | - | ||||||||||||||||||||||||
1508 | - | |||||||||||||||||||||||||
1509 | - | |||||||||||||||||||||||||
1510 | - | |||||||||||||||||||||||||
1511 | - | |||||||||||||||||||||||||
1512 | - | |||||||||||||||||||||||||
1513 | const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded
| 0 | ||||||||||||||||||||||||
1514 | qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded
| 0 | ||||||||||||||||||||||||
1515 | - | |||||||||||||||||||||||||
1516 | const QSize viewportSize = qq->contentsRect().size(); | - | ||||||||||||||||||||||||
1517 | - | |||||||||||||||||||||||||
1518 | bool horizontalWantsToShow = contentsSize.width() > viewportSize.width(); | - | ||||||||||||||||||||||||
1519 | bool verticalWantsToShow; | - | ||||||||||||||||||||||||
1520 | if (horizontalWantsToShow
| 0 | ||||||||||||||||||||||||
1521 | verticalWantsToShow = contentsSize.height() > viewportSize.height() - qq->horizontalScrollBar()->height(); never executed: verticalWantsToShow = contentsSize.height() > viewportSize.height() - qq->horizontalScrollBar()->height(); | 0 | ||||||||||||||||||||||||
1522 | else | - | ||||||||||||||||||||||||
1523 | verticalWantsToShow = contentsSize.height() > viewportSize.height(); never executed: verticalWantsToShow = contentsSize.height() > viewportSize.height(); | 0 | ||||||||||||||||||||||||
1524 | - | |||||||||||||||||||||||||
1525 | if (bothScrollBarsAuto
| 0 | ||||||||||||||||||||||||
1526 | - | |||||||||||||||||||||||||
1527 | - | |||||||||||||||||||||||||
1528 | verticalScrollBar()->setRange(0, 0); | - | ||||||||||||||||||||||||
1529 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1530 | verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height()); | - | ||||||||||||||||||||||||
1531 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1532 | } | - | ||||||||||||||||||||||||
1533 | - | |||||||||||||||||||||||||
1534 | void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool ) | - | ||||||||||||||||||||||||
1535 | { | - | ||||||||||||||||||||||||
1536 | dd->scrollContentsBy(isRightToLeft() ? -dx : dx, dy); | - | ||||||||||||||||||||||||
1537 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1538 | - | |||||||||||||||||||||||||
1539 | int QCommonListViewBase::verticalScrollToValue(int , QListView::ScrollHint hint, | - | ||||||||||||||||||||||||
1540 | bool above, bool below, const QRect &area, const QRect &rect) const | - | ||||||||||||||||||||||||
1541 | { | - | ||||||||||||||||||||||||
1542 | int verticalValue = verticalScrollBar()->value(); | - | ||||||||||||||||||||||||
1543 | QRect adjusted = rect.adjusted(-spacing(), -spacing(), spacing(), spacing()); | - | ||||||||||||||||||||||||
1544 | if (hint == QListView::PositionAtTop
| 0 | ||||||||||||||||||||||||
1545 | verticalValue += adjusted.top(); never executed: verticalValue += adjusted.top(); | 0 | ||||||||||||||||||||||||
1546 | else if (hint == QListView::PositionAtBottom
| 0 | ||||||||||||||||||||||||
1547 | verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1); never executed: verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1); | 0 | ||||||||||||||||||||||||
1548 | else if (hint == QListView::PositionAtCenter
| 0 | ||||||||||||||||||||||||
1549 | verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2); never executed: verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2); | 0 | ||||||||||||||||||||||||
1550 | return never executed: verticalValue;return verticalValue; never executed: return verticalValue; | 0 | ||||||||||||||||||||||||
1551 | } | - | ||||||||||||||||||||||||
1552 | - | |||||||||||||||||||||||||
1553 | int QCommonListViewBase::horizontalOffset() const | - | ||||||||||||||||||||||||
1554 | { | - | ||||||||||||||||||||||||
1555 | return never executed: (isRightToLeft()return (isRightToLeft() ? horizontalScrollBar()->maximum() - horizontalScrollBar()->value() : horizontalScrollBar()->value());
never executed: return (isRightToLeft() ? horizontalScrollBar()->maximum() - horizontalScrollBar()->value() : horizontalScrollBar()->value()); | 0 | ||||||||||||||||||||||||
1556 | } | - | ||||||||||||||||||||||||
1557 | - | |||||||||||||||||||||||||
1558 | int QCommonListViewBase::horizontalScrollToValue(const int , QListView::ScrollHint hint, | - | ||||||||||||||||||||||||
1559 | bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const | - | ||||||||||||||||||||||||
1560 | { | - | ||||||||||||||||||||||||
1561 | int horizontalValue = horizontalScrollBar()->value(); | - | ||||||||||||||||||||||||
1562 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
1563 | if (hint == QListView::PositionAtCenter
| 0 | ||||||||||||||||||||||||
1564 | horizontalValue += ((area.width() - rect.width()) / 2) - rect.left(); | - | ||||||||||||||||||||||||
1565 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1566 | if (leftOf
| 0 | ||||||||||||||||||||||||
1567 | horizontalValue -= rect.left(); never executed: horizontalValue -= rect.left(); | 0 | ||||||||||||||||||||||||
1568 | else if (rightOf
| 0 | ||||||||||||||||||||||||
1569 | horizontalValue += qMin(rect.left(), area.width() - rect.right()); never executed: horizontalValue += qMin(rect.left(), area.width() - rect.right()); | 0 | ||||||||||||||||||||||||
1570 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1571 | } else { | - | ||||||||||||||||||||||||
1572 | if (hint == QListView::PositionAtCenter
| 0 | ||||||||||||||||||||||||
1573 | horizontalValue += rect.left() - ((area.width()- rect.width()) / 2); | - | ||||||||||||||||||||||||
1574 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1575 | if (leftOf
| 0 | ||||||||||||||||||||||||
1576 | horizontalValue += rect.left(); never executed: horizontalValue += rect.left(); | 0 | ||||||||||||||||||||||||
1577 | else if (rightOf
| 0 | ||||||||||||||||||||||||
1578 | horizontalValue += qMin(rect.left(), rect.right() - area.width()); never executed: horizontalValue += qMin(rect.left(), rect.right() - area.width()); | 0 | ||||||||||||||||||||||||
1579 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1580 | } | - | ||||||||||||||||||||||||
1581 | return never executed: horizontalValue;return horizontalValue; never executed: return horizontalValue; | 0 | ||||||||||||||||||||||||
1582 | } | - | ||||||||||||||||||||||||
1583 | - | |||||||||||||||||||||||||
1584 | - | |||||||||||||||||||||||||
1585 | - | |||||||||||||||||||||||||
1586 | - | |||||||||||||||||||||||||
1587 | QListModeViewBase::QListModeViewBase(QListView *q, QListViewPrivate *d) | - | ||||||||||||||||||||||||
1588 | : QCommonListViewBase(q, d) | - | ||||||||||||||||||||||||
1589 | { | - | ||||||||||||||||||||||||
1590 | dd->defaultDropAction = Qt::CopyAction; | - | ||||||||||||||||||||||||
1591 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1592 | - | |||||||||||||||||||||||||
1593 | - | |||||||||||||||||||||||||
1594 | QAbstractItemView::DropIndicatorPosition QListModeViewBase::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const | - | ||||||||||||||||||||||||
1595 | { | - | ||||||||||||||||||||||||
1596 | QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport; | - | ||||||||||||||||||||||||
1597 | if (!dd->overwrite
| 0 | ||||||||||||||||||||||||
1598 | const int margin = 2; | - | ||||||||||||||||||||||||
1599 | if (pos.x() - rect.left() < margin
| 0 | ||||||||||||||||||||||||
1600 | r = QAbstractItemView::AboveItem; | - | ||||||||||||||||||||||||
1601 | } never executed: else if (rect.right() - pos.x() < marginend of block
| 0 | ||||||||||||||||||||||||
1602 | r = QAbstractItemView::BelowItem; | - | ||||||||||||||||||||||||
1603 | } never executed: else if (rect.contains(pos, true)end of block
| 0 | ||||||||||||||||||||||||
1604 | r = QAbstractItemView::OnItem; | - | ||||||||||||||||||||||||
1605 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1606 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1607 | QRect touchingRect = rect; | - | ||||||||||||||||||||||||
1608 | touchingRect.adjust(-1, -1, 1, 1); | - | ||||||||||||||||||||||||
1609 | if (touchingRect.contains(pos, false)
| 0 | ||||||||||||||||||||||||
1610 | r = QAbstractItemView::OnItem; | - | ||||||||||||||||||||||||
1611 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1612 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1613 | - | |||||||||||||||||||||||||
1614 | if (r == QAbstractItemView::OnItem
| 0 | ||||||||||||||||||||||||
1615 | r = pos.x() < rect.center().x()
never executed: r = pos.x() < rect.center().x() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem; | 0 | ||||||||||||||||||||||||
1616 | - | |||||||||||||||||||||||||
1617 | return never executed: r;return r; never executed: return r; | 0 | ||||||||||||||||||||||||
1618 | } | - | ||||||||||||||||||||||||
1619 | - | |||||||||||||||||||||||||
1620 | void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event) | - | ||||||||||||||||||||||||
1621 | { | - | ||||||||||||||||||||||||
1622 | if (qq->dragDropMode() == QAbstractItemView::InternalMove
| 0 | ||||||||||||||||||||||||
1623 | && (event->source() != qq
| 0 | ||||||||||||||||||||||||
1624 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1625 | - | |||||||||||||||||||||||||
1626 | - | |||||||||||||||||||||||||
1627 | event->ignore(); | - | ||||||||||||||||||||||||
1628 | - | |||||||||||||||||||||||||
1629 | - | |||||||||||||||||||||||||
1630 | QPoint p = event->pos(); | - | ||||||||||||||||||||||||
1631 | QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); | - | ||||||||||||||||||||||||
1632 | rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing()); | - | ||||||||||||||||||||||||
1633 | const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect); | - | ||||||||||||||||||||||||
1634 | QModelIndex index = intersectVector.count() > 0
| 0 | ||||||||||||||||||||||||
1635 | ? intersectVector.last() : QModelIndex(); | - | ||||||||||||||||||||||||
1636 | dd->hover = index; | - | ||||||||||||||||||||||||
1637 | if (!dd->droppingOnItself(event, index)
| 0 | ||||||||||||||||||||||||
1638 | && dd->canDrop(event)
| 0 | ||||||||||||||||||||||||
1639 | - | |||||||||||||||||||||||||
1640 | if (index.isValid()
| 0 | ||||||||||||||||||||||||
1641 | QRect rect = qq->visualRect(index); | - | ||||||||||||||||||||||||
1642 | dd->dropIndicatorPosition = position(event->pos(), rect, index); | - | ||||||||||||||||||||||||
1643 | - | |||||||||||||||||||||||||
1644 | switch (dd->dropIndicatorPosition) { | - | ||||||||||||||||||||||||
1645 | case never executed: QAbstractItemView::AboveItem:case QAbstractItemView::AboveItem: never executed: case QAbstractItemView::AboveItem: | 0 | ||||||||||||||||||||||||
1646 | if (dd->isIndexDropEnabled(index.parent())
| 0 | ||||||||||||||||||||||||
1647 | dd->dropIndicatorRect = QRect(rect.left()-dd->spacing(), rect.top(), 0, rect.height()); | - | ||||||||||||||||||||||||
1648 | event->accept(); | - | ||||||||||||||||||||||||
1649 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1650 | dd->dropIndicatorRect = QRect(); | - | ||||||||||||||||||||||||
1651 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1652 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1653 | case never executed: QAbstractItemView::BelowItem:case QAbstractItemView::BelowItem: never executed: case QAbstractItemView::BelowItem: | 0 | ||||||||||||||||||||||||
1654 | if (dd->isIndexDropEnabled(index.parent())
| 0 | ||||||||||||||||||||||||
1655 | dd->dropIndicatorRect = QRect(rect.right()+dd->spacing(), rect.top(), 0, rect.height()); | - | ||||||||||||||||||||||||
1656 | event->accept(); | - | ||||||||||||||||||||||||
1657 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1658 | dd->dropIndicatorRect = QRect(); | - | ||||||||||||||||||||||||
1659 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1660 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1661 | case never executed: QAbstractItemView::OnItem:case QAbstractItemView::OnItem: never executed: case QAbstractItemView::OnItem: | 0 | ||||||||||||||||||||||||
1662 | if (dd->isIndexDropEnabled(index)
| 0 | ||||||||||||||||||||||||
1663 | dd->dropIndicatorRect = rect; | - | ||||||||||||||||||||||||
1664 | event->accept(); | - | ||||||||||||||||||||||||
1665 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1666 | dd->dropIndicatorRect = QRect(); | - | ||||||||||||||||||||||||
1667 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1668 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1669 | case never executed: QAbstractItemView::OnViewport:case QAbstractItemView::OnViewport: never executed: case QAbstractItemView::OnViewport: | 0 | ||||||||||||||||||||||||
1670 | dd->dropIndicatorRect = QRect(); | - | ||||||||||||||||||||||||
1671 | if (dd->isIndexDropEnabled(qq->rootIndex())
| 0 | ||||||||||||||||||||||||
1672 | event->accept(); | - | ||||||||||||||||||||||||
1673 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1674 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1675 | } | - | ||||||||||||||||||||||||
1676 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1677 | dd->dropIndicatorRect = QRect(); | - | ||||||||||||||||||||||||
1678 | dd->dropIndicatorPosition = QAbstractItemView::OnViewport; | - | ||||||||||||||||||||||||
1679 | if (dd->isIndexDropEnabled(qq->rootIndex())
| 0 | ||||||||||||||||||||||||
1680 | event->accept(); | - | ||||||||||||||||||||||||
1681 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1682 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1683 | dd->viewport->update(); | - | ||||||||||||||||||||||||
1684 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1685 | - | |||||||||||||||||||||||||
1686 | if (dd->shouldAutoScroll(event->pos())
| 0 | ||||||||||||||||||||||||
1687 | qq->startAutoScroll(); never executed: qq->startAutoScroll(); | 0 | ||||||||||||||||||||||||
1688 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1689 | bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex) | - | ||||||||||||||||||||||||
1690 | { | - | ||||||||||||||||||||||||
1691 | if (event->isAccepted()
| 0 | ||||||||||||||||||||||||
1692 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1693 | - | |||||||||||||||||||||||||
1694 | QModelIndex index; | - | ||||||||||||||||||||||||
1695 | if (dd->viewport->rect().contains(event->pos())
| 0 | ||||||||||||||||||||||||
1696 | - | |||||||||||||||||||||||||
1697 | QPoint p = event->pos(); | - | ||||||||||||||||||||||||
1698 | QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); | - | ||||||||||||||||||||||||
1699 | rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing()); | - | ||||||||||||||||||||||||
1700 | const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect); | - | ||||||||||||||||||||||||
1701 | index = intersectVector.count() > 0
| 0 | ||||||||||||||||||||||||
1702 | ? intersectVector.last() : QModelIndex(); | - | ||||||||||||||||||||||||
1703 | if (!index.isValid()
| 0 | ||||||||||||||||||||||||
1704 | index = dd->root; never executed: index = dd->root; | 0 | ||||||||||||||||||||||||
1705 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1706 | - | |||||||||||||||||||||||||
1707 | - | |||||||||||||||||||||||||
1708 | if (dd->model->supportedDropActions() & event->dropAction()
| 0 | ||||||||||||||||||||||||
1709 | int row = -1; | - | ||||||||||||||||||||||||
1710 | int col = -1; | - | ||||||||||||||||||||||||
1711 | if (index != dd->root
| 0 | ||||||||||||||||||||||||
1712 | dd->dropIndicatorPosition = position(event->pos(), qq->visualRect(index), index); | - | ||||||||||||||||||||||||
1713 | switch (dd->dropIndicatorPosition) { | - | ||||||||||||||||||||||||
1714 | case never executed: QAbstractItemView::AboveItem:case QAbstractItemView::AboveItem: never executed: case QAbstractItemView::AboveItem: | 0 | ||||||||||||||||||||||||
1715 | row = index.row(); | - | ||||||||||||||||||||||||
1716 | col = index.column(); | - | ||||||||||||||||||||||||
1717 | index = index.parent(); | - | ||||||||||||||||||||||||
1718 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1719 | case never executed: QAbstractItemView::BelowItem:case QAbstractItemView::BelowItem: never executed: case QAbstractItemView::BelowItem: | 0 | ||||||||||||||||||||||||
1720 | row = index.row() + 1; | - | ||||||||||||||||||||||||
1721 | col = index.column(); | - | ||||||||||||||||||||||||
1722 | index = index.parent(); | - | ||||||||||||||||||||||||
1723 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1724 | case never executed: QAbstractItemView::OnItem:case QAbstractItemView::OnItem: never executed: case QAbstractItemView::OnItem: | 0 | ||||||||||||||||||||||||
1725 | case never executed: QAbstractItemView::OnViewport:case QAbstractItemView::OnViewport: never executed: case QAbstractItemView::OnViewport: | 0 | ||||||||||||||||||||||||
1726 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1727 | } | - | ||||||||||||||||||||||||
1728 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1729 | dd->dropIndicatorPosition = QAbstractItemView::OnViewport; | - | ||||||||||||||||||||||||
1730 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1731 | *dropIndex = index; | - | ||||||||||||||||||||||||
1732 | *dropRow = row; | - | ||||||||||||||||||||||||
1733 | *dropCol = col; | - | ||||||||||||||||||||||||
1734 | if (!dd->droppingOnItself(event, index)
| 0 | ||||||||||||||||||||||||
1735 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1736 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1737 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1738 | } | - | ||||||||||||||||||||||||
1739 | - | |||||||||||||||||||||||||
1740 | - | |||||||||||||||||||||||||
1741 | - | |||||||||||||||||||||||||
1742 | void QListModeViewBase::updateVerticalScrollBar(const QSize &step) | - | ||||||||||||||||||||||||
1743 | { | - | ||||||||||||||||||||||||
1744 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
1745 | && ((flow() == QListView::TopToBottom
| 0 | ||||||||||||||||||||||||
1746 | || (flow() == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
1747 | const int steps = (flow() == QListView::TopToBottom
| 0 | ||||||||||||||||||||||||
1748 | if (steps > 0
| 0 | ||||||||||||||||||||||||
1749 | const int pageSteps = perItemScrollingPageSteps(viewport()->height(), contentsSize.height(), isWrapping()); | - | ||||||||||||||||||||||||
1750 | verticalScrollBar()->setSingleStep(1); | - | ||||||||||||||||||||||||
1751 | verticalScrollBar()->setPageStep(pageSteps); | - | ||||||||||||||||||||||||
1752 | verticalScrollBar()->setRange(0, steps - pageSteps); | - | ||||||||||||||||||||||||
1753 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1754 | verticalScrollBar()->setRange(0, 0); | - | ||||||||||||||||||||||||
1755 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1756 | - | |||||||||||||||||||||||||
1757 | - | |||||||||||||||||||||||||
1758 | } else { | - | ||||||||||||||||||||||||
1759 | QCommonListViewBase::updateVerticalScrollBar(step); | - | ||||||||||||||||||||||||
1760 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1761 | } | - | ||||||||||||||||||||||||
1762 | - | |||||||||||||||||||||||||
1763 | void QListModeViewBase::updateHorizontalScrollBar(const QSize &step) | - | ||||||||||||||||||||||||
1764 | { | - | ||||||||||||||||||||||||
1765 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
1766 | && ((flow() == QListView::TopToBottom
| 0 | ||||||||||||||||||||||||
1767 | || (flow() == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
1768 | int steps = (flow() == QListView::TopToBottom
| 0 | ||||||||||||||||||||||||
1769 | if (steps > 0
| 0 | ||||||||||||||||||||||||
1770 | const int pageSteps = perItemScrollingPageSteps(viewport()->width(), contentsSize.width(), isWrapping()); | - | ||||||||||||||||||||||||
1771 | horizontalScrollBar()->setSingleStep(1); | - | ||||||||||||||||||||||||
1772 | horizontalScrollBar()->setPageStep(pageSteps); | - | ||||||||||||||||||||||||
1773 | horizontalScrollBar()->setRange(0, steps - pageSteps); | - | ||||||||||||||||||||||||
1774 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1775 | horizontalScrollBar()->setRange(0, 0); | - | ||||||||||||||||||||||||
1776 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1777 | } else { | - | ||||||||||||||||||||||||
1778 | QCommonListViewBase::updateHorizontalScrollBar(step); | - | ||||||||||||||||||||||||
1779 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1780 | } | - | ||||||||||||||||||||||||
1781 | - | |||||||||||||||||||||||||
1782 | int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hint, | - | ||||||||||||||||||||||||
1783 | bool above, bool below, const QRect &area, const QRect &rect) const | - | ||||||||||||||||||||||||
1784 | { | - | ||||||||||||||||||||||||
1785 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
1786 | int value; | - | ||||||||||||||||||||||||
1787 | if (scrollValueMap.isEmpty()
| 0 | ||||||||||||||||||||||||
1788 | value = 0; | - | ||||||||||||||||||||||||
1789 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1790 | int scrollBarValue = verticalScrollBar()->value(); | - | ||||||||||||||||||||||||
1791 | int numHidden = 0; | - | ||||||||||||||||||||||||
1792 | for (int i = 0; i < flowPositions.count() - 1
| 0 | ||||||||||||||||||||||||
1793 | if (isHidden(i)
| 0 | ||||||||||||||||||||||||
1794 | ++ never executed: numHidden;++numHidden; never executed: ++numHidden; | 0 | ||||||||||||||||||||||||
1795 | value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()) - numHidden, flowPositions.count() - 1); | - | ||||||||||||||||||||||||
1796 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1797 | if (above
| 0 | ||||||||||||||||||||||||
1798 | hint = QListView::PositionAtTop; never executed: hint = QListView::PositionAtTop; | 0 | ||||||||||||||||||||||||
1799 | else if (below
| 0 | ||||||||||||||||||||||||
1800 | hint = QListView::PositionAtBottom; never executed: hint = QListView::PositionAtBottom; | 0 | ||||||||||||||||||||||||
1801 | if (hint == QListView::EnsureVisible
| 0 | ||||||||||||||||||||||||
1802 | return never executed: value;return value; never executed: return value; | 0 | ||||||||||||||||||||||||
1803 | - | |||||||||||||||||||||||||
1804 | return never executed: perItemScrollToValue(index, value, area.height(), hint, Qt::Vertical, isWrapping(), rect.height());return perItemScrollToValue(index, value, area.height(), hint, Qt::Vertical, isWrapping(), rect.height()); never executed: return perItemScrollToValue(index, value, area.height(), hint, Qt::Vertical, isWrapping(), rect.height()); | 0 | ||||||||||||||||||||||||
1805 | } | - | ||||||||||||||||||||||||
1806 | - | |||||||||||||||||||||||||
1807 | return never executed: QCommonListViewBase::verticalScrollToValue(index, hint, above, below, area, rect);return QCommonListViewBase::verticalScrollToValue(index, hint, above, below, area, rect); never executed: return QCommonListViewBase::verticalScrollToValue(index, hint, above, below, area, rect); | 0 | ||||||||||||||||||||||||
1808 | } | - | ||||||||||||||||||||||||
1809 | - | |||||||||||||||||||||||||
1810 | int QListModeViewBase::horizontalOffset() const | - | ||||||||||||||||||||||||
1811 | { | - | ||||||||||||||||||||||||
1812 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
1813 | if (isWrapping()
| 0 | ||||||||||||||||||||||||
1814 | if (flow() == QListView::TopToBottom
| 0 | ||||||||||||||||||||||||
1815 | const int max = segmentPositions.count() - 1; | - | ||||||||||||||||||||||||
1816 | int currentValue = qBound(0, horizontalScrollBar()->value(), max); | - | ||||||||||||||||||||||||
1817 | int position = segmentPositions.at(currentValue); | - | ||||||||||||||||||||||||
1818 | int maximumValue = qBound(0, horizontalScrollBar()->maximum(), max); | - | ||||||||||||||||||||||||
1819 | int maximum = segmentPositions.at(maximumValue); | - | ||||||||||||||||||||||||
1820 | return never executed: (isRightToLeft()return (isRightToLeft() ? maximum - position : position);
never executed: return (isRightToLeft() ? maximum - position : position); | 0 | ||||||||||||||||||||||||
1821 | } | - | ||||||||||||||||||||||||
1822 | } never executed: else if (flow() == QListView::LeftToRightend of block
| 0 | ||||||||||||||||||||||||
1823 | int position = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->value())); | - | ||||||||||||||||||||||||
1824 | int maximum = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->maximum())); | - | ||||||||||||||||||||||||
1825 | return never executed: (isRightToLeft()return (isRightToLeft() ? maximum - position : position);
never executed: return (isRightToLeft() ? maximum - position : position); | 0 | ||||||||||||||||||||||||
1826 | } | - | ||||||||||||||||||||||||
1827 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1828 | return never executed: QCommonListViewBase::horizontalOffset();return QCommonListViewBase::horizontalOffset(); never executed: return QCommonListViewBase::horizontalOffset(); | 0 | ||||||||||||||||||||||||
1829 | } | - | ||||||||||||||||||||||||
1830 | - | |||||||||||||||||||||||||
1831 | int QListModeViewBase::verticalOffset() const | - | ||||||||||||||||||||||||
1832 | { | - | ||||||||||||||||||||||||
1833 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
1834 | if (isWrapping()
| 0 | ||||||||||||||||||||||||
1835 | if (flow() == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
1836 | int value = verticalScrollBar()->value(); | - | ||||||||||||||||||||||||
1837 | if (value >= segmentPositions.count()
| 0 | ||||||||||||||||||||||||
1838 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1839 | return never executed: segmentPositions.at(value) - spacing();return segmentPositions.at(value) - spacing(); never executed: return segmentPositions.at(value) - spacing(); | 0 | ||||||||||||||||||||||||
1840 | } | - | ||||||||||||||||||||||||
1841 | } never executed: else if (flow() == QListView::TopToBottomend of block
| 0 | ||||||||||||||||||||||||
1842 | int value = verticalScrollBar()->value(); | - | ||||||||||||||||||||||||
1843 | if (value > scrollValueMap.count()
| 0 | ||||||||||||||||||||||||
1844 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1845 | return never executed: flowPositions.at(scrollValueMap.at(value)) - spacing();return flowPositions.at(scrollValueMap.at(value)) - spacing(); never executed: return flowPositions.at(scrollValueMap.at(value)) - spacing(); | 0 | ||||||||||||||||||||||||
1846 | } | - | ||||||||||||||||||||||||
1847 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1848 | return never executed: QCommonListViewBase::verticalOffset();return QCommonListViewBase::verticalOffset(); never executed: return QCommonListViewBase::verticalOffset(); | 0 | ||||||||||||||||||||||||
1849 | } | - | ||||||||||||||||||||||||
1850 | - | |||||||||||||||||||||||||
1851 | int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint hint, | - | ||||||||||||||||||||||||
1852 | bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const | - | ||||||||||||||||||||||||
1853 | { | - | ||||||||||||||||||||||||
1854 | if (horizontalScrollMode() != QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
1855 | return never executed: QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect);return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect); never executed: return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect); | 0 | ||||||||||||||||||||||||
1856 | - | |||||||||||||||||||||||||
1857 | int value; | - | ||||||||||||||||||||||||
1858 | if (scrollValueMap.isEmpty()
| 0 | ||||||||||||||||||||||||
1859 | value = 0; never executed: value = 0; | 0 | ||||||||||||||||||||||||
1860 | else | - | ||||||||||||||||||||||||
1861 | value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1); never executed: value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1); | 0 | ||||||||||||||||||||||||
1862 | if (leftOf
| 0 | ||||||||||||||||||||||||
1863 | hint = QListView::PositionAtTop; never executed: hint = QListView::PositionAtTop; | 0 | ||||||||||||||||||||||||
1864 | else if (rightOf
| 0 | ||||||||||||||||||||||||
1865 | hint = QListView::PositionAtBottom; never executed: hint = QListView::PositionAtBottom; | 0 | ||||||||||||||||||||||||
1866 | if (hint == QListView::EnsureVisible
| 0 | ||||||||||||||||||||||||
1867 | return never executed: value;return value; never executed: return value; | 0 | ||||||||||||||||||||||||
1868 | - | |||||||||||||||||||||||||
1869 | return never executed: perItemScrollToValue(index, value, area.width(), hint, Qt::Horizontal, isWrapping(), rect.width());return perItemScrollToValue(index, value, area.width(), hint, Qt::Horizontal, isWrapping(), rect.width()); never executed: return perItemScrollToValue(index, value, area.width(), hint, Qt::Horizontal, isWrapping(), rect.width()); | 0 | ||||||||||||||||||||||||
1870 | } | - | ||||||||||||||||||||||||
1871 | - | |||||||||||||||||||||||||
1872 | void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand) | - | ||||||||||||||||||||||||
1873 | { | - | ||||||||||||||||||||||||
1874 | - | |||||||||||||||||||||||||
1875 | const int verticalValue = verticalScrollBar()->value(); | - | ||||||||||||||||||||||||
1876 | const int horizontalValue = horizontalScrollBar()->value(); | - | ||||||||||||||||||||||||
1877 | const bool vertical = (verticalScrollMode() == QAbstractItemView::ScrollPerItem); | - | ||||||||||||||||||||||||
1878 | const bool horizontal = (horizontalScrollMode() == QAbstractItemView::ScrollPerItem); | - | ||||||||||||||||||||||||
1879 | - | |||||||||||||||||||||||||
1880 | if (isWrapping()
| 0 | ||||||||||||||||||||||||
1881 | if (segmentPositions.isEmpty()
| 0 | ||||||||||||||||||||||||
1882 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1883 | const int max = segmentPositions.count() - 1; | - | ||||||||||||||||||||||||
1884 | if (horizontal
| 0 | ||||||||||||||||||||||||
1885 | int currentValue = qBound(0, horizontalValue, max); | - | ||||||||||||||||||||||||
1886 | int previousValue = qBound(0, currentValue + dx, max); | - | ||||||||||||||||||||||||
1887 | int currentCoordinate = segmentPositions.at(currentValue) - spacing(); | - | ||||||||||||||||||||||||
1888 | int previousCoordinate = segmentPositions.at(previousValue) - spacing(); | - | ||||||||||||||||||||||||
1889 | dx = previousCoordinate - currentCoordinate; | - | ||||||||||||||||||||||||
1890 | } never executed: else if (verticalend of block
| 0 | ||||||||||||||||||||||||
1891 | int currentValue = qBound(0, verticalValue, max); | - | ||||||||||||||||||||||||
1892 | int previousValue = qBound(0, currentValue + dy, max); | - | ||||||||||||||||||||||||
1893 | int currentCoordinate = segmentPositions.at(currentValue) - spacing(); | - | ||||||||||||||||||||||||
1894 | int previousCoordinate = segmentPositions.at(previousValue) - spacing(); | - | ||||||||||||||||||||||||
1895 | dy = previousCoordinate - currentCoordinate; | - | ||||||||||||||||||||||||
1896 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1897 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1898 | if (flowPositions.isEmpty()
| 0 | ||||||||||||||||||||||||
1899 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1900 | const int max = scrollValueMap.count() - 1; | - | ||||||||||||||||||||||||
1901 | if (vertical
| 0 | ||||||||||||||||||||||||
1902 | int currentValue = qBound(0, verticalValue, max); | - | ||||||||||||||||||||||||
1903 | int previousValue = qBound(0, currentValue + dy, max); | - | ||||||||||||||||||||||||
1904 | int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue)); | - | ||||||||||||||||||||||||
1905 | int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue)); | - | ||||||||||||||||||||||||
1906 | dy = previousCoordinate - currentCoordinate; | - | ||||||||||||||||||||||||
1907 | } never executed: else if (horizontalend of block
| 0 | ||||||||||||||||||||||||
1908 | int currentValue = qBound(0, horizontalValue, max); | - | ||||||||||||||||||||||||
1909 | int previousValue = qBound(0, currentValue + dx, max); | - | ||||||||||||||||||||||||
1910 | int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue)); | - | ||||||||||||||||||||||||
1911 | int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue)); | - | ||||||||||||||||||||||||
1912 | dx = previousCoordinate - currentCoordinate; | - | ||||||||||||||||||||||||
1913 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1914 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1915 | QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand); | - | ||||||||||||||||||||||||
1916 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1917 | - | |||||||||||||||||||||||||
1918 | bool QListModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max) | - | ||||||||||||||||||||||||
1919 | { | - | ||||||||||||||||||||||||
1920 | doStaticLayout(info); | - | ||||||||||||||||||||||||
1921 | if (batchStartRow > max
| 0 | ||||||||||||||||||||||||
1922 | flowPositions.resize(flowPositions.count()); | - | ||||||||||||||||||||||||
1923 | segmentPositions.resize(segmentPositions.count()); | - | ||||||||||||||||||||||||
1924 | segmentStartRows.resize(segmentStartRows.count()); | - | ||||||||||||||||||||||||
1925 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1926 | } | - | ||||||||||||||||||||||||
1927 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1928 | } | - | ||||||||||||||||||||||||
1929 | - | |||||||||||||||||||||||||
1930 | QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) const | - | ||||||||||||||||||||||||
1931 | { | - | ||||||||||||||||||||||||
1932 | if (flowPositions.isEmpty()
| 0 | ||||||||||||||||||||||||
1933 | || segmentPositions.isEmpty()
| 0 | ||||||||||||||||||||||||
1934 | || index.row() >= flowPositions.count()
| 0 | ||||||||||||||||||||||||
1935 | return never executed: QListViewItem();return QListViewItem(); never executed: return QListViewItem(); | 0 | ||||||||||||||||||||||||
1936 | - | |||||||||||||||||||||||||
1937 | const int segment = qBinarySearch<int>(segmentStartRows, index.row(), | - | ||||||||||||||||||||||||
1938 | 0, segmentStartRows.count() - 1); | - | ||||||||||||||||||||||||
1939 | - | |||||||||||||||||||||||||
1940 | - | |||||||||||||||||||||||||
1941 | QStyleOptionViewItem options = viewOptions(); | - | ||||||||||||||||||||||||
1942 | options.rect.setSize(contentsSize); | - | ||||||||||||||||||||||||
1943 | QSize size = (uniformItemSizes()
| 0 | ||||||||||||||||||||||||
1944 | ? cachedItemSize() : itemSize(options, index); | - | ||||||||||||||||||||||||
1945 | - | |||||||||||||||||||||||||
1946 | QPoint pos; | - | ||||||||||||||||||||||||
1947 | if (flow() == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
1948 | pos.setX(flowPositions.at(index.row())); | - | ||||||||||||||||||||||||
1949 | pos.setY(segmentPositions.at(segment)); | - | ||||||||||||||||||||||||
1950 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1951 | pos.setY(flowPositions.at(index.row())); | - | ||||||||||||||||||||||||
1952 | pos.setX(segmentPositions.at(segment)); | - | ||||||||||||||||||||||||
1953 | if (isWrapping()
| 0 | ||||||||||||||||||||||||
1954 | int right = (segment + 1 >= segmentPositions.count()
| 0 | ||||||||||||||||||||||||
1955 | ? contentsSize.width() | - | ||||||||||||||||||||||||
1956 | : segmentPositions.at(segment + 1)); | - | ||||||||||||||||||||||||
1957 | size.setWidth(right - pos.x()); | - | ||||||||||||||||||||||||
1958 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1959 | size.setWidth(qMax(size.width(), viewport()->width() - 2 * spacing())); | - | ||||||||||||||||||||||||
1960 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1961 | } | - | ||||||||||||||||||||||||
1962 | - | |||||||||||||||||||||||||
1963 | return never executed: QListViewItem(QRect(pos, size), index.row());return QListViewItem(QRect(pos, size), index.row()); never executed: return QListViewItem(QRect(pos, size), index.row()); | 0 | ||||||||||||||||||||||||
1964 | } | - | ||||||||||||||||||||||||
1965 | - | |||||||||||||||||||||||||
1966 | QPoint QListModeViewBase::initStaticLayout(const QListViewLayoutInfo &info) | - | ||||||||||||||||||||||||
1967 | { | - | ||||||||||||||||||||||||
1968 | int x, y; | - | ||||||||||||||||||||||||
1969 | if (info.first == 0
| 0 | ||||||||||||||||||||||||
1970 | flowPositions.clear(); | - | ||||||||||||||||||||||||
1971 | segmentPositions.clear(); | - | ||||||||||||||||||||||||
1972 | segmentStartRows.clear(); | - | ||||||||||||||||||||||||
1973 | segmentExtents.clear(); | - | ||||||||||||||||||||||||
1974 | scrollValueMap.clear(); | - | ||||||||||||||||||||||||
1975 | x = info.bounds.left() + info.spacing; | - | ||||||||||||||||||||||||
1976 | y = info.bounds.top() + info.spacing; | - | ||||||||||||||||||||||||
1977 | segmentPositions.append(info.flow == QListView::LeftToRight ? y : x); | - | ||||||||||||||||||||||||
1978 | segmentStartRows.append(0); | - | ||||||||||||||||||||||||
1979 | } never executed: else if (info.wrapend of block
| 0 | ||||||||||||||||||||||||
1980 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
1981 | x = batchSavedPosition; | - | ||||||||||||||||||||||||
1982 | y = segmentPositions.last(); | - | ||||||||||||||||||||||||
1983 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1984 | x = segmentPositions.last(); | - | ||||||||||||||||||||||||
1985 | y = batchSavedPosition; | - | ||||||||||||||||||||||||
1986 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1987 | } else { | - | ||||||||||||||||||||||||
1988 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
1989 | x = batchSavedPosition; | - | ||||||||||||||||||||||||
1990 | y = info.bounds.top() + info.spacing; | - | ||||||||||||||||||||||||
1991 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1992 | x = info.bounds.left() + info.spacing; | - | ||||||||||||||||||||||||
1993 | y = batchSavedPosition; | - | ||||||||||||||||||||||||
1994 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1995 | } | - | ||||||||||||||||||||||||
1996 | return never executed: QPoint(x, y);return QPoint(x, y); never executed: return QPoint(x, y); | 0 | ||||||||||||||||||||||||
1997 | } | - | ||||||||||||||||||||||||
1998 | - | |||||||||||||||||||||||||
1999 | - | |||||||||||||||||||||||||
2000 | - | |||||||||||||||||||||||||
2001 | - | |||||||||||||||||||||||||
2002 | void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info) | - | ||||||||||||||||||||||||
2003 | { | - | ||||||||||||||||||||||||
2004 | const bool useItemSize = !info.grid.isValid(); | - | ||||||||||||||||||||||||
2005 | const QPoint topLeft = initStaticLayout(info); | - | ||||||||||||||||||||||||
2006 | QStyleOptionViewItem option = viewOptions(); | - | ||||||||||||||||||||||||
2007 | option.rect = info.bounds; | - | ||||||||||||||||||||||||
2008 | option.rect.adjust(info.spacing, info.spacing, -info.spacing, -info.spacing); | - | ||||||||||||||||||||||||
2009 | - | |||||||||||||||||||||||||
2010 | - | |||||||||||||||||||||||||
2011 | - | |||||||||||||||||||||||||
2012 | - | |||||||||||||||||||||||||
2013 | - | |||||||||||||||||||||||||
2014 | - | |||||||||||||||||||||||||
2015 | - | |||||||||||||||||||||||||
2016 | int segStartPosition; | - | ||||||||||||||||||||||||
2017 | int segEndPosition; | - | ||||||||||||||||||||||||
2018 | int deltaFlowPosition; | - | ||||||||||||||||||||||||
2019 | int deltaSegPosition; | - | ||||||||||||||||||||||||
2020 | int deltaSegHint; | - | ||||||||||||||||||||||||
2021 | int flowPosition; | - | ||||||||||||||||||||||||
2022 | int segPosition; | - | ||||||||||||||||||||||||
2023 | - | |||||||||||||||||||||||||
2024 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2025 | segStartPosition = info.bounds.left(); | - | ||||||||||||||||||||||||
2026 | segEndPosition = info.bounds.width(); | - | ||||||||||||||||||||||||
2027 | flowPosition = topLeft.x(); | - | ||||||||||||||||||||||||
2028 | segPosition = topLeft.y(); | - | ||||||||||||||||||||||||
2029 | deltaFlowPosition = info.grid.width(); | - | ||||||||||||||||||||||||
2030 | deltaSegPosition = useItemSize
| 0 | ||||||||||||||||||||||||
2031 | deltaSegHint = info.grid.height(); | - | ||||||||||||||||||||||||
2032 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2033 | segStartPosition = info.bounds.top(); | - | ||||||||||||||||||||||||
2034 | segEndPosition = info.bounds.height(); | - | ||||||||||||||||||||||||
2035 | flowPosition = topLeft.y(); | - | ||||||||||||||||||||||||
2036 | segPosition = topLeft.x(); | - | ||||||||||||||||||||||||
2037 | deltaFlowPosition = info.grid.height(); | - | ||||||||||||||||||||||||
2038 | deltaSegPosition = useItemSize
| 0 | ||||||||||||||||||||||||
2039 | deltaSegHint = info.grid.width(); | - | ||||||||||||||||||||||||
2040 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2041 | - | |||||||||||||||||||||||||
2042 | for (int row = info.first; row <= info.last
| 0 | ||||||||||||||||||||||||
2043 | if (isHidden(row)
| 0 | ||||||||||||||||||||||||
2044 | flowPositions.append(flowPosition); | - | ||||||||||||||||||||||||
2045 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2046 | - | |||||||||||||||||||||||||
2047 | if (useItemSize
| 0 | ||||||||||||||||||||||||
2048 | QSize hint = itemSize(option, modelIndex(row)); | - | ||||||||||||||||||||||||
2049 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2050 | deltaFlowPosition = hint.width() + info.spacing; | - | ||||||||||||||||||||||||
2051 | deltaSegHint = hint.height() + info.spacing; | - | ||||||||||||||||||||||||
2052 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2053 | deltaFlowPosition = hint.height() + info.spacing; | - | ||||||||||||||||||||||||
2054 | deltaSegHint = hint.width() + info.spacing; | - | ||||||||||||||||||||||||
2055 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2056 | } | - | ||||||||||||||||||||||||
2057 | - | |||||||||||||||||||||||||
2058 | if (info.wrap
| 0 | ||||||||||||||||||||||||
2059 | segmentExtents.append(flowPosition); | - | ||||||||||||||||||||||||
2060 | flowPosition = info.spacing + segStartPosition; | - | ||||||||||||||||||||||||
2061 | segPosition += deltaSegPosition; | - | ||||||||||||||||||||||||
2062 | if (info.wrap
| 0 | ||||||||||||||||||||||||
2063 | segPosition += info.spacing; never executed: segPosition += info.spacing; | 0 | ||||||||||||||||||||||||
2064 | segmentPositions.append(segPosition); | - | ||||||||||||||||||||||||
2065 | segmentStartRows.append(row); | - | ||||||||||||||||||||||||
2066 | deltaSegPosition = 0; | - | ||||||||||||||||||||||||
2067 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2068 | - | |||||||||||||||||||||||||
2069 | scrollValueMap.append(flowPositions.count()); | - | ||||||||||||||||||||||||
2070 | flowPositions.append(flowPosition); | - | ||||||||||||||||||||||||
2071 | - | |||||||||||||||||||||||||
2072 | deltaSegPosition = qMax(deltaSegHint, deltaSegPosition); | - | ||||||||||||||||||||||||
2073 | flowPosition += info.spacing + deltaFlowPosition; | - | ||||||||||||||||||||||||
2074 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2075 | } | - | ||||||||||||||||||||||||
2076 | - | |||||||||||||||||||||||||
2077 | batchSavedPosition = flowPosition; | - | ||||||||||||||||||||||||
2078 | batchSavedDeltaSeg = deltaSegPosition; | - | ||||||||||||||||||||||||
2079 | batchStartRow = info.last + 1; | - | ||||||||||||||||||||||||
2080 | if (info.last == info.max
| 0 | ||||||||||||||||||||||||
2081 | flowPosition -= info.spacing; never executed: flowPosition -= info.spacing; | 0 | ||||||||||||||||||||||||
2082 | - | |||||||||||||||||||||||||
2083 | QRect rect = info.bounds; | - | ||||||||||||||||||||||||
2084 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2085 | rect.setRight(segmentPositions.count() == 1 ? flowPosition : info.bounds.right()); | - | ||||||||||||||||||||||||
2086 | rect.setBottom(segPosition + deltaSegPosition); | - | ||||||||||||||||||||||||
2087 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2088 | rect.setRight(segPosition + deltaSegPosition); | - | ||||||||||||||||||||||||
2089 | rect.setBottom(segmentPositions.count() == 1 ? flowPosition : info.bounds.bottom()); | - | ||||||||||||||||||||||||
2090 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2091 | contentsSize = QSize(rect.right(), rect.bottom()); | - | ||||||||||||||||||||||||
2092 | - | |||||||||||||||||||||||||
2093 | if (info.last == info.max
| 0 | ||||||||||||||||||||||||
2094 | segmentExtents.append(flowPosition); | - | ||||||||||||||||||||||||
2095 | scrollValueMap.append(flowPositions.count()); | - | ||||||||||||||||||||||||
2096 | flowPositions.append(flowPosition); | - | ||||||||||||||||||||||||
2097 | segmentPositions.append(info.wrap ? segPosition + deltaSegPosition : 2147483647); | - | ||||||||||||||||||||||||
2098 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2099 | - | |||||||||||||||||||||||||
2100 | QRect changedRect(topLeft, rect.bottomRight()); | - | ||||||||||||||||||||||||
2101 | if (clipRect().intersects(changedRect)
| 0 | ||||||||||||||||||||||||
2102 | viewport()->update(); never executed: viewport()->update(); | 0 | ||||||||||||||||||||||||
2103 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2104 | - | |||||||||||||||||||||||||
2105 | - | |||||||||||||||||||||||||
2106 | - | |||||||||||||||||||||||||
2107 | - | |||||||||||||||||||||||||
2108 | - | |||||||||||||||||||||||||
2109 | - | |||||||||||||||||||||||||
2110 | QVector<QModelIndex> QListModeViewBase::intersectingSet(const QRect &area) const | - | ||||||||||||||||||||||||
2111 | { | - | ||||||||||||||||||||||||
2112 | QVector<QModelIndex> ret; | - | ||||||||||||||||||||||||
2113 | int segStartPosition; | - | ||||||||||||||||||||||||
2114 | int segEndPosition; | - | ||||||||||||||||||||||||
2115 | int flowStartPosition; | - | ||||||||||||||||||||||||
2116 | int flowEndPosition; | - | ||||||||||||||||||||||||
2117 | if (flow() == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2118 | segStartPosition = area.top(); | - | ||||||||||||||||||||||||
2119 | segEndPosition = area.bottom(); | - | ||||||||||||||||||||||||
2120 | flowStartPosition = area.left(); | - | ||||||||||||||||||||||||
2121 | flowEndPosition = area.right(); | - | ||||||||||||||||||||||||
2122 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2123 | segStartPosition = area.left(); | - | ||||||||||||||||||||||||
2124 | segEndPosition = area.right(); | - | ||||||||||||||||||||||||
2125 | flowStartPosition = area.top(); | - | ||||||||||||||||||||||||
2126 | flowEndPosition = area.bottom(); | - | ||||||||||||||||||||||||
2127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2128 | if (segmentPositions.count() < 2
| 0 | ||||||||||||||||||||||||
2129 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
2130 | - | |||||||||||||||||||||||||
2131 | const int segLast = segmentPositions.count() - 2; | - | ||||||||||||||||||||||||
2132 | int seg = qBinarySearch<int>(segmentPositions, segStartPosition, 0, segLast + 1); | - | ||||||||||||||||||||||||
2133 | for (; seg <= segLast
| 0 | ||||||||||||||||||||||||
2134 | int first = segmentStartRows.at(seg); | - | ||||||||||||||||||||||||
2135 | int last = (seg < segLast
| 0 | ||||||||||||||||||||||||
2136 | if (segmentExtents.at(seg) < flowStartPosition
| 0 | ||||||||||||||||||||||||
2137 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2138 | int row = qBinarySearch<int>(flowPositions, flowStartPosition, first, last); | - | ||||||||||||||||||||||||
2139 | for (; row <= last
| 0 | ||||||||||||||||||||||||
2140 | if (isHidden(row)
| 0 | ||||||||||||||||||||||||
2141 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2142 | QModelIndex index = modelIndex(row); | - | ||||||||||||||||||||||||
2143 | if (index.isValid()
| 0 | ||||||||||||||||||||||||
2144 | ret += index; never executed: ret += index; | 0 | ||||||||||||||||||||||||
2145 | - | |||||||||||||||||||||||||
2146 | - | |||||||||||||||||||||||||
2147 | - | |||||||||||||||||||||||||
2148 | - | |||||||||||||||||||||||||
2149 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2150 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2151 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
2152 | } | - | ||||||||||||||||||||||||
2153 | - | |||||||||||||||||||||||||
2154 | void QListModeViewBase::dataChanged(const QModelIndex &, const QModelIndex &) | - | ||||||||||||||||||||||||
2155 | { | - | ||||||||||||||||||||||||
2156 | dd->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
2157 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2158 | - | |||||||||||||||||||||||||
2159 | - | |||||||||||||||||||||||||
2160 | QRect QListModeViewBase::mapToViewport(const QRect &rect) const | - | ||||||||||||||||||||||||
2161 | { | - | ||||||||||||||||||||||||
2162 | if (isWrapping()
| 0 | ||||||||||||||||||||||||
2163 | return never executed: rect;return rect; never executed: return rect; | 0 | ||||||||||||||||||||||||
2164 | - | |||||||||||||||||||||||||
2165 | - | |||||||||||||||||||||||||
2166 | QRect result = rect; | - | ||||||||||||||||||||||||
2167 | if (flow() == QListView::TopToBottom
| 0 | ||||||||||||||||||||||||
2168 | result.setLeft(spacing()); | - | ||||||||||||||||||||||||
2169 | result.setWidth(qMax(rect.width(), qMax(contentsSize.width(), viewport()->width()) - 2 * spacing())); | - | ||||||||||||||||||||||||
2170 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2171 | result.setTop(spacing()); | - | ||||||||||||||||||||||||
2172 | result.setHeight(qMax(rect.height(), qMax(contentsSize.height(), viewport()->height()) - 2 * spacing())); | - | ||||||||||||||||||||||||
2173 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2174 | return never executed: result;return result; never executed: return result; | 0 | ||||||||||||||||||||||||
2175 | } | - | ||||||||||||||||||||||||
2176 | - | |||||||||||||||||||||||||
2177 | int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wrap) const | - | ||||||||||||||||||||||||
2178 | { | - | ||||||||||||||||||||||||
2179 | QVector<int> positions; | - | ||||||||||||||||||||||||
2180 | if (wrap
| 0 | ||||||||||||||||||||||||
2181 | positions = segmentPositions; never executed: positions = segmentPositions; | 0 | ||||||||||||||||||||||||
2182 | else if (!flowPositions.isEmpty()
| 0 | ||||||||||||||||||||||||
2183 | positions.reserve(scrollValueMap.size()); | - | ||||||||||||||||||||||||
2184 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(scrollValueMap)>::type> _container_((scrollValueMap)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (int itemShown = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
2185 | positions.append(flowPositions.at(itemShown)); never executed: positions.append(flowPositions.at(itemShown)); | 0 | ||||||||||||||||||||||||
2186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2187 | if (positions.isEmpty()
| 0 | ||||||||||||||||||||||||
2188 | return never executed: positions.count();return positions.count(); never executed: return positions.count(); | 0 | ||||||||||||||||||||||||
2189 | if (uniformItemSizes()
| 0 | ||||||||||||||||||||||||
2190 | for (int i = 1; i < positions.count()
| 0 | ||||||||||||||||||||||||
2191 | if (positions.at(i) > 0
| 0 | ||||||||||||||||||||||||
2192 | return never executed: length / positions.at(i);return length / positions.at(i); never executed: return length / positions.at(i); | 0 | ||||||||||||||||||||||||
2193 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2194 | } | - | ||||||||||||||||||||||||
2195 | int pageSteps = 0; | - | ||||||||||||||||||||||||
2196 | int steps = positions.count() - 1; | - | ||||||||||||||||||||||||
2197 | int max = qMax(length, bounds); | - | ||||||||||||||||||||||||
2198 | int min = qMin(length, bounds); | - | ||||||||||||||||||||||||
2199 | int pos = min - (max - positions.last()); | - | ||||||||||||||||||||||||
2200 | - | |||||||||||||||||||||||||
2201 | while (pos >= 0
| 0 | ||||||||||||||||||||||||
2202 | pos -= (positions.at(steps) - positions.at(steps - 1)); | - | ||||||||||||||||||||||||
2203 | if (pos >= 0
| 0 | ||||||||||||||||||||||||
2204 | ++ never executed: pageSteps;++pageSteps; never executed: ++pageSteps; | 0 | ||||||||||||||||||||||||
2205 | --steps; | - | ||||||||||||||||||||||||
2206 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2207 | - | |||||||||||||||||||||||||
2208 | - | |||||||||||||||||||||||||
2209 | return never executed: qMax(pageSteps, 1);return qMax(pageSteps, 1); never executed: return qMax(pageSteps, 1); | 0 | ||||||||||||||||||||||||
2210 | } | - | ||||||||||||||||||||||||
2211 | - | |||||||||||||||||||||||||
2212 | int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int viewportSize, | - | ||||||||||||||||||||||||
2213 | QAbstractItemView::ScrollHint hint, | - | ||||||||||||||||||||||||
2214 | Qt::Orientation orientation, bool wrap, int itemExtent) const | - | ||||||||||||||||||||||||
2215 | { | - | ||||||||||||||||||||||||
2216 | if (index < 0
| 0 | ||||||||||||||||||||||||
2217 | return never executed: scrollValue;return scrollValue; never executed: return scrollValue; | 0 | ||||||||||||||||||||||||
2218 | - | |||||||||||||||||||||||||
2219 | itemExtent += spacing(); | - | ||||||||||||||||||||||||
2220 | QVector<int> visibleFlowPositions; | - | ||||||||||||||||||||||||
2221 | visibleFlowPositions.reserve(flowPositions.count() - 1); | - | ||||||||||||||||||||||||
2222 | for (int i = 0; i < flowPositions.count() - 1
| 0 | ||||||||||||||||||||||||
2223 | if (!isHidden(i)
| 0 | ||||||||||||||||||||||||
2224 | visibleFlowPositions.append(flowPositions.at(i)); never executed: visibleFlowPositions.append(flowPositions.at(i)); | 0 | ||||||||||||||||||||||||
2225 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2226 | - | |||||||||||||||||||||||||
2227 | if (!wrap
| 0 | ||||||||||||||||||||||||
2228 | int topIndex = index; | - | ||||||||||||||||||||||||
2229 | const int bottomIndex = topIndex; | - | ||||||||||||||||||||||||
2230 | const int bottomCoordinate = visibleFlowPositions.at(index); | - | ||||||||||||||||||||||||
2231 | - | |||||||||||||||||||||||||
2232 | while (topIndex > 0
| 0 | ||||||||||||||||||||||||
2233 | (
| 0 | ||||||||||||||||||||||||
2234 | topIndex--; | - | ||||||||||||||||||||||||
2235 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2236 | - | |||||||||||||||||||||||||
2237 | const int itemCount = bottomIndex - topIndex + 1; | - | ||||||||||||||||||||||||
2238 | switch (hint) { | - | ||||||||||||||||||||||||
2239 | case never executed: QAbstractItemView::PositionAtTop:case QAbstractItemView::PositionAtTop: never executed: case QAbstractItemView::PositionAtTop: | 0 | ||||||||||||||||||||||||
2240 | return never executed: index;return index; never executed: return index; | 0 | ||||||||||||||||||||||||
2241 | case never executed: QAbstractItemView::PositionAtBottom:case QAbstractItemView::PositionAtBottom: never executed: case QAbstractItemView::PositionAtBottom: | 0 | ||||||||||||||||||||||||
2242 | return never executed: index - itemCount + 1;return index - itemCount + 1; never executed: return index - itemCount + 1; | 0 | ||||||||||||||||||||||||
2243 | case never executed: QAbstractItemView::PositionAtCenter:case QAbstractItemView::PositionAtCenter: never executed: case QAbstractItemView::PositionAtCenter: | 0 | ||||||||||||||||||||||||
2244 | return never executed: index - (itemCount / 2);return index - (itemCount / 2); never executed: return index - (itemCount / 2); | 0 | ||||||||||||||||||||||||
2245 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
2246 | break; never executed: break; | 0 | ||||||||||||||||||||||||
2247 | } | - | ||||||||||||||||||||||||
2248 | } else { | - | ||||||||||||||||||||||||
2249 | Qt::Orientation flowOrientation = (flow() == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2250 | ? Qt::Horizontal : Qt::Vertical); | - | ||||||||||||||||||||||||
2251 | if (flowOrientation == orientation
| 0 | ||||||||||||||||||||||||
2252 | - | |||||||||||||||||||||||||
2253 | return never executed: visibleFlowPositions.at(index);return visibleFlowPositions.at(index); never executed: return visibleFlowPositions.at(index); | 0 | ||||||||||||||||||||||||
2254 | } else if (!segmentStartRows.isEmpty()
| 0 | ||||||||||||||||||||||||
2255 | int segment = qBinarySearch<int>(segmentStartRows, index, 0, segmentStartRows.count() - 1); | - | ||||||||||||||||||||||||
2256 | int leftSegment = segment; | - | ||||||||||||||||||||||||
2257 | const int rightSegment = leftSegment; | - | ||||||||||||||||||||||||
2258 | const int bottomCoordinate = segmentPositions.at(segment); | - | ||||||||||||||||||||||||
2259 | - | |||||||||||||||||||||||||
2260 | while (leftSegment > scrollValue
| 0 | ||||||||||||||||||||||||
2261 | (
| 0 | ||||||||||||||||||||||||
2262 | leftSegment--; | - | ||||||||||||||||||||||||
2263 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2264 | - | |||||||||||||||||||||||||
2265 | const int segmentCount = rightSegment - leftSegment + 1; | - | ||||||||||||||||||||||||
2266 | switch (hint) { | - | ||||||||||||||||||||||||
2267 | case never executed: QAbstractItemView::PositionAtTop:case QAbstractItemView::PositionAtTop: never executed: case QAbstractItemView::PositionAtTop: | 0 | ||||||||||||||||||||||||
2268 | return never executed: segment;return segment; never executed: return segment; | 0 | ||||||||||||||||||||||||
2269 | case never executed: QAbstractItemView::PositionAtBottom:case QAbstractItemView::PositionAtBottom: never executed: case QAbstractItemView::PositionAtBottom: | 0 | ||||||||||||||||||||||||
2270 | return never executed: segment - segmentCount + 1;return segment - segmentCount + 1; never executed: return segment - segmentCount + 1; | 0 | ||||||||||||||||||||||||
2271 | case never executed: QAbstractItemView::PositionAtCenter:case QAbstractItemView::PositionAtCenter: never executed: case QAbstractItemView::PositionAtCenter: | 0 | ||||||||||||||||||||||||
2272 | return never executed: segment - (segmentCount / 2);return segment - (segmentCount / 2); never executed: return segment - (segmentCount / 2); | 0 | ||||||||||||||||||||||||
2273 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
2274 | break; never executed: break; | 0 | ||||||||||||||||||||||||
2275 | } | - | ||||||||||||||||||||||||
2276 | } | - | ||||||||||||||||||||||||
2277 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2278 | return never executed: scrollValue;return scrollValue; never executed: return scrollValue; | 0 | ||||||||||||||||||||||||
2279 | } | - | ||||||||||||||||||||||||
2280 | - | |||||||||||||||||||||||||
2281 | void QListModeViewBase::clear() | - | ||||||||||||||||||||||||
2282 | { | - | ||||||||||||||||||||||||
2283 | flowPositions.clear(); | - | ||||||||||||||||||||||||
2284 | segmentPositions.clear(); | - | ||||||||||||||||||||||||
2285 | segmentStartRows.clear(); | - | ||||||||||||||||||||||||
2286 | segmentExtents.clear(); | - | ||||||||||||||||||||||||
2287 | batchSavedPosition = 0; | - | ||||||||||||||||||||||||
2288 | batchStartRow = 0; | - | ||||||||||||||||||||||||
2289 | batchSavedDeltaSeg = 0; | - | ||||||||||||||||||||||||
2290 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2291 | - | |||||||||||||||||||||||||
2292 | - | |||||||||||||||||||||||||
2293 | - | |||||||||||||||||||||||||
2294 | - | |||||||||||||||||||||||||
2295 | - | |||||||||||||||||||||||||
2296 | void QIconModeViewBase::setPositionForIndex(const QPoint &position, const QModelIndex &index) | - | ||||||||||||||||||||||||
2297 | { | - | ||||||||||||||||||||||||
2298 | if (index.row() >= items.count()
| 0 | ||||||||||||||||||||||||
2299 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2300 | const QSize oldContents = contentsSize; | - | ||||||||||||||||||||||||
2301 | qq->update(index); | - | ||||||||||||||||||||||||
2302 | moveItem(index.row(), position); | - | ||||||||||||||||||||||||
2303 | qq->update(index); | - | ||||||||||||||||||||||||
2304 | - | |||||||||||||||||||||||||
2305 | if (contentsSize != oldContents
| 0 | ||||||||||||||||||||||||
2306 | dd->viewUpdateGeometries(); never executed: dd->viewUpdateGeometries(); | 0 | ||||||||||||||||||||||||
2307 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2308 | - | |||||||||||||||||||||||||
2309 | void QIconModeViewBase::appendHiddenRow(int row) | - | ||||||||||||||||||||||||
2310 | { | - | ||||||||||||||||||||||||
2311 | if (row >= 0
| 0 | ||||||||||||||||||||||||
2312 | tree.removeLeaf(items.at(row).rect(), row); never executed: tree.removeLeaf(items.at(row).rect(), row); | 0 | ||||||||||||||||||||||||
2313 | QCommonListViewBase::appendHiddenRow(row); | - | ||||||||||||||||||||||||
2314 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2315 | - | |||||||||||||||||||||||||
2316 | void QIconModeViewBase::removeHiddenRow(int row) | - | ||||||||||||||||||||||||
2317 | { | - | ||||||||||||||||||||||||
2318 | QCommonListViewBase::removeHiddenRow(row); | - | ||||||||||||||||||||||||
2319 | if (row >= 0
| 0 | ||||||||||||||||||||||||
2320 | tree.insertLeaf(items.at(row).rect(), row); never executed: tree.insertLeaf(items.at(row).rect(), row); | 0 | ||||||||||||||||||||||||
2321 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2322 | - | |||||||||||||||||||||||||
2323 | - | |||||||||||||||||||||||||
2324 | bool QIconModeViewBase::filterStartDrag(Qt::DropActions supportedActions) | - | ||||||||||||||||||||||||
2325 | { | - | ||||||||||||||||||||||||
2326 | - | |||||||||||||||||||||||||
2327 | - | |||||||||||||||||||||||||
2328 | - | |||||||||||||||||||||||||
2329 | QModelIndexList indexes = dd->selectionModel->selectedIndexes(); | - | ||||||||||||||||||||||||
2330 | if (indexes.count() > 0
| 0 | ||||||||||||||||||||||||
2331 | if (viewport()->acceptDrops()
| 0 | ||||||||||||||||||||||||
2332 | QModelIndexList::ConstIterator it = indexes.constBegin(); | - | ||||||||||||||||||||||||
2333 | for (; it != indexes.constEnd()
| 0 | ||||||||||||||||||||||||
2334 | if (dd->model->flags(*it) & Qt::ItemIsDragEnabled
| 0 | ||||||||||||||||||||||||
2335 | && (*
| 0 | ||||||||||||||||||||||||
2336 | draggedItems.push_back(*it); never executed: draggedItems.push_back(*it); | 0 | ||||||||||||||||||||||||
2337 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2338 | - | |||||||||||||||||||||||||
2339 | QRect rect; | - | ||||||||||||||||||||||||
2340 | QPixmap pixmap = dd->renderToPixmap(indexes, &rect); | - | ||||||||||||||||||||||||
2341 | rect.adjust(horizontalOffset(), verticalOffset(), 0, 0); | - | ||||||||||||||||||||||||
2342 | QDrag *drag = new QDrag(qq); | - | ||||||||||||||||||||||||
2343 | drag->setMimeData(dd->model->mimeData(indexes)); | - | ||||||||||||||||||||||||
2344 | drag->setPixmap(pixmap); | - | ||||||||||||||||||||||||
2345 | drag->setHotSpot(dd->pressedPosition - rect.topLeft()); | - | ||||||||||||||||||||||||
2346 | Qt::DropAction action = drag->exec(supportedActions, dd->defaultDropAction); | - | ||||||||||||||||||||||||
2347 | draggedItems.clear(); | - | ||||||||||||||||||||||||
2348 | if (action == Qt::MoveAction
| 0 | ||||||||||||||||||||||||
2349 | dd->clearOrRemove(); never executed: dd->clearOrRemove(); | 0 | ||||||||||||||||||||||||
2350 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2351 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2352 | } | - | ||||||||||||||||||||||||
2353 | - | |||||||||||||||||||||||||
2354 | bool QIconModeViewBase::filterDropEvent(QDropEvent *e) | - | ||||||||||||||||||||||||
2355 | { | - | ||||||||||||||||||||||||
2356 | if (e->source() != qq
| 0 | ||||||||||||||||||||||||
2357 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2358 | - | |||||||||||||||||||||||||
2359 | const QSize contents = contentsSize; | - | ||||||||||||||||||||||||
2360 | QPoint offset(horizontalOffset(), verticalOffset()); | - | ||||||||||||||||||||||||
2361 | QPoint end = e->pos() + offset; | - | ||||||||||||||||||||||||
2362 | if (qq->acceptDrops()
| 0 | ||||||||||||||||||||||||
2363 | const Qt::ItemFlags dropableFlags = Qt::ItemIsDropEnabled|Qt::ItemIsEnabled; | - | ||||||||||||||||||||||||
2364 | const QVector<QModelIndex> &dropIndices = intersectingSet(QRect(end, QSize(1, 1))); | - | ||||||||||||||||||||||||
2365 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(dropIndices)>::type> _container_((dropIndices)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QModelIndex &index = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
2366 | if ((
| 0 | ||||||||||||||||||||||||
2367 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2368 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2369 | QPoint start = dd->pressedPosition; | - | ||||||||||||||||||||||||
2370 | QPoint delta = (dd->movement == QListView::Snap
| 0 | ||||||||||||||||||||||||
2371 | QList<QModelIndex> indexes = dd->selectionModel->selectedIndexes(); | - | ||||||||||||||||||||||||
2372 | for (int i = 0; i < indexes.count()
| 0 | ||||||||||||||||||||||||
2373 | QModelIndex index = indexes.at(i); | - | ||||||||||||||||||||||||
2374 | QRect rect = dd->rectForIndex(index); | - | ||||||||||||||||||||||||
2375 | viewport()->update(dd->mapToViewport(rect, false)); | - | ||||||||||||||||||||||||
2376 | QPoint dest = rect.topLeft() + delta; | - | ||||||||||||||||||||||||
2377 | if (qq->isRightToLeft()
| 0 | ||||||||||||||||||||||||
2378 | dest.setX(dd->flipX(dest.x()) - rect.width()); never executed: dest.setX(dd->flipX(dest.x()) - rect.width()); | 0 | ||||||||||||||||||||||||
2379 | moveItem(index.row(), dest); | - | ||||||||||||||||||||||||
2380 | qq->update(index); | - | ||||||||||||||||||||||||
2381 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2382 | dd->stopAutoScroll(); | - | ||||||||||||||||||||||||
2383 | draggedItems.clear(); | - | ||||||||||||||||||||||||
2384 | dd->emitIndexesMoved(indexes); | - | ||||||||||||||||||||||||
2385 | e->accept(); | - | ||||||||||||||||||||||||
2386 | - | |||||||||||||||||||||||||
2387 | if (contentsSize != contents
| 0 | ||||||||||||||||||||||||
2388 | if ((contentsSize.width() <= contents.width()
| 0 | ||||||||||||||||||||||||
2389 | || contentsSize.height() <= contents.height()
| 0 | ||||||||||||||||||||||||
2390 | updateContentsSize(); | - | ||||||||||||||||||||||||
2391 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2392 | dd->viewUpdateGeometries(); | - | ||||||||||||||||||||||||
2393 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2394 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2395 | } | - | ||||||||||||||||||||||||
2396 | - | |||||||||||||||||||||||||
2397 | bool QIconModeViewBase::filterDragLeaveEvent(QDragLeaveEvent *e) | - | ||||||||||||||||||||||||
2398 | { | - | ||||||||||||||||||||||||
2399 | viewport()->update(draggedItemsRect()); | - | ||||||||||||||||||||||||
2400 | draggedItemsPos = QPoint(-1, -1); | - | ||||||||||||||||||||||||
2401 | return never executed: QCommonListViewBase::filterDragLeaveEvent(e);return QCommonListViewBase::filterDragLeaveEvent(e); never executed: return QCommonListViewBase::filterDragLeaveEvent(e); | 0 | ||||||||||||||||||||||||
2402 | } | - | ||||||||||||||||||||||||
2403 | - | |||||||||||||||||||||||||
2404 | bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e) | - | ||||||||||||||||||||||||
2405 | { | - | ||||||||||||||||||||||||
2406 | if (e->source() != qq
| 0 | ||||||||||||||||||||||||
2407 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2408 | - | |||||||||||||||||||||||||
2409 | - | |||||||||||||||||||||||||
2410 | e->ignore(); | - | ||||||||||||||||||||||||
2411 | - | |||||||||||||||||||||||||
2412 | QRect itemsRect = this->itemsRect(draggedItems); | - | ||||||||||||||||||||||||
2413 | viewport()->update(itemsRect.translated(draggedItemsDelta())); | - | ||||||||||||||||||||||||
2414 | - | |||||||||||||||||||||||||
2415 | draggedItemsPos = e->pos(); | - | ||||||||||||||||||||||||
2416 | - | |||||||||||||||||||||||||
2417 | viewport()->update(itemsRect.translated(draggedItemsDelta())); | - | ||||||||||||||||||||||||
2418 | - | |||||||||||||||||||||||||
2419 | QModelIndex index; | - | ||||||||||||||||||||||||
2420 | if (movement() == QListView::Snap
| 0 | ||||||||||||||||||||||||
2421 | QRect rect(snapToGrid(e->pos() + offset()), gridSize()); | - | ||||||||||||||||||||||||
2422 | const QVector<QModelIndex> intersectVector = intersectingSet(rect); | - | ||||||||||||||||||||||||
2423 | index = intersectVector.count() > 0
| 0 | ||||||||||||||||||||||||
2424 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2425 | index = qq->indexAt(e->pos()); | - | ||||||||||||||||||||||||
2426 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2427 | - | |||||||||||||||||||||||||
2428 | if (draggedItems.contains(index)
| 0 | ||||||||||||||||||||||||
2429 | e->accept(); never executed: e->accept(); | 0 | ||||||||||||||||||||||||
2430 | else if (dd->model->flags(index) & Qt::ItemIsDropEnabled
| 0 | ||||||||||||||||||||||||
2431 | e->accept(); never executed: e->accept(); | 0 | ||||||||||||||||||||||||
2432 | else if (!index.isValid()
| 0 | ||||||||||||||||||||||||
2433 | e->accept(); never executed: e->accept(); | 0 | ||||||||||||||||||||||||
2434 | - | |||||||||||||||||||||||||
2435 | - | |||||||||||||||||||||||||
2436 | if (dd->shouldAutoScroll(e->pos())
| 0 | ||||||||||||||||||||||||
2437 | dd->startAutoScroll(); never executed: dd->startAutoScroll(); | 0 | ||||||||||||||||||||||||
2438 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
2439 | } | - | ||||||||||||||||||||||||
2440 | - | |||||||||||||||||||||||||
2441 | - | |||||||||||||||||||||||||
2442 | void QIconModeViewBase::setRowCount(int rowCount) | - | ||||||||||||||||||||||||
2443 | { | - | ||||||||||||||||||||||||
2444 | tree.create(qMax(rowCount - hiddenCount(), 0)); | - | ||||||||||||||||||||||||
2445 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2446 | - | |||||||||||||||||||||||||
2447 | void QIconModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand) | - | ||||||||||||||||||||||||
2448 | { | - | ||||||||||||||||||||||||
2449 | if (scrollElasticBand
| 0 | ||||||||||||||||||||||||
2450 | dd->scrollElasticBandBy(isRightToLeft() ? -dx : dx, dy); never executed: dd->scrollElasticBandBy(isRightToLeft() ? -dx : dx, dy); | 0 | ||||||||||||||||||||||||
2451 | - | |||||||||||||||||||||||||
2452 | QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand); | - | ||||||||||||||||||||||||
2453 | if (!draggedItems.isEmpty()
| 0 | ||||||||||||||||||||||||
2454 | viewport()->update(draggedItemsRect().translated(dx, dy)); never executed: viewport()->update(draggedItemsRect().translated(dx, dy)); | 0 | ||||||||||||||||||||||||
2455 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2456 | - | |||||||||||||||||||||||||
2457 | void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) | - | ||||||||||||||||||||||||
2458 | { | - | ||||||||||||||||||||||||
2459 | if (column() >= topLeft.column()
| 0 | ||||||||||||||||||||||||
2460 | QStyleOptionViewItem option = viewOptions(); | - | ||||||||||||||||||||||||
2461 | int bottom = qMin(items.count(), bottomRight.row() + 1); | - | ||||||||||||||||||||||||
2462 | for (int row = topLeft.row(); row < bottom
| 0 | ||||||||||||||||||||||||
2463 | items[row].resize(itemSize(option, modelIndex(row))); never executed: items[row].resize(itemSize(option, modelIndex(row))); | 0 | ||||||||||||||||||||||||
2464 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2465 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2466 | - | |||||||||||||||||||||||||
2467 | bool QIconModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max) | - | ||||||||||||||||||||||||
2468 | { | - | ||||||||||||||||||||||||
2469 | if (info.last >= items.count()
| 0 | ||||||||||||||||||||||||
2470 | - | |||||||||||||||||||||||||
2471 | QStyleOptionViewItem option = viewOptions(); | - | ||||||||||||||||||||||||
2472 | for (int row = items.count(); row <= info.last
| 0 | ||||||||||||||||||||||||
2473 | QSize size = itemSize(option, modelIndex(row)); | - | ||||||||||||||||||||||||
2474 | QListViewItem item(QRect(0, 0, size.width(), size.height()), row); | - | ||||||||||||||||||||||||
2475 | items.append(item); | - | ||||||||||||||||||||||||
2476 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2477 | doDynamicLayout(info); | - | ||||||||||||||||||||||||
2478 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2479 | return never executed: (batchStartRow > max);return (batchStartRow > max); never executed: return (batchStartRow > max); | 0 | ||||||||||||||||||||||||
2480 | } | - | ||||||||||||||||||||||||
2481 | - | |||||||||||||||||||||||||
2482 | QListViewItem QIconModeViewBase::indexToListViewItem(const QModelIndex &index) const | - | ||||||||||||||||||||||||
2483 | { | - | ||||||||||||||||||||||||
2484 | if (index.isValid()
| 0 | ||||||||||||||||||||||||
2485 | return never executed: items.at(index.row());return items.at(index.row()); never executed: return items.at(index.row()); | 0 | ||||||||||||||||||||||||
2486 | return never executed: QListViewItem();return QListViewItem(); never executed: return QListViewItem(); | 0 | ||||||||||||||||||||||||
2487 | } | - | ||||||||||||||||||||||||
2488 | - | |||||||||||||||||||||||||
2489 | void QIconModeViewBase::initBspTree(const QSize &contents) | - | ||||||||||||||||||||||||
2490 | { | - | ||||||||||||||||||||||||
2491 | - | |||||||||||||||||||||||||
2492 | int leafCount = tree.leafCount(); | - | ||||||||||||||||||||||||
2493 | for (int l = 0; l < leafCount
| 0 | ||||||||||||||||||||||||
2494 | tree.leaf(l).clear(); never executed: tree.leaf(l).clear(); | 0 | ||||||||||||||||||||||||
2495 | - | |||||||||||||||||||||||||
2496 | QBspTree::Node::Type type = QBspTree::Node::Both; | - | ||||||||||||||||||||||||
2497 | - | |||||||||||||||||||||||||
2498 | if (contents.height() / contents.width() >= 3
| 0 | ||||||||||||||||||||||||
2499 | type = QBspTree::Node::HorizontalPlane; never executed: type = QBspTree::Node::HorizontalPlane; | 0 | ||||||||||||||||||||||||
2500 | else if (contents.width() / contents.height() >= 3
| 0 | ||||||||||||||||||||||||
2501 | type = QBspTree::Node::VerticalPlane; never executed: type = QBspTree::Node::VerticalPlane; | 0 | ||||||||||||||||||||||||
2502 | - | |||||||||||||||||||||||||
2503 | tree.init(QRect(0, 0, contents.width(), contents.height()), type); | - | ||||||||||||||||||||||||
2504 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2505 | - | |||||||||||||||||||||||||
2506 | QPoint QIconModeViewBase::initDynamicLayout(const QListViewLayoutInfo &info) | - | ||||||||||||||||||||||||
2507 | { | - | ||||||||||||||||||||||||
2508 | int x, y; | - | ||||||||||||||||||||||||
2509 | if (info.first == 0
| 0 | ||||||||||||||||||||||||
2510 | x = info.bounds.x() + info.spacing; | - | ||||||||||||||||||||||||
2511 | y = info.bounds.y() + info.spacing; | - | ||||||||||||||||||||||||
2512 | items.reserve(rowCount() - hiddenCount()); | - | ||||||||||||||||||||||||
2513 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2514 | int idx = info.first - 1; | - | ||||||||||||||||||||||||
2515 | while (idx > 0
| 0 | ||||||||||||||||||||||||
2516 | -- never executed: idx;--idx; never executed: --idx; | 0 | ||||||||||||||||||||||||
2517 | const QListViewItem &item = items.at(idx); | - | ||||||||||||||||||||||||
2518 | x = item.x; | - | ||||||||||||||||||||||||
2519 | y = item.y; | - | ||||||||||||||||||||||||
2520 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2521 | x += (info.grid.isValid()
never executed: x += (info.grid.isValid() ? info.grid.width() : item.w) + info.spacing; | 0 | ||||||||||||||||||||||||
2522 | else | - | ||||||||||||||||||||||||
2523 | y += (info.grid.isValid()
never executed: y += (info.grid.isValid() ? info.grid.height() : item.h) + info.spacing; | 0 | ||||||||||||||||||||||||
2524 | } | - | ||||||||||||||||||||||||
2525 | return never executed: QPoint(x, y);return QPoint(x, y); never executed: return QPoint(x, y); | 0 | ||||||||||||||||||||||||
2526 | } | - | ||||||||||||||||||||||||
2527 | - | |||||||||||||||||||||||||
2528 | - | |||||||||||||||||||||||||
2529 | - | |||||||||||||||||||||||||
2530 | - | |||||||||||||||||||||||||
2531 | void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info) | - | ||||||||||||||||||||||||
2532 | { | - | ||||||||||||||||||||||||
2533 | const bool useItemSize = !info.grid.isValid(); | - | ||||||||||||||||||||||||
2534 | const QPoint topLeft = initDynamicLayout(info); | - | ||||||||||||||||||||||||
2535 | - | |||||||||||||||||||||||||
2536 | int segStartPosition; | - | ||||||||||||||||||||||||
2537 | int segEndPosition; | - | ||||||||||||||||||||||||
2538 | int deltaFlowPosition; | - | ||||||||||||||||||||||||
2539 | int deltaSegPosition; | - | ||||||||||||||||||||||||
2540 | int deltaSegHint; | - | ||||||||||||||||||||||||
2541 | int flowPosition; | - | ||||||||||||||||||||||||
2542 | int segPosition; | - | ||||||||||||||||||||||||
2543 | - | |||||||||||||||||||||||||
2544 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2545 | segStartPosition = info.bounds.left() + info.spacing; | - | ||||||||||||||||||||||||
2546 | segEndPosition = info.bounds.right(); | - | ||||||||||||||||||||||||
2547 | deltaFlowPosition = info.grid.width(); | - | ||||||||||||||||||||||||
2548 | deltaSegPosition = (useItemSize
| 0 | ||||||||||||||||||||||||
2549 | deltaSegHint = info.grid.height(); | - | ||||||||||||||||||||||||
2550 | flowPosition = topLeft.x(); | - | ||||||||||||||||||||||||
2551 | segPosition = topLeft.y(); | - | ||||||||||||||||||||||||
2552 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2553 | segStartPosition = info.bounds.top() + info.spacing; | - | ||||||||||||||||||||||||
2554 | segEndPosition = info.bounds.bottom(); | - | ||||||||||||||||||||||||
2555 | deltaFlowPosition = info.grid.height(); | - | ||||||||||||||||||||||||
2556 | deltaSegPosition = (useItemSize
| 0 | ||||||||||||||||||||||||
2557 | deltaSegHint = info.grid.width(); | - | ||||||||||||||||||||||||
2558 | flowPosition = topLeft.y(); | - | ||||||||||||||||||||||||
2559 | segPosition = topLeft.x(); | - | ||||||||||||||||||||||||
2560 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2561 | - | |||||||||||||||||||||||||
2562 | if (moved.count() != items.count()
| 0 | ||||||||||||||||||||||||
2563 | moved.resize(items.count()); never executed: moved.resize(items.count()); | 0 | ||||||||||||||||||||||||
2564 | - | |||||||||||||||||||||||||
2565 | QRect rect(QPoint(), topLeft); | - | ||||||||||||||||||||||||
2566 | QListViewItem *item = 0; | - | ||||||||||||||||||||||||
2567 | for (int row = info.first; row <= info.last
| 0 | ||||||||||||||||||||||||
2568 | item = &items[row]; | - | ||||||||||||||||||||||||
2569 | if (isHidden(row)
| 0 | ||||||||||||||||||||||||
2570 | item->invalidate(); | - | ||||||||||||||||||||||||
2571 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2572 | - | |||||||||||||||||||||||||
2573 | if (useItemSize
| 0 | ||||||||||||||||||||||||
2574 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2575 | deltaFlowPosition = item->w + info.spacing; never executed: deltaFlowPosition = item->w + info.spacing; | 0 | ||||||||||||||||||||||||
2576 | else | - | ||||||||||||||||||||||||
2577 | deltaFlowPosition = item->h + info.spacing; never executed: deltaFlowPosition = item->h + info.spacing; | 0 | ||||||||||||||||||||||||
2578 | } else { | - | ||||||||||||||||||||||||
2579 | item->w = qMin<int>(info.grid.width(), item->w); | - | ||||||||||||||||||||||||
2580 | item->h = qMin<int>(info.grid.height(), item->h); | - | ||||||||||||||||||||||||
2581 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2582 | - | |||||||||||||||||||||||||
2583 | - | |||||||||||||||||||||||||
2584 | if (info.wrap
| 0 | ||||||||||||||||||||||||
2585 | && flowPosition + deltaFlowPosition > segEndPosition
| 0 | ||||||||||||||||||||||||
2586 | && flowPosition > segStartPosition
| 0 | ||||||||||||||||||||||||
2587 | flowPosition = segStartPosition; | - | ||||||||||||||||||||||||
2588 | segPosition += deltaSegPosition; | - | ||||||||||||||||||||||||
2589 | if (useItemSize
| 0 | ||||||||||||||||||||||||
2590 | deltaSegPosition = 0; never executed: deltaSegPosition = 0; | 0 | ||||||||||||||||||||||||
2591 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2592 | - | |||||||||||||||||||||||||
2593 | - | |||||||||||||||||||||||||
2594 | if (useItemSize
| 0 | ||||||||||||||||||||||||
2595 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2596 | deltaSegHint = item->h + info.spacing; never executed: deltaSegHint = item->h + info.spacing; | 0 | ||||||||||||||||||||||||
2597 | else | - | ||||||||||||||||||||||||
2598 | deltaSegHint = item->w + info.spacing; never executed: deltaSegHint = item->w + info.spacing; | 0 | ||||||||||||||||||||||||
2599 | deltaSegPosition = qMax(deltaSegPosition, deltaSegHint); | - | ||||||||||||||||||||||||
2600 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2601 | - | |||||||||||||||||||||||||
2602 | - | |||||||||||||||||||||||||
2603 | - | |||||||||||||||||||||||||
2604 | - | |||||||||||||||||||||||||
2605 | if (!moved.testBit(row)
| 0 | ||||||||||||||||||||||||
2606 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2607 | if (useItemSize
| 0 | ||||||||||||||||||||||||
2608 | item->x = flowPosition; | - | ||||||||||||||||||||||||
2609 | item->y = segPosition; | - | ||||||||||||||||||||||||
2610 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2611 | item->x = flowPosition + ((deltaFlowPosition - item->w) / 2); | - | ||||||||||||||||||||||||
2612 | item->y = segPosition; | - | ||||||||||||||||||||||||
2613 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2614 | } else { | - | ||||||||||||||||||||||||
2615 | if (useItemSize
| 0 | ||||||||||||||||||||||||
2616 | item->y = flowPosition; | - | ||||||||||||||||||||||||
2617 | item->x = segPosition; | - | ||||||||||||||||||||||||
2618 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2619 | item->y = flowPosition + ((deltaFlowPosition - item->h) / 2); | - | ||||||||||||||||||||||||
2620 | item->x = segPosition; | - | ||||||||||||||||||||||||
2621 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2622 | } | - | ||||||||||||||||||||||||
2623 | } | - | ||||||||||||||||||||||||
2624 | - | |||||||||||||||||||||||||
2625 | - | |||||||||||||||||||||||||
2626 | if (useItemSize
| 0 | ||||||||||||||||||||||||
2627 | rect |= item->rect(); never executed: rect |= item->rect(); | 0 | ||||||||||||||||||||||||
2628 | else if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2629 | rect |= QRect(flowPosition, segPosition, deltaFlowPosition, deltaSegPosition); never executed: rect |= QRect(flowPosition, segPosition, deltaFlowPosition, deltaSegPosition); | 0 | ||||||||||||||||||||||||
2630 | else | - | ||||||||||||||||||||||||
2631 | rect |= QRect(segPosition, flowPosition, deltaSegPosition, deltaFlowPosition); never executed: rect |= QRect(segPosition, flowPosition, deltaSegPosition, deltaFlowPosition); | 0 | ||||||||||||||||||||||||
2632 | - | |||||||||||||||||||||||||
2633 | - | |||||||||||||||||||||||||
2634 | flowPosition += deltaFlowPosition; | - | ||||||||||||||||||||||||
2635 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2636 | } | - | ||||||||||||||||||||||||
2637 | batchSavedDeltaSeg = deltaSegPosition; | - | ||||||||||||||||||||||||
2638 | batchStartRow = info.last + 1; | - | ||||||||||||||||||||||||
2639 | bool done = (info.last >= rowCount() - 1); | - | ||||||||||||||||||||||||
2640 | - | |||||||||||||||||||||||||
2641 | if (done
| 0 | ||||||||||||||||||||||||
2642 | contentsSize = rect.size(); | - | ||||||||||||||||||||||||
2643 | if (info.flow == QListView::LeftToRight
| 0 | ||||||||||||||||||||||||
2644 | contentsSize.rheight() += info.spacing; never executed: contentsSize.rheight() += info.spacing; | 0 | ||||||||||||||||||||||||
2645 | else | - | ||||||||||||||||||||||||
2646 | contentsSize.rwidth() += info.spacing; never executed: contentsSize.rwidth() += info.spacing; | 0 | ||||||||||||||||||||||||
2647 | } | - | ||||||||||||||||||||||||
2648 | if (rect.size().isEmpty()
| 0 | ||||||||||||||||||||||||
2649 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2650 | - | |||||||||||||||||||||||||
2651 | int insertFrom = info.first; | - | ||||||||||||||||||||||||
2652 | if (done
| 0 | ||||||||||||||||||||||||
2653 | initBspTree(rect.size()); | - | ||||||||||||||||||||||||
2654 | insertFrom = 0; | - | ||||||||||||||||||||||||
2655 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2656 | - | |||||||||||||||||||||||||
2657 | for (int row = insertFrom; row <= info.last
| 0 | ||||||||||||||||||||||||
2658 | tree.insertLeaf(items.at(row).rect(), row); never executed: tree.insertLeaf(items.at(row).rect(), row); | 0 | ||||||||||||||||||||||||
2659 | - | |||||||||||||||||||||||||
2660 | QRect changedRect(topLeft, rect.bottomRight()); | - | ||||||||||||||||||||||||
2661 | if (clipRect().intersects(changedRect)
| 0 | ||||||||||||||||||||||||
2662 | viewport()->update(); never executed: viewport()->update(); | 0 | ||||||||||||||||||||||||
2663 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2664 | - | |||||||||||||||||||||||||
2665 | QVector<QModelIndex> QIconModeViewBase::intersectingSet(const QRect &area) const | - | ||||||||||||||||||||||||
2666 | { | - | ||||||||||||||||||||||||
2667 | QIconModeViewBase *that = const_cast<QIconModeViewBase*>(this); | - | ||||||||||||||||||||||||
2668 | QBspTree::Data data(static_cast<void*>(that)); | - | ||||||||||||||||||||||||
2669 | QVector<QModelIndex> res; | - | ||||||||||||||||||||||||
2670 | that->interSectingVector = &res; | - | ||||||||||||||||||||||||
2671 | that->tree.climbTree(area, &QIconModeViewBase::addLeaf, data); | - | ||||||||||||||||||||||||
2672 | that->interSectingVector = 0; | - | ||||||||||||||||||||||||
2673 | return never executed: res;return res; never executed: return res; | 0 | ||||||||||||||||||||||||
2674 | } | - | ||||||||||||||||||||||||
2675 | - | |||||||||||||||||||||||||
2676 | QRect QIconModeViewBase::itemsRect(const QVector<QModelIndex> &indexes) const | - | ||||||||||||||||||||||||
2677 | { | - | ||||||||||||||||||||||||
2678 | QVector<QModelIndex>::const_iterator it = indexes.begin(); | - | ||||||||||||||||||||||||
2679 | QListViewItem item = indexToListViewItem(*it); | - | ||||||||||||||||||||||||
2680 | QRect rect(item.x, item.y, item.w, item.h); | - | ||||||||||||||||||||||||
2681 | for (; it != indexes.end()
| 0 | ||||||||||||||||||||||||
2682 | item = indexToListViewItem(*it); | - | ||||||||||||||||||||||||
2683 | rect |= viewItemRect(item); | - | ||||||||||||||||||||||||
2684 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2685 | return never executed: rect;return rect; never executed: return rect; | 0 | ||||||||||||||||||||||||
2686 | } | - | ||||||||||||||||||||||||
2687 | - | |||||||||||||||||||||||||
2688 | int QIconModeViewBase::itemIndex(const QListViewItem &item) const | - | ||||||||||||||||||||||||
2689 | { | - | ||||||||||||||||||||||||
2690 | if (!item.isValid()
| 0 | ||||||||||||||||||||||||
2691 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
2692 | int i = item.indexHint; | - | ||||||||||||||||||||||||
2693 | if (i < items.count()
| 0 | ||||||||||||||||||||||||
2694 | if (items.at(i) == item
| 0 | ||||||||||||||||||||||||
2695 | return never executed: i;return i; never executed: return i; | 0 | ||||||||||||||||||||||||
2696 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2697 | i = items.count() - 1; | - | ||||||||||||||||||||||||
2698 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2699 | - | |||||||||||||||||||||||||
2700 | int j = i; | - | ||||||||||||||||||||||||
2701 | int c = items.count(); | - | ||||||||||||||||||||||||
2702 | bool a = true; | - | ||||||||||||||||||||||||
2703 | bool b = true; | - | ||||||||||||||||||||||||
2704 | - | |||||||||||||||||||||||||
2705 | while (a
| 0 | ||||||||||||||||||||||||
2706 | if (a
| 0 | ||||||||||||||||||||||||
2707 | if (items.at(i) == item
| 0 | ||||||||||||||||||||||||
2708 | items.at(i).indexHint = i; | - | ||||||||||||||||||||||||
2709 | return never executed: i;return i; never executed: return i; | 0 | ||||||||||||||||||||||||
2710 | } | - | ||||||||||||||||||||||||
2711 | a = ++i < c; | - | ||||||||||||||||||||||||
2712 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2713 | if (b
| 0 | ||||||||||||||||||||||||
2714 | if (items.at(j) == item
| 0 | ||||||||||||||||||||||||
2715 | items.at(j).indexHint = j; | - | ||||||||||||||||||||||||
2716 | return never executed: j;return j; never executed: return j; | 0 | ||||||||||||||||||||||||
2717 | } | - | ||||||||||||||||||||||||
2718 | b = --j > -1; | - | ||||||||||||||||||||||||
2719 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2720 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2721 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
2722 | } | - | ||||||||||||||||||||||||
2723 | - | |||||||||||||||||||||||||
2724 | void QIconModeViewBase::addLeaf(QVector<int> &leaf, const QRect &area, | - | ||||||||||||||||||||||||
2725 | uint visited, QBspTree::Data data) | - | ||||||||||||||||||||||||
2726 | { | - | ||||||||||||||||||||||||
2727 | QListViewItem *vi; | - | ||||||||||||||||||||||||
2728 | QIconModeViewBase *_this = static_cast<QIconModeViewBase *>(data.ptr); | - | ||||||||||||||||||||||||
2729 | for (int i = 0; i < leaf.count()
| 0 | ||||||||||||||||||||||||
2730 | int idx = leaf.at(i); | - | ||||||||||||||||||||||||
2731 | if (idx < 0
| 0 | ||||||||||||||||||||||||
2732 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2733 | vi = &_this->items[idx]; | - | ||||||||||||||||||||||||
2734 | ((!(vi)) ? qt_assert("vi",__FILE__,3140) : qt_noop()); | - | ||||||||||||||||||||||||
2735 | if (vi->isValid()
| 0 | ||||||||||||||||||||||||
2736 | QModelIndex index = _this->dd->listViewItemToIndex(*vi); | - | ||||||||||||||||||||||||
2737 | ((!(index.isValid())) ? qt_assert("index.isValid()",__FILE__,3143) : qt_noop()); | - | ||||||||||||||||||||||||
2738 | _this->interSectingVector->append(index); | - | ||||||||||||||||||||||||
2739 | vi->visited = visited; | - | ||||||||||||||||||||||||
2740 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2741 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2742 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2743 | - | |||||||||||||||||||||||||
2744 | void QIconModeViewBase::moveItem(int index, const QPoint &dest) | - | ||||||||||||||||||||||||
2745 | { | - | ||||||||||||||||||||||||
2746 | - | |||||||||||||||||||||||||
2747 | QListViewItem *item = &items[index]; | - | ||||||||||||||||||||||||
2748 | QRect rect = item->rect(); | - | ||||||||||||||||||||||||
2749 | - | |||||||||||||||||||||||||
2750 | - | |||||||||||||||||||||||||
2751 | tree.removeLeaf(rect, index); | - | ||||||||||||||||||||||||
2752 | item->move(dest); | - | ||||||||||||||||||||||||
2753 | tree.insertLeaf(QRect(dest, rect.size()), index); | - | ||||||||||||||||||||||||
2754 | - | |||||||||||||||||||||||||
2755 | - | |||||||||||||||||||||||||
2756 | contentsSize = (QRect(QPoint(0, 0), contentsSize)|QRect(dest, rect.size())).size(); | - | ||||||||||||||||||||||||
2757 | - | |||||||||||||||||||||||||
2758 | - | |||||||||||||||||||||||||
2759 | if (moved.count() != items.count()
| 0 | ||||||||||||||||||||||||
2760 | moved.resize(items.count()); never executed: moved.resize(items.count()); | 0 | ||||||||||||||||||||||||
2761 | moved.setBit(index, true); | - | ||||||||||||||||||||||||
2762 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2763 | - | |||||||||||||||||||||||||
2764 | QPoint QIconModeViewBase::snapToGrid(const QPoint &pos) const | - | ||||||||||||||||||||||||
2765 | { | - | ||||||||||||||||||||||||
2766 | int x = pos.x() - (pos.x() % gridSize().width()); | - | ||||||||||||||||||||||||
2767 | int y = pos.y() - (pos.y() % gridSize().height()); | - | ||||||||||||||||||||||||
2768 | return never executed: QPoint(x, y);return QPoint(x, y); never executed: return QPoint(x, y); | 0 | ||||||||||||||||||||||||
2769 | } | - | ||||||||||||||||||||||||
2770 | - | |||||||||||||||||||||||||
2771 | QPoint QIconModeViewBase::draggedItemsDelta() const | - | ||||||||||||||||||||||||
2772 | { | - | ||||||||||||||||||||||||
2773 | if (movement() == QListView::Snap
| 0 | ||||||||||||||||||||||||
2774 | QPoint snapdelta = QPoint((offset().x() % gridSize().width()), | - | ||||||||||||||||||||||||
2775 | (offset().y() % gridSize().height())); | - | ||||||||||||||||||||||||
2776 | return never executed: snapToGrid(draggedItemsPos + snapdelta) - snapToGrid(pressedPosition()) - snapdelta;return snapToGrid(draggedItemsPos + snapdelta) - snapToGrid(pressedPosition()) - snapdelta; never executed: return snapToGrid(draggedItemsPos + snapdelta) - snapToGrid(pressedPosition()) - snapdelta; | 0 | ||||||||||||||||||||||||
2777 | } | - | ||||||||||||||||||||||||
2778 | return never executed: draggedItemsPos - pressedPosition();return draggedItemsPos - pressedPosition(); never executed: return draggedItemsPos - pressedPosition(); | 0 | ||||||||||||||||||||||||
2779 | } | - | ||||||||||||||||||||||||
2780 | - | |||||||||||||||||||||||||
2781 | QRect QIconModeViewBase::draggedItemsRect() const | - | ||||||||||||||||||||||||
2782 | { | - | ||||||||||||||||||||||||
2783 | QRect rect = itemsRect(draggedItems); | - | ||||||||||||||||||||||||
2784 | rect.translate(draggedItemsDelta()); | - | ||||||||||||||||||||||||
2785 | return never executed: rect;return rect; never executed: return rect; | 0 | ||||||||||||||||||||||||
2786 | } | - | ||||||||||||||||||||||||
2787 | - | |||||||||||||||||||||||||
2788 | void QListViewPrivate::scrollElasticBandBy(int dx, int dy) | - | ||||||||||||||||||||||||
2789 | { | - | ||||||||||||||||||||||||
2790 | if (dx > 0
| 0 | ||||||||||||||||||||||||
2791 | elasticBand.moveRight(elasticBand.right() + dx); never executed: elasticBand.moveRight(elasticBand.right() + dx); | 0 | ||||||||||||||||||||||||
2792 | else if (dx < 0
| 0 | ||||||||||||||||||||||||
2793 | elasticBand.moveLeft(elasticBand.left() - dx); never executed: elasticBand.moveLeft(elasticBand.left() - dx); | 0 | ||||||||||||||||||||||||
2794 | if (dy > 0
| 0 | ||||||||||||||||||||||||
2795 | elasticBand.moveBottom(elasticBand.bottom() + dy); never executed: elasticBand.moveBottom(elasticBand.bottom() + dy); | 0 | ||||||||||||||||||||||||
2796 | else if (dy < 0
| 0 | ||||||||||||||||||||||||
2797 | elasticBand.moveTop(elasticBand.top() - dy); never executed: elasticBand.moveTop(elasticBand.top() - dy); | 0 | ||||||||||||||||||||||||
2798 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2799 | - | |||||||||||||||||||||||||
2800 | void QIconModeViewBase::clear() | - | ||||||||||||||||||||||||
2801 | { | - | ||||||||||||||||||||||||
2802 | tree.destroy(); | - | ||||||||||||||||||||||||
2803 | items.clear(); | - | ||||||||||||||||||||||||
2804 | moved.clear(); | - | ||||||||||||||||||||||||
2805 | batchStartRow = 0; | - | ||||||||||||||||||||||||
2806 | batchSavedDeltaSeg = 0; | - | ||||||||||||||||||||||||
2807 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2808 | - | |||||||||||||||||||||||||
2809 | void QIconModeViewBase::updateContentsSize() | - | ||||||||||||||||||||||||
2810 | { | - | ||||||||||||||||||||||||
2811 | QRect bounding; | - | ||||||||||||||||||||||||
2812 | for (int i = 0; i < items.count()
| 0 | ||||||||||||||||||||||||
2813 | bounding |= items.at(i).rect(); never executed: bounding |= items.at(i).rect(); | 0 | ||||||||||||||||||||||||
2814 | contentsSize = bounding.size(); | - | ||||||||||||||||||||||||
2815 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2816 | - | |||||||||||||||||||||||||
2817 | - | |||||||||||||||||||||||||
2818 | - | |||||||||||||||||||||||||
2819 | - | |||||||||||||||||||||||||
2820 | void QListView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | - | ||||||||||||||||||||||||
2821 | { | - | ||||||||||||||||||||||||
2822 | - | |||||||||||||||||||||||||
2823 | if (QAccessible::isActive()
| 0 | ||||||||||||||||||||||||
2824 | if (current.isValid()
| 0 | ||||||||||||||||||||||||
2825 | int entry = visualIndex(current); | - | ||||||||||||||||||||||||
2826 | QAccessibleEvent event(this, QAccessible::Focus); | - | ||||||||||||||||||||||||
2827 | event.setChild(entry); | - | ||||||||||||||||||||||||
2828 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||
2829 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2830 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2831 | - | |||||||||||||||||||||||||
2832 | QAbstractItemView::currentChanged(current, previous); | - | ||||||||||||||||||||||||
2833 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2834 | - | |||||||||||||||||||||||||
2835 | - | |||||||||||||||||||||||||
2836 | - | |||||||||||||||||||||||||
2837 | - | |||||||||||||||||||||||||
2838 | void QListView::selectionChanged(const QItemSelection &selected, | - | ||||||||||||||||||||||||
2839 | const QItemSelection &deselected) | - | ||||||||||||||||||||||||
2840 | { | - | ||||||||||||||||||||||||
2841 | - | |||||||||||||||||||||||||
2842 | if (QAccessible::isActive()
| 0 | ||||||||||||||||||||||||
2843 | - | |||||||||||||||||||||||||
2844 | QModelIndex sel = selected.indexes().value(0); | - | ||||||||||||||||||||||||
2845 | if (sel.isValid()
| 0 | ||||||||||||||||||||||||
2846 | int entry = visualIndex(sel); | - | ||||||||||||||||||||||||
2847 | QAccessibleEvent event(this, QAccessible::SelectionAdd); | - | ||||||||||||||||||||||||
2848 | event.setChild(entry); | - | ||||||||||||||||||||||||
2849 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||
2850 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2851 | QModelIndex desel = deselected.indexes().value(0); | - | ||||||||||||||||||||||||
2852 | if (desel.isValid()
| 0 | ||||||||||||||||||||||||
2853 | int entry = visualIndex(desel); | - | ||||||||||||||||||||||||
2854 | QAccessibleEvent event(this, QAccessible::SelectionRemove); | - | ||||||||||||||||||||||||
2855 | event.setChild(entry); | - | ||||||||||||||||||||||||
2856 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||
2857 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2858 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2859 | - | |||||||||||||||||||||||||
2860 | QAbstractItemView::selectionChanged(selected, deselected); | - | ||||||||||||||||||||||||
2861 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2862 | - | |||||||||||||||||||||||||
2863 | int QListView::visualIndex(const QModelIndex &index) const | - | ||||||||||||||||||||||||
2864 | { | - | ||||||||||||||||||||||||
2865 | const QListViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2866 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
2867 | QListViewItem itm = d->indexToListViewItem(index); | - | ||||||||||||||||||||||||
2868 | int visualIndex = d->commonListView->itemIndex(itm); | - | ||||||||||||||||||||||||
2869 | for (int row = 0; row <= index.row()
| 0 | ||||||||||||||||||||||||
2870 | if (d->isHidden(row)
| 0 | ||||||||||||||||||||||||
2871 | visualIndex--; never executed: visualIndex--; | 0 | ||||||||||||||||||||||||
2872 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2873 | return never executed: visualIndex;return visualIndex; never executed: return visualIndex; | 0 | ||||||||||||||||||||||||
2874 | } | - | ||||||||||||||||||||||||
2875 | - | |||||||||||||||||||||||||
2876 | - | |||||||||||||||||||||||||
2877 | - | |||||||||||||||||||||||||
2878 | - | |||||||||||||||||||||||||
2879 | - | |||||||||||||||||||||||||
2880 | - | |||||||||||||||||||||||||
2881 | QSize QListView::viewportSizeHint() const | - | ||||||||||||||||||||||||
2882 | { | - | ||||||||||||||||||||||||
2883 | return never executed: QAbstractItemView::viewportSizeHint();return QAbstractItemView::viewportSizeHint(); never executed: return QAbstractItemView::viewportSizeHint(); | 0 | ||||||||||||||||||||||||
2884 | } | - | ||||||||||||||||||||||||
2885 | - | |||||||||||||||||||||||||
2886 | - | |||||||||||||||||||||||||
2887 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |