aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-09-07 13:55:23 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-09-10 09:30:58 +0000
commit2aaf007c1367f58ce80bc660c56ab2c3284d1388 (patch)
treebde3db0fd685eda84ab35712ce19bd7c03a4c1e0 /src/quick/items
parent8415875d286f2ecc78e77e9c19972f323f76054a (diff)
QQuickTableView: don't override margins API in TableView
Flickable has a margins API with the exact same naming as the margins API in TableView. This means that overriding those properties in TableView was an oversight, and a mistake. This patch will therefore remove the margins API from TableView. However, since the API already exists is in Flickable, the resulting API remains unchanged. But it will ease the TableView implementation a bit, since we can then remove code that takes margins into account (since Flickable does this automatically for us). The only real difference that will take effect from this change, is that any overlay or underlay items inside the flickable will need to have negative coordinates if you want to position them on top of the margins (e.g to create a header on top of the table). Change-Id: I43af66e49f5ddff90739a1c789aacb77ed18b4ce Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquicktableview.cpp140
-rw-r--r--src/quick/items/qquicktableview_p.h20
-rw-r--r--src/quick/items/qquicktableview_p_p.h1
3 files changed, 12 insertions, 149 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index ffd0ff4fa5..093aec6cdc 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -210,42 +210,6 @@
*/
/*!
- \qmlproperty real QtQuick::TableView::topMargin
-
- This property holds the margin between the top of the table and
- the top of the content view.
-
- The default value is 0.
-*/
-
-/*!
- \qmlproperty real QtQuick::TableView::bottomMargin
-
- This property holds the margin between the bottom of the table and
- the bottom of the content view.
-
- The default value is 0.
-*/
-
-/*!
- \qmlproperty real QtQuick::TableView::leftMargin
-
- This property holds the margin between the left side of the table and
- the left side of the content view.
-
- The default value is 0.
-*/
-
-/*!
- \qmlproperty real QtQuick::TableView::rightMargin
-
- This property holds the margin between the right side of the table and
- the right side of the content view.
-
- The default value is 0.
-*/
-
-/*!
\qmlproperty var QtQuick::TableView::rowHeightProvider
This property can hold a function that returns the row height for each row
@@ -531,14 +495,10 @@ void QQuickTableViewPrivate::updateContentWidth()
contentSizeBenchMarkPoint.setX(currentRightColumn);
const qreal spacing = currentRightColumn * cellSpacing.width();
- const qreal margins = tableMargins.left() + tableMargins.right();
- qreal currentWidth = loadedTableOuterRect.right() - tableMargins.left();
+ qreal currentWidth = loadedTableOuterRect.right();
const qreal averageCellWidth = (currentWidth - spacing) / (currentRightColumn + 1);
qreal estimatedWidth = (tableSize.width() * (averageCellWidth + cellSpacing.width())) - cellSpacing.width();
- currentWidth += margins;
- estimatedWidth += margins;
-
if (currentRightColumn >= tableSize.width() - 1) {
// We are at the last column, and can set the exact width
if (currentWidth != q->implicitWidth())
@@ -572,14 +532,10 @@ void QQuickTableViewPrivate::updateContentHeight()
contentSizeBenchMarkPoint.setY(currentBottomRow);
const qreal spacing = currentBottomRow * cellSpacing.height();
- const qreal margins = tableMargins.top() + tableMargins.bottom();
- qreal currentHeight = loadedTableOuterRect.bottom() - tableMargins.top();
+ qreal currentHeight = loadedTableOuterRect.bottom();
const qreal averageCellHeight = (currentHeight - spacing) / (currentBottomRow + 1);
qreal estimatedHeight = (tableSize.height() * (averageCellHeight + cellSpacing.height())) - cellSpacing.height();
- currentHeight += margins;
- estimatedHeight += margins;
-
if (currentBottomRow >= tableSize.height() - 1) {
// We are at the last row, and can set the exact height
if (currentHeight != q->implicitHeight())
@@ -605,23 +561,23 @@ void QQuickTableViewPrivate::enforceTableAtOrigin()
bool layoutNeeded = false;
const qreal flickMargin = 50;
- if (loadedTable.x() == 0 && loadedTableOuterRect.x() > tableMargins.left()) {
+ if (loadedTable.x() == 0 && loadedTableOuterRect.x() > 0) {
// The table is at the beginning, but not at the edge of the
- // content view. So move the table to origo.
- loadedTableOuterRect.moveLeft(tableMargins.left());
+ // content view. So move the table to origin.
+ loadedTableOuterRect.moveLeft(0);
layoutNeeded = true;
- } else if (loadedTableOuterRect.x() < tableMargins.left()) {
+ } else if (loadedTableOuterRect.x() < 0) {
// The table is outside the beginning of the content view. Move
// the whole table inside, and make some room for flicking.
- loadedTableOuterRect.moveLeft(qFuzzyIsNull(tableMargins.left() + loadedTable.x()) ? 0 : flickMargin);
+ loadedTableOuterRect.moveLeft(loadedTable.x() == 0 ? 0 : flickMargin);
layoutNeeded = true;
}
- if (loadedTable.y() == 0 && loadedTableOuterRect.y() > tableMargins.top()) {
- loadedTableOuterRect.moveTop(tableMargins.top());
+ if (loadedTable.y() == 0 && loadedTableOuterRect.y() > 0) {
+ loadedTableOuterRect.moveTop(0);
layoutNeeded = true;
- } else if (loadedTableOuterRect.y() < tableMargins.top()) {
- loadedTableOuterRect.moveTop(qFuzzyIsNull(tableMargins.top() + loadedTable.y()) ? 0 : flickMargin);
+ } else if (loadedTableOuterRect.y() < 0) {
+ loadedTableOuterRect.moveTop(loadedTable.y() == 0 ? 0 : flickMargin);
layoutNeeded = true;
}
@@ -1319,7 +1275,7 @@ void QQuickTableViewPrivate::beginRebuildTable()
if (rebuildOptions & RebuildOption::All) {
releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
topLeft = QPoint(0, 0);
- topLeftPos = QPointF(tableMargins.left(), tableMargins.top());
+ topLeftPos = QPoint(0, 0);
q->setContentX(0);
q->setContentY(0);
} else if (rebuildOptions & RebuildOption::ViewportOnly) {
@@ -1783,78 +1739,6 @@ void QQuickTableView::setColumnSpacing(qreal spacing)
emit columnSpacingChanged();
}
-qreal QQuickTableView::topMargin() const
-{
- return d_func()->tableMargins.top();
-}
-
-void QQuickTableView::setTopMargin(qreal margin)
-{
- Q_D(QQuickTableView);
- if (qt_is_nan(margin))
- return;
- if (qFuzzyCompare(d->tableMargins.top(), margin))
- return;
-
- d->tableMargins.setTop(margin);
- d->invalidateColumnRowPositions();
- emit topMarginChanged();
-}
-
-qreal QQuickTableView::bottomMargin() const
-{
- return d_func()->tableMargins.bottom();
-}
-
-void QQuickTableView::setBottomMargin(qreal margin)
-{
- Q_D(QQuickTableView);
- if (qt_is_nan(margin))
- return;
- if (qFuzzyCompare(d->tableMargins.bottom(), margin))
- return;
-
- d->tableMargins.setBottom(margin);
- d->invalidateColumnRowPositions();
- emit bottomMarginChanged();
-}
-
-qreal QQuickTableView::leftMargin() const
-{
- return d_func()->tableMargins.left();
-}
-
-void QQuickTableView::setLeftMargin(qreal margin)
-{
- Q_D(QQuickTableView);
- if (qt_is_nan(margin))
- return;
- if (qFuzzyCompare(d->tableMargins.left(), margin))
- return;
-
- d->tableMargins.setLeft(margin);
- d->invalidateColumnRowPositions();
- emit leftMarginChanged();
-}
-
-qreal QQuickTableView::rightMargin() const
-{
- return d_func()->tableMargins.right();
-}
-
-void QQuickTableView::setRightMargin(qreal margin)
-{
- Q_D(QQuickTableView);
- if (qt_is_nan(margin))
- return;
- if (qFuzzyCompare(d->tableMargins.right(), margin))
- return;
-
- d->tableMargins.setRight(margin);
- d->invalidateColumnRowPositions();
- emit rightMarginChanged();
-}
-
QJSValue QQuickTableView::rowHeightProvider() const
{
return d_func()->rowHeightProvider;
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h
index 2ffc23d29b..0a2eff8fc1 100644
--- a/src/quick/items/qquicktableview_p.h
+++ b/src/quick/items/qquicktableview_p.h
@@ -72,10 +72,6 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable
Q_PROPERTY(int columns READ columns NOTIFY columnsChanged)
Q_PROPERTY(qreal rowSpacing READ rowSpacing WRITE setRowSpacing NOTIFY rowSpacingChanged)
Q_PROPERTY(qreal columnSpacing READ columnSpacing WRITE setColumnSpacing NOTIFY columnSpacingChanged)
- Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
- Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
- Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
- Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
Q_PROPERTY(QJSValue rowHeightProvider READ rowHeightProvider WRITE setRowHeightProvider NOTIFY rowHeightProviderChanged)
Q_PROPERTY(QJSValue columnWidthProvider READ columnWidthProvider WRITE setColumnWidthProvider NOTIFY columnWidthProviderChanged)
Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
@@ -96,18 +92,6 @@ public:
qreal columnSpacing() const;
void setColumnSpacing(qreal spacing);
- qreal topMargin() const;
- void setTopMargin(qreal margin);
-
- qreal bottomMargin() const;
- void setBottomMargin(qreal margin);
-
- qreal leftMargin() const;
- void setLeftMargin(qreal margin);
-
- qreal rightMargin() const;
- void setRightMargin(qreal margin);
-
QJSValue rowHeightProvider() const;
void setRowHeightProvider(QJSValue provider);
@@ -137,10 +121,6 @@ Q_SIGNALS:
void columnsChanged();
void rowSpacingChanged();
void columnSpacingChanged();
- void topMarginChanged();
- void bottomMarginChanged();
- void leftMarginChanged();
- void rightMarginChanged();
void rowHeightProviderChanged();
void columnWidthProviderChanged();
void modelChanged();
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index 1e8c10c285..e7b2c57086 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -227,7 +227,6 @@ public:
QPoint contentSizeBenchMarkPoint = QPoint(-1, -1);
QSizeF cellSpacing = QSizeF(0, 0);
- QMarginsF tableMargins;
QQmlTableInstanceModel::ReusableFlag reusableFlag = QQmlTableInstanceModel::Reusable;