diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-07-19 23:06:36 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-07-19 23:06:36 (GMT) |
commit | b6f85c59d1cd45a4df57440b9d39659d2646223e (patch) | |
tree | e2d34780f79821eb41d3dcc978a5e4aa656fc79e | |
parent | dff083ccb6971fa28d838493353857783297b4a9 (diff) | |
parent | 1dc2e92b4630a0c19d1d2bdf5a05cd18003c566a (diff) | |
download | Qt-b6f85c59d1cd45a4df57440b9d39659d2646223e.zip Qt-b6f85c59d1cd45a4df57440b9d39659d2646223e.tar.gz Qt-b6f85c59d1cd45a4df57440b9d39659d2646223e.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
28 files changed, 456 insertions, 48 deletions
diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml new file mode 100644 index 0000000..4c65605 --- /dev/null +++ b/examples/declarative/snow/ImageBatch.qml @@ -0,0 +1,70 @@ +GridView { + id: MyGrid + property int offset: 0 + property var ref + property bool isSelected: ref.selectedItemColumn >= offset && ref.selectedItemColumn < offset + 5 + + currentIndex: (ref.selectedItemColumn - offset) + ref.selectedItemRow * 5 + + property int imageWidth: ref.imageWidth + property int imageHeight: ref.imageHeight + + width: 5 * imageWidth + height: 4 * imageHeight + cellWidth: imageWidth + cellHeight: imageHeight + + states: State { + name: "selected"; when: MyGrid.isSelected + SetProperties { target: MyGrid; z: 150 } + } + transitions: Transition { + SequentialAnimation { + PauseAnimation { duration: 150 } + SetPropertyAction { properties: "z" } + } + } + model: XmlListModel { + property string tags : "" + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" + + XmlRole { name: "url"; query: "media:content/@url/string()" } + } + + Item { + id: Root + property bool isSelected: GridView.isCurrentItem && MyGrid.isSelected + transformOrigin: "Center" + width: MyGrid.imageWidth; height: MyGrid.imageHeight; + + Image { id: Image; source: url; preserveAspect: true; smooth: true; anchors.fill: parent; + opacity: (status == 0)?1:0; opacity: Behavior { NumberAnimation { properties: "opacity" } } } + Loading { anchors.centeredIn: parent; visible: Image.status } + + states: State { + name: "selected" + when: Root.isSelected + SetProperties { target: Root; scale: 3; z: 100 } + } + transitions: [ + Transition { + toState: "selected" + SequentialAnimation { + PauseAnimation { duration: 150 } + SetPropertyAction { properties: "z" } + NumberAnimation { properties: "scale"; duration: 150; } + } + }, + Transition { + fromState: "selected" + SequentialAnimation { + NumberAnimation { properties: "scale"; duration: 150 } + SetPropertyAction { properties: "z" } + } + } + ] + } +} + diff --git a/examples/declarative/snow/Loading.qml b/examples/declarative/snow/Loading.qml new file mode 100644 index 0000000..0a8a51a --- /dev/null +++ b/examples/declarative/snow/Loading.qml @@ -0,0 +1,6 @@ +Image { + id: Loading; source: "pics/loading.png"; transformOrigin: "Center" + rotation: NumberAnimation { + id: "RotationAnimation"; from: 0; to: 360; running: Loading.visible == true; repeat: true; duration: 900 + } +} diff --git a/examples/declarative/snow/create.js b/examples/declarative/snow/create.js new file mode 100644 index 0000000..9def7a7 --- /dev/null +++ b/examples/declarative/snow/create.js @@ -0,0 +1,12 @@ +var myComponent = null; + +function createNewBlock() { + if (myComponent == null) + myComponent = createComponent("ImageBatch.qml"); + + var obj = myComponent.createObject(); + obj.parent = MyLayout; + obj.offset = maximumColumn + 1; + obj.ref = ImagePanel; + maximumColumn += 5; +} diff --git a/examples/declarative/snow/pics/loading.png b/examples/declarative/snow/pics/loading.png Binary files differnew file mode 100644 index 0000000..0296cfe --- /dev/null +++ b/examples/declarative/snow/pics/loading.png diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml new file mode 100644 index 0000000..2b413bb --- /dev/null +++ b/examples/declarative/snow/snow.qml @@ -0,0 +1,67 @@ +Rect { + id: ImagePanel + width: 1024 + height: 768 + color: "black" + + property int maximumColumn: 4 + property int selectedItemRow: 0 + property int selectedItemColumn: 0 + + Script { source: "create.js" } + + onSelectedItemColumnChanged: if (selectedItemColumn == maximumColumn) createNewBlock(); + + property int imageWidth: 200 + property int imageHeight: 200 + + property int selectedX: selectedItemColumn * imageWidth + property int selectedY: selectedItemRow * imageHeight + + Item { + anchors.centeredIn: parent + HorizontalLayout { + id: MyLayout + property real targetX: -(selectedX + imageWidth / 2) + + property real targetDeform: 0 + property bool slowDeform: true + + property real deform + deform: Follow { source: MyLayout.targetDeform; velocity: MyLayout.slowDeform?0.1:2 } + + onDeformChanged: if(deform == targetDeform) { slowDeform = true; targetDeform = 0; } + + ImageBatch { offset: 0; ref: ImagePanel } + + x: Follow { source: MyLayout.targetX; velocity: 1000 } + y: Follow { source: -(selectedY + imageHeight / 2); velocity: 500 } + } + + transform: Rotation3D { + axis { startX: 0; startY: 0; endX: 0; endY: 1 } + angle: MyLayout.deform * 100 + } + } + + Script { + function leftPressed() { + if (selectedItemColumn <= 0) return; + selectedItemColumn -= 1; + MyLayout.slowDeform = false; + MyLayout.targetDeform = Math.max(Math.min(MyLayout.deform - 0.1, -0.1), -0.4); + } + function rightPressed() { + selectedItemColumn += 1; + MyLayout.slowDeform = false; + MyLayout.targetDeform = Math.min(Math.max(MyLayout.deform + 0.1, 0.1), 0.4); + } + } + KeyActions { + focus: true + leftArrow: "leftPressed()" + rightArrow: "rightPressed()" + upArrow: "if (selectedItemRow > 0) selectedItemRow = selectedItemRow - 1" + downArrow: "if (selectedItemRow < 3) selectedItemRow = selectedItemRow + 1" + } +} diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index f31794d..d71a22a 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -33,7 +33,8 @@ HEADERS += \ kernel/qsystemsemaphore.h \ kernel/qsystemsemaphore_p.h \ kernel/qfunctions_p.h \ - kernel/qmetaobjectbuilder_p.h + kernel/qmetaobjectbuilder_p.h \ + kernel/qguard_p.h SOURCES += \ kernel/qabstracteventdispatcher.cpp \ @@ -56,7 +57,8 @@ SOURCES += \ kernel/qsharedmemory.cpp \ kernel/qsystemsemaphore.cpp \ kernel/qmetaobjectbuilder.cpp \ - kernel/qpointer.cpp + kernel/qpointer.cpp \ + kernel/qguard.cpp win32 { SOURCES += \ diff --git a/src/corelib/kernel/qguard.cpp b/src/corelib/kernel/qguard.cpp new file mode 100644 index 0000000..c61be00 --- /dev/null +++ b/src/corelib/kernel/qguard.cpp @@ -0,0 +1,26 @@ +#include "qguard_p.h" +#include <private/qobject_p.h> + +void q_guard_addGuard(QGuard<QObject> *g) +{ + QObjectPrivate *p = QObjectPrivate::get(g->o); + if (p->wasDeleted) { + qWarning("QGuard: cannot add guard to deleted object"); + g->o = 0; + return; + } + + g->next = p->objectGuards; + p->objectGuards = g; + g->prev = &p->objectGuards; + if (g->next) + g->next->prev = &g->next; +} + +void q_guard_removeGuard(QGuard<QObject> *g) +{ + *g->prev = g->next; + g->next = 0; + g->prev = 0; +} + diff --git a/src/corelib/kernel/qguard_p.h b/src/corelib/kernel/qguard_p.h new file mode 100644 index 0000000..7236ed6 --- /dev/null +++ b/src/corelib/kernel/qguard_p.h @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGUARD_P_H +#define QGUARD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#include "QtCore/qglobal.h" + +QT_BEGIN_NAMESPACE + +class QObject; +template<class T> +class QGuard +{ + QObject *o; + QGuard<QObject> *next; + QGuard<QObject> **prev; + friend void q_guard_addGuard(QGuard<QObject> *); + friend void q_guard_removeGuard(QGuard<QObject> *); + friend class QObjectPrivate; +public: + inline QGuard(); + inline QGuard(T *); + inline QGuard(const QGuard<T> &); + inline virtual ~QGuard(); + + inline QGuard<T> &operator=(const QGuard<T> &o); + inline QGuard<T> &operator=(T *); + + inline bool isNull() const + { return !o; } + + inline T* operator->() const + { return static_cast<T*>(const_cast<QObject*>(o)); } + inline T& operator*() const + { return *static_cast<T*>(const_cast<QObject*>(o)); } + inline operator T*() const + { return static_cast<T*>(const_cast<QObject*>(o)); } + inline T* data() const + { return static_cast<T*>(const_cast<QObject*>(o)); } + +protected: + virtual void objectDestroyed(T *) {} +}; + +void Q_CORE_EXPORT q_guard_addGuard(QGuard<QObject> *); +void Q_CORE_EXPORT q_guard_removeGuard(QGuard<QObject> *); + +template<class T> +QGuard<T>::QGuard() +: o(0), next(0), prev(0) +{ +} + +template<class T> +QGuard<T>::QGuard(T *g) +: o(g), next(0), prev(0) +{ + if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this)); +} + +template<class T> +QGuard<T>::QGuard(const QGuard<T> &g) +: o(g.o), next(0), prev(0) +{ + if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this)); +} + +template<class T> +QGuard<T>::~QGuard() +{ + if (prev) q_guard_removeGuard(reinterpret_cast<QGuard<QObject> *>(this)); + o = 0; +} + +template<class T> +QGuard<T> &QGuard<T>::operator=(const QGuard<T> &g) +{ + if (g.o != o) { + if (prev) + q_guard_removeGuard(reinterpret_cast<QGuard<QObject> *>(this)); + o = g.o; + if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this)); + } + return *this; +} + +template<class T> +inline QGuard<T> &QGuard<T>::operator=(T *g) +{ + if (g != o) { + if (prev) + q_guard_removeGuard(reinterpret_cast<QGuard<QObject> *>(this)); + o = g; + if (o) q_guard_addGuard(reinterpret_cast<QGuard<QObject> *>(this)); + } + return *this; +} + +QT_END_NAMESPACE + +#endif // QGUARD_P_H diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 1742cd0..8517897 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -144,6 +144,7 @@ QObjectPrivate::QObjectPrivate(int version) inEventHandler = false; inThreadChangeEvent = false; deleteWatch = 0; + objectGuards = 0; metaObject = 0; hasGuards = false; } @@ -428,7 +429,22 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o) */ void QObjectPrivate::clearGuards(QObject *object) { - if (!QObjectPrivate::get(object)->hasGuards) + QObjectPrivate *priv = QObjectPrivate::get(object); + QGuard<QObject> *guard = priv->objectGuards; + while (guard) { + guard->o = 0; + guard = guard->next; + } + while (priv->objectGuards) { + guard = priv->objectGuards; + guard->prev = 0; + if (guard->next) guard->next->prev = &priv->objectGuards; + priv->objectGuards = guard->next; + guard->next = 0; + guard->objectDestroyed(object); + } + + if (!priv->hasGuards) return; GuardHash *hash = guardHash(); if (hash) { diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 83239fe..4ac0d2d 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -60,6 +60,7 @@ #include "QtCore/qvector.h" #include "QtCore/qreadwritelock.h" #include "QtCore/qvariant.h" +#include "qguard_p.h" QT_BEGIN_NAMESPACE @@ -184,6 +185,7 @@ public: static void resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch); int *deleteWatch; + QGuard<QObject> *objectGuards; static QObjectPrivate *get(QObject *o) { return o->d_func(); diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index c31163c..08d38ba 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -55,7 +55,7 @@ #include <private/qmlanimation_p.h> #include "qfxparticles.h" - +#include <QPainter> QT_BEGIN_NAMESPACE #define PI_SQR 9.8696044 diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index e154268..7f0029d 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -645,6 +645,7 @@ void QmlXmlListModel::queryCompleted(int id, int size) if (size > 0) { d->data = d->qmlXmlQuery.modelData(); emit itemsInserted(0, d->size); + emit countChanged(); } } diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h index d9871ab..3b6ffb4 100644 --- a/src/declarative/extra/qmlxmllistmodel.h +++ b/src/declarative/extra/qmlxmllistmodel.h @@ -98,6 +98,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public Q_PROPERTY(QString query READ query WRITE setQuery) Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations) Q_PROPERTY(QmlList<XmlListModelRole *> *roles READ roleObjects) + Q_PROPERTY(int count READ count NOTIFY countChanged) Q_CLASSINFO("DefaultProperty", "roles") public: @@ -130,6 +131,7 @@ public: signals: void statusChanged(Status); void progressChanged(qreal progress); + void countChanged(); public Q_SLOTS: void reload(); diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 11b630a..905af3b 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -45,6 +45,8 @@ #include "private/qfxflickable_p.h" #include "qfxgridview.h" +#include <QKeyEvent> + QT_BEGIN_NAMESPACE class QFxGridViewAttached : public QObject @@ -811,7 +813,7 @@ QFxItem *QFxGridView::currentItem() Q_D(QFxGridView); if (!d->currentItem) { // Always return something valid - if (!d->tmpCurrent) + if (!d->tmpCurrent) d->tmpCurrent = new QFxItem(viewport()); return d->tmpCurrent; } diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index f57782c..027b22a 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -47,6 +47,9 @@ #include <QFile> #include <QtDeclarative/qmlengine.h> +#include <QKeyEvent> +#include <QPainter> + QT_BEGIN_NAMESPACE @@ -233,12 +236,12 @@ void QFxImage::componentComplete() \qmlproperty bool Image::smooth Set this property if you want the image to be smoothly filtered when scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If - the Image is displayed at its natural size, this property has no visual or + transformed. Smooth filtering gives better visual quality, but is slower. If + the Image is displayed at its natural size, this property has no visual or performance effect. - \note Generally scaling artifacts are only visible if the image is stationary on - the screen. A common pattern when animating an image is to disable smooth + \note Generally scaling artifacts are only visible if the image is stationary on + the screen. A common pattern when animating an image is to disable smooth filtering at the beginning of the animation and reenable it at the conclusion. */ @@ -247,7 +250,7 @@ void QFxImage::componentComplete() \brief whether the image is smoothly transformed. This property is provided purely for the purpose of optimization. Turning - smooth transforms off is faster, but looks worse; turning smooth + smooth transforms off is faster, but looks worse; turning smooth transformations on is slower, but looks better. By default smooth transformations are off. @@ -301,9 +304,22 @@ void QFxImage::paintContents(QPainter &p) p.restore(); } else if (!d->scaleGrid || d->scaleGrid->isNull()) { if (width() != pix.width() || height() != pix.height()) { + qreal widthScale = width() / qreal(pix.width()); + qreal heightScale = height() / qreal(pix.height()); + QTransform scale; - scale.scale(width() / qreal(pix.width()), - height() / qreal(pix.height())); + + if (d->preserveAspect) { + if (widthScale < heightScale) { + heightScale = widthScale; + scale.translate(0, (height() - heightScale * pix.height()) / 2); + } else if(heightScale < widthScale) { + widthScale = heightScale; + scale.translate((width() - widthScale * pix.width()) / 2, 0); + } + } + + scale.scale(widthScale, heightScale); QTransform old = p.transform(); p.setWorldTransform(scale * old); p.drawPixmap(0, 0, pix); @@ -335,7 +351,7 @@ void QFxImage::paintContents(QPainter &p) p.drawPixmap(QRect(sgl, 0, w - xSide, sgt), pix, QRect(sgl, 0, pix.width() - xSide, sgt)); // Upper right - if (sgt && pix.width() - sgr) + if (sgt && pix.width() - sgr) p.drawPixmap(QPoint(w-sgr, 0), pix, QRect(pix.width()-sgr, 0, sgr, sgt)); // Middle left @@ -346,13 +362,13 @@ void QFxImage::paintContents(QPainter &p) // Middle if (pix.width() - xSide && pix.height() - ySide) p.drawPixmap(QRect(sgl, sgt, w - xSide, h - ySide), - pix, + pix, QRect(sgl, sgt, pix.width() - xSide, pix.height() - ySide)); // Middle right if (sgr && pix.height() - ySide) p.drawPixmap(QRect(w-sgr, sgt, sgr, h - ySide), pix, QRect(pix.width()-sgr, sgt, sgr, pix.height() - ySide)); - // Lower left + // Lower left if (sgl && sgr) p.drawPixmap(QPoint(0, h - sgb), pix, QRect(0, pix.height() - sgb, sgl, sgb)); @@ -448,6 +464,22 @@ QUrl QFxImage::source() const return d->url; } +bool QFxImage::preserveAspect() const +{ + Q_D(const QFxImage); + return d->preserveAspect; +} + +void QFxImage::setPreserveAspect(bool p) +{ + Q_D(QFxImage); + + if (p == d->preserveAspect) + return; + d->preserveAspect = p; + update(); +} + void QFxImage::setSource(const QUrl &url) { #ifdef Q_ENABLE_PERFORMANCE_LOG diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 378c20d..7b3445c 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -65,7 +65,7 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem Q_PROPERTY(bool tile READ isTiled WRITE setTiled) Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false) Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) - + Q_PROPERTY(bool preserveAspect READ preserveAspect WRITE setPreserveAspect); public: QFxImage(QFxItem *parent=0); ~QFxImage(); @@ -85,6 +85,9 @@ public: Status status() const; qreal progress() const; + bool preserveAspect() const; + void setPreserveAspect(bool); + QUrl source() const; virtual void setSource(const QUrl &url); diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h index e4a3a90..7792dbf 100644 --- a/src/declarative/fx/qfximage_p.h +++ b/src/declarative/fx/qfximage_p.h @@ -55,6 +55,8 @@ #include "qfxitem_p.h" +#include <QtCore/qpointer.h> + QT_BEGIN_NAMESPACE class QSvgRenderer; @@ -69,11 +71,12 @@ class QFxImagePrivate : public QFxItemPrivate public: QFxImagePrivate() : scaleGrid(0), tiled(false), smooth(false), opaque(false), - status(QFxImage::Idle), sciReply(0), progress(0.0) + preserveAspect(false), status(QFxImage::Idle), sciReply(0), + progress(0.0) { } - ~QFxImagePrivate() + ~QFxImagePrivate() { delete scaleGrid; } @@ -82,16 +85,17 @@ public: QFxScaleGrid *getScaleGrid() { - if (!scaleGrid) + if (!scaleGrid) scaleGrid = new QFxScaleGrid; return scaleGrid; } - + QFxScaleGrid *scaleGrid; QPixmap pix; bool tiled : 1; bool smooth : 1; bool opaque : 1; + bool preserveAspect : 1; QFxImage::Status status; QUrl url; diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index 24cf3fc..da79979 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -44,6 +44,7 @@ #include <QValidator> #include <QApplication> #include <QFontMetrics> +#include <QPainter> QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxLineEdit,LineEdit); diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 889cfdd..351365d 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -46,6 +46,7 @@ #include "qfxlistview.h" #include <qmlexpression.h> +#include <QKeyEvent> QT_BEGIN_NAMESPACE class QFxListViewAttached : public QObject @@ -292,7 +293,7 @@ public: } return -1; // Not in visibleList } - + bool mapRangeFromModel(int &index, int &count) const { if (index + count < visibleIndex) return false; diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index c79abbd..7ff3361 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -48,6 +48,7 @@ #include <QEvent> #include <QApplication> #include <QGraphicsSceneMouseEvent> +#include <QPainter> QT_BEGIN_NAMESPACE diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 2ad8536..32d3eb4 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -42,6 +42,7 @@ #include "qfxrect.h" #include "qfxrect_p.h" +#include <QPainter> QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxPen,Pen) @@ -331,7 +332,7 @@ void QFxRect::setGradient(QFxGradient *gradient) This property holds the corner radius used to draw a rounded rect. If radius is non-zero, the rect will be painted as a rounded rectangle, otherwise it will be - painted as a normal rectangle. The same radius is used by all 4 corners; there is currently + painted as a normal rectangle. The same radius is used by all 4 corners; there is currently no way to specify different radii for different corners. */ @@ -591,7 +592,7 @@ void QFxRect::drawRect(QPainter &p) if (yMiddles) p.drawPixmap(QRect(width()-xOffset+pw/2, yOffset-pw/2, xOffset, height() - ySide + pw), d->rectImage, QRect(d->rectImage.width()-xOffset, d->rectImage.height()/2, xOffset, 1)); - // Lower left + // Lower left p.drawPixmap(QPoint(-pw/2, height() - yOffset + pw/2), d->rectImage, QRect(0, d->rectImage.height() - yOffset, xOffset, yOffset)); // Lower Middle diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 8618b87..2bae53f 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -49,7 +49,7 @@ #include <QTextDocument> #include <QTextCursor> #include <QGraphicsSceneMouseEvent> - +#include <QPainter> QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxText,Text) @@ -68,7 +68,7 @@ QML_DEFINE_TYPE(QFxText,Text) \image declarative-text.png - If height and width are not explicitly set, Text will attempt to determine how + If height and width are not explicitly set, Text will attempt to determine how much room is needed and set it accordingly. Unless \c wrap is set, it will always prefer width to height (all text will be placed on a single line). @@ -86,7 +86,7 @@ QML_DEFINE_TYPE(QFxText,Text) \brief The QFxText class provides a formatted text item that you can add to a QFxView. - Text was designed for read-only text; it does not allow for any text editing. + Text was designed for read-only text; it does not allow for any text editing. It can display both plain and rich text. For example: \qml @@ -96,7 +96,7 @@ QML_DEFINE_TYPE(QFxText,Text) \image text.png - If height and width are not explicitly set, Text will attempt to determine how + If height and width are not explicitly set, Text will attempt to determine how much room is needed and set it accordingly. Unless \c wrap is set, it will always prefer width to height (all text will be placed on a single line). @@ -161,9 +161,9 @@ void QFxText::setText(const QString &n) if (d->richText) { if (!d->doc) { - d->control = new QTextControl(this); + d->control = new QTextControl(this); d->control->setTextInteractionFlags(Qt::TextBrowserInteraction); - d->doc = d->control->document(); + d->doc = d->control->document(); d->doc->setDocumentMargin(0); } d->doc->setHtml(n); @@ -299,8 +299,8 @@ QColor QFxText::styleColor() const Sets the horizontal and vertical alignment of the text within the Text items width and height. By default, the text is top-left aligned. - The valid values for \c hAlign are \c AlignLeft, \c AlignRight and - \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom + The valid values for \c hAlign are \c AlignLeft, \c AlignRight and + \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom and \c AlignVCenter. */ @@ -479,7 +479,7 @@ QString QFxText::activeLink() const return d->activeLink; } -void QFxText::geometryChanged(const QRectF &newGeometry, +void QFxText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { Q_D(QFxText); @@ -516,7 +516,7 @@ void QFxTextPrivate::updateSize() QSize size(0, 0); //setup instance of QTextLayout for all cases other than richtext - if (!richText) + if (!richText) { tmp = text; tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); @@ -545,7 +545,7 @@ void QFxTextPrivate::updateSize() dy -= (int)doc->size().height(); } else { dy -= size.height(); - } + } int yoff = 0; if (q->heightValid()) { @@ -555,7 +555,7 @@ void QFxTextPrivate::updateSize() yoff = dy/2; } q->setBaselineOffset(fm.ascent() + yoff); - + if (!q->widthValid()) { int newWidth = (richText ? (int)doc->idealWidth() : size.width()); q->setImplicitWidth(newWidth); @@ -645,7 +645,7 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout) QTextLine line = layout->createLine(); if (!line.isValid()) break; - + if ((wrap || elideMode != Qt::ElideNone) && q->widthValid()) line.setLineWidth(lineWidth); } @@ -686,7 +686,7 @@ QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle) if (drawStyle) { p.setPen(styleColor); } - else + else p.setPen(color); p.setFont(f); layout.draw(&p, QPointF(0, 0)); @@ -813,7 +813,7 @@ void QFxText::paintContents(QPainter &p) break; } - bool needClip = !clip() && (d->imgCache.width() > width() || + bool needClip = !clip() && (d->imgCache.width() > width() || d->imgCache.height() > height()); if (needClip) { @@ -862,7 +862,7 @@ void QFxText::mousePressEvent(QGraphicsSceneMouseEvent *event) if (!event->isAccepted()) QFxItem::mousePressEvent(event); - + } /*! diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 5a62727..f9cde7c 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -50,7 +50,7 @@ #include <QGraphicsSceneMouseEvent> #include <QDebug> - +#include <QPainter> QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxTextEdit, TextEdit) @@ -353,8 +353,8 @@ void QFxTextEdit::setHighlightedTextColor(const QColor &color) Sets the horizontal and vertical alignment of the text within the TextEdit items width and height. By default, the text is top-left aligned. - The valid values for \c hAlign are \c AlignLeft, \c AlignRight and - \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom + The valid values for \c hAlign are \c AlignLeft, \c AlignRight and + \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom and \c AlignVCenter. */ @@ -670,7 +670,7 @@ void QFxTextEdit::setTextMargin(qreal margin) d->document->setDocumentMargin(d->textMargin); } -void QFxTextEdit::geometryChanged(const QRectF &newGeometry, +void QFxTextEdit::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { if (newGeometry.width() != oldGeometry.width()) @@ -762,7 +762,7 @@ Qt::TextInteractionFlags QFxTextEdit::textInteractionFlags() const } /*! - Returns the cursor for the point at the given \a pos on the + Returns the cursor for the point at the given \a pos on the text edit. */ QTextCursor QFxTextEdit::cursorForPosition(const QPoint &pos) const @@ -1130,9 +1130,9 @@ void QFxTextEdit::updateSize() if (!heightValid()) { if (d->text.isEmpty()) { setImplicitHeight(fm.height()); - } else { + } else { setImplicitHeight((int)d->document->size().height()); - } + } } setContentsSize(QSize(width(), height())); } else { @@ -1146,7 +1146,7 @@ void QFxTextEditPrivate::updateDefaultTextOption() QTextOption opt = document->defaultTextOption(); int oldAlignment = opt.alignment(); opt.setAlignment((Qt::Alignment)(int)(hAlign | vAlign)); - + QTextOption::WrapMode oldWrapMode = opt.wrapMode(); if (wrap) diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 7149455..a3dca79e 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -43,6 +43,8 @@ #include <QPen> #include <QFile> #include <QEvent> +#include <QMouseEvent> +#include <QKeyEvent> #include <QBasicTimer> #include <QApplication> #include <QGraphicsSceneMouseEvent> diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 220c464..138be29 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -903,6 +903,11 @@ void QmlCompiler::genComponent(QmlParser::Object *obj) genObject(root); + QmlInstruction def; + init.line = 0; + def.type = QmlInstruction::SetDefault; + output->bytecode << def; + output->bytecode[count - 1].createComponent.count = output->bytecode.count() - count; diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index ba03987..7240eaa 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -48,6 +48,7 @@ #include <QtCore/qrect.h> #include <QtGui/qpainterpath.h> #include <QtGui/qpixmap.h> +#include <QtGui/qstyleoption.h> class tst_QGraphicsItem; diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 7204d7f..d14ae7f 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -56,7 +56,6 @@ #include "qgraphicsitem.h" #include "qset.h" #include "qpixmapcache.h" -#include "qgraphicsview_p.h" #include <QtCore/qpoint.h> diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index ff7e8c6..fc8fa2b 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -59,6 +59,7 @@ #include "qgraphicssceneevent.h" #include "qgraphicsview.h" +#include "qgraphicsview_p.h" #include "qgraphicsitem_p.h" #include <private/qobject_p.h> |