summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp22
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp48
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp17
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h2
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp87
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp1
-rw-r--r--src/declarative/util/qdeclarativefontloader_p.h3
-rw-r--r--src/gui/kernel/qaction_p.h8
-rw-r--r--src/openvg/qpixmapdata_vg.cpp53
-rw-r--r--src/openvg/qpixmapdata_vg_p.h8
15 files changed, 195 insertions, 70 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 7fee44e..a6e8c85 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE
static const int FlickThreshold = 20;
// Really slow flicks can be annoying.
-static const int minimumFlickVelocity = 200;
+static const int MinimumFlickVelocity = 75;
QDeclarativeFlickableVisibleArea::QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent)
: QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.)
@@ -779,23 +779,15 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv
}
vTime = timeline.time();
- if (qAbs(vData.velocity) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) {
- qreal velocity = vData.velocity;
- if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
- velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
- flickY(velocity);
- } else {
+ if (qAbs(vData.velocity) > MinimumFlickVelocity && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold)
+ flickY(vData.velocity);
+ else
fixupY();
- }
- if (qAbs(hData.velocity) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) {
- qreal velocity = hData.velocity;
- if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
- velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
- flickX(velocity);
- } else {
+ if (qAbs(hData.velocity) > MinimumFlickVelocity && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold)
+ flickX(hData.velocity);
+ else
fixupX();
- }
lastPosTime.invalidate();
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 47a410c..1cc5f81 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -331,7 +331,7 @@ qreal QDeclarativeImage::paintedHeight() const
Unlike the \l {Item::}{width} and \l {Item::}{height} properties, which scale
the painting of the image, this property sets the actual number of pixels
stored for the loaded image so that large images do not use more
- memory than necessary. For example, this ensures the image is memory is no
+ memory than necessary. For example, this ensures the image in memory is no
larger than 1024x1024 pixels, regardless of the Image's \l {Item::}{width} and
\l {Item::}{height} values:
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index ba40443..d6b935b 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -147,10 +147,15 @@ void QDeclarativeImageBase::load()
setImplicitWidth(0);
setImplicitHeight(0);
emit statusChanged(d->status);
+ d->sourcesize.setWidth(0);
+ d->sourcesize.setHeight(0);
+ emit sourceSizeChanged();
pixmapChange();
update();
} else {
+
d->status = Loading;
+ emit statusChanged(d->status);
d->pix.load(qmlEngine(this), d->url, d->sourcesize, d->async);
@@ -169,53 +174,34 @@ void QDeclarativeImageBase::load()
d->pix.connectDownloadProgress(this, thisRequestProgress);
} else {
- QSize impsize = d->pix.implicitSize();
- setImplicitWidth(impsize.width());
- setImplicitHeight(impsize.height());
-
- if (d->pix.isReady()) {
- d->status = Ready;
-
- if (!d->sourcesize.isValid())
- emit sourceSizeChanged();
-
- } else {
- d->status = Error;
- qmlInfo(this) << d->pix.error();
- }
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit progressChanged(d->progress);
- pixmapChange();
- update();
+ requestFinished();
}
-
}
-
- emit statusChanged(d->status);
}
void QDeclarativeImageBase::requestFinished()
{
Q_D(QDeclarativeImageBase);
- QSize impsize = d->pix.implicitSize();
-
if (d->pix.isError()) {
d->status = Error;
qmlInfo(this) << d->pix.error();
+ } else {
+ d->status = Ready;
}
+ emit statusChanged(d->status);
- setImplicitWidth(impsize.width());
- setImplicitHeight(impsize.height());
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
- if (d->status == Loading)
- d->status = Ready;
d->progress = 1.0;
- emit statusChanged(d->status);
- emit progressChanged(1.0);
- if (!d->sourcesize.isValid())
+ emit progressChanged(d->progress);
+
+ if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height()) {
+ d->sourcesize.setWidth(d->pix.width());
+ d->sourcesize.setHeight(d->pix.height());
emit sourceSizeChanged();
+ }
pixmapChange();
update();
}
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
index 62e03e7..0c069ce 100644
--- a/src/declarative/graphicsitems/qdeclarativepath.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -893,6 +893,7 @@ void QDeclarativePathPercent::setValue(qreal value)
{
if (_value != value) {
_value = value;
+ emit valueChanged();
emit changed();
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativepath_p.h b/src/declarative/graphicsitems/qdeclarativepath_p.h
index 195057c..21e1b24 100644
--- a/src/declarative/graphicsitems/qdeclarativepath_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepath_p.h
@@ -190,13 +190,16 @@ private:
class Q_AUTOTEST_EXPORT QDeclarativePathPercent : public QDeclarativePathElement
{
Q_OBJECT
- Q_PROPERTY(qreal value READ value WRITE setValue)
+ Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
public:
QDeclarativePathPercent(QObject *parent=0) : QDeclarativePathElement(parent) {}
qreal value() const;
void setValue(qreal value);
+signals:
+ void valueChanged();
+
private:
qreal _value;
};
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index b96b43c..e5ad743 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -1047,10 +1047,10 @@ QPixmap QDeclarativeTextPrivate::richTextImage(bool drawStyle)
QAbstractTextDocumentLayout::PaintContext context;
+ QTextOption oldOption(doc->defaultTextOption());
if (drawStyle) {
context.palette.setColor(QPalette::Text, styleColor);
- // ### Do we really want this?
- QTextOption colorOption;
+ QTextOption colorOption(doc->defaultTextOption());
colorOption.setFlags(QTextOption::SuppressColors);
doc->setDefaultTextOption(colorOption);
} else {
@@ -1058,7 +1058,7 @@ QPixmap QDeclarativeTextPrivate::richTextImage(bool drawStyle)
}
doc->documentLayout()->draw(&p, context);
if (drawStyle)
- doc->setDefaultTextOption(QTextOption());
+ doc->setDefaultTextOption(oldOption);
return img;
}
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 50a0a33..65b14cf 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -966,7 +966,7 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q
Q_ASSERT(p->declarativeData);
QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
if (d->ownContext && d->context)
- d->context->clearExpressions();
+ d->context->clearContext();
if (inPackage) {
emit destroyingPackage(qobject_cast<QDeclarativePackage*>(obj));
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index a58dc6c..a3b16d9 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -533,8 +533,21 @@ void QDeclarativeContextData::invalidate()
parent = 0;
}
-void QDeclarativeContextData::clearExpressions()
+void QDeclarativeContextData::clearContext()
{
+ if (engine) {
+ while (componentAttached) {
+ QDeclarativeComponentAttached *a = componentAttached;
+ componentAttached = a->next;
+ if (componentAttached) componentAttached->prev = &componentAttached;
+
+ a->next = 0;
+ a->prev = 0;
+
+ emit a->destruction();
+ }
+ }
+
QDeclarativeAbstractExpression *expression = expressions;
while (expression) {
QDeclarativeAbstractExpression *nextExpression = expression->m_nextExpression;
@@ -555,7 +568,7 @@ void QDeclarativeContextData::destroy()
if (engine) invalidate();
- clearExpressions();
+ clearContext();
while (contextObjects) {
QDeclarativeData *co = contextObjects;
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index c5a039a..6c14feb 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -113,7 +113,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeContextData
public:
QDeclarativeContextData();
QDeclarativeContextData(QDeclarativeContext *);
- void clearExpressions();
+ void clearContext();
void destroy();
void invalidate();
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index ff1a0e9..d832638 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -965,8 +965,9 @@ public:
QScriptValue send(QScriptValue *me, const QByteArray &);
QScriptValue abort(QScriptValue *me);
- QString responseBody() const;
+ QString responseBody();
const QByteArray & rawResponseBody() const;
+ bool receivedXml() const;
private slots:
void downloadProgress(qint64);
void error(QNetworkReply::NetworkError);
@@ -989,6 +990,15 @@ private:
HeadersList m_headersList;
void fillHeadersList();
+ bool m_gotXml;
+ QByteArray m_mime;
+ QByteArray m_charset;
+ QTextCodec *m_textCodec;
+#ifndef QT_NO_TEXTCODEC
+ QTextCodec* findTextCodec() const;
+#endif
+ void readEncoding();
+
QScriptValue m_me; // Set to the data object while a send() is ongoing (to access the callback)
QScriptValue dispatchCallback(QScriptValue *me);
@@ -1006,7 +1016,7 @@ private:
QDeclarativeXMLHttpRequest::QDeclarativeXMLHttpRequest(QNetworkAccessManager *manager)
: m_state(Unsent), m_errorFlag(false), m_sendFlag(false),
- m_redirectCount(0), m_network(0), m_nam(manager)
+ m_redirectCount(0), m_gotXml(false), m_textCodec(0), m_network(0), m_nam(manager)
{
}
@@ -1277,6 +1287,7 @@ void QDeclarativeXMLHttpRequest::finished()
if (cbv.isError()) printError(cbv);
}
m_responseEntityBody.append(m_network->readAll());
+ readEncoding();
if (xhrDump()) {
qWarning().nospace() << "XMLHttpRequest: RESPONSE " << qPrintable(m_url.toString());
@@ -1302,15 +1313,72 @@ void QDeclarativeXMLHttpRequest::finished()
}
-QString QDeclarativeXMLHttpRequest::responseBody() const
+void QDeclarativeXMLHttpRequest::readEncoding()
+{
+ foreach (const HeaderPair &header, m_headersList) {
+ if (header.first == "content-type") {
+ int separatorIdx = header.second.indexOf(';');
+ if (separatorIdx == -1) {
+ m_mime == header.second;
+ } else {
+ m_mime = header.second.mid(0, separatorIdx);
+ int charsetIdx = header.second.indexOf("charset=");
+ if (charsetIdx != -1) {
+ charsetIdx += 8;
+ separatorIdx = header.second.indexOf(';', charsetIdx);
+ m_charset = header.second.mid(charsetIdx, separatorIdx >= 0 ? separatorIdx : header.second.length());
+ }
+ }
+ break;
+ }
+ }
+
+ if (m_mime.isEmpty() || m_mime == "text/xml" || m_mime == "application/xml" || m_mime.endsWith("+xml"))
+ m_gotXml = true;
+}
+
+bool QDeclarativeXMLHttpRequest::receivedXml() const
+{
+ return m_gotXml;
+}
+
+
+#ifndef QT_NO_TEXTCODEC
+QTextCodec* QDeclarativeXMLHttpRequest::findTextCodec() const
+{
+ QTextCodec *codec = 0;
+
+ if (!m_charset.isEmpty())
+ codec = QTextCodec::codecForName(m_charset);
+
+ if (!codec && m_gotXml) {
+ QXmlStreamReader reader(m_responseEntityBody);
+ reader.readNext();
+ codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8());
+ }
+
+ if (!codec && m_mime == "text/html")
+ codec = QTextCodec::codecForHtml(m_responseEntityBody, 0);
+
+ if (!codec)
+ codec = QTextCodec::codecForUtfText(m_responseEntityBody, 0);
+
+ if (!codec)
+ codec = QTextCodec::codecForName("UTF-8");
+ return codec;
+}
+#endif
+
+
+QString QDeclarativeXMLHttpRequest::responseBody()
{
- QXmlStreamReader reader(m_responseEntityBody);
- reader.readNext();
#ifndef QT_NO_TEXTCODEC
- QTextCodec *codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8());
- if (codec)
- return codec->toUnicode(m_responseEntityBody);
+ if (!m_textCodec)
+ m_textCodec = findTextCodec();
+ if (m_textCodec)
+ return m_textCodec->toUnicode(m_responseEntityBody);
#endif
+
return QString::fromUtf8(m_responseEntityBody);
}
@@ -1571,7 +1639,8 @@ static QScriptValue qmlxmlhttprequest_responseXML(QScriptContext *context, QScri
if (!request)
THROW_REFERENCE("Not an XMLHttpRequest object");
- if (request->readyState() != QDeclarativeXMLHttpRequest::Loading &&
+ if (!request->receivedXml() ||
+ request->readyState() != QDeclarativeXMLHttpRequest::Loading &&
request->readyState() != QDeclarativeXMLHttpRequest::Done)
return engine->nullValue();
else
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index 291583c..1755855 100644
--- a/src/declarative/util/qdeclarativefontloader.cpp
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -130,6 +130,7 @@ void QDeclarativeFontLoader::setSource(const QUrl &url)
d->status = Loading;
emit statusChanged();
+ emit sourceChanged();
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
if (!lf.isEmpty()) {
diff --git a/src/declarative/util/qdeclarativefontloader_p.h b/src/declarative/util/qdeclarativefontloader_p.h
index a5fbb8f..0344d99 100644
--- a/src/declarative/util/qdeclarativefontloader_p.h
+++ b/src/declarative/util/qdeclarativefontloader_p.h
@@ -60,7 +60,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeFontLoader : public QObject
Q_DECLARE_PRIVATE(QDeclarativeFontLoader)
Q_ENUMS(Status)
- Q_PROPERTY(QUrl source READ source WRITE setSource)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
@@ -82,6 +82,7 @@ private Q_SLOTS:
void replyFinished();
Q_SIGNALS:
+ void sourceChanged();
void nameChanged();
void statusChanged();
};
diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h
index 899b01b..5764318 100644
--- a/src/gui/kernel/qaction_p.h
+++ b/src/gui/kernel/qaction_p.h
@@ -112,12 +112,12 @@ public:
//for soft keys management
uint forceEnabledInSoftkeys : 1;
uint menuActionSoftkeys : 1;
-
- QAction::MenuRole menuRole : 3;
- QAction::SoftKeyRole softKeyRole : 2;
- QAction::Priority priority : 14;
int iconVisibleInMenu : 3; // Only has values -1, 0, and 1
+ QAction::MenuRole menuRole;
+ QAction::SoftKeyRole softKeyRole;
+ QAction::Priority priority;
+
QList<QWidget *> widgets;
#ifndef QT_NO_GRAPHICSVIEW
QList<QGraphicsWidget *> graphicsWidgets;
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index cb413d0..e8ec333 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -47,6 +47,9 @@
#endif
#include "qvg_p.h"
#include "qvgimagepool_p.h"
+#include <QBuffer>
+#include <QImageReader>
+#include <QtGui/private/qimage_p.h>
QT_BEGIN_NAMESPACE
@@ -152,11 +155,59 @@ void QVGPixmapData::resize(int wid, int ht)
void QVGPixmapData::fromImage
(const QImage &image, Qt::ImageConversionFlags flags)
{
+ QImage img = image;
+ createPixmapForImage(img, flags, false);
+}
+
+void QVGPixmapData::fromImageReader(QImageReader *imageReader,
+ Qt::ImageConversionFlags flags)
+{
+ QImage image = imageReader->read();
+ if (image.isNull())
+ return;
+
+ createPixmapForImage(image, flags, true);
+}
+
+bool QVGPixmapData::fromFile(const QString &filename, const char *format,
+ Qt::ImageConversionFlags flags)
+{
+ QImage image = QImageReader(filename, format).read();
+ if (image.isNull())
+ return false;
+
+ createPixmapForImage(image, flags, true);
+
+ return !isNull();
+}
+
+bool QVGPixmapData::fromData(const uchar *buffer, uint len, const char *format,
+ Qt::ImageConversionFlags flags)
+{
+ QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer), len);
+ QBuffer b(&a);
+ b.open(QIODevice::ReadOnly);
+ QImage image = QImageReader(&b, format).read();
+ if (image.isNull())
+ return false;
+
+ createPixmapForImage(image, flags, true);
+
+ return !isNull();
+}
+
+void QVGPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace)
+{
if (image.size() == QSize(w, h))
setSerialNumber(++qt_vg_pixmap_serial);
else
resize(image.width(), image.height());
- source = image.convertToFormat(sourceFormat(), flags);
+
+ if (inPlace && image.data_ptr()->convertInPlace(sourceFormat(), flags))
+ source = image;
+ else
+ source = image.convertToFormat(sourceFormat());
+
recreate = true;
}
diff --git a/src/openvg/qpixmapdata_vg_p.h b/src/openvg/qpixmapdata_vg_p.h
index c21b48f..114d545 100644
--- a/src/openvg/qpixmapdata_vg_p.h
+++ b/src/openvg/qpixmapdata_vg_p.h
@@ -64,6 +64,7 @@ QT_BEGIN_NAMESPACE
class QEglContext;
class QVGImagePool;
+class QImageReader;
#if !defined(QT_NO_EGL)
class QVGPixmapData;
@@ -87,6 +88,12 @@ public:
void resize(int width, int height);
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
+ void fromImageReader(QImageReader *imageReader,
+ Qt::ImageConversionFlags flags);
+ bool fromFile(const QString &filename, const char *format,
+ Qt::ImageConversionFlags flags);
+ bool fromData(const uchar *buffer, uint len, const char *format,
+ Qt::ImageConversionFlags flags);
void fill(const QColor &color);
bool hasAlphaChannel() const;
@@ -126,6 +133,7 @@ public:
protected:
int metric(QPaintDevice::PaintDeviceMetric metric) const;
+ void createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace);
#if defined(Q_OS_SYMBIAN)
void cleanup();