diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-04 04:16:57 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-04 04:16:57 (GMT) |
commit | 120134ec588a6edf572df8d1fae40013753d233e (patch) | |
tree | 3cd78f46a5ffb72408c9fc4e3267095ccec1957a /src | |
parent | e042014961636d459dc84df93ad2cca96049e2d1 (diff) | |
parent | 684fe7af0b6d8133973132fd5b6b01cc16957a10 (diff) | |
download | Qt-120134ec588a6edf572df8d1fae40013753d233e.zip Qt-120134ec588a6edf572df8d1fae40013753d233e.tar.gz Qt-120134ec588a6edf572df8d1fae40013753d233e.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/extra/qmlgraphicsparticles.cpp | 10 | ||||
-rw-r--r-- | src/declarative/graphicsitems/graphicsitems.pri | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsborderimage.cpp | 14 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsimagebase.cpp | 10 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsitem.cpp | 8 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsitem.h | 6 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstextedit.cpp | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstextinput.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 20 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine_p.h | 1 | ||||
-rw-r--r-- | src/declarative/util/qmlpixmapcache.cpp (renamed from src/declarative/graphicsitems/qmlgraphicspixmapcache.cpp) | 15 | ||||
-rw-r--r-- | src/declarative/util/qmlpixmapcache_p.h (renamed from src/declarative/graphicsitems/qmlgraphicspixmapcache_p.h) | 10 | ||||
-rw-r--r-- | src/declarative/util/util.pri | 6 |
14 files changed, 65 insertions, 43 deletions
diff --git a/src/declarative/extra/qmlgraphicsparticles.cpp b/src/declarative/extra/qmlgraphicsparticles.cpp index aba7e27..0349a4e 100644 --- a/src/declarative/extra/qmlgraphicsparticles.cpp +++ b/src/declarative/extra/qmlgraphicsparticles.cpp @@ -50,7 +50,7 @@ #ifndef INT_MAX #define INT_MAX 2147483647 #endif -#include <private/qmlgraphicspixmapcache_p.h> +#include <private/qmlpixmapcache_p.h> #include <private/qfxperf_p_p.h> #include <private/qmlanimation_p_p.h> #include <QNetworkReply> @@ -619,7 +619,7 @@ QmlGraphicsParticles::~QmlGraphicsParticles() { Q_D(QmlGraphicsParticles); if (d->pendingPixmapCache) - QmlGraphicsPixmapCache::cancelGet(d->url, this); + QmlPixmapCache::cancelGet(d->url, this); } /*! @@ -641,7 +641,7 @@ void QmlGraphicsParticles::imageLoaded() { Q_D(QmlGraphicsParticles); d->pendingPixmapCache = false; - QmlGraphicsPixmapCache::find(d->url, &d->image); + QmlPixmapCache::find(d->url, &d->image); d->paintItem->updateSize(); d->paintItem->update(); } @@ -654,7 +654,7 @@ void QmlGraphicsParticles::setSource(const QUrl &name) return; if (d->pendingPixmapCache) { - QmlGraphicsPixmapCache::cancelGet(d->url, this); + QmlPixmapCache::cancelGet(d->url, this); d->pendingPixmapCache = false; } if (name.isEmpty()) { @@ -665,7 +665,7 @@ void QmlGraphicsParticles::setSource(const QUrl &name) } else { d->url = name; Q_ASSERT(!name.isRelative()); - QNetworkReply *reply = QmlGraphicsPixmapCache::get(qmlEngine(this), d->url, &d->image); + QNetworkReply *reply = QmlPixmapCache::get(qmlEngine(this), d->url, &d->image); if (reply) { connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded())); d->pendingPixmapCache = true; diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri index 15d775c..cf71451 100644 --- a/src/declarative/graphicsitems/graphicsitems.pri +++ b/src/declarative/graphicsitems/graphicsitems.pri @@ -39,7 +39,6 @@ HEADERS += \ graphicsitems/qmlgraphicstextedit_p_p.h \ graphicsitems/qmlgraphicstext_p.h \ graphicsitems/qmlgraphicstext_p_p.h \ - graphicsitems/qmlgraphicspixmapcache_p.h \ graphicsitems/qmlgraphicsvisualitemmodel_p.h \ graphicsitems/qmlgraphicslistview_p.h \ graphicsitems/qmlgraphicsgraphicsobjectcontainer_p.h \ @@ -70,7 +69,6 @@ SOURCES += \ graphicsitems/qmlgraphicstextinput.cpp \ graphicsitems/qmlgraphicstext.cpp \ graphicsitems/qmlgraphicstextedit.cpp \ - graphicsitems/qmlgraphicspixmapcache.cpp \ graphicsitems/qmlgraphicsvisualitemmodel.cpp \ graphicsitems/qmlgraphicslistview.cpp \ graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp \ diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp index ed39a2b..89bbe91 100644 --- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp @@ -80,7 +80,7 @@ QmlGraphicsBorderImage::~QmlGraphicsBorderImage() if (d->sciReply) d->sciReply->deleteLater(); if (d->sciPendingPixmapCache) - QmlGraphicsPixmapCache::cancelGet(d->sciurl, this); + QmlPixmapCache::cancelGet(d->sciurl, this); } /*! \qmlproperty enum BorderImage::status @@ -160,11 +160,11 @@ void QmlGraphicsBorderImage::setSource(const QUrl &url) } if (d->pendingPixmapCache) { - QmlGraphicsPixmapCache::cancelGet(d->url, this); + QmlPixmapCache::cancelGet(d->url, this); d->pendingPixmapCache = false; } if (d->sciPendingPixmapCache) { - QmlGraphicsPixmapCache::cancelGet(d->sciurl, this); + QmlPixmapCache::cancelGet(d->sciurl, this); d->sciPendingPixmapCache = false; } @@ -203,7 +203,7 @@ void QmlGraphicsBorderImage::setSource(const QUrl &url) this, SLOT(sciRequestFinished())); } } else { - QNetworkReply *reply = QmlGraphicsPixmapCache::get(qmlEngine(this), d->url, &d->pix); + QNetworkReply *reply = QmlPixmapCache::get(qmlEngine(this), d->url, &d->pix); if (reply) { d->pendingPixmapCache = true; connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); @@ -320,7 +320,7 @@ void QmlGraphicsBorderImage::setGridScaledImage(const QmlGraphicsGridScaledImage d->verticalTileMode = sci.verticalTileRule(); d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); - QNetworkReply *reply = QmlGraphicsPixmapCache::get(qmlEngine(this), d->sciurl, &d->pix); + QNetworkReply *reply = QmlPixmapCache::get(qmlEngine(this), d->sciurl, &d->pix); if (reply) { d->sciPendingPixmapCache = true; connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); @@ -348,10 +348,10 @@ void QmlGraphicsBorderImage::requestFinished() if (d->url.path().endsWith(QLatin1String(".sci"))) { d->sciPendingPixmapCache = false; - QmlGraphicsPixmapCache::find(d->sciurl, &d->pix); + QmlPixmapCache::find(d->sciurl, &d->pix); } else { d->pendingPixmapCache = false; - if (!QmlGraphicsPixmapCache::find(d->url, &d->pix)) + if (!QmlPixmapCache::find(d->url, &d->pix)) d->status = Error; } setImplicitWidth(d->pix.width()); diff --git a/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp b/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp index 283fb04..e86b53d 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimagebase.cpp @@ -45,7 +45,7 @@ #include <QNetworkReply> #include <QFile> #include <QtDeclarative/qmlengine.h> -#include <private/qmlgraphicspixmapcache_p.h> +#include <private/qmlpixmapcache_p.h> QT_BEGIN_NAMESPACE @@ -65,7 +65,7 @@ QmlGraphicsImageBase::~QmlGraphicsImageBase() { Q_D(QmlGraphicsImageBase); if (d->pendingPixmapCache) - QmlGraphicsPixmapCache::cancelGet(d->url, this); + QmlPixmapCache::cancelGet(d->url, this); } QmlGraphicsImageBase::Status QmlGraphicsImageBase::status() const @@ -95,7 +95,7 @@ void QmlGraphicsImageBase::setSource(const QUrl &url) return; if (d->pendingPixmapCache) { - QmlGraphicsPixmapCache::cancelGet(d->url, this); + QmlPixmapCache::cancelGet(d->url, this); d->pendingPixmapCache = false; } @@ -117,7 +117,7 @@ void QmlGraphicsImageBase::setSource(const QUrl &url) update(); } else { d->status = Loading; - QNetworkReply *reply = QmlGraphicsPixmapCache::get(qmlEngine(this), d->url, &d->pix); + QNetworkReply *reply = QmlPixmapCache::get(qmlEngine(this), d->url, &d->pix); if (reply) { d->pendingPixmapCache = true; connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); @@ -147,7 +147,7 @@ void QmlGraphicsImageBase::requestFinished() d->pendingPixmapCache = false; - if (!QmlGraphicsPixmapCache::find(d->url, &d->pix)) + if (!QmlPixmapCache::find(d->url, &d->pix)) d->status = Error; setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 5083f43..51b8365 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -2667,9 +2667,9 @@ void QmlGraphicsItem::setTransformOrigin(TransformOrigin origin) The default is false. - \sa setSmoothTransform() + \sa setSmooth() */ -bool QmlGraphicsItem::smoothTransform() const +bool QmlGraphicsItem::smooth() const { Q_D(const QmlGraphicsItem); return d->smooth; @@ -2679,9 +2679,9 @@ bool QmlGraphicsItem::smoothTransform() const Sets whether the item should be drawn with antialiasing and smooth pixmap filtering to \a smooth. - \sa smoothTransform() + \sa smooth() */ -void QmlGraphicsItem::setSmoothTransform(bool smooth) +void QmlGraphicsItem::setSmooth(bool smooth) { Q_D(QmlGraphicsItem); if (d->smooth == smooth) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h index bdfc245..f64964c 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem.h @@ -91,7 +91,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlP Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged) Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL) Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) - Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) + Q_PROPERTY(bool smooth READ smooth WRITE setSmooth) Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect) Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") @@ -144,8 +144,8 @@ public: TransformOrigin transformOrigin() const; void setTransformOrigin(TransformOrigin); - bool smoothTransform() const; - void setSmoothTransform(bool); + bool smooth() const; + void setSmooth(bool); QRectF boundingRect() const; virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); diff --git a/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h b/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h index b66a5a5..d4ae0a6 100644 --- a/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsscalegrid_p_p.h @@ -44,7 +44,7 @@ #include <QtCore/QString> #include <QtCore/QObject> -#include <private/qmlgraphicspixmapcache_p.h> +#include <private/qmlpixmapcache_p.h> #include <QtDeclarative/qml.h> #include "qmlgraphicsborderimage_p.h" diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp index 13df329..e84f514 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp @@ -946,7 +946,7 @@ void QmlGraphicsTextEditPrivate::init() { Q_Q(QmlGraphicsTextEdit); - q->setSmoothTransform(smooth); + q->setSmooth(smooth); q->setAcceptedMouseButtons(Qt::LeftButton); q->setFlag(QGraphicsItem::ItemHasNoContents, false); q->setFlag(QGraphicsItem::ItemAcceptsInputMethod); diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp index 9a4f627..42de2b6 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp @@ -673,7 +673,7 @@ void QmlGraphicsTextInputPrivate::init() control->setCursorWidth(1); control->setPasswordCharacter(QLatin1Char('*')); control->setLayoutDirection(Qt::LeftToRight); - q->setSmoothTransform(smooth); + q->setSmooth(smooth); q->setAcceptedMouseButtons(Qt::LeftButton); q->setFlag(QGraphicsItem::ItemHasNoContents, false); q->setFlag(QGraphicsItem::ItemAcceptsInputMethod); diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index c562e02..2926791 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -147,6 +147,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) qtObject.setProperty(QLatin1String("tint"), scriptEngine.newFunction(QmlEnginePrivate::tint, 2)); //misc methods + qtObject.setProperty(QLatin1String("closestAngle"), scriptEngine.newFunction(QmlEnginePrivate::closestAngle, 2)); qtObject.setProperty(QLatin1String("playSound"), scriptEngine.newFunction(QmlEnginePrivate::playSound, 1)); qtObject.setProperty(QLatin1String("openUrlExternally"),scriptEngine.newFunction(desktopOpenUrl, 1)); @@ -810,6 +811,25 @@ QScriptValue QmlEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngin return e->newVariant(QVariant(ret)); } +QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e) +{ + if(ctxt->argumentCount() < 2) + return e->newVariant(QVariant(0.0)); + qreal a = ctxt->argument(0).toNumber(); + qreal b = ctxt->argument(1).toNumber(); + qreal ret = b; + qreal diff = b-a; + while(diff > 180.0){ + ret -= 360.0; + diff -= 360.0; + } + while(diff < -180.0){ + ret += 360.0; + diff += 360.0; + } + return e->newVariant(QVariant(ret)); +} + QScriptValue QmlEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine) { if(ctxt->argumentCount() != 2) diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index b050ef6..3c60b5c 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -269,6 +269,7 @@ public: static QScriptValue darker(QScriptContext*, QScriptEngine*); static QScriptValue tint(QScriptContext*, QScriptEngine*); + static QScriptValue closestAngle(QScriptContext*, QScriptEngine*); static QScriptValue playSound(QScriptContext*, QScriptEngine*); static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*); diff --git a/src/declarative/graphicsitems/qmlgraphicspixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index fdf489c..f5904c0 100644 --- a/src/declarative/graphicsitems/qmlgraphicspixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qmlgraphicspixmapcache_p.h" +#include "qmlpixmapcache_p.h" #include <QImageReader> #include <QHash> #include <QNetworkReply> @@ -50,6 +50,7 @@ #include <QtCore/qdebug.h> QT_BEGIN_NAMESPACE + class QSharedNetworkReply; typedef QHash<QString, QSharedNetworkReply *> QmlGraphicsSharedNetworkReplyHash; static QmlGraphicsSharedNetworkReplyHash qfxActiveNetworkReplies; @@ -118,7 +119,7 @@ static bool readImage(QIODevice *dev, QPixmap *pixmap) /*! \internal - \class QmlGraphicsPixmapCache + \class QmlPixmapCache \brief Enacapsultes a pixmap for QmlGraphics items. This class is NOT reentrant. @@ -140,7 +141,7 @@ static QString toLocalFileOrQrc(const QUrl& url) Returns true if the image was loaded without error. */ -bool QmlGraphicsPixmapCache::find(const QUrl& url, QPixmap *pixmap) +bool QmlPixmapCache::find(const QUrl& url, QPixmap *pixmap) { #ifdef Q_ENABLE_PERFORMANCE_LOG QmlPerfTimer<QmlPerf::PixmapLoad> perf; @@ -169,7 +170,7 @@ bool QmlGraphicsPixmapCache::find(const QUrl& url, QPixmap *pixmap) QmlGraphicsSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key); if (iter == qfxActiveNetworkReplies.end()) { // API usage error - qWarning() << "QmlGraphicsPixmapCache: URL not loaded" << url; + qWarning() << "QmlPixmapCache: URL not loaded" << url; ok = false; } else { if ((*iter)->reply->error()) { @@ -213,7 +214,7 @@ bool QmlGraphicsPixmapCache::find(const QUrl& url, QPixmap *pixmap) The returned QNetworkReply will be deleted when all get() calls are matched by a corresponding find() call. */ -QNetworkReply *QmlGraphicsPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap) +QNetworkReply *QmlPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap) { #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML QString lf = toLocalFileOrQrc(url); @@ -259,7 +260,7 @@ QNetworkReply *QmlGraphicsPixmapCache::get(QmlEngine *engine, const QUrl& url, Q Any connections from the QNetworkReply returned by get() to \a obj will be disconnected. */ -void QmlGraphicsPixmapCache::cancelGet(const QUrl& url, QObject* obj) +void QmlPixmapCache::cancelGet(const QUrl& url, QObject* obj) { QString key = url.toString(); QmlGraphicsSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key); @@ -274,7 +275,7 @@ void QmlGraphicsPixmapCache::cancelGet(const QUrl& url, QObject* obj) This function is mainly for test verification. It returns the number of requests that are still unfinished. */ -int QmlGraphicsPixmapCache::pendingRequests() +int QmlPixmapCache::pendingRequests() { return qfxActiveNetworkReplies.count(); } diff --git a/src/declarative/graphicsitems/qmlgraphicspixmapcache_p.h b/src/declarative/util/qmlpixmapcache_p.h index 29de98d..e6ed452 100644 --- a/src/declarative/graphicsitems/qmlgraphicspixmapcache_p.h +++ b/src/declarative/util/qmlpixmapcache_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QMLGRAPHICSPIXMAPCACHE_H -#define QMLGRAPHICSPIXMAPCACHE_H +#ifndef QMLPIXMAPCACHE_H +#define QMLPIXMAPCACHE_H #include <QtCore/QString> #include <QtGui/QPixmap> @@ -53,13 +53,13 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QmlEngine; class QNetworkReply; -class Q_DECLARATIVE_EXPORT QmlGraphicsPixmapCache +class Q_DECLARATIVE_EXPORT QmlPixmapCache { public: static QNetworkReply *get(QmlEngine *, const QUrl& url, QPixmap *pixmap); static void cancelGet(const QUrl& url, QObject* obj); - static bool find(const QUrl& url, QPixmap *pixmap); // url must have been passed to QmlGraphicsPixmapCache::get, and any returned reply finished. + static bool find(const QUrl& url, QPixmap *pixmap); // url must have been passed to QmlPixmapCache::get, and any returned reply finished. static int pendingRequests(); // mainly for test verification }; @@ -68,4 +68,4 @@ QT_END_NAMESPACE QT_END_HEADER -#endif // QMLGRAPHICSPIXMAPCACHE_H +#endif // QMLPIXMAPCACHE_H diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 87ccb58..f955ef6 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -20,7 +20,8 @@ SOURCES += \ util/qmltimeline.cpp \ util/qmltimer.cpp \ util/qmlbind.cpp \ - util/qmlpropertymap.cpp + util/qmlpropertymap.cpp \ + util/qmlpixmapcache.cpp HEADERS += \ util/qmlview.h \ @@ -47,4 +48,5 @@ HEADERS += \ util/qmltimeline_p_p.h \ util/qmltimer_p.h \ util/qmlbind_p.h \ - util/qmlpropertymap_p.h + util/qmlpropertymap_p.h \ + util/qmlpixmapcache_p.h |