summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-10-27 03:56:11 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-10-27 03:56:11 (GMT)
commit174b95702dac03866f684426f84dfdf882293b0b (patch)
tree388a7db9b2a3e5f61bca508e88954f2961b4e34b
parenta9745ccc4d1d5e8e033a805fe1870221250f7dec (diff)
parentb214f0da048a71cd7da410c32c111d3b92cbca47 (diff)
downloadQt-174b95702dac03866f684426f84dfdf882293b0b.zip
Qt-174b95702dac03866f684426f84dfdf882293b0b.tar.gz
Qt-174b95702dac03866f684426f84dfdf882293b0b.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--examples/declarative/focusscope/test3.qml4
-rw-r--r--examples/declarative/listview/itemlist.qml4
-rw-r--r--examples/declarative/listview/listview.qml7
-rw-r--r--examples/declarative/parallax/ParallaxView.qml19
-rw-r--r--examples/declarative/parallax/parallax.qml49
-rw-r--r--src/declarative/fx/qfxflickable.cpp27
-rw-r--r--src/declarative/fx/qfxlistview.cpp57
-rw-r--r--src/declarative/fx/qfxlistview.h8
-rw-r--r--src/declarative/qml/qmlcompiler.cpp2
-rw-r--r--tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml7
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp7
14 files changed, 112 insertions, 87 deletions
diff --git a/examples/declarative/focusscope/test3.qml b/examples/declarative/focusscope/test3.qml
index e5aa7b6..1b3181b 100644
--- a/examples/declarative/focusscope/test3.qml
+++ b/examples/declarative/focusscope/test3.qml
@@ -40,8 +40,8 @@ Rectangle {
model: model
delegate: verticalDelegate
preferredHighlightBegin: 100
- preferredHighlightEnd: 101
- strictlyEnforceHighlightRange: true
+ preferredHighlightEnd: 100
+ highlightRangeMode: "StrictlyEnforceRange"
}
diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml
index 6dfc90b..77f5c2d 100644
--- a/examples/declarative/listview/itemlist.qml
+++ b/examples/declarative/listview/itemlist.qml
@@ -30,8 +30,8 @@ Rectangle {
anchors.bottomMargin: 30
model: itemModel
preferredHighlightBegin: 0
- preferredHighlightEnd: 1
- strictlyEnforceHighlightRange: true
+ preferredHighlightEnd: 0
+ highlightRangeMode: "StrictlyEnforceRange"
orientation: "Horizontal"
}
diff --git a/examples/declarative/listview/listview.qml b/examples/declarative/listview/listview.qml
index 98974fd..b614904 100644
--- a/examples/declarative/listview/listview.qml
+++ b/examples/declarative/listview/listview.qml
@@ -41,7 +41,7 @@ Rectangle {
// current item within the the bounds of the range, however
// items will not scroll beyond the beginning or end of the view,
// forcing the highlight to move outside the range at the ends.
- // The third list sets strictlyEnforceHighlightRange to true
+ // The third list sets the highlightRangeMode to StrictlyEnforceRange
// and sets a range smaller than the height of an item. This
// forces the current item to change when the view is flicked,
// since the highlight is unable to move.
@@ -61,6 +61,7 @@ Rectangle {
model: MyPetsModel; delegate: petDelegate; highlight: petHighlight
preferredHighlightBegin: 80
preferredHighlightEnd: 220
+ highlightRangeMode: "ApplyRange"
currentIndex: list1.currentIndex
}
ListView {
@@ -69,7 +70,7 @@ Rectangle {
model: MyPetsModel; delegate: petDelegate; highlight: petHighlight
currentIndex: list1.currentIndex
preferredHighlightBegin: 125
- preferredHighlightEnd: 126
- strictlyEnforceHighlightRange: true
+ preferredHighlightEnd: 125
+ highlightRangeMode: "StrictlyEnforceRange"
}
}
diff --git a/examples/declarative/parallax/ParallaxView.qml b/examples/declarative/parallax/ParallaxView.qml
index 4ddab00..38bb8c0 100644
--- a/examples/declarative/parallax/ParallaxView.qml
+++ b/examples/declarative/parallax/ParallaxView.qml
@@ -10,7 +10,6 @@ Item {
width: Math.max(list.viewportWidth, parent.width)
}
- /*
default property alias content: visualModel.children
ListView {
id: list
@@ -21,21 +20,7 @@ Item {
highlight: Item { height: 1; width: 1}
preferredHighlightBegin: 0
- preferredHighlightEnd: 1
- strictlyEnforceHighlightRange: true
- }
- */
-
- default property alias content: flickArea.data
- Flickable {
- id: list
- anchors.fill: parent
- overShoot: false
- viewportWidth: flickArea.width
-
- Item {
- id: flickArea
- width: childrenRect.width
- }
+ preferredHighlightEnd: 0
+ highlightRangeMode: "StrictlyEnforceRange"
}
}
diff --git a/examples/declarative/parallax/parallax.qml b/examples/declarative/parallax/parallax.qml
index 9adcfd7..b2139ec 100644
--- a/examples/declarative/parallax/parallax.qml
+++ b/examples/declarative/parallax/parallax.qml
@@ -9,37 +9,34 @@ Rectangle {
anchors.fill: parent
background: "pics/background.jpg"
- Row {
- Item {
- width: 320
- height: 480
-
- Clock {
- anchors.centerIn: parent
- }
+ Item {
+ width: 320
+ height: 480
+
+ Clock {
+ anchors.centerIn: parent
}
+ }
- Item {
- width: 320
- height: 480
+ Item {
+ width: 320
+ height: 480
- Smiley {}
- }
+ Smiley {}
+ }
- Item {
- width: 320
- height: 480
-
- Loader {
- anchors.centerIn: parent
- width: 300; height: 460
- clip: true
- resizeMode: Loader.SizeItemToLoader
-
- source: "../../../demos/declarative/samegame/samegame.qml"
- }
+ Item {
+ width: 320
+ height: 480
+
+ Loader {
+ anchors.centerIn: parent
+ width: 300; height: 460
+ clip: true
+ resizeMode: Loader.SizeItemToLoader
+
+ source: "../../../demos/declarative/samegame/samegame.qml"
}
-
}
}
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index a83ee66..cbfe9f6 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -618,11 +618,18 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
newY = minY + (newY - minY) / 2;
if (newY < maxY && maxY - minY < 0)
newY = maxY + (newY - maxY) / 2;
- if (q->overShoot() || (newY <= minY && newY >= maxY)) {
+ if (!q->overShoot() && (newY > minY || newY < maxY)) {
+ if (newY > minY)
+ newY = minY;
+ else if (newY < maxY)
+ newY = maxY;
+ else
+ rejectY = true;
+ }
+ if (!rejectY) {
_moveY.setValue(newY);
moved = true;
- } else if (!q->overShoot())
- rejectY = true;
+ }
if (qAbs(dy) > DragThreshold)
stealMouse = true;
}
@@ -638,11 +645,19 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
newX = minX + (newX - minX) / 2;
if (newX < maxX && maxX - minX < 0)
newX = maxX + (newX - maxX) / 2;
- if (q->overShoot() || (newX <= minX && newX >= maxX)) {
+ if (!q->overShoot() && (newX > minX || newX < maxX)) {
+ if (newX > minX)
+ newX = minX;
+ else if (newX < maxX)
+ newX = maxX;
+ else
+ rejectX = true;
+ }
+ if (!rejectX) {
_moveX.setValue(newX);
moved = true;
- } else if (!q->overShoot())
- rejectX = true;
+ }
+
if (qAbs(dx) > DragThreshold)
stealMouse = true;
}
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 1a4a60c..28d2bb2 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -176,9 +176,9 @@ public:
, highlightRangeStart(0), highlightRangeEnd(0)
, highlightComponent(0), highlight(0), trackedItem(0)
, moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0.0)
- , highlightMoveSpeed(400), highlightResizeSpeed(400)
+ , highlightMoveSpeed(400), highlightResizeSpeed(400), highlightRange(QFxListView::NoHighlightRange)
, ownModel(false), wrap(false), autoHighlight(true)
- , haveHighlightRange(false), strictHighlightRange(false)
+ , haveHighlightRange(false)
{}
void init();
@@ -392,12 +392,12 @@ public:
qreal spacing;
qreal highlightMoveSpeed;
qreal highlightResizeSpeed;
+ QFxListView::HighlightRangeMode highlightRange;
bool ownModel : 1;
bool wrap : 1;
bool autoHighlight : 1;
bool haveHighlightRange : 1;
- bool strictHighlightRange : 1;
};
void QFxListViewPrivate::init()
@@ -798,7 +798,7 @@ void QFxListViewPrivate::fixupY()
if (orient == Qt::Horizontal)
return;
- if (haveHighlightRange && strictHighlightRange) {
+ if (haveHighlightRange && highlightRange == QFxListView::StrictlyEnforceRange) {
if (currentItem && highlight && currentItem->position() != highlight->position()) {
moveReason = Mouse;
timeline.clear();
@@ -813,7 +813,7 @@ void QFxListViewPrivate::fixupX()
if (orient == Qt::Vertical)
return;
- if (haveHighlightRange && strictHighlightRange) {
+ if (haveHighlightRange && highlightRange == QFxListView::StrictlyEnforceRange) {
if (currentItem && highlight && currentItem->position() != highlight->position()) {
moveReason = Mouse;
timeline.clear();
@@ -1141,19 +1141,25 @@ void QFxListView::setHighlightFollowsCurrentItem(bool autoHighlight)
/*!
\qmlproperty real ListView::preferredHighlightBegin
\qmlproperty real ListView::preferredHighlightEnd
- \qmlproperty bool ListView::strictlyEnforceHighlightRange
+ \qmlproperty bool ListView::highlightRangeMode
These properties set the preferred range of the highlight (current item)
within the view.
- If the strictlyEnforceHighlightRange property is false (default)
+ If highlightRangeMode is set to \e ApplyRange the view will
+ attempt to maintain the highlight within the range, however
the highlight can move outside of the range at the ends of the list
or due to a mouse interaction.
- If strictlyEnforceHighlightRange is true then the highlight will never
- move outside the range. This means that the current item will change
+ If highlightRangeMode is set to \e StrictlyEnforceRange the highlight will never
+ move outside of the range. This means that the current item will change
if a keyboard or mouse action would cause the highlight to move
outside of the range.
+
+ The default value is \e NoHighlightRange.
+
+ Note that a valid range requires preferredHighlightEnd to be greater
+ than or equal to preferredHighlightBegin.
*/
qreal QFxListView::preferredHighlightBegin() const
{
@@ -1165,7 +1171,7 @@ void QFxListView::setPreferredHighlightBegin(qreal start)
{
Q_D(QFxListView);
d->highlightRangeStart = start;
- d->haveHighlightRange = d->highlightRangeStart < d->highlightRangeEnd;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
}
qreal QFxListView::preferredHighlightEnd() const
@@ -1178,19 +1184,20 @@ void QFxListView::setPreferredHighlightEnd(qreal end)
{
Q_D(QFxListView);
d->highlightRangeEnd = end;
- d->haveHighlightRange = d->highlightRangeStart < d->highlightRangeEnd;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
}
-bool QFxListView::strictlyEnforceHighlightRange() const
+QFxListView::HighlightRangeMode QFxListView::highlightRangeMode() const
{
Q_D(const QFxListView);
- return d->strictHighlightRange;
+ return d->highlightRange;
}
-void QFxListView::setStrictlyEnforceHighlightRange(bool strict)
+void QFxListView::setHighlightRangeMode(HighlightRangeMode mode)
{
Q_D(QFxListView);
- d->strictHighlightRange = strict;
+ d->highlightRange = mode;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
}
/*!
@@ -1375,14 +1382,14 @@ void QFxListView::viewportMoved()
if (isFlicking() || d->pressed)
d->moveReason = QFxListViewPrivate::Mouse;
if (d->moveReason == QFxListViewPrivate::Mouse) {
- if (d->haveHighlightRange && d->strictHighlightRange && d->highlight) {
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
int idx = d->snapIndex();
if (idx >= 0 && idx != d->currentIndex)
d->updateCurrent(idx);
qreal pos = d->currentItem->position();
- if (pos > d->position() + d->highlightRangeEnd - d->highlight->size())
- pos = d->position() + d->highlightRangeEnd - d->highlight->size();
+ if (pos > d->position() + d->highlightRangeEnd - 1 - d->highlight->size())
+ pos = d->position() + d->highlightRangeEnd - 1 - d->highlight->size();
if (pos < d->position() + d->highlightRangeStart)
pos = d->position() + d->highlightRangeStart;
d->highlight->setPosition(pos);
@@ -1396,7 +1403,7 @@ qreal QFxListView::minYExtent() const
if (d->orient == Qt::Horizontal)
return QFxFlickable::minYExtent();
qreal extent = -d->startPosition();
- if (d->haveHighlightRange && d->strictHighlightRange)
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
extent += d->highlightRangeStart;
return extent;
@@ -1408,8 +1415,8 @@ qreal QFxListView::maxYExtent() const
if (d->orient == Qt::Horizontal)
return QFxFlickable::maxYExtent();
qreal extent;
- if (d->haveHighlightRange && d->strictHighlightRange)
- extent = -(d->endPosition() - d->highlightRangeEnd);
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent = -(d->positionAt(count()-1) - d->highlightRangeEnd);
else
extent = -(d->endPosition() - height());
qreal minY = minYExtent();
@@ -1424,7 +1431,7 @@ qreal QFxListView::minXExtent() const
if (d->orient == Qt::Vertical)
return QFxFlickable::minXExtent();
qreal extent = -d->startPosition();
- if (d->haveHighlightRange && d->strictHighlightRange)
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
extent += d->highlightRangeStart;
return extent;
@@ -1436,8 +1443,8 @@ qreal QFxListView::maxXExtent() const
if (d->orient == Qt::Vertical)
return QFxFlickable::maxXExtent();
qreal extent;
- if (d->haveHighlightRange && d->strictHighlightRange)
- extent = -(d->endPosition() - d->highlightRangeEnd);
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent = -(d->positionAt(count()-1) - d->highlightRangeEnd);
else
extent = -(d->endPosition() - width());
qreal minX = minXExtent();
@@ -1536,7 +1543,7 @@ void QFxListView::trackedPositionChanged()
if (!isFlicking() && !d->pressed && d->moveReason != QFxListViewPrivate::Mouse) {
const qreal trackedPos = d->trackedItem->position();
if (d->haveHighlightRange) {
- if (d->strictHighlightRange) {
+ if (d->highlightRange == StrictlyEnforceRange) {
qreal pos = d->position();
if (trackedPos > pos + d->highlightRangeEnd - d->trackedItem->size())
pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size();
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 1ff0e27..0fa0fa0 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -69,7 +69,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin)
Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd)
- Q_PROPERTY(bool strictlyEnforceHighlightRange READ strictlyEnforceHighlightRange WRITE setStrictlyEnforceHighlightRange)
+ Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
@@ -80,6 +80,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
+ Q_ENUMS(HighlightRangeMode)
Q_CLASSINFO("DefaultProperty", "data")
public:
@@ -104,8 +105,9 @@ public:
bool highlightFollowsCurrentItem() const;
void setHighlightFollowsCurrentItem(bool);
- bool strictlyEnforceHighlightRange() const;
- void setStrictlyEnforceHighlightRange(bool strict);
+ enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
+ HighlightRangeMode highlightRangeMode() const;
+ void setHighlightRangeMode(HighlightRangeMode mode);
qreal preferredHighlightBegin() const;
void setPreferredHighlightBegin(qreal);
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 69ebf9c..60282dc 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1687,7 +1687,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
if (prop->type < (int)QVariant::UserType) {
QmlEnginePrivate *ep =
static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine));
- if (ep->valueTypes[prop->type]) {
+ if (prop->type >= 0 /* QVariant == -1 */ && ep->valueTypes[prop->type]) {
COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type],
prop->value, obj, ctxt.incr()));
obj->addValueTypeProperty(prop);
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt
new file mode 100644
index 0000000..7c00ce4
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt
@@ -0,0 +1 @@
+5:5:Invalid property access
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml
new file mode 100644
index 0000000..5e95c48
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Object {
+ property var o;
+ o.blah: 10
+}
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt
new file mode 100644
index 0000000..7c00ce4
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt
@@ -0,0 +1 @@
+5:5:Invalid property access
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml
new file mode 100644
index 0000000..b11d34c
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Object {
+ property int o;
+ o.blah: 10
+}
+
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index d51bbcc..4bc02c0 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -180,7 +180,6 @@ void tst_qmllanguage::errors_data()
QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false;
QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false;
-
QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false;
QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true;
QTest::newRow("fakeDotProperty") << "fakeDotProperty.qml" << "fakeDotProperty.errors.txt" << false;
@@ -191,12 +190,16 @@ void tst_qmllanguage::errors_data()
QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false;
QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false;
QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
+ QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false;
QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
- QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
+
+
}
void tst_qmllanguage::errors()