Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | void QSpanCollection::addSpan(QSpanCollection::Span *span) | - |
12 | { | - |
13 | spans.append(span); | - |
14 | Index::iterator it_y = index.lowerBound(-span->top()); | - |
15 | if (it_y == index.end() || it_y.key() != -span->top()) { | - |
16 | | - |
17 | SubIndex sub_index; | - |
18 | if (it_y != index.end()) { | - |
19 | | - |
20 | | - |
21 | const SubIndex previousList = it_y.value(); | - |
22 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(previousList)>::type> _container_((previousList)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (Span *s = *_container_.i; _container_.control; _container_.control = 0) { | - |
23 | | - |
24 | if(s->bottom() >= span->top()) | - |
25 | sub_index.insert(-s->left(), s); | - |
26 | } | - |
27 | } | - |
28 | it_y = index.insert(-span->top(), sub_index); | - |
29 | | - |
30 | } | - |
31 | | - |
32 | | - |
33 | while(-it_y.key() <= span->bottom()) { | - |
34 | (*it_y).insert(-span->left(), span); | - |
35 | if(it_y == index.begin()) | - |
36 | break; | - |
37 | --it_y; | - |
38 | } | - |
39 | } | - |
40 | void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height) | - |
41 | { | - |
42 | if (old_height < span->height()) { | - |
43 | | - |
44 | Index::iterator it_y = index.lowerBound(-(span->top() + old_height - 1)); | - |
45 | ((!(it_y != index.end())) ? qt_assert("it_y != index.end()",__FILE__,101108) : qt_noop()); | - |
46 | while (-it_y.key() <= span->bottom()) { | - |
47 | (*it_y).insert(-span->left(), span); | - |
48 | if(it_y == index.begin()) | - |
49 | break; | - |
50 | --it_y; | - |
51 | } | - |
52 | } else if (old_height > span->height()) { | - |
53 | | - |
54 | Index::iterator it_y = index.lowerBound(-qMax(span->bottom(), span->top())); | - |
55 | ((!(it_y != index.end())) ? qt_assert("it_y != index.end()",__FILE__,111118) : qt_noop()); | - |
56 | while (-it_y.key() <= span->top() + old_height -1) { | - |
57 | if (-it_y.key() > span->bottom()) { | - |
58 | int removed = (*it_y).remove(-span->left()); | - |
59 | ((!(removed == 1)) ? qt_assert("removed == 1",__FILE__,115122) : qt_noop()); (void)removed;; | - |
60 | if (it_y->isEmpty()) { | - |
61 | it_y = index.erase(it_y); | - |
62 | } | - |
63 | } | - |
64 | if(it_y == index.begin()) | - |
65 | break; | - |
66 | --it_y; | - |
67 | } | - |
68 | } | - |
69 | | - |
70 | if (span->width() == 0 && span->height() == 0) { | - |
71 | spans.removeOne(span); | - |
72 | delete span; | - |
73 | } | - |
74 | } | - |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | QSpanCollection::Span *QSpanCollection::spanAt(int x, int y) const | - |
80 | { | - |
81 | Index::const_iterator it_y = index.lowerBound(-y); | - |
82 | if (it_y == index.end()) | - |
83 | return 0; | - |
84 | SubIndex::const_iterator it_x = (*it_y).lowerBound(-x); | - |
85 | if (it_x == (*it_y).end()) | - |
86 | return 0; | - |
87 | Span *span = *it_x; | - |
88 | if (span->right() >= x && span->bottom() >= y) | - |
89 | return span; | - |
90 | return 0; | - |
91 | } | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | void QSpanCollection::clear() | - |
98 | { | - |
99 | qDeleteAll(spans); | - |
100 | index.clear(); | - |
101 | spans.clear(); | - |
102 | } | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | QList<QSpanCollection::Span *> QSpanCollection::spansInRect(int x, int y, int w, int h) const | - |
108 | { | - |
109 | QSet<Span *> list; | - |
110 | Index::const_iterator it_y = index.lowerBound(-y); | - |
111 | if(it_y == index.end()) | - |
112 | --it_y; | - |
113 | while(-it_y.key() <= y + h) { | - |
114 | SubIndex::const_iterator it_x = (*it_y).lowerBound(-x); | - |
115 | if (it_x == (*it_y).end()) | - |
116 | --it_x; | - |
117 | while(-it_x.key() <= x + w) { | - |
118 | Span *s = *it_x; | - |
119 | if (s->bottom() >= y && s->right() >= x) | - |
120 | list << s; | - |
121 | if (it_x == (*it_y).begin()) | - |
122 | break; | - |
123 | --it_x; | - |
124 | } | - |
125 | if(it_y == index.begin()) | - |
126 | break; | - |
127 | --it_y; | - |
128 | } | - |
129 | return list.toList(); | - |
130 | } | - |
131 | void QSpanCollection::updateInsertedRows(int start, int end) | - |
132 | { | - |
133 | | - |
134 | | - |
135 | | - |
136 | if (spans.isEmpty()) | - |
137 | return; | - |
138 | | - |
139 | int delta = end - start + 1; | - |
140 | | - |
141 | | - |
142 | | - |
143 | for (SpanList::iterator it = spans.begin(); it != spans.end(); ++it) { | - |
144 | Span *span = *it; | - |
145 | | - |
146 | | - |
147 | | - |
148 | if (span->m_bottom < start) | - |
149 | continue; | - |
150 | if (span->m_top >= start) | - |
151 | span->m_top += delta; | - |
152 | span->m_bottom += delta; | - |
153 | } | - |
154 | | - |
155 | | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | for (Index::iterator it_y = index.begin(); it_y != index.end(); ) { | - |
162 | int y = -it_y.key(); | - |
163 | if (y < start) { | - |
164 | ++it_y; | - |
165 | continue; | - |
166 | } | - |
167 | | - |
168 | index.insert(-y - delta, it_y.value()); | - |
169 | it_y = index.erase(it_y); | - |
170 | } | - |
171 | | - |
172 | | - |
173 | | - |
174 | } | - |
175 | | - |
176 | | - |
177 | | - |
178 | | - |
179 | void QSpanCollection::updateInsertedColumns(int start, int end) | - |
180 | { | - |
181 | | - |
182 | | - |
183 | | - |
184 | if (spans.isEmpty()) | - |
185 | return; | - |
186 | | - |
187 | int delta = end - start + 1; | - |
188 | | - |
189 | | - |
190 | | - |
191 | for (SpanList::iterator it = spans.begin(); it != spans.end(); ++it) { | - |
192 | Span *span = *it; | - |
193 | | - |
194 | | - |
195 | | - |
196 | if (span->m_right < start) | - |
197 | continue; | - |
198 | if (span->m_left >= start) | - |
199 | span->m_left += delta; | - |
200 | span->m_right += delta; | - |
201 | } | - |
202 | | - |
203 | | - |
204 | | - |
205 | | - |
206 | | - |
207 | | - |
208 | | - |
209 | for (Index::iterator it_y = index.begin(); it_y != index.end(); ++it_y) { | - |
210 | SubIndex &subindex = it_y.value(); | - |
211 | for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ) { | - |
212 | int x = -it.key(); | - |
213 | if (x < start) { | - |
214 | ++it; | - |
215 | continue; | - |
216 | } | - |
217 | subindex.insert(-x - delta, it.value()); | - |
218 | it = subindex.erase(it); | - |
219 | } | - |
220 | } | - |
221 | | - |
222 | | - |
223 | | - |
224 | } | - |
225 | | - |
226 | | - |
227 | | - |
228 | | - |
229 | | - |
230 | | - |
231 | bool QSpanCollection::cleanSpanSubIndex(QSpanCollection::SubIndex &subindex, int y, bool update) | - |
232 | { | - |
233 | if (subindex.isEmpty()) | - |
234 | return true; | - |
235 | | - |
236 | bool should_be_deleted = true; | - |
237 | SubIndex::iterator it = subindex.end(); | - |
238 | do { | - |
239 | --it; | - |
240 | int x = -it.key(); | - |
241 | Span *span = it.value(); | - |
242 | if (span->will_be_deleted) { | - |
243 | it = subindex.erase(it); | - |
244 | continue; | - |
245 | } | - |
246 | if (update && span->m_left != x) { | - |
247 | subindex.insert(-span->m_left, span); | - |
248 | it = subindex.erase(it); | - |
249 | } | - |
250 | if (should_be_deleted && span->m_top == y) | - |
251 | should_be_deleted = false; | - |
252 | } while (it != subindex.begin()); | - |
253 | | - |
254 | return should_be_deleted; | - |
255 | } | - |
256 | | - |
257 | | - |
258 | | - |
259 | | - |
260 | void QSpanCollection::updateRemovedRows(int start, int end) | - |
261 | { | - |
262 | | - |
263 | | - |
264 | | - |
265 | if (spans.isEmpty()) | - |
266 | return; | - |
267 | | - |
268 | SpanList spansToBeDeleted; | - |
269 | int delta = end - start + 1; | - |
270 | | - |
271 | | - |
272 | | - |
273 | for (SpanList::iterator it = spans.begin(); it != spans.end(); ) { | - |
274 | Span *span = *it; | - |
275 | | - |
276 | | - |
277 | | - |
278 | if (span->m_bottom < start) { | - |
279 | ++it; | - |
280 | continue; | - |
281 | } | - |
282 | if (span->m_top < start) { | - |
283 | if (span->m_bottom <= end) | - |
284 | span->m_bottom = start - 1; | - |
285 | else | - |
286 | span->m_bottom -= delta; | - |
287 | } else { | - |
288 | if (span->m_bottom > end) { | - |
289 | if (span->m_top <= end) | - |
290 | span->m_top = start; | - |
291 | else | - |
292 | span->m_top -= delta; | - |
293 | span->m_bottom -= delta; | - |
294 | } else { | - |
295 | span->will_be_deleted = true; | - |
296 | } | - |
297 | } | - |
298 | if (span->m_top == span->m_bottom && span->m_left == span->m_right) | - |
299 | span->will_be_deleted = true; | - |
300 | if (span->will_be_deleted) { | - |
301 | spansToBeDeleted.append(span); | - |
302 | it = spans.erase(it); | - |
303 | } else { | - |
304 | ++it; | - |
305 | } | - |
306 | } | - |
307 | | - |
308 | | - |
309 | | - |
310 | | - |
311 | | - |
312 | | - |
313 | if (spans.isEmpty()) { | - |
314 | qDeleteAll(spansToBeDeleted); | - |
315 | index.clear(); | - |
316 | return; | - |
317 | } | - |
318 | | - |
319 | Index::iterator it_y = index.end(); | - |
320 | do { | - |
321 | --it_y; | - |
322 | int y = -it_y.key(); | - |
323 | SubIndex &subindex = it_y.value(); | - |
324 | if (y < start) { | - |
325 | if (cleanSpanSubIndex(subindex, y)) | - |
326 | it_y = index.erase(it_y); | - |
327 | } else if (y >= start && y <= end) { | - |
328 | bool span_at_start = false; | - |
329 | SubIndex spansToBeMoved; | - |
330 | for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ++it) { | - |
331 | Span *span = it.value(); | - |
332 | if (span->will_be_deleted) | - |
333 | continue; | - |
334 | if (!span_at_start && span->m_top == start) | - |
335 | span_at_start = true; | - |
336 | spansToBeMoved.insert(it.key(), span); | - |
337 | } | - |
338 | | - |
339 | if (y == start && span_at_start) | - |
340 | subindex.clear(); | - |
341 | else | - |
342 | it_y = index.erase(it_y); | - |
343 | | - |
344 | if (span_at_start) { | - |
345 | Index::iterator it_start; | - |
346 | if (y == start) | - |
347 | it_start = it_y; | - |
348 | else { | - |
349 | it_start = index.find(-start); | - |
350 | if (it_start == index.end()) | - |
351 | it_start = index.insert(-start, SubIndex()); | - |
352 | } | - |
353 | SubIndex &start_subindex = it_start.value(); | - |
354 | for (SubIndex::iterator it = spansToBeMoved.begin(); it != spansToBeMoved.end(); ++it) | - |
355 | start_subindex.insert(it.key(), it.value()); | - |
356 | } | - |
357 | } else { | - |
358 | if (y == end + 1) { | - |
359 | Index::iterator it_top = index.find(-y + delta); | - |
360 | if (it_top == index.end()) | - |
361 | it_top = index.insert(-y + delta, SubIndex()); | - |
362 | for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ) { | - |
363 | Span *span = it.value(); | - |
364 | if (!span->will_be_deleted) | - |
365 | it_top.value().insert(it.key(), span); | - |
366 | ++it; | - |
367 | } | - |
368 | } else { | - |
369 | index.insert(-y + delta, subindex); | - |
370 | } | - |
371 | it_y = index.erase(it_y); | - |
372 | } | - |
373 | } while (it_y != index.begin()); | - |
374 | | - |
375 | | - |
376 | | - |
377 | | - |
378 | | - |
379 | | - |
380 | | - |
381 | qDeleteAll(spansToBeDeleted); | - |
382 | } | - |
383 | | - |
384 | | - |
385 | | - |
386 | | - |
387 | void QSpanCollection::updateRemovedColumns(int start, int end) | - |
388 | { | - |
389 | | - |
390 | | - |
391 | | - |
392 | if (spans.isEmpty()) | - |
393 | return; | - |
394 | | - |
395 | SpanList toBeDeleted; | - |
396 | int delta = end - start + 1; | - |
397 | | - |
398 | | - |
399 | | - |
400 | for (SpanList::iterator it = spans.begin(); it != spans.end(); ) { | - |
401 | Span *span = *it; | - |
402 | | - |
403 | | - |
404 | | - |
405 | if (span->m_right < start) { | - |
406 | ++it; | - |
407 | continue; | - |
408 | } | - |
409 | if (span->m_left < start) { | - |
410 | if (span->m_right <= end) | - |
411 | span->m_right = start - 1; | - |
412 | else | - |
413 | span->m_right -= delta; | - |
414 | } else { | - |
415 | if (span->m_right > end) { | - |
416 | if (span->m_left <= end) | - |
417 | span->m_left = start; | - |
418 | else | - |
419 | span->m_left -= delta; | - |
420 | span->m_right -= delta; | - |
421 | } else { | - |
422 | span->will_be_deleted = true; | - |
423 | } | - |
424 | } | - |
425 | if (span->m_top == span->m_bottom && span->m_left == span->m_right) | - |
426 | span->will_be_deleted = true; | - |
427 | if (span->will_be_deleted) { | - |
428 | toBeDeleted.append(span); | - |
429 | it = spans.erase(it); | - |
430 | } else { | - |
431 | ++it; | - |
432 | } | - |
433 | } | - |
434 | | - |
435 | | - |
436 | | - |
437 | | - |
438 | | - |
439 | | - |
440 | if (spans.isEmpty()) { | - |
441 | qDeleteAll(toBeDeleted); | - |
442 | index.clear(); | - |
443 | return; | - |
444 | } | - |
445 | | - |
446 | for (Index::iterator it_y = index.begin(); it_y != index.end(); ) { | - |
447 | int y = -it_y.key(); | - |
448 | if (cleanSpanSubIndex(it_y.value(), y, true)) | - |
449 | it_y = index.erase(it_y); | - |
450 | else | - |
451 | ++it_y; | - |
452 | } | - |
453 | | - |
454 | | - |
455 | | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | qDeleteAll(toBeDeleted); | - |
461 | } | - |
462 | | - |
463 | | - |
464 | | - |
465 | | - |
466 | | - |
467 | | - |
468 | bool QSpanCollection::checkConsistency() const | - |
469 | { | - |
470 | for (Index::const_iterator it_y = index.begin(); it_y != index.end(); ++it_y) { | - |
471 | int y = -it_y.key(); | - |
472 | const SubIndex &subIndex = it_y.value(); | - |
473 | for (SubIndex::const_iterator it = subIndex.begin(); it != subIndex.end(); ++it) { | - |
474 | int x = -it.key(); | - |
475 | Span *span = it.value(); | - |
476 | if (!spans.contains(span) || span->left() != x | - |
477 | || y < span->top() || y > span->bottom()) | - |
478 | return false; | - |
479 | } | - |
480 | } | - |
481 | | - |
482 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(spans)>::type> _container_((spans)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const Span *span = *_container_.i; _container_.control; _container_.control = 0) { | - |
483 | if (span->width() < 1 || span->height() < 1 | - |
484 | || (span->width() == 1 && span->height() == 1)) | - |
485 | return false; | - |
486 | for (int y = span->top(); y <= span->bottom(); ++y) { | - |
487 | Index::const_iterator it_y = index.find(-y); | - |
488 | if (it_y == index.end()) { | - |
489 | if (y == span->top()) | - |
490 | return false; | - |
491 | else | - |
492 | continue; | - |
493 | } | - |
494 | const SubIndex &subIndex = it_y.value(); | - |
495 | SubIndex::const_iterator it = subIndex.find(-span->left()); | - |
496 | if (it == subIndex.end() || it.value() != span) | - |
497 | return false; | - |
498 | } | - |
499 | } | - |
500 | return true; | - |
501 | } | - |
502 | | - |
503 | | - |
504 | class QTableCornerButton : public QAbstractButton | - |
505 | { | - |
506 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - |
507 | #pragma GCC diagnostic push | - |
508 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - |
509 | #pragma GCC diagnostic pop | - |
510 | struct QPrivateSignal {}; | - |
511 | public: | - |
512 | QTableCornerButton(QWidget *parent) : QAbstractButton(parent) {} | - |
513 | void paintEvent(QPaintEvent*) override { | - |
514 | QStyleOptionHeader opt; | - |
515 | opt.init(this); | - |
516 | QStyle::State state = QStyle::State_None; | - |
517 | if (isEnabled()) | - |
518 | state |= QStyle::State_Enabled; | - |
519 | if (isActiveWindow()) | - |
520 | state |= QStyle::State_Active; | - |
521 | if (isDown()) | - |
522 | state |= QStyle::State_Sunken; | - |
523 | opt.state = state; | - |
524 | opt.rect = rect(); | - |
525 | opt.position = QStyleOptionHeader::OnlyOneSection; | - |
526 | QPainter painter(this); | - |
527 | style()->drawControl(QStyle::CE_Header, &opt, &painter, this); | - |
528 | } | - |
529 | }; | - |
530 | | - |
531 | void QTableViewPrivate::init() | - |
532 | { | - |
533 | QTableView * const q = q_func(); | - |
534 | | - |
535 | q->setEditTriggers(editTriggers|QAbstractItemView::AnyKeyPressed); | - |
536 | | - |
537 | QHeaderView *vertical = new QHeaderView(Qt::Vertical, q); | - |
538 | vertical->setSectionsClickable(true); | - |
539 | vertical->setHighlightSections(true); | - |
540 | q->setVerticalHeader(vertical); | - |
541 | | - |
542 | QHeaderView *horizontal = new QHeaderView(Qt::Horizontal, q); | - |
543 | horizontal->setSectionsClickable(true); | - |
544 | horizontal->setHighlightSections(true); | - |
545 | q->setHorizontalHeader(horizontal); | - |
546 | | - |
547 | tabKeyNavigation = true; | - |
548 | | - |
549 | cornerWidget = new QTableCornerButton(q); | - |
550 | cornerWidget->setFocusPolicy(Qt::NoFocus); | - |
551 | QObject::connect(cornerWidget, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "617""624"), q, qFlagLocation("1""selectAll()" "\0" __FILE__ ":" "617""624")); | - |
552 | } | - |
553 | | - |
554 | | - |
555 | | - |
556 | | - |
557 | | - |
558 | void QTableViewPrivate::trimHiddenSelections(QItemSelectionRange *range) const | - |
559 | { | - |
560 | ((!(range && range->isValid())) ? qt_assert("range && range->isValid()",__FILE__,626633) : qt_noop()); | - |
561 | | - |
562 | int top = range->top(); | - |
563 | int left = range->left(); | - |
564 | int bottom = range->bottom(); | - |
565 | int right = range->right(); | - |
566 | | - |
567 | while (bottom >= top && verticalHeader->isSectionHidden(bottom)) | - |
568 | --bottom; | - |
569 | while (right >= left && horizontalHeader->isSectionHidden(right)) | - |
570 | --right; | - |
571 | | - |
572 | if (top > bottom || left > right) { | - |
573 | *range = QItemSelectionRange(); | - |
574 | return; | - |
575 | } | - |
576 | | - |
577 | while (verticalHeader->isSectionHidden(top) && top <= bottom) | - |
578 | ++top; | - |
579 | while (horizontalHeader->isSectionHidden(left) && left <= right) | - |
580 | ++left; | - |
581 | | - |
582 | if (top > bottom || left > right) { | - |
583 | *range = QItemSelectionRange(); | - |
584 | return; | - |
585 | } | - |
586 | | - |
587 | QModelIndex bottomRight = model->index(bottom, right, range->parent()); | - |
588 | QModelIndex topLeft = model->index(top, left, range->parent()); | - |
589 | *range = QItemSelectionRange(topLeft, bottomRight); | - |
590 | } | - |
591 | | - |
592 | | - |
593 | | - |
594 | | - |
595 | | - |
596 | void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan) | - |
597 | { | - |
598 | if (__builtin_expect(!!(TRUE | never evaluated | FALSE | never evaluated |
row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
599 | QMessageLogger(__FILE__, 665672, __PRETTY_FUNCTION__).warning("QTableView::setSpan: invalid span given: (%d, %d, %d, %d)", | - |
600 | row, column, rowSpan, columnSpan); | - |
601 | return; never executed: return; | 0 |
602 | } | - |
603 | QSpanCollection::Span *sp = spans.spanAt(column, row); | - |
604 | if (spTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
605 | if (sp->top() != rowTRUE | never evaluated | FALSE | never evaluated |
|| sp->left() != columnTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
606 | QMessageLogger(__FILE__, 672679, __PRETTY_FUNCTION__).warning("QTableView::setSpan: span cannot overlap"); | - |
607 | return; never executed: return; | 0 |
608 | } | - |
609 | if (rowSpan == 1TRUE | never evaluated | FALSE | never evaluated |
&& columnSpan == 1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
610 | rowSpan = columnSpan = 0; | - |
611 | } never executed: end of block | 0 |
612 | const int old_height = sp->height(); | - |
613 | sp->m_bottom = row + rowSpan - 1; | - |
614 | sp->m_right = column + columnSpan - 1; | - |
615 | spans.updateSpan(sp, old_height); | - |
616 | return; never executed: return; | 0 |
617 | } else if (__builtin_expect(!!(TRUE | never evaluated | FALSE | never evaluated |
rowSpan == 1 && columnSpan == 1)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
618 | QMessageLogger(__FILE__, 684691, __PRETTY_FUNCTION__).warning("QTableView::setSpan: single cell span won't be added"); | - |
619 | return; never executed: return; | 0 |
620 | } | - |
621 | sp = new QSpanCollection::Span(row, column, rowSpan, columnSpan); | - |
622 | spans.addSpan(sp); | - |
623 | } never executed: end of block | 0 |
624 | | - |
625 | | - |
626 | | - |
627 | | - |
628 | | - |
629 | QSpanCollection::Span QTableViewPrivate::span(int row, int column) const | - |
630 | { | - |
631 | QSpanCollection::Span *sp = spans.spanAt(column, row); | - |
632 | if (sp) | - |
633 | return *sp; | - |
634 | | - |
635 | return QSpanCollection::Span(row, column, 1, 1); | - |
636 | } | - |
637 | | - |
638 | | - |
639 | | - |
640 | | - |
641 | | - |
642 | int QTableViewPrivate::sectionSpanEndLogical(const QHeaderView *header, int logical, int span) const | - |
643 | { | - |
644 | int visual = header->visualIndex(logical); | - |
645 | for (int i = 1; i < span; ) { | - |
646 | if (++visual >= header->count()) | - |
647 | break; | - |
648 | logical = header->logicalIndex(visual); | - |
649 | ++i; | - |
650 | } | - |
651 | return logical; | - |
652 | } | - |
653 | | - |
654 | | - |
655 | | - |
656 | | - |
657 | | - |
658 | | - |
659 | int QTableViewPrivate::sectionSpanSize(const QHeaderView *header, int logical, int span) const | - |
660 | { | - |
661 | int endLogical = sectionSpanEndLogical(header, logical, span); | - |
662 | return header->sectionPosition(endLogical) | - |
663 | - header->sectionPosition(logical) | - |
664 | + header->sectionSize(endLogical); | - |
665 | } | - |
666 | | - |
667 | | - |
668 | | - |
669 | | - |
670 | | - |
671 | | - |
672 | | - |
673 | bool QTableViewPrivate::spanContainsSection(const QHeaderView *header, int logical, int spanLogical, int span) const | - |
674 | { | - |
675 | if (logical == spanLogical) | - |
676 | return true; | - |
677 | int visual = header->visualIndex(spanLogical); | - |
678 | for (int i = 1; i < span; ) { | - |
679 | if (++visual >= header->count()) | - |
680 | break; | - |
681 | spanLogical = header->logicalIndex(visual); | - |
682 | if (logical == spanLogical) | - |
683 | return true; | - |
684 | ++i; | - |
685 | } | - |
686 | return false; | - |
687 | } | - |
688 | | - |
689 | | - |
690 | | - |
691 | | - |
692 | | - |
693 | QRect QTableViewPrivate::visualSpanRect(const QSpanCollection::Span &span) const | - |
694 | { | - |
695 | const QTableView * const q = q_func(); | - |
696 | | - |
697 | int row = span.top(); | - |
698 | int rowp = verticalHeader->sectionViewportPosition(row); | - |
699 | int rowh = rowSpanHeight(row, span.height()); | - |
700 | | - |
701 | int column = span.left(); | - |
702 | int colw = columnSpanWidth(column, span.width()); | - |
703 | if (q->isRightToLeft()) | - |
704 | column = span.right(); | - |
705 | int colp = horizontalHeader->sectionViewportPosition(column); | - |
706 | | - |
707 | const int i = showGrid ? 1 : 0; | - |
708 | if (q->isRightToLeft()) | - |
709 | return QRect(colp + i, rowp, colw - i, rowh - i); | - |
710 | return QRect(colp, rowp, colw - i, rowh - i); | - |
711 | } | - |
712 | | - |
713 | | - |
714 | | - |
715 | | - |
716 | | - |
717 | | - |
718 | | - |
719 | void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter, | - |
720 | const QStyleOptionViewItem &option, QBitArray *drawn, | - |
721 | int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn) | - |
722 | { | - |
723 | bool alternateBase = false; | - |
724 | QRegion region = viewport->rect(); | - |
725 | | - |
726 | QList<QSpanCollection::Span *> visibleSpans; | - |
727 | bool sectionMoved = verticalHeader->sectionsMoved()TRUE | never evaluated | FALSE | never evaluated |
|| horizontalHeader->sectionsMoved()TRUE | never evaluated | FALSE | never evaluated |
; | 0 |
728 | | - |
729 | if (!sectionMovedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
730 | visibleSpans = spans.spansInRect(logicalColumn(firstVisualColumn), logicalRow(firstVisualRow), | - |
731 | lastVisualColumn - firstVisualColumn + 1, lastVisualRow - firstVisualRow + 1); | - |
732 | } never executed: end of block else { | 0 |
733 | QSet<QSpanCollection::Span *> set; | - |
734 | for(int x = firstVisualColumn; x <= lastVisualColumnTRUE | never evaluated | FALSE | never evaluated |
; x++) | 0 |
735 | for(int y = firstVisualRow; y <= lastVisualRowTRUE | never evaluated | FALSE | never evaluated |
; y++) | 0 |
736 | set. never executed: set.insert(spans.spanAt(x,y)); insert(spans.spanAt(x,y));never executed: set.insert(spans.spanAt(x,y)); | 0 |
737 | set.remove(0); | - |
738 | visibleSpans = set.toList(); | - |
739 | } never executed: end of block | 0 |
740 | | - |
741 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(visibleSpans)>::type> _container_((visibleSpans)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QSpanCollection::Span *span = *_container_.i; _container_.control; _container_.control = 0) { | - |
742 | int row = span->top(); | - |
743 | int col = span->left(); | - |
744 | QModelIndex index = model->index(row, col, root); | - |
745 | if (!index.isValid()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
746 | continue; never executed: continue; | 0 |
747 | QRect rect = visualSpanRect(*span); | - |
748 | rect.translate(scrollDelayOffset); | - |
749 | if (!area.intersects(rect)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
750 | continue; never executed: continue; | 0 |
751 | QStyleOptionViewItem opt = option; | - |
752 | opt.rect = rect; | - |
753 | alternateBase = alternatingColorsTRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
span->top() & 1)TRUE | never evaluated | FALSE | never evaluated |
; | 0 |
754 | if (alternateBase)opt.features|= QStyleOptionViewItem::Alternate; | - |
| else | |
| opt.features &= ~setFlag(QStyleOptionViewItem::Alternate;, alternateBase); | |
755 | drawCell(painter, opt, index); | - |
756 | region -= rect; | - |
757 | for (int r = span->top(); r <= span->bottom()TRUE | never evaluated | FALSE | never evaluated |
; ++r) { | 0 |
758 | const int vr = visualRow(r); | - |
759 | if (vr < firstVisualRowTRUE | never evaluated | FALSE | never evaluated |
|| vr > lastVisualRowTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
760 | continue; never executed: continue; | 0 |
761 | for (int c = span->left(); c <= span->right()TRUE | never evaluated | FALSE | never evaluated |
; ++c) { | 0 |
762 | const int vc = visualColumn(c); | - |
763 | if (vc < firstVisualColumnTRUE | never evaluated | FALSE | never evaluated |
|| vc > lastVisualColumnTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
764 | continue; never executed: continue; | 0 |
765 | drawn->setBit((vr - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1) | - |
766 | + vc - firstVisualColumn); | - |
767 | } never executed: end of block | 0 |
768 | } never executed: end of block | 0 |
769 | | - |
770 | } never executed: end of block | 0 |
771 | painter->setClipRegion(region); | - |
772 | } never executed: end of block | 0 |
773 | | - |
774 | | - |
775 | | - |
776 | | - |
777 | | - |
778 | void QTableViewPrivate::_q_updateSpanInsertedRows(const QModelIndex &parent, int start, int end) | - |
779 | { | - |
780 | (void)parent; | - |
781 | spans.updateInsertedRows(start, end); | - |
782 | } | - |
783 | | - |
784 | | - |
785 | | - |
786 | | - |
787 | | - |
788 | void QTableViewPrivate::_q_updateSpanInsertedColumns(const QModelIndex &parent, int start, int end) | - |
789 | { | - |
790 | (void)parent; | - |
791 | spans.updateInsertedColumns(start, end); | - |
792 | } | - |
793 | | - |
794 | | - |
795 | | - |
796 | | - |
797 | | - |
798 | void QTableViewPrivate::_q_updateSpanRemovedRows(const QModelIndex &parent, int start, int end) | - |
799 | { | - |
800 | (void)parent; | - |
801 | spans.updateRemovedRows(start, end); | - |
802 | } | - |
803 | | - |
804 | | - |
805 | | - |
806 | | - |
807 | | - |
808 | void QTableViewPrivate::_q_updateSpanRemovedColumns(const QModelIndex &parent, int start, int end) | - |
809 | { | - |
810 | (void)parent; | - |
811 | spans.updateRemovedColumns(start, end); | - |
812 | } | - |
813 | | - |
814 | | - |
815 | | - |
816 | | - |
817 | | - |
818 | void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) | - |
819 | { | - |
820 | QTableView * const q = q_func(); | - |
821 | QStyleOptionViewItem opt = option; | - |
822 | | - |
823 | if (selectionModel && selectionModel->isSelected(index)) | - |
824 | opt.state |= QStyle::State_Selected; | - |
825 | if (index == hover) | - |
826 | opt.state |= QStyle::State_MouseOver; | - |
827 | if (option.state & QStyle::State_Enabled) { | - |
828 | QPalette::ColorGroup cg; | - |
829 | if ((model->flags(index) & Qt::ItemIsEnabled) == 0) { | - |
830 | opt.state &= ~QStyle::State_Enabled; | - |
831 | cg = QPalette::Disabled; | - |
832 | } else { | - |
833 | cg = QPalette::Normal; | - |
834 | } | - |
835 | opt.palette.setCurrentColorGroup(cg); | - |
836 | } | - |
837 | | - |
838 | if (index == q->currentIndex()) { | - |
839 | const bool focus = (q->hasFocus() || viewport->hasFocus()) && q->currentIndex().isValid(); | - |
840 | if (focus) | - |
841 | opt.state |= QStyle::State_HasFocus; | - |
842 | } | - |
843 | | - |
844 | q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, q); | - |
845 | | - |
846 | q->itemDelegate(index)->paint(painter, opt, index); | - |
847 | } | - |
848 | | - |
849 | | - |
850 | | - |
851 | | - |
852 | | - |
853 | int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const | - |
854 | { | - |
855 | const QTableView * const q = q_func(); | - |
856 | QWidget *editor = editorForIndex(index).widget.data(); | - |
857 | if (editor && persistent.contains(editor)) { | - |
858 | hint = qMax(hint, editor->sizeHint().width()); | - |
859 | int min = editor->minimumSize().width(); | - |
860 | int max = editor->maximumSize().width(); | - |
861 | hint = qBound(min, hint, max); | - |
862 | } | - |
863 | hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width()); | - |
864 | return hint; | - |
865 | } | - |
866 | | - |
867 | | - |
868 | | - |
869 | | - |
870 | | - |
871 | int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QStyleOptionViewItem &option) const | - |
872 | { | - |
873 | const QTableView * const q = q_func(); | - |
874 | QWidget *editor = editorForIndex(index).widget.data(); | - |
875 | if (editor && persistent.contains(editor)) { | - |
876 | hint = qMax(hint, editor->sizeHint().height()); | - |
877 | int min = editor->minimumSize().height(); | - |
878 | int max = editor->maximumSize().height(); | - |
879 | hint = qBound(min, hint, max); | - |
880 | } | - |
881 | | - |
882 | if (wrapItemText) { | - |
883 | option.rect.setY(q->rowViewportPosition(index.row())); | - |
884 | int height = q->rowHeight(index.row()); | - |
885 | | - |
886 | | - |
887 | | - |
888 | | - |
889 | | - |
890 | | - |
891 | if (height == 0) | - |
892 | height = 1; | - |
893 | option.rect.setHeight(height); | - |
894 | option.rect.setX(q->columnViewportPosition(index.column())); | - |
895 | option.rect.setWidth(q->columnWidth(index.column())); | - |
896 | } | - |
897 | hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).height()); | - |
898 | return hint; | - |
899 | } | - |
900 | QTableView::QTableView(QWidget *parent) | - |
901 | : QAbstractItemView(*new QTableViewPrivate, parent) | - |
902 | { | - |
903 | QTableViewPrivate * const d = d_func(); | - |
904 | d->init(); | - |
905 | } | - |
906 | | - |
907 | | - |
908 | | - |
909 | | - |
910 | QTableView::QTableView(QTableViewPrivate &dd, QWidget *parent) | - |
911 | : QAbstractItemView(dd, parent) | - |
912 | { | - |
913 | QTableViewPrivate * const d = d_func(); | - |
914 | d->init(); | - |
915 | } | - |
916 | | - |
917 | | - |
918 | | - |
919 | | - |
920 | QTableView::~QTableView() | - |
921 | { | - |
922 | } | - |
923 | | - |
924 | | - |
925 | | - |
926 | | - |
927 | QSize QTableView::viewportSizeHint() const | - |
928 | { | - |
929 | const QTableViewPrivate * const d = d_func(); | - |
930 | QSize result( (d->verticalHeader->isHidden() ? 0 : d->verticalHeader->width()) + d->horizontalHeader->length(), | - |
931 | (d->horizontalHeader->isHidden() ? 0 : d->horizontalHeader->height()) + d->verticalHeader->length()); | - |
932 | result += QSize(verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0, | - |
933 | horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0); | - |
934 | return result; | - |
935 | } | - |
936 | | - |
937 | | - |
938 | | - |
939 | | - |
940 | void QTableView::setModel(QAbstractItemModel *model) | - |
941 | { | - |
942 | QTableViewPrivate * const d = d_func(); | - |
943 | if (model == d->model) | - |
944 | return; | - |
945 | | - |
946 | if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) { | - |
947 | disconnect(d->model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "1117""1121"), | - |
948 | this, qFlagLocation("1""_q_updateSpanInsertedRows(QModelIndex,int,int)" "\0" __FILE__ ":" "1118""1122")); | - |
949 | disconnect(d->model, qFlagLocation("2""columnsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "1119""1123"), | - |
950 | this, qFlagLocation("1""_q_updateSpanInsertedColumns(QModelIndex,int,int)" "\0" __FILE__ ":" "1120""1124")); | - |
951 | disconnect(d->model, qFlagLocation("2""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "1121""1125"), | - |
952 | this, qFlagLocation("1""_q_updateSpanRemovedRows(QModelIndex,int,int)" "\0" __FILE__ ":" "1122""1126")); | - |
953 | disconnect(d->model, qFlagLocation("2""columnsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "1123""1127"), | - |
954 | this, qFlagLocation("1""_q_updateSpanRemovedColumns(QModelIndex,int,int)" "\0" __FILE__ ":" "1124""1128")); | - |
955 | } | - |
956 | if (d->selectionModel) { | - |
957 | disconnect(d->selectionModel, qFlagLocation("2""currentRowChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "1127""1131"), | - |
958 | d->model, qFlagLocation("1""submit()" "\0" __FILE__ ":" "1128""1132")); | - |
959 | } | - |
960 | if (model) { | - |
961 | connect(model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "1131""1135"), | - |
962 | this, qFlagLocation("1""_q_updateSpanInsertedRows(QModelIndex,int,int)" "\0" __FILE__ ":" "1132""1136")); | - |
963 | connect(model, qFlagLocation("2""columnsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "1133""1137"), | - |
964 | this, qFlagLocation("1""_q_updateSpanInsertedColumns(QModelIndex,int,int)" "\0" __FILE__ ":" "1134""1138")); | - |
965 | connect(model, qFlagLocation("2""rowsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "1135""1139"), | - |
966 | this, qFlagLocation("1""_q_updateSpanRemovedRows(QModelIndex,int,int)" "\0" __FILE__ ":" "1136""1140")); | - |
967 | connect(model, qFlagLocation("2""columnsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "1137""1141"), | - |
968 | this, qFlagLocation("1""_q_updateSpanRemovedColumns(QModelIndex,int,int)" "\0" __FILE__ ":" "1138""1142")); | - |
969 | } | - |
970 | d->verticalHeader->setModel(model); | - |
971 | d->horizontalHeader->setModel(model); | - |
972 | QAbstractItemView::setModel(model); | - |
973 | } | - |
974 | | - |
975 | | - |
976 | | - |
977 | | - |
978 | void QTableView::setRootIndex(const QModelIndex &index) | - |
979 | { | - |
980 | QTableViewPrivate * const d = d_func(); | - |
981 | if (index == d->root) { | - |
982 | viewport()->update(); | - |
983 | return; | - |
984 | } | - |
985 | d->verticalHeader->setRootIndex(index); | - |
986 | d->horizontalHeader->setRootIndex(index); | - |
987 | QAbstractItemView::setRootIndex(index); | - |
988 | } | - |
989 | | - |
990 | | - |
991 | | - |
992 | | - |
993 | void QTableView::doItemsLayout() | - |
994 | { | - |
995 | QTableViewPrivate * const d = d_func(); | - |
996 | QAbstractItemView::doItemsLayout(); | - |
997 | d->verticalHeader->d_func()->setScrollOffset(verticalScrollBar(), verticalScrollMode()); | - |
998 | if (!d->verticalHeader->updatesEnabled()) | - |
999 | d->verticalHeader->setUpdatesEnabled(true); | - |
1000 | } | - |
1001 | | - |
1002 | | - |
1003 | | - |
1004 | | - |
1005 | void QTableView::setSelectionModel(QItemSelectionModel *selectionModel) | - |
1006 | { | - |
1007 | QTableViewPrivate * const d = d_func(); | - |
1008 | ((!(selectionModel)) ? qt_assert("selectionModel",__FILE__,11781182) : qt_noop()); | - |
1009 | if (d->selectionModel) { | - |
1010 | | - |
1011 | disconnect(d->selectionModel, qFlagLocation("2""currentRowChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "1181""1185"), | - |
1012 | d->model, qFlagLocation("1""submit()" "\0" __FILE__ ":" "1182""1186")); | - |
1013 | } | - |
1014 | | - |
1015 | d->verticalHeader->setSelectionModel(selectionModel); | - |
1016 | d->horizontalHeader->setSelectionModel(selectionModel); | - |
1017 | QAbstractItemView::setSelectionModel(selectionModel); | - |
1018 | | - |
1019 | if (d->selectionModel) { | - |
1020 | | - |
1021 | connect(d->selectionModel, qFlagLocation("2""currentRowChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "1191""1195"), | - |
1022 | d->model, qFlagLocation("1""submit()" "\0" __FILE__ ":" "1192""1196")); | - |
1023 | } | - |
1024 | } | - |
1025 | | - |
1026 | | - |
1027 | | - |
1028 | | - |
1029 | | - |
1030 | | - |
1031 | QHeaderView *QTableView::horizontalHeader() const | - |
1032 | { | - |
1033 | const QTableViewPrivate * const d = d_func(); | - |
1034 | return d->horizontalHeader; | - |
1035 | } | - |
1036 | | - |
1037 | | - |
1038 | | - |
1039 | | - |
1040 | | - |
1041 | | - |
1042 | QHeaderView *QTableView::verticalHeader() const | - |
1043 | { | - |
1044 | const QTableViewPrivate * const d = d_func(); | - |
1045 | return d->verticalHeader; | - |
1046 | } | - |
1047 | | - |
1048 | | - |
1049 | | - |
1050 | | - |
1051 | | - |
1052 | | - |
1053 | void QTableView::setHorizontalHeader(QHeaderView *header) | - |
1054 | { | - |
1055 | QTableViewPrivate * const d = d_func(); | - |
1056 | | - |
1057 | if (!header || header == d->horizontalHeader) | - |
1058 | return; | - |
1059 | if (d->horizontalHeader && d->horizontalHeader->parent() == this) | - |
1060 | delete d->horizontalHeader; | - |
1061 | d->horizontalHeader = header; | - |
1062 | d->horizontalHeader->setParent(this); | - |
1063 | d->horizontalHeader->d_func()->setAllowUserMoveOfSection0(true); | - |
1064 | if (!d->horizontalHeader->model()) { | - |
1065 | d->horizontalHeader->setModel(d->model); | - |
1066 | if (d->selectionModel) | - |
1067 | d->horizontalHeader->setSelectionModel(d->selectionModel); | - |
1068 | } | - |
1069 | | - |
1070 | connect(d->horizontalHeader,qFlagLocation("2""sectionResized(int,int,int)" "\0" __FILE__ ":" "1240""1244"), | - |
1071 | this, qFlagLocation("1""columnResized(int,int,int)" "\0" __FILE__ ":" "1241""1245")); | - |
1072 | connect(d->horizontalHeader, qFlagLocation("2""sectionMoved(int,int,int)" "\0" __FILE__ ":" "1242""1246"), | - |
1073 | this, qFlagLocation("1""columnMoved(int,int,int)" "\0" __FILE__ ":" "1243""1247")); | - |
1074 | connect(d->horizontalHeader, qFlagLocation("2""sectionCountChanged(int,int)" "\0" __FILE__ ":" "1244""1248"), | - |
1075 | this, qFlagLocation("1""columnCountChanged(int,int)" "\0" __FILE__ ":" "1245""1249")); | - |
1076 | connect(d->horizontalHeader, qFlagLocation("2""sectionPressed(int)" "\0" __FILE__ ":" "1246""1250"), this, qFlagLocation("1""selectColumn(int)" "\0" __FILE__ ":" "1246""1250")); | - |
1077 | connect(d->horizontalHeader, qFlagLocation("2""sectionEntered(int)" "\0" __FILE__ ":" "1247""1251"), this, qFlagLocation("1""_q_selectColumn(int)" "\0" __FILE__ ":" "1247""1251")); | - |
1078 | connect(d->horizontalHeader, qFlagLocation("2""sectionHandleDoubleClicked(int)" "\0" __FILE__ ":" "1248""1252"), | - |
1079 | this, qFlagLocation("1""resizeColumnToContents(int)" "\0" __FILE__ ":" "1249""1253")); | - |
1080 | connect(d->horizontalHeader, qFlagLocation("2""geometriesChanged()" "\0" __FILE__ ":" "1250""1254"), this, qFlagLocation("1""updateGeometries()" "\0" __FILE__ ":" "1250""1254")); | - |
1081 | | - |
1082 | | - |
1083 | setSortingEnabled(d->sortingEnabled); | - |
1084 | } | - |
1085 | | - |
1086 | | - |
1087 | | - |
1088 | | - |
1089 | | - |
1090 | | - |
1091 | void QTableView::setVerticalHeader(QHeaderView *header) | - |
1092 | { | - |
1093 | QTableViewPrivate * const d = d_func(); | - |
1094 | | - |
1095 | if (!header || header == d->verticalHeader) | - |
1096 | return; | - |
1097 | if (d->verticalHeader && d->verticalHeader->parent() == this) | - |
1098 | delete d->verticalHeader; | - |
1099 | d->verticalHeader = header; | - |
1100 | d->verticalHeader->setParent(this); | - |
1101 | d->verticalHeader->d_func()->setAllowUserMoveOfSection0(true); | - |
1102 | if (!d->verticalHeader->model()) { | - |
1103 | d->verticalHeader->setModel(d->model); | - |
1104 | if (d->selectionModel) | - |
1105 | d->verticalHeader->setSelectionModel(d->selectionModel); | - |
1106 | } | - |
1107 | | - |
1108 | connect(d->verticalHeader, qFlagLocation("2""sectionResized(int,int,int)" "\0" __FILE__ ":" "1278""1282"), | - |
1109 | this, qFlagLocation("1""rowResized(int,int,int)" "\0" __FILE__ ":" "1279""1283")); | - |
1110 | connect(d->verticalHeader, qFlagLocation("2""sectionMoved(int,int,int)" "\0" __FILE__ ":" "1280""1284"), | - |
1111 | this, qFlagLocation("1""rowMoved(int,int,int)" "\0" __FILE__ ":" "1281""1285")); | - |
1112 | connect(d->verticalHeader, qFlagLocation("2""sectionCountChanged(int,int)" "\0" __FILE__ ":" "1282""1286"), | - |
1113 | this, qFlagLocation("1""rowCountChanged(int,int)" "\0" __FILE__ ":" "1283""1287")); | - |
1114 | connect(d->verticalHeader, qFlagLocation("2""sectionPressed(int)" "\0" __FILE__ ":" "1284""1288"), this, qFlagLocation("1""selectRow(int)" "\0" __FILE__ ":" "1284""1288")); | - |
1115 | connect(d->verticalHeader, qFlagLocation("2""sectionEntered(int)" "\0" __FILE__ ":" "1285""1289"), this, qFlagLocation("1""_q_selectRow(int)" "\0" __FILE__ ":" "1285""1289")); | - |
1116 | connect(d->verticalHeader, qFlagLocation("2""sectionHandleDoubleClicked(int)" "\0" __FILE__ ":" "1286""1290"), | - |
1117 | this, qFlagLocation("1""resizeRowToContents(int)" "\0" __FILE__ ":" "1287""1291")); | - |
1118 | connect(d->verticalHeader, qFlagLocation("2""geometriesChanged()" "\0" __FILE__ ":" "1288""1292"), this, qFlagLocation("1""updateGeometries()" "\0" __FILE__ ":" "1288""1292")); | - |
1119 | } | - |
1120 | | - |
1121 | | - |
1122 | | - |
1123 | | - |
1124 | | - |
1125 | | - |
1126 | void QTableView::scrollContentsBy(int dx, int dy) | - |
1127 | { | - |
1128 | QTableViewPrivate * const d = d_func(); | - |
1129 | | - |
1130 | d->delayedAutoScroll.stop(); | - |
1131 | | - |
1132 | dx = isRightToLeft() ? -dx : dx; | - |
1133 | if (dx) { | - |
1134 | int oldOffset = d->horizontalHeader->offset(); | - |
1135 | d->horizontalHeader->d_func()->setScrollOffset(horizontalScrollBar(), horizontalScrollMode()); | - |
1136 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) { | - |
1137 | int newOffset = d->horizontalHeader->offset(); | - |
1138 | dx = isRightToLeft() ? newOffset - oldOffset : oldOffset - newOffset; | - |
1139 | } | - |
1140 | } | - |
1141 | if (dy) { | - |
1142 | int oldOffset = d->verticalHeader->offset(); | - |
1143 | d->verticalHeader->d_func()->setScrollOffset(verticalScrollBar(), verticalScrollMode()); | - |
1144 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) { | - |
1145 | int newOffset = d->verticalHeader->offset(); | - |
1146 | dy = oldOffset - newOffset; | - |
1147 | } | - |
1148 | } | - |
1149 | d->scrollContentsBy(dx, dy); | - |
1150 | | - |
1151 | if (d->showGrid) { | - |
1152 | | - |
1153 | | - |
1154 | | - |
1155 | if (dy > 0 && d->horizontalHeader->isHidden() && d->verticalScrollMode == ScrollPerItem) { | - |
1156 | d->viewport->update(0, dy, d->viewport->width(), dy); | - |
1157 | } | - |
1158 | if (dx > 0 && d->verticalHeader->isHidden() && d->horizontalScrollMode == ScrollPerItem) { | - |
1159 | d->viewport->update(dx, 0, dx, d->viewport->height()); | - |
1160 | } | - |
1161 | } | - |
1162 | } | - |
1163 | | - |
1164 | | - |
1165 | | - |
1166 | | - |
1167 | QStyleOptionViewItem QTableView::viewOptions() const | - |
1168 | { | - |
1169 | QStyleOptionViewItem option = QAbstractItemView::viewOptions(); | - |
1170 | option.showDecorationSelected = true; | - |
1171 | return option; | - |
1172 | } | - |
1173 | | - |
1174 | | - |
1175 | | - |
1176 | | - |
1177 | void QTableView::paintEvent(QPaintEvent *event) | - |
1178 | { | - |
1179 | QTableViewPrivate * const d = d_func(); | - |
1180 | | - |
1181 | QStyleOptionViewItem option = d->viewOptionsV1(); | - |
1182 | const QPoint offset = d->scrollDelayOffset; | - |
1183 | const bool showGrid = d->showGrid; | - |
1184 | const int gridSize = showGridTRUE | never evaluated | FALSE | never evaluated |
? 1 : 0; | 0 |
1185 | const int gridHint = style()->styleHint(QStyle::SH_Table_GridLineColor, &option, this); | - |
1186 | const QColor gridColor = static_cast<QRgb>(gridHint); | - |
1187 | const QPen gridPen = QPen(gridColor, 0, d->gridStyle); | - |
1188 | const QHeaderView *verticalHeader = d->verticalHeader; | - |
1189 | const QHeaderView *horizontalHeader = d->horizontalHeader; | - |
1190 | const bool alternate = d->alternatingColors; | - |
1191 | const bool rightToLeft = isRightToLeft(); | - |
1192 | | - |
1193 | QPainter painter(d->viewport); | - |
1194 | | - |
1195 | | - |
1196 | if (horizontalHeader->count() == 0TRUE | never evaluated | FALSE | never evaluated |
|| verticalHeader->count() == 0TRUE | never evaluated | FALSE | never evaluated |
|| !d->itemDelegateTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1197 | return; never executed: return; | 0 |
1198 | | - |
1199 | uint x = horizontalHeader->length() - horizontalHeader->offset() - (rightToLeftTRUE | never evaluated | FALSE | never evaluated |
? 0 : 1); | 0 |
1200 | uint y = verticalHeader->length() - verticalHeader->offset() - 1; | - |
1201 | | - |
1202 | | - |
1203 | | - |
1204 | const QRegion region = event->region().translated(offset); | - |
| const QVector<QRect> rects = region.rects();int firstVisualRow = qMax(verticalHeader->visualIndexAt(0),0); | |
1205 | int lastVisualRow = verticalHeader->visualIndexAt(verticalHeader->viewport()->height()); | - |
1206 | if (lastVisualRow == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1207 | lastVisualRow = d->model->rowCount(d->root) - 1; never executed: lastVisualRow = d->model->rowCount(d->root) - 1; | 0 |
1208 | | - |
1209 | int firstVisualColumn = horizontalHeader->visualIndexAt(0); | - |
1210 | int lastVisualColumn = horizontalHeader->visualIndexAt(horizontalHeader->viewport()->width()); | - |
1211 | if (rightToLeftTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1212 | qSwap(firstVisualColumn, lastVisualColumn); never executed: qSwap(firstVisualColumn, lastVisualColumn); | 0 |
1213 | if (firstVisualColumn == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1214 | firstVisualColumn = 0; never executed: firstVisualColumn = 0; | 0 |
1215 | if (lastVisualColumn == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1216 | lastVisualColumn = horizontalHeader->count() - 1; never executed: lastVisualColumn = horizontalHeader->count() - 1; | 0 |
1217 | | - |
1218 | QBitArray drawn((lastVisualRow - firstVisualRow + 1) * (lastVisualColumn - firstVisualColumn + 1)); | - |
1219 | | - |
1220 | const QRegion region = event->region().translated(offset); | - |
1221 | | - |
1222 | if (d->hasSpans()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1223 | d->drawAndClipSpans(region, &painter, option, &drawn, | - |
1224 | firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn); | - |
1225 | } never executed: end of block | 0 |
1226 | | - |
1227 | for (int i = 0; iconst QVector<QRect> rects = region.sizerects(); | - |
1228 | ++i) { | - |
| QRectfor (auto dirtyArea =: rects.at(i);) { | |
1229 | dirtyArea.setBottom(qMin(dirtyArea.bottom(), int(y))); | - |
1230 | if (rightToLeftTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1231 | dirtyArea.setLeft(qMax(dirtyArea.left(), d->viewport->width() - int(x))); | - |
1232 | } never executed: end of block else { | 0 |
1233 | dirtyArea.setRight(qMin(dirtyArea.right(), int(x))); | - |
1234 | } never executed: end of block | 0 |
1235 | | - |
1236 | | - |
1237 | int left = horizontalHeader->visualIndexAt(dirtyArea.left()); | - |
1238 | int right = horizontalHeader->visualIndexAt(dirtyArea.right()); | - |
1239 | if (rightToLeftTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1240 | qSwap(left, right); never executed: qSwap(left, right); | 0 |
1241 | if (left == -1TRUE | never evaluated | FALSE | never evaluated |
) left = 0;never executed: left = 0; | 0 |
1242 | if (right == -1TRUE | never evaluated | FALSE | never evaluated |
) right = horizontalHeader->count() - 1;never executed: right = horizontalHeader->count() - 1; | 0 |
1243 | | - |
1244 | | - |
1245 | int bottom = verticalHeader->visualIndexAt(dirtyArea.bottom()); | - |
1246 | if (bottom == -1TRUE | never evaluated | FALSE | never evaluated |
) bottom = verticalHeader->count() - 1;never executed: bottom = verticalHeader->count() - 1; | 0 |
1247 | int top = 0; | - |
1248 | bool alternateBase = false; | - |
1249 | if (alternateTRUE | never evaluated | FALSE | never evaluated |
&& verticalHeader->sectionsHidden()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1250 | uint verticalOffset = verticalHeader->offset(); | - |
1251 | int row = verticalHeader->logicalIndex(top); | - |
1252 | for (int y = 0; | - |
1253 | ((TRUE | never evaluated | FALSE | never evaluated |
uint)(y += verticalHeader->sectionSize(top)) <= verticalOffset)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
top < bottom)TRUE | never evaluated | FALSE | never evaluated |
; | 0 |
1254 | ++top) { | - |
1255 | row = verticalHeader->logicalIndex(top); | - |
1256 | if (alternateTRUE | never evaluated | FALSE | never evaluated |
&& !verticalHeader->isSectionHidden(row)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1257 | alternateBase = !alternateBase; never executed: alternateBase = !alternateBase; | 0 |
1258 | } never executed: end of block | 0 |
1259 | } never executed: end of block else { | 0 |
1260 | top = verticalHeader->visualIndexAt(dirtyArea.top()); | - |
1261 | alternateBase = (TRUE | never evaluated | FALSE | never evaluated |
top & 1)TRUE | never evaluated | FALSE | never evaluated |
&& alternateTRUE | never evaluated | FALSE | never evaluated |
; | 0 |
1262 | } never executed: end of block | 0 |
1263 | if (top == -1TRUE | never evaluated | FALSE | never evaluated |
|| top > bottomTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1264 | continue; never executed: continue; | 0 |
1265 | | - |
1266 | | - |
1267 | for (int visualRowIndex = top; visualRowIndex <= bottomTRUE | never evaluated | FALSE | never evaluated |
; ++visualRowIndex) { | 0 |
1268 | int row = verticalHeader->logicalIndex(visualRowIndex); | - |
1269 | if (verticalHeader->isSectionHidden(row)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1270 | continue; never executed: continue; | 0 |
1271 | int rowY = rowViewportPosition(row); | - |
1272 | rowY += offset.y(); | - |
1273 | int rowh = rowHeight(row) - gridSize; | - |
1274 | | - |
1275 | | - |
1276 | for (int visualColumnIndex = left; visualColumnIndex <= rightTRUE | never evaluated | FALSE | never evaluated |
; ++visualColumnIndex) { | 0 |
1277 | int currentBit = (visualRowIndex - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1) | - |
1278 | + visualColumnIndex - firstVisualColumn; | - |
1279 | | - |
1280 | if (currentBit < 0TRUE | never evaluated | FALSE | never evaluated |
|| currentBit >= drawn.size()TRUE | never evaluated | FALSE | never evaluated |
|| drawn.testBit(currentBit)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1281 | continue; never executed: continue; | 0 |
1282 | drawn.setBit(currentBit); | - |
1283 | | - |
1284 | int col = horizontalHeader->logicalIndex(visualColumnIndex); | - |
1285 | if (horizontalHeader->isSectionHidden(col)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1286 | continue; never executed: continue; | 0 |
1287 | int colp = columnViewportPosition(col); | - |
1288 | colp += offset.x(); | - |
1289 | int colw = columnWidth(col) - gridSize; | - |
1290 | | - |
1291 | const QModelIndex index = d->model->index(row, col, d->root); | - |
1292 | if (index.isValid()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1293 | option.rect = QRect(colp + (showGrid && rightToLeft ? 1 : 0), rowY, colw, rowh); | - |
1294 | if (alternateTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1295 | if (alternateBaseTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1296 | option.features |= QStyleOptionViewItem::Alternate; never executed: option.features |= QStyleOptionViewItem::Alternate; | 0 |
1297 | else | - |
1298 | option.features &= ~QStyleOptionViewItem::Alternate; never executed: option.features &= ~QStyleOptionViewItem::Alternate; | 0 |
1299 | } | - |
1300 | d->drawCell(&painter, option, index); | - |
1301 | } never executed: end of block | 0 |
1302 | } never executed: end of block | 0 |
1303 | alternateBase = !alternateBaseTRUE | never evaluated | FALSE | never evaluated |
&& alternateTRUE | never evaluated | FALSE | never evaluated |
; | 0 |
1304 | } never executed: end of block | 0 |
1305 | | - |
1306 | if (showGridTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1307 | | - |
1308 | while (verticalHeader->isSectionHidden(verticalHeader->logicalIndex(bottom))TRUE | never evaluated | FALSE | never evaluated |
) --never executed: --bottom; bottom;never executed: --bottom; | 0 |
1309 | QPen old = painter.pen(); | - |
1310 | painter.setPen(gridPen); | - |
1311 | | - |
1312 | for (int visualIndex = top; visualIndex <= bottomTRUE | never evaluated | FALSE | never evaluated |
; ++visualIndex) { | 0 |
1313 | int row = verticalHeader->logicalIndex(visualIndex); | - |
1314 | if (verticalHeader->isSectionHidden(row)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1315 | continue; never executed: continue; | 0 |
1316 | int rowY = rowViewportPosition(row); | - |
1317 | rowY += offset.y(); | - |
1318 | int rowh = rowHeight(row) - gridSize; | - |
1319 | painter.drawLine(dirtyArea.left(), rowY + rowh, dirtyArea.right(), rowY + rowh); | - |
1320 | } never executed: end of block | 0 |
1321 | | - |
1322 | | - |
1323 | for (int h = left; h <= rightTRUE | never evaluated | FALSE | never evaluated |
; ++h) { | 0 |
1324 | int col = horizontalHeader->logicalIndex(h); | - |
1325 | if (horizontalHeader->isSectionHidden(col)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1326 | continue; never executed: continue; | 0 |
1327 | int colp = columnViewportPosition(col); | - |
1328 | colp += offset.x(); | - |
1329 | if (!rightToLeftTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1330 | colp += columnWidth(col) - gridSize; never executed: colp += columnWidth(col) - gridSize; | 0 |
1331 | painter.drawLine(colp, dirtyArea.top(), colp, dirtyArea.bottom()); | - |
1332 | } never executed: end of block | 0 |
1333 | | - |
1334 | | - |
1335 | | - |
1336 | if (horizontalHeader->isHidden()TRUE | never evaluated | FALSE | never evaluated |
&& verticalScrollMode() == ScrollPerItemTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1337 | painter.drawLine(dirtyArea.left(), 0, dirtyArea.right(), 0); never executed: painter.drawLine(dirtyArea.left(), 0, dirtyArea.right(), 0); | 0 |
1338 | if (verticalHeader->isHidden()TRUE | never evaluated | FALSE | never evaluated |
&& horizontalScrollMode() == ScrollPerItemTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1339 | painter.drawLine(0, dirtyArea.top(), 0, dirtyArea.bottom()); never executed: painter.drawLine(0, dirtyArea.top(), 0, dirtyArea.bottom()); | 0 |
1340 | painter.setPen(old); | - |
1341 | } never executed: end of block | 0 |
1342 | } never executed: end of block | 0 |
1343 | | - |
1344 | | - |
1345 | | - |
1346 | d->paintDropIndicator(&painter); | - |
1347 | | - |
1348 | } never executed: end of block | 0 |
1349 | | - |
1350 | | - |
1351 | | - |
1352 | | - |
1353 | | - |
1354 | QModelIndex QTableView::indexAt(const QPoint &pos) const | - |
1355 | { | - |
1356 | const QTableViewPrivate * const d = d_func(); | - |
1357 | d->executePostedLayout(); | - |
1358 | int r = rowAt(pos.y()); | - |
1359 | int c = columnAt(pos.x()); | - |
1360 | if (r >= 0 && c >= 0) { | - |
1361 | if (d->hasSpans()) { | - |
1362 | QSpanCollection::Span span = d->span(r, c); | - |
1363 | r = span.top(); | - |
1364 | c = span.left(); | - |
1365 | } | - |
1366 | return d->model->index(r, c, d->root); | - |
1367 | } | - |
1368 | return QModelIndex(); | - |
1369 | } | - |
1370 | int QTableView::horizontalOffset() const | - |
1371 | { | - |
1372 | const QTableViewPrivate * const d = d_func(); | - |
1373 | return d->horizontalHeader->offset(); | - |
1374 | } | - |
1375 | int QTableView::verticalOffset() const | - |
1376 | { | - |
1377 | const QTableViewPrivate * const d = d_func(); | - |
1378 | return d->verticalHeader->offset(); | - |
1379 | } | - |
1380 | QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) | - |
1381 | { | - |
1382 | QTableViewPrivate * const d = d_func(); | - |
1383 | (void)modifiers;; | - |
1384 | | - |
1385 | int bottom = d->model->rowCount(d->root) - 1; | - |
1386 | | - |
1387 | while (bottom >= 0 && isRowHidden(d->logicalRow(bottom))) | - |
1388 | --bottom; | - |
1389 | | - |
1390 | int right = d->model->columnCount(d->root) - 1; | - |
1391 | | - |
1392 | while (right >= 0 && isColumnHidden(d->logicalColumn(right))) | - |
1393 | --right; | - |
1394 | | - |
1395 | if (bottom == -1 || right == -1) | - |
1396 | return QModelIndex(); | - |
1397 | | - |
1398 | QModelIndex current = currentIndex(); | - |
1399 | | - |
1400 | if (!current.isValid()) { | - |
1401 | int row = 0; | - |
1402 | int column = 0; | - |
1403 | while (column < right && isColumnHidden(d->logicalColumn(column))) | - |
1404 | ++column; | - |
1405 | while (isRowHidden(d->logicalRow(row)) && row < bottom) | - |
1406 | ++row; | - |
1407 | d->visualCursor = QPoint(column, row); | - |
1408 | return d->model->index(d->logicalRow(row), d->logicalColumn(column), d->root); | - |
1409 | } | - |
1410 | | - |
1411 | | - |
1412 | QPoint visualCurrent(d->visualColumn(current.column()), d->visualRow(current.row())); | - |
1413 | if (visualCurrent != d->visualCursor) { | - |
1414 | if (d->hasSpans()) { | - |
1415 | QSpanCollection::Span span = d->span(current.row(), current.column()); | - |
1416 | if (span.top() > d->visualCursor.y() || d->visualCursor.y() > span.bottom() | - |
1417 | || span.left() > d->visualCursor.x() || d->visualCursor.x() > span.right()) | - |
1418 | d->visualCursor = visualCurrent; | - |
1419 | } else { | - |
1420 | d->visualCursor = visualCurrent; | - |
1421 | } | - |
1422 | } | - |
1423 | | - |
1424 | int visualRow = d->visualCursor.y(); | - |
1425 | if (visualRow > bottom) | - |
1426 | visualRow = bottom; | - |
1427 | ((!(visualRow != -1)) ? qt_assert("visualRow != -1",__FILE__,16251628) : qt_noop()); | - |
1428 | int visualColumn = d->visualCursor.x(); | - |
1429 | if (visualColumn > right) | - |
1430 | visualColumn = right; | - |
1431 | ((!(visualColumn != -1)) ? qt_assert("visualColumn != -1",__FILE__,16291632) : qt_noop()); | - |
1432 | | - |
1433 | if (isRightToLeft()) { | - |
1434 | if (cursorAction == MoveLeft) | - |
1435 | cursorAction = MoveRight; | - |
1436 | else if (cursorAction == MoveRight) | - |
1437 | cursorAction = MoveLeft; | - |
1438 | } | - |
1439 | | - |
1440 | switch (cursorAction) { | - |
1441 | case MoveUp: { | - |
1442 | int originalRow = visualRow; | - |
1443 | | - |
1444 | | - |
1445 | | - |
1446 | | - |
1447 | | - |
1448 | int r = d->logicalRow(visualRow); | - |
1449 | int c = d->logicalColumn(visualColumn); | - |
1450 | if (r != -1 && d->hasSpans()) { | - |
1451 | QSpanCollection::Span span = d->span(r, c); | - |
1452 | if (span.width() > 1 || span.height() > 1) | - |
1453 | visualRow = d->visualRow(span.top()); | - |
1454 | } | - |
1455 | while (visualRow >= 0) { | - |
1456 | --visualRow; | - |
1457 | r = d->logicalRow(visualRow); | - |
1458 | c = d->logicalColumn(visualColumn); | - |
1459 | if (r == -1 || (!isRowHidden(r) && d->isCellEnabled(r, c))) | - |
1460 | break; | - |
1461 | } | - |
1462 | if (visualRow < 0) | - |
1463 | visualRow = originalRow; | - |
1464 | break; | - |
1465 | } | - |
1466 | case MoveDown: { | - |
1467 | int originalRow = visualRow; | - |
1468 | if (d->hasSpans()) { | - |
1469 | QSpanCollection::Span span = d->span(current.row(), current.column()); | - |
1470 | visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); | - |
1471 | } | - |
1472 | | - |
1473 | | - |
1474 | | - |
1475 | | - |
1476 | int r = d->logicalRow(visualRow); | - |
1477 | int c = d->logicalColumn(visualColumn); | - |
1478 | if (r != -1 && d->hasSpans()) { | - |
1479 | QSpanCollection::Span span = d->span(r, c); | - |
1480 | if (span.width() > 1 || span.height() > 1) | - |
1481 | visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); | - |
1482 | } | - |
1483 | while (visualRow <= bottom) { | - |
1484 | ++visualRow; | - |
1485 | r = d->logicalRow(visualRow); | - |
1486 | c = d->logicalColumn(visualColumn); | - |
1487 | if (r == -1 || (!isRowHidden(r) && d->isCellEnabled(r, c))) | - |
1488 | break; | - |
1489 | } | - |
1490 | if (visualRow > bottom) | - |
1491 | visualRow = originalRow; | - |
1492 | break; | - |
1493 | } | - |
1494 | case MovePrevious: | - |
1495 | case MoveLeft: { | - |
1496 | int originalRow = visualRow; | - |
1497 | int originalColumn = visualColumn; | - |
1498 | bool firstTime = true; | - |
1499 | bool looped = false; | - |
1500 | bool wrapped = false; | - |
1501 | do { | - |
1502 | int r = d->logicalRow(visualRow); | - |
1503 | int c = d->logicalColumn(visualColumn); | - |
1504 | if (firstTime && c != -1 && d->hasSpans()) { | - |
1505 | firstTime = false; | - |
1506 | QSpanCollection::Span span = d->span(r, c); | - |
1507 | if (span.width() > 1 || span.height() > 1) | - |
1508 | visualColumn = d->visualColumn(span.left()); | - |
1509 | } | - |
1510 | while (visualColumn >= 0) { | - |
1511 | --visualColumn; | - |
1512 | r = d->logicalRow(visualRow); | - |
1513 | c = d->logicalColumn(visualColumn); | - |
1514 | if (r == -1 || c == -1 || (!isRowHidden(r) && !isColumnHidden(c) && d->isCellEnabled(r, c))) | - |
1515 | break; | - |
1516 | if (wrapped && (originalRow < visualRow || (originalRow == visualRow && originalColumn <= visualColumn))) { | - |
1517 | looped = true; | - |
1518 | break; | - |
1519 | } | - |
1520 | } | - |
1521 | if (cursorAction == MoveLeft || visualColumn >= 0) | - |
1522 | break; | - |
1523 | visualColumn = right + 1; | - |
1524 | if (visualRow == 0) { | - |
1525 | wrapped = true; | - |
1526 | visualRow = bottom; | - |
1527 | } else { | - |
1528 | --visualRow; | - |
1529 | } | - |
1530 | } while (!looped); | - |
1531 | if (visualColumn < 0) | - |
1532 | visualColumn = originalColumn; | - |
1533 | break; | - |
1534 | } | - |
1535 | case MoveNext: | - |
1536 | case MoveRight: { | - |
1537 | int originalRow = visualRow; | - |
1538 | int originalColumn = visualColumn; | - |
1539 | bool firstTime = true; | - |
1540 | bool looped = false; | - |
1541 | bool wrapped = false; | - |
1542 | do { | - |
1543 | int r = d->logicalRow(visualRow); | - |
1544 | int c = d->logicalColumn(visualColumn); | - |
1545 | if (firstTime && c != -1 && d->hasSpans()) { | - |
1546 | firstTime = false; | - |
1547 | QSpanCollection::Span span = d->span(r, c); | - |
1548 | if (span.width() > 1 || span.height() > 1) | - |
1549 | visualColumn = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width())); | - |
1550 | } | - |
1551 | while (visualColumn <= right) { | - |
1552 | ++visualColumn; | - |
1553 | r = d->logicalRow(visualRow); | - |
1554 | c = d->logicalColumn(visualColumn); | - |
1555 | if (r == -1 || c == -1 || (!isRowHidden(r) && !isColumnHidden(c) && d->isCellEnabled(r, c))) | - |
1556 | break; | - |
1557 | if (wrapped && (originalRow > visualRow || (originalRow == visualRow && originalColumn >= visualColumn))) { | - |
1558 | looped = true; | - |
1559 | break; | - |
1560 | } | - |
1561 | } | - |
1562 | if (cursorAction == MoveRight || visualColumn <= right) | - |
1563 | break; | - |
1564 | visualColumn = -1; | - |
1565 | if (visualRow == bottom) { | - |
1566 | wrapped = true; | - |
1567 | visualRow = 0; | - |
1568 | } else { | - |
1569 | ++visualRow; | - |
1570 | } | - |
1571 | } while (!looped); | - |
1572 | if (visualColumn > right) | - |
1573 | visualColumn = originalColumn; | - |
1574 | break; | - |
1575 | } | - |
1576 | case MoveHome: | - |
1577 | visualColumn = 0; | - |
1578 | while (visualColumn < right && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn)) | - |
1579 | ++visualColumn; | - |
1580 | if (modifiers & Qt::ControlModifier) { | - |
1581 | visualRow = 0; | - |
1582 | while (visualRow < bottom && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn)) | - |
1583 | ++visualRow; | - |
1584 | } | - |
1585 | break; | - |
1586 | case MoveEnd: | - |
1587 | visualColumn = right; | - |
1588 | if (modifiers & Qt::ControlModifier) | - |
1589 | visualRow = bottom; | - |
1590 | break; | - |
1591 | case MovePageUp: { | - |
1592 | int newRow = rowAt(visualRect(current).bottom() - d->viewport->height()); | - |
1593 | if (newRow == -1) | - |
1594 | newRow = d->logicalRow(0); | - |
1595 | return d->model->index(newRow, current.column(), d->root); | - |
1596 | } | - |
1597 | case MovePageDown: { | - |
1598 | int newRow = rowAt(visualRect(current).top() + d->viewport->height()); | - |
1599 | if (newRow == -1) | - |
1600 | newRow = d->logicalRow(bottom); | - |
1601 | return d->model->index(newRow, current.column(), d->root); | - |
1602 | }} | - |
1603 | | - |
1604 | d->visualCursor = QPoint(visualColumn, visualRow); | - |
1605 | int logicalRow = d->logicalRow(visualRow); | - |
1606 | int logicalColumn = d->logicalColumn(visualColumn); | - |
1607 | if (!d->model->hasIndex(logicalRow, logicalColumn, d->root)) | - |
1608 | return QModelIndex(); | - |
1609 | | - |
1610 | QModelIndex result = d->model->index(logicalRow, logicalColumn, d->root); | - |
1611 | if (!d->isRowHidden(logicalRow) && !d->isColumnHidden(logicalColumn) && d->isIndexEnabled(result)) { | - |
1612 | if (d->hasSpans()) { | - |
1613 | QSpanCollection::Span span = d->span(result.row(), result.column()); | - |
1614 | if (span.width() > 1 || span.height() > 1) { | - |
1615 | result = d->model->sibling(span.top(), span.left(), result); | - |
1616 | } | - |
1617 | } | - |
1618 | return result; | - |
1619 | } | - |
1620 | | - |
1621 | return QModelIndex(); | - |
1622 | } | - |
1623 | void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) | - |
1624 | { | - |
1625 | QTableViewPrivate * const d = d_func(); | - |
1626 | QModelIndex tl = indexAt(QPoint(isRightToLeft() ? qMax(rect.left(), rect.right()) | - |
1627 | : qMin(rect.left(), rect.right()), qMin(rect.top(), rect.bottom()))); | - |
1628 | QModelIndex br = indexAt(QPoint(isRightToLeft() ? qMin(rect.left(), rect.right()) : | - |
1629 | qMax(rect.left(), rect.right()), qMax(rect.top(), rect.bottom()))); | - |
1630 | if (!d->selectionModel || !tl.isValid() || !br.isValid() || !d->isIndexEnabled(tl) || !d->isIndexEnabled(br)) | - |
1631 | return; | - |
1632 | | - |
1633 | bool verticalMoved = verticalHeader()->sectionsMoved(); | - |
1634 | bool horizontalMoved = horizontalHeader()->sectionsMoved(); | - |
1635 | | - |
1636 | QItemSelection selection; | - |
1637 | | - |
1638 | if (d->hasSpans()) { | - |
1639 | bool expanded; | - |
1640 | int top = qMin(d->visualRow(tl.row()), d->visualRow(br.row())); | - |
1641 | int left = qMin(d->visualColumn(tl.column()), d->visualColumn(br.column())); | - |
1642 | int bottom = qMax(d->visualRow(tl.row()), d->visualRow(br.row())); | - |
1643 | int right = qMax(d->visualColumn(tl.column()), d->visualColumn(br.column())); | - |
1644 | do { | - |
1645 | expanded = false; | - |
1646 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->spans.spans)>::type> _container_((d->spans.spans)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QSpanCollection::Span *it = *_container_.i; _container_.control; _container_.control = 0) { | - |
1647 | const QSpanCollection::Span &span = *it; | - |
1648 | int t = d->visualRow(span.top()); | - |
1649 | int l = d->visualColumn(span.left()); | - |
1650 | int b = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); | - |
1651 | int r = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width())); | - |
1652 | if ((t > bottom) || (l > right) || (top > b) || (left > r)) | - |
1653 | continue; | - |
1654 | if (t < top) { | - |
1655 | top = t; | - |
1656 | expanded = true; | - |
1657 | } | - |
1658 | if (l < left) { | - |
1659 | left = l; | - |
1660 | expanded = true; | - |
1661 | } | - |
1662 | if (b > bottom) { | - |
1663 | bottom = b; | - |
1664 | expanded = true; | - |
1665 | } | - |
1666 | if (r > right) { | - |
1667 | right = r; | - |
1668 | expanded = true; | - |
1669 | } | - |
1670 | if (expanded) | - |
1671 | break; | - |
1672 | } | - |
1673 | } while (expanded); | - |
1674 | selection.reserve((right - left + 1) * (bottom - top + 1)); | - |
1675 | for (int horizontal = left; horizontal <= right; ++horizontal) { | - |
1676 | int column = d->logicalColumn(horizontal); | - |
1677 | for (int vertical = top; vertical <= bottom; ++vertical) { | - |
1678 | int row = d->logicalRow(vertical); | - |
1679 | QModelIndex index = d->model->index(row, column, d->root); | - |
1680 | selection.append(QItemSelectionRange(index)); | - |
1681 | } | - |
1682 | } | - |
1683 | } else if (verticalMoved && horizontalMoved) { | - |
1684 | int top = d->visualRow(tl.row()); | - |
1685 | int left = d->visualColumn(tl.column()); | - |
1686 | int bottom = d->visualRow(br.row()); | - |
1687 | int right = d->visualColumn(br.column()); | - |
1688 | selection.reserve((right - left + 1) * (bottom - top + 1)); | - |
1689 | for (int horizontal = left; horizontal <= right; ++horizontal) { | - |
1690 | int column = d->logicalColumn(horizontal); | - |
1691 | for (int vertical = top; vertical <= bottom; ++vertical) { | - |
1692 | int row = d->logicalRow(vertical); | - |
1693 | QModelIndex index = d->model->index(row, column, d->root); | - |
1694 | selection.append(QItemSelectionRange(index)); | - |
1695 | } | - |
1696 | } | - |
1697 | } else if (horizontalMoved) { | - |
1698 | int left = d->visualColumn(tl.column()); | - |
1699 | int right = d->visualColumn(br.column()); | - |
1700 | selection.reserve(right - left + 1); | - |
1701 | for (int visual = left; visual <= right; ++visual) { | - |
1702 | int column = d->logicalColumn(visual); | - |
1703 | QModelIndex topLeft = d->model->index(tl.row(), column, d->root); | - |
1704 | QModelIndex bottomRight = d->model->index(br.row(), column, d->root); | - |
1705 | selection.append(QItemSelectionRange(topLeft, bottomRight)); | - |
1706 | } | - |
1707 | } else if (verticalMoved) { | - |
1708 | int top = d->visualRow(tl.row()); | - |
1709 | int bottom = d->visualRow(br.row()); | - |
1710 | selection.reserve(bottom - top + 1); | - |
1711 | for (int visual = top; visual <= bottom; ++visual) { | - |
1712 | int row = d->logicalRow(visual); | - |
1713 | QModelIndex topLeft = d->model->index(row, tl.column(), d->root); | - |
1714 | QModelIndex bottomRight = d->model->index(row, br.column(), d->root); | - |
1715 | selection.append(QItemSelectionRange(topLeft, bottomRight)); | - |
1716 | } | - |
1717 | } else { | - |
1718 | QItemSelectionRange range(tl, br); | - |
1719 | if (!range.isEmpty()) | - |
1720 | selection.append(range); | - |
1721 | } | - |
1722 | | - |
1723 | d->selectionModel->select(selection, command); | - |
1724 | } | - |
1725 | QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) const | - |
1726 | { | - |
1727 | const QTableViewPrivate * const d = d_func(); | - |
1728 | | - |
1729 | if (selection.isEmpty()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1730 | return never executed: return QRegion(); QRegion();never executed: return QRegion(); | 0 |
1731 | | - |
1732 | QRegion selectionRegion; | - |
1733 | const QRect &viewportRect = d->viewport->rect(); | - |
1734 | bool verticalMoved = verticalHeader()->sectionsMoved(); | - |
1735 | bool horizontalMoved = horizontalHeader()->sectionsMoved(); | - |
1736 | | - |
1737 | if ((verticalMovedTRUE | never evaluated | FALSE | never evaluated |
&& horizontalMovedTRUE | never evaluated | FALSE | never evaluated |
) || (d->hasSpans()TRUE | never evaluated | FALSE | never evaluated |
&& (verticalMovedTRUE | never evaluated | FALSE | never evaluated |
|| horizontalMovedTRUE | never evaluated | FALSE | never evaluated |
))) { | 0 |
1738 | for (int i = 0; i <const auto &range : selection.count(); ++i) { | - |
1739 | QItemSelectionRange range = selection.at(i);if (range.parent() != d->rootTRUE | never evaluated | FALSE | never evaluated |
|| !range.isValid()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1740 | continue; never executed: continue; | 0 |
1741 | for (int r = range.top(); r <= range.bottom()TRUE | never evaluated | FALSE | never evaluated |
; ++r) | 0 |
1742 | for (int c = range.left(); c <= range.right()TRUE | never evaluated | FALSE | never evaluated |
; ++c) { | 0 |
1743 | const QRect &rangeRect = visualRect(d->model->index(r, c, d->root)); | - |
1744 | if (viewportRect.intersects(rangeRect)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1745 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 |
1746 | } never executed: end of block | 0 |
1747 | } never executed: end of block | 0 |
1748 | } never executed: end of block else if (horizontalMovedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1749 | for (int i = 0; i <const auto &range : selection.count(); ++i) { | - |
1750 | QItemSelectionRange range = selection.at(i);if (range.parent() != d->rootTRUE | never evaluated | FALSE | never evaluated |
|| !range.isValid()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1751 | continue; never executed: continue; | 0 |
1752 | int top = rowViewportPosition(range.top()); | - |
1753 | int bottom = rowViewportPosition(range.bottom()) + rowHeight(range.bottom()); | - |
1754 | if (top > bottomTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1755 | qSwap<int>(top, bottom); never executed: qSwap<int>(top, bottom); | 0 |
1756 | int height = bottom - top; | - |
1757 | for (int c = range.left(); c <= range.right()TRUE | never evaluated | FALSE | never evaluated |
; ++c) { | 0 |
1758 | const QRect rangeRect(columnViewportPosition(c), top, columnWidth(c), height); | - |
1759 | if (viewportRect.intersects(rangeRect)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1760 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 |
1761 | } never executed: end of block | 0 |
1762 | } never executed: end of block | 0 |
1763 | } never executed: end of block else if (verticalMovedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1764 | for (int i = 0; i <const auto &range : selection.count(); ++i) { | - |
1765 | QItemSelectionRange range = selection.at(i);if (range.parent() != d->rootTRUE | never evaluated | FALSE | never evaluated |
|| !range.isValid()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1766 | continue; never executed: continue; | 0 |
1767 | int left = columnViewportPosition(range.left()); | - |
1768 | int right = columnViewportPosition(range.right()) + columnWidth(range.right()); | - |
1769 | if (left > rightTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1770 | qSwap<int>(left, right); never executed: qSwap<int>(left, right); | 0 |
1771 | int width = right - left; | - |
1772 | for (int r = range.top(); r <= range.bottom()TRUE | never evaluated | FALSE | never evaluated |
; ++r) { | 0 |
1773 | const QRect rangeRect(left, rowViewportPosition(r), width, rowHeight(r)); | - |
1774 | if (viewportRect.intersects(rangeRect)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1775 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 |
1776 | } never executed: end of block | 0 |
1777 | } never executed: end of block | 0 |
1778 | } never executed: end of block else { | 0 |
1779 | const int gridAdjust = showGrid()TRUE | never evaluated | FALSE | never evaluated |
? 1 : 0; | 0 |
1780 | for (int i = 0; i <auto range : selection.count(); ++i) { | - |
1781 | QItemSelectionRange range = selection.at(i);if (range.parent() != d->rootTRUE | never evaluated | FALSE | never evaluated |
|| !range.isValid()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1782 | continue; never executed: continue; | 0 |
1783 | d->trimHiddenSelections(&range); | - |
1784 | | - |
1785 | const int rtop = rowViewportPosition(range.top()); | - |
1786 | const int rbottom = rowViewportPosition(range.bottom()) + rowHeight(range.bottom()); | - |
1787 | int rleft; | - |
1788 | int rright; | - |
1789 | if (isLeftToRight()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1790 | rleft = columnViewportPosition(range.left()); | - |
1791 | rright = columnViewportPosition(range.right()) + columnWidth(range.right()); | - |
1792 | } never executed: end of block else { | 0 |
1793 | rleft = columnViewportPosition(range.right()); | - |
1794 | rright = columnViewportPosition(range.left()) + columnWidth(range.left()); | - |
1795 | } never executed: end of block | 0 |
1796 | const QRect rangeRect(QPoint(rleft, rtop), QPoint(rright - 1 - gridAdjust, rbottom - 1 - gridAdjust)); | - |
1797 | if (viewportRect.intersects(rangeRect)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1798 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 |
1799 | if (d->hasSpans()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1800 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->spans.const auto spansInRect (range.left(), range.top(), range.width(), range.height()))>::type> _container_((= d->spans.spansInRect(range.left(), range.top(), range.width(), range.height()))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)()); | - |
1801 | for (QSpanCollection::Span *s = *_container_.i; _container_.control; _container_.control = 0: spansInRect) { | - |
1802 | if (range.contains(s->top(), s->left(), range.parent())TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1803 | const QRect &visualSpanRect = d->visualSpanRect(*s); | - |
1804 | if (viewportRect.intersects(visualSpanRect)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1805 | selectionRegion += visualSpanRect; never executed: selectionRegion += visualSpanRect; | 0 |
1806 | } never executed: end of block | 0 |
1807 | } never executed: end of block | 0 |
1808 | } never executed: end of block | 0 |
1809 | } never executed: end of block | 0 |
1810 | } never executed: end of block | 0 |
1811 | | - |
1812 | return never executed: return selectionRegion; selectionRegion;never executed: return selectionRegion; | 0 |
1813 | } | - |
1814 | | - |
1815 | | - |
1816 | | - |
1817 | | - |
1818 | | - |
1819 | QModelIndexList QTableView::selectedIndexes() const | - |
1820 | { | - |
1821 | const QTableViewPrivate * const d = d_func(); | - |
1822 | QModelIndexList viewSelected; | - |
1823 | QModelIndexList modelSelected; | - |
1824 | if (d->selectionModel) | - |
1825 | modelSelected = d->selectionModel->selectedIndexes(); | - |
1826 | for (int i = 0; i < modelSelected.count(); ++i) { | - |
1827 | QModelIndex index = modelSelected.at(i); | - |
1828 | if (!isIndexHidden(index) && index.parent() == d->root) | - |
1829 | viewSelected.append(index); | - |
1830 | } | - |
1831 | return viewSelected; | - |
1832 | } | - |
1833 | | - |
1834 | | - |
1835 | | - |
1836 | | - |
1837 | | - |
1838 | | - |
1839 | | - |
1840 | void QTableView::rowCountChanged(int oldCount, int newCount ) | - |
1841 | { | - |
1842 | QTableViewPrivate * const d = d_func(); | - |
1843 | | - |
1844 | | - |
1845 | if (newCount < oldCount) | - |
1846 | d->verticalHeader->setUpdatesEnabled(false); | - |
1847 | d->doDelayedItemsLayout(); | - |
1848 | } | - |
1849 | | - |
1850 | | - |
1851 | | - |
1852 | | - |
1853 | | - |
1854 | | - |
1855 | void QTableView::columnCountChanged(int, int) | - |
1856 | { | - |
1857 | QTableViewPrivate * const d = d_func(); | - |
1858 | updateGeometries(); | - |
1859 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) | - |
1860 | d->horizontalHeader->setOffsetToSectionPosition(horizontalScrollBar()->value()); | - |
1861 | else | - |
1862 | d->horizontalHeader->setOffset(horizontalScrollBar()->value()); | - |
1863 | d->viewport->update(); | - |
1864 | } | - |
1865 | | - |
1866 | | - |
1867 | | - |
1868 | | - |
1869 | void QTableView::updateGeometries() | - |
1870 | { | - |
1871 | QTableViewPrivate * const d = d_func(); | - |
1872 | if (d->geometryRecursionBlockTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1873 | return; never executed: return; | 0 |
1874 | d->geometryRecursionBlock = true; | - |
1875 | | - |
1876 | int width = 0; | - |
1877 | if (!d->verticalHeader->isHidden()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1878 | width = qMax(d->verticalHeader->minimumWidth(), d->verticalHeader->sizeHint().width()); | - |
1879 | width = qMin(width, d->verticalHeader->maximumWidth()); | - |
1880 | } never executed: end of block | 0 |
1881 | int height = 0; | - |
1882 | if (!d->horizontalHeader->isHidden()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1883 | height = qMax(d->horizontalHeader->minimumHeight(), d->horizontalHeader->sizeHint().height()); | - |
1884 | height = qMin(height, d->horizontalHeader->maximumHeight()); | - |
1885 | } never executed: end of block | 0 |
1886 | bool reverse = isRightToLeft(); | - |
1887 | if (reverseTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1888 | setViewportMargins(0, height, width, 0); never executed: setViewportMargins(0, height, width, 0); | 0 |
1889 | else | - |
1890 | setViewportMargins(width, height, 0, 0); never executed: setViewportMargins(width, height, 0, 0); | 0 |
1891 | | - |
1892 | | - |
1893 | | - |
1894 | QRect vg = d->viewport->geometry(); | - |
1895 | | - |
1896 | int verticalLeft = reverseTRUE | never evaluated | FALSE | never evaluated |
? vg.right() + 1 : (vg.left() - width); | 0 |
1897 | d->verticalHeader->setGeometry(verticalLeft, vg.top(), width, vg.height()); | - |
1898 | if (d->verticalHeader->isHidden()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1899 | QMetaObject::invokeMethod(d->verticalHeader, "updateGeometries"); never executed: QMetaObject::invokeMethod(d->verticalHeader, "updateGeometries"); | 0 |
1900 | | - |
1901 | int horizontalTop = vg.top() - height; | - |
1902 | d->horizontalHeader->setGeometry(vg.left(), horizontalTop, vg.width(), height); | - |
1903 | if (d->horizontalHeader->isHidden()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1904 | QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries"); never executed: QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries"); | 0 |
1905 | | - |
1906 | | - |
1907 | if (d->horizontalHeader->isHidden()TRUE | never evaluated | FALSE | never evaluated |
|| d->verticalHeader->isHidden()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1908 | d->cornerWidget->setHidden(true); | - |
1909 | } never executed: end of block else { | 0 |
1910 | d->cornerWidget->setHidden(false); | - |
1911 | d->cornerWidget->setGeometry(verticalLeft, horizontalTop, width, height); | - |
1912 | } never executed: end of block | 0 |
1913 | | - |
1914 | | - |
1915 | | - |
1916 | | - |
1917 | QSize vsize = d->viewport->size(); | - |
1918 | QSize max = maximumViewportSize(); | - |
1919 | uint horizontalLength = d->horizontalHeader->length(); | - |
1920 | uint verticalLength = d->verticalHeader->length(); | - |
1921 | if ((TRUE | never evaluated | FALSE | never evaluated |
uint)max.width() >= horizontalLengthTRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
uint)max.height() >= verticalLengthTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1922 | vsize = max; never executed: vsize = max; | 0 |
1923 | | - |
1924 | | - |
1925 | const int columnCount = d->horizontalHeader->count(); | - |
1926 | const int viewportWidth = vsize.width(); | - |
1927 | int columnsInViewport = 0; | - |
1928 | for (int width = 0, column = columnCount - 1; column >= 0TRUE | never evaluated | FALSE | never evaluated |
; --column) { | 0 |
1929 | int logical = d->horizontalHeader->logicalIndex(column); | - |
1930 | if (!d->horizontalHeader->isSectionHidden(logical)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1931 | width += d->horizontalHeader->sectionSize(logical); | - |
1932 | if (width > viewportWidthTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1933 | break; never executed: break; | 0 |
1934 | ++columnsInViewport; | - |
1935 | } never executed: end of block | 0 |
1936 | } never executed: end of block | 0 |
1937 | columnsInViewport = qMax(columnsInViewport, 1); | - |
1938 | | - |
1939 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItemTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1940 | const int visibleColumns = columnCount - d->horizontalHeader->hiddenSectionCount(); | - |
1941 | horizontalScrollBar()->setRange(0, visibleColumns - columnsInViewport); | - |
1942 | horizontalScrollBar()->setPageStep(columnsInViewport); | - |
1943 | if (columnsInViewport >= visibleColumnsTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1944 | d->horizontalHeader->setOffset(0); never executed: d->horizontalHeader->setOffset(0); | 0 |
1945 | horizontalScrollBar()->setSingleStep(1); | - |
1946 | } never executed: end of block else { | 0 |
1947 | horizontalScrollBar()->setPageStep(vsize.width()); | - |
1948 | horizontalScrollBar()->setRange(0, horizontalLength - vsize.width()); | - |
1949 | horizontalScrollBar()->setSingleStepd_func()->itemviewChangeSingleStep(qMax(vsize.width() / (columnsInViewport + 1), 2)); | - |
1950 | } never executed: end of block | 0 |
1951 | | - |
1952 | | - |
1953 | const int rowCount = d->verticalHeader->count(); | - |
1954 | const int viewportHeight = vsize.height(); | - |
1955 | int rowsInViewport = 0; | - |
1956 | for (int height = 0, row = rowCount - 1; row >= 0TRUE | never evaluated | FALSE | never evaluated |
; --row) { | 0 |
1957 | int logical = d->verticalHeader->logicalIndex(row); | - |
1958 | if (!d->verticalHeader->isSectionHidden(logical)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1959 | height += d->verticalHeader->sectionSize(logical); | - |
1960 | if (height > viewportHeightTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1961 | break; never executed: break; | 0 |
1962 | ++rowsInViewport; | - |
1963 | } never executed: end of block | 0 |
1964 | } never executed: end of block | 0 |
1965 | rowsInViewport = qMax(rowsInViewport, 1); | - |
1966 | | - |
1967 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItemTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1968 | const int visibleRows = rowCount - d->verticalHeader->hiddenSectionCount(); | - |
1969 | verticalScrollBar()->setRange(0, visibleRows - rowsInViewport); | - |
1970 | verticalScrollBar()->setPageStep(rowsInViewport); | - |
1971 | if (rowsInViewport >= visibleRowsTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1972 | d->verticalHeader->setOffset(0); never executed: d->verticalHeader->setOffset(0); | 0 |
1973 | verticalScrollBar()->setSingleStep(1); | - |
1974 | } never executed: end of block else { | 0 |
1975 | verticalScrollBar()->setPageStep(vsize.height()); | - |
1976 | verticalScrollBar()->setRange(0, verticalLength - vsize.height()); | - |
1977 | verticalScrollBar()->setSingleStepd_func()->itemviewChangeSingleStep(qMax(vsize.height() / (rowsInViewport + 1), 2)); | - |
1978 | } never executed: end of block | 0 |
1979 | | - |
1980 | d->geometryRecursionBlock = false; | - |
1981 | QAbstractItemView::updateGeometries(); | - |
1982 | } never executed: end of block | 0 |
1983 | int QTableView::sizeHintForRow(int row) const | - |
1984 | { | - |
1985 | const QTableViewPrivate * const d = d_func(); | - |
1986 | | - |
1987 | if (!model()) | - |
1988 | return -1; | - |
1989 | | - |
1990 | ensurePolished(); | - |
1991 | const int maximumProcessCols = d->verticalHeader->resizeContentsPrecision(); | - |
1992 | | - |
1993 | | - |
1994 | int left = qMax(0, d->horizontalHeader->visualIndexAt(0)); | - |
1995 | int right = d->horizontalHeader->visualIndexAt(d->viewport->width()); | - |
1996 | if (right == -1) | - |
1997 | right = d->model->columnCount(d->root) - 1; | - |
1998 | | - |
1999 | QStyleOptionViewItem option = d->viewOptionsV1(); | - |
2000 | | - |
2001 | int hint = 0; | - |
2002 | QModelIndex index; | - |
2003 | int columnsProcessed = 0; | - |
2004 | int column = left; | - |
2005 | for (; column <= right; ++column) { | - |
2006 | int logicalColumn = d->horizontalHeader->logicalIndex(column); | - |
2007 | if (d->horizontalHeader->isSectionHidden(logicalColumn)) | - |
2008 | continue; | - |
2009 | index = d->model->index(row, logicalColumn, d->root); | - |
2010 | hint = d->heightHintForIndex(index, hint, option); | - |
2011 | | - |
2012 | ++columnsProcessed; | - |
2013 | if (columnsProcessed == maximumProcessCols) | - |
2014 | break; | - |
2015 | } | - |
2016 | | - |
2017 | int actualRight = d->model->columnCount(d->root) - 1; | - |
2018 | int idxLeft = left; | - |
2019 | int idxRight = column - 1; | - |
2020 | | - |
2021 | if (maximumProcessCols == 0) | - |
2022 | columnsProcessed = 0; | - |
2023 | | - |
2024 | while (columnsProcessed != maximumProcessCols && (idxLeft > 0 || idxRight < actualRight)) { | - |
2025 | int logicalIdx = -1; | - |
2026 | | - |
2027 | if ((columnsProcessed % 2 && idxLeft > 0) || idxRight == actualRight) { | - |
2028 | while (idxLeft > 0) { | - |
2029 | --idxLeft; | - |
2030 | int logcol = d->horizontalHeader->logicalIndex(idxLeft); | - |
2031 | if (d->horizontalHeader->isSectionHidden(logcol)) | - |
2032 | continue; | - |
2033 | logicalIdx = logcol; | - |
2034 | break; | - |
2035 | } | - |
2036 | } else { | - |
2037 | while (idxRight < actualRight) { | - |
2038 | ++idxRight; | - |
2039 | int logcol = d->horizontalHeader->logicalIndex(idxRight); | - |
2040 | if (d->horizontalHeader->isSectionHidden(logcol)) | - |
2041 | continue; | - |
2042 | logicalIdx = logcol; | - |
2043 | break; | - |
2044 | } | - |
2045 | } | - |
2046 | if (logicalIdx < 0) | - |
2047 | continue; | - |
2048 | | - |
2049 | index = d->model->index(row, logicalIdx, d->root); | - |
2050 | hint = d->heightHintForIndex(index, hint, option); | - |
2051 | ++columnsProcessed; | - |
2052 | } | - |
2053 | | - |
2054 | return d->showGrid ? hint + 1 : hint; | - |
2055 | } | - |
2056 | int QTableView::sizeHintForColumn(int column) const | - |
2057 | { | - |
2058 | const QTableViewPrivate * const d = d_func(); | - |
2059 | | - |
2060 | if (!model()) | - |
2061 | return -1; | - |
2062 | | - |
2063 | ensurePolished(); | - |
2064 | const int maximumProcessRows = d->horizontalHeader->resizeContentsPrecision(); | - |
2065 | | - |
2066 | int top = qMax(0, d->verticalHeader->visualIndexAt(0)); | - |
2067 | int bottom = d->verticalHeader->visualIndexAt(d->viewport->height()); | - |
2068 | if (!isVisible() || bottom == -1) | - |
2069 | bottom = d->model->rowCount(d->root) - 1; | - |
2070 | | - |
2071 | QStyleOptionViewItem option = d->viewOptionsV1(); | - |
2072 | | - |
2073 | int hint = 0; | - |
2074 | int rowsProcessed = 0; | - |
2075 | QModelIndex index; | - |
2076 | int row = top; | - |
2077 | for (; row <= bottom; ++row) { | - |
2078 | int logicalRow = d->verticalHeader->logicalIndex(row); | - |
2079 | if (d->verticalHeader->isSectionHidden(logicalRow)) | - |
2080 | continue; | - |
2081 | index = d->model->index(logicalRow, column, d->root); | - |
2082 | | - |
2083 | hint = d->widthHintForIndex(index, hint, option); | - |
2084 | ++rowsProcessed; | - |
2085 | if (rowsProcessed == maximumProcessRows) | - |
2086 | break; | - |
2087 | } | - |
2088 | | - |
2089 | int actualBottom = d->model->rowCount(d->root) - 1; | - |
2090 | int idxTop = top; | - |
2091 | int idxBottom = row - 1; | - |
2092 | | - |
2093 | if (maximumProcessRows == 0) | - |
2094 | rowsProcessed = 0; | - |
2095 | | - |
2096 | while (rowsProcessed != maximumProcessRows && (idxTop > 0 || idxBottom < actualBottom)) { | - |
2097 | int logicalIdx = -1; | - |
2098 | | - |
2099 | if ((rowsProcessed % 2 && idxTop > 0) || idxBottom == actualBottom) { | - |
2100 | while (idxTop > 0) { | - |
2101 | --idxTop; | - |
2102 | int logrow = d->verticalHeader->logicalIndex(idxTop); | - |
2103 | if (d->verticalHeader->isSectionHidden(logrow)) | - |
2104 | continue; | - |
2105 | logicalIdx = logrow; | - |
2106 | break; | - |
2107 | } | - |
2108 | } else { | - |
2109 | while (idxBottom < actualBottom) { | - |
2110 | ++idxBottom; | - |
2111 | int logrow = d->verticalHeader->logicalIndex(idxBottom); | - |
2112 | if (d->verticalHeader->isSectionHidden(logrow)) | - |
2113 | continue; | - |
2114 | logicalIdx = logrow; | - |
2115 | break; | - |
2116 | } | - |
2117 | } | - |
2118 | if (logicalIdx < 0) | - |
2119 | continue; | - |
2120 | | - |
2121 | index = d->model->index(logicalIdx, column, d->root); | - |
2122 | hint = d->widthHintForIndex(index, hint, option); | - |
2123 | ++rowsProcessed; | - |
2124 | } | - |
2125 | | - |
2126 | return d->showGrid ? hint + 1 : hint; | - |
2127 | } | - |
2128 | | - |
2129 | | - |
2130 | | - |
2131 | | - |
2132 | | - |
2133 | int QTableView::rowViewportPosition(int row) const | - |
2134 | { | - |
2135 | const QTableViewPrivate * const d = d_func(); | - |
2136 | return d->verticalHeader->sectionViewportPosition(row); | - |
2137 | } | - |
2138 | int QTableView::rowAt(int y) const | - |
2139 | { | - |
2140 | const QTableViewPrivate * const d = d_func(); | - |
2141 | return d->verticalHeader->logicalIndexAt(y); | - |
2142 | } | - |
2143 | | - |
2144 | | - |
2145 | | - |
2146 | | - |
2147 | | - |
2148 | | - |
2149 | void QTableView::setRowHeight(int row, int height) | - |
2150 | { | - |
2151 | const QTableViewPrivate * const d = d_func(); | - |
2152 | d->verticalHeader->resizeSection(row, height); | - |
2153 | } | - |
2154 | | - |
2155 | | - |
2156 | | - |
2157 | | - |
2158 | | - |
2159 | | - |
2160 | int QTableView::rowHeight(int row) const | - |
2161 | { | - |
2162 | const QTableViewPrivate * const d = d_func(); | - |
2163 | return d->verticalHeader->sectionSize(row); | - |
2164 | } | - |
2165 | | - |
2166 | | - |
2167 | | - |
2168 | | - |
2169 | | - |
2170 | int QTableView::columnViewportPosition(int column) const | - |
2171 | { | - |
2172 | const QTableViewPrivate * const d = d_func(); | - |
2173 | return d->horizontalHeader->sectionViewportPosition(column); | - |
2174 | } | - |
2175 | int QTableView::columnAt(int x) const | - |
2176 | { | - |
2177 | const QTableViewPrivate * const d = d_func(); | - |
2178 | return d->horizontalHeader->logicalIndexAt(x); | - |
2179 | } | - |
2180 | | - |
2181 | | - |
2182 | | - |
2183 | | - |
2184 | | - |
2185 | | - |
2186 | void QTableView::setColumnWidth(int column, int width) | - |
2187 | { | - |
2188 | const QTableViewPrivate * const d = d_func(); | - |
2189 | d->horizontalHeader->resizeSection(column, width); | - |
2190 | } | - |
2191 | | - |
2192 | | - |
2193 | | - |
2194 | | - |
2195 | | - |
2196 | | - |
2197 | int QTableView::columnWidth(int column) const | - |
2198 | { | - |
2199 | const QTableViewPrivate * const d = d_func(); | - |
2200 | return d->horizontalHeader->sectionSize(column); | - |
2201 | } | - |
2202 | | - |
2203 | | - |
2204 | | - |
2205 | | - |
2206 | | - |
2207 | | - |
2208 | bool QTableView::isRowHidden(int row) const | - |
2209 | { | - |
2210 | const QTableViewPrivate * const d = d_func(); | - |
2211 | return d->verticalHeader->isSectionHidden(row); | - |
2212 | } | - |
2213 | | - |
2214 | | - |
2215 | | - |
2216 | | - |
2217 | | - |
2218 | | - |
2219 | void QTableView::setRowHidden(int row, bool hide) | - |
2220 | { | - |
2221 | QTableViewPrivate * const d = d_func(); | - |
2222 | if (row < 0 || row >= d->verticalHeader->count()) | - |
2223 | return; | - |
2224 | d->verticalHeader->setSectionHidden(row, hide); | - |
2225 | } | - |
2226 | | - |
2227 | | - |
2228 | | - |
2229 | | - |
2230 | | - |
2231 | | - |
2232 | bool QTableView::isColumnHidden(int column) const | - |
2233 | { | - |
2234 | const QTableViewPrivate * const d = d_func(); | - |
2235 | return d->horizontalHeader->isSectionHidden(column); | - |
2236 | } | - |
2237 | | - |
2238 | | - |
2239 | | - |
2240 | | - |
2241 | | - |
2242 | | - |
2243 | | - |
2244 | void QTableView::setColumnHidden(int column, bool hide) | - |
2245 | { | - |
2246 | QTableViewPrivate * const d = d_func(); | - |
2247 | if (column < 0 || column >= d->horizontalHeader->count()) | - |
2248 | return; | - |
2249 | d->horizontalHeader->setSectionHidden(column, hide); | - |
2250 | } | - |
2251 | void QTableView::setSortingEnabled(bool enable) | - |
2252 | { | - |
2253 | QTableViewPrivate * const d = d_func(); | - |
2254 | d->sortingEnabled = enable; | - |
2255 | horizontalHeader()->setSortIndicatorShown(enable); | - |
2256 | if (enable) { | - |
2257 | disconnect(d->horizontalHeader, qFlagLocation("2""sectionEntered(int)" "\0" __FILE__ ":" "2550""2549"), | - |
2258 | this, qFlagLocation("1""_q_selectColumn(int)" "\0" __FILE__ ":" "2551""2550")); | - |
2259 | disconnect(horizontalHeader(), qFlagLocation("2""sectionPressed(int)" "\0" __FILE__ ":" "2552""2551"), | - |
2260 | this, qFlagLocation("1""selectColumn(int)" "\0" __FILE__ ":" "2553""2552")); | - |
2261 | connect(horizontalHeader(), qFlagLocation("2""sortIndicatorChanged(int,Qt::SortOrder)" "\0" __FILE__ ":" "2554""2553"), | - |
2262 | this, qFlagLocation("1""sortByColumn(int)" "\0" __FILE__ ":" "2555""2554"), Qt::UniqueConnection); | - |
2263 | sortByColumn(horizontalHeader()->sortIndicatorSection(), | - |
2264 | horizontalHeader()->sortIndicatorOrder()); | - |
2265 | } else { | - |
2266 | connect(d->horizontalHeader, qFlagLocation("2""sectionEntered(int)" "\0" __FILE__ ":" "2559""2558"), | - |
2267 | this, qFlagLocation("1""_q_selectColumn(int)" "\0" __FILE__ ":" "2560""2559"), Qt::UniqueConnection); | - |
2268 | connect(horizontalHeader(), qFlagLocation("2""sectionPressed(int)" "\0" __FILE__ ":" "2561""2560"), | - |
2269 | this, qFlagLocation("1""selectColumn(int)" "\0" __FILE__ ":" "2562""2561"), Qt::UniqueConnection); | - |
2270 | disconnect(horizontalHeader(), qFlagLocation("2""sortIndicatorChanged(int,Qt::SortOrder)" "\0" __FILE__ ":" "2563""2562"), | - |
2271 | this, qFlagLocation("1""sortByColumn(int)" "\0" __FILE__ ":" "2564""2563")); | - |
2272 | } | - |
2273 | } | - |
2274 | | - |
2275 | bool QTableView::isSortingEnabled() const | - |
2276 | { | - |
2277 | const QTableViewPrivate * const d = d_func(); | - |
2278 | return d->sortingEnabled; | - |
2279 | } | - |
2280 | bool QTableView::showGrid() const | - |
2281 | { | - |
2282 | const QTableViewPrivate * const d = d_func(); | - |
2283 | return d->showGrid; | - |
2284 | } | - |
2285 | | - |
2286 | void QTableView::setShowGrid(bool show) | - |
2287 | { | - |
2288 | QTableViewPrivate * const d = d_func(); | - |
2289 | if (d->showGrid != show) { | - |
2290 | d->showGrid = show; | - |
2291 | d->viewport->update(); | - |
2292 | } | - |
2293 | } | - |
2294 | | - |
2295 | | - |
2296 | | - |
2297 | | - |
2298 | | - |
2299 | | - |
2300 | | - |
2301 | Qt::PenStyle QTableView::gridStyle() const | - |
2302 | { | - |
2303 | const QTableViewPrivate * const d = d_func(); | - |
2304 | return d->gridStyle; | - |
2305 | } | - |
2306 | | - |
2307 | void QTableView::setGridStyle(Qt::PenStyle style) | - |
2308 | { | - |
2309 | QTableViewPrivate * const d = d_func(); | - |
2310 | if (d->gridStyle != style) { | - |
2311 | d->gridStyle = style; | - |
2312 | d->viewport->update(); | - |
2313 | } | - |
2314 | } | - |
2315 | void QTableView::setWordWrap(bool on) | - |
2316 | { | - |
2317 | QTableViewPrivate * const d = d_func(); | - |
2318 | if (d->wrapItemText == on) | - |
2319 | return; | - |
2320 | d->wrapItemText = on; | - |
2321 | QMetaObject::invokeMethod(d->verticalHeader, "resizeSections"); | - |
2322 | QMetaObject::invokeMethod(d->horizontalHeader, "resizeSections"); | - |
2323 | } | - |
2324 | | - |
2325 | bool QTableView::wordWrap() const | - |
2326 | { | - |
2327 | const QTableViewPrivate * const d = d_func(); | - |
2328 | return d->wrapItemText; | - |
2329 | } | - |
2330 | void QTableView::setCornerButtonEnabled(bool enable) | - |
2331 | { | - |
2332 | QTableViewPrivate * const d = d_func(); | - |
2333 | d->cornerWidget->setEnabled(enable); | - |
2334 | } | - |
2335 | | - |
2336 | bool QTableView::isCornerButtonEnabled() const | - |
2337 | { | - |
2338 | const QTableViewPrivate * const d = d_func(); | - |
2339 | return d->cornerWidget->isEnabled(); | - |
2340 | } | - |
2341 | QRect QTableView::visualRect(const QModelIndex &index) const | - |
2342 | { | - |
2343 | const QTableViewPrivate * const d = d_func(); | - |
2344 | if (!d->isIndexValid(index) || index.parent() != d->root | - |
2345 | || (!d->hasSpans() && isIndexHidden(index))) | - |
2346 | return QRect(); | - |
2347 | | - |
2348 | d->executePostedLayout(); | - |
2349 | | - |
2350 | if (d->hasSpans()) { | - |
2351 | QSpanCollection::Span span = d->span(index.row(), index.column()); | - |
2352 | return d->visualSpanRect(span); | - |
2353 | } | - |
2354 | | - |
2355 | int rowp = rowViewportPosition(index.row()); | - |
2356 | int rowh = rowHeight(index.row()); | - |
2357 | int colp = columnViewportPosition(index.column()); | - |
2358 | int colw = columnWidth(index.column()); | - |
2359 | | - |
2360 | const int i = showGrid() ? 1 : 0; | - |
2361 | return QRect(colp, rowp, colw - i, rowh - i); | - |
2362 | } | - |
2363 | | - |
2364 | | - |
2365 | | - |
2366 | | - |
2367 | | - |
2368 | | - |
2369 | | - |
2370 | void QTableView::scrollTo(const QModelIndex &index, ScrollHint hint) | - |
2371 | { | - |
2372 | QTableViewPrivate * const d = d_func(); | - |
2373 | | - |
2374 | | - |
2375 | if (!d->isIndexValid(index) | - |
2376 | || (d->model->parent(index) != d->root) | - |
2377 | || isRowHidden(index.row()) || isColumnHidden(index.column())) | - |
2378 | return; | - |
2379 | | - |
2380 | QSpanCollection::Span span; | - |
2381 | if (d->hasSpans()) | - |
2382 | span = d->span(index.row(), index.column()); | - |
2383 | | - |
2384 | | - |
2385 | | - |
2386 | int viewportWidth = d->viewport->width(); | - |
2387 | int horizontalOffset = d->horizontalHeader->offset(); | - |
2388 | int horizontalPosition = d->horizontalHeader->sectionPosition(index.column()); | - |
2389 | int horizontalIndex = d->horizontalHeader->visualIndex(index.column()); | - |
2390 | int cellWidth = d->hasSpans() | - |
2391 | ? d->columnSpanWidth(index.column(), span.width()) | - |
2392 | : d->horizontalHeader->sectionSize(index.column()); | - |
2393 | | - |
2394 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) { | - |
2395 | | - |
2396 | bool positionAtLeft = (horizontalPosition - horizontalOffset < 0); | - |
2397 | bool positionAtRight = (horizontalPosition - horizontalOffset + cellWidth > viewportWidth); | - |
2398 | | - |
2399 | if (hint == PositionAtCenter || positionAtRight) { | - |
2400 | int w = (hint == PositionAtCenter ? viewportWidth / 2 : viewportWidth); | - |
2401 | int x = cellWidth; | - |
2402 | while (horizontalIndex > 0) { | - |
2403 | x += columnWidth(d->horizontalHeader->logicalIndex(horizontalIndex-1)); | - |
2404 | if (x > w) | - |
2405 | break; | - |
2406 | --horizontalIndex; | - |
2407 | } | - |
2408 | } | - |
2409 | | - |
2410 | if (positionAtRight || hint == PositionAtCenter || positionAtLeft) { | - |
2411 | int hiddenSections = 0; | - |
2412 | if (d->horizontalHeader->sectionsHidden()) { | - |
2413 | for (int s = horizontalIndex - 1; s >= 0; --s) { | - |
2414 | int column = d->horizontalHeader->logicalIndex(s); | - |
2415 | if (d->horizontalHeader->isSectionHidden(column)) | - |
2416 | ++hiddenSections; | - |
2417 | } | - |
2418 | } | - |
2419 | horizontalScrollBar()->setValue(horizontalIndex - hiddenSections); | - |
2420 | } | - |
2421 | | - |
2422 | } else { | - |
2423 | if (hint == PositionAtCenter) { | - |
2424 | horizontalScrollBar()->setValue(horizontalPosition - ((viewportWidth - cellWidth) / 2)); | - |
2425 | } else { | - |
2426 | if (horizontalPosition - horizontalOffset < 0 || cellWidth > viewportWidth) | - |
2427 | horizontalScrollBar()->setValue(horizontalPosition); | - |
2428 | else if (horizontalPosition - horizontalOffset + cellWidth > viewportWidth) | - |
2429 | horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth); | - |
2430 | } | - |
2431 | } | - |
2432 | | - |
2433 | | - |
2434 | | - |
2435 | int viewportHeight = d->viewport->height(); | - |
2436 | int verticalOffset = d->verticalHeader->offset(); | - |
2437 | int verticalPosition = d->verticalHeader->sectionPosition(index.row()); | - |
2438 | int verticalIndex = d->verticalHeader->visualIndex(index.row()); | - |
2439 | int cellHeight = d->hasSpans() | - |
2440 | ? d->rowSpanHeight(index.row(), span.height()) | - |
2441 | : d->verticalHeader->sectionSize(index.row()); | - |
2442 | | - |
2443 | if (verticalPosition - verticalOffset < 0 || cellHeight > viewportHeight) { | - |
2444 | if (hint == EnsureVisible) | - |
2445 | hint = PositionAtTop; | - |
2446 | } else if (verticalPosition - verticalOffset + cellHeight > viewportHeight) { | - |
2447 | if (hint == EnsureVisible) | - |
2448 | hint = PositionAtBottom; | - |
2449 | } | - |
2450 | | - |
2451 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) { | - |
2452 | | - |
2453 | if (hint == PositionAtBottom || hint == PositionAtCenter) { | - |
2454 | int h = (hint == PositionAtCenter ? viewportHeight / 2 : viewportHeight); | - |
2455 | int y = cellHeight; | - |
2456 | while (verticalIndex > 0) { | - |
2457 | int row = d->verticalHeader->logicalIndex(verticalIndex - 1); | - |
2458 | y += d->verticalHeader->sectionSize(row); | - |
2459 | if (y > h) | - |
2460 | break; | - |
2461 | --verticalIndex; | - |
2462 | } | - |
2463 | } | - |
2464 | | - |
2465 | if (hint == PositionAtBottom || hint == PositionAtCenter || hint == PositionAtTop) { | - |
2466 | int hiddenSections = 0; | - |
2467 | if (d->verticalHeader->sectionsHidden()) { | - |
2468 | for (int s = verticalIndex - 1; s >= 0; --s) { | - |
2469 | int row = d->verticalHeader->logicalIndex(s); | - |
2470 | if (d->verticalHeader->isSectionHidden(row)) | - |
2471 | ++hiddenSections; | - |
2472 | } | - |
2473 | } | - |
2474 | verticalScrollBar()->setValue(verticalIndex - hiddenSections); | - |
2475 | } | - |
2476 | | - |
2477 | } else { | - |
2478 | if (hint == PositionAtTop) { | - |
2479 | verticalScrollBar()->setValue(verticalPosition); | - |
2480 | } else if (hint == PositionAtBottom) { | - |
2481 | verticalScrollBar()->setValue(verticalPosition - viewportHeight + cellHeight); | - |
2482 | } else if (hint == PositionAtCenter) { | - |
2483 | verticalScrollBar()->setValue(verticalPosition - ((viewportHeight - cellHeight) / 2)); | - |
2484 | } | - |
2485 | } | - |
2486 | | - |
2487 | update(index); | - |
2488 | } | - |
2489 | void QTableView::rowResized(int row, int, int) | - |
2490 | { | - |
2491 | QTableViewPrivate * const d = d_func(); | - |
2492 | d->rowsToUpdate.append(row); | - |
2493 | if (d->rowResizeTimerID == 0) | - |
2494 | d->rowResizeTimerID = startTimer(0); | - |
2495 | } | - |
2496 | void QTableView::columnResized(int column, int, int) | - |
2497 | { | - |
2498 | QTableViewPrivate * const d = d_func(); | - |
2499 | d->columnsToUpdate.append(column); | - |
2500 | if (d->columnResizeTimerID == 0) | - |
2501 | d->columnResizeTimerID = startTimer(0); | - |
2502 | } | - |
2503 | | - |
2504 | | - |
2505 | | - |
2506 | | - |
2507 | void QTableView::timerEvent(QTimerEvent *event) | - |
2508 | { | - |
2509 | QTableViewPrivate * const d = d_func(); | - |
2510 | | - |
2511 | if (event->timerId() == d->columnResizeTimerID) { | - |
2512 | updateGeometries(); | - |
2513 | killTimer(d->columnResizeTimerID); | - |
2514 | d->columnResizeTimerID = 0; | - |
2515 | | - |
2516 | QRect rect; | - |
2517 | int viewportHeight = d->viewport->height(); | - |
2518 | int viewportWidth = d->viewport->width(); | - |
2519 | if (d->hasSpans()) { | - |
2520 | rect = QRect(0, 0, viewportWidth, viewportHeight); | - |
2521 | } else { | - |
2522 | for (int i = d->columnsToUpdate.size()-1; i >= 0; --i) { | - |
2523 | int column = d->columnsToUpdate.at(i); | - |
2524 | int x = columnViewportPosition(column); | - |
2525 | if (isRightToLeft()) | - |
2526 | rect |= QRect(0, 0, x + columnWidth(column), viewportHeight); | - |
2527 | else | - |
2528 | rect |= QRect(x, 0, viewportWidth - x, viewportHeight); | - |
2529 | } | - |
2530 | } | - |
2531 | | - |
2532 | d->viewport->update(rect.normalized()); | - |
2533 | d->columnsToUpdate.clear(); | - |
2534 | } | - |
2535 | | - |
2536 | if (event->timerId() == d->rowResizeTimerID) { | - |
2537 | updateGeometries(); | - |
2538 | killTimer(d->rowResizeTimerID); | - |
2539 | d->rowResizeTimerID = 0; | - |
2540 | | - |
2541 | int viewportHeight = d->viewport->height(); | - |
2542 | int viewportWidth = d->viewport->width(); | - |
2543 | int top; | - |
2544 | if (d->hasSpans()) { | - |
2545 | top = 0; | - |
2546 | } else { | - |
2547 | top = viewportHeight; | - |
2548 | for (int i = d->rowsToUpdate.size()-1; i >= 0; --i) { | - |
2549 | int y = rowViewportPosition(d->rowsToUpdate.at(i)); | - |
2550 | top = qMin(top, y); | - |
2551 | } | - |
2552 | } | - |
2553 | | - |
2554 | d->viewport->update(QRect(0, top, viewportWidth, viewportHeight - top)); | - |
2555 | d->rowsToUpdate.clear(); | - |
2556 | } | - |
2557 | | - |
2558 | QAbstractItemView::timerEvent(event); | - |
2559 | } | - |
2560 | void QTableView::rowMoved(int, int oldIndex, int newIndex) | - |
2561 | { | - |
2562 | QTableViewPrivate * const d = d_func(); | - |
2563 | | - |
2564 | updateGeometries(); | - |
2565 | int logicalOldIndex = d->verticalHeader->logicalIndex(oldIndex); | - |
2566 | int logicalNewIndex = d->verticalHeader->logicalIndex(newIndex); | - |
2567 | if (d->hasSpans()) { | - |
2568 | d->viewport->update(); | - |
2569 | } else { | - |
2570 | int oldTop = rowViewportPosition(logicalOldIndex); | - |
2571 | int newTop = rowViewportPosition(logicalNewIndex); | - |
2572 | int oldBottom = oldTop + rowHeight(logicalOldIndex); | - |
2573 | int newBottom = newTop + rowHeight(logicalNewIndex); | - |
2574 | int top = qMin(oldTop, newTop); | - |
2575 | int bottom = qMax(oldBottom, newBottom); | - |
2576 | int height = bottom - top; | - |
2577 | d->viewport->update(0, top, d->viewport->width(), height); | - |
2578 | } | - |
2579 | } | - |
2580 | void QTableView::columnMoved(int, int oldIndex, int newIndex) | - |
2581 | { | - |
2582 | QTableViewPrivate * const d = d_func(); | - |
2583 | | - |
2584 | updateGeometries(); | - |
2585 | int logicalOldIndex = d->horizontalHeader->logicalIndex(oldIndex); | - |
2586 | int logicalNewIndex = d->horizontalHeader->logicalIndex(newIndex); | - |
2587 | if (d->hasSpans()) { | - |
2588 | d->viewport->update(); | - |
2589 | } else { | - |
2590 | int oldLeft = columnViewportPosition(logicalOldIndex); | - |
2591 | int newLeft = columnViewportPosition(logicalNewIndex); | - |
2592 | int oldRight = oldLeft + columnWidth(logicalOldIndex); | - |
2593 | int newRight = newLeft + columnWidth(logicalNewIndex); | - |
2594 | int left = qMin(oldLeft, newLeft); | - |
2595 | int right = qMax(oldRight, newRight); | - |
2596 | int width = right - left; | - |
2597 | d->viewport->update(left, 0, width, d->viewport->height()); | - |
2598 | } | - |
2599 | } | - |
2600 | | - |
2601 | | - |
2602 | | - |
2603 | | - |
2604 | | - |
2605 | | - |
2606 | | - |
2607 | void QTableView::selectRow(int row) | - |
2608 | { | - |
2609 | QTableViewPrivate * const d = d_func(); | - |
2610 | d->selectRow(row, true); | - |
2611 | } | - |
2612 | | - |
2613 | | - |
2614 | | - |
2615 | | - |
2616 | | - |
2617 | | - |
2618 | | - |
2619 | void QTableView::selectColumn(int column) | - |
2620 | { | - |
2621 | QTableViewPrivate * const d = d_func(); | - |
2622 | d->selectColumn(column, true); | - |
2623 | } | - |
2624 | | - |
2625 | | - |
2626 | | - |
2627 | | - |
2628 | | - |
2629 | | - |
2630 | void QTableView::hideRow(int row) | - |
2631 | { | - |
2632 | QTableViewPrivate * const d = d_func(); | - |
2633 | d->verticalHeader->hideSection(row); | - |
2634 | } | - |
2635 | | - |
2636 | | - |
2637 | | - |
2638 | | - |
2639 | | - |
2640 | | - |
2641 | void QTableView::hideColumn(int column) | - |
2642 | { | - |
2643 | QTableViewPrivate * const d = d_func(); | - |
2644 | d->horizontalHeader->hideSection(column); | - |
2645 | } | - |
2646 | | - |
2647 | | - |
2648 | | - |
2649 | | - |
2650 | | - |
2651 | | - |
2652 | void QTableView::showRow(int row) | - |
2653 | { | - |
2654 | QTableViewPrivate * const d = d_func(); | - |
2655 | d->verticalHeader->showSection(row); | - |
2656 | } | - |
2657 | | - |
2658 | | - |
2659 | | - |
2660 | | - |
2661 | | - |
2662 | | - |
2663 | void QTableView::showColumn(int column) | - |
2664 | { | - |
2665 | QTableViewPrivate * const d = d_func(); | - |
2666 | d->horizontalHeader->showSection(column); | - |
2667 | } | - |
2668 | | - |
2669 | | - |
2670 | | - |
2671 | | - |
2672 | | - |
2673 | | - |
2674 | | - |
2675 | void QTableView::resizeRowToContents(int row) | - |
2676 | { | - |
2677 | QTableViewPrivate * const d = d_func(); | - |
2678 | int content = sizeHintForRow(row); | - |
2679 | int header = d->verticalHeader->sectionSizeHint(row); | - |
2680 | d->verticalHeader->resizeSection(row, qMax(content, header)); | - |
2681 | } | - |
2682 | | - |
2683 | | - |
2684 | | - |
2685 | | - |
2686 | | - |
2687 | | - |
2688 | | - |
2689 | void QTableView::resizeRowsToContents() | - |
2690 | { | - |
2691 | QTableViewPrivate * const d = d_func(); | - |
2692 | d->verticalHeader->resizeSections(QHeaderView::ResizeToContents); | - |
2693 | } | - |
2694 | void QTableView::resizeColumnToContents(int column) | - |
2695 | { | - |
2696 | QTableViewPrivate * const d = d_func(); | - |
2697 | int content = sizeHintForColumn(column); | - |
2698 | int header = d->horizontalHeader->sectionSizeHint(column); | - |
2699 | d->horizontalHeader->resizeSection(column, qMax(content, header)); | - |
2700 | } | - |
2701 | | - |
2702 | | - |
2703 | | - |
2704 | | - |
2705 | | - |
2706 | | - |
2707 | | - |
2708 | void QTableView::resizeColumnsToContents() | - |
2709 | { | - |
2710 | QTableViewPrivate * const d = d_func(); | - |
2711 | d->horizontalHeader->resizeSections(QHeaderView::ResizeToContents); | - |
2712 | } | - |
2713 | | - |
2714 | | - |
2715 | | - |
2716 | | - |
2717 | | - |
2718 | | - |
2719 | | - |
2720 | void QTableView::sortByColumn(int column) | - |
2721 | { | - |
2722 | QTableViewPrivate * const d = d_func(); | - |
2723 | if (column == -1) | - |
2724 | return; | - |
2725 | d->model->sort(column, d->horizontalHeader->sortIndicatorOrder()); | - |
2726 | } | - |
2727 | void QTableView::sortByColumn(int column, Qt::SortOrder order) | - |
2728 | { | - |
2729 | QTableViewPrivate * const d = d_func(); | - |
2730 | d->horizontalHeader->setSortIndicator(column, order); | - |
2731 | sortByColumn(column); | - |
2732 | } | - |
2733 | | - |
2734 | | - |
2735 | | - |
2736 | | - |
2737 | void QTableView::verticalScrollbarAction(int action) | - |
2738 | { | - |
2739 | QAbstractItemView::verticalScrollbarAction(action); | - |
2740 | } | - |
2741 | | - |
2742 | | - |
2743 | | - |
2744 | | - |
2745 | void QTableView::horizontalScrollbarAction(int action) | - |
2746 | { | - |
2747 | QAbstractItemView::horizontalScrollbarAction(action); | - |
2748 | } | - |
2749 | | - |
2750 | | - |
2751 | | - |
2752 | | - |
2753 | bool QTableView::isIndexHidden(const QModelIndex &index) const | - |
2754 | { | - |
2755 | const QTableViewPrivate * const d = d_func(); | - |
2756 | ((!(d->isIndexValid(index))) ? qt_assert("d->isIndexValid(index)",__FILE__,31423141) : qt_noop()); | - |
2757 | if (isRowHidden(index.row()) || isColumnHidden(index.column())) | - |
2758 | return true; | - |
2759 | if (d->hasSpans()) { | - |
2760 | QSpanCollection::Span span = d->span(index.row(), index.column()); | - |
2761 | return !((span.top() == index.row()) && (span.left() == index.column())); | - |
2762 | } | - |
2763 | return false; | - |
2764 | } | - |
2765 | void QTableView::setSpan(int row, int column, int rowSpan, int columnSpan) | - |
2766 | { | - |
2767 | QTableViewPrivate * const d = d_func(); | - |
2768 | if (row < 0 || column < 0 || rowSpan < 0 || columnSpan < 0) | - |
2769 | return; | - |
2770 | d->setSpan(row, column, rowSpan, columnSpan); | - |
2771 | d->viewport->update(); | - |
2772 | } | - |
2773 | int QTableView::rowSpan(int row, int column) const | - |
2774 | { | - |
2775 | const QTableViewPrivate * const d = d_func(); | - |
2776 | return d->rowSpan(row, column); | - |
2777 | } | - |
2778 | int QTableView::columnSpan(int row, int column) const | - |
2779 | { | - |
2780 | const QTableViewPrivate * const d = d_func(); | - |
2781 | return d->columnSpan(row, column); | - |
2782 | } | - |
2783 | void QTableView::clearSpans() | - |
2784 | { | - |
2785 | QTableViewPrivate * const d = d_func(); | - |
2786 | d->spans.clear(); | - |
2787 | d->viewport->update(); | - |
2788 | } | - |
2789 | | - |
2790 | void QTableViewPrivate::_q_selectRow(int row) | - |
2791 | { | - |
2792 | selectRow(row, false); | - |
2793 | } | - |
2794 | | - |
2795 | void QTableViewPrivate::_q_selectColumn(int column) | - |
2796 | { | - |
2797 | selectColumn(column, false); | - |
2798 | } | - |
2799 | | - |
2800 | void QTableViewPrivate::selectRow(int row, bool anchor) | - |
2801 | { | - |
2802 | QTableView * const q = q_func(); | - |
2803 | | - |
2804 | if (q->selectionBehavior() == QTableView::SelectColumns | - |
2805 | || (q->selectionMode() == QTableView::SingleSelection | - |
2806 | && q->selectionBehavior() == QTableView::SelectItems)) | - |
2807 | return; | - |
2808 | | - |
2809 | if (row >= 0 && row < model->rowCount(root)) { | - |
2810 | int column = horizontalHeader->logicalIndexAt(q->isRightToLeft() ? viewport->width() : 0); | - |
2811 | QModelIndex index = model->index(row, column, root); | - |
2812 | QItemSelectionModel::SelectionFlags command = q->selectionCommand(index); | - |
2813 | selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | - |
2814 | if ((anchor && !(command & QItemSelectionModel::Current)) | - |
2815 | || (q->selectionMode() == QTableView::SingleSelection)) | - |
2816 | rowSectionAnchor = row; | - |
2817 | | - |
2818 | if (q->selectionMode() != QTableView::SingleSelection | - |
2819 | && command.testFlag(QItemSelectionModel::Toggle)) { | - |
2820 | if (anchor) | - |
2821 | ctrlDragSelectionFlag = verticalHeader->selectionModel()->selectedRows().contains(index) | - |
2822 | ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; | - |
2823 | command &= ~QItemSelectionModel::Toggle; | - |
2824 | command |= ctrlDragSelectionFlag; | - |
2825 | if (!anchor) | - |
2826 | command |= QItemSelectionModel::Current; | - |
2827 | } | - |
2828 | | - |
2829 | QModelIndex upper = model->index(qMin(rowSectionAnchor, row), column, root); | - |
2830 | QModelIndex lower = model->index(qMax(rowSectionAnchor, row), column, root); | - |
2831 | if ((verticalHeader->sectionsMoved() && upper.row() != lower.row())) { | - |
2832 | q->setSelection(q->visualRect(upper) | q->visualRect(lower), command | QItemSelectionModel::Rows); | - |
2833 | } else { | - |
2834 | selectionModel->select(QItemSelection(upper, lower), command | QItemSelectionModel::Rows); | - |
2835 | } | - |
2836 | } | - |
2837 | } | - |
2838 | | - |
2839 | void QTableViewPrivate::selectColumn(int column, bool anchor) | - |
2840 | { | - |
2841 | QTableView * const q = q_func(); | - |
2842 | | - |
2843 | if (q->selectionBehavior() == QTableView::SelectRows | - |
2844 | || (q->selectionMode() == QTableView::SingleSelection | - |
2845 | && q->selectionBehavior() == QTableView::SelectItems)) | - |
2846 | return; | - |
2847 | | - |
2848 | if (column >= 0 && column < model->columnCount(root)) { | - |
2849 | int row = verticalHeader->logicalIndexAt(0); | - |
2850 | QModelIndex index = model->index(row, column, root); | - |
2851 | QItemSelectionModel::SelectionFlags command = q->selectionCommand(index); | - |
2852 | selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | - |
2853 | if ((anchor && !(command & QItemSelectionModel::Current)) | - |
2854 | || (q->selectionMode() == QTableView::SingleSelection)) | - |
2855 | columnSectionAnchor = column; | - |
2856 | | - |
2857 | if (q->selectionMode() != QTableView::SingleSelection | - |
2858 | && command.testFlag(QItemSelectionModel::Toggle)) { | - |
2859 | if (anchor) | - |
2860 | ctrlDragSelectionFlag = horizontalHeader->selectionModel()->selectedColumns().contains(index) | - |
2861 | ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; | - |
2862 | command &= ~QItemSelectionModel::Toggle; | - |
2863 | command |= ctrlDragSelectionFlag; | - |
2864 | if (!anchor) | - |
2865 | command |= QItemSelectionModel::Current; | - |
2866 | } | - |
2867 | | - |
2868 | QModelIndex left = model->index(row, qMin(columnSectionAnchor, column), root); | - |
2869 | QModelIndex right = model->index(row, qMax(columnSectionAnchor, column), root); | - |
2870 | if ((horizontalHeader->sectionsMoved() && left.column() != right.column())) { | - |
2871 | q->setSelection(q->visualRect(left) | q->visualRect(right), command | QItemSelectionModel::Columns); | - |
2872 | } else { | - |
2873 | selectionModel->select(QItemSelection(left, right), command | QItemSelectionModel::Columns); | - |
2874 | } | - |
2875 | } | - |
2876 | } | - |
2877 | | - |
2878 | | - |
2879 | | - |
2880 | | - |
2881 | void QTableView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | - |
2882 | { | - |
2883 | | - |
2884 | if (QAccessible::isActive()) { | - |
2885 | if (current.isValid()) { | - |
2886 | QTableViewPrivate * const d = d_func(); | - |
2887 | int entry = d->accessibleTable2Index(current); | - |
2888 | QAccessibleEvent event(this, QAccessible::Focus); | - |
2889 | event.setChild(entry); | - |
2890 | QAccessible::updateAccessibility(&event); | - |
2891 | } | - |
2892 | } | - |
2893 | | - |
2894 | QAbstractItemView::currentChanged(current, previous); | - |
2895 | } | - |
2896 | | - |
2897 | | - |
2898 | | - |
2899 | | - |
2900 | void QTableView::selectionChanged(const QItemSelection &selected, | - |
2901 | const QItemSelection &deselected) | - |
2902 | { | - |
2903 | QTableViewPrivate * const d = d_func(); | - |
2904 | (void)d; | - |
2905 | | - |
2906 | if (QAccessible::isActive()) { | - |
2907 | | - |
2908 | QModelIndex sel = selected.indexes().value(0); | - |
2909 | if (sel.isValid()) { | - |
2910 | int entry = d->accessibleTable2Index(sel); | - |
2911 | QAccessibleEvent event(this, QAccessible::SelectionAdd); | - |
2912 | event.setChild(entry); | - |
2913 | QAccessible::updateAccessibility(&event); | - |
2914 | } | - |
2915 | QModelIndex desel = deselected.indexes().value(0); | - |
2916 | if (desel.isValid()) { | - |
2917 | int entry = d->accessibleTable2Index(desel); | - |
2918 | QAccessibleEvent event(this, QAccessible::SelectionRemove); | - |
2919 | event.setChild(entry); | - |
2920 | QAccessible::updateAccessibility(&event); | - |
2921 | } | - |
2922 | } | - |
2923 | | - |
2924 | QAbstractItemView::selectionChanged(selected, deselected); | - |
2925 | } | - |
2926 | | - |
2927 | int QTableView::visualIndex(const QModelIndex &index) const | - |
2928 | { | - |
2929 | return index.row(); | - |
2930 | } | - |
2931 | | - |
2932 | | - |
2933 | | - |
2934 | | - |
| | |