44 #ifndef QT_NO_TABLEVIEW 55 #include <private/qtableview_p.h> 56 #ifndef QT_NO_ACCESSIBILITY 69 if (it_y ==
index.
end() || it_y.key() != -span->
top()) {
76 foreach(
Span *s, previousList) {
87 while(-it_y.key() <= span->
bottom()) {
88 (*it_y).insert(-span->
left(), span);
105 if (old_height < span->height()) {
109 while (-it_y.key() <= span->
bottom()) {
110 (*it_y).insert(-span->
left(), span);
115 }
else if (old_height > span->
height()) {
119 while (-it_y.key() <= span->
top() + old_height -1) {
120 if (-it_y.key() > span->
bottom()) {
121 int removed = (*it_y).remove(-span->
left());
123 if (it_y->isEmpty()) {
148 if (it_x == (*it_y).end())
176 while(-it_y.key() <= y + h) {
178 if (it_x == (*it_y).end())
180 while(-it_x.
key() <= x + w) {
184 if (it_x == (*it_y).begin())
195 #undef DEBUG_SPAN_UPDATE 197 #ifdef DEBUG_SPAN_UPDATE 200 str <<
"(" << span.
top() <<
"," << span.
left() <<
"," << span.
bottom() <<
"," << span.
right() <<
")";
210 #ifdef DEBUG_SPAN_UPDATE 218 int delta = end - start + 1;
219 #ifdef DEBUG_SPAN_UPDATE 224 #ifdef DEBUG_SPAN_UPDATE 225 qDebug() << span << *span;
227 if (span->m_bottom < start)
229 if (span->m_top >= start)
230 span->
m_top += delta;
231 span->m_bottom += delta;
234 #ifdef DEBUG_SPAN_UPDATE 237 qDebug() << span << *span;
250 #ifdef DEBUG_SPAN_UPDATE 260 #ifdef DEBUG_SPAN_UPDATE 268 int delta = end - start + 1;
269 #ifdef DEBUG_SPAN_UPDATE 274 #ifdef DEBUG_SPAN_UPDATE 275 qDebug() << span << *span;
277 if (span->m_right < start)
279 if (span->m_left >= start)
281 span->m_right += delta;
284 #ifdef DEBUG_SPAN_UPDATE 287 qDebug() << span << *span;
298 subindex.
insert(-x - delta,
it.value());
302 #ifdef DEBUG_SPAN_UPDATE 317 bool should_be_deleted =
true;
324 it = subindex.
erase(it);
327 if (update && span->
m_left != x) {
329 it = subindex.
erase(it);
331 if (should_be_deleted && span->
m_top == y)
332 should_be_deleted =
false;
333 }
while (it != subindex.
begin());
335 return should_be_deleted;
343 #ifdef DEBUG_SPAN_UPDATE 352 int delta = end - start + 1;
353 #ifdef DEBUG_SPAN_UPDATE 358 #ifdef DEBUG_SPAN_UPDATE 359 qDebug() << span << *span;
361 if (span->m_bottom < start) {
365 if (span->m_top < start) {
366 if (span->m_bottom <= end)
367 span->m_bottom = start - 1;
369 span->m_bottom -= delta;
371 if (span->m_bottom > end) {
372 if (span->m_top <= end)
375 span->m_top -= delta;
376 span->m_bottom -= delta;
378 span->will_be_deleted =
true;
381 if (span->m_top == span->m_bottom && span->m_left == span->m_right)
382 span->will_be_deleted =
true;
383 if (span->will_be_deleted) {
384 spansToBeDeleted.
append(span);
391 #ifdef DEBUG_SPAN_UPDATE 394 qDebug() << span << *span;
410 }
else if (y >= start && y <= end) {
411 bool span_at_start =
false;
417 if (!span_at_start && span->
m_top == start)
418 span_at_start =
true;
419 spansToBeMoved.
insert(
it.key(), span);
422 if (y == start && span_at_start)
448 it_top.value().insert(
it.key(), span);
458 #ifdef DEBUG_SPAN_UPDATE 462 qDebug() << span << *span;
472 #ifdef DEBUG_SPAN_UPDATE 481 int delta = end - start + 1;
482 #ifdef DEBUG_SPAN_UPDATE 487 #ifdef DEBUG_SPAN_UPDATE 488 qDebug() << span << *span;
490 if (span->m_right < start) {
494 if (span->m_left < start) {
495 if (span->m_right <= end)
496 span->m_right = start - 1;
498 span->m_right -= delta;
500 if (span->m_right > end) {
501 if (span->m_left <= end)
502 span->m_left = start;
504 span->m_left -= delta;
505 span->m_right -= delta;
507 span->will_be_deleted =
true;
510 if (span->m_top == span->m_bottom && span->m_left == span->m_right)
511 span->will_be_deleted =
true;
512 if (span->will_be_deleted) {
520 #ifdef DEBUG_SPAN_UPDATE 523 qDebug() << span << *span;
539 #ifdef DEBUG_SPAN_UPDATE 543 qDebug() << span << *span;
548 #ifdef QT_BUILD_INTERNAL 556 bool QSpanCollection::checkConsistency()
const 565 || y < span->
top() || y > span->
bottom())
574 for (
int y = span->
top(); y <= span->
bottom(); ++y) {
577 if (y == span->
top())
584 if (it == subIndex.
end() || it.
value() != span)
603 if (isActiveWindow())
624 q->setVerticalHeader(vertical);
629 q->setHorizontalHeader(horizontal);
631 tabKeyNavigation =
true;
649 int top = range->
top();
651 int bottom = range->
bottom();
654 while (bottom >= top && verticalHeader->isSectionHidden(bottom))
656 while (right >= left && horizontalHeader->isSectionHidden(right))
659 if (top > bottom || left > right) {
664 while (verticalHeader->isSectionHidden(top) && top <= bottom)
666 while (horizontalHeader->isSectionHidden(left) && left <=
right)
669 if (top > bottom || left > right) {
688 if (row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0) {
689 qWarning() <<
"QTableView::setSpan: invalid span given: (" << row <<
',' << column <<
',' << rowSpan <<
',' << columnSpan <<
')';
694 if (sp->
top() != row || sp->
left() != column) {
695 qWarning() <<
"QTableView::setSpan: span cannot overlap";
698 if (rowSpan == 1 && columnSpan == 1) {
699 rowSpan = columnSpan = 0;
701 const int old_height = sp->
height();
703 sp->
m_right = column + columnSpan - 1;
704 spans.updateSpan(sp, old_height);
706 }
else if (rowSpan == 1 && columnSpan == 1) {
707 qWarning() <<
"QTableView::setSpan: single cell span won't be added";
740 for (
int i = 1; i < span; ) {
741 if (++visual >= header->
count())
759 int endLogical = sectionSpanEndLogical(header, logical, span);
776 if (logical == spanLogical)
779 for (
int i = 1; i < span; ) {
780 if (++visual >= header->
count())
783 if (logical == spanLogical)
801 int row = span.
top();
802 int rowp = verticalHeader->sectionViewportPosition(row);
803 int rowh = rowSpanHeight(row, span.
height());
805 int column = span.
left();
806 int colw = columnSpanWidth(column, span.
width());
807 if (q->isRightToLeft())
808 column = span.
right();
809 int colp = horizontalHeader->sectionViewportPosition(column);
811 const int i = showGrid ? 1 : 0;
812 if (q->isRightToLeft())
813 return QRect(colp + i, rowp, colw - i, rowh - i);
814 return QRect(colp, rowp, colw - i, rowh - i);
828 int firstVisualRow,
int lastVisualRow,
int firstVisualColumn,
int lastVisualColumn)
830 bool alternateBase =
false;
831 QRegion region = viewport->rect();
834 bool sectionMoved = verticalHeader->sectionsMoved() || horizontalHeader->sectionsMoved();
837 visibleSpans =
spans.spansInRect(logicalColumn(firstVisualColumn), logicalRow(firstVisualRow),
838 lastVisualColumn - firstVisualColumn + 1, lastVisualRow - firstVisualRow + 1);
841 for(
int x = firstVisualColumn; x <= lastVisualColumn; x++)
842 for(
int y = firstVisualRow; y <= lastVisualRow; y++)
843 set.insert(
spans.spanAt(x,y));
845 visibleSpans =
set.toList();
849 int row = span->
top();
850 int col = span->
left();
854 QRect rect = visualSpanRect(*span);
860 alternateBase = alternatingColors && (span->
top() & 1);
865 drawCell(painter, opt, index);
867 for (
int r = span->
top(); r <= span->
bottom(); ++r) {
868 const int vr = visualRow(r);
869 if (vr < firstVisualRow || vr > lastVisualRow)
872 const int vc = visualColumn(
c);
873 if (vc < firstVisualColumn || vc > lastVisualColumn)
875 drawn->
setBit((vr - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1)
876 + vc - firstVisualColumn);
894 spans.updateInsertedRows(start, end);
907 spans.updateInsertedColumns(start, end);
920 spans.updateRemovedRows(start, end);
933 spans.updateRemovedColumns(start, end);
948 if (selectionModel && selectionModel->isSelected(index))
963 if (index == q->currentIndex()) {
964 const bool focus = (q->hasFocus() || viewport->hasFocus()) && q->currentIndex().isValid();
971 q->itemDelegate(index)->paint(painter, opt, index);
1106 if (model ==
d->model)
1129 d->verticalHeader->setModel(model);
1130 d->horizontalHeader->setModel(model);
1140 if (index ==
d->root) {
1144 d->verticalHeader->setRootIndex(index);
1145 d->horizontalHeader->setRootIndex(index);
1159 d->verticalHeader->setOffsetToLastSection();
1165 if (!
d->verticalHeader->updatesEnabled())
1166 d->verticalHeader->setUpdatesEnabled(
true);
1176 d->verticalHeader->setSelectionModel(selectionModel);
1177 d->horizontalHeader->setSelectionModel(selectionModel);
1189 return d->horizontalHeader;
1200 return d->verticalHeader;
1212 if (!header || header ==
d->horizontalHeader)
1214 if (
d->horizontalHeader &&
d->horizontalHeader->parent() ==
this)
1215 delete d->horizontalHeader;
1216 d->horizontalHeader = header;
1217 d->horizontalHeader->setParent(
this);
1218 if (!
d->horizontalHeader->model()) {
1219 d->horizontalHeader->setModel(
d->model);
1220 if (
d->selectionModel)
1221 d->horizontalHeader->setSelectionModel(
d->selectionModel);
1228 connect(
d->horizontalHeader,
SIGNAL(sectionCountChanged(
int,
int)),
1231 connect(
d->horizontalHeader,
SIGNAL(sectionEntered(
int)),
this,
SLOT(_q_selectColumn(
int)));
1232 connect(
d->horizontalHeader,
SIGNAL(sectionHandleDoubleClicked(
int)),
1249 if (!header || header ==
d->verticalHeader)
1251 if (
d->verticalHeader &&
d->verticalHeader->parent() ==
this)
1252 delete d->verticalHeader;
1253 d->verticalHeader = header;
1254 d->verticalHeader->setParent(
this);
1255 if (!
d->verticalHeader->model()) {
1256 d->verticalHeader->setModel(
d->model);
1257 if (
d->selectionModel)
1258 d->verticalHeader->setSelectionModel(
d->selectionModel);
1268 connect(
d->verticalHeader,
SIGNAL(sectionEntered(
int)),
this,
SLOT(_q_selectRow(
int)));
1269 connect(
d->verticalHeader,
SIGNAL(sectionHandleDoubleClicked(
int)),
1286 d->delayedAutoScroll.stop();
1291 int oldOffset =
d->horizontalHeader->offset();
1293 d->horizontalHeader->setOffsetToLastSection();
1296 int newOffset =
d->horizontalHeader->offset();
1297 dx =
isRightToLeft() ? newOffset - oldOffset : oldOffset - newOffset;
1304 int oldOffset =
d->verticalHeader->offset();
1306 d->verticalHeader->setOffsetToLastSection();
1309 int newOffset =
d->verticalHeader->offset();
1310 dy = oldOffset - newOffset;
1315 d->scrollContentsBy(dx, dy);
1321 if (dy > 0 &&
d->horizontalHeader->isHidden() &&
d->verticalScrollMode ==
ScrollPerItem) {
1322 d->viewport->update(0, dy,
d->viewport->width(), dy);
1324 if (dx > 0 &&
d->verticalHeader->isHidden() &&
d->horizontalScrollMode ==
ScrollPerItem) {
1325 d->viewport->update(dx, 0, dx,
d->viewport->height());
1348 const QPoint offset =
d->scrollDelayOffset;
1350 const int gridSize = showGrid ? 1 : 0;
1352 const QColor gridColor =
static_cast<QRgb>(gridHint);
1353 const QPen gridPen =
QPen(gridColor, 0,
d->gridStyle);
1356 const bool alternate =
d->alternatingColors;
1362 if (horizontalHeader->
count() == 0 || verticalHeader->
count() == 0 || !
d->itemDelegate)
1365 uint x = horizontalHeader->
length() - horizontalHeader->
offset() - (rightToLeft ? 0 : 1);
1375 if (lastVisualRow == -1)
1376 lastVisualRow =
d->model->rowCount(
d->root) - 1;
1381 qSwap(firstVisualColumn, lastVisualColumn);
1382 if (firstVisualColumn == -1)
1383 firstVisualColumn = 0;
1384 if (lastVisualColumn == -1)
1385 lastVisualColumn = horizontalHeader->
count() - 1;
1387 QBitArray drawn((lastVisualRow - firstVisualRow + 1) * (lastVisualColumn - firstVisualColumn + 1));
1389 if (
d->hasSpans()) {
1390 d->drawAndClipSpans(region, &painter, option, &drawn,
1391 firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn);
1394 for (
int i = 0; i < rects.
size(); ++i) {
1395 QRect dirtyArea = rects.
at(i);
1408 if (left == -1) left = 0;
1409 if (right == -1) right = horizontalHeader->
count() - 1;
1413 if (bottom == -1) bottom = verticalHeader->
count() - 1;
1415 bool alternateBase =
false;
1420 ((
uint)(y += verticalHeader->
sectionSize(top)) <= verticalOffset) && (top < bottom);
1424 alternateBase = !alternateBase;
1428 alternateBase = (top & 1) && alternate;
1430 if (top == -1 || top > bottom)
1434 for (
int visualRowIndex = top; visualRowIndex <= bottom; ++visualRowIndex) {
1435 int row = verticalHeader->
logicalIndex(visualRowIndex);
1443 for (
int visualColumnIndex = left; visualColumnIndex <=
right; ++visualColumnIndex) {
1444 int currentBit = (visualRowIndex - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1)
1445 + visualColumnIndex - firstVisualColumn;
1447 if (currentBit < 0 || currentBit >= drawn.
size() || drawn.
testBit(currentBit))
1449 drawn.
setBit(currentBit);
1451 int col = horizontalHeader->
logicalIndex(visualColumnIndex);
1460 option.
rect =
QRect(colp + (showGrid && rightToLeft ? 1 : 0), rowY, colw, rowh);
1467 d->drawCell(&painter, option, index);
1470 alternateBase = !alternateBase && alternate;
1486 painter.
drawLine(dirtyArea.
left(), rowY + rowh, dirtyArea.
right(), rowY + rowh);
1490 for (
int h = left; h <=
right; ++h) {
1511 #ifndef QT_NO_DRAGANDDROP 1513 d->paintDropIndicator(&painter);
1524 d->executePostedLayout();
1527 if (r >= 0 && c >= 0) {
1528 if (
d->hasSpans()) {
1533 return d->model->index(r, c,
d->root);
1549 return d->horizontalHeader->offset();
1563 return d->verticalHeader->offset();
1582 int bottom =
d->model->rowCount(
d->root) - 1;
1584 while (bottom >= 0 &&
isRowHidden(
d->logicalRow(bottom)))
1587 int right =
d->model->columnCount(
d->root) - 1;
1592 if (bottom == -1 || right == -1)
1602 while (
isRowHidden(
d->logicalRow(row)) && row < bottom)
1604 d->visualCursor =
QPoint(column, row);
1605 return d->model->index(
d->logicalRow(row),
d->logicalColumn(column),
d->root);
1609 QPoint visualCurrent(
d->visualColumn(current.
column()),
d->visualRow(current.
row()));
1610 if (visualCurrent !=
d->visualCursor) {
1611 if (
d->hasSpans()) {
1613 if (span.
top() >
d->visualCursor.y() ||
d->visualCursor.y() > span.
bottom()
1614 || span.
left() >
d->visualCursor.x() ||
d->visualCursor.x() > span.
right())
1615 d->visualCursor = visualCurrent;
1617 d->visualCursor = visualCurrent;
1621 int visualRow =
d->visualCursor.y();
1622 if (visualRow > bottom)
1625 int visualColumn =
d->visualCursor.x();
1626 if (visualColumn > right)
1627 visualColumn =
right;
1637 switch (cursorAction) {
1639 int originalRow = visualRow;
1640 #ifdef QT_KEYPAD_NAVIGATION 1641 if (QApplication::keypadNavigationEnabled() && visualRow == 0)
1642 visualRow =
d->visualRow(
model()->rowCount() - 1) + 1;
1645 int r =
d->logicalRow(visualRow);
1646 int c =
d->logicalColumn(visualColumn);
1647 if (r != -1 &&
d->hasSpans()) {
1650 visualRow =
d->visualRow(span.
top());
1652 while (visualRow >= 0) {
1654 r =
d->logicalRow(visualRow);
1655 c =
d->logicalColumn(visualColumn);
1656 if (r == -1 || (!
isRowHidden(r) &&
d->isCellEnabled(r, c)))
1660 visualRow = originalRow;
1664 int originalRow = visualRow;
1665 if (
d->hasSpans()) {
1667 visualRow =
d->visualRow(
d->rowSpanEndLogical(span.
top(), span.
height()));
1669 #ifdef QT_KEYPAD_NAVIGATION 1670 if (QApplication::keypadNavigationEnabled() && visualRow >= bottom)
1673 int r =
d->logicalRow(visualRow);
1674 int c =
d->logicalColumn(visualColumn);
1675 if (r != -1 &&
d->hasSpans()) {
1678 visualRow =
d->visualRow(
d->rowSpanEndLogical(span.
top(), span.
height()));
1680 while (visualRow <= bottom) {
1682 r =
d->logicalRow(visualRow);
1683 c =
d->logicalColumn(visualColumn);
1684 if (r == -1 || (!
isRowHidden(r) &&
d->isCellEnabled(r, c)))
1687 if (visualRow > bottom)
1688 visualRow = originalRow;
1693 int originalRow = visualRow;
1694 int originalColumn = visualColumn;
1695 bool firstTime =
true;
1696 bool looped =
false;
1697 bool wrapped =
false;
1699 int r =
d->logicalRow(visualRow);
1700 int c =
d->logicalColumn(visualColumn);
1701 if (firstTime && c != -1 &&
d->hasSpans()) {
1705 visualColumn =
d->visualColumn(span.
left());
1707 while (visualColumn >= 0) {
1709 r =
d->logicalRow(visualRow);
1710 c =
d->logicalColumn(visualColumn);
1713 if (wrapped && (originalRow < visualRow || (originalRow == visualRow && originalColumn <= visualColumn))) {
1718 if (cursorAction ==
MoveLeft || visualColumn >= 0)
1720 visualColumn = right + 1;
1721 if (visualRow == 0) {
1728 if (visualColumn < 0)
1729 visualColumn = originalColumn;
1734 int originalRow = visualRow;
1735 int originalColumn = visualColumn;
1736 bool firstTime =
true;
1737 bool looped =
false;
1738 bool wrapped =
false;
1740 int r =
d->logicalRow(visualRow);
1741 int c =
d->logicalColumn(visualColumn);
1742 if (firstTime && c != -1 &&
d->hasSpans()) {
1746 visualColumn =
d->visualColumn(
d->columnSpanEndLogical(span.
left(), span.
width()));
1748 while (visualColumn <= right) {
1750 r =
d->logicalRow(visualRow);
1751 c =
d->logicalColumn(visualColumn);
1754 if (wrapped && (originalRow > visualRow || (originalRow == visualRow && originalColumn >= visualColumn))) {
1759 if (cursorAction ==
MoveRight || visualColumn <= right)
1762 if (visualRow == bottom) {
1769 if (visualColumn > right)
1770 visualColumn = originalColumn;
1775 while (visualColumn < right && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn))
1779 while (visualRow < bottom && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn))
1784 visualColumn =
right;
1785 if (modifiers & Qt::ControlModifier)
1791 newRow =
d->logicalRow(0);
1792 return d->model->index(newRow, current.
column(),
d->root);
1797 newRow =
d->logicalRow(bottom);
1798 return d->model->index(newRow, current.
column(),
d->root);
1801 d->visualCursor =
QPoint(visualColumn, visualRow);
1802 int logicalRow =
d->logicalRow(visualRow);
1803 int logicalColumn =
d->logicalColumn(visualColumn);
1804 if (!
d->model->hasIndex(logicalRow, logicalColumn,
d->root))
1807 QModelIndex result =
d->model->index(logicalRow, logicalColumn,
d->root);
1808 if (!
d->isRowHidden(logicalRow) && !
d->isColumnHidden(logicalColumn) &&
d->isIndexEnabled(result))
1831 if (!
d->selectionModel || !tl.
isValid() || !br.isValid() || !
d->isIndexEnabled(tl) || !
d->isIndexEnabled(br))
1839 if (
d->hasSpans()) {
1841 int top =
qMin(
d->visualRow(tl.
row()),
d->visualRow(br.row()));
1842 int left =
qMin(
d->visualColumn(tl.
column()),
d->visualColumn(br.column()));
1843 int bottom =
qMax(
d->visualRow(tl.
row()),
d->visualRow(br.row()));
1849 int t =
d->visualRow(span.
top());
1850 int l =
d->visualColumn(span.
left());
1851 int b =
d->visualRow(
d->rowSpanEndLogical(span.
top(), span.
height()));
1852 int r =
d->visualColumn(
d->columnSpanEndLogical(span.
left(), span.
width()));
1853 if ((t > bottom) || (l >
right) || (top > b) || (left > r))
1875 for (
int horizontal = left; horizontal <=
right; ++horizontal) {
1876 int column =
d->logicalColumn(horizontal);
1877 for (
int vertical = top; vertical <= bottom; ++vertical) {
1878 int row =
d->logicalRow(vertical);
1883 }
else if (verticalMoved && horizontalMoved) {
1884 int top =
d->visualRow(tl.
row());
1886 int bottom =
d->visualRow(br.row());
1887 int right =
d->visualColumn(br.column());
1888 for (
int horizontal = left; horizontal <=
right; ++horizontal) {
1889 int column =
d->logicalColumn(horizontal);
1890 for (
int vertical = top; vertical <= bottom; ++vertical) {
1891 int row =
d->logicalRow(vertical);
1896 }
else if (horizontalMoved) {
1898 int right =
d->visualColumn(br.column());
1899 for (
int visual = left; visual <=
right; ++visual) {
1900 int column =
d->logicalColumn(visual);
1902 QModelIndex bottomRight =
d->model->index(br.row(), column,
d->root);
1905 }
else if (verticalMoved) {
1906 int top =
d->visualRow(tl.
row());
1907 int bottom =
d->visualRow(br.row());
1908 for (
int visual = top; visual <= bottom; ++visual) {
1909 int row =
d->logicalRow(visual);
1911 QModelIndex bottomRight =
d->model->index(row, br.column(),
d->root);
1920 d->selectionModel->select(selection, command);
1943 const QRect &viewportRect =
d->viewport->rect();
1947 if ((verticalMoved && horizontalMoved) || (
d->hasSpans() && (verticalMoved || horizontalMoved))) {
1948 for (
int i = 0; i < selection.
count(); ++i) {
1952 for (
int r = range.
top(); r <= range.
bottom(); ++r)
1956 selectionRegion += rangeRect;
1959 }
else if (horizontalMoved) {
1960 for (
int i = 0; i < selection.
count(); ++i) {
1967 qSwap<int>(top, bottom);
1968 int height = bottom - top;
1972 selectionRegion += rangeRect;
1975 }
else if (verticalMoved) {
1976 for (
int i = 0; i < selection.
count(); ++i) {
1985 for (
int r = range.
top(); r <= range.
bottom(); ++r) {
1988 selectionRegion += rangeRect;
1992 const int gridAdjust =
showGrid() ? 1 : 0;
1993 for (
int i = 0; i < selection.
count(); ++i) {
1997 d->trimHiddenSelections(&range);
2010 const QRect rangeRect(
QPoint(rleft, rtop),
QPoint(rright - 1 - gridAdjust, rbottom - 1 - gridAdjust));
2012 selectionRegion += rangeRect;
2013 if (
d->hasSpans()) {
2017 const QRect &visualSpanRect =
d->visualSpanRect(*s);
2019 selectionRegion += visualSpanRect;
2026 return selectionRegion;
2038 if (
d->selectionModel)
2039 modelSelected =
d->selectionModel->selectedIndexes();
2040 for (
int i = 0; i < modelSelected.
count(); ++i) {
2043 viewSelected.
append(index);
2045 return viewSelected;
2059 if (newCount < oldCount)
2060 d->verticalHeader->setUpdatesEnabled(
false);
2061 d->doDelayedItemsLayout();
2077 d->viewport->update();
2086 if (
d->geometryRecursionBlock)
2088 d->geometryRecursionBlock =
true;
2091 if (!
d->verticalHeader->isHidden()) {
2092 width =
qMax(
d->verticalHeader->minimumWidth(),
d->verticalHeader->sizeHint().width());
2093 width =
qMin(width,
d->verticalHeader->maximumWidth());
2096 if (!
d->horizontalHeader->isHidden()) {
2097 height =
qMax(
d->horizontalHeader->minimumHeight(),
d->horizontalHeader->sizeHint().height());
2098 height =
qMin(height,
d->horizontalHeader->maximumHeight());
2108 QRect vg =
d->viewport->geometry();
2110 int verticalLeft = reverse ? vg.
right() + 1 : (vg.
left() -
width);
2111 d->verticalHeader->setGeometry(verticalLeft, vg.
top(),
width, vg.
height());
2112 if (
d->verticalHeader->isHidden())
2116 d->horizontalHeader->setGeometry(vg.
left(), horizontalTop, vg.
width(),
height);
2117 if (
d->horizontalHeader->isHidden())
2121 if (
d->horizontalHeader->isHidden() ||
d->verticalHeader->isHidden()) {
2122 d->cornerWidget->setHidden(
true);
2124 d->cornerWidget->setHidden(
false);
2125 d->cornerWidget->setGeometry(verticalLeft, horizontalTop, width, height);
2131 QSize vsize =
d->viewport->size();
2133 uint horizontalLength =
d->horizontalHeader->length();
2134 uint verticalLength =
d->verticalHeader->length();
2139 const int columnCount =
d->horizontalHeader->count();
2140 const int viewportWidth = vsize.
width();
2141 int columnsInViewport = 0;
2142 for (
int width = 0, column = columnCount - 1; column >= 0; --column) {
2143 int logical =
d->horizontalHeader->logicalIndex(column);
2144 if (!
d->horizontalHeader->isSectionHidden(logical)) {
2145 width +=
d->horizontalHeader->sectionSize(logical);
2146 if (width > viewportWidth)
2148 ++columnsInViewport;
2151 columnsInViewport =
qMax(columnsInViewport, 1);
2154 const int visibleColumns = columnCount -
d->horizontalHeader->hiddenSectionCount();
2157 if (columnsInViewport >= visibleColumns)
2158 d->horizontalHeader->setOffset(0);
2167 const int rowCount =
d->verticalHeader->count();
2168 const int viewportHeight = vsize.
height();
2169 int rowsInViewport = 0;
2170 for (
int height = 0, row = rowCount - 1; row >= 0; --row) {
2171 int logical =
d->verticalHeader->logicalIndex(row);
2172 if (!
d->verticalHeader->isSectionHidden(logical)) {
2173 height +=
d->verticalHeader->sectionSize(logical);
2174 if (height > viewportHeight)
2179 rowsInViewport =
qMax(rowsInViewport, 1);
2182 const int visibleRows = rowCount -
d->verticalHeader->hiddenSectionCount();
2185 if (rowsInViewport >= visibleRows)
2186 d->verticalHeader->setOffset(0);
2194 d->geometryRecursionBlock =
false;
2221 int left =
qMax(0,
d->horizontalHeader->visualIndexAt(0));
2222 int right =
d->horizontalHeader->visualIndexAt(
d->viewport->width());
2224 right =
d->model->columnCount(
d->root) - 1;
2230 for (
int column = left; column <=
right; ++column) {
2231 int logicalColumn =
d->horizontalHeader->logicalIndex(column);
2232 if (
d->horizontalHeader->isSectionHidden(logicalColumn))
2234 index =
d->model->index(row, logicalColumn,
d->root);
2235 if (
d->wrapItemText) {
2242 QWidget *editor =
d->editorForIndex(index).widget.data();
2243 if (editor &&
d->persistent.contains(editor)) {
2247 hint =
qBound(min, hint, max);
2253 return d->showGrid ? hint + 1 : hint;
2280 int top =
qMax(0,
d->verticalHeader->visualIndexAt(0));
2281 int bottom =
d->verticalHeader->visualIndexAt(
d->viewport->height());
2283 bottom =
d->model->rowCount(
d->root) - 1;
2289 for (
int row = top; row <= bottom; ++row) {
2290 int logicalRow =
d->verticalHeader->logicalIndex(row);
2291 if (
d->verticalHeader->isSectionHidden(logicalRow))
2293 index =
d->model->index(logicalRow, column,
d->root);
2295 QWidget *editor =
d->editorForIndex(index).widget.data();
2296 if (editor &&
d->persistent.contains(editor)) {
2300 hint =
qBound(min, hint, max);
2306 return d->showGrid ? hint + 1 : hint;
2316 return d->verticalHeader->sectionViewportPosition(row);
2331 return d->verticalHeader->logicalIndexAt(y);
2345 d->verticalHeader->resizeSection(row, height);
2356 return d->verticalHeader->sectionSize(row);
2366 return d->horizontalHeader->sectionViewportPosition(column);
2381 return d->horizontalHeader->logicalIndexAt(x);
2395 d->horizontalHeader->resizeSection(column, width);
2406 return d->horizontalHeader->sectionSize(column);
2417 return d->verticalHeader->isSectionHidden(row);
2428 if (row < 0 || row >=
d->verticalHeader->count())
2430 d->verticalHeader->setSectionHidden(row, hide);
2441 return d->horizontalHeader->isSectionHidden(column);
2453 if (column < 0 || column >=
d->horizontalHeader->count())
2455 d->horizontalHeader->setSectionHidden(column, hide);
2485 d->sortingEnabled = enable;
2489 this,
SLOT(_q_selectColumn(
int)));
2509 return d->sortingEnabled;
2531 if (
d->showGrid != show) {
2533 d->viewport->update();
2549 return d->gridStyle;
2555 if (
d->gridStyle != style) {
2557 d->viewport->update();
2581 if (
d->wrapItemText == on)
2583 d->wrapItemText = on;
2591 return d->wrapItemText;
2611 d->cornerWidget->setEnabled(enable);
2617 return d->cornerWidget->isEnabled();
2633 if (!
d->isIndexValid(index) || index.
parent() !=
d->root
2637 d->executePostedLayout();
2639 if (
d->hasSpans()) {
2641 return d->visualSpanRect(span);
2650 return QRect(colp, rowp, colw - i, rowh - i);
2667 if (!
d->isIndexValid(index)
2668 || (
d->model->parent(index) !=
d->root)
2678 int viewportWidth =
d->viewport->width();
2680 int horizontalPosition =
d->horizontalHeader->sectionPosition(index.
column());
2681 int horizontalIndex =
d->horizontalHeader->visualIndex(index.
column());
2682 int cellWidth =
d->hasSpans()
2684 :
d->horizontalHeader->sectionSize(index.
column());
2688 bool positionAtLeft = (horizontalPosition - horizontalOffset < 0);
2689 bool positionAtRight = (horizontalPosition - horizontalOffset + cellWidth > viewportWidth);
2694 while (horizontalIndex > 0) {
2695 x +=
columnWidth(
d->horizontalHeader->logicalIndex(horizontalIndex-1));
2703 int hiddenSections = 0;
2704 if (
d->horizontalHeader->sectionsHidden()) {
2705 for (
int s = horizontalIndex - 1; s >= 0; --s) {
2706 int column =
d->horizontalHeader->logicalIndex(s);
2707 if (
d->horizontalHeader->isSectionHidden(column))
2718 if (horizontalPosition - horizontalOffset < 0 || cellWidth > viewportWidth)
2720 else if (horizontalPosition - horizontalOffset + cellWidth > viewportWidth)
2727 int viewportHeight =
d->viewport->height();
2729 int verticalPosition =
d->verticalHeader->sectionPosition(index.
row());
2730 int verticalIndex =
d->verticalHeader->visualIndex(index.
row());
2731 int cellHeight =
d->hasSpans()
2732 ?
d->rowSpanHeight(index.
row(), span.
height())
2733 :
d->verticalHeader->sectionSize(index.
row());
2735 if (verticalPosition - verticalOffset < 0 || cellHeight > viewportHeight) {
2738 }
else if (verticalPosition - verticalOffset + cellHeight > viewportHeight) {
2748 while (verticalIndex > 0) {
2749 int row =
d->verticalHeader->logicalIndex(verticalIndex - 1);
2750 y +=
d->verticalHeader->sectionSize(row);
2758 int hiddenSections = 0;
2759 if (
d->verticalHeader->sectionsHidden()) {
2760 for (
int s = verticalIndex - 1; s >= 0; --s) {
2761 int row =
d->verticalHeader->logicalIndex(s);
2762 if (
d->verticalHeader->isSectionHidden(row))
2792 d->rowsToUpdate.append(row);
2793 if (
d->rowResizeTimerID == 0)
2807 d->columnsToUpdate.append(column);
2808 if (
d->columnResizeTimerID == 0)
2819 if (event->
timerId() ==
d->columnResizeTimerID) {
2822 d->columnResizeTimerID = 0;
2825 int viewportHeight =
d->viewport->height();
2826 int viewportWidth =
d->viewport->width();
2827 if (
d->hasSpans()) {
2828 rect =
QRect(0, 0, viewportWidth, viewportHeight);
2830 for (
int i =
d->columnsToUpdate.size()-1; i >= 0; --i) {
2831 int column =
d->columnsToUpdate.at(i);
2836 rect |=
QRect(x, 0, viewportWidth - x, viewportHeight);
2841 d->columnsToUpdate.clear();
2844 if (event->
timerId() ==
d->rowResizeTimerID) {
2847 d->rowResizeTimerID = 0;
2849 int viewportHeight =
d->viewport->height();
2850 int viewportWidth =
d->viewport->width();
2852 if (
d->hasSpans()) {
2855 top = viewportHeight;
2856 for (
int i =
d->rowsToUpdate.size()-1; i >= 0; --i) {
2862 d->viewport->update(
QRect(0, top, viewportWidth, viewportHeight - top));
2863 d->rowsToUpdate.clear();
2881 int logicalOldIndex =
d->verticalHeader->logicalIndex(oldIndex);
2882 int logicalNewIndex =
d->verticalHeader->logicalIndex(newIndex);
2883 if (
d->hasSpans()) {
2884 d->viewport->update();
2888 int oldBottom = oldTop +
rowHeight(logicalOldIndex);
2889 int newBottom = newTop +
rowHeight(logicalNewIndex);
2890 int top =
qMin(oldTop, newTop);
2891 int bottom =
qMax(oldBottom, newBottom);
2892 int height = bottom - top;
2893 d->viewport->update(0, top,
d->viewport->width(),
height);
2909 int logicalOldIndex =
d->horizontalHeader->logicalIndex(oldIndex);
2910 int logicalNewIndex =
d->horizontalHeader->logicalIndex(newIndex);
2911 if (
d->hasSpans()) {
2912 d->viewport->update();
2916 int oldRight = oldLeft +
columnWidth(logicalOldIndex);
2917 int newRight = newLeft +
columnWidth(logicalNewIndex);
2921 d->viewport->update(left, 0, width,
d->viewport->height());
2934 d->selectRow(row,
true);
2946 d->selectColumn(column,
true);
2957 d->verticalHeader->hideSection(row);
2968 d->horizontalHeader->hideSection(column);
2979 d->verticalHeader->showSection(row);
2990 d->horizontalHeader->showSection(column);
3001 int header =
d->verticalHeader->sectionSizeHint(row);
3002 d->verticalHeader->resizeSection(row,
qMax(content, header));
3026 int header =
d->horizontalHeader->sectionSizeHint(column);
3027 d->horizontalHeader->resizeSection(column,
qMax(content, header));
3054 d->model->sort(column,
d->horizontalHeader->sortIndicatorOrder());
3070 d->horizontalHeader->setSortIndicator(column, order);
3099 if (
d->hasSpans()) {
3121 if (row < 0 || column < 0 || rowSpan < 0 || columnSpan < 0)
3123 d->setSpan(row, column, rowSpan, columnSpan);
3124 d->viewport->update();
3141 return d->rowSpan(row, column);
3158 return d->columnSpan(row, column);
3176 d->viewport->update();
3198 if (row >= 0 && row < model->rowCount(root)) {
3201 QItemSelectionModel::SelectionFlags command = q->selectionCommand(index);
3205 rowSectionAnchor = row;
3213 command |= ctrlDragSelectionFlag;
3221 q->setSelection(q->visualRect(tl)|q->visualRect(br), command);
3236 if (column >= 0 && column < model->columnCount(root)) {
3239 QItemSelectionModel::SelectionFlags command = q->selectionCommand(index);
3243 columnSectionAnchor = column;
3251 command |= ctrlDragSelectionFlag;
3258 qMax(columnSectionAnchor, column), root);
3260 q->setSelection(q->visualRect(tl)|q->visualRect(br), command);
3271 #ifndef QT_NO_ACCESSIBILITY 3276 int entry =
d->accessibleTable2Index(current);
3296 #ifndef QT_NO_ACCESSIBILITY 3304 int entry =
d->accessibleTable2Index(sel);
3316 int entry =
d->accessibleTable2Index(desel);
3337 #include "qtableview.moc" 3339 #include "moc_qtableview.cpp" 3341 #endif // QT_NO_TABLEVIEW
QModelIndexList selectedRows(int column=0) const
Returns the indexes in the given column for the rows where all columns are selected.
int startTimer(int interval)
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer...
void clear()
Removes all the items in the list.
The QPainter class performs low-level painting on widgets and other paint devices.
The QDebug class provides an output stream for debugging information.
The QColor class provides colors based on RGB, HSV or CMYK values.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
void trimHiddenSelections(QItemSelectionRange *range) const
Trims away indices that are hidden in the treeview due to hidden horizontal or vertical sections...
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object's accessibility information.
const Key & key() const
Returns the current item's key as a const reference.
iterator erase(iterator pos)
Removes the item pointed to by the iterator pos from the list, and returns an iterator to the next it...
bool isIndexHidden(const QModelIndex &index) const
Reimplemented Function
bool isColumnHidden(int column) const
Returns true if the given column is hidden; otherwise returns false.
static QAbstractItemModel * staticEmptyModel()
void hideColumn(int column)
Hide the given column.
int columnAt(int x) const
Returns the column in which the given x-coordinate, x, in contents coordinates is located...
The QItemSelectionModel class keeps track of a view's selected items.
void sortByColumn(int column, Qt::SortOrder order)
Sorts the model by the values in the given column in the given order.
void setHeight(int h)
Sets the height of the rectangle to the given height.
int left() const
Returns the column index corresponding to the leftmost selected column in the selection range...
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
void setSpan(int row, int column, int rowSpan, int columnSpan)
Sets the span for the cell at (row, column).
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
void setBit(int i)
Sets the bit at index position i to 1.
#define QT_END_NAMESPACE
This macro expands to.
virtual QStyleOptionViewItem viewOptions() const
Returns a QStyleOptionViewItem structure populated with the view's palette, font, state...
virtual void setSelectionModel(QItemSelectionModel *selectionModel)
Sets the current selection model to the given selectionModel.
int rowSpan(int row, int column) const
Returns the row span of the table element at (row, column).
ScrollMode horizontalScrollMode() const
QRect visualSpanRect(const QSpanCollection::Span &span) const
Returns the visual rect for the given span.
int columnWidth(int column) const
Returns the width of the given column.
int columnViewportPosition(int column) const
Returns the x-coordinate in contents coordinates of the given column.
QStyle::State state
the style flags that are used when drawing the control
#define it(className, varName)
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
Reimplemented Function
Span * spanAt(int x, int y) const
void showRow(int row)
Show the given row.
void updateRemovedColumns(int start, int end)
void setModel(QAbstractItemModel *model)
Reimplemented Function
bool isValid() const
Returns true if the selection range is valid; otherwise returns false.
int sizeHintForRow(int row) const
Returns the size hint for the given row's height or -1 if there is no model.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
virtual void setRootIndex(const QModelIndex &index)
Sets the root item to the item at the given index.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
bool remove(const T &value)
static C reverse(const C &l)
void _q_selectColumn(int column)
void resizeRowsToContents()
Resizes all rows based on the size hints of the delegate used to render each item in the rows...
void updateSpan(Span *span, int old_height)
QRect visualRect(const QModelIndex &index) const
Returns the rectangle on the viewport occupied by the given index.
void resizeColumnsToContents()
Resizes all columns based on the size hints of the delegate used to render each item in the columns...
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
QRect normalized() const
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
QHeaderView * horizontalHeader() const
Returns the table view's horizontal header.
The QItemSelectionRange class manages information about a range of selected items in a model...
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
void updateInsertedColumns(int start, int end)
int left() const
Returns the x-coordinate of the rectangle's left edge.
void setRootIndex(const QModelIndex &index)
Reimplemented Function
void timerEvent(QTimerEvent *event)
This function is called with the given event when a timer event is sent to the widget.
int width() const
Returns the width of the rectangle.
bool removeOne(const T &t)
Removes the first occurrences of value in the list.
void init(const QWidget *w)
Use initFrom(widget) instead.
void rowResized(int row, int oldHeight, int newHeight)
This slot is called to change the height of the given row.
int rowViewportPosition(int row) const
Returns the y-coordinate in contents coordinates of the given row.
int bottom() const
Returns the row index corresponding to the lowermost selected row in the selection range...
const Key & key() const
Returns the current item's key.
void _q_updateSpanInsertedRows(const QModelIndex &parent, int start, int end)
Updates spans after row insertion.
void append(const T &)
Inserts value at the end of the list.
int count(const T &t) const
Returns the number of occurrences of value in the list.
virtual void verticalScrollbarAction(int action)
int right() const
Returns the column index corresponding to the rightmost selected column in the selection range...
iterator find(const Key &key)
Returns an iterator pointing to the item with key key in the map.
void drawLine(const QLineF &line)
Draws a line defined by line.
int height() const
Returns the height of the rectangle.
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
QAbstractItemDelegate * itemDelegate() const
Returns the item delegate used by this view and model.
void columnResized(int column, int oldWidth, int newWidth)
This slot is called to change the width of the given column.
virtual void doItemsLayout()
This function is intended to lay out the items in the view.
void setGridStyle(Qt::PenStyle style)
bool isEmpty() const
Returns true if the selection range contains no selectable item.
QList< Span * > spansInRect(int x, int y, int w, int h) const
void selectRow(int row, bool anchor)
bool testBit(int i) const
Returns true if the bit at index position i is 1; otherwise returns false.
bool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
void horizontalScrollbarAction(int action)
int rowAt(int y) const
Returns the row in which the given y-coordinate, y, in contents coordinates is located.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
QModelIndex parent() const
Returns the parent model item index of the items in the selection range.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QTableView(QWidget *parent=0)
Constructs a table view with a parent to represent the data.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
void setRange(int min, int max)
Sets the slider's minimum to min and its maximum to max.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
The QStyleOptionViewItemV2 class is used to describe the parameters necessary for drawing a frame in ...
void setHorizontalHeader(QHeaderView *header)
Sets the widget to use for the horizontal header to header.
T & value() const
Returns a modifiable reference to the current item's value.
void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
int width() const
Returns the number of selected columns in the selection range.
Q_CORE_EXPORT void qDebug(const char *,...)
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
virtual 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 setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
int rowHeight(int row) const
Returns the height of the given row.
void resizeColumnToContents(int column)
Resizes the given column based on the size hints of the delegate used to render each item in the colu...
The QLinkedList class is a template class that provides linked lists.
int width() const
Returns the width.
void append(const T &t)
Inserts value at the end of the list.
void selectColumn(int column, bool anchor)
void scrollContentsBy(int dx, int dy)
Scroll the contents of the table view by (dx, dy).
const QPen & pen() const
Returns the painter's current pen.
#define QT_BEGIN_NAMESPACE
This macro expands to.
ViewItemFeatures features
a bitwise OR of the features that describe this view item
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
QStyleOptionViewItem viewOptions() const
Reimplemented Function
ScrollMode verticalScrollMode() const
~QTableView()
Destroys the table view.
void setVerticalHeader(QHeaderView *header)
Sets the widget to use for the vertical header to header.
void hideRow(int row)
Hide the given row.
QList< T > toList() const
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
QItemSelectionModel * selectionModel() const
Returns the current selection model.
void clearSpans()
Removes all row and column spans in the table view.
int row() const
Returns the row this model index refers to.
void setCornerButtonEnabled(bool enable)
void verticalScrollbarAction(int action)
void updateInsertedRows(int start, int end)
const T value(const Key &key) const
Returns the value associated with the key key.
const T & at(int i) const
Returns the item at index position i in the list.
void showColumn(int column)
Show the given column.
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
This slot is called when a new item becomes the current item.
void drawCell(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index)
Draws a table cell.
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
void _q_updateSpanInsertedColumns(const QModelIndex &parent, int start, int end)
Updates spans after column insertion.
Q_CORE_EXPORT void qWarning(const char *,...)
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
bool showDecorationSelected
whether the decoration should be highlighted on selected items
void setShowGrid(bool show)
QHeaderView * verticalHeader() const
Returns the table view's vertical header.
QModelIndex currentIndex() const
Returns the model index of the current item.
The QLinkedList::iterator class provides an STL-style non-const iterator for QLinkedList.
The QRegion class specifies a clip region for a painter.
T value(int i) const
Returns the value at index position i in the list.
void selectRow(int row)
Selects the given row in the table view if the current SelectionMode and SelectionBehavior allows row...
void setRowHeight(int row, int height)
Sets the height of the given row to be height.
void updateRemovedRows(int start, int end)
void columnMoved(int column, int oldIndex, int newIndex)
This slot is called to change the index of the given column in the table view.
The QTableView class provides a default model/view implementation of a table view.
void setX(int x)
Sets the left edge of the rectangle to the given x coordinate.
bool contains(const QModelIndex &index) const
Returns true if the model item specified by the index lies within the range of selected items; otherw...
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
bool cleanSpanSubIndex(SubIndex &subindex, int end, bool update=false)
void timerEvent(QTimerEvent *event)
Reimplemented Function
void qSwap(T &value1, T &value2)
const T & at(int i) const
Returns the item at index position i in the vector.
void drawAndClipSpans(const QRegion &area, QPainter *painter, const QStyleOptionViewItemV4 &option, QBitArray *drawn, int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn)
Draws the spanning cells within rect area, and clips them off as preparation for the main drawing loo...
The QAbstractItemModel class provides the abstract interface for item model classes.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
static bool isActive()
Returns true if an accessibility implementation has been requested during the runtime of the applicat...
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
bool isCornerButtonEnabled() const
The QBitArray class provides an array of bits.
void setColumnWidth(int column, int width)
Sets the width of the given column to be width.
QPalette palette
the palette that should be used when painting the control
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
This slot is called when the selection is changed.
void paintEvent(QPaintEvent *e)
Paints the table on receipt of the given paint event event.
The QAbstractItemView class provides the basic functionality for item view classes.
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
QSpanCollection::Span span(int row, int column) const
Gets the span information for the cell at (row, column).
int top() const
Returns the y-coordinate of the rectangle's top edge.
The QItemSelection class manages information about selected items in a model.
int visualIndex(const QModelIndex &index) const
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
int right() const
Returns the x-coordinate of the rectangle's right edge.
int sectionSpanEndLogical(const QHeaderView *header, int logical, int span) const
Returns the logical index of the last section that's part of the span.
QModelIndexList selectedColumns(int row=0) const
Returns the indexes in the given row for columns where all rows are selected.
The QMap::iterator class provides an STL-style non-const iterator for QMap and QMultiMap.
The QTimerEvent class contains parameters that describe a timer event.
void setWordWrap(bool on)
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
int height() const
Returns the number of selected rows in the selection range.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged().
int columnSpan(int row, int column) const
Returns the column span of the table element at (row, column).
void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)
Makes sure that the given item is visible in the table view, scrolling if necessary.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
QObject * parent() const
Returns a pointer to the parent object.
void setSelectionModel(QItemSelectionModel *selectionModel)
Reimplemented Function
void setSpan(int row, int column, int rowSpan, int columnSpan)
Sets the span of the table element at (row, column) to the number of rows and columns specified by (r...
The QPoint class defines a point in the plane using integer precision.
void setRowHidden(int row, bool hide)
If hide is true row will be hidden, otherwise it will be shown.
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
The QModelIndex class is used to locate data in a data model.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
bool isEmpty() const
Returns true if the map contains no items; otherwise returns false.
void setWidth(int w)
Sets the width of the rectangle to the given width.
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 setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
int height() const
Returns the height.
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
const T & value() const
Returns the current item's value.
void rowMoved(int row, int oldIndex, int newIndex)
This slot is called to change the index of the given row in the table view.
bool isRowHidden(int row) const
Returns true if the given row is hidden; otherwise returns false.
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
Moves the cursor in accordance with the given cursorAction, using the information provided by the mod...
void updateGeometries()
Reimplemented Function
void columnCountChanged(int oldCount, int newCount)
This slot is called whenever columns are added or deleted.
int y() const
Returns the y coordinate of this point.
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
This slot is called when rows are inserted.
bool intersects(const QRegion &r) const
Returns true if this region intersects with region, otherwise returns false.
int verticalOffset() const
Returns the vertical offset of the items in the table view.
virtual void updateGeometries()
Updates the geometry of the child widgets of the view.
int top() const
Returns the row index corresponding to the uppermost selected row in the selection range...
void setSortingEnabled(bool enable)
If enabled true enables sorting for the table and immediately trigger a call to sortByColumn() with t...
void _q_updateSpanRemovedColumns(const QModelIndex &parent, int start, int end)
Updates spans after column removal.
QDataStream & operator<<(QDataStream &s, const QAxBase &c)
void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
Applies the selection flags to the items in or touched by the rectangle, rect.
iterator erase(iterator it)
Removes the (key, value) pair pointed to by the iterator pos from the map, and returns an iterator to...
QRegion visualRegionForSelection(const QItemSelection &selection) const
Returns the rectangle from the viewport of the items in the given selection.
The QSize class defines the size of a two-dimensional object using integer point precision.
void _q_selectRow(int row)
QRegion translated(int dx, int dy) const
Returns a copy of the region that is translated dx along the x axis and dy along the y axis...
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
int horizontalOffset() const
Returns the horizontal offset of the items in the table view.
iterator lowerBound(const Key &key)
Returns an iterator pointing to the first item with key key in the map.
CursorAction
This enum describes the different ways to navigate between items,.
int x() const
Returns the x coordinate of this point.
bool spanContainsSection(const QHeaderView *header, int logical, int spanLogical, int span) const
Returns true if the section at logical index logical is part of the span starting at logical index sp...
QModelIndexList indexes() const
Returns a list of model indexes that correspond to the selected items.
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
virtual void horizontalScrollbarAction(int action)
int sectionSpanSize(const QHeaderView *header, int logical, int span) const
Returns the size of the span starting at logical index logical and spanning span sections.
The QPaintEvent class contains event parameters for paint events.
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Appends a new row to the current test data.
QAbstractItemModel * model() const
Returns the model that this view is presenting.
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
static const KeyPair *const end
void rowCountChanged(int oldCount, int newCount)
This slot is called whenever rows are added or deleted.
bool event(QEvent *event)
Reimplemented Function
Qt::PenStyle gridStyle() const
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
bool isSortingEnabled() const
int size() const
Returns the number of bits stored in the bit array.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
int size() const
Returns the number of items in the vector.
void setColumnHidden(int column, bool hide)
If hide is true the given column will be hidden; otherwise it will be shown.
QModelIndex indexAt(const QPoint &p) const
Returns the index position of the model item corresponding to the table item at position pos in conte...
QRect rect
the area that should be used for various calculations and painting
QModelIndexList selectedIndexes() const
Reimplemented Function
void clear()
Removes all items from the map.
void _q_updateSpanRemovedRows(const QModelIndex &parent, int start, int end)
Updates spans after row removal.
The QMap class is a template class that provides a skip-list-based dictionary.
int column() const
Returns the column this model index refers to.
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Reimplemented Function
The QList class is a template class that provides lists.
static int area(const QSize &s)
void selectColumn(int column)
Selects the given column in the table view if the current SelectionMode and SelectionBehavior allows ...
void killTimer(int id)
Kills the timer with timer identifier, id.
friend class const_iterator
int sizeHintForColumn(int column) const
Returns the size hint for the given column's width or -1 if there is no model.