aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qdeclarativestyledtext.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-02-07 17:52:52 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-07 11:53:54 +0100
commit978550b6c75b204fad433437d153794ae98eea9f (patch)
treee5ead42f67eacea929a8f2bfa3340a183c1f1015 /src/quick/util/qdeclarativestyledtext.cpp
parenta6eb09137247a880c58995464a35c1ad5c3f0c20 (diff)
Resolve StyledText img tags relative to baseUrl.
Change-Id: I954195d52330c65e851b7c0fcdb6c8dabf29335d Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
Diffstat (limited to 'src/quick/util/qdeclarativestyledtext.cpp')
-rw-r--r--src/quick/util/qdeclarativestyledtext.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/quick/util/qdeclarativestyledtext.cpp b/src/quick/util/qdeclarativestyledtext.cpp
index 39ea6b1a22..3023fc53dc 100644
--- a/src/quick/util/qdeclarativestyledtext.cpp
+++ b/src/quick/util/qdeclarativestyledtext.cpp
@@ -83,9 +83,10 @@ public:
QDeclarativeStyledTextPrivate(const QString &t, QTextLayout &l,
QList<QDeclarativeStyledTextImgTag*> &imgTags,
+ const QUrl &baseUrl,
QDeclarativeContext *context,
bool preloadImages)
- : text(t), layout(l), imgTags(&imgTags), baseFont(layout.font()), hasNewLine(false), nbImages(0), updateImagePositions(false)
+ : text(t), layout(l), imgTags(&imgTags), baseFont(layout.font()), baseUrl(baseUrl), hasNewLine(false), nbImages(0), updateImagePositions(false)
, preFormat(false), prependSpace(false), hasSpace(true), preloadImages(preloadImages), context(context)
{
}
@@ -117,6 +118,7 @@ public:
QList<QDeclarativeStyledTextImgTag*> *imgTags;
QFont baseFont;
QStack<List> listStack;
+ QUrl baseUrl;
bool hasNewLine;
int nbImages;
bool updateImagePositions;
@@ -155,9 +157,11 @@ const QChar QDeclarativeStyledTextPrivate::lineFeed(QLatin1Char('\n'));
const QChar QDeclarativeStyledTextPrivate::space(QLatin1Char(' '));
QDeclarativeStyledText::QDeclarativeStyledText(const QString &string, QTextLayout &layout,
- QList<QDeclarativeStyledTextImgTag*> &imgTags, QDeclarativeContext *context,
+ QList<QDeclarativeStyledTextImgTag*> &imgTags,
+ const QUrl &baseUrl,
+ QDeclarativeContext *context,
bool preloadImages)
- : d(new QDeclarativeStyledTextPrivate(string, layout, imgTags, context, preloadImages))
+ : d(new QDeclarativeStyledTextPrivate(string, layout, imgTags, baseUrl, context, preloadImages))
{
}
@@ -167,12 +171,14 @@ QDeclarativeStyledText::~QDeclarativeStyledText()
}
void QDeclarativeStyledText::parse(const QString &string, QTextLayout &layout,
- QList<QDeclarativeStyledTextImgTag*> &imgTags, QDeclarativeContext *context,
+ QList<QDeclarativeStyledTextImgTag*> &imgTags,
+ const QUrl &baseUrl,
+ QDeclarativeContext *context,
bool preloadImages)
{
if (string.isEmpty())
return;
- QDeclarativeStyledText styledText(string, layout, imgTags, context, preloadImages);
+ QDeclarativeStyledText styledText(string, layout, imgTags, baseUrl, context, preloadImages);
styledText.d->parse();
}
@@ -657,7 +663,7 @@ void QDeclarativeStyledTextPrivate::parseImageAttributes(const QChar *&ch, const
// if we don't know its size but the image is a local image,
// we load it in the pixmap cache and save its implicit size
// to avoid a relayout later on.
- QUrl url = context->resolvedUrl(image->url);
+ QUrl url = baseUrl.resolved(image->url);
if (url.isLocalFile()) {
QDeclarativePixmap *pix = new QDeclarativePixmap(context->engine(), url, image->size);
if (pix && pix->isReady()) {