summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-16 00:13:24 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-16 00:13:24 (GMT)
commite4e566272f41a27b7b160c6e1344d24f66ad022c (patch)
tree0a0ab20cb0dca377a4c6129882daee3719342e60
parent338d6ca0d2d98c8c3ffc8c29b8135de8e0bb8a7b (diff)
parent2eb67032ea81aa105a854644f337ad5377c2994e (diff)
downloadQt-e4e566272f41a27b7b160c6e1344d24f66ad022c.zip
Qt-e4e566272f41a27b7b160c6e1344d24f66ad022c.tar.gz
Qt-e4e566272f41a27b7b160c6e1344d24f66ad022c.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--examples/declarative/dynamic/dynamic.qml8
-rw-r--r--examples/declarative/loader/Browser.qml58
-rw-r--r--examples/declarative/loader/loader.pro9
-rw-r--r--examples/declarative/loader/main.cpp42
-rw-r--r--src/declarative/debugger/qmldebugclient.cpp2
-rw-r--r--src/declarative/extra/qmlfolderlistmodel.cpp9
-rw-r--r--src/declarative/extra/qmlfolderlistmodel.h3
-rw-r--r--src/declarative/fx/qfxlistview.cpp2
-rw-r--r--src/declarative/fx/qfxtext.cpp8
-rw-r--r--src/declarative/fx/qfxtextinput.cpp26
-rw-r--r--src/declarative/fx/qfxtextinput.h2
-rw-r--r--src/declarative/fx/qfxtextinput_p.h2
-rw-r--r--src/declarative/qml/qml.h20
-rw-r--r--src/declarative/qml/qmlcompiler.cpp4
-rw-r--r--src/declarative/qml/qmlcustomparser_p.h8
-rw-r--r--src/declarative/qml/qmlengine.cpp2
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp1
-rw-r--r--src/declarative/qml/qmlrewrite.cpp73
-rw-r--r--src/declarative/qml/qmlrewrite_p.h22
-rw-r--r--tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp8
-rw-r--r--tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp26
-rw-r--r--tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml5
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp5
-rw-r--r--tests/auto/declarative/visual/qfxtext/elide/multilength.qml20
-rw-r--r--tests/auto/declarative/visual/tst_visual.cpp2
25 files changed, 309 insertions, 58 deletions
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
index 66fdf87..2c6a8e0 100644
--- a/examples/declarative/dynamic/dynamic.qml
+++ b/examples/declarative/dynamic/dynamic.qml
@@ -8,6 +8,7 @@ Rectangle {
Script { source: "dynamic.js" }
property bool extendStars: false
+ property var fourthBox: undefined
Item { id: targetItem; x: 100; y: 100; }
Item { id: targetItem2; x: 0; y: 300; }
@@ -20,7 +21,7 @@ Rectangle {
MouseRegion {
anchors.fill: parent
- onClicked: { a = createWithComponent(); }
+ onClicked: { var a = createWithComponent(); }
}
}
@@ -47,8 +48,8 @@ Rectangle {
MouseRegion {
anchors.fill: parent
onClicked: {
- if (fourthBox == null) {
- a = createQml(targetItem2);
+ if (fourthBox == null || fourthBox == undefined) {
+ var a = createQml(targetItem2);
if (a != null) {
a.parent = targetItem2;//BUG: this should happen automatically
fourthBox = a;
@@ -68,6 +69,7 @@ Rectangle {
Particles {
x: 0
y: 0
+ z: 10
count: 20
lifeSpan: 500
width: 100
diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml
index 5f972f1..9eedd4e 100644
--- a/examples/declarative/loader/Browser.qml
+++ b/examples/declarative/loader/Browser.qml
@@ -2,13 +2,14 @@ import Qt 4.6
Rectangle {
id: root
+ property bool keyPressed: false
width: parent.width
height: parent.height
- color: palette.base
+ color: palette.window
FolderListModel {
id: folders
nameFilters: [ "*.qml" ]
-// folder: "E:"
+ folder: "E:"
}
SystemPalette { id: palette; colorGroup: Qt.Active }
@@ -25,7 +26,7 @@ Rectangle {
}
}
width: root.width
- height: 32
+ height: 48
color: "transparent"
Rectangle {
id: highlight; visible: false
@@ -36,15 +37,15 @@ Rectangle {
}
}
Item {
- width: 32; height: 32
+ width: 46; height: 46
Image { source: "images/fileopen.png"; anchors.centerIn: parent; visible: folders.isFolder(index)}
}
Text {
id: nameText
anchors.fill: parent; verticalAlignment: "AlignVCenter"
- text: fileName; anchors.leftMargin: 32
- font.pointSize: 10
- color: palette.windowText
+ text: fileName; anchors.leftMargin: 48
+ font.pixelSize: 32
+ color: wrapper.isCurrentItem ? palette.highlightedText : palette.text
}
MouseRegion {
id: mouseRegion
@@ -62,13 +63,6 @@ Rectangle {
}
}
- Script {
- function up(path) {
- var pos = path.toString().lastIndexOf("/");
- return path.toString().substring(0, pos);
- }
- }
-
ListView {
id: view
anchors.top: titleBar.bottom
@@ -77,37 +71,59 @@ Rectangle {
anchors.bottom: parent.bottom
model: folders
delegate: folderDelegate
- highlight: Rectangle { color: "#FFFBAF" }
+ highlight: Rectangle { color: palette.highlight; visible: root.keyPressed }
clip: true
focus: true
+ pressDelay: 100
+
Keys.onPressed: {
- if (event.key == Qt.Key_Return || event.key == Qt.Key_Select) {
+ root.keyPressed = true;
+ if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) {
view.currentItem.launch();
event.accepted = true;
}
}
+ Keys.onLeftPressed: folders.folder = up(folders.folder)
}
Rectangle {
id: titleBar
width: parent.width
- height: 32
- color: palette.button; border.color: palette.mid
+ height: 48
+ color: palette.lighter(palette.window); border.color: palette.mid
Rectangle {
id: upButton
- width: 30
+ width: 48
height: titleBar.height
border.color: palette.mid; color: "transparent"
- MouseRegion { anchors.fill: parent; onClicked: folders.folder = up(folders.folder) }
+
+ Script {
+ function up(path) {
+ var pos = path.toString().lastIndexOf("/");
+ return path.toString().substring(0, pos);
+ }
+ }
+
Image { anchors.centerIn: parent; source: "images/up.png" }
+ MouseRegion { id: upRegion; anchors.fill: parent
+ onClicked: if (folders.parentFolder != "") folders.folder = folders.parentFolder
+ }
+ states: [
+ State {
+ name: "pressed"
+ when: upRegion.pressed
+ PropertyChanges { target: upButton; color: palette.highlightedText }
+ }
+ ]
}
Text {
anchors.left: upButton.right; anchors.right: parent.right; height: parent.height
anchors.leftMargin: 4; anchors.rightMargin: 4
- text: folders.folder; color: palette.buttonText
+ text: folders.folder; color: palette.text
elide: "ElideLeft"; horizontalAlignment: "AlignRight"; verticalAlignment: "AlignVCenter"
+ font.pixelSize: 32
}
}
}
diff --git a/examples/declarative/loader/loader.pro b/examples/declarative/loader/loader.pro
index 089eaff..9b03b8f 100644
--- a/examples/declarative/loader/loader.pro
+++ b/examples/declarative/loader/loader.pro
@@ -7,3 +7,12 @@ target.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS loader.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader
INSTALLS += target sources
+
+symbian {
+# TARGET.UID3 =
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+ TARGET.EPOCHEAPSIZE = 100000 20000000
+ HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h
+ LIBS += -lesock -lconnmon -linsock
+ TARGET.CAPABILITY = NetworkServices
+}
diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp
index fbae5f1..0993814 100644
--- a/examples/declarative/loader/main.cpp
+++ b/examples/declarative/loader/main.cpp
@@ -15,6 +15,15 @@
#include <QDebug>
#include <QNetworkDiskCache>
#include <QNetworkAccessManager>
+#include <QtCore>
+
+#if defined (Q_OS_SYMBIAN)
+#define SYMBIAN_NETWORK_INIT
+#endif
+
+#if defined (SYMBIAN_NETWORK_INIT)
+#include "sym_iap_util.h"
+#endif
QmlView *canvas = 0;
@@ -30,13 +39,11 @@ public:
setLayout(layout);
#ifdef Q_OS_SYMBIAN
QAction *closeAction = new QAction("Close", this);
- closeAction->setSoftKeyRole(QAction::BackSoftKey);
+ closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
-
- QList<QAction*> softKeys;
- softKeys.append(closeAction);
- setSoftKeys(softKeys);
+ addAction(closeAction);
#endif
+ connect(logText, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
}
void append(const QString &text) {
@@ -50,6 +57,9 @@ public:
return logger;
}
+signals:
+ void textChanged();
+
private:
QPlainTextEdit *logText;
};
@@ -112,7 +122,7 @@ public:
}
}
- canvas->setUrl(fileName);
+ canvas->setUrl(url);
canvas->execute();
}
@@ -124,8 +134,9 @@ class MainWindow : public QMainWindow
{
Q_OBJECT
public:
- MainWindow() : QMainWindow() {}
-
+ MainWindow() : QMainWindow()
+ {
+ }
public slots:
void toggleFullScreen()
@@ -149,6 +160,13 @@ public slots:
Logger::instance()->show();
#endif
}
+
+ void enableNetwork()
+ {
+#if defined(SYMBIAN_NETWORK_INIT)
+ qt_SetDefaultIap();
+#endif
+ }
};
class ConfiguredNetworkAccessManager : public QNetworkAccessManager {
@@ -185,8 +203,6 @@ int main(int argc, char *argv[])
canvas->setFocusPolicy(Qt::StrongFocus);
canvas->engine()->setNetworkAccessManager(new ConfiguredNetworkAccessManager);
- mw->setCentralWidget(canvas);
-
QMenuBar *mb = mw->menuBar();
QAction *showLogAction = new QAction("View Log...", mw);
mb->addAction(showLogAction);
@@ -194,6 +210,11 @@ int main(int argc, char *argv[])
QAction *toggleFSAction = new QAction("Fullscreen", mw);
mb->addAction(toggleFSAction);
QObject::connect(toggleFSAction, SIGNAL(triggered()), mw, SLOT(toggleFullScreen()));
+#if defined(SYMBIAN_NETWORK_INIT)
+ QAction *enableNetworkAction = new QAction("Enable Network", mw);
+ mb->addAction(enableNetworkAction);
+ QObject::connect(enableNetworkAction, SIGNAL(triggered()), mw, SLOT(enableNetwork()));
+#endif
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("qmlLauncher", launcher);
@@ -205,6 +226,7 @@ int main(int argc, char *argv[])
mw->show();
#endif
canvas->execute();
+ mw->setCentralWidget(canvas);
return app.exec();
}
diff --git a/src/declarative/debugger/qmldebugclient.cpp b/src/declarative/debugger/qmldebugclient.cpp
index d13de57..3171808 100644
--- a/src/declarative/debugger/qmldebugclient.cpp
+++ b/src/declarative/debugger/qmldebugclient.cpp
@@ -104,7 +104,7 @@ bool QmlDebugConnection::isConnected() const
class QmlDebugClientPrivate : public QObjectPrivate
{
- Q_DECLARE_PUBLIC(QmlDebugClient);
+ Q_DECLARE_PUBLIC(QmlDebugClient)
public:
QmlDebugClientPrivate();
diff --git a/src/declarative/extra/qmlfolderlistmodel.cpp b/src/declarative/extra/qmlfolderlistmodel.cpp
index bdea03f..4a7c2f1 100644
--- a/src/declarative/extra/qmlfolderlistmodel.cpp
+++ b/src/declarative/extra/qmlfolderlistmodel.cpp
@@ -195,6 +195,15 @@ void QmlFolderListModel::setFolder(const QString &folder)
}
}
+QString QmlFolderListModel::parentFolder() const
+{
+ Q_D(const QmlFolderListModel);
+ int pos = d->folder.lastIndexOf('/');
+ if (pos == -1)
+ return QString();
+ return d->folder.left(pos);
+}
+
/*!
\qmlproperty list<string> FolderListModel::nameFilters
diff --git a/src/declarative/extra/qmlfolderlistmodel.h b/src/declarative/extra/qmlfolderlistmodel.h
index 24a3ac6..6bb1c4b 100644
--- a/src/declarative/extra/qmlfolderlistmodel.h
+++ b/src/declarative/extra/qmlfolderlistmodel.h
@@ -61,6 +61,7 @@ class Q_DECLARATIVE_EXPORT QmlFolderListModel : public QListModelInterface, publ
Q_INTERFACES(QmlParserStatus)
Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged)
+ Q_PROPERTY(QString parentFolder READ parentFolder NOTIFY folderChanged)
Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
Q_PROPERTY(SortField sortField READ sortField WRITE setSortField)
Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed)
@@ -77,6 +78,8 @@ public:
QString folder() const;
void setFolder(const QString &folder);
+ QString parentFolder() const;
+
QStringList nameFilters() const;
void setNameFilters(const QStringList &filters);
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 604d16b..4fb0ec1 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -166,7 +166,7 @@ public:
class QFxListViewPrivate : public QFxFlickablePrivate
{
- Q_DECLARE_PUBLIC(QFxListView);
+ Q_DECLARE_PUBLIC(QFxListView)
public:
QFxListViewPrivate()
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index c26ed2c..4d02f0d 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -427,9 +427,13 @@ void QFxText::setTextFormat(TextFormat format)
This property cannot be used with wrap enabled or with rich text.
- Eliding can be ElideNone, ElideLeft, ElideMiddle, or ElideRight.
+ Eliding can be ElideNone (the default), ElideLeft, ElideMiddle, or ElideRight.
- ElideNone is the default.
+ If the text is a multi-length string, and the mode is not ElideNone,
+ the first string that fits will be used, otherwise the last will be elided.
+
+ Multi-length strings are ordered from longest to shortest, separated by the
+ Unicode "String Terminator" character U009C (write this in QML with "\\x9C").
*/
Qt::TextElideMode QFxText::elideMode() const
{
diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp
index f5bf911..e9ddd3f 100644
--- a/src/declarative/fx/qfxtextinput.cpp
+++ b/src/declarative/fx/qfxtextinput.cpp
@@ -289,6 +289,18 @@ void QFxTextInput::setCursorPosition(int cp)
}
/*!
+ \internal
+
+ Returns a Rect which encompasses the cursor, but which may be larger than is
+ required. Ignores custom cursor delegates.
+*/
+QRect QFxTextInput::cursorRect() const
+{
+ Q_D(const QFxTextInput);
+ return d->control->cursorRect();
+}
+
+/*!
\qmlproperty int TextInput::selectionStart
The cursor position before the first character in the current selection.
@@ -489,17 +501,19 @@ void QFxTextInput::setCursorDelegate(QmlComponent* c)
{
Q_D(QFxTextInput);
d->cursorComponent = c;
- d->startCreatingCursor();
+ if(!c){
+ //note that the components are owned by something else
+ disconnect(d->control, SIGNAL(cursorPositionChanged(int, int)),
+ this, SLOT(moveCursor()));
+ delete d->cursorItem;
+ }else{
+ d->startCreatingCursor();
+ }
}
void QFxTextInputPrivate::startCreatingCursor()
{
Q_Q(QFxTextInput);
- if(!cursorComponent){
- q->disconnect(control, SIGNAL(cursorPositionChanged(int, int)),
- q, SLOT(moveCursor()));
- return;
- }
q->connect(control, SIGNAL(cursorPositionChanged(int, int)),
q, SLOT(moveCursor()));
if(cursorComponent->isReady()){
diff --git a/src/declarative/fx/qfxtextinput.h b/src/declarative/fx/qfxtextinput.h
index d5d0450..2540d41 100644
--- a/src/declarative/fx/qfxtextinput.h
+++ b/src/declarative/fx/qfxtextinput.h
@@ -131,6 +131,8 @@ public:
int cursorPosition() const;
void setCursorPosition(int cp);
+ QRect cursorRect() const;
+
int selectionStart() const;
void setSelectionStart(int);
diff --git a/src/declarative/fx/qfxtextinput_p.h b/src/declarative/fx/qfxtextinput_p.h
index a2b45bb..3978be4 100644
--- a/src/declarative/fx/qfxtextinput_p.h
+++ b/src/declarative/fx/qfxtextinput_p.h
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
class QFxTextInputPrivate : public QFxPaintedItemPrivate
{
- Q_DECLARE_PUBLIC(QFxTextInput);
+ Q_DECLARE_PUBLIC(QFxTextInput)
public:
QFxTextInputPrivate() : control(new QLineControl(QString())),
color((QRgb)0), style(QFxText::Normal),
diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h
index 23f2f1e..c437ef1 100644
--- a/src/declarative/qml/qml.h
+++ b/src/declarative/qml/qml.h
@@ -74,6 +74,24 @@ QT_MODULE(Declarative)
QT_BEGIN_NAMESPACE
+#if defined(Q_OS_SYMBIAN)
+#define QML_DEFINE_INTERFACE(INTERFACE) \
+ static int defineInterface##INTERFACE = qmlRegisterInterface<INTERFACE>(#INTERFACE);
+
+#define QML_DEFINE_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, NAME, TYPE, EXTENSION) \
+ static int registerExtended##TYPE = qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE);
+
+#define QML_DEFINE_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, NAME, TYPE) \
+ static int defineType##TYPE = qmlRegisterType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE);
+
+#define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \
+ static int registerExtendedNoCreate##TYPE = qmlRegisterExtendedType<TYPE,EXTENSION>(#TYPE);
+
+#define QML_DEFINE_NOCREATE_TYPE(TYPE) \
+ static int registerNoCreate##TYPE = qmlRegisterType<TYPE>(#TYPE);
+
+#else
+
#define QML_DEFINE_INTERFACE(INTERFACE) \
template<> QmlPrivate::InstanceType QmlPrivate::Define<INTERFACE *,0,0,0>::instance(qmlRegisterInterface<INTERFACE>(#INTERFACE));
@@ -89,6 +107,8 @@ QT_BEGIN_NAMESPACE
#define QML_DEFINE_NOCREATE_TYPE(TYPE) \
template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,0,0,0>::instance(qmlRegisterType<TYPE>(#TYPE));
+#endif
+
class QmlContext;
class QmlEngine;
Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *);
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index c744509..e2fd7cb 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -2039,7 +2039,7 @@ bool QmlCompiler::mergeDynamicMetaProperties(QmlParser::Object *obj)
return true;
}
-static QAtomicInt classIndexCounter;
+Q_GLOBAL_STATIC(QAtomicInt, classIndexCounter)
bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
{
@@ -2058,7 +2058,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
QByteArray newClassName = obj->metatype->className();
newClassName.append("_QML_");
- int idx = classIndexCounter.fetchAndAddRelaxed(1);
+ int idx = classIndexCounter()->fetchAndAddRelaxed(1);
newClassName.append(QByteArray::number(idx));
QMetaObjectBuilder builder;
diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h
index 5be0680..eb3e579 100644
--- a/src/declarative/qml/qmlcustomparser_p.h
+++ b/src/declarative/qml/qmlcustomparser_p.h
@@ -127,8 +127,14 @@ protected:
private:
QList<QmlError> exceptions;
};
-#define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, NAME, TYPE, CUSTOMTYPE) \
+
+#if defined(Q_OS_SYMBIAN)
+# define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, NAME, TYPE, CUSTOMTYPE) \
+ static int defineCustomType##NAME = qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, #NAME, #TYPE, new CUSTOMTYPE);
+#else
+# define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, NAME, TYPE, CUSTOMTYPE) \
template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN_FROM), (VERSION_MAJ_TO)>::instance(qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, #NAME, #TYPE, new CUSTOMTYPE));
+#endif
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index f0ecf1d..528e8c9 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -1099,7 +1099,7 @@ public:
int slash = type.indexOf('/');
if (slash >= 0) {
while (!s) {
- s = set.value(QString::fromLatin1(type.left(slash)));
+ s = set.value(QString::fromUtf8(type.left(slash)));
int nslash = type.indexOf('/',slash+1);
if (nslash > 0)
slash = nslash;
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp
index 122db51..ae2cfcc 100644
--- a/src/declarative/qml/qmlobjectscriptclass.cpp
+++ b/src/declarative/qml/qmlobjectscriptclass.cpp
@@ -250,6 +250,7 @@ void QmlObjectScriptClass::setProperty(QObject *obj,
Q_ASSERT(lastData);
QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine);
+ Q_ASSERT(enginePriv->currentExpression);
// ### Can well known types be optimized?
QVariant v = QmlScriptClass::toVariant(engine, value);
diff --git a/src/declarative/qml/qmlrewrite.cpp b/src/declarative/qml/qmlrewrite.cpp
index a41b571..43b2529 100644
--- a/src/declarative/qml/qmlrewrite.cpp
+++ b/src/declarative/qml/qmlrewrite.cpp
@@ -71,6 +71,7 @@ QString RewriteBinding::rewrite(QString code, unsigned position,
TextWriter w;
_writer = &w;
_position = position;
+ _inLoop = 0;
accept(node);
@@ -111,12 +112,80 @@ bool RewriteBinding::visit(AST::Block *ast)
bool RewriteBinding::visit(AST::ExpressionStatement *ast)
{
- unsigned startOfExpressionStatement = ast->firstSourceLocation().begin() - _position;
- _writer->replace(startOfExpressionStatement, 0, QLatin1String("return "));
+ if (! _inLoop) {
+ unsigned startOfExpressionStatement = ast->firstSourceLocation().begin() - _position;
+ _writer->replace(startOfExpressionStatement, 0, QLatin1String("return "));
+ }
return false;
}
+bool RewriteBinding::visit(AST::DoWhileStatement *ast)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::DoWhileStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::WhileStatement *ast)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::WhileStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::ForStatement *ast)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::ForStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::LocalForStatement *ast)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::LocalForStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::ForEachStatement *ast)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::ForEachStatement *)
+{
+ --_inLoop;
+}
+
+bool RewriteBinding::visit(AST::LocalForEachStatement *ast)
+{
+ ++_inLoop;
+ return true;
+}
+
+void RewriteBinding::endVisit(AST::LocalForEachStatement *)
+{
+ --_inLoop;
+}
+
} // namespace QmlRewrite
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlrewrite_p.h b/src/declarative/qml/qmlrewrite_p.h
index b6fe017..59057d5 100644
--- a/src/declarative/qml/qmlrewrite_p.h
+++ b/src/declarative/qml/qmlrewrite_p.h
@@ -76,8 +76,30 @@ protected:
void accept(AST::Node *node);
QString rewrite(QString code, unsigned position, AST::Statement *node);
+
virtual bool visit(AST::Block *ast);
virtual bool visit(AST::ExpressionStatement *ast);
+
+ virtual bool visit(AST::DoWhileStatement *ast);
+ virtual void endVisit(AST::DoWhileStatement *ast);
+
+ virtual bool visit(AST::WhileStatement *ast);
+ virtual void endVisit(AST::WhileStatement *ast);
+
+ virtual bool visit(AST::ForStatement *ast);
+ virtual void endVisit(AST::ForStatement *ast);
+
+ virtual bool visit(AST::LocalForStatement *ast);
+ virtual void endVisit(AST::LocalForStatement *ast);
+
+ virtual bool visit(AST::ForEachStatement *ast);
+ virtual void endVisit(AST::ForEachStatement *ast);
+
+ virtual bool visit(AST::LocalForEachStatement *ast);
+ virtual void endVisit(AST::LocalForEachStatement *ast);
+
+private:
+ int _inLoop;
};
} // namespace QmlRewrite
diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
index 7ab598f..f78e564 100644
--- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
+++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
@@ -433,10 +433,10 @@ void tst_qfxtextedit::selection()
void tst_qfxtextedit::cursorDelegate()
{
- QmlView* view = new QmlView(0);
- view->show();
- view->setUrl(QUrl("data/cursorTest.qml"));
+ QmlView* view = createView(SRCDIR "/data/cursorTest.qml");
view->execute();
+ view->show();
+ view->setFocus();
QFxTextEdit *textEditObject = view->root()->findChild<QFxTextEdit*>("textEditObject");
QVERIFY(textEditObject != 0);
QVERIFY(textEditObject->findChild<QFxItem*>("cursorInstance"));
@@ -467,6 +467,7 @@ void tst_qfxtextedit::navigation()
QmlView *canvas = createView(SRCDIR "/data/navigation.qml");
canvas->execute();
canvas->show();
+ canvas->setFocus();
QVERIFY(canvas->root() != 0);
@@ -474,6 +475,7 @@ void tst_qfxtextedit::navigation()
QVERIFY(input != 0);
QTRY_VERIFY(input->hasFocus() == true);
+ QEXPECT_FAIL("", "Depends on QT-2236", Abort);
simulateKey(canvas, Qt::Key_Left);
QVERIFY(input->hasFocus() == false);
simulateKey(canvas, Qt::Key_Right);
diff --git a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
index bd0b9c3..069574c 100644
--- a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
+++ b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
@@ -310,6 +310,7 @@ void tst_qfxtextinput::navigation()
QmlView *canvas = createView(SRCDIR "/data/navigation.qml");
canvas->execute();
canvas->show();
+ canvas->setFocus();
QVERIFY(canvas->root() != 0);
@@ -329,7 +330,30 @@ void tst_qfxtextinput::navigation()
void tst_qfxtextinput::cursorDelegate()
{
- //TODO:Get the QFxTextEdit test passing first
+ QmlView* view = createView(SRCDIR "/data/cursorTest.qml");
+ view->execute();
+ view->show();
+ view->setFocus();
+ QFxTextInput *textInputObject = view->root()->findChild<QFxTextInput*>("textInputObject");
+ QVERIFY(textInputObject != 0);
+ QVERIFY(textInputObject->findChild<QFxItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textInputObject->setFocus(true);
+ QFxItem* delegateObject = textInputObject->findChild<QFxItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ //Test Delegate gets moved
+ for(int i=0; i<= textInputObject->text().length(); i++){
+ textInputObject->setCursorPosition(i);
+ //+5 is because the TextInput cursorRect is just a 10xHeight area centered on cursor position
+ QCOMPARE(textInputObject->cursorRect().x() + 5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
+ }
+ textInputObject->setCursorPosition(0);
+ QCOMPARE(textInputObject->cursorRect().x()+5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
+ //Test Delegate gets deleted
+ textInputObject->setCursorDelegate(0);
+ QVERIFY(!textInputObject->findChild<QFxItem*>("cursorInstance"));
}
void tst_qfxtextinput::simulateKey(QmlView *view, int key)
diff --git a/tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml b/tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml
new file mode 100644
index 0000000..c0b2f94
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml
@@ -0,0 +1,5 @@
+import Test 1.0 as Áâãäå
+
+Áâãäå.MyTypeObject {
+ stringProperty: "Test áâãäå: 40"
+}
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index b68d9bf..8d4ae65 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -126,14 +126,14 @@ void tst_qmllanguage::initTestCase()
// For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded
QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile());
QVERIFY(in.open(QIODevice::ReadOnly));
- QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\241\303\242\303\243\303\244\303\245.qml")).toLocalFile());
+ QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
QVERIFY(out.open(QIODevice::WriteOnly));
out.write(in.readAll());
}
void tst_qmllanguage::cleanupTestCase()
{
- QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\241\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
+ QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
}
void tst_qmllanguage::errors_data()
@@ -711,6 +711,7 @@ void tst_qmllanguage::i18n_data()
QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15");
QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20");
QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30");
+ QTest::newRow("i18nNameSpace") << "i18nNameSpace.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 40");
}
void tst_qmllanguage::i18n()
diff --git a/tests/auto/declarative/visual/qfxtext/elide/multilength.qml b/tests/auto/declarative/visual/qfxtext/elide/multilength.qml
new file mode 100644
index 0000000..6cd37b4
--- /dev/null
+++ b/tests/auto/declarative/visual/qfxtext/elide/multilength.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+Rectangle {
+ width: 500
+ height: 50
+ color: "lightBlue"
+ Rectangle {
+ width: MyText.width
+ height: MyText.height
+ color: "white"
+ anchors.centerIn: parent
+ Text {
+ id: MyText
+ width: NumberAnimation { from: 500; to: 0; running: true; repeat: true; duration: 1000 }
+ elide: "ElideRight"
+ text: "aaaaaaa bbbbbbb ccccccc\x9Caaaaa bbbbb ccccc\x9Caaa bbb ccc\x9Ca b c"
+ text: "Brevity is the soul of wit, and tediousness the limbs and outward flourishes.\x9CBrevity is a great charm of eloquence.\x9CBe concise!\x9CSHHHHHHHHHHHHHHHHHHHHHHHHHHHH"
+ }
+ }
+}
diff --git a/tests/auto/declarative/visual/tst_visual.cpp b/tests/auto/declarative/visual/tst_visual.cpp
index 367166d..cb32085 100644
--- a/tests/auto/declarative/visual/tst_visual.cpp
+++ b/tests/auto/declarative/visual/tst_visual.cpp
@@ -112,7 +112,7 @@ QString tst_visual::toTestScript(const QString &file, Mode mode)
QString("data");
QString testname = file.mid(index + 1, file.length() - index - 5);
- if (platformsuffix && (mode == UpdatePlatformVisuals || QDir(testdata+QLatin1String(platformsuffix)).exists())) {
+ if (platformsuffix && (mode == UpdatePlatformVisuals || QFile::exists(testdata+QLatin1String(platformsuffix)+QDir::separator()+testname))) {
QString platformdir = testdata + QLatin1String(platformsuffix);
if (mode == UpdatePlatformVisuals) {
Q_ASSERT(QDir().mkpath(platformdir));