diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-07-13 13:30:07 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-07-18 22:12:18 +0000 |
commit | 379ba8640a9cf7e43e848eb07c11989f0f4f3ddd (patch) | |
tree | 5131b7c128d36549677f239ea954edd8a1665365 | |
parent | aec42f9953954d48a11465f56b5e5ee4987f3b44 (diff) |
QQuickTableView: remove TableView.cellWidth/Height
The attached properties TableView.cellWidth/Height were added
for corner cases where you couldn't set/override implicit size
for a delegate item. But now that we have added rowHeightProvider
and columnWidthProvider (and we know that we're going to offer a
broader API to set row/column size from a HeaderView), you have
a way out for those cases as well. So lets remove the attached
properties until we know for sure if they will be needed.
Change-Id: I7d20fb02c36aebd3f24964630ccb68d4c813e93e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 12 | ||||
-rw-r--r-- | src/quick/items/qquicktableview_p.h | 22 | ||||
-rw-r--r-- | tests/auto/quick/qquicktableview/data/countingtableview.qml | 4 | ||||
-rw-r--r-- | tests/auto/quick/qquicktableview/data/plaintableview.qml | 4 | ||||
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 2 | ||||
-rw-r--r-- | tests/manual/tableview/abstracttablemodel/main.qml | 4 | ||||
-rw-r--r-- | tests/manual/tableview/listmodel/main.qml | 4 | ||||
-rw-r--r-- | tests/manual/tableview/storagemodel/main.qml | 4 |
8 files changed, 11 insertions, 45 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index b5668ccf53..db1d262df7 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -490,29 +490,17 @@ Qt::Edge QQuickTableViewPrivate::nextEdgeToUnload(const QRectF rect) qreal QQuickTableViewPrivate::cellWidth(const QPoint& cell) { - // If a delegate item has TableView.cellWidth set, then - // we prefer that. Otherwise we fall back to use implicitWidth. // Using an items width directly is not an option, since we change // it during layout (which would also cause problems when recycling items). auto const cellItem = loadedTableItem(cell)->item; - if (auto const attached = getAttachedObject(cellItem)) { - if (!attached->m_cellWidth.isNull) - return attached->m_cellWidth; - } return cellItem->implicitWidth(); } qreal QQuickTableViewPrivate::cellHeight(const QPoint& cell) { - // If a delegate item has TableView.cellHeight set, then - // we prefer that. Otherwise we fall back to use implicitHeight. // Using an items height directly is not an option, since we change // it during layout (which would also cause problems when recycling items). auto const cellItem = loadedTableItem(cell)->item; - if (auto const attached = getAttachedObject(cellItem)) { - if (!attached->m_cellHeight.isNull) - return attached->m_cellHeight; - } return cellItem->implicitHeight(); } diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h index c0dbaf4d48..fe18de5cc4 100644 --- a/src/quick/items/qquicktableview_p.h +++ b/src/quick/items/qquicktableview_p.h @@ -150,8 +150,6 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTableViewAttached : public QObject Q_OBJECT Q_PROPERTY(QQuickTableView *tableView READ tableView NOTIFY tableViewChanged) - Q_PROPERTY(qreal cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged) - Q_PROPERTY(qreal cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged) public: QQuickTableViewAttached(QObject *parent) @@ -165,31 +163,11 @@ public: Q_EMIT tableViewChanged(); } - qreal cellWidth() const { return m_cellWidth; } - void setCellWidth(qreal newWidth) { - if (newWidth == m_cellWidth) - return; - m_cellWidth = newWidth; - Q_EMIT cellWidthChanged(); - } - - qreal cellHeight() const { return m_cellHeight; } - void setCellHeight(qreal newHeight) { - if (newHeight == m_cellHeight) - return; - m_cellHeight = newHeight; - Q_EMIT cellHeightChanged(); - } - Q_SIGNALS: void tableViewChanged(); - void cellWidthChanged(); - void cellHeightChanged(); private: QPointer<QQuickTableView> m_tableview; - QQmlNullableValue<qreal> m_cellWidth; - QQmlNullableValue<qreal> m_cellHeight; friend class QQuickTableViewPrivate; }; diff --git a/tests/auto/quick/qquicktableview/data/countingtableview.qml b/tests/auto/quick/qquicktableview/data/countingtableview.qml index d8315be54f..1e8e9f43fb 100644 --- a/tests/auto/quick/qquicktableview/data/countingtableview.qml +++ b/tests/auto/quick/qquicktableview/data/countingtableview.qml @@ -64,8 +64,8 @@ Item { id: tableViewDelegate Rectangle { objectName: "tableViewDelegate" - TableView.cellWidth: 100 - TableView.cellHeight: 50 + implicitWidth: 100 + implicitHeight: 50 color: "lightgray" border.width: 1 Text { diff --git a/tests/auto/quick/qquicktableview/data/plaintableview.qml b/tests/auto/quick/qquicktableview/data/plaintableview.qml index 7668f0ca01..a073941faa 100644 --- a/tests/auto/quick/qquicktableview/data/plaintableview.qml +++ b/tests/auto/quick/qquicktableview/data/plaintableview.qml @@ -66,8 +66,8 @@ Item { id: tableViewDelegate Rectangle { objectName: "tableViewDelegate" - TableView.cellWidth: delegateWidth - TableView.cellHeight: delegateHeight + implicitWidth: delegateWidth + implicitHeight: delegateHeight color: "lightgray" border.width: 1 Text { diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index dc2176f839..34d8dc8d55 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -208,7 +208,7 @@ void tst_QQuickTableView::checkImplicitSizeDelegate() { // Check that we can set the size of delegate items using // implicit width/height, instead of forcing the user to - // create an attached object by using TableView.cellWidth/Height. + // create an attached object by using implicitWidth/Height. LOAD_TABLEVIEW("tableviewimplicitsize.qml"); auto model = TestModelAsVariant(100, 100); diff --git a/tests/manual/tableview/abstracttablemodel/main.qml b/tests/manual/tableview/abstracttablemodel/main.qml index 271752aaf1..52541657df 100644 --- a/tests/manual/tableview/abstracttablemodel/main.qml +++ b/tests/manual/tableview/abstracttablemodel/main.qml @@ -76,8 +76,8 @@ Window { Component { id: tableViewDelegate Rectangle { - TableView.cellWidth: column % 3 ? 80 : 50 - TableView.cellHeight: row % 3 ? 80 : 50 + implicitWidth: column % 3 ? 80 : 50 + implicitHeight: row % 3 ? 80 : 50 Text { anchors.centerIn: parent diff --git a/tests/manual/tableview/listmodel/main.qml b/tests/manual/tableview/listmodel/main.qml index ca39e6a2b9..53cc1ed141 100644 --- a/tests/manual/tableview/listmodel/main.qml +++ b/tests/manual/tableview/listmodel/main.qml @@ -72,8 +72,8 @@ Window { delegate: Component { Rectangle { id: tableDelegate - TableView.cellWidth: 100 - TableView.cellHeight: 50 + implicitWidth: 100 + implicitHeight: 50 Text { anchors.centerIn: parent diff --git a/tests/manual/tableview/storagemodel/main.qml b/tests/manual/tableview/storagemodel/main.qml index f76da374e3..ba73c7e5bf 100644 --- a/tests/manual/tableview/storagemodel/main.qml +++ b/tests/manual/tableview/storagemodel/main.qml @@ -60,8 +60,8 @@ Window { rowSpacing: 1 delegate: Rectangle { id: tableDelegate - TableView.cellWidth: displayText.implicitWidth + 8 - TableView.cellHeight: displayText.implicitHeight + 14 + implicitWidth: displayText.implicitWidth + 8 + implicitHeight: displayText.implicitHeight + 14 Text { id: displayText |