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())
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
180#ifdef DEBUG_SPAN_UPDATE
187#ifdef DEBUG_SPAN_UPDATE
191#ifdef DEBUG_SPAN_UPDATE
197 span->m_top += delta;
198 span->m_bottom += delta;
201#ifdef DEBUG_SPAN_UPDATE
207 for (Index::iterator it_y =
index.begin(); it_y !=
index.end(); ) {
214 index.insert(-
y - delta, it_y.value());
215 it_y =
index.erase(it_y);
217#ifdef DEBUG_SPAN_UPDATE
227#ifdef DEBUG_SPAN_UPDATE
234#ifdef DEBUG_SPAN_UPDATE
238#ifdef DEBUG_SPAN_UPDATE
244 span->m_left += delta;
245 span->m_right += delta;
248#ifdef DEBUG_SPAN_UPDATE
254 for (Index::iterator it_y =
index.begin(); it_y !=
index.end(); ++it_y) {
266#ifdef DEBUG_SPAN_UPDATE
281 bool should_be_deleted =
true;
282 SubIndex::iterator
it = subindex.
end();
287 if (
span->will_be_deleted) {
291 if (update &&
span->m_left !=
x) {
295 if (should_be_deleted &&
span->m_top ==
y)
296 should_be_deleted =
false;
297 }
while (
it != subindex.
begin());
299 return should_be_deleted;
307#ifdef DEBUG_SPAN_UPDATE
315#ifdef DEBUG_SPAN_UPDATE
318 for (SpanList::iterator
it =
spans.begin();
it !=
spans.end(); ) {
320#ifdef DEBUG_SPAN_UPDATE
331 span->m_bottom -= delta;
337 span->m_top -= delta;
338 span->m_bottom -= delta;
340 span->will_be_deleted =
true;
344 span->will_be_deleted =
true;
345 if (
span->will_be_deleted) {
346 spansToBeDeleted.push_back(
span);
353#ifdef DEBUG_SPAN_UPDATE
364 Index::iterator it_y =
index.end();
370 if (cleanSpanSubIndex(subindex,
y))
371 it_y =
index.erase(it_y);
373 bool span_at_start =
false;
377 if (
span->will_be_deleted)
379 if (!span_at_start &&
span->m_top ==
start)
380 span_at_start =
true;
384 if (
y ==
start && span_at_start)
387 it_y =
index.erase(it_y);
390 Index::iterator it_start;
395 if (it_start ==
index.end())
404 Index::iterator it_top =
index.find(-
y + delta);
405 if (it_top ==
index.end())
409 if (!
span->will_be_deleted)
416 it_y =
index.erase(it_y);
418 }
while (it_y !=
index.begin());
420#ifdef DEBUG_SPAN_UPDATE
434#ifdef DEBUG_SPAN_UPDATE
442#ifdef DEBUG_SPAN_UPDATE
445 for (SpanList::iterator
it =
spans.begin();
it !=
spans.end(); ) {
447#ifdef DEBUG_SPAN_UPDATE
458 span->m_right -= delta;
464 span->m_left -= delta;
465 span->m_right -= delta;
467 span->will_be_deleted =
true;
471 span->will_be_deleted =
true;
472 if (
span->will_be_deleted) {
473 toBeDeleted.push_back(
span);
480#ifdef DEBUG_SPAN_UPDATE
491 for (Index::iterator it_y =
index.begin(); it_y !=
index.end(); ) {
493 if (cleanSpanSubIndex(it_y.value(),
y,
true))
494 it_y =
index.erase(it_y);
499#ifdef DEBUG_SPAN_UPDATE
508#ifdef QT_BUILD_INTERNAL
513bool QSpanCollection::checkConsistency()
const
515 for (Index::const_iterator it_y =
index.begin(); it_y !=
index.end(); ++it_y) {
517 const SubIndex &subIndex = it_y.value();
518 for (SubIndex::const_iterator
it = subIndex.
begin();
it != subIndex.
end(); ++
it) {
528 if (
span->width() < 1 ||
span->height() < 1
529 || (
span->width() == 1 &&
span->height() == 1))
531 for (
int y =
span->top();
y <=
span->bottom(); ++
y) {
532 Index::const_iterator it_y =
index.find(-
y);
533 if (it_y ==
index.end()) {
534 if (
y ==
span->top())
539 const SubIndex &subIndex = it_y.value();
540 SubIndex::const_iterator
it = subIndex.
find(-
span->left());
549#if QT_CONFIG(abstractbutton)
583 q->setVerticalHeader(vertical);
588 q->setHorizontalHeader(horizontal);
592#if QT_CONFIG(abstractbutton)
593 cornerWidget =
new QTableCornerButton(
q);
641 using minMaxPair = std::pair<int, int>;
642 const auto calcMinMax = [
q](
QHeaderView *hdr,
int startIdx,
int endIdx, minMaxPair bounds) -> minMaxPair
644 minMaxPair
ret(std::numeric_limits<int>::max(), std::numeric_limits<int>::min());
646 for (
int i = startIdx;
i <= endIdx; ++
i) {
651 if (
ret.first <= bounds.first &&
ret.second >= bounds.second)
655 if (
q->isRightToLeft() &&
q->horizontalHeader() == hdr)
656 std::swap(startIdx, endIdx);
665 minMaxPair(
rect.top(),
rect.bottom()));
666 if (yVals.first == yVals.second)
672 const QRect intersected =
rect.intersected(colRect);
677 minMaxPair(
rect.left(),
rect.right()));
678 const QRect updateRect(
QPoint(xVals.first, yVals.first),
679 QPoint(xVals.second, yVals.second));
680 return rect.intersected(updateRect);
690 qWarning(
"QTableView::setSpan: invalid span given: (%d, %d, %d, %d)",
697 qWarning(
"QTableView::setSpan: span cannot overlap");
703 const int old_height =
sp->height();
709 qWarning(
"QTableView::setSpan: single cell span won't be added");
735 int visual =
header->visualIndex(logical);
736 for (
int i = 1;
i <
span; ) {
739 logical =
header->logicalIndex(visual);
753 return header->sectionPosition(endLogical)
754 -
header->sectionPosition(logical)
755 +
header->sectionSize(endLogical);
766 if (logical == spanLogical)
768 int visual =
header->visualIndex(spanLogical);
769 for (
int i = 1;
i <
span; ) {
772 spanLogical =
header->logicalIndex(visual);
773 if (logical == spanLogical)
790 const auto isCellActive = [
this](
int vr,
int lc)
795 switch (searchDirection) {
822 const auto isCellActive = [
this](
int lr,
int vc)
827 switch (searchDirection) {
854 if (
q->isRightToLeft())
859 if (
q->isRightToLeft())
860 return QRect(colp +
i, rowp, colw -
i, rowh -
i);
861 return QRect(colp, rowp, colw -
i, rowh -
i);
872 int firstVisualRow,
int lastVisualRow,
int firstVisualColumn,
int lastVisualColumn)
875 bool alternateBase =
false;
883 lastVisualColumn - firstVisualColumn + 1, lastVisualRow - firstVisualRow + 1);
902 const int spanVisualRight = spanVisualLeft +
span->width() - 1;
903 const int spanVisualBottom = spanVisualTop +
span->height() - 1;
904 if ((spanVisualLeft <= lastVisualColumn && spanVisualRight >= firstVisualColumn)
905 && (spanVisualTop <= lastVisualRow && spanVisualBottom >= firstVisualRow))
912 int col =
span->left();
914 if (!
index.isValid())
923 opt.
features.setFlag(QStyleOptionViewItem::Alternate, alternateBase);
931 if (
q->isLeftToRight())
938 for (
int r =
span->top();
r <=
span->bottom(); ++
r) {
940 if (vr < firstVisualRow || vr > lastVisualRow)
942 for (
int c =
span->left();
c <=
span->right(); ++
c) {
944 if (vc < firstVisualColumn || vc > lastVisualColumn)
946 drawn->
setBit((vr - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1)
947 + vc - firstVisualColumn);
1028 if (
index ==
q->currentIndex()) {
1029 const bool focus = (
q->hasFocus() ||
viewport->hasFocus()) &&
q->currentIndex().isValid();
1046 const int oldHint =
hint;
1061 for (
int i = 1;
i <=
span->width(); ++
i)
1096 option.rect.setX(
q->columnViewportPosition(
index.column()));
1230 QSize result( (
d->verticalHeader->isHidden() ? 0 :
d->verticalHeader->width()) +
d->horizontalHeader->length(),
1231 (
d->horizontalHeader->isHidden() ? 0 :
d->horizontalHeader->height()) +
d->verticalHeader->length());
1254 if (
d->selectionModel) {
1256 d->model,
SLOT(submit()));
1268 d->verticalHeader->setModel(
model);
1269 d->horizontalHeader->setModel(
model);
1283 d->verticalHeader->setRootIndex(
index);
1284 d->horizontalHeader->setRootIndex(
index);
1295 if (!
d->verticalHeader->updatesEnabled())
1296 d->verticalHeader->setUpdatesEnabled(
true);
1306 if (
d->selectionModel) {
1309 d->model,
SLOT(submit()));
1316 if (
d->selectionModel) {
1319 d->model,
SLOT(submit()));
1331 return d->horizontalHeader;
1342 return d->verticalHeader;
1356 if (
d->horizontalHeader &&
d->horizontalHeader->parent() ==
this)
1357 delete d->horizontalHeader;
1359 d->horizontalHeader->setParent(
this);
1360 d->horizontalHeader->setFirstSectionMovable(
true);
1361 if (!
d->horizontalHeader->model()) {
1362 d->horizontalHeader->setModel(
d->model);
1363 if (
d->selectionModel)
1364 d->horizontalHeader->setSelectionModel(
d->selectionModel);
1371 connect(
d->horizontalHeader,
SIGNAL(sectionCountChanged(
int,
int)),
1374 connect(
d->horizontalHeader,
SIGNAL(sectionEntered(
int)),
this,
SLOT(_q_selectColumn(
int)));
1375 connect(
d->horizontalHeader,
SIGNAL(sectionHandleDoubleClicked(
int)),
1394 if (
d->verticalHeader &&
d->verticalHeader->parent() ==
this)
1395 delete d->verticalHeader;
1397 d->verticalHeader->setParent(
this);
1398 d->verticalHeader->setFirstSectionMovable(
true);
1399 if (!
d->verticalHeader->model()) {
1400 d->verticalHeader->setModel(
d->model);
1401 if (
d->selectionModel)
1402 d->verticalHeader->setSelectionModel(
d->selectionModel);
1412 connect(
d->verticalHeader,
SIGNAL(sectionEntered(
int)),
this,
SLOT(_q_selectRow(
int)));
1413 connect(
d->verticalHeader,
SIGNAL(sectionHandleDoubleClicked(
int)),
1427 d->delayedAutoScroll.stop();
1429 dx = isRightToLeft() ? -dx : dx;
1431 int oldOffset =
d->horizontalHeader->offset();
1434 int newOffset =
d->horizontalHeader->offset();
1435 dx = isRightToLeft() ? newOffset - oldOffset : oldOffset - newOffset;
1439 int oldOffset =
d->verticalHeader->offset();
1442 int newOffset =
d->verticalHeader->offset();
1443 dy = oldOffset - newOffset;
1446 d->scrollContentsBy(dx, dy);
1452 if (dy > 0 &&
d->horizontalHeader->isHidden()) {
1453 d->viewport->update(0, dy,
d->viewport->width(), dy);
1455 if (dx > 0 &&
d->verticalHeader->isHidden()) {
1456 d->viewport->update(dx, 0, dx,
d->viewport->height());
1467 option->showDecorationSelected =
true;
1477 QStyleOptionViewItem
option;
1481 const int gridSize =
showGrid ? 1 : 0;
1484 const QPen gridPen =
QPen(gridColor, 1,
d->gridStyle);
1487 const bool alternate =
d->alternatingColors;
1488 const bool rightToLeft = isRightToLeft();
1503 if (lastVisualRow == -1)
1504 lastVisualRow =
d->model->rowCount(
d->root) - 1;
1509 qSwap(firstVisualColumn, lastVisualColumn);
1510 if (firstVisualColumn == -1)
1511 firstVisualColumn = 0;
1512 if (lastVisualColumn == -1)
1515 QBitArray drawn((lastVisualRow - firstVisualRow + 1) * (lastVisualColumn - firstVisualColumn + 1));
1519 if (
d->hasSpans()) {
1521 firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn);
1524 for (
QRect dirtyArea : region) {
1525 dirtyArea.setBottom(
qMin(dirtyArea.bottom(),
int(
y)));
1527 dirtyArea.setLeft(
qMax(dirtyArea.left(),
d->viewport->width() -
int(
x)));
1529 dirtyArea.setRight(
qMin(dirtyArea.right(),
int(
x)));
1532 if (!dirtyArea.isValid())
1547 bool alternateBase =
false;
1556 alternateBase = !alternateBase;
1560 alternateBase = (
top & 1) && alternate;
1566 for (
int visualRowIndex =
top; visualRowIndex <=
bottom; ++visualRowIndex) {
1575 for (
int visualColumnIndex =
left; visualColumnIndex <=
right; ++visualColumnIndex) {
1576 int currentBit = (visualRowIndex - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1)
1577 + visualColumnIndex - firstVisualColumn;
1579 if (currentBit < 0 || currentBit >= drawn.
size() || drawn.
testBit(currentBit))
1581 drawn.
setBit(currentBit);
1591 if (
index.isValid()) {
1595 option.features |= QStyleOptionViewItem::Alternate;
1597 option.features &= ~QStyleOptionViewItem::Alternate;
1602 alternateBase = !alternateBase && alternate;
1611 for (
int visualIndex =
top; visualIndex <=
bottom; ++visualIndex) {
1618 QLineF line(dirtyArea.left(), rowY + rowh, dirtyArea.right(), rowY + rowh);
1631 QLineF line(colp, dirtyArea.top(), colp, dirtyArea.bottom());
1640 if (rowY == dirtyArea.top())
1648 if (!isLeftToRight())
1650 if (isLeftToRight() && colX == dirtyArea.left())
1652 if (!isLeftToRight() && colX == dirtyArea.right())
1660#if QT_CONFIG(draganddrop)
1673 d->executePostedLayout();
1676 if (
r >= 0 &&
c >= 0) {
1677 if (
d->hasSpans()) {
1682 return d->model->index(
r,
c,
d->root);
1698 return d->horizontalHeader->offset();
1712 return d->verticalHeader->offset();
1728 int bottom =
d->model->rowCount(
d->root) - 1;
1733 int right =
d->model->columnCount(
d->root) - 1;
1751 return d->model->index(
d->logicalRow(
row),
d->logicalColumn(
column),
d->root);
1755 QPoint visualCurrent(
d->visualColumn(current.
column()),
d->visualRow(current.
row()));
1756 if (visualCurrent !=
d->visualCursor) {
1757 if (
d->hasSpans()) {
1759 if (
span.top() >
d->visualCursor.y() ||
d->visualCursor.y() >
span.bottom()
1760 ||
span.left() >
d->visualCursor.x() ||
d->visualCursor.x() >
span.right())
1761 d->visualCursor = visualCurrent;
1763 d->visualCursor = visualCurrent;
1767 int visualRow =
d->visualCursor.y();
1771 int visualColumn =
d->visualCursor.x();
1772 if (visualColumn >
right)
1773 visualColumn =
right;
1776 if (isRightToLeft()) {
1783 switch (cursorAction) {
1785 int originalRow = visualRow;
1786#ifdef QT_KEYPAD_NAVIGATION
1787 if (QApplicationPrivate::keypadNavigationEnabled() && visualRow == 0)
1788 visualRow =
d->visualRow(
model()->rowCount() - 1) + 1;
1791 int r =
d->logicalRow(visualRow);
1792 int c =
d->logicalColumn(visualColumn);
1793 if (
r != -1 &&
d->hasSpans()) {
1795 if (
span.width() > 1 ||
span.height() > 1)
1796 visualRow =
d->visualRow(
span.top());
1798 while (visualRow >= 0) {
1800 r =
d->logicalRow(visualRow);
1801 c =
d->logicalColumn(visualColumn);
1806 visualRow = originalRow;
1810 int originalRow = visualRow;
1811 if (
d->hasSpans()) {
1813 visualRow =
d->visualRow(
d->rowSpanEndLogical(
span.top(),
span.height()));
1815#ifdef QT_KEYPAD_NAVIGATION
1816 if (QApplicationPrivate::keypadNavigationEnabled() && visualRow >=
bottom)
1819 int r =
d->logicalRow(visualRow);
1820 int c =
d->logicalColumn(visualColumn);
1821 if (
r != -1 &&
d->hasSpans()) {
1823 if (
span.width() > 1 ||
span.height() > 1)
1824 visualRow =
d->visualRow(
d->rowSpanEndLogical(
span.top(),
span.height()));
1826 while (visualRow <=
bottom) {
1828 r =
d->logicalRow(visualRow);
1829 c =
d->logicalColumn(visualColumn);
1834 visualRow = originalRow;
1839 int originalRow = visualRow;
1840 int originalColumn = visualColumn;
1841 bool firstTime =
true;
1842 bool looped =
false;
1843 bool wrapped =
false;
1845 int r =
d->logicalRow(visualRow);
1846 int c =
d->logicalColumn(visualColumn);
1847 if (firstTime &&
c != -1 &&
d->hasSpans()) {
1850 if (
span.width() > 1 ||
span.height() > 1)
1851 visualColumn =
d->visualColumn(
span.left());
1853 while (visualColumn >= 0) {
1855 r =
d->logicalRow(visualRow);
1856 c =
d->logicalColumn(visualColumn);
1859 if (wrapped && (originalRow < visualRow || (originalRow == visualRow && originalColumn <= visualColumn))) {
1864 if (cursorAction ==
MoveLeft || visualColumn >= 0)
1866 visualColumn =
right + 1;
1867 if (visualRow == 0) {
1874 if (visualColumn < 0)
1875 visualColumn = originalColumn;
1880 int originalRow = visualRow;
1881 int originalColumn = visualColumn;
1882 bool firstTime =
true;
1883 bool looped =
false;
1884 bool wrapped =
false;
1886 int r =
d->logicalRow(visualRow);
1887 int c =
d->logicalColumn(visualColumn);
1888 if (firstTime &&
c != -1 &&
d->hasSpans()) {
1891 if (
span.width() > 1 ||
span.height() > 1)
1892 visualColumn =
d->visualColumn(
d->columnSpanEndLogical(
span.left(),
span.width()));
1894 while (visualColumn <=
right) {
1896 r =
d->logicalRow(visualRow);
1897 c =
d->logicalColumn(visualColumn);
1900 if (wrapped && (originalRow > visualRow || (originalRow == visualRow && originalColumn >= visualColumn))) {
1908 if (visualRow ==
bottom) {
1915 if (visualColumn >
right)
1916 visualColumn = originalColumn;
1920 visualColumn =
d->nextActiveVisualColumn(visualRow, 0,
right,
1923 visualRow =
d->nextActiveVisualRow(0, visualColumn,
bottom,
1927 visualColumn =
d->nextActiveVisualColumn(visualRow,
right, -1,
1930 visualRow =
d->nextActiveVisualRow(
bottom, visualColumn, -1,
1935 int visualRow = (newLogicalRow == -1 ? 0 :
d->visualRow(newLogicalRow));
1936 visualRow =
d->nextActiveVisualRow(visualRow, current.
column(),
bottom,
1938 newLogicalRow =
d->logicalRow(visualRow);
1939 return d->model->index(newLogicalRow, current.
column(),
d->root);
1943 int visualRow = (newLogicalRow == -1 ?
bottom :
d->visualRow(newLogicalRow));
1944 visualRow =
d->nextActiveVisualRow(visualRow, current.
column(), -1,
1946 newLogicalRow =
d->logicalRow(visualRow);
1947 return d->model->index(newLogicalRow, current.
column(),
d->root);
1950 d->visualCursor =
QPoint(visualColumn, visualRow);
1951 int logicalRow =
d->logicalRow(visualRow);
1952 int logicalColumn =
d->logicalColumn(visualColumn);
1953 if (!
d->model->hasIndex(logicalRow, logicalColumn,
d->root))
1957 if (!
d->isRowHidden(logicalRow) && !
d->isColumnHidden(logicalColumn) &&
d->isIndexEnabled(
result)) {
1958 if (
d->hasSpans()) {
1960 if (
span.width() > 1 ||
span.height() > 1) {
1984 if (!
d->selectionModel || !tl.
isValid() || !br.
isValid() || !
d->isIndexEnabled(tl) || !
d->isIndexEnabled(br))
1992 if (
d->hasSpans()) {
1996 bool intersectsSpan =
false;
2005 int t =
d->visualRow(
span.top());
2006 int l =
d->visualColumn(
span.left());
2007 int b =
d->visualRow(
d->rowSpanEndLogical(
span.top(),
span.height()));
2008 int r =
d->visualColumn(
d->columnSpanEndLogical(
span.left(),
span.width()));
2011 intersectsSpan =
true;
2032 if (intersectsSpan) {
2034 for (
int horizontal =
left; horizontal <=
right; ++horizontal) {
2035 int column =
d->logicalColumn(horizontal);
2036 for (
int vertical =
top; vertical <=
bottom; ++vertical) {
2037 int row =
d->logicalRow(vertical);
2044 if (!
range.isEmpty())
2047 }
else if (verticalMoved && horizontalMoved) {
2048 int top =
d->visualRow(tl.
row());
2053 for (
int horizontal =
left; horizontal <=
right; ++horizontal) {
2054 int column =
d->logicalColumn(horizontal);
2055 for (
int vertical =
top; vertical <=
bottom; ++vertical) {
2056 int row =
d->logicalRow(vertical);
2061 }
else if (horizontalMoved) {
2065 for (
int visual =
left; visual <=
right; ++visual) {
2066 int column =
d->logicalColumn(visual);
2071 }
else if (verticalMoved) {
2072 int top =
d->visualRow(tl.
row());
2075 for (
int visual =
top; visual <=
bottom; ++visual) {
2076 int row =
d->logicalRow(visual);
2083 if (!
range.isEmpty())
2087 d->selectionModel->select(
selection, command);
2107 const QRect &viewportRect =
d->viewport->rect();
2111 if ((verticalMoved && horizontalMoved) || (
d->hasSpans() && (verticalMoved || horizontalMoved))) {
2113 if (
range.parent() !=
d->root || !
range.isValid())
2119 selectionRegion += rangeRect;
2122 }
else if (horizontalMoved) {
2124 if (
range.parent() !=
d->root || !
range.isValid())
2134 selectionRegion += rangeRect;
2137 }
else if (verticalMoved) {
2139 if (
range.parent() !=
d->root || !
range.isValid())
2149 selectionRegion += rangeRect;
2153 const int gridAdjust =
showGrid() ? 1 : 0;
2155 if (
range.parent() !=
d->root || !
range.isValid())
2157 d->trimHiddenSelections(&
range);
2163 if (isLeftToRight()) {
2170 const QRect rangeRect(
QPoint(rleft, rtop),
QPoint(rright - 1 - gridAdjust, rbottom - 1 - gridAdjust));
2172 selectionRegion += rangeRect;
2173 if (
d->hasSpans()) {
2174 const auto spansInRect =
d->spans.spansInRect(
range.left(),
range.top(),
range.width(),
range.height());
2176 if (
range.contains(
s->top(),
s->left(),
range.parent())) {
2177 const QRect &visualSpanRect =
d->visualSpanRect(*
s);
2179 selectionRegion += visualSpanRect;
2186 return selectionRegion;
2198 if (
d->selectionModel)
2199 modelSelected =
d->selectionModel->selectedIndexes();
2200 for (
int i = 0;
i < modelSelected.
size(); ++
i) {
2205 return viewSelected;
2219 if (newCount < oldCount)
2220 d->verticalHeader->setUpdatesEnabled(
false);
2221 d->doDelayedItemsLayout();
2234 d->horizontalHeader->setOffsetToSectionPosition(horizontalScrollBar()->
value());
2236 d->horizontalHeader->setOffset(horizontalScrollBar()->
value());
2237 d->viewport->update();
2246 if (
d->geometryRecursionBlock)
2248 d->geometryRecursionBlock =
true;
2251 if (!
d->verticalHeader->isHidden()) {
2252 width =
qMax(
d->verticalHeader->minimumWidth(),
d->verticalHeader->sizeHint().width());
2256 if (!
d->horizontalHeader->isHidden()) {
2257 height =
qMax(
d->horizontalHeader->minimumHeight(),
d->horizontalHeader->sizeHint().height());
2260 bool reverse = isRightToLeft();
2268 QRect vg =
d->viewport->geometry();
2270 int verticalLeft = reverse ? vg.
right() + 1 : (vg.
left() -
width);
2271 d->verticalHeader->setGeometry(verticalLeft, vg.
top(),
width, vg.
height());
2272 if (
d->verticalHeader->isHidden())
2276 d->horizontalHeader->setGeometry(vg.
left(), horizontalTop, vg.
width(),
height);
2277 if (
d->horizontalHeader->isHidden())
2280#if QT_CONFIG(abstractbutton)
2282 if (
d->horizontalHeader->isHidden() ||
d->verticalHeader->isHidden()) {
2283 d->cornerWidget->setHidden(
true);
2285 d->cornerWidget->setHidden(
false);
2286 d->cornerWidget->setGeometry(verticalLeft, horizontalTop,
width,
height);
2293 QSize vsize =
d->viewport->size();
2294 QSize max = maximumViewportSize();
2295 const int horizontalLength =
d->horizontalHeader->length();
2296 const int verticalLength =
d->verticalHeader->length();
2297 if (max.
width() >= horizontalLength && max.
height() >= verticalLength)
2301 const int columnCount =
d->horizontalHeader->count();
2302 const int viewportWidth = vsize.
width();
2303 int columnsInViewport = 0;
2305 int logical =
d->horizontalHeader->logicalIndex(
column);
2306 if (!
d->horizontalHeader->isSectionHidden(logical)) {
2307 width +=
d->horizontalHeader->sectionSize(logical);
2308 if (
width > viewportWidth)
2310 ++columnsInViewport;
2313 columnsInViewport =
qMax(columnsInViewport, 1);
2316 const int visibleColumns = columnCount -
d->horizontalHeader->hiddenSectionCount();
2317 horizontalScrollBar()->setRange(0, visibleColumns - columnsInViewport);
2318 horizontalScrollBar()->setPageStep(columnsInViewport);
2319 if (columnsInViewport >= visibleColumns)
2320 d->horizontalHeader->setOffset(0);
2321 horizontalScrollBar()->setSingleStep(1);
2323 horizontalScrollBar()->setPageStep(vsize.
width());
2324 horizontalScrollBar()->setRange(0, horizontalLength - vsize.
width());
2325 horizontalScrollBar()->d_func()->itemviewChangeSingleStep(
qMax(vsize.
width() / (columnsInViewport + 1), 2));
2329 const int rowCount =
d->verticalHeader->count();
2330 const int viewportHeight = vsize.
height();
2331 int rowsInViewport = 0;
2333 int logical =
d->verticalHeader->logicalIndex(
row);
2334 if (!
d->verticalHeader->isSectionHidden(logical)) {
2335 height +=
d->verticalHeader->sectionSize(logical);
2336 if (
height > viewportHeight)
2341 rowsInViewport =
qMax(rowsInViewport, 1);
2344 const int visibleRows = rowCount -
d->verticalHeader->hiddenSectionCount();
2345 verticalScrollBar()->setRange(0, visibleRows - rowsInViewport);
2346 verticalScrollBar()->setPageStep(rowsInViewport);
2347 if (rowsInViewport >= visibleRows)
2348 d->verticalHeader->setOffset(0);
2349 verticalScrollBar()->setSingleStep(1);
2351 verticalScrollBar()->setPageStep(vsize.
height());
2352 verticalScrollBar()->setRange(0, verticalLength - vsize.
height());
2353 verticalScrollBar()->d_func()->itemviewChangeSingleStep(
qMax(vsize.
height() / (rowsInViewport + 1), 2));
2357 d->geometryRecursionBlock =
false;
2383 const int maximumProcessCols =
d->verticalHeader->resizeContentsPrecision();
2386 int left =
qMax(0,
d->horizontalHeader->visualIndexAt(0));
2387 int right =
d->horizontalHeader->visualIndexAt(
d->viewport->width());
2389 right =
d->model->columnCount(
d->root) - 1;
2391 QStyleOptionViewItem
option;
2396 int columnsProcessed = 0;
2399 int logicalColumn =
d->horizontalHeader->logicalIndex(
column);
2400 if (
d->horizontalHeader->isSectionHidden(logicalColumn))
2402 index =
d->model->index(
row, logicalColumn,
d->root);
2406 if (columnsProcessed == maximumProcessCols)
2410 int actualRight =
d->model->columnCount(
d->root) - 1;
2412 int idxRight =
column - 1;
2414 if (maximumProcessCols == 0)
2415 columnsProcessed = 0;
2417 while (columnsProcessed != maximumProcessCols && (idxLeft > 0 || idxRight < actualRight)) {
2418 int logicalIdx = -1;
2420 if ((columnsProcessed % 2 && idxLeft > 0) || idxRight == actualRight) {
2421 while (idxLeft > 0) {
2423 int logcol =
d->horizontalHeader->logicalIndex(idxLeft);
2424 if (
d->horizontalHeader->isSectionHidden(logcol))
2426 logicalIdx = logcol;
2430 while (idxRight < actualRight) {
2432 int logcol =
d->horizontalHeader->logicalIndex(idxRight);
2433 if (
d->horizontalHeader->isSectionHidden(logcol))
2435 logicalIdx = logcol;
2442 index =
d->model->index(
row, logicalIdx,
d->root);
2473 const int maximumProcessRows =
d->horizontalHeader->resizeContentsPrecision();
2475 int top =
qMax(0,
d->verticalHeader->visualIndexAt(0));
2476 int bottom =
d->verticalHeader->visualIndexAt(
d->viewport->height());
2478 bottom =
d->model->rowCount(
d->root) - 1;
2480 QStyleOptionViewItem
option;
2484 int rowsProcessed = 0;
2488 int logicalRow =
d->verticalHeader->logicalIndex(
row);
2489 if (
d->verticalHeader->isSectionHidden(logicalRow))
2495 if (rowsProcessed == maximumProcessRows)
2499 int actualBottom =
d->model->rowCount(
d->root) - 1;
2501 int idxBottom =
row - 1;
2503 if (maximumProcessRows == 0)
2506 while (rowsProcessed != maximumProcessRows && (idxTop > 0 || idxBottom < actualBottom)) {
2507 int logicalIdx = -1;
2509 if ((rowsProcessed % 2 && idxTop > 0) || idxBottom == actualBottom) {
2510 while (idxTop > 0) {
2512 int logrow =
d->verticalHeader->logicalIndex(idxTop);
2513 if (
d->verticalHeader->isSectionHidden(logrow))
2515 logicalIdx = logrow;
2519 while (idxBottom < actualBottom) {
2521 int logrow =
d->verticalHeader->logicalIndex(idxBottom);
2522 if (
d->verticalHeader->isSectionHidden(logrow))
2524 logicalIdx = logrow;
2546 return d->verticalHeader->sectionViewportPosition(
row);
2561 return d->verticalHeader->logicalIndexAt(
y);
2572 d->verticalHeader->resizeSection(
row,
height);
2583 return d->verticalHeader->sectionSize(
row);
2593 return d->horizontalHeader->sectionViewportPosition(
column);
2608 return d->horizontalHeader->logicalIndexAt(
x);
2630 return d->horizontalHeader->sectionSize(
column);
2641 return d->verticalHeader->isSectionHidden(
row);
2652 if (row < 0 || row >=
d->verticalHeader->count())
2654 d->verticalHeader->setSectionHidden(
row,
hide);
2665 return d->horizontalHeader->isSectionHidden(
column);
2677 if (column < 0 || column >=
d->horizontalHeader->count())
2679 d->horizontalHeader->setSectionHidden(
column,
hide);
2709 this,
SLOT(_q_selectColumn(
int)));
2732 return d->sortingEnabled;
2751 if (
d->showGrid !=
show) {
2753 d->viewport->update();
2766 return d->gridStyle;
2772 if (
d->gridStyle != style) {
2773 d->gridStyle = style;
2774 d->viewport->update();
2795 if (
d->wrapItemText == on)
2797 d->wrapItemText = on;
2805 return d->wrapItemText;
2808#if QT_CONFIG(abstractbutton)
2820void QTableView::setCornerButtonEnabled(
bool enable)
2823 d->cornerWidget->setEnabled(
enable);
2826bool QTableView::isCornerButtonEnabled()
const
2829 return d->cornerWidget->isEnabled();
2843 if (!
d->isIndexValid(
index) ||
index.parent() !=
d->root
2847 d->executePostedLayout();
2849 if (
d->hasSpans()) {
2851 return d->visualSpanRect(
span);
2860 return QRect(colp, rowp, colw -
i, rowh -
i);
2874 if (!
d->isIndexValid(
index)
2875 || (
d->model->parent(
index) !=
d->root)
2885 int viewportWidth =
d->viewport->width();
2887 int horizontalPosition =
d->horizontalHeader->sectionPosition(
index.column());
2888 int horizontalIndex =
d->horizontalHeader->visualIndex(
index.column());
2889 int cellWidth =
d->hasSpans()
2890 ?
d->columnSpanWidth(
index.column(),
span.width())
2891 :
d->horizontalHeader->sectionSize(
index.column());
2896 bool positionAtRight = (horizontalPosition -
horizontalOffset + cellWidth > viewportWidth);
2901 while (horizontalIndex > 0) {
2902 x +=
columnWidth(
d->horizontalHeader->logicalIndex(horizontalIndex-1));
2910 int hiddenSections = 0;
2911 if (
d->horizontalHeader->sectionsHidden()) {
2912 for (
int s = horizontalIndex - 1;
s >= 0; --
s) {
2913 int column =
d->horizontalHeader->logicalIndex(
s);
2914 if (
d->horizontalHeader->isSectionHidden(
column))
2918 horizontalScrollBar()->setValue(horizontalIndex - hiddenSections);
2923 horizontalScrollBar()->setValue(horizontalPosition - ((viewportWidth - cellWidth) / 2));
2925 if (horizontalPosition - horizontalOffset < 0 || cellWidth > viewportWidth)
2926 horizontalScrollBar()->setValue(horizontalPosition);
2927 else if (horizontalPosition -
horizontalOffset + cellWidth > viewportWidth)
2928 horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth);
2934 int viewportHeight =
d->viewport->height();
2936 int verticalPosition =
d->verticalHeader->sectionPosition(
index.row());
2937 int verticalIndex =
d->verticalHeader->visualIndex(
index.row());
2938 int cellHeight =
d->hasSpans()
2939 ?
d->rowSpanHeight(
index.row(),
span.height())
2940 :
d->verticalHeader->sectionSize(
index.row());
2942 if (verticalPosition - verticalOffset < 0 || cellHeight > viewportHeight) {
2945 }
else if (verticalPosition -
verticalOffset + cellHeight > viewportHeight) {
2955 while (verticalIndex > 0) {
2956 int row =
d->verticalHeader->logicalIndex(verticalIndex - 1);
2957 y +=
d->verticalHeader->sectionSize(
row);
2965 int hiddenSections = 0;
2966 if (
d->verticalHeader->sectionsHidden()) {
2967 for (
int s = verticalIndex - 1;
s >= 0; --
s) {
2968 int row =
d->verticalHeader->logicalIndex(
s);
2969 if (
d->verticalHeader->isSectionHidden(
row))
2973 verticalScrollBar()->setValue(verticalIndex - hiddenSections);
2978 verticalScrollBar()->setValue(verticalPosition);
2980 verticalScrollBar()->setValue(verticalPosition - viewportHeight + cellHeight);
2982 verticalScrollBar()->setValue(verticalPosition - ((viewportHeight - cellHeight) / 2));
2999 d->rowsToUpdate.append(
row);
3000 if (
d->rowResizeTimerID == 0)
3001 d->rowResizeTimerID = startTimer(0);
3014 d->columnsToUpdate.append(
column);
3015 if (
d->columnResizeTimerID == 0)
3016 d->columnResizeTimerID = startTimer(0);
3026 if (
event->timerId() ==
d->columnResizeTimerID) {
3027 const int oldScrollMax = horizontalScrollBar()->maximum();
3030 killTimer(
d->columnResizeTimerID);
3031 d->columnResizeTimerID = 0;
3037 int viewportHeight =
d->viewport->height();
3038 int viewportWidth =
d->viewport->width();
3039 if (
d->hasSpans() || horizontalScrollBar()->
value() == oldScrollMax) {
3040 rect =
QRect(0, 0, viewportWidth, viewportHeight);
3042 for (
int i =
d->columnsToUpdate.size()-1;
i >= 0; --
i) {
3043 int column =
d->columnsToUpdate.at(
i);
3045 if (isRightToLeft())
3048 rect |=
QRect(
x, 0, viewportWidth -
x, viewportHeight);
3052 d->viewport->update(
rect.normalized());
3053 d->columnsToUpdate.clear();
3056 if (
event->timerId() ==
d->rowResizeTimerID) {
3057 const int oldScrollMax = verticalScrollBar()->maximum();
3060 killTimer(
d->rowResizeTimerID);
3061 d->rowResizeTimerID = 0;
3066 int viewportHeight =
d->viewport->height();
3067 int viewportWidth =
d->viewport->width();
3069 if (
d->hasSpans() || verticalScrollBar()->
value() == oldScrollMax) {
3072 top = viewportHeight;
3073 for (
int i =
d->rowsToUpdate.size()-1;
i >= 0; --
i) {
3079 d->viewport->update(
QRect(0,
top, viewportWidth, viewportHeight -
top));
3080 d->rowsToUpdate.clear();
3099 int logicalOldIndex =
d->verticalHeader->logicalIndex(oldIndex);
3100 int logicalNewIndex =
d->verticalHeader->logicalIndex(newIndex);
3101 if (
d->hasSpans()) {
3102 d->viewport->update();
3106 int oldBottom = oldTop +
rowHeight(logicalOldIndex);
3107 int newBottom = newTop +
rowHeight(logicalNewIndex);
3108 int top =
qMin(oldTop, newTop);
3111 d->viewport->update(0,
top,
d->viewport->width(),
height);
3128 int logicalOldIndex =
d->horizontalHeader->logicalIndex(oldIndex);
3129 int logicalNewIndex =
d->horizontalHeader->logicalIndex(newIndex);
3130 if (
d->hasSpans()) {
3131 d->viewport->update();
3135 int oldRight = oldLeft +
columnWidth(logicalOldIndex);
3136 int newRight = newLeft +
columnWidth(logicalNewIndex);
3140 d->viewport->update(
left, 0,
width,
d->viewport->height());
3153 d->selectRow(
row,
true);
3165 d->selectColumn(
column,
true);
3176 d->verticalHeader->hideSection(
row);
3187 d->horizontalHeader->hideSection(
column);
3198 d->verticalHeader->showSection(
row);
3209 d->horizontalHeader->showSection(
column);
3222 int header =
d->verticalHeader->sectionSizeHint(
row);
3286 if (!
d->sortingEnabled ||
3287 (
d->horizontalHeader->sortIndicatorSection() ==
column &&
d->horizontalHeader->sortIndicatorOrder() ==
order))
3316 if (
d->hasSpans()) {
3338 d->viewport->update();
3381 d->viewport->update();
3403 if (
row >= 0 && row < model->rowCount(
root)) {
3406 QItemSelectionModel::SelectionFlags command =
q->selectionCommand(
index);
3443 if (
column >= 0 && column < model->columnCount(
root)) {
3446 QItemSelectionModel::SelectionFlags command =
q->selectionCommand(
index);
3479#if QT_CONFIG(accessibility)
3480 if (QAccessible::isActive()) {
3483 int entry =
d->accessibleTable2Index(current);
3484 QAccessibleEvent
event(
this, QAccessible::Focus);
3485 event.setChild(
entry);
3486 QAccessible::updateAccessibility(&
event);
3501#if QT_CONFIG(accessibility)
3502 if (QAccessible::isActive()) {
3506 int entry =
d->accessibleTable2Index(sel);
3507 QAccessibleEvent
event(
this, QAccessible::SelectionAdd);
3508 event.setChild(
entry);
3509 QAccessible::updateAccessibility(&
event);
3513 int entry =
d->accessibleTable2Index(desel);
3514 QAccessibleEvent
event(
this, QAccessible::SelectionRemove);
3515 event.setChild(
entry);
3516 QAccessible::updateAccessibility(&
event);
3530#include "qtableview.moc"
3532#include "moc_qtableview.cpp"
static QAbstractItemModel * staticEmptyModel()
virtual Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
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.
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)
virtual void selectAll(QItemSelectionModel::SelectionFlags command)
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 rowsInserted(const QModelIndex &parent, int start, int end)
This slot is called when rows are inserted.
virtual void updateEditorGeometries()
QItemSelectionModel * selectionModel() const
Returns the current selection model.
virtual void updateGeometries()
virtual void horizontalScrollbarAction(int action)
bool testBit(qsizetype i) const
Returns true if the bit at index position i is 1; otherwise returns false.
void setBit(qsizetype i)
Sets the bit at index position i to 1.
qsizetype size() const
Returns the number of bits stored in the bit array.
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().
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.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
T value(qsizetype i) const
void reserve(qsizetype size)
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
iterator erase(const_iterator it)
constexpr int row() const noexcept
Returns the row this model 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 QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\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
\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.
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 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 right(qsizetype n) const
Returns a substring that contains the n rightmost characters of the string.
qsizetype count(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
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
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given element with the provided painter with the style options specified by option.
QRect visualSpanRect(const QSpanCollection::Span &span) const
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)
QHeaderView * horizontalHeader
bool isRowHidden(int row) const
bool isCellEnabled(int row, int column) const
void _q_selectColumn(int column)
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
void _q_updateSpanInsertedRows(const QModelIndex &parent, int start, int end)
void selectColumn(int column, bool anchor)
void trimHiddenSelections(QItemSelectionRange *range) const
void _q_updateSpanInsertedColumns(const QModelIndex &parent, int start, int end)
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
void _q_updateSpanRemovedRows(const QModelIndex &parent, int start, int end)
int sectionSpanEndLogical(const QHeaderView *header, int logical, int span) const
void _q_updateSpanRemovedColumns(const QModelIndex &parent, int start, int end)
void selectRow(int row, bool anchor)
int rowSpan(int row, int column) const
QRect intersectedRect(const QRect rect, const QModelIndex &topLeft, const QModelIndex &bottomRight) const override
int visualColumn(int logicalCol) const
void _q_sortIndicatorChanged(int column, Qt::SortOrder order)
void _q_selectRow(int row)
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.
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 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 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 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.
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)
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
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent