summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/3rdparty/3rdparty.pri7
-rw-r--r--src/declarative/QmlChanges.txt2
-rw-r--r--src/declarative/declarative.pro1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors.cpp48
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp7
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp290
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h11
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp38
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp98
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp28
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp7
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp24
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p_p.h16
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp94
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp20
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp82
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp61
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp110
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h5
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp14
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp11
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp12
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp5
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp94
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h2
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h20
-rw-r--r--src/declarative/util/qdeclarativeconnections.cpp29
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp21
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp128
-rw-r--r--src/declarative/util/qdeclarativepackage.cpp15
-rw-r--r--src/declarative/util/qdeclarativepackage_p.h6
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp6
-rw-r--r--src/declarative/util/qdeclarativestate.cpp42
-rw-r--r--src/declarative/util/qdeclarativestate_p.h1
-rw-r--r--src/declarative/util/qdeclarativestate_p_p.h3
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp8
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp42
-rw-r--r--src/declarative/util/qdeclarativesystempalette.cpp42
-rw-r--r--src/declarative/util/qdeclarativeview.cpp20
-rw-r--r--src/declarative/util/qdeclarativeview.h1
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp10
-rw-r--r--src/declarative/util/qlistmodelinterface.cpp (renamed from src/declarative/3rdparty/qlistmodelinterface.cpp)0
-rw-r--r--src/declarative/util/qlistmodelinterface_p.h (renamed from src/declarative/3rdparty/qlistmodelinterface_p.h)0
-rw-r--r--src/declarative/util/util.pri6
-rw-r--r--src/gui/image/qpixmapcache.cpp29
-rw-r--r--src/gui/text/qtextcursor.cpp3
-rw-r--r--src/gui/text/qtextdocument_p.cpp19
-rw-r--r--src/gui/text/qtextdocument_p.h2
-rw-r--r--src/imports/particles/qdeclarativeparticles.cpp26
-rw-r--r--src/imports/qimportbase.pri2
-rw-r--r--src/imports/webkit/qdeclarativewebview.cpp4
61 files changed, 991 insertions, 612 deletions
diff --git a/src/declarative/3rdparty/3rdparty.pri b/src/declarative/3rdparty/3rdparty.pri
deleted file mode 100644
index fbdcc11155..0000000000
--- 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/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 5735b1ebe5..8b6b83f664 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/declarative.pro b/src/declarative/declarative.pro
index 8037a16c4a..510e7a5db1 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/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
index aa53aba041..67969772c3 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);
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
index 261cc5cf40..d8527d3c11 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/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
index 1f1e453c8f..cf458dab54 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/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 10dc0f8a19..fdc1444341 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<QGraphicsObject> 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/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index ffffc2f117..3792595d56 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
@@ -246,16 +261,37 @@ 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;
}
+ 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) {
@@ -283,6 +319,9 @@ public:
scheduleLayout();
}
}
+ } else if ((header && header->item == item) || (footer && footer->item == item)) {
+ updateHeader();
+ updateFooter();
}
}
@@ -330,6 +369,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 +455,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 +564,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
@@ -557,7 +603,7 @@ void QDeclarativeGridViewPrivate::layout()
{
Q_Q(QDeclarativeGridView);
layoutScheduled = false;
- if (!isValid()) {
+ if (!isValid() && !visibleItems.count()) {
clear();
return;
}
@@ -579,6 +625,10 @@ void QDeclarativeGridViewPrivate::layout()
item->setPosition(colPos, rowPos);
}
}
+ if (header)
+ updateHeader();
+ if (footer)
+ updateFooter();
q->refill();
updateHighlight();
moveReason = Other;
@@ -742,6 +792,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<QDeclarativeItem *>(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<QDeclarativeItemPrivate*>(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<QDeclarativeItem *>(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<QDeclarativeItemPrivate*>(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;
@@ -753,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;
@@ -761,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();
@@ -773,26 +944,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();
- }
- }
- vTime = timeline.time();
- }
- } 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);
- if (fixupDuration) {
- timeline.move(data.move, pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
- } else {
- data.move.setValue(pos);
- q->viewportMoved();
+ else
+ timeline.set(data.move, -viewPos);
}
vTime = timeline.time();
}
@@ -806,7 +961,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) {
@@ -851,9 +1005,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;
@@ -958,11 +1113,13 @@ QDeclarativeGridView::~QDeclarativeGridView()
d->clear();
if (d->ownModel)
delete d->model;
+ delete d->header;
+ delete d->footer;
}
/*!
\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.
*/
@@ -1524,6 +1681,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 +1808,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));
@@ -1603,13 +1823,17 @@ 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));
} else {
extent = -(d->endPosition() - height());
}
+ if (d->footer)
+ extent -= d->footer->item->height();
const qreal minY = minYExtent();
if (extent > minY)
extent = minY;
@@ -1622,6 +1846,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));
@@ -1635,13 +1861,17 @@ 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));
} else {
- extent = -(d->endPosition() - height());
+ extent = -(d->endPosition() - width());
}
+ 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 2bf154c725..021aad91aa 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/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 94240c2f23..ec08517255 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}
*/
/*!
@@ -95,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/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 9949e6528d..18806e7f2b 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:
@@ -726,7 +728,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 {
@@ -1633,7 +1635,7 @@ void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *pro
QObject *QDeclarativeItemPrivate::resources_at(QDeclarativeListProperty<QObject> *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 +2393,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<QGraphicsItem *> children = childItems();
+ for (int i = children.count()-1; i >= 0; --i) {
+ if (QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(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 77e316b997..4f420f8952 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();
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index dbd19768cf..dcf18afe17 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)
@@ -733,7 +737,7 @@ void QDeclarativeListViewPrivate::layout()
{
Q_Q(QDeclarativeListView);
layoutScheduled = false;
- if (!isValid()) {
+ if (!isValid() && !visibleItems.count()) {
clear();
setPosition(0);
return;
@@ -1045,6 +1049,8 @@ void QDeclarativeListViewPrivate::updateFooter()
QDeclarative_setParent_noEvent(item, q->viewport());
item->setParentItem(q->viewport());
item->setZValue(1);
+ QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(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<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
+ itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
header = new FxListItem(item, q);
if (visibleItems.isEmpty())
visiblePos = header->size();
@@ -1116,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;
@@ -1124,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();
@@ -1136,30 +1177,13 @@ 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();
}
- } 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 {
- data.move.setValue(-pos);
- q->viewportMoved();
- }
- vTime = timeline.time();
- }
- }
} else {
QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
}
@@ -1354,6 +1378,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)
@@ -2074,6 +2100,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 +2132,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);
@@ -2222,7 +2266,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));
@@ -2264,7 +2310,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/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 898c5a564e..25b11195dc 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/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index 6fca283b76..c4956dfc74 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)
@@ -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 4e909ffcee..3d7bd1e8f1 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);
}
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index f58b054b73..0c2d249f7c 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/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 20cc46b035..ad61bab064 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -219,6 +219,7 @@ void QDeclarativeBasePositioner::prePositioning()
QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(ii));
if (!child)
continue;
+ QDeclarativeItemPrivate *childPrivate = static_cast<QDeclarativeItemPrivate*>(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<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(child));
+ return child->opacity() == 0.0 || childPrivate->explicitlyHidden || !child->width() || !child->height();
+}
+
/*!
\qmlclass Column QDeclarativeColumn
\since 4.7
@@ -349,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
@@ -416,11 +426,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;
@@ -496,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
@@ -649,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
@@ -904,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/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
index 04f0181edb..822079b45e 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 *)
{
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index 691cfa24bf..995e22ac1b 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 f4722c3513..c2e0d672bc 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -119,8 +119,6 @@ QSet<QUrl> 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: "<b>Hello</b> <i>World!</i>" }
\endqml
@@ -128,10 +126,10 @@ QSet<QUrl> 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
@@ -163,7 +161,7 @@ QSet<QUrl> 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)
@@ -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().
@@ -1171,7 +1167,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/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 94973f2833..3b4f2a709c 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: "<b>Hello</b> <i>World!</i>"
- 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
*/
/*!
@@ -110,7 +113,7 @@ TextEdit {
\image declarative-textedit.png
- A QDeclarativeTextEdit object can be instantiated in Qml using the tag \c &lt;TextEdit&gt;.
+ A QDeclarativeTextEdit object can be instantiated in QML using the tag \c &lt;TextEdit&gt;.
*/
/*!
@@ -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()
{
@@ -1391,11 +1404,11 @@ 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
+ 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.
@@ -1415,9 +1428,9 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption()
textEdit.openSoftwareInputPanel();
} else {
textEdit.focus = false;
- textEdit.closeSoftwareInputPanel();
}
}
+ onPressAndHold: textEdit.closeSoftwareInputPanel();
}
}
\endcode
@@ -1442,11 +1455,11 @@ 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
+ 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.
@@ -1466,9 +1479,9 @@ void QDeclarativeTextEdit::openSoftwareInputPanel()
textEdit.openSoftwareInputPanel();
} else {
textEdit.focus = false;
- textEdit.closeSoftwareInputPanel();
}
}
+ onPressAndHold: textEdit.closeSoftwareInputPanel();
}
}
\endcode
@@ -1489,22 +1502,11 @@ 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();
}
}
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 0ecb2f3c3e..d08f607ae1 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 8d320f4b8a..633c01e65c 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)
@@ -249,7 +252,12 @@ 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();
+ emit colorChanged(c);
+ }
}
@@ -553,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
@@ -596,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).
*/
/*!
@@ -1234,9 +1246,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 +1270,9 @@ void QDeclarativeTextInput::moveCursorSelection(int position)
textInput.openSoftwareInputPanel();
} else {
textInput.focus = false;
- textInput.closeSoftwareInputPanel();
}
}
+ onPressAndHold: textInput.closeSoftwareInputPanel();
}
}
\endqml
@@ -1285,9 +1297,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 +1321,9 @@ void QDeclarativeTextInput::openSoftwareInputPanel()
textInput.openSoftwareInputPanel();
} else {
textInput.focus = false;
- textInput.closeSoftwareInputPanel();
}
}
+ onPressAndHold: textInput.closeSoftwareInputPanel();
}
}
\endqml
@@ -1333,24 +1345,13 @@ 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();
}
}
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 e34634a42a..c539bd3424 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/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 2a88a80ce0..5092349eed 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.
+ model via the \l{VisualItemModel::index}{index} attached property.
The example below places three colored rectangles in a ListView.
\code
+ import Qt 4.7
+
Rectangle {
VisualItemModel {
id: itemModel
@@ -139,12 +141,21 @@ public:
\endcode
\image visualitemmodel.png
+
+ \sa {declarative/modelviews/visualitemmodel}{VisualItemModel example}
*/
QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(QObject *parent)
: QDeclarativeVisualModel(*(new QDeclarativeVisualItemModelPrivate), 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<QDeclarativeItem> QDeclarativeVisualItemModel::children()
{
Q_D(QDeclarativeVisualItemModel);
@@ -607,30 +618,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 +801,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);
-
- view.setSource(QUrl("qrc:view.qml"));
- view.show();
-
- return app.exec();
- }
-
- #include "main.moc"
- \endcode
-
- \code
- // view.qml
- import Qt 4.7
+ 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.
- 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 +848,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 +868,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 +962,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/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
index 0bdbbcf142..079c9e6a92 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/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 9847079f7a..55ee783f3b 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.
@@ -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 6a13f15a24..2221d78fb1 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/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 39b0802383..0715624e44 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/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index dbc25bb8c2..c17ec950cc 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<typename T>
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 3eaecc1c37..4b1bbd621b 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 <QtCore/qobject.h>
#include <QtCore/qrect.h>
@@ -547,6 +548,7 @@ private:
QFont font;
bool pixelSizeSet;
bool pointSizeSet;
+ mutable QDeclarativeNullableValue<int> dpi;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index e0ee84f84b..aec84a64ac 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/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 0eae136030..25cf13349a 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
@@ -2132,52 +2133,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 +2195,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 +2774,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 e7cd8a8f63..3f8fbdd798 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 3b0f52e3fa..b6d6bbb795 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<QDeclarativeItem*> 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
diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp
index 808d196403..b364821ee1 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<Signal>" 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/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index 3c2e2394a0..83bdb17c2a 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/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 7518eb7a3b..ff83227d09 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.
@@ -244,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
*/
@@ -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 9617b8672a..b149120775 100644
--- a/src/declarative/util/qdeclarativepackage.cpp
+++ b/src/declarative/util/qdeclarativepackage.cpp
@@ -48,17 +48,17 @@ 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.
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 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,12 @@ QT_BEGIN_NAMESPACE
\snippet examples/declarative/modelviews/package/view.qml 0
- \sa QtDeclarative
+ \sa {declarative/modelviews/package}{Package example}, QtDeclarative
+*/
+
+/*!
+ \qmlattachedproperty bool Package::name
+ This attached property holds the name of an item within a Package.
*/
diff --git a/src/declarative/util/qdeclarativepackage_p.h b/src/declarative/util/qdeclarativepackage_p.h
index 57d9c2211d..6b12ef728b 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
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index e98afeba7b..8e3ec82022 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 dc2b2cc971..ae19a9ce15 100644
--- a/src/declarative/util/qdeclarativestate.cpp
+++ b/src/declarative/util/qdeclarativestate.cpp
@@ -136,12 +136,31 @@ 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.
+
+ 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.
+
+ \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 +192,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.
*/
@@ -187,6 +206,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
@@ -197,12 +223,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.
@@ -229,7 +255,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/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h
index 37b24cb2f0..2e2ce7b0c9 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 4a2af0f803..2ef9bb084d 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<QDeclarativeSimpleAction> SimpleActionList;
QString name;
QDeclarativeBinding *when;
+ bool named;
struct OperationGuard : public QDeclarativeGuard<QDeclarativeStateOperation>
{
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index 9b042d7a4c..67cd12ef13 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
@@ -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/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 99f163e507..51e6f992e4 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.
*/
@@ -583,9 +591,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 +695,18 @@ 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
+
+ \image anchorchanges.png
AnchorChanges can be animated using AnchorAnimation.
\qml
diff --git a/src/declarative/util/qdeclarativesystempalette.cpp b/src/declarative/util/qdeclarativesystempalette.cpp
index 6c624467a8..c3348596a1 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
*/
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 6059ad6684..0414e65818 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 e9cff32569..cdcf134aa4 100644
--- a/src/declarative/util/qdeclarativeview.h
+++ b/src/declarative/util/qdeclarativeview.h
@@ -90,6 +90,7 @@ public:
QList<QDeclarativeError> errors() const;
QSize sizeHint() const;
+ QSize initialSize() const;
Q_SIGNALS:
void sceneResized(QSize size); // ???
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 4f9355b4f3..4adef25bb5 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -523,10 +523,13 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
A XmlListModel could create a model from this data, like this:
\qml
+ import Qt 4.7
+
XmlListModel {
id: xmlModel
source: "http://www.mysite.com/feed.xml"
query: "/rss/channel/item"
+
XmlRole { name: "title"; query: "title/string()" }
XmlRole { name: "pubDate"; query: "pubDate/string()" }
}
@@ -536,7 +539,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
a model item for each \c <item> 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 <item>.
(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/src/declarative/3rdparty/qlistmodelinterface.cpp b/src/declarative/util/qlistmodelinterface.cpp
index 98d6a5b4fa..98d6a5b4fa 100644
--- a/src/declarative/3rdparty/qlistmodelinterface.cpp
+++ b/src/declarative/util/qlistmodelinterface.cpp
diff --git a/src/declarative/3rdparty/qlistmodelinterface_p.h b/src/declarative/util/qlistmodelinterface_p.h
index 07592ad55b..07592ad55b 100644
--- a/src/declarative/3rdparty/qlistmodelinterface_p.h
+++ b/src/declarative/util/qlistmodelinterface_p.h
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index f20bba164d..04cfc68c94 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
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index 7a6a73f436..ca21a0c688 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<QString,QPixmap> > 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<QString, QPixmapCache::Key>::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<QPixmapCache::Key, QPixmapCacheEntry>::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<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost);
if (success) {
if(!theid) {
- theid = startTimer(30000);
+ theid = startTimer(flush_time);
t = false;
}
const_cast<QPixmapCache::Key&>(key) = cacheKey;
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index 23849bc854..a9caa6ba8a 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 e2bca04d8c..f3cd48157f 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 ac5ed3c86e..d1bd6987bc 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/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp
index ecc6604aef..630c068b6e 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;
@@ -1284,11 +1286,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<QPainter::PixmapFragment, 256> pixmapData;
-#else
- QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData;
-#endif
pixmapData.resize(d->particles.count());
const QRectF sourceRect = d->image.rect();
@@ -1296,32 +1294,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()
diff --git a/src/imports/qimportbase.pri b/src/imports/qimportbase.pri
index 612ff202e3..0f70030dac 100644
--- a/src/imports/qimportbase.pri
+++ b/src/imports/qimportbase.pri
@@ -18,6 +18,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)
diff --git a/src/imports/webkit/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp
index 9e5647f8bf..383f1cef7e 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.
*/