summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-09-02 05:53:25 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-09-02 05:53:25 (GMT)
commit5531b8cc935b70771bcf62472d92ff4b3887e3bd (patch)
treecb1a0831054ef3c606adc5ff569f9673e85d7a98
parent9317724be9d588ba8616e3cbf6300f9c32a64ede (diff)
parentb6e26ee808ae3ffe1c4fba03cc89baf47d65d3a8 (diff)
downloadQt-5531b8cc935b70771bcf62472d92ff4b3887e3bd.zip
Qt-5531b8cc935b70771bcf62472d92ff4b3887e3bd.tar.gz
Qt-5531b8cc935b70771bcf62472d92ff4b3887e3bd.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui-scriptopt
Conflicts: demos/declarative/samegame/content/samegame.js
-rw-r--r--demos/declarative/samegame/SameGame.qml13
-rw-r--r--demos/declarative/samegame/content/Dialog.qml18
-rwxr-xr-xdemos/declarative/samegame/content/samegame.js34
-rw-r--r--demos/declarative/samegame/highscores/README1
-rwxr-xr-xdemos/declarative/samegame/highscores/score_data.xml2
-rwxr-xr-xdemos/declarative/samegame/highscores/score_style.xsl27
-rwxr-xr-xdemos/declarative/samegame/highscores/scores.php34
-rw-r--r--src/declarative/fx/qfxitem.cpp2
-rw-r--r--src/declarative/fx/qfxrect.cpp61
-rw-r--r--src/declarative/fx/qfxrect.h4
-rw-r--r--src/declarative/fx/qfxrect_p.h1
-rw-r--r--src/declarative/qml/qmldeclarativedata_p.h5
-rw-r--r--src/declarative/qml/qmlengine.cpp112
-rw-r--r--src/declarative/qml/qmlengine_p.h4
-rw-r--r--src/declarative/qml/qmlenginedebug.cpp11
-rw-r--r--src/declarative/qml/qmlinfo.cpp16
-rw-r--r--src/declarative/qml/qmlinstruction_p.h1
-rw-r--r--src/declarative/qml/qmlvme.cpp5
18 files changed, 271 insertions, 80 deletions
diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml
index 0da5679..877c1cc 100644
--- a/demos/declarative/samegame/SameGame.qml
+++ b/demos/declarative/samegame/SameGame.qml
@@ -34,6 +34,19 @@ Rectangle {
}
Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
+ Dialog {
+ id: scoreName; anchors.centerIn: parent; z: 22;
+ TextInput {
+ id: Editor
+ onAccepted: {
+ if(scoreName.opacity==1&&Editor.text!="")
+ sendHighScore(Editor.text);
+ scoreName.forceClose();
+ }
+ anchors.verticalCenter: parent.verticalCenter
+ x:160; width: 200; height:20; focus: true
+ }
+ }
Rectangle {
id: ToolBar
diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml
index 72c7900..401d211 100644
--- a/demos/declarative/samegame/content/Dialog.qml
+++ b/demos/declarative/samegame/content/Dialog.qml
@@ -2,14 +2,20 @@ import Qt 4.6
Rectangle {
id: page
+ function forceClose() {
+ page.closed();
+ page.opacity = 0;
+ }
+ function show(txt) {
+ MyText.text = txt;
+ page.opacity = 1;
+ }
+ signal closed();
color: "white"; border.width: 1; width: MyText.width + 20; height: 60;
- property string text: "Hello World!"
opacity: 0
opacity: Behavior {
- SequentialAnimation {
- NumberAnimation {property: "opacity"; from: 0; duration: 1500 }
- NumberAnimation {property: "opacity"; to: 0; duration: 1500 }
- }
+ NumberAnimation { duration: 1000 }
}
- Text { id: MyText; anchors.centerIn: parent; text: parent.text }
+ Text { id: MyText; anchors.centerIn: parent; text: "Hello World!" }
+ MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); }
}
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index 91a436f..9914edb 100755
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -6,16 +6,24 @@ var tileSize = 40;
var maxIndex = maxX*maxY;
var board = new Array(maxIndex);
var tileSrc = "content/BoomBlock.qml";
+var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php";
+var timer;
var component;
//Index function used instead of a 2D array
-function index(xIdx,yIdx){
+function index(xIdx,yIdx) {
return xIdx + (yIdx * maxX);
}
+function timeStr(msecs) {
+ var secs = Math.floor(msecs/1000);
+ var m = Math.floor(secs/60);
+ var ret = "" + m + "m " + (secs%60) + "s";
+ return ret;
+}
+
function initBoard()
{
- var a = new Date;
for(i = 0; i<maxIndex; i++){
//Delete old blocks
if(board[i] != null)
@@ -35,8 +43,7 @@ function initBoard()
startCreatingBlock(xIdx,yIdx);
}
}
- var e = new Date;
- print (e.valueOf() - a.valueOf());
+ timer = new Date();
}
var fillFound;//Set after a floodFill call to the number of tiles found
@@ -137,8 +144,10 @@ function victoryCheck()
gameCanvas.score += 500;
//Checks for game over
if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){
- dialog.text = "Game Over. Your score is " + gameCanvas.score;
- dialog.opacity = 1;
+ dialog.show("Game Over. Your score is " + gameCanvas.score);
+ timer = new Date() - timer;
+ if(scoresURL != "")
+ scoreName.show("Please enter your name: ");
}
}
@@ -212,3 +221,16 @@ function startCreatingBlock(xIdx,yIdx){
component.statusChanged.connect(finishCreatingBlock());
return;
}
+
+function sendHighScore(name) {
+ var postman = new XMLHttpRequest()
+ var postData = "name="+name+"&score="+gameCanvas.score
+ +"&gridSize="+maxX+"x"+maxY +"&time="+Math.floor(timer/1000);
+ postman.open("POST", scoresURL, true);
+ postman.onreadystatechange = function() {
+ if (postman.readyState == postman.DONE) {
+ dialog.show("Your score has been uploaded.");
+ }
+ }
+ postman.send(postData);
+}
diff --git a/demos/declarative/samegame/highscores/README b/demos/declarative/samegame/highscores/README
new file mode 100644
index 0000000..eaa00fa
--- /dev/null
+++ b/demos/declarative/samegame/highscores/README
@@ -0,0 +1 @@
+The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it.
diff --git a/demos/declarative/samegame/highscores/score_data.xml b/demos/declarative/samegame/highscores/score_data.xml
new file mode 100755
index 0000000..c3fd90d
--- /dev/null
+++ b/demos/declarative/samegame/highscores/score_data.xml
@@ -0,0 +1,2 @@
+<record><score>1000000</score><name>Alan the Tester</name><gridSize>0x0</gridSize><seconds>0</seconds></record>
+<record><score>6213</score><name>Alan</name><gridSize>12x17</gridSize><seconds>51</seconds></record>
diff --git a/demos/declarative/samegame/highscores/score_style.xsl b/demos/declarative/samegame/highscores/score_style.xsl
new file mode 100755
index 0000000..7dcf07e
--- /dev/null
+++ b/demos/declarative/samegame/highscores/score_style.xsl
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+ <html>
+ <head><title>SameGame High Scores</title></head>
+ <body>
+ <h2>SameGame High Scores</h2>
+ <table border="1">
+ <tr bgcolor="lightsteelblue">
+ <th>Name</th>
+ <th>Score</th>
+ <th>Grid Size</th>
+ <th>Time, s</th>
+ </tr>
+ <xsl:for-each select="records/record">
+ <tr>
+ <td><xsl:value-of select="name"/></td>
+ <td><xsl:value-of select="score"/></td>
+ <td><xsl:value-of select="gridSize"/></td>
+ <td><xsl:value-of select="seconds"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/demos/declarative/samegame/highscores/scores.php b/demos/declarative/samegame/highscores/scores.php
new file mode 100755
index 0000000..3cceb2d
--- /dev/null
+++ b/demos/declarative/samegame/highscores/scores.php
@@ -0,0 +1,34 @@
+<?php
+ $score = $_POST["score"];
+ echo "<html>";
+ echo "<head><title>SameGame High Scores</title></head><body>";
+ if($score > 0){#Sending in a new high score
+ $name = $_POST["name"];
+ $grid = $_POST["gridSize"];
+ $time = $_POST["time"];
+ if($name == "")
+ $name = "Anonymous";
+ //if($grid != "10x10"){
+ //Need a standard, so as to reject others?
+ //}
+ $file = fopen("score_data.xml", "a"); #It's XML. Happy?
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
+ . $time . "</seconds></record>\n");
+ echo "Your score has been recorded. Thanks for playing!";
+ if($ret == False)
+ echo "<br/> There was an error though, so don't expect to see that score again.";
+ }else{#Read high score list
+ #Now uses XSLT to display. So just print the file. With XML cruft added.
+ #Note that firefox at least won't apply the XSLT on a php file. So redirecting
+ $file = fopen("scores.xml", "w");
+ $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
+ . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
+ . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
+ if($ret == False)
+ echo "There was an internal error. Sorry.";
+ else
+ echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
+ }
+ echo "</body></html>";
+?>
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index c436622..d28f531 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -928,7 +928,7 @@ private:
virtual void keyPressed(QKeyEvent *event);
virtual void keyReleased(QKeyEvent *event);
- const char *keyToSignal(int key) {
+ const QByteArray keyToSignal(int key) {
QByteArray keySignal;
if (key >= Qt::Key_0 && key <= Qt::Key_9) {
keySignal = "digit0Pressed";
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index f8223f2..fbd7ee8 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -328,63 +328,6 @@ void QFxRect::setColor(const QColor &c)
update();
}
-/*!
- \qmlproperty color Rectangle::tintColor
- This property holds The color to tint the rectangle.
-
- This color will be drawn over the rectangle's color when the rectangle is painted. The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red tint by having the tint color be pure red which is only 1/16th opaque.
-
- \qml
- Rectangle { x: 0; width: 80; height: 80; color: "lightsteelblue" }
- Rectangle { x: 100; width: 80; height: 80; color: "lightsteelblue"; tintColor: "#10FF0000" }
- \endqml
- \image declarative-rect_tint.png
-
- This attribute is not intended to be used with a single color over the lifetime of an user interface. It is most useful when a subtle change is intended to be conveyed due to some event; you can then use the tint color to more effectively tune the visible color.
-*/
-QColor QFxRect::tintColor() const
-{
- Q_D(const QFxRect);
- return d->tintColor;
-}
-
-void QFxRect::setTintColor(const QColor &c)
-{
- Q_D(QFxRect);
- if (d->tintColor == c)
- return;
-
- d->tintColor = c;
- update();
-}
-
-QColor QFxRectPrivate::getColor()
-{
- if (tintColor.isValid()) {
- int a = tintColor.alpha();
- if (a == 0xFF)
- return tintColor;
- else if (a == 0x00)
- return color;
- else {
- uint src = tintColor.rgba();
- uint dest = color.rgba();
-
- uint res = (((a * (src & 0xFF00FF)) +
- ((0xFF - a) * (dest & 0xFF00FF))) >> 8) & 0xFF00FF;
- res |= (((a * ((src >> 8) & 0xFF00FF)) +
- ((0xFF - a) * ((dest >> 8) & 0xFF00FF)))) & 0xFF00FF00;
- if ((src & 0xFF000000) == 0xFF000000)
- res |= 0xFF000000;
-
- return QColor::fromRgba(res);
- }
- } else {
- return color;
- }
-}
-
-
void QFxRect::generateRoundedRect()
{
Q_D(QFxRect);
@@ -443,7 +386,7 @@ void QFxRect::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
bool oldAA = p->testRenderHint(QPainter::Antialiasing);
if (d->smooth)
p->setRenderHints(QPainter::Antialiasing, true);
- p->fillRect(QRectF(0, 0, width(), height()), d->getColor());
+ p->fillRect(QRectF(0, 0, width(), height()), d->color);
if (d->smooth)
p->setRenderHint(QPainter::Antialiasing, oldAA);
}
@@ -527,7 +470,7 @@ void QFxRect::drawRect(QPainter &p)
// Middle
if (xMiddles && yMiddles)
// XXX paint errors in animation example
- //p.fillRect(xOffset-pw/2, yOffset-pw/2, width() - xSide + pw, height() - ySide + pw, d->getColor());
+ //p.fillRect(xOffset-pw/2, yOffset-pw/2, width() - xSide + pw, height() - ySide + pw, d->color);
p.drawPixmap(QRect(xOffset-pw/2, yOffset-pw/2, width() - xSide + pw, height() - ySide + pw), d->rectImage,
QRect(d->rectImage.width()/2, d->rectImage.height()/2, 1, 1));
// Middle right
diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h
index 359e8fc..439cc65 100644
--- a/src/declarative/fx/qfxrect.h
+++ b/src/declarative/fx/qfxrect.h
@@ -136,7 +136,6 @@ class Q_DECLARATIVE_EXPORT QFxRect : public QFxItem
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor)
- Q_PROPERTY(QColor tintColor READ tintColor WRITE setTintColor)
Q_PROPERTY(QFxGradient *gradient READ gradient WRITE setGradient)
Q_PROPERTY(QFxPen * border READ border)
Q_PROPERTY(qreal radius READ radius WRITE setRadius)
@@ -146,9 +145,6 @@ public:
QColor color() const;
void setColor(const QColor &);
- QColor tintColor() const;
- void setTintColor(const QColor &);
-
QFxPen *border();
QFxGradient *gradient() const;
diff --git a/src/declarative/fx/qfxrect_p.h b/src/declarative/fx/qfxrect_p.h
index 25fa38d..8eb074a 100644
--- a/src/declarative/fx/qfxrect_p.h
+++ b/src/declarative/fx/qfxrect_p.h
@@ -81,7 +81,6 @@ public:
QColor getColor();
QColor color;
QFxGradient *gradient;
- QColor tintColor;
QFxPen *getPen() {
if (!pen) {
Q_Q(QFxRect);
diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h
index 5a51eb7..a316c0c 100644
--- a/src/declarative/qml/qmldeclarativedata_p.h
+++ b/src/declarative/qml/qmldeclarativedata_p.h
@@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE
class QmlCompiledData;
class QmlAbstractBinding;
+class QmlContext;
class QmlDeclarativeData : public QDeclarativeData
{
public:
@@ -69,6 +70,10 @@ public:
QmlContext *context;
QmlAbstractBinding *bindings;
+ QmlContext *outerContext; // Can't this be found from context?
+ ushort lineNumber;
+ ushort columnNumber;
+
QmlCompiledData *deferredComponent; // Can't this be found from the context?
unsigned int deferredIdx;
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 124c8f3..0d6e281 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -80,6 +80,7 @@
#include <private/qmlbinding_p.h>
#include <private/qmlvme_p.h>
#include <private/qmlenginedebug_p.h>
+#include <private/qmlstringconverters_p.h>
#include <private/qmlxmlhttprequest_p.h>
Q_DECLARE_METATYPE(QmlMetaProperty)
@@ -121,12 +122,18 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
qt_add_qmlxmlhttprequest(&scriptEngine);
+ //types
qtObject.setProperty(QLatin1String("rgba"), scriptEngine.newFunction(QmlEnginePrivate::rgba, 4));
qtObject.setProperty(QLatin1String("hsla"), scriptEngine.newFunction(QmlEnginePrivate::hsla, 4));
qtObject.setProperty(QLatin1String("rect"), scriptEngine.newFunction(QmlEnginePrivate::rect, 4));
qtObject.setProperty(QLatin1String("point"), scriptEngine.newFunction(QmlEnginePrivate::point, 2));
qtObject.setProperty(QLatin1String("size"), scriptEngine.newFunction(QmlEnginePrivate::size, 2));
qtObject.setProperty(QLatin1String("vector3d"), scriptEngine.newFunction(QmlEnginePrivate::vector, 3));
+
+ //color helpers
+ qtObject.setProperty(QLatin1String("lighter"), scriptEngine.newFunction(QmlEnginePrivate::lighter, 1));
+ qtObject.setProperty(QLatin1String("darker"), scriptEngine.newFunction(QmlEnginePrivate::darker, 1));
+ qtObject.setProperty(QLatin1String("tint"), scriptEngine.newFunction(QmlEnginePrivate::tint, 2));
}
QmlEnginePrivate::~QmlEnginePrivate()
@@ -889,6 +896,111 @@ QScriptValue QmlEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine)
return qScriptValueFromValue(engine, qVariantFromValue(QSizeF(w, h)));
}
+QScriptValue QmlEnginePrivate::lighter(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() < 1)
+ return engine->nullValue();
+ QVariant v = ctxt->argument(0).toVariant();
+ QColor color;
+ if (v.type() == QVariant::Color)
+ color = v.value<QColor>();
+ else if (v.type() == QVariant::String) {
+ bool ok;
+ color = QmlStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok)
+ return engine->nullValue();
+ } else
+ return engine->nullValue();
+ color = color.lighter();
+ return qScriptValueFromValue(engine, qVariantFromValue(color));
+}
+
+QScriptValue QmlEnginePrivate::darker(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() < 1)
+ return engine->nullValue();
+ QVariant v = ctxt->argument(0).toVariant();
+ QColor color;
+ if (v.type() == QVariant::Color)
+ color = v.value<QColor>();
+ else if (v.type() == QVariant::String) {
+ bool ok;
+ color = QmlStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok)
+ return engine->nullValue();
+ } else
+ return engine->nullValue();
+ color = color.darker();
+ return qScriptValueFromValue(engine, qVariantFromValue(color));
+}
+
+/*!
+ This function allows tinting one color with another.
+
+ The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red tint by having the tint color be pure red which is only 1/16th opaque.
+
+ \qml
+ Rectangle { x: 0; width: 80; height: 80; color: "lightsteelblue" }
+ Rectangle { x: 100; width: 80; height: 80; color: Qt.tint("lightsteelblue", "#10FF0000") }
+ \endqml
+ \image declarative-rect_tint.png
+
+ Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color.
+*/
+QScriptValue QmlEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() < 2)
+ return engine->nullValue();
+ //get color
+ QVariant v = ctxt->argument(0).toVariant();
+ QColor color;
+ if (v.type() == QVariant::Color)
+ color = v.value<QColor>();
+ else if (v.type() == QVariant::String) {
+ bool ok;
+ color = QmlStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok)
+ return engine->nullValue();
+ } else
+ return engine->nullValue();
+
+ //get tint color
+ v = ctxt->argument(1).toVariant();
+ QColor tintColor;
+ if (v.type() == QVariant::Color)
+ tintColor = v.value<QColor>();
+ else if (v.type() == QVariant::String) {
+ bool ok;
+ tintColor = QmlStringConverters::colorFromString(v.toString(), &ok);
+ if (!ok)
+ return engine->nullValue();
+ } else
+ return engine->nullValue();
+
+ //tint
+ QColor finalColor;
+ int a = tintColor.alpha();
+ if (a == 0xFF)
+ finalColor = tintColor;
+ else if (a == 0x00)
+ finalColor = color;
+ else {
+ uint src = tintColor.rgba();
+ uint dest = color.rgba();
+
+ uint res = (((a * (src & 0xFF00FF)) +
+ ((0xFF - a) * (dest & 0xFF00FF))) >> 8) & 0xFF00FF;
+ res |= (((a * ((src >> 8) & 0xFF00FF)) +
+ ((0xFF - a) * ((dest >> 8) & 0xFF00FF)))) & 0xFF00FF00;
+ if ((src & 0xFF000000) == 0xFF000000)
+ res |= 0xFF000000;
+
+ finalColor = QColor::fromRgba(res);
+ }
+
+ return qScriptValueFromValue(engine, qVariantFromValue(finalColor));
+}
+
QmlScriptClass::QmlScriptClass(QmlEngine *bindengine)
: QScriptClass(QmlEnginePrivate::getScriptEngine(bindengine)),
engine(bindengine)
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 2c7409b..451276d 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -240,6 +240,10 @@ public:
static QScriptValue size(QScriptContext*, QScriptEngine*);
static QScriptValue rect(QScriptContext*, QScriptEngine*);
+ static QScriptValue lighter(QScriptContext*, QScriptEngine*);
+ static QScriptValue darker(QScriptContext*, QScriptEngine*);
+ static QScriptValue tint(QScriptContext*, QScriptEngine*);
+
static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; }
static QmlEngine *getEngine(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p->q_func(); }
static QmlEnginePrivate *get(QmlEngine *e) { return e->d_func(); }
diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp
index 0e78cad..321fe74 100644
--- a/src/declarative/qml/qmlenginedebug.cpp
+++ b/src/declarative/qml/qmlenginedebug.cpp
@@ -181,9 +181,16 @@ void QmlEngineDebugServer::buildObjectList(QDataStream &message,
QmlEngineDebugServer::QmlObjectData
QmlEngineDebugServer::objectData(QObject *object)
{
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(object);
QmlObjectData rv;
- rv.lineNumber = -1;
- rv.columnNumber = -1;
+ if (ddata) {
+ rv.url = ddata->outerContext->baseUrl();
+ rv.lineNumber = ddata->lineNumber;
+ rv.columnNumber = ddata->columnNumber;
+ } else {
+ rv.lineNumber = -1;
+ rv.columnNumber = -1;
+ }
rv.objectName = object->objectName();
rv.objectType = object->metaObject()->className();
diff --git a/src/declarative/qml/qmlinfo.cpp b/src/declarative/qml/qmlinfo.cpp
index 65a4298..e47b4ab 100644
--- a/src/declarative/qml/qmlinfo.cpp
+++ b/src/declarative/qml/qmlinfo.cpp
@@ -40,6 +40,8 @@
****************************************************************************/
#include "qmlinfo.h"
+#include <private/qmldeclarativedata_p.h>
+#include <QtDeclarative/qmlcontext.h>
QT_BEGIN_NAMESPACE
@@ -80,7 +82,19 @@ QmlInfo::QmlInfo(QObject *object)
*this << "QML";
if (object)
*this << object->metaObject()->className();
- *this << "(unknown location):";
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(object);
+ if (ddata) {
+ QString location = QLatin1String("(");
+ location += ddata->outerContext->baseUrl().toString();
+ location += QLatin1String(":");
+ location += QString::number(ddata->lineNumber);
+ location += QLatin1String(":");
+ location += QString::number(ddata->columnNumber);
+ location += QLatin1String(")");
+ *this << location.toLatin1().constData();
+ } else {
+ *this << "(unknown location):";
+ }
}
/*!
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 8861609a..ede06a2 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -170,6 +170,7 @@ public:
struct {
int type;
int data;
+ ushort column;
} create;
struct {
int data;
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 930e6e4..7907195 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -174,6 +174,11 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledData
VME_EXCEPTION("Unable to create object of type" << types.at(instr.create.type).className);
}
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(o);
+ ddata->outerContext = ctxt;
+ ddata->lineNumber = instr.line;
+ ddata->columnNumber = instr.create.column;
+
if (instr.create.data != -1) {
QmlCustomParser *customParser =
types.at(instr.create.type).type->customParser();