diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-11-05 00:53:00 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-11-05 00:53:00 (GMT) |
commit | aa6f6174374e0abfe94f37ccefce2d0e2b5fe13e (patch) | |
tree | 2848c48829255e8a2e85cc50bd84cc6a2a27939c /src/declarative | |
parent | f3cce7a770f25c42d5c85b012df338fc712f5b2e (diff) | |
parent | 9e5c80bd52467afa481775fe9695bac7edcf7324 (diff) | |
download | Qt-aa6f6174374e0abfe94f37ccefce2d0e2b5fe13e.zip Qt-aa6f6174374e0abfe94f37ccefce2d0e2b5fe13e.tar.gz Qt-aa6f6174374e0abfe94f37ccefce2d0e2b5fe13e.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
32 files changed, 200 insertions, 488 deletions
diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri index 9d0e760..a84dfca 100644 --- a/src/declarative/extra/extra.pri +++ b/src/declarative/extra/extra.pri @@ -2,7 +2,6 @@ SOURCES += \ extra/qnumberformat.cpp \ extra/qmlnumberformatter.cpp \ extra/qmldatetimeformatter.cpp \ - extra/qmlgraphicsintegermodel.cpp \ extra/qmlgraphicsanimatedimageitem.cpp \ extra/qmlgraphicsparticles.cpp \ extra/qmlbehavior.cpp \ @@ -12,7 +11,6 @@ HEADERS += \ extra/qnumberformat_p.h \ extra/qmlnumberformatter_p.h \ extra/qmldatetimeformatter_p.h \ - extra/qmlgraphicsintegermodel_p.h \ extra/qmlgraphicsanimatedimageitem_p.h \ extra/qmlgraphicsanimatedimageitem_p_p.h \ extra/qmlgraphicsparticles_p.h \ diff --git a/src/declarative/extra/qmlfontloader.cpp b/src/declarative/extra/qmlfontloader.cpp index 8c17d0f..e8db649 100644 --- a/src/declarative/extra/qmlfontloader.cpp +++ b/src/declarative/extra/qmlfontloader.cpp @@ -163,6 +163,8 @@ void QmlFontLoader::setName(const QString &name) return; d->name = name; emit nameChanged(); + d->status = Ready; + emit statusChanged(); } /*! diff --git a/src/declarative/extra/qmlgraphicsintegermodel.cpp b/src/declarative/extra/qmlgraphicsintegermodel.cpp deleted file mode 100644 index bcd00e6..0000000 --- a/src/declarative/extra/qmlgraphicsintegermodel.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlgraphicsintegermodel_p.h" - -QT_BEGIN_NAMESPACE - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,IntegerModel,QmlGraphicsIntegerModel) - -class QmlGraphicsIntegerModelPrivate -{ -public: - QmlGraphicsIntegerModelPrivate() : minimum(0), maximum(0) {} - int minimum; - int maximum; -}; - -QmlGraphicsIntegerModel::QmlGraphicsIntegerModel(QObject *parent) - : QListModelInterface(parent) -{ - d = new QmlGraphicsIntegerModelPrivate; -} - -QmlGraphicsIntegerModel::~QmlGraphicsIntegerModel() -{ - delete d; -} - -int QmlGraphicsIntegerModel::minimum() const -{ - return d->minimum; -} - -void QmlGraphicsIntegerModel::setMinimum(int minimum) -{ - d->minimum = minimum; -} - -int QmlGraphicsIntegerModel::maximum() const -{ - return d->maximum; -} - -void QmlGraphicsIntegerModel::setMaximum(int maximum) -{ - d->maximum = maximum; -} - -int QmlGraphicsIntegerModel::count() const -{ - return qMax(0, d->maximum - d->minimum + 1); -} - -QHash<int,QVariant> QmlGraphicsIntegerModel::data(int index, const QList<int> &roles) const -{ - QHash<int,QVariant> returnHash; - - for (int i = 0; i < roles.size(); ++i) { - int role = roles.at(i); - QVariant info; - switch(role) { - case Qt::DisplayRole: - info = QVariant(QString::number(d->minimum+index)); - break; - default: - break; - } - returnHash.insert(role, info); - } - return returnHash; -} - -QString QmlGraphicsIntegerModel::toString(int role) const -{ - switch(role) { - case Qt::DisplayRole: - return QLatin1String("display"); - default: - return QLatin1String(""); - } -} - -QList<int> QmlGraphicsIntegerModel::roles() const -{ - return QList<int>() << Qt::DisplayRole; -} - -QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlgraphicsintegermodel_p.h b/src/declarative/extra/qmlgraphicsintegermodel_p.h deleted file mode 100644 index 4055e01..0000000 --- a/src/declarative/extra/qmlgraphicsintegermodel_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLGRAPHICSINTMODEL_H -#define QMLGRAPHICSINTMODEL_H - -#include <QtCore/QObject> -#include <QtDeclarative/qml.h> -#include <private/qlistmodelinterface_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QmlGraphicsIntegerModelPrivate; -class Q_DECLARATIVE_EXPORT QmlGraphicsIntegerModel : public QListModelInterface -{ - Q_OBJECT -public: - QmlGraphicsIntegerModel(QObject *parent=0); - ~QmlGraphicsIntegerModel(); - - Q_PROPERTY(int minimum READ minimum WRITE setMinimum) - int minimum() const; - void setMinimum(int); - - Q_PROPERTY(int maximum READ maximum WRITE setMaximum) - int maximum() const; - void setMaximum(int); - - int count() const; - QHash<int, QVariant> data(int index, const QList<int> &roles) const; - QList<int> roles() const; - QString toString(int role) const; - -private: - QmlGraphicsIntegerModelPrivate *d; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QmlGraphicsIntegerModel) - -QT_END_HEADER - -#endif 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/qmlgraphicseffects.cpp b/src/declarative/graphicsitems/qmlgraphicseffects.cpp index c611eea..b642e60 100644 --- a/src/declarative/graphicsitems/qmlgraphicseffects.cpp +++ b/src/declarative/graphicsitems/qmlgraphicseffects.cpp @@ -81,25 +81,6 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Blur,QGraphicsBlurEffect) By default, the blur hint is Qt.PerformanceHint. */ -QML_DECLARE_TYPE(QGraphicsGrayscaleEffect) -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Grayscale,QGraphicsGrayscaleEffect) - -/*! - \qmlclass Grayscale QGraphicsGrayscaleEffect - \brief The Grayscale object provides a grayscale effect. - - A grayscale effect renders the source item in shades of gray. - - \img graphicseffect-grayscale.png -*/ - -/*! - \qmlproperty real Grayscale::strength - - To what extent the source item is "grayed". A strength of 0.0 is equal to no effect, - while 1.0 means full grayscale. By default, the strength is 1.0. -*/ - QML_DECLARE_TYPE(QGraphicsColorizeEffect) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Colorize,QGraphicsColorizeEffect) @@ -128,32 +109,6 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Colorize,QGraphicsColorizeEffect while 1.0 means full colorization. By default, the strength is 1.0. */ -QML_DECLARE_TYPE(QGraphicsPixelizeEffect) -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Pixelize,QGraphicsPixelizeEffect) - -/*! - \qmlclass Pixelize QGraphicsPixelizeEffect - \brief The Pixelize object provides a pixelize effect. - - A pixelize effect renders the source item in lower resolution. The resolution - can be modified using the pixelSize property. - - By default, the pixel size is 3. - - \img graphicseffect-pixelize.png -*/ - -/*! - \qmlproperty int Pixelize::pixelSize - The size of a pixel in the effect. - - Setting the pixel size to 2 means two pixels in the source item will be used to - represent one pixel in the output. Using a bigger size results in lower resolution. - - By default, the pixel size is 3. -*/ - - QML_DECLARE_TYPE(QGraphicsDropShadowEffect) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,DropShadow,QGraphicsDropShadowEffect) @@ -223,55 +178,3 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Opacity,QGraphicsOpacityEffect) By default, the opacity is 0.7. */ -QML_DECLARE_TYPE(QGraphicsBloomEffect) -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Bloom,QGraphicsBloomEffect) - -/*! - \qmlclass Bloom QGraphicsBloomEffect - \brief The Bloom object provides a bloom/glow effect. - - A bloom/glow effect adds fringes of light around bright areas in the source item. - - \img graphicseffect-bloom.png -*/ - -/*! - \qmlproperty real Bloom::blurRadius - The blur radius in pixels of the effect. - - Using a smaller radius results in a sharper appearance, whereas a bigger - radius results in a more blurred appearance. - - By default, the blur radius is 5 pixels. -*/ - -/*! - \qmlproperty enumeration Bloom::blurHint - - Use the Qt.PerformanceHint hint to say that you want a faster blur, - and the Qt.QualityHint hint to say that you prefer a higher quality blur. - - When animating the blur radius it's recommended to use Qt.PerformanceHint. - - By default, the blur hint is Qt.PerformanceHint. -*/ - -/*! - \qmlproperty int Bloom::brightness - This property specifies how bright the glow should appear. - - The value should be in the range of 0 to 255, where 0 is dark - and 255 is bright. - - By default, the brightness is 70. -*/ - -/*! - \qmlproperty real Bloom::strength - The strength of the glow. - - A strength of 0.0 is equal to no effect, while 1.0 means maximum glow. - - By default, the strength is 0.7. -*/ - 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/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index a393cb1..efe047a 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -398,7 +398,7 @@ public: QmlComponent *highlightComponent; FxListItem *highlight; FxListItem *trackedItem; - enum MovementReason { Other, Key, Mouse }; + enum MovementReason { Other, SetIndex, Mouse }; MovementReason moveReason; int buffer; QmlEaseFollow *highlightPosAnimator; @@ -422,6 +422,7 @@ void QmlGraphicsListViewPrivate::init() q->setFlag(QGraphicsItem::ItemIsFocusScope); QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(refill())); QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(refill())); + QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); } void QmlGraphicsListViewPrivate::clear() @@ -1178,8 +1179,8 @@ int QmlGraphicsListView::currentIndex() const void QmlGraphicsListView::setCurrentIndex(int index) { Q_D(QmlGraphicsListView); - d->moveReason = QmlGraphicsListViewPrivate::Other; if (d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) { + d->moveReason = QmlGraphicsListViewPrivate::SetIndex; cancelFlick(); d->updateCurrent(index); } else { @@ -1516,18 +1517,20 @@ void QmlGraphicsListView::viewportMoved() refill(); if (isFlicking() || d->moving) d->moveReason = QmlGraphicsListViewPrivate::Mouse; - if (d->moveReason == QmlGraphicsListViewPrivate::Mouse) { + if (d->moveReason != QmlGraphicsListViewPrivate::SetIndex) { if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { - int idx = d->snapIndex(); - if (idx >= 0 && idx != d->currentIndex) - d->updateCurrent(idx); - - qreal pos = d->currentItem->position(); + // reposition highlight + qreal pos = d->highlight->position(); if (pos > d->position() + d->highlightRangeEnd - 1 - d->highlight->size()) pos = d->position() + d->highlightRangeEnd - 1 - d->highlight->size(); if (pos < d->position() + d->highlightRangeStart) pos = d->position() + d->highlightRangeStart; d->highlight->setPosition(pos); + + // update current index + int idx = d->snapIndex(); + if (idx >= 0 && idx != d->currentIndex) + d->updateCurrent(idx); } } } @@ -1599,7 +1602,6 @@ void QmlGraphicsListView::keyPressEvent(QKeyEvent *event) if ((d->orient == QmlGraphicsListView::Horizontal && event->key() == Qt::Key_Left) || (d->orient == QmlGraphicsListView::Vertical && event->key() == Qt::Key_Up)) { if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) { - d->moveReason = QmlGraphicsListViewPrivate::Key; decrementCurrentIndex(); event->accept(); return; @@ -1610,7 +1612,6 @@ void QmlGraphicsListView::keyPressEvent(QKeyEvent *event) } else if ((d->orient == QmlGraphicsListView::Horizontal && event->key() == Qt::Key_Right) || (d->orient == QmlGraphicsListView::Vertical && event->key() == Qt::Key_Down)) { if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) { - d->moveReason = QmlGraphicsListViewPrivate::Key; incrementCurrentIndex(); event->accept(); return; @@ -1634,6 +1635,7 @@ void QmlGraphicsListView::incrementCurrentIndex() { Q_D(QmlGraphicsListView); if (currentIndex() < d->model->count() - 1 || d->wrap) { + d->moveReason = QmlGraphicsListViewPrivate::SetIndex; int index = currentIndex()+1; cancelFlick(); d->updateCurrent(index < d->model->count() ? index : 0); @@ -1650,6 +1652,7 @@ void QmlGraphicsListView::decrementCurrentIndex() { Q_D(QmlGraphicsListView); if (currentIndex() > 0 || d->wrap) { + d->moveReason = QmlGraphicsListViewPrivate::SetIndex; int index = currentIndex()-1; cancelFlick(); d->updateCurrent(index >= 0 ? index : d->model->count()-1); @@ -2024,6 +2027,12 @@ void QmlGraphicsListView::destroyingItem(QmlGraphicsItem *item) d->unrequestedItems.remove(item); } +void QmlGraphicsListView::animStopped() +{ + Q_D(QmlGraphicsListView); + d->moveReason = QmlGraphicsListViewPrivate::Other; +} + QmlGraphicsListViewAttached *QmlGraphicsListView::qmlAttachedProperties(QObject *obj) { return QmlGraphicsListViewAttached::properties(obj); diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h index 115cad9..446d71a 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicslistview_p.h @@ -174,6 +174,7 @@ private Q_SLOTS: void destroyRemoved(); void createdItem(int index, QmlGraphicsItem *item); void destroyingItem(QmlGraphicsItem *item); + void animStopped(); }; QT_END_NAMESPACE 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/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp index 6790923..d640fc9 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp @@ -534,7 +534,7 @@ void QmlGraphicsTextPrivate::updateSize() void QmlGraphicsTextPrivate::drawOutline() { - QPixmap img = QPixmap(imgCache.size()); + QPixmap img = QPixmap(imgStyleCache.width()+2,imgStyleCache.height()+2); img.fill(Qt::transparent); QPainter ppm(&img); @@ -558,7 +558,7 @@ void QmlGraphicsTextPrivate::drawOutline() void QmlGraphicsTextPrivate::drawOutline(int yOffset) { - QPixmap img = QPixmap(imgCache.size()); + QPixmap img = QPixmap(imgStyleCache.width()+2,imgStyleCache.height()+2); img.fill(Qt::transparent); QPainter ppm(&img); 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/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index 686c0da..80b2458 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -617,6 +617,8 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model) this, SLOT(_q_rowsRemoved(const QModelIndex &,int,int))); QObject::disconnect(d->m_abstractItemModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&))); + QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), + this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); } else if (d->m_visualItemModel) { QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)), this, SIGNAL(itemsInserted(int,int))); @@ -654,6 +656,8 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model) this, SLOT(_q_rowsRemoved(const QModelIndex &,int,int))); QObject::connect(d->m_abstractItemModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&))); + QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), + this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); return; } if ((d->m_visualItemModel = qvariant_cast<QmlGraphicsVisualDataModel *>(model))) { @@ -978,9 +982,10 @@ void QmlGraphicsVisualDataModel::_q_itemsMoved(int from, int to, int count) for (QHash<int,QmlGraphicsVisualDataModelPrivate::ObjectRef>::Iterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ) { + int diff = from > to ? count : -count; if (iter.key() >= qMin(from,to) && iter.key() < qMax(from+count,to+count)) { QmlGraphicsVisualDataModelPrivate::ObjectRef objRef = *iter; - int index = iter.key() + from - to; + int index = iter.key() + diff; iter = d->m_cache.erase(iter); items.insert(index, objRef); @@ -996,20 +1001,35 @@ void QmlGraphicsVisualDataModel::_q_itemsMoved(int from, int to, int count) emit itemsMoved(from, to, count); } -void QmlGraphicsVisualDataModel::_q_rowsInserted(const QModelIndex &, int begin, int end) +void QmlGraphicsVisualDataModel::_q_rowsInserted(const QModelIndex &parent, int begin, int end) { - _q_itemsInserted(begin, end - begin + 1); + if (!parent.isValid()) + _q_itemsInserted(begin, end - begin + 1); } -void QmlGraphicsVisualDataModel::_q_rowsRemoved(const QModelIndex &, int begin, int end) +void QmlGraphicsVisualDataModel::_q_rowsRemoved(const QModelIndex &parent, int begin, int end) { - _q_itemsRemoved(begin, end - begin + 1); + if (!parent.isValid()) + _q_itemsRemoved(begin, end - begin + 1); +} + +void QmlGraphicsVisualDataModel::_q_rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) +{ + const int count = sourceEnd - sourceStart + 1; + if (!destinationParent.isValid() && !sourceParent.isValid()) { + _q_itemsMoved(sourceStart, destinationRow, count); + } else if (!sourceParent.isValid()) { + _q_itemsRemoved(sourceStart, count); + } else if (!destinationParent.isValid()) { + _q_itemsInserted(destinationRow, count); + } } void QmlGraphicsVisualDataModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end) { Q_D(QmlGraphicsVisualDataModel); - _q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles); + if (!begin.parent().isValid()) + _q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles); } void QmlGraphicsVisualDataModel::_q_createdPackage(int index, QmlPackage *package) diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h index 8b0a8f5..3ff2a74 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h @@ -183,6 +183,7 @@ private Q_SLOTS: void _q_itemsMoved(int from, int to, int count); void _q_rowsInserted(const QModelIndex &,int,int); void _q_rowsRemoved(const QModelIndex &,int,int); + void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int); void _q_dataChanged(const QModelIndex&,const QModelIndex&); void _q_createdPackage(int index, QmlPackage *package); void _q_destroyingPackage(QmlPackage *package); diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 3253e72..240f16c 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -814,8 +814,7 @@ void QmlCompiler::genObject(QmlParser::Object *obj) create.create.type = obj->type; if (!output->types.at(create.create.type).type && !obj->bindingBitmask.isEmpty()) { - while (obj->bindingBitmask.size() % 4) - obj->bindingBitmask.append(char(0)); + Q_ASSERT(obj->bindingBitmask.size() % 4 == 0); create.create.bindingBits = output->indexForByteArray(obj->bindingBitmask); } else { @@ -1044,20 +1043,23 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, // Find, check and set the "id" property (if any) Property *idProp = 0; if (obj->properties.count() > 1 || - (obj->properties.count() == 1 && obj->properties.begin().key() != "id") || - !obj->scriptBlockObjects.isEmpty()) - COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid component specification")); + (obj->properties.count() == 1 && obj->properties.begin().key() != "id")) + COMPILE_EXCEPTION(*obj->properties.begin(), qApp->translate("QmlCompiler","Invalid component specification")); + + if (!obj->scriptBlockObjects.isEmpty()) + COMPILE_EXCEPTION(obj->scriptBlockObjects.first(), qApp->translate("QmlCompiler","Invalid component specification")); if (obj->properties.count()) idProp = *obj->properties.begin(); + if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive()))) - COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid component id specification")); + COMPILE_EXCEPTION(idProp, qApp->translate("QmlCompiler","Invalid component id specification")); if (idProp) { QString idVal = idProp->values.first()->primitive(); if (compileState.ids.contains(idVal)) - COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","id is not unique")); + COMPILE_EXCEPTION(idProp, qApp->translate("QmlCompiler","id is not unique")); obj->id = idVal; addId(idVal, obj); @@ -1093,7 +1095,7 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script) Property *source = *script->properties.begin(); if (script->defaultProperty) - COMPILE_EXCEPTION(source, qApp->translate("QmlCompiler","Invalid Script block. Specify either the source property or inline script.")); + COMPILE_EXCEPTION(source, qApp->translate("QmlCompiler","Invalid Script block. Specify either the source property or inline script")); if (source->value || source->values.count() != 1 || source->values.at(0)->object || !source->values.at(0)->value.isString()) @@ -1180,12 +1182,10 @@ bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj, bool QmlCompiler::buildSubObject(Object *obj, const BindingContext &ctxt) { Q_ASSERT(obj->metatype); + Q_ASSERT(!obj->defaultProperty); Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding // sub-context - if (obj->defaultProperty) - COMPILE_CHECK(buildProperty(obj->defaultProperty, obj, ctxt)); - foreach(Property *prop, obj->properties) { if (isSignalPropertyName(prop->name)) { COMPILE_CHECK(buildSignal(prop, obj, ctxt)); @@ -1230,9 +1230,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj, const BindingContext &ctxt) { Q_ASSERT(obj->metaObject()); - - if (prop->isEmpty()) - COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Empty property assignment")); + Q_ASSERT(!prop->isEmpty()); QByteArray name = prop->name; Q_ASSERT(name.startsWith("on")); @@ -1261,6 +1259,10 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj, prop->values.at(0)->type = Value::SignalObject; } else { prop->values.at(0)->type = Value::SignalExpression; + + QString script = prop->values.at(0)->value.asScript().trimmed(); + if (script.isEmpty()) + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Empty signal assignment")); } } @@ -1701,6 +1703,9 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, Q_ASSERT(prop->type != 0); Q_ASSERT(prop->index != -1); + if (prop->values.count()) + COMPILE_EXCEPTION(prop->values.first(), qApp->translate("QmlCompiler", "Invalid value in grouped property")); + if (prop->type < (int)QVariant::UserType) { QmlEnginePrivate *ep = static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine)); diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp index 4615764..fda284a 100644 --- a/src/declarative/qml/qmlcontextscriptclass.cpp +++ b/src/declarative/qml/qmlcontextscriptclass.cpp @@ -219,6 +219,7 @@ QScriptValue QmlContextScriptClass::property(Object *object, const Identifier &n void QmlContextScriptClass::setProperty(Object *object, const Identifier &name, const QScriptValue &value) { + Q_UNUSED(object); Q_ASSERT(lastScopeObject || lastDefaultObject != -1); QmlContext *bindContext = lastContext; diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 29d91bc..f81f2ed 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)); @@ -815,6 +816,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/qml/qmlglobalscriptclass.cpp b/src/declarative/qml/qmlglobalscriptclass.cpp index a9c5d3d..fd270e3 100644 --- a/src/declarative/qml/qmlglobalscriptclass.cpp +++ b/src/declarative/qml/qmlglobalscriptclass.cpp @@ -70,10 +70,10 @@ QmlGlobalScriptClass::queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id) { - Q_UNUSED(object) - Q_UNUSED(name) - Q_UNUSED(flags) - Q_UNUSED(id) + Q_UNUSED(object); + Q_UNUSED(name); + Q_UNUSED(flags); + Q_UNUSED(id); return HandlesReadAccess | HandlesWriteAccess; } @@ -82,9 +82,9 @@ QmlGlobalScriptClass::property(const QScriptValue &object, const QScriptString &name, uint id) { - Q_UNUSED(object) - Q_UNUSED(name) - Q_UNUSED(id) + Q_UNUSED(object); + Q_UNUSED(name); + Q_UNUSED(id); return engine()->undefinedValue(); } @@ -92,8 +92,9 @@ void QmlGlobalScriptClass::setProperty(QScriptValue &object, const QScriptString &name, uint id, const QScriptValue &value) { - Q_UNUSED(object) - Q_UNUSED(value) + Q_UNUSED(object); + Q_UNUSED(id); + Q_UNUSED(value); QString error = QLatin1String("Invalid write to global property \"") + name.toString() + QLatin1String("\""); engine()->currentContext()->throwError(error); diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp index f067db6..a180e49 100644 --- a/src/declarative/qml/qmllistscriptclass.cpp +++ b/src/declarative/qml/qmllistscriptclass.cpp @@ -54,6 +54,7 @@ QmlListScriptClass::QmlListScriptClass(QmlEngine *e) : QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(e)), engine(e) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + Q_UNUSED(scriptEngine); m_lengthId = createPersistentIdentifier(QLatin1String("length")); } @@ -81,6 +82,8 @@ QScriptClass::QueryFlags QmlListScriptClass::queryProperty(Object *object, const Identifier &name, QScriptClass::QueryFlags flags) { + Q_UNUSED(object); + Q_UNUSED(flags); if (name == m_lengthId.identifier) return QScriptClass::HandlesReadAccess; @@ -115,9 +118,11 @@ QScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name) if (data->type == QListPtr) { const QList<QObject *> &qlist = *((QList<QObject *>*)list); - if (name == m_lengthId.identifier) - return qlist.count(); - else if (lastIndex < qlist.count()) + quint32 count = qlist.count(); + + if (name == m_lengthId.identifier) + return count; + else if (lastIndex < count) return enginePriv->objectClass->newQObject(qlist.at(lastIndex)); else return scriptEngine->undefinedValue(); @@ -126,9 +131,9 @@ QScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name) Q_ASSERT(data->type == QmlListPtr); const QmlList<QObject *> &qmllist = *((QmlList<QObject *>*)list); - int count = qmllist.count(); + quint32 count = qmllist.count(); - if (name == m_lengthId.identifier) + if (name == m_lengthId.identifier) return count; else if (lastIndex < count) return enginePriv->objectClass->newQObject(qmllist.at(lastIndex)); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 8385352..4ad9aac 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -111,27 +111,12 @@ void QmlMetaPropertyPrivate::initDefault(QObject *obj) if (!obj) return; - object = obj; QMetaProperty p = QmlMetaType::defaultProperty(obj); core.load(p); - if (core.isValid()) + if (core.isValid()) { isDefaultProperty = true; -} - -/*! - \internal - - Creates a QmlMetaProperty for the property at index \a idx of \a obj. - */ -QmlMetaProperty::QmlMetaProperty(QObject *obj, int idx, QmlContext *ctxt) -: d(new QmlMetaPropertyPrivate) -{ - Q_ASSERT(obj); - - d->q = this; - d->context = ctxt; - d->object = obj; - d->core.load(obj->metaObject()->property(idx)); + object = obj; + } } /*! @@ -142,6 +127,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name) { d->q = this; d->initProperty(obj, name); + if (!isValid()) d->object = 0; } /*! @@ -154,6 +140,7 @@ QmlMetaProperty::QmlMetaProperty(QObject *obj, const QString &name, QmlContext * d->q = this; d->context = ctxt; d->initProperty(obj, name); + if (!isValid()) { d->object = 0; d->context = 0; } } void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name) @@ -425,12 +412,14 @@ bool QmlMetaProperty::isWritable() const { QmlMetaProperty::PropertyCategory category = propertyCategory(); + if (!d->object) + return false; if (category == List || category == QmlList) return true; else if (type() & SignalProperty) - return true; + return false; else if (d->core.isValid() && d->object) - return d->object->metaObject()->property(d->core.coreIndex).isWritable(); + return d->core.flags & QmlPropertyCache::Data::IsWritable; else return false; } @@ -456,25 +445,6 @@ bool QmlMetaProperty::isValid() const } /*! - Returns all of \a obj's Qt properties. -*/ -QStringList QmlMetaProperty::properties(QObject *obj) -{ - // ### What is this used for? - if (!obj) - return QStringList(); - - QStringList rv; - const QMetaObject *mo = obj->metaObject(); - for (int ii = 0; ii < mo->propertyCount(); ++ii) { - QMetaProperty prop = mo->property(ii); - rv << QString::fromUtf8(prop.name()); - } - - return rv; -} - -/*! Return the name of this QML property. */ QString QmlMetaProperty::name() const @@ -494,7 +464,13 @@ QString QmlMetaProperty::name() const return rv; } else { - return d->core.name; + if (type() & SignalProperty) { + QString name = QLatin1String("on") + d->core.name; + name[2] = name.at(2).toUpper(); + return name; + } else { + return d->core.name; + } } } @@ -558,12 +534,17 @@ QmlAbstractBinding *QmlMetaProperty::binding() const Ownership of \a newBinding transfers to QML. Ownership of the return value is assumed by the caller. + + \a flags is passed through to the binding and is used for the initial update (when + the binding sets the intial value, it will use these flags for the write). */ QmlAbstractBinding * QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding, QmlMetaProperty::WriteFlags flags) const { - if (!isProperty() || (type() & Attached) || !d->object) + if (!isProperty() || (type() & Attached) || !d->object) { + delete newBinding; return 0; + } return d->setBinding(d->object, d->core, newBinding, flags); } @@ -627,8 +608,10 @@ QmlExpression *QmlMetaProperty::signalExpression() const */ QmlExpression *QmlMetaProperty::setSignalExpression(QmlExpression *expr) const { - if (!(type() & SignalProperty)) + if (!(type() & SignalProperty)) { + delete expr; return 0; + } const QObjectList &children = d->object->children(); @@ -683,13 +666,7 @@ QVariant QmlMetaProperty::read() const if (type() & SignalProperty) { - const QObjectList &children = object()->children(); - - for (int ii = 0; ii < children.count(); ++ii) { - QmlBoundSignal *sig = QmlBoundSignal::cast(children.at(ii)); - if (sig && sig->index() == d->core.coreIndex) - return sig->expression()->expression(); - } + return QVariant(); } else if (type() & Property) { @@ -854,7 +831,7 @@ bool QmlMetaPropertyPrivate::write(QObject *object, const QmlPropertyCache::Data return false; if (context && u.isRelative() && !u.isEmpty()) - u = context->baseUrl().resolved(u); + u = context->resolvedUrl(u); int status = -1; void *argv[] = { &u, 0, &status, &flags }; QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv); @@ -987,7 +964,7 @@ bool QmlMetaProperty::write(const QVariant &value) const bool QmlMetaProperty::write(const QVariant &value, QmlMetaProperty::WriteFlags flags) const { - if (d->object && type() & Property && d->core.isValid()) + if (d->object && type() & Property && d->core.isValid() && isWritable()) return d->writeValueProperty(value, flags); else return false; @@ -1080,27 +1057,6 @@ Q_GLOBAL_STATIC(QmlValueTypeFactory, qmlValueTypes); Returns the property information serialized into a single integer. QmlMetaProperty uses the bottom 24 bits only. */ -quint32 QmlMetaProperty::save() const -{ - quint32 rv = 0; - if (type() & Attached) { - rv = d->attachedFunc; - } else if (type() != Invalid) { - rv = d->core.coreIndex; - } - - Q_ASSERT(rv <= 0x7FF); - Q_ASSERT(type() <= 0x3F); - Q_ASSERT(d->valueTypeCoreIdx <= 0x7F); - - rv |= (type() << 18); - - if (type() & ValueTypeProperty) - rv |= (d->valueTypeCoreIdx << 11); - - return rv; -} - quint32 QmlMetaPropertyPrivate::saveValueType(int core, int valueType) { Q_ASSERT(core <= 0x7FF); @@ -1127,8 +1083,11 @@ quint32 QmlMetaPropertyPrivate::saveProperty(int core) to QmlMetaProperty::save(). Only the bottom 24-bits are used, the high bits can be set to any value. */ -void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt) +void QmlMetaPropertyPrivate::restore(QmlMetaProperty &prop, quint32 id, + QObject *obj, QmlContext *ctxt) { + QmlMetaPropertyPrivate *d = prop.d; + QmlEnginePrivate *enginePrivate = 0; if (ctxt && ctxt->engine()) enginePrivate = QmlEnginePrivate::get(ctxt->engine()); @@ -1140,9 +1099,9 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt) uint type = id >> 18; id &= 0xFFFF; - if (type & Attached) { + if (type & QmlMetaProperty::Attached) { d->attachedFunc = id; - } else if (type & ValueTypeProperty) { + } else if (type & QmlMetaProperty::ValueTypeProperty) { int coreIdx = id & 0x7FF; int valueTypeIdx = id >> 11; @@ -1156,7 +1115,7 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt) d->core.load(p); d->valueTypeCoreIdx = valueTypeIdx; d->valueTypePropType = p2.userType(); - } else if (type & Property) { + } else if (type & QmlMetaProperty::Property) { QmlPropertyCache *cache = enginePrivate?enginePrivate->cache(obj):0; @@ -1168,12 +1127,12 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt) d->core.load(p); } - } else if (type & SignalProperty) { + } else if (type & QmlMetaProperty::SignalProperty) { QMetaMethod method = obj->metaObject()->method(id); d->core.load(method); } else { - *this = QmlMetaProperty(); + prop = QmlMetaProperty(); } } diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h index ce4ac1e..6db99c6 100644 --- a/src/declarative/qml/qmlmetaproperty.h +++ b/src/declarative/qml/qmlmetaproperty.h @@ -79,10 +79,8 @@ public: QmlMetaProperty(QObject *, const QString &, QmlContext *); QmlMetaProperty(const QmlMetaProperty &); QmlMetaProperty &operator=(const QmlMetaProperty &); - QmlMetaProperty(QObject *, int, QmlContext * = 0); ~QmlMetaProperty(); - static QStringList properties(QObject *); QString name() const; QVariant read() const; @@ -96,9 +94,6 @@ public: bool connectNotifier(QObject *dest, const char *slot) const; bool connectNotifier(QObject *dest, int method) const; - quint32 save() const; - void restore(quint32, QObject *, QmlContext * = 0); - QMetaMethod method() const; enum Type { Invalid = 0x00, @@ -138,6 +133,7 @@ public: int valueTypeCoreIndex() const; private: friend class QmlEnginePrivate; + friend class QmlMetaPropertyPrivate;; QmlMetaPropertyPrivate *d; }; typedef QList<QmlMetaProperty> QmlMetaProperties; diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index 925f1ea..d225afa 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -104,8 +104,9 @@ public: static QmlAbstractBinding *setBinding(QObject *, const QmlPropertyCache::Data &, QmlAbstractBinding *, QmlMetaProperty::WriteFlags flags = QmlMetaProperty::DontRemoveBinding); - static quint32 saveValueType(int, int); - static quint32 saveProperty(int); + static void Q_AUTOTEST_EXPORT restore(QmlMetaProperty &prop, quint32, QObject *, QmlContext * = 0); + static quint32 Q_AUTOTEST_EXPORT saveValueType(int, int); + static quint32 Q_AUTOTEST_EXPORT saveProperty(int); static bool equal(const QMetaObject *, const QMetaObject *); static bool canConvert(const QMetaObject *from, const QMetaObject *to); diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 62ec025..f3d0f65 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -591,7 +591,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, stack.at(stack.count() - 1 - instr.assignBinding.context); QmlMetaProperty mp; - mp.restore(instr.assignBinding.property, target, ctxt); + QmlMetaPropertyPrivate::restore(mp, instr.assignBinding.property, target, ctxt); int coreIndex = mp.coreIndex(); @@ -648,7 +648,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlPropertyValueSource *vs = reinterpret_cast<QmlPropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.assignValueSource.castValue); QObject *target = stack.at(stack.count() - 1 - instr.assignValueSource.owner); QmlMetaProperty prop; - prop.restore(instr.assignValueSource.property, target, ctxt); + QmlMetaPropertyPrivate::restore(prop, instr.assignValueSource.property, target, ctxt); obj->setParent(target); vs->setTarget(prop); } @@ -660,7 +660,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlPropertyValueInterceptor *vi = reinterpret_cast<QmlPropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.assignValueInterceptor.castValue); QObject *target = stack.at(stack.count() - 1 - instr.assignValueInterceptor.owner); QmlMetaProperty prop; - prop.restore(instr.assignValueInterceptor.property, target, ctxt); + QmlMetaPropertyPrivate::restore(prop, instr.assignValueInterceptor.property, target, ctxt); obj->setParent(target); vi->setTarget(prop); QmlVMEMetaObject *mo = static_cast<QmlVMEMetaObject *>((QMetaObject*)target->metaObject()); 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 |