summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-03-04 04:49:56 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-03-04 04:49:56 (GMT)
commitba85f14b140c08cbafe263954947d818152146e0 (patch)
treef4aef61ed35c7cfd66195e160b963b1a40b65a98 /src/declarative
parenteda079761194a96783cdb8d49c79eb2c9c0b7dac (diff)
parent8047d8f2e63df60b5ea3f6fd02568658c3d19fc6 (diff)
downloadQt-ba85f14b140c08cbafe263954947d818152146e0.zip
Qt-ba85f14b140c08cbafe263954947d818152146e0.tar.gz
Qt-ba85f14b140c08cbafe263954947d818152146e0.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp26
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h19
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp11
-rw-r--r--src/declarative/util/qdeclarativeview.cpp2
4 files changed, 37 insertions, 21 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 5b313be..463b238 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -52,8 +52,6 @@
QT_BEGIN_NAMESPACE
-QHash<QObject*, QDeclarativeGridViewAttached*> QDeclarativeGridViewAttached::attachedProperties;
-
//----------------------------------------------------------------------------
@@ -61,8 +59,9 @@ class FxGridItem
{
public:
FxGridItem(QDeclarativeItem *i, QDeclarativeGridView *v) : item(i), view(v) {
- attached = QDeclarativeGridViewAttached::properties(item);
- attached->m_view = view;
+ attached = static_cast<QDeclarativeGridViewAttached*>(qmlAttachedPropertiesObject<QDeclarativeGridView>(item));
+ if (attached)
+ attached->m_view = view;
}
~FxGridItem() {}
@@ -697,6 +696,11 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex)
In this case ListModel is a handy way for us to test our UI. In practice
the model would be implemented in C++, or perhaps via a SQL data source.
+
+ Note that views do not enable \e clip automatically. If the view
+ is not clipped by another item or the screen, it will be necessary
+ to set \e {clip: true} in order to have the out of view items clipped
+ nicely.
*/
QDeclarativeGridView::QDeclarativeGridView(QDeclarativeItem *parent)
: QDeclarativeFlickable(*(new QDeclarativeGridViewPrivate), parent)
@@ -1336,6 +1340,18 @@ void QDeclarativeGridView::moveCurrentIndexRight()
}
}
+/*!
+ \qmlmethod GridView::positionViewAtIndex(int index)
+
+ Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view.
+ If positioning the view at the index would cause empty space to be displayed at
+ the end of the view, the view will be positioned at the end.
+
+ It is not recommended to use contentX or contentY to position the view
+ at a particular index. This is unreliable since removing items from the start
+ of the list does not cause all other items to be repositioned.
+ The correct way to bring an item into view is with positionViewAtIndex.
+*/
void QDeclarativeGridView::positionViewAtIndex(int index)
{
Q_D(QDeclarativeGridView);
@@ -1743,7 +1759,7 @@ void QDeclarativeGridView::refill()
QDeclarativeGridViewAttached *QDeclarativeGridView::qmlAttachedProperties(QObject *obj)
{
- return QDeclarativeGridViewAttached::properties(obj);
+ return new QDeclarativeGridViewAttached(obj);
}
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index d463a46..22fcef6 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -167,9 +167,7 @@ class QDeclarativeGridViewAttached : public QObject
public:
QDeclarativeGridViewAttached(QObject *parent)
: QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
- ~QDeclarativeGridViewAttached() {
- attachedProperties.remove(parent());
- }
+ ~QDeclarativeGridViewAttached() {}
Q_PROPERTY(QDeclarativeGridView *view READ view CONSTANT)
QDeclarativeGridView *view() { return m_view; }
@@ -192,15 +190,6 @@ public:
}
}
- static QDeclarativeGridViewAttached *properties(QObject *obj) {
- QDeclarativeGridViewAttached *rv = attachedProperties.value(obj);
- if (!rv) {
- rv = new QDeclarativeGridViewAttached(obj);
- attachedProperties.insert(obj, rv);
- }
- return rv;
- }
-
void emitAdd() { emit add(); }
void emitRemove() { emit remove(); }
@@ -212,10 +201,8 @@ Q_SIGNALS:
public:
QDeclarativeGridView *m_view;
- bool m_isCurrent;
- bool m_delayRemove;
-
- static QHash<QObject*, QDeclarativeGridViewAttached*> attachedProperties;
+ bool m_isCurrent : 1;
+ bool m_delayRemove : 1;
};
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index eb5315d..32627da 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -1359,6 +1359,11 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity)
In this case ListModel is a handy way for us to test our UI. In practice
the model would be implemented in C++, or perhaps via a SQL data source.
+
+ Note that views do not enable \e clip automatically. If the view
+ is not clipped by another item or the screen, it will be necessary
+ to set \e {clip: true} in order to have the out of view items clipped
+ nicely.
*/
QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent)
@@ -2281,6 +2286,12 @@ void QDeclarativeListView::decrementCurrentIndex()
Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view.
If positioning the view at the index would cause empty space to be displayed at
the end of the view, the view will be positioned at the end.
+
+ It is not recommended to use contentX or contentY to position the view
+ at a particular index. This is unreliable since removing items from the start
+ of the list does not cause all other items to be repositioned, and because
+ the actual start of the view can vary based on the size of the delegates.
+ The correct way to bring an item into view is with positionViewAtIndex.
*/
void QDeclarativeListView::positionViewAtIndex(int index)
{
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index f08e634..cd67aeb 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -194,6 +194,7 @@ void QDeclarativeViewPrivate::execute()
\o Initializes QGraphicsView for QML key handling:
\list
\o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus);
+ \o QGraphicsView::setFocusPolicy(Qt::StrongFocus);
\o QGraphicsScene::setStickyFocus(true);
\endlist
\endlist
@@ -268,6 +269,7 @@ void QDeclarativeViewPrivate::init()
q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
q->viewport()->setFocusPolicy(Qt::NoFocus);
+ q->setFocusPolicy(Qt::StrongFocus);
scene.setStickyFocus(true); //### needed for correct focus handling
}