summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-05-11 00:22:00 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-05-11 00:22:00 (GMT)
commit7c70691d2867870f415118e5feef2963e882b140 (patch)
tree72ed5a3eb1cd48f1fc0bd8703e0b98f6fd4d1134 /src
parent221bb769bdb0c8c31825efd2b3ebcb063aff6afa (diff)
parentac19c9a30a47bfe8b374d390525b06ebdb26b4ca (diff)
downloadQt-7c70691d2867870f415118e5feef2963e882b140.zip
Qt-7c70691d2867870f415118e5feef2963e882b140.tar.gz
Qt-7c70691d2867870f415118e5feef2963e882b140.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r--src/declarative/3rdparty/qlistmodelinterface.cpp23
-rw-r--r--src/declarative/3rdparty/qlistmodelinterface.h27
-rw-r--r--src/declarative/fx/qfxflickable.cpp4
-rw-r--r--src/declarative/fx/qfxlistview.cpp49
-rw-r--r--src/declarative/fx/qfxpathview.cpp7
-rw-r--r--src/declarative/fx/qfxpathview.h1
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp4
7 files changed, 54 insertions, 61 deletions
diff --git a/src/declarative/3rdparty/qlistmodelinterface.cpp b/src/declarative/3rdparty/qlistmodelinterface.cpp
index 7e50378..d327b58 100644
--- a/src/declarative/3rdparty/qlistmodelinterface.cpp
+++ b/src/declarative/3rdparty/qlistmodelinterface.cpp
@@ -69,22 +69,16 @@ QT_BEGIN_NAMESPACE
Returns the number of data entries in the model.
*/
-/*! \fn QHash_int QListModelInterface::data(int index, const QList_int &roles) const
+/*! \fn QHash_int QListModelInterface::data(int index, const QList<int> &roles) const
Returns the data at the given \a index for the specifed \a roles.
*/
-/*! \fn bool QListModelInterface::setData(int index, const QHash_int &values)
+/*! \fn bool QListModelInterface::setData(int index, const QHash<int> &values)
Sets the data at the given \a index. \a values is a mapping of
QVariant values to roles.
*/
-/*! \fn bool QListModelInterface::setData(int index, const QVariant &value, int role)
- This convenience function builds a QHash_int from
- the specified \a role and \a value and calls the other setData()
- with the QHash and the \a index.
-*/
-
-/*! \fn QList_int QListModelInterface::roles() const
+/*! \fn QList<int> QListModelInterface::roles() const
Returns the list of roles for which the list model interface
provides data.
*/
@@ -102,15 +96,4 @@ QT_BEGIN_NAMESPACE
\value IconRole
*/
-/*!
- \typedef QListModelInterface::QHash_int
-
- Synonym for QHash<int, QVariant>.
-*/
-
-/*!
- \typedef QListModelInterface::QList_int
-
- Synonym for QList<int>.
-*/
QT_END_NAMESPACE
diff --git a/src/declarative/3rdparty/qlistmodelinterface.h b/src/declarative/3rdparty/qlistmodelinterface.h
index 8a0cf44..191a95b 100644
--- a/src/declarative/3rdparty/qlistmodelinterface.h
+++ b/src/declarative/3rdparty/qlistmodelinterface.h
@@ -60,38 +60,19 @@ class Q_DECLARATIVE_EXPORT QListModelInterface : public QObject
QListModelInterface(QObject *parent = 0) : QObject(parent) {}
virtual ~QListModelInterface() {}
- // ### move these into the Qt namespace
- enum Roles {
- TextRole = Qt::DisplayRole,
- IconRole = Qt::DecorationRole
- };
-
virtual int count() const = 0;
-
- typedef QHash<int, QVariant> QHash_int;
- typedef QList<int> QList_int;
- virtual QHash_int data(int index, const QList_int &roles = QList_int()) const = 0;
-
- virtual bool setData(int index, const QHash_int &values)
+ virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const = 0;
+ virtual bool setData(int index, const QHash<int,QVariant> &values)
{ Q_UNUSED(index); Q_UNUSED(values); return false; }
- inline bool setData(int index, const QVariant &value, int role)
- {
- QHash_int values;
- values.insert(role, value);
- return setData(index, values);
- }
-
- virtual QList_int roles() const = 0;
+ virtual QList<int> roles() const = 0;
virtual QString toString(int role) const = 0;
- //void bind(int index, int role, QObject *object, const char *propertyName, bool readOnly = true);
-
Q_SIGNALS:
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
void itemsMoved(int from, int to, int count);
- void itemsChanged(int index, int count, const QList_int &roles);
+ void itemsChanged(int index, int count, const QList<int> &roles);
protected:
QListModelInterface(QObjectPrivate &dd, QObject *parent)
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 890bb31..4ace811 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -129,10 +129,12 @@ void QFxFlickablePrivate::fixupX()
vTime = _tl.time();
if (_moveX.value() > q->minXExtent() || q->maxXExtent() > 0) {
+ _tl.clear();
_tl.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
} else if (_moveX.value() < q->maxXExtent()) {
+ _tl.clear();
_tl.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
@@ -148,9 +150,11 @@ void QFxFlickablePrivate::fixupY()
vTime = _tl.time();
if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
+ _tl.clear();
_tl.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else if (_moveY.value() < q->maxYExtent()) {
+ _tl.clear();
_tl.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else {
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index ad752a7..bb71a91 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -293,6 +293,29 @@ public:
}
return -1; // Not in visibleList
}
+
+ bool mapRangeFromModel(int &index, int &count) const {
+ if (index + count < visibleIndex)
+ return false;
+
+ int lastIndex = -1;
+ for (int i = visibleItems.count()-1; i >= 0; --i) {
+ FxListItem *listItem = visibleItems.at(i);
+ if (listItem->index != -1) {
+ lastIndex = listItem->index;
+ break;
+ }
+ }
+
+ if (index > lastIndex)
+ return false;
+
+ int last = qMin(index + count - 1, lastIndex);
+ index = qMax(index, visibleIndex);
+ count = last - index + 1;
+
+ return true;
+ }
// for debugging only
void checkVisible() const {
@@ -468,7 +491,7 @@ void QFxListViewPrivate::refill(qreal from, qreal to)
++modelIndex;
changed = true;
}
- while (visibleIndex > 0 && visiblePos > from) {
+ while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos > from) {
//qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos;
item = getItem(visibleIndex-1);
--visibleIndex;
@@ -1388,20 +1411,19 @@ void QFxListView::itemsInserted(int modelIndex, int count)
{
Q_D(QFxListView);
if (!d->visibleItems.count() || d->model->count() <= 1) {
- refill();
+ d->layout();
d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
emit countChanged();
return;
}
- int index = d->mapFromModel(modelIndex);
- if (index == -1) {
+ if (!d->mapRangeFromModel(modelIndex, count)) {
int i = d->visibleItems.count() - 1;
while (i > 0 && d->visibleItems.at(i)->index == -1)
--i;
if (d->visibleItems.at(i)->index + 1 == modelIndex) {
// Special case of appending an item to the model.
- index = d->visibleIndex + d->visibleItems.count();
+ modelIndex = d->visibleIndex + d->visibleItems.count();
} else {
if (modelIndex + count - 1 < d->visibleIndex) {
// Insert before visible items
@@ -1418,27 +1440,22 @@ void QFxListView::itemsInserted(int modelIndex, int count)
if (d->currentItem)
d->currentItem->index = d->currentIndex;
}
+ d->layout();
emit countChanged();
return;
}
}
// At least some of the added items will be visible
- int insertCount = count;
- if (index < d->visibleIndex) {
- insertCount -= d->visibleIndex - index;
- index = d->visibleIndex;
- modelIndex = d->visibleIndex;
- }
- index -= d->visibleIndex;
+ int index = modelIndex - d->visibleIndex;
int to = d->buffer+d->position()+d->size()-1;
// index can be the next item past the end of the visible items list (i.e. appended)
int pos = index < d->visibleItems.count() ? d->visibleItems.at(index)->position()
: d->visibleItems.at(index-1)->endPosition()+1;
int initialPos = pos;
QList<FxListItem*> added;
- for (int i = 0; i < insertCount && pos <= to; ++i) {
+ for (int i = 0; i < count && pos <= to; ++i) {
FxListItem *item = d->createItem(modelIndex + i);
d->visibleItems.insert(index, item);
item->setPosition(pos);
@@ -1479,8 +1496,7 @@ void QFxListView::itemsInserted(int modelIndex, int count)
void QFxListView::itemsRemoved(int modelIndex, int count)
{
Q_D(QFxListView);
- int index = d->mapFromModel(modelIndex);
- if (index == -1) {
+ if (!d->mapRangeFromModel(modelIndex, count)) {
if (modelIndex + count - 1 < d->visibleIndex) {
// Items removed before our visible items.
d->visibleIndex -= count;
@@ -1504,6 +1520,7 @@ void QFxListView::itemsRemoved(int modelIndex, int count)
d->currentIndex = -1;
d->updateCurrent(qMin(modelIndex, d->model->count()-1));
}
+ d->layout();
emit countChanged();
return;
}
@@ -1561,6 +1578,8 @@ void QFxListView::itemsRemoved(int modelIndex, int count)
if (d->visibleItems.isEmpty()) {
d->visibleIndex = 0;
+ d->visiblePos = 0;
+ d->_tl.clear();
d->setPosition(0);
if (d->model->count() == 0)
update();
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 77d5fa2..b7215cf 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -66,6 +66,11 @@ public:
{
}
+ ~QFxPathViewAttached()
+ {
+ QFxPathView::attachedProperties.remove(parent());
+ }
+
QVariant value(const QByteArray &name) const
{
return mo->value(name);
@@ -583,7 +588,7 @@ void QFxPathViewPrivate::regenerate()
void QFxPathViewPrivate::updateItem(QFxItem *item, qreal percent)
{
- if (QObject *obj = QFxPathView::attachedProperties.value(item)) {
+ if (QObject *obj = QFxPathView::qmlAttachedProperties(item)) {
foreach(const QString &attr, path->attributes())
static_cast<QFxPathViewAttached *>(obj)->setValue(attr.toLatin1(), path->attributeAt(attr, percent));
}
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index 0e1ac6f..2ecd04e 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -122,6 +122,7 @@ protected:
QFxPathView(QFxPathViewPrivate &dd, QFxItem *parent);
private:
+ friend class QFxPathViewAttached;
static QHash<QObject*, QObject*> attachedProperties;
Q_DISABLE_COPY(QFxPathView)
Q_DECLARE_PRIVATE(QFxPathView)
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 0092ec2..169e2ea 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -226,9 +226,9 @@ ProcessAST::defineObjectBinding_helper(int line,
return 0;
}
- SourceLocation loc = typeLocation;
+ LocationSpan loc = ProcessAST::location(typeLocation, typeLocation);
if (propertyName)
- loc = location(propertyName);
+ loc = ProcessAST::location(propertyName);
_stateStack.pushProperty(objectType, loc);
accept(initializer);