diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-05-04 12:48:42 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-05-28 09:29:47 +0000 |
commit | 7dc48bb0b56de00faab2d67570c74f0512991263 (patch) | |
tree | 02176c42c3c630bea9fb1646a900bf8f3f35f1b1 /src/quick/items/qquicktableview_p.h | |
parent | 61bbac145a6d69ab07e74b2f54ba1257bd6c3721 (diff) |
TableView: switch to use TableView.cellWidth/cellHeight
This is logically more correct since TableView will override
width / height anyway to make the delegates fit into the table if
they are not as wide/tall as the widest column/row.
And it gets even more problematic when we recycle delegates, since
in that case we need to keep the original width binding of the
delegate to calulate the size of new columns. And this all
fits better by using attached properties instead.
Change-Id: Ia5f2acd2bfc45f3fb160c3782191ad8da9f780e6
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview_p.h')
-rw-r--r-- | src/quick/items/qquicktableview_p.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h index 8cc5800d7e..0589d83f50 100644 --- a/src/quick/items/qquicktableview_p.h +++ b/src/quick/items/qquicktableview_p.h @@ -141,6 +141,8 @@ 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) Q_PROPERTY(int row READ row NOTIFY rowChanged) Q_PROPERTY(int column READ column NOTIFY columnChanged) @@ -156,6 +158,22 @@ public: Q_EMIT tableViewChanged(); } + qreal cellWidth() const { return m_cellSize.width(); } + void setCellWidth(qreal newWidth) { + if (newWidth == m_cellSize.width()) + return; + m_cellSize.setWidth(newWidth); + Q_EMIT cellWidthChanged(); + } + + qreal cellHeight() const { return m_cellSize.height(); } + void setCellHeight(qreal newHeight) { + if (newHeight == m_cellSize.height()) + return; + m_cellSize.setHeight(newHeight); + Q_EMIT cellHeightChanged(); + } + int row() const { return m_row; } void setRow(int newRow) { if (newRow == m_row) @@ -174,6 +192,8 @@ public: Q_SIGNALS: void tableViewChanged(); + void cellWidthChanged(); + void cellHeightChanged(); void rowChanged(); void columnChanged(); @@ -181,6 +201,7 @@ private: QPointer<QQuickTableView> m_tableview; int m_row = -1; int m_column = -1; + QSizeF m_cellSize; }; QT_END_NAMESPACE |