15#if QT_CONFIG(abstractbutton)
18#include <private/qapplication_p.h>
19#include <private/qtableview_p.h>
20#include <private/qheaderview_p.h>
21#include <private/qscrollbar_p.h>
22#if QT_CONFIG(accessibility)
36 Index::iterator it_y =
index.lowerBound(-
span->top());
37 if (it_y ==
index.end() || it_y.key() != -
span->top()) {
40 if (it_y !=
index.end()) {
44 for (
Span *
s : previousList) {
46 if (
s->bottom() >=
span->top())
47 sub_index.insert(-
s->left(),
s);
50 it_y =
index.insert(-
span->top(), sub_index);
55 while(-it_y.key() <=
span->bottom()) {
57 if (it_y ==
index.begin())
73 if (old_height < span->
height()) {
75 Index::iterator it_y =
index.lowerBound(-(
span->top() + old_height - 1));
77 while (-it_y.key() <=
span->bottom()) {
79 if (it_y ==
index.begin())
83 }
else if (old_height >
span->height()) {
87 while (-it_y.key() <=
span->top() + old_height -1) {
88 if (-it_y.key() >
span->bottom()) {
89 int removed = (*it_y).remove(-
span->left());
92 if (it_y->isEmpty()) {
93 it_y =
index.erase(it_y);
96 if (it_y ==
index.begin())
102 if (
span->width() == 0 &&
span->height() == 0) {
114 Index::const_iterator it_y =
index.lowerBound(-
y);
115 if (it_y ==
index.end())
118 if (it_x == (*it_y).end())
121 if (
span->right() >=
x &&
span->bottom() >=
y)
143 Index::const_iterator it_y =
index.lowerBound(-
y);
144 if (it_y ==
index.end())
146 while(-it_y.key() <=
y +
h) {
148 if (it_x == (*it_y).end())
150 while(-it_x.key() <=
x +
w) {
152 if (
s->bottom() >=
y &&
s->right() >=
x)
154 if (it_x == (*it_y).begin())
158 if (it_y ==
index.begin())
165#undef DEBUG_SPAN_UPDATE
167#ifdef DEBUG_SPAN_UPDATE
176 for (
const auto *
span : spans)
187#ifdef DEBUG_SPAN_UPDATE
194#ifdef DEBUG_SPAN_UPDATE
198#ifdef DEBUG_SPAN_UPDATE
204 span->m_top += delta;
205 span->m_bottom += delta;
208#ifdef DEBUG_SPAN_UPDATE
213 for (Index::iterator it_y =
index.begin(); it_y !=
index.end(); ) {
220 index.insert(-
y - delta, it_y.value());
221 it_y =
index.erase(it_y);
223#ifdef DEBUG_SPAN_UPDATE
233#ifdef DEBUG_SPAN_UPDATE
240#ifdef DEBUG_SPAN_UPDATE
244#ifdef DEBUG_SPAN_UPDATE
250 span->m_left += delta;
251 span->m_right += delta;
254#ifdef DEBUG_SPAN_UPDATE
259 for (Index::iterator it_y =
index.begin(); it_y !=
index.end(); ++it_y) {
271#ifdef DEBUG_SPAN_UPDATE
283 if (subindex.isEmpty())
286 bool should_be_deleted =
true;
287 SubIndex::iterator
it = subindex.
end();
292 if (
span->will_be_deleted) {
296 if (update &&
span->m_left !=
x) {
297 subindex.insert(-
span->m_left,
span);
300 if (should_be_deleted &&
span->m_top ==
y)
301 should_be_deleted =
false;
302 }
while (
it != subindex.
begin());
304 return should_be_deleted;
312#ifdef DEBUG_SPAN_UPDATE
320#ifdef DEBUG_SPAN_UPDATE
325#ifdef DEBUG_SPAN_UPDATE
336 span->m_bottom -= delta;
342 span->m_top -= delta;
343 span->m_bottom -= delta;
345 span->will_be_deleted =
true;
349 span->will_be_deleted =
true;
350 if (
span->will_be_deleted) {
351 spansToBeDeleted.push_back(
span);
358#ifdef DEBUG_SPAN_UPDATE
368 Index::iterator it_y =
index.end();
374 if (cleanSpanSubIndex(subindex,
y))
375 it_y =
index.erase(it_y);
377 bool span_at_start =
false;
381 if (
span->will_be_deleted)
383 if (!span_at_start &&
span->m_top ==
start)
384 span_at_start =
true;
388 if (
y ==
start && span_at_start)
391 it_y =
index.erase(it_y);
394 Index::iterator it_start;
399 if (it_start ==
index.end())
404 start_subindex.insert(
it.key(),
it.value());
408 Index::iterator it_top =
index.find(-
y + delta);
409 if (it_top ==
index.end())
413 if (!
span->will_be_deleted)
420 it_y =
index.erase(it_y);
422 }
while (it_y !=
index.begin());
424#ifdef DEBUG_SPAN_UPDATE
427 qDebug() << spansToBeDeleted;
437#ifdef DEBUG_SPAN_UPDATE
445#ifdef DEBUG_SPAN_UPDATE
450#ifdef DEBUG_SPAN_UPDATE
461 span->m_right -= delta;
467 span->m_left -= delta;
468 span->m_right -= delta;
470 span->will_be_deleted =
true;
474 span->will_be_deleted =
true;
475 if (
span->will_be_deleted) {
476 toBeDeleted.push_back(
span);
483#ifdef DEBUG_SPAN_UPDATE
493 for (Index::iterator it_y =
index.begin(); it_y !=
index.end(); ) {
495 if (cleanSpanSubIndex(it_y.value(),
y,
true))
496 it_y =
index.erase(it_y);
501#ifdef DEBUG_SPAN_UPDATE
509#ifdef QT_BUILD_INTERNAL
514bool QSpanCollection::checkConsistency()
const
516 for (Index::const_iterator it_y =
index.begin(); it_y !=
index.end(); ++it_y) {
518 const SubIndex &subIndex = it_y.value();
519 for (SubIndex::const_iterator
it = subIndex.
begin();
it != subIndex.
end(); ++
it) {
529 if (
span->width() < 1 ||
span->height() < 1
530 || (
span->width() == 1 &&
span->height() == 1))
532 for (
int y =
span->top();
y <=
span->bottom(); ++
y) {
533 Index::const_iterator it_y =
index.find(-
y);
534 if (it_y ==
index.end()) {
535 if (
y ==
span->top())
540 const SubIndex &subIndex = it_y.value();
541 SubIndex::const_iterator
it = subIndex.
find(-
span->left());
550#if QT_CONFIG(abstractbutton)
562 if (isActiveWindow())
584 q->setVerticalHeader(vertical);
589 q->setHorizontalHeader(horizontal);
593#if QT_CONFIG(abstractbutton)
594 cornerWidget =
new QTableCornerButton(
q);
597 cornerWidget, &QTableCornerButton::clicked,
613#if QT_CONFIG(abstractbutton)
660 using minMaxPair = std::pair<int, int>;
661 const auto calcMinMax = [
q](
QHeaderView *hdr,
int startIdx,
int endIdx, minMaxPair bounds) -> minMaxPair
663 minMaxPair
ret(std::numeric_limits<int>::max(), std::numeric_limits<int>::min());
665 for (
int i = startIdx;
i <= endIdx; ++
i) {
670 if (
ret.first <= bounds.first &&
ret.second >= bounds.second)
674 if (
q->isRightToLeft() &&
q->horizontalHeader() == hdr)
675 std::swap(startIdx, endIdx);
684 minMaxPair(
rect.top(),
rect.bottom()));
685 if (yVals.first == yVals.second)
696 minMaxPair(
rect.left(),
rect.right()));
697 const QRect updateRect(
QPoint(xVals.first, yVals.first),
698 QPoint(xVals.second, yVals.second));
699 return rect.intersected(updateRect);
709 qWarning(
"QTableView::setSpan: invalid span given: (%d, %d, %d, %d)",
716 qWarning(
"QTableView::setSpan: span cannot overlap");
722 const int old_height =
sp->height();
728 qWarning(
"QTableView::setSpan: single cell span won't be added");
754 int visual =
header->visualIndex(logical);
755 for (
int i = 1;
i <
span; ) {
756 if (++visual >=
header->count())
758 logical =
header->logicalIndex(visual);
772 return header->sectionPosition(endLogical)
773 -
header->sectionPosition(logical)
774 +
header->sectionSize(endLogical);
785 if (logical == spanLogical)
787 int visual =
header->visualIndex(spanLogical);
788 for (
int i = 1;
i <
span; ) {
789 if (++visual >=
header->count())
791 spanLogical =
header->logicalIndex(visual);
792 if (logical == spanLogical)
809 const auto isCellActive = [
this](
int vr,
int lc)
814 switch (searchDirection) {
841 const auto isCellActive = [
this](
int lr,
int vc)
846 switch (searchDirection) {
873 if (
q->isRightToLeft())
878 if (
q->isRightToLeft())
879 return QRect(colp +
i, rowp, colw -
i, rowh -
i);
880 return QRect(colp, rowp, colw -
i, rowh -
i);
891 int firstVisualRow,
int lastVisualRow,
int firstVisualColumn,
int lastVisualColumn)
894 bool alternateBase =
false;
897 QSet<QSpanCollection::Span *> visibleSpans;
902 lastVisualColumn - firstVisualColumn + 1, lastVisualRow - firstVisualRow + 1);
921 const int spanVisualRight = spanVisualLeft +
span->width() - 1;
922 const int spanVisualBottom = spanVisualTop +
span->height() - 1;
923 if ((spanVisualLeft <= lastVisualColumn && spanVisualRight >= firstVisualColumn)
924 && (spanVisualTop <= lastVisualRow && spanVisualBottom >= firstVisualRow))
925 visibleSpans.insert(
span);
931 int col =
span->left();
933 if (!
index.isValid())
942 opt.
features.setFlag(QStyleOptionViewItem::Alternate, alternateBase);
950 if (
q->isLeftToRight())
957 for (
int r =
span->top();
r <=
span->bottom(); ++
r) {
959 if (vr < firstVisualRow || vr > lastVisualRow)
961 for (
int c =
span->left();
c <=
span->right(); ++
c) {
963 if (vc < firstVisualColumn || vc > lastVisualColumn)
965 drawn->setBit((vr - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1)
966 + vc - firstVisualColumn);
1047 if (
index ==
q->currentIndex()) {
1048 const bool focus = (
q->hasFocus() ||
viewport->hasFocus()) &&
q->currentIndex().isValid();
1065 const int oldHint =
hint;
1080 for (
int i = 1;
i <=
span->width(); ++
i)
1115 option.rect.setX(
q->columnViewportPosition(
index.column()));
1242 d->clearConnections();
1251 QSize result( (
d->verticalHeader->isHidden() ? 0 :
d->verticalHeader->width()) +
d->horizontalHeader->length(),
1252 (
d->horizontalHeader->isHidden() ? 0 :
d->horizontalHeader->height()) +
d->verticalHeader->length());
1269 if (
d->selectionModel) {
1273 d->modelConnections = {
1284 d->verticalHeader->setModel(
model);
1285 d->horizontalHeader->setModel(
model);
1299 d->verticalHeader->setRootIndex(
index);
1300 d->horizontalHeader->setRootIndex(
index);
1311 if (!
d->verticalHeader->updatesEnabled())
1312 d->verticalHeader->setUpdatesEnabled(
true);
1322 if (
d->selectionModel) {
1331 if (
d->selectionModel) {
1333 d->selectionmodelConnection =
1347 return d->horizontalHeader;
1358 return d->verticalHeader;
1374 if (
d->horizontalHeader &&
d->horizontalHeader->parent() ==
this)
1375 delete d->horizontalHeader;
1377 d->horizontalHeader->setParent(
this);
1378 d->horizontalHeader->setFirstSectionMovable(
true);
1379 if (!
d->horizontalHeader->model()) {
1380 d->horizontalHeader->setModel(
d->model);
1381 if (
d->selectionModel)
1382 d->horizontalHeader->setSelectionModel(
d->selectionModel);
1385 d->horHeaderConnections = {
1414 if (
d->verticalHeader &&
d->verticalHeader->parent() ==
this)
1415 delete d->verticalHeader;
1417 d->verticalHeader->setParent(
this);
1418 d->verticalHeader->setFirstSectionMovable(
true);
1419 if (!
d->verticalHeader->model()) {
1420 d->verticalHeader->setModel(
d->model);
1421 if (
d->selectionModel)
1422 d->verticalHeader->setSelectionModel(
d->selectionModel);
1425 d->verHeaderConnections = {
1439 this, [
d](
int row) { d->selectRow(row, false); })
1452 d->delayedAutoScroll.stop();
1454 dx = isRightToLeft() ? -dx : dx;
1456 int oldOffset =
d->horizontalHeader->offset();
1459 int newOffset =
d->horizontalHeader->offset();
1460 dx = isRightToLeft() ? newOffset - oldOffset : oldOffset - newOffset;
1464 int oldOffset =
d->verticalHeader->offset();
1467 int newOffset =
d->verticalHeader->offset();
1468 dy = oldOffset - newOffset;
1471 d->scrollContentsBy(dx, dy);
1477 if (dy > 0 &&
d->horizontalHeader->isHidden()) {
1478 d->viewport->update(0, dy,
d->viewport->width(), dy);
1480 if (dx > 0 &&
d->verticalHeader->isHidden()) {
1481 d->viewport->update(dx, 0, dx,
d->viewport->height());
1492 option->showDecorationSelected =
true;
1502 QStyleOptionViewItem
option;
1506 const int gridSize =
showGrid ? 1 : 0;
1509 const QPen gridPen =
QPen(gridColor, 1,
d->gridStyle);
1512 const bool alternate =
d->alternatingColors;
1513 const bool rightToLeft = isRightToLeft();
1528 if (lastVisualRow == -1)
1529 lastVisualRow =
d->model->rowCount(
d->root) - 1;
1534 qSwap(firstVisualColumn, lastVisualColumn);
1535 if (firstVisualColumn == -1)
1536 firstVisualColumn = 0;
1537 if (lastVisualColumn == -1)
1540 QBitArray drawn((lastVisualRow - firstVisualRow + 1) * (lastVisualColumn - firstVisualColumn + 1));
1544 if (
d->hasSpans()) {
1546 firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn);
1549 for (
QRect dirtyArea : region) {
1550 dirtyArea.setBottom(
qMin(dirtyArea.bottom(),
int(
y)));
1552 dirtyArea.setLeft(
qMax(dirtyArea.left(),
d->viewport->width() -
int(
x)));
1554 dirtyArea.setRight(
qMin(dirtyArea.right(),
int(
x)));
1557 if (!dirtyArea.isValid())
1572 bool alternateBase =
false;
1581 alternateBase = !alternateBase;
1585 alternateBase = (
top & 1) && alternate;
1591 for (
int visualRowIndex =
top; visualRowIndex <=
bottom; ++visualRowIndex) {
1600 for (
int visualColumnIndex =
left; visualColumnIndex <=
right; ++visualColumnIndex) {
1601 int currentBit = (visualRowIndex - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1)
1602 + visualColumnIndex - firstVisualColumn;
1604 if (currentBit < 0 || currentBit >= drawn.size() || drawn.testBit(currentBit))
1606 drawn.setBit(currentBit);
1616 if (
index.isValid()) {
1620 option.features |= QStyleOptionViewItem::Alternate;
1622 option.features &= ~QStyleOptionViewItem::Alternate;
1627 alternateBase = !alternateBase && alternate;
1636 for (
int visualIndex =
top; visualIndex <=
bottom; ++visualIndex) {
1643 QLineF line(dirtyArea.left(), rowY + rowh, dirtyArea.right(), rowY + rowh);
1656 QLineF line(colp, dirtyArea.top(), colp, dirtyArea.bottom());
1665 if (rowY == dirtyArea.top())
1673 if (!isLeftToRight())
1675 if (isLeftToRight() && colX == dirtyArea.left())
1677 if (!isLeftToRight() && colX == dirtyArea.right())
1685#if QT_CONFIG(draganddrop)
1698 d->executePostedLayout();
1701 if (
r >= 0 &&
c >= 0) {
1702 if (
d->hasSpans()) {
1707 return d->model->index(
r,
c,
d->root);
1723 return d->horizontalHeader->offset();
1737 return d->verticalHeader->offset();
1753 int bottom =
d->model->rowCount(
d->root) - 1;
1758 int right =
d->model->columnCount(
d->root) - 1;
1776 return d->model->index(
d->logicalRow(
row),
d->logicalColumn(
column),
d->root);
1780 QPoint visualCurrent(
d->visualColumn(current.
column()),
d->visualRow(current.
row()));
1781 if (visualCurrent !=
d->visualCursor) {
1782 if (
d->hasSpans()) {
1784 if (
span.top() >
d->visualCursor.y() ||
d->visualCursor.y() >
span.bottom()
1785 ||
span.left() >
d->visualCursor.x() ||
d->visualCursor.x() >
span.right())
1786 d->visualCursor = visualCurrent;
1788 d->visualCursor = visualCurrent;
1792 int visualRow =
d->visualCursor.y();
1796 int visualColumn =
d->visualCursor.x();
1797 if (visualColumn >
right)
1798 visualColumn =
right;
1801 if (isRightToLeft()) {
1808 switch (cursorAction) {
1810 int originalRow = visualRow;
1811#ifdef QT_KEYPAD_NAVIGATION
1812 if (QApplicationPrivate::keypadNavigationEnabled() && visualRow == 0)
1813 visualRow =
d->visualRow(
model()->rowCount() - 1) + 1;
1816 int r =
d->logicalRow(visualRow);
1817 int c =
d->logicalColumn(visualColumn);
1818 if (
r != -1 &&
d->hasSpans()) {
1820 if (
span.width() > 1 ||
span.height() > 1)
1821 visualRow =
d->visualRow(
span.top());
1823 while (visualRow >= 0) {
1825 r =
d->logicalRow(visualRow);
1826 c =
d->logicalColumn(visualColumn);
1831 visualRow = originalRow;
1835 int originalRow = visualRow;
1836 if (
d->hasSpans()) {
1838 visualRow =
d->visualRow(
d->rowSpanEndLogical(
span.top(),
span.height()));
1840#ifdef QT_KEYPAD_NAVIGATION
1841 if (QApplicationPrivate::keypadNavigationEnabled() && visualRow >=
bottom)
1844 int r =
d->logicalRow(visualRow);
1845 int c =
d->logicalColumn(visualColumn);
1846 if (
r != -1 &&
d->hasSpans()) {
1848 if (
span.width() > 1 ||
span.height() > 1)
1849 visualRow =
d->visualRow(
d->rowSpanEndLogical(
span.top(),
span.height()));
1851 while (visualRow <=
bottom) {
1853 r =
d->logicalRow(visualRow);
1854 c =
d->logicalColumn(visualColumn);
1859 visualRow = originalRow;
1864 int originalRow = visualRow;
1865 int originalColumn = visualColumn;
1866 bool firstTime =
true;
1867 bool looped =
false;
1868 bool wrapped =
false;
1870 int r =
d->logicalRow(visualRow);
1871 int c =
d->logicalColumn(visualColumn);
1872 if (firstTime &&
c != -1 &&
d->hasSpans()) {
1875 if (
span.width() > 1 ||
span.height() > 1)
1876 visualColumn =
d->visualColumn(
span.left());
1878 while (visualColumn >= 0) {
1880 r =
d->logicalRow(visualRow);
1881 c =
d->logicalColumn(visualColumn);
1884 if (wrapped && (originalRow < visualRow || (originalRow == visualRow && originalColumn <= visualColumn))) {
1889 if (cursorAction ==
MoveLeft || visualColumn >= 0)
1891 visualColumn =
right + 1;
1892 if (visualRow == 0) {
1899 if (visualColumn < 0)
1900 visualColumn = originalColumn;
1905 int originalRow = visualRow;
1906 int originalColumn = visualColumn;
1907 bool firstTime =
true;
1908 bool looped =
false;
1909 bool wrapped =
false;
1911 int r =
d->logicalRow(visualRow);
1912 int c =
d->logicalColumn(visualColumn);
1913 if (firstTime &&
c != -1 &&
d->hasSpans()) {
1916 if (
span.width() > 1 ||
span.height() > 1)
1917 visualColumn =
d->visualColumn(
d->columnSpanEndLogical(
span.left(),
span.width()));
1919 while (visualColumn <=
right) {
1921 r =
d->logicalRow(visualRow);
1922 c =
d->logicalColumn(visualColumn);
1925 if (wrapped && (originalRow > visualRow || (originalRow == visualRow && originalColumn >= visualColumn))) {
1933 if (visualRow ==
bottom) {
1940 if (visualColumn >
right)
1941 visualColumn = originalColumn;
1945 visualColumn =
d->nextActiveVisualColumn(visualRow, 0,
right,
1948 visualRow =
d->nextActiveVisualRow(0, visualColumn,
bottom,
1952 visualColumn =
d->nextActiveVisualColumn(visualRow,
right, -1,
1955 visualRow =
d->nextActiveVisualRow(
bottom, visualColumn, -1,
1960 int visualRow = (newLogicalRow == -1 ? 0 :
d->visualRow(newLogicalRow));
1961 visualRow =
d->nextActiveVisualRow(visualRow, current.
column(),
bottom,
1963 newLogicalRow =
d->logicalRow(visualRow);
1964 return d->model->index(newLogicalRow, current.
column(),
d->root);
1968 int visualRow = (newLogicalRow == -1 ?
bottom :
d->visualRow(newLogicalRow));
1969 visualRow =
d->nextActiveVisualRow(visualRow, current.
column(), -1,
1971 newLogicalRow =
d->logicalRow(visualRow);
1972 return d->model->index(newLogicalRow, current.
column(),
d->root);
1975 d->visualCursor =
QPoint(visualColumn, visualRow);
1976 int logicalRow =
d->logicalRow(visualRow);
1977 int logicalColumn =
d->logicalColumn(visualColumn);
1978 if (!
d->model->hasIndex(logicalRow, logicalColumn,
d->root))
1982 if (!
d->isRowHidden(logicalRow) && !
d->isColumnHidden(logicalColumn) &&
d->isIndexEnabled(
result)) {
1983 if (
d->hasSpans()) {
1985 if (
span.width() > 1 ||
span.height() > 1) {
2009 if (!
d->selectionModel || !tl.
isValid() || !br.
isValid() || !
d->isIndexEnabled(tl) || !
d->isIndexEnabled(br))
2017 if (
d->hasSpans()) {
2021 bool intersectsSpan =
false;
2030 int t =
d->visualRow(
span.top());
2031 int l =
d->visualColumn(
span.left());
2032 int b =
d->visualRow(
d->rowSpanEndLogical(
span.top(),
span.height()));
2033 int r =
d->visualColumn(
d->columnSpanEndLogical(
span.left(),
span.width()));
2036 intersectsSpan =
true;
2057 if (intersectsSpan) {
2059 for (
int horizontal =
left; horizontal <=
right; ++horizontal) {
2060 int column =
d->logicalColumn(horizontal);
2061 for (
int vertical =
top; vertical <=
bottom; ++vertical) {
2062 int row =
d->logicalRow(vertical);
2069 if (!
range.isEmpty())
2072 }
else if (verticalMoved && horizontalMoved) {
2073 int top =
d->visualRow(tl.
row());
2078 for (
int horizontal =
left; horizontal <=
right; ++horizontal) {
2079 int column =
d->logicalColumn(horizontal);
2080 for (
int vertical =
top; vertical <=
bottom; ++vertical) {
2081 int row =
d->logicalRow(vertical);
2086 }
else if (horizontalMoved) {
2090 for (
int visual =
left; visual <=
right; ++visual) {
2091 int column =
d->logicalColumn(visual);
2096 }
else if (verticalMoved) {
2097 int top =
d->visualRow(tl.
row());
2100 for (
int visual =
top; visual <=
bottom; ++visual) {
2101 int row =
d->logicalRow(visual);
2108 if (!
range.isEmpty())
2112 d->selectionModel->select(
selection, command);
2132 const QRect &viewportRect =
d->viewport->rect();
2136 if ((verticalMoved && horizontalMoved) || (
d->hasSpans() && (verticalMoved || horizontalMoved))) {
2138 if (
range.parent() !=
d->root || !
range.isValid())
2144 selectionRegion += rangeRect;
2147 }
else if (horizontalMoved) {
2149 if (
range.parent() !=
d->root || !
range.isValid())
2159 selectionRegion += rangeRect;
2162 }
else if (verticalMoved) {
2164 if (
range.parent() !=
d->root || !
range.isValid())
2174 selectionRegion += rangeRect;
2178 const int gridAdjust =
showGrid() ? 1 : 0;
2180 if (
range.parent() !=
d->root || !
range.isValid())
2182 d->trimHiddenSelections(&
range);
2188 if (isLeftToRight()) {
2195 const QRect rangeRect(
QPoint(rleft, rtop),
QPoint(rright - 1 - gridAdjust, rbottom - 1 - gridAdjust));
2197 selectionRegion += rangeRect;
2198 if (
d->hasSpans()) {
2199 const auto spansInRect =
d->spans.spansInRect(
range.left(),
range.top(),
range.width(),
range.height());
2201 if (
range.contains(
s->top(),
s->left(),
range.parent())) {
2202 const QRect &visualSpanRect =
d->visualSpanRect(*
s);
2204 selectionRegion += visualSpanRect;
2211 return selectionRegion;
2223 if (
d->selectionModel)
2224 modelSelected =
d->selectionModel->selectedIndexes();
2225 for (
int i = 0;
i < modelSelected.size(); ++
i) {
2228 viewSelected.append(
index);
2230 return viewSelected;
2244 if (newCount < oldCount)
2245 d->verticalHeader->setUpdatesEnabled(
false);
2246 d->doDelayedItemsLayout();
2259 d->horizontalHeader->setOffsetToSectionPosition(horizontalScrollBar()->
value());
2261 d->horizontalHeader->setOffset(horizontalScrollBar()->
value());
2262 d->viewport->update();
2271 if (
d->geometryRecursionBlock)
2273 d->geometryRecursionBlock =
true;
2276 if (!
d->verticalHeader->isHidden()) {
2277 width =
qMax(
d->verticalHeader->minimumWidth(),
d->verticalHeader->sizeHint().width());
2281 if (!
d->horizontalHeader->isHidden()) {
2282 height =
qMax(
d->horizontalHeader->minimumHeight(),
d->horizontalHeader->sizeHint().height());
2285 bool reverse = isRightToLeft();
2293 QRect vg =
d->viewport->geometry();
2295 int verticalLeft = reverse ? vg.
right() + 1 : (vg.
left() -
width);
2296 d->verticalHeader->setGeometry(verticalLeft, vg.
top(),
width, vg.
height());
2297 if (
d->verticalHeader->isHidden())
2301 d->horizontalHeader->setGeometry(vg.
left(), horizontalTop, vg.
width(),
height);
2302 if (
d->horizontalHeader->isHidden())
2305#if QT_CONFIG(abstractbutton)
2307 if (
d->horizontalHeader->isHidden() ||
d->verticalHeader->isHidden()) {
2308 d->cornerWidget->setHidden(
true);
2310 d->cornerWidget->setHidden(
false);
2311 d->cornerWidget->setGeometry(verticalLeft, horizontalTop,
width,
height);
2318 QSize vsize =
d->viewport->size();
2319 QSize max = maximumViewportSize();
2320 const int horizontalLength =
d->horizontalHeader->length();
2321 const int verticalLength =
d->verticalHeader->length();
2322 if (max.
width() >= horizontalLength && max.
height() >= verticalLength)
2326 const int columnCount =
d->horizontalHeader->count();
2327 const int viewportWidth = vsize.
width();
2328 int columnsInViewport = 0;
2330 int logical =
d->horizontalHeader->logicalIndex(
column);
2331 if (!
d->horizontalHeader->isSectionHidden(logical)) {
2332 width +=
d->horizontalHeader->sectionSize(logical);
2333 if (
width > viewportWidth)
2335 ++columnsInViewport;
2338 columnsInViewport =
qMax(columnsInViewport, 1);
2341 const int visibleColumns = columnCount -
d->horizontalHeader->hiddenSectionCount();
2342 horizontalScrollBar()->setRange(0, visibleColumns - columnsInViewport);
2343 horizontalScrollBar()->setPageStep(columnsInViewport);
2344 if (columnsInViewport >= visibleColumns)
2345 d->horizontalHeader->setOffset(0);
2346 horizontalScrollBar()->setSingleStep(1);
2348 horizontalScrollBar()->setPageStep(vsize.width());
2349 horizontalScrollBar()->setRange(0, horizontalLength - vsize.width());
2350 horizontalScrollBar()->d_func()->itemviewChangeSingleStep(
qMax(vsize.width() / (columnsInViewport + 1), 2));
2354 const int rowCount =
d->verticalHeader->count();
2355 const int viewportHeight = vsize.height();
2356 int rowsInViewport = 0;
2358 int logical =
d->verticalHeader->logicalIndex(
row);
2359 if (!
d->verticalHeader->isSectionHidden(logical)) {
2360 height +=
d->verticalHeader->sectionSize(logical);
2361 if (
height > viewportHeight)
2366 rowsInViewport =
qMax(rowsInViewport, 1);
2369 const int visibleRows = rowCount -
d->verticalHeader->hiddenSectionCount();
2370 verticalScrollBar()->setRange(0, visibleRows - rowsInViewport);
2371 verticalScrollBar()->setPageStep(rowsInViewport);
2372 if (rowsInViewport >= visibleRows)
2373 d->verticalHeader->setOffset(0);
2374 verticalScrollBar()->setSingleStep(1);
2376 verticalScrollBar()->setPageStep(vsize.height());
2377 verticalScrollBar()->setRange(0, verticalLength - vsize.height());
2378 verticalScrollBar()->d_func()->itemviewChangeSingleStep(
qMax(vsize.height() / (rowsInViewport + 1), 2));
2382 d->geometryRecursionBlock =
false;
2408 const int maximumProcessCols =
d->verticalHeader->resizeContentsPrecision();
2411 int left =
qMax(0,
d->horizontalHeader->visualIndexAt(0));
2412 int right =
d->horizontalHeader->visualIndexAt(
d->viewport->width());
2414 right =
d->model->columnCount(
d->root) - 1;
2416 QStyleOptionViewItem
option;
2421 int columnsProcessed = 0;
2424 int logicalColumn =
d->horizontalHeader->logicalIndex(
column);
2425 if (
d->horizontalHeader->isSectionHidden(logicalColumn))
2431 if (columnsProcessed == maximumProcessCols)
2435 const int actualRight =
d->model->columnCount(
d->root) - 1;
2437 int idxRight =
column - 1;
2439 if (maximumProcessCols == 0 || actualRight < idxLeft)
2440 columnsProcessed = maximumProcessCols;
2442 while (columnsProcessed != maximumProcessCols && (idxLeft > 0 || idxRight < actualRight)) {
2443 int logicalIdx = -1;
2445 if ((columnsProcessed % 2 && idxLeft > 0) || idxRight == actualRight) {
2446 while (idxLeft > 0) {
2448 int logcol =
d->horizontalHeader->logicalIndex(idxLeft);
2449 if (
d->horizontalHeader->isSectionHidden(logcol))
2451 logicalIdx = logcol;
2455 while (idxRight < actualRight) {
2457 int logcol =
d->horizontalHeader->logicalIndex(idxRight);
2458 if (
d->horizontalHeader->isSectionHidden(logcol))
2460 logicalIdx = logcol;
2464 if (logicalIdx >= 0) {
2465 index =
d->model->index(
row, logicalIdx,
d->root);
2497 const int maximumProcessRows =
d->horizontalHeader->resizeContentsPrecision();
2499 int top =
qMax(0,
d->verticalHeader->visualIndexAt(0));
2500 int bottom =
d->verticalHeader->visualIndexAt(
d->viewport->height());
2502 bottom =
d->model->rowCount(
d->root) - 1;
2504 QStyleOptionViewItem
option;
2508 int rowsProcessed = 0;
2512 int logicalRow =
d->verticalHeader->logicalIndex(
row);
2513 if (
d->verticalHeader->isSectionHidden(logicalRow))
2519 if (rowsProcessed == maximumProcessRows)
2523 const int actualBottom =
d->model->rowCount(
d->root) - 1;
2525 int idxBottom =
row - 1;
2527 if (maximumProcessRows == 0 || actualBottom < idxTop)
2528 rowsProcessed = maximumProcessRows;
2530 while (rowsProcessed != maximumProcessRows && (idxTop > 0 || idxBottom < actualBottom)) {
2531 int logicalIdx = -1;
2533 if ((rowsProcessed % 2 && idxTop > 0) || idxBottom == actualBottom) {
2534 while (idxTop > 0) {
2536 int logrow =
d->verticalHeader->logicalIndex(idxTop);
2537 if (
d->verticalHeader->isSectionHidden(logrow))
2539 logicalIdx = logrow;
2543 while (idxBottom < actualBottom) {
2545 int logrow =
d->verticalHeader->logicalIndex(idxBottom);
2546 if (
d->verticalHeader->isSectionHidden(logrow))
2548 logicalIdx = logrow;
2552 if (logicalIdx >= 0) {
2569 return d->verticalHeader->sectionViewportPosition(
row);
2584 return d->verticalHeader->logicalIndexAt(
y);
2595 d->verticalHeader->resizeSection(
row,
height);
2606 return d->verticalHeader->sectionSize(
row);
2616 return d->horizontalHeader->sectionViewportPosition(
column);
2631 return d->horizontalHeader->logicalIndexAt(
x);
2653 return d->horizontalHeader->sectionSize(
column);
2664 return d->verticalHeader->isSectionHidden(
row);
2675 if (row < 0 || row >=
d->verticalHeader->count())
2677 d->verticalHeader->setSectionHidden(
row,
hide);
2688 return d->horizontalHeader->isSectionHidden(
column);
2700 if (column < 0 || column >=
d->horizontalHeader->count())
2702 d->horizontalHeader->setSectionHidden(
column,
hide);
2732 d->dynHorHeaderConnections.clear();
2737 d->horizontalHeader->sortIndicatorOrder());
2738 d->dynHorHeaderConnections = {
2743 d->dynHorHeaderConnections = {
2747 this, [
d](
int column) {d->selectColumn(column, false); })
2756 return d->sortingEnabled;
2775 if (
d->showGrid !=
show) {
2777 d->viewport->update();
2790 return d->gridStyle;
2796 if (
d->gridStyle != style) {
2797 d->gridStyle = style;
2798 d->viewport->update();
2819 if (
d->wrapItemText == on)
2821 d->wrapItemText = on;
2829 return d->wrapItemText;
2832#if QT_CONFIG(abstractbutton)
2844void QTableView::setCornerButtonEnabled(
bool enable)
2847 d->cornerWidget->setEnabled(
enable);
2850bool QTableView::isCornerButtonEnabled()
const
2853 return d->cornerWidget->isEnabled();
2867 if (!
d->isIndexValid(
index) ||
index.parent() !=
d->root
2871 d->executePostedLayout();
2873 if (
d->hasSpans()) {
2875 return d->visualSpanRect(
span);
2884 return QRect(colp, rowp, colw -
i, rowh -
i);
2898 if (!
d->isIndexValid(
index)
2899 || (
d->model->parent(
index) !=
d->root)
2909 int viewportWidth =
d->viewport->
width();
2911 int horizontalPosition =
d->horizontalHeader->sectionPosition(
index.column());
2912 int horizontalIndex =
d->horizontalHeader->visualIndex(
index.column());
2913 int cellWidth =
d->hasSpans()
2914 ?
d->columnSpanWidth(
index.column(),
span.width())
2915 :
d->horizontalHeader->sectionSize(
index.column());
2920 bool positionAtRight = (horizontalPosition -
horizontalOffset + cellWidth > viewportWidth);
2925 while (horizontalIndex > 0) {
2926 x +=
columnWidth(
d->horizontalHeader->logicalIndex(horizontalIndex-1));
2934 int hiddenSections = 0;
2935 if (
d->horizontalHeader->sectionsHidden()) {
2936 for (
int s = horizontalIndex - 1;
s >= 0; --
s) {
2937 int column =
d->horizontalHeader->logicalIndex(
s);
2938 if (
d->horizontalHeader->isSectionHidden(
column))
2942 horizontalScrollBar()->setValue(horizontalIndex - hiddenSections);
2947 horizontalScrollBar()->setValue(horizontalPosition - ((viewportWidth - cellWidth) / 2));
2949 if (horizontalPosition - horizontalOffset < 0 || cellWidth > viewportWidth)
2950 horizontalScrollBar()->setValue(horizontalPosition);
2951 else if (horizontalPosition -
horizontalOffset + cellWidth > viewportWidth)
2952 horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth);
2958 int viewportHeight =
d->viewport->height();
2960 int verticalPosition =
d->verticalHeader->sectionPosition(
index.row());
2961 int verticalIndex =
d->verticalHeader->visualIndex(
index.row());
2962 int cellHeight =
d->hasSpans()
2963 ?
d->rowSpanHeight(
index.row(),
span.height())
2964 :
d->verticalHeader->sectionSize(
index.row());
2966 if (verticalPosition - verticalOffset < 0 || cellHeight > viewportHeight) {
2969 }
else if (verticalPosition -
verticalOffset + cellHeight > viewportHeight) {
2979 while (verticalIndex > 0) {
2980 int row =
d->verticalHeader->logicalIndex(verticalIndex - 1);
2981 y +=
d->verticalHeader->sectionSize(
row);
2989 int hiddenSections = 0;
2990 if (
d->verticalHeader->sectionsHidden()) {
2991 for (
int s = verticalIndex - 1;
s >= 0; --
s) {
2992 int row =
d->verticalHeader->logicalIndex(
s);
2993 if (
d->verticalHeader->isSectionHidden(
row))
2997 verticalScrollBar()->setValue(verticalIndex - hiddenSections);
3002 verticalScrollBar()->setValue(verticalPosition);
3004 verticalScrollBar()->setValue(verticalPosition - viewportHeight + cellHeight);
3006 verticalScrollBar()->setValue(verticalPosition - ((viewportHeight - cellHeight) / 2));
3023 d->rowsToUpdate.append(
row);
3024 if (
d->rowResizeTimerID == 0)
3025 d->rowResizeTimerID = startTimer(0);
3038 d->columnsToUpdate.append(
column);
3039 if (
d->columnResizeTimerID == 0)
3040 d->columnResizeTimerID = startTimer(0);
3050 if (
event->timerId() ==
d->columnResizeTimerID) {
3051 const int oldScrollMax = horizontalScrollBar()->maximum();
3054 killTimer(
d->columnResizeTimerID);
3055 d->columnResizeTimerID = 0;
3061 int viewportHeight =
d->viewport->
height();
3062 int viewportWidth =
d->viewport->width();
3063 if (
d->hasSpans() || horizontalScrollBar()->
value() == oldScrollMax) {
3064 rect =
QRect(0, 0, viewportWidth, viewportHeight);
3066 for (
int i =
d->columnsToUpdate.size()-1;
i >= 0; --
i) {
3067 int column =
d->columnsToUpdate.at(
i);
3069 if (isRightToLeft())
3072 rect |=
QRect(
x, 0, viewportWidth -
x, viewportHeight);
3076 d->viewport->update(
rect.normalized());
3077 d->columnsToUpdate.clear();
3080 if (
event->timerId() ==
d->rowResizeTimerID) {
3081 const int oldScrollMax = verticalScrollBar()->maximum();
3084 killTimer(
d->rowResizeTimerID);
3085 d->rowResizeTimerID = 0;
3090 int viewportHeight =
d->viewport->height();
3091 int viewportWidth =
d->viewport->width();
3093 if (
d->hasSpans() || verticalScrollBar()->
value() == oldScrollMax) {
3096 top = viewportHeight;
3097 for (
int i =
d->rowsToUpdate.size()-1;
i >= 0; --
i) {
3103 d->viewport->update(
QRect(0,
top, viewportWidth, viewportHeight -
top));
3104 d->rowsToUpdate.clear();
3123 int logicalOldIndex =
d->verticalHeader->logicalIndex(oldIndex);
3124 int logicalNewIndex =
d->verticalHeader->logicalIndex(newIndex);
3125 if (
d->hasSpans()) {
3126 d->viewport->update();
3130 int oldBottom = oldTop +
rowHeight(logicalOldIndex);
3131 int newBottom = newTop +
rowHeight(logicalNewIndex);
3132 int top =
qMin(oldTop, newTop);
3135 d->viewport->update(0,
top,
d->viewport->width(),
height);
3152 int logicalOldIndex =
d->horizontalHeader->logicalIndex(oldIndex);
3153 int logicalNewIndex =
d->horizontalHeader->logicalIndex(newIndex);
3154 if (
d->hasSpans()) {
3155 d->viewport->update();
3159 int oldRight = oldLeft +
columnWidth(logicalOldIndex);
3160 int newRight = newLeft +
columnWidth(logicalNewIndex);
3164 d->viewport->update(
left, 0,
width,
d->viewport->height());
3177 d->selectRow(
row,
true);
3189 d->selectColumn(
column,
true);
3200 d->verticalHeader->hideSection(
row);
3211 d->horizontalHeader->hideSection(
column);
3222 d->verticalHeader->showSection(
row);
3233 d->horizontalHeader->showSection(
column);
3246 int header =
d->verticalHeader->sectionSizeHint(
row);
3310 if (!
d->sortingEnabled ||
3311 (
d->horizontalHeader->sortIndicatorSection() ==
column &&
d->horizontalHeader->sortIndicatorOrder() ==
order))
3340 if (
d->hasSpans()) {
3362 d->viewport->update();
3405 d->viewport->update();
3417 if (
row >= 0 && row < model->rowCount(
root)) {
3420 QItemSelectionModel::SelectionFlags command =
q->selectionCommand(
index);
3457 if (
column >= 0 && column < model->columnCount(
root)) {
3460 QItemSelectionModel::SelectionFlags command =
q->selectionCommand(
index);
3493#if QT_CONFIG(accessibility)
3494 if (QAccessible::isActive()) {
3495 if (current.
isValid() && hasFocus()) {
3497 int entry =
d->accessibleTable2Index(current);
3498 QAccessibleEvent
event(
this, QAccessible::Focus);
3499 event.setChild(
entry);
3500 QAccessible::updateAccessibility(&
event);
3515#if QT_CONFIG(accessibility)
3516 if (QAccessible::isActive()) {
3519 if (sel.isValid()) {
3520 int entry =
d->accessibleTable2Index(sel);
3521 QAccessibleEvent
event(
this, QAccessible::SelectionAdd);
3522 event.setChild(
entry);
3523 QAccessible::updateAccessibility(&
event);
3525 QModelIndex desel = deselected.indexes().value(0);
3526 if (desel.isValid()) {
3527 int entry =
d->accessibleTable2Index(desel);
3528 QAccessibleEvent
event(
this, QAccessible::SelectionRemove);
3529 event.setChild(
entry);
3530 QAccessible::updateAccessibility(&
event);
3544#include "qtableview.moc"
3546#include "moc_qtableview.cpp"
static QAbstractItemModel * staticEmptyModel()
void columnsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been removed from the model.
virtual Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been inserted into the model.
void columnsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been inserted into the model.
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index.
void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been removed from the model.
virtual bool submit()
Lets the model know that it should submit cached information to permanent storage.
const QEditorInfo & editorForIndex(const QModelIndex &index) const
QSet< QWidget * > persistent
QAbstractItemView::EditTriggers editTriggers
QPersistentModelIndex currentSelectionStartIndex
QPointer< QItemSelectionModel > selectionModel
QItemSelectionModel::SelectionFlag ctrlDragSelectionFlag
QPersistentModelIndex root
QAbstractItemModel * model
QWidget * editor(const QModelIndex &index, const QStyleOptionViewItem &options)
QPersistentModelIndex hover
The QAbstractItemView class provides the basic functionality for item view classes.
QAbstractItemModel * model() const
Returns the model that this view is presenting.
virtual void setSelectionModel(QItemSelectionModel *selectionModel)
Sets the current selection model to the given selectionModel.
void timerEvent(QTimerEvent *event) override
This function is called with the given event when a timer event is sent to the widget.
ScrollMode verticalScrollMode
how the view scrolls its contents in the vertical direction
virtual void verticalScrollbarAction(int action)
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
This slot is called when the selection is changed.
State state() const
Returns the item view's state.
QModelIndex currentIndex() const
Returns the model index of the current item.
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
ScrollMode horizontalScrollMode
how the view scrolls its contents in the horizontal direction
virtual void setRootIndex(const QModelIndex &index)
Sets the root item to the item at the given index.
virtual void initViewItemOption(QStyleOptionViewItem *option) const
virtual void doItemsLayout()
void update(const QModelIndex &index)
CursorAction
This enum describes the different ways to navigate between items,.
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
This slot is called when a new item becomes the current item.
ScrollHint
\value EnsureVisible Scroll to ensure that the item is visible.
virtual void selectAll()
Selects all items in the view.
virtual void updateEditorGeometries()
QItemSelectionModel * selectionModel() const
Returns the current selection model.
virtual void updateGeometries()
virtual void horizontalScrollbarAction(int action)
The QColor class provides colors based on RGB, HSV or CMYK values.
static QColor fromRgba(QRgb rgba) noexcept
Static convenience function that returns a QColor constructed from the given QRgb value rgba.
Q_INVOKABLE QModelIndexList selectedRows(int column=0) const
Q_INVOKABLE bool isSelected(const QModelIndex &index) const
Returns true if the given model item index is selected.
virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged().
void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
This signal is emitted if the current item changes and its row is different to the row of the previou...
Q_INVOKABLE QModelIndexList selectedColumns(int row=0) const
Q_CORE_EXPORT QModelIndexList indexes() const
Returns a list of model indexes that correspond to the selected items.
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
bool isEmpty() const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
T value(const Key &key, const T &defaultValue=T()) const
constexpr int row() const noexcept
Returns the row this model index refers to.
constexpr const QAbstractItemModel * model() const noexcept
Returns a pointer to the model containing the item that this index refers to.
constexpr int column() const noexcept
Returns the column this model index refers to.
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
const QPen & pen() const
Returns the painter's current pen.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(const QLineF &line)
Draws a line defined by line.
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
void setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
int column() const
Returns the column this persistent model index refers to.
int row() const
Returns the row this persistent model index refers to.
\inmodule QtCore\reentrant
T * data() const noexcept
\inmodule QtCore\reentrant
bool intersects(const QRect &r) const noexcept
Returns true if this rectangle intersects with the given rectangle (i.e., there is at least one pixel...
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
QRect intersected(const QRect &other) const noexcept
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QRegion class specifies a clip region for a painter.
QRegion translated(int dx, int dy) const
iterator erase(const_iterator i)
iterator find(const T &value)
bool contains(const T &value) const
iterator insert(const T &value)
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
std::list< Span * > SpanList
QSet< Span * > spansInRect(int x, int y, int w, int h) const
void updateRemovedColumns(int start, int end)
void updateInsertedColumns(int start, int end)
void updateSpan(Span *span, int old_height)
Span * spanAt(int x, int y) const
void updateRemovedRows(int start, int end)
void updateInsertedRows(int start, int end)
QString left(qsizetype n) const &
QString right(qsizetype n) const &
void initFrom(const QWidget *w)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
@ SH_Table_AlwaysDrawLeftTopGridLines
QRect visualSpanRect(const QSpanCollection::Span &span) const
QMetaObject::Connection selectionmodelConnection
int logicalColumn(int visualCol) const
void drawAndClipSpans(const QRegion &area, QPainter *painter, const QStyleOptionViewItem &option, QBitArray *drawn, int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn)
void updateSpanInsertedRows(const QModelIndex &parent, int start, int end)
QHeaderView * horizontalHeader
std::array< QMetaObject::Connection, 7 > verHeaderConnections
std::vector< QMetaObject::Connection > dynHorHeaderConnections
bool isRowHidden(int row) const
bool isCellEnabled(int row, int column) const
bool isColumnHidden(int column) const
int sectionSpanSize(const QHeaderView *header, int logical, int span) const
int nextActiveVisualColumn(int row, int columnToStart, int limit, SearchDirection searchDirection) const
int columnSpan(int row, int column) const
std::array< QMetaObject::Connection, 4 > modelConnections
void updateSpanRemovedColumns(const QModelIndex &parent, int start, int end)
void selectColumn(int column, bool anchor)
void trimHiddenSelections(QItemSelectionRange *range) const
int logicalRow(int visualRow) const
QSpanCollection::Span span(int row, int column) const
void drawCell(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)
int visualRow(int logicalRow) const
int widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
QHeaderView * verticalHeader
bool spanContainsSection(const QHeaderView *header, int logical, int spanLogical, int span) const
int heightHintForIndex(const QModelIndex &index, int hint, QStyleOptionViewItem &option) const
int rowSpanHeight(int row, int span) const
int nextActiveVisualRow(int rowToStart, int column, int limit, SearchDirection searchDirection) const
void setSpan(int row, int column, int rowSpan, int columnSpan)
int columnSpanWidth(int column, int span) const
int sectionSpanEndLogical(const QHeaderView *header, int logical, int span) const
void updateSpanRemovedRows(const QModelIndex &parent, int start, int end)
void selectRow(int row, bool anchor)
void updateSpanInsertedColumns(const QModelIndex &parent, int start, int end)
int rowSpan(int row, int column) const
QRect intersectedRect(const QRect rect, const QModelIndex &topLeft, const QModelIndex &bottomRight) const override
std::array< QMetaObject::Connection, 5 > horHeaderConnections
int visualColumn(int logicalCol) const
void sortIndicatorChanged(int column, Qt::SortOrder order)
The QTableView class provides a default model/view implementation of a table view.
void setModel(QAbstractItemModel *model) override
\reimp
int rowAt(int y) const
Returns the row in which the given y-coordinate, y, in contents coordinates is located.
void verticalScrollbarAction(int action) override
bool isColumnHidden(int column) const
Returns true if the given column is hidden; otherwise returns false.
void setHorizontalHeader(QHeaderView *header)
Sets the widget to use for the horizontal header to header.
QTableView(QWidget *parent=nullptr)
Constructs a table view with a parent to represent the data.
int rowSpan(int row, int column) const
void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible) override
\reimp
void columnCountChanged(int oldCount, int newCount)
This slot is called whenever columns are added or deleted.
void setSortingEnabled(bool enable)
If enable is true, enables sorting for the table and immediately trigger a call to sortByColumn() wit...
bool showGrid
whether the grid is shown
void columnResized(int column, int oldWidth, int newWidth)
This slot is called to change the width of the given column.
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override
\reimp
void setRootIndex(const QModelIndex &index) override
\reimp
void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override
Selects the items within the given rect and in accordance with the specified selection flags.
int columnViewportPosition(int column) const
Returns the x-coordinate in contents coordinates of the given column.
void setVerticalHeader(QHeaderView *header)
Sets the widget to use for the vertical header to header.
QRect visualRect(const QModelIndex &index) const override
\reimp
void sortByColumn(int column, Qt::SortOrder order)
QModelIndex indexAt(const QPoint &p) const override
Returns the index position of the model item corresponding to the table item at position pos in conte...
void resizeColumnsToContents()
Resizes all columns based on the size hints of the delegate used to render each item in the columns.
void initViewItemOption(QStyleOptionViewItem *option) const override
\reimp
int columnWidth(int column) const
Returns the width of the given column.
void setColumnHidden(int column, bool hide)
If hide is true the given column will be hidden; otherwise it will be shown.
int rowHeight(int row) const
Returns the height of the given row.
void setRowHidden(int row, bool hide)
If hide is true row will be hidden, otherwise it will be shown.
void columnMoved(int column, int oldIndex, int newIndex)
This slot is called to change the index of the given column in the table view.
int sizeHintForColumn(int column) const override
Returns the size hint for the given column's width or -1 if there is no model.
bool isRowHidden(int row) const
Returns true if the given row is hidden; otherwise returns false.
void showRow(int row)
Show the given row.
void rowMoved(int row, int oldIndex, int newIndex)
This slot is called to change the index of the given row in the table view.
void scrollContentsBy(int dx, int dy) override
\reimp
void setWordWrap(bool on)
void horizontalScrollbarAction(int action) override
void paintEvent(QPaintEvent *e) override
Paints the table on receipt of the given paint event event.
bool isSortingEnabled() const
Qt::PenStyle gridStyle
the pen style used to draw the grid.
QSize viewportSizeHint() const override
\reimp
void setColumnWidth(int column, int width)
void setShowGrid(bool show)
void selectColumn(int column)
Selects the given column in the table view if the current SelectionMode and SelectionBehavior allows ...
int sizeHintForRow(int row) const override
Returns the size hint for the given row's height or -1 if there is no model.
void selectRow(int row)
Selects the given row in the table view if the current SelectionMode and SelectionBehavior allows row...
void hideRow(int row)
Hide the given row.
QRegion visualRegionForSelection(const QItemSelection &selection) const override
\reimp
void updateGeometries() override
\reimp
QHeaderView * horizontalHeader() const
Returns the table view's horizontal header.
int verticalOffset() const override
Returns the vertical offset of the items in the table view.
void showColumn(int column)
Show the given column.
QModelIndexList selectedIndexes() const override
\reimp
bool wordWrap
the item text word-wrapping policy
void rowResized(int row, int oldHeight, int newHeight)
This slot is called to change the height of the given row.
void setSelectionModel(QItemSelectionModel *selectionModel) override
\reimp
int columnSpan(int row, int column) const
void resizeColumnToContents(int column)
Resizes the given column based on the size hints of the delegate used to render each item in the colu...
QHeaderView * verticalHeader() const
Returns the table view's vertical header.
void doItemsLayout() override
void timerEvent(QTimerEvent *event) override
\reimp
~QTableView()
Destroys the table view.
int columnAt(int x) const
Returns the column in which the given x-coordinate, x, in contents coordinates is located.
int rowViewportPosition(int row) const
Returns the y-coordinate in contents coordinates of the given row.
void setSpan(int row, int column, int rowSpan, int columnSpan)
bool isIndexHidden(const QModelIndex &index) const override
\reimp
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override
\reimp
void hideColumn(int column)
Hide the given column.
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
Moves the cursor in accordance with the given cursorAction, using the information provided by the mod...
void rowCountChanged(int oldCount, int newCount)
This slot is called whenever rows are added or deleted.
void resizeRowToContents(int row)
Resizes the given row based on the size hints of the delegate used to render each item in the row.
void setGridStyle(Qt::PenStyle style)
void setRowHeight(int row, int height)
void resizeRowsToContents()
Resizes all rows based on the size hints of the delegate used to render each item in the rows.
int horizontalOffset() const override
Returns the horizontal offset of the items in the table view.
EGLImageKHR int int EGLuint64KHR * modifiers
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QTextStream & endl(QTextStream &stream)
Writes '\n' to the stream and flushes the stream.
DBusConnection * connection
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static int area(const QSize &s)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble top
GLenum GLuint GLintptr offset
GLfloat GLfloat GLfloat GLfloat h
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void GLsizei void void * span
GLfixed GLfixed GLint GLint order
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
QSqlQueryModel * model
[16]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
view viewport() -> scroll(dx, dy, deviceRect)
QItemSelection * selection
[0]
QPointer< QWidget > widget
bool contains(const AT &t) const noexcept