summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-01 13:00:57 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-01 13:00:57 (GMT)
commit405ae4ef5382cd8ee0adfbe45c59c8d92e3ffdf6 (patch)
tree0122507f3c5ca236db3139fba231685297138f4a /src/declarative/graphicsitems
parent8968c79c575755cdb52d5e615ed19e4529047464 (diff)
parent9fc5c260858559662e156865e4666e5a91452cc2 (diff)
downloadQt-405ae4ef5382cd8ee0adfbe45c59c8d92e3ffdf6.zip
Qt-405ae4ef5382cd8ee0adfbe45c59c8d92e3ffdf6.tar.gz
Qt-405ae4ef5382cd8ee0adfbe45c59c8d92e3ffdf6.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (76 commits) Reseted QtDeclarative module def files Get WebView tests passing again Remove arbitrary width checks Removed compilation warning for systems with no OpenGL support Fix bug in SameGame's dialog component doc fix Add abstractitemmodel example, and fix some model docs docs - quote code with snippets, other improvements Fix webkit import for webkit tests. Remove qmlviewer dependency on QDeclarativeTimer Remove a few more unnecessary exports. Don't export declarative private classes Add additional text layout benchmarks. Don't access uninitialized value. Minor Twitter demo enhancements Added SET_BINDING message to QDeclarative debugger protocol Add ListView.nextSection attached property Remove the old font.outline documentation Docs - add more links to relevant examples Rewrite runtime & qmlviewer docs and emphasise that qmlviewer shouldn't ...
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp71
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h9
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativefocuspanel_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativefocusscope.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativefocusscope_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp70
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp5
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp119
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h20
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath_p.h16
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p.h10
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle_p.h6
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp152
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp38
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp20
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativetranslate_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h6
40 files changed, 427 insertions, 199 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h
index 5981cd3..ec361ea 100644
--- a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h
@@ -55,7 +55,7 @@ QT_MODULE(Declarative)
class QMovie;
class QDeclarativeAnimatedImagePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeAnimatedImage : public QDeclarativeImage
+class Q_AUTOTEST_EXPORT QDeclarativeAnimatedImage : public QDeclarativeImage
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage_p.h b/src/declarative/graphicsitems/qdeclarativeborderimage_p.h
index 07f049e..9944cbe 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage_p.h
@@ -54,7 +54,7 @@ QT_MODULE(Declarative)
class QDeclarativeScaleGrid;
class QDeclarativeGridScaledImage;
class QDeclarativeBorderImagePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeBorderImage : public QDeclarativeImageBase
+class Q_AUTOTEST_EXPORT QDeclarativeBorderImage : public QDeclarativeImageBase
{
Q_OBJECT
Q_ENUMS(TileMode)
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 3f681b7..a40546f 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -122,7 +122,7 @@ void QDeclarativeFlickableVisibleArea::updateVisible()
QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
- : viewport(new QDeclarativeItem)
+ : contentItem(new QDeclarativeItem)
, hData(this, &QDeclarativeFlickablePrivate::setRoundedViewportX)
, vData(this, &QDeclarativeFlickablePrivate::setRoundedViewportY)
, flickingHorizontally(false), flickingVertically(false)
@@ -140,8 +140,8 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
void QDeclarativeFlickablePrivate::init()
{
Q_Q(QDeclarativeFlickable);
- QDeclarative_setParent_noEvent(viewport, q);
- viewport->setParentItem(q);
+ QDeclarative_setParent_noEvent(contentItem, q);
+ contentItem->setParentItem(q);
static int timelineUpdatedIdx = -1;
static int timelineCompletedIdx = -1;
static int flickableTickedIdx = -1;
@@ -158,7 +158,7 @@ void QDeclarativeFlickablePrivate::init()
q, flickableMovementEndingIdx, Qt::DirectConnection);
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setFiltersChildEvents(true);
- QDeclarativeItemPrivate *viewportPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(viewport));
+ QDeclarativeItemPrivate *viewportPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(contentItem));
viewportPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
lastPosTime.invalidate();
}
@@ -182,7 +182,7 @@ qreal QDeclarativeFlickablePrivate::overShootDistance(qreal velocity, qreal size
void QDeclarativeFlickablePrivate::itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeom, const QRectF &oldGeom)
{
Q_Q(QDeclarativeFlickable);
- if (item == viewport) {
+ if (item == contentItem) {
if (newGeom.x() != oldGeom.x())
emit q->contentXChanged();
if (newGeom.y() != oldGeom.y())
@@ -579,10 +579,28 @@ void QDeclarativeFlickable::ticked()
viewportMoved();
}
-QDeclarativeItem *QDeclarativeFlickable::viewport()
+/*!
+ \qmlproperty Item Flickable::contentItem
+
+ The internal item that contains the Items to be moved in the Flickable.
+
+ Items declared as children of a Flickable are automatically parented to the Flickable's contentItem.
+
+ Items created dynamically need to be explicitly parented to the \e contentItem:
+ \code
+ Flickable {
+ id: myFlickable
+ function addItem(file) {
+ var component = Qt.createComponent(file)
+ component.createObject(myFlickable.contentItem);
+ }
+ }
+ \endcode
+*/
+QDeclarativeItem *QDeclarativeFlickable::contentItem()
{
Q_D(QDeclarativeFlickable);
- return d->viewport;
+ return d->contentItem;
}
QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea()
@@ -899,12 +917,12 @@ void QDeclarativeFlickablePrivate::clearDelayedPress()
void QDeclarativeFlickablePrivate::setRoundedViewportX(qreal x)
{
- viewport->setX(qRound(x));
+ contentItem->setX(qRound(x));
}
void QDeclarativeFlickablePrivate::setRoundedViewportY(qreal y)
{
- viewport->setY(qRound(y));
+ contentItem->setY(qRound(y));
}
void QDeclarativeFlickable::timerEvent(QTimerEvent *event)
@@ -953,20 +971,19 @@ void QDeclarativeFlickable::viewportMoved()
{
Q_D(QDeclarativeFlickable);
- int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime);
- if (!elapsed)
- return;
-
qreal prevY = d->lastFlickablePosition.x();
qreal prevX = d->lastFlickablePosition.y();
d->velocityTimeline.clear();
if (d->pressed) {
- qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed;
- qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / elapsed;
- d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing);
+ int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime);
+ if (elapsed > 0) {
+ qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed;
+ qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / elapsed;
+ d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing);
+ }
} else {
if (d->timeline.time() > d->vTime) {
qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / (d->timeline.time() - d->vTime);
@@ -991,13 +1008,13 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry,
bool changed = false;
if (newGeometry.width() != oldGeometry.width()) {
if (d->hData.viewSize < 0) {
- d->viewport->setWidth(width());
+ d->contentItem->setWidth(width());
emit contentWidthChanged();
}
}
if (newGeometry.height() != oldGeometry.height()) {
if (d->vData.viewSize < 0) {
- d->viewport->setHeight(height());
+ d->contentItem->setHeight(height());
emit contentHeightChanged();
}
}
@@ -1018,7 +1035,7 @@ void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty<QObject>
{
QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o);
if (i)
- i->setParentItem(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->viewport);
+ i->setParentItem(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem);
else
o->setParent(prop->object);
}
@@ -1032,7 +1049,7 @@ QDeclarativeListProperty<QObject> QDeclarativeFlickable::flickableData()
QDeclarativeListProperty<QGraphicsObject> QDeclarativeFlickable::flickableChildren()
{
Q_D(QDeclarativeFlickable);
- return QGraphicsItemPrivate::get(d->viewport)->childrenList();
+ return QGraphicsItemPrivate::get(d->contentItem)->childrenList();
}
/*!
@@ -1102,9 +1119,9 @@ void QDeclarativeFlickable::setContentWidth(qreal w)
return;
d->hData.viewSize = w;
if (w < 0)
- d->viewport->setWidth(width());
+ d->contentItem->setWidth(width());
else
- d->viewport->setWidth(w);
+ d->contentItem->setWidth(w);
// Make sure that we're entirely in view.
if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
int oldDuration = d->fixupDuration;
@@ -1129,9 +1146,9 @@ void QDeclarativeFlickable::setContentHeight(qreal h)
return;
d->vData.viewSize = h;
if (h < 0)
- d->viewport->setHeight(height());
+ d->contentItem->setHeight(height());
else
- d->viewport->setHeight(h);
+ d->contentItem->setHeight(h);
// Make sure that we're entirely in view.
if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
int oldDuration = d->fixupDuration;
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
index d40a0dc..47746c6 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
@@ -52,7 +52,7 @@ QT_MODULE(Declarative)
class QDeclarativeFlickablePrivate;
class QDeclarativeFlickableVisibleArea;
-class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeFlickable : public QDeclarativeItem
{
Q_OBJECT
@@ -60,6 +60,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
+ Q_PROPERTY(QDeclarativeItem *contentItem READ contentItem CONSTANT)
Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
@@ -111,10 +112,10 @@ public:
void setContentHeight(qreal);
qreal contentX() const;
- void setContentX(qreal pos);
+ virtual void setContentX(qreal pos);
qreal contentY() const;
- void setContentY(qreal pos);
+ virtual void setContentY(qreal pos);
bool isMoving() const;
bool isMovingHorizontally() const;
@@ -143,7 +144,7 @@ public:
bool isAtYEnd() const;
bool isAtYBeginning() const;
- QDeclarativeItem *viewport();
+ QDeclarativeItem *contentItem();
enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
FlickableDirection flickDirection() const; // deprecated
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
index 66d2678..b919e1b 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -125,7 +125,7 @@ public:
void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &);
public:
- QDeclarativeItem *viewport;
+ QDeclarativeItem *contentItem;
AxisData hData;
AxisData vData;
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable_p.h b/src/declarative/graphicsitems/qdeclarativeflipable_p.h
index fd0119b..78eaf53 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflipable_p.h
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeFlipablePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeFlipable : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeFlipable : public QDeclarativeItem
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativefocuspanel_p.h b/src/declarative/graphicsitems/qdeclarativefocuspanel_p.h
index d9ca0b0..99bd540 100644
--- a/src/declarative/graphicsitems/qdeclarativefocuspanel_p.h
+++ b/src/declarative/graphicsitems/qdeclarativefocuspanel_p.h
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class Q_DECLARATIVE_EXPORT QDeclarativeFocusPanel : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeFocusPanel : public QDeclarativeItem
{
Q_OBJECT
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
diff --git a/src/declarative/graphicsitems/qdeclarativefocusscope.cpp b/src/declarative/graphicsitems/qdeclarativefocusscope.cpp
index 4bd2a86..e8e6fa2 100644
--- a/src/declarative/graphicsitems/qdeclarativefocusscope.cpp
+++ b/src/declarative/graphicsitems/qdeclarativefocusscope.cpp
@@ -54,6 +54,8 @@ QT_BEGIN_NAMESPACE
Focus scopes assist in keyboard focus handling when building reusable QML
components. All the details are covered in the
\l {qmlfocus}{keyboard focus documentation}.
+
+ \sa {declarative/keyinteraction/focus}{Keyboard focus example}
*/
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativefocusscope_p.h b/src/declarative/graphicsitems/qdeclarativefocusscope_p.h
index c65a07c..363167e 100644
--- a/src/declarative/graphicsitems/qdeclarativefocusscope_p.h
+++ b/src/declarative/graphicsitems/qdeclarativefocusscope_p.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
//### set component root as focusscope
-class Q_DECLARATIVE_EXPORT QDeclarativeFocusScope : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeFocusScope : public QDeclarativeItem
{
Q_OBJECT
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem)
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 3792595..cb99129 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -151,9 +151,9 @@ public:
void setPosition(qreal pos) {
Q_Q(QDeclarativeGridView);
if (flow == QDeclarativeGridView::LeftToRight)
- q->setContentY(pos);
+ q->QDeclarativeFlickable::setContentY(pos);
else
- q->setContentX(pos);
+ q->QDeclarativeFlickable::setContentX(pos);
}
int size() const {
Q_Q(const QDeclarativeGridView);
@@ -421,10 +421,10 @@ FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex)
if (model->completePending()) {
// complete
listItem->item->setZValue(1);
- listItem->item->setParentItem(q->viewport());
+ listItem->item->setParentItem(q->contentItem());
model->completeItem();
} else {
- listItem->item->setParentItem(q->viewport());
+ listItem->item->setParentItem(q->contentItem());
}
unrequestedItems.remove(listItem->item);
}
@@ -716,12 +716,12 @@ void QDeclarativeGridViewPrivate::createHighlight()
}
} else {
item = new QDeclarativeItem;
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
highlight = new FxGridItem(item, q);
highlightXAnimator = new QSmoothedAnimation(q);
highlightXAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("x"));
@@ -808,8 +808,8 @@ void QDeclarativeGridViewPrivate::updateFooter()
delete context;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
item->setZValue(1);
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -854,8 +854,8 @@ void QDeclarativeGridViewPrivate::updateHeader()
delete context;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
item->setZValue(1);
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -1099,6 +1099,8 @@ void QDeclarativeGridViewPrivate::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 {declarative/modelviews/gridview}{GridView example}
*/
QDeclarativeGridView::QDeclarativeGridView(QDeclarativeItem *parent)
: QDeclarativeFlickable(*(new QDeclarativeGridViewPrivate), parent)
@@ -1742,6 +1744,22 @@ void QDeclarativeGridView::setHeader(QDeclarativeComponent *header)
}
}
+void QDeclarativeGridView::setContentX(qreal pos)
+{
+ Q_D(QDeclarativeGridView);
+ // Positioning the view manually should override any current movement state
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
+ QDeclarativeFlickable::setContentX(pos);
+}
+
+void QDeclarativeGridView::setContentY(qreal pos)
+{
+ Q_D(QDeclarativeGridView);
+ // Positioning the view manually should override any current movement state
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
+ QDeclarativeFlickable::setContentY(pos);
+}
+
bool QDeclarativeGridView::event(QEvent *event)
{
Q_D(QDeclarativeGridView);
@@ -1919,6 +1937,8 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event)
Move the currentIndex up one item in the view.
The current index will wrap if keyNavigationWraps is true and it
is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeGridView::moveCurrentIndexUp()
{
@@ -1942,6 +1962,8 @@ void QDeclarativeGridView::moveCurrentIndexUp()
Move the currentIndex down one item in the view.
The current index will wrap if keyNavigationWraps is true and it
is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeGridView::moveCurrentIndexDown()
{
@@ -1965,6 +1987,8 @@ void QDeclarativeGridView::moveCurrentIndexDown()
Move the currentIndex left one item in the view.
The current index will wrap if keyNavigationWraps is true and it
is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeGridView::moveCurrentIndexLeft()
{
@@ -1988,6 +2012,8 @@ void QDeclarativeGridView::moveCurrentIndexLeft()
Move the currentIndex right one item in the view.
The current index will wrap if keyNavigationWraps is true and it
is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeGridView::moveCurrentIndexRight()
{
@@ -2028,6 +2054,14 @@ void QDeclarativeGridView::moveCurrentIndexRight()
at a particular index. This is unreliable since removing items from the start
of the view does not cause all other items to be repositioned.
The correct way to bring an item into view is with \c positionViewAtIndex.
+
+ \bold Note: methods should only be called after the Component has completed. To position
+ the view at startup, this method should be called by Component.onCompleted. For
+ example, to position the view at the end:
+
+ \code
+ Component.onCompleted: positionViewAtIndex(count - 1, GridView.Beginning)
+ \endcode
*/
void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
{
@@ -2037,6 +2071,8 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
if (mode < Beginning || mode > Contain)
return;
+ if (d->layoutScheduled)
+ d->layout();
qreal pos = d->position();
FxGridItem *item = d->visibleItem(index);
if (!item) {
@@ -2079,6 +2115,8 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
pos = qMin(pos, maxExtent);
qreal minExtent = d->flow == QDeclarativeGridView::LeftToRight ? -minYExtent() : -minXExtent();
pos = qMax(pos, minExtent);
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
+ cancelFlick();
d->setPosition(pos);
}
d->fixupPosition();
@@ -2093,6 +2131,8 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
If the item is outside the visible area, -1 is returned, regardless of
whether an item will exist at that point when scrolled into view.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
int QDeclarativeGridView::indexAt(int x, int y) const
{
@@ -2113,10 +2153,16 @@ void QDeclarativeGridView::componentComplete()
d->updateGrid();
if (d->isValid()) {
refill();
+ d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
if (d->currentIndex < 0)
d->updateCurrent(0);
else
d->updateCurrent(d->currentIndex);
+ if (d->highlight) {
+ d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos());
+ d->updateTrackedItem();
+ }
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
d->fixupPosition();
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index 021aad9..d6bbaf3 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -52,7 +52,7 @@ QT_MODULE(Declarative)
class QDeclarativeVisualModel;
class QDeclarativeGridViewAttached;
class QDeclarativeGridViewPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeGridView : public QDeclarativeFlickable
+class Q_AUTOTEST_EXPORT QDeclarativeGridView : public QDeclarativeFlickable
{
Q_OBJECT
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGridView)
@@ -151,6 +151,9 @@ public:
QDeclarativeComponent *header() const;
void setHeader(QDeclarativeComponent *);
+ virtual void setContentX(qreal pos);
+ virtual void setContentY(qreal pos);
+
enum PositionMode { Beginning, Center, End, Visible, Contain };
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index ec08517..ff61302 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -199,6 +199,7 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
fillMode: Image.PreserveAspectCrop
smooth: true
source: "qtlogo.png"
+ clip: true
}
\endqml
@@ -220,6 +221,7 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
Image {
width: 120; height: 120
fillMode: Image.TileVertically
+ smooth: true
source: "qtlogo.png"
}
\endqml
@@ -231,11 +233,14 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
Image {
width: 120; height: 120
fillMode: Image.TileHorizontally
+ smooth: true
source: "qtlogo.png"
}
\endqml
\endtable
+
+ \sa {declarative/imageelements/image}{Image example}
*/
QDeclarativeImage::FillMode QDeclarativeImage::fillMode() const
{
diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p.h
index fa5b2a9..a4f4475 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimage_p.h
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeImagePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeImage : public QDeclarativeImageBase
+class Q_AUTOTEST_EXPORT QDeclarativeImage : public QDeclarativeImageBase
{
Q_OBJECT
Q_ENUMS(FillMode)
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
index 49b1c58..f5896b1 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
@@ -49,7 +49,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QDeclarativeImageBasePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeImageBase : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeImageBase : public QDeclarativeItem
{
Q_OBJECT
Q_ENUMS(Status)
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 336010f..9a17d78 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -149,7 +149,7 @@ QT_BEGIN_NAMESPACE
}
\endqml
- \sa Rotate, Translate
+ \sa Rotation, Translate
*/
/*!
@@ -196,6 +196,8 @@ QT_BEGIN_NAMESPACE
\snippet doc/src/snippets/declarative/rotation.qml 0
\image axisrotation.png
+
+ \sa {declarative/ui-components/dialcontrol}{Dial Control example}, {declarative/toys/clocks}{Clocks example}
*/
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 06a3239..e519bd9 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -105,7 +105,7 @@ public:
else
return (view->orientation() == QDeclarativeListView::Vertical ? item->y() : item->x());
}
- int size() const {
+ qreal size() const {
if (section)
return (view->orientation() == QDeclarativeListView::Vertical ? item->height()+section->height() : item->width()+section->height());
else
@@ -216,9 +216,9 @@ public:
void setPosition(qreal pos) {
Q_Q(QDeclarativeListView);
if (orient == QDeclarativeListView::Vertical)
- q->setContentY(pos);
+ q->QDeclarativeFlickable::setContentY(pos);
else
- q->setContentX(pos);
+ q->QDeclarativeFlickable::setContentX(pos);
}
qreal size() const {
Q_Q(const QDeclarativeListView);
@@ -421,7 +421,7 @@ public:
void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
Q_Q(QDeclarativeListView);
QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry);
- if (item != viewport && (!highlight || item != highlight->item)) {
+ if (item != contentItem && (!highlight || item != highlight->item)) {
if ((orient == QDeclarativeListView::Vertical && newGeometry.height() != oldGeometry.height())
|| (orient == QDeclarativeListView::Horizontal && newGeometry.width() != oldGeometry.width())) {
scheduleLayout();
@@ -476,7 +476,7 @@ public:
QHash<QDeclarativeItem*,int> unrequestedItems;
FxListItem *currentItem;
QDeclarativeListView::Orientation orient;
- int visiblePos;
+ qreal visiblePos;
int visibleIndex;
qreal averageSize;
int currentIndex;
@@ -575,15 +575,19 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex)
listItem->attached->m_prevSection = item->attached->section();
else
listItem->attached->m_prevSection = sectionAt(modelIndex-1);
+ if (FxListItem *item = visibleItem(modelIndex+1))
+ listItem->attached->m_nextSection = item->attached->section();
+ else
+ listItem->attached->m_nextSection = sectionAt(modelIndex+1);
}
}
if (model->completePending()) {
// complete
listItem->item->setZValue(1);
- listItem->item->setParentItem(q->viewport());
+ listItem->item->setParentItem(q->contentItem());
model->completeItem();
} else {
- listItem->item->setParentItem(q->viewport());
+ listItem->item->setParentItem(q->contentItem());
}
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -655,7 +659,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
bool changed = false;
FxListItem *item = 0;
- int pos = itemEnd + 1;
+ qreal pos = itemEnd + 1;
while (modelIndex < model->count() && pos <= fillTo) {
// qDebug() << "refill: append item" << modelIndex << "pos" << pos;
if (!(item = createItem(modelIndex)))
@@ -744,8 +748,8 @@ void QDeclarativeListViewPrivate::layout()
}
updateSections();
if (!visibleItems.isEmpty()) {
- int oldEnd = visibleItems.last()->endPosition();
- int pos = visibleItems.first()->endPosition() + spacing + 1;
+ qreal oldEnd = visibleItems.last()->endPosition();
+ qreal pos = visibleItems.first()->endPosition() + spacing + 1;
for (int i=1; i < visibleItems.count(); ++i) {
FxListItem *item = visibleItems.at(i);
item->setPosition(pos);
@@ -840,8 +844,8 @@ void QDeclarativeListViewPrivate::createHighlight()
item = new QDeclarativeItem;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
highlight = new FxListItem(item, q);
if (currentItem && autoHighlight) {
if (orient == QDeclarativeListView::Vertical) {
@@ -921,8 +925,8 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem)
delete nobj;
} else {
listItem->section->setZValue(1);
- QDeclarative_setParent_noEvent(listItem->section, q->viewport());
- listItem->section->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(listItem->section, q->contentItem());
+ listItem->section->setParentItem(q->contentItem());
}
} else {
delete context;
@@ -951,14 +955,26 @@ void QDeclarativeListViewPrivate::updateSections()
QString prevSection;
if (visibleIndex > 0)
prevSection = sectionAt(visibleIndex-1);
+ QDeclarativeListViewAttached *prevAtt = 0;
+ int idx = -1;
for (int i = 0; i < visibleItems.count(); ++i) {
if (visibleItems.at(i)->index != -1) {
QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached;
attached->setPrevSection(prevSection);
+ if (prevAtt)
+ prevAtt->setNextSection(attached->section());
createSection(visibleItems.at(i));
prevSection = attached->section();
+ prevAtt = attached;
+ idx = visibleItems.at(i)->index;
}
}
+ if (prevAtt) {
+ if (idx > 0 && idx < model->count()-1)
+ prevAtt->setNextSection(sectionAt(idx+1));
+ else
+ prevAtt->setNextSection(QString());
+ }
}
}
@@ -1027,7 +1043,7 @@ void QDeclarativeListViewPrivate::updateAverage()
qreal sum = 0.0;
for (int i = 0; i < visibleItems.count(); ++i)
sum += visibleItems.at(i)->size();
- averageSize = sum / visibleItems.count();
+ averageSize = qRound(sum / visibleItems.count());
}
void QDeclarativeListViewPrivate::updateFooter()
@@ -1046,8 +1062,8 @@ void QDeclarativeListViewPrivate::updateFooter()
delete context;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
item->setZValue(1);
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -1086,8 +1102,8 @@ void QDeclarativeListViewPrivate::updateHeader()
delete context;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
item->setZValue(1);
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -1379,7 +1395,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
to set \e {clip: true} in order to have the out of view items clipped
nicely.
- \sa ListModel, GridView, {declarative/modelviews/listview}{ListView examples}
+ \sa {Data Models}, GridView, {declarative/modelviews/listview}{ListView examples}
*/
QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent)
@@ -1418,7 +1434,7 @@ QDeclarativeListView::~QDeclarativeListView()
*/
/*!
- \qmlattachedproperty string ListView::prevSection
+ \qmlattachedproperty string ListView::previousSection
This attached property holds the section of the previous element.
It is attached to each instance of the delegate.
@@ -1427,6 +1443,15 @@ QDeclarativeListView::~QDeclarativeListView()
*/
/*!
+ \qmlattachedproperty string ListView::nextSection
+ This attached property holds the section of the next element.
+
+ It is attached to each instance of the delegate.
+
+ The section is evaluated using the \l {ListView::section.property}{section} properties.
+*/
+
+/*!
\qmlattachedproperty string ListView::section
This attached property holds the section of this element.
@@ -1547,9 +1572,12 @@ void QDeclarativeListView::setModel(const QVariant &model)
that is not needed for the normal display of the delegate in a \l Loader which
can load additional elements when needed.
- Tthe ListView will lay out the items based on the size of the root item
+ The ListView will lay out the items based on the size of the root item
in the delegate.
+ It is recommended that the delagate's size be a whole number to avoid sub-pixel
+ alignment of items.
+
\note Delegates are instantiated as needed and may be destroyed at any time.
State should \e never be stored in a delegate.
*/
@@ -1960,9 +1988,9 @@ void QDeclarativeListView::setCacheBuffer(int b)
\c section.delegate holds the delegate component for each section.
- Each item in the list has attached properties named \c ListView.section and
- \c ListView.prevSection. These may be used to place a section header for
- related items.
+ Each item in the list has attached properties named \c ListView.section,
+ \c ListView.previousSection and \c ListView.nextSection. These may be
+ used to place a section header for related items.
For example, here is a ListView that displays a list of animals, separated
into sections. Each item in the ListView is placed in a different section
@@ -2182,6 +2210,22 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header)
}
}
+void QDeclarativeListView::setContentX(qreal pos)
+{
+ Q_D(QDeclarativeListView);
+ // Positioning the view manually should override any current movement state
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ QDeclarativeFlickable::setContentX(pos);
+}
+
+void QDeclarativeListView::setContentY(qreal pos)
+{
+ Q_D(QDeclarativeListView);
+ // Positioning the view manually should override any current movement state
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ QDeclarativeFlickable::setContentY(pos);
+}
+
bool QDeclarativeListView::event(QEvent *event)
{
Q_D(QDeclarativeListView);
@@ -2386,6 +2430,8 @@ void QDeclarativeListView::keyPressEvent(QKeyEvent *event)
Increments the current index. The current index will wrap
if keyNavigationWraps is true and it is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeListView::incrementCurrentIndex()
{
@@ -2403,6 +2449,8 @@ void QDeclarativeListView::incrementCurrentIndex()
Decrements the current index. The current index will wrap
if keyNavigationWraps is true and it is currently at the beginning.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeListView::decrementCurrentIndex()
{
@@ -2439,6 +2487,14 @@ void QDeclarativeListView::decrementCurrentIndex()
of the list does not cause all other items to be repositioned, and because
the actual start of the view can vary based on the size of the delegates.
The correct way to bring an item into view is with \c positionViewAtIndex.
+
+ \bold Note: methods should only be called after the Component has completed. To position
+ the view at startup, this method should be called by Component.onCompleted. For
+ example, to position the view at the end:
+
+ \code
+ Component.onCompleted: positionViewAtIndex(count - 1, ListView.Beginning)
+ \endcode
*/
void QDeclarativeListView::positionViewAtIndex(int index, int mode)
{
@@ -2448,6 +2504,8 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode)
if (mode < Beginning || mode > Contain)
return;
+ if (d->layoutScheduled)
+ d->layout();
qreal pos = d->position();
FxListItem *item = d->visibleItem(index);
if (!item) {
@@ -2491,6 +2549,8 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode)
pos = qMin(pos, maxExtent);
qreal minExtent = d->orient == QDeclarativeListView::Vertical ? -minYExtent() : -minXExtent();
pos = qMax(pos, minExtent);
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ cancelFlick();
d->setPosition(pos);
}
d->fixupPosition();
@@ -2505,6 +2565,8 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode)
If the item is outside the visible area, -1 is returned, regardless of
whether an item will exist at that point when scrolled into view.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
int QDeclarativeListView::indexAt(int x, int y) const
{
@@ -2529,6 +2591,11 @@ void QDeclarativeListView::componentComplete()
d->updateCurrent(0);
else
d->updateCurrent(d->currentIndex);
+ if (d->highlight) {
+ d->highlight->setPosition(d->currentItem->position());
+ d->updateTrackedItem();
+ }
+ d->moveReason = QDeclarativeListViewPrivate::Other;
d->fixupPosition();
}
}
@@ -2961,7 +3028,7 @@ void QDeclarativeListView::createdItem(int index, QDeclarativeItem *item)
{
Q_D(QDeclarativeListView);
if (d->requestedIndex != index) {
- item->setParentItem(viewport());
+ item->setParentItem(contentItem());
d->unrequestedItems.insert(item, index);
if (d->orient == QDeclarativeListView::Vertical)
item->setY(d->positionAt(index));
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index d6e8023..9941040 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class Q_DECLARATIVE_EXPORT QDeclarativeViewSection : public QObject
+class Q_AUTOTEST_EXPORT QDeclarativeViewSection : public QObject
{
Q_OBJECT
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY changed)
@@ -86,7 +86,7 @@ private:
class QDeclarativeVisualModel;
class QDeclarativeListViewAttached;
class QDeclarativeListViewPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeListView : public QDeclarativeFlickable
+class Q_AUTOTEST_EXPORT QDeclarativeListView : public QDeclarativeFlickable
{
Q_OBJECT
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeListView)
@@ -198,6 +198,9 @@ public:
QDeclarativeComponent *header() const;
void setHeader(QDeclarativeComponent *);
+ virtual void setContentX(qreal pos);
+ virtual void setContentY(qreal pos);
+
static QDeclarativeListViewAttached *qmlAttachedProperties(QObject *);
enum PositionMode { Beginning, Center, End, Visible, Contain };
@@ -276,7 +279,7 @@ public:
}
}
- Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged)
+ Q_PROPERTY(QString previousSection READ prevSection NOTIFY prevSectionChanged)
QString prevSection() const { return m_prevSection; }
void setPrevSection(const QString &sect) {
if (m_prevSection != sect) {
@@ -285,6 +288,15 @@ public:
}
}
+ Q_PROPERTY(QString nextSection READ nextSection NOTIFY nextSectionChanged)
+ QString nextSection() const { return m_nextSection; }
+ void setNextSection(const QString &sect) {
+ if (m_nextSection != sect) {
+ m_nextSection = sect;
+ emit nextSectionChanged();
+ }
+ }
+
Q_PROPERTY(QString section READ section NOTIFY sectionChanged)
QString section() const { return m_section; }
void setSection(const QString &sect) {
@@ -310,6 +322,7 @@ Q_SIGNALS:
void currentItemChanged();
void sectionChanged();
void prevSectionChanged();
+ void nextSectionChanged();
void delayRemoveChanged();
void add();
void remove();
@@ -318,6 +331,7 @@ public:
QDeclarativeListView *m_view;
mutable QString m_section;
QString m_prevSection;
+ QString m_nextSection;
bool m_isCurrent : 1;
bool m_delayRemove : 1;
};
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 25b1119..c8c9e44 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -174,7 +174,7 @@ void QDeclarativeLoaderPrivate::initResize()
QDeclarativeLoader::QDeclarativeLoader(QDeclarativeItem *parent)
: QDeclarativeItem(*(new QDeclarativeLoaderPrivate), parent)
{
- Q_D(QDeclarativeItem);
+ Q_D(QDeclarativeLoader);
d->flags |= QGraphicsItem::ItemIsFocusScope;
}
@@ -183,6 +183,14 @@ QDeclarativeLoader::QDeclarativeLoader(QDeclarativeItem *parent)
*/
QDeclarativeLoader::~QDeclarativeLoader()
{
+ Q_D(QDeclarativeLoader);
+ if (d->item) {
+ if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(d->item)) {
+ QDeclarativeItemPrivate *p =
+ static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(qmlItem));
+ p->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry);
+ }
+ }
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p.h b/src/declarative/graphicsitems/qdeclarativeloader_p.h
index ec7ffe9..d63eaf7 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeloader_p.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeLoaderPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeLoader : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeLoader : public QDeclarativeItem
{
Q_OBJECT
Q_ENUMS(Status)
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index 0bed41b..caf251d 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -192,7 +192,7 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate()
MouseArea is an invisible item: it is never painted.
- \sa MouseEvent
+ \sa MouseEvent, {declarative/touchinteraction/mousearea}{MouseArea example}
*/
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
index df77ac6..4fe3fcb 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class Q_DECLARATIVE_EXPORT QDeclarativeDrag : public QObject
+class Q_AUTOTEST_EXPORT QDeclarativeDrag : public QObject
{
Q_OBJECT
@@ -110,7 +110,7 @@ private:
class QDeclarativeMouseEvent;
class QDeclarativeMouseAreaPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeMouseArea : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
index 13d1b61..3b9b8df 100644
--- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
@@ -151,6 +151,7 @@ void QDeclarativePaintedItem::setContentsSize(const QSize &size)
{
Q_D(QDeclarativePaintedItem);
if (d->contentsSize == size) return;
+ prepareGeometryChange();
d->contentsSize = size;
clearCache();
update();
@@ -247,8 +248,7 @@ QRectF QDeclarativePaintedItem::boundingRect() const
void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QDeclarativePaintedItem);
- const QRect content(0,0,qCeil(d->contentsSize.width()*d->contentsScale),
- qCeil(d->contentsSize.height()*d->contentsScale));
+ const QRect content = boundingRect().toRect();
if (content.width() <= 0 || content.height() <= 0)
return;
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem_p.h b/src/declarative/graphicsitems/qdeclarativepainteditem_p.h
index 86f065a..8142986 100644
--- a/src/declarative/graphicsitems/qdeclarativepainteditem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem_p.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativePaintedItemPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativePaintedItem : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativePaintedItem : public QDeclarativeItem
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativepath_p.h b/src/declarative/graphicsitems/qdeclarativepath_p.h
index dad43e6..001bcdf 100644
--- a/src/declarative/graphicsitems/qdeclarativepath_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepath_p.h
@@ -54,7 +54,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class Q_DECLARATIVE_EXPORT QDeclarativePathElement : public QObject
+class Q_AUTOTEST_EXPORT QDeclarativePathElement : public QObject
{
Q_OBJECT
public:
@@ -63,7 +63,7 @@ Q_SIGNALS:
void changed();
};
-class Q_DECLARATIVE_EXPORT QDeclarativePathAttribute : public QDeclarativePathElement
+class Q_AUTOTEST_EXPORT QDeclarativePathAttribute : public QDeclarativePathElement
{
Q_OBJECT
@@ -87,7 +87,7 @@ private:
qreal _value;
};
-class Q_DECLARATIVE_EXPORT QDeclarativeCurve : public QDeclarativePathElement
+class Q_AUTOTEST_EXPORT QDeclarativeCurve : public QDeclarativePathElement
{
Q_OBJECT
@@ -109,7 +109,7 @@ private:
qreal _y;
};
-class Q_DECLARATIVE_EXPORT QDeclarativePathLine : public QDeclarativeCurve
+class Q_AUTOTEST_EXPORT QDeclarativePathLine : public QDeclarativeCurve
{
Q_OBJECT
public:
@@ -118,7 +118,7 @@ public:
void addToPath(QPainterPath &path);
};
-class Q_DECLARATIVE_EXPORT QDeclarativePathQuad : public QDeclarativeCurve
+class Q_AUTOTEST_EXPORT QDeclarativePathQuad : public QDeclarativeCurve
{
Q_OBJECT
@@ -140,7 +140,7 @@ private:
qreal _controlY;
};
-class Q_DECLARATIVE_EXPORT QDeclarativePathCubic : public QDeclarativeCurve
+class Q_AUTOTEST_EXPORT QDeclarativePathCubic : public QDeclarativeCurve
{
Q_OBJECT
@@ -172,7 +172,7 @@ private:
int _control2Y;
};
-class Q_DECLARATIVE_EXPORT QDeclarativePathPercent : public QDeclarativePathElement
+class Q_AUTOTEST_EXPORT QDeclarativePathPercent : public QDeclarativePathElement
{
Q_OBJECT
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY changed)
@@ -187,7 +187,7 @@ private:
};
class QDeclarativePathPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativePath : public QObject, public QDeclarativeParserStatus
+class Q_AUTOTEST_EXPORT QDeclarativePath : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 0c2d249..0e980b3 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -552,6 +552,8 @@ void QDeclarativePathView::setCurrentIndex(int idx)
\qmlmethod PathView::incrementCurrentIndex()
Increments the current index.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativePathView::incrementCurrentIndex()
{
@@ -563,6 +565,8 @@ void QDeclarativePathView::incrementCurrentIndex()
\qmlmethod PathView::decrementCurrentIndex()
Decrements the current index.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativePathView::decrementCurrentIndex()
{
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h
index 8a6f53f..d2980c6 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h
@@ -53,7 +53,7 @@ QT_MODULE(Declarative)
class QDeclarativePathViewPrivate;
class QDeclarativePathViewAttached;
-class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativePathView : public QDeclarativeItem
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index b9231a1..179f13d 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -1027,13 +1027,13 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
continue;
if (d->flow == LeftToRight) {
- if (hoffset && hoffset + child.item->width() > width()) {
+ if (widthValid() && hoffset && hoffset + child.item->width() > width()) {
hoffset = 0;
voffset += linemax + spacing();
linemax = 0;
}
} else {
- if (voffset && voffset + child.item->height() > height()) {
+ if (heightValid() && voffset && voffset + child.item->height() > height()) {
voffset = 0;
hoffset += linemax + spacing();
linemax = 0;
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
index 787dcd3..c03e518 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeBasePositionerPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeBasePositioner : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeBasePositioner : public QDeclarativeItem
{
Q_OBJECT
@@ -112,7 +112,7 @@ private:
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeBasePositioner)
};
-class Q_DECLARATIVE_EXPORT QDeclarativeColumn : public QDeclarativeBasePositioner
+class Q_AUTOTEST_EXPORT QDeclarativeColumn : public QDeclarativeBasePositioner
{
Q_OBJECT
public:
@@ -124,7 +124,7 @@ private:
Q_DISABLE_COPY(QDeclarativeColumn)
};
-class Q_DECLARATIVE_EXPORT QDeclarativeRow: public QDeclarativeBasePositioner
+class Q_AUTOTEST_EXPORT QDeclarativeRow: public QDeclarativeBasePositioner
{
Q_OBJECT
public:
@@ -136,7 +136,7 @@ private:
Q_DISABLE_COPY(QDeclarativeRow)
};
-class Q_DECLARATIVE_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner
+class Q_AUTOTEST_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner
{
Q_OBJECT
Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
@@ -174,7 +174,7 @@ private:
};
class QDeclarativeFlowPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeFlow: public QDeclarativeBasePositioner
+class Q_AUTOTEST_EXPORT QDeclarativeFlow: public QDeclarativeBasePositioner
{
Q_OBJECT
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index 2756877..c49be46 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -446,6 +446,7 @@ void QDeclarativeRectangle::drawRect(QPainter &p)
p.setRenderHint(QPainter::Antialiasing);
if (d->pen && d->pen->isValid()) {
QPen pn(QColor(d->pen->color()), d->pen->width());
+ pn.setJoinStyle(Qt::MiterJoin);
p.setPen(pn);
} else {
p.setPen(Qt::NoPen);
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle_p.h b/src/declarative/graphicsitems/qdeclarativerectangle_p.h
index 7272962..ecc3fbf 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle_p.h
+++ b/src/declarative/graphicsitems/qdeclarativerectangle_p.h
@@ -68,7 +68,7 @@ public:
QColor color() const { return _color; }
void setColor(const QColor &c);
- bool isValid() { return _valid; };
+ bool isValid() { return _valid; }
Q_SIGNALS:
void penChanged();
@@ -79,7 +79,7 @@ private:
bool _valid;
};
-class Q_DECLARATIVE_EXPORT QDeclarativeGradientStop : public QObject
+class Q_AUTOTEST_EXPORT QDeclarativeGradientStop : public QObject
{
Q_OBJECT
@@ -103,7 +103,7 @@ private:
QColor m_color;
};
-class Q_DECLARATIVE_EXPORT QDeclarativeGradient : public QObject
+class Q_AUTOTEST_EXPORT QDeclarativeGradient : public QObject
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater_p.h b/src/declarative/graphicsitems/qdeclarativerepeater_p.h
index db46699..ff58fa0 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater_p.h
+++ b/src/declarative/graphicsitems/qdeclarativerepeater_p.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeRepeaterPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeRepeater : public QDeclarativeItem
+class Q_AUTOTEST_EXPORT QDeclarativeRepeater : public QDeclarativeItem
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index c2e0d67..0bd9a53 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -136,6 +136,8 @@ QSet<QUrl> QTextDocumentWithImageResources::errors;
HTML img tags that load remote images, the text is reloaded.
Text provides read-only text. For editable text, see \l TextEdit.
+
+ \sa {declarative/text/fonts}{Fonts example}
*/
/*!
@@ -225,12 +227,6 @@ QDeclarativeTextPrivate::~QDeclarativeTextPrivate()
*/
/*!
- \qmlproperty bool Text::font.outline
-
- Sets whether the font has an outline style.
-*/
-
-/*!
\qmlproperty bool Text::font.strikeout
Sets whether the font has a strikeout style.
@@ -441,6 +437,8 @@ void QDeclarativeText::setStyleColor(const QColor &color)
\qml
Text { font.pointSize: 18; text: "hello"; style: Text.Raised; styleColor: "gray" }
\endqml
+
+ \sa style
*/
QColor QDeclarativeText::styleColor() const
{
@@ -663,6 +661,71 @@ void QDeclarativeText::setElideMode(QDeclarativeText::TextElideMode mode)
emit elideModeChanged(d->elideMode);
}
+QRectF QDeclarativeText::boundingRect() const
+{
+ Q_D(const QDeclarativeText);
+
+ int w = width();
+ int h = height();
+
+ int x = 0;
+ int y = 0;
+
+ if (d->cache || d->style != Normal) {
+ switch (d->hAlign) {
+ case AlignLeft:
+ x = 0;
+ break;
+ case AlignRight:
+ x = w - d->imgCache.width();
+ break;
+ case AlignHCenter:
+ x = (w - d->imgCache.width()) / 2;
+ break;
+ }
+
+ switch (d->vAlign) {
+ case AlignTop:
+ y = 0;
+ break;
+ case AlignBottom:
+ y = h - d->imgCache.height();
+ break;
+ case AlignVCenter:
+ y = (h - d->imgCache.height()) / 2;
+ break;
+ }
+
+ return QRectF(x,y,d->imgCache.width(),d->imgCache.height());
+ } else {
+ switch (d->hAlign) {
+ case AlignLeft:
+ x = 0;
+ break;
+ case AlignRight:
+ x = w - d->cachedLayoutSize.width();
+ break;
+ case AlignHCenter:
+ x = (w - d->cachedLayoutSize.width()) / 2;
+ break;
+ }
+
+ switch (d->vAlign) {
+ case AlignTop:
+ y = 0;
+ break;
+ case AlignBottom:
+ y = h - d->cachedLayoutSize.height();
+ break;
+ case AlignVCenter:
+ y = (h - d->cachedLayoutSize.height()) / 2;
+ break;
+ }
+
+ return QRectF(x,y,d->cachedLayoutSize.width(),d->cachedLayoutSize.height());
+ }
+}
+
void QDeclarativeText::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
@@ -713,6 +776,7 @@ void QDeclarativeTextPrivate::updateLayout()
}
}
+
void QDeclarativeTextPrivate::updateSize()
{
Q_Q(QDeclarativeText);
@@ -730,7 +794,10 @@ void QDeclarativeTextPrivate::updateSize()
//setup instance of QTextLayout for all cases other than richtext
if (!richText) {
size = setupTextLayout(&layout);
- cachedLayoutSize = size;
+ if (cachedLayoutSize != size) {
+ q->prepareGeometryChange();
+ cachedLayoutSize = size;
+ }
dy -= size.height();
} else {
singleline = false; // richtext can't elide or be optimized for single-line case
@@ -744,7 +811,13 @@ void QDeclarativeTextPrivate::updateSize()
else
doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
dy -= (int)doc->size().height();
- cachedLayoutSize = doc->size().toSize();
+ q->prepareGeometryChange();
+ QSize dsize = doc->size().toSize();
+ if (dsize != cachedLayoutSize) {
+ q->prepareGeometryChange();
+ cachedLayoutSize = dsize;
+ }
+ size = QSize(int(doc->idealWidth()),dsize.height());
}
int yoff = 0;
@@ -757,8 +830,8 @@ void QDeclarativeTextPrivate::updateSize()
q->setBaselineOffset(fm.ascent() + yoff);
//### need to comfirm cost of always setting these for richText
- q->setImplicitWidth(richText ? (int)doc->idealWidth() : size.width());
- q->setImplicitHeight(richText ? (int)doc->size().height() : size.height());
+ q->setImplicitWidth(size.width());
+ q->setImplicitHeight(size.height());
emit q->paintedSizeChanged();
} else {
dirty = true;
@@ -813,6 +886,8 @@ void QDeclarativeTextPrivate::drawOutline()
ppm.drawPixmap(pos, imgCache);
ppm.end();
+ if (imgCache.size() != img.size())
+ q_func()->prepareGeometryChange();
imgCache = img;
}
@@ -831,6 +906,8 @@ void QDeclarativeTextPrivate::drawOutline(int yOffset)
ppm.drawPixmap(pos, imgCache);
ppm.end();
+ if (imgCache.size() != img.size())
+ q_func()->prepareGeometryChange();
imgCache = img;
}
@@ -955,18 +1032,21 @@ void QDeclarativeTextPrivate::checkImgCache()
return;
bool empty = text.isEmpty();
+ QPixmap newImgCache;
if (empty) {
- imgCache = QPixmap();
imgStyleCache = QPixmap();
} else if (richText) {
- imgCache = richTextImage(false);
+ newImgCache = richTextImage(false);
if (style != QDeclarativeText::Normal)
imgStyleCache = richTextImage(true); //### should use styleColor
} else {
- imgCache = wrappedTextImage(false);
+ newImgCache = wrappedTextImage(false);
if (style != QDeclarativeText::Normal)
imgStyleCache = wrappedTextImage(true); //### should use styleColor
}
+ if (imgCache.size() != newImgCache.size())
+ q_func()->prepareGeometryChange();
+ imgCache = newImgCache;
if (!empty)
switch (style) {
case QDeclarativeText::Outline:
@@ -1031,35 +1111,7 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
if (d->smooth)
p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
- int w = width();
- int h = height();
-
- int x = 0;
- int y = 0;
-
- switch (d->hAlign) {
- case AlignLeft:
- x = 0;
- break;
- case AlignRight:
- x = w - d->imgCache.width();
- break;
- case AlignHCenter:
- x = (w - d->imgCache.width()) / 2;
- break;
- }
-
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->imgCache.height();
- break;
- case AlignVCenter:
- y = (h - d->imgCache.height()) / 2;
- break;
- }
+ QRect br = boundingRect().toRect();
bool needClip = clip() && (d->imgCache.width() > width() ||
d->imgCache.height() > height());
@@ -1068,7 +1120,7 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
p->save();
p->setClipRect(boundingRect(), Qt::IntersectClip);
}
- p->drawPixmap(x, y, d->imgCache);
+ p->drawPixmap(br.x(), br.y(), d->imgCache);
if (needClip)
p->restore();
@@ -1077,20 +1129,8 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
} else {
- int h = height();
- int y = 0;
+ qreal y = boundingRect().y();
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->cachedLayoutSize.height();
- break;
- case AlignVCenter:
- y = (h - d->cachedLayoutSize.height()) / 2;
- break;
- }
bool needClip = !clip() && (d->cachedLayoutSize.width() > width() ||
d->cachedLayoutSize.height() > height());
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h
index db21140..cd97df3 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p.h
@@ -143,6 +143,8 @@ public:
qreal paintedWidth() const;
qreal paintedHeight() const;
+ QRectF boundingRect() const;
+
Q_SIGNALS:
void textChanged(const QString &text);
void linkActivated(const QString &link);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 3106daf..c6566ff 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -99,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, TextInput
+ \sa Text, TextInput, {declarative/text/textselection}{Text Selection example}
*/
/*!
@@ -186,12 +186,6 @@ QString QDeclarativeTextEdit::text() const
*/
/*!
- \qmlproperty bool TextEdit::font.outline
-
- Sets whether the font has an outline style.
-*/
-
-/*!
\qmlproperty bool TextEdit::font.strikeout
Sets whether the font has a strikeout style.
@@ -1231,8 +1225,13 @@ void QDeclarativeTextEdit::updateImgCache(const QRectF &rf)
r = QRect(0,0,INT_MAX,INT_MAX);
} else {
r = rf.toRect();
- if (r != QRect(0,0,INT_MAX,INT_MAX)) // Don't translate "everything"
+ if (r.height() > INT_MAX/2) {
+ // Take care of overflow when translating "everything"
+ r.setTop(r.y() + d->yoff);
+ r.setBottom(INT_MAX/2);
+ } else {
r = r.translated(0,d->yoff);
+ }
}
dirtyCache(r);
emit update();
@@ -1284,6 +1283,7 @@ void QDeclarativeTextEditPrivate::init()
void QDeclarativeTextEdit::q_textChanged()
{
updateSize();
+ updateMicroFocus();
emit textChanged(text());
}
@@ -1325,8 +1325,17 @@ void QDeclarativeTextEdit::updateSelectionMarkers()
d->lastSelectionEnd = d->control->textCursor().selectionEnd();
emit selectionEndChanged();
}
+ updateMicroFocus();
}
+QRectF QDeclarativeTextEdit::boundingRect() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ QRectF r = QDeclarativePaintedItem::boundingRect();
+ return r.translated(0,d->yoff);
+}
+
+
//### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't
// need to do all the calculations each time
void QDeclarativeTextEdit::updateSize()
@@ -1341,13 +1350,20 @@ void QDeclarativeTextEdit::updateSize()
d->document->setTextWidth(width());
dy -= (int)d->document->size().height();
+ int nyoff;
if (heightValid()) {
if (d->vAlign == AlignBottom)
- d->yoff = dy;
+ nyoff = dy;
else if (d->vAlign == AlignVCenter)
- d->yoff = dy/2;
+ nyoff = dy/2;
+ else
+ nyoff = 0;
} else {
- d->yoff = 0;
+ nyoff = 0;
+ }
+ if (nyoff != d->yoff) {
+ prepareGeometryChange();
+ d->yoff = nyoff;
}
setBaselineOffset(fm.ascent() + d->yoff + d->textMargin);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index d08f607..279af78 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -58,7 +58,7 @@ QT_MODULE(Declarative)
class QDeclarativeTextEditPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
+class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
{
Q_OBJECT
Q_ENUMS(VAlignment)
@@ -195,6 +195,8 @@ public:
Q_INVOKABLE int positionAt(int x, int y) const;
Q_INVOKABLE void moveCursorSelection(int pos);
+ QRectF boundingRect() const;
+
Q_SIGNALS:
void textChanged(const QString &);
void paintedSizeChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index ec14c78..ed999a2 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
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
+ \sa TextEdit, Text, {declarative/text/textselection}{Text Selection example}
*/
QDeclarativeTextInput::QDeclarativeTextInput(QDeclarativeItem* parent)
: QDeclarativePaintedItem(*(new QDeclarativeTextInputPrivate), parent)
@@ -152,12 +152,6 @@ void QDeclarativeTextInput::setText(const QString &s)
*/
/*!
- \qmlproperty bool TextInput::font.outline
-
- Sets whether the font has an outline style.
-*/
-
-/*!
\qmlproperty bool TextInput::font.strikeout
Sets whether the font has a strikeout style.
@@ -1398,18 +1392,11 @@ void QDeclarativeTextInputPrivate::init()
q->connect(control, SIGNAL(selectionChanged()),
q, SLOT(selectionChanged()));
q->connect(control, SIGNAL(textChanged(const QString &)),
- q, SIGNAL(displayTextChanged(const QString &)));
- q->connect(control, SIGNAL(textChanged(const QString &)),
q, SLOT(q_textChanged()));
q->connect(control, SIGNAL(accepted()),
q, SIGNAL(accepted()));
q->connect(control, SIGNAL(updateNeeded(QRect)),
q, SLOT(updateRect(QRect)));
- q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
- q, SLOT(updateRect()));//TODO: Only update rect between pos's
- q->connect(control, SIGNAL(selectionChanged()),
- q, SLOT(updateRect()));//TODO: Only update rect in selection
- //Note that above TODOs probably aren't that big a savings
q->updateSize();
oldValidity = control->hasAcceptableInput();
lastSelectionStart = 0;
@@ -1422,6 +1409,8 @@ void QDeclarativeTextInputPrivate::init()
void QDeclarativeTextInput::cursorPosChanged()
{
Q_D(QDeclarativeTextInput);
+ updateRect();//TODO: Only update rect between pos's
+ updateMicroFocus();
emit cursorPositionChanged();
if(!d->control->hasSelectedText()){
@@ -1439,6 +1428,7 @@ void QDeclarativeTextInput::cursorPosChanged()
void QDeclarativeTextInput::selectionChanged()
{
Q_D(QDeclarativeTextInput);
+ updateRect();//TODO: Only update rect in selection
emit selectedTextChanged();
if(d->lastSelectionStart != d->control->selectionStart()){
@@ -1460,7 +1450,9 @@ void QDeclarativeTextInput::q_textChanged()
Q_D(QDeclarativeTextInput);
d->updateHorizontalScroll();
updateSize();
+ updateMicroFocus();
emit textChanged();
+ emit displayTextChanged();
if(hasAcceptableInput() != d->oldValidity){
d->oldValidity = hasAcceptableInput();
emit acceptableInputChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index 6934da4..bacd041 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -56,7 +56,7 @@ QT_MODULE(Declarative)
class QDeclarativeTextInputPrivate;
class QValidator;
-class Q_DECLARATIVE_EXPORT QDeclarativeTextInput : public QDeclarativePaintedItem
+class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativePaintedItem
{
Q_OBJECT
Q_ENUMS(HAlignment)
@@ -208,7 +208,7 @@ Q_SIGNALS:
void inputMaskChanged(const QString &inputMask);
void echoModeChanged(EchoMode echoMode);
void passwordCharacterChanged();
- void displayTextChanged(const QString &text);
+ void displayTextChanged();
void focusOnPressChanged(bool focusOnPress);
void autoScrollChanged(bool autoScroll);
void selectByMouseChanged(bool selectByMouse);
diff --git a/src/declarative/graphicsitems/qdeclarativetranslate_p.h b/src/declarative/graphicsitems/qdeclarativetranslate_p.h
index 939692b..0207dce 100644
--- a/src/declarative/graphicsitems/qdeclarativetranslate_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetranslate_p.h
@@ -52,7 +52,7 @@ QT_MODULE(Declarative)
class QDeclarativeTranslatePrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeTranslate : public QGraphicsTransform
+class Q_AUTOTEST_EXPORT QDeclarativeTranslate : public QGraphicsTransform
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 5092349..786d6f9 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -283,7 +283,7 @@ public:
if (m_roles.count() == 1)
m_roleNames.insert("modelData", m_roles.at(0));
if (m_roles.count())
- m_roleNames.insert("hasModelChildren", 0);
+ m_roleNames.insert("hasModelChildren", -1);
} else if (m_listAccessor) {
m_roleNames.insert("modelData", 0);
if (m_listAccessor->type() == QDeclarativeListAccessor::Instance) {
@@ -818,6 +818,12 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
\c view.qml:
\snippet doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml 0
+ If the \l model is a QAbstractItemModel subclass, the delegate can also
+ reference a \c hasModelChildren property (optionally qualified by a
+ \e model. prefix) that indicates whether the delegate's model item has
+ any child nodes.
+
+
\sa modelIndex(), parentModelIndex()
*/
QVariant QDeclarativeVisualDataModel::rootIndex() const
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
index 079c9e6..d5c0de2 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
@@ -60,7 +60,7 @@ class QDeclarativeComponent;
class QDeclarativePackage;
class QDeclarativeVisualDataModelPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeVisualModel : public QObject
+class Q_AUTOTEST_EXPORT QDeclarativeVisualModel : public QObject
{
Q_OBJECT
@@ -103,7 +103,7 @@ private:
class QDeclarativeVisualItemModelAttached;
class QDeclarativeVisualItemModelPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeVisualItemModel : public QDeclarativeVisualModel
+class Q_AUTOTEST_EXPORT QDeclarativeVisualItemModel : public QDeclarativeVisualModel
{
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeVisualItemModel)
@@ -138,7 +138,7 @@ private:
};
-class Q_DECLARATIVE_EXPORT QDeclarativeVisualDataModel : public QDeclarativeVisualModel
+class Q_AUTOTEST_EXPORT QDeclarativeVisualDataModel : public QDeclarativeVisualModel
{
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeVisualDataModel)