Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qtreeview.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||
10 | QTreeView::QTreeView(QWidget *parent) | - | ||||||||||||||||||||||||
11 | : QAbstractItemView(*new QTreeViewPrivate, parent) | - | ||||||||||||||||||||||||
12 | { | - | ||||||||||||||||||||||||
13 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
14 | d->initialize(); | - | ||||||||||||||||||||||||
15 | } never executed: end of block | 0 | ||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||
17 | - | |||||||||||||||||||||||||
18 | - | |||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||
20 | QTreeView::QTreeView(QTreeViewPrivate &dd, QWidget *parent) | - | ||||||||||||||||||||||||
21 | : QAbstractItemView(dd, parent) | - | ||||||||||||||||||||||||
22 | { | - | ||||||||||||||||||||||||
23 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
24 | d->initialize(); | - | ||||||||||||||||||||||||
25 | } never executed: end of block | 0 | ||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||
27 | - | |||||||||||||||||||||||||
28 | - | |||||||||||||||||||||||||
29 | - | |||||||||||||||||||||||||
30 | QTreeView::~QTreeView() | - | ||||||||||||||||||||||||
31 | { | - | ||||||||||||||||||||||||
32 | } | - | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||
37 | void QTreeView::setModel(QAbstractItemModel *model) | - | ||||||||||||||||||||||||
38 | { | - | ||||||||||||||||||||||||
39 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
40 | if (model == d->model
| 0 | ||||||||||||||||||||||||
41 | return; never executed: return; | 0 | ||||||||||||||||||||||||
42 | if (d->model
| 0 | ||||||||||||||||||||||||
43 | disconnect(d->model, qFlagLocation("2""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "219"), | - | ||||||||||||||||||||||||
44 | this, qFlagLocation("1""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "220")); | - | ||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | disconnect(d->model, qFlagLocation("2""modelAboutToBeReset()" "\0" __FILE__ ":" "222"), this, qFlagLocation("1""_q_modelAboutToBeReset()" "\0" __FILE__ ":" "222")); | - | ||||||||||||||||||||||||
47 | } never executed: end of block | 0 | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | if (d->selectionModel
| 0 | ||||||||||||||||||||||||
50 | disconnect(d->selectionModel, qFlagLocation("2""currentRowChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "226"), | - | ||||||||||||||||||||||||
51 | d->model, qFlagLocation("1""submit()" "\0" __FILE__ ":" "227")); | - | ||||||||||||||||||||||||
52 | disconnect(d->model, qFlagLocation("2""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "228"), | - | ||||||||||||||||||||||||
53 | this, qFlagLocation("1""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "229")); | - | ||||||||||||||||||||||||
54 | disconnect(d->model, qFlagLocation("2""modelAboutToBeReset()" "\0" __FILE__ ":" "230"), this, qFlagLocation("1""_q_modelAboutToBeReset()" "\0" __FILE__ ":" "230")); | - | ||||||||||||||||||||||||
55 | } never executed: end of block | 0 | ||||||||||||||||||||||||
56 | d->viewItems.clear(); | - | ||||||||||||||||||||||||
57 | d->expandedIndexes.clear(); | - | ||||||||||||||||||||||||
58 | d->hiddenIndexes.clear(); | - | ||||||||||||||||||||||||
59 | d->header->setModel(model); | - | ||||||||||||||||||||||||
60 | QAbstractItemView::setModel(model); | - | ||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | disconnect(d->model, qFlagLocation("2""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "239"), | - | ||||||||||||||||||||||||
64 | this, qFlagLocation("1""_q_rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "240")); | - | ||||||||||||||||||||||||
65 | - | |||||||||||||||||||||||||
66 | disconnect(d->model, qFlagLocation("2""layoutChanged()" "\0" __FILE__ ":" "242"), | - | ||||||||||||||||||||||||
67 | d->header, qFlagLocation("1""_q_layoutChanged()" "\0" __FILE__ ":" "243")); | - | ||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | connect(d->model, qFlagLocation("2""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "245"), | - | ||||||||||||||||||||||||
70 | this, qFlagLocation("1""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "246")); | - | ||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | connect(d->model, qFlagLocation("2""modelAboutToBeReset()" "\0" __FILE__ ":" "248"), qFlagLocation("1""_q_modelAboutToBeReset()" "\0" __FILE__ ":" "248")); | - | ||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | if (d->sortingEnabled
| 0 | ||||||||||||||||||||||||
75 | d->_q_sortIndicatorChanged(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); never executed: d->_q_sortIndicatorChanged(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); | 0 | ||||||||||||||||||||||||
76 | } never executed: end of block | 0 | ||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | void QTreeView::setRootIndex(const QModelIndex &index) | - | ||||||||||||||||||||||||
82 | { | - | ||||||||||||||||||||||||
83 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
84 | d->header->setRootIndex(index); | - | ||||||||||||||||||||||||
85 | QAbstractItemView::setRootIndex(index); | - | ||||||||||||||||||||||||
86 | } never executed: end of block | 0 | ||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | - | |||||||||||||||||||||||||
91 | void QTreeView::setSelectionModel(QItemSelectionModel *selectionModel) | - | ||||||||||||||||||||||||
92 | { | - | ||||||||||||||||||||||||
93 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
94 | ((!(selectionModel)) ? qt_assert("selectionModel",__FILE__,270) : qt_noop()); | - | ||||||||||||||||||||||||
95 | if (d->selectionModel
| 0 | ||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||
97 | disconnect(d->selectionModel, qFlagLocation("2""currentRowChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "273"), | - | ||||||||||||||||||||||||
98 | d->model, qFlagLocation("1""submit()" "\0" __FILE__ ":" "274")); | - | ||||||||||||||||||||||||
99 | } never executed: end of block | 0 | ||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||
101 | d->header->setSelectionModel(selectionModel); | - | ||||||||||||||||||||||||
102 | QAbstractItemView::setSelectionModel(selectionModel); | - | ||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | if (d->selectionModel
| 0 | ||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||
106 | connect(d->selectionModel, qFlagLocation("2""currentRowChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "282"), | - | ||||||||||||||||||||||||
107 | d->model, qFlagLocation("1""submit()" "\0" __FILE__ ":" "283")); | - | ||||||||||||||||||||||||
108 | } never executed: end of block | 0 | ||||||||||||||||||||||||
109 | } never executed: end of block | 0 | ||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | - | |||||||||||||||||||||||||
116 | QHeaderView *QTreeView::header() const | - | ||||||||||||||||||||||||
117 | { | - | ||||||||||||||||||||||||
118 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
119 | return never executed: d->header;return d->header; never executed: return d->header; | 0 | ||||||||||||||||||||||||
120 | } | - | ||||||||||||||||||||||||
121 | void QTreeView::setHeader(QHeaderView *header) | - | ||||||||||||||||||||||||
122 | { | - | ||||||||||||||||||||||||
123 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
124 | if (header == d->header
| 0 | ||||||||||||||||||||||||
125 | return; never executed: return; | 0 | ||||||||||||||||||||||||
126 | if (d->header
| 0 | ||||||||||||||||||||||||
127 | delete d->header; never executed: delete d->header; | 0 | ||||||||||||||||||||||||
128 | d->header = header; | - | ||||||||||||||||||||||||
129 | d->header->setParent(this); | - | ||||||||||||||||||||||||
130 | d->header->d_func()->setAllowUserMoveOfSection0(false); | - | ||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||
132 | if (!d->header->model()
| 0 | ||||||||||||||||||||||||
133 | d->header->setModel(d->model); | - | ||||||||||||||||||||||||
134 | if (d->selectionModel
| 0 | ||||||||||||||||||||||||
135 | d->header->setSelectionModel(d->selectionModel); never executed: d->header->setSelectionModel(d->selectionModel); | 0 | ||||||||||||||||||||||||
136 | } never executed: end of block | 0 | ||||||||||||||||||||||||
137 | - | |||||||||||||||||||||||||
138 | connect(d->header, qFlagLocation("2""sectionResized(int,int,int)" "\0" __FILE__ ":" "323"), | - | ||||||||||||||||||||||||
139 | this, qFlagLocation("1""columnResized(int,int,int)" "\0" __FILE__ ":" "324")); | - | ||||||||||||||||||||||||
140 | connect(d->header, qFlagLocation("2""sectionMoved(int,int,int)" "\0" __FILE__ ":" "325"), | - | ||||||||||||||||||||||||
141 | this, qFlagLocation("1""columnMoved()" "\0" __FILE__ ":" "326")); | - | ||||||||||||||||||||||||
142 | connect(d->header, qFlagLocation("2""sectionCountChanged(int,int)" "\0" __FILE__ ":" "327"), | - | ||||||||||||||||||||||||
143 | this, qFlagLocation("1""columnCountChanged(int,int)" "\0" __FILE__ ":" "328")); | - | ||||||||||||||||||||||||
144 | connect(d->header, qFlagLocation("2""sectionHandleDoubleClicked(int)" "\0" __FILE__ ":" "329"), | - | ||||||||||||||||||||||||
145 | this, qFlagLocation("1""resizeColumnToContents(int)" "\0" __FILE__ ":" "330")); | - | ||||||||||||||||||||||||
146 | connect(d->header, qFlagLocation("2""geometriesChanged()" "\0" __FILE__ ":" "331"), | - | ||||||||||||||||||||||||
147 | this, qFlagLocation("1""updateGeometries()" "\0" __FILE__ ":" "332")); | - | ||||||||||||||||||||||||
148 | - | |||||||||||||||||||||||||
149 | setSortingEnabled(d->sortingEnabled); | - | ||||||||||||||||||||||||
150 | d->updateGeometry(); | - | ||||||||||||||||||||||||
151 | } never executed: end of block | 0 | ||||||||||||||||||||||||
152 | int QTreeView::autoExpandDelay() const | - | ||||||||||||||||||||||||
153 | { | - | ||||||||||||||||||||||||
154 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
155 | return never executed: d->autoExpandDelay;return d->autoExpandDelay; never executed: return d->autoExpandDelay; | 0 | ||||||||||||||||||||||||
156 | } | - | ||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||
158 | void QTreeView::setAutoExpandDelay(int delay) | - | ||||||||||||||||||||||||
159 | { | - | ||||||||||||||||||||||||
160 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
161 | d->autoExpandDelay = delay; | - | ||||||||||||||||||||||||
162 | } never executed: end of block | 0 | ||||||||||||||||||||||||
163 | int QTreeView::indentation() const | - | ||||||||||||||||||||||||
164 | { | - | ||||||||||||||||||||||||
165 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
166 | return never executed: d->indent;return d->indent; never executed: return d->indent; | 0 | ||||||||||||||||||||||||
167 | } | - | ||||||||||||||||||||||||
168 | - | |||||||||||||||||||||||||
169 | void QTreeView::setIndentation(int i) | - | ||||||||||||||||||||||||
170 | { | - | ||||||||||||||||||||||||
171 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
172 | if (!d->customIndent
| 0 | ||||||||||||||||||||||||
173 | d->indent = i; | - | ||||||||||||||||||||||||
174 | d->customIndent = true; | - | ||||||||||||||||||||||||
175 | d->viewport->update(); | - | ||||||||||||||||||||||||
176 | } never executed: end of block | 0 | ||||||||||||||||||||||||
177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | void QTreeView::resetIndentation() | - | ||||||||||||||||||||||||
180 | { | - | ||||||||||||||||||||||||
181 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
182 | if (d->customIndent
| 0 | ||||||||||||||||||||||||
183 | d->updateIndentationFromStyle(); | - | ||||||||||||||||||||||||
184 | d->customIndent = false; | - | ||||||||||||||||||||||||
185 | } never executed: end of block | 0 | ||||||||||||||||||||||||
186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
187 | bool QTreeView::rootIsDecorated() const | - | ||||||||||||||||||||||||
188 | { | - | ||||||||||||||||||||||||
189 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
190 | return never executed: d->rootDecoration;return d->rootDecoration; never executed: return d->rootDecoration; | 0 | ||||||||||||||||||||||||
191 | } | - | ||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||
193 | void QTreeView::setRootIsDecorated(bool show) | - | ||||||||||||||||||||||||
194 | { | - | ||||||||||||||||||||||||
195 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
196 | if (show != d->rootDecoration
| 0 | ||||||||||||||||||||||||
197 | d->rootDecoration = show; | - | ||||||||||||||||||||||||
198 | d->viewport->update(); | - | ||||||||||||||||||||||||
199 | } never executed: end of block | 0 | ||||||||||||||||||||||||
200 | } never executed: end of block | 0 | ||||||||||||||||||||||||
201 | bool QTreeView::uniformRowHeights() const | - | ||||||||||||||||||||||||
202 | { | - | ||||||||||||||||||||||||
203 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
204 | return never executed: d->uniformRowHeights;return d->uniformRowHeights; never executed: return d->uniformRowHeights; | 0 | ||||||||||||||||||||||||
205 | } | - | ||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||
207 | void QTreeView::setUniformRowHeights(bool uniform) | - | ||||||||||||||||||||||||
208 | { | - | ||||||||||||||||||||||||
209 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
210 | d->uniformRowHeights = uniform; | - | ||||||||||||||||||||||||
211 | } never executed: end of block | 0 | ||||||||||||||||||||||||
212 | bool QTreeView::itemsExpandable() const | - | ||||||||||||||||||||||||
213 | { | - | ||||||||||||||||||||||||
214 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
215 | return never executed: d->itemsExpandable;return d->itemsExpandable; never executed: return d->itemsExpandable; | 0 | ||||||||||||||||||||||||
216 | } | - | ||||||||||||||||||||||||
217 | - | |||||||||||||||||||||||||
218 | void QTreeView::setItemsExpandable(bool enable) | - | ||||||||||||||||||||||||
219 | { | - | ||||||||||||||||||||||||
220 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
221 | d->itemsExpandable = enable; | - | ||||||||||||||||||||||||
222 | } never executed: end of block | 0 | ||||||||||||||||||||||||
223 | bool QTreeView::expandsOnDoubleClick() const | - | ||||||||||||||||||||||||
224 | { | - | ||||||||||||||||||||||||
225 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
226 | return never executed: d->expandsOnDoubleClick;return d->expandsOnDoubleClick; never executed: return d->expandsOnDoubleClick; | 0 | ||||||||||||||||||||||||
227 | } | - | ||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||
229 | void QTreeView::setExpandsOnDoubleClick(bool enable) | - | ||||||||||||||||||||||||
230 | { | - | ||||||||||||||||||||||||
231 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
232 | d->expandsOnDoubleClick = enable; | - | ||||||||||||||||||||||||
233 | } never executed: end of block | 0 | ||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | - | |||||||||||||||||||||||||
238 | int QTreeView::columnViewportPosition(int column) const | - | ||||||||||||||||||||||||
239 | { | - | ||||||||||||||||||||||||
240 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
241 | return never executed: d->header->sectionViewportPosition(column);return d->header->sectionViewportPosition(column); never executed: return d->header->sectionViewportPosition(column); | 0 | ||||||||||||||||||||||||
242 | } | - | ||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | - | |||||||||||||||||||||||||
249 | int QTreeView::columnWidth(int column) const | - | ||||||||||||||||||||||||
250 | { | - | ||||||||||||||||||||||||
251 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
252 | return never executed: d->header->sectionSize(column);return d->header->sectionSize(column); never executed: return d->header->sectionSize(column); | 0 | ||||||||||||||||||||||||
253 | } | - | ||||||||||||||||||||||||
254 | void QTreeView::setColumnWidth(int column, int width) | - | ||||||||||||||||||||||||
255 | { | - | ||||||||||||||||||||||||
256 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
257 | d->header->resizeSection(column, width); | - | ||||||||||||||||||||||||
258 | } never executed: end of block | 0 | ||||||||||||||||||||||||
259 | - | |||||||||||||||||||||||||
260 | - | |||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||
263 | - | |||||||||||||||||||||||||
264 | int QTreeView::columnAt(int x) const | - | ||||||||||||||||||||||||
265 | { | - | ||||||||||||||||||||||||
266 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
267 | return never executed: d->header->logicalIndexAt(x);return d->header->logicalIndexAt(x); never executed: return d->header->logicalIndexAt(x); | 0 | ||||||||||||||||||||||||
268 | } | - | ||||||||||||||||||||||||
269 | - | |||||||||||||||||||||||||
270 | - | |||||||||||||||||||||||||
271 | - | |||||||||||||||||||||||||
272 | - | |||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||
275 | bool QTreeView::isColumnHidden(int column) const | - | ||||||||||||||||||||||||
276 | { | - | ||||||||||||||||||||||||
277 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
278 | return never executed: d->header->isSectionHidden(column);return d->header->isSectionHidden(column); never executed: return d->header->isSectionHidden(column); | 0 | ||||||||||||||||||||||||
279 | } | - | ||||||||||||||||||||||||
280 | - | |||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||
282 | - | |||||||||||||||||||||||||
283 | - | |||||||||||||||||||||||||
284 | - | |||||||||||||||||||||||||
285 | - | |||||||||||||||||||||||||
286 | void QTreeView::setColumnHidden(int column, bool hide) | - | ||||||||||||||||||||||||
287 | { | - | ||||||||||||||||||||||||
288 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
289 | if (column < 0
| 0 | ||||||||||||||||||||||||
290 | return; never executed: return; | 0 | ||||||||||||||||||||||||
291 | d->header->setSectionHidden(column, hide); | - | ||||||||||||||||||||||||
292 | } never executed: end of block | 0 | ||||||||||||||||||||||||
293 | bool QTreeView::isHeaderHidden() const | - | ||||||||||||||||||||||||
294 | { | - | ||||||||||||||||||||||||
295 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
296 | return never executed: d->header->isHidden();return d->header->isHidden(); never executed: return d->header->isHidden(); | 0 | ||||||||||||||||||||||||
297 | } | - | ||||||||||||||||||||||||
298 | - | |||||||||||||||||||||||||
299 | void QTreeView::setHeaderHidden(bool hide) | - | ||||||||||||||||||||||||
300 | { | - | ||||||||||||||||||||||||
301 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
302 | d->header->setHidden(hide); | - | ||||||||||||||||||||||||
303 | } never executed: end of block | 0 | ||||||||||||||||||||||||
304 | - | |||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | - | |||||||||||||||||||||||||
307 | - | |||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | - | |||||||||||||||||||||||||
310 | - | |||||||||||||||||||||||||
311 | bool QTreeView::isRowHidden(int row, const QModelIndex &parent) const | - | ||||||||||||||||||||||||
312 | { | - | ||||||||||||||||||||||||
313 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
314 | if (!d->model
| 0 | ||||||||||||||||||||||||
315 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
316 | return never executed: d->isRowHidden(d->model->index(row, 0, parent));return d->isRowHidden(d->model->index(row, 0, parent)); never executed: return d->isRowHidden(d->model->index(row, 0, parent)); | 0 | ||||||||||||||||||||||||
317 | } | - | ||||||||||||||||||||||||
318 | - | |||||||||||||||||||||||||
319 | - | |||||||||||||||||||||||||
320 | - | |||||||||||||||||||||||||
321 | - | |||||||||||||||||||||||||
322 | - | |||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
324 | void QTreeView::setRowHidden(int row, const QModelIndex &parent, bool hide) | - | ||||||||||||||||||||||||
325 | { | - | ||||||||||||||||||||||||
326 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
327 | if (!d->model
| 0 | ||||||||||||||||||||||||
328 | return; never executed: return; | 0 | ||||||||||||||||||||||||
329 | QModelIndex index = d->model->index(row, 0, parent); | - | ||||||||||||||||||||||||
330 | if (!index.isValid()
| 0 | ||||||||||||||||||||||||
331 | return; never executed: return; | 0 | ||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | if (hide
| 0 | ||||||||||||||||||||||||
334 | d->hiddenIndexes.insert(index); | - | ||||||||||||||||||||||||
335 | } never executed: else if(d->isPersistent(index)end of block
| 0 | ||||||||||||||||||||||||
336 | d->hiddenIndexes.remove(index); | - | ||||||||||||||||||||||||
337 | } never executed: end of block | 0 | ||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||
339 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
341 | bool QTreeView::isFirstColumnSpanned(int row, const QModelIndex &parent) const | - | ||||||||||||||||||||||||
342 | { | - | ||||||||||||||||||||||||
343 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
344 | if (d->spanningIndexes.isEmpty()
| 0 | ||||||||||||||||||||||||
345 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
346 | QModelIndex index = d->model->index(row, 0, parent); | - | ||||||||||||||||||||||||
347 | for (int i = 0; i < d->spanningIndexes.count()
| 0 | ||||||||||||||||||||||||
348 | if (d->spanningIndexes.at(i) == index
| 0 | ||||||||||||||||||||||||
349 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
350 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
351 | } | - | ||||||||||||||||||||||||
352 | void QTreeView::setFirstColumnSpanned(int row, const QModelIndex &parent, bool span) | - | ||||||||||||||||||||||||
353 | { | - | ||||||||||||||||||||||||
354 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
355 | if (!d->model
| 0 | ||||||||||||||||||||||||
356 | return; never executed: return; | 0 | ||||||||||||||||||||||||
357 | QModelIndex index = d->model->index(row, 0, parent); | - | ||||||||||||||||||||||||
358 | if (!index.isValid()
| 0 | ||||||||||||||||||||||||
359 | return; never executed: return; | 0 | ||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||
361 | if (span
| 0 | ||||||||||||||||||||||||
362 | QPersistentModelIndex persistent(index); | - | ||||||||||||||||||||||||
363 | if (!d->spanningIndexes.contains(persistent)
| 0 | ||||||||||||||||||||||||
364 | d->spanningIndexes.append(persistent); never executed: d->spanningIndexes.append(persistent); | 0 | ||||||||||||||||||||||||
365 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
366 | QPersistentModelIndex persistent(index); | - | ||||||||||||||||||||||||
367 | int i = d->spanningIndexes.indexOf(persistent); | - | ||||||||||||||||||||||||
368 | if (i >= 0
| 0 | ||||||||||||||||||||||||
369 | d->spanningIndexes.remove(i); never executed: d->spanningIndexes.remove(i); | 0 | ||||||||||||||||||||||||
370 | } never executed: end of block | 0 | ||||||||||||||||||||||||
371 | - | |||||||||||||||||||||||||
372 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
373 | int i = d->viewIndex(index); | - | ||||||||||||||||||||||||
374 | if (i >= 0
| 0 | ||||||||||||||||||||||||
375 | d->viewItems[i].spanning = span; never executed: d->viewItems[i].spanning = span; | 0 | ||||||||||||||||||||||||
376 | - | |||||||||||||||||||||||||
377 | d->viewport->update(); | - | ||||||||||||||||||||||||
378 | } never executed: end of block | 0 | ||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | - | |||||||||||||||||||||||||
383 | void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) | - | ||||||||||||||||||||||||
384 | { | - | ||||||||||||||||||||||||
385 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | if (d->delayedPendingLayout
| 0 | ||||||||||||||||||||||||
389 | return; never executed: return; | 0 | ||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | - | |||||||||||||||||||||||||
394 | bool sizeChanged = false; | - | ||||||||||||||||||||||||
395 | int topViewIndex = d->viewIndex(topLeft); | - | ||||||||||||||||||||||||
396 | if (topViewIndex == 0
| 0 | ||||||||||||||||||||||||
397 | int newDefaultItemHeight = indexRowSizeHint(topLeft); | - | ||||||||||||||||||||||||
398 | sizeChanged = d->defaultItemHeight != newDefaultItemHeight; | - | ||||||||||||||||||||||||
399 | d->defaultItemHeight = newDefaultItemHeight; | - | ||||||||||||||||||||||||
400 | } never executed: end of block | 0 | ||||||||||||||||||||||||
401 | - | |||||||||||||||||||||||||
402 | if (topViewIndex != -1
| 0 | ||||||||||||||||||||||||
403 | if (topLeft.row() == bottomRight.row()
| 0 | ||||||||||||||||||||||||
404 | int oldHeight = d->itemHeight(topViewIndex); | - | ||||||||||||||||||||||||
405 | d->invalidateHeightCache(topViewIndex); | - | ||||||||||||||||||||||||
406 | sizeChanged |= (oldHeight != d->itemHeight(topViewIndex)); | - | ||||||||||||||||||||||||
407 | if (topLeft.column() == 0
| 0 | ||||||||||||||||||||||||
408 | d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft); never executed: d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft); | 0 | ||||||||||||||||||||||||
409 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
410 | int bottomViewIndex = d->viewIndex(bottomRight); | - | ||||||||||||||||||||||||
411 | for (int i = topViewIndex; i <= bottomViewIndex
| 0 | ||||||||||||||||||||||||
412 | int oldHeight = d->itemHeight(i); | - | ||||||||||||||||||||||||
413 | d->invalidateHeightCache(i); | - | ||||||||||||||||||||||||
414 | sizeChanged |= (oldHeight != d->itemHeight(i)); | - | ||||||||||||||||||||||||
415 | if (topLeft.column() == 0
| 0 | ||||||||||||||||||||||||
416 | d->viewItems[i].hasChildren = d->hasVisibleChildren(d->viewItems.at(i).index); never executed: d->viewItems[i].hasChildren = d->hasVisibleChildren(d->viewItems.at(i).index); | 0 | ||||||||||||||||||||||||
417 | } never executed: end of block | 0 | ||||||||||||||||||||||||
418 | } never executed: end of block | 0 | ||||||||||||||||||||||||
419 | } | - | ||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||
421 | if (sizeChanged
| 0 | ||||||||||||||||||||||||
422 | d->updateScrollBars(); | - | ||||||||||||||||||||||||
423 | d->viewport->update(); | - | ||||||||||||||||||||||||
424 | } never executed: end of block | 0 | ||||||||||||||||||||||||
425 | QAbstractItemView::dataChanged(topLeft, bottomRight, roles); | - | ||||||||||||||||||||||||
426 | } never executed: end of block | 0 | ||||||||||||||||||||||||
427 | void QTreeView::hideColumn(int column) | - | ||||||||||||||||||||||||
428 | { | - | ||||||||||||||||||||||||
429 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
430 | d->header->hideSection(column); | - | ||||||||||||||||||||||||
431 | } never executed: end of block | 0 | ||||||||||||||||||||||||
432 | - | |||||||||||||||||||||||||
433 | - | |||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | - | |||||||||||||||||||||||||
438 | void QTreeView::showColumn(int column) | - | ||||||||||||||||||||||||
439 | { | - | ||||||||||||||||||||||||
440 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
441 | d->header->showSection(column); | - | ||||||||||||||||||||||||
442 | } never executed: end of block | 0 | ||||||||||||||||||||||||
443 | void QTreeView::expand(const QModelIndex &index) | - | ||||||||||||||||||||||||
444 | { | - | ||||||||||||||||||||||||
445 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
446 | if (!d->isIndexValid(index)
| 0 | ||||||||||||||||||||||||
447 | return; never executed: return; | 0 | ||||||||||||||||||||||||
448 | if (index.flags() & Qt::ItemNeverHasChildren
| 0 | ||||||||||||||||||||||||
449 | return; never executed: return; | 0 | ||||||||||||||||||||||||
450 | if (d->isIndexExpanded(index)
| 0 | ||||||||||||||||||||||||
451 | return; never executed: return; | 0 | ||||||||||||||||||||||||
452 | if (d->delayedPendingLayout
| 0 | ||||||||||||||||||||||||
453 | - | |||||||||||||||||||||||||
454 | if (d->storeExpanded(index)
| 0 | ||||||||||||||||||||||||
455 | expanded(index); never executed: expanded(index); | 0 | ||||||||||||||||||||||||
456 | return; never executed: return; | 0 | ||||||||||||||||||||||||
457 | } | - | ||||||||||||||||||||||||
458 | - | |||||||||||||||||||||||||
459 | int i = d->viewIndex(index); | - | ||||||||||||||||||||||||
460 | if (i != -1
| 0 | ||||||||||||||||||||||||
461 | d->expand(i, true); | - | ||||||||||||||||||||||||
462 | if (!d->isAnimating()
| 0 | ||||||||||||||||||||||||
463 | updateGeometries(); | - | ||||||||||||||||||||||||
464 | d->viewport->update(); | - | ||||||||||||||||||||||||
465 | } never executed: end of block | 0 | ||||||||||||||||||||||||
466 | } never executed: else if (d->storeExpanded(index)end of block
| 0 | ||||||||||||||||||||||||
467 | expanded(index); | - | ||||||||||||||||||||||||
468 | } never executed: end of block | 0 | ||||||||||||||||||||||||
469 | } never executed: end of block | 0 | ||||||||||||||||||||||||
470 | void QTreeView::collapse(const QModelIndex &index) | - | ||||||||||||||||||||||||
471 | { | - | ||||||||||||||||||||||||
472 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
473 | if (!d->isIndexValid(index)
| 0 | ||||||||||||||||||||||||
474 | return; never executed: return; | 0 | ||||||||||||||||||||||||
475 | if (!d->isIndexExpanded(index)
| 0 | ||||||||||||||||||||||||
476 | return; never executed: return; | 0 | ||||||||||||||||||||||||
477 | - | |||||||||||||||||||||||||
478 | d->delayedAutoScroll.stop(); | - | ||||||||||||||||||||||||
479 | - | |||||||||||||||||||||||||
480 | if (d->delayedPendingLayout
| 0 | ||||||||||||||||||||||||
481 | - | |||||||||||||||||||||||||
482 | if (d->isPersistent(index)
| 0 | ||||||||||||||||||||||||
483 | collapsed(index); never executed: collapsed(index); | 0 | ||||||||||||||||||||||||
484 | return; never executed: return; | 0 | ||||||||||||||||||||||||
485 | } | - | ||||||||||||||||||||||||
486 | int i = d->viewIndex(index); | - | ||||||||||||||||||||||||
487 | if (i != -1
| 0 | ||||||||||||||||||||||||
488 | d->collapse(i, true); | - | ||||||||||||||||||||||||
489 | if (!d->isAnimating()
| 0 | ||||||||||||||||||||||||
490 | updateGeometries(); | - | ||||||||||||||||||||||||
491 | viewport()->update(); | - | ||||||||||||||||||||||||
492 | } never executed: end of block | 0 | ||||||||||||||||||||||||
493 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
494 | if (d->isPersistent(index)
| 0 | ||||||||||||||||||||||||
495 | collapsed(index); never executed: collapsed(index); | 0 | ||||||||||||||||||||||||
496 | } never executed: end of block | 0 | ||||||||||||||||||||||||
497 | } | - | ||||||||||||||||||||||||
498 | bool QTreeView::isExpanded(const QModelIndex &index) const | - | ||||||||||||||||||||||||
499 | { | - | ||||||||||||||||||||||||
500 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
501 | return never executed: d->isIndexExpanded(index);return d->isIndexExpanded(index); never executed: return d->isIndexExpanded(index); | 0 | ||||||||||||||||||||||||
502 | } | - | ||||||||||||||||||||||||
503 | - | |||||||||||||||||||||||||
504 | - | |||||||||||||||||||||||||
505 | - | |||||||||||||||||||||||||
506 | - | |||||||||||||||||||||||||
507 | - | |||||||||||||||||||||||||
508 | - | |||||||||||||||||||||||||
509 | - | |||||||||||||||||||||||||
510 | void QTreeView::setExpanded(const QModelIndex &index, bool expanded) | - | ||||||||||||||||||||||||
511 | { | - | ||||||||||||||||||||||||
512 | if (expanded
| 0 | ||||||||||||||||||||||||
513 | this->expand(index); never executed: this->expand(index); | 0 | ||||||||||||||||||||||||
514 | else | - | ||||||||||||||||||||||||
515 | this->collapse(index); never executed: this->collapse(index); | 0 | ||||||||||||||||||||||||
516 | } | - | ||||||||||||||||||||||||
517 | void QTreeView::setSortingEnabled(bool enable) | - | ||||||||||||||||||||||||
518 | { | - | ||||||||||||||||||||||||
519 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
520 | header()->setSortIndicatorShown(enable); | - | ||||||||||||||||||||||||
521 | header()->setSectionsClickable(enable); | - | ||||||||||||||||||||||||
522 | if (enable
| 0 | ||||||||||||||||||||||||
523 | - | |||||||||||||||||||||||||
524 | - | |||||||||||||||||||||||||
525 | sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); | - | ||||||||||||||||||||||||
526 | connect(header(), qFlagLocation("2""sortIndicatorChanged(int,Qt::SortOrder)" "\0" __FILE__ ":" "878"), | - | ||||||||||||||||||||||||
527 | this, qFlagLocation("1""_q_sortIndicatorChanged(int,Qt::SortOrder)" "\0" __FILE__ ":" "879"), Qt::UniqueConnection); | - | ||||||||||||||||||||||||
528 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
529 | disconnect(header(), qFlagLocation("2""sortIndicatorChanged(int,Qt::SortOrder)" "\0" __FILE__ ":" "881"), | - | ||||||||||||||||||||||||
530 | this, qFlagLocation("1""_q_sortIndicatorChanged(int,Qt::SortOrder)" "\0" __FILE__ ":" "882")); | - | ||||||||||||||||||||||||
531 | } never executed: end of block | 0 | ||||||||||||||||||||||||
532 | d->sortingEnabled = enable; | - | ||||||||||||||||||||||||
533 | } never executed: end of block | 0 | ||||||||||||||||||||||||
534 | - | |||||||||||||||||||||||||
535 | bool QTreeView::isSortingEnabled() const | - | ||||||||||||||||||||||||
536 | { | - | ||||||||||||||||||||||||
537 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
538 | return never executed: d->sortingEnabled;return d->sortingEnabled; never executed: return d->sortingEnabled; | 0 | ||||||||||||||||||||||||
539 | } | - | ||||||||||||||||||||||||
540 | void QTreeView::setAnimated(bool animate) | - | ||||||||||||||||||||||||
541 | { | - | ||||||||||||||||||||||||
542 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
543 | d->animationsEnabled = animate; | - | ||||||||||||||||||||||||
544 | } never executed: end of block | 0 | ||||||||||||||||||||||||
545 | - | |||||||||||||||||||||||||
546 | bool QTreeView::isAnimated() const | - | ||||||||||||||||||||||||
547 | { | - | ||||||||||||||||||||||||
548 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
549 | return never executed: d->animationsEnabled;return d->animationsEnabled; never executed: return d->animationsEnabled; | 0 | ||||||||||||||||||||||||
550 | } | - | ||||||||||||||||||||||||
551 | void QTreeView::setAllColumnsShowFocus(bool enable) | - | ||||||||||||||||||||||||
552 | { | - | ||||||||||||||||||||||||
553 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
554 | if (d->allColumnsShowFocus == enable
| 0 | ||||||||||||||||||||||||
555 | return; never executed: return; | 0 | ||||||||||||||||||||||||
556 | d->allColumnsShowFocus = enable; | - | ||||||||||||||||||||||||
557 | d->viewport->update(); | - | ||||||||||||||||||||||||
558 | } never executed: end of block | 0 | ||||||||||||||||||||||||
559 | - | |||||||||||||||||||||||||
560 | bool QTreeView::allColumnsShowFocus() const | - | ||||||||||||||||||||||||
561 | { | - | ||||||||||||||||||||||||
562 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
563 | return never executed: d->allColumnsShowFocus;return d->allColumnsShowFocus; never executed: return d->allColumnsShowFocus; | 0 | ||||||||||||||||||||||||
564 | } | - | ||||||||||||||||||||||||
565 | void QTreeView::setWordWrap(bool on) | - | ||||||||||||||||||||||||
566 | { | - | ||||||||||||||||||||||||
567 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
568 | if (d->wrapItemText == on
| 0 | ||||||||||||||||||||||||
569 | return; never executed: return; | 0 | ||||||||||||||||||||||||
570 | d->wrapItemText = on; | - | ||||||||||||||||||||||||
571 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
572 | } never executed: end of block | 0 | ||||||||||||||||||||||||
573 | - | |||||||||||||||||||||||||
574 | bool QTreeView::wordWrap() const | - | ||||||||||||||||||||||||
575 | { | - | ||||||||||||||||||||||||
576 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
577 | return never executed: d->wrapItemText;return d->wrapItemText; never executed: return d->wrapItemText; | 0 | ||||||||||||||||||||||||
578 | } | - | ||||||||||||||||||||||||
579 | void QTreeView::setTreePosition(int index) | - | ||||||||||||||||||||||||
580 | { | - | ||||||||||||||||||||||||
581 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
582 | d->treePosition = index; | - | ||||||||||||||||||||||||
583 | update(); | - | ||||||||||||||||||||||||
584 | } never executed: end of block | 0 | ||||||||||||||||||||||||
585 | int QTreeView::treePosition() const | - | ||||||||||||||||||||||||
586 | { | - | ||||||||||||||||||||||||
587 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
588 | return never executed: d->treePosition;return d->treePosition; never executed: return d->treePosition; | 0 | ||||||||||||||||||||||||
589 | } | - | ||||||||||||||||||||||||
590 | - | |||||||||||||||||||||||||
591 | - | |||||||||||||||||||||||||
592 | - | |||||||||||||||||||||||||
593 | - | |||||||||||||||||||||||||
594 | void QTreeView::keyboardSearch(const QString &search) | - | ||||||||||||||||||||||||
595 | { | - | ||||||||||||||||||||||||
596 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
597 | if (!d->model->rowCount(d->root)
| 0 | ||||||||||||||||||||||||
598 | return; never executed: return; | 0 | ||||||||||||||||||||||||
599 | - | |||||||||||||||||||||||||
600 | QModelIndex start; | - | ||||||||||||||||||||||||
601 | if (currentIndex().isValid()
| 0 | ||||||||||||||||||||||||
602 | start = currentIndex(); never executed: start = currentIndex(); | 0 | ||||||||||||||||||||||||
603 | else | - | ||||||||||||||||||||||||
604 | start = d->model->index(0, 0, d->root); never executed: start = d->model->index(0, 0, d->root); | 0 | ||||||||||||||||||||||||
605 | - | |||||||||||||||||||||||||
606 | bool skipRow = false; | - | ||||||||||||||||||||||||
607 | bool keyboardTimeWasValid = d->keyboardInputTime.isValid(); | - | ||||||||||||||||||||||||
608 | qint64 keyboardInputTimeElapsed; | - | ||||||||||||||||||||||||
609 | if (keyboardTimeWasValid
| 0 | ||||||||||||||||||||||||
610 | keyboardInputTimeElapsed = d->keyboardInputTime.restart(); never executed: keyboardInputTimeElapsed = d->keyboardInputTime.restart(); | 0 | ||||||||||||||||||||||||
611 | else | - | ||||||||||||||||||||||||
612 | d->keyboardInputTime.start(); never executed: d->keyboardInputTime.start(); | 0 | ||||||||||||||||||||||||
613 | if (search.isEmpty()
| 0 | ||||||||||||||||||||||||
614 | || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()
| 0 | ||||||||||||||||||||||||
615 | d->keyboardInput = search; | - | ||||||||||||||||||||||||
616 | skipRow = currentIndex().isValid(); | - | ||||||||||||||||||||||||
617 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
618 | d->keyboardInput += search; | - | ||||||||||||||||||||||||
619 | } never executed: end of block | 0 | ||||||||||||||||||||||||
620 | - | |||||||||||||||||||||||||
621 | - | |||||||||||||||||||||||||
622 | bool sameKey = false; | - | ||||||||||||||||||||||||
623 | if (d->keyboardInput.length() > 1
| 0 | ||||||||||||||||||||||||
624 | int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1)); | - | ||||||||||||||||||||||||
625 | sameKey = (c == d->keyboardInput.length()); | - | ||||||||||||||||||||||||
626 | if (sameKey
| 0 | ||||||||||||||||||||||||
627 | skipRow = true; never executed: skipRow = true; | 0 | ||||||||||||||||||||||||
628 | } never executed: end of block | 0 | ||||||||||||||||||||||||
629 | - | |||||||||||||||||||||||||
630 | - | |||||||||||||||||||||||||
631 | if (skipRow
| 0 | ||||||||||||||||||||||||
632 | if (indexBelow(start).isValid()
| 0 | ||||||||||||||||||||||||
633 | start = indexBelow(start); never executed: start = indexBelow(start); | 0 | ||||||||||||||||||||||||
634 | else | - | ||||||||||||||||||||||||
635 | start = d->model->index(0, start.column(), d->root); never executed: start = d->model->index(0, start.column(), d->root); | 0 | ||||||||||||||||||||||||
636 | } | - | ||||||||||||||||||||||||
637 | - | |||||||||||||||||||||||||
638 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
639 | int startIndex = d->viewIndex(start); | - | ||||||||||||||||||||||||
640 | if (startIndex <= -1
| 0 | ||||||||||||||||||||||||
641 | return; never executed: return; | 0 | ||||||||||||||||||||||||
642 | - | |||||||||||||||||||||||||
643 | int previousLevel = -1; | - | ||||||||||||||||||||||||
644 | int bestAbove = -1; | - | ||||||||||||||||||||||||
645 | int bestBelow = -1; | - | ||||||||||||||||||||||||
646 | QString searchString = sameKey
| 0 | ||||||||||||||||||||||||
647 | for (int i = 0; i < d->viewItems.count()
| 0 | ||||||||||||||||||||||||
648 | if ((
| 0 | ||||||||||||||||||||||||
649 | QModelIndex searchFrom = d->viewItems.at(i).index; | - | ||||||||||||||||||||||||
650 | if (start.column() > 0
| 0 | ||||||||||||||||||||||||
651 | searchFrom = searchFrom.sibling(searchFrom.row(), start.column()); never executed: searchFrom = searchFrom.sibling(searchFrom.row(), start.column()); | 0 | ||||||||||||||||||||||||
652 | if (searchFrom.parent() == start.parent()
| 0 | ||||||||||||||||||||||||
653 | searchFrom = start; never executed: searchFrom = start; | 0 | ||||||||||||||||||||||||
654 | QModelIndexList match = d->model->match(searchFrom, Qt::DisplayRole, searchString); | - | ||||||||||||||||||||||||
655 | if (match.count()
| 0 | ||||||||||||||||||||||||
656 | int hitIndex = d->viewIndex(match.at(0)); | - | ||||||||||||||||||||||||
657 | if (hitIndex >= 0
| 0 | ||||||||||||||||||||||||
658 | bestAbove = bestAbove == -1
never executed: bestAbove = bestAbove == -1 ? hitIndex : qMin(hitIndex, bestAbove); | 0 | ||||||||||||||||||||||||
659 | else if (hitIndex >= startIndex
| 0 | ||||||||||||||||||||||||
660 | bestBelow = bestBelow == -1
never executed: bestBelow = bestBelow == -1 ? hitIndex : qMin(hitIndex, bestBelow); | 0 | ||||||||||||||||||||||||
661 | } never executed: end of block | 0 | ||||||||||||||||||||||||
662 | } never executed: end of block | 0 | ||||||||||||||||||||||||
663 | previousLevel = d->viewItems.at(i).level; | - | ||||||||||||||||||||||||
664 | } never executed: end of block | 0 | ||||||||||||||||||||||||
665 | - | |||||||||||||||||||||||||
666 | QModelIndex index; | - | ||||||||||||||||||||||||
667 | if (bestBelow > -1
| 0 | ||||||||||||||||||||||||
668 | index = d->viewItems.at(bestBelow).index; never executed: index = d->viewItems.at(bestBelow).index; | 0 | ||||||||||||||||||||||||
669 | else if (bestAbove > -1
| 0 | ||||||||||||||||||||||||
670 | index = d->viewItems.at(bestAbove).index; never executed: index = d->viewItems.at(bestAbove).index; | 0 | ||||||||||||||||||||||||
671 | - | |||||||||||||||||||||||||
672 | if (start.column() > 0
| 0 | ||||||||||||||||||||||||
673 | index = index.sibling(index.row(), start.column()); never executed: index = index.sibling(index.row(), start.column()); | 0 | ||||||||||||||||||||||||
674 | - | |||||||||||||||||||||||||
675 | if (index.isValid()
| 0 | ||||||||||||||||||||||||
676 | QItemSelectionModel::SelectionFlags flags = (d->selectionMode == SingleSelection
| 0 | ||||||||||||||||||||||||
677 | ? QItemSelectionModel::SelectionFlags( | - | ||||||||||||||||||||||||
678 | QItemSelectionModel::ClearAndSelect | - | ||||||||||||||||||||||||
679 | |d->selectionBehaviorFlags()) | - | ||||||||||||||||||||||||
680 | : QItemSelectionModel::SelectionFlags( | - | ||||||||||||||||||||||||
681 | QItemSelectionModel::NoUpdate)); | - | ||||||||||||||||||||||||
682 | selectionModel()->setCurrentIndex(index, flags); | - | ||||||||||||||||||||||||
683 | } never executed: end of block | 0 | ||||||||||||||||||||||||
684 | } never executed: end of block | 0 | ||||||||||||||||||||||||
685 | - | |||||||||||||||||||||||||
686 | - | |||||||||||||||||||||||||
687 | - | |||||||||||||||||||||||||
688 | - | |||||||||||||||||||||||||
689 | - | |||||||||||||||||||||||||
690 | QRect QTreeView::visualRect(const QModelIndex &index) const | - | ||||||||||||||||||||||||
691 | { | - | ||||||||||||||||||||||||
692 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
693 | - | |||||||||||||||||||||||||
694 | if (!d->isIndexValid(index)
| 0 | ||||||||||||||||||||||||
695 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
696 | - | |||||||||||||||||||||||||
697 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||
699 | int vi = d->viewIndex(index); | - | ||||||||||||||||||||||||
700 | if (vi < 0
| 0 | ||||||||||||||||||||||||
701 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
702 | - | |||||||||||||||||||||||||
703 | bool spanning = d->viewItems.at(vi).spanning; | - | ||||||||||||||||||||||||
704 | - | |||||||||||||||||||||||||
705 | - | |||||||||||||||||||||||||
706 | int x = (spanning
| 0 | ||||||||||||||||||||||||
707 | int w = (spanning
| 0 | ||||||||||||||||||||||||
708 | - | |||||||||||||||||||||||||
709 | if (d->isTreePosition(index.column())
| 0 | ||||||||||||||||||||||||
710 | int i = d->indentationForItem(vi); | - | ||||||||||||||||||||||||
711 | w -= i; | - | ||||||||||||||||||||||||
712 | if (!isRightToLeft()
| 0 | ||||||||||||||||||||||||
713 | x += i; never executed: x += i; | 0 | ||||||||||||||||||||||||
714 | } never executed: end of block | 0 | ||||||||||||||||||||||||
715 | - | |||||||||||||||||||||||||
716 | int y = d->coordinateForItem(vi); | - | ||||||||||||||||||||||||
717 | int h = d->itemHeight(vi); | - | ||||||||||||||||||||||||
718 | - | |||||||||||||||||||||||||
719 | return never executed: QRect(x, y, w, h);return QRect(x, y, w, h); never executed: return QRect(x, y, w, h); | 0 | ||||||||||||||||||||||||
720 | } | - | ||||||||||||||||||||||||
721 | void QTreeView::scrollTo(const QModelIndex &index, ScrollHint hint) | - | ||||||||||||||||||||||||
722 | { | - | ||||||||||||||||||||||||
723 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
724 | - | |||||||||||||||||||||||||
725 | if (!d->isIndexValid(index)
| 0 | ||||||||||||||||||||||||
726 | return; never executed: return; | 0 | ||||||||||||||||||||||||
727 | - | |||||||||||||||||||||||||
728 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
729 | d->updateScrollBars(); | - | ||||||||||||||||||||||||
730 | - | |||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||
732 | QModelIndex parent = index.parent(); | - | ||||||||||||||||||||||||
733 | while (parent != d->root
| 0 | ||||||||||||||||||||||||
734 | if (!isExpanded(parent)
| 0 | ||||||||||||||||||||||||
735 | expand(parent); never executed: expand(parent); | 0 | ||||||||||||||||||||||||
736 | parent = d->model->parent(parent); | - | ||||||||||||||||||||||||
737 | } never executed: end of block | 0 | ||||||||||||||||||||||||
738 | - | |||||||||||||||||||||||||
739 | int item = d->viewIndex(index); | - | ||||||||||||||||||||||||
740 | if (item < 0
| 0 | ||||||||||||||||||||||||
741 | return; never executed: return; | 0 | ||||||||||||||||||||||||
742 | - | |||||||||||||||||||||||||
743 | QRect area = d->viewport->rect(); | - | ||||||||||||||||||||||||
744 | - | |||||||||||||||||||||||||
745 | - | |||||||||||||||||||||||||
746 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
747 | int top = verticalScrollBar()->value(); | - | ||||||||||||||||||||||||
748 | int bottom = top + verticalScrollBar()->pageStep(); | - | ||||||||||||||||||||||||
749 | if (hint == EnsureVisible
| 0 | ||||||||||||||||||||||||
750 | - | |||||||||||||||||||||||||
751 | } never executed: else if (hint == PositionAtTopend of block
| 0 | ||||||||||||||||||||||||
752 | verticalScrollBar()->setValue(item); | - | ||||||||||||||||||||||||
753 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
754 | const int currentItemHeight = d->itemHeight(item); | - | ||||||||||||||||||||||||
755 | int y = (hint == PositionAtCenter
| 0 | ||||||||||||||||||||||||
756 | - | |||||||||||||||||||||||||
757 | ? area.height() / 2 + currentItemHeight - 1 | - | ||||||||||||||||||||||||
758 | - | |||||||||||||||||||||||||
759 | : area.height()); | - | ||||||||||||||||||||||||
760 | if (y > currentItemHeight
| 0 | ||||||||||||||||||||||||
761 | while (item >= 0
| 0 | ||||||||||||||||||||||||
762 | y -= d->itemHeight(item); | - | ||||||||||||||||||||||||
763 | if (y < 0
| 0 | ||||||||||||||||||||||||
764 | item++; | - | ||||||||||||||||||||||||
765 | break; never executed: break; | 0 | ||||||||||||||||||||||||
766 | } | - | ||||||||||||||||||||||||
767 | item--; | - | ||||||||||||||||||||||||
768 | } never executed: end of block | 0 | ||||||||||||||||||||||||
769 | } never executed: end of block | 0 | ||||||||||||||||||||||||
770 | verticalScrollBar()->setValue(item); | - | ||||||||||||||||||||||||
771 | } never executed: end of block | 0 | ||||||||||||||||||||||||
772 | } else { | - | ||||||||||||||||||||||||
773 | QRect rect(columnViewportPosition(index.column()), | - | ||||||||||||||||||||||||
774 | d->coordinateForItem(item), | - | ||||||||||||||||||||||||
775 | columnWidth(index.column()), | - | ||||||||||||||||||||||||
776 | d->itemHeight(item)); | - | ||||||||||||||||||||||||
777 | - | |||||||||||||||||||||||||
778 | if (rect.isEmpty()
| 0 | ||||||||||||||||||||||||
779 | - | |||||||||||||||||||||||||
780 | } never executed: else if (hint == EnsureVisibleend of block
| 0 | ||||||||||||||||||||||||
781 | d->viewport->update(rect); | - | ||||||||||||||||||||||||
782 | - | |||||||||||||||||||||||||
783 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
784 | bool above = (hint == EnsureVisible
| 0 | ||||||||||||||||||||||||
785 | && (rect.top() < area.top()
| 0 | ||||||||||||||||||||||||
786 | || area.height() < rect.height()
| 0 | ||||||||||||||||||||||||
787 | bool below = (hint == EnsureVisible
| 0 | ||||||||||||||||||||||||
788 | && rect.bottom() > area.bottom()
| 0 | ||||||||||||||||||||||||
789 | && rect.height() < area.height()
| 0 | ||||||||||||||||||||||||
790 | - | |||||||||||||||||||||||||
791 | int verticalValue = verticalScrollBar()->value(); | - | ||||||||||||||||||||||||
792 | if (hint == PositionAtTop
| 0 | ||||||||||||||||||||||||
793 | verticalValue += rect.top(); never executed: verticalValue += rect.top(); | 0 | ||||||||||||||||||||||||
794 | else if (hint == PositionAtBottom
| 0 | ||||||||||||||||||||||||
795 | verticalValue += rect.bottom() - area.height(); never executed: verticalValue += rect.bottom() - area.height(); | 0 | ||||||||||||||||||||||||
796 | else if (hint == PositionAtCenter
| 0 | ||||||||||||||||||||||||
797 | verticalValue += rect.top() - ((area.height() - rect.height()) / 2); never executed: verticalValue += rect.top() - ((area.height() - rect.height()) / 2); | 0 | ||||||||||||||||||||||||
798 | verticalScrollBar()->setValue(verticalValue); | - | ||||||||||||||||||||||||
799 | } never executed: end of block | 0 | ||||||||||||||||||||||||
800 | } | - | ||||||||||||||||||||||||
801 | - | |||||||||||||||||||||||||
802 | int viewportWidth = d->viewport->width(); | - | ||||||||||||||||||||||||
803 | int horizontalOffset = d->header->offset(); | - | ||||||||||||||||||||||||
804 | int horizontalPosition = d->header->sectionPosition(index.column()); | - | ||||||||||||||||||||||||
805 | int cellWidth = d->header->sectionSize(index.column()); | - | ||||||||||||||||||||||||
806 | - | |||||||||||||||||||||||||
807 | if (hint == PositionAtCenter
| 0 | ||||||||||||||||||||||||
808 | horizontalScrollBar()->setValue(horizontalPosition - ((viewportWidth - cellWidth) / 2)); | - | ||||||||||||||||||||||||
809 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
810 | if (horizontalPosition - horizontalOffset < 0
| 0 | ||||||||||||||||||||||||
811 | horizontalScrollBar()->setValue(horizontalPosition); never executed: horizontalScrollBar()->setValue(horizontalPosition); | 0 | ||||||||||||||||||||||||
812 | else if (horizontalPosition - horizontalOffset + cellWidth > viewportWidth
| 0 | ||||||||||||||||||||||||
813 | horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth); never executed: horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth); | 0 | ||||||||||||||||||||||||
814 | } never executed: end of block | 0 | ||||||||||||||||||||||||
815 | } | - | ||||||||||||||||||||||||
816 | - | |||||||||||||||||||||||||
817 | - | |||||||||||||||||||||||||
818 | - | |||||||||||||||||||||||||
819 | - | |||||||||||||||||||||||||
820 | void QTreeView::timerEvent(QTimerEvent *event) | - | ||||||||||||||||||||||||
821 | { | - | ||||||||||||||||||||||||
822 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
823 | if (event->timerId() == d->columnResizeTimerID
| 0 | ||||||||||||||||||||||||
824 | updateGeometries(); | - | ||||||||||||||||||||||||
825 | killTimer(d->columnResizeTimerID); | - | ||||||||||||||||||||||||
826 | d->columnResizeTimerID = 0; | - | ||||||||||||||||||||||||
827 | QRect rect; | - | ||||||||||||||||||||||||
828 | int viewportHeight = d->viewport->height(); | - | ||||||||||||||||||||||||
829 | int viewportWidth = d->viewport->width(); | - | ||||||||||||||||||||||||
830 | for (int i = d->columnsToUpdate.size() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
831 | int column = d->columnsToUpdate.at(i); | - | ||||||||||||||||||||||||
832 | int x = columnViewportPosition(column); | - | ||||||||||||||||||||||||
833 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
834 | rect |= QRect(0, 0, x + columnWidth(column), viewportHeight); never executed: rect |= QRect(0, 0, x + columnWidth(column), viewportHeight); | 0 | ||||||||||||||||||||||||
835 | else | - | ||||||||||||||||||||||||
836 | rect |= QRect(x, 0, viewportWidth - x, viewportHeight); never executed: rect |= QRect(x, 0, viewportWidth - x, viewportHeight); | 0 | ||||||||||||||||||||||||
837 | } | - | ||||||||||||||||||||||||
838 | d->viewport->update(rect.normalized()); | - | ||||||||||||||||||||||||
839 | d->columnsToUpdate.clear(); | - | ||||||||||||||||||||||||
840 | } never executed: else if (event->timerId() == d->openTimer.timerId()end of block
| 0 | ||||||||||||||||||||||||
841 | QPoint pos = d->viewport->mapFromGlobal(QCursor::pos()); | - | ||||||||||||||||||||||||
842 | if (state() == QAbstractItemView::DraggingState
| 0 | ||||||||||||||||||||||||
843 | && d->viewport->rect().contains(pos)
| 0 | ||||||||||||||||||||||||
844 | QModelIndex index = indexAt(pos); | - | ||||||||||||||||||||||||
845 | setExpanded(index, !isExpanded(index)); | - | ||||||||||||||||||||||||
846 | } never executed: end of block | 0 | ||||||||||||||||||||||||
847 | d->openTimer.stop(); | - | ||||||||||||||||||||||||
848 | } never executed: end of block | 0 | ||||||||||||||||||||||||
849 | - | |||||||||||||||||||||||||
850 | QAbstractItemView::timerEvent(event); | - | ||||||||||||||||||||||||
851 | } never executed: end of block | 0 | ||||||||||||||||||||||||
852 | - | |||||||||||||||||||||||||
853 | - | |||||||||||||||||||||||||
854 | - | |||||||||||||||||||||||||
855 | - | |||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||
857 | void QTreeView::dragMoveEvent(QDragMoveEvent *event) | - | ||||||||||||||||||||||||
858 | { | - | ||||||||||||||||||||||||
859 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
860 | if (d->autoExpandDelay >= 0
| 0 | ||||||||||||||||||||||||
861 | d->openTimer.start(d->autoExpandDelay, this); never executed: d->openTimer.start(d->autoExpandDelay, this); | 0 | ||||||||||||||||||||||||
862 | QAbstractItemView::dragMoveEvent(event); | - | ||||||||||||||||||||||||
863 | } never executed: end of block | 0 | ||||||||||||||||||||||||
864 | - | |||||||||||||||||||||||||
865 | - | |||||||||||||||||||||||||
866 | - | |||||||||||||||||||||||||
867 | - | |||||||||||||||||||||||||
868 | - | |||||||||||||||||||||||||
869 | bool QTreeView::viewportEvent(QEvent *event) | - | ||||||||||||||||||||||||
870 | { | - | ||||||||||||||||||||||||
871 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
872 | switch (event->type()) { | - | ||||||||||||||||||||||||
873 | case never executed: QEvent::HoverEnter:case QEvent::HoverEnter: never executed: case QEvent::HoverEnter: | 0 | ||||||||||||||||||||||||
874 | case never executed: QEvent::HoverLeave:case QEvent::HoverLeave: never executed: case QEvent::HoverLeave: | 0 | ||||||||||||||||||||||||
875 | case never executed: QEvent::HoverMove:case QEvent::HoverMove: never executed: {case QEvent::HoverMove: | 0 | ||||||||||||||||||||||||
876 | QHoverEvent *he = static_cast<QHoverEvent*>(event); | - | ||||||||||||||||||||||||
877 | int oldBranch = d->hoverBranch; | - | ||||||||||||||||||||||||
878 | d->hoverBranch = d->itemDecorationAt(he->pos()); | - | ||||||||||||||||||||||||
879 | QModelIndex newIndex = indexAt(he->pos()); | - | ||||||||||||||||||||||||
880 | if (d->hover != newIndex
| 0 | ||||||||||||||||||||||||
881 | - | |||||||||||||||||||||||||
882 | - | |||||||||||||||||||||||||
883 | QRect rect = visualRect(newIndex); | - | ||||||||||||||||||||||||
884 | rect.setX(0); | - | ||||||||||||||||||||||||
885 | rect.setWidth(viewport()->width()); | - | ||||||||||||||||||||||||
886 | viewport()->update(rect); | - | ||||||||||||||||||||||||
887 | } never executed: end of block | 0 | ||||||||||||||||||||||||
888 | break; never executed: }break; | 0 | ||||||||||||||||||||||||
889 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
890 | break; never executed: break; | 0 | ||||||||||||||||||||||||
891 | } | - | ||||||||||||||||||||||||
892 | return never executed: QAbstractItemView::viewportEvent(event);return QAbstractItemView::viewportEvent(event); never executed: return QAbstractItemView::viewportEvent(event); | 0 | ||||||||||||||||||||||||
893 | } | - | ||||||||||||||||||||||||
894 | - | |||||||||||||||||||||||||
895 | - | |||||||||||||||||||||||||
896 | - | |||||||||||||||||||||||||
897 | - | |||||||||||||||||||||||||
898 | void QTreeView::paintEvent(QPaintEvent *event) | - | ||||||||||||||||||||||||
899 | { | - | ||||||||||||||||||||||||
900 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
901 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
902 | QPainter painter(viewport()); | - | ||||||||||||||||||||||||
903 | - | |||||||||||||||||||||||||
904 | if (d->isAnimating()
| 0 | ||||||||||||||||||||||||
905 | drawTree(&painter, event->region() - d->animatedOperation.rect()); | - | ||||||||||||||||||||||||
906 | d->drawAnimatedOperation(&painter); | - | ||||||||||||||||||||||||
907 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
908 | - | |||||||||||||||||||||||||
909 | { | - | ||||||||||||||||||||||||
910 | drawTree(&painter, event->region()); | - | ||||||||||||||||||||||||
911 | - | |||||||||||||||||||||||||
912 | d->paintDropIndicator(&painter); | - | ||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||
914 | } never executed: end of block | 0 | ||||||||||||||||||||||||
915 | } | - | ||||||||||||||||||||||||
916 | - | |||||||||||||||||||||||||
917 | int QTreeViewPrivate::logicalIndexForTree() const | - | ||||||||||||||||||||||||
918 | { | - | ||||||||||||||||||||||||
919 | int index = treePosition; | - | ||||||||||||||||||||||||
920 | if (index < 0
| 0 | ||||||||||||||||||||||||
921 | index = header->logicalIndex(0); never executed: index = header->logicalIndex(0); | 0 | ||||||||||||||||||||||||
922 | return never executed: index;return index; never executed: return index; | 0 | ||||||||||||||||||||||||
923 | } | - | ||||||||||||||||||||||||
924 | - | |||||||||||||||||||||||||
925 | void QTreeViewPrivate::paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItem *option, int y, int bottom) const | - | ||||||||||||||||||||||||
926 | { | - | ||||||||||||||||||||||||
927 | const QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
928 | if (!alternatingColors
| 0 | ||||||||||||||||||||||||
929 | return; never executed: return; | 0 | ||||||||||||||||||||||||
930 | int rowHeight = defaultItemHeight; | - | ||||||||||||||||||||||||
931 | if (rowHeight <= 0
| 0 | ||||||||||||||||||||||||
932 | rowHeight = itemDelegate->sizeHint(*option, QModelIndex()).height(); | - | ||||||||||||||||||||||||
933 | if (rowHeight <= 0
| 0 | ||||||||||||||||||||||||
934 | return; never executed: return; | 0 | ||||||||||||||||||||||||
935 | } never executed: end of block | 0 | ||||||||||||||||||||||||
936 | while (y <= bottom
| 0 | ||||||||||||||||||||||||
937 | option->rect.setRect(0, y, viewport->width(), rowHeight); | - | ||||||||||||||||||||||||
938 | if (current & 1
| 0 | ||||||||||||||||||||||||
939 | option->features |= QStyleOptionViewItem::Alternate; | - | ||||||||||||||||||||||||
940 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
941 | option->features &= ~QStyleOptionViewItem::Alternate; | - | ||||||||||||||||||||||||
942 | } never executed: end of block | 0 | ||||||||||||||||||||||||
943 | ++current; | - | ||||||||||||||||||||||||
944 | q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, option, painter, q); | - | ||||||||||||||||||||||||
945 | y += rowHeight; | - | ||||||||||||||||||||||||
946 | } never executed: end of block | 0 | ||||||||||||||||||||||||
947 | } never executed: end of block | 0 | ||||||||||||||||||||||||
948 | - | |||||||||||||||||||||||||
949 | bool QTreeViewPrivate::expandOrCollapseItemAtPos(const QPoint &pos) | - | ||||||||||||||||||||||||
950 | { | - | ||||||||||||||||||||||||
951 | QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
952 | - | |||||||||||||||||||||||||
953 | if ((state != QAbstractItemView::NoState
| 0 | ||||||||||||||||||||||||
954 | && state != QAbstractItemView::EditingState
| 0 | ||||||||||||||||||||||||
955 | || !viewport->rect().contains(pos)
| 0 | ||||||||||||||||||||||||
956 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
957 | - | |||||||||||||||||||||||||
958 | int i = itemDecorationAt(pos); | - | ||||||||||||||||||||||||
959 | if ((
| 0 | ||||||||||||||||||||||||
960 | if (viewItems.at(i).expanded
| 0 | ||||||||||||||||||||||||
961 | collapse(i, true); never executed: collapse(i, true); | 0 | ||||||||||||||||||||||||
962 | else | - | ||||||||||||||||||||||||
963 | expand(i, true); never executed: expand(i, true); | 0 | ||||||||||||||||||||||||
964 | if (!isAnimating()
| 0 | ||||||||||||||||||||||||
965 | q->updateGeometries(); | - | ||||||||||||||||||||||||
966 | viewport->update(); | - | ||||||||||||||||||||||||
967 | } never executed: end of block | 0 | ||||||||||||||||||||||||
968 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
969 | } | - | ||||||||||||||||||||||||
970 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
971 | } | - | ||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||
973 | void QTreeViewPrivate::_q_modelDestroyed() | - | ||||||||||||||||||||||||
974 | { | - | ||||||||||||||||||||||||
975 | - | |||||||||||||||||||||||||
976 | - | |||||||||||||||||||||||||
977 | viewItems.clear(); | - | ||||||||||||||||||||||||
978 | QAbstractItemViewPrivate::_q_modelDestroyed(); | - | ||||||||||||||||||||||||
979 | } never executed: end of block | 0 | ||||||||||||||||||||||||
980 | - | |||||||||||||||||||||||||
981 | - | |||||||||||||||||||||||||
982 | - | |||||||||||||||||||||||||
983 | - | |||||||||||||||||||||||||
984 | - | |||||||||||||||||||||||||
985 | - | |||||||||||||||||||||||||
986 | QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const | - | ||||||||||||||||||||||||
987 | { | - | ||||||||||||||||||||||||
988 | ((!(r)) ? qt_assert("r",__FILE__,1409) : qt_noop()); | - | ||||||||||||||||||||||||
989 | const QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
990 | if (spanningIndexes.isEmpty()
| 0 | ||||||||||||||||||||||||
991 | return never executed: QAbstractItemViewPrivate::draggablePaintPairs(indexes, r);return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r); never executed: return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r); | 0 | ||||||||||||||||||||||||
992 | QModelIndexList list; | - | ||||||||||||||||||||||||
993 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(indexes)>::type> _container_((indexes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QModelIndex &idx = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
994 | if (idx.column() > 0
| 0 | ||||||||||||||||||||||||
995 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
996 | list << idx; | - | ||||||||||||||||||||||||
997 | } never executed: end of block | 0 | ||||||||||||||||||||||||
998 | return never executed: QAbstractItemViewPrivate::draggablePaintPairs(list, r);return QAbstractItemViewPrivate::draggablePaintPairs(list, r); never executed: return QAbstractItemViewPrivate::draggablePaintPairs(list, r); | 0 | ||||||||||||||||||||||||
999 | } | - | ||||||||||||||||||||||||
1000 | - | |||||||||||||||||||||||||
1001 | void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItem *option, const QModelIndex ¤t) const | - | ||||||||||||||||||||||||
1002 | { | - | ||||||||||||||||||||||||
1003 | const int row = viewIndex(current); | - | ||||||||||||||||||||||||
1004 | option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None) | - | ||||||||||||||||||||||||
1005 | | (viewItems.at(row).hasChildren ? QStyle::State_Children : QStyle::State_None) | - | ||||||||||||||||||||||||
1006 | | (viewItems.at(row).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None); | - | ||||||||||||||||||||||||
1007 | - | |||||||||||||||||||||||||
1008 | option->showDecorationSelected = (
| 0 | ||||||||||||||||||||||||
1009 | || option->showDecorationSelected
| 0 | ||||||||||||||||||||||||
1010 | - | |||||||||||||||||||||||||
1011 | QVector<int> logicalIndices; | - | ||||||||||||||||||||||||
1012 | QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList; | - | ||||||||||||||||||||||||
1013 | const bool spanning = viewItems.at(row).spanning; | - | ||||||||||||||||||||||||
1014 | const int left = (spanning
| 0 | ||||||||||||||||||||||||
1015 | const int right = (spanning
| 0 | ||||||||||||||||||||||||
1016 | calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right); | - | ||||||||||||||||||||||||
1017 | - | |||||||||||||||||||||||||
1018 | const int visualIndex = logicalIndices.indexOf(current.column()); | - | ||||||||||||||||||||||||
1019 | option->viewItemPosition = viewItemPosList.at(visualIndex); | - | ||||||||||||||||||||||||
1020 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1021 | void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const | - | ||||||||||||||||||||||||
1022 | { | - | ||||||||||||||||||||||||
1023 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1024 | const QVector<QTreeViewItem> viewItems = d->viewItems; | - | ||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||
1026 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||||||||
1027 | const QStyle::State state = option.state; | - | ||||||||||||||||||||||||
1028 | d->current = 0; | - | ||||||||||||||||||||||||
1029 | - | |||||||||||||||||||||||||
1030 | if (viewItems.count() == 0
| 0 | ||||||||||||||||||||||||
1031 | d->paintAlternatingRowColors(painter, &option, 0, region.boundingRect().bottom()+1); | - | ||||||||||||||||||||||||
1032 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1033 | } | - | ||||||||||||||||||||||||
1034 | - | |||||||||||||||||||||||||
1035 | int firstVisibleItemOffset = 0; | - | ||||||||||||||||||||||||
1036 | const int firstVisibleItem = d->firstVisibleItem(&firstVisibleItemOffset); | - | ||||||||||||||||||||||||
1037 | if (firstVisibleItem < 0
| 0 | ||||||||||||||||||||||||
1038 | d->paintAlternatingRowColors(painter, &option, 0, region.boundingRect().bottom()+1); | - | ||||||||||||||||||||||||
1039 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1040 | } | - | ||||||||||||||||||||||||
1041 | - | |||||||||||||||||||||||||
1042 | const int viewportWidth = d->viewport->width(); | - | ||||||||||||||||||||||||
1043 | - | |||||||||||||||||||||||||
1044 | QPoint hoverPos = d->viewport->mapFromGlobal(QCursor::pos()); | - | ||||||||||||||||||||||||
1045 | d->hoverBranch = d->itemDecorationAt(hoverPos); | - | ||||||||||||||||||||||||
1046 | - | |||||||||||||||||||||||||
1047 | QVector<QRect> rects = region.rects(); | - | ||||||||||||||||||||||||
1048 | QVector<int> drawn; | - | ||||||||||||||||||||||||
1049 | bool multipleRects = (rects.size() > 1); | - | ||||||||||||||||||||||||
1050 | for (int a = 0; a < rects.size()
| 0 | ||||||||||||||||||||||||
1051 | const QRect area = (multipleRects
| 0 | ||||||||||||||||||||||||
1052 | ? QRect(0, rects.at(a).y(), viewportWidth, rects.at(a).height()) | - | ||||||||||||||||||||||||
1053 | : rects.at(a)); | - | ||||||||||||||||||||||||
1054 | d->leftAndRight = d->startAndEndColumns(area); | - | ||||||||||||||||||||||||
1055 | - | |||||||||||||||||||||||||
1056 | int i = firstVisibleItem; | - | ||||||||||||||||||||||||
1057 | int y = firstVisibleItemOffset; | - | ||||||||||||||||||||||||
1058 | - | |||||||||||||||||||||||||
1059 | - | |||||||||||||||||||||||||
1060 | for (; i < viewItems.count()
| 0 | ||||||||||||||||||||||||
1061 | const int itemHeight = d->itemHeight(i); | - | ||||||||||||||||||||||||
1062 | if (y + itemHeight > area.top()
| 0 | ||||||||||||||||||||||||
1063 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1064 | y += itemHeight; | - | ||||||||||||||||||||||||
1065 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1066 | - | |||||||||||||||||||||||||
1067 | - | |||||||||||||||||||||||||
1068 | for (; i < viewItems.count()
| 0 | ||||||||||||||||||||||||
1069 | const int itemHeight = d->itemHeight(i); | - | ||||||||||||||||||||||||
1070 | option.rect.setRect(0, y, viewportWidth, itemHeight); | - | ||||||||||||||||||||||||
1071 | option.state = state | (viewItems.at(i).expanded ? QStyle::State_Open : QStyle::State_None) | - | ||||||||||||||||||||||||
1072 | | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None) | - | ||||||||||||||||||||||||
1073 | | (viewItems.at(i).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None); | - | ||||||||||||||||||||||||
1074 | d->current = i; | - | ||||||||||||||||||||||||
1075 | d->spanning = viewItems.at(i).spanning; | - | ||||||||||||||||||||||||
1076 | if (!multipleRects
| 0 | ||||||||||||||||||||||||
1077 | drawRow(painter, option, viewItems.at(i).index); | - | ||||||||||||||||||||||||
1078 | if (multipleRects
| 0 | ||||||||||||||||||||||||
1079 | drawn.append(i); never executed: drawn.append(i); | 0 | ||||||||||||||||||||||||
1080 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1081 | y += itemHeight; | - | ||||||||||||||||||||||||
1082 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1083 | - | |||||||||||||||||||||||||
1084 | if (y <= area.bottom()
| 0 | ||||||||||||||||||||||||
1085 | d->current = i; | - | ||||||||||||||||||||||||
1086 | d->paintAlternatingRowColors(painter, &option, y, area.bottom()); | - | ||||||||||||||||||||||||
1087 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1088 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1089 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1090 | - | |||||||||||||||||||||||||
1091 | - | |||||||||||||||||||||||||
1092 | static inline bool ancestorOf(QObject *widget, QObject *other) | - | ||||||||||||||||||||||||
1093 | { | - | ||||||||||||||||||||||||
1094 | for (QObject *parent = other; parent != 0
| 0 | ||||||||||||||||||||||||
1095 | if (parent == widget
| 0 | ||||||||||||||||||||||||
1096 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1097 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1098 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1099 | } | - | ||||||||||||||||||||||||
1100 | - | |||||||||||||||||||||||||
1101 | void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItem::ViewItemPosition> *itemPositions, int left, int right) const | - | ||||||||||||||||||||||||
1102 | { | - | ||||||||||||||||||||||||
1103 | const int columnCount = header->count(); | - | ||||||||||||||||||||||||
1104 | - | |||||||||||||||||||||||||
1105 | - | |||||||||||||||||||||||||
1106 | - | |||||||||||||||||||||||||
1107 | int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1; | - | ||||||||||||||||||||||||
1108 | for (int visualIndex = left - 1; visualIndex >= 0
| 0 | ||||||||||||||||||||||||
1109 | int logicalIndex = header->logicalIndex(visualIndex); | - | ||||||||||||||||||||||||
1110 | if (!header->isSectionHidden(logicalIndex)
| 0 | ||||||||||||||||||||||||
1111 | logicalIndexBeforeLeft = logicalIndex; | - | ||||||||||||||||||||||||
1112 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1113 | } | - | ||||||||||||||||||||||||
1114 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1115 | - | |||||||||||||||||||||||||
1116 | for (int visualIndex = left; visualIndex < columnCount
| 0 | ||||||||||||||||||||||||
1117 | int logicalIndex = header->logicalIndex(visualIndex); | - | ||||||||||||||||||||||||
1118 | if (!header->isSectionHidden(logicalIndex)
| 0 | ||||||||||||||||||||||||
1119 | if (visualIndex > right
| 0 | ||||||||||||||||||||||||
1120 | logicalIndexAfterRight = logicalIndex; | - | ||||||||||||||||||||||||
1121 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1122 | } | - | ||||||||||||||||||||||||
1123 | logicalIndices->append(logicalIndex); | - | ||||||||||||||||||||||||
1124 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1125 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1126 | - | |||||||||||||||||||||||||
1127 | itemPositions->resize(logicalIndices->count()); | - | ||||||||||||||||||||||||
1128 | for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices->count()
| 0 | ||||||||||||||||||||||||
1129 | const int headerSection = logicalIndices->at(currentLogicalSection); | - | ||||||||||||||||||||||||
1130 | - | |||||||||||||||||||||||||
1131 | int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices->count()
| 0 | ||||||||||||||||||||||||
1132 | ? logicalIndexAfterRight | - | ||||||||||||||||||||||||
1133 | : logicalIndices->at(currentLogicalSection + 1); | - | ||||||||||||||||||||||||
1134 | int prevLogicalSection = currentLogicalSection - 1 < 0
| 0 | ||||||||||||||||||||||||
1135 | ? logicalIndexBeforeLeft | - | ||||||||||||||||||||||||
1136 | : logicalIndices->at(currentLogicalSection - 1); | - | ||||||||||||||||||||||||
1137 | QStyleOptionViewItem::ViewItemPosition pos; | - | ||||||||||||||||||||||||
1138 | if (columnCount == 1
| 0 | ||||||||||||||||||||||||
1139 | || (headerSection == 0
| 0 | ||||||||||||||||||||||||
1140 | pos = QStyleOptionViewItem::OnlyOne; never executed: pos = QStyleOptionViewItem::OnlyOne; | 0 | ||||||||||||||||||||||||
1141 | else if (isTreePosition(headerSection)
| 0 | ||||||||||||||||||||||||
1142 | pos = QStyleOptionViewItem::Beginning; never executed: pos = QStyleOptionViewItem::Beginning; | 0 | ||||||||||||||||||||||||
1143 | else if (nextLogicalSection == 0
| 0 | ||||||||||||||||||||||||
1144 | pos = QStyleOptionViewItem::End; never executed: pos = QStyleOptionViewItem::End; | 0 | ||||||||||||||||||||||||
1145 | else | - | ||||||||||||||||||||||||
1146 | pos = QStyleOptionViewItem::Middle; never executed: pos = QStyleOptionViewItem::Middle; | 0 | ||||||||||||||||||||||||
1147 | (*itemPositions)[currentLogicalSection] = pos; | - | ||||||||||||||||||||||||
1148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1149 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1150 | - | |||||||||||||||||||||||||
1151 | - | |||||||||||||||||||||||||
1152 | - | |||||||||||||||||||||||||
1153 | - | |||||||||||||||||||||||||
1154 | - | |||||||||||||||||||||||||
1155 | int QTreeViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option, int i) const | - | ||||||||||||||||||||||||
1156 | { | - | ||||||||||||||||||||||||
1157 | QWidget *editor = editorForIndex(index).widget.data(); | - | ||||||||||||||||||||||||
1158 | if (editor
| 0 | ||||||||||||||||||||||||
1159 | hint = qMax(hint, editor->sizeHint().width()); | - | ||||||||||||||||||||||||
1160 | int min = editor->minimumSize().width(); | - | ||||||||||||||||||||||||
1161 | int max = editor->maximumSize().width(); | - | ||||||||||||||||||||||||
1162 | hint = qBound(min, hint, max); | - | ||||||||||||||||||||||||
1163 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1164 | int xhint = delegateForIndex(index)->sizeHint(option, index).width(); | - | ||||||||||||||||||||||||
1165 | hint = qMax(hint, xhint + (isTreePosition(index.column()) ? indentationForItem(i) : 0)); | - | ||||||||||||||||||||||||
1166 | return never executed: hint;return hint; never executed: return hint; | 0 | ||||||||||||||||||||||||
1167 | } | - | ||||||||||||||||||||||||
1168 | void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, | - | ||||||||||||||||||||||||
1169 | const QModelIndex &index) const | - | ||||||||||||||||||||||||
1170 | { | - | ||||||||||||||||||||||||
1171 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1172 | QStyleOptionViewItem opt = option; | - | ||||||||||||||||||||||||
1173 | const QPoint offset = d->scrollDelayOffset; | - | ||||||||||||||||||||||||
1174 | const int y = option.rect.y() + offset.y(); | - | ||||||||||||||||||||||||
1175 | const QModelIndex parent = index.parent(); | - | ||||||||||||||||||||||||
1176 | const QHeaderView *header = d->header; | - | ||||||||||||||||||||||||
1177 | const QModelIndex current = currentIndex(); | - | ||||||||||||||||||||||||
1178 | const QModelIndex hover = d->hover; | - | ||||||||||||||||||||||||
1179 | const bool reverse = isRightToLeft(); | - | ||||||||||||||||||||||||
1180 | const QStyle::State state = opt.state; | - | ||||||||||||||||||||||||
1181 | const bool spanning = d->spanning; | - | ||||||||||||||||||||||||
1182 | const int left = (spanning
| 0 | ||||||||||||||||||||||||
1183 | const int right = (spanning
| 0 | ||||||||||||||||||||||||
1184 | const bool alternate = d->alternatingColors; | - | ||||||||||||||||||||||||
1185 | const bool enabled = (state & QStyle::State_Enabled) != 0; | - | ||||||||||||||||||||||||
1186 | const bool allColumnsShowFocus = d->allColumnsShowFocus; | - | ||||||||||||||||||||||||
1187 | - | |||||||||||||||||||||||||
1188 | - | |||||||||||||||||||||||||
1189 | - | |||||||||||||||||||||||||
1190 | - | |||||||||||||||||||||||||
1191 | bool indexWidgetHasFocus = false; | - | ||||||||||||||||||||||||
1192 | if ((
| 0 | ||||||||||||||||||||||||
1193 | const int r = index.row(); | - | ||||||||||||||||||||||||
1194 | QWidget *fw = QApplication::focusWidget(); | - | ||||||||||||||||||||||||
1195 | for (int c = 0; c < header->count()
| 0 | ||||||||||||||||||||||||
1196 | QModelIndex idx = d->model->index(r, c, parent); | - | ||||||||||||||||||||||||
1197 | if (QWidget *editor = indexWidget(idx)
| 0 | ||||||||||||||||||||||||
1198 | if (ancestorOf(editor, fw)
| 0 | ||||||||||||||||||||||||
1199 | indexWidgetHasFocus = true; | - | ||||||||||||||||||||||||
1200 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1201 | } | - | ||||||||||||||||||||||||
1202 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1203 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1204 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1205 | - | |||||||||||||||||||||||||
1206 | const bool widgetHasFocus = hasFocus(); | - | ||||||||||||||||||||||||
1207 | bool currentRowHasFocus = false; | - | ||||||||||||||||||||||||
1208 | if (allColumnsShowFocus
| 0 | ||||||||||||||||||||||||
1209 | - | |||||||||||||||||||||||||
1210 | const int r = index.row(); | - | ||||||||||||||||||||||||
1211 | for (int c = 0; c < left
| 0 | ||||||||||||||||||||||||
1212 | QModelIndex idx = d->model->index(r, c, parent); | - | ||||||||||||||||||||||||
1213 | currentRowHasFocus = (idx == current); | - | ||||||||||||||||||||||||
1214 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1215 | QModelIndex parent = d->model->parent(index); | - | ||||||||||||||||||||||||
1216 | for (int c = right; c < header->count()
| 0 | ||||||||||||||||||||||||
1217 | currentRowHasFocus = (d->model->index(r, c, parent) == current); | - | ||||||||||||||||||||||||
1218 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1219 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1220 | - | |||||||||||||||||||||||||
1221 | - | |||||||||||||||||||||||||
1222 | - | |||||||||||||||||||||||||
1223 | opt.showDecorationSelected = (
| 0 | ||||||||||||||||||||||||
1224 | || option.showDecorationSelected
| 0 | ||||||||||||||||||||||||
1225 | - | |||||||||||||||||||||||||
1226 | int width, height = option.rect.height(); | - | ||||||||||||||||||||||||
1227 | int position; | - | ||||||||||||||||||||||||
1228 | QModelIndex modelIndex; | - | ||||||||||||||||||||||||
1229 | const bool hoverRow = selectionBehavior() == QAbstractItemView::SelectRows
| 0 | ||||||||||||||||||||||||
1230 | && index.parent() == hover.parent()
| 0 | ||||||||||||||||||||||||
1231 | && index.row() == hover.row()
| 0 | ||||||||||||||||||||||||
1232 | - | |||||||||||||||||||||||||
1233 | QVector<int> logicalIndices; | - | ||||||||||||||||||||||||
1234 | QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList; | - | ||||||||||||||||||||||||
1235 | d->calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right); | - | ||||||||||||||||||||||||
1236 | - | |||||||||||||||||||||||||
1237 | for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count()
| 0 | ||||||||||||||||||||||||
1238 | int headerSection = logicalIndices.at(currentLogicalSection); | - | ||||||||||||||||||||||||
1239 | position = columnViewportPosition(headerSection) + offset.x(); | - | ||||||||||||||||||||||||
1240 | width = header->sectionSize(headerSection); | - | ||||||||||||||||||||||||
1241 | - | |||||||||||||||||||||||||
1242 | if (spanning
| 0 | ||||||||||||||||||||||||
1243 | int lastSection = header->logicalIndex(header->count() - 1); | - | ||||||||||||||||||||||||
1244 | if (!reverse
| 0 | ||||||||||||||||||||||||
1245 | width = columnViewportPosition(lastSection) + header->sectionSize(lastSection) - position; | - | ||||||||||||||||||||||||
1246 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1247 | width += position - columnViewportPosition(lastSection); | - | ||||||||||||||||||||||||
1248 | position = columnViewportPosition(lastSection); | - | ||||||||||||||||||||||||
1249 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1250 | } | - | ||||||||||||||||||||||||
1251 | - | |||||||||||||||||||||||||
1252 | modelIndex = d->model->index(index.row(), headerSection, parent); | - | ||||||||||||||||||||||||
1253 | if (!modelIndex.isValid()
| 0 | ||||||||||||||||||||||||
1254 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1255 | opt.state = state; | - | ||||||||||||||||||||||||
1256 | - | |||||||||||||||||||||||||
1257 | opt.viewItemPosition = viewItemPosList.at(currentLogicalSection); | - | ||||||||||||||||||||||||
1258 | - | |||||||||||||||||||||||||
1259 | - | |||||||||||||||||||||||||
1260 | if (indexWidgetHasFocus
| 0 | ||||||||||||||||||||||||
1261 | opt.state |= QStyle::State_Active; never executed: opt.state |= QStyle::State_Active; | 0 | ||||||||||||||||||||||||
1262 | - | |||||||||||||||||||||||||
1263 | if (d->selectionModel->isSelected(modelIndex)
| 0 | ||||||||||||||||||||||||
1264 | opt.state |= QStyle::State_Selected; never executed: opt.state |= QStyle::State_Selected; | 0 | ||||||||||||||||||||||||
1265 | if (widgetHasFocus
| 0 | ||||||||||||||||||||||||
1266 | if (allColumnsShowFocus
| 0 | ||||||||||||||||||||||||
1267 | currentRowHasFocus = true; never executed: currentRowHasFocus = true; | 0 | ||||||||||||||||||||||||
1268 | else | - | ||||||||||||||||||||||||
1269 | opt.state |= QStyle::State_HasFocus; never executed: opt.state |= QStyle::State_HasFocus; | 0 | ||||||||||||||||||||||||
1270 | } | - | ||||||||||||||||||||||||
1271 | if ((hoverRow
| 0 | ||||||||||||||||||||||||
1272 | && (option.showDecorationSelected
| 0 | ||||||||||||||||||||||||
1273 | opt.state |= QStyle::State_MouseOver; never executed: opt.state |= QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
1274 | else | - | ||||||||||||||||||||||||
1275 | opt.state &= ~QStyle::State_MouseOver; never executed: opt.state &= ~QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
1276 | - | |||||||||||||||||||||||||
1277 | if (enabled
| 0 | ||||||||||||||||||||||||
1278 | QPalette::ColorGroup cg; | - | ||||||||||||||||||||||||
1279 | if ((
| 0 | ||||||||||||||||||||||||
1280 | opt.state &= ~QStyle::State_Enabled; | - | ||||||||||||||||||||||||
1281 | cg = QPalette::Disabled; | - | ||||||||||||||||||||||||
1282 | } never executed: else if (opt.state & QStyle::State_Activeend of block
| 0 | ||||||||||||||||||||||||
1283 | cg = QPalette::Active; | - | ||||||||||||||||||||||||
1284 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1285 | cg = QPalette::Inactive; | - | ||||||||||||||||||||||||
1286 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1287 | opt.palette.setCurrentColorGroup(cg); | - | ||||||||||||||||||||||||
1288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1289 | - | |||||||||||||||||||||||||
1290 | if (alternate
| 0 | ||||||||||||||||||||||||
1291 | if (d->current & 1
| 0 | ||||||||||||||||||||||||
1292 | opt.features |= QStyleOptionViewItem::Alternate; | - | ||||||||||||||||||||||||
1293 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1294 | opt.features &= ~QStyleOptionViewItem::Alternate; | - | ||||||||||||||||||||||||
1295 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1296 | } | - | ||||||||||||||||||||||||
1297 | - | |||||||||||||||||||||||||
1298 | - | |||||||||||||||||||||||||
1299 | - | |||||||||||||||||||||||||
1300 | - | |||||||||||||||||||||||||
1301 | - | |||||||||||||||||||||||||
1302 | if (d->isTreePosition(headerSection)
| 0 | ||||||||||||||||||||||||
1303 | const int i = d->indentationForItem(d->current); | - | ||||||||||||||||||||||||
1304 | QRect branches(reverse ? position + width - i : position, y, i, height); | - | ||||||||||||||||||||||||
1305 | const bool setClipRect = branches.width() > width; | - | ||||||||||||||||||||||||
1306 | if (setClipRect
| 0 | ||||||||||||||||||||||||
1307 | painter->save(); | - | ||||||||||||||||||||||||
1308 | painter->setClipRect(QRect(position, y, width, height)); | - | ||||||||||||||||||||||||
1309 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1310 | - | |||||||||||||||||||||||||
1311 | opt.rect = branches; | - | ||||||||||||||||||||||||
1312 | style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this); | - | ||||||||||||||||||||||||
1313 | - | |||||||||||||||||||||||||
1314 | - | |||||||||||||||||||||||||
1315 | - | |||||||||||||||||||||||||
1316 | QStyle::State oldState = opt.state; | - | ||||||||||||||||||||||||
1317 | opt.state &= ~QStyle::State_Selected; | - | ||||||||||||||||||||||||
1318 | opt.rect.setRect(reverse ? position : i + position, y, width - i, height); | - | ||||||||||||||||||||||||
1319 | style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this); | - | ||||||||||||||||||||||||
1320 | opt.state = oldState; | - | ||||||||||||||||||||||||
1321 | - | |||||||||||||||||||||||||
1322 | if (d->indent != 0
| 0 | ||||||||||||||||||||||||
1323 | drawBranches(painter, branches, index); never executed: drawBranches(painter, branches, index); | 0 | ||||||||||||||||||||||||
1324 | if (setClipRect
| 0 | ||||||||||||||||||||||||
1325 | painter->restore(); never executed: painter->restore(); | 0 | ||||||||||||||||||||||||
1326 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1327 | QStyle::State oldState = opt.state; | - | ||||||||||||||||||||||||
1328 | opt.state &= ~QStyle::State_Selected; | - | ||||||||||||||||||||||||
1329 | opt.rect.setRect(position, y, width, height); | - | ||||||||||||||||||||||||
1330 | style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this); | - | ||||||||||||||||||||||||
1331 | opt.state = oldState; | - | ||||||||||||||||||||||||
1332 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1333 | - | |||||||||||||||||||||||||
1334 | d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex); | - | ||||||||||||||||||||||||
1335 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1336 | - | |||||||||||||||||||||||||
1337 | if (currentRowHasFocus
| 0 | ||||||||||||||||||||||||
1338 | QStyleOptionFocusRect o; | - | ||||||||||||||||||||||||
1339 | o.QStyleOption::operator=(option); | - | ||||||||||||||||||||||||
1340 | o.state |= QStyle::State_KeyboardFocusChange; | - | ||||||||||||||||||||||||
1341 | QPalette::ColorGroup cg = (
| 0 | ||||||||||||||||||||||||
1342 | ? QPalette::Normal : QPalette::Disabled; | - | ||||||||||||||||||||||||
1343 | o.backgroundColor = option.palette.color(cg, d->selectionModel->isSelected(index) | - | ||||||||||||||||||||||||
1344 | ? QPalette::Highlight : QPalette::Background); | - | ||||||||||||||||||||||||
1345 | int x = 0; | - | ||||||||||||||||||||||||
1346 | if (!option.showDecorationSelected
| 0 | ||||||||||||||||||||||||
1347 | x = header->sectionPosition(0) + d->indentationForItem(d->current); never executed: x = header->sectionPosition(0) + d->indentationForItem(d->current); | 0 | ||||||||||||||||||||||||
1348 | QRect focusRect(x - header->offset(), y, header->length() - x, height); | - | ||||||||||||||||||||||||
1349 | o.rect = style()->visualRect(layoutDirection(), d->viewport->rect(), focusRect); | - | ||||||||||||||||||||||||
1350 | style()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter); | - | ||||||||||||||||||||||||
1351 | - | |||||||||||||||||||||||||
1352 | - | |||||||||||||||||||||||||
1353 | if (allColumnsShowFocus
| 0 | ||||||||||||||||||||||||
1354 | && header->sectionsMoved()
| 0 | ||||||||||||||||||||||||
1355 | QRect sectionRect(0, y, header->sectionPosition(0), height); | - | ||||||||||||||||||||||||
1356 | o.rect = style()->visualRect(layoutDirection(), d->viewport->rect(), sectionRect); | - | ||||||||||||||||||||||||
1357 | style()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter); | - | ||||||||||||||||||||||||
1358 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1359 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1360 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1361 | - | |||||||||||||||||||||||||
1362 | - | |||||||||||||||||||||||||
1363 | - | |||||||||||||||||||||||||
1364 | - | |||||||||||||||||||||||||
1365 | - | |||||||||||||||||||||||||
1366 | - | |||||||||||||||||||||||||
1367 | void QTreeView::drawBranches(QPainter *painter, const QRect &rect, | - | ||||||||||||||||||||||||
1368 | const QModelIndex &index) const | - | ||||||||||||||||||||||||
1369 | { | - | ||||||||||||||||||||||||
1370 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1371 | const bool reverse = isRightToLeft(); | - | ||||||||||||||||||||||||
1372 | const int indent = d->indent; | - | ||||||||||||||||||||||||
1373 | const int outer = d->rootDecoration
| 0 | ||||||||||||||||||||||||
1374 | const int item = d->current; | - | ||||||||||||||||||||||||
1375 | const QTreeViewItem &viewItem = d->viewItems.at(item); | - | ||||||||||||||||||||||||
1376 | int level = viewItem.level; | - | ||||||||||||||||||||||||
1377 | QRect primitive(reverse ? rect.left() : rect.right() + 1, rect.top(), indent, rect.height()); | - | ||||||||||||||||||||||||
1378 | - | |||||||||||||||||||||||||
1379 | QModelIndex parent = index.parent(); | - | ||||||||||||||||||||||||
1380 | QModelIndex current = parent; | - | ||||||||||||||||||||||||
1381 | QModelIndex ancestor = current.parent(); | - | ||||||||||||||||||||||||
1382 | - | |||||||||||||||||||||||||
1383 | QStyleOptionViewItem opt = viewOptions(); | - | ||||||||||||||||||||||||
1384 | QStyle::State extraFlags = QStyle::State_None; | - | ||||||||||||||||||||||||
1385 | if (isEnabled()
| 0 | ||||||||||||||||||||||||
1386 | extraFlags |= QStyle::State_Enabled; never executed: extraFlags |= QStyle::State_Enabled; | 0 | ||||||||||||||||||||||||
1387 | if (window()->isActiveWindow()
| 0 | ||||||||||||||||||||||||
1388 | extraFlags |= QStyle::State_Active; never executed: extraFlags |= QStyle::State_Active; | 0 | ||||||||||||||||||||||||
1389 | QPoint oldBO = painter->brushOrigin(); | - | ||||||||||||||||||||||||
1390 | if (verticalScrollMode() == QAbstractItemView::ScrollPerPixel
| 0 | ||||||||||||||||||||||||
1391 | painter->setBrushOrigin(QPoint(0, verticalOffset())); never executed: painter->setBrushOrigin(QPoint(0, verticalOffset())); | 0 | ||||||||||||||||||||||||
1392 | - | |||||||||||||||||||||||||
1393 | if (d->alternatingColors
| 0 | ||||||||||||||||||||||||
1394 | if (d->current & 1
| 0 | ||||||||||||||||||||||||
1395 | opt.features |= QStyleOptionViewItem::Alternate; | - | ||||||||||||||||||||||||
1396 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1397 | opt.features &= ~QStyleOptionViewItem::Alternate; | - | ||||||||||||||||||||||||
1398 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1399 | } | - | ||||||||||||||||||||||||
1400 | - | |||||||||||||||||||||||||
1401 | - | |||||||||||||||||||||||||
1402 | - | |||||||||||||||||||||||||
1403 | bool hoverRow = selectionBehavior() == QAbstractItemView::SelectRows
| 0 | ||||||||||||||||||||||||
1404 | && opt.showDecorationSelected
| 0 | ||||||||||||||||||||||||
1405 | && index.parent() == d->hover.parent()
| 0 | ||||||||||||||||||||||||
1406 | && index.row() == d->hover.row()
| 0 | ||||||||||||||||||||||||
1407 | - | |||||||||||||||||||||||||
1408 | if (d->selectionModel->isSelected(index)
| 0 | ||||||||||||||||||||||||
1409 | extraFlags |= QStyle::State_Selected; never executed: extraFlags |= QStyle::State_Selected; | 0 | ||||||||||||||||||||||||
1410 | - | |||||||||||||||||||||||||
1411 | if (level >= outer
| 0 | ||||||||||||||||||||||||
1412 | - | |||||||||||||||||||||||||
1413 | primitive.moveLeft(reverse ? primitive.left() : primitive.left() - indent); | - | ||||||||||||||||||||||||
1414 | opt.rect = primitive; | - | ||||||||||||||||||||||||
1415 | - | |||||||||||||||||||||||||
1416 | const bool expanded = viewItem.expanded; | - | ||||||||||||||||||||||||
1417 | const bool children = viewItem.hasChildren; | - | ||||||||||||||||||||||||
1418 | bool moreSiblings = viewItem.hasMoreSiblings; | - | ||||||||||||||||||||||||
1419 | - | |||||||||||||||||||||||||
1420 | opt.state = QStyle::State_Item | extraFlags | - | ||||||||||||||||||||||||
1421 | | (moreSiblings ? QStyle::State_Sibling : QStyle::State_None) | - | ||||||||||||||||||||||||
1422 | | (children ? QStyle::State_Children : QStyle::State_None) | - | ||||||||||||||||||||||||
1423 | | (expanded ? QStyle::State_Open : QStyle::State_None); | - | ||||||||||||||||||||||||
1424 | if (hoverRow
| 0 | ||||||||||||||||||||||||
1425 | opt.state |= QStyle::State_MouseOver; never executed: opt.state |= QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
1426 | else | - | ||||||||||||||||||||||||
1427 | opt.state &= ~QStyle::State_MouseOver; never executed: opt.state &= ~QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
1428 | style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this); | - | ||||||||||||||||||||||||
1429 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1430 | - | |||||||||||||||||||||||||
1431 | for (--level; level >= outer
| 0 | ||||||||||||||||||||||||
1432 | primitive.moveLeft(reverse ? primitive.left() + indent : primitive.left() - indent); | - | ||||||||||||||||||||||||
1433 | opt.rect = primitive; | - | ||||||||||||||||||||||||
1434 | opt.state = extraFlags; | - | ||||||||||||||||||||||||
1435 | bool moreSiblings = false; | - | ||||||||||||||||||||||||
1436 | if (d->hiddenIndexes.isEmpty()
| 0 | ||||||||||||||||||||||||
1437 | moreSiblings = (d->model->rowCount(ancestor) - 1 > current.row()); | - | ||||||||||||||||||||||||
1438 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1439 | int successor = item + viewItem.total + 1; | - | ||||||||||||||||||||||||
1440 | while (successor < d->viewItems.size()
| 0 | ||||||||||||||||||||||||
1441 | && d->viewItems.at(successor).level >= uint(level)
| 0 | ||||||||||||||||||||||||
1442 | const QTreeViewItem &successorItem = d->viewItems.at(successor); | - | ||||||||||||||||||||||||
1443 | if (successorItem.level == uint(level)
| 0 | ||||||||||||||||||||||||
1444 | moreSiblings = true; | - | ||||||||||||||||||||||||
1445 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1446 | } | - | ||||||||||||||||||||||||
1447 | successor += successorItem.total + 1; | - | ||||||||||||||||||||||||
1448 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1449 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1450 | if (moreSiblings
| 0 | ||||||||||||||||||||||||
1451 | opt.state |= QStyle::State_Sibling; never executed: opt.state |= QStyle::State_Sibling; | 0 | ||||||||||||||||||||||||
1452 | if (hoverRow
| 0 | ||||||||||||||||||||||||
1453 | opt.state |= QStyle::State_MouseOver; never executed: opt.state |= QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
1454 | else | - | ||||||||||||||||||||||||
1455 | opt.state &= ~QStyle::State_MouseOver; never executed: opt.state &= ~QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
1456 | style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this); | - | ||||||||||||||||||||||||
1457 | current = ancestor; | - | ||||||||||||||||||||||||
1458 | ancestor = current.parent(); | - | ||||||||||||||||||||||||
1459 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1460 | painter->setBrushOrigin(oldBO); | - | ||||||||||||||||||||||||
1461 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1462 | - | |||||||||||||||||||||||||
1463 | - | |||||||||||||||||||||||||
1464 | - | |||||||||||||||||||||||||
1465 | - | |||||||||||||||||||||||||
1466 | void QTreeView::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1467 | { | - | ||||||||||||||||||||||||
1468 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1469 | bool handled = false; | - | ||||||||||||||||||||||||
1470 | if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress
| 0 | ||||||||||||||||||||||||
1471 | handled = d->expandOrCollapseItemAtPos(event->pos()); never executed: handled = d->expandOrCollapseItemAtPos(event->pos()); | 0 | ||||||||||||||||||||||||
1472 | if (!handled
| 0 | ||||||||||||||||||||||||
1473 | QAbstractItemView::mousePressEvent(event); never executed: QAbstractItemView::mousePressEvent(event); | 0 | ||||||||||||||||||||||||
1474 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1475 | - | |||||||||||||||||||||||||
1476 | - | |||||||||||||||||||||||||
1477 | - | |||||||||||||||||||||||||
1478 | - | |||||||||||||||||||||||||
1479 | void QTreeView::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1480 | { | - | ||||||||||||||||||||||||
1481 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1482 | if (d->itemDecorationAt(event->pos()) == -1
| 0 | ||||||||||||||||||||||||
1483 | QAbstractItemView::mouseReleaseEvent(event); | - | ||||||||||||||||||||||||
1484 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1485 | if (state() == QAbstractItemView::DragSelectingState
| 0 | ||||||||||||||||||||||||
1486 | setState(QAbstractItemView::NoState); never executed: setState(QAbstractItemView::NoState); | 0 | ||||||||||||||||||||||||
1487 | if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease
| 0 | ||||||||||||||||||||||||
1488 | d->expandOrCollapseItemAtPos(event->pos()); never executed: d->expandOrCollapseItemAtPos(event->pos()); | 0 | ||||||||||||||||||||||||
1489 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1490 | } | - | ||||||||||||||||||||||||
1491 | - | |||||||||||||||||||||||||
1492 | - | |||||||||||||||||||||||||
1493 | - | |||||||||||||||||||||||||
1494 | - | |||||||||||||||||||||||||
1495 | void QTreeView::mouseDoubleClickEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1496 | { | - | ||||||||||||||||||||||||
1497 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1498 | if (state() != NoState
| 0 | ||||||||||||||||||||||||
1499 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1500 | - | |||||||||||||||||||||||||
1501 | int i = d->itemDecorationAt(event->pos()); | - | ||||||||||||||||||||||||
1502 | if (i == -1
| 0 | ||||||||||||||||||||||||
1503 | i = d->itemAtCoordinate(event->y()); | - | ||||||||||||||||||||||||
1504 | if (i == -1
| 0 | ||||||||||||||||||||||||
1505 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1506 | - | |||||||||||||||||||||||||
1507 | const QPersistentModelIndex firstColumnIndex = d->viewItems.at(i).index; | - | ||||||||||||||||||||||||
1508 | const QPersistentModelIndex persistent = indexAt(event->pos()); | - | ||||||||||||||||||||||||
1509 | - | |||||||||||||||||||||||||
1510 | if (d->pressedIndex != persistent
| 0 | ||||||||||||||||||||||||
1511 | mousePressEvent(event); | - | ||||||||||||||||||||||||
1512 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1513 | } | - | ||||||||||||||||||||||||
1514 | - | |||||||||||||||||||||||||
1515 | - | |||||||||||||||||||||||||
1516 | doubleClicked(persistent); | - | ||||||||||||||||||||||||
1517 | - | |||||||||||||||||||||||||
1518 | if (!persistent.isValid()
| 0 | ||||||||||||||||||||||||
1519 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1520 | - | |||||||||||||||||||||||||
1521 | if (edit(persistent, DoubleClicked, event)
| 0 | ||||||||||||||||||||||||
1522 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1523 | - | |||||||||||||||||||||||||
1524 | if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this)
| 0 | ||||||||||||||||||||||||
1525 | activated(persistent); never executed: activated(persistent); | 0 | ||||||||||||||||||||||||
1526 | - | |||||||||||||||||||||||||
1527 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
1528 | if (d->itemsExpandable
| 0 | ||||||||||||||||||||||||
1529 | && d->expandsOnDoubleClick
| 0 | ||||||||||||||||||||||||
1530 | && d->hasVisibleChildren(persistent)
| 0 | ||||||||||||||||||||||||
1531 | if (!((
| 0 | ||||||||||||||||||||||||
1532 | - | |||||||||||||||||||||||||
1533 | for (i = 0; i < d->viewItems.count()
| 0 | ||||||||||||||||||||||||
1534 | if (d->viewItems.at(i).index == firstColumnIndex
| 0 | ||||||||||||||||||||||||
1535 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1536 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1537 | if (i == d->viewItems.count()
| 0 | ||||||||||||||||||||||||
1538 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1539 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1540 | if (d->viewItems.at(i).expanded
| 0 | ||||||||||||||||||||||||
1541 | d->collapse(i, true); never executed: d->collapse(i, true); | 0 | ||||||||||||||||||||||||
1542 | else | - | ||||||||||||||||||||||||
1543 | d->expand(i, true); never executed: d->expand(i, true); | 0 | ||||||||||||||||||||||||
1544 | updateGeometries(); | - | ||||||||||||||||||||||||
1545 | viewport()->update(); | - | ||||||||||||||||||||||||
1546 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1547 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1548 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1549 | - | |||||||||||||||||||||||||
1550 | - | |||||||||||||||||||||||||
1551 | - | |||||||||||||||||||||||||
1552 | - | |||||||||||||||||||||||||
1553 | void QTreeView::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
1554 | { | - | ||||||||||||||||||||||||
1555 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1556 | if (d->itemDecorationAt(event->pos()) == -1
| 0 | ||||||||||||||||||||||||
1557 | QAbstractItemView::mouseMoveEvent(event); never executed: QAbstractItemView::mouseMoveEvent(event); | 0 | ||||||||||||||||||||||||
1558 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1559 | - | |||||||||||||||||||||||||
1560 | - | |||||||||||||||||||||||||
1561 | - | |||||||||||||||||||||||||
1562 | - | |||||||||||||||||||||||||
1563 | void QTreeView::keyPressEvent(QKeyEvent *event) | - | ||||||||||||||||||||||||
1564 | { | - | ||||||||||||||||||||||||
1565 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1566 | QModelIndex current = currentIndex(); | - | ||||||||||||||||||||||||
1567 | - | |||||||||||||||||||||||||
1568 | if (d->isIndexValid(current)
| 0 | ||||||||||||||||||||||||
1569 | switch (event->key()) { | - | ||||||||||||||||||||||||
1570 | case never executed: Qt::Key_Asterisk:case Qt::Key_Asterisk: never executed: {case Qt::Key_Asterisk: | 0 | ||||||||||||||||||||||||
1571 | QStack<QModelIndex> parents; | - | ||||||||||||||||||||||||
1572 | parents.push(current); | - | ||||||||||||||||||||||||
1573 | while (!parents.isEmpty()
| 0 | ||||||||||||||||||||||||
1574 | QModelIndex parent = parents.pop(); | - | ||||||||||||||||||||||||
1575 | for (int row = 0; row < d->model->rowCount(parent)
| 0 | ||||||||||||||||||||||||
1576 | QModelIndex child = d->model->index(row, 0, parent); | - | ||||||||||||||||||||||||
1577 | if (!d->isIndexValid(child)
| 0 | ||||||||||||||||||||||||
1578 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1579 | parents.push(child); | - | ||||||||||||||||||||||||
1580 | expand(child); | - | ||||||||||||||||||||||||
1581 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1582 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1583 | expand(current); | - | ||||||||||||||||||||||||
1584 | break; never executed: }break; | 0 | ||||||||||||||||||||||||
1585 | case never executed: Qt::Key_Plus:case Qt::Key_Plus: never executed: case Qt::Key_Plus: | 0 | ||||||||||||||||||||||||
1586 | expand(current); | - | ||||||||||||||||||||||||
1587 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1588 | case never executed: Qt::Key_Minus:case Qt::Key_Minus: never executed: case Qt::Key_Minus: | 0 | ||||||||||||||||||||||||
1589 | collapse(current); | - | ||||||||||||||||||||||||
1590 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1591 | } | - | ||||||||||||||||||||||||
1592 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1593 | - | |||||||||||||||||||||||||
1594 | QAbstractItemView::keyPressEvent(event); | - | ||||||||||||||||||||||||
1595 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1596 | - | |||||||||||||||||||||||||
1597 | - | |||||||||||||||||||||||||
1598 | - | |||||||||||||||||||||||||
1599 | - | |||||||||||||||||||||||||
1600 | QModelIndex QTreeView::indexAt(const QPoint &point) const | - | ||||||||||||||||||||||||
1601 | { | - | ||||||||||||||||||||||||
1602 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1603 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
1604 | - | |||||||||||||||||||||||||
1605 | int visualIndex = d->itemAtCoordinate(point.y()); | - | ||||||||||||||||||||||||
1606 | QModelIndex idx = d->modelIndex(visualIndex); | - | ||||||||||||||||||||||||
1607 | if (!idx.isValid()
| 0 | ||||||||||||||||||||||||
1608 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
1609 | - | |||||||||||||||||||||||||
1610 | if (d->viewItems.at(visualIndex).spanning
| 0 | ||||||||||||||||||||||||
1611 | return never executed: idx;return idx; never executed: return idx; | 0 | ||||||||||||||||||||||||
1612 | - | |||||||||||||||||||||||||
1613 | int column = d->columnAt(point.x()); | - | ||||||||||||||||||||||||
1614 | if (column == idx.column()
| 0 | ||||||||||||||||||||||||
1615 | return never executed: idx;return idx; never executed: return idx; | 0 | ||||||||||||||||||||||||
1616 | if (column < 0
| 0 | ||||||||||||||||||||||||
1617 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
1618 | return never executed: idx.sibling(idx.row(), column);return idx.sibling(idx.row(), column); never executed: return idx.sibling(idx.row(), column); | 0 | ||||||||||||||||||||||||
1619 | } | - | ||||||||||||||||||||||||
1620 | - | |||||||||||||||||||||||||
1621 | - | |||||||||||||||||||||||||
1622 | - | |||||||||||||||||||||||||
1623 | - | |||||||||||||||||||||||||
1624 | QModelIndex QTreeView::indexAbove(const QModelIndex &index) const | - | ||||||||||||||||||||||||
1625 | { | - | ||||||||||||||||||||||||
1626 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1627 | if (!d->isIndexValid(index)
| 0 | ||||||||||||||||||||||||
1628 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
1629 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
1630 | int i = d->viewIndex(index); | - | ||||||||||||||||||||||||
1631 | if (--
| 0 | ||||||||||||||||||||||||
1632 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
1633 | const QModelIndex firstColumnIndex = d->viewItems.at(i).index; | - | ||||||||||||||||||||||||
1634 | return never executed: firstColumnIndex.sibling(firstColumnIndex.row(), index.column());return firstColumnIndex.sibling(firstColumnIndex.row(), index.column()); never executed: return firstColumnIndex.sibling(firstColumnIndex.row(), index.column()); | 0 | ||||||||||||||||||||||||
1635 | } | - | ||||||||||||||||||||||||
1636 | - | |||||||||||||||||||||||||
1637 | - | |||||||||||||||||||||||||
1638 | - | |||||||||||||||||||||||||
1639 | - | |||||||||||||||||||||||||
1640 | QModelIndex QTreeView::indexBelow(const QModelIndex &index) const | - | ||||||||||||||||||||||||
1641 | { | - | ||||||||||||||||||||||||
1642 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1643 | if (!d->isIndexValid(index)
| 0 | ||||||||||||||||||||||||
1644 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
1645 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
1646 | int i = d->viewIndex(index); | - | ||||||||||||||||||||||||
1647 | if (++
| 0 | ||||||||||||||||||||||||
1648 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
1649 | const QModelIndex firstColumnIndex = d->viewItems.at(i).index; | - | ||||||||||||||||||||||||
1650 | return never executed: firstColumnIndex.sibling(firstColumnIndex.row(), index.column());return firstColumnIndex.sibling(firstColumnIndex.row(), index.column()); never executed: return firstColumnIndex.sibling(firstColumnIndex.row(), index.column()); | 0 | ||||||||||||||||||||||||
1651 | } | - | ||||||||||||||||||||||||
1652 | - | |||||||||||||||||||||||||
1653 | - | |||||||||||||||||||||||||
1654 | - | |||||||||||||||||||||||||
1655 | - | |||||||||||||||||||||||||
1656 | - | |||||||||||||||||||||||||
1657 | - | |||||||||||||||||||||||||
1658 | void QTreeView::doItemsLayout() | - | ||||||||||||||||||||||||
1659 | { | - | ||||||||||||||||||||||||
1660 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1661 | if (!d->customIndent
| 0 | ||||||||||||||||||||||||
1662 | - | |||||||||||||||||||||||||
1663 | - | |||||||||||||||||||||||||
1664 | - | |||||||||||||||||||||||||
1665 | d->updateIndentationFromStyle(); | - | ||||||||||||||||||||||||
1666 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1667 | if (d->hasRemovedItems
| 0 | ||||||||||||||||||||||||
1668 | - | |||||||||||||||||||||||||
1669 | d->hasRemovedItems = false; | - | ||||||||||||||||||||||||
1670 | QSet<QPersistentModelIndex>::iterator it = d->expandedIndexes.begin(); | - | ||||||||||||||||||||||||
1671 | while (it != d->expandedIndexes.end()
| 0 | ||||||||||||||||||||||||
1672 | if (!it->isValid()
| 0 | ||||||||||||||||||||||||
1673 | it = d->expandedIndexes.erase(it); never executed: it = d->expandedIndexes.erase(it); | 0 | ||||||||||||||||||||||||
1674 | else | - | ||||||||||||||||||||||||
1675 | ++ never executed: it;++it; never executed: ++it; | 0 | ||||||||||||||||||||||||
1676 | } | - | ||||||||||||||||||||||||
1677 | it = d->hiddenIndexes.begin(); | - | ||||||||||||||||||||||||
1678 | while (it != d->hiddenIndexes.end()
| 0 | ||||||||||||||||||||||||
1679 | if (!it->isValid()
| 0 | ||||||||||||||||||||||||
1680 | it = d->hiddenIndexes.erase(it); never executed: it = d->hiddenIndexes.erase(it); | 0 | ||||||||||||||||||||||||
1681 | else | - | ||||||||||||||||||||||||
1682 | ++ never executed: it;++it; never executed: ++it; | 0 | ||||||||||||||||||||||||
1683 | } | - | ||||||||||||||||||||||||
1684 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1685 | d->viewItems.clear(); | - | ||||||||||||||||||||||||
1686 | QModelIndex parent = d->root; | - | ||||||||||||||||||||||||
1687 | if (d->model->hasChildren(parent)
| 0 | ||||||||||||||||||||||||
1688 | d->layout(-1); | - | ||||||||||||||||||||||||
1689 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1690 | QAbstractItemView::doItemsLayout(); | - | ||||||||||||||||||||||||
1691 | d->header->doItemsLayout(); | - | ||||||||||||||||||||||||
1692 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1693 | - | |||||||||||||||||||||||||
1694 | - | |||||||||||||||||||||||||
1695 | - | |||||||||||||||||||||||||
1696 | - | |||||||||||||||||||||||||
1697 | void QTreeView::reset() | - | ||||||||||||||||||||||||
1698 | { | - | ||||||||||||||||||||||||
1699 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1700 | d->expandedIndexes.clear(); | - | ||||||||||||||||||||||||
1701 | d->hiddenIndexes.clear(); | - | ||||||||||||||||||||||||
1702 | d->spanningIndexes.clear(); | - | ||||||||||||||||||||||||
1703 | d->viewItems.clear(); | - | ||||||||||||||||||||||||
1704 | QAbstractItemView::reset(); | - | ||||||||||||||||||||||||
1705 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1706 | int QTreeView::horizontalOffset() const | - | ||||||||||||||||||||||||
1707 | { | - | ||||||||||||||||||||||||
1708 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1709 | return never executed: d->header->offset();return d->header->offset(); never executed: return d->header->offset(); | 0 | ||||||||||||||||||||||||
1710 | } | - | ||||||||||||||||||||||||
1711 | - | |||||||||||||||||||||||||
1712 | - | |||||||||||||||||||||||||
1713 | - | |||||||||||||||||||||||||
1714 | - | |||||||||||||||||||||||||
1715 | - | |||||||||||||||||||||||||
1716 | - | |||||||||||||||||||||||||
1717 | int QTreeView::verticalOffset() const | - | ||||||||||||||||||||||||
1718 | { | - | ||||||||||||||||||||||||
1719 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1720 | if (d->verticalScrollMode == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
1721 | if (d->uniformRowHeights
| 0 | ||||||||||||||||||||||||
1722 | return never executed: verticalScrollBar()->value() * d->defaultItemHeight;return verticalScrollBar()->value() * d->defaultItemHeight; never executed: return verticalScrollBar()->value() * d->defaultItemHeight; | 0 | ||||||||||||||||||||||||
1723 | - | |||||||||||||||||||||||||
1724 | - | |||||||||||||||||||||||||
1725 | - | |||||||||||||||||||||||||
1726 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
1727 | int offset = 0; | - | ||||||||||||||||||||||||
1728 | for (int i = 0; i < d->viewItems.count()
| 0 | ||||||||||||||||||||||||
1729 | if (i == verticalScrollBar()->value()
| 0 | ||||||||||||||||||||||||
1730 | return never executed: offset;return offset; never executed: return offset; | 0 | ||||||||||||||||||||||||
1731 | offset += d->itemHeight(i); | - | ||||||||||||||||||||||||
1732 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1733 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1734 | } | - | ||||||||||||||||||||||||
1735 | - | |||||||||||||||||||||||||
1736 | return never executed: verticalScrollBar()->value();return verticalScrollBar()->value(); never executed: return verticalScrollBar()->value(); | 0 | ||||||||||||||||||||||||
1737 | } | - | ||||||||||||||||||||||||
1738 | - | |||||||||||||||||||||||||
1739 | - | |||||||||||||||||||||||||
1740 | - | |||||||||||||||||||||||||
1741 | - | |||||||||||||||||||||||||
1742 | - | |||||||||||||||||||||||||
1743 | QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) | - | ||||||||||||||||||||||||
1744 | { | - | ||||||||||||||||||||||||
1745 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1746 | (void)modifiers;; | - | ||||||||||||||||||||||||
1747 | - | |||||||||||||||||||||||||
1748 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
1749 | - | |||||||||||||||||||||||||
1750 | QModelIndex current = currentIndex(); | - | ||||||||||||||||||||||||
1751 | if (!current.isValid()
| 0 | ||||||||||||||||||||||||
1752 | int i = d->below(-1); | - | ||||||||||||||||||||||||
1753 | int c = 0; | - | ||||||||||||||||||||||||
1754 | while (c < d->header->count()
| 0 | ||||||||||||||||||||||||
1755 | ++ never executed: c;++c; never executed: ++c; | 0 | ||||||||||||||||||||||||
1756 | if (i < d->viewItems.count()
| 0 | ||||||||||||||||||||||||
1757 | return never executed: d->modelIndex(i, d->header->logicalIndex(c));return d->modelIndex(i, d->header->logicalIndex(c)); never executed: return d->modelIndex(i, d->header->logicalIndex(c)); | 0 | ||||||||||||||||||||||||
1758 | } | - | ||||||||||||||||||||||||
1759 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
1760 | } | - | ||||||||||||||||||||||||
1761 | int vi = -1; | - | ||||||||||||||||||||||||
1762 | if (vi < 0
| 0 | ||||||||||||||||||||||||
1763 | vi = qMax(0, d->viewIndex(current)); never executed: vi = qMax(0, d->viewIndex(current)); | 0 | ||||||||||||||||||||||||
1764 | - | |||||||||||||||||||||||||
1765 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
1766 | if (cursorAction == MoveRight
| 0 | ||||||||||||||||||||||||
1767 | cursorAction = MoveLeft; never executed: cursorAction = MoveLeft; | 0 | ||||||||||||||||||||||||
1768 | else if (cursorAction == MoveLeft
| 0 | ||||||||||||||||||||||||
1769 | cursorAction = MoveRight; never executed: cursorAction = MoveRight; | 0 | ||||||||||||||||||||||||
1770 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1771 | switch (cursorAction) { | - | ||||||||||||||||||||||||
1772 | case never executed: MoveNext:case MoveNext: never executed: case MoveNext: | 0 | ||||||||||||||||||||||||
1773 | case never executed: MoveDown:case MoveDown: never executed: case MoveDown: | 0 | ||||||||||||||||||||||||
1774 | - | |||||||||||||||||||||||||
1775 | - | |||||||||||||||||||||||||
1776 | - | |||||||||||||||||||||||||
1777 | - | |||||||||||||||||||||||||
1778 | return never executed: d->modelIndex(d->below(vi), current.column());return d->modelIndex(d->below(vi), current.column()); never executed: return d->modelIndex(d->below(vi), current.column()); | 0 | ||||||||||||||||||||||||
1779 | case never executed: MovePrevious:case MovePrevious: never executed: case MovePrevious: | 0 | ||||||||||||||||||||||||
1780 | case never executed: MoveUp:case MoveUp: never executed: case MoveUp: | 0 | ||||||||||||||||||||||||
1781 | - | |||||||||||||||||||||||||
1782 | - | |||||||||||||||||||||||||
1783 | - | |||||||||||||||||||||||||
1784 | - | |||||||||||||||||||||||||
1785 | return never executed: d->modelIndex(d->above(vi), current.column());return d->modelIndex(d->above(vi), current.column()); never executed: return d->modelIndex(d->above(vi), current.column()); | 0 | ||||||||||||||||||||||||
1786 | case never executed: MoveLeft:case MoveLeft: never executed: {case MoveLeft: | 0 | ||||||||||||||||||||||||
1787 | QScrollBar *sb = horizontalScrollBar(); | - | ||||||||||||||||||||||||
1788 | if (vi < d->viewItems.count()
| 0 | ||||||||||||||||||||||||
1789 | d->collapse(vi, true); | - | ||||||||||||||||||||||||
1790 | d->moveCursorUpdatedView = true; | - | ||||||||||||||||||||||||
1791 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1792 | bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this); | - | ||||||||||||||||||||||||
1793 | if (descend
| 0 | ||||||||||||||||||||||||
1794 | QModelIndex par = current.parent(); | - | ||||||||||||||||||||||||
1795 | if (par.isValid()
| 0 | ||||||||||||||||||||||||
1796 | return never executed: par;return par; never executed: return par; | 0 | ||||||||||||||||||||||||
1797 | else | - | ||||||||||||||||||||||||
1798 | descend = false; never executed: descend = false; | 0 | ||||||||||||||||||||||||
1799 | } | - | ||||||||||||||||||||||||
1800 | if (!descend
| 0 | ||||||||||||||||||||||||
1801 | if (d->selectionBehavior == SelectItems
| 0 | ||||||||||||||||||||||||
1802 | int visualColumn = d->header->visualIndex(current.column()) - 1; | - | ||||||||||||||||||||||||
1803 | while (visualColumn >= 0
| 0 | ||||||||||||||||||||||||
1804 | visualColumn--; never executed: visualColumn--; | 0 | ||||||||||||||||||||||||
1805 | int newColumn = d->header->logicalIndex(visualColumn); | - | ||||||||||||||||||||||||
1806 | QModelIndex next = current.sibling(current.row(), newColumn); | - | ||||||||||||||||||||||||
1807 | if (next.isValid()
| 0 | ||||||||||||||||||||||||
1808 | return never executed: next;return next; never executed: return next; | 0 | ||||||||||||||||||||||||
1809 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1810 | - | |||||||||||||||||||||||||
1811 | int oldValue = sb->value(); | - | ||||||||||||||||||||||||
1812 | sb->setValue(sb->value() - sb->singleStep()); | - | ||||||||||||||||||||||||
1813 | if (oldValue != sb->value()
| 0 | ||||||||||||||||||||||||
1814 | d->moveCursorUpdatedView = true; never executed: d->moveCursorUpdatedView = true; | 0 | ||||||||||||||||||||||||
1815 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1816 | - | |||||||||||||||||||||||||
1817 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1818 | updateGeometries(); | - | ||||||||||||||||||||||||
1819 | viewport()->update(); | - | ||||||||||||||||||||||||
1820 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1821 | } | - | ||||||||||||||||||||||||
1822 | case never executed: MoveRight:case MoveRight: never executed: case MoveRight: | 0 | ||||||||||||||||||||||||
1823 | if (vi < d->viewItems.count()
| 0 | ||||||||||||||||||||||||
1824 | && d->hasVisibleChildren(d->viewItems.at(vi).index)
| 0 | ||||||||||||||||||||||||
1825 | d->expand(vi, true); | - | ||||||||||||||||||||||||
1826 | d->moveCursorUpdatedView = true; | - | ||||||||||||||||||||||||
1827 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1828 | bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this); | - | ||||||||||||||||||||||||
1829 | if (descend
| 0 | ||||||||||||||||||||||||
1830 | QModelIndex idx = d->modelIndex(d->below(vi)); | - | ||||||||||||||||||||||||
1831 | if (idx.parent() == current
| 0 | ||||||||||||||||||||||||
1832 | return never executed: idx;return idx; never executed: return idx; | 0 | ||||||||||||||||||||||||
1833 | else | - | ||||||||||||||||||||||||
1834 | descend = false; never executed: descend = false; | 0 | ||||||||||||||||||||||||
1835 | } | - | ||||||||||||||||||||||||
1836 | if (!descend
| 0 | ||||||||||||||||||||||||
1837 | if (d->selectionBehavior == SelectItems
| 0 | ||||||||||||||||||||||||
1838 | int visualColumn = d->header->visualIndex(current.column()) + 1; | - | ||||||||||||||||||||||||
1839 | while (visualColumn < d->model->columnCount(current.parent())
| 0 | ||||||||||||||||||||||||
1840 | visualColumn++; never executed: visualColumn++; | 0 | ||||||||||||||||||||||||
1841 | const int newColumn = d->header->logicalIndex(visualColumn); | - | ||||||||||||||||||||||||
1842 | const QModelIndex next = current.sibling(current.row(), newColumn); | - | ||||||||||||||||||||||||
1843 | if (next.isValid()
| 0 | ||||||||||||||||||||||||
1844 | return never executed: next;return next; never executed: return next; | 0 | ||||||||||||||||||||||||
1845 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1846 | - | |||||||||||||||||||||||||
1847 | - | |||||||||||||||||||||||||
1848 | QScrollBar *sb = horizontalScrollBar(); | - | ||||||||||||||||||||||||
1849 | int oldValue = sb->value(); | - | ||||||||||||||||||||||||
1850 | sb->setValue(sb->value() + sb->singleStep()); | - | ||||||||||||||||||||||||
1851 | if (oldValue != sb->value()
| 0 | ||||||||||||||||||||||||
1852 | d->moveCursorUpdatedView = true; never executed: d->moveCursorUpdatedView = true; | 0 | ||||||||||||||||||||||||
1853 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1854 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1855 | updateGeometries(); | - | ||||||||||||||||||||||||
1856 | viewport()->update(); | - | ||||||||||||||||||||||||
1857 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1858 | case never executed: MovePageUp:case MovePageUp: never executed: case MovePageUp: | 0 | ||||||||||||||||||||||||
1859 | return never executed: d->modelIndex(d->pageUp(vi), current.column());return d->modelIndex(d->pageUp(vi), current.column()); never executed: return d->modelIndex(d->pageUp(vi), current.column()); | 0 | ||||||||||||||||||||||||
1860 | case never executed: MovePageDown:case MovePageDown: never executed: case MovePageDown: | 0 | ||||||||||||||||||||||||
1861 | return never executed: d->modelIndex(d->pageDown(vi), current.column());return d->modelIndex(d->pageDown(vi), current.column()); never executed: return d->modelIndex(d->pageDown(vi), current.column()); | 0 | ||||||||||||||||||||||||
1862 | case never executed: MoveHome:case MoveHome: never executed: case MoveHome: | 0 | ||||||||||||||||||||||||
1863 | return never executed: d->model->index(0, current.column(), d->root);return d->model->index(0, current.column(), d->root); never executed: return d->model->index(0, current.column(), d->root); | 0 | ||||||||||||||||||||||||
1864 | case never executed: MoveEnd:case MoveEnd: never executed: case MoveEnd: | 0 | ||||||||||||||||||||||||
1865 | return never executed: d->modelIndex(d->viewItems.count() - 1, current.column());return d->modelIndex(d->viewItems.count() - 1, current.column()); never executed: return d->modelIndex(d->viewItems.count() - 1, current.column()); | 0 | ||||||||||||||||||||||||
1866 | } | - | ||||||||||||||||||||||||
1867 | return never executed: current;return current; never executed: return current; | 0 | ||||||||||||||||||||||||
1868 | } | - | ||||||||||||||||||||||||
1869 | - | |||||||||||||||||||||||||
1870 | - | |||||||||||||||||||||||||
1871 | - | |||||||||||||||||||||||||
1872 | - | |||||||||||||||||||||||||
1873 | - | |||||||||||||||||||||||||
1874 | - | |||||||||||||||||||||||||
1875 | - | |||||||||||||||||||||||||
1876 | void QTreeView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) | - | ||||||||||||||||||||||||
1877 | { | - | ||||||||||||||||||||||||
1878 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1879 | if (!selectionModel()
| 0 | ||||||||||||||||||||||||
1880 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1881 | - | |||||||||||||||||||||||||
1882 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
1883 | QPoint tl(isRightToLeft() ? qMax(rect.left(), rect.right()) | - | ||||||||||||||||||||||||
1884 | : qMin(rect.left(), rect.right()), qMin(rect.top(), rect.bottom())); | - | ||||||||||||||||||||||||
1885 | QPoint br(isRightToLeft() ? qMin(rect.left(), rect.right()) : | - | ||||||||||||||||||||||||
1886 | qMax(rect.left(), rect.right()), qMax(rect.top(), rect.bottom())); | - | ||||||||||||||||||||||||
1887 | QModelIndex topLeft = indexAt(tl); | - | ||||||||||||||||||||||||
1888 | QModelIndex bottomRight = indexAt(br); | - | ||||||||||||||||||||||||
1889 | if (!topLeft.isValid()
| 0 | ||||||||||||||||||||||||
1890 | if (command & QItemSelectionModel::Clear
| 0 | ||||||||||||||||||||||||
1891 | selectionModel()->clear(); never executed: selectionModel()->clear(); | 0 | ||||||||||||||||||||||||
1892 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1893 | } | - | ||||||||||||||||||||||||
1894 | if (!topLeft.isValid()
| 0 | ||||||||||||||||||||||||
1895 | topLeft = d->viewItems.first().index; never executed: topLeft = d->viewItems.first().index; | 0 | ||||||||||||||||||||||||
1896 | if (!bottomRight.isValid()
| 0 | ||||||||||||||||||||||||
1897 | const int column = d->header->logicalIndex(d->header->count() - 1); | - | ||||||||||||||||||||||||
1898 | const QModelIndex index = d->viewItems.last().index; | - | ||||||||||||||||||||||||
1899 | bottomRight = index.sibling(index.row(), column); | - | ||||||||||||||||||||||||
1900 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1901 | - | |||||||||||||||||||||||||
1902 | if (!d->isIndexEnabled(topLeft)
| 0 | ||||||||||||||||||||||||
1903 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1904 | - | |||||||||||||||||||||||||
1905 | d->select(topLeft, bottomRight, command); | - | ||||||||||||||||||||||||
1906 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1907 | QRegion QTreeView::visualRegionForSelection(const QItemSelection &selection) const | - | ||||||||||||||||||||||||
1908 | { | - | ||||||||||||||||||||||||
1909 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1910 | if (selection.isEmpty()
| 0 | ||||||||||||||||||||||||
1911 | return never executed: QRegion();return QRegion(); never executed: return QRegion(); | 0 | ||||||||||||||||||||||||
1912 | - | |||||||||||||||||||||||||
1913 | QRegion selectionRegion; | - | ||||||||||||||||||||||||
1914 | const QRect &viewportRect = d->viewport->rect(); | - | ||||||||||||||||||||||||
1915 | for (int i = 0; i < selection.count()
| 0 | ||||||||||||||||||||||||
1916 | QItemSelectionRange range = selection.at(i); | - | ||||||||||||||||||||||||
1917 | if (!range.isValid()
| 0 | ||||||||||||||||||||||||
1918 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1919 | QModelIndex parent = range.parent(); | - | ||||||||||||||||||||||||
1920 | QModelIndex leftIndex = range.topLeft(); | - | ||||||||||||||||||||||||
1921 | int columnCount = d->model->columnCount(parent); | - | ||||||||||||||||||||||||
1922 | while (leftIndex.isValid()
| 0 | ||||||||||||||||||||||||
1923 | if (leftIndex.column() + 1 < columnCount
| 0 | ||||||||||||||||||||||||
1924 | leftIndex = d->model->index(leftIndex.row(), leftIndex.column() + 1, parent); never executed: leftIndex = d->model->index(leftIndex.row(), leftIndex.column() + 1, parent); | 0 | ||||||||||||||||||||||||
1925 | else | - | ||||||||||||||||||||||||
1926 | leftIndex = QModelIndex(); never executed: leftIndex = QModelIndex(); | 0 | ||||||||||||||||||||||||
1927 | } | - | ||||||||||||||||||||||||
1928 | if (!leftIndex.isValid()
| 0 | ||||||||||||||||||||||||
1929 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1930 | const QRect leftRect = visualRect(leftIndex); | - | ||||||||||||||||||||||||
1931 | int top = leftRect.top(); | - | ||||||||||||||||||||||||
1932 | QModelIndex rightIndex = range.bottomRight(); | - | ||||||||||||||||||||||||
1933 | while (rightIndex.isValid()
| 0 | ||||||||||||||||||||||||
1934 | if (rightIndex.column() - 1 >= 0
| 0 | ||||||||||||||||||||||||
1935 | rightIndex = d->model->index(rightIndex.row(), rightIndex.column() - 1, parent); never executed: rightIndex = d->model->index(rightIndex.row(), rightIndex.column() - 1, parent); | 0 | ||||||||||||||||||||||||
1936 | else | - | ||||||||||||||||||||||||
1937 | rightIndex = QModelIndex(); never executed: rightIndex = QModelIndex(); | 0 | ||||||||||||||||||||||||
1938 | } | - | ||||||||||||||||||||||||
1939 | if (!rightIndex.isValid()
| 0 | ||||||||||||||||||||||||
1940 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1941 | const QRect rightRect = visualRect(rightIndex); | - | ||||||||||||||||||||||||
1942 | int bottom = rightRect.bottom(); | - | ||||||||||||||||||||||||
1943 | if (top > bottom
| 0 | ||||||||||||||||||||||||
1944 | qSwap<int>(top, bottom); never executed: qSwap<int>(top, bottom); | 0 | ||||||||||||||||||||||||
1945 | int height = bottom - top + 1; | - | ||||||||||||||||||||||||
1946 | if (d->header->sectionsMoved()
| 0 | ||||||||||||||||||||||||
1947 | for (int c = range.left(); c <= range.right()
| 0 | ||||||||||||||||||||||||
1948 | const QRect rangeRect(columnViewportPosition(c), top, columnWidth(c), height); | - | ||||||||||||||||||||||||
1949 | if (viewportRect.intersects(rangeRect)
| 0 | ||||||||||||||||||||||||
1950 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 | ||||||||||||||||||||||||
1951 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1952 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1953 | QRect combined = leftRect|rightRect; | - | ||||||||||||||||||||||||
1954 | combined.setX(columnViewportPosition(isRightToLeft() ? range.right() : range.left())); | - | ||||||||||||||||||||||||
1955 | if (viewportRect.intersects(combined)
| 0 | ||||||||||||||||||||||||
1956 | selectionRegion += combined; never executed: selectionRegion += combined; | 0 | ||||||||||||||||||||||||
1957 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1958 | } | - | ||||||||||||||||||||||||
1959 | return never executed: selectionRegion;return selectionRegion; never executed: return selectionRegion; | 0 | ||||||||||||||||||||||||
1960 | } | - | ||||||||||||||||||||||||
1961 | - | |||||||||||||||||||||||||
1962 | - | |||||||||||||||||||||||||
1963 | - | |||||||||||||||||||||||||
1964 | - | |||||||||||||||||||||||||
1965 | QModelIndexList QTreeView::selectedIndexes() const | - | ||||||||||||||||||||||||
1966 | { | - | ||||||||||||||||||||||||
1967 | QModelIndexList viewSelected; | - | ||||||||||||||||||||||||
1968 | QModelIndexList modelSelected; | - | ||||||||||||||||||||||||
1969 | if (selectionModel()
| 0 | ||||||||||||||||||||||||
1970 | modelSelected = selectionModel()->selectedIndexes(); never executed: modelSelected = selectionModel()->selectedIndexes(); | 0 | ||||||||||||||||||||||||
1971 | for (int i = 0; i < modelSelected.count()
| 0 | ||||||||||||||||||||||||
1972 | - | |||||||||||||||||||||||||
1973 | QModelIndex index = modelSelected.at(i); | - | ||||||||||||||||||||||||
1974 | while (index.isValid()
| 0 | ||||||||||||||||||||||||
1975 | index = index.parent(); never executed: index = index.parent(); | 0 | ||||||||||||||||||||||||
1976 | if (index.isValid()
| 0 | ||||||||||||||||||||||||
1977 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1978 | viewSelected.append(modelSelected.at(i)); | - | ||||||||||||||||||||||||
1979 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1980 | return never executed: viewSelected;return viewSelected; never executed: return viewSelected; | 0 | ||||||||||||||||||||||||
1981 | } | - | ||||||||||||||||||||||||
1982 | - | |||||||||||||||||||||||||
1983 | - | |||||||||||||||||||||||||
1984 | - | |||||||||||||||||||||||||
1985 | - | |||||||||||||||||||||||||
1986 | void QTreeView::scrollContentsBy(int dx, int dy) | - | ||||||||||||||||||||||||
1987 | { | - | ||||||||||||||||||||||||
1988 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1989 | - | |||||||||||||||||||||||||
1990 | d->delayedAutoScroll.stop(); | - | ||||||||||||||||||||||||
1991 | - | |||||||||||||||||||||||||
1992 | dx = isRightToLeft()
| 0 | ||||||||||||||||||||||||
1993 | if (dx
| 0 | ||||||||||||||||||||||||
1994 | int oldOffset = d->header->offset(); | - | ||||||||||||||||||||||||
1995 | d->header->d_func()->setScrollOffset(horizontalScrollBar(), horizontalScrollMode()); | - | ||||||||||||||||||||||||
1996 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
1997 | int newOffset = d->header->offset(); | - | ||||||||||||||||||||||||
1998 | dx = isRightToLeft()
| 0 | ||||||||||||||||||||||||
1999 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2000 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2001 | - | |||||||||||||||||||||||||
2002 | const int itemHeight = d->defaultItemHeight <= 0
| 0 | ||||||||||||||||||||||||
2003 | if (d->viewItems.isEmpty()
| 0 | ||||||||||||||||||||||||
2004 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2005 | - | |||||||||||||||||||||||||
2006 | - | |||||||||||||||||||||||||
2007 | int viewCount = d->viewport->height() / itemHeight; | - | ||||||||||||||||||||||||
2008 | int maxDeltaY = qMin(d->viewItems.count(), viewCount); | - | ||||||||||||||||||||||||
2009 | - | |||||||||||||||||||||||||
2010 | if (qAbs(dy) > qAbs(maxDeltaY)
| 0 | ||||||||||||||||||||||||
2011 | verticalScrollBar()->update(); | - | ||||||||||||||||||||||||
2012 | d->viewport->update(); | - | ||||||||||||||||||||||||
2013 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2014 | } | - | ||||||||||||||||||||||||
2015 | - | |||||||||||||||||||||||||
2016 | if (dy
| 0 | ||||||||||||||||||||||||
2017 | int currentScrollbarValue = verticalScrollBar()->value(); | - | ||||||||||||||||||||||||
2018 | int previousScrollbarValue = currentScrollbarValue + dy; | - | ||||||||||||||||||||||||
2019 | int currentViewIndex = currentScrollbarValue; | - | ||||||||||||||||||||||||
2020 | int previousViewIndex = previousScrollbarValue; | - | ||||||||||||||||||||||||
2021 | const QVector<QTreeViewItem> viewItems = d->viewItems; | - | ||||||||||||||||||||||||
2022 | dy = 0; | - | ||||||||||||||||||||||||
2023 | if (previousViewIndex < currentViewIndex
| 0 | ||||||||||||||||||||||||
2024 | for (int i = previousViewIndex; i < currentViewIndex
| 0 | ||||||||||||||||||||||||
2025 | if (i < d->viewItems.count()
| 0 | ||||||||||||||||||||||||
2026 | dy -= d->itemHeight(i); never executed: dy -= d->itemHeight(i); | 0 | ||||||||||||||||||||||||
2027 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2028 | } never executed: else if (previousViewIndex > currentViewIndexend of block
| 0 | ||||||||||||||||||||||||
2029 | for (int i = previousViewIndex - 1; i >= currentViewIndex
| 0 | ||||||||||||||||||||||||
2030 | if (i < d->viewItems.count()
| 0 | ||||||||||||||||||||||||
2031 | dy += d->itemHeight(i); never executed: dy += d->itemHeight(i); | 0 | ||||||||||||||||||||||||
2032 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2033 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2034 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2035 | - | |||||||||||||||||||||||||
2036 | d->scrollContentsBy(dx, dy); | - | ||||||||||||||||||||||||
2037 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2038 | - | |||||||||||||||||||||||||
2039 | - | |||||||||||||||||||||||||
2040 | - | |||||||||||||||||||||||||
2041 | - | |||||||||||||||||||||||||
2042 | void QTreeView::columnMoved() | - | ||||||||||||||||||||||||
2043 | { | - | ||||||||||||||||||||||||
2044 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2045 | updateEditorGeometries(); | - | ||||||||||||||||||||||||
2046 | d->viewport->update(); | - | ||||||||||||||||||||||||
2047 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2048 | - | |||||||||||||||||||||||||
2049 | - | |||||||||||||||||||||||||
2050 | - | |||||||||||||||||||||||||
2051 | - | |||||||||||||||||||||||||
2052 | void QTreeView::reexpand() | - | ||||||||||||||||||||||||
2053 | { | - | ||||||||||||||||||||||||
2054 | - | |||||||||||||||||||||||||
2055 | } | - | ||||||||||||||||||||||||
2056 | - | |||||||||||||||||||||||||
2057 | - | |||||||||||||||||||||||||
2058 | - | |||||||||||||||||||||||||
2059 | - | |||||||||||||||||||||||||
2060 | - | |||||||||||||||||||||||||
2061 | void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) | - | ||||||||||||||||||||||||
2062 | { | - | ||||||||||||||||||||||||
2063 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2064 | - | |||||||||||||||||||||||||
2065 | if (d->delayedPendingLayout
| 0 | ||||||||||||||||||||||||
2066 | QAbstractItemView::rowsInserted(parent, start, end); | - | ||||||||||||||||||||||||
2067 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2068 | } | - | ||||||||||||||||||||||||
2069 | - | |||||||||||||||||||||||||
2070 | - | |||||||||||||||||||||||||
2071 | if (parent.column() != 0
| 0 | ||||||||||||||||||||||||
2072 | QAbstractItemView::rowsInserted(parent, start, end); | - | ||||||||||||||||||||||||
2073 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2074 | } | - | ||||||||||||||||||||||||
2075 | - | |||||||||||||||||||||||||
2076 | const int parentRowCount = d->model->rowCount(parent); | - | ||||||||||||||||||||||||
2077 | const int delta = end - start + 1; | - | ||||||||||||||||||||||||
2078 | if (parent != d->root
| 0 | ||||||||||||||||||||||||
2079 | QAbstractItemView::rowsInserted(parent, start, end); | - | ||||||||||||||||||||||||
2080 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2081 | } | - | ||||||||||||||||||||||||
2082 | - | |||||||||||||||||||||||||
2083 | const int parentItem = d->viewIndex(parent); | - | ||||||||||||||||||||||||
2084 | if (((
| 0 | ||||||||||||||||||||||||
2085 | || (
| 0 | ||||||||||||||||||||||||
2086 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
2087 | } never executed: else if (parentItem != -1end of block
| 0 | ||||||||||||||||||||||||
2088 | - | |||||||||||||||||||||||||
2089 | d->viewItems[parentItem].hasChildren = true; | - | ||||||||||||||||||||||||
2090 | viewport()->update(); | - | ||||||||||||||||||||||||
2091 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2092 | QAbstractItemView::rowsInserted(parent, start, end); | - | ||||||||||||||||||||||||
2093 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2094 | - | |||||||||||||||||||||||||
2095 | - | |||||||||||||||||||||||||
2096 | - | |||||||||||||||||||||||||
2097 | - | |||||||||||||||||||||||||
2098 | - | |||||||||||||||||||||||||
2099 | void QTreeView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) | - | ||||||||||||||||||||||||
2100 | { | - | ||||||||||||||||||||||||
2101 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2102 | QAbstractItemView::rowsAboutToBeRemoved(parent, start, end); | - | ||||||||||||||||||||||||
2103 | d->viewItems.clear(); | - | ||||||||||||||||||||||||
2104 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2105 | - | |||||||||||||||||||||||||
2106 | - | |||||||||||||||||||||||||
2107 | - | |||||||||||||||||||||||||
2108 | - | |||||||||||||||||||||||||
2109 | - | |||||||||||||||||||||||||
2110 | - | |||||||||||||||||||||||||
2111 | - | |||||||||||||||||||||||||
2112 | void QTreeView::rowsRemoved(const QModelIndex &parent, int start, int end) | - | ||||||||||||||||||||||||
2113 | { | - | ||||||||||||||||||||||||
2114 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2115 | d->viewItems.clear(); | - | ||||||||||||||||||||||||
2116 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
2117 | d->hasRemovedItems = true; | - | ||||||||||||||||||||||||
2118 | d->_q_rowsRemoved(parent, start, end); | - | ||||||||||||||||||||||||
2119 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2120 | - | |||||||||||||||||||||||||
2121 | - | |||||||||||||||||||||||||
2122 | - | |||||||||||||||||||||||||
2123 | - | |||||||||||||||||||||||||
2124 | - | |||||||||||||||||||||||||
2125 | void QTreeView::columnCountChanged(int oldCount, int newCount) | - | ||||||||||||||||||||||||
2126 | { | - | ||||||||||||||||||||||||
2127 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2128 | if (oldCount == 0
| 0 | ||||||||||||||||||||||||
2129 | - | |||||||||||||||||||||||||
2130 | d->doDelayedItemsLayout(); | - | ||||||||||||||||||||||||
2131 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2132 | - | |||||||||||||||||||||||||
2133 | if (isVisible()
| 0 | ||||||||||||||||||||||||
2134 | updateGeometries(); never executed: updateGeometries(); | 0 | ||||||||||||||||||||||||
2135 | viewport()->update(); | - | ||||||||||||||||||||||||
2136 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2137 | - | |||||||||||||||||||||||||
2138 | - | |||||||||||||||||||||||||
2139 | - | |||||||||||||||||||||||||
2140 | - | |||||||||||||||||||||||||
2141 | - | |||||||||||||||||||||||||
2142 | - | |||||||||||||||||||||||||
2143 | void QTreeView::resizeColumnToContents(int column) | - | ||||||||||||||||||||||||
2144 | { | - | ||||||||||||||||||||||||
2145 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2146 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
2147 | if (column < 0
| 0 | ||||||||||||||||||||||||
2148 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2149 | int contents = sizeHintForColumn(column); | - | ||||||||||||||||||||||||
2150 | int header = d->header->isHidden()
| 0 | ||||||||||||||||||||||||
2151 | d->header->resizeSection(column, qMax(contents, header)); | - | ||||||||||||||||||||||||
2152 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2153 | - | |||||||||||||||||||||||||
2154 | - | |||||||||||||||||||||||||
2155 | - | |||||||||||||||||||||||||
2156 | - | |||||||||||||||||||||||||
2157 | - | |||||||||||||||||||||||||
2158 | - | |||||||||||||||||||||||||
2159 | - | |||||||||||||||||||||||||
2160 | void QTreeView::sortByColumn(int column) | - | ||||||||||||||||||||||||
2161 | { | - | ||||||||||||||||||||||||
2162 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2163 | sortByColumn(column, d->header->sortIndicatorOrder()); | - | ||||||||||||||||||||||||
2164 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2165 | void QTreeView::sortByColumn(int column, Qt::SortOrder order) | - | ||||||||||||||||||||||||
2166 | { | - | ||||||||||||||||||||||||
2167 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2168 | - | |||||||||||||||||||||||||
2169 | - | |||||||||||||||||||||||||
2170 | d->header->setSortIndicator(column, order); | - | ||||||||||||||||||||||||
2171 | - | |||||||||||||||||||||||||
2172 | if (!d->sortingEnabled
| 0 | ||||||||||||||||||||||||
2173 | d->model->sort(column, order); never executed: d->model->sort(column, order); | 0 | ||||||||||||||||||||||||
2174 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2175 | - | |||||||||||||||||||||||||
2176 | - | |||||||||||||||||||||||||
2177 | - | |||||||||||||||||||||||||
2178 | - | |||||||||||||||||||||||||
2179 | void QTreeView::selectAll() | - | ||||||||||||||||||||||||
2180 | { | - | ||||||||||||||||||||||||
2181 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2182 | if (!selectionModel()
| 0 | ||||||||||||||||||||||||
2183 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2184 | SelectionMode mode = d->selectionMode; | - | ||||||||||||||||||||||||
2185 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
2186 | if (mode != SingleSelection
| 0 | ||||||||||||||||||||||||
2187 | const QModelIndex &idx = d->viewItems.last().index; | - | ||||||||||||||||||||||||
2188 | QModelIndex lastItemIndex = idx.sibling(idx.row(), d->model->columnCount(idx.parent()) - 1); | - | ||||||||||||||||||||||||
2189 | d->select(d->viewItems.first().index, lastItemIndex, | - | ||||||||||||||||||||||||
2190 | QItemSelectionModel::ClearAndSelect | - | ||||||||||||||||||||||||
2191 | |QItemSelectionModel::Rows); | - | ||||||||||||||||||||||||
2192 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2193 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2194 | - | |||||||||||||||||||||||||
2195 | - | |||||||||||||||||||||||||
2196 | - | |||||||||||||||||||||||||
2197 | - | |||||||||||||||||||||||||
2198 | QSize QTreeView::viewportSizeHint() const | - | ||||||||||||||||||||||||
2199 | { | - | ||||||||||||||||||||||||
2200 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2201 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
2202 | - | |||||||||||||||||||||||||
2203 | if (d->viewItems.size() == 0
| 0 | ||||||||||||||||||||||||
2204 | return never executed: QAbstractItemView::viewportSizeHint();return QAbstractItemView::viewportSizeHint(); never executed: return QAbstractItemView::viewportSizeHint(); | 0 | ||||||||||||||||||||||||
2205 | - | |||||||||||||||||||||||||
2206 | - | |||||||||||||||||||||||||
2207 | const QRect deepestRect = visualRect(d->viewItems.last().index); | - | ||||||||||||||||||||||||
2208 | - | |||||||||||||||||||||||||
2209 | if (!deepestRect.isValid()
| 0 | ||||||||||||||||||||||||
2210 | return never executed: QAbstractItemView::viewportSizeHint();return QAbstractItemView::viewportSizeHint(); never executed: return QAbstractItemView::viewportSizeHint(); | 0 | ||||||||||||||||||||||||
2211 | - | |||||||||||||||||||||||||
2212 | QSize result = QSize(d->header->length(), deepestRect.bottom() + 1); | - | ||||||||||||||||||||||||
2213 | - | |||||||||||||||||||||||||
2214 | - | |||||||||||||||||||||||||
2215 | result += QSize(0, d->header->isVisible() ? d->header->height() : 0); | - | ||||||||||||||||||||||||
2216 | - | |||||||||||||||||||||||||
2217 | - | |||||||||||||||||||||||||
2218 | result += QSize(verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0, | - | ||||||||||||||||||||||||
2219 | horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0); | - | ||||||||||||||||||||||||
2220 | - | |||||||||||||||||||||||||
2221 | return never executed: result;return result; never executed: return result; | 0 | ||||||||||||||||||||||||
2222 | } | - | ||||||||||||||||||||||||
2223 | void QTreeView::expandAll() | - | ||||||||||||||||||||||||
2224 | { | - | ||||||||||||||||||||||||
2225 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2226 | d->viewItems.clear(); | - | ||||||||||||||||||||||||
2227 | d->interruptDelayedItemsLayout(); | - | ||||||||||||||||||||||||
2228 | d->layout(-1, true); | - | ||||||||||||||||||||||||
2229 | updateGeometries(); | - | ||||||||||||||||||||||||
2230 | d->viewport->update(); | - | ||||||||||||||||||||||||
2231 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2232 | void QTreeView::collapseAll() | - | ||||||||||||||||||||||||
2233 | { | - | ||||||||||||||||||||||||
2234 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2235 | QSet<QPersistentModelIndex> old_expandedIndexes; | - | ||||||||||||||||||||||||
2236 | old_expandedIndexes = d->expandedIndexes; | - | ||||||||||||||||||||||||
2237 | d->expandedIndexes.clear(); | - | ||||||||||||||||||||||||
2238 | if (!signalsBlocked()
| 0 | ||||||||||||||||||||||||
2239 | QSet<QPersistentModelIndex>::const_iterator i = old_expandedIndexes.constBegin(); | - | ||||||||||||||||||||||||
2240 | for (; i != old_expandedIndexes.constEnd()
| 0 | ||||||||||||||||||||||||
2241 | const QPersistentModelIndex &mi = (*i); | - | ||||||||||||||||||||||||
2242 | if (mi.isValid()
| 0 | ||||||||||||||||||||||||
2243 | collapsed(mi); never executed: collapsed(mi); | 0 | ||||||||||||||||||||||||
2244 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2246 | doItemsLayout(); | - | ||||||||||||||||||||||||
2247 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2248 | - | |||||||||||||||||||||||||
2249 | - | |||||||||||||||||||||||||
2250 | - | |||||||||||||||||||||||||
2251 | - | |||||||||||||||||||||||||
2252 | - | |||||||||||||||||||||||||
2253 | - | |||||||||||||||||||||||||
2254 | - | |||||||||||||||||||||||||
2255 | void QTreeView::expandToDepth(int depth) | - | ||||||||||||||||||||||||
2256 | { | - | ||||||||||||||||||||||||
2257 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2258 | d->viewItems.clear(); | - | ||||||||||||||||||||||||
2259 | QSet<QPersistentModelIndex> old_expandedIndexes; | - | ||||||||||||||||||||||||
2260 | old_expandedIndexes = d->expandedIndexes; | - | ||||||||||||||||||||||||
2261 | d->expandedIndexes.clear(); | - | ||||||||||||||||||||||||
2262 | d->interruptDelayedItemsLayout(); | - | ||||||||||||||||||||||||
2263 | d->layout(-1); | - | ||||||||||||||||||||||||
2264 | for (int i = 0; i < d->viewItems.count()
| 0 | ||||||||||||||||||||||||
2265 | if (d->viewItems.at(i).level <= (uint)depth
| 0 | ||||||||||||||||||||||||
2266 | d->viewItems[i].expanded = true; | - | ||||||||||||||||||||||||
2267 | d->layout(i); | - | ||||||||||||||||||||||||
2268 | d->storeExpanded(d->viewItems.at(i).index); | - | ||||||||||||||||||||||||
2269 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2270 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2271 | - | |||||||||||||||||||||||||
2272 | bool someSignalEnabled = isSignalConnected(QMetaMethod::fromSignal(&QTreeView::collapsed)); | - | ||||||||||||||||||||||||
2273 | someSignalEnabled |= isSignalConnected(QMetaMethod::fromSignal(&QTreeView::expanded)); | - | ||||||||||||||||||||||||
2274 | - | |||||||||||||||||||||||||
2275 | if (!signalsBlocked()
| 0 | ||||||||||||||||||||||||
2276 | - | |||||||||||||||||||||||||
2277 | QSet<QPersistentModelIndex> collapsedIndexes = old_expandedIndexes - d->expandedIndexes; | - | ||||||||||||||||||||||||
2278 | QSet<QPersistentModelIndex>::const_iterator i = collapsedIndexes.constBegin(); | - | ||||||||||||||||||||||||
2279 | for (; i != collapsedIndexes.constEnd()
| 0 | ||||||||||||||||||||||||
2280 | const QPersistentModelIndex &mi = (*i); | - | ||||||||||||||||||||||||
2281 | if (mi.isValid()
| 0 | ||||||||||||||||||||||||
2282 | collapsed(mi); never executed: collapsed(mi); | 0 | ||||||||||||||||||||||||
2283 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2284 | - | |||||||||||||||||||||||||
2285 | QSet<QPersistentModelIndex> expandedIndexs = d->expandedIndexes - old_expandedIndexes; | - | ||||||||||||||||||||||||
2286 | i = expandedIndexs.constBegin(); | - | ||||||||||||||||||||||||
2287 | for (; i != expandedIndexs.constEnd()
| 0 | ||||||||||||||||||||||||
2288 | const QPersistentModelIndex &mi = (*i); | - | ||||||||||||||||||||||||
2289 | if (mi.isValid()
| 0 | ||||||||||||||||||||||||
2290 | expanded(mi); never executed: expanded(mi); | 0 | ||||||||||||||||||||||||
2291 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2292 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2293 | - | |||||||||||||||||||||||||
2294 | updateGeometries(); | - | ||||||||||||||||||||||||
2295 | d->viewport->update(); | - | ||||||||||||||||||||||||
2296 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2297 | void QTreeView::columnResized(int column, int , int ) | - | ||||||||||||||||||||||||
2298 | { | - | ||||||||||||||||||||||||
2299 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2300 | d->columnsToUpdate.append(column); | - | ||||||||||||||||||||||||
2301 | if (d->columnResizeTimerID == 0
| 0 | ||||||||||||||||||||||||
2302 | d->columnResizeTimerID = startTimer(0); never executed: d->columnResizeTimerID = startTimer(0); | 0 | ||||||||||||||||||||||||
2303 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2304 | - | |||||||||||||||||||||||||
2305 | - | |||||||||||||||||||||||||
2306 | - | |||||||||||||||||||||||||
2307 | - | |||||||||||||||||||||||||
2308 | void QTreeView::updateGeometries() | - | ||||||||||||||||||||||||
2309 | { | - | ||||||||||||||||||||||||
2310 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2311 | if (d->header
| 0 | ||||||||||||||||||||||||
2312 | if (d->geometryRecursionBlock
| 0 | ||||||||||||||||||||||||
2313 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2314 | d->geometryRecursionBlock = true; | - | ||||||||||||||||||||||||
2315 | int height = 0; | - | ||||||||||||||||||||||||
2316 | if (!d->header->isHidden()
| 0 | ||||||||||||||||||||||||
2317 | height = qMax(d->header->minimumHeight(), d->header->sizeHint().height()); | - | ||||||||||||||||||||||||
2318 | height = qMin(height, d->header->maximumHeight()); | - | ||||||||||||||||||||||||
2319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2320 | setViewportMargins(0, height, 0, 0); | - | ||||||||||||||||||||||||
2321 | QRect vg = d->viewport->geometry(); | - | ||||||||||||||||||||||||
2322 | QRect geometryRect(vg.left(), vg.top() - height, vg.width(), height); | - | ||||||||||||||||||||||||
2323 | d->header->setGeometry(geometryRect); | - | ||||||||||||||||||||||||
2324 | QMetaObject::invokeMethod(d->header, "updateGeometries"); | - | ||||||||||||||||||||||||
2325 | d->updateScrollBars(); | - | ||||||||||||||||||||||||
2326 | d->geometryRecursionBlock = false; | - | ||||||||||||||||||||||||
2327 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2328 | QAbstractItemView::updateGeometries(); | - | ||||||||||||||||||||||||
2329 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2330 | int QTreeView::sizeHintForColumn(int column) const | - | ||||||||||||||||||||||||
2331 | { | - | ||||||||||||||||||||||||
2332 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2333 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
2334 | if (d->viewItems.isEmpty()
| 0 | ||||||||||||||||||||||||
2335 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
2336 | ensurePolished(); | - | ||||||||||||||||||||||||
2337 | int w = 0; | - | ||||||||||||||||||||||||
2338 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||||||||
2339 | const QVector<QTreeViewItem> viewItems = d->viewItems; | - | ||||||||||||||||||||||||
2340 | - | |||||||||||||||||||||||||
2341 | const int maximumProcessRows = d->header->resizeContentsPrecision(); | - | ||||||||||||||||||||||||
2342 | - | |||||||||||||||||||||||||
2343 | int offset = 0; | - | ||||||||||||||||||||||||
2344 | int start = d->firstVisibleItem(&offset); | - | ||||||||||||||||||||||||
2345 | int end = d->lastVisibleItem(start, offset); | - | ||||||||||||||||||||||||
2346 | if (start < 0
| 0 | ||||||||||||||||||||||||
2347 | end = viewItems.size() - 1; | - | ||||||||||||||||||||||||
2348 | if (maximumProcessRows < 0
| 0 | ||||||||||||||||||||||||
2349 | start = 0; | - | ||||||||||||||||||||||||
2350 | } never executed: else if (maximumProcessRows == 0end of block
| 0 | ||||||||||||||||||||||||
2351 | start = qMax(0, end - 1); | - | ||||||||||||||||||||||||
2352 | int remainingHeight = viewport()->height(); | - | ||||||||||||||||||||||||
2353 | while (start > 0
| 0 | ||||||||||||||||||||||||
2354 | remainingHeight -= d->itemHeight(start); | - | ||||||||||||||||||||||||
2355 | --start; | - | ||||||||||||||||||||||||
2356 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2357 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2358 | start = qMax(0, end - maximumProcessRows); | - | ||||||||||||||||||||||||
2359 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2360 | } | - | ||||||||||||||||||||||||
2361 | - | |||||||||||||||||||||||||
2362 | int rowsProcessed = 0; | - | ||||||||||||||||||||||||
2363 | - | |||||||||||||||||||||||||
2364 | for (int i = start; i <= end
| 0 | ||||||||||||||||||||||||
2365 | if (viewItems.at(i).spanning
| 0 | ||||||||||||||||||||||||
2366 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2367 | QModelIndex index = viewItems.at(i).index; | - | ||||||||||||||||||||||||
2368 | index = index.sibling(index.row(), column); | - | ||||||||||||||||||||||||
2369 | w = d->widthHintForIndex(index, w, option, i); | - | ||||||||||||||||||||||||
2370 | ++rowsProcessed; | - | ||||||||||||||||||||||||
2371 | if (rowsProcessed == maximumProcessRows
| 0 | ||||||||||||||||||||||||
2372 | break; never executed: break; | 0 | ||||||||||||||||||||||||
2373 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2374 | - | |||||||||||||||||||||||||
2375 | --end; | - | ||||||||||||||||||||||||
2376 | int actualBottom = viewItems.size() - 1; | - | ||||||||||||||||||||||||
2377 | - | |||||||||||||||||||||||||
2378 | if (maximumProcessRows == 0
| 0 | ||||||||||||||||||||||||
2379 | rowsProcessed = 0; never executed: rowsProcessed = 0; | 0 | ||||||||||||||||||||||||
2380 | - | |||||||||||||||||||||||||
2381 | while (rowsProcessed != maximumProcessRows
| 0 | ||||||||||||||||||||||||
2382 | int idx = -1; | - | ||||||||||||||||||||||||
2383 | - | |||||||||||||||||||||||||
2384 | if ((rowsProcessed % 2
| 0 | ||||||||||||||||||||||||
2385 | while (start > 0
| 0 | ||||||||||||||||||||||||
2386 | --start; | - | ||||||||||||||||||||||||
2387 | if (viewItems.at(start).spanning
| 0 | ||||||||||||||||||||||||
2388 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2389 | idx = start; | - | ||||||||||||||||||||||||
2390 | break; never executed: break; | 0 | ||||||||||||||||||||||||
2391 | } | - | ||||||||||||||||||||||||
2392 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2393 | while (end < actualBottom
| 0 | ||||||||||||||||||||||||
2394 | ++end; | - | ||||||||||||||||||||||||
2395 | if (viewItems.at(end).spanning
| 0 | ||||||||||||||||||||||||
2396 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2397 | idx = end; | - | ||||||||||||||||||||||||
2398 | break; never executed: break; | 0 | ||||||||||||||||||||||||
2399 | } | - | ||||||||||||||||||||||||
2400 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2401 | if (idx < 0
| 0 | ||||||||||||||||||||||||
2402 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2403 | - | |||||||||||||||||||||||||
2404 | QModelIndex index = viewItems.at(idx).index; | - | ||||||||||||||||||||||||
2405 | index = index.sibling(index.row(), column); | - | ||||||||||||||||||||||||
2406 | w = d->widthHintForIndex(index, w, option, idx); | - | ||||||||||||||||||||||||
2407 | ++rowsProcessed; | - | ||||||||||||||||||||||||
2408 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2409 | return never executed: w;return w; never executed: return w; | 0 | ||||||||||||||||||||||||
2410 | } | - | ||||||||||||||||||||||||
2411 | - | |||||||||||||||||||||||||
2412 | - | |||||||||||||||||||||||||
2413 | - | |||||||||||||||||||||||||
2414 | - | |||||||||||||||||||||||||
2415 | - | |||||||||||||||||||||||||
2416 | - | |||||||||||||||||||||||||
2417 | int QTreeView::indexRowSizeHint(const QModelIndex &index) const | - | ||||||||||||||||||||||||
2418 | { | - | ||||||||||||||||||||||||
2419 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2420 | if (!d->isIndexValid(index)
| 0 | ||||||||||||||||||||||||
2421 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2422 | - | |||||||||||||||||||||||||
2423 | int start = -1; | - | ||||||||||||||||||||||||
2424 | int end = -1; | - | ||||||||||||||||||||||||
2425 | int indexRow = index.row(); | - | ||||||||||||||||||||||||
2426 | int count = d->header->count(); | - | ||||||||||||||||||||||||
2427 | bool emptyHeader = (count == 0); | - | ||||||||||||||||||||||||
2428 | QModelIndex parent = index.parent(); | - | ||||||||||||||||||||||||
2429 | - | |||||||||||||||||||||||||
2430 | if (count
| 0 | ||||||||||||||||||||||||
2431 | - | |||||||||||||||||||||||||
2432 | start = d->header->visualIndexAt(0); | - | ||||||||||||||||||||||||
2433 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2434 | - | |||||||||||||||||||||||||
2435 | count = d->model->columnCount(parent); | - | ||||||||||||||||||||||||
2436 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2437 | - | |||||||||||||||||||||||||
2438 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
2439 | start = (start == -1
| 0 | ||||||||||||||||||||||||
2440 | end = 0; | - | ||||||||||||||||||||||||
2441 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2442 | start = (start == -1
| 0 | ||||||||||||||||||||||||
2443 | end = count - 1; | - | ||||||||||||||||||||||||
2444 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2445 | - | |||||||||||||||||||||||||
2446 | if (end < start
| 0 | ||||||||||||||||||||||||
2447 | qSwap(end, start); never executed: qSwap(end, start); | 0 | ||||||||||||||||||||||||
2448 | - | |||||||||||||||||||||||||
2449 | int height = -1; | - | ||||||||||||||||||||||||
2450 | QStyleOptionViewItem option = d->viewOptionsV1(); | - | ||||||||||||||||||||||||
2451 | - | |||||||||||||||||||||||||
2452 | - | |||||||||||||||||||||||||
2453 | - | |||||||||||||||||||||||||
2454 | - | |||||||||||||||||||||||||
2455 | - | |||||||||||||||||||||||||
2456 | option.rect.setWidth(-1); | - | ||||||||||||||||||||||||
2457 | - | |||||||||||||||||||||||||
2458 | for (int column = start; column <= end
| 0 | ||||||||||||||||||||||||
2459 | int logicalColumn = emptyHeader
| 0 | ||||||||||||||||||||||||
2460 | if (d->header->isSectionHidden(logicalColumn)
| 0 | ||||||||||||||||||||||||
2461 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
2462 | QModelIndex idx = d->model->index(indexRow, logicalColumn, parent); | - | ||||||||||||||||||||||||
2463 | if (idx.isValid()
| 0 | ||||||||||||||||||||||||
2464 | QWidget *editor = d->editorForIndex(idx).widget.data(); | - | ||||||||||||||||||||||||
2465 | if (editor
| 0 | ||||||||||||||||||||||||
2466 | height = qMax(height, editor->sizeHint().height()); | - | ||||||||||||||||||||||||
2467 | int min = editor->minimumSize().height(); | - | ||||||||||||||||||||||||
2468 | int max = editor->maximumSize().height(); | - | ||||||||||||||||||||||||
2469 | height = qBound(min, height, max); | - | ||||||||||||||||||||||||
2470 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2471 | int hint = d->delegateForIndex(idx)->sizeHint(option, idx).height(); | - | ||||||||||||||||||||||||
2472 | height = qMax(height, hint); | - | ||||||||||||||||||||||||
2473 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2474 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2475 | - | |||||||||||||||||||||||||
2476 | return never executed: height;return height; never executed: return height; | 0 | ||||||||||||||||||||||||
2477 | } | - | ||||||||||||||||||||||||
2478 | - | |||||||||||||||||||||||||
2479 | - | |||||||||||||||||||||||||
2480 | - | |||||||||||||||||||||||||
2481 | - | |||||||||||||||||||||||||
2482 | - | |||||||||||||||||||||||||
2483 | - | |||||||||||||||||||||||||
2484 | int QTreeView::rowHeight(const QModelIndex &index) const | - | ||||||||||||||||||||||||
2485 | { | - | ||||||||||||||||||||||||
2486 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2487 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
2488 | int i = d->viewIndex(index); | - | ||||||||||||||||||||||||
2489 | if (i == -1
| 0 | ||||||||||||||||||||||||
2490 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2491 | return never executed: d->itemHeight(i);return d->itemHeight(i); never executed: return d->itemHeight(i); | 0 | ||||||||||||||||||||||||
2492 | } | - | ||||||||||||||||||||||||
2493 | - | |||||||||||||||||||||||||
2494 | - | |||||||||||||||||||||||||
2495 | - | |||||||||||||||||||||||||
2496 | - | |||||||||||||||||||||||||
2497 | void QTreeView::horizontalScrollbarAction(int action) | - | ||||||||||||||||||||||||
2498 | { | - | ||||||||||||||||||||||||
2499 | QAbstractItemView::horizontalScrollbarAction(action); | - | ||||||||||||||||||||||||
2500 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2501 | - | |||||||||||||||||||||||||
2502 | - | |||||||||||||||||||||||||
2503 | - | |||||||||||||||||||||||||
2504 | - | |||||||||||||||||||||||||
2505 | bool QTreeView::isIndexHidden(const QModelIndex &index) const | - | ||||||||||||||||||||||||
2506 | { | - | ||||||||||||||||||||||||
2507 | return never executed: (isColumnHidden(index.column())return (isColumnHidden(index.column()) || isRowHidden(index.row(), index.parent()));
never executed: return (isColumnHidden(index.column()) || isRowHidden(index.row(), index.parent())); | 0 | ||||||||||||||||||||||||
2508 | } | - | ||||||||||||||||||||||||
2509 | - | |||||||||||||||||||||||||
2510 | - | |||||||||||||||||||||||||
2511 | - | |||||||||||||||||||||||||
2512 | - | |||||||||||||||||||||||||
2513 | void QTreeViewPrivate::initialize() | - | ||||||||||||||||||||||||
2514 | { | - | ||||||||||||||||||||||||
2515 | QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
2516 | - | |||||||||||||||||||||||||
2517 | updateIndentationFromStyle(); | - | ||||||||||||||||||||||||
2518 | updateStyledFrameWidths(); | - | ||||||||||||||||||||||||
2519 | q->setSelectionBehavior(QAbstractItemView::SelectRows); | - | ||||||||||||||||||||||||
2520 | q->setSelectionMode(QAbstractItemView::SingleSelection); | - | ||||||||||||||||||||||||
2521 | q->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); | - | ||||||||||||||||||||||||
2522 | q->setAttribute(Qt::WA_MacShowFocusRect); | - | ||||||||||||||||||||||||
2523 | - | |||||||||||||||||||||||||
2524 | QHeaderView *header = new QHeaderView(Qt::Horizontal, q); | - | ||||||||||||||||||||||||
2525 | header->setSectionsMovable(true); | - | ||||||||||||||||||||||||
2526 | header->setStretchLastSection(true); | - | ||||||||||||||||||||||||
2527 | header->setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter); | - | ||||||||||||||||||||||||
2528 | q->setHeader(header); | - | ||||||||||||||||||||||||
2529 | - | |||||||||||||||||||||||||
2530 | animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animate, 0, q); | - | ||||||||||||||||||||||||
2531 | QObject::connect(&animatedOperation, qFlagLocation("2""finished()" "\0" __FILE__ ":" "3068"), q, qFlagLocation("1""_q_endAnimatedOperation()" "\0" __FILE__ ":" "3068")); | - | ||||||||||||||||||||||||
2532 | - | |||||||||||||||||||||||||
2533 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2534 | - | |||||||||||||||||||||||||
2535 | void QTreeViewPrivate::expand(int item, bool emitSignal) | - | ||||||||||||||||||||||||
2536 | { | - | ||||||||||||||||||||||||
2537 | QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
2538 | - | |||||||||||||||||||||||||
2539 | if (item == -1
| 0 | ||||||||||||||||||||||||
2540 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2541 | const QModelIndex index = viewItems.at(item).index; | - | ||||||||||||||||||||||||
2542 | if (index.flags() & Qt::ItemNeverHasChildren
| 0 | ||||||||||||||||||||||||
2543 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2544 | - | |||||||||||||||||||||||||
2545 | - | |||||||||||||||||||||||||
2546 | if (emitSignal
| 0 | ||||||||||||||||||||||||
2547 | prepareAnimatedOperation(item, QVariantAnimation::Forward); never executed: prepareAnimatedOperation(item, QVariantAnimation::Forward); | 0 | ||||||||||||||||||||||||
2548 | - | |||||||||||||||||||||||||
2549 | - | |||||||||||||||||||||||||
2550 | if (state != QAbstractItemView::AnimatingState
| 0 | ||||||||||||||||||||||||
2551 | stateBeforeAnimation = state; never executed: stateBeforeAnimation = state; | 0 | ||||||||||||||||||||||||
2552 | q->setState(QAbstractItemView::ExpandingState); | - | ||||||||||||||||||||||||
2553 | storeExpanded(index); | - | ||||||||||||||||||||||||
2554 | viewItems[item].expanded = true; | - | ||||||||||||||||||||||||
2555 | layout(item); | - | ||||||||||||||||||||||||
2556 | q->setState(stateBeforeAnimation); | - | ||||||||||||||||||||||||
2557 | - | |||||||||||||||||||||||||
2558 | if (model->canFetchMore(index)
| 0 | ||||||||||||||||||||||||
2559 | model->fetchMore(index); never executed: model->fetchMore(index); | 0 | ||||||||||||||||||||||||
2560 | if (emitSignal
| 0 | ||||||||||||||||||||||||
2561 | q->expanded(index); | - | ||||||||||||||||||||||||
2562 | - | |||||||||||||||||||||||||
2563 | if (animationsEnabled
| 0 | ||||||||||||||||||||||||
2564 | beginAnimatedOperation(); never executed: beginAnimatedOperation(); | 0 | ||||||||||||||||||||||||
2565 | - | |||||||||||||||||||||||||
2566 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2567 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2568 | - | |||||||||||||||||||||||||
2569 | void QTreeViewPrivate::insertViewItems(int pos, int count, const QTreeViewItem &viewItem) | - | ||||||||||||||||||||||||
2570 | { | - | ||||||||||||||||||||||||
2571 | viewItems.insert(pos, count, viewItem); | - | ||||||||||||||||||||||||
2572 | QTreeViewItem *items = viewItems.data(); | - | ||||||||||||||||||||||||
2573 | for (int i = pos + count; i < viewItems.count()
| 0 | ||||||||||||||||||||||||
2574 | if (items[i].parentItem >= pos
| 0 | ||||||||||||||||||||||||
2575 | items[i].parentItem += count; never executed: items[i].parentItem += count; | 0 | ||||||||||||||||||||||||
2576 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2577 | - | |||||||||||||||||||||||||
2578 | void QTreeViewPrivate::removeViewItems(int pos, int count) | - | ||||||||||||||||||||||||
2579 | { | - | ||||||||||||||||||||||||
2580 | viewItems.remove(pos, count); | - | ||||||||||||||||||||||||
2581 | QTreeViewItem *items = viewItems.data(); | - | ||||||||||||||||||||||||
2582 | for (int i = pos; i < viewItems.count()
| 0 | ||||||||||||||||||||||||
2583 | if (items[i].parentItem >= pos
| 0 | ||||||||||||||||||||||||
2584 | items[i].parentItem -= count; never executed: items[i].parentItem -= count; | 0 | ||||||||||||||||||||||||
2585 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2586 | void QTreeViewPrivate::collapse(int item, bool emitSignal) | - | ||||||||||||||||||||||||
2587 | { | - | ||||||||||||||||||||||||
2588 | QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
2589 | - | |||||||||||||||||||||||||
2590 | if (item == -1
| 0 | ||||||||||||||||||||||||
2591 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2592 | - | |||||||||||||||||||||||||
2593 | - | |||||||||||||||||||||||||
2594 | delayedAutoScroll.stop(); | - | ||||||||||||||||||||||||
2595 | - | |||||||||||||||||||||||||
2596 | int total = viewItems.at(item).total; | - | ||||||||||||||||||||||||
2597 | const QModelIndex &modelIndex = viewItems.at(item).index; | - | ||||||||||||||||||||||||
2598 | if (!isPersistent(modelIndex)
| 0 | ||||||||||||||||||||||||
2599 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2600 | QSet<QPersistentModelIndex>::iterator it = expandedIndexes.find(modelIndex); | - | ||||||||||||||||||||||||
2601 | if (it == expandedIndexes.end()
| 0 | ||||||||||||||||||||||||
2602 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2603 | - | |||||||||||||||||||||||||
2604 | - | |||||||||||||||||||||||||
2605 | if (emitSignal
| 0 | ||||||||||||||||||||||||
2606 | prepareAnimatedOperation(item, QVariantAnimation::Backward); never executed: prepareAnimatedOperation(item, QVariantAnimation::Backward); | 0 | ||||||||||||||||||||||||
2607 | - | |||||||||||||||||||||||||
2608 | - | |||||||||||||||||||||||||
2609 | - | |||||||||||||||||||||||||
2610 | if (state != QAbstractItemView::AnimatingState
| 0 | ||||||||||||||||||||||||
2611 | stateBeforeAnimation = state; never executed: stateBeforeAnimation = state; | 0 | ||||||||||||||||||||||||
2612 | q->setState(QAbstractItemView::CollapsingState); | - | ||||||||||||||||||||||||
2613 | expandedIndexes.erase(it); | - | ||||||||||||||||||||||||
2614 | viewItems[item].expanded = false; | - | ||||||||||||||||||||||||
2615 | int index = item; | - | ||||||||||||||||||||||||
2616 | while (index > -1
| 0 | ||||||||||||||||||||||||
2617 | viewItems[index].total -= total; | - | ||||||||||||||||||||||||
2618 | index = viewItems[index].parentItem; | - | ||||||||||||||||||||||||
2619 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2620 | removeViewItems(item + 1, total); | - | ||||||||||||||||||||||||
2621 | q->setState(stateBeforeAnimation); | - | ||||||||||||||||||||||||
2622 | - | |||||||||||||||||||||||||
2623 | if (emitSignal
| 0 | ||||||||||||||||||||||||
2624 | q->collapsed(modelIndex); | - | ||||||||||||||||||||||||
2625 | - | |||||||||||||||||||||||||
2626 | if (animationsEnabled
| 0 | ||||||||||||||||||||||||
2627 | beginAnimatedOperation(); never executed: beginAnimatedOperation(); | 0 | ||||||||||||||||||||||||
2628 | - | |||||||||||||||||||||||||
2629 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2630 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2631 | - | |||||||||||||||||||||||||
2632 | - | |||||||||||||||||||||||||
2633 | void QTreeViewPrivate::prepareAnimatedOperation(int item, QVariantAnimation::Direction direction) | - | ||||||||||||||||||||||||
2634 | { | - | ||||||||||||||||||||||||
2635 | animatedOperation.item = item; | - | ||||||||||||||||||||||||
2636 | animatedOperation.viewport = viewport; | - | ||||||||||||||||||||||||
2637 | animatedOperation.setDirection(direction); | - | ||||||||||||||||||||||||
2638 | - | |||||||||||||||||||||||||
2639 | int top = coordinateForItem(item) + itemHeight(item); | - | ||||||||||||||||||||||||
2640 | QRect rect = viewport->rect(); | - | ||||||||||||||||||||||||
2641 | rect.setTop(top); | - | ||||||||||||||||||||||||
2642 | if (direction == QVariantAnimation::Backward
| 0 | ||||||||||||||||||||||||
2643 | const int limit = rect.height() * 2; | - | ||||||||||||||||||||||||
2644 | int h = 0; | - | ||||||||||||||||||||||||
2645 | int c = item + viewItems.at(item).total + 1; | - | ||||||||||||||||||||||||
2646 | for (int i = item + 1; i < c
| 0 | ||||||||||||||||||||||||
2647 | h += itemHeight(i); never executed: h += itemHeight(i); | 0 | ||||||||||||||||||||||||
2648 | rect.setHeight(h); | - | ||||||||||||||||||||||||
2649 | animatedOperation.setEndValue(top + h); | - | ||||||||||||||||||||||||
2650 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2651 | animatedOperation.setStartValue(top); | - | ||||||||||||||||||||||||
2652 | animatedOperation.before = renderTreeToPixmapForAnimation(rect); | - | ||||||||||||||||||||||||
2653 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2654 | - | |||||||||||||||||||||||||
2655 | void QTreeViewPrivate::beginAnimatedOperation() | - | ||||||||||||||||||||||||
2656 | { | - | ||||||||||||||||||||||||
2657 | QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
2658 | - | |||||||||||||||||||||||||
2659 | QRect rect = viewport->rect(); | - | ||||||||||||||||||||||||
2660 | rect.setTop(animatedOperation.top()); | - | ||||||||||||||||||||||||
2661 | if (animatedOperation.direction() == QVariantAnimation::Forward
| 0 | ||||||||||||||||||||||||
2662 | const int limit = rect.height() * 2; | - | ||||||||||||||||||||||||
2663 | int h = 0; | - | ||||||||||||||||||||||||
2664 | int c = animatedOperation.item + viewItems.at(animatedOperation.item).total + 1; | - | ||||||||||||||||||||||||
2665 | for (int i = animatedOperation.item + 1; i < c
| 0 | ||||||||||||||||||||||||
2666 | h += itemHeight(i); never executed: h += itemHeight(i); | 0 | ||||||||||||||||||||||||
2667 | rect.setHeight(h); | - | ||||||||||||||||||||||||
2668 | animatedOperation.setEndValue(animatedOperation.top() + h); | - | ||||||||||||||||||||||||
2669 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2670 | - | |||||||||||||||||||||||||
2671 | if (!rect.isEmpty()
| 0 | ||||||||||||||||||||||||
2672 | animatedOperation.after = renderTreeToPixmapForAnimation(rect); | - | ||||||||||||||||||||||||
2673 | - | |||||||||||||||||||||||||
2674 | q->setState(QAbstractItemView::AnimatingState); | - | ||||||||||||||||||||||||
2675 | animatedOperation.start(); | - | ||||||||||||||||||||||||
2676 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2677 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2678 | - | |||||||||||||||||||||||||
2679 | void QTreeViewPrivate::drawAnimatedOperation(QPainter *painter) const | - | ||||||||||||||||||||||||
2680 | { | - | ||||||||||||||||||||||||
2681 | const int start = animatedOperation.startValue().toInt(), | - | ||||||||||||||||||||||||
2682 | end = animatedOperation.endValue().toInt(), | - | ||||||||||||||||||||||||
2683 | current = animatedOperation.currentValue().toInt(); | - | ||||||||||||||||||||||||
2684 | bool collapsing = animatedOperation.direction() == QVariantAnimation::Backward; | - | ||||||||||||||||||||||||
2685 | const QPixmap top = collapsing
| 0 | ||||||||||||||||||||||||
2686 | painter->drawPixmap(0, start, top, 0, end - current - 1, top.width(), top.height()); | - | ||||||||||||||||||||||||
2687 | const QPixmap bottom = collapsing
| 0 | ||||||||||||||||||||||||
2688 | painter->drawPixmap(0, current, bottom); | - | ||||||||||||||||||||||||
2689 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2690 | - | |||||||||||||||||||||||||
2691 | QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) const | - | ||||||||||||||||||||||||
2692 | { | - | ||||||||||||||||||||||||
2693 | const QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
2694 | QPixmap pixmap(rect.size() * q->devicePixelRatio()); | - | ||||||||||||||||||||||||
2695 | pixmap.setDevicePixelRatio(q->devicePixelRatio()); | - | ||||||||||||||||||||||||
2696 | if (rect.size().isEmpty()
| 0 | ||||||||||||||||||||||||
2697 | return never executed: pixmap;return pixmap; never executed: return pixmap; | 0 | ||||||||||||||||||||||||
2698 | pixmap.fill(Qt::transparent); | - | ||||||||||||||||||||||||
2699 | QPainter painter(&pixmap); | - | ||||||||||||||||||||||||
2700 | painter.fillRect(QRect(QPoint(0,0), rect.size()), q->palette().base()); | - | ||||||||||||||||||||||||
2701 | painter.translate(0, -rect.top()); | - | ||||||||||||||||||||||||
2702 | q->drawTree(&painter, QRegion(rect)); | - | ||||||||||||||||||||||||
2703 | painter.end(); | - | ||||||||||||||||||||||||
2704 | - | |||||||||||||||||||||||||
2705 | - | |||||||||||||||||||||||||
2706 | QStyleOptionViewItem option = viewOptionsV1(); | - | ||||||||||||||||||||||||
2707 | for (QEditorIndexHash::const_iterator it = editorIndexHash.constBegin(); it != editorIndexHash.constEnd()
| 0 | ||||||||||||||||||||||||
2708 | QWidget *editor = it.key(); | - | ||||||||||||||||||||||||
2709 | const QModelIndex &index = it.value(); | - | ||||||||||||||||||||||||
2710 | option.rect = q->visualRect(index); | - | ||||||||||||||||||||||||
2711 | if (option.rect.isValid()
| 0 | ||||||||||||||||||||||||
2712 | - | |||||||||||||||||||||||||
2713 | if (QAbstractItemDelegate *delegate = delegateForIndex(index)
| 0 | ||||||||||||||||||||||||
2714 | delegate-> never executed: updateEditorGeometry(editor, option, index);delegate->updateEditorGeometry(editor, option, index); never executed: delegate->updateEditorGeometry(editor, option, index); | 0 | ||||||||||||||||||||||||
2715 | - | |||||||||||||||||||||||||
2716 | const QPoint pos = editor->pos(); | - | ||||||||||||||||||||||||
2717 | if (rect.contains(pos)
| 0 | ||||||||||||||||||||||||
2718 | editor->render(&pixmap, pos - rect.topLeft()); | - | ||||||||||||||||||||||||
2719 | - | |||||||||||||||||||||||||
2720 | - | |||||||||||||||||||||||||
2721 | editor->hide(); | - | ||||||||||||||||||||||||
2722 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2723 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2724 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2725 | - | |||||||||||||||||||||||||
2726 | - | |||||||||||||||||||||||||
2727 | return never executed: pixmap;return pixmap; never executed: return pixmap; | 0 | ||||||||||||||||||||||||
2728 | } | - | ||||||||||||||||||||||||
2729 | - | |||||||||||||||||||||||||
2730 | void QTreeViewPrivate::_q_endAnimatedOperation() | - | ||||||||||||||||||||||||
2731 | { | - | ||||||||||||||||||||||||
2732 | QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
2733 | q->setState(stateBeforeAnimation); | - | ||||||||||||||||||||||||
2734 | q->updateGeometries(); | - | ||||||||||||||||||||||||
2735 | viewport->update(); | - | ||||||||||||||||||||||||
2736 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2737 | - | |||||||||||||||||||||||||
2738 | - | |||||||||||||||||||||||||
2739 | void QTreeViewPrivate::_q_modelAboutToBeReset() | - | ||||||||||||||||||||||||
2740 | { | - | ||||||||||||||||||||||||
2741 | viewItems.clear(); | - | ||||||||||||||||||||||||
2742 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2743 | - | |||||||||||||||||||||||||
2744 | void QTreeViewPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end) | - | ||||||||||||||||||||||||
2745 | { | - | ||||||||||||||||||||||||
2746 | if (start <= 0
| 0 | ||||||||||||||||||||||||
2747 | viewItems.clear(); never executed: viewItems.clear(); | 0 | ||||||||||||||||||||||||
2748 | QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(parent, start, end); | - | ||||||||||||||||||||||||
2749 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2750 | - | |||||||||||||||||||||||||
2751 | void QTreeViewPrivate::_q_columnsRemoved(const QModelIndex &parent, int start, int end) | - | ||||||||||||||||||||||||
2752 | { | - | ||||||||||||||||||||||||
2753 | if (start <= 0
| 0 | ||||||||||||||||||||||||
2754 | doDelayedItemsLayout(); never executed: doDelayedItemsLayout(); | 0 | ||||||||||||||||||||||||
2755 | QAbstractItemViewPrivate::_q_columnsRemoved(parent, start, end); | - | ||||||||||||||||||||||||
2756 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2757 | void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninitialized) | - | ||||||||||||||||||||||||
2758 | { | - | ||||||||||||||||||||||||
2759 | QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
2760 | QModelIndex current; | - | ||||||||||||||||||||||||
2761 | QModelIndex parent = (
| 0 | ||||||||||||||||||||||||
2762 | - | |||||||||||||||||||||||||
2763 | if (i>=0
| 0 | ||||||||||||||||||||||||
2764 | - | |||||||||||||||||||||||||
2765 | - | |||||||||||||||||||||||||
2766 | - | |||||||||||||||||||||||||
2767 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2768 | } | - | ||||||||||||||||||||||||
2769 | - | |||||||||||||||||||||||||
2770 | int count = 0; | - | ||||||||||||||||||||||||
2771 | if (model->hasChildren(parent)
| 0 | ||||||||||||||||||||||||
2772 | if (model->canFetchMore(parent)
| 0 | ||||||||||||||||||||||||
2773 | model->fetchMore(parent); never executed: model->fetchMore(parent); | 0 | ||||||||||||||||||||||||
2774 | count = model->rowCount(parent); | - | ||||||||||||||||||||||||
2775 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2776 | - | |||||||||||||||||||||||||
2777 | bool expanding = true; | - | ||||||||||||||||||||||||
2778 | if (i == -1
| 0 | ||||||||||||||||||||||||
2779 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
2780 | QModelIndex index = model->index(0, 0, parent); | - | ||||||||||||||||||||||||
2781 | defaultItemHeight = q->indexRowSizeHint(index); | - | ||||||||||||||||||||||||
2782 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2783 | viewItems.resize(count); | - | ||||||||||||||||||||||||
2784 | afterIsUninitialized = true; | - | ||||||||||||||||||||||||
2785 | } never executed: else if (viewItems[i].total != (uint)countend of block
| 0 | ||||||||||||||||||||||||
2786 | if (!afterIsUninitialized
| 0 | ||||||||||||||||||||||||
2787 | insertViewItems(i + 1, count, QTreeViewItem()); never executed: insertViewItems(i + 1, count, QTreeViewItem()); | 0 | ||||||||||||||||||||||||
2788 | else if (count > 0
| 0 | ||||||||||||||||||||||||
2789 | viewItems.resize(viewItems.count() + count); never executed: viewItems.resize(viewItems.count() + count); | 0 | ||||||||||||||||||||||||
2790 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2791 | expanding = false; | - | ||||||||||||||||||||||||
2792 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2793 | - | |||||||||||||||||||||||||
2794 | int first = i + 1; | - | ||||||||||||||||||||||||
2795 | int level = (i >= 0
| 0 | ||||||||||||||||||||||||
2796 | int hidden = 0; | - | ||||||||||||||||||||||||
2797 | int last = 0; | - | ||||||||||||||||||||||||
2798 | int children = 0; | - | ||||||||||||||||||||||||
2799 | QTreeViewItem *item = 0; | - | ||||||||||||||||||||||||
2800 | for (int j = first; j < first + count
| 0 | ||||||||||||||||||||||||
2801 | current = model->index(j - first, 0, parent); | - | ||||||||||||||||||||||||
2802 | if (isRowHidden(current)
| 0 | ||||||||||||||||||||||||
2803 | ++hidden; | - | ||||||||||||||||||||||||
2804 | last = j - hidden + children; | - | ||||||||||||||||||||||||
2805 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2806 | last = j - hidden + children; | - | ||||||||||||||||||||||||
2807 | if (item
| 0 | ||||||||||||||||||||||||
2808 | item->hasMoreSiblings = true; never executed: item->hasMoreSiblings = true; | 0 | ||||||||||||||||||||||||
2809 | item = &viewItems[last]; | - | ||||||||||||||||||||||||
2810 | item->index = current; | - | ||||||||||||||||||||||||
2811 | item->parentItem = i; | - | ||||||||||||||||||||||||
2812 | item->level = level; | - | ||||||||||||||||||||||||
2813 | item->height = 0; | - | ||||||||||||||||||||||||
2814 | item->spanning = q->isFirstColumnSpanned(current.row(), parent); | - | ||||||||||||||||||||||||
2815 | item->expanded = false; | - | ||||||||||||||||||||||||
2816 | item->total = 0; | - | ||||||||||||||||||||||||
2817 | item->hasMoreSiblings = false; | - | ||||||||||||||||||||||||
2818 | if ((recursiveExpanding
| 0 | ||||||||||||||||||||||||
2819 | if (recursiveExpanding
| 0 | ||||||||||||||||||||||||
2820 | q->expanded(current); never executed: q->expanded(current); | 0 | ||||||||||||||||||||||||
2821 | item->expanded = true; | - | ||||||||||||||||||||||||
2822 | layout(last, recursiveExpanding, afterIsUninitialized); | - | ||||||||||||||||||||||||
2823 | item = &viewItems[last]; | - | ||||||||||||||||||||||||
2824 | children += item->total; | - | ||||||||||||||||||||||||
2825 | item->hasChildren = item->total > 0; | - | ||||||||||||||||||||||||
2826 | last = j - hidden + children; | - | ||||||||||||||||||||||||
2827 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2828 | item->hasChildren = hasVisibleChildren(current); | - | ||||||||||||||||||||||||
2829 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2830 | } | - | ||||||||||||||||||||||||
2831 | } | - | ||||||||||||||||||||||||
2832 | - | |||||||||||||||||||||||||
2833 | - | |||||||||||||||||||||||||
2834 | if (hidden > 0
| 0 | ||||||||||||||||||||||||
2835 | if (!afterIsUninitialized
| 0 | ||||||||||||||||||||||||
2836 | removeViewItems(last + 1, hidden); never executed: removeViewItems(last + 1, hidden); | 0 | ||||||||||||||||||||||||
2837 | else | - | ||||||||||||||||||||||||
2838 | viewItems.resize(viewItems.size() - hidden); never executed: viewItems.resize(viewItems.size() - hidden); | 0 | ||||||||||||||||||||||||
2839 | } | - | ||||||||||||||||||||||||
2840 | - | |||||||||||||||||||||||||
2841 | if (!expanding
| 0 | ||||||||||||||||||||||||
2842 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2843 | - | |||||||||||||||||||||||||
2844 | while (i > -1
| 0 | ||||||||||||||||||||||||
2845 | viewItems[i].total += count - hidden; | - | ||||||||||||||||||||||||
2846 | i = viewItems[i].parentItem; | - | ||||||||||||||||||||||||
2847 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2848 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2849 | - | |||||||||||||||||||||||||
2850 | int QTreeViewPrivate::pageUp(int i) const | - | ||||||||||||||||||||||||
2851 | { | - | ||||||||||||||||||||||||
2852 | int index = itemAtCoordinate(coordinateForItem(i) - viewport->height()); | - | ||||||||||||||||||||||||
2853 | while (isItemHiddenOrDisabled(index)
| 0 | ||||||||||||||||||||||||
2854 | index--; never executed: index--; | 0 | ||||||||||||||||||||||||
2855 | return never executed: index == -1return index == -1 ? 0 : index;
never executed: return index == -1 ? 0 : index; | 0 | ||||||||||||||||||||||||
2856 | } | - | ||||||||||||||||||||||||
2857 | - | |||||||||||||||||||||||||
2858 | int QTreeViewPrivate::pageDown(int i) const | - | ||||||||||||||||||||||||
2859 | { | - | ||||||||||||||||||||||||
2860 | int index = itemAtCoordinate(coordinateForItem(i) + viewport->height()); | - | ||||||||||||||||||||||||
2861 | while (isItemHiddenOrDisabled(index)
| 0 | ||||||||||||||||||||||||
2862 | index++; never executed: index++; | 0 | ||||||||||||||||||||||||
2863 | return never executed: index == -1return index == -1 ? viewItems.count() - 1 : index;
never executed: return index == -1 ? viewItems.count() - 1 : index; | 0 | ||||||||||||||||||||||||
2864 | } | - | ||||||||||||||||||||||||
2865 | - | |||||||||||||||||||||||||
2866 | int QTreeViewPrivate::indentationForItem(int item) const | - | ||||||||||||||||||||||||
2867 | { | - | ||||||||||||||||||||||||
2868 | if (item < 0
| 0 | ||||||||||||||||||||||||
2869 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2870 | int level = viewItems.at(item).level; | - | ||||||||||||||||||||||||
2871 | if (rootDecoration
| 0 | ||||||||||||||||||||||||
2872 | ++ never executed: level;++level; never executed: ++level; | 0 | ||||||||||||||||||||||||
2873 | return never executed: level * indent;return level * indent; never executed: return level * indent; | 0 | ||||||||||||||||||||||||
2874 | } | - | ||||||||||||||||||||||||
2875 | - | |||||||||||||||||||||||||
2876 | int QTreeViewPrivate::itemHeight(int item) const | - | ||||||||||||||||||||||||
2877 | { | - | ||||||||||||||||||||||||
2878 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
2879 | return never executed: defaultItemHeight;return defaultItemHeight; never executed: return defaultItemHeight; | 0 | ||||||||||||||||||||||||
2880 | if (viewItems.isEmpty()
| 0 | ||||||||||||||||||||||||
2881 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2882 | const QModelIndex &index = viewItems.at(item).index; | - | ||||||||||||||||||||||||
2883 | if (!index.isValid()
| 0 | ||||||||||||||||||||||||
2884 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2885 | int height = viewItems.at(item).height; | - | ||||||||||||||||||||||||
2886 | if (height <= 0
| 0 | ||||||||||||||||||||||||
2887 | height = q_func()->indexRowSizeHint(index); | - | ||||||||||||||||||||||||
2888 | viewItems[item].height = height; | - | ||||||||||||||||||||||||
2889 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2890 | return never executed: qMax(height, 0);return qMax(height, 0); never executed: return qMax(height, 0); | 0 | ||||||||||||||||||||||||
2891 | } | - | ||||||||||||||||||||||||
2892 | - | |||||||||||||||||||||||||
2893 | - | |||||||||||||||||||||||||
2894 | - | |||||||||||||||||||||||||
2895 | - | |||||||||||||||||||||||||
2896 | - | |||||||||||||||||||||||||
2897 | - | |||||||||||||||||||||||||
2898 | int QTreeViewPrivate::coordinateForItem(int item) const | - | ||||||||||||||||||||||||
2899 | { | - | ||||||||||||||||||||||||
2900 | if (verticalScrollMode == QAbstractItemView::ScrollPerPixel
| 0 | ||||||||||||||||||||||||
2901 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
2902 | return never executed: (item * defaultItemHeight) - vbar->value();return (item * defaultItemHeight) - vbar->value(); never executed: return (item * defaultItemHeight) - vbar->value(); | 0 | ||||||||||||||||||||||||
2903 | - | |||||||||||||||||||||||||
2904 | int y = 0; | - | ||||||||||||||||||||||||
2905 | for (int i = 0; i < viewItems.count()
| 0 | ||||||||||||||||||||||||
2906 | if (i == item
| 0 | ||||||||||||||||||||||||
2907 | return never executed: y - vbar->value();return y - vbar->value(); never executed: return y - vbar->value(); | 0 | ||||||||||||||||||||||||
2908 | y += itemHeight(i); | - | ||||||||||||||||||||||||
2909 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2910 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2911 | int topViewItemIndex = vbar->value(); | - | ||||||||||||||||||||||||
2912 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
2913 | return never executed: defaultItemHeight * (item - topViewItemIndex);return defaultItemHeight * (item - topViewItemIndex); never executed: return defaultItemHeight * (item - topViewItemIndex); | 0 | ||||||||||||||||||||||||
2914 | if (item >= topViewItemIndex
| 0 | ||||||||||||||||||||||||
2915 | - | |||||||||||||||||||||||||
2916 | - | |||||||||||||||||||||||||
2917 | int viewItemCoordinate = 0; | - | ||||||||||||||||||||||||
2918 | int viewItemIndex = topViewItemIndex; | - | ||||||||||||||||||||||||
2919 | while (viewItemIndex < viewItems.count()
| 0 | ||||||||||||||||||||||||
2920 | if (viewItemIndex == item
| 0 | ||||||||||||||||||||||||
2921 | return never executed: viewItemCoordinate;return viewItemCoordinate; never executed: return viewItemCoordinate; | 0 | ||||||||||||||||||||||||
2922 | viewItemCoordinate += itemHeight(viewItemIndex); | - | ||||||||||||||||||||||||
2923 | ++viewItemIndex; | - | ||||||||||||||||||||||||
2924 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2925 | - | |||||||||||||||||||||||||
2926 | ((!(false)) ? qt_assert("false",__FILE__,3487) : qt_noop()); | - | ||||||||||||||||||||||||
2927 | return never executed: viewItemCoordinate;return viewItemCoordinate; never executed: return viewItemCoordinate; | 0 | ||||||||||||||||||||||||
2928 | } else { | - | ||||||||||||||||||||||||
2929 | - | |||||||||||||||||||||||||
2930 | int viewItemCoordinate = 0; | - | ||||||||||||||||||||||||
2931 | for (int viewItemIndex = topViewItemIndex; viewItemIndex > 0
| 0 | ||||||||||||||||||||||||
2932 | if (viewItemIndex == item
| 0 | ||||||||||||||||||||||||
2933 | return never executed: viewItemCoordinate;return viewItemCoordinate; never executed: return viewItemCoordinate; | 0 | ||||||||||||||||||||||||
2934 | viewItemCoordinate -= itemHeight(viewItemIndex - 1); | - | ||||||||||||||||||||||||
2935 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2936 | return never executed: viewItemCoordinate;return viewItemCoordinate; never executed: return viewItemCoordinate; | 0 | ||||||||||||||||||||||||
2937 | } | - | ||||||||||||||||||||||||
2938 | } | - | ||||||||||||||||||||||||
2939 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
2940 | } | - | ||||||||||||||||||||||||
2941 | int QTreeViewPrivate::itemAtCoordinate(int coordinate) const | - | ||||||||||||||||||||||||
2942 | { | - | ||||||||||||||||||||||||
2943 | const int itemCount = viewItems.count(); | - | ||||||||||||||||||||||||
2944 | if (itemCount == 0
| 0 | ||||||||||||||||||||||||
2945 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
2946 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
2947 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
2948 | if (verticalScrollMode == QAbstractItemView::ScrollPerPixel
| 0 | ||||||||||||||||||||||||
2949 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
2950 | const int viewItemIndex = (coordinate + vbar->value()) / defaultItemHeight; | - | ||||||||||||||||||||||||
2951 | return never executed: ((viewItemIndex >= itemCountreturn ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex);
never executed: return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex); | 0 | ||||||||||||||||||||||||
2952 | } | - | ||||||||||||||||||||||||
2953 | - | |||||||||||||||||||||||||
2954 | int viewItemCoordinate = 0; | - | ||||||||||||||||||||||||
2955 | const int contentsCoordinate = coordinate + vbar->value(); | - | ||||||||||||||||||||||||
2956 | for (int viewItemIndex = 0; viewItemIndex < viewItems.count()
| 0 | ||||||||||||||||||||||||
2957 | viewItemCoordinate += itemHeight(viewItemIndex); | - | ||||||||||||||||||||||||
2958 | if (viewItemCoordinate >= contentsCoordinate
| 0 | ||||||||||||||||||||||||
2959 | return never executed: (viewItemIndex >= itemCountreturn (viewItemIndex >= itemCount ? -1 : viewItemIndex);
never executed: return (viewItemIndex >= itemCount ? -1 : viewItemIndex); | 0 | ||||||||||||||||||||||||
2960 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2961 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2962 | int topViewItemIndex = vbar->value(); | - | ||||||||||||||||||||||||
2963 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
2964 | if (coordinate < 0
| 0 | ||||||||||||||||||||||||
2965 | coordinate -= defaultItemHeight - 1; never executed: coordinate -= defaultItemHeight - 1; | 0 | ||||||||||||||||||||||||
2966 | const int viewItemIndex = topViewItemIndex + (coordinate / defaultItemHeight); | - | ||||||||||||||||||||||||
2967 | return never executed: ((viewItemIndex >= itemCountreturn ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex);
never executed: return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex); | 0 | ||||||||||||||||||||||||
2968 | } | - | ||||||||||||||||||||||||
2969 | if (coordinate >= 0
| 0 | ||||||||||||||||||||||||
2970 | - | |||||||||||||||||||||||||
2971 | int viewItemCoordinate = 0; | - | ||||||||||||||||||||||||
2972 | for (int viewItemIndex = topViewItemIndex; viewItemIndex < viewItems.count()
| 0 | ||||||||||||||||||||||||
2973 | viewItemCoordinate += itemHeight(viewItemIndex); | - | ||||||||||||||||||||||||
2974 | if (viewItemCoordinate > coordinate
| 0 | ||||||||||||||||||||||||
2975 | return never executed: (viewItemIndex >= itemCountreturn (viewItemIndex >= itemCount ? -1 : viewItemIndex);
never executed: return (viewItemIndex >= itemCount ? -1 : viewItemIndex); | 0 | ||||||||||||||||||||||||
2976 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2977 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
2978 | - | |||||||||||||||||||||||||
2979 | int viewItemCoordinate = 0; | - | ||||||||||||||||||||||||
2980 | for (int viewItemIndex = topViewItemIndex; viewItemIndex >= 0
| 0 | ||||||||||||||||||||||||
2981 | if (viewItemCoordinate <= coordinate
| 0 | ||||||||||||||||||||||||
2982 | return never executed: (viewItemIndex >= itemCountreturn (viewItemIndex >= itemCount ? -1 : viewItemIndex);
never executed: return (viewItemIndex >= itemCount ? -1 : viewItemIndex); | 0 | ||||||||||||||||||||||||
2983 | viewItemCoordinate -= itemHeight(viewItemIndex); | - | ||||||||||||||||||||||||
2984 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2985 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2986 | } | - | ||||||||||||||||||||||||
2987 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
2988 | } | - | ||||||||||||||||||||||||
2989 | - | |||||||||||||||||||||||||
2990 | int QTreeViewPrivate::viewIndex(const QModelIndex &_index) const | - | ||||||||||||||||||||||||
2991 | { | - | ||||||||||||||||||||||||
2992 | if (!_index.isValid()
| 0 | ||||||||||||||||||||||||
2993 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
2994 | - | |||||||||||||||||||||||||
2995 | const int totalCount = viewItems.count(); | - | ||||||||||||||||||||||||
2996 | const QModelIndex index = _index.sibling(_index.row(), 0); | - | ||||||||||||||||||||||||
2997 | const int row = index.row(); | - | ||||||||||||||||||||||||
2998 | const quintptr internalId = index.internalId(); | - | ||||||||||||||||||||||||
2999 | - | |||||||||||||||||||||||||
3000 | - | |||||||||||||||||||||||||
3001 | int localCount = qMin(lastViewedItem - 1, totalCount - lastViewedItem); | - | ||||||||||||||||||||||||
3002 | for (int i = 0; i < localCount
| 0 | ||||||||||||||||||||||||
3003 | const QModelIndex &idx1 = viewItems.at(lastViewedItem + i).index; | - | ||||||||||||||||||||||||
3004 | if (idx1.row() == row
| 0 | ||||||||||||||||||||||||
3005 | lastViewedItem = lastViewedItem + i; | - | ||||||||||||||||||||||||
3006 | return never executed: lastViewedItem;return lastViewedItem; never executed: return lastViewedItem; | 0 | ||||||||||||||||||||||||
3007 | } | - | ||||||||||||||||||||||||
3008 | const QModelIndex &idx2 = viewItems.at(lastViewedItem - i - 1).index; | - | ||||||||||||||||||||||||
3009 | if (idx2.row() == row
| 0 | ||||||||||||||||||||||||
3010 | lastViewedItem = lastViewedItem - i - 1; | - | ||||||||||||||||||||||||
3011 | return never executed: lastViewedItem;return lastViewedItem; never executed: return lastViewedItem; | 0 | ||||||||||||||||||||||||
3012 | } | - | ||||||||||||||||||||||||
3013 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3014 | - | |||||||||||||||||||||||||
3015 | for (int j = qMax(0, lastViewedItem + localCount); j < totalCount
| 0 | ||||||||||||||||||||||||
3016 | const QModelIndex &idx = viewItems.at(j).index; | - | ||||||||||||||||||||||||
3017 | if (idx.row() == row
| 0 | ||||||||||||||||||||||||
3018 | lastViewedItem = j; | - | ||||||||||||||||||||||||
3019 | return never executed: j;return j; never executed: return j; | 0 | ||||||||||||||||||||||||
3020 | } | - | ||||||||||||||||||||||||
3021 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3022 | for (int j = qMin(totalCount, lastViewedItem - localCount) - 1; j >= 0
| 0 | ||||||||||||||||||||||||
3023 | const QModelIndex &idx = viewItems.at(j).index; | - | ||||||||||||||||||||||||
3024 | if (idx.row() == row
| 0 | ||||||||||||||||||||||||
3025 | lastViewedItem = j; | - | ||||||||||||||||||||||||
3026 | return never executed: j;return j; never executed: return j; | 0 | ||||||||||||||||||||||||
3027 | } | - | ||||||||||||||||||||||||
3028 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3029 | - | |||||||||||||||||||||||||
3030 | - | |||||||||||||||||||||||||
3031 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
3032 | } | - | ||||||||||||||||||||||||
3033 | - | |||||||||||||||||||||||||
3034 | QModelIndex QTreeViewPrivate::modelIndex(int i, int column) const | - | ||||||||||||||||||||||||
3035 | { | - | ||||||||||||||||||||||||
3036 | if (i < 0
| 0 | ||||||||||||||||||||||||
3037 | return never executed: QModelIndex();return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||||||||
3038 | - | |||||||||||||||||||||||||
3039 | QModelIndex ret = viewItems.at(i).index; | - | ||||||||||||||||||||||||
3040 | if (column
| 0 | ||||||||||||||||||||||||
3041 | ret = ret.sibling(ret.row(), column); never executed: ret = ret.sibling(ret.row(), column); | 0 | ||||||||||||||||||||||||
3042 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
3043 | } | - | ||||||||||||||||||||||||
3044 | - | |||||||||||||||||||||||||
3045 | int QTreeViewPrivate::firstVisibleItem(int *offset) const | - | ||||||||||||||||||||||||
3046 | { | - | ||||||||||||||||||||||||
3047 | const int value = vbar->value(); | - | ||||||||||||||||||||||||
3048 | if (verticalScrollMode == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
3049 | if (offset
| 0 | ||||||||||||||||||||||||
3050 | * never executed: offset = 0;*offset = 0; never executed: *offset = 0; | 0 | ||||||||||||||||||||||||
3051 | return never executed: (value < 0return (value < 0 || value >= viewItems.count()) ? -1 : value;
never executed: return (value < 0 || value >= viewItems.count()) ? -1 : value; | 0 | ||||||||||||||||||||||||
3052 | } | - | ||||||||||||||||||||||||
3053 | - | |||||||||||||||||||||||||
3054 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
3055 | if (!defaultItemHeight
| 0 | ||||||||||||||||||||||||
3056 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
3057 | - | |||||||||||||||||||||||||
3058 | if (offset
| 0 | ||||||||||||||||||||||||
3059 | * never executed: offset = -(value % defaultItemHeight);*offset = -(value % defaultItemHeight); never executed: *offset = -(value % defaultItemHeight); | 0 | ||||||||||||||||||||||||
3060 | return never executed: value / defaultItemHeight;return value / defaultItemHeight; never executed: return value / defaultItemHeight; | 0 | ||||||||||||||||||||||||
3061 | } | - | ||||||||||||||||||||||||
3062 | int y = 0; | - | ||||||||||||||||||||||||
3063 | for (int i = 0; i < viewItems.count()
| 0 | ||||||||||||||||||||||||
3064 | y += itemHeight(i); | - | ||||||||||||||||||||||||
3065 | if (y > value
| 0 | ||||||||||||||||||||||||
3066 | if (offset
| 0 | ||||||||||||||||||||||||
3067 | * never executed: offset = y - value - itemHeight(i);*offset = y - value - itemHeight(i); never executed: *offset = y - value - itemHeight(i); | 0 | ||||||||||||||||||||||||
3068 | return never executed: i;return i; never executed: return i; | 0 | ||||||||||||||||||||||||
3069 | } | - | ||||||||||||||||||||||||
3070 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3071 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
3072 | } | - | ||||||||||||||||||||||||
3073 | - | |||||||||||||||||||||||||
3074 | int QTreeViewPrivate::lastVisibleItem(int firstVisual, int offset) const | - | ||||||||||||||||||||||||
3075 | { | - | ||||||||||||||||||||||||
3076 | if (firstVisual < 0
| 0 | ||||||||||||||||||||||||
3077 | firstVisual = firstVisibleItem(&offset); | - | ||||||||||||||||||||||||
3078 | if (firstVisual < 0
| 0 | ||||||||||||||||||||||||
3079 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
3080 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3081 | int y = - offset; | - | ||||||||||||||||||||||||
3082 | int value = viewport->height(); | - | ||||||||||||||||||||||||
3083 | - | |||||||||||||||||||||||||
3084 | for (int i = firstVisual; i < viewItems.count()
| 0 | ||||||||||||||||||||||||
3085 | y += itemHeight(i); | - | ||||||||||||||||||||||||
3086 | if (y > value
| 0 | ||||||||||||||||||||||||
3087 | return never executed: i;return i; never executed: return i; | 0 | ||||||||||||||||||||||||
3088 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3089 | return never executed: viewItems.size() - 1;return viewItems.size() - 1; never executed: return viewItems.size() - 1; | 0 | ||||||||||||||||||||||||
3090 | } | - | ||||||||||||||||||||||||
3091 | - | |||||||||||||||||||||||||
3092 | int QTreeViewPrivate::columnAt(int x) const | - | ||||||||||||||||||||||||
3093 | { | - | ||||||||||||||||||||||||
3094 | return never executed: header->logicalIndexAt(x);return header->logicalIndexAt(x); never executed: return header->logicalIndexAt(x); | 0 | ||||||||||||||||||||||||
3095 | } | - | ||||||||||||||||||||||||
3096 | - | |||||||||||||||||||||||||
3097 | void QTreeViewPrivate::updateScrollBars() | - | ||||||||||||||||||||||||
3098 | { | - | ||||||||||||||||||||||||
3099 | QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
3100 | QSize viewportSize = viewport->size(); | - | ||||||||||||||||||||||||
3101 | if (!viewportSize.isValid()
| 0 | ||||||||||||||||||||||||
3102 | viewportSize = QSize(0, 0); never executed: viewportSize = QSize(0, 0); | 0 | ||||||||||||||||||||||||
3103 | - | |||||||||||||||||||||||||
3104 | executePostedLayout(); | - | ||||||||||||||||||||||||
3105 | if (viewItems.isEmpty()
| 0 | ||||||||||||||||||||||||
3106 | q->doItemsLayout(); | - | ||||||||||||||||||||||||
3107 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3108 | - | |||||||||||||||||||||||||
3109 | int itemsInViewport = 0; | - | ||||||||||||||||||||||||
3110 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
3111 | if (defaultItemHeight <= 0
| 0 | ||||||||||||||||||||||||
3112 | itemsInViewport = viewItems.count(); never executed: itemsInViewport = viewItems.count(); | 0 | ||||||||||||||||||||||||
3113 | else | - | ||||||||||||||||||||||||
3114 | itemsInViewport = viewportSize.height() / defaultItemHeight; never executed: itemsInViewport = viewportSize.height() / defaultItemHeight; | 0 | ||||||||||||||||||||||||
3115 | } else { | - | ||||||||||||||||||||||||
3116 | const int itemsCount = viewItems.count(); | - | ||||||||||||||||||||||||
3117 | const int viewportHeight = viewportSize.height(); | - | ||||||||||||||||||||||||
3118 | for (int height = 0, item = itemsCount - 1; item >= 0
| 0 | ||||||||||||||||||||||||
3119 | height += itemHeight(item); | - | ||||||||||||||||||||||||
3120 | if (height > viewportHeight
| 0 | ||||||||||||||||||||||||
3121 | break; never executed: break; | 0 | ||||||||||||||||||||||||
3122 | ++itemsInViewport; | - | ||||||||||||||||||||||||
3123 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3124 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3125 | if (verticalScrollMode == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
3126 | if (!viewItems.isEmpty()
| 0 | ||||||||||||||||||||||||
3127 | itemsInViewport = qMax(1, itemsInViewport); never executed: itemsInViewport = qMax(1, itemsInViewport); | 0 | ||||||||||||||||||||||||
3128 | vbar->setRange(0, viewItems.count() - itemsInViewport); | - | ||||||||||||||||||||||||
3129 | vbar->setPageStep(itemsInViewport); | - | ||||||||||||||||||||||||
3130 | vbar->setSingleStep(1); | - | ||||||||||||||||||||||||
3131 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
3132 | int contentsHeight = 0; | - | ||||||||||||||||||||||||
3133 | if (uniformRowHeights
| 0 | ||||||||||||||||||||||||
3134 | contentsHeight = defaultItemHeight * viewItems.count(); | - | ||||||||||||||||||||||||
3135 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
3136 | for (int i = 0; i < viewItems.count()
| 0 | ||||||||||||||||||||||||
3137 | contentsHeight += itemHeight(i); never executed: contentsHeight += itemHeight(i); | 0 | ||||||||||||||||||||||||
3138 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3139 | vbar->setRange(0, contentsHeight - viewportSize.height()); | - | ||||||||||||||||||||||||
3140 | vbar->setPageStep(viewportSize.height()); | - | ||||||||||||||||||||||||
3141 | vbar->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2)); | - | ||||||||||||||||||||||||
3142 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3143 | - | |||||||||||||||||||||||||
3144 | const int columnCount = header->count(); | - | ||||||||||||||||||||||||
3145 | const int viewportWidth = viewportSize.width(); | - | ||||||||||||||||||||||||
3146 | int columnsInViewport = 0; | - | ||||||||||||||||||||||||
3147 | for (int width = 0, column = columnCount - 1; column >= 0
| 0 | ||||||||||||||||||||||||
3148 | int logical = header->logicalIndex(column); | - | ||||||||||||||||||||||||
3149 | width += header->sectionSize(logical); | - | ||||||||||||||||||||||||
3150 | if (width > viewportWidth
| 0 | ||||||||||||||||||||||||
3151 | break; never executed: break; | 0 | ||||||||||||||||||||||||
3152 | ++columnsInViewport; | - | ||||||||||||||||||||||||
3153 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3154 | if (columnCount > 0
| 0 | ||||||||||||||||||||||||
3155 | columnsInViewport = qMax(1, columnsInViewport); never executed: columnsInViewport = qMax(1, columnsInViewport); | 0 | ||||||||||||||||||||||||
3156 | if (horizontalScrollMode == QAbstractItemView::ScrollPerItem
| 0 | ||||||||||||||||||||||||
3157 | hbar->setRange(0, columnCount - columnsInViewport); | - | ||||||||||||||||||||||||
3158 | hbar->setPageStep(columnsInViewport); | - | ||||||||||||||||||||||||
3159 | hbar->setSingleStep(1); | - | ||||||||||||||||||||||||
3160 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
3161 | const int horizontalLength = header->length(); | - | ||||||||||||||||||||||||
3162 | const QSize maxSize = q->maximumViewportSize(); | - | ||||||||||||||||||||||||
3163 | if (maxSize.width() >= horizontalLength
| 0 | ||||||||||||||||||||||||
3164 | viewportSize = maxSize; never executed: viewportSize = maxSize; | 0 | ||||||||||||||||||||||||
3165 | hbar->setPageStep(viewportSize.width()); | - | ||||||||||||||||||||||||
3166 | hbar->setRange(0, qMax(horizontalLength - viewportSize.width(), 0)); | - | ||||||||||||||||||||||||
3167 | hbar->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2)); | - | ||||||||||||||||||||||||
3168 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3169 | } | - | ||||||||||||||||||||||||
3170 | - | |||||||||||||||||||||||||
3171 | int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const | - | ||||||||||||||||||||||||
3172 | { | - | ||||||||||||||||||||||||
3173 | executePostedLayout(); | - | ||||||||||||||||||||||||
3174 | int x = pos.x(); | - | ||||||||||||||||||||||||
3175 | int column = header->logicalIndexAt(x); | - | ||||||||||||||||||||||||
3176 | if (!isTreePosition(column)
| 0 | ||||||||||||||||||||||||
3177 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
3178 | - | |||||||||||||||||||||||||
3179 | int viewItemIndex = itemAtCoordinate(pos.y()); | - | ||||||||||||||||||||||||
3180 | QRect returning = itemDecorationRect(modelIndex(viewItemIndex)); | - | ||||||||||||||||||||||||
3181 | if (!returning.contains(pos)
| 0 | ||||||||||||||||||||||||
3182 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
3183 | - | |||||||||||||||||||||||||
3184 | return never executed: viewItemIndex;return viewItemIndex; never executed: return viewItemIndex; | 0 | ||||||||||||||||||||||||
3185 | } | - | ||||||||||||||||||||||||
3186 | - | |||||||||||||||||||||||||
3187 | QRect QTreeViewPrivate::itemDecorationRect(const QModelIndex &index) const | - | ||||||||||||||||||||||||
3188 | { | - | ||||||||||||||||||||||||
3189 | const QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
3190 | if (!rootDecoration
| 0 | ||||||||||||||||||||||||
3191 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
3192 | - | |||||||||||||||||||||||||
3193 | int viewItemIndex = viewIndex(index); | - | ||||||||||||||||||||||||
3194 | if (viewItemIndex < 0
| 0 | ||||||||||||||||||||||||
3195 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
3196 | - | |||||||||||||||||||||||||
3197 | int itemIndentation = indentationForItem(viewItemIndex); | - | ||||||||||||||||||||||||
3198 | int position = header->sectionViewportPosition(logicalIndexForTree()); | - | ||||||||||||||||||||||||
3199 | int size = header->sectionSize(logicalIndexForTree()); | - | ||||||||||||||||||||||||
3200 | - | |||||||||||||||||||||||||
3201 | QRect rect; | - | ||||||||||||||||||||||||
3202 | if (q->isRightToLeft()
| 0 | ||||||||||||||||||||||||
3203 | rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex), never executed: rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex)); | 0 | ||||||||||||||||||||||||
3204 | indent, itemHeight(viewItemIndex)); never executed: rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex)); | 0 | ||||||||||||||||||||||||
3205 | else | - | ||||||||||||||||||||||||
3206 | rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex), never executed: rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex)); | 0 | ||||||||||||||||||||||||
3207 | indent, itemHeight(viewItemIndex)); never executed: rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex)); | 0 | ||||||||||||||||||||||||
3208 | QStyleOption opt; | - | ||||||||||||||||||||||||
3209 | opt.initFrom(q); | - | ||||||||||||||||||||||||
3210 | opt.rect = rect; | - | ||||||||||||||||||||||||
3211 | return never executed: q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q);return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q); never executed: return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q); | 0 | ||||||||||||||||||||||||
3212 | } | - | ||||||||||||||||||||||||
3213 | - | |||||||||||||||||||||||||
3214 | QList<QPair<int, int> > QTreeViewPrivate::columnRanges(const QModelIndex &topIndex, | - | ||||||||||||||||||||||||
3215 | const QModelIndex &bottomIndex) const | - | ||||||||||||||||||||||||
3216 | { | - | ||||||||||||||||||||||||
3217 | const int topVisual = header->visualIndex(topIndex.column()), | - | ||||||||||||||||||||||||
3218 | bottomVisual = header->visualIndex(bottomIndex.column()); | - | ||||||||||||||||||||||||
3219 | - | |||||||||||||||||||||||||
3220 | const int start = qMin(topVisual, bottomVisual); | - | ||||||||||||||||||||||||
3221 | const int end = qMax(topVisual, bottomVisual); | - | ||||||||||||||||||||||||
3222 | - | |||||||||||||||||||||||||
3223 | QList<int> logicalIndexes; | - | ||||||||||||||||||||||||
3224 | - | |||||||||||||||||||||||||
3225 | - | |||||||||||||||||||||||||
3226 | for (int c = start; c <= end
| 0 | ||||||||||||||||||||||||
3227 | const int logical = header->logicalIndex(c); | - | ||||||||||||||||||||||||
3228 | if (!header->isSectionHidden(logical)
| 0 | ||||||||||||||||||||||||
3229 | logicalIndexes << logical; | - | ||||||||||||||||||||||||
3230 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3231 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3232 | - | |||||||||||||||||||||||||
3233 | std::sort(logicalIndexes.begin(), logicalIndexes.end()); | - | ||||||||||||||||||||||||
3234 | - | |||||||||||||||||||||||||
3235 | QList<QPair<int, int> > ret; | - | ||||||||||||||||||||||||
3236 | QPair<int, int> current; | - | ||||||||||||||||||||||||
3237 | current.first = -2; | - | ||||||||||||||||||||||||
3238 | current.second = -2; | - | ||||||||||||||||||||||||
3239 | for(int i = 0; i < logicalIndexes.count()
| 0 | ||||||||||||||||||||||||
3240 | const int logicalColumn = logicalIndexes.at(i); | - | ||||||||||||||||||||||||
3241 | if (current.second + 1 != logicalColumn
| 0 | ||||||||||||||||||||||||
3242 | if (current.first != -2
| 0 | ||||||||||||||||||||||||
3243 | - | |||||||||||||||||||||||||
3244 | ret += current; | - | ||||||||||||||||||||||||
3245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3246 | - | |||||||||||||||||||||||||
3247 | current.first = current.second = logicalColumn; | - | ||||||||||||||||||||||||
3248 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
3249 | current.second++; | - | ||||||||||||||||||||||||
3250 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3251 | } | - | ||||||||||||||||||||||||
3252 | - | |||||||||||||||||||||||||
3253 | - | |||||||||||||||||||||||||
3254 | if (current.first != -2
| 0 | ||||||||||||||||||||||||
3255 | ret += current; | - | ||||||||||||||||||||||||
3256 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3257 | - | |||||||||||||||||||||||||
3258 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
3259 | } | - | ||||||||||||||||||||||||
3260 | - | |||||||||||||||||||||||||
3261 | void QTreeViewPrivate::select(const QModelIndex &topIndex, const QModelIndex &bottomIndex, | - | ||||||||||||||||||||||||
3262 | QItemSelectionModel::SelectionFlags command) | - | ||||||||||||||||||||||||
3263 | { | - | ||||||||||||||||||||||||
3264 | QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
3265 | QItemSelection selection; | - | ||||||||||||||||||||||||
3266 | const int top = viewIndex(topIndex), | - | ||||||||||||||||||||||||
3267 | bottom = viewIndex(bottomIndex); | - | ||||||||||||||||||||||||
3268 | - | |||||||||||||||||||||||||
3269 | const QList< QPair<int, int> > colRanges = columnRanges(topIndex, bottomIndex); | - | ||||||||||||||||||||||||
3270 | QList< QPair<int, int> >::const_iterator it; | - | ||||||||||||||||||||||||
3271 | for (it = colRanges.begin(); it != colRanges.end()
| 0 | ||||||||||||||||||||||||
3272 | const int left = (*it).first, | - | ||||||||||||||||||||||||
3273 | right = (*it).second; | - | ||||||||||||||||||||||||
3274 | - | |||||||||||||||||||||||||
3275 | QModelIndex previous; | - | ||||||||||||||||||||||||
3276 | QItemSelectionRange currentRange; | - | ||||||||||||||||||||||||
3277 | QStack<QItemSelectionRange> rangeStack; | - | ||||||||||||||||||||||||
3278 | for (int i = top; i <= bottom
| 0 | ||||||||||||||||||||||||
3279 | QModelIndex index = modelIndex(i); | - | ||||||||||||||||||||||||
3280 | QModelIndex parent = index.parent(); | - | ||||||||||||||||||||||||
3281 | QModelIndex previousParent = previous.parent(); | - | ||||||||||||||||||||||||
3282 | if (previous.isValid()
| 0 | ||||||||||||||||||||||||
3283 | - | |||||||||||||||||||||||||
3284 | if (qAbs(previous.row() - index.row()) > 1
| 0 | ||||||||||||||||||||||||
3285 | - | |||||||||||||||||||||||||
3286 | if (currentRange.isValid()
| 0 | ||||||||||||||||||||||||
3287 | selection.append(currentRange); | - | ||||||||||||||||||||||||
3288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3289 | - | |||||||||||||||||||||||||
3290 | currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right)); | - | ||||||||||||||||||||||||
3291 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
3292 | QModelIndex tl = model->index(currentRange.top(), currentRange.left(), | - | ||||||||||||||||||||||||
3293 | currentRange.parent()); | - | ||||||||||||||||||||||||
3294 | currentRange = QItemSelectionRange(tl, index.sibling(index.row(), right)); | - | ||||||||||||||||||||||||
3295 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3296 | } else if (previous.isValid()
| 0 | ||||||||||||||||||||||||
3297 | - | |||||||||||||||||||||||||
3298 | rangeStack.push(currentRange); | - | ||||||||||||||||||||||||
3299 | currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right)); | - | ||||||||||||||||||||||||
3300 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
3301 | if (currentRange.isValid()
| 0 | ||||||||||||||||||||||||
3302 | selection.append(currentRange); never executed: selection.append(currentRange); | 0 | ||||||||||||||||||||||||
3303 | if (rangeStack.isEmpty()
| 0 | ||||||||||||||||||||||||
3304 | currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right)); | - | ||||||||||||||||||||||||
3305 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
3306 | currentRange = rangeStack.pop(); | - | ||||||||||||||||||||||||
3307 | index = currentRange.bottomRight(); | - | ||||||||||||||||||||||||
3308 | --i; | - | ||||||||||||||||||||||||
3309 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3310 | } | - | ||||||||||||||||||||||||
3311 | previous = index; | - | ||||||||||||||||||||||||
3312 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3313 | if (currentRange.isValid()
| 0 | ||||||||||||||||||||||||
3314 | selection.append(currentRange); never executed: selection.append(currentRange); | 0 | ||||||||||||||||||||||||
3315 | for (int i = 0; i < rangeStack.count()
| 0 | ||||||||||||||||||||||||
3316 | selection.append(rangeStack.at(i)); never executed: selection.append(rangeStack.at(i)); | 0 | ||||||||||||||||||||||||
3317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3318 | q->selectionModel()->select(selection, command); | - | ||||||||||||||||||||||||
3319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3320 | - | |||||||||||||||||||||||||
3321 | QPair<int,int> QTreeViewPrivate::startAndEndColumns(const QRect &rect) const | - | ||||||||||||||||||||||||
3322 | { | - | ||||||||||||||||||||||||
3323 | const QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
3324 | int start = header->visualIndexAt(rect.left()); | - | ||||||||||||||||||||||||
3325 | int end = header->visualIndexAt(rect.right()); | - | ||||||||||||||||||||||||
3326 | if (q->isRightToLeft()
| 0 | ||||||||||||||||||||||||
3327 | start = (start == -1
| 0 | ||||||||||||||||||||||||
3328 | end = (end == -1
| 0 | ||||||||||||||||||||||||
3329 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
3330 | start = (start == -1
| 0 | ||||||||||||||||||||||||
3331 | end = (end == -1
| 0 | ||||||||||||||||||||||||
3332 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3333 | return never executed: qMakePair<int,int>(qMin(start, end), qMax(start, end));return qMakePair<int,int>(qMin(start, end), qMax(start, end)); never executed: return qMakePair<int,int>(qMin(start, end), qMax(start, end)); | 0 | ||||||||||||||||||||||||
3334 | } | - | ||||||||||||||||||||||||
3335 | - | |||||||||||||||||||||||||
3336 | bool QTreeViewPrivate::hasVisibleChildren(const QModelIndex& parent) const | - | ||||||||||||||||||||||||
3337 | { | - | ||||||||||||||||||||||||
3338 | const QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
3339 | if (parent.flags() & Qt::ItemNeverHasChildren
| 0 | ||||||||||||||||||||||||
3340 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3341 | if (model->hasChildren(parent)
| 0 | ||||||||||||||||||||||||
3342 | if (hiddenIndexes.isEmpty()
| 0 | ||||||||||||||||||||||||
3343 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
3344 | if (q->isIndexHidden(parent)
| 0 | ||||||||||||||||||||||||
3345 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3346 | int rowCount = model->rowCount(parent); | - | ||||||||||||||||||||||||
3347 | for (int i = 0; i < rowCount
| 0 | ||||||||||||||||||||||||
3348 | if (!q->isRowHidden(i, parent)
| 0 | ||||||||||||||||||||||||
3349 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
3350 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3351 | if (rowCount == 0
| 0 | ||||||||||||||||||||||||
3352 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
3353 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3354 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
3355 | } | - | ||||||||||||||||||||||||
3356 | - | |||||||||||||||||||||||||
3357 | void QTreeViewPrivate::_q_sortIndicatorChanged(int column, Qt::SortOrder order) | - | ||||||||||||||||||||||||
3358 | { | - | ||||||||||||||||||||||||
3359 | model->sort(column, order); | - | ||||||||||||||||||||||||
3360 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3361 | - | |||||||||||||||||||||||||
3362 | int QTreeViewPrivate::accessibleTree2Index(const QModelIndex &index) const | - | ||||||||||||||||||||||||
3363 | { | - | ||||||||||||||||||||||||
3364 | const QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
3365 | - | |||||||||||||||||||||||||
3366 | - | |||||||||||||||||||||||||
3367 | return never executed: (q->visualIndex(index) + (q->header()return (q->visualIndex(index) + (q->header() ? 1 : 0)) * index.model()->columnCount() + index.column();
never executed: return (q->visualIndex(index) + (q->header() ? 1 : 0)) * index.model()->columnCount() + index.column(); | 0 | ||||||||||||||||||||||||
3368 | } | - | ||||||||||||||||||||||||
3369 | - | |||||||||||||||||||||||||
3370 | void QTreeViewPrivate::updateIndentationFromStyle() | - | ||||||||||||||||||||||||
3371 | { | - | ||||||||||||||||||||||||
3372 | const QTreeView * const q = q_func(); | - | ||||||||||||||||||||||||
3373 | indent = q->style()->pixelMetric(QStyle::PM_TreeViewIndentation, 0, q); | - | ||||||||||||||||||||||||
3374 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3375 | - | |||||||||||||||||||||||||
3376 | - | |||||||||||||||||||||||||
3377 | - | |||||||||||||||||||||||||
3378 | - | |||||||||||||||||||||||||
3379 | void QTreeView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | - | ||||||||||||||||||||||||
3380 | { | - | ||||||||||||||||||||||||
3381 | QAbstractItemView::currentChanged(current, previous); | - | ||||||||||||||||||||||||
3382 | - | |||||||||||||||||||||||||
3383 | if (allColumnsShowFocus()
| 0 | ||||||||||||||||||||||||
3384 | if (previous.isValid()
| 0 | ||||||||||||||||||||||||
3385 | QRect previousRect = visualRect(previous); | - | ||||||||||||||||||||||||
3386 | previousRect.setX(0); | - | ||||||||||||||||||||||||
3387 | previousRect.setWidth(viewport()->width()); | - | ||||||||||||||||||||||||
3388 | viewport()->update(previousRect); | - | ||||||||||||||||||||||||
3389 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3390 | if (current.isValid()
| 0 | ||||||||||||||||||||||||
3391 | QRect currentRect = visualRect(current); | - | ||||||||||||||||||||||||
3392 | currentRect.setX(0); | - | ||||||||||||||||||||||||
3393 | currentRect.setWidth(viewport()->width()); | - | ||||||||||||||||||||||||
3394 | viewport()->update(currentRect); | - | ||||||||||||||||||||||||
3395 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3396 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3397 | - | |||||||||||||||||||||||||
3398 | if (QAccessible::isActive()
| 0 | ||||||||||||||||||||||||
3399 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
3400 | - | |||||||||||||||||||||||||
3401 | QAccessibleEvent event(this, QAccessible::Focus); | - | ||||||||||||||||||||||||
3402 | event.setChild(d->accessibleTree2Index(current)); | - | ||||||||||||||||||||||||
3403 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||
3404 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3405 | - | |||||||||||||||||||||||||
3406 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3407 | - | |||||||||||||||||||||||||
3408 | - | |||||||||||||||||||||||||
3409 | - | |||||||||||||||||||||||||
3410 | - | |||||||||||||||||||||||||
3411 | void QTreeView::selectionChanged(const QItemSelection &selected, | - | ||||||||||||||||||||||||
3412 | const QItemSelection &deselected) | - | ||||||||||||||||||||||||
3413 | { | - | ||||||||||||||||||||||||
3414 | QAbstractItemView::selectionChanged(selected, deselected); | - | ||||||||||||||||||||||||
3415 | - | |||||||||||||||||||||||||
3416 | if (QAccessible::isActive()
| 0 | ||||||||||||||||||||||||
3417 | QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
3418 | - | |||||||||||||||||||||||||
3419 | - | |||||||||||||||||||||||||
3420 | QModelIndex sel = selected.indexes().value(0); | - | ||||||||||||||||||||||||
3421 | if (sel.isValid()
| 0 | ||||||||||||||||||||||||
3422 | int entry = d->accessibleTree2Index(sel); | - | ||||||||||||||||||||||||
3423 | ((!(entry >= 0)) ? qt_assert("entry >= 0",__FILE__,3992) : qt_noop()); | - | ||||||||||||||||||||||||
3424 | QAccessibleEvent event(this, QAccessible::SelectionAdd); | - | ||||||||||||||||||||||||
3425 | event.setChild(entry); | - | ||||||||||||||||||||||||
3426 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||
3427 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3428 | QModelIndex desel = deselected.indexes().value(0); | - | ||||||||||||||||||||||||
3429 | if (desel.isValid()
| 0 | ||||||||||||||||||||||||
3430 | int entry = d->accessibleTree2Index(desel); | - | ||||||||||||||||||||||||
3431 | ((!(entry >= 0)) ? qt_assert("entry >= 0",__FILE__,4000) : qt_noop()); | - | ||||||||||||||||||||||||
3432 | QAccessibleEvent event(this, QAccessible::SelectionRemove); | - | ||||||||||||||||||||||||
3433 | event.setChild(entry); | - | ||||||||||||||||||||||||
3434 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||
3435 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3436 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3437 | - | |||||||||||||||||||||||||
3438 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3439 | - | |||||||||||||||||||||||||
3440 | int QTreeView::visualIndex(const QModelIndex &index) const | - | ||||||||||||||||||||||||
3441 | { | - | ||||||||||||||||||||||||
3442 | const QTreeViewPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
3443 | d->executePostedLayout(); | - | ||||||||||||||||||||||||
3444 | return never executed: d->viewIndex(index);return d->viewIndex(index); never executed: return d->viewIndex(index); | 0 | ||||||||||||||||||||||||
3445 | } | - | ||||||||||||||||||||||||
3446 | - | |||||||||||||||||||||||||
3447 | - | |||||||||||||||||||||||||
3448 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |