summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorA-Team <ateam@pad.test.qt.nokia.com>2010-10-05 22:00:13 (GMT)
committerA-Team <ateam@pad.test.qt.nokia.com>2010-10-05 22:00:13 (GMT)
commitcbd26879cb942a2c4ee7ccd919ee18a45b5b87bb (patch)
treebeb5782a54a102fad2ed78c8231f6ef093ceada9 /src/declarative
parente3bcf44684aa30271c986911b328c9d9c372912a (diff)
parent591807899deb3fc479bd32722756f74b899977d5 (diff)
downloadQt-cbd26879cb942a2c4ee7ccd919ee18a45b5b87bb.zip
Qt-cbd26879cb942a2c4ee7ccd919ee18a45b5b87bb.tar.gz
Qt-cbd26879cb942a2c4ee7ccd919ee18a45b5b87bb.tar.bz2
Merge branch '4.7-upstream' into 4.7-doc
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice.cpp4
-rw-r--r--src/declarative/declarative.pro4
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri7
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp9
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp38
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p_p.h18
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextlayout.cpp358
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextlayout_p.h74
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h3
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp18
-rw-r--r--src/declarative/qml/rewriter/rewriter.cpp102
-rw-r--r--src/declarative/qml/rewriter/rewriter.pri5
-rw-r--r--src/declarative/qml/rewriter/rewriter_p.h153
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp2
16 files changed, 493 insertions, 306 deletions
diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp
index d2ef00d..b98cd5d 100644
--- a/src/declarative/debugger/qdeclarativedebugservice.cpp
+++ b/src/declarative/debugger/qdeclarativedebugservice.cpp
@@ -219,8 +219,8 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
server->waitForConnection();
}
} else {
- qWarning(QString("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
- "Format is -qmljsdebugger=port:<port>[,block]").arg(
+ qWarning(QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "Format is -qmljsdebugger=port:<port>[,block]").arg(
appD->qmljsDebugArguments).toAscii().constData());
}
}
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index 510e7a5..299ca06 100644
--- a/src/declarative/declarative.pro
+++ b/src/declarative/declarative.pro
@@ -26,3 +26,7 @@ include(qml/qml.pri)
include(debugger/debugger.pri)
symbian:TARGET.UID3=0x2001E623
+
+DEFINES += QT_NO_OPENTYPE
+INCLUDEPATH += ../3rdparty/harfbuzz/src
+
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index d420595..ffdeb29 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -49,7 +49,8 @@ HEADERS += \
$$PWD/qdeclarativelistview_p.h \
$$PWD/qdeclarativelayoutitem_p.h \
$$PWD/qdeclarativeitemchangelistener_p.h \
- $$PWD/qdeclarativegraphicswidget_p.h
+ $$PWD/qdeclarativegraphicswidget_p.h \
+ $$PWD/qdeclarativetextlayout_p.h
SOURCES += \
$$PWD/qdeclarativeitemsmodule.cpp \
@@ -81,4 +82,6 @@ SOURCES += \
$$PWD/qdeclarativevisualitemmodel.cpp \
$$PWD/qdeclarativelistview.cpp \
$$PWD/qdeclarativelayoutitem.cpp \
- $$PWD/qdeclarativegraphicswidget.cpp
+ $$PWD/qdeclarativegraphicswidget.cpp \
+ $$PWD/qdeclarativetextlayout.cpp
+
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 8d08c99..8216ab7 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -2591,7 +2591,7 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count)
while (moved.count()) {
int idx = moved.begin().key();
FxGridItem *item = moved.take(idx);
- if (item->item == d->currentItem->item)
+ if (d->currentItem && item->item == d->currentItem->item)
item->setPosition(d->colPosAt(idx), d->rowPosAt(idx));
d->releaseItem(item);
}
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 9cd9ad6..08d237f 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -253,6 +253,15 @@ void QDeclarativeImage::setFillMode(FillMode mode)
emit fillModeChanged();
}
+/*!
+
+ \qmlproperty real Image::paintedWidth
+ \qmlproperty real Image::paintedHeight
+
+ These properties hold the size of the image that is actually painted.
+ In most cases it is the same as \c width and \c height, but when using a \c fillMode like
+ \c PreserveAspectFit \c paintedWidth or \c paintedHeight can be smaller than \c width and \c height.
+*/
qreal QDeclarativeImage::paintedWidth() const
{
Q_D(const QDeclarativeImage);
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index c1e6aaa..6b46bc5 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -3090,7 +3090,7 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count)
while (moved.count()) {
int idx = moved.begin().key();
FxListItem *item = moved.take(idx);
- if (item->item == d->currentItem->item)
+ if (d->currentItem && item->item == d->currentItem->item)
item->setPosition(d->positionAt(idx));
d->releaseItem(item);
}
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 1f4c1c7..65f1564 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -82,6 +82,19 @@ private:
static QSet<QUrl> errors;
};
+DEFINE_BOOL_CONFIG_OPTION(disableImageCache, QML_DISABLE_IMAGE_CACHE);
+
+QDeclarativeTextPrivate::QDeclarativeTextPrivate()
+: color((QRgb)0), style(QDeclarativeText::Normal),
+ hAlign(QDeclarativeText::AlignLeft), vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone),
+ imgDirty(true), dirty(true), richText(false), singleline(false), cache(true), internalWidthUpdate(false), doc(0),
+ format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap)
+{
+ cache = !disableImageCache();
+ QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton;
+ QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents;
+}
+
QTextDocumentWithImageResources::QTextDocumentWithImageResources(QDeclarativeText *parent)
: QTextDocument(parent), outstanding(0)
{
@@ -145,7 +158,6 @@ void QTextDocumentWithImageResources::requestFinished()
void QTextDocumentWithImageResources::setText(const QString &text)
{
if (!m_resources.isEmpty()) {
- qWarning("CLEAR");
qDeleteAll(m_resources);
m_resources.clear();
outstanding = 0;
@@ -792,7 +804,7 @@ void QDeclarativeTextPrivate::updateSize()
//setup instance of QTextLayout for all cases other than richtext
if (!richText) {
- size = setupTextLayout(&layout);
+ size = setupTextLayout();
if (cachedLayoutSize != size) {
q->prepareGeometryChange();
cachedLayoutSize = size;
@@ -907,10 +919,10 @@ void QDeclarativeTextPrivate::drawOutline(int yOffset)
imgCache = img;
}
-QSize QDeclarativeTextPrivate::setupTextLayout(QTextLayout *layout)
+QSize QDeclarativeTextPrivate::setupTextLayout()
{
Q_Q(QDeclarativeText);
- layout->setCacheEnabled(true);
+ layout.setCacheEnabled(true);
int height = 0;
qreal widthUsed = 0;
@@ -920,25 +932,25 @@ QSize QDeclarativeTextPrivate::setupTextLayout(QTextLayout *layout)
if ((wrapMode != QDeclarativeText::NoWrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid())
lineWidth = q->width();
- QTextOption textOption = layout->textOption();
+ QTextOption textOption = layout.textOption();
textOption.setWrapMode(QTextOption::WrapMode(wrapMode));
- layout->setTextOption(textOption);
+ layout.setTextOption(textOption);
- layout->beginLayout();
+ layout.beginLayout();
while (1) {
- QTextLine line = layout->createLine();
+ QTextLine line = layout.createLine();
if (!line.isValid())
break;
if ((wrapMode != QDeclarativeText::NoWrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid())
line.setLineWidth(lineWidth);
}
- layout->endLayout();
+ layout.endLayout();
int x = 0;
- for (int i = 0; i < layout->lineCount(); ++i) {
- QTextLine line = layout->lineAt(i);
+ for (int i = 0; i < layout.lineCount(); ++i) {
+ QTextLine line = layout.lineAt(i);
widthUsed = qMax(widthUsed, line.naturalTextWidth());
line.setPosition(QPointF(0, height));
height += int(line.height());
@@ -1000,7 +1012,7 @@ void QDeclarativeTextPrivate::drawWrappedText(QPainter *p, const QPointF &pos, b
else
p->setPen(color);
p->setFont(font);
- layout.draw(p, pos);
+ layout.draw(p , pos);
}
QPixmap QDeclarativeTextPrivate::richTextImage(bool drawStyle)
@@ -1131,7 +1143,7 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
} else {
qreal y = boundingRect().y();
- bool needClip = !clip() && (d->cachedLayoutSize.width() > width() ||
+ bool needClip = clip() && (d->cachedLayoutSize.width() > width() ||
d->cachedLayoutSize.height() > height());
if (needClip) {
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
index 48552a7..db68558 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
@@ -55,6 +55,7 @@
#include "qdeclarativeitem.h"
#include "private/qdeclarativeitem_p.h"
+#include "private/qdeclarativetextlayout_p.h"
#include <qdeclarative.h>
@@ -69,18 +70,7 @@ class QDeclarativeTextPrivate : public QDeclarativeItemPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeText)
public:
- QDeclarativeTextPrivate()
- : color((QRgb)0), style(QDeclarativeText::Normal),
- hAlign(QDeclarativeText::AlignLeft), vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone),
- imgDirty(true), dirty(true), richText(false), singleline(false), cache(true), internalWidthUpdate(false), doc(0),
- format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap)
- {
-#if defined(QML_NO_TEXT_CACHE)
- cache = false;
-#endif
- QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton;
- QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents;
- }
+ QDeclarativeTextPrivate();
~QDeclarativeTextPrivate();
@@ -101,7 +91,7 @@ public:
QPixmap wrappedTextImage(bool drawStyle);
void drawWrappedText(QPainter *p, const QPointF &pos, bool drawStyle);
QPixmap richTextImage(bool drawStyle);
- QSize setupTextLayout(QTextLayout *layout);
+ QSize setupTextLayout();
QString text;
QFont font;
@@ -121,7 +111,7 @@ public:
bool cache:1;
bool internalWidthUpdate:1;
QTextDocumentWithImageResources *doc;
- QTextLayout layout;
+ QDeclarativeTextLayout layout;
QSize cachedLayoutSize;
QDeclarativeText::TextFormat format;
QDeclarativeText::WrapMode wrapMode;
diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
new file mode 100644
index 0000000..e8b5fb2
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
@@ -0,0 +1,358 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 "qdeclarativetextlayout_p.h"
+#include <private/qstatictext_p.h>
+#include <private/qfontengine_p.h>
+#include <private/qtextengine_p.h>
+#include <private/qpainter_p.h>
+#include <private/qpaintengineex_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeTextLayoutPrivate
+{
+public:
+ QDeclarativeTextLayoutPrivate()
+ : cached(false) {}
+
+ QPointF position;
+
+ bool cached;
+ QVector<QStaticTextItem> items;
+ QVector<QFixedPoint> positions;
+ QVector<glyph_t> glyphs;
+ QVector<QChar> chars;
+};
+
+Q_GUI_EXPORT extern int qt_defaultDpiX();
+Q_GUI_EXPORT extern int qt_defaultDpiY();
+
+namespace {
+class DrawTextItemRecorder: public QPaintEngine
+{
+ public:
+ DrawTextItemRecorder(bool untransformedCoordinates, bool useBackendOptimizations)
+ : m_inertText(0), m_dirtyPen(false), m_useBackendOptimizations(useBackendOptimizations),
+ m_untransformedCoordinates(untransformedCoordinates)
+ {
+ }
+
+ virtual void updateState(const QPaintEngineState &newState)
+ {
+ if (newState.state() & QPaintEngine::DirtyPen)
+ m_dirtyPen = true;
+ }
+
+ virtual void drawTextItem(const QPointF &position, const QTextItem &textItem)
+ {
+ int glyphOffset = m_inertText->glyphs.size(); // Store offset into glyph pool
+ int positionOffset = m_inertText->glyphs.size(); // Offset into position pool
+ int charOffset = m_inertText->chars.size();
+
+ const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
+
+ bool needFreshCurrentItem = true;
+ if (!m_inertText->items.isEmpty()) {
+ QStaticTextItem &last = m_inertText->items[m_inertText->items.count() - 1];
+
+ if (last.fontEngine == ti.fontEngine && last.font == ti.font() &&
+ (!m_dirtyPen || last.color == state->pen().color())) {
+ needFreshCurrentItem = false;
+
+ last.numChars += ti.num_chars;
+ last.numGlyphs += ti.glyphs.numGlyphs;
+
+ }
+ }
+
+ if (needFreshCurrentItem) {
+ QStaticTextItem currentItem;
+
+ currentItem.fontEngine = ti.fontEngine;
+ currentItem.font = ti.font();
+ currentItem.charOffset = charOffset;
+ currentItem.numChars = ti.num_chars;
+ currentItem.numGlyphs = ti.glyphs.numGlyphs;
+ currentItem.glyphOffset = glyphOffset;
+ currentItem.positionOffset = positionOffset;
+ currentItem.useBackendOptimizations = m_useBackendOptimizations;
+ if (m_dirtyPen)
+ currentItem.color = state->pen().color();
+
+ m_inertText->items.append(currentItem);
+ }
+
+ QTransform matrix = m_untransformedCoordinates ? QTransform() : state->transform();
+ matrix.translate(position.x(), position.y());
+
+ QVarLengthArray<glyph_t> glyphs;
+ QVarLengthArray<QFixedPoint> positions;
+ ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
+
+ int size = glyphs.size();
+ Q_ASSERT(size == ti.glyphs.numGlyphs);
+ Q_ASSERT(size == positions.size());
+
+ m_inertText->glyphs.resize(m_inertText->glyphs.size() + size);
+ m_inertText->positions.resize(m_inertText->glyphs.size());
+ m_inertText->chars.resize(m_inertText->chars.size() + ti.num_chars);
+
+ glyph_t *glyphsDestination = m_inertText->glyphs.data() + glyphOffset;
+ qMemCopy(glyphsDestination, glyphs.constData(), sizeof(glyph_t) * ti.glyphs.numGlyphs);
+
+ QFixedPoint *positionsDestination = m_inertText->positions.data() + positionOffset;
+ qMemCopy(positionsDestination, positions.constData(), sizeof(QFixedPoint) * ti.glyphs.numGlyphs);
+
+ QChar *charsDestination = m_inertText->chars.data() + charOffset;
+ qMemCopy(charsDestination, ti.chars, sizeof(QChar) * ti.num_chars);
+
+ }
+
+ virtual void drawPolygon(const QPointF *, int , PolygonDrawMode )
+ {
+ /* intentionally empty */
+ }
+
+ virtual bool begin(QPaintDevice *) { return true; }
+ virtual bool end() { return true; }
+ virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) {}
+ virtual Type type() const
+ {
+ return User;
+ }
+
+ void begin(QDeclarativeTextLayoutPrivate *t) {
+ m_inertText = t;
+ m_dirtyPen = false;
+ }
+
+ private:
+ QDeclarativeTextLayoutPrivate *m_inertText;
+
+ bool m_dirtyPen;
+ bool m_useBackendOptimizations;
+ bool m_untransformedCoordinates;
+};
+
+class DrawTextItemDevice: public QPaintDevice
+{
+ public:
+ DrawTextItemDevice(bool untransformedCoordinates, bool useBackendOptimizations)
+ {
+ m_paintEngine = new DrawTextItemRecorder(untransformedCoordinates,
+ useBackendOptimizations);
+ }
+
+ ~DrawTextItemDevice()
+ {
+ delete m_paintEngine;
+ }
+
+ void begin(QDeclarativeTextLayoutPrivate *t) {
+ m_paintEngine->begin(t);
+ }
+
+ int metric(PaintDeviceMetric m) const
+ {
+ int val;
+ switch (m) {
+ case PdmWidth:
+ case PdmHeight:
+ case PdmWidthMM:
+ case PdmHeightMM:
+ val = 0;
+ break;
+ case PdmDpiX:
+ case PdmPhysicalDpiX:
+ val = qt_defaultDpiX();
+ break;
+ case PdmDpiY:
+ case PdmPhysicalDpiY:
+ val = qt_defaultDpiY();
+ break;
+ case PdmNumColors:
+ val = 16777216;
+ break;
+ case PdmDepth:
+ val = 24;
+ break;
+ default:
+ val = 0;
+ qWarning("DrawTextItemDevice::metric: Invalid metric command");
+ }
+ return val;
+ }
+
+ virtual QPaintEngine *paintEngine() const
+ {
+ return m_paintEngine;
+ }
+
+ private:
+ DrawTextItemRecorder *m_paintEngine;
+};
+
+struct InertTextPainter {
+ InertTextPainter()
+ : device(true, true), painter(&device) {}
+
+ DrawTextItemDevice device;
+ QPainter painter;
+};
+}
+
+Q_GLOBAL_STATIC(InertTextPainter, inertTextPainter);
+
+/*!
+\class QDeclarativeTextLayout
+\brief The QDeclarativeTextLayout class is a version of QStaticText that works with QTextLayouts.
+\internal
+
+This class is basically a copy of the QStaticText code, but it is adapted to source its text from
+QTextLayout.
+
+It is also considerably faster to create a QDeclarativeTextLayout than a QStaticText because it uses
+a single, shared QPainter instance. QStaticText by comparison creates a new QPainter per instance.
+As a consequence this means that QDeclarativeTextLayout is not re-enterant. Adding a lock around
+the shared painter solves this, and only introduces a minor performance penalty, but is unnecessary
+for QDeclarativeTextLayout's current use (QDeclarativeText is already tied to the GUI thread).
+*/
+
+QDeclarativeTextLayout::QDeclarativeTextLayout()
+: d(0)
+{
+}
+
+QDeclarativeTextLayout::QDeclarativeTextLayout(const QString &text)
+: QTextLayout(text), d(0)
+{
+}
+
+QDeclarativeTextLayout::~QDeclarativeTextLayout()
+{
+ if (d) delete d;
+}
+
+void QDeclarativeTextLayout::beginLayout()
+{
+ if (d && d->cached) {
+ d->cached = false;
+ d->items.clear();
+ d->positions.clear();
+ d->glyphs.clear();
+ d->chars.clear();
+ d->position = QPointF();
+ }
+ QTextLayout::beginLayout();
+}
+
+void QDeclarativeTextLayout::prepare()
+{
+ if (!d || !d->cached) {
+
+ if (!d)
+ d = new QDeclarativeTextLayoutPrivate;
+
+ InertTextPainter *itp = inertTextPainter();
+ itp->device.begin(d);
+ QTextLayout::draw(&itp->painter, QPointF(0, 0));
+
+ glyph_t *glyphPool = d->glyphs.data();
+ QFixedPoint *positionPool = d->positions.data();
+ QChar *charPool = d->chars.data();
+
+ int itemCount = d->items.count();
+ for (int ii = 0; ii < itemCount; ++ii) {
+ QStaticTextItem &item = d->items[ii];
+ item.glyphs = glyphPool + item.glyphOffset;
+ item.glyphPositions = positionPool + item.positionOffset;
+ item.chars = charPool + item.charOffset;
+ }
+
+ d->cached = true;
+ }
+}
+
+void QDeclarativeTextLayout::draw(QPainter *painter, const QPointF &p)
+{
+ QPainterPrivate *priv = QPainterPrivate::get(painter);
+
+ bool paintEngineSupportsTransformations = priv->extended &&
+ (priv->extended->type() == QPaintEngine::OpenGL2 ||
+ priv->extended->type() == QPaintEngine::OpenVG ||
+ priv->extended->type() == QPaintEngine::OpenGL);
+
+ if (!paintEngineSupportsTransformations) {
+ QTextLayout::draw(painter, p);
+ return;
+ }
+
+ prepare();
+
+ int itemCount = d->items.count();
+
+ if (p != d->position) {
+ QFixed fx = QFixed::fromReal(p.x());
+ QFixed fy = QFixed::fromReal(p.y());
+ QFixed oldX = QFixed::fromReal(d->position.x());
+ QFixed oldY = QFixed::fromReal(d->position.y());
+ for (int item = 0; item < itemCount; ++item) {
+ QStaticTextItem &textItem = d->items[item];
+
+ for (int ii = 0; ii < textItem.numGlyphs; ++ii) {
+ textItem.glyphPositions[ii].x += fx - oldX;
+ textItem.glyphPositions[ii].y += fy - oldY;
+ }
+ textItem.userDataNeedsUpdate = true;
+ }
+
+ d->position = p;
+ }
+
+ for (int ii = 0; ii < itemCount; ++ii) {
+ QStaticTextItem &item = d->items[ii];
+ priv->extended->drawStaticTextItem(&item);
+ }
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout_p.h b/src/declarative/graphicsitems/qdeclarativetextlayout_p.h
new file mode 100644
index 0000000..90bf0e0
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativetextlayout_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 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 QDECLARATIVETEXTLAYOUT_P_H
+#define QDECLARATIVETEXTLAYOUT_P_H
+
+#include <QtGui/qtextlayout.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeTextLayoutPrivate;
+class QDeclarativeTextLayout : public QTextLayout
+{
+public:
+ QDeclarativeTextLayout();
+ QDeclarativeTextLayout(const QString &);
+ ~QDeclarativeTextLayout();
+
+ void beginLayout();
+
+ void prepare();
+ void draw(QPainter *, const QPointF & = QPointF());
+
+private:
+ QDeclarativeTextLayoutPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVETEXTLAYOUT_P_H
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
index e159786..f09d8dd 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
@@ -67,7 +67,6 @@ class Q_AUTOTEST_EXPORT QDeclarativeVisualModel : public QObject
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
- QDeclarativeVisualModel(QObject *parent=0) : QObject(parent) {}
virtual ~QDeclarativeVisualModel() {}
enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 };
@@ -79,7 +78,7 @@ public:
virtual ReleaseFlags release(QDeclarativeItem *item) = 0;
virtual bool completePending() const = 0;
virtual void completeItem() = 0;
- virtual QString stringValue(int, const QString &) { return QString(); }
+ virtual QString stringValue(int, const QString &) = 0;
virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const = 0;
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 724553f..584c5ec 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -207,7 +207,7 @@ For example:
import QtQuick 1.0
Text {
- color: Qt.rgba(255, 0, 0, 1)
+ color: Qt.rgba(1, 0, 0, 1)
text: Qt.md5("hello, world")
}
\endqml
@@ -284,9 +284,11 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
QUrl QDeclarativeScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url)
{
if (p) {
- QDeclarativeContextData *ctxt = QDeclarativeEnginePrivate::get(this)->getContext(context);
- Q_ASSERT(ctxt);
- return ctxt->resolvedUrl(url);
+ QDeclarativeContextData *ctxt = p->getContext(context);
+ if (ctxt)
+ return ctxt->resolvedUrl(url);
+ else
+ return p->getUrl(context).resolved(url);
}
return baseUrl.resolved(url);
}
@@ -1146,12 +1148,8 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS
QString arg = ctxt->argument(0).toString();
if (arg.isEmpty())
return engine->nullValue();
- QUrl url;
+ QUrl url = QDeclarativeScriptEngine::get(engine)->resolvedUrl(ctxt, QUrl(arg));
QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt);
- if (context)
- url = QUrl(context->resolvedUrl(QUrl(arg)));
- else
- url = activeEnginePriv->getUrl(ctxt).resolved(QUrl(arg));
QDeclarativeComponent *c = new QDeclarativeComponent(activeEngine, url, activeEngine);
QDeclarativeComponentPrivate::get(c)->creationContext = context;
QDeclarativeData::get(c, true)->setImplicitDestructible();
@@ -1635,7 +1633,7 @@ QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QSc
return QScriptValue(e, false);
bool ret = false;
#ifndef QT_NO_DESKTOPSERVICES
- ret = QDesktopServices::openUrl(QUrl(ctxt->argument(0).toString()));
+ ret = QDesktopServices::openUrl(QDeclarativeScriptEngine::get(e)->resolvedUrl(ctxt, QUrl(ctxt->argument(0).toString())));
#endif
return QScriptValue(e, ret);
}
diff --git a/src/declarative/qml/rewriter/rewriter.cpp b/src/declarative/qml/rewriter/rewriter.cpp
deleted file mode 100644
index 6d2ccfb..0000000
--- a/src/declarative/qml/rewriter/rewriter.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 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 "private/rewriter_p.h"
-
-#include <qdeclarativejsast_p.h>
-
-QT_QML_BEGIN_NAMESPACE
-
-using namespace QDeclarativeJS;
-
-void Rewriter::replace(const AST::SourceLocation &loc, const QString &text)
-{ replace(loc.offset, loc.length, text); }
-
-void Rewriter::remove(const AST::SourceLocation &loc)
-{ return replace(loc.offset, loc.length, QString()); }
-
-void Rewriter::remove(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc)
-{ return replace(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, QString()); }
-
-void Rewriter::insertTextBefore(const AST::SourceLocation &loc, const QString &text)
-{ replace(loc.offset, 0, text); }
-
-void Rewriter::insertTextAfter(const AST::SourceLocation &loc, const QString &text)
-{ replace(loc.offset + loc.length, 0, text); }
-
-void Rewriter::replace(int offset, int length, const QString &text)
-{ textWriter.replace(offset, length, text); }
-
-void Rewriter::insertText(int offset, const QString &text)
-{ replace(offset, 0, text); }
-
-void Rewriter::removeText(int offset, int length)
-{ replace(offset, length, QString()); }
-
-QString Rewriter::textAt(const AST::SourceLocation &loc) const
-{ return _code.mid(loc.offset, loc.length); }
-
-QString Rewriter::textAt(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc) const
-{ return _code.mid(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset); }
-
-void Rewriter::accept(QDeclarativeJS::AST::Node *node)
-{ QDeclarativeJS::AST::Node::acceptChild(node, this); }
-
-void Rewriter::moveTextBefore(const AST::SourceLocation &firstLoc,
- const AST::SourceLocation &lastLoc,
- const AST::SourceLocation &loc)
-{
- move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset);
-}
-
-void Rewriter::moveTextAfter(const AST::SourceLocation &firstLoc,
- const AST::SourceLocation &lastLoc,
- const AST::SourceLocation &loc)
-{
- move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset + loc.length);
-}
-
-void Rewriter::move(int pos, int length, int to)
-{
- textWriter.move(pos, length, to);
-}
-
-QT_QML_END_NAMESPACE
diff --git a/src/declarative/qml/rewriter/rewriter.pri b/src/declarative/qml/rewriter/rewriter.pri
index 2c29061..a9fa1b5 100644
--- a/src/declarative/qml/rewriter/rewriter.pri
+++ b/src/declarative/qml/rewriter/rewriter.pri
@@ -2,8 +2,3 @@ INCLUDEPATH += $$PWD
HEADERS += $$PWD/textwriter_p.h
SOURCES += $$PWD/textwriter.cpp
-
-!no_ast_rewriter {
- HEADERS += $$PWD/rewriter_p.h
- SOURCES += $$PWD/rewriter.cpp
-}
diff --git a/src/declarative/qml/rewriter/rewriter_p.h b/src/declarative/qml/rewriter/rewriter_p.h
deleted file mode 100644
index 4799469..0000000
--- a/src/declarative/qml/rewriter/rewriter_p.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 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 REWRITER_H
-#define REWRITER_H
-
-#include "private/textwriter_p.h"
-
-#include <qdeclarativejsastvisitor_p.h>
-
-#include <QtCore/QList>
-#include <QtCore/QString>
-
-QT_BEGIN_HEADER
-QT_QML_BEGIN_NAMESPACE
-
-namespace QDeclarativeJS {
-
-////////////////////////////////////////////////////////////////////////////////
-// Replacement
-////////////////////////////////////////////////////////////////////////////////
-class Replacement
-{
- int _offset;
- int _length;
- QString _text;
-
-public:
- Replacement(int offset = 0, int length = 0, const QString &text = QString())
- : _offset(offset), _length(length), _text(text)
- { }
-
- bool isNull() const { return _offset == _length; }
- operator bool() const { return ! isNull(); }
-
- int offset() const { return _offset; }
- int length() const { return _length; }
- QString text() const { return _text; }
-};
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Rewriter
-////////////////////////////////////////////////////////////////////////////////
-class Rewriter: public AST::Visitor
-{
-protected:
- TextWriter textWriter;
-public:
- //
- // Token based API
- //
-
- /// Returns the text of the token at the given \a location.
- QString textAt(const AST::SourceLocation &location) const;
-
- QString textAt(const AST::SourceLocation &firstLoc,
- const AST::SourceLocation &lastLoc) const;
-
- /// Replace the token at \a loc with the given \a text.
- void replace(const AST::SourceLocation &loc, const QString &text);
-
- /// Remove the token at the given \a location.
- void remove(const AST::SourceLocation &location);
-
- /// Remove all tokens in the range [\a firstLoc, \a lastLoc].
- void remove(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc);
-
- /// Insert \a text before the token at the given \a location.
- void insertTextBefore(const AST::SourceLocation &location, const QString &text);
-
- /// Insert \a text after the token at the given \a location.
- void insertTextAfter(const AST::SourceLocation &loc, const QString &text);
-
- void moveTextBefore(const AST::SourceLocation &firstLoc,
- const AST::SourceLocation &lastLoc,
- const AST::SourceLocation &loc);
-
- void moveTextAfter(const AST::SourceLocation &firstLoc,
- const AST::SourceLocation &lastLoc,
- const AST::SourceLocation &loc);
-
- //
- // low-level offset based API
- //
- virtual void replace(int offset, int length, const QString &text);
- virtual void move(int pos, int length, int to);
- void insertText(int offset, const QString &text);
- void removeText(int offset, int length);
-
- /// Visit the given \a node.
- void accept(AST::Node *node);
-
- /// Returns the original unchanged source code.
- QString code() const { return _code; }
-
- /// Returns the list of replacements.
- QList<Replacement> replacementList() const { return _replacementList; }
-
-protected:
- /// \internal
- void setCode(const QString &code) { _code = code; }
-
-private:
- QString _code;
- QList<Replacement> _replacementList;
-};
-
-} // end of namespace QDeclarativeJS
-
-QT_QML_END_NAMESPACE
-QT_END_HEADER
-
-#endif // REWRITER_H
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 24edc89..ce5b483 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -476,7 +476,7 @@ public:
void QDeclarativeXmlListModelPrivate::append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role)
{
QDeclarativeXmlListModel *_this = qobject_cast<QDeclarativeXmlListModel *>(list->object);
- if (_this) {
+ if (_this && role) {
int i = _this->d_func()->roleObjects.count();
_this->d_func()->roleObjects.append(role);
if (_this->d_func()->roleNames.contains(role->name())) {