From 79742b14982004ac1b77558e6ab6b649898336c7 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 3 Jun 2010 15:27:23 +1000 Subject: Add header and footer to GridView Also document them for both ListView and GridView Task-number: QTBUG-11191 --- .../graphicsitems/qdeclarativegridview.cpp | 190 ++++++++++++++++++++- .../graphicsitems/qdeclarativegridview_p.h | 11 ++ .../graphicsitems/qdeclarativelistview.cpp | 26 +++ .../tst_qdeclarativegridview.cpp | 13 ++ 4 files changed, 239 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index ffffc2f..82c69a0 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -108,6 +108,7 @@ public: , highlightComponent(0), highlight(0), trackedItem(0) , moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0) , highlightMoveDuration(150) + , footerComponent(0), footer(0), headerComponent(0), header(0) , bufferMode(BufferBefore | BufferAfter), snapMode(QDeclarativeGridView::NoSnap) , ownModel(false), wrap(false), autoHighlight(true) , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false) @@ -128,6 +129,8 @@ public: void createHighlight(); void updateHighlight(); void updateCurrent(int modelIndex); + void updateHeader(); + void updateFooter(); void fixupPosition(); FxGridItem *visibleItem(int modelIndex) const { @@ -230,6 +233,18 @@ public: return visibleItems.count() ? visibleItems.first() : 0; } + int lastVisibleIndex() const { + int lastIndex = -1; + for (int i = visibleItems.count()-1; i >= 0; --i) { + FxGridItem *gridItem = visibleItems.at(i); + if (gridItem->index != -1) { + lastIndex = gridItem->index; + break; + } + } + return lastIndex; + } + // Map a model index to visibleItems list index. // These may differ if removed items are still present in the visible list, // e.g. doing a removal animation @@ -283,6 +298,9 @@ public: scheduleLayout(); } } + } else if ((header && header->item == item) || (footer && footer->item == item)) { + updateHeader(); + updateFooter(); } } @@ -330,6 +348,10 @@ public: QSmoothedAnimation *highlightXAnimator; QSmoothedAnimation *highlightYAnimator; int highlightMoveDuration; + QDeclarativeComponent *footerComponent; + FxGridItem *footer; + QDeclarativeComponent *headerComponent; + FxGridItem *header; enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 }; int bufferMode; QDeclarativeGridView::SnapMode snapMode; @@ -412,7 +434,6 @@ void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) Q_Q(QDeclarativeGridView); if (!isValid() || !q->isComponentComplete()) return; - itemCount = model->count(); qreal bufferFrom = from - buffer; qreal bufferTo = to + buffer; @@ -522,6 +543,10 @@ void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) deferredRelease = true; } if (changed) { + if (header) + updateHeader(); + if (footer) + updateFooter(); if (flow == QDeclarativeGridView::LeftToRight) q->setContentHeight(endPosition() - startPosition()); else @@ -579,6 +604,10 @@ void QDeclarativeGridViewPrivate::layout() item->setPosition(colPos, rowPos); } } + if (header) + updateHeader(); + if (footer) + updateFooter(); q->refill(); updateHighlight(); moveReason = Other; @@ -742,6 +771,94 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex) releaseItem(oldCurrentItem); } +void QDeclarativeGridViewPrivate::updateFooter() +{ + Q_Q(QDeclarativeGridView); + if (!footer && footerComponent) { + QDeclarativeItem *item = 0; + QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); + QObject *nobj = footerComponent->create(context); + if (nobj) { + QDeclarative_setParent_noEvent(context, nobj); + item = qobject_cast(nobj); + if (!item) + delete nobj; + } else { + delete context; + } + if (item) { + QDeclarative_setParent_noEvent(item, q->viewport()); + item->setParentItem(q->viewport()); + item->setZValue(1); + QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); + itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); + footer = new FxGridItem(item, q); + } + } + if (footer) { + if (visibleItems.count()) { + qreal endPos = endPosition(); + if (lastVisibleIndex() == model->count()-1) { + footer->setPosition(0, endPos); + } else { + qreal visiblePos = position() + q->height(); + if (endPos <= visiblePos || footer->endRowPos() < endPos) + footer->setPosition(0, endPos); + } + } else { + qreal endPos = 0; + if (header) { + endPos += flow == QDeclarativeGridView::LeftToRight + ? header->item->height() + : header->item->width(); + } + footer->setPosition(0, endPos); + } + } +} + +void QDeclarativeGridViewPrivate::updateHeader() +{ + Q_Q(QDeclarativeGridView); + if (!header && headerComponent) { + QDeclarativeItem *item = 0; + QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); + QObject *nobj = headerComponent->create(context); + if (nobj) { + QDeclarative_setParent_noEvent(context, nobj); + item = qobject_cast(nobj); + if (!item) + delete nobj; + } else { + delete context; + } + if (item) { + QDeclarative_setParent_noEvent(item, q->viewport()); + item->setParentItem(q->viewport()); + item->setZValue(1); + QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); + itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); + header = new FxGridItem(item, q); + } + } + if (header) { + if (visibleItems.count()) { + qreal startPos = startPosition(); + qreal headerSize = flow == QDeclarativeGridView::LeftToRight + ? header->item->height() + : header->item->width(); + if (visibleIndex == 0) { + header->setPosition(0, startPos - headerSize); + } else { + if (position() <= startPos || header->rowPos() > startPos - headerSize) + header->setPosition(0, startPos - headerSize); + } + } else { + header->setPosition(0, 0); + } + } +} + void QDeclarativeGridViewPrivate::fixupPosition() { moveReason = Other; @@ -958,6 +1075,8 @@ QDeclarativeGridView::~QDeclarativeGridView() d->clear(); if (d->ownModel) delete d->model; + delete d->header; + delete d->footer; } /*! @@ -1524,6 +1643,67 @@ void QDeclarativeGridView::setSnapMode(SnapMode mode) } } +/*! + \qmlproperty Component GridView::footer + This property holds the component to use as the footer. + + An instance of the footer component is created for each view. The + footer is positioned at the end of the view, after any items. + + \sa header +*/ +QDeclarativeComponent *QDeclarativeGridView::footer() const +{ + Q_D(const QDeclarativeGridView); + return d->footerComponent; +} + +void QDeclarativeGridView::setFooter(QDeclarativeComponent *footer) +{ + Q_D(QDeclarativeGridView); + if (d->footerComponent != footer) { + if (d->footer) { + delete d->footer; + d->footer = 0; + } + d->footerComponent = footer; + d->updateFooter(); + d->updateGrid(); + emit footerChanged(); + } +} + +/*! + \qmlproperty Component GridView::header + This property holds the component to use as the header. + + An instance of the header component is created for each view. The + header is positioned at the beginning of the view, before any items. + + \sa footer +*/ +QDeclarativeComponent *QDeclarativeGridView::header() const +{ + Q_D(const QDeclarativeGridView); + return d->headerComponent; +} + +void QDeclarativeGridView::setHeader(QDeclarativeComponent *header) +{ + Q_D(QDeclarativeGridView); + if (d->headerComponent != header) { + if (d->header) { + delete d->header; + d->header = 0; + } + d->headerComponent = header; + d->updateHeader(); + d->updateFooter(); + d->updateGrid(); + emit headerChanged(); + } +} + bool QDeclarativeGridView::event(QEvent *event) { Q_D(QDeclarativeGridView); @@ -1590,6 +1770,8 @@ qreal QDeclarativeGridView::minYExtent() const if (d->flow == QDeclarativeGridView::TopToBottom) return QDeclarativeFlickable::minYExtent(); qreal extent = -d->startPosition(); + if (d->header && d->visibleItems.count()) + extent += d->header->item->height(); if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { extent += d->highlightRangeStart; extent = qMax(extent, -(d->rowPosAt(0) + d->rowSize() - d->highlightRangeEnd)); @@ -1610,6 +1792,8 @@ qreal QDeclarativeGridView::maxYExtent() const } else { extent = -(d->endPosition() - height()); } + if (d->footer) + extent -= d->footer->item->height(); const qreal minY = minYExtent(); if (extent > minY) extent = minY; @@ -1622,6 +1806,8 @@ qreal QDeclarativeGridView::minXExtent() const if (d->flow == QDeclarativeGridView::LeftToRight) return QDeclarativeFlickable::minXExtent(); qreal extent = -d->startPosition(); + if (d->header && d->visibleItems.count()) + extent += d->header->item->width(); if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { extent += d->highlightRangeStart; extent = qMax(extent, -(d->rowPosAt(0) + d->rowSize() - d->highlightRangeEnd)); @@ -1642,6 +1828,8 @@ qreal QDeclarativeGridView::maxXExtent() const } else { extent = -(d->endPosition() - height()); } + if (d->footer) + extent -= d->footer->item->width(); const qreal minX = minXExtent(); if (extent > minX) extent = minX; diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h index 2bf154c..021aad9 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview_p.h +++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h @@ -80,6 +80,9 @@ class Q_DECLARATIVE_EXPORT QDeclarativeGridView : public QDeclarativeFlickable Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged) + Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader NOTIFY headerChanged) + Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter NOTIFY footerChanged) + Q_ENUMS(HighlightRangeMode) Q_ENUMS(SnapMode) Q_ENUMS(Flow) @@ -142,6 +145,12 @@ public: SnapMode snapMode() const; void setSnapMode(SnapMode mode); + QDeclarativeComponent *footer() const; + void setFooter(QDeclarativeComponent *); + + QDeclarativeComponent *header() const; + void setHeader(QDeclarativeComponent *); + enum PositionMode { Beginning, Center, End, Visible, Contain }; Q_INVOKABLE void positionViewAtIndex(int index, int mode); @@ -172,6 +181,8 @@ Q_SIGNALS: void keyNavigationWrapsChanged(); void cacheBufferChanged(); void snapModeChanged(); + void headerChanged(); + void footerChanged(); protected: virtual bool event(QEvent *event); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index dbd1976..f2cc971 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -427,6 +427,10 @@ public: scheduleLayout(); } } + if ((header && header->item == item) || (footer && footer->item == item)) { + updateHeader(); + updateFooter(); + } if (currentItem && currentItem->item == item) updateHighlight(); if (trackedItem && trackedItem->item == item) @@ -1045,6 +1049,8 @@ void QDeclarativeListViewPrivate::updateFooter() QDeclarative_setParent_noEvent(item, q->viewport()); item->setParentItem(q->viewport()); item->setZValue(1); + QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); + itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); footer = new FxListItem(item, q); } } @@ -1083,6 +1089,8 @@ void QDeclarativeListViewPrivate::updateHeader() QDeclarative_setParent_noEvent(item, q->viewport()); item->setParentItem(q->viewport()); item->setZValue(1); + QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); + itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); header = new FxListItem(item, q); if (visibleItems.isEmpty()) visiblePos = header->size(); @@ -2074,6 +2082,15 @@ void QDeclarativeListView::setSnapMode(SnapMode mode) } } +/*! + \qmlproperty Component ListView::footer + This property holds the component to use as the footer. + + An instance of the footer component is created for each view. The + footer is positioned at the end of the view, after any items. + + \sa header +*/ QDeclarativeComponent *QDeclarativeListView::footer() const { Q_D(const QDeclarativeListView); @@ -2097,6 +2114,15 @@ void QDeclarativeListView::setFooter(QDeclarativeComponent *footer) } } +/*! + \qmlproperty Component ListView::header + This property holds the component to use as the header. + + An instance of the header component is created for each view. The + header is positioned at the beginning of the view, before any items. + + \sa footer +*/ QDeclarativeComponent *QDeclarativeListView::header() const { Q_D(const QDeclarativeListView); diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 2db3ee6..fb09d39 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -833,21 +833,34 @@ void tst_QDeclarativeGridView::componentChanges() QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged())); QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged())); + QSignalSpy headerSpy(gridView, SIGNAL(headerChanged())); + QSignalSpy footerSpy(gridView, SIGNAL(footerChanged())); gridView->setHighlight(&component); gridView->setDelegate(&delegateComponent); + gridView->setHeader(&component); + gridView->setFooter(&component); QTRY_COMPARE(gridView->highlight(), &component); QTRY_COMPARE(gridView->delegate(), &delegateComponent); + QTRY_COMPARE(gridView->header(), &component); + QTRY_COMPARE(gridView->footer(), &component); QTRY_COMPARE(highlightSpy.count(),1); QTRY_COMPARE(delegateSpy.count(),1); + QTRY_COMPARE(headerSpy.count(),1); + QTRY_COMPARE(footerSpy.count(),1); gridView->setHighlight(&component); gridView->setDelegate(&delegateComponent); + gridView->setHeader(&component); + gridView->setFooter(&component); QTRY_COMPARE(highlightSpy.count(),1); QTRY_COMPARE(delegateSpy.count(),1); + QTRY_COMPARE(headerSpy.count(),1); + QTRY_COMPARE(footerSpy.count(),1); + delete canvas; } -- cgit v0.12 From 9337c140cab7db1285f893b66d0e56423a74c253 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 3 Jun 2010 16:31:29 +1000 Subject: Always integer align anchor center points This dramatically reduces the number of items that are half pixel aligned and thus render poorly. --- .../graphicsitems/qdeclarativeanchors.cpp | 48 ++++++++++++++++------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp index aa53aba..6796977 100644 --- a/src/declarative/graphicsitems/qdeclarativeanchors.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanchors.cpp @@ -53,6 +53,30 @@ QT_BEGIN_NAMESPACE //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? //TODO: support non-parent, non-sibling (need to find lowest common ancestor) +static qreal hcenter(QGraphicsItem *i) +{ + QGraphicsItemPrivate *item = QGraphicsItemPrivate::get(i); + + qreal width = item->width(); + int iw = width; + if (iw % 2) + return (width + 1) / 2; + else + return width / 2; +} + +static qreal vcenter(QGraphicsItem *i) +{ + QGraphicsItemPrivate *item = QGraphicsItemPrivate::get(i); + + qreal height = item->height(); + int ih = height; + if (ih % 2) + return (height + 1) / 2; + else + return height / 2; +} + //### const item? //local position static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine) @@ -73,10 +97,10 @@ static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine ret = item->y() + d->height(); break; case QDeclarativeAnchorLine::HCenter: - ret = item->x() + d->width()/2; + ret = item->x() + hcenter(item); break; case QDeclarativeAnchorLine::VCenter: - ret = item->y() + d->height()/2; + ret = item->y() + vcenter(item); break; case QDeclarativeAnchorLine::Baseline: if (d->isDeclarativeItem) @@ -108,10 +132,10 @@ static qreal adjustedPosition(QGraphicsObject *item, QDeclarativeAnchorLine::Anc ret = d->height(); break; case QDeclarativeAnchorLine::HCenter: - ret = d->width()/2; + ret = hcenter(item); break; case QDeclarativeAnchorLine::VCenter: - ret = d->height()/2; + ret = vcenter(item); break; case QDeclarativeAnchorLine::Baseline: if (d->isDeclarativeItem) @@ -192,14 +216,14 @@ void QDeclarativeAnchorsPrivate::centerInChanged() QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item); if (centerIn == item->parentItem()) { QGraphicsItemPrivate *parentPrivate = QGraphicsItemPrivate::get(item->parentItem()); - QPointF p((parentPrivate->width() - itemPrivate->width()) / 2. + hCenterOffset, - (parentPrivate->height() - itemPrivate->height()) / 2. + vCenterOffset); + QPointF p(hcenter(item->parentItem()) - hcenter(item) + hCenterOffset, + vcenter(item->parentItem()) - vcenter(item) + vCenterOffset); setItemPos(p); } else if (centerIn->parentItem() == item->parentItem()) { QGraphicsItemPrivate *centerPrivate = QGraphicsItemPrivate::get(centerIn); - QPointF p(centerIn->x() + (centerPrivate->width() - itemPrivate->width()) / 2. + hCenterOffset, - centerIn->y() + (centerPrivate->height() - itemPrivate->height()) / 2. + vCenterOffset); + QPointF p(centerIn->x() + hcenter(centerIn) - hcenter(item) + hCenterOffset, + centerIn->y() + vcenter(centerIn) - vcenter(item) + vCenterOffset); setItemPos(p); } @@ -535,9 +559,9 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors() //Handle vCenter if (vCenter.item == item->parentItem()) { setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine) - - itemPrivate->height()/2 + vCenterOffset); + - vcenter(item) + vCenterOffset); } else if (vCenter.item->parentItem() == item->parentItem()) { - setItemY(position(vCenter.item, vCenter.anchorLine) - itemPrivate->height()/2 + vCenterOffset); + setItemY(position(vCenter.item, vCenter.anchorLine) - vcenter(item) + vCenterOffset); } } else if (usedAnchors & QDeclarativeAnchors::BaselineAnchor) { //Handle baseline @@ -604,9 +628,9 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors() } else if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) { //Handle hCenter if (hCenter.item == item->parentItem()) { - setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - itemPrivate->width()/2 + hCenterOffset); + setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - hcenter(item) + hCenterOffset); } else if (hCenter.item->parentItem() == item->parentItem()) { - setItemX(position(hCenter.item, hCenter.anchorLine) - itemPrivate->width()/2 + hCenterOffset); + setItemX(position(hCenter.item, hCenter.anchorLine) - hcenter(item) + hCenterOffset); } } -- cgit v0.12 From 939375996496a55a1bb424d6a328f47d2224ed51 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 3 Jun 2010 16:27:47 +1000 Subject: Improve input panel handling in declarative demos and examples Task-number: QTBUG-11157 Reviewed-by: Warwick Allison --- demos/declarative/flickr/mobile/TitleBar.qml | 2 +- .../photoviewer/PhotoViewerCore/EditableButton.qml | 2 +- demos/declarative/samegame/SamegameCore/Dialog.qml | 5 +++-- demos/declarative/samegame/samegame.qml | 20 ++++++++++++++++---- .../declarative/twitter/TwitterCore/HomeTitleBar.qml | 2 +- demos/declarative/twitter/TwitterCore/TitleBar.qml | 2 +- demos/declarative/twitter/twitter.qml | 5 +++++ examples/declarative/text/edit/edit.qml | 3 +++ examples/declarative/toys/corkboards/Day.qml | 7 ++++++- .../declarative/toys/dynamicscene/dynamicscene.qml | 7 ++++++- .../tutorials/samegame/samegame4/content/Dialog.qml | 12 ++++++++++-- .../ui-components/searchbox/SearchBox.qml | 4 ++-- .../declarative/ui-components/searchbox/main.qml | 5 +++++ .../graphicsitems/qdeclarativetextedit.cpp | 2 +- .../graphicsitems/qdeclarativetextinput.cpp | 2 +- .../tst_qdeclarativetextedit.cpp | 6 ------ .../tst_qdeclarativetextinput.cpp | 6 ------ 17 files changed, 62 insertions(+), 30 deletions(-) diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml index da144d4..c7e1a53 100644 --- a/demos/declarative/flickr/mobile/TitleBar.qml +++ b/demos/declarative/flickr/mobile/TitleBar.qml @@ -118,7 +118,7 @@ Item { name: "Tags" PropertyChanges { target: container; x: -tagButton.x + 5 } PropertyChanges { target: tagButton; text: "OK" } - PropertyChanges { target: lineEdit; focus: true } + PropertyChanges { target: editor; focus: true } } transitions: Transition { diff --git a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml index e15adbc..6109535 100644 --- a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml +++ b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml @@ -77,6 +77,6 @@ Item { MouseArea { anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } - onClicked: textInput.forceFocus() + onClicked: { textInput.forceFocus(); textInput.openSoftwareInputPanel(); } } } diff --git a/demos/declarative/samegame/SamegameCore/Dialog.qml b/demos/declarative/samegame/SamegameCore/Dialog.qml index 8dd12f6..c71a4b3 100644 --- a/demos/declarative/samegame/SamegameCore/Dialog.qml +++ b/demos/declarative/samegame/SamegameCore/Dialog.qml @@ -47,13 +47,14 @@ Rectangle { property Item text: dialogText signal closed - + signal opened function forceClose() { page.closed(); page.opacity = 0; } function show(txt) { + page.opened(); dialogText.text = txt; page.opacity = 1; } @@ -62,7 +63,7 @@ Rectangle { color: "white" border.width: 1 opacity: 0 - + visible: opacity > 0 Behavior on opacity { NumberAnimation { duration: 1000 } } diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 54c18d6..9a721da 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -90,17 +90,31 @@ Rectangle { enabled: initialWidth != 0 } + onOpened: nameInputText.focus = true; + onClosed: { + nameInputText.focus = false; + if (nameInputText.text != "") + Logic.saveHighScore(nameInputText.text); + } Text { id: dialogText anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } text: "You won! Please enter your name: " } + MouseArea { + anchors.fill: parent + onClicked: { + if (nameInputText.text == "") + nameInputText.openSoftwareInputPanel(); + else + nameInputDialog.forceClose(); + } + } TextInput { id: nameInputText anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } - focus: true - + focus: false onTextChanged: { var newWidth = nameInputText.width + dialogText.width + 40; if ( (newWidth > nameInputDialog.width && newWidth < screen.width) @@ -108,8 +122,6 @@ Rectangle { nameInputDialog.width = newWidth; } onAccepted: { - if (nameInputDialog.opacity == 1 && nameInputText.text != "") - Logic.saveHighScore(nameInputText.text); nameInputDialog.forceClose(); } } diff --git a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml index 3828a40..52164ed 100644 --- a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml @@ -148,7 +148,7 @@ Item { PropertyChanges { target: tagButton; text: "OK" } PropertyChanges { target: tagButton; width: 28 } PropertyChanges { target: tagButton; height: 24 } - PropertyChanges { target: txtEdit; focus: true } + PropertyChanges { target: editor; focus: true } } ] transitions: [ diff --git a/demos/declarative/twitter/TwitterCore/TitleBar.qml b/demos/declarative/twitter/TwitterCore/TitleBar.qml index 0cf79a3..6cd0a50 100644 --- a/demos/declarative/twitter/TwitterCore/TitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/TitleBar.qml @@ -107,7 +107,7 @@ Item { name: "Tags" PropertyChanges { target: container; x: -tagButton.x + 5 } PropertyChanges { target: tagButton; text: "OK" } - PropertyChanges { target: lineEdit; focus: true } + PropertyChanges { target: editor; focus: true } } transitions: Transition { diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml index aa216cc..08cecb0 100644 --- a/demos/declarative/twitter/twitter.qml +++ b/demos/declarative/twitter/twitter.qml @@ -70,6 +70,11 @@ Item { Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + MouseArea { + anchors.fill: parent + onClicked: screen.focus = false; + } + Twitter.RssModel { id: rssModel } Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'} Text { diff --git a/examples/declarative/text/edit/edit.qml b/examples/declarative/text/edit/edit.qml index 0be42e9..4668ab2 100644 --- a/examples/declarative/text/edit/edit.qml +++ b/examples/declarative/text/edit/edit.qml @@ -121,6 +121,9 @@ Rectangle { onClicked: { if (editor.state == "") { edit.cursorPosition = edit.positionAt(mouse.x+x,mouse.y+y); + if (!edit.focus) + edit.focus = true; + edit.openSoftwareInputPanel(); } } function hitHandle(h,x,y) { return x>=h.x+flick.contentX && x=h.y+flick.contentY && y 0 Text { id: dialogText @@ -82,7 +85,6 @@ Rectangle { id: textInput anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } width: 80 - focus: true text: "" onAccepted: container.hide() // close dialog when Enter is pressed @@ -91,7 +93,13 @@ Rectangle { MouseArea { anchors.fill: parent - onClicked: hide(); + + onClicked: { + if (textInput.text == "" && textInput.opacity > 0) + textInput.openSoftwareInputPanel(); + else + hide(); + } } //![3] diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml index c022626..eaa6b6b 100644 --- a/examples/declarative/ui-components/searchbox/SearchBox.qml +++ b/examples/declarative/ui-components/searchbox/SearchBox.qml @@ -66,7 +66,7 @@ FocusScope { font.italic: true } - MouseArea { anchors.fill: parent; onClicked: focusScope.focus = true } + MouseArea { anchors.fill: parent; onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } } TextInput { id: textInput @@ -82,7 +82,7 @@ FocusScope { MouseArea { anchors.fill: parent - onClicked: { textInput.text = ''; focusScope.focus = true } + onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } } } diff --git a/examples/declarative/ui-components/searchbox/main.qml b/examples/declarative/ui-components/searchbox/main.qml index 0508d5a..bf3bed8 100644 --- a/examples/declarative/ui-components/searchbox/main.qml +++ b/examples/declarative/ui-components/searchbox/main.qml @@ -41,9 +41,14 @@ import Qt 4.7 Rectangle { + id: page width: 500; height: 250 color: "#edecec" + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } Column { anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } spacing: 10 diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 48826ff..535a39d 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1488,7 +1488,7 @@ void QDeclarativeTextEdit::focusInEvent(QFocusEvent *event) { Q_D(const QDeclarativeTextEdit); if (d->showInputPanelOnFocus) { - if (d->focusOnPress && !isReadOnly() && event->reason() != Qt::ActiveWindowFocusReason) { + if (d->focusOnPress && !isReadOnly()) { openSoftwareInputPanel(); } } diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 1202101..3911a97 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1333,7 +1333,7 @@ void QDeclarativeTextInput::focusInEvent(QFocusEvent *event) { Q_D(const QDeclarativeTextInput); if (d->showInputPanelOnFocus) { - if (d->focusOnPress && !isReadOnly() && event->reason() != Qt::ActiveWindowFocusReason) { + if (d->focusOnPress && !isReadOnly()) { openSoftwareInputPanel(); } } diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index fbab30e..474eb3f 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -956,12 +956,6 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() edit.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); - // active window focus reason should not cause input panel to open - QGraphicsObject * editObject = qobject_cast(&edit); - editObject->setFocus(Qt::ActiveWindowFocusReason); - QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, false); - // and input panel should not open if focus has already been set edit.setFocus(true); QCOMPARE(ic.openInputPanelReceived, false); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 3cb4da0..c1c6634 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -902,12 +902,6 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() input.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); - // active window focus reason should not cause input panel to open - QGraphicsObject * inputObject = qobject_cast(&input); - inputObject->setFocus(Qt::ActiveWindowFocusReason); - QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, false); - // and input panel should not open if focus has already been set input.setFocus(true); QCOMPARE(ic.openInputPanelReceived, false); -- cgit v0.12 From 66c24c2efad5c8784b92a7b9872d2732ebd8a446 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 3 Jun 2010 18:06:20 +1000 Subject: Add more Q_AUTOTEST_EXPORTs --- src/declarative/util/qdeclarativeanimation.cpp | 73 ++++++++++-------------- src/declarative/util/qdeclarativeanimation_p.h | 2 +- src/declarative/util/qdeclarativeanimation_p_p.h | 20 ++++++- 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 0eae136..1447532 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2132,52 +2132,39 @@ QAbstractAnimation *QDeclarativePropertyAnimation::qtAnimation() return d->va; } -struct PropertyUpdater : public QDeclarativeBulkValueUpdater +void QDeclarativeAnimationPropertyUpdater::setValue(qreal v) { - QDeclarativeStateActions actions; - int interpolatorType; //for Number/ColorAnimation - int prevInterpolatorType; //for generic - QVariantAnimation::Interpolator interpolator; - bool reverse; - bool fromSourced; - bool fromDefined; - bool *wasDeleted; - PropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {} - ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; } - void setValue(qreal v) - { - bool deleted = false; - wasDeleted = &deleted; - if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 - v = 1 - v; - for (int ii = 0; ii < actions.count(); ++ii) { - QDeclarativeAction &action = actions[ii]; - - if (v == 1.) - QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); - else { - if (!fromSourced && !fromDefined) { - action.fromValue = action.property.read(); - if (interpolatorType) - QDeclarativePropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); - } - if (!interpolatorType) { - int propType = action.property.propertyType(); - if (!prevInterpolatorType || prevInterpolatorType != propType) { - prevInterpolatorType = propType; - interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); - } + bool deleted = false; + wasDeleted = &deleted; + if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 + v = 1 - v; + for (int ii = 0; ii < actions.count(); ++ii) { + QDeclarativeAction &action = actions[ii]; + + if (v == 1.) + QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + else { + if (!fromSourced && !fromDefined) { + action.fromValue = action.property.read(); + if (interpolatorType) + QDeclarativePropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); + } + if (!interpolatorType) { + int propType = action.property.propertyType(); + if (!prevInterpolatorType || prevInterpolatorType != propType) { + prevInterpolatorType = propType; + interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); } - if (interpolator) - QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); } - if (deleted) - return; + if (interpolator) + QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); } - wasDeleted = 0; - fromSourced = true; + if (deleted) + return; } -}; + wasDeleted = 0; + fromSourced = true; +} void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, @@ -2207,7 +2194,7 @@ void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions props << d->defaultProperties.split(QLatin1Char(',')); } - PropertyUpdater *data = new PropertyUpdater; + QDeclarativeAnimationPropertyUpdater *data = new QDeclarativeAnimationPropertyUpdater; data->interpolatorType = d->interpolatorType; data->interpolator = d->interpolator; data->reverse = direction == Backward ? true : false; @@ -2786,7 +2773,7 @@ void QDeclarativeAnchorAnimation::transition(QDeclarativeStateActions &actions, { Q_UNUSED(modified); Q_D(QDeclarativeAnchorAnimation); - PropertyUpdater *data = new PropertyUpdater; + QDeclarativeAnimationPropertyUpdater *data = new QDeclarativeAnimationPropertyUpdater; data->interpolatorType = QMetaType::QReal; data->interpolator = d->interpolator; diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index e7cd8a8..3f8fbdd 100644 --- a/src/declarative/util/qdeclarativeanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -384,7 +384,7 @@ Q_SIGNALS: }; class QDeclarativeAnimationGroupPrivate; -class QDeclarativeAnimationGroup : public QDeclarativeAbstractAnimation +class Q_AUTOTEST_EXPORT QDeclarativeAnimationGroup : public QDeclarativeAbstractAnimation { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup) diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h index 3b0f52e..b6d6bbb 100644 --- a/src/declarative/util/qdeclarativeanimation_p_p.h +++ b/src/declarative/util/qdeclarativeanimation_p_p.h @@ -96,7 +96,7 @@ private: }; //performs an action of type QAbstractAnimationAction -class QActionAnimation : public QAbstractAnimation +class Q_AUTOTEST_EXPORT QActionAnimation : public QAbstractAnimation { Q_OBJECT public: @@ -143,7 +143,7 @@ public: }; //animates QDeclarativeBulkValueUpdater (assumes start and end values will be reals or compatible) -class QDeclarativeBulkValueAnimator : public QVariantAnimation +class Q_AUTOTEST_EXPORT QDeclarativeBulkValueAnimator : public QVariantAnimation { Q_OBJECT public: @@ -378,6 +378,22 @@ public: QList targets; }; +class Q_AUTOTEST_EXPORT QDeclarativeAnimationPropertyUpdater : public QDeclarativeBulkValueUpdater +{ +public: + QDeclarativeStateActions actions; + int interpolatorType; //for Number/ColorAnimation + int prevInterpolatorType; //for generic + QVariantAnimation::Interpolator interpolator; + bool reverse; + bool fromSourced; + bool fromDefined; + bool *wasDeleted; + QDeclarativeAnimationPropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {} + ~QDeclarativeAnimationPropertyUpdater() { if (wasDeleted) *wasDeleted = true; } + void setValue(qreal v); +}; + QT_END_NAMESPACE #endif // QDECLARATIVEANIMATION_P_H -- cgit v0.12 From ecff296323a81059810a91709f502921bc9277c2 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 4 Jun 2010 11:22:28 +1000 Subject: Revert to Portrait/Landscape terminology for Orientation enum, with additional PortraitInverted and LandscapeInverted values. TopUp etc. only indicates rotation which makes it difficult to resize the window according to whether the device is in Portrait or Landscape orientation. --- .../qdeclarativeviewer/data/orientation.qml | 20 +++++++++--------- tools/qml/deviceorientation.cpp | 2 +- tools/qml/deviceorientation.h | 8 ++++---- tools/qml/deviceorientation_maemo.cpp | 12 +++++------ tools/qml/qmlruntime.cpp | 24 +++++++++++----------- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml index be911a3..57db82d 100644 --- a/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml +++ b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml @@ -1,18 +1,18 @@ import Qt 4.7 Rectangle { color: "black" - width: (runtime.orientation == Orientation.RightUp || runtime.orientation == Orientation.LeftUp) ? 300 : 200 - height: (runtime.orientation == Orientation.RightUp || runtime.orientation == Orientation.LeftUp) ? 200 : 300 + width: (runtime.orientation == Orientation.Landscape || runtime.orientation == Orientation.LandscapeInverted) ? 300 : 200 + height: (runtime.orientation == Orientation.Landscape || runtime.orientation == Orientation.LandscapeInverted) ? 200 : 300 Text { text: { - if (runtime.orientation == Orientation.TopUp) - return "TopUp" - if (runtime.orientation == Orientation.TopDown) - return "TopDown" - if (runtime.orientation == Orientation.LeftUp) - return "LeftUp" - if (runtime.orientation == Orientation.RightUp) - return "RightUp" + if (runtime.orientation == Orientation.Portrait) + return "Portrait" + if (runtime.orientation == Orientation.PortraitInverted) + return "PortraitInverted" + if (runtime.orientation == Orientation.Landscape) + return "Landscape" + if (runtime.orientation == Orientation.LandscapeInverted) + return "LandscapeInverted" } color: "white" } diff --git a/tools/qml/deviceorientation.cpp b/tools/qml/deviceorientation.cpp index a13b912..e7c70d5 100644 --- a/tools/qml/deviceorientation.cpp +++ b/tools/qml/deviceorientation.cpp @@ -47,7 +47,7 @@ class DefaultDeviceOrientation : public DeviceOrientation { Q_OBJECT public: - DefaultDeviceOrientation() : DeviceOrientation(), m_orientation(DeviceOrientation::TopUp) {} + DefaultDeviceOrientation() : DeviceOrientation(), m_orientation(DeviceOrientation::Portrait) {} Orientation orientation() const { return m_orientation; diff --git a/tools/qml/deviceorientation.h b/tools/qml/deviceorientation.h index fe73868..817bfc8 100644 --- a/tools/qml/deviceorientation.h +++ b/tools/qml/deviceorientation.h @@ -54,10 +54,10 @@ class DeviceOrientation : public QObject public: enum Orientation { UnknownOrientation, - TopUp, - TopDown, - LeftUp, - RightUp + Portrait, + Landscape, + PortraitInverted, + LandscapeInverted }; virtual Orientation orientation() const = 0; diff --git a/tools/qml/deviceorientation_maemo.cpp b/tools/qml/deviceorientation_maemo.cpp index 501ff79..7948e2a 100644 --- a/tools/qml/deviceorientation_maemo.cpp +++ b/tools/qml/deviceorientation_maemo.cpp @@ -48,11 +48,11 @@ class MaemoOrientation : public DeviceOrientation Q_OBJECT public: MaemoOrientation() - : DeviceOrientation(),m_current(TopUp), m_lastSeen(TopUp), m_lastSeenCount(0) + : DeviceOrientation(),m_current(Portrait), m_lastSeen(Portrait), m_lastSeenCount(0) { m_current = get(); if (m_current == UnknownOrientation) - m_current = TopUp; + m_current = Portrait; startTimer(100); } @@ -101,13 +101,13 @@ private: if (abs(az) > 850) { o = UnknownOrientation; } else if (ax < -750) { - o = LeftUp; + o = Portrait; } else if (ax > 750) { - o = RightUp; + o = PortraitInverted; } else if (ay < -750) { - o = TopUp; + o = Landscape; } else if (ay > 750) { - o = TopDown; + o = LandscapeInverted; } return o; diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index f681303..5b0139f 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -581,10 +581,10 @@ void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) orientation->setExclusive(true); connect(orientation, SIGNAL(triggered(QAction*)), this, SLOT(changeOrientation(QAction*))); - orientation->addAction(tr("orientation: TopUp")); - orientation->addAction(tr("orientation: LeftUp")); - orientation->addAction(tr("orientation: TopDown")); - orientation->addAction(tr("orientation: RightUp")); + orientation->addAction(tr("orientation: Portrait")); + orientation->addAction(tr("orientation: Landscape")); + orientation->addAction(tr("orientation: Portrait (Inverted)")); + orientation->addAction(tr("orientation: Landscape (Inverted)")); QList actions = orientation->actions(); for (int i=0; iaddAction(actions[i]); @@ -1177,14 +1177,14 @@ void QDeclarativeViewer::changeOrientation(QAction *action) action->setChecked(true); QString o = action->text().split(QLatin1Char(':')).value(1).trimmed(); - if (o == QLatin1String("TopUp")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::TopUp); - else if (o == QLatin1String("TopDown")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::TopDown); - else if (o == QLatin1String("LeftUp")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::LeftUp); - else if (o == QLatin1String("RightUp")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::RightUp); + if (o == QLatin1String("Portrait")) + DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait); + else if (o == QLatin1String("Landscape")) + DeviceOrientation::instance()->setOrientation(DeviceOrientation::Landscape); + else if (o == QLatin1String("Portrait (Inverted)")) + DeviceOrientation::instance()->setOrientation(DeviceOrientation::PortraitInverted); + else if (o == QLatin1String("Landscape (Inverted)")) + DeviceOrientation::instance()->setOrientation(DeviceOrientation::LandscapeInverted); } void QDeclarativeViewer::orientationChanged() -- cgit v0.12 From 136eed8528608d8427baa4787d52611857ed0dbd Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 4 Jun 2010 14:38:25 +1000 Subject: Update docs for the runtime.orientation values --- doc/src/declarative/qmlruntime.qdoc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index cef5e63..66b4b2b 100644 --- a/doc/src/declarative/qmlruntime.qdoc +++ b/doc/src/declarative/qmlruntime.qdoc @@ -152,7 +152,7 @@ \section2 Runtime Object - All applications using the launcher will have access to the 'runtime' + All applications using the launcher will have access to the \c runtime property on the root context. This property contains several pieces of information about the runtime environment of the application. @@ -160,11 +160,19 @@ A special piece of dummy data which is integrated into the launcher is a simple orientation property. The orientation can be set via the - settings menu in the application, or by pressing Ctrl+T to toggle it. + settings menu in the application, or by pressing Ctrl+T to rotate it. - To use this from within your QML file, access runtime.orientation, - which can be either Orientation.Landscape or Orientation.Portrait and which can be bound to in your - application. An example is below: + To use this from within your QML file, access \c runtime.orientation, + which can be one of the following values: + + \list + \o \c Orientation.Portrait + \o \c Orientation.Landscape + \o \c Orientation.PortraitInverted (Portrait orientation, upside-down) + \o \c Orientation.LandscapeInverted (Landscape orientation, upside-down) + \endlist + + These values can be bound to in your application. For example: \code Item { @@ -172,13 +180,13 @@ } \endcode - This allows your application to respond to the orientation of the screen changing. The launcher + This allows your application to respond to changes in the screen's orientation. The launcher will automatically update this on some platforms (currently the N900 only) to match the physical screen's orientation. On other plaforms orientation changes will only happen when explictly asked for. \section3 Window Active - The runtime.isActiveWindow property tells whether the main window of the launcher is currently active + The \c runtime.isActiveWindow property tells whether the main window of the launcher is currently active or not. This is especially useful for embedded devices when you want to pause parts of your application, including animations, when your application loses focus or goes to the background. -- cgit v0.12 From 523b6a0da134700cead707530149067286228858 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 4 Jun 2010 12:55:08 +1000 Subject: Remove version ifdefs from Particles; only 4.7 is supported. --- src/imports/particles/qdeclarativeparticles.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp index ecc6604..56b89b5 100644 --- a/src/imports/particles/qdeclarativeparticles.cpp +++ b/src/imports/particles/qdeclarativeparticles.cpp @@ -1284,11 +1284,7 @@ void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphics const int myX = x() + parentItem()->x(); const int myY = y() + parentItem()->y(); -#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) QVarLengthArray pixmapData; -#else - QVarLengthArray pixmapData; -#endif pixmapData.resize(d->particles.count()); const QRectF sourceRect = d->image.rect(); @@ -1296,32 +1292,20 @@ void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphics qreal halfPHeight = sourceRect.height()/2.; for (int i = 0; i < d->particles.count(); ++i) { const QDeclarativeParticle &particle = d->particles.at(i); -#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) pixmapData[i].x = particle.x - myX + halfPWidth; pixmapData[i].y = particle.y - myY + halfPHeight; -#else - pixmapData[i].point = QPointF(particle.x - myX + halfPWidth, particle.y - myY + halfPHeight); -#endif pixmapData[i].opacity = particle.opacity; //these never change pixmapData[i].rotation = 0; pixmapData[i].scaleX = 1; pixmapData[i].scaleY = 1; -#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) pixmapData[i].sourceLeft = sourceRect.left(); pixmapData[i].sourceTop = sourceRect.top(); pixmapData[i].width = sourceRect.width(); pixmapData[i].height = sourceRect.height(); -#else - pixmapData[i].source = sourceRect; -#endif } -#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) p->drawPixmapFragments(pixmapData.data(), d->particles.count(), d->image); -#else - qDrawPixmaps(p, pixmapData.data(), d->particles.count(), d->image); -#endif } void QDeclarativeParticles::componentComplete() -- cgit v0.12 From 312152dafde1dbe5824f0af0a649918c5ebcab5e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 4 Jun 2010 13:18:14 +1000 Subject: Ensure ParticleMotionGravity always pulls in the right direction. --- src/imports/particles/qdeclarativeparticles.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp index 56b89b5..630c068 100644 --- a/src/imports/particles/qdeclarativeparticles.cpp +++ b/src/imports/particles/qdeclarativeparticles.cpp @@ -241,11 +241,13 @@ void QDeclarativeParticleMotionGravity::setAcceleration(qreal accel) void QDeclarativeParticleMotionGravity::advance(QDeclarativeParticle &p, int interval) { - qreal xdiff = p.x - _xAttr; - qreal ydiff = p.y - _yAttr; + qreal xdiff = _xAttr - p.x; + qreal ydiff = _yAttr - p.y; + qreal absXdiff = qAbs(xdiff); + qreal absYdiff = qAbs(ydiff); - qreal xcomp = xdiff / (xdiff + ydiff); - qreal ycomp = ydiff / (xdiff + ydiff); + qreal xcomp = xdiff / (absXdiff + absYdiff); + qreal ycomp = ydiff / (absXdiff + absYdiff); p.x_velocity += xcomp * _accel * interval; p.y_velocity += ycomp * _accel * interval; -- cgit v0.12 From fc017309a7a63a537f496d9c51b3a6390c5f5534 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 4 Jun 2010 16:12:43 +1000 Subject: Move QListModelInterface into util. Get rid of src/declarative/3rdparty. --- src/declarative/3rdparty/3rdparty.pri | 7 -- src/declarative/3rdparty/qlistmodelinterface.cpp | 109 ----------------------- src/declarative/3rdparty/qlistmodelinterface_p.h | 85 ------------------ src/declarative/declarative.pro | 1 - src/declarative/util/qlistmodelinterface.cpp | 109 +++++++++++++++++++++++ src/declarative/util/qlistmodelinterface_p.h | 85 ++++++++++++++++++ src/declarative/util/util.pri | 6 +- 7 files changed, 198 insertions(+), 204 deletions(-) delete mode 100644 src/declarative/3rdparty/3rdparty.pri delete mode 100644 src/declarative/3rdparty/qlistmodelinterface.cpp delete mode 100644 src/declarative/3rdparty/qlistmodelinterface_p.h create mode 100644 src/declarative/util/qlistmodelinterface.cpp create mode 100644 src/declarative/util/qlistmodelinterface_p.h diff --git a/src/declarative/3rdparty/3rdparty.pri b/src/declarative/3rdparty/3rdparty.pri deleted file mode 100644 index fbdcc11..0000000 --- a/src/declarative/3rdparty/3rdparty.pri +++ /dev/null @@ -1,7 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qlistmodelinterface_p.h\ - -SOURCES += \ - $$PWD/qlistmodelinterface.cpp \ diff --git a/src/declarative/3rdparty/qlistmodelinterface.cpp b/src/declarative/3rdparty/qlistmodelinterface.cpp deleted file mode 100644 index 98d6a5b..0000000 --- a/src/declarative/3rdparty/qlistmodelinterface.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclaractive module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qlistmodelinterface_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \internal - \class QListModelInterface - \brief The QListModelInterface class can be subclassed to provide C++ models to QDeclarativeGraphics Views - - This class is comprised primarily of pure virtual functions which - you must implement in a subclass. You can then use the subclass - as a model for a QDeclarativeGraphics view, such as a QDeclarativeListView. -*/ - -/*! \fn QListModelInterface::QListModelInterface(QObject *parent) - Constructs a QListModelInterface with the specified \a parent. -*/ - - /*! \fn QListModelInterface::QListModelInterface(QObjectPrivate &dd, QObject *parent) - - \internal - */ - -/*! \fn QListModelInterface::~QListModelInterface() - The destructor is virtual. - */ - -/*! \fn int QListModelInterface::count() const - Returns the number of data entries in the model. -*/ - -/*! \fn QHash QListModelInterface::data(int index, const QList& roles) const - Returns the data at the given \a index for the specifed \a roles. -*/ - -/*! \fn bool QListModelInterface::setData(int index, const QHash& values) - Sets the data at the given \a index. \a values is a mapping of - QVariant values to roles. Returns false. -*/ - -/*! \fn QList QListModelInterface::roles() const - Returns the list of roles for which the list model interface - provides data. -*/ - -/*! \fn QString QListModelInterface::toString(int role) const - Returns a string description of the specified \a role. -*/ - -/*! \fn void QListModelInterface::itemsInserted(int index, int count) - Emit this signal when \a count items are inserted at \a index. - */ - -/*! \fn void QListModelInterface::itemsRemoved(int index, int count) - Emit this signal when \a count items are removed at \a index. - */ - -/*! \fn void QListModelInterface::itemsMoved(int from, int to, int count) - Emit this signal when \a count items are moved from index \a from - to index \a to. - */ - -/*! \fn void QListModelInterface::itemsChanged(int index, int count, const QList &roles) - Emit this signal when \a count items at \a index have had their - \a roles changed. - */ - -QT_END_NAMESPACE diff --git a/src/declarative/3rdparty/qlistmodelinterface_p.h b/src/declarative/3rdparty/qlistmodelinterface_p.h deleted file mode 100644 index 07592ad..0000000 --- a/src/declarative/3rdparty/qlistmodelinterface_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QLISTMODELINTERFACE_H -#define QLISTMODELINTERFACE_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class Q_DECLARATIVE_EXPORT QListModelInterface : public QObject -{ - Q_OBJECT - public: - QListModelInterface(QObject *parent = 0) : QObject(parent) {} - virtual ~QListModelInterface() {} - - virtual int count() const = 0; - virtual QHash data(int index, const QList& roles = QList()) const = 0; - virtual QVariant data(int index, int role) const = 0; - virtual bool setData(int index, const QHash& values) - { Q_UNUSED(index); Q_UNUSED(values); return false; } - - virtual QList roles() const = 0; - virtual QString toString(int role) const = 0; - - 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 &roles); - - protected: - QListModelInterface(QObjectPrivate &dd, QObject *parent) - : QObject(dd, parent) {} -}; - - -QT_END_NAMESPACE - -QT_END_HEADER -#endif //QTREEMODELINTERFACE_H diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index 8037a16..510e7a5 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -20,7 +20,6 @@ include(../qbase.pri) #DESTDIR=. #modules -include(3rdparty/3rdparty.pri) include(util/util.pri) include(graphicsitems/graphicsitems.pri) include(qml/qml.pri) diff --git a/src/declarative/util/qlistmodelinterface.cpp b/src/declarative/util/qlistmodelinterface.cpp new file mode 100644 index 0000000..98d6a5b --- /dev/null +++ b/src/declarative/util/qlistmodelinterface.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclaractive module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "private/qlistmodelinterface_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \internal + \class QListModelInterface + \brief The QListModelInterface class can be subclassed to provide C++ models to QDeclarativeGraphics Views + + This class is comprised primarily of pure virtual functions which + you must implement in a subclass. You can then use the subclass + as a model for a QDeclarativeGraphics view, such as a QDeclarativeListView. +*/ + +/*! \fn QListModelInterface::QListModelInterface(QObject *parent) + Constructs a QListModelInterface with the specified \a parent. +*/ + + /*! \fn QListModelInterface::QListModelInterface(QObjectPrivate &dd, QObject *parent) + + \internal + */ + +/*! \fn QListModelInterface::~QListModelInterface() + The destructor is virtual. + */ + +/*! \fn int QListModelInterface::count() const + Returns the number of data entries in the model. +*/ + +/*! \fn QHash QListModelInterface::data(int index, const QList& roles) const + Returns the data at the given \a index for the specifed \a roles. +*/ + +/*! \fn bool QListModelInterface::setData(int index, const QHash& values) + Sets the data at the given \a index. \a values is a mapping of + QVariant values to roles. Returns false. +*/ + +/*! \fn QList QListModelInterface::roles() const + Returns the list of roles for which the list model interface + provides data. +*/ + +/*! \fn QString QListModelInterface::toString(int role) const + Returns a string description of the specified \a role. +*/ + +/*! \fn void QListModelInterface::itemsInserted(int index, int count) + Emit this signal when \a count items are inserted at \a index. + */ + +/*! \fn void QListModelInterface::itemsRemoved(int index, int count) + Emit this signal when \a count items are removed at \a index. + */ + +/*! \fn void QListModelInterface::itemsMoved(int from, int to, int count) + Emit this signal when \a count items are moved from index \a from + to index \a to. + */ + +/*! \fn void QListModelInterface::itemsChanged(int index, int count, const QList &roles) + Emit this signal when \a count items at \a index have had their + \a roles changed. + */ + +QT_END_NAMESPACE diff --git a/src/declarative/util/qlistmodelinterface_p.h b/src/declarative/util/qlistmodelinterface_p.h new file mode 100644 index 0000000..07592ad --- /dev/null +++ b/src/declarative/util/qlistmodelinterface_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QLISTMODELINTERFACE_H +#define QLISTMODELINTERFACE_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class Q_DECLARATIVE_EXPORT QListModelInterface : public QObject +{ + Q_OBJECT + public: + QListModelInterface(QObject *parent = 0) : QObject(parent) {} + virtual ~QListModelInterface() {} + + virtual int count() const = 0; + virtual QHash data(int index, const QList& roles = QList()) const = 0; + virtual QVariant data(int index, int role) const = 0; + virtual bool setData(int index, const QHash& values) + { Q_UNUSED(index); Q_UNUSED(values); return false; } + + virtual QList roles() const = 0; + virtual QString toString(int role) const = 0; + + 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 &roles); + + protected: + QListModelInterface(QObjectPrivate &dd, QObject *parent) + : QObject(dd, parent) {} +}; + + +QT_END_NAMESPACE + +QT_END_HEADER +#endif //QTREEMODELINTERFACE_H diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index f20bba1..04cfc68 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -27,7 +27,8 @@ SOURCES += \ $$PWD/qdeclarativebehavior.cpp \ $$PWD/qdeclarativefontloader.cpp \ $$PWD/qdeclarativestyledtext.cpp \ - $$PWD/qdeclarativelistmodelworkeragent.cpp + $$PWD/qdeclarativelistmodelworkeragent.cpp \ + $$PWD/qlistmodelinterface.cpp HEADERS += \ $$PWD/qdeclarativeutilmodule_p.h\ @@ -61,7 +62,8 @@ HEADERS += \ $$PWD/qdeclarativebehavior_p.h \ $$PWD/qdeclarativefontloader_p.h \ $$PWD/qdeclarativestyledtext_p.h \ - $$PWD/qdeclarativelistmodelworkeragent_p.h + $$PWD/qdeclarativelistmodelworkeragent_p.h \ + $$PWD/qlistmodelinterface_p.h contains(QT_CONFIG, xmlpatterns) { QT+=xmlpatterns -- cgit v0.12 From c785e5db81f51e7ed5feb20cc24f967c42f37af8 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 7 Jun 2010 10:36:16 +1000 Subject: Add some performance tips to QML docs. --- doc/src/declarative/declarativeui.qdoc | 1 + doc/src/declarative/qdeclarativeperformance.qdoc | 120 +++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 doc/src/declarative/qdeclarativeperformance.qdoc diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index 1199b26..7a49d0a 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -118,6 +118,7 @@ application or to build completely new applications. QML is fully \l \o \l {QML Security} \o \l {QtDeclarative Module} \o \l {Debugging QML} +\o \l {QML Performance} \o \l {QML Coding Conventions} \endlist */ diff --git a/doc/src/declarative/qdeclarativeperformance.qdoc b/doc/src/declarative/qdeclarativeperformance.qdoc new file mode 100644 index 0000000..b535e4b --- /dev/null +++ b/doc/src/declarative/qdeclarativeperformance.qdoc @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qdeclarativeperformance.html +\title QML Performance + +\section1 Opaque Items + +Items hidden behind an opaque item incur a cost. If an item will be enitrely +obscured by an opaque item, set its opacity to 0. One common example of +this is when a "details" page is shown over the main application view. + +\section1 Clipping + +\e clip is set to false by default. Enable clipping only when necessary. + +\section1 Anchors vs. Binding + +It is more efficient to use anchors rather than bindings to position items +relative to each other. Consider this use of bindings to position rect2 +relative to rect1: + +\code +Rectangle { + id: rect1 + x: 20 + width: 200; height: 200 +} +Rectange { + id: rect2 + x: rect1.x + y: rect1.y + rect1.height + width: rect1.width - 20 + height: 200 +} +\endcode + +This is achieved more efficiently using anchors: + +\code +Rectangle { + id: rect1 + x: 20 + width: 200; height: 200 +} +Rectange { + id: rect2 + height: 200 + anchors.left: rect1.left + anchors.top: rect1.bottom + anchors.right: rect1.right + anchors.rightMargin: 20 +} +\endcode + +\section1 Images + +Images consume a great deal of memory and may also be costly to load. In order +to deal with large images efficiently it is recommended that the Image::sourceSize +property be set to a size no greater than that necessary to render it. Beware that +changing the sourceSize will cause the image to be reloaded. + +Images on the local filesystem are usually loaded synchronously. This is usually +the desired behavior for user interface elements, however for large images that +do not necessarily need to be visible immediately, set the Image::asynchronous +property to true. This will load the image in a low priority thread. + +\section1 View Delegates + +Delegates must be created quickly as the view is flicked. There are two important +aspects to maintaining a smooth view: + +\list +\o Small delegates - keep the amount of QML to a minimum. Have just enough +QML in the delegate to display the necessary information. Any additional functionality +that is only needed when the delegate is clicked, for example, should be created by +a Loader as needed. +\o Fast data access - ensure the data model is as fast as possible. +\endlist + +*/ -- cgit v0.12 From 2613a33d957ae2b274364672ee5280b6317b71b0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 7 Jun 2010 12:32:02 +1000 Subject: Improve docs about Qml component case sensitivity. Task-number: QTBUG-11253 --- doc/src/declarative/extending.qdoc | 10 +++++++--- doc/src/declarative/qdeclarativedocument.qdoc | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 574b0b2..173fb6d 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -896,9 +896,13 @@ in other projects without the use of C++. Components can also help to reduce duplication inside one project by limiting the need for large numbers of copy-and-pasted blocks. -Any snippet of QML code can become a component, just by placing it in the file -".qml" where is the new element name, and begins with an uppercase -letter. These QML files automatically become available as new QML element types +Any snippet of QML code can become a component, just by placing it in the file ".qml" +where is the new element name, and begins with an uppercase letter. Note that +the case of all characters in the are significant on some filesystems, notably +UNIX filesystems. It is recommended that the case of the filename matches the case of +the component name in QML exactly, regardless of the platform the QML will be deployed to. + +These QML files automatically become available as new QML element types to other QML components and applications in the same directory. For example, here we show how a component named "Box" is defined and used diff --git a/doc/src/declarative/qdeclarativedocument.qdoc b/doc/src/declarative/qdeclarativedocument.qdoc index bc099ce..8336512 100644 --- a/doc/src/declarative/qdeclarativedocument.qdoc +++ b/doc/src/declarative/qdeclarativedocument.qdoc @@ -96,9 +96,6 @@ Once created, instances are not dependent on the component that created them, so operate on independent data. Here is an example of a simple "Button" component that is instantiated four times, each with a different value for its \c text property. -\table -\row -\o \raw HTML
\endraw @@ -125,10 +122,19 @@ BorderImage { \raw HTML
\endraw -\endtable -In addition to the top-level component that all QML documents define, documents may also -include additional \e inline components. Inline components are declared using the +Any snippet of QML code can become a component, just by placing it in the file ".qml" +where is the new element name, and begins with an uppercase letter. Note that +the case of all characters in the are significant on some filesystems, notably +UNIX filesystems. It is recommended that the case of the filename matches the case of +the component name in QML exactly, regardless of the platform the QML will be deployed to. + +These QML files automatically become available as new QML element types +to other QML components and applications in the same directory. + +In addition to the top-level component that all QML documents define, and any reusable +components placed in separate files, documents may also +include \e inline components. Inline components are declared using the \l Component element, as can be seen in the first example above. Inline components share all the characteristics of regular top-level components and use the same \c import list as their containing QML document. Components are one of the most basic building blocks in QML, and are -- cgit v0.12 From 22126ec530d07c7ba80f90812c9d6128b2d4a56f Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Mon, 7 Jun 2010 13:03:05 +1000 Subject: Fix regression in input panel autotests --- .../declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 7 ++++++- .../qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 474eb3f..9e5285f 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -956,7 +956,12 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() edit.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); - // and input panel should not open if focus has already been set + edit.setFocus(true); + QCOMPARE(ic.openInputPanelReceived, true); + QCOMPARE(ic.closeInputPanelReceived, false); + ic.openInputPanelReceived = false; + + // input panel should not open if focus has already been set edit.setFocus(true); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index c1c6634..370ecfb 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -902,7 +902,12 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() input.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); - // and input panel should not open if focus has already been set + input.setFocus(true); + QCOMPARE(ic.openInputPanelReceived, true); + QCOMPARE(ic.closeInputPanelReceived, false); + ic.openInputPanelReceived = false; + + // input panel should not open if focus has already been set input.setFocus(true); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); -- cgit v0.12 From ed5f6c87e783960f880d56f58149985366d34615 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 7 Jun 2010 11:54:19 +1000 Subject: Add image example. --- doc/src/declarative/examples.qdoc | 1 + doc/src/examples/qml-examples.qdoc | 9 +++ doc/src/images/qml-image-example.png | Bin 0 -> 58184 bytes .../declarative/imageelements/image/ImageCell.qml | 60 +++++++++++++++++++ .../declarative/imageelements/image/face-smile.png | Bin 0 -> 15408 bytes examples/declarative/imageelements/image/image.qml | 66 +++++++++++++++++++++ .../imageelements/image/image.qmlproject | 16 +++++ 7 files changed, 152 insertions(+) create mode 100644 doc/src/images/qml-image-example.png create mode 100644 examples/declarative/imageelements/image/ImageCell.qml create mode 100644 examples/declarative/imageelements/image/face-smile.png create mode 100644 examples/declarative/imageelements/image/image.qml create mode 100644 examples/declarative/imageelements/image/image.qmlproject diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 8f39685..cc67664 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -79,6 +79,7 @@ For example, from your build directory, run: \section2 Image Elements \list \o \l{declarative/imageelements/borderimage}{BorderImage} +\o \l{declarative/imageelements/image}{Image} \endlist \section2 Positioners diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index 035628e..9dbf853 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -75,6 +75,15 @@ */ /*! + \title Image Elements: Image + \example declarative/imageelements/image + + This example shows how to use the Image element and its \l{Image::fillMode}{fillModes}. + + \image qml-image-example.png +*/ + +/*! \page declarative-cppextensions-reference.html \title C++ Extensions: Reference examples diff --git a/doc/src/images/qml-image-example.png b/doc/src/images/qml-image-example.png new file mode 100644 index 0000000..c1951c0 Binary files /dev/null and b/doc/src/images/qml-image-example.png differ diff --git a/examples/declarative/imageelements/image/ImageCell.qml b/examples/declarative/imageelements/image/ImageCell.qml new file mode 100644 index 0000000..bd232b9 --- /dev/null +++ b/examples/declarative/imageelements/image/ImageCell.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import Qt 4.7 + +Item { + property alias mode: image.fillMode + property alias caption: captionItem.text + + width: parent.cellWidth; height: parent.cellHeight + + Image { + id: image + width: parent.width; height: parent.height - captionItem.height + source: "face-smile.png" + clip: true // only makes a difference if mode is PreserveAspectCrop + smooth: true + } + + Text { + id: captionItem + anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom + } +} diff --git a/examples/declarative/imageelements/image/face-smile.png b/examples/declarative/imageelements/image/face-smile.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/examples/declarative/imageelements/image/face-smile.png differ diff --git a/examples/declarative/imageelements/image/image.qml b/examples/declarative/imageelements/image/image.qml new file mode 100644 index 0000000..bc5ae37 --- /dev/null +++ b/examples/declarative/imageelements/image/image.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +Rectangle { + width: 490 + height: 285 + + Grid { + property int cellWidth: (width - (spacing * (columns - 1))) / columns + property int cellHeight: (height - (spacing * (rows - 1))) / rows + + anchors.fill: parent + anchors.margins: 30 + + columns: 3 + rows: 2 + spacing: 30 + + ImageCell { mode: Image.Stretch; caption: "Stretch" } + ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" } + ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" } + + ImageCell { mode: Image.Tile; caption: "Tile" } + ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" } + ImageCell { mode: Image.TileVertically; caption: "TileVertically" } + } +} diff --git a/examples/declarative/imageelements/image/image.qmlproject b/examples/declarative/imageelements/image/image.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/imageelements/image/image.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} -- cgit v0.12 From 0619c12bfee40826034dbc31f9d398182a3aa49f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 7 Jun 2010 14:44:06 +1000 Subject: Ensure state operations assigned to the default state are triggered when returning to that state. Task-number: QTBUG-11228 --- src/declarative/util/qdeclarativestate.cpp | 7 +++++++ src/declarative/util/qdeclarativestate_p.h | 1 + src/declarative/util/qdeclarativestate_p_p.h | 3 ++- src/declarative/util/qdeclarativestategroup.cpp | 4 ++-- .../qdeclarativestates/data/returnToBase.qml | 21 +++++++++++++++++++++ .../qdeclarativestates/tst_qdeclarativestates.cpp | 21 +++++++++++++++++++++ 6 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativestates/data/returnToBase.qml diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index dc2b2cc..eca90a4 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -187,6 +187,13 @@ void QDeclarativeState::setName(const QString &n) { Q_D(QDeclarativeState); d->name = n; + d->named = true; +} + +bool QDeclarativeState::isNamed() const +{ + Q_D(const QDeclarativeState); + return d->named; } bool QDeclarativeState::isWhenKnown() const diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h index 37b24cb..2e2ce7b 100644 --- a/src/declarative/util/qdeclarativestate_p.h +++ b/src/declarative/util/qdeclarativestate_p.h @@ -146,6 +146,7 @@ public: QString name() const; void setName(const QString &); + bool isNamed() const; /*'when' is a QDeclarativeBinding to limit state changes oscillation due to the unpredictable order of evaluation of bound expressions*/ diff --git a/src/declarative/util/qdeclarativestate_p_p.h b/src/declarative/util/qdeclarativestate_p_p.h index 4a2af0f..2ef9bb0 100644 --- a/src/declarative/util/qdeclarativestate_p_p.h +++ b/src/declarative/util/qdeclarativestate_p_p.h @@ -101,12 +101,13 @@ class QDeclarativeStatePrivate : public QObjectPrivate public: QDeclarativeStatePrivate() - : when(0), inState(false), group(0) {} + : when(0), named(false), inState(false), group(0) {} typedef QList SimpleActionList; QString name; QDeclarativeBinding *when; + bool named; struct OperationGuard : public QDeclarativeGuard { diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index 9b042d7..1e530a1 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -263,7 +263,7 @@ void QDeclarativeStateGroup::componentComplete() for (int ii = 0; ii < d->states.count(); ++ii) { QDeclarativeState *state = d->states.at(ii); - if (state->name().isEmpty()) + if (!state->isNamed()) state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount)); } @@ -295,7 +295,7 @@ bool QDeclarativeStateGroupPrivate::updateAutoState() for (int ii = 0; ii < states.count(); ++ii) { QDeclarativeState *state = states.at(ii); if (state->isWhenKnown()) { - if (!state->name().isEmpty()) { + if (state->isNamed()) { if (state->when() && state->when()->evaluate().toBool()) { if (stateChangeDebug()) qWarning() << "Setting auto state due to:" diff --git a/tests/auto/declarative/qdeclarativestates/data/returnToBase.qml b/tests/auto/declarative/qdeclarativestates/data/returnToBase.qml new file mode 100644 index 0000000..e342331 --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/returnToBase.qml @@ -0,0 +1,21 @@ +import Qt 4.7 + +Rectangle { + id: theRect + property bool triggerState: false + property string stateString: "" + states: [ State { + when: triggerState + PropertyChanges { + target: theRect + stateString: "inState" + } + }, + State { + name: "" + PropertyChanges { + target: theRect + stateString: "originalState" + } + }] +} diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index ea074a4..055a34c 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -112,6 +112,7 @@ private slots: void whenOrdering(); void urlResolution(); void unnamedWhen(); + void returnToBase(); }; void tst_qdeclarativestates::initTestCase() @@ -1085,6 +1086,26 @@ void tst_qdeclarativestates::unnamedWhen() QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); } +void tst_qdeclarativestates::returnToBase() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/returnToBase.qml"); + QDeclarativeRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); + rect->setProperty("triggerState", true); + QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); + rect->setProperty("triggerState", false); + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState")); +} + + QTEST_MAIN(tst_qdeclarativestates) #include "tst_qdeclarativestates.moc" -- cgit v0.12 From f410fb06c584fa0e893ab6066ea8b03a5323fe07 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Mon, 7 Jun 2010 14:52:20 +1000 Subject: Remove unnecessary CloseSoftwareInputPanel events after TextEdit or TextInput has lost focus Task-number: Reviewed-by: Warwick Allison --- .../graphicsitems/qdeclarativetextedit.cpp | 27 +++----- .../graphicsitems/qdeclarativetextedit_p.h | 1 - .../graphicsitems/qdeclarativetextinput.cpp | 27 +++----- .../graphicsitems/qdeclarativetextinput_p.h | 1 - .../tst_qdeclarativetextedit.cpp | 73 ++++++++++++++-------- .../tst_qdeclarativetextinput.cpp | 72 +++++++++++++-------- 6 files changed, 109 insertions(+), 92 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index d0e0ad3..c086851 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1391,9 +1391,9 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption() your application. By default the opening of input panels follows the platform style. On Symbian^1 and - Symbian^3 -based devices the panels are opened by clicking TextEdit and need to be - manually closed by the user. On other platforms the panels are automatically opened - when TextEdit element gains focus and closed when the focus is lost. + Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms + the panels are automatically opened when TextEdit element gains focus. Input panels are + always closed if no editor owns focus. . You can disable the automatic behavior by setting the property \c focusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement @@ -1415,9 +1415,9 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption() textEdit.openSoftwareInputPanel(); } else { textEdit.focus = false; - textEdit.closeSoftwareInputPanel(); } } + onPressAndHold: textEdit.closeSoftwareInputPanel(); } } \endcode @@ -1442,9 +1442,9 @@ void QDeclarativeTextEdit::openSoftwareInputPanel() your application. By default the opening of input panels follows the platform style. On Symbian^1 and - Symbian^3 -based devices the panels are opened by clicking TextEdit and need to be - manually closed by the user. On other platforms the panels are automatically opened - when TextEdit element gains focus and closed when the focus is lost. + Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms + the panels are automatically opened when TextEdit element gains focus. Input panels are + always closed if no editor owns focus. . You can disable the automatic behavior by setting the property \c focusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement @@ -1466,9 +1466,9 @@ void QDeclarativeTextEdit::openSoftwareInputPanel() textEdit.openSoftwareInputPanel(); } else { textEdit.focus = false; - textEdit.closeSoftwareInputPanel(); } } + onPressAndHold: textEdit.closeSoftwareInputPanel(); } } \endcode @@ -1496,15 +1496,4 @@ void QDeclarativeTextEdit::focusInEvent(QFocusEvent *event) QDeclarativePaintedItem::focusInEvent(event); } -void QDeclarativeTextEdit::focusOutEvent(QFocusEvent *event) -{ - Q_D(const QDeclarativeTextEdit); - if (d->showInputPanelOnFocus) { - if (d->focusOnPress && !isReadOnly()) { - closeSoftwareInputPanel(); - } - } - QDeclarativePaintedItem::focusOutEvent(event); -} - QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h index 0ecb2f3..d08f607 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h @@ -247,7 +247,6 @@ protected: void keyPressEvent(QKeyEvent *); void keyReleaseEvent(QKeyEvent *); void focusInEvent(QFocusEvent *event); - void focusOutEvent(QFocusEvent *event); // mouse filter? void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 3911a97..b877c50 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1234,9 +1234,9 @@ void QDeclarativeTextInput::moveCursorSelection(int position) your application. By default the opening of input panels follows the platform style. On Symbian^1 and - Symbian^3 -based devices the panels are opened by clicking TextInput and need to be - manually closed by the user. On other platforms the panels are automatically opened - when TextInput element gains focus and closed when the focus is lost. + Symbian^3 -based devices the panels are opened by clicking TextInput. On other platforms + the panels are automatically opened when TextInput element gains focus. Input panels are + always closed if no editor owns focus. . You can disable the automatic behavior by setting the property \c focusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement @@ -1258,9 +1258,9 @@ void QDeclarativeTextInput::moveCursorSelection(int position) textInput.openSoftwareInputPanel(); } else { textInput.focus = false; - textInput.closeSoftwareInputPanel(); } } + onPressAndHold: textInput.closeSoftwareInputPanel(); } } \endqml @@ -1285,9 +1285,9 @@ void QDeclarativeTextInput::openSoftwareInputPanel() your application. By default the opening of input panels follows the platform style. On Symbian^1 and - Symbian^3 -based devices the panels are opened by clicking TextInput and need to be - manually closed by the user. On other platforms the panels are automatically opened - when TextInput element gains focus and closed when the focus is lost. + Symbian^3 -based devices the panels are opened by clicking TextInput. On other platforms + the panels are automatically opened when TextInput element gains focus. Input panels are + always closed if no editor owns focus. . You can disable the automatic behavior by setting the property \c focusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement @@ -1309,9 +1309,9 @@ void QDeclarativeTextInput::openSoftwareInputPanel() textInput.openSoftwareInputPanel(); } else { textInput.focus = false; - textInput.closeSoftwareInputPanel(); } } + onPressAndHold: textInput.closeSoftwareInputPanel(); } } \endqml @@ -1340,17 +1340,6 @@ void QDeclarativeTextInput::focusInEvent(QFocusEvent *event) QDeclarativePaintedItem::focusInEvent(event); } -void QDeclarativeTextInput::focusOutEvent(QFocusEvent *event) -{ - Q_D(const QDeclarativeTextInput); - if (d->showInputPanelOnFocus) { - if (d->focusOnPress && !isReadOnly()) { - closeSoftwareInputPanel(); - } - } - QDeclarativePaintedItem::focusOutEvent(event); -} - void QDeclarativeTextInputPrivate::init() { Q_Q(QDeclarativeTextInput); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index e34634a..c539bd3 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -224,7 +224,6 @@ protected: void keyPressEvent(QKeyEvent* ev); bool event(QEvent *e); void focusInEvent(QFocusEvent *event); - void focusOutEvent(QFocusEvent *event); public Q_SLOTS: void selectAll(); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 9e5285f..053c9ef 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -862,6 +862,7 @@ void tst_qdeclarativetextedit::openInputPanelOnClick() edit.setFocus(false); edit.setFocus(true); edit.setFocus(false); + QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); } @@ -887,6 +888,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() QDeclarativeTextEditPrivate *editPrivate = static_cast(pri); editPrivate->showInputPanelOnFocus = true; + // test default values QVERIFY(edit.focusOnPress()); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); @@ -896,75 +898,94 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() QApplication::processEvents(); QVERIFY(edit.hasFocus()); QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; // no events on release QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - // Even with focus already gained, user needs - // to be able to open panel by pressing on the editor + // if already focused, input panel can be opened on press + QVERIFY(edit.hasFocus()); QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - // input panel closed on focus lost - edit.setFocus(false); + // input method should stay enabled if focus + // is lost to an item that also accepts inputs + QDeclarativeTextEdit anotherEdit; + scene.addItem(&anotherEdit); + anotherEdit.setFocus(true); + QApplication::processEvents(); + QCOMPARE(ic.openInputPanelReceived, true); + ic.openInputPanelReceived = false; + QCOMPARE(view.inputContext(), &ic); + QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); + + // input method should be disabled if focus + // is lost to an item that doesn't accept inputs + QDeclarativeItem item; + scene.addItem(&item); + item.setFocus(true); QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, true); - ic.closeInputPanelReceived = false; + QVERIFY(view.inputContext() == 0); + QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); - // no automatic input panel events if focusOnPress is false + // no automatic input panel events should + // be sent if focusOnPress is false + edit.setFocusOnPress(false); + QCOMPARE(focusOnPressSpy.count(),1); edit.setFocusOnPress(false); QCOMPARE(focusOnPressSpy.count(),1); - QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); - QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); edit.setFocus(false); edit.setFocus(true); + QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); + QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); + QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); - edit.setFocusOnPress(false); - QCOMPARE(focusOnPressSpy.count(),1); - - // one show input panel event when openSoftwareInputPanel is called + // one show input panel event should + // be set when openSoftwareInputPanel is called edit.openSoftwareInputPanel(); QCOMPARE(ic.openInputPanelReceived, true); QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - // one close input panel event when closeSoftwareInputPanel is called + // one close input panel event should + // be sent when closeSoftwareInputPanel is called edit.closeSoftwareInputPanel(); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, true); - ic.openInputPanelReceived = false; + ic.closeInputPanelReceived = false; // set focusOnPress back to true edit.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); + edit.setFocusOnPress(true); + QCOMPARE(focusOnPressSpy.count(),2); edit.setFocus(false); + QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, true); + QCOMPARE(ic.closeInputPanelReceived, false); ic.closeInputPanelReceived = false; - edit.setFocusOnPress(true); - QCOMPARE(focusOnPressSpy.count(),2); - + // input panel should not re-open + // if focus has already been set edit.setFocus(true); QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - - // input panel should not open if focus has already been set edit.setFocus(true); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, false); + + // input method should be disabled + // if TextEdit loses focus + edit.setFocus(false); + QApplication::processEvents(); + QVERIFY(view.inputContext() == 0); + QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); } void tst_qdeclarativetextedit::geometrySignals() diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 370ecfb..c9de0aa 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -833,6 +833,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QDeclarativeTextInputPrivate *inputPrivate = static_cast(pri); inputPrivate->showInputPanelOnFocus = true; + // test default values QVERIFY(input.focusOnPress()); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); @@ -842,75 +843,94 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QApplication::processEvents(); QVERIFY(input.hasFocus()); QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; // no events on release QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - // Even with focus already gained, user needs - // to be able to open panel by pressing on the editor + // if already focused, input panel can be opened on press + QVERIFY(input.hasFocus()); QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - // input panel closed on focus lost - input.setFocus(false); + // input method should stay enabled if focus + // is lost to an item that also accepts inputs + QDeclarativeTextInput anotherInput; + scene.addItem(&anotherInput); + anotherInput.setFocus(true); + QApplication::processEvents(); + QCOMPARE(ic.openInputPanelReceived, true); + ic.openInputPanelReceived = false; + QCOMPARE(view.inputContext(), &ic); + QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); + + // input method should be disabled if focus + // is lost to an item that doesn't accept inputs + QDeclarativeItem item; + scene.addItem(&item); + item.setFocus(true); QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, true); - ic.closeInputPanelReceived = false; + QVERIFY(view.inputContext() == 0); + QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); - // no automatic input panel events if focusOnPress is false + // no automatic input panel events should + // be sent if focusOnPress is false + input.setFocusOnPress(false); + QCOMPARE(focusOnPressSpy.count(),1); input.setFocusOnPress(false); QCOMPARE(focusOnPressSpy.count(),1); - QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); - QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); input.setFocus(false); input.setFocus(true); + QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); + QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); + QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); - input.setFocusOnPress(false); - QCOMPARE(focusOnPressSpy.count(),1); - - // one show input panel event when openSoftwareInputPanel is called + // one show input panel event should + // be set when openSoftwareInputPanel is called input.openSoftwareInputPanel(); QCOMPARE(ic.openInputPanelReceived, true); QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - // one close input panel event when closeSoftwareInputPanel is called + // one close input panel event should + // be sent when closeSoftwareInputPanel is called input.closeSoftwareInputPanel(); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, true); - ic.openInputPanelReceived = false; + ic.closeInputPanelReceived = false; // set focusOnPress back to true input.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); + input.setFocusOnPress(true); + QCOMPARE(focusOnPressSpy.count(),2); input.setFocus(false); + QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, true); + QCOMPARE(ic.closeInputPanelReceived, false); ic.closeInputPanelReceived = false; - input.setFocusOnPress(true); - QCOMPARE(focusOnPressSpy.count(),2); - + // input panel should not re-open + // if focus has already been set input.setFocus(true); QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - - // input panel should not open if focus has already been set input.setFocus(true); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, false); + + // input method should be disabled + // if TextEdit loses focus + input.setFocus(false); + QApplication::processEvents(); + QVERIFY(view.inputContext() == 0); + QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); } class MyTextInput : public QDeclarativeTextInput -- cgit v0.12 From a4f4fff60d20e509cb57bd0dab30533e1e299aee Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 7 Jun 2010 15:59:11 +1000 Subject: Keep reported point/pixel size in sync. This allows you to, for example, bind to a Text's font.pixelSize, even if one was never explicitly set. Task-number: QTBUG-11111 --- src/declarative/qml/qdeclarativevaluetype.cpp | 12 ++++++++++++ src/declarative/qml/qdeclarativevaluetype_p.h | 2 ++ .../qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index dbc25bb..c17ec95 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -47,6 +47,8 @@ QT_BEGIN_NAMESPACE +Q_DECL_IMPORT extern int qt_defaultDpi(); + template int qmlRegisterValueTypeEnums(const char *qmlName) { @@ -909,6 +911,11 @@ void QDeclarativeFontValueType::setStrikeout(bool b) qreal QDeclarativeFontValueType::pointSize() const { + if (font.pointSizeF() == -1) { + if (dpi.isNull) + dpi = qt_defaultDpi(); + return font.pixelSize() * qreal(72.) / qreal(dpi); + } return font.pointSizeF(); } @@ -929,6 +936,11 @@ void QDeclarativeFontValueType::setPointSize(qreal size) int QDeclarativeFontValueType::pixelSize() const { + if (font.pixelSize() == -1) { + if (dpi.isNull) + dpi = qt_defaultDpi(); + return (font.pointSizeF() * dpi) / qreal(72.); + } return font.pixelSize(); } diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h index 3eaecc1..4b1bbd6 100644 --- a/src/declarative/qml/qdeclarativevaluetype_p.h +++ b/src/declarative/qml/qdeclarativevaluetype_p.h @@ -55,6 +55,7 @@ #include "qdeclarativeproperty.h" #include "private/qdeclarativeproperty_p.h" +#include "private/qdeclarativenullablevalue_p_p.h" #include #include @@ -547,6 +548,7 @@ private: QFont font; bool pixelSizeSet; bool pointSizeSet; + mutable QDeclarativeNullableValue dpi; }; QT_END_NAMESPACE diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 53fd68c..5e46fab 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -46,6 +46,8 @@ #include #include "testtypes.h" +extern int qt_defaultDpi(); + class tst_qdeclarativevaluetypes : public QObject { Q_OBJECT @@ -464,7 +466,7 @@ void tst_qdeclarativevaluetypes::font() QCOMPARE(object->property("f_overline").toBool(), object->font().overline()); QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut()); QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF()); - QCOMPARE(object->property("f_pixelSize").toInt(), object->font().pixelSize()); + QCOMPARE(object->property("f_pixelSize").toInt(), int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.))); QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization()); QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing()); QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing()); -- cgit v0.12 From f6eeb554631faa542cb14388a46f05a0822b8033 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 7 Jun 2010 16:27:09 +1000 Subject: Accept enter key in the webbrower demo url input. --- demos/declarative/webbrowser/content/UrlInput.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/demos/declarative/webbrowser/content/UrlInput.qml b/demos/declarative/webbrowser/content/UrlInput.qml index 9ea1904..b57fae6 100644 --- a/demos/declarative/webbrowser/content/UrlInput.qml +++ b/demos/declarative/webbrowser/content/UrlInput.qml @@ -73,6 +73,10 @@ Item { urlText.text = webView.url webView.focus = true } + Keys.onEnterPressed: { + container.urlEntered(urlText.text) + webView.focus = true + } Keys.onReturnPressed: { container.urlEntered(urlText.text) webView.focus = true -- cgit v0.12 From e4c7f469d1cdaf535b5e7aacaca7f96553084b79 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Mon, 7 Jun 2010 17:04:45 +1000 Subject: Make declarative autotests compile on Symbian abld build system Task-number: Reviewed-by: Martin Jones --- tests/auto/declarative/declarative.pro | 2 +- tests/auto/declarative/examples/examples.pro | 3 +-- tests/auto/declarative/examples/tst_examples.cpp | 5 +++++ tests/auto/declarative/parserstress/parserstress.pro | 3 +-- tests/auto/declarative/parserstress/tst_parserstress.cpp | 5 +++++ .../auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro | 3 +-- .../declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp | 5 +++++ .../qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro | 3 +-- .../qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp | 5 +++++ .../declarative/qdeclarativeanimations/qdeclarativeanimations.pro | 3 +-- .../qdeclarativeanimations/tst_qdeclarativeanimations.cpp | 5 +++++ .../declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro | 3 +-- .../qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp | 5 +++++ .../auto/declarative/qdeclarativebinding/qdeclarativebinding.pro | 4 +--- .../declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp | 5 +++++ .../qdeclarativeborderimage/qdeclarativeborderimage.pro | 4 +--- .../qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp | 4 ++++ .../declarative/qdeclarativecomponent/qdeclarativecomponent.pro | 4 +--- .../qdeclarativecomponent/tst_qdeclarativecomponent.cpp | 5 +++++ .../declarative/qdeclarativeconnection/qdeclarativeconnection.pro | 4 +--- .../qdeclarativeconnection/tst_qdeclarativeconnection.cpp | 5 +++++ .../auto/declarative/qdeclarativecontext/qdeclarativecontext.pro | 4 +--- .../declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp | 5 +++++ tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro | 3 +-- tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp | 5 +++++ .../declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro | 8 +++++++- .../qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 5 +++++ tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro | 5 +---- .../declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp | 5 +++++ tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro | 4 +--- .../auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp | 5 +++++ .../declarative/qdeclarativeflickable/qdeclarativeflickable.pro | 4 +--- .../qdeclarativeflickable/tst_qdeclarativeflickable.cpp | 5 +++++ .../declarative/qdeclarativeflipable/qdeclarativeflipable.pro | 4 +--- .../declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp | 5 +++++ .../declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro | 3 +-- .../qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp | 4 ++++ .../qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro | 4 +--- .../tst_qdeclarativefolderlistmodel.cpp | 5 +++++ .../declarative/qdeclarativefontloader/qdeclarativefontloader.pro | 4 +--- .../qdeclarativefontloader/tst_qdeclarativefontloader.cpp | 5 +++++ .../declarative/qdeclarativegridview/qdeclarativegridview.pro | 4 +--- .../declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp | 5 +++++ tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro | 4 +--- .../auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp | 4 ++++ .../qdeclarativeimageprovider/qdeclarativeimageprovider.pro | 4 +--- .../qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp | 5 +++++ tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro | 3 +-- tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp | 5 +++++ .../qdeclarativeinstruction/qdeclarativeinstruction.pro | 4 +--- .../qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp | 5 +++++ tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro | 3 +-- tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp | 5 +++++ .../declarative/qdeclarativelanguage/qdeclarativelanguage.pro | 3 +-- .../declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp | 5 +++++ .../declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro | 6 ++---- .../qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp | 5 +++++ .../declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro | 4 +--- .../qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 5 +++++ .../declarative/qdeclarativelistview/qdeclarativelistview.pro | 4 +--- .../declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 5 +++++ tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro | 3 +-- .../declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp | 5 +++++ .../declarative/qdeclarativemetatype/qdeclarativemetatype.pro | 4 +--- .../declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp | 5 +++++ .../qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp | 5 +++++ .../qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro | 4 ++-- .../declarative/qdeclarativemousearea/qdeclarativemousearea.pro | 4 +--- .../qdeclarativemousearea/tst_qdeclarativemousearea.cpp | 5 +++++ .../declarative/qdeclarativeparticles/qdeclarativeparticles.pro | 4 +--- .../qdeclarativeparticles/tst_qdeclarativeparticles.cpp | 5 +++++ .../declarative/qdeclarativepathview/qdeclarativepathview.pro | 4 +--- .../declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp | 5 +++++ .../qdeclarativepixmapcache/qdeclarativepixmapcache.pro | 3 +-- .../qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp | 5 +++++ .../qdeclarativepositioners/qdeclarativepositioners.pro | 4 +--- .../qdeclarativepositioners/tst_qdeclarativepositioners.cpp | 5 +++++ .../declarative/qdeclarativeproperty/qdeclarativeproperty.pro | 3 +-- .../declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp | 5 +++++ tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro | 3 +-- tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp | 5 +++++ .../declarative/qdeclarativerepeater/qdeclarativerepeater.pro | 4 +--- .../declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp | 5 +++++ .../qdeclarativesmoothedanimation.pro | 4 +--- .../tst_qdeclarativesmoothedanimation.cpp | 5 +++++ .../qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro | 4 +--- .../qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp | 5 +++++ .../qdeclarativespringfollow/qdeclarativespringfollow.pro | 4 +--- .../qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp | 5 +++++ .../qdeclarativesqldatabase/qdeclarativesqldatabase.pro | 4 +--- .../qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp | 5 +++++ tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro | 4 +--- .../declarative/qdeclarativestates/tst_qdeclarativestates.cpp | 4 ++++ .../qdeclarativesystempalette/qdeclarativesystempalette.pro | 5 +---- .../qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp | 5 +++++ tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro | 3 +-- tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp | 5 +++++ .../declarative/qdeclarativetextedit/qdeclarativetextedit.pro | 4 +--- .../declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 5 +++++ .../declarative/qdeclarativetextinput/qdeclarativetextinput.pro | 4 +--- .../qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 5 +++++ tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro | 4 +--- .../auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp | 5 +++++ .../declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro | 3 +-- .../qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp | 5 +++++ tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro | 3 +-- tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp | 5 +++++ tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro | 3 +-- .../declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 5 +++++ .../qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro | 3 +-- .../tst_qdeclarativevisualdatamodel.cpp | 5 +++++ .../auto/declarative/qdeclarativewebview/qdeclarativewebview.pro | 4 +--- .../declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp | 5 +++++ .../qdeclarativeworkerscript/qdeclarativeworkerscript.pro | 4 +--- .../qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp | 5 +++++ .../qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro | 4 +--- .../qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp | 5 +++++ .../qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro | 3 +-- .../qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp | 5 +++++ tests/auto/declarative/qmlvisual/qmlvisual.pro | 4 +--- tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp | 5 +++++ 121 files changed, 365 insertions(+), 160 deletions(-) diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 484fbef..3d2dbf0 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,12 +1,12 @@ TEMPLATE = subdirs !symbian: { SUBDIRS += \ - examples \ qdeclarativemetatype \ qmetaobjectbuilder } SUBDIRS += \ + examples \ parserstress \ qdeclarativeanchors \ qdeclarativeanimatedimage \ diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index 92a16f1..2e243b4 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -7,9 +7,8 @@ SOURCES += tst_examples.cpp include(../../../../tools/qml/qml.pri) symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 605345e..da115a7 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -47,6 +47,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_examples : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/parserstress/parserstress.pro b/tests/auto/declarative/parserstress/parserstress.pro index 3a675e4..bb1d69f 100644 --- a/tests/auto/declarative/parserstress/parserstress.pro +++ b/tests/auto/declarative/parserstress/parserstress.pro @@ -5,9 +5,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_parserstress.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = ..\\..\\qscriptjstestsuite\\tests - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp index c86908b..522a63a 100644 --- a/tests/auto/declarative/parserstress/tst_parserstress.cpp +++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp @@ -46,6 +46,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_parserstress : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro index 452ad55..9798bb6 100644 --- a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro +++ b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro @@ -4,9 +4,8 @@ SOURCES += tst_qdeclarativeanchors.cpp macx:CONFIG -= app_bundle symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp index 22f7966..97b77d0 100644 --- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp +++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp @@ -50,6 +50,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + Q_DECLARE_METATYPE(QDeclarativeAnchors::Anchor) Q_DECLARE_METATYPE(QDeclarativeAnchorLine::AnchorLine) diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro index 7213abd..0a2f0f2 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro +++ b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro @@ -5,9 +5,8 @@ SOURCES += tst_qdeclarativeanimatedimage.cpp ../shared/testhttpserver.cpp macx:CONFIG -= app_bundle symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp index 237a436..1001278 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp @@ -48,6 +48,11 @@ #include "../shared/testhttpserver.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + #define TRY_WAIT(expr) \ do { \ for (int ii = 0; ii < 6; ++ii) { \ diff --git a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro index f7ed371..ed47dca 100644 --- a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro +++ b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro @@ -4,9 +4,8 @@ SOURCES += tst_qdeclarativeanimations.cpp macx:CONFIG -= app_bundle symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index ed7e506..5cf4c23 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -48,6 +48,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativeanimations : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro index 7137af1..cfb59ef 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro +++ b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro @@ -4,9 +4,8 @@ SOURCES += tst_qdeclarativebehaviors.cpp macx:CONFIG -= app_bundle symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 45e5304..70739fb 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -49,6 +49,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativebehaviors : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro index 04535db..a7ba2a8 100644 --- a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro +++ b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativebinding.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp index 8ab7b0b..653b34a 100644 --- a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp +++ b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp @@ -45,6 +45,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativebinding : public QObject { diff --git a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro index 3aa2197..a21761b 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro +++ b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro @@ -5,11 +5,9 @@ macx:CONFIG -= app_bundle HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeborderimage.cpp ../shared/testhttpserver.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index 69b4a89..1b73cf7 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -54,6 +54,10 @@ #include "../shared/testhttpserver.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif #define SERVER_PORT 14446 #define SERVER_ADDR "http://127.0.0.1:14446" diff --git a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro index 98c38ad..4124f94 100644 --- a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro +++ b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro @@ -5,9 +5,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativecomponent.cpp -symbian: { - DEFINES += SRCDIR=\".\" -} else { +!symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp index faa1c21..8a19b8b 100644 --- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp +++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -45,6 +45,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativecomponent : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro index bbf8630..d06ce4f 100644 --- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro +++ b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeconnection.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp index 00e97ca..d384372 100644 --- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp +++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp @@ -46,6 +46,11 @@ #include "../../../shared/util.h" #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativeconnection : public QObject { diff --git a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro index 0e1a5b1..74bb78c 100644 --- a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro +++ b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro @@ -3,9 +3,7 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativecontext.cpp macx:CONFIG -= app_bundle -symbian: { - DEFINES += SRCDIR=\".\" -} else { +!symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index 7f0e6c0..605cf8e 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -46,6 +46,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativecontext : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro index 9f1e50c..415d4e2 100644 --- a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro +++ b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro @@ -5,9 +5,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativedom.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp index 6c19566..13960b1 100644 --- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp +++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp @@ -46,6 +46,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativedom : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro index c907be5..58cad34 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro +++ b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro @@ -12,7 +12,13 @@ INCLUDEPATH += ../shared # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + importFiles.sources = data + importFiles.path = . + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index e75abac..16e7ec5 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -53,6 +53,11 @@ #include "testtypes.h" #include "testhttpserver.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + /* This test covers evaluation of ECMAScript expressions and bindings from within QML. This does not include static QML language issues. diff --git a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro index 23afd07..7119ad9 100644 --- a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro +++ b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro @@ -4,10 +4,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeengine.cpp -# Define SRCDIR equal to test's source directory -symbian: { - DEFINES += SRCDIR=\".\" -} else { +!symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp index 0aebea1..56ebd73 100644 --- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp +++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp @@ -50,6 +50,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativeengine : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro index fae11f9..29b7149 100644 --- a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro +++ b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro @@ -3,9 +3,7 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativeerror.cpp macx:CONFIG -= app_bundle -symbian: { - DEFINES += SRCDIR=\".\" -} else { +!symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp b/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp index ba1ebae..0279953 100644 --- a/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp +++ b/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp @@ -43,6 +43,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativeerror : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro index 7a70109..be0ba6c 100644 --- a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro +++ b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeflickable.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 2c6890e..2ba5574 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -46,6 +46,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativeflickable : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro index 9b4fbc9..759e80b 100644 --- a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro +++ b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeflipable.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp index f32cdbd..f56c032 100644 --- a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp +++ b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp @@ -48,6 +48,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativeflipable : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro index c021fcf..24749c6 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro +++ b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro @@ -4,9 +4,8 @@ SOURCES += tst_qdeclarativefocusscope.cpp macx:CONFIG -= app_bundle symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index 04bb1c5..7732e6d 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif class tst_qdeclarativefocusscope : public QObject { diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro index 487d0e1..91bf4a7 100644 --- a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativefolderlistmodel.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp index 3cf9613..b2e3a5b 100644 --- a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp @@ -48,6 +48,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + // From qdeclarastivefolderlistmodel.h const int FileNameRole = Qt::UserRole+1; const int FilePathRole = Qt::UserRole+2; diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro index dbe0dcb..01dca26 100644 --- a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro +++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro @@ -5,11 +5,9 @@ macx:CONFIG -= app_bundle HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativefontloader.cpp ../shared/testhttpserver.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp index 36908d9..ae23017 100644 --- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp +++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp @@ -47,6 +47,11 @@ #define SERVER_PORT 14448 +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativefontloader : public QObject { diff --git a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro index 033e20e..a99a1b9 100644 --- a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro +++ b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativegridview.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index fb09d39..9b7c261 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -52,6 +52,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativeGridView : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro index a8b8eca..244a1e1 100644 --- a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro +++ b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro @@ -5,11 +5,9 @@ macx:CONFIG -= app_bundle HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeimage.cpp ../shared/testhttpserver.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 720702a..c09f7fc 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -55,6 +55,10 @@ #include "../shared/testhttpserver.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif #define SERVER_PORT 14451 #define SERVER_ADDR "http://127.0.0.1:14451" diff --git a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro index 1b828a5..bdb6423 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro +++ b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro @@ -8,11 +8,9 @@ SOURCES += tst_qdeclarativeimageprovider.cpp # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index cc4ec20..4185790 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -45,6 +45,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + // QDeclarativeImageProvider::request() is run in an idle thread where possible // Be generous in our timeout. #define TRY_WAIT(expr) \ diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro index c6719c0..2c20e7e 100644 --- a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro +++ b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro @@ -5,9 +5,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeinfo.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp index 36db448..03df71f 100644 --- a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp +++ b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp @@ -46,6 +46,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativeinfo : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro index 350f6c6..c8a48c9 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro +++ b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro @@ -3,9 +3,7 @@ contains(QT_CONFIG,declarative): QT += declarative script SOURCES += tst_qdeclarativeinstruction.cpp macx:CONFIG -= app_bundle -symbian: { - DEFINES += SRCDIR=\".\" -} else { +!symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index 1e88255..d5a911a 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -42,6 +42,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativeinstruction : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro index f494ef1..f4901c4 100644 --- a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro +++ b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro @@ -5,9 +5,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeitem.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index ecc813e..c2d3660 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -47,6 +47,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativeItem : public QObject { diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro index 2b7eb1c..43c451f 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro +++ b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro @@ -12,9 +12,8 @@ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp symbian: { - DEFINES += SRCDIR=\".\"\"\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 011870c..413843a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -55,6 +55,11 @@ #include "../../../shared/util.h" #include "testhttpserver.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES) diff --git a/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro index 79954fe..5076e51 100644 --- a/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro +++ b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro @@ -4,12 +4,10 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelayoutitem.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" -} \ No newline at end of file +} diff --git a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp index c0c5abc..bbdba74 100644 --- a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp +++ b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp @@ -49,6 +49,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativelayoutitem : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro index 53bb9ec..e90db49 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro +++ b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro @@ -5,11 +5,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelistmodel.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index be4ffe8..b3b6c20 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -51,6 +51,11 @@ #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativelistmodel : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro index b406fde..2c5a859 100644 --- a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro +++ b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelistview.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 2aef9bb..7376c00 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -52,6 +52,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativeListView : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro index 9334928..b07bf9e 100644 --- a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro +++ b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro @@ -8,9 +8,8 @@ SOURCES += tst_qdeclarativeloader.cpp \ ../shared/testhttpserver.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 11cc61b..d047a2a 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -50,6 +50,11 @@ #define SERVER_PORT 14450 +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + inline QUrl TEST_FILE(const QString &filename) { return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); diff --git a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro index 0d32ab8..f13250e 100644 --- a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro +++ b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro @@ -3,9 +3,7 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativemetatype.cpp macx:CONFIG -= app_bundle -symbian: { - DEFINES += SRCDIR=\".\" -} else { +!symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp index 76e86c9..8964f8a 100644 --- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp +++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp @@ -54,6 +54,11 @@ #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativemetatype : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index 6d17acc..2081f0e 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -56,6 +56,11 @@ private slots: void importsPlugin(); }; +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + #define VERIFY_ERRORS(errorfile) \ if (!errorfile) { \ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \ diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro index 29a1009..fb3630f 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro @@ -2,10 +2,10 @@ load(qttest_p4) SOURCES = tst_qdeclarativemoduleplugin.cpp QT += declarative CONFIG -= app_bundle + symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro index 6f9c98c..3d39aa8 100644 --- a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro +++ b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro @@ -5,11 +5,9 @@ macx:CONFIG -= app_bundle HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativemousearea.cpp ../shared/testhttpserver.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index ff3bf45..5a10372 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -46,6 +46,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativeMouseArea: public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro index 31172a9..f9ca90f 100644 --- a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro +++ b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeparticles.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp index 093190c..caf69fc 100644 --- a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp +++ b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp @@ -43,6 +43,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativeParticles : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro index 6bef61c..04fd26b 100644 --- a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro +++ b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativepathview.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index dffc7ac..bf1e13a 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -57,6 +57,11 @@ #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativePathView : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro index 99a94bc..3130364 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro +++ b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro @@ -10,9 +10,8 @@ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index 0cc13ad..f1018b2 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -49,6 +49,11 @@ // These don't let normal people run tests! //#include "../network-settings.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativepixmapcache : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro index 2c5b473..5dc7bb8 100644 --- a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro +++ b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro @@ -3,11 +3,9 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativepositioners.cpp macx:CONFIG -= app_bundle -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index e639014..62ec707 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -48,6 +48,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativePositioners : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro index f37d952..4121a33 100644 --- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro +++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro @@ -5,9 +5,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeproperty.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index 53614fe..0ca0e03 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -48,6 +48,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + inline QUrl TEST_FILE(const QString &filename) { QFileInfo fileInfo(__FILE__); diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro index b381a9b..6af6500 100644 --- a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro +++ b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro @@ -4,9 +4,8 @@ SOURCES += tst_qdeclarativeqt.cpp macx:CONFIG -= app_bundle symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 5095be8..06561fa 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -51,6 +51,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativeqt : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro index 51667af..f3ff9ed 100644 --- a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro +++ b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativerepeater.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index e6b2fdd..3cc68f4 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -48,6 +48,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + inline QUrl TEST_FILE(const QString &filename) { return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro index 6b98f1e..872aeb9 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesmoothedanimation.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp index 7cf318a..d9164f6 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp @@ -46,6 +46,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativesmoothedanimation : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro index eb7d793..dff4922 100644 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesmoothedfollow.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp b/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp index ac750d9..b9ac23f 100644 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp @@ -48,6 +48,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativesmoothedfollow : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro index 6ed8924..1c17ba0 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro +++ b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativespringfollow.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp index 8a07d6b..e0e2892 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp +++ b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp @@ -45,6 +45,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativespringfollow : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro index 9cdb884..1462c9a 100644 --- a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro +++ b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro @@ -5,11 +5,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesqldatabase.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp b/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp index 7486a4b..f92d7e8 100644 --- a/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp +++ b/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp @@ -53,6 +53,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativesqldatabase : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro index 6f4ecb3..2bae041 100644 --- a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro +++ b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativestates.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 055a34c..f196837 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -49,6 +49,10 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif class MyRect : public QDeclarativeRectangle { diff --git a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro index 786bc1b..0062688 100644 --- a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro +++ b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro @@ -4,10 +4,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesystempalette.cpp -# Define SRCDIR equal to test's source directory -symbian: { - DEFINES += SRCDIR=\".\" -} else { +!symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp index 7927d97..dd1fd7a 100644 --- a/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp +++ b/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp @@ -47,6 +47,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativesystempalette : public QObject { diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro index 51c7f43..c1a36fd 100644 --- a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro +++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro @@ -10,9 +10,8 @@ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 551e17b..01120b1 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -51,6 +51,11 @@ #include "../../../shared/util.h" #include "testhttpserver.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativetext : public QObject { diff --git a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro index 2adb2b8..4b6bd49 100644 --- a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro +++ b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro @@ -5,11 +5,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetextedit.cpp ../shared/testhttpserver.cpp HEADERS += ../shared/testhttpserver.h -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 053c9ef..f7ba7a1 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -56,6 +56,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativetextedit : public QObject { diff --git a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro index 2953567..8f42448 100644 --- a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro +++ b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetextinput.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index c9de0aa..3143580 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -50,6 +50,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativetextinput : public QObject { diff --git a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro index d95165c..398139a 100644 --- a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro +++ b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro @@ -4,9 +4,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetimer.cpp -symbian: { - DEFINES += SRCDIR=\".\" -} else { +!symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp index da2d173..f49cbd0 100644 --- a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp +++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp @@ -46,6 +46,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativetimer : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro index 02c480c..90e46d3 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro +++ b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro @@ -8,9 +8,8 @@ SOURCES += tst_qdeclarativevaluetypes.cpp \ testtypes.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 5e46fab..237d020 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -46,6 +46,11 @@ #include #include "testtypes.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + extern int qt_defaultDpi(); class tst_qdeclarativevaluetypes : public QObject diff --git a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro index ad54713..21a9195 100644 --- a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro +++ b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro @@ -5,9 +5,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeview.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp index b183105..cc48bd0 100644 --- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp @@ -47,6 +47,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativeView : public QObject { diff --git a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro index 9bb6161..6189916 100644 --- a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro +++ b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro @@ -7,9 +7,8 @@ include(../../../../tools/qml/qml.pri) SOURCES += tst_qdeclarativeviewer.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index f296d9e..49273ea 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -45,6 +45,11 @@ #include #include "qmlruntime.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativeViewer : public QObject { diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro b/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro index c87171b..92e5f60 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro @@ -5,9 +5,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativevisualdatamodel.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index 8f3fb16..90c9c6f 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -52,6 +52,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + static void initStandardTreeModel(QStandardItemModel *model) { QStandardItem *item; diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro index 8caa393..562a9fb 100644 --- a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro +++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro @@ -5,11 +5,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativewebview.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp index beabf86..f33e5a4 100644 --- a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp +++ b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp @@ -50,6 +50,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativewebview : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro index 36b3449..2f8f23d 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro +++ b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro @@ -4,11 +4,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeworkerscript.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index 7a4315a..52c11e9 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -53,6 +53,11 @@ Q_DECLARE_METATYPE(QScriptValue) +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_QDeclarativeWorkerScript : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro index b54f670..619b239 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro @@ -8,11 +8,9 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativexmlhttprequest.cpp \ ../shared/testhttpserver.cpp -# Define SRCDIR equal to test's source directory symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp index 1d26f2c..8141fcb 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp @@ -48,6 +48,11 @@ #define SERVER_PORT 14445 +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + class tst_qdeclarativexmlhttprequest : public QObject { Q_OBJECT diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro index 7c006f1..472cffb 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro +++ b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro @@ -9,9 +9,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativexmllistmodel.cpp symbian: { - DEFINES += SRCDIR=\".\" importFiles.sources = data - importFiles.path = + importFiles.path = . DEPLOYMENT = importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 35790e4..bd19bd3 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -50,6 +50,11 @@ #include #include "../../../shared/util.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + typedef QPair QDeclarativeXmlListRange; typedef QList QDeclarativeXmlModelData; diff --git a/tests/auto/declarative/qmlvisual/qmlvisual.pro b/tests/auto/declarative/qmlvisual/qmlvisual.pro index dca9b04..cb7e5d7 100644 --- a/tests/auto/declarative/qmlvisual/qmlvisual.pro +++ b/tests/auto/declarative/qmlvisual/qmlvisual.pro @@ -5,7 +5,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qmlvisual.cpp symbian: { - importFiles.path = + importFiles.path = . importFiles.sources = animation \ fillmode \ focusscope \ @@ -28,8 +28,6 @@ symbian: { selftest_noimages \ webview DEPLOYMENT = importFiles - - DEFINES += QT_TEST_SOURCE_DIR=\".\" } else { DEFINES += QT_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" } diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index 71dc451..a2d3273 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -47,6 +47,11 @@ #include #include +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define QT_TEST_SOURCE_DIR "." +#endif + enum Mode { Record, RecordNoVisuals, RecordSnapshot, Play, TestVisuals, RemoveVisuals, UpdateVisuals, UpdatePlatformVisuals, Test }; static QString testdir; -- cgit v0.12 From 0656d1578e86a2e9e0e1ec1d3c79e8766415a86d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 8 Jun 2010 10:59:53 +1000 Subject: Add test for PropertyChanges with attached properties. Task-number: QTBUG-11283 --- .../data/attachedPropertyChanges.qml | 20 ++++++++++ .../qdeclarativestates/tst_qdeclarativestates.cpp | 43 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativestates/data/attachedPropertyChanges.qml diff --git a/tests/auto/declarative/qdeclarativestates/data/attachedPropertyChanges.qml b/tests/auto/declarative/qdeclarativestates/data/attachedPropertyChanges.qml new file mode 100644 index 0000000..e17823b --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/attachedPropertyChanges.qml @@ -0,0 +1,20 @@ +import Qt.test 1.0 +import Qt 4.7 + +Item { + id: item + width: 100; height: 100 + MyRectangle.foo: 0 + + states: State { + name: "foo1" + PropertyChanges { + target: item + MyRectangle.foo: 1 + width: 50 + } + } + + Component.onCompleted: item.state = "foo1" +} + diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 055a34c..1ddbe4d 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -50,6 +50,20 @@ #include +class MyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo WRITE setFoo) +public: + MyAttached(QObject *parent) : QObject(parent), m_foo(13) {} + + int foo() const { return m_foo; } + void setFoo(int f) { m_foo = f; } + +private: + int m_foo; +}; + class MyRect : public QDeclarativeRectangle { Q_OBJECT @@ -61,6 +75,10 @@ public: int propertyWithNotify() const { return m_prop; } void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); } + + static MyAttached *qmlAttachedProperties(QObject *o) { + return new MyAttached(o); + } Q_SIGNALS: void didSomething(); void oddlyNamedNotifySignal(); @@ -69,6 +87,8 @@ private: int m_prop; }; +QML_DECLARE_TYPE(MyRect) +QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES) class tst_qdeclarativestates : public QObject { @@ -83,6 +103,7 @@ private slots: void initTestCase(); void basicChanges(); + void attachedPropertyChanges(); void basicExtension(); void basicBinding(); void signalOverride(); @@ -220,6 +241,28 @@ void tst_qdeclarativestates::basicChanges() } } +void tst_qdeclarativestates::attachedPropertyChanges() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent component(&engine, SRCDIR "/data/attachedPropertyChanges.qml"); + QVERIFY(component.isReady()); + + QDeclarativeItem *item = qobject_cast(component.create()); + QVERIFY(item != 0); + QCOMPARE(item->width(), 50.0); + + // Ensure attached property has been changed + QObject *attObj = qmlAttachedPropertiesObject(item, false); + QVERIFY(attObj); + + MyAttached *att = qobject_cast(attObj); + QVERIFY(att); + + QEXPECT_FAIL("", "QTBUG-11283", Abort); + QCOMPARE(att->foo(), 1); +} + void tst_qdeclarativestates::basicExtension() { QDeclarativeEngine engine; -- cgit v0.12 From 31de141d722a2994b98f079b5be91a98cb34a3dc Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 8 Jun 2010 11:36:49 +1000 Subject: Add an example of animated item add/remove in ListView --- .../declarative/modelviews/listview/dynamic.qml | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/examples/declarative/modelviews/listview/dynamic.qml b/examples/declarative/modelviews/listview/dynamic.qml index cf0e387..df2e094 100644 --- a/examples/declarative/modelviews/listview/dynamic.qml +++ b/examples/declarative/modelviews/listview/dynamic.qml @@ -95,6 +95,7 @@ Rectangle { id: fruitDelegate Item { + id: wrapper width: container.width; height: 55 Column { @@ -169,6 +170,38 @@ Rectangle { MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } } + + // Animate adding and removing items + ListView.delayRemove: true // so that the item is not destroyed immediately + ListView.onAdd: state = "add" + ListView.onRemove: state = "remove" + states: [ + State { + name: "add" + PropertyChanges { target: wrapper; height: 55; clip: true } + }, + State { + name: "remove" + PropertyChanges { target: wrapper; height: 0; clip: true } + } + ] + transitions: [ + Transition { + to: "add" + SequentialAnimation { + NumberAnimation { properties: "height"; from: 0; to: 55 } + PropertyAction { target: wrapper; property: "state"; value: "" } + } + }, + Transition { + to: "remove" + SequentialAnimation { + NumberAnimation { properties: "height" } + // Make sure delayRemove is set back to false so that the item can be destroyed + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } + } + } + ] } } -- cgit v0.12 From 436395417fb092dc143d64aea52ad00d7c9b7488 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 8 Jun 2010 16:47:58 +1000 Subject: Don't layout multiple times when an ancestor becomes (in)visible. It is also only necessary to omit positioning an item if it is explicitly not visible. Task-number: QTBUG-11236 --- .../graphicsitems/qdeclarativepositioners.cpp | 18 +++++++++++------- .../graphicsitems/qdeclarativepositioners_p_p.h | 16 ++++++++++------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 20cc46b..18618ab 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -219,6 +219,7 @@ void QDeclarativeBasePositioner::prePositioning() QDeclarativeItem *child = qobject_cast(children.at(ii)); if (!child) continue; + QDeclarativeItemPrivate *childPrivate = static_cast(QGraphicsItemPrivate::get(child)); PositionedItem *item = 0; PositionedItem posItem(child); int wIdx = oldItems.find(posItem); @@ -227,11 +228,13 @@ void QDeclarativeBasePositioner::prePositioning() positionedItems.append(posItem); item = &positionedItems[positionedItems.count()-1]; item->isNew = true; - if (child->opacity() <= 0.0 || !child->isVisible()) + if (child->opacity() <= 0.0 || childPrivate->explicitlyHidden) item->isVisible = false; } else { item = &oldItems[wIdx]; - if (child->opacity() <= 0.0 || !child->isVisible()) { + // Items are only omitted from positioning if they are explicitly hidden + // i.e. their positioning is not affected if an ancestor is hidden. + if (child->opacity() <= 0.0 || childPrivate->explicitlyHidden) { item->isVisible = false; } else if (!item->isVisible) { item->isVisible = true; @@ -299,6 +302,12 @@ void QDeclarativeBasePositioner::finishApplyTransitions() d->moveActions.clear(); } +static inline bool isInvisible(QDeclarativeItem *child) +{ + QDeclarativeItemPrivate *childPrivate = static_cast(QGraphicsItemPrivate::get(child)); + return child->opacity() == 0.0 || childPrivate->explicitlyHidden || !child->width() || !child->height(); +} + /*! \qmlclass Column QDeclarativeColumn \since 4.7 @@ -416,11 +425,6 @@ QDeclarativeColumn::QDeclarativeColumn(QDeclarativeItem *parent) { } -static inline bool isInvisible(QDeclarativeItem *child) -{ - return child->opacity() == 0.0 || !child->isVisible() || !child->width() || !child->height(); -} - void QDeclarativeColumn::doPositioning(QSizeF *contentSize) { int voffset = 0; diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h index 04f0181..822079b 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h @@ -100,18 +100,23 @@ public: bool doingPositioning : 1; bool anchorConflict : 1; - virtual void itemSiblingOrderChanged(QDeclarativeItem* other) + void schedulePositioning() { Q_Q(QDeclarativeBasePositioner); - Q_UNUSED(other); if(!queuedPositioning){ - //Delay is due to many children often being reordered at once - //And we only want to reposition them all once QTimer::singleShot(0,q,SLOT(prePositioning())); queuedPositioning = true; } } + virtual void itemSiblingOrderChanged(QDeclarativeItem* other) + { + Q_UNUSED(other); + //Delay is due to many children often being reordered at once + //And we only want to reposition them all once + schedulePositioning(); + } + void itemGeometryChanged(QDeclarativeItem *, const QRectF &newGeometry, const QRectF &oldGeometry) { Q_Q(QDeclarativeBasePositioner); @@ -120,8 +125,7 @@ public: } virtual void itemVisibilityChanged(QDeclarativeItem *) { - Q_Q(QDeclarativeBasePositioner); - q->prePositioning(); + schedulePositioning(); } virtual void itemOpacityChanged(QDeclarativeItem *) { -- cgit v0.12 From 3e707f559f6f26ab7a5d5623f8e5af9ea9cc317e Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 8 Jun 2010 09:25:04 +0200 Subject: Fix slow network access in qmlviewer (Windows) If no proxy is defined in the preferences, qmlviewer uses systemProxyForQuery to automatically retrieve the proxy settings of the Operating System. However, calling systemProxyForQuery can take several seconds in case Windows to automatically detect proxies (QTBUG-10106). This hot fix therefore just disables querying the OS proxies on Windows. Task-number: QTBUG-11261 Reviewed-by: Warwick Allison --- tools/qml/qmlruntime.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 5b0139f..d95bec2 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -281,7 +281,12 @@ public: ret << httpProxy; return ret; } +#ifdef Q_OS_WIN + // systemProxyForQuery can take insanely long on Windows (QTBUG-10106) + return QNetworkProxyFactory::proxyForQuery(query); +#else return QNetworkProxyFactory::systemProxyForQuery(query); +#endif } void setHttpProxy (QNetworkProxy proxy) { -- cgit v0.12 From a46e97c429077022bc7f426a3adec588643abc57 Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 4 Jun 2010 11:39:07 +0200 Subject: Cursor positioning in QTextDocument after undo() QTextDocument had no way of storing the cursor position from which a document change was initiated in the undo stack. That means that any undo operation would reposition the text cursor to the text position where the actual change happened. This works in many cases, but not always. In Qt Creator we have standard IDE shortcuts like e.g. Ctrl+Return for InsertLineBelowCurrentLine, which insert a newline at the end of the current line, not at the cursor position. Using undo there resulted in a surprisingly wrong cursor position. The problem becomes worse with more advanced refactoring and productivity tools (like snippets). The patch creates a synthetic CursorMoved undo item with the position which was current at the time of calling QTextCursor::beginEditBlock(), but only if necesary, i.e. only in those cases where the cursor would be positioned wrongly. Reviewed-by: Roberto Raggi --- src/gui/text/qtextcursor.cpp | 3 +++ src/gui/text/qtextdocument_p.cpp | 19 +++++++++++++++++++ src/gui/text/qtextdocument_p.h | 2 ++ tests/auto/qtextcursor/tst_qtextcursor.cpp | 18 +++++++++++++++++- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index d6ac3aa..3db66ce 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -2437,6 +2437,9 @@ void QTextCursor::beginEditBlock() if (!d || !d->priv) return; + if (d->priv->editBlock == 0) // we are the initial edit block, store current cursor position for undo + d->priv->editBlockCursorPosition = d->position; + d->priv->beginEditBlock(); } diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index e2bca04..f3cd481 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -192,6 +192,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() initialBlockCharFormatIndex(-1) // set correctly later in init() { editBlock = 0; + editBlockCursorPosition = -1; docChangeFrom = -1; undoState = 0; @@ -967,6 +968,10 @@ int QTextDocumentPrivate::undoRedo(bool undo) editPos = -1; break; } + case QTextUndoCommand::CursorMoved: + editPos = c.pos; + editLength = 0; + break; case QTextUndoCommand::Custom: resetBlockRevision = -1; // ## TODO if (undo) @@ -1046,6 +1051,18 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) if (undoState < undoStack.size()) clearUndoRedoStacks(QTextDocument::RedoStack); + if (editBlock != 0 && editBlockCursorPosition >= 0) { // we had a beginEditBlock() with a cursor position + if (c.pos != (quint32) editBlockCursorPosition) { // and that cursor position is different from the command + // generate a CursorMoved undo item + QT_INIT_TEXTUNDOCOMMAND(cc, QTextUndoCommand::CursorMoved, true, QTextUndoCommand::MoveCursor, + 0, 0, editBlockCursorPosition, 0, 0); + undoStack.append(cc); + undoState++; + editBlockCursorPosition = -1; + } + } + + if (!undoStack.isEmpty() && modified) { QTextUndoCommand &last = undoStack[undoState - 1]; @@ -1167,6 +1184,8 @@ void QTextDocumentPrivate::endEditBlock() } } + editBlockCursorPosition = -1; + finishEdit(); } diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index ac5ed3c..d1bd698 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -132,6 +132,7 @@ public: BlockAdded = 6, BlockDeleted = 7, GroupFormatChange = 8, + CursorMoved = 9, Custom = 256 }; enum Operation { @@ -315,6 +316,7 @@ private: bool modified; int editBlock; + int editBlockCursorPosition; int docChangeFrom; int docChangeOldLength; int docChangeLength; diff --git a/tests/auto/qtextcursor/tst_qtextcursor.cpp b/tests/auto/qtextcursor/tst_qtextcursor.cpp index 99babac..41835bb 100644 --- a/tests/auto/qtextcursor/tst_qtextcursor.cpp +++ b/tests/auto/qtextcursor/tst_qtextcursor.cpp @@ -151,6 +151,7 @@ private slots: void cursorPositionWithBlockUndoAndRedo(); void cursorPositionWithBlockUndoAndRedo2(); + void cursorPositionWithBlockUndoAndRedo3(); private: int blockCount(); @@ -1756,9 +1757,9 @@ void tst_QTextCursor::adjustCursorsOnInsert() void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo() { cursor.insertText("AAAABBBBCCCCDDDD"); - cursor.beginEditBlock(); cursor.setPosition(12); int cursorPositionBefore = cursor.position(); + cursor.beginEditBlock(); cursor.insertText("*"); cursor.setPosition(8); cursor.insertText("*"); @@ -1814,5 +1815,20 @@ void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo2() QCOMPARE(cursor.position(), cursorPositionBefore); } +void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo3() +{ + // verify that it's the position of the beginEditBlock that counts, and not the last edit position + cursor.insertText("AAAABBBB"); + int cursorPositionBefore = cursor.position(); + cursor.beginEditBlock(); + cursor.setPosition(4); + QVERIFY(cursor.position() != cursorPositionBefore); + cursor.insertText("*"); + cursor.endEditBlock(); + QCOMPARE(cursor.position(), 5); + doc->undo(&cursor); + QCOMPARE(cursor.position(), cursorPositionBefore); +} + QTEST_MAIN(tst_QTextCursor) #include "tst_qtextcursor.moc" -- cgit v0.12 From 9623b49fd3055ede03569e6e9a46a4237f6e119f Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 8 Jun 2010 11:30:28 +0200 Subject: Add qmlmethod Item::childAt() to delarative item The method allows for more flexbile mouse and touch handling. It offers a fast way to identify a child item for a given pixel position. --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 24 +++++++++++++++++++++- src/declarative/graphicsitems/qdeclarativeitem.h | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 9949e65..bef09bb 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1633,7 +1633,7 @@ void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty *pro QObject *QDeclarativeItemPrivate::resources_at(QDeclarativeListProperty *prop, int index) { - QObjectList children = prop->object->children(); + const QObjectList children = prop->object->children(); if (index < children.count()) return children.at(index); else @@ -2391,6 +2391,28 @@ void QDeclarativeItem::forceFocus() } } + +/*! + \qmlmethod Item::childAt(real x, real y) + + Returns the visible child item at point (\a x, \a y), which is in this + item's coordinate system, or \c null if there is no such item. + */ +QDeclarativeItem *QDeclarativeItem::childAt(qreal x, qreal y) const +{ + const QList children = childItems(); + for (int i = children.count()-1; i >= 0; --i) { + if (QDeclarativeItem *child = qobject_cast(children.at(i))) { + if (child->isVisible() && child->x() <= x + && child->x() + child->width() >= x + && child->y() <= y + && child->y() + child->height() >= y) + return child; + } + } + return 0; +} + void QDeclarativeItemPrivate::focusChanged(bool flag) { Q_Q(QDeclarativeItem); diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h index 77e316b..4f420f8 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/declarative/graphicsitems/qdeclarativeitem.h @@ -148,6 +148,7 @@ public: Q_INVOKABLE QScriptValue mapFromItem(const QScriptValue &item, qreal x, qreal y) const; Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, qreal x, qreal y) const; Q_INVOKABLE void forceFocus(); + Q_INVOKABLE QDeclarativeItem *childAt(qreal x, qreal y) const; Q_SIGNALS: void childrenChanged(); -- cgit v0.12 From e5567b2e0513f5a03987f78df2d565c0e6c6a951 Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 8 Jun 2010 12:00:17 +0200 Subject: Fix snake demo Code degeneration lead to three bugs: 1. progress bar worked only the first time 2. restart was broken 3. highscore model was not persistent Reviewed-by: Trust me --- demos/declarative/snake/content/HighScoreModel.qml | 2 +- demos/declarative/snake/content/snake.js | 1 + demos/declarative/snake/snake.qml | 12 ++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/demos/declarative/snake/content/HighScoreModel.qml b/demos/declarative/snake/content/HighScoreModel.qml index 99799c8..42482f8 100644 --- a/demos/declarative/snake/content/HighScoreModel.qml +++ b/demos/declarative/snake/content/HighScoreModel.qml @@ -106,7 +106,7 @@ ListModel { } if (rs.rows.length > maxScores) tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?", - [rs.rows.item(maxScores).score]); + [game, rs.rows.item(maxScores).score]); } } ) diff --git a/demos/declarative/snake/content/snake.js b/demos/declarative/snake/content/snake.js index 6f78b33..4d05e33 100644 --- a/demos/declarative/snake/content/snake.js +++ b/demos/declarative/snake/content/snake.js @@ -37,6 +37,7 @@ function startNewGame() startNewGameTimer.running = true; return; } + numRows = numRowsAvailable; numColumns = numColumnsAvailable; board = new Array(numRows * numColumns); diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml index 565e92c..46114f5 100644 --- a/demos/declarative/snake/snake.qml +++ b/demos/declarative/snake/snake.qml @@ -86,7 +86,7 @@ Rectangle { onTriggered: { Logic.moveSkull() } } Timer { - + id: startNewGameTimer; interval: 700; onTriggered: { Logic.startNewGame(); } } @@ -177,7 +177,6 @@ Rectangle { id: progressIndicator color: "#221edd"; width: 0; - Behavior on width { NumberAnimation { duration: startHeartbeatTimer.running ? 1000 : 0}} height: 30; } } @@ -227,4 +226,13 @@ Rectangle { } ] + transitions: [ + Transition { + from: "*" + to: "starting" + NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } + + } + ] + } -- cgit v0.12 From 5c6501970c7b6805b7edc30f90187700f05d9f15 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 9 Jun 2010 11:51:29 +1000 Subject: Fix drawing flicker on Qml Viewer startup Task-number: QTBUG-10251 and QTBUG-11156 Reviewed-by: Martin Jones --- src/declarative/QmlChanges.txt | 2 + src/declarative/util/qdeclarativeview.cpp | 20 ++- src/declarative/util/qdeclarativeview.h | 1 + .../qdeclarativeview/tst_qdeclarativeview.cpp | 5 + .../qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 187 +++++++++++++++++++++ tools/qml/qmlruntime.cpp | 7 +- 6 files changed, 214 insertions(+), 8 deletions(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 5735b1e..8b6b83f 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,6 +1,8 @@ ============================================================================= The changes below are pre Qt 4.7.0 RC +QDeclarativeView + - initialSize() function added TextInput and TextEdit: - openSoftwareInputPanel() and closeSoftwareInputPanel() functions added Flickable: diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 6059ad6..0414e65 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -131,7 +131,7 @@ class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarative Q_DECLARE_PUBLIC(QDeclarativeView) public: QDeclarativeViewPrivate() - : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {} + : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject), initialSize(0,0) {} ~QDeclarativeViewPrivate() { delete root; } void execute(); void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); @@ -150,6 +150,7 @@ public: QBasicTimer resizetimer; QDeclarativeView::ResizeMode resizeMode; + QSize initialSize; QElapsedTimer frameTimer; void init(); @@ -586,9 +587,11 @@ void QDeclarativeView::setRootObject(QObject *obj) } if (d->root) { - QSize initialSize = d->rootObjectSize(); - if (initialSize != size()) { - resize(initialSize); + d->initialSize = d->rootObjectSize(); + if (d->initialSize != size()) { + if (!(parentWidget() && parentWidget()->layout())) { + resize(d->initialSize); + } } d->initResize(); } @@ -638,6 +641,15 @@ QSize QDeclarativeView::sizeHint() const } /*! + Returns the initial size of the root object +*/ +QSize QDeclarativeView::initialSize() const +{ + Q_D(const QDeclarativeView); + return d->initialSize; +} + +/*! Returns the view's root \l {QGraphicsObject} {item}. */ QGraphicsObject *QDeclarativeView::rootObject() const diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h index e9cff32..cdcf134 100644 --- a/src/declarative/util/qdeclarativeview.h +++ b/src/declarative/util/qdeclarativeview.h @@ -90,6 +90,7 @@ public: QList errors() const; QSize sizeHint() const; + QSize initialSize() const; Q_SIGNALS: void sceneResized(QSize size); // ??? diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp index cc48bd0..6450e38 100644 --- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp @@ -80,6 +80,7 @@ void tst_QDeclarativeView::resizemodedeclarativeitem() QVERIFY(canvas); QSignalSpy sceneResizedSpy(canvas, SIGNAL(sceneResized(QSize))); canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); + QCOMPARE(QSize(0,0), canvas->initialSize()); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml")); QDeclarativeItem* declarativeItem = qobject_cast(canvas->rootObject()); QVERIFY(declarativeItem); @@ -90,6 +91,7 @@ void tst_QDeclarativeView::resizemodedeclarativeitem() QCOMPARE(declarativeItem->height(), 200.0); QCOMPARE(canvas->size(), QSize(200, 200)); QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(canvas->size(), canvas->initialSize()); QCOMPARE(sceneResizedSpy.count(), 1); // size update from view @@ -135,6 +137,7 @@ void tst_QDeclarativeView::resizemodedeclarativeitem() QCOMPARE(declarativeItem->width(), 200.0); QCOMPARE(declarativeItem->height(), 200.0); QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(canvas->size(), canvas->initialSize()); QCOMPARE(sceneResizedSpy2.count(), 1); // size update from root object @@ -184,6 +187,7 @@ void tst_QDeclarativeView::resizemodegraphicswidget() QCOMPARE(canvas->size(), QSize(200, 200)); QCOMPARE(canvas->size(), QSize(200, 200)); QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(canvas->size(), canvas->initialSize()); QCOMPARE(sceneResizedSpy.count(), 1); // size update from view @@ -223,6 +227,7 @@ void tst_QDeclarativeView::resizemodegraphicswidget() QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 200.0)); QCOMPARE(canvas->size(), QSize(200, 200)); QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(canvas->size(), canvas->initialSize()); QCOMPARE(sceneResizedSpy2.count(), 1); // size update from root object diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 49273ea..91b7cf8 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -59,6 +59,11 @@ public: private slots: void orientation(); + void loading(); + void fileBrowser(); + void resizing(); + void paths(); + void slowMode(); private: QDeclarativeEngine engine; @@ -108,6 +113,188 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(viewer->size(), viewer->sizeHint()); } +void tst_QDeclarativeViewer::loading() +{ + QDeclarativeViewer *viewer = new QDeclarativeViewer(); + QVERIFY(viewer); + viewer->setSizeToView(true); + viewer->open(SRCDIR "/data/orientation.qml"); + QVERIFY(viewer->view()); + QVERIFY(viewer->menuBar()); + QDeclarativeItem* rootItem = qobject_cast(viewer->view()->rootObject()); + QVERIFY(rootItem); + viewer->show(); + + // initial size + QCOMPARE(rootItem->width(), 200.0); + QCOMPARE(rootItem->height(), 300.0); + QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); + QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + viewer->resize(QSize(400, 500)); + qApp->processEvents(); + + // window resized + QCOMPARE(rootItem->width(), 400.0); + QCOMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); + QCOMPARE(viewer->view()->size(), QSize(400, 500-viewer->menuBar()->height())); + QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500-viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(400, 500)); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + viewer->reload(); + rootItem = qobject_cast(viewer->view()->rootObject()); + QVERIFY(rootItem); + + // reload cause the window to return back to initial size + QCOMPARE(rootItem->width(), 200.0); + QCOMPARE(rootItem->height(), 300.0); + QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); + QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + viewer->resize(QSize(400, 500)); + qApp->processEvents(); + + // window resized again + QCOMPARE(rootItem->width(), 400.0); + QCOMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); + QCOMPARE(viewer->view()->size(), QSize(400, 500-viewer->menuBar()->height())); + QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500-viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(400, 500)); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + viewer->open(SRCDIR "/data/orientation.qml"); + rootItem = qobject_cast(viewer->view()->rootObject()); + QVERIFY(rootItem); + + // open also causes the window to return back to initial size + QCOMPARE(rootItem->width(), 200.0); + QCOMPARE(rootItem->height(), 300.0); + QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); + QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); +} + +void tst_QDeclarativeViewer::fileBrowser() +{ + QDeclarativeViewer *viewer = new QDeclarativeViewer(); + QVERIFY(viewer); + viewer->setUseNativeFileBrowser(false); + viewer->openFile(); + viewer->show(); + + // Browser.qml successfully loaded + QDeclarativeItem* browserItem = qobject_cast(viewer->view()->rootObject()); + QVERIFY(viewer->view()); + QVERIFY(viewer->menuBar()); + QVERIFY(browserItem); + + // load something + viewer->open(SRCDIR "/data/orientation.qml"); + QVERIFY(viewer->view()); + QVERIFY(viewer->menuBar()); + QDeclarativeItem* rootItem = qobject_cast(viewer->view()->rootObject()); + QVERIFY(rootItem); + QVERIFY(browserItem != rootItem); + + // go back to Browser.qml + viewer->openFile(); + browserItem = qobject_cast(viewer->view()->rootObject()); + QVERIFY(viewer->view()); + QVERIFY(viewer->menuBar()); + QVERIFY(browserItem); +} + +void tst_QDeclarativeViewer::resizing() +{ + QDeclarativeViewer *viewer = new QDeclarativeViewer(); + QVERIFY(viewer); + viewer->open(SRCDIR "/data/orientation.qml"); + QVERIFY(viewer->view()); + QVERIFY(viewer->menuBar()); + QDeclarativeItem* rootItem = qobject_cast(viewer->view()->rootObject()); + QVERIFY(rootItem); + viewer->show(); + + // initial size + QCOMPARE(rootItem->width(), 200.0); + QCOMPARE(rootItem->height(), 300.0); + QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); + QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + viewer->setSizeToView(false); + + // size view to root object + rootItem->setWidth(100); + rootItem->setHeight(200); + qApp->processEvents(); + + QCOMPARE(rootItem->width(), 100.0); + QCOMPARE(rootItem->height(), 200.0); + QCOMPARE(viewer->view()->size(), QSize(100, 200)); + QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(100, 200)); + QCOMPARE(viewer->size(), QSize(100, 200+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + // do not size root object to view + viewer->resize(QSize(150,250)); + QCOMPARE(rootItem->width(), 100.0); + QCOMPARE(rootItem->height(), 200.0); + + viewer->setSizeToView(true); + + // size root object to view + viewer->resize(QSize(250,350)); + qApp->processEvents(); + + QCOMPARE(rootItem->width(), 250.0); + QCOMPARE(rootItem->height(), 350.0-viewer->menuBar()->height()); + QCOMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height())); + QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350-viewer->menuBar()->height())); + QCOMPARE(viewer->size(), QSize(250, 350)); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + // do not size view to root object + rootItem->setWidth(100); + rootItem->setHeight(200); + QCOMPARE(viewer->size(), QSize(250, 350)); +} + +void tst_QDeclarativeViewer::paths() +{ + QDeclarativeViewer *viewer = new QDeclarativeViewer(); + QVERIFY(viewer); + + viewer->addLibraryPath("miscImportPath"); + viewer->view()->engine()->importPathList().contains("miscImportPath"); + + viewer->addPluginPath("miscPluginPath"); + viewer->view()->engine()->pluginPathList().contains("miscPluginPath"); +} + +void tst_QDeclarativeViewer::slowMode() +{ + QDeclarativeViewer *viewer = new QDeclarativeViewer(); + QVERIFY(viewer); + + viewer->setSlowMode(true); + viewer->setSlowMode(false); +} + QTEST_MAIN(tst_QDeclarativeViewer) #include "tst_qdeclarativeviewer.moc" diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index d95bec2..676881d 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -804,11 +804,11 @@ void QDeclarativeViewer::statusChanged() tester->executefailure(); if (canvas->status() == QDeclarativeView::Ready) { - initialSize = canvas->sizeHint(); + initialSize = canvas->initialSize(); if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { - updateSizeHints(); if (!isFullScreen() && !isMaximized()) { resize(QSize(initialSize.width(), initialSize.height()+menuBarHeight())); + updateSizeHints(); } } } @@ -941,7 +941,7 @@ void QDeclarativeViewer::sceneResized(QSize size) if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { updateSizeHints(); } - } + } } void QDeclarativeViewer::keyPressEvent(QKeyEvent *event) @@ -1264,7 +1264,6 @@ void QDeclarativeViewer::updateSizeHints() setMinimumSize(QSize(0,0)); setMaximumSize(QSize(16777215,16777215)); } - updateGeometry(); } void QDeclarativeViewer::registerTypes() -- cgit v0.12 From 5ba8d0703d1b8388679473da1311e368ed0c3086 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 9 Jun 2010 14:15:56 +1000 Subject: Fixed `nmake clean' breaking declarative imports on Windows. Generally, doing a `clean' ought to clean up space by deleting intermediate objects, but leave the build in a working state (as opposed to `distclean' which deletes intermediate and target objects). For this to work for declarative imports, the qmldir file should be treated as a target, not an intermediate object. --- src/imports/qimportbase.pri | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/imports/qimportbase.pri b/src/imports/qimportbase.pri index 91f6552..02364af 100644 --- a/src/imports/qimportbase.pri +++ b/src/imports/qimportbase.pri @@ -17,6 +17,8 @@ copy2build.output = $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} copy2build.name = COPY ${QMAKE_FILE_IN} copy2build.CONFIG += no_link +# `clean' should leave the build in a runnable state, which means it shouldn't delete qmldir +copy2build.CONFIG += no_clean QMAKE_EXTRA_COMPILERS += copy2build TARGET = $$qtLibraryTarget($$TARGET) -- cgit v0.12 From cd05d3ec57a9e1de604933201530ee0a81d12a39 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 9 Jun 2010 14:39:28 +1000 Subject: Fix autotest. --- .../declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 237d020..81334f2 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -51,7 +51,9 @@ #define SRCDIR "." #endif +QT_BEGIN_NAMESPACE extern int qt_defaultDpi(); +QT_END_NAMESPACE class tst_qdeclarativevaluetypes : public QObject { -- cgit v0.12 From 17fcc84e5ebcf09f80a4bbebafde913d0422a91e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 9 Jun 2010 16:18:33 +1000 Subject: Small optimization when checking if MouseArea's onPressAndHold is being used. --- src/declarative/graphicsitems/qdeclarativemousearea.cpp | 2 +- src/declarative/graphicsitems/qdeclarativemousearea_p_p.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index 6fca283..a68e664 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -410,7 +410,7 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) setHovered(true); d->startScene = event->scenePos(); // we should only start timer if pressAndHold is connected to. - if (d->isConnected("pressAndHold(QDeclarativeMouseEvent*)")) + if (d->isPressAndHoldConnected()) d->pressAndHoldTimer.start(PressAndHoldDelay, this); setKeepMouseGrab(false); event->setAccepted(setPressed(true)); diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h index 4e909ff..3d7bd1e 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h @@ -88,9 +88,9 @@ public: lastModifiers = event->modifiers(); } - bool isConnected(const char *signal) { + bool isPressAndHoldConnected() { Q_Q(QDeclarativeMouseArea); - int idx = QObjectPrivate::get(q)->signalIndex(signal); + static int idx = QObjectPrivate::get(q)->signalIndex("pressAndHold(QDeclarativeMouseEvent*)"); return QObjectPrivate::get(q)->isSignalConnected(idx); } -- cgit v0.12 From 22d7c82b71f34df637efd0ed39b3d63719a2bf67 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 9 Jun 2010 16:29:14 +1000 Subject: Fix GridView bounds behavior with snapping enabled. Task-number: QTBUG-11299 --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 82c69a0..538bc69 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -261,12 +261,19 @@ public: return -1; // Not in visibleList } - qreal snapPosAt(qreal pos) { + qreal snapPosAt(qreal pos) const { + Q_Q(const QDeclarativeGridView); qreal snapPos = 0; if (!visibleItems.isEmpty()) { pos += rowSize()/2; snapPos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize(); snapPos = pos - fmodf(pos - snapPos, qreal(rowSize())); + qreal maxExtent = flow == QDeclarativeGridView::LeftToRight ? -q->maxYExtent() : -q->maxXExtent(); + qreal minExtent = flow == QDeclarativeGridView::LeftToRight ? -q->minYExtent() : -q->minXExtent(); + if (snapPos > maxExtent) + snapPos = maxExtent; + if (snapPos < minExtent) + snapPos = minExtent; } return snapPos; } @@ -901,7 +908,6 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m } } else if (snapMode != QDeclarativeGridView::NoSnap) { qreal pos = -snapPosAt(-(data.move.value() - highlightRangeStart)) + highlightRangeStart; - pos = qMin(qMax(pos, maxExtent), minExtent); qreal dist = qAbs(data.move.value() - pos); if (dist > 0) { timeline.reset(data.move); @@ -923,7 +929,6 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity) { Q_Q(QDeclarativeGridView); - moveReason = Mouse; if ((!haveHighlightRange || highlightRange != QDeclarativeGridView::StrictlyEnforceRange) && snapMode == QDeclarativeGridView::NoSnap) { @@ -968,9 +973,10 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m qreal accel = deceleration; qreal v2 = v * v; qreal overshootDist = 0.0; - if (maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) { + if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarativeGridView::SnapOneRow) { // + rowSize()/4 to encourage moving at least one item in the flick direction qreal dist = v2 / (accel * 2.0) + rowSize()/4; + dist = qMin(dist, maxDistance); if (v > 0) dist = -dist; data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart; @@ -1826,7 +1832,7 @@ qreal QDeclarativeGridView::maxXExtent() const if (d->highlightRangeEnd != d->highlightRangeStart) extent = qMin(extent, -(d->endPosition() - d->highlightRangeEnd + 1)); } else { - extent = -(d->endPosition() - height()); + extent = -(d->endPosition() - width()); } if (d->footer) extent -= d->footer->item->width(); -- cgit v0.12 From 96032bd846c7188ce2655d2402c7a745e91a5168 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 10 Jun 2010 09:32:20 +1000 Subject: Fix crash when changing ListView model with highlightRangeMode: ListView.StrictlyEnforceRange Task-number: QTBUG-11328 --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 8 ++++++-- src/declarative/graphicsitems/qdeclarativelistview.cpp | 8 ++++++-- .../declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp | 7 +++++++ .../declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 8 ++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 538bc69..0609a48 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1791,7 +1791,9 @@ qreal QDeclarativeGridView::maxYExtent() const if (d->flow == QDeclarativeGridView::TopToBottom) return QDeclarativeFlickable::maxYExtent(); qreal extent; - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { + if (!d->model || !d->model->count()) { + extent = 0; + } else if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { extent = -(d->rowPosAt(d->model->count()-1) - d->highlightRangeStart); if (d->highlightRangeEnd != d->highlightRangeStart) extent = qMin(extent, -(d->endPosition() - d->highlightRangeEnd + 1)); @@ -1827,7 +1829,9 @@ qreal QDeclarativeGridView::maxXExtent() const if (d->flow == QDeclarativeGridView::LeftToRight) return QDeclarativeFlickable::maxXExtent(); qreal extent; - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { + if (!d->model || !d->model->count()) { + extent = 0; + } if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { extent = -(d->rowPosAt(d->model->count()-1) - d->highlightRangeStart); if (d->highlightRangeEnd != d->highlightRangeStart) extent = qMin(extent, -(d->endPosition() - d->highlightRangeEnd + 1)); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index f2cc971..3f2b4ce 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -2248,7 +2248,9 @@ qreal QDeclarativeListView::maxYExtent() const if (d->orient == QDeclarativeListView::Horizontal) return height(); if (d->maxExtentDirty) { - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { + if (!d->model || !d->model->count()) { + d->maxExtent = 0; + } else if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { d->maxExtent = -(d->positionAt(d->model->count()-1) - d->highlightRangeStart); if (d->highlightRangeEnd != d->highlightRangeStart) d->maxExtent = qMin(d->maxExtent, -(d->endPosition() - d->highlightRangeEnd + 1)); @@ -2290,7 +2292,9 @@ qreal QDeclarativeListView::maxXExtent() const if (d->orient == QDeclarativeListView::Vertical) return width(); if (d->maxExtentDirty) { - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { + if (!d->model || !d->model->count()) { + d->maxExtent = 0; + } else if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { d->maxExtent = -(d->positionAt(d->model->count()-1) - d->highlightRangeStart); if (d->highlightRangeEnd != d->highlightRangeStart) d->maxExtent = qMin(d->maxExtent, -(d->endPosition() - d->highlightRangeEnd + 1)); diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 9b7c261..4e35bc0 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -1110,6 +1110,13 @@ void tst_QDeclarativeGridView::enforceRange() gridview->setCurrentIndex(5); QTRY_COMPARE(gridview->contentY(), 100.); + TestModel model2; + for (int i = 0; i < 5; i++) + model2.addItem("Item" + QString::number(i), ""); + + ctxt->setContextProperty("testModel", &model2); + QCOMPARE(gridview->count(), 5); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 7376c00..cd42b63 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -807,6 +807,14 @@ void tst_QDeclarativeListView::enforceRange() QTRY_COMPARE(listview->currentIndex(), 6); + // change model + TestModel model2; + for (int i = 0; i < 5; i++) + model2.addItem("Item" + QString::number(i), ""); + + ctxt->setContextProperty("testModel", &model2); + QCOMPARE(listview->count(), 5); + delete canvas; } -- cgit v0.12 From ce8a3100868e2c545d0af3332e9b801c1fd0bc3f Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 8 Jun 2010 10:50:07 +1000 Subject: Move some example code into snippets/ and add other doc fixes --- doc/src/declarative/animation.qdoc | 149 ++++----------------- doc/src/declarative/qdeclarativestates.qdoc | 52 ++----- doc/src/snippets/declarative/anchorchanges.qml | 28 ++++ doc/src/snippets/declarative/animation.qml | 141 +++++++++++++++++++ doc/src/snippets/declarative/createQmlObject.qml | 4 +- doc/src/snippets/declarative/state.qml | 29 ++++ doc/src/snippets/declarative/states.qml | 41 ++++++ src/declarative/qml/qdeclarativecomponent.cpp | 2 +- src/declarative/qml/qdeclarativeengine.cpp | 11 +- .../util/qdeclarativepropertychanges.cpp | 6 +- src/declarative/util/qdeclarativestate.cpp | 34 ++++- src/declarative/util/qdeclarativestategroup.cpp | 4 +- .../util/qdeclarativestateoperations.cpp | 32 ++--- 13 files changed, 329 insertions(+), 204 deletions(-) create mode 100644 doc/src/snippets/declarative/anchorchanges.qml create mode 100644 doc/src/snippets/declarative/animation.qml create mode 100644 doc/src/snippets/declarative/state.qml create mode 100644 doc/src/snippets/declarative/states.qml diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index 6e98949..c320898 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -46,14 +46,14 @@ Animation in QML is done by animating properties of objects. Properties of type real, int, color, rect, point, size, and vector3d can all be animated. -QML supports three main forms of animation - basic property animation, +QML supports three main forms of animation: basic property animation, transitions, and property behaviors. \tableofcontents \section1 Basic Property Animation -The simplest form of animation is directly using \l PropertyAnimation, which can animate all of the property +The simplest form of animation is a \l PropertyAnimation, which can animate all of the property types listed above. If the property you are animating is a number or color, you can alternatively use NumberAnimation or ColorAnimation. These elements don't add any additional functionality, but will help enforce type correctness and are slightly more efficient. @@ -62,61 +62,23 @@ A property animation can be specified as a value source using the \e Animation \ for repeating animations. The following example creates a bouncing effect: -\qml -Rectangle { - id: rect - width: 120; height: 200; - Image { - id: img - source: "qt-logo.png" - x: 60-img.width/2 - y: 0 - SequentialAnimation on y { - loops: Animation.Infinite - NumberAnimation { to: 200-img.height; easing.type: Easing.OutBounce; duration: 2000 } - PauseAnimation { duration: 1000 } - NumberAnimation { to: 0; easing.type: Easing.OutQuad; duration: 1000 } - } - } -} -\endqml +\snippet doc/src/snippets/declarative/animation.qml property-anim-1 \image propanim.gif When you assign an animation as a value source, you do not need to specify \c property -or \c target; they are automatically selected for you. You do, however, need to specify \c to. +or \c target values; they are automatically selected for you. You do, however, need to specify a \c to value. An animation specified as a value source will be \c running by default. -\qml -Rectangle { - id: rect - width: 200; height: 200; - Rectangle { - color: "red" - width: 50; height: 50 - NumberAnimation on x { to: 50 } - } -} -\endqml +For example, here is a rectangle that uses a \l NumberAnimation value source to animate the movement +from its current position to an \c x value of 50. The animation starts immediately, and only the \c to +property is required: + +\snippet doc/src/snippets/declarative/animation.qml property-anim-2 A property animation can also be specified as a resource that is manipulated from script. -\qml -PropertyAnimation { - id: animation - target: image - property: "scale" - from: 1; to: .5 -} -Image { - id: image - source: "image.png" - MouseArea { - anchors.fill: parent - onPressed: animation.start() - } -} -\endqml +\snippet doc/src/snippets/declarative/animation.qml property-anim-3 As can be seen, when an animation is used like this (as opposed to as a value source) you will need to explicitly set the \c target and \c property to animate. @@ -131,50 +93,20 @@ can only be triggered by a state change. For example, a transition could describe how an item moves from its initial position to its new position: -\code -transitions: [ - Transition { - NumberAnimation { - properties: "x,y" - easing.type: Easing.OutBounce - duration: 200 - } - } -] -\endcode +\snippet doc/src/snippets/declarative/animation.qml transitions-1 As can be seen, transitions make use of the same basic animation classes introduced above. In the above example we have specified that we want to animate the \c x and \c y properties, but have not -specified the objects to animate or the \c to values. By default these values are supplied by the framework -- +specified the objects to animate or the \c to values. By default these values are supplied by the framework; the animation will animate any \c targets whose \c x and \c y have changed, and the \c to values will be those defined in the end state. You can always supply explicit values to override these implicit values when needed. -\code -Transition { - from: "*" - to: "MyState" - reversible: true - SequentialAnimation { - NumberAnimation { - duration: 1000 - easing.type: Easing.OutBounce - // animate myItem's x and y if they have changed in the state - target: myItem - properties: "x,y" - } - NumberAnimation { - duration: 1000 - // animate myItem2's y to 200, regardless of what happens in the state - target: myItem2 - property: "y" - to: 200 - } - } -} -\endcode +\snippet doc/src/snippets/declarative/animation.qml transitions-2 QML transitions have selectors to determine which state changes a transition should apply to. The following transition will only be triggered when we enter into the \c "details" state. +(The "*" value is a wildcard value that specifies the transition should be applied when changing +from \e any state to the "details" state.) \code Transition { @@ -188,30 +120,7 @@ Transitions can happen in parallel, in sequence, or in any combination of the tw animations in a transition will happen in parallel. The following example shows a rather complex transition making use of both sequential and parallel animations: -\code -Transition { - from: "*" - to: "MyState" - reversible: true - SequentialAnimation { - ColorAnimation { duration: 1000 } - PauseAnimation { duration: 1000 } - ParallelAnimation { - NumberAnimation { - duration: 1000 - easing.type: Easing.OutBounce - targets: box1 - properties: "x,y" - } - NumberAnimation { - duration: 1000 - targets: box2 - properties: "x,y" - } - } - } -} -\endcode +\snippet doc/src/snippets/declarative/animation.qml transitions-3 \section1 Property Behaviors @@ -219,24 +128,15 @@ A \l{Behavior}{property behavior} specifies a default animation to run whenever of what caused the change. The \c enabled property can be used to force a \l Behavior to only apply under certain circumstances. -In the following snippet, we specify that we want the x position of redRect to be animated -whenever it changes. The animation will last 300 milliseconds and use an InOutQuad easing curve. +In the following snippet, we specify that we want the \c x position of \c redRect to be animated +whenever it changes. The animation will last 300 milliseconds and use an \l{PropertyAnimation::easing.type}{Easing.InOutQuad} easing curve. -\qml -Rectangle { - id: redRect - color: "red" - width: 100; height: 100 - Behavior on x { NumberAnimation { duration: 300; easing.type: Easing.InOutQuad } } -} -\endqml +\snippet doc/src/snippets/declarative/animation.qml behavior Like using an animation as a value source, when used in a Behavior and animation does not need to specify a \c target or \c property. -To trigger this behavior, we could: -\list -\o Enter a state that changes x +To trigger this behavior, we could enter a state that changes \c x: \qml State { @@ -249,7 +149,7 @@ State { } \endqml -\o Update x from a script +Or, update \c x from a script: \qml MouseArea { @@ -257,11 +157,10 @@ MouseArea { onClicked: redRect.x = 24; } \endqml -\endlist -If x were bound to another property, triggering the binding would also trigger the behavior. +If \c x were bound to another property, triggering the binding would also trigger the behavior. -If a state change has a transition animation matching a property with a Behavior, the transition animation -will override the Behavior for that state change. +If a state change has a transition animation matching a property with a \l Behavior, the transition animation +will override the \l Behavior for that state change. */ diff --git a/doc/src/declarative/qdeclarativestates.qdoc b/doc/src/declarative/qdeclarativestates.qdoc index fd0c677..43b5c31 100644 --- a/doc/src/declarative/qdeclarativestates.qdoc +++ b/doc/src/declarative/qdeclarativestates.qdoc @@ -70,58 +70,30 @@ In QML: \o A state can affect the properties of other objects, not just the object owning the state (and not just that object's children). \endlist +To define a state for an item, add a \l State element to the \l{Item::states}{states} property. To +change the current state of an \l Item, set the \l{Item::state}{state} property to the name +of the required state. + Here is an example of using states. In the default state \c myRect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. Clicking within the mouse area changes the state from the default state to the 'moved' state, thus moving the rectangle. -\qml -Item { - id: myItem - - Rectangle { - id: myRect - width: 100 - height: 100 - color: "red" - } - - states: [ - State { - name: "moved" - PropertyChanges { - target: myRect - x: 50 - y: 50 - } - } - ] - - MouseArea { - anchors.fill: parent - onClicked: myItem.state = 'moved' - } -} -\endqml +\snippet doc/src/snippets/declarative/states.qml 0 +\snippet doc/src/snippets/declarative/states.qml 1 State changes can be animated using \l{state-transitions}{Transitions}. -For example, adding this code to the above \c {Item {}} element animates the transition to the "moved" state: +For example, adding this code to the above \c Item element animates the transition to the "moved" state: -\qml - transitions: [ - Transition { - NumberAnimation { properties: "x,y"; duration: 500 } - } - ] -\endqml +\snippet doc/src/snippets/declarative/states.qml transitions See \l{state-transitions}{Transitions} for more information. Other things you can do in a state change: \list -\o override signal handlers with PropertyChanges -\o change an item's visual parent with ParentChange -\o change an item's anchors with AnchorChanges -\o run some script with StateChangeScript +\o Override signal handlers with PropertyChanges +\o Change an item's visual parent with ParentChange +\o Change an item's anchors with AnchorChanges +\o Run some script with StateChangeScript \endlist */ diff --git a/doc/src/snippets/declarative/anchorchanges.qml b/doc/src/snippets/declarative/anchorchanges.qml new file mode 100644 index 0000000..6c0a0ad --- /dev/null +++ b/doc/src/snippets/declarative/anchorchanges.qml @@ -0,0 +1,28 @@ +//![0] +import Qt 4.7 + +Item { + id: window + width: 200; height: 200 + + Rectangle { id: myRect; width: 100; height: 100; color: "red" } + + states: State { + name: "reanchored" + + AnchorChanges { + target: myRect + anchors.top: window.top + anchors.bottom: window.bottom + } + PropertyChanges { + target: myRect + anchors.topMargin: 3 + anchors.bottomMargin: 3 + } + } + + MouseArea { anchors.fill: parent; onClicked: window.state = "reanchored" } +} +//![0] + diff --git a/doc/src/snippets/declarative/animation.qml b/doc/src/snippets/declarative/animation.qml new file mode 100644 index 0000000..f5c6bf6 --- /dev/null +++ b/doc/src/snippets/declarative/animation.qml @@ -0,0 +1,141 @@ +import Qt 4.7 + +Row { + +//![property-anim-1] +Rectangle { + id: rect + width: 120; height: 200 + + Image { + id: img + source: "pics/qt.png" + x: 60 - img.width/2 + y: 0 + + SequentialAnimation on y { + loops: Animation.Infinite + NumberAnimation { to: 200 - img.height; easing.type: Easing.OutBounce; duration: 2000 } + PauseAnimation { duration: 1000 } + NumberAnimation { to: 0; easing.type: Easing.OutQuad; duration: 1000 } + } + } +} +//![property-anim-1] + +//![property-anim-2] +Rectangle { + width: 200; height: 200 + + Rectangle { + color: "red" + width: 50; height: 50 + NumberAnimation on x { to: 50 } + } +} +//![property-anim-2] + + +Item { +//![property-anim-3] +PropertyAnimation { + id: animation + target: image + property: "scale" + from: 1; to: 0.5 +} + +Image { + id: image + source: "pics/qt.png" + MouseArea { + anchors.fill: parent + onPressed: animation.start() + } +} +//![property-anim-3] +} + + +//![transitions-1] +transitions: [ + Transition { + NumberAnimation { + properties: "x,y" + easing.type: Easing.OutBounce + duration: 200 + } + } +] +//![transitions-1] + + +//![transitions-2] +Transition { + from: "*" + to: "MyState" + reversible: true + + SequentialAnimation { + NumberAnimation { + duration: 1000 + easing.type: Easing.OutBounce + + // animate myItem's x and y if they have changed in the state + target: myItem + properties: "x,y" + } + + NumberAnimation { + duration: 1000 + + // animate myItem2's y to 200, regardless of what happens in the state + target: myItem2 + property: "y" + to: 200 + } + } +} +//![transitions-2] + + +//![transitions-3] +Transition { + from: "*" + to: "MyState" + reversible: true + + SequentialAnimation { + ColorAnimation { duration: 1000 } + PauseAnimation { duration: 1000 } + + ParallelAnimation { + NumberAnimation { + duration: 1000 + easing.type: Easing.OutBounce + targets: box1 + properties: "x,y" + } + NumberAnimation { + duration: 1000 + targets: box2 + properties: "x,y" + } + } + } +} +//![transitions-3] + +//![behavior] +Rectangle { + id: redRect + color: "red" + width: 100; height: 100 + + Behavior on x { + NumberAnimation { duration: 300; easing.type: Easing.InOutQuad } + } +} +//![behavior] + +} diff --git a/doc/src/snippets/declarative/createQmlObject.qml b/doc/src/snippets/declarative/createQmlObject.qml index f2ac6e6..f274e40 100644 --- a/doc/src/snippets/declarative/createQmlObject.qml +++ b/doc/src/snippets/declarative/createQmlObject.qml @@ -42,7 +42,7 @@ import Qt 4.7 Rectangle { - id: targetItem + id: parentItem property QtObject newObject width: 100 @@ -51,7 +51,7 @@ Rectangle { function createIt() { //![0] newObject = Qt.createQmlObject('import Qt 4.7; Rectangle {color: "red"; width: 20; height: 20}', - targetItem, "dynamicSnippet1"); + parentItem, "dynamicSnippet1"); //![0] } diff --git a/doc/src/snippets/declarative/state.qml b/doc/src/snippets/declarative/state.qml new file mode 100644 index 0000000..0954298 --- /dev/null +++ b/doc/src/snippets/declarative/state.qml @@ -0,0 +1,29 @@ +//![0] +import Qt 4.7 + +Rectangle { + id: myRect + width: 100; height: 100 + color: "black" + + states: [ + State { + name: "clicked" + PropertyChanges { + target: myRect + color: "red" + } + } + ] + + MouseArea { + anchors.fill: parent + onClicked: { + if (myRect.state == "") // i.e. the default state + myRect.state = "clicked"; + else + myRect.state = ""; + } + } +} +//![0] diff --git a/doc/src/snippets/declarative/states.qml b/doc/src/snippets/declarative/states.qml new file mode 100644 index 0000000..7bfb5bd --- /dev/null +++ b/doc/src/snippets/declarative/states.qml @@ -0,0 +1,41 @@ +//![0] +import Qt 4.7 + +Item { + id: myItem + width: 200; height: 200 + + Rectangle { + id: myRect + width: 100; height: 100 + color: "red" + } + + states: [ + State { + name: "moved" + PropertyChanges { + target: myRect + x: 50 + y: 50 + } + } + ] + + MouseArea { + anchors.fill: parent + onClicked: myItem.state = 'moved' + } +//![0] + +//![transitions] +transitions: [ + Transition { + NumberAnimation { properties: "x,y"; duration: 500 } + } +] +//![transitions] + +//![1] +} +//![1] diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 9847079..7b51239 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -78,7 +78,7 @@ class QByteArray; \since 4.7 \brief The Component element encapsulates a QML component description. - Components are reusable, encapsulated Qml element with a well-defined interface. + Components are reusable, encapsulated QML elements with well-defined interfaces. They are often defined in \l {qdeclarativedocuments.html}{Component Files}. The \e Component element allows defining components within a QML file. diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 39b0802..0715624 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -191,7 +191,7 @@ when the property has one of the following types: \o \c vector3d - use \l{Qt::vector3d()}{Qt.vector3d()} \endlist -There are also string based constructors for these types, see \l{qdeclarativebasictypes.html}{QML Basic Types}. +There are also string based constructors for these types. See \l{qdeclarativebasictypes.html}{QML Basic Types} for more information. \section1 Date/Time Formatters @@ -1054,8 +1054,9 @@ or \c null if there was an error in creating the component. Call \l {Component::createObject()}{Component.createObject()} on the returned component to create an object instance of the component. -Here is an example. Remember that QML files that might be loaded -over the network cannot be expected to be ready immediately. +Here is an example. Notice it checks whether the component \l{Component::status}{status} is +\c Component.Ready before calling \l {Component::createObject()}{createObject()} +in case the QML file is loaded over a network and thus is not ready immediately. \snippet doc/src/snippets/declarative/componentCreation.js 0 \codeline @@ -1095,12 +1096,12 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS /*! \qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath) -Returns a new object created from the given \a string of QML with the specified \a parent, +Returns a new object created from the given \a string of QML which will have the specified \a parent, or \c null if there was an error in creating the object. If \a filepath is specified, it will be used for error reporting for the created object. -Example (where \c targetItem is the id of an existing QML item): +Example (where \c parentItem is the id of an existing QML item): \snippet doc/src/snippets/declarative/createQmlObject.qml 0 diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index e98afeb..8e3ec82 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -91,7 +91,7 @@ QT_BEGIN_NAMESPACE \endqml By default, PropertyChanges will establish new bindings where appropriate. - For example, the following creates a new binding for myItem's height property. + For example, the following creates a new binding for myItem's \c height property. \qml PropertyChanges { @@ -500,8 +500,8 @@ QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions() If explicit is set to true, any potential bindings will be interpreted as once-off assignments that occur when the state is entered. - In the following example, the addition of explicit prevents myItem.width from - being bound to parent.width. Instead, it is assigned the value of parent.width + In the following example, the addition of explicit prevents \c myItem.width from + being bound to \c parent.width. Instead, it is assigned the value of \c parent.width at the time of the state change. \qml PropertyChanges { diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index eca90a4..37f9f6a 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -136,12 +136,30 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje \since 4.7 \brief The State element defines configurations of objects and properties. - A state is specified as a set of batched changes from the default configuration. + A \e state is a set of batched changes from the default configuration. + + All items have a default state that defines the default configuration of objects + and property values. New states can be defined by adding State items to the \l {Item::states}{states} property to + allow items to switch between different configurations. These configurations + can, for example, be used to apply different sets of property values or execute + different scripts. + + Here is an example. In the default state, \c myRect is colored black. In the "clicked" + state, the color is red. Clicking within the MouseArea toggles the rectangle's state + between the default state and the "clicked" state, thus toggling the color of the + rectangle between black and red. + + \snippet doc/src/snippets/declarative/state.qml 0 + + Notice the default state is referred to using an empty string (""). + + States are commonly used together with \l {state-transitions}{Transitions} to provide + animations when state changes occur. \note setting the state of an object from within another state of the same object is not allowed. - \sa {qmlstates}{States}, {state-transitions}{Transitions}, QtDeclarative + \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, QtDeclarative */ /*! @@ -173,7 +191,7 @@ QDeclarativeState::~QDeclarativeState() /*! \qmlproperty string State::name - This property holds the name of the state + This property holds the name of the state. Each state should have a unique name. */ @@ -204,12 +222,12 @@ bool QDeclarativeState::isWhenKnown() const /*! \qmlproperty bool State::when - This property holds when the state should be applied + This property holds when the state should be applied. - This should be set to an expression that evaluates to true when you want the state to + This should be set to an expression that evaluates to \c true when you want the state to be applied. - If multiple states in a group have \c when clauses that evaluate to true at the same time, + If multiple states in a group have \c when clauses that evaluate to \c true at the same time, the first matching state will be applied. For example, in the following snippet \c state1 will always be selected rather than \c state2 when sharedCondition becomes \c true. @@ -236,7 +254,9 @@ void QDeclarativeState::setWhen(QDeclarativeBinding *when) /*! \qmlproperty string State::extend - This property holds the state that this state extends + This property holds the state that this state extends. + + When a state extends another state, it inherits all the changes of that state. The state being extended is treated as the base state in regards to the changes specified by the extending state. diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index 1e530a1..67cd12e 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -91,8 +91,8 @@ public: \since 4.7 \brief The StateGroup element provides state support for non-Item elements. - Item (and all dervied elements) provides built in support for states and transitions - via its state, states and transitions properties. StateGroup provides an easy way to + Item (and all derived elements) provides built in support for states and transitions + via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to use this support in other (non-Item-derived) elements. \qml diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 99f163e..2d55931 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -583,9 +583,9 @@ public: \qmlclass StateChangeScript QDeclarativeStateChangeScript \brief The StateChangeScript element allows you to run a script in a state. - StateChangeScripts are run when entering the state. You can use - ScriptAction to specify at which point in the transition - you want the StateChangeScript to be run. + A StateChangeScript is run upon entering a state. You can optionally use + ScriptAction to specify the point in the transition at which + the StateChangeScript should to be run. \qml State { @@ -687,22 +687,16 @@ QString QDeclarativeStateChangeScript::typeName() const \qmlclass AnchorChanges QDeclarativeAnchorChanges \brief The AnchorChanges element allows you to change the anchors of an item in a state. - In the following example we change the top and bottom anchors of an item: - \qml - State { - name: "reanchored" - AnchorChanges { - target: content; - anchors.top: window.top; - anchors.bottom: window.bottom - } - PropertyChanges { - target: content; - anchors.topMargin: 3 - anchors.bottomMargin: 3; - } - } - \endqml + The AnchorChanges element is used to modify the anchors of an item in a \l State. + + AnchorChanges cannot be used to modify the margins on an item. For this, use + PropertyChanges intead. + + In the following example we change the top and bottom anchors of an item + using AnchorChanges, and the top and bottom anchor margins using + PropertyChanges: + + \snippet doc/src/snippets/declarative/anchorchanges.qml 0 AnchorChanges can be animated using AnchorAnimation. \qml -- cgit v0.12 From 4a36a17e06b3ec7c20bcef9692d46dba5504151a Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 9 Jun 2010 18:04:48 +1000 Subject: Doc improvements: move some example code to snippets, add screenshots, other minor doc fixes --- doc/src/declarative/elements.qdoc | 2 - doc/src/declarative/pics/anchorchanges.png | Bin 0 -> 566 bytes doc/src/declarative/pics/listmodel-nested.png | Bin 0 -> 7493 bytes doc/src/declarative/pics/listmodel.png | Bin 0 -> 3407 bytes doc/src/declarative/pics/parentchange.png | Bin 0 -> 509 bytes doc/src/snippets/declarative/anchorchanges.qml | 51 ++++++++- doc/src/snippets/declarative/animation.qml | 40 +++++++ doc/src/snippets/declarative/listmodel-nested.qml | 103 +++++++++++++++++ doc/src/snippets/declarative/listmodel-simple.qml | 80 +++++++++++++ doc/src/snippets/declarative/listmodel.qml | 60 ++++++++++ doc/src/snippets/declarative/parentchange.qml | 69 +++++++++++ doc/src/snippets/declarative/state.qml | 40 +++++++ doc/src/snippets/declarative/states.qml | 40 +++++++ doc/src/snippets/declarative/visualdatamodel.qml | 65 +++++++++++ .../declarative/visualdatamodel_rootindex/main.cpp | 63 +++++++++++ .../declarative/visualdatamodel_rootindex/view.qml | 66 +++++++++++ .../visualdatamodel_rootindex.pro | 4 + src/declarative/graphicsitems/qdeclarativeitem.cpp | 2 +- .../graphicsitems/qdeclarativevisualitemmodel.cpp | 99 +++++----------- src/declarative/qml/qdeclarativecomponent.cpp | 12 +- src/declarative/qml/qdeclarativecontext.cpp | 2 +- src/declarative/util/qdeclarativeanimation.cpp | 21 ++-- src/declarative/util/qdeclarativeconnections.cpp | 29 ++--- src/declarative/util/qdeclarativelistmodel.cpp | 126 ++++----------------- src/declarative/util/qdeclarativepackage.cpp | 8 +- src/declarative/util/qdeclarativestate.cpp | 5 +- .../util/qdeclarativestateoperations.cpp | 10 ++ src/declarative/util/qdeclarativexmllistmodel.cpp | 10 +- tests/auto/declarative/examples/tst_examples.cpp | 1 + 29 files changed, 783 insertions(+), 225 deletions(-) create mode 100644 doc/src/declarative/pics/anchorchanges.png create mode 100644 doc/src/declarative/pics/listmodel-nested.png create mode 100644 doc/src/declarative/pics/listmodel.png create mode 100644 doc/src/declarative/pics/parentchange.png create mode 100644 doc/src/snippets/declarative/listmodel-nested.qml create mode 100644 doc/src/snippets/declarative/listmodel-simple.qml create mode 100644 doc/src/snippets/declarative/listmodel.qml create mode 100644 doc/src/snippets/declarative/parentchange.qml create mode 100644 doc/src/snippets/declarative/visualdatamodel.qml create mode 100644 doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp create mode 100644 doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml create mode 100644 doc/src/snippets/declarative/visualdatamodel_rootindex/visualdatamodel_rootindex.pro diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index aa48bcb..31fa948 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -211,6 +211,4 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \endlist \endtable -\o - */ diff --git a/doc/src/declarative/pics/anchorchanges.png b/doc/src/declarative/pics/anchorchanges.png new file mode 100644 index 0000000..4973e4e Binary files /dev/null and b/doc/src/declarative/pics/anchorchanges.png differ diff --git a/doc/src/declarative/pics/listmodel-nested.png b/doc/src/declarative/pics/listmodel-nested.png new file mode 100644 index 0000000..ee7ffba Binary files /dev/null and b/doc/src/declarative/pics/listmodel-nested.png differ diff --git a/doc/src/declarative/pics/listmodel.png b/doc/src/declarative/pics/listmodel.png new file mode 100644 index 0000000..7ab1771 Binary files /dev/null and b/doc/src/declarative/pics/listmodel.png differ diff --git a/doc/src/declarative/pics/parentchange.png b/doc/src/declarative/pics/parentchange.png new file mode 100644 index 0000000..93206fb Binary files /dev/null and b/doc/src/declarative/pics/parentchange.png differ diff --git a/doc/src/snippets/declarative/anchorchanges.qml b/doc/src/snippets/declarative/anchorchanges.qml index 6c0a0ad..993618b 100644 --- a/doc/src/snippets/declarative/anchorchanges.qml +++ b/doc/src/snippets/declarative/anchorchanges.qml @@ -1,11 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ //![0] import Qt 4.7 -Item { +Rectangle { id: window - width: 200; height: 200 + width: 120; height: 120 + color: "black" - Rectangle { id: myRect; width: 100; height: 100; color: "red" } + Rectangle { id: myRect; width: 50; height: 50; color: "red" } states: State { name: "reanchored" @@ -17,8 +58,8 @@ Item { } PropertyChanges { target: myRect - anchors.topMargin: 3 - anchors.bottomMargin: 3 + anchors.topMargin: 10 + anchors.bottomMargin: 10 } } diff --git a/doc/src/snippets/declarative/animation.qml b/doc/src/snippets/declarative/animation.qml index f5c6bf6..65acd36 100644 --- a/doc/src/snippets/declarative/animation.qml +++ b/doc/src/snippets/declarative/animation.qml @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ import Qt 4.7 Row { diff --git a/doc/src/snippets/declarative/listmodel-nested.qml b/doc/src/snippets/declarative/listmodel-nested.qml new file mode 100644 index 0000000..4ae43ff --- /dev/null +++ b/doc/src/snippets/declarative/listmodel-nested.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import Qt 4.7 + +Rectangle { + width: 200; height: 200 + + +//![model] +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Orange" + cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Banana" + cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } +} +//![model] + +//![delegate] +Component { + id: fruitDelegate + Item { + width: 200; height: 50 + Text { id: nameField; text: name } + Text { text: '$' + cost; anchors.left: nameField.right } + Row { + anchors.top: nameField.bottom + spacing: 5 + Text { text: "Attributes:" } + Repeater { + model: attributes + Text { text: description } + } + } + } +} +//![delegate] + +ListView { + width: 200; height: 200 + model: fruitModel + delegate: fruitDelegate +} + +} diff --git a/doc/src/snippets/declarative/listmodel-simple.qml b/doc/src/snippets/declarative/listmodel-simple.qml new file mode 100644 index 0000000..00b8cb0 --- /dev/null +++ b/doc/src/snippets/declarative/listmodel-simple.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Rectangle { + width: 200; height: 200 + + ListModel { + id: fruitModel +//![0] + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } +//![1] + } + + Component { + id: fruitDelegate + Row { + spacing: 10 + Text { text: name } + Text { text: '$' + cost } + } + } + + ListView { + anchors.fill: parent + model: fruitModel + delegate: fruitDelegate + } +} +//![1] diff --git a/doc/src/snippets/declarative/listmodel.qml b/doc/src/snippets/declarative/listmodel.qml new file mode 100644 index 0000000..91b8230 --- /dev/null +++ b/doc/src/snippets/declarative/listmodel.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } +} +//![0] diff --git a/doc/src/snippets/declarative/parentchange.qml b/doc/src/snippets/declarative/parentchange.qml new file mode 100644 index 0000000..7f5718a --- /dev/null +++ b/doc/src/snippets/declarative/parentchange.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Rectangle { + width: 200 + height: 100 + + Rectangle { + id: redRect + width: 100; height: 100 + color: "red" + } + + Rectangle { + id: blueRect + x: redRect.width + width: 50; height: 50 + color: "blue" + + states: State { + name: "reparented" + ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 } + } + + MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" } + } +} +//![0] + diff --git a/doc/src/snippets/declarative/state.qml b/doc/src/snippets/declarative/state.qml index 0954298..a99c2e2 100644 --- a/doc/src/snippets/declarative/state.qml +++ b/doc/src/snippets/declarative/state.qml @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ //![0] import Qt 4.7 diff --git a/doc/src/snippets/declarative/states.qml b/doc/src/snippets/declarative/states.qml index 7bfb5bd..c3b1796 100644 --- a/doc/src/snippets/declarative/states.qml +++ b/doc/src/snippets/declarative/states.qml @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ //![0] import Qt 4.7 diff --git a/doc/src/snippets/declarative/visualdatamodel.qml b/doc/src/snippets/declarative/visualdatamodel.qml new file mode 100644 index 0000000..cdde513 --- /dev/null +++ b/doc/src/snippets/declarative/visualdatamodel.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Rectangle { + width: 200; height: 100 + + VisualDataModel { + id: visualModel + model: ListModel { + ListElement { name: "Apple" } + ListElement { name: "Orange" } + } + delegate: Rectangle { + height: 25 + width: 100 + Text { text: "Name: " + name} + } + } + + ListView { + anchors.fill: parent + model: visualModel + } +} +//![0] diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp b/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp new file mode 100644 index 0000000..f77061e --- /dev/null +++ b/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp @@ -0,0 +1,63 @@ +myModel/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include +#include + +//![0] +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QDeclarativeView view; + + QDirModel model; + view.rootContext()->setContextProperty("dirModel", &model); + + view.setSource(QUrl::fromLocalFile("view.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml b/doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml new file mode 100644 index 0000000..e623faa --- /dev/null +++ b/doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +ListView { + id: view + width: 300 + height: 400 + + model: VisualDataModel { + model: dirModel + + delegate: Rectangle { + width: 200; height: 25 + Text { text: filePath } + + MouseArea { + anchors.fill: parent + onClicked: { + if (hasModelChildren) + view.model.rootIndex = view.model.modelIndex(index) + } + } + } + } +} +//![0] diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/visualdatamodel_rootindex.pro b/doc/src/snippets/declarative/visualdatamodel_rootindex/visualdatamodel_rootindex.pro new file mode 100644 index 0000000..fec070c --- /dev/null +++ b/doc/src/snippets/declarative/visualdatamodel_rootindex/visualdatamodel_rootindex.pro @@ -0,0 +1,4 @@ +TEMPLATE = app +QT += gui declarative + +SOURCES += main.cpp diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index bef09bb..7ab280e 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -726,7 +726,7 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) The signal properties have a \l KeyEvent parameter, named \e event which contains details of the event. If a key is handled \e event.accepted should be set to true to prevent the - event from propagating up the item heirarchy. + event from propagating up the item hierarchy. \code Item { diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 2a88a80..e133adb 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -113,16 +113,18 @@ public: \since 4.7 \brief The VisualItemModel allows items to be provided to a view. - The children of the VisualItemModel are provided in a model which - can be used in a view. Note that no delegate should be - provided to a view since the VisualItemModel contains the - visual delegate (items). + A VisualItemModel contains the visual items to be used in a view. + When a VisualItemModel is used in a view, the view does not require + a delegate since the VisualItemModel already contains the visual + delegate (items). An item can determine its index within the model via the \c VisualItemModel.index attached property. The example below places three colored rectangles in a ListView. \code + import Qt 4.7 + Rectangle { VisualItemModel { id: itemModel @@ -607,30 +609,15 @@ QDeclarativeVisualDataModelData *QDeclarativeVisualDataModelPrivate::data(QObjec A VisualDataModel encapsulates a model and the delegate that will be instantiated for items in the model. - It is usually not necessary to create a VisualDataModel directly, - since the QML views will create one internally. + It is usually not necessary to create VisualDataModel elements. + However, it can be useful for manipulating and accessing the \l modelIndex + when a QAbstractItemModel subclass is used as the + model. Also, VisualDataModel is used together with \l Package to + provide delegates to multiple views. The example below illustrates using a VisualDataModel with a ListView. - \code - VisualDataModel { - id: visualModel - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - Text { text: "Name:" + name} - } - } - } - ListView { - width: 100 - height: 100 - anchors.fill: parent - model: visualModel - } - \endcode + \snippet doc/src/snippets/declarative/visualdatamodel.qml 0 */ QDeclarativeVisualDataModel::QDeclarativeVisualDataModel() @@ -805,56 +792,22 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate) /*! \qmlproperty QModelIndex VisualDataModel::rootIndex - QAbstractItemModel provides a heirachical tree of data, whereas + QAbstractItemModel provides a hierarchical tree of data, whereas QML only operates on list data. \c rootIndex allows the children of any node in a QAbstractItemModel to be provided by this model. This property only affects models of type QAbstractItemModel. - \code - // main.cpp - - int main(int argc, char ** argv) - { - QApplication app(argc, argv); - - QDeclarativeView view; - - QDirModel model; - view.rootContext()->setContextProperty("myModel", &model); + For example, here is a simple interactive file system browser. + When a directory name is clicked, the view's \c rootIndex is set to the + QModelIndex node of the clicked directory, thus updating the view to show + the new directory's contents. - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); - } - - #include "main.moc" - \endcode - - \code - // view.qml - import Qt 4.7 - - ListView { - id: view - width: 200 - height: 200 - model: VisualDataModel { - model: myModel - delegate: Component { - Rectangle { - height: 25; width: 200 - Text { text: filePath } - MouseArea { - anchors.fill: parent; - onClicked: if (hasModelChildren) view.model.rootIndex = view.model.modelIndex(index) - } - } - } - } - } - \endcode + \c main.cpp: + \snippet doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp 0 + + \c view.qml: + \snippet doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml 0 \sa modelIndex(), parentModelIndex() */ @@ -886,7 +839,7 @@ void QDeclarativeVisualDataModel::setRootIndex(const QVariant &root) /*! \qmlmethod QModelIndex VisualDataModel::modelIndex(int index) - QAbstractItemModel provides a heirachical tree of data, whereas + QAbstractItemModel provides a hierarchical tree of data, whereas QML only operates on list data. This function assists in using tree models in QML. @@ -906,7 +859,7 @@ QVariant QDeclarativeVisualDataModel::modelIndex(int idx) const /*! \qmlmethod QModelIndex VisualDataModel::parentModelIndex() - QAbstractItemModel provides a heirachical tree of data, whereas + QAbstractItemModel provides a hierarchical tree of data, whereas QML only operates on list data. This function assists in using tree models in QML. @@ -1000,10 +953,10 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q The \a parts property selects a VisualDataModel which creates delegates from the part named. This is used in conjunction with - the Package element. + the \l Package element. For example, the code below selects a model which creates - delegates named \e list from a Package: + delegates named \e list from a \l Package: \code VisualDataModel { diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 7b51239..55ee783 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -547,16 +547,18 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q /*! \qmlmethod object Component::createObject(parent) - Returns an object instance from this component, or null if object creation fails. + + Creates and returns an object instance of this component that will have the given + \a parent. Returns null if object creation fails. The object will be created in the same context as the one in which the component was created. This function will always return null when called on components which were not created in QML. - Note that if the returned object is to be displayed, its \c parent must be set to - an existing item in a scene, or else the object will not be visible. The parent - argument is required to help you avoid this, you must explicitly pass in null if - you wish to create an object without setting a parent. + If you wish to create an object without setting a parent, specify \c null for + the \a parent value. Note that if the returned object is to be displayed, you + must provide a valid \a parent value or set the returned object's \l{Item::parent}{parent} + property, or else the object will not be visible. */ /*! diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 6a13f15..2221d78 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -116,7 +116,7 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate() All properties added explicitly by QDeclarativeContext::setContextProperty() take precedence over the context object's properties. - Contexts form a hierarchy. The root of this heirarchy is the QDeclarativeEngine's + Contexts form a hierarchy. The root of this hierarchy is the QDeclarativeEngine's \l {QDeclarativeEngine::rootContext()}{root context}. A component instance can access the data in its own context, as well as all its ancestor contexts. Data can be made available to all instances by modifying the diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 1447532..25cf133 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -1774,7 +1774,7 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) To specify an easing curve you need to specify at least the type. For some curves you can also specify amplitude, period and/or overshoot (more details provided after the table). The default easing curve is - Linear. + \c Easing.Linear. \qml PropertyAnimation { properties: "y"; easing.type: Easing.InOutElastic; easing.amplitude: 2.0; easing.period: 1.5 } @@ -1951,15 +1951,15 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) \o \inlineimage qeasingcurve-outinbounce.png \endtable - easing.amplitude is only applicable for bounce and elastic curves (curves of type - Easing.InBounce, Easing.OutBounce, Easing.InOutBounce, Easing.OutInBounce, Easing.InElastic, - Easing.OutElastic, Easing.InOutElastic or Easing.OutInElastic). + \c easing.amplitude is only applicable for bounce and elastic curves (curves of type + \c Easing.InBounce, \c Easing.OutBounce, \c Easing.InOutBounce, \c Easing.OutInBounce, \c Easing.InElastic, + \c Easing.OutElastic, \c Easing.InOutElastic or \c Easing.OutInElastic). - easing.overshoot is only applicable if type is: Easing.InBack, Easing.OutBack, - Easing.InOutBack or Easing.OutInBack. + \c easing.overshoot is only applicable if \c easing.type is: \c Easing.InBack, \c Easing.OutBack, + \c Easing.InOutBack or \c Easing.OutInBack. - easing.period is only applicable if type is: Easing.InElastic, Easing.OutElastic, - Easing.InOutElastic or Easing.OutInElastic. + \c easing.period is only applicable if easing.type is: \c Easing.InElastic, \c Easing.OutElastic, + \c Easing.InOutElastic or \c Easing.OutInElastic. See the \l {declarative/animation/easing}{easing} example for a demonstration of the different easing settings. @@ -2045,8 +2045,9 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop) The singular forms are slightly optimized, so if you do have only a single target/property to animate you should try to use them. - In many cases these properties do not need to be explicitly specified -- they can be - inferred from the animation framework. + In many cases these properties do not need to be explicitly specified, as they can be + inferred from the animation framework: + \table 80% \row \o Value Source / Behavior diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp index 808d196..b364821 100644 --- a/src/declarative/util/qdeclarativeconnections.cpp +++ b/src/declarative/util/qdeclarativeconnections.cpp @@ -72,7 +72,9 @@ public: /*! \qmlclass Connections QDeclarativeConnections \since 4.7 - \brief A Connections object describes generalized connections to signals. + \brief A Connections element describes generalized connections to signals. + + A Connections object creates a connection to a QML signal. When connecting to signals in QML, the usual way is to create an "on" handler that reacts when a signal is received, like this: @@ -83,16 +85,16 @@ public: } \endqml - However, in some cases, it is not possible to connect to a signal in this - way, such as: + However, it is not possible to connect to a signal in this way in some + cases, such as when: \list - \i multiple connections to the same signal - \i connections outside the scope of the signal sender - \i connections to targets not defined in QML + \i Multiple connections to the same signal are required + \i Creating connections outside the scope of the signal sender + \i Connecting to targets not defined in QML \endlist - When any of these are needed, the Connections object can be used instead. + When any of these are needed, the Connections element can be used instead. For example, the above code can be changed to use a Connections object, like this: @@ -105,7 +107,7 @@ public: } \endqml - More generally, the Connections object can be a child of some other object than + More generally, the Connections object can be a child of some object other than the sender of the signal: \qml @@ -141,7 +143,7 @@ QDeclarativeConnections::~QDeclarativeConnections() \qmlproperty Object Connections::target This property holds the object that sends the signal. - If not set at all, the target defaults to be the parent of the Connections. + If this property is not set, the \c target defaults to the parent of the Connection. If set to null, no connection is made and any signal handlers are ignored until the target is not null. @@ -175,12 +177,11 @@ void QDeclarativeConnections::setTarget(QObject *obj) /*! \qmlproperty bool Connections::ignoreUnknownSignals - Normally, you will get a runtime error if you try to connect - to signals on an object which the object does not have. + Normally, a connection to a non-existent signal produces runtime errors. - By setting this flag to true, such errors are ignored. This is - useful if you intend to connect to different types of object, handling - a different set of signals for each. + If this property is set to \c true, such errors are ignored. + This is useful if you intend to connect to different types of objects, handling + a different set of signals for each object. */ bool QDeclarativeConnections::ignoreUnknownSignals() const { diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 7518eb7..78a3207 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -76,125 +76,41 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM For example: - \code - ListModel { - id: fruitModel - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } - } - \endcode + \snippet doc/src/snippets/declarative/listmodel.qml 0 - Roles (properties) must begin with a lower-case letter.The above example defines a + Roles (properties) must begin with a lower-case letter. The above example defines a ListModel containing three elements, with the roles "name" and "cost". Values must be simple constants - either strings (quoted), bools (true, false), numbers, or enum values (like Text.AlignHCenter). The defined model can be used in views such as ListView: - \code - Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { text: name } - Text { text: '$'+cost; anchors.right: parent.right } - } - } - ListView { - model: fruitModel - delegate: fruitDelegate - anchors.fill: parent - } - \endcode + \snippet doc/src/snippets/declarative/listmodel-simple.qml 0 + \dots 8 + \snippet doc/src/snippets/declarative/listmodel-simple.qml 1 + \image listmodel.png It is possible for roles to contain list data. In the example below we create a list of fruit attributes: - \code - ListModel { - id: fruitModel - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Orange" - cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Banana" - cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } - } - \endcode + \snippet doc/src/snippets/declarative/listmodel-nested.qml model + + The delegate below displays all the fruit attributes: + + \snippet doc/src/snippets/declarative/listmodel-nested.qml delegate + \image listmodel-nested.png - The delegate below will list all the fruit attributes: - \code - Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { id: name; text: name } - Text { text: '$'+cost; anchors.right: parent.right } - Row { - anchors.top: name.bottom - spacing: 5 - Text { text: "Attributes:" } - Repeater { - model: attributes - Component { Text { text: description } } - } - } - } - } - \endcode \section2 Modifying list models The content of a ListModel may be created and modified using the clear(), - append(), and set() methods. For example: - - \code - Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { text: name } - Text { text: '$'+cost; anchors.right: parent.right } - - // Double the price when clicked. - MouseArea { - anchors.fill: parent - onClicked: fruitModel.set(index, "cost", cost*2) - } - } - } - \endcode + append(), set() and setProperty() methods. For example: + + \snippet doc/src/snippets/declarative/listmodel-modify.qml delegate When creating content dynamically, note that the set of available properties cannot be changed - except by first clearing the model - whatever properties are first added are then the - only permitted properties in the model. + except by first clearing the model. Whatever properties are first added to the model are then the + only permitted properties in the model until it is cleared. \section2 Using threaded list models with WorkerScript @@ -214,11 +130,11 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM \snippet examples/declarative/threading/threadedlistmodel/dataloader.js 0 The application's \tt Timer object periodically sends a message to the - worker script by calling \tt WorkerScript::sendMessage(). When this message - is received, \tt WorkerScript.onMessage() is invoked in + worker script by calling \l WorkerScript::sendMessage(). When this message + is received, \l {WorkerScript::onMessage}{WorkerScript.onMessage()} is invoked in \tt dataloader.js, which appends the current time to the list model. - Note the call to sync() from the \c WorkerScript.onMessage() handler. + Note the call to sync() from the \l {WorkerScript::onMessage}{WorkerScript.onMessage()} handler. You must call sync() or else the changes made to the list from the external thread will not be reflected in the list model in the main thread. @@ -454,7 +370,7 @@ void QDeclarativeListModel::insert(int index, const QScriptValue& valuemap) to the end of the list: \code - fruitModel.move(0,fruitModel.count-3,3) + fruitModel.move(0, fruitModel.count - 3, 3) \endcode \sa append() diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp index 9617b86..9245fc2 100644 --- a/src/declarative/util/qdeclarativepackage.cpp +++ b/src/declarative/util/qdeclarativepackage.cpp @@ -48,9 +48,9 @@ QT_BEGIN_NAMESPACE /*! \qmlclass Package QDeclarativePackage - \brief Package provides a collection of named items + \brief Package provides a collection of named items. - The Package class is currently used in conjunction with + The Package class is used in conjunction with VisualDataModel to enable delegates with a shared context to be provided to multiple views. @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE \e {Package.name} attached property. The example below creates a Package containing two named items; - \e list and \e grid. The third element in the package is parented to whichever + \e list and \e grid. The third element in the package (the \l Rectangle) is parented to whichever delegate it should appear in. This allows an item to move between views. @@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE \snippet examples/declarative/modelviews/package/view.qml 0 - \sa QtDeclarative + \sa {declarative/modelviews/package}{Package example}, QtDeclarative */ diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index 37f9f6a..ae19a9c 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -144,8 +144,9 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje can, for example, be used to apply different sets of property values or execute different scripts. - Here is an example. In the default state, \c myRect is colored black. In the "clicked" - state, the color is red. Clicking within the MouseArea toggles the rectangle's state + The following example displays a single Rectangle. In the default state, the rectangle + is colored black. In the "clicked" state, a PropertyChanges element changes the + rectangle's color to red. Clicking within the MouseArea toggles the rectangle's state between the default state and the "clicked" state, thus toggling the color of the rectangle between black and red. diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 2d55931..51e6f99 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -172,6 +172,14 @@ void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, Q items involved in the reparenting (i.e. items in the common ancestor tree for the original and new parent). + The example below displays a large red rectangle and a small blue rectangle, side by side. + When the \c blueRect is clicked, it changes to the "reparented" state: its parent is changed to \c redRect and it is + positioned at (10, 10) within the red rectangle, as specified in the ParentChange. + + \snippet doc/src/snippets/declarative/parentchange.qml 0 + + \image parentchange.png + You can specify at which point in a transition you want a ParentChange to occur by using a ParentAnimation. */ @@ -698,6 +706,8 @@ QString QDeclarativeStateChangeScript::typeName() const \snippet doc/src/snippets/declarative/anchorchanges.qml 0 + \image anchorchanges.png + AnchorChanges can be animated using AnchorAnimation. \qml //animate our anchor changes diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 4f9355b..4adef25 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -523,10 +523,13 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty in the XML document. The XmlRole objects define the - model item attributes; here, each model item will have \c title and \c pubDate + model item attributes. Here, each model item will have \c title and \c pubDate attributes that match the \c title and \c pubDate values of its corresponding \c . (See \l XmlRole::query for more examples of valid XPath expressions for XmlRole.) @@ -672,11 +675,11 @@ void QDeclarativeXmlListModel::setSource(const QUrl &src) /*! \qmlproperty string XmlListModel::xml - This property holds XML text set directly. + This property holds the XML data for this model, if set. The text is assumed to be UTF-8 encoded. - If both source and xml are set, xml will be used. + If both \l source and \c xml are set, \c xml will be used. */ QString QDeclarativeXmlListModel::xml() const { @@ -733,6 +736,7 @@ void QDeclarativeXmlListModel::setQuery(const QString &query) source: "http://mysite.com/feed.xml" query: "/feed/entry" namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + XmlRole { name: "title"; query: "title/string()" } } \endqml diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index da115a7..cff0b46 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -85,6 +85,7 @@ tst_examples::tst_examples() // Add directories you want excluded here + excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex"; #ifdef QT_NO_WEBKIT excludedDirs << "examples/declarative/modelviews/webview"; -- cgit v0.12 From 433ad48e3ce0fd66d6165714c0bd811d5cb79a35 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 10 Jun 2010 09:48:27 +1000 Subject: qmlviewer: ensure that only clicks on the current file list are handled. Task-number: QTBUG-11315 --- tools/qml/content/Browser.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qml/content/Browser.qml b/tools/qml/content/Browser.qml index 838a848..ff2bb47 100644 --- a/tools/qml/content/Browser.qml +++ b/tools/qml/content/Browser.qml @@ -134,7 +134,7 @@ Rectangle { MouseArea { id: mouseRegion anchors.fill: parent - onClicked: { launch() } + onClicked: { if (folders == wrapper.ListView.view.model) launch() } } states: [ State { -- cgit v0.12 From 6eb8af2ceca2d0fc8b7108bec3525d915d31fe65 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 10 Jun 2010 10:22:34 +1000 Subject: Improve test stability. --- .../qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 91b7cf8..abc9688 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -44,6 +44,7 @@ #include #include #include "qmlruntime.h" +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -85,6 +86,10 @@ void tst_QDeclarativeViewer::orientation() QVERIFY(rootItem); window.show(); + QApplication::setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(&window)); + QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); QCOMPARE(viewer->view()->size(), QSize(200, 300)); @@ -125,6 +130,10 @@ void tst_QDeclarativeViewer::loading() QVERIFY(rootItem); viewer->show(); + QApplication::setActiveWindow(viewer); + QTest::qWaitForWindowShown(viewer); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); + // initial size QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); @@ -192,6 +201,10 @@ void tst_QDeclarativeViewer::fileBrowser() viewer->openFile(); viewer->show(); + QApplication::setActiveWindow(viewer); + QTest::qWaitForWindowShown(viewer); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); + // Browser.qml successfully loaded QDeclarativeItem* browserItem = qobject_cast(viewer->view()->rootObject()); QVERIFY(viewer->view()); @@ -225,6 +238,10 @@ void tst_QDeclarativeViewer::resizing() QVERIFY(rootItem); viewer->show(); + QApplication::setActiveWindow(viewer); + QTest::qWaitForWindowShown(viewer); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); + // initial size QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); -- cgit v0.12 From 85864036462e80c18b8a272eb4dcbe339b7033e0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 10 Jun 2010 10:33:44 +1000 Subject: Stablize qmlviewer test --- .../qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 91b7cf8..8626560 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -43,6 +43,7 @@ #include #include #include +#include "../../../shared/util.h" #include "qmlruntime.h" #ifdef Q_OS_SYMBIAN @@ -126,8 +127,8 @@ void tst_QDeclarativeViewer::loading() viewer->show(); // initial size - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); + QTRY_COMPARE(rootItem->width(), 200.0); + QTRY_COMPARE(rootItem->height(), 300.0); QCOMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); @@ -137,8 +138,8 @@ void tst_QDeclarativeViewer::loading() qApp->processEvents(); // window resized - QCOMPARE(rootItem->width(), 400.0); - QCOMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); + QTRY_COMPARE(rootItem->width(), 400.0); + QTRY_COMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); QCOMPARE(viewer->view()->size(), QSize(400, 500-viewer->menuBar()->height())); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500-viewer->menuBar()->height())); @@ -150,8 +151,8 @@ void tst_QDeclarativeViewer::loading() QVERIFY(rootItem); // reload cause the window to return back to initial size - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); + QTRY_COMPARE(rootItem->width(), 200.0); + QTRY_COMPARE(rootItem->height(), 300.0); QCOMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); @@ -162,8 +163,8 @@ void tst_QDeclarativeViewer::loading() qApp->processEvents(); // window resized again - QCOMPARE(rootItem->width(), 400.0); - QCOMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); + QTRY_COMPARE(rootItem->width(), 400.0); + QTRY_COMPARE(rootItem->height(), 500.0-viewer->menuBar()->height()); QCOMPARE(viewer->view()->size(), QSize(400, 500-viewer->menuBar()->height())); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500-viewer->menuBar()->height())); @@ -175,8 +176,8 @@ void tst_QDeclarativeViewer::loading() QVERIFY(rootItem); // open also causes the window to return back to initial size - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); + QTRY_COMPARE(rootItem->width(), 200.0); + QTRY_COMPARE(rootItem->height(), 300.0); QCOMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); @@ -260,8 +261,8 @@ void tst_QDeclarativeViewer::resizing() viewer->resize(QSize(250,350)); qApp->processEvents(); - QCOMPARE(rootItem->width(), 250.0); - QCOMPARE(rootItem->height(), 350.0-viewer->menuBar()->height()); + QTRY_COMPARE(rootItem->width(), 250.0); + QTRY_COMPARE(rootItem->height(), 350.0-viewer->menuBar()->height()); QCOMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height())); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350-viewer->menuBar()->height())); @@ -271,7 +272,7 @@ void tst_QDeclarativeViewer::resizing() // do not size view to root object rootItem->setWidth(100); rootItem->setHeight(200); - QCOMPARE(viewer->size(), QSize(250, 350)); + QTRY_COMPARE(viewer->size(), QSize(250, 350)); } void tst_QDeclarativeViewer::paths() -- cgit v0.12 From d346ba1ec7a1becd5120fbe181da0374606481c6 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 10 Jun 2010 10:49:13 +1000 Subject: Add 'on' prefix to documentation of signals --- src/declarative/graphicsitems/qdeclarativetext.cpp | 2 +- src/imports/webkit/qdeclarativewebview.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index f4722c3..3b89ad9 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -1171,7 +1171,7 @@ void QDeclarativeText::mousePressEvent(QGraphicsSceneMouseEvent *event) } /*! - \qmlsignal Text::linkActivated(link) + \qmlsignal Text::onLinkActivated(link) This handler is called when the user clicks on a link embedded in the text. */ diff --git a/src/imports/webkit/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp index 9e5647f..383f1ce 100644 --- a/src/imports/webkit/qdeclarativewebview.cpp +++ b/src/imports/webkit/qdeclarativewebview.cpp @@ -1163,9 +1163,9 @@ QString QDeclarativeWebPage::chooseFile(QWebFrame *originatingFrame, const QStri } /*! - \qmlsignal WebView::alert(message) + \qmlsignal WebView::onAlert(message) - This signal is emitted when the web engine sends a JavaScript alert. The \a message is the text + This handler is called when the web engine sends a JavaScript alert. The \a message is the text to be displayed in the alert to the user. */ -- cgit v0.12 From 2306073c6806e3e35d0786fec5c49e165b119e36 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 10 Jun 2010 11:19:48 +1000 Subject: Document attached properties --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativepathview.cpp | 7 +++++++ src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 9 ++++++++- src/declarative/util/qdeclarativepackage.cpp | 7 ++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 0609a48..ed1d271 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1087,7 +1087,7 @@ QDeclarativeGridView::~QDeclarativeGridView() /*! \qmlattachedproperty bool GridView::isCurrentItem - This attched property is true if this delegate is the current item; otherwise false. + This attached property is true if this delegate is the current item; otherwise false. It is attached to each instance of the delegate. */ diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index f58b054..0c2d249 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -358,6 +358,13 @@ QDeclarativePathView::~QDeclarativePathView() } /*! + \qmlattachedproperty PathView PathView::view + This attached property holds the view that manages this delegate instance. + + It is attached to each instance of the delegate. +*/ + +/*! \qmlattachedproperty bool PathView::onPath This attached property holds whether the item is currently on the path. diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index e133adb..410f526 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -119,7 +119,7 @@ public: delegate (items). An item can determine its index within the - model via the \c VisualItemModel.index attached property. + model via the \l{VisualItemModel::index}{index} attached property. The example below places three colored rectangles in a ListView. \code @@ -147,6 +147,13 @@ QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(QObject *parent) { } +/*! + \qmlattachedproperty int VisualItemModel::index + This attached property holds the index of this delegate's item within the model. + + It is attached to each instance of the delegate. +*/ + QDeclarativeListProperty QDeclarativeVisualItemModel::children() { Q_D(QDeclarativeVisualItemModel); diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp index 9245fc2..b149120 100644 --- a/src/declarative/util/qdeclarativepackage.cpp +++ b/src/declarative/util/qdeclarativepackage.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE to be provided to multiple views. Any item within a Package may be assigned a name via the - \e {Package.name} attached property. + \l{Package::name}{Package.name} attached property. The example below creates a Package containing two named items; \e list and \e grid. The third element in the package (the \l Rectangle) is parented to whichever @@ -73,6 +73,11 @@ QT_BEGIN_NAMESPACE \sa {declarative/modelviews/package}{Package example}, QtDeclarative */ +/*! + \qmlattachedproperty bool Package::name + This attached property holds the name of an item within a Package. +*/ + class QDeclarativePackagePrivate : public QObjectPrivate { -- cgit v0.12 From 28b14cbb2003671f6f76b15d069572ef42194e62 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 10 Jun 2010 11:21:09 +1000 Subject: Remove 'XXX Experimental' from VisualItemModel/VisualDataModel and Package --- src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h | 5 ----- src/declarative/util/qdeclarativepackage_p.h | 6 ------ 2 files changed, 11 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h index 0bdbbcf..079c9e6 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h @@ -54,11 +54,6 @@ Q_DECLARE_METATYPE(QModelIndex) QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -/***************************************************************************** - ***************************************************************************** - XXX Experimental - ***************************************************************************** -*****************************************************************************/ class QDeclarativeItem; class QDeclarativeComponent; diff --git a/src/declarative/util/qdeclarativepackage_p.h b/src/declarative/util/qdeclarativepackage_p.h index 57d9c22..6b12ef7 100644 --- a/src/declarative/util/qdeclarativepackage_p.h +++ b/src/declarative/util/qdeclarativepackage_p.h @@ -50,12 +50,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -/***************************************************************************** - ***************************************************************************** - XXX Experimental - ***************************************************************************** -*****************************************************************************/ - class QDeclarativePackagePrivate; class QDeclarativePackageAttached; class Q_AUTOTEST_EXPORT QDeclarativePackage : public QObject -- cgit v0.12 From 2115bbae2387335f8ea29e0ffee70e00d4a15dc1 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 10 Jun 2010 14:29:21 +1000 Subject: Add go button to webbrowser example. Task-number: QTBUG-11310 --- demos/declarative/webbrowser/content/Button.qml | 10 ++++++++-- demos/declarative/webbrowser/content/Header.qml | 22 +++++++++++++++++++-- demos/declarative/webbrowser/content/UrlInput.qml | 7 +++++++ .../content/pics/go-jump-locationbar.png | Bin 0 -> 714 bytes demos/declarative/webbrowser/webbrowser.qml | 1 + 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 demos/declarative/webbrowser/content/pics/go-jump-locationbar.png diff --git a/demos/declarative/webbrowser/content/Button.qml b/demos/declarative/webbrowser/content/Button.qml index 4642cc7..2a2e7ef 100644 --- a/demos/declarative/webbrowser/content/Button.qml +++ b/demos/declarative/webbrowser/content/Button.qml @@ -45,15 +45,21 @@ Item { property alias image: icon.source property variant action + signal clicked + width: 40; height: parent.height Image { id: icon; anchors.centerIn: parent - opacity: if(action != undefined) {action.enabled ? 1.0 : 0.4} else 0 + opacity: if (action != undefined) { action.enabled ? 1.0 : 0.4 } else 1 } MouseArea { anchors { fill: parent; topMargin: -10; bottomMargin: -10 } - onClicked: action.trigger() + onClicked: { + if (action != undefined) + action.trigger() + parent.clicked() + } } } diff --git a/demos/declarative/webbrowser/content/Header.qml b/demos/declarative/webbrowser/content/Header.qml index 2c9d0fb..5abf440 100644 --- a/demos/declarative/webbrowser/content/Header.qml +++ b/demos/declarative/webbrowser/content/Header.qml @@ -42,7 +42,10 @@ import Qt 4.7 Image { + id: header + property alias editUrl: urlInput.url + property bool urlChanged: false source: "pics/titlebar-bg.png"; fillMode: Image.TileHorizontally @@ -91,19 +94,34 @@ Image { onUrlEntered: { webBrowser.urlString = url webBrowser.focus = true + header.urlChanged = false } + onUrlChanged: header.urlChanged = true } Button { id: reloadButton anchors { right: parent.right; rightMargin: 4 } - action: webView.reload; image: "pics/view-refresh.png"; visible: webView.progress == 1.0 + action: webView.reload; image: "pics/view-refresh.png" + visible: webView.progress == 1.0 && !header.urlChanged } Button { id: stopButton anchors { right: parent.right; rightMargin: 4 } - action: webView.stop; image: "pics/edit-delete.png"; visible: webView.progress < 1.0 + action: webView.stop; image: "pics/edit-delete.png" + visible: webView.progress < 1.0 && !header.urlChanged + } + + Button { + id: goButton + anchors { right: parent.right; rightMargin: 4 } + onClicked: { + webBrowser.urlString = urlInput.url + webBrowser.focus = true + header.urlChanged = false + } + image: "pics/go-jump-locationbar.png"; visible: header.urlChanged } } } diff --git a/demos/declarative/webbrowser/content/UrlInput.qml b/demos/declarative/webbrowser/content/UrlInput.qml index b57fae6..9992456 100644 --- a/demos/declarative/webbrowser/content/UrlInput.qml +++ b/demos/declarative/webbrowser/content/UrlInput.qml @@ -48,6 +48,7 @@ Item { property alias url: urlText.text signal urlEntered(string url) + signal urlChanged width: parent.height; height: parent.height @@ -69,18 +70,24 @@ Item { id: urlText horizontalAlignment: TextEdit.AlignLeft font.pixelSize: 14; focusOnPress: true + + onTextChanged: container.urlChanged() + Keys.onEscapePressed: { urlText.text = webView.url webView.focus = true } + Keys.onEnterPressed: { container.urlEntered(urlText.text) webView.focus = true } + Keys.onReturnPressed: { container.urlEntered(urlText.text) webView.focus = true } + anchors { left: parent.left; right: parent.right; leftMargin: 18; rightMargin: 18 verticalCenter: parent.verticalCenter diff --git a/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png b/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png new file mode 100644 index 0000000..636fe38 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png differ diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index a923c92..53ba6da 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -55,6 +55,7 @@ Rectangle { FlickableWebView { id: webView url: webBrowser.urlString + onProgressChanged: header.urlChanged = false anchors { top: headerSpace.bottom; left: parent.left; right: parent.right; bottom: parent.bottom } } -- cgit v0.12 From b14860e0f3b9853f96c2042b261f0c1394360ccd Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 10 Jun 2010 15:47:23 +1000 Subject: Update on color change. Task-number: QTBUG-11330 --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index b877c50..c74e0a2 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -249,7 +249,11 @@ QColor QDeclarativeTextInput::color() const void QDeclarativeTextInput::setColor(const QColor &c) { Q_D(QDeclarativeTextInput); - d->color = c; + if (c != d->color) { + d->color = c; + clearCache(); + update(); + } } -- cgit v0.12 From 7f06f14d01547ca115bc7d06c04bbaf924148910 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 10 Jun 2010 15:47:23 +1000 Subject: Update on color change. Task-number: QTBUG-11330 --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index c74e0a2..01b1447 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -253,6 +253,7 @@ void QDeclarativeTextInput::setColor(const QColor &c) d->color = c; clearCache(); update(); + emit colorChanged(c); } } -- cgit v0.12 From f50b196c3bf2b18e3b1e66f8459be94b42326dc6 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 11 Jun 2010 09:41:23 +1000 Subject: Remove accidentaly added characters. --- doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp b/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp index f77061e..174adee 100644 --- a/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp +++ b/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp @@ -1,4 +1,4 @@ -myModel/**************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -- cgit v0.12 From 3b15102a287c48bb6766acf49c61471abe003bef Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 11 Jun 2010 10:08:04 +1000 Subject: Make snippet compile and pass license test, and add missing snippet file --- doc/src/snippets/declarative/listmodel-modify.qml | 97 +++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 doc/src/snippets/declarative/listmodel-modify.qml diff --git a/doc/src/snippets/declarative/listmodel-modify.qml b/doc/src/snippets/declarative/listmodel-modify.qml new file mode 100644 index 0000000..03fb314 --- /dev/null +++ b/doc/src/snippets/declarative/listmodel-modify.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import Qt 4.7 + +Rectangle { + width: 200; height: 200 + +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Orange" + cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Banana" + cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } +} + +//![delegate] + Component { + id: fruitDelegate + Item { + width: 200; height: 50 + Text { text: name } + Text { text: '$' + cost; anchors.right: parent.right } + + // Double the price when clicked. + MouseArea { + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", cost * 2) + } + } + } +//![delegate] + +ListView { + width: 200; height: 200 + model: fruitModel + delegate: fruitDelegate +} + +} -- cgit v0.12 From 90786cb0d8dd8da2cc53258c93c0129f7c4095fc Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 11 Jun 2010 10:14:13 +1000 Subject: Avoid recursive refill() in List/GridView Task-number: QTBUG-11362 --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 16 ++++++---------- src/declarative/graphicsitems/qdeclarativelistview.cpp | 16 ++++++---------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index ed1d271..da01eb5 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -897,12 +897,10 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m timeline.reset(data.move); if (viewPos != position()) { - if (fixupDuration) { + if (fixupDuration) timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - } else { - data.move.setValue(-viewPos); - q->viewportMoved(); - } + else + timeline.set(data.move, -viewPos); } vTime = timeline.time(); } @@ -911,12 +909,10 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m qreal dist = qAbs(data.move.value() - pos); if (dist > 0) { timeline.reset(data.move); - if (fixupDuration) { + if (fixupDuration) timeline.move(data.move, pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - } else { - data.move.setValue(pos); - q->viewportMoved(); - } + else + timeline.set(data.move, pos); vTime = timeline.time(); } } else { diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 3f2b4ce..4848008 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1144,12 +1144,10 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m timeline.reset(data.move); if (viewPos != position()) { - if (fixupDuration) { + if (fixupDuration) timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - } else { - data.move.setValue(-viewPos); - q->viewportMoved(); - } + else + timeline.set(data.move, -viewPos); } vTime = timeline.time(); } @@ -1159,12 +1157,10 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m qreal dist = qAbs(data.move + pos); if (dist > 0) { timeline.reset(data.move); - if (fixupDuration) { + if (fixupDuration) timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - } else { - data.move.setValue(-pos); - q->viewportMoved(); - } + else + timeline.set(data.move, -pos); vTime = timeline.time(); } } -- cgit v0.12 From 779b07d29e390bac21c31b77f97e0316e6c26454 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 11 Jun 2010 11:12:20 +1000 Subject: Do not keep flush timer running once no pixmaps are detached. Task-number: QT-3500 --- src/gui/image/qpixmapcache.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 7a6a73f..ca21a0c 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -196,9 +196,10 @@ public: static QPixmapCache::KeyData* getKeyData(QPixmapCache::Key *key); QList< QPair > allPixmaps() const; - void flushDetachedPixmaps(bool nt); + bool flushDetachedPixmaps(bool nt); private: + enum { soon_time = 10000, flush_time = 30000 }; int *keyArray; int theid; int ps; @@ -236,38 +237,44 @@ QPMCache::~QPMCache() cleaning-up, and to not cut down the size of the cache while the cache is in active use. - When the last pixmap has been deleted from the cache, kill the - timer so Qt won't keep the CPU from going into sleep mode. + When the last detached pixmap has been deleted from the cache, kill the + timer so Qt won't keep the CPU from going into sleep mode. Currently + the timer is not restarted when the pixmap becomes unused, but it does + restart once something else is added (i.e. the cache space is actually needed). + + Returns true if any were removed. */ -void QPMCache::flushDetachedPixmaps(bool nt) +bool QPMCache::flushDetachedPixmaps(bool nt) { int mc = maxCost(); setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1); setMaxCost(mc); ps = totalCost(); + bool any = false; QHash::iterator it = cacheKeys.begin(); while (it != cacheKeys.end()) { if (!contains(it.value())) { releaseKey(it.value()); it = cacheKeys.erase(it); + any = true; } else { ++it; } } + + return any; } void QPMCache::timerEvent(QTimerEvent *) { bool nt = totalCost() == ps; - flushDetachedPixmaps(nt); - - if (!size()) { + if (!flushDetachedPixmaps(nt)) { killTimer(theid); theid = 0; } else if (nt != t) { killTimer(theid); - theid = startTimer(nt ? 10000 : 30000); + theid = startTimer(nt ? soon_time : flush_time); t = nt; } } @@ -315,7 +322,7 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) if (success) { cacheKeys.insert(key, cacheKey); if (!theid) { - theid = startTimer(30000); + theid = startTimer(flush_time); t = false; } } else { @@ -331,7 +338,7 @@ QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) bool success = QCache::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { if (!theid) { - theid = startTimer(30000); + theid = startTimer(flush_time); t = false; } } else { @@ -352,7 +359,7 @@ bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int bool success = QCache::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { if(!theid) { - theid = startTimer(30000); + theid = startTimer(flush_time); t = false; } const_cast(key) = cacheKey; -- cgit v0.12 From 947358481f27ae44423d218aaece36375a2f7a2d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 11 Jun 2010 11:45:01 +1000 Subject: Fix qmlviewer test failure on windows Attempted to make window size smaller than Windows minimum. --- .../qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index ef99173..c249414 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -255,21 +255,21 @@ void tst_QDeclarativeViewer::resizing() viewer->setSizeToView(false); // size view to root object - rootItem->setWidth(100); + rootItem->setWidth(150); rootItem->setHeight(200); qApp->processEvents(); - QCOMPARE(rootItem->width(), 100.0); + QCOMPARE(rootItem->width(), 150.0); QCOMPARE(rootItem->height(), 200.0); - QCOMPARE(viewer->view()->size(), QSize(100, 200)); + QCOMPARE(viewer->view()->size(), QSize(150, 200)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(100, 200)); - QCOMPARE(viewer->size(), QSize(100, 200+viewer->menuBar()->height())); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200)); + QCOMPARE(viewer->size(), QSize(150, 200+viewer->menuBar()->height())); QCOMPARE(viewer->size(), viewer->sizeHint()); // do not size root object to view - viewer->resize(QSize(150,250)); - QCOMPARE(rootItem->width(), 100.0); + viewer->resize(QSize(180,250)); + QCOMPARE(rootItem->width(), 150.0); QCOMPARE(rootItem->height(), 200.0); viewer->setSizeToView(true); @@ -287,7 +287,7 @@ void tst_QDeclarativeViewer::resizing() QCOMPARE(viewer->size(), viewer->sizeHint()); // do not size view to root object - rootItem->setWidth(100); + rootItem->setWidth(150); rootItem->setHeight(200); QTRY_COMPARE(viewer->size(), QSize(250, 350)); } -- cgit v0.12 From ab0d9f5efd274c8062a03fb3a1c83e4d16afd6fb Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 11 Jun 2010 11:13:37 +1000 Subject: Doc improvements, including snippet fixes, linking to examples, making docs more consistent --- doc/src/declarative/pics/repeater-simple.png | Bin 0 -> 404 bytes doc/src/snippets/declarative/repeater-index.qml | 56 ------------ .../snippets/declarative/repeater-modeldata.qml | 52 ------------ doc/src/snippets/declarative/repeater.qml | 53 +++++++++--- doc/src/snippets/declarative/rotation.qml | 56 ++++++------ doc/src/snippets/declarative/systempalette.qml | 55 ++++++++++++ .../graphicsitems/qdeclarativeanimatedimage.cpp | 7 +- .../graphicsitems/qdeclarativeflickable.cpp | 8 +- .../graphicsitems/qdeclarativeimage.cpp | 2 + src/declarative/graphicsitems/qdeclarativeitem.cpp | 12 +-- .../graphicsitems/qdeclarativelistview.cpp | 2 + .../graphicsitems/qdeclarativeloader.cpp | 28 ++++-- .../graphicsitems/qdeclarativepositioners.cpp | 6 ++ .../graphicsitems/qdeclarativerepeater.cpp | 94 +++++++++++++-------- src/declarative/graphicsitems/qdeclarativetext.cpp | 16 ++-- .../graphicsitems/qdeclarativetextedit.cpp | 51 ++++++----- .../graphicsitems/qdeclarativetextinput.cpp | 25 ++++-- src/declarative/util/qdeclarativefontloader.cpp | 21 +++-- src/declarative/util/qdeclarativesystempalette.cpp | 42 +++++---- 19 files changed, 324 insertions(+), 262 deletions(-) create mode 100644 doc/src/declarative/pics/repeater-simple.png delete mode 100644 doc/src/snippets/declarative/repeater-index.qml delete mode 100644 doc/src/snippets/declarative/repeater-modeldata.qml create mode 100644 doc/src/snippets/declarative/systempalette.qml diff --git a/doc/src/declarative/pics/repeater-simple.png b/doc/src/declarative/pics/repeater-simple.png new file mode 100644 index 0000000..6da6295 Binary files /dev/null and b/doc/src/declarative/pics/repeater-simple.png differ diff --git a/doc/src/snippets/declarative/repeater-index.qml b/doc/src/snippets/declarative/repeater-index.qml deleted file mode 100644 index 3eee742..0000000 --- a/doc/src/snippets/declarative/repeater-index.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -Rectangle { - width: 50; height: childrenRect.height; color: "white" - -//! [0] - Column { - Repeater { - model: 10 - Text { text: "I'm item " + index } - } - } -//! [0] -} - diff --git a/doc/src/snippets/declarative/repeater-modeldata.qml b/doc/src/snippets/declarative/repeater-modeldata.qml deleted file mode 100644 index 3b4cc6d..0000000 --- a/doc/src/snippets/declarative/repeater-modeldata.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -//! [0] -Column { - Repeater { - model: ["apples", "oranges", "pears"] - Text { text: "Data: " + modelData } - } -} -//! [0] - diff --git a/doc/src/snippets/declarative/repeater.qml b/doc/src/snippets/declarative/repeater.qml index 8b4d9cb..be5d62d 100644 --- a/doc/src/snippets/declarative/repeater.qml +++ b/doc/src/snippets/declarative/repeater.qml @@ -39,19 +39,52 @@ ** ****************************************************************************/ +//! [import] import Qt 4.7 +//! [import] -Rectangle { - width: 220; height: 20; color: "white" +Row { -//! [0] - Row { - Rectangle { width: 10; height: 20; color: "red" } - Repeater { - model: 10 - Rectangle { width: 20; height: 20; radius: 10; color: "green" } +//! [simple] +Row { + Repeater { + model: 3 + Rectangle { + width: 100; height: 40 + border.width: 1 + color: "yellow" } - Rectangle { width: 10; height: 20; color: "blue" } } -//! [0] +} +//! [simple] + +//! [index] +Column { + Repeater { + model: 10 + Text { text: "I'm item " + index } + } +} +//! [index] + +//! [modeldata] +Column { + Repeater { + model: ["apples", "oranges", "pears"] + Text { text: "Data: " + modelData } + } +} +//! [modeldata] + +//! [layout] +Row { + Rectangle { width: 10; height: 20; color: "red" } + Repeater { + model: 10 + Rectangle { width: 20; height: 20; radius: 10; color: "green" } + } + Rectangle { width: 10; height: 20; color: "blue" } +} +//! [layout] + } diff --git a/doc/src/snippets/declarative/rotation.qml b/doc/src/snippets/declarative/rotation.qml index 0fb9a61..5437292 100644 --- a/doc/src/snippets/declarative/rotation.qml +++ b/doc/src/snippets/declarative/rotation.qml @@ -38,37 +38,33 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +//! [0] import Qt 4.7 -Rectangle { - width: 360; height: 80 - color: "white" -//! [0] - Row { - x: 10; y: 10 - spacing: 10 - Image { source: "pics/qt.png" } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } - smooth: true - } +Row { + x: 10; y: 10 + spacing: 10 + + Image { source: "pics/qt.png" } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } + smooth: true + } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } + smooth: true + } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } + smooth: true + } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } + smooth: true } -//! [0] } +//! [0] diff --git a/doc/src/snippets/declarative/systempalette.qml b/doc/src/snippets/declarative/systempalette.qml new file mode 100644 index 0000000..98b333e --- /dev/null +++ b/doc/src/snippets/declarative/systempalette.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Qt 4.7 + +Rectangle { + SystemPalette { id: myPalette; colorGroup: SystemPalette.Active } + + width: 640; height: 480 + color: myPalette.window + + Text { + anchors.fill: parent + text: "Hello!"; color: myPalette.windowText + } +} +//![0] diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp index 261cc5c..d8527d3 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp @@ -63,9 +63,10 @@ QT_BEGIN_NAMESPACE \inherits Image \since 4.7 - This item provides for playing animations stored as images containing a series of frames, - such as GIF files. The full list of supported formats can be determined with - QMovie::supportedFormats(). + The AnimatedImage element provides for playing animations stored as images containing a series of frames, + such as GIF files. + + The full list of supported formats can be determined with QMovie::supportedFormats(). \table \row diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 10dc0f8..fdc1444 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -351,6 +351,8 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() Flickable places its children on a surface that can be dragged and flicked. \code + import Qt 4.7 + Flickable { width: 200; height: 200 contentWidth: image.width; contentHeight: image.height @@ -1039,11 +1041,11 @@ QDeclarativeListProperty QDeclarativeFlickable::flickableChildr The \c boundsBehavior can be one of: \list - \o \e Flickable.StopAtBounds - the contents can not be dragged beyond the boundary + \o Flickable.StopAtBounds - the contents can not be dragged beyond the boundary of the flickable, and flicks will not overshoot. - \o \e Flickable.DragOverBounds - the contents can be dragged beyond the boundary + \o Flickable.DragOverBounds - the contents can be dragged beyond the boundary of the Flickable, but flicks will not overshoot. - \o \e Flickable.DragAndOvershootBounds (default) - the contents can be dragged + \o Flickable.DragAndOvershootBounds (default) - the contents can be dragged beyond the boundary of the Flickable, and can overshoot the boundary when flicked. \endlist diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 94240c2..463ad5a 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -83,6 +83,8 @@ QT_BEGIN_NAMESPACE that images which do not form part of the user interface have their size bounded via the \l sourceSize property. This is especially important for content that is loaded from external sources or provided by the user. + + \sa {declarative/imageelements/image}{Image example} */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 7ab280e..18806e7 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -86,8 +86,8 @@ QT_BEGIN_NAMESPACE The Transform elements let you create and control advanced transformations that can be configured independently using specialized properties. - You can assign any number of Transform elements to an Item. Each Transform is applied in order, - one at a time, to the Item it's assigned to. + You can assign any number of Transform elements to an \l Item. Each Transform is applied in order, + one at a time. */ /*! @@ -134,9 +134,9 @@ QT_BEGIN_NAMESPACE /*! \qmlclass Scale QGraphicsScale \since 4.7 - \brief The Scale object provides a way to scale an Item. + \brief The Scale element provides a way to scale an Item. - The Scale object gives more control over scaling than using Item's scale property. Specifically, + The Scale element gives more control over scaling than using \l Item's \l{Item::scale}{scale} property. Specifically, it allows a different scale for the x and y axes, and allows the scale to be relative to an arbitrary point. @@ -148,6 +148,8 @@ QT_BEGIN_NAMESPACE transform: Scale { origin.x: 25; origin.y: 25; xScale: 3} } \endqml + + \sa Rotate, Translate */ /*! @@ -175,7 +177,7 @@ QT_BEGIN_NAMESPACE \since 4.7 \brief The Rotation object provides a way to rotate an Item. - The Rotation object gives more control over rotation than using Item's rotation property. + The Rotation object gives more control over rotation than using \l Item's \l{Item::rotation}{rotation} property. Specifically, it allows (z axis) rotation to be relative to an arbitrary point. The following example rotates a Rectangle around its interior point 25, 25: diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 4848008..5cead2b 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1358,6 +1358,8 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m 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. + + \sa ListModel, GridView */ QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent) diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 898c5a5..25b1119 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -112,27 +112,35 @@ void QDeclarativeLoaderPrivate::initResize() \inherits Item \brief The Loader item allows dynamically loading an Item-based - subtree from a QML URL or Component. + subtree from a URL or Component. - Loader instantiates an item from a component. The component to - instantiate may be specified directly by the \l sourceComponent + The Loader element instantiates an item from a component. The component to + be instantiated may be specified directly by the \l sourceComponent property, or loaded from a URL via the \l source property. - It is also an effective means of delaying the creation of a component - until it is required: + Loader can be used to delay the creation of a component until it is required. + For example, this loads "Page1.qml" as a component into the \l Loader element + when the \l MouseArea is clicked: + \code import Qt 4.7 - Loader { id: pageLoader } + Item { + width: 200; height: 200 - Rectangle { MouseArea { anchors.fill: parent onClicked: pageLoader.source = "Page1.qml" } + + Loader { id: pageLoader } } \endcode + Note that Loader is like any other graphical Item and needs to be positioned + and sized accordingly to become visible. When a component is loaded, the + Loader is automatically resized to the size of the component. + If the Loader source is changed, any previous items instantiated will be destroyed. Setting \l source to an empty string, or setting sourceComponent to \e undefined @@ -225,7 +233,7 @@ void QDeclarativeLoader::setSource(const QUrl &url) /*! \qmlproperty Component Loader::sourceComponent - The sourceComponent property holds the \l{Component} to instantiate. + This property holds the \l{Component} to instantiate. \qml Item { @@ -239,6 +247,8 @@ void QDeclarativeLoader::setSource(const QUrl &url) } \endqml + Note this value must hold a \l Component object; it cannot be a \l Item. + \sa source, progress */ @@ -401,7 +411,7 @@ void QDeclarativeLoader::componentComplete() /*! \qmlsignal Loader::onLoaded() - This handler is called when the \l status becomes Loader.Ready, or on successful + This handler is called when the \l status becomes \c Loader.Ready, or on successful initial load. */ diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 18618ab..ad61bab 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -358,6 +358,7 @@ Column { positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Column. + \sa Row, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Column::add @@ -500,6 +501,8 @@ Row { width of a child depend on the position of a child, then the positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Row. + + \sa Column, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Row::add @@ -653,6 +656,8 @@ Grid { width or height of a child depend on the position of a child, then the positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Grid. + + \sa Flow, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Grid::add @@ -908,6 +913,7 @@ void QDeclarativeGrid::reportConflictingAnchors() positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Flow. + \sa Grid, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Flow::add diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 691cfa2..995e22a 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -65,55 +65,75 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() \since 4.7 \inherits Item - \brief The Repeater item allows you to repeat an Item-based component using a model. + \brief The Repeater element allows you to repeat an Item-based component using a model. - The Repeater item is used to create a large number of - similar items. For each entry in the model, an item is instantiated - in a context seeded with data from the model. If the repeater will - be instantiating a large number of instances, it may be more efficient to - use one of Qt Declarative's \l {xmlViews}{view items}. + The Repeater element is used to create a large number of + similar items. Like other view elements, a Repeater has a \l model and a \l delegate: + for each entry in the model, the delegate is instantiated + in a context seeded with data from the model. A Repeater item is usually + enclosed in a positioner element such as \l Row or \l Column to visually + position the multiple delegate items created by the Repeater. - The model may be either an object list, a string list, a number or a Qt model. - In each case, the data element and the index is exposed to each instantiated - component. - - The index is always exposed as an accessible \c index property. - In the case of an object or string list, the data element (of type string - or object) is available as the \c modelData property. In the case of a Qt model, - all roles are available as named properties just like in the view classes. + The following Repeater creates three instances of a \l Rectangle item within + a \l Row: + + \snippet doc/src/snippets/declarative/repeater.qml import + \codeline + \snippet doc/src/snippets/declarative/repeater.qml simple + + \image repeater-simple.png + + The \l model of a Repeater can be specified as a model object, a number, a string list + or an object list. If a model object is used, the + \l delegate can access the model roles as named properties, just as for view elements like + ListView and GridView. - The following example shows how to use the \c index property inside the instantiated - items: + The \l delegate can also access two additional properties: - \snippet doc/src/snippets/declarative/repeater-index.qml 0 - \image repeater-index.png + \list + \o \c index - the index of the delegate's item + \o \c modelData - the data element for the delegate, which is useful where the \l model is a string or object list + \endlist - The repeater could also use the \c modelData property to reference the data for a + Here is a Repeater that uses the \c index property inside the instantiated items: + + \table + \row + \o \snippet doc/src/snippets/declarative/repeater.qml index + \o \image repeater-index.png + \endtable + + Here is another Repeater that uses the \c modelData property to reference the data for a particular index: - \snippet doc/src/snippets/declarative/repeater-modeldata.qml 0 - \image repeater-modeldata.png + \table + \row + \o \snippet doc/src/snippets/declarative/repeater.qml modeldata + \o \image repeater-modeldata.png + \endtable Items instantiated by the Repeater are inserted, in order, as children of the Repeater's parent. The insertion starts immediately after - the repeater's position in its parent stacking list. This is to allow - you to use a Repeater inside a layout. The following QML example shows how - the instantiated items would visually appear stacked between the red and - blue rectangles. - - \snippet doc/src/snippets/declarative/repeater.qml 0 + the repeater's position in its parent stacking list. This allows + a Repeater to be used inside a layout. For example, the following Repeater's + items are stacked between a red rectangle and a blue rectangle: + + \snippet doc/src/snippets/declarative/repeater.qml layout \image repeater.png - The repeater instance continues to own all items it instantiates, even - if they are otherwise manipulated. It is illegal to manually remove an item - created by the Repeater. + A Repeater item owns all items it instantiates. Removing or dynamically destroying + an item created by a Repeater results in unpredictable behavior. - \note Repeater is Item-based, and cannot be used to repeat non-Item-derived objects. + Note that if a repeater is + required to instantiate a large number of items, it may be more efficient to + use other view elements such as ListView. + + \note Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects. For example, it cannot be used to repeat QtObjects. \badcode Item { - //XXX illegal. Can't repeat QtObject as it doesn't derive from Item. + //XXX does not work! Can't repeat QtObject as it doesn't derive from Item. Repeater { model: 10 QtObject {} @@ -149,7 +169,15 @@ QDeclarativeRepeater::~QDeclarativeRepeater() The model providing data for the repeater. - The model may be either an object list, a string list, a number or a Qt model. + This property can be set to any of the following: + + \list + \o A number that indicates the number of delegates to be created + \o A model (e.g. a ListModel item, or a QAbstractItemModel subclass) + \o A string list + \o An object list + \endlist + In each case, the data element and the index is exposed to each instantiated component. The index is always exposed as an accessible \c index property. In the case of an object or string list, the data element (of type string diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 3b89ad9..0fe3c74 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -119,8 +119,6 @@ QSet QTextDocumentWithImageResources::errors; A Text item can display both plain and rich text. For example: \qml - import Qt 4.7 - Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" } Text { text: "Hello World!" } \endqml @@ -128,10 +126,10 @@ QSet QTextDocumentWithImageResources::errors; \image declarative-text.png If height and width are not explicitly set, Text will attempt to determine how - much room is needed and set it accordingly. Unless \c wrapMode is set, it will always + much room is needed and set it accordingly. Unless \l wrapMode is set, it will always prefer width to height (all text will be placed on a single line). - The \c elide property can alternatively be used to fit a single line of + The \l elide property can alternatively be used to fit a single line of plain text to a set width. Note that the \l{Supported HTML Subset} is limited. Also, if the text contains @@ -507,13 +505,11 @@ void QDeclarativeText::setVAlign(VAlignment align) wrap if an explicit width has been set. wrapMode can be one of: \list - \o Text.NoWrap - no wrapping will be performed. If the text contains insufficient newlines, then implicitWidth will exceed a set width. - \o Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, implicitWidth will exceed a set width. + \o Text.NoWrap (default) - no wrapping will be performed. If the text contains insufficient newlines, then \l paintedWidth will exceed a set width. + \o Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, \l paintedWidth will exceed a set width. \o Text.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word. \o Text.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word. \endlist - - The default is Text.NoWrap. */ QDeclarativeText::WrapMode QDeclarativeText::wrapMode() const { @@ -543,13 +539,13 @@ void QDeclarativeText::setWrapMode(WrapMode mode) Supported text formats are: \list - \o Text.AutoText + \o Text.AutoText (default) \o Text.PlainText \o Text.RichText \o Text.StyledText \endlist - The default is Text.AutoText. If the text format is Text.AutoText the text element + If the text format is \c Text.AutoText the text element will automatically determine whether the text should be treated as rich text. This determination is made using Qt::mightBeRichText(). diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index c086851..451f0fa 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -62,25 +62,28 @@ QT_BEGIN_NAMESPACE /*! \qmlclass TextEdit QDeclarativeTextEdit \since 4.7 - \brief The TextEdit item allows you to add editable formatted text to a scene. + \brief The TextEdit item displays multiple lines of editable formatted text. \inherits Item + The TextEdit item displays a block of editable, formatted text. + It can display both plain and rich text. For example: \qml TextEdit { - id: edit + width: 240 text: "Hello World!" - focus: true font.family: "Helvetica" font.pointSize: 20 color: "blue" - width: 240 + focus: true } \endqml \image declarative-textedit.gif + Setting \l {Item::focus}{focus} to \c true enables the TextEdit item to receive keyboard focus. + Note that the TextEdit does not implement scrolling, following the cursor, or other behaviors specific to a look-and-feel. For example, to add flickable scrolling that follows the cursor: @@ -96,7 +99,7 @@ TextEdit { You can translate between cursor positions (characters from the start of the document) and pixel points using positionAt() and positionToRectangle(). - \sa Text + \sa Text, TextInput */ /*! @@ -206,7 +209,7 @@ QString QDeclarativeTextEdit::text() const Sets the font size in pixels. Using this function makes the font device dependent. - Use \c pointSize to set the size of the font in a device independent manner. + Use \l pointSize to set the size of the font in a device independent manner. */ /*! @@ -453,12 +456,22 @@ void QDeclarativeTextEdit::setSelectedTextColor(const QColor &color) \qmlproperty enumeration TextEdit::horizontalAlignment \qmlproperty enumeration TextEdit::verticalAlignment - Sets the horizontal and vertical alignment of the text within the TextEdit items + Sets the horizontal and vertical alignment of the text within the TextEdit item's width and height. By default, the text is top-left aligned. - The valid values for \c horizontalAlignment are \c TextEdit.AlignLeft, \c TextEdit.AlignRight and - \c TextEdit.AlignHCenter. The valid values for \c verticalAlignment are \c TextEdit.AlignTop, \c TextEdit.AlignBottom - and \c TextEdit.AlignVCenter. + Valid values for \c horizontalAlignment are: + \list + \o TextEdit.AlignLeft (default) + \o TextEdit.AlignRight + \o TextEdit.AlignHCenter + \endlist + + Valid values for \c verticalAlignment are: + \list + \o TextEdit.AlignTop (default) + \o TextEdit.AlignBottom + \c TextEdit.AlignVCenter + \endlist */ QDeclarativeTextEdit::HAlignment QDeclarativeTextEdit::hAlign() const { @@ -529,8 +542,8 @@ void QDeclarativeTextEdit::setWrapMode(WrapMode mode) /*! \qmlproperty real TextEdit::paintedWidth - Returns the width of the text, including width past the width - which is covered due to insufficient wrapping if WrapMode is set. + Returns the width of the text, including the width past the width + which is covered due to insufficient wrapping if \l wrapMode is set. */ qreal QDeclarativeTextEdit::paintedWidth() const { @@ -540,8 +553,8 @@ qreal QDeclarativeTextEdit::paintedWidth() const /*! \qmlproperty real TextEdit::paintedHeight - Returns the height of the text, including height past the height - which is covered due to there being more text than fits in the set height. + Returns the height of the text, including the height past the height + that is covered if the text does not fit within the set height. */ qreal QDeclarativeTextEdit::paintedHeight() const { @@ -567,10 +580,10 @@ QRectF QDeclarativeTextEdit::positionToRectangle(int pos) const /*! \qmlmethod int TextEdit::positionAt(x,y) - Returns the text position closest to pixel position (\a x,\a y). + Returns the text position closest to pixel position (\a x, \a y). Position 0 is before the first character, position 1 is after the first character - but before the second, and so on until position text.length, which is after all characters. + but before the second, and so on until position \l {text}.length, which is after all characters. */ int QDeclarativeTextEdit::positionAt(int x, int y) const { @@ -1082,7 +1095,7 @@ void QDeclarativeTextEdit::copy() /*! \qmlmethod TextEdit::paste() - Relaces the currently selected text by the contents of the system clipboard. + Replaces the currently selected text by the contents of the system clipboard. */ void QDeclarativeTextEdit::paste() { @@ -1395,7 +1408,7 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption() the panels are automatically opened when TextEdit element gains focus. Input panels are always closed if no editor owns focus. - . You can disable the automatic behavior by setting the property \c focusOnPress to false + You can disable the automatic behavior by setting the property \c focusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement the behavior you want. @@ -1446,7 +1459,7 @@ void QDeclarativeTextEdit::openSoftwareInputPanel() the panels are automatically opened when TextEdit element gains focus. Input panels are always closed if no editor owns focus. - . You can disable the automatic behavior by setting the property \c focusOnPress to false + You can disable the automatic behavior by setting the property \c focusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement the behavior you want. diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 01b1447..ad7a3a7 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -56,17 +56,20 @@ QT_BEGIN_NAMESPACE /*! \qmlclass TextInput QDeclarativeTextInput \since 4.7 - \brief The TextInput item allows you to add an editable line of text to a scene. + \brief The TextInput item displays an editable line of text. \inherits Item - TextInput can only display a single line of text, and can only display - plain text. However it can provide addition input constraints on the text. + The TextInput element displays a single line of editable plain text. - Input constraints include setting a QValidator, an input mask, or a - maximum input length. + TextInput is used to accept a line of text input. Input constraints + can be placed on a TextInput item (for example, through a \l validator or \l inputMask), + and setting \l echoMode to an appropriate value enables TextInput to be used for + a password input field. On Mac OS X, the Up/Down key bindings for Home/End are explicitly disabled. If you want such bindings (on any platform), you will need to construct them in QML. + + \sa TextEdit, Text */ QDeclarativeTextInput::QDeclarativeTextInput(QDeclarativeItem* parent) : QDeclarativePaintedItem(*(new QDeclarativeTextInputPrivate), parent) @@ -558,7 +561,7 @@ void QDeclarativeTextInput::setAutoScroll(bool b) /*! \qmlclass IntValidator QIntValidator - This element provides a validator for integer values + This element provides a validator for integer values. */ /*! \qmlproperty int IntValidator::top @@ -601,10 +604,14 @@ void QDeclarativeTextInput::setAutoScroll(bool b) \qmlproperty enumeration DoubleValidator::notation This property holds the notation of how a string can describe a number. - The values for this property are DoubleValidator.StandardNotation or DoubleValidator.ScientificNotation. - If this property is set to DoubleValidator.ScientificNotation, the written number may have an exponent part(i.e. 1.5E-2). + The possible values for this property are: + + \list + \o DoubleValidator.StandardNotation + \o DoubleValidator.ScientificNotation (default) + \endlist - By default, this property is set to DoubleValidator.ScientificNotation. + If this property is set to DoubleValidator.ScientificNotation, the written number may have an exponent part (e.g. 1.5E-2). */ /*! diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 3c2e239..83bdb17 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -79,18 +79,27 @@ public: /*! \qmlclass FontLoader QDeclarativeFontLoader \since 4.7 - \brief This item allows using fonts by name or url. + \brief The FontLoader element allows fonts to be loaded by name or URL. - Example: + The FontLoader element is used to load fonts by name or URL. + + The \l status indicates when the font has been loaded, which is useful + for fonts loaded from remote sources. + + For example: \qml import Qt 4.7 - FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" } + Column { + FontLoader { id: fixedFont; name: "Courier" } + FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" } - Text { text: "Fixed-size font"; font.family: fixedFont.name } - Text { text: "Fancy font"; font.family: webFont.name } + Text { text: "Fixed-size font"; font.family: fixedFont.name } + Text { text: "Fancy font"; font.family: webFont.name } + } \endqml + + \sa {declarative/text/fonts}{Fonts example} */ QDeclarativeFontLoader::QDeclarativeFontLoader(QObject *parent) : QObject(*(new QDeclarativeFontLoaderPrivate), parent) diff --git a/src/declarative/util/qdeclarativesystempalette.cpp b/src/declarative/util/qdeclarativesystempalette.cpp index 6c62446..c334859 100644 --- a/src/declarative/util/qdeclarativesystempalette.cpp +++ b/src/declarative/util/qdeclarativesystempalette.cpp @@ -59,22 +59,25 @@ public: /*! \qmlclass SystemPalette QDeclarativeSystemPalette \since 4.7 - \brief The SystemPalette item gives access to the Qt palettes. - \sa QPalette + \brief The SystemPalette element provides access to the Qt palettes. - Example: - \qml - SystemPalette { id: myPalette; colorGroup: Qt.Active } + The SystemPalette element provides access to the Qt application + palettes. This provides information about the standard colors used + for application windows, buttons and other features. These colors + are grouped into three \e {color groups}: \c Active, \c Inactive, + and \c Disabled. See the QPalette documentation for details about + color groups and the properties provided by SystemPalette. - Rectangle { - width: 640; height: 480 - color: myPalette.window - Text { - anchors.fill: parent - text: "Hello!"; color: myPalette.windowText - } - } - \endqml + This can be used to color items in a way that provides a more + native look and feel. + + The following example creates a palette from the \c Active color + group and uses this to color the window and text items + appropriately: + + \snippet doc/src/snippets/declarative/systempalette.qml 0 + + \sa QPalette */ QDeclarativeSystemPalette::QDeclarativeSystemPalette(QObject *parent) : QObject(*(new QDeclarativeSystemPalettePrivate), parent) @@ -258,10 +261,15 @@ QColor QDeclarativeSystemPalette::highlightedText() const } /*! - \qmlproperty QDeclarativeSystemPalette::ColorGroup SystemPalette::colorGroup + \qmlproperty enumeration SystemPalette::colorGroup + + The color group of the palette. This can be one of: - The color group of the palette. It can be Active, Inactive or Disabled. - Active is the default. + \list + \o SystemPalette.Active (default) + \o SystemPalette.Inactive + \o SystemPalette.Disabled + \endlist \sa QPalette::ColorGroup */ -- cgit v0.12 From 6f420a858afabf906977072f5efc67cdfc831d99 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 11 Jun 2010 11:45:55 +1000 Subject: Minor doc fixes --- src/declarative/graphicsitems/qdeclarativeborderimage.cpp | 2 +- src/declarative/graphicsitems/qdeclarativeimage.cpp | 2 +- src/declarative/graphicsitems/qdeclarativemousearea.cpp | 4 ++-- src/declarative/graphicsitems/qdeclarativetext.cpp | 2 +- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 +- src/declarative/qml/qdeclarativeworkerscript.cpp | 5 ++++- src/declarative/util/qdeclarativelistmodel.cpp | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 1f1e453..cf458da 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -138,7 +138,7 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() BorderImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. - It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies + It can also handle .sci files, which are a QML-specific format. A .sci file uses a simple text-based format that specifies the borders, the image file and the tile rules. The following .sci file sets the borders to 10 on each side for the image \c picture.png: diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 463ad5a..ec08517 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -97,7 +97,7 @@ QT_BEGIN_NAMESPACE Image { source: "pics/star.png" } \endqml - A QDeclarativeImage object can be instantiated in Qml using the tag \l Image. + A QDeclarativeImage object can be instantiated in QML using the tag \l Image. */ QDeclarativeImage::QDeclarativeImage(QDeclarativeItem *parent) diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index a68e664..c4956df 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -305,12 +305,12 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() /*! \internal \class QDeclarativeMouseArea - \brief The QDeclarativeMouseArea class provides a simple mouse handling abstraction for use within Qml. + \brief The QDeclarativeMouseArea class provides a simple mouse handling abstraction for use within QML. All QDeclarativeItem derived classes can do mouse handling but the QDeclarativeMouseArea class exposes mouse handling data as properties and tracks flicking and dragging of the mouse. - A QDeclarativeMouseArea object can be instantiated in Qml using the tag \l MouseArea. + A QDeclarativeMouseArea object can be instantiated in QML using the tag \l MouseArea. */ QDeclarativeMouseArea::QDeclarativeMouseArea(QDeclarativeItem *parent) : QDeclarativeItem(*(new QDeclarativeMouseAreaPrivate), parent) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 0fe3c74..c2e0d67 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -161,7 +161,7 @@ QSet QTextDocumentWithImageResources::errors; The \c elide property can alternatively be used to fit a line of plain text to a set width. - A QDeclarativeText object can be instantiated in Qml using the tag \c Text. + A QDeclarativeText object can be instantiated in QML using the tag \c Text. */ QDeclarativeText::QDeclarativeText(QDeclarativeItem *parent) : QDeclarativeItem(*(new QDeclarativeTextPrivate), parent) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 451f0fa..3b4f2a7 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -113,7 +113,7 @@ TextEdit { \image declarative-textedit.png - A QDeclarativeTextEdit object can be instantiated in Qml using the tag \c <TextEdit>. + A QDeclarativeTextEdit object can be instantiated in QML using the tag \c <TextEdit>. */ /*! diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index e0ee84f..aec84a6 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -523,7 +523,7 @@ void QDeclarativeWorkerScriptEngine::run() Messages can be passed between the new thread and the parent thread using \l sendMessage() and the \l {WorkerScript::onMessage}{onMessage()} handler. - Here is an example: + An example: \snippet doc/src/snippets/declarative/workerscript.qml 0 @@ -541,6 +541,9 @@ void QDeclarativeWorkerScriptEngine::run() called, triggering the \tt WorkerScript.onMessage() handler in \tt script.js. This in turn sends a reply message that is then received by the \tt onMessage() handler of \tt myWorker. + + \sa {declarative/threading/workerscript}{WorkerScript example}, + {declarative/threading/threadedlistmodel}{Threaded ListModel example} */ QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent) : QObject(parent), m_engine(0), m_scriptId(-1), m_componentComplete(true) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 78a3207..ff83227 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -160,7 +160,7 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM In addition, the WorkerScript cannot add any list data to the model. - \sa {qmlmodels}{Data Models}, WorkerScript, QtDeclarative + \sa {qmlmodels}{Data Models}, {declarative/threading/threadedlistmodel}{Threaded ListModel example}, QtDeclarative */ -- cgit v0.12 From 5e99815f85c953760d027be50caea5a386b6b710 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 11 Jun 2010 14:15:30 +1000 Subject: Fix test - sizeHint should not change after initial load. Also use QTRY_COMPARE for some tests. --- .../declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index c249414..f30f758 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -93,7 +93,7 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -103,7 +103,7 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(rootItem->width(), 300.0); QCOMPARE(rootItem->height(), 200.0); - QCOMPARE(viewer->view()->size(), QSize(300, 200)); + QTRY_COMPARE(viewer->view()->size(), QSize(300, 200)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200)); QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height())); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -113,7 +113,7 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -265,7 +265,6 @@ void tst_QDeclarativeViewer::resizing() QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200)); QCOMPARE(viewer->size(), QSize(150, 200+viewer->menuBar()->height())); - QCOMPARE(viewer->size(), viewer->sizeHint()); // do not size root object to view viewer->resize(QSize(180,250)); @@ -284,7 +283,6 @@ void tst_QDeclarativeViewer::resizing() QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350-viewer->menuBar()->height())); QCOMPARE(viewer->size(), QSize(250, 350)); - QCOMPARE(viewer->size(), viewer->sizeHint()); // do not size view to root object rootItem->setWidth(150); -- cgit v0.12 From db414f8db1cca5d811416eb1ecec0536c379e107 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 11 Jun 2010 15:11:12 +1000 Subject: Make snapping work properly for highlight ranges > item size Snapping was only being applied to the current item when it was at a highlight range boundary. Task-number: QTBUG-11304 --- .../graphicsitems/qdeclarativegridview.cpp | 62 +++++++++++++++++----- .../graphicsitems/qdeclarativelistview.cpp | 50 +++++++++++------ 2 files changed, 84 insertions(+), 28 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index da01eb5..dc2bbd9 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -278,6 +278,20 @@ public: return snapPos; } + FxGridItem *snapItemAt(qreal pos) { + for (int i = 0; i < visibleItems.count(); ++i) { + FxGridItem *item = visibleItems[i]; + if (item->index == -1) + continue; + qreal itemTop = item->rowPos(); + if (item->index == model->count()-1 || (itemTop+rowSize()/2 >= pos)) + return item; + } + if (visibleItems.count() && visibleItems.first()->rowPos() <= pos) + return visibleItems.first(); + return 0; + } + int snapIndex() { int index = currentIndex; for (int i = 0; i < visibleItems.count(); ++i) { @@ -877,7 +891,6 @@ void QDeclarativeGridViewPrivate::fixupPosition() void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) { - Q_Q(QDeclarativeGridView); if ((flow == QDeclarativeGridView::TopToBottom && &data == &vData) || (flow == QDeclarativeGridView::LeftToRight && &data == &hData)) return; @@ -885,7 +898,41 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m int oldDuration = fixupDuration; fixupDuration = moveReason == Mouse ? fixupDuration : 0; - if (haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) { + if (snapMode != QDeclarativeGridView::NoSnap) { + FxGridItem *topItem = snapItemAt(position()+highlightRangeStart); + FxGridItem *bottomItem = snapItemAt(position()+highlightRangeEnd); + qreal pos; + if (topItem && bottomItem && haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) { + qreal topPos = qMin(topItem->rowPos() - highlightRangeStart, -maxExtent); + qreal bottomPos = qMax(bottomItem->rowPos() - highlightRangeEnd, -minExtent); + pos = qAbs(data.move + topPos) < qAbs(data.move + bottomPos) ? topPos : bottomPos; + } else if (topItem) { + pos = qMax(qMin(topItem->rowPos() - highlightRangeStart, -maxExtent), -minExtent); + } else if (bottomItem) { + pos = qMax(qMin(bottomItem->rowPos() - highlightRangeStart, -maxExtent), -minExtent); + } else { + fixupDuration = oldDuration; + return; + } + if (currentItem && haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) { + updateHighlight(); + qreal currPos = currentItem->rowPos(); + if (pos < currPos + rowSize() - highlightRangeEnd) + pos = currPos + rowSize() - highlightRangeEnd; + if (pos > currPos - highlightRangeStart) + pos = currPos - highlightRangeStart; + } + + qreal dist = qAbs(data.move + pos); + if (dist > 0) { + timeline.reset(data.move); + if (fixupDuration) + timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); + else + timeline.set(data.move, -pos); + vTime = timeline.time(); + } + } else if (haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) { if (currentItem) { updateHighlight(); qreal pos = currentItem->rowPos(); @@ -904,17 +951,6 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m } vTime = timeline.time(); } - } else if (snapMode != QDeclarativeGridView::NoSnap) { - qreal pos = -snapPosAt(-(data.move.value() - highlightRangeStart)) + highlightRangeStart; - qreal dist = qAbs(data.move.value() - pos); - if (dist > 0) { - timeline.reset(data.move); - if (fixupDuration) - timeline.move(data.move, pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - else - timeline.set(data.move, pos); - vTime = timeline.time(); - } } else { QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 4848008..72be670 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1124,7 +1124,6 @@ void QDeclarativeListViewPrivate::fixupPosition() void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) { - Q_Q(QDeclarativeListView); if ((orient == QDeclarativeListView::Horizontal && &data == &vData) || (orient == QDeclarativeListView::Vertical && &data == &hData)) return; @@ -1132,7 +1131,41 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m int oldDuration = fixupDuration; fixupDuration = moveReason == Mouse ? fixupDuration : 0; - if (haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) { + if (snapMode != QDeclarativeListView::NoSnap) { + FxListItem *topItem = snapItemAt(position()+highlightRangeStart); + FxListItem *bottomItem = snapItemAt(position()+highlightRangeEnd); + qreal pos; + if (topItem && bottomItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) { + qreal topPos = qMin(topItem->position() - highlightRangeStart, -maxExtent); + qreal bottomPos = qMax(bottomItem->position() - highlightRangeEnd, -minExtent); + pos = qAbs(data.move + topPos) < qAbs(data.move + bottomPos) ? topPos : bottomPos; + } else if (topItem) { + pos = qMax(qMin(topItem->position() - highlightRangeStart, -maxExtent), -minExtent); + } else if (bottomItem) { + pos = qMax(qMin(bottomItem->position() - highlightRangeStart, -maxExtent), -minExtent); + } else { + fixupDuration = oldDuration; + return; + } + if (currentItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) { + updateHighlight(); + qreal currPos = currentItem->position(); + if (pos < currPos + currentItem->size() - highlightRangeEnd) + pos = currPos + currentItem->size() - highlightRangeEnd; + if (pos > currPos - highlightRangeStart) + pos = currPos - highlightRangeStart; + } + + qreal dist = qAbs(data.move + pos); + if (dist > 0) { + timeline.reset(data.move); + if (fixupDuration) + timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); + else + timeline.set(data.move, -pos); + vTime = timeline.time(); + } + } else if (haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) { if (currentItem) { updateHighlight(); qreal pos = currentItem->position(); @@ -1151,19 +1184,6 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m } vTime = timeline.time(); } - } else if (snapMode != QDeclarativeListView::NoSnap) { - if (FxListItem *item = snapItemAt(position())) { - qreal pos = qMin(item->position() - highlightRangeStart, -maxExtent); - qreal dist = qAbs(data.move + pos); - if (dist > 0) { - timeline.reset(data.move); - if (fixupDuration) - timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - else - timeline.set(data.move, -pos); - vTime = timeline.time(); - } - } } else { QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); } -- cgit v0.12 From f0bb05cb7e85715d8a47c5d1ddd603edc6959c20 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 11 Jun 2010 14:59:09 +1000 Subject: Move listview/itemlist.qml to a separate visualitemmodel example --- doc/src/declarative/examples.qdoc | 1 + doc/src/examples/qml-examples.qdoc | 7 + .../modelviews/listview/content/pics/add.png | Bin 1577 -> 0 bytes .../modelviews/listview/content/pics/del.png | Bin 1661 -> 0 bytes .../modelviews/listview/content/pics/trash.png | Bin 989 -> 0 bytes .../declarative/modelviews/listview/dynamic.qml | 281 --------------------- .../modelviews/listview/dynamiclist.qml | 281 +++++++++++++++++++++ .../modelviews/listview/expandingdelegates.qml | 200 +++++++++++++++ .../modelviews/listview/highlightranges.qml | 133 ++++++++++ .../declarative/modelviews/listview/itemlist.qml | 107 -------- .../modelviews/listview/listview-example.qml | 133 ---------- .../declarative/modelviews/listview/recipes.qml | 200 --------------- .../modelviews/visualitemmodel/visualitemmodel.qml | 107 ++++++++ .../visualitemmodel/visualitemmodel.qmlproject | 16 ++ .../graphicsitems/qdeclarativevisualitemmodel.cpp | 2 + 15 files changed, 747 insertions(+), 721 deletions(-) delete mode 100644 examples/declarative/modelviews/listview/content/pics/add.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/del.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/trash.png delete mode 100644 examples/declarative/modelviews/listview/dynamic.qml create mode 100644 examples/declarative/modelviews/listview/dynamiclist.qml create mode 100644 examples/declarative/modelviews/listview/expandingdelegates.qml create mode 100644 examples/declarative/modelviews/listview/highlightranges.qml delete mode 100644 examples/declarative/modelviews/listview/itemlist.qml delete mode 100644 examples/declarative/modelviews/listview/listview-example.qml delete mode 100644 examples/declarative/modelviews/listview/recipes.qml create mode 100644 examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml create mode 100644 examples/declarative/modelviews/visualitemmodel/visualitemmodel.qmlproject diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index cc67664..ad8c10c 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -118,6 +118,7 @@ For example, from your build directory, run: \o \l{declarative/modelviews/package}{Package} \o \l{declarative/modelviews/parallax}{Parallax} \o \l{declarative/modelviews/stringlistmodel}{String ListModel} +\o \l{declarative/modelviews/visualitemmodel}{VisualItemModel} \o \l{declarative/modelviews/webview}{WebView} \endlist diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index 9dbf853..b6069f2 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -247,6 +247,13 @@ */ /*! + \title Models and Views: VisualItemModel + \example declarative/modelviews/visualitemmodel + + This example shows how to use the VisualItemModel element. +*/ + +/*! \title Models and Views: WebView \example declarative/modelviews/webview diff --git a/examples/declarative/modelviews/listview/content/pics/add.png b/examples/declarative/modelviews/listview/content/pics/add.png deleted file mode 100644 index f29d84b..0000000 Binary files a/examples/declarative/modelviews/listview/content/pics/add.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/del.png b/examples/declarative/modelviews/listview/content/pics/del.png deleted file mode 100644 index 1d753a3..0000000 Binary files a/examples/declarative/modelviews/listview/content/pics/del.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/trash.png b/examples/declarative/modelviews/listview/content/pics/trash.png deleted file mode 100644 index 2042595..0000000 Binary files a/examples/declarative/modelviews/listview/content/pics/trash.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/dynamic.qml b/examples/declarative/modelviews/listview/dynamic.qml deleted file mode 100644 index df2e094..0000000 --- a/examples/declarative/modelviews/listview/dynamic.qml +++ /dev/null @@ -1,281 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 -import "content" -import "../../ui-components/scrollbar" - -Rectangle { - id: container - width: 640; height: 480 - color: "#343434" - - ListModel { - id: fruitModel - - ListElement { - name: "Apple"; cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Banana"; cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } - ListElement { - name: "Cumquat"; cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Durian"; cost: 9.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Smelly" } - ] - } - ListElement { - name: "Elderberry"; cost: 0.05 - attributes: [ - ListElement { description: "Berry" } - ] - } - ListElement { - name: "Fig"; cost: 0.25 - attributes: [ - ListElement { description: "Flower" } - ] - } - } - - Component { - id: fruitDelegate - - Item { - id: wrapper - width: container.width; height: 55 - - Column { - id: moveButtons - x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter - - Image { - source: "content/pics/go-up.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) } - } - Image { source: "content/pics/go-down.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index+1,1) } - } - } - - Column { - anchors { right: itemButtons.left; verticalCenter: parent.verticalCenter; left: moveButtons.right; leftMargin: 10 } - - Text { - id: label - width: parent.width - color: "White" - font.bold: true; font.pixelSize: 15 - text: name; elide: Text.ElideRight - } - Row { - spacing: 5 - Repeater { - model: attributes - Component { - Text { text: description; color: "White" } - } - } - } - } - - Row { - id: itemButtons - - anchors { right: removeButton.left; rightMargin: 35; verticalCenter: parent.verticalCenter } - width: childrenRect.width - spacing: 10 - - Image { - source: "content/pics/list-add.png" - scale: clickUp.isPressed ? 0.9 : 1 - - ClickAutoRepeating { - id: clickUp - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", cost+0.25) - } - } - - Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; } - - Image { - source: "content/pics/list-remove.png" - scale: clickDown.isPressed ? 0.9 : 1 - - ClickAutoRepeating { - id: clickDown - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) - } - } - } - Image { - id: removeButton - anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 } - source: "content/pics/archive-remove.png" - - MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } - } - - // Animate adding and removing items - ListView.delayRemove: true // so that the item is not destroyed immediately - ListView.onAdd: state = "add" - ListView.onRemove: state = "remove" - states: [ - State { - name: "add" - PropertyChanges { target: wrapper; height: 55; clip: true } - }, - State { - name: "remove" - PropertyChanges { target: wrapper; height: 0; clip: true } - } - ] - transitions: [ - Transition { - to: "add" - SequentialAnimation { - NumberAnimation { properties: "height"; from: 0; to: 55 } - PropertyAction { target: wrapper; property: "state"; value: "" } - } - }, - Transition { - to: "remove" - SequentialAnimation { - NumberAnimation { properties: "height" } - // Make sure delayRemove is set back to false so that the item can be destroyed - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } - } - } - ] - } - } - - ListView { - id: view - anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top } - model: fruitModel - delegate: fruitDelegate - } - - // Attach scrollbar to the right edge of the view. - ScrollBar { - id: verticalScrollBar - - width: 8; height: view.height; anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - - // Only show the scrollbar when the view is moving. - states: State { - name: "ShowBars"; when: view.movingVertically - PropertyChanges { target: verticalScrollBar; opacity: 1 } - } - transitions: Transition { - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - Row { - id: buttons - - x: 8; width: childrenRect.width; height: childrenRect.height - anchors { bottom: parent.bottom; bottomMargin: 8 } - spacing: 8 - - Image { - source: "content/pics/archive-insert.png" - - MouseArea { - anchors.fill: parent - onClicked: { - fruitModel.append({ - "name": "Pizza Margarita", - "cost": 5.95, - "attributes": [{"description": "Cheese"},{"description": "Tomato"}] - }) - } - } - } - - Image { - source: "content/pics/archive-insert.png" - - MouseArea { - anchors.fill: parent; - onClicked: { - fruitModel.insert(0, { - "name": "Pizza Supreme", - "cost": 9.95, - "attributes": [{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}] - }) - } - } - } - - Image { - source: "content/pics/archive-remove.png" - - MouseArea { - anchors.fill: parent - onClicked: fruitModel.clear() - } - } - } -} diff --git a/examples/declarative/modelviews/listview/dynamiclist.qml b/examples/declarative/modelviews/listview/dynamiclist.qml new file mode 100644 index 0000000..df2e094 --- /dev/null +++ b/examples/declarative/modelviews/listview/dynamiclist.qml @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 +import "content" +import "../../ui-components/scrollbar" + +Rectangle { + id: container + width: 640; height: 480 + color: "#343434" + + ListModel { + id: fruitModel + + ListElement { + name: "Apple"; cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Banana"; cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } + ListElement { + name: "Cumquat"; cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Durian"; cost: 9.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Smelly" } + ] + } + ListElement { + name: "Elderberry"; cost: 0.05 + attributes: [ + ListElement { description: "Berry" } + ] + } + ListElement { + name: "Fig"; cost: 0.25 + attributes: [ + ListElement { description: "Flower" } + ] + } + } + + Component { + id: fruitDelegate + + Item { + id: wrapper + width: container.width; height: 55 + + Column { + id: moveButtons + x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter + + Image { + source: "content/pics/go-up.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) } + } + Image { source: "content/pics/go-down.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index+1,1) } + } + } + + Column { + anchors { right: itemButtons.left; verticalCenter: parent.verticalCenter; left: moveButtons.right; leftMargin: 10 } + + Text { + id: label + width: parent.width + color: "White" + font.bold: true; font.pixelSize: 15 + text: name; elide: Text.ElideRight + } + Row { + spacing: 5 + Repeater { + model: attributes + Component { + Text { text: description; color: "White" } + } + } + } + } + + Row { + id: itemButtons + + anchors { right: removeButton.left; rightMargin: 35; verticalCenter: parent.verticalCenter } + width: childrenRect.width + spacing: 10 + + Image { + source: "content/pics/list-add.png" + scale: clickUp.isPressed ? 0.9 : 1 + + ClickAutoRepeating { + id: clickUp + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", cost+0.25) + } + } + + Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; } + + Image { + source: "content/pics/list-remove.png" + scale: clickDown.isPressed ? 0.9 : 1 + + ClickAutoRepeating { + id: clickDown + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + } + } + } + Image { + id: removeButton + anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 } + source: "content/pics/archive-remove.png" + + MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + } + + // Animate adding and removing items + ListView.delayRemove: true // so that the item is not destroyed immediately + ListView.onAdd: state = "add" + ListView.onRemove: state = "remove" + states: [ + State { + name: "add" + PropertyChanges { target: wrapper; height: 55; clip: true } + }, + State { + name: "remove" + PropertyChanges { target: wrapper; height: 0; clip: true } + } + ] + transitions: [ + Transition { + to: "add" + SequentialAnimation { + NumberAnimation { properties: "height"; from: 0; to: 55 } + PropertyAction { target: wrapper; property: "state"; value: "" } + } + }, + Transition { + to: "remove" + SequentialAnimation { + NumberAnimation { properties: "height" } + // Make sure delayRemove is set back to false so that the item can be destroyed + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } + } + } + ] + } + } + + ListView { + id: view + anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top } + model: fruitModel + delegate: fruitDelegate + } + + // Attach scrollbar to the right edge of the view. + ScrollBar { + id: verticalScrollBar + + width: 8; height: view.height; anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + + // Only show the scrollbar when the view is moving. + states: State { + name: "ShowBars"; when: view.movingVertically + PropertyChanges { target: verticalScrollBar; opacity: 1 } + } + transitions: Transition { + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + Row { + id: buttons + + x: 8; width: childrenRect.width; height: childrenRect.height + anchors { bottom: parent.bottom; bottomMargin: 8 } + spacing: 8 + + Image { + source: "content/pics/archive-insert.png" + + MouseArea { + anchors.fill: parent + onClicked: { + fruitModel.append({ + "name": "Pizza Margarita", + "cost": 5.95, + "attributes": [{"description": "Cheese"},{"description": "Tomato"}] + }) + } + } + } + + Image { + source: "content/pics/archive-insert.png" + + MouseArea { + anchors.fill: parent; + onClicked: { + fruitModel.insert(0, { + "name": "Pizza Supreme", + "cost": 9.95, + "attributes": [{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}] + }) + } + } + } + + Image { + source: "content/pics/archive-remove.png" + + MouseArea { + anchors.fill: parent + onClicked: fruitModel.clear() + } + } + } +} diff --git a/examples/declarative/modelviews/listview/expandingdelegates.qml b/examples/declarative/modelviews/listview/expandingdelegates.qml new file mode 100644 index 0000000..f4b97ea --- /dev/null +++ b/examples/declarative/modelviews/listview/expandingdelegates.qml @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 +import "content" + +// This example illustrates expanding a list item to show a more detailed view + +Rectangle { + id: page + width: 400; height: 240 + color: "black" + + // Delegate for the recipes. This delegate has two modes: + // 1. the list mode (default), which just shows the picture and title of the recipe. + // 2. the details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: wrapper + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + width: list.width + + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 1; y: 2; width: parent.width - 2; height: parent.height - 4 + color: "#FEFFEE" + border.color: "#FFBE4F" + radius: 5 + } + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + id: pageMouse + anchors.fill: parent + onClicked: wrapper.state = 'Details'; + } + + // Layout the page. Picture, title and ingredients at the top, method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to wrapper.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipePic.height; width: parent.width + spacing: 10 + + Image { + id: recipePic + source: picture; width: 48; height: 48 + } + + Column { + width: background.width-recipePic.width-20; height: recipePic.height; + spacing: 5 + + Text { id: name; text: title; font.bold: true; font.pointSize: 16 } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: wrapper.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: wrapper.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width-20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: wrapper.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height; clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + MediaButton { + y: 10; anchors { right: background.right; rightMargin: 5 } + opacity: wrapper.detailsOpacity + text: "Close" + + onClicked: wrapper.state = ''; + } + + // Set the default height to the height of the picture, plus margin. + height: 68 + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipePic; width: 128; height: 128 } // Make picture bigger + PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 } // Make details visible + PropertyChanges { target: wrapper; height: list.height } // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + PropertyChanges { target: wrapper.ListView.view; explicit: true; contentY: wrapper.y } + + // Disallow flicking while we're in detailed view + PropertyChanges { target: wrapper.ListView.view; interactive: false } + } + + transitions: Transition { + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } + } + } + } + } + + // The actual list + ListView { + id: list + anchors.fill: parent + clip: true + model: Recipes + delegate: recipeDelegate + } +} diff --git a/examples/declarative/modelviews/listview/highlightranges.qml b/examples/declarative/modelviews/listview/highlightranges.qml new file mode 100644 index 0000000..a8a95c4 --- /dev/null +++ b/examples/declarative/modelviews/listview/highlightranges.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +Rectangle { + width: 600; height: 300 + + // MyPets model is defined in dummydata/MyPetsModel.qml + // The viewer automatically loads files in dummydata/* to assist + // development without a real data source. + // This one contains my pets. + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + width: 200; height: 50 + Column { + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + } + } + + // Define a highlight component. Just one of these will be instantiated + // by each ListView and placed behind the current item. + Component { + id: petHighlight + Rectangle { color: "#FFFF88" } + } + + // Show the model in three lists, with different highlight ranges. + // preferredHighlightBegin and preferredHighlightEnd set the + // range in which to attempt to maintain the highlight. + // + // Note that the second and third ListView + // set their currentIndex to be the same as the first, and that + // the first ListView is given keyboard focus. + // + // The default mode allows the currentItem to move freely + // within the visible area. If it would move outside the visible + // area, the view is scrolled to keep it visible. + // + // The second list sets a highlight range which attempts to keep the + // 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 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. + // + // Note that the first ListView sets its currentIndex to be equal to + // the third ListView's currentIndex. By flicking List3 with + // the mouse, the current index of List1 will be changed. + + ListView { + id: list1 + width: 200; height: parent.height + model: MyPetsModel + delegate: petDelegate + + highlight: petHighlight + currentIndex: list3.currentIndex + focus: true + } + + ListView { + id: list2 + x: 200; width: 200; height: parent.height + model: MyPetsModel + delegate: petDelegate + + highlight: petHighlight + currentIndex: list1.currentIndex + preferredHighlightBegin: 80; preferredHighlightEnd: 220 + highlightRangeMode: ListView.ApplyRange + } + + ListView { + id: list3 + x: 400; width: 200; height: parent.height + model: MyPetsModel + delegate: petDelegate + + highlight: Rectangle { color: "lightsteelblue" } + currentIndex: list1.currentIndex + preferredHighlightBegin: 125; preferredHighlightEnd: 125 + highlightRangeMode: ListView.StrictlyEnforceRange + flickDeceleration: 1000 + } +} diff --git a/examples/declarative/modelviews/listview/itemlist.qml b/examples/declarative/modelviews/listview/itemlist.qml deleted file mode 100644 index 1b44e05..0000000 --- a/examples/declarative/modelviews/listview/itemlist.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example demonstrates placing items in a view using -// a VisualItemModel - -import Qt 4.7 - -Rectangle { - color: "lightgray" - width: 240 - height: 320 - - VisualItemModel { - id: itemModel - - Rectangle { - width: view.width; height: view.height - color: "#FFFEF0" - Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - width: view.width; height: view.height - color: "#F0FFF7" - Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - width: view.width; height: view.height - color: "#F4F0FF" - Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } - } - } - - ListView { - id: view - anchors { fill: parent; bottomMargin: 30 } - model: itemModel - preferredHighlightBegin: 0; preferredHighlightEnd: 0 - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem; flickDeceleration: 2000 - } - - Rectangle { - width: 240; height: 30 - anchors { top: view.bottom; bottom: parent.bottom } - color: "gray" - - Row { - anchors.centerIn: parent - spacing: 20 - - Repeater { - model: itemModel.count - - Rectangle { - width: 5; height: 5 - radius: 3 - color: view.currentIndex == index ? "blue" : "white" - - MouseArea { - width: 20; height: 20 - anchors.centerIn: parent - onClicked: view.currentIndex = index - } - } - } - } - } -} diff --git a/examples/declarative/modelviews/listview/listview-example.qml b/examples/declarative/modelviews/listview/listview-example.qml deleted file mode 100644 index a8a95c4..0000000 --- a/examples/declarative/modelviews/listview/listview-example.qml +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -Rectangle { - width: 600; height: 300 - - // MyPets model is defined in dummydata/MyPetsModel.qml - // The viewer automatically loads files in dummydata/* to assist - // development without a real data source. - // This one contains my pets. - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - width: 200; height: 50 - Column { - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - } - } - - // Define a highlight component. Just one of these will be instantiated - // by each ListView and placed behind the current item. - Component { - id: petHighlight - Rectangle { color: "#FFFF88" } - } - - // Show the model in three lists, with different highlight ranges. - // preferredHighlightBegin and preferredHighlightEnd set the - // range in which to attempt to maintain the highlight. - // - // Note that the second and third ListView - // set their currentIndex to be the same as the first, and that - // the first ListView is given keyboard focus. - // - // The default mode allows the currentItem to move freely - // within the visible area. If it would move outside the visible - // area, the view is scrolled to keep it visible. - // - // The second list sets a highlight range which attempts to keep the - // 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 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. - // - // Note that the first ListView sets its currentIndex to be equal to - // the third ListView's currentIndex. By flicking List3 with - // the mouse, the current index of List1 will be changed. - - ListView { - id: list1 - width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - - highlight: petHighlight - currentIndex: list3.currentIndex - focus: true - } - - ListView { - id: list2 - x: 200; width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - - highlight: petHighlight - currentIndex: list1.currentIndex - preferredHighlightBegin: 80; preferredHighlightEnd: 220 - highlightRangeMode: ListView.ApplyRange - } - - ListView { - id: list3 - x: 400; width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - - highlight: Rectangle { color: "lightsteelblue" } - currentIndex: list1.currentIndex - preferredHighlightBegin: 125; preferredHighlightEnd: 125 - highlightRangeMode: ListView.StrictlyEnforceRange - flickDeceleration: 1000 - } -} diff --git a/examples/declarative/modelviews/listview/recipes.qml b/examples/declarative/modelviews/listview/recipes.qml deleted file mode 100644 index f4b97ea..0000000 --- a/examples/declarative/modelviews/listview/recipes.qml +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 -import "content" - -// This example illustrates expanding a list item to show a more detailed view - -Rectangle { - id: page - width: 400; height: 240 - color: "black" - - // Delegate for the recipes. This delegate has two modes: - // 1. the list mode (default), which just shows the picture and title of the recipe. - // 2. the details mode, which also shows the ingredients and method. - Component { - id: recipeDelegate - - Item { - id: wrapper - - // Create a property to contain the visibility of the details. - // We can bind multiple element's opacity to this one property, - // rather than having a "PropertyChanges" line for each element we - // want to fade. - property real detailsOpacity : 0 - - width: list.width - - // A simple rounded rectangle for the background - Rectangle { - id: background - x: 1; y: 2; width: parent.width - 2; height: parent.height - 4 - color: "#FEFFEE" - border.color: "#FFBE4F" - radius: 5 - } - - // This mouse region covers the entire delegate. - // When clicked it changes mode to 'Details'. If we are already - // in Details mode, then no change will happen. - MouseArea { - id: pageMouse - anchors.fill: parent - onClicked: wrapper.state = 'Details'; - } - - // Layout the page. Picture, title and ingredients at the top, method at the - // bottom. Note that elements that should not be visible in the list - // mode have their opacity set to wrapper.detailsOpacity. - Row { - id: topLayout - x: 10; y: 10; height: recipePic.height; width: parent.width - spacing: 10 - - Image { - id: recipePic - source: picture; width: 48; height: 48 - } - - Column { - width: background.width-recipePic.width-20; height: recipePic.height; - spacing: 5 - - Text { id: name; text: title; font.bold: true; font.pointSize: 16 } - - Text { - text: "Ingredients" - font.pointSize: 12; font.bold: true - opacity: wrapper.detailsOpacity - } - - Text { - text: ingredients - wrapMode: Text.WordWrap - width: parent.width - opacity: wrapper.detailsOpacity - } - } - } - - Item { - id: details - x: 10; width: parent.width-20 - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: wrapper.detailsOpacity - - Text { - id: methodTitle - anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height; clip: true - - Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } - } - - Image { - anchors { right: flick.right; top: flick.top } - source: "content/pics/moreUp.png" - opacity: flick.atYBeginning ? 0 : 1 - } - - Image { - anchors { right: flick.right; bottom: flick.bottom } - source: "content/pics/moreDown.png" - opacity: flick.atYEnd ? 0 : 1 - } - } - - // A button to close the detailed view, i.e. set the state back to default (''). - MediaButton { - y: 10; anchors { right: background.right; rightMargin: 5 } - opacity: wrapper.detailsOpacity - text: "Close" - - onClicked: wrapper.state = ''; - } - - // Set the default height to the height of the picture, plus margin. - height: 68 - - states: State { - name: "Details" - - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipePic; width: 128; height: 128 } // Make picture bigger - PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 } // Make details visible - PropertyChanges { target: wrapper; height: list.height } // Fill the entire list area with the detailed view - - // Move the list so that this item is at the top. - PropertyChanges { target: wrapper.ListView.view; explicit: true; contentY: wrapper.y } - - // Disallow flicking while we're in detailed view - PropertyChanges { target: wrapper.ListView.view; interactive: false } - } - - transitions: Transition { - // Make the state changes smooth - ParallelAnimation { - ColorAnimation { property: "color"; duration: 500 } - NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } - } - } - } - } - - // The actual list - ListView { - id: list - anchors.fill: parent - clip: true - model: Recipes - delegate: recipeDelegate - } -} diff --git a/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml b/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml new file mode 100644 index 0000000..1b44e05 --- /dev/null +++ b/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example demonstrates placing items in a view using +// a VisualItemModel + +import Qt 4.7 + +Rectangle { + color: "lightgray" + width: 240 + height: 320 + + VisualItemModel { + id: itemModel + + Rectangle { + width: view.width; height: view.height + color: "#FFFEF0" + Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + width: view.width; height: view.height + color: "#F0FFF7" + Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + width: view.width; height: view.height + color: "#F4F0FF" + Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } + } + } + + ListView { + id: view + anchors { fill: parent; bottomMargin: 30 } + model: itemModel + preferredHighlightBegin: 0; preferredHighlightEnd: 0 + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem; flickDeceleration: 2000 + } + + Rectangle { + width: 240; height: 30 + anchors { top: view.bottom; bottom: parent.bottom } + color: "gray" + + Row { + anchors.centerIn: parent + spacing: 20 + + Repeater { + model: itemModel.count + + Rectangle { + width: 5; height: 5 + radius: 3 + color: view.currentIndex == index ? "blue" : "white" + + MouseArea { + width: 20; height: 20 + anchors.centerIn: parent + onClicked: view.currentIndex = index + } + } + } + } + } +} diff --git a/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qmlproject b/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 410f526..5092349 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -141,6 +141,8 @@ public: \endcode \image visualitemmodel.png + + \sa {declarative/modelviews/visualitemmodel}{VisualItemModel example} */ QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(QObject *parent) : QDeclarativeVisualModel(*(new QDeclarativeVisualItemModelPrivate), parent) -- cgit v0.12 From 6e34e119551a7e20e7202d819568d537458fb776 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 11 Jun 2010 15:52:13 +1000 Subject: ListView.onRemove animation is not played when the list has only one item. Task-number: QTBUG-11285 --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativelistview.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index dc2bbd9..3792595 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -603,7 +603,7 @@ void QDeclarativeGridViewPrivate::layout() { Q_Q(QDeclarativeGridView); layoutScheduled = false; - if (!isValid()) { + if (!isValid() && !visibleItems.count()) { clear(); return; } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index d8d317c..dcf18af 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -737,7 +737,7 @@ void QDeclarativeListViewPrivate::layout() { Q_Q(QDeclarativeListView); layoutScheduled = false; - if (!isValid()) { + if (!isValid() && !visibleItems.count()) { clear(); setPosition(0); return; -- cgit v0.12