aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-09-19 13:50:03 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-19 06:24:47 +0200
commit1aa075b6319ded90d79dfe28605294283502bead (patch)
tree59751e7937657d1544a9a2db1ff71f432195db1e /src
parentb0539f0ed9e848afd6df2cb4d01eb5af70168df8 (diff)
Make cellWidth/cellHeight reals rather than ints.
When they were ints, it was relatively easy to end up with a different row or column count than expected, because of rounding. Change-Id: Ifc5eba2b5598cbc0220df25f91f031581c3b51a5 Reviewed-on: http://codereview.qt-project.org/5112 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/items/qsggridview.cpp30
-rw-r--r--src/declarative/items/qsggridview_p.h12
2 files changed, 21 insertions, 21 deletions
diff --git a/src/declarative/items/qsggridview.cpp b/src/declarative/items/qsggridview.cpp
index e2fe5cd9c8..4d794aaa78 100644
--- a/src/declarative/items/qsggridview.cpp
+++ b/src/declarative/items/qsggridview.cpp
@@ -93,7 +93,7 @@ public:
qreal colPos() const {
if (view->flow() == QSGGridView::LeftToRight) {
if (view->effectiveLayoutDirection() == Qt::RightToLeft) {
- int colSize = view->cellWidth();
+ qreal colSize = view->cellWidth();
int columns = view->width()/colSize;
return colSize * (columns-1) - item->x();
} else {
@@ -152,8 +152,8 @@ public:
virtual qreal originPosition() const;
virtual qreal lastPosition() const;
- int rowSize() const;
- int colSize() const;
+ qreal rowSize() const;
+ qreal colSize() const;
qreal colPosAt(int modelIndex) const;
qreal rowPosAt(int modelIndex) const;
qreal snapPosAt(qreal pos) const;
@@ -196,8 +196,8 @@ public:
QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
QSGGridView::Flow flow;
- int cellWidth;
- int cellHeight;
+ qreal cellWidth;
+ qreal cellHeight;
int columns;
QSGGridView::SnapMode snapMode;
@@ -276,10 +276,10 @@ qreal QSGGridViewPrivate::endPositionAt(int index) const
return rowPosAt(index) + rowSize();
}
-int QSGGridViewPrivate::rowSize() const {
+qreal QSGGridViewPrivate::rowSize() const {
return flow == QSGGridView::LeftToRight ? cellHeight : cellWidth;
}
-int QSGGridViewPrivate::colSize() const {
+qreal QSGGridViewPrivate::colSize() const {
return flow == QSGGridView::LeftToRight ? cellWidth : cellHeight;
}
@@ -1374,24 +1374,24 @@ void QSGGridView::setFlow(Flow flow)
/*!
- \qmlproperty int QtQuick2::GridView::cellWidth
- \qmlproperty int QtQuick2::GridView::cellHeight
+ \qmlproperty real QtQuick2::GridView::cellWidth
+ \qmlproperty real QtQuick2::GridView::cellHeight
These properties holds the width and height of each cell in the grid.
The default cell size is 100x100.
*/
-int QSGGridView::cellWidth() const
+qreal QSGGridView::cellWidth() const
{
Q_D(const QSGGridView);
return d->cellWidth;
}
-void QSGGridView::setCellWidth(int cellWidth)
+void QSGGridView::setCellWidth(qreal cellWidth)
{
Q_D(QSGGridView);
if (cellWidth != d->cellWidth && cellWidth > 0) {
- d->cellWidth = qMax(1, cellWidth);
+ d->cellWidth = qMax(qreal(1), cellWidth);
d->updateViewport();
emit cellWidthChanged();
d->forceLayout = true;
@@ -1399,17 +1399,17 @@ void QSGGridView::setCellWidth(int cellWidth)
}
}
-int QSGGridView::cellHeight() const
+qreal QSGGridView::cellHeight() const
{
Q_D(const QSGGridView);
return d->cellHeight;
}
-void QSGGridView::setCellHeight(int cellHeight)
+void QSGGridView::setCellHeight(qreal cellHeight)
{
Q_D(QSGGridView);
if (cellHeight != d->cellHeight && cellHeight > 0) {
- d->cellHeight = qMax(1, cellHeight);
+ d->cellHeight = qMax(qreal(1), cellHeight);
d->updateViewport();
emit cellHeightChanged();
d->forceLayout = true;
diff --git a/src/declarative/items/qsggridview_p.h b/src/declarative/items/qsggridview_p.h
index 1cdf81d213..c3b92d0448 100644
--- a/src/declarative/items/qsggridview_p.h
+++ b/src/declarative/items/qsggridview_p.h
@@ -61,8 +61,8 @@ class Q_AUTOTEST_EXPORT QSGGridView : public QSGItemView
Q_DECLARE_PRIVATE(QSGGridView)
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
- Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
- Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
+ Q_PROPERTY(qreal cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
+ Q_PROPERTY(qreal cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
@@ -81,11 +81,11 @@ public:
Flow flow() const;
void setFlow(Flow);
- int cellWidth() const;
- void setCellWidth(int);
+ qreal cellWidth() const;
+ void setCellWidth(qreal);
- int cellHeight() const;
- void setCellHeight(int);
+ qreal cellHeight() const;
+ void setCellHeight(qreal);
enum SnapMode { NoSnap, SnapToRow, SnapOneRow };
SnapMode snapMode() const;