summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-02-03 06:11:38 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-02-03 06:11:38 (GMT)
commit9c700d5d0981c9f0ffc8be552a0e7305a3692cb2 (patch)
treec7bf2a99e10641eeaa2be70d28382b0361b4750c
parentbacc9a899aaee5e81d74e86fd30d46f4ab537488 (diff)
parent59865a84484c29bd21bda62e3c55c8d2eb957f28 (diff)
downloadQt-9c700d5d0981c9f0ffc8be552a0e7305a3692cb2.zip
Qt-9c700d5d0981c9f0ffc8be552a0e7305a3692cb2.tar.gz
Qt-9c700d5d0981c9f0ffc8be552a0e7305a3692cb2.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp10
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp6
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview.cpp63
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview_p_p.h18
5 files changed, 80 insertions, 25 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index df8c275..c4edb28 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
@@ -826,17 +826,17 @@ void QmlGraphicsFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
QmlGraphicsItem::wheelEvent(event);
} else if (yflick()) {
if (event->delta() > 0)
- d->velocityY = qMax(event->delta() - d->verticalVelocity.value(), 250.0);
+ d->velocityY = qMax(event->delta() - d->verticalVelocity.value(), qreal(250.0));
else
- d->velocityY = qMin(event->delta() - d->verticalVelocity.value(), -250.0);
+ d->velocityY = qMin(event->delta() - d->verticalVelocity.value(), qreal(-250.0));
d->flicked = false;
d->flickY(d->velocityY);
event->accept();
} else if (xflick()) {
if (event->delta() > 0)
- d->velocityX = qMax(event->delta() - d->horizontalVelocity.value(), 250.0);
+ d->velocityX = qMax(event->delta() - d->horizontalVelocity.value(), qreal(250.0));
else
- d->velocityX = qMin(event->delta() - d->horizontalVelocity.value(), -250.0);
+ d->velocityX = qMin(event->delta() - d->horizontalVelocity.value(), qreal(-250.0));
d->flicked = false;
d->flickX(d->velocityX);
event->accept();
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 890d3ad..7105300 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -151,7 +151,7 @@ class QmlGraphicsGridViewPrivate : public QmlGraphicsFlickablePrivate
public:
QmlGraphicsGridViewPrivate()
- : model(0), currentItem(0), flow(QmlGraphicsGridView::LeftToRight)
+ : currentItem(0), flow(QmlGraphicsGridView::LeftToRight)
, visiblePos(0), visibleIndex(0) , currentIndex(-1)
, cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1)
, highlightComponent(0), highlight(0), trackedItem(0)
@@ -307,7 +307,7 @@ public:
}
}
- QmlGraphicsVisualModel *model;
+ QGuard<QmlGraphicsVisualModel> model;
QVariant modelVariant;
QList<FxGridItem*> visibleItems;
QHash<QmlGraphicsItem*,int> unrequestedItems;
@@ -350,6 +350,7 @@ void QmlGraphicsGridViewPrivate::init()
void QmlGraphicsGridViewPrivate::clear()
{
+ qDebug() << "clearing items" << visibleItems.count();
for (int i = 0; i < visibleItems.count(); ++i)
releaseItem(visibleItems.at(i));
visibleItems.clear();
@@ -384,13 +385,16 @@ FxGridItem *QmlGraphicsGridViewPrivate::createItem(int modelIndex)
void QmlGraphicsGridViewPrivate::releaseItem(FxGridItem *item)
{
Q_Q(QmlGraphicsGridView);
- if (!item)
+ if (!item || !model)
return;
if (trackedItem == item) {
QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
trackedItem = 0;
}
+ qDebug() << "release" << item;
+ qDebug() << " item" << item->item;
+ qDebug() << " model" << model;
if (model->release(item->item) == 0) {
// item was not destroyed, and we no longer reference it.
unrequestedItems.insert(item->item, model->indexOf(item->item, q));
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index ad0aa04..8fb7c84 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -210,7 +210,7 @@ class QmlGraphicsListViewPrivate : public QmlGraphicsFlickablePrivate, private Q
public:
QmlGraphicsListViewPrivate()
- : model(0), currentItem(0), orient(QmlGraphicsListView::Vertical)
+ : currentItem(0), orient(QmlGraphicsListView::Vertical)
, visiblePos(0), visibleIndex(0)
, averageSize(100.0), currentIndex(-1), requestedIndex(-1)
, highlightRangeStart(0), highlightRangeEnd(0)
@@ -495,7 +495,7 @@ public:
virtual void flickX(qreal velocity);
virtual void flickY(qreal velocity);
- QmlGraphicsVisualModel *model;
+ QGuard<QmlGraphicsVisualModel> model;
QVariant modelVariant;
QList<FxListItem*> visibleItems;
QHash<QmlGraphicsItem*,int> unrequestedItems;
@@ -615,7 +615,7 @@ FxListItem *QmlGraphicsListViewPrivate::createItem(int modelIndex)
void QmlGraphicsListViewPrivate::releaseItem(FxListItem *item)
{
Q_Q(QmlGraphicsListView);
- if (!item)
+ if (!item || !model)
return;
if (trackedItem == item) {
const char *notifier1 = orient == QmlGraphicsListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
index 112eda2..85e87eb 100644
--- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
@@ -71,9 +71,11 @@ inline qreal qmlMod(qreal x, qreal y)
class QmlGraphicsPathViewAttached : public QObject
{
Q_OBJECT
+
+ Q_PROPERTY(bool onPath READ isOnPath NOTIFY onPathChanged)
public:
QmlGraphicsPathViewAttached(QObject *parent)
- : QObject(parent), mo(new QmlOpenMetaObject(this))
+ : QObject(parent), mo(new QmlOpenMetaObject(this)), onPath(false)
{
}
@@ -91,10 +93,49 @@ public:
mo->setValue(name, val);
}
+ bool isOnPath() const { return onPath; }
+ void setOnPath(bool on) {
+ if (on != onPath) {
+ onPath = on;
+ emit onPathChanged();
+ }
+ }
+
+Q_SIGNALS:
+ void onPathChanged();
+
private:
QmlOpenMetaObject *mo;
+ bool onPath;
};
+
+QmlGraphicsItem *QmlGraphicsPathViewPrivate::getItem(int modelIndex)
+{
+ Q_Q(QmlGraphicsPathView);
+ requestedIndex = modelIndex;
+ QmlGraphicsItem *item = model->item(modelIndex);
+ if (item) {
+ if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item))
+ static_cast<QmlGraphicsPathViewAttached *>(obj)->setOnPath(true);
+ item->setParentItem(q);
+ }
+ requestedIndex = -1;
+ return item;
+}
+
+void QmlGraphicsPathViewPrivate::releaseItem(QmlGraphicsItem *item)
+{
+ if (!item || !model)
+ return;
+ if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item))
+ static_cast<QmlGraphicsPathViewAttached *>(obj)->setOnPath(false);
+ if (model->release(item) == 0) {
+ if (QObject *obj = QmlGraphicsPathView::qmlAttachedProperties(item))
+ static_cast<QmlGraphicsPathViewAttached *>(obj)->setOnPath(false);
+ }
+}
+
/*!
\qmlclass PathView QmlGraphicsPathView
\brief The PathView element lays out model-provided items on a path.
@@ -126,6 +167,26 @@ QmlGraphicsPathView::~QmlGraphicsPathView()
}
/*!
+ \qmlattachedproperty bool PathView::onPath
+ This attached property holds whether the item is currently on the path.
+
+ If a pathItemCount has been set, it is possible that some items may
+ be instantiated, but not considered to be currently on the path.
+ Usually, these items would be set invisible, for example:
+
+ \code
+ Component {
+ Rectangle {
+ visible: PathView.onPath
+ ...
+ }
+ }
+ \endcode
+
+ It is attached to each instance of the delegate.
+*/
+
+/*!
\qmlproperty model PathView::model
This property holds the model providing data for the view.
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
index 7ffe6ac..18cb205 100644
--- a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h
@@ -79,7 +79,7 @@ public:
: path(0), currentIndex(0), startPc(0), lastDist(0)
, lastElapsed(0), stealMouse(false), ownModel(false), activeItem(0)
, snapPos(0), dragMargin(0), moveOffset(this, &QmlGraphicsPathViewPrivate::setOffset)
- , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1), model(0)
+ , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1)
, moveReason(Other)
{
fixupOffsetEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsPathViewPrivate, &QmlGraphicsPathViewPrivate::fixOffset>(&moveOffset, this);
@@ -95,18 +95,8 @@ public:
q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked()));
}
- QmlGraphicsItem *getItem(int modelIndex) {
- Q_Q(QmlGraphicsPathView);
- requestedIndex = modelIndex;
- QmlGraphicsItem *item = model->item(modelIndex);
- if (item)
- item->setParentItem(q);
- requestedIndex = -1;
- return item;
- }
- void releaseItem(QmlGraphicsItem *item) {
- model->release(item);
- }
+ QmlGraphicsItem *getItem(int modelIndex);
+ void releaseItem(QmlGraphicsItem *item);
bool isValid() const {
return model && model->count() > 0 && model->isValid() && path;
@@ -143,7 +133,7 @@ public:
int pathOffset;
int requestedIndex;
QList<QmlGraphicsItem *> items;
- QmlGraphicsVisualModel *model;
+ QGuard<QmlGraphicsVisualModel> model;
QVariant modelVariant;
enum MovementReason { Other, Key, Mouse };
MovementReason moveReason;