diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/quick/doc/src/includes/tableview.qdocinc | 11 | ||||
| -rw-r--r-- | src/quick/items/qquicktableview.cpp | 46 |
2 files changed, 57 insertions, 0 deletions
diff --git a/src/quick/doc/src/includes/tableview.qdocinc b/src/quick/doc/src/includes/tableview.qdocinc new file mode 100644 index 0000000000..d83b0c1d9a --- /dev/null +++ b/src/quick/doc/src/includes/tableview.qdocinc @@ -0,0 +1,11 @@ +//! [explicit-column-size-and-syncview] +\note If a \l syncView is set, together with a \l {Qt::Horizontal}{Qt.Horizontal} +\l syncDirection, the sync view will control the column widths. Therefore, in that +case, any call to this function will be forwarded to the sync view instead. +//! [explicit-column-size-and-syncview] + +//! [explicit-row-size-and-syncview] +\note If a \l syncView is set, together with a \l {Qt::Vertical}{Qt.Vertical} +\l syncDirection, the sync view will control the row heights. Therefore, in that +case, any call to this function will be forwarded to the sync view instead. +//! [explicit-row-size-and-syncview] diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index ba4f0e605f..74e3c9ff8b 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -901,6 +901,8 @@ \note The sizes you set will not be cleared if you change the \l model. To clear the sizes, you need to call \l clearColumnWidths() explicitly. + \include tableview.qdocinc explicit-column-size-and-syncview + \note For models with \e lots of columns, using \l setColumnWidth() to set the widths for all the columns at start-up, can be suboptimal. This will consume start-up time and memory (for storing all the widths). A more scalable approach is to use a @@ -916,6 +918,8 @@ Clears all the column widths set with \l setColumnWidth(). + \include tableview.qdocinc explicit-column-size-and-syncview + \sa setColumnWidth(), clearRowHeights(), {Row heights and column widths} */ @@ -930,6 +934,8 @@ A return value equal to \c -1 means that no explicit width has been set for the column. + \include tableview.qdocinc explicit-column-size-and-syncview + \sa setColumnWidth(), columnWidth(), {Row heights and column widths} */ @@ -967,6 +973,8 @@ \note The sizes you set will not be cleared if you change the \l model. To clear the sizes, you need to call \l clearRowHeights() explicitly. + \include tableview.qdocinc explicit-row-size-and-syncview + \note For models with \e lots of rows, using \l setRowHeight() to set the heights for all the rows at start-up, can be suboptimal. This will consume start-up time and memory (for storing all the heights). A more scalable approach is to use a @@ -982,6 +990,8 @@ Clears all the row heights set with \l setRowHeight(). + \include tableview.qdocinc explicit-row-size-and-syncview + \sa setRowHeight(), clearColumnWidths(), {Row heights and column widths} */ @@ -996,6 +1006,8 @@ A return value equal to \c -1 means that no explicit height has been set for the row. + \include tableview.qdocinc explicit-row-size-and-syncview + \sa setRowHeight(), rowHeight(), {Row heights and column widths} */ @@ -5028,6 +5040,11 @@ void QQuickTableView::setColumnWidth(int column, qreal size) return; } + if (d->syncHorizontally) { + d->syncView->setColumnWidth(column, size); + return; + } + if (qFuzzyCompare(explicitColumnWidth(column), size)) return; @@ -5036,6 +5053,9 @@ void QQuickTableView::setColumnWidth(int column, qreal size) else d->explicitColumnWidths.insert(column, size); + if (d->loadedItems.isEmpty()) + return; + const bool allColumnsLoaded = d->atTableEnd(Qt::LeftEdge) && d->atTableEnd(Qt::RightEdge); if (column >= leftColumn() || column <= rightColumn() || allColumnsLoaded) d->forceLayout(false); @@ -5045,6 +5065,11 @@ void QQuickTableView::clearColumnWidths() { Q_D(QQuickTableView); + if (d->syncHorizontally) { + d->syncView->clearColumnWidths(); + return; + } + if (d->explicitColumnWidths.isEmpty()) return; @@ -5055,6 +5080,10 @@ void QQuickTableView::clearColumnWidths() qreal QQuickTableView::explicitColumnWidth(int column) const { Q_D(const QQuickTableView); + + if (d->syncHorizontally) + return d->syncView->explicitColumnWidth(column); + const auto it = d->explicitColumnWidths.constFind(column); if (it != d->explicitColumnWidths.constEnd()) return *it; @@ -5069,6 +5098,11 @@ void QQuickTableView::setRowHeight(int row, qreal size) return; } + if (d->syncVertically) { + d->syncView->setRowHeight(row, size); + return; + } + if (qFuzzyCompare(explicitRowHeight(row), size)) return; @@ -5077,6 +5111,9 @@ void QQuickTableView::setRowHeight(int row, qreal size) else d->explicitRowHeights.insert(row, size); + if (d->loadedItems.isEmpty()) + return; + const bool allRowsLoaded = d->atTableEnd(Qt::TopEdge) && d->atTableEnd(Qt::BottomEdge); if (row >= topRow() || row <= bottomRow() || allRowsLoaded) d->forceLayout(false); @@ -5086,6 +5123,11 @@ void QQuickTableView::clearRowHeights() { Q_D(QQuickTableView); + if (d->syncVertically) { + d->syncView->clearRowHeights(); + return; + } + if (d->explicitRowHeights.isEmpty()) return; @@ -5096,6 +5138,10 @@ void QQuickTableView::clearRowHeights() qreal QQuickTableView::explicitRowHeight(int row) const { Q_D(const QQuickTableView); + + if (d->syncVertically) + return d->syncView->explicitRowHeight(row); + const auto it = d->explicitRowHeights.constFind(row); if (it != d->explicitRowHeights.constEnd()) return *it; |
