summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-05-18 06:40:15 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-05-18 06:40:15 (GMT)
commit0add74a9339a9d7dda302aa4f31cbb50bdb69908 (patch)
tree9d2c767bee200cb79f81aed24551bcb1989eefb7 /src/declarative
parentc22504ae79b45268d603c2b2bc66bd2a59c331c7 (diff)
parent3769beacd9126b567f6a42e6c357a7eda004a602 (diff)
downloadQt-0add74a9339a9d7dda302aa4f31cbb50bdb69908.zip
Qt-0add74a9339a9d7dda302aa4f31cbb50bdb69908.tar.gz
Qt-0add74a9339a9d7dda302aa4f31cbb50bdb69908.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/fx/qfximage.cpp36
-rw-r--r--src/declarative/fx/qfxrect.cpp52
-rw-r--r--src/declarative/qml/qmlengine.cpp19
-rw-r--r--src/declarative/qml/qmlengine_p.h2
-rw-r--r--src/declarative/qml/qmlexpression.h2
-rw-r--r--src/declarative/qml/qmlvme.cpp2
6 files changed, 75 insertions, 38 deletions
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 9d7a36a..4197a80 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -361,49 +361,57 @@ void QFxImage::paintContents(QPainter &p)
p.drawImage(0, 0, pix);
}
} else {
- const int sgl = d->_scaleGrid->left();
- const int sgr = d->_scaleGrid->right();
- const int sgt = d->_scaleGrid->top();
- const int sgb = d->_scaleGrid->bottom();
- const int xSide = qMin(sgl + sgr, int(width()));
- const int ySide = qMin(sgt + sgb, int(height()));
+ int sgl = d->_scaleGrid->left();
+ int sgr = d->_scaleGrid->right();
+ int sgt = d->_scaleGrid->top();
+ int sgb = d->_scaleGrid->bottom();
+
+ int w = width();
+ int h = height();
+ if (sgt + sgb > h)
+ sgt = sgb = h/2;
+ if (sgl + sgr > w)
+ sgl = sgr = w/2;
+
+ const int xSide = sgl + sgr;
+ const int ySide = sgt + sgb;
// Upper left
if (sgt && sgl)
p.drawImage(QRect(0, 0, sgl, sgt), pix, QRect(0, 0, sgl, sgt));
// Upper middle
if (pix.width() - xSide && sgt)
- p.drawImage(QRect(sgl, 0, width() - xSide, sgt), pix,
+ p.drawImage(QRect(sgl, 0, w - xSide, sgt), pix,
QRect(sgl, 0, pix.width() - xSide, sgt));
// Upper right
if (sgt && pix.width() - sgr)
- p.drawImage(QPoint(width()-sgr, 0), pix,
+ p.drawImage(QPoint(w-sgr, 0), pix,
QRect(pix.width()-sgr, 0, sgr, sgt));
// Middle left
if (sgl && pix.height() - ySide)
- p.drawImage(QRect(0, sgt, sgl, height() - ySide), pix,
+ p.drawImage(QRect(0, sgt, sgl, h - ySide), pix,
QRect(0, sgt, sgl, pix.height() - ySide));
// Middle
if (pix.width() - xSide && pix.height() - ySide)
- p.drawImage(QRect(sgl, sgt, width() - xSide, height() - ySide),
+ p.drawImage(QRect(sgl, sgt, w - xSide, h - ySide),
pix,
QRect(sgl, sgt, pix.width() - xSide, pix.height() - ySide));
// Middle right
if (sgr && pix.height() - ySide)
- p.drawImage(QRect(width()-sgr, sgt, sgr, height() - ySide), pix,
+ p.drawImage(QRect(w-sgr, sgt, sgr, h - ySide), pix,
QRect(pix.width()-sgr, sgt, sgr, pix.height() - ySide));
// Lower left
if (sgl && sgr)
- p.drawImage(QPoint(0, height() - sgb), pix,
+ p.drawImage(QPoint(0, h - sgb), pix,
QRect(0, pix.height() - sgb, sgl, sgb));
// Lower Middle
if (pix.width() - xSide && sgb)
- p.drawImage(QRect(sgl, height() - sgb, width() - xSide, sgb), pix,
+ p.drawImage(QRect(sgl, h - sgb, w - xSide, sgb), pix,
QRect(sgl, pix.height() - sgb, pix.width() - xSide, sgb));
// Lower Right
if (sgr && sgb)
- p.drawImage(QPoint(width()-sgr, height() - sgb), pix,
+ p.drawImage(QPoint(w-sgr, h - sgb), pix,
QRect(pix.width()-sgr, pix.height() - sgb, sgr, sgb));
}
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index dafd8a2..d75a45a 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -486,45 +486,57 @@ void QFxRect::drawRect(QPainter &p)
}
//basically same code as QFxImage uses to paint sci images
- int xSide = qMin(offset * 2, int(width()));
- int ySide = qMin(offset * 2, int(height()));;
+ int w = width();
+ int h = height();
+ int xOffset = offset;
+ int xSide = xOffset * 2;
+ if (xSide > w) {
+ xOffset = w/2;
+ xSide = xOffset * 2;
+ }
+ int yOffset = offset;
+ int ySide = yOffset * 2;
+ if (ySide > h) {
+ yOffset = h/2;
+ ySide = yOffset * 2;
+ }
// Upper left
- p.drawImage(QRect(0, 0, offset, offset), d->_rectImage, QRect(0, 0, offset, offset));
+ p.drawImage(QRect(0, 0, xOffset, yOffset), d->_rectImage, QRect(0, 0, xOffset, yOffset));
// Upper middle
if (d->_rectImage.width() - xSide)
- p.drawImage(QRect(offset, 0, width() - xSide, offset), d->_rectImage,
- QRect(offset, 0, d->_rectImage.width() - xSide, offset));
+ p.drawImage(QRect(xOffset, 0, w - xSide, yOffset), d->_rectImage,
+ QRect(xOffset, 0, d->_rectImage.width() - xSide, yOffset));
// Upper right
- if (d->_rectImage.width() - offset) {
- p.drawImage(QPoint(width()-offset, 0), d->_rectImage,
- QRect(d->_rectImage.width()-offset, 0, offset, offset));
+ if (d->_rectImage.width() - xOffset) {
+ p.drawImage(QPoint(w-xOffset, 0), d->_rectImage,
+ QRect(d->_rectImage.width()-xOffset, 0, xOffset, yOffset));
}
// Middle left
if (d->_rectImage.height() - ySide)
- p.drawImage(QRect(0, offset, offset, height() - ySide), d->_rectImage,
- QRect(0, offset, offset, d->_rectImage.height() - ySide));
+ p.drawImage(QRect(0, yOffset, xOffset, height() - ySide), d->_rectImage,
+ QRect(0, yOffset, xOffset, d->_rectImage.height() - ySide));
// Middle
if (d->_rectImage.width() - xSide && d->_rectImage.height() - ySide)
- p.drawImage(QRect(offset, offset, width() - xSide, height() - ySide), d->_rectImage,
- QRect(offset, offset, d->_rectImage.width() - xSide, d->_rectImage.height() - ySide));
+ p.drawImage(QRect(xOffset, yOffset, w - xSide, height() - ySide), d->_rectImage,
+ QRect(xOffset, yOffset, d->_rectImage.width() - xSide, d->_rectImage.height() - ySide));
// Midlle right
if (d->_rectImage.height() - ySide)
- p.drawImage(QRect(width()-offset, offset, offset, height() - ySide), d->_rectImage,
- QRect(d->_rectImage.width()-offset, offset, offset, d->_rectImage.height() - ySide));
+ p.drawImage(QRect(w-xOffset, yOffset, xOffset, height() - ySide), d->_rectImage,
+ QRect(d->_rectImage.width()-xOffset, yOffset, xOffset, d->_rectImage.height() - ySide));
// Lower left
- p.drawImage(QPoint(0, height() - offset), d->_rectImage, QRect(0, d->_rectImage.height() - offset, offset, offset));
+ p.drawImage(QPoint(0, height() - yOffset), d->_rectImage, QRect(0, d->_rectImage.height() - yOffset, xOffset, yOffset));
// Lower Middle
if (d->_rectImage.width() - xSide)
- p.drawImage(QRect(offset, height() - offset, width() - xSide, offset), d->_rectImage,
- QRect(offset, d->_rectImage.height() - offset, d->_rectImage.width() - xSide, offset));
+ p.drawImage(QRect(xOffset, height() - yOffset, w - xSide, yOffset), d->_rectImage,
+ QRect(xOffset, d->_rectImage.height() - yOffset, d->_rectImage.width() - xSide, yOffset));
// Lower Right
- if (d->_rectImage.width() - offset)
- p.drawImage(QPoint(width()-offset, height() - offset), d->_rectImage,
- QRect(d->_rectImage.width()-offset, d->_rectImage.height() - offset, offset, offset));
+ if (d->_rectImage.width() - xOffset)
+ p.drawImage(QPoint(w-xOffset, height() - yOffset), d->_rectImage,
+ QRect(d->_rectImage.width()-xOffset, d->_rectImage.height() - yOffset, xOffset, yOffset));
}
}
#endif
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index b2d3a9c..0209c1d 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -193,6 +193,7 @@ void QmlEnginePrivate::clear(SimpleList<QmlParserStatus> &pss)
void QmlEnginePrivate::init()
{
+ scriptEngine.installTranslatorFunctions();
contextClass = new QmlContextScriptClass(q);
objectClass = new QmlObjectScriptClass(q);
rootContext = new QmlContext(q);
@@ -781,17 +782,17 @@ QmlEngine *QmlEngine::activeEngine()
QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b)
-: q(b), ctxt(0), sseData(0), proxy(0), me(0), trackChange(false), id(0), log(0)
+: q(b), ctxt(0), sseData(0), proxy(0), me(0), trackChange(false), line(-1), id(0), log(0)
{
}
QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b, void *expr, QmlRefCount *rc)
-: q(b), ctxt(0), sse((const char *)expr, rc), sseData(0), proxy(0), me(0), trackChange(true), id(0), log(0)
+: q(b), ctxt(0), sse((const char *)expr, rc), sseData(0), proxy(0), me(0), trackChange(true), line(-1), id(0), log(0)
{
}
QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b, const QString &expr, bool ssecompile)
-: q(b), ctxt(0), expression(expr), sseData(0), proxy(0), me(0), trackChange(true), id(0), log(0)
+: q(b), ctxt(0), expression(expr), sseData(0), proxy(0), me(0), trackChange(true), line(-1), id(0), log(0)
{
if (ssecompile) {
#ifdef Q_ENABLE_PERFORMANCE_LOG
@@ -996,7 +997,7 @@ QVariant QmlExpression::value()
for (int i = context()->d_func()->scopeChain.size() - 1; i > -1; --i) {
scriptEngine->currentContext()->pushScope(context()->d_func()->scopeChain.at(i));
}
- QScriptValue svalue = scriptEngine->evaluate(expression());
+ QScriptValue svalue = scriptEngine->evaluate(expression(), d->fileName, d->line);
if (scriptEngine->hasUncaughtException()) {
if (scriptEngine->uncaughtException().isError()){
QScriptValue exception = scriptEngine->uncaughtException();
@@ -1151,6 +1152,16 @@ void QmlExpression::setTrackChange(bool trackChange)
}
/*!
+ Set the location of this expression to \a line of \a fileName. This information
+ is used by the script engine.
+*/
+void QmlExpression::setSourceLocation(const QString &fileName, int line)
+{
+ d->fileName = fileName;
+ d->line = line;
+}
+
+/*!
Returns the expression's scope object, if provided, otherwise 0.
In addition to data provided by the expression's QmlContext, the scope
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 7578fdf..7cafb59 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -277,6 +277,8 @@ public:
BindExpressionProxy *proxy;
QObject *me;
bool trackChange;
+ QString fileName;
+ int line;
quint32 id;
diff --git a/src/declarative/qml/qmlexpression.h b/src/declarative/qml/qmlexpression.h
index 2c6b1ad..ea3b093 100644
--- a/src/declarative/qml/qmlexpression.h
+++ b/src/declarative/qml/qmlexpression.h
@@ -78,6 +78,8 @@ public:
bool trackChange() const;
void setTrackChange(bool);
+ void setSourceLocation(const QString &fileName, int line);
+
QObject *scopeObject() const;
quint32 id() const;
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 53ed05a..f4ce891 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -526,6 +526,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
QFx_setParent_noEvent(bind, target);
bind->setTarget(mp);
+ bind->setSourceLocation(comp->url.toString(), instr.line);
}
break;
@@ -551,6 +552,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
QFx_setParent_noEvent(bind, target);
bind->setTarget(mp);
+ bind->setSourceLocation(comp->url.toString(), instr.line);
}
break;