From decc287134139c61da5610afc060a6ca8d09f368 Mon Sep 17 00:00:00 2001
From: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
Date: Tue, 4 Aug 2009 15:59:25 +0200
Subject: Cocoa: Menus show old selected values.

We never told Cocoa that it needed to redraw the window view
when a window was shown. This is implicit if the window is
shown for the first time, but needs to be done explicit
if you hide and show it again.

Task-number: 254672
Reviewed-by: bnilsen
---
 src/gui/kernel/qwidget_mac.mm                    |  6 ++++++
 tests/auto/qwidget_window/tst_qwidget_window.cpp | 24 +++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 8913c89..057df81 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3249,6 +3249,12 @@ void QWidgetPrivate::show_sys()
 #ifndef QT_MAC_USE_COCOA
         SizeWindow(window, q->width(), q->height(), true);
 #endif
+
+#ifdef QT_MAC_USE_COCOA
+        // Make sure that we end up sending a repaint event to
+        // the widget if the window has been visible one before:
+        [qt_mac_get_contentview_for(window) setNeedsDisplay:YES];
+#endif
         if(qt_mac_is_macsheet(q)) {
             qt_event_request_showsheet(q);
         } else if(qt_mac_is_macdrawer(q)) {
diff --git a/tests/auto/qwidget_window/tst_qwidget_window.cpp b/tests/auto/qwidget_window/tst_qwidget_window.cpp
index f059abe..6dddfe8 100644
--- a/tests/auto/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/qwidget_window/tst_qwidget_window.cpp
@@ -78,6 +78,7 @@ private slots:
     void tst_windowFilePath();
 
     void tst_showWithoutActivating();
+    void tst_paintEventOnSecondShow();
 };
 
 void tst_QWidget_window::initTestCase()
@@ -150,7 +151,9 @@ class TestWidget : public QWidget
 {
 public:
     int m_first, m_next;    
-    void reset(){ m_first = m_next = 0; }
+    bool paintEventReceived;
+
+    void reset(){ m_first = m_next = 0; paintEventReceived = false; }
     bool event(QEvent *event)
     {
         switch (event->type()) {
@@ -162,6 +165,10 @@ public:
                 m_next = event->type();
             else 
                 m_first = event->type();
+            break;
+        case QEvent::Paint:
+            paintEventReceived = true;
+            break;
         default:
             break;
         }
@@ -300,5 +307,20 @@ void tst_QWidget_window::tst_showWithoutActivating()
 #endif // Q_WS_X11
 }
 
+void tst_QWidget_window::tst_paintEventOnSecondShow()
+{
+    TestWidget w;
+    w.show();
+    w.hide();
+
+    w.reset();
+    w.show();
+#ifdef Q_WS_X11
+    QTest::qWait(500);
+#endif
+    QApplication::processEvents();
+    QVERIFY(w.paintEventReceived);
+}
+
 QTEST_MAIN(tst_QWidget_window)
 #include "tst_qwidget_window.moc"
-- 
cgit v0.12


From 83c76bb2d1eeca2003720d243ef656aa241a3d49 Mon Sep 17 00:00:00 2001
From: Martin Smith <msmith@trolltech.com>
Date: Wed, 5 Aug 2009 10:27:44 +0200
Subject: qdoc: Removed the "No such group" qdoc error.

This error was printed if you used a \ingroup xxx,
but there was no \group xxx anywhere. Now we will
stop using the \group command, but we will retain
the \ingroup command for use with the \annotatedlist
command.
---
 tools/qdoc3/tree.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp
index d75af70..f832062 100644
--- a/tools/qdoc3/tree.cpp
+++ b/tools/qdoc3/tree.cpp
@@ -575,10 +575,12 @@ void Tree::resolveGroups()
         if (fake && fake->subType() == Node::Group) {
             fake->addGroupMember(i.value());
         }
+#if 0        
         else {
             if (prevGroup != i.key())
                 i.value()->doc().location().warning(tr("No such group '%1'").arg(i.key()));
         }
+#endif        
 
         prevGroup = i.key();
     }
-- 
cgit v0.12


From a3cb29b310f3d8b4de919bb19d98ae93edde7c85 Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Wed, 5 Aug 2009 11:01:12 +0200
Subject: sequential animation group: add autotest for pause/resume

---
 .../tst_qsequentialanimationgroup.cpp              | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 97ff04b..744ba52 100644
--- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -88,6 +88,7 @@ private slots:
     void currentAnimationWithZeroDuration();
     void insertAnimation();
     void clearAnimations();
+    void pauseResume();
 };
 
 tst_QSequentialAnimationGroup::tst_QSequentialAnimationGroup()
@@ -1644,5 +1645,40 @@ void tst_QSequentialAnimationGroup::clearAnimations()
     QCOMPARE(group.state(), QAbstractAnimation::Running);
 }
 
+void tst_QSequentialAnimationGroup::pauseResume()
+{
+    QObject dummy;
+    dummy.setProperty("foo", 0);
+    QParallelAnimationGroup group;
+    QPropertyAnimation *anim = new QPropertyAnimation(&dummy, "foo", &group);
+    anim->setDuration(250);
+    anim->setEndValue(250);
+    QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+    QCOMPARE(group.duration(), 250);
+    group.start();
+    QTest::qWait(100);
+    QCOMPARE(group.state(), QAnimationGroup::Running);
+    QCOMPARE(anim->state(), QAnimationGroup::Running);
+    QCOMPARE(spy.count(), 1);
+    spy.clear();
+    const int currentTime = group.currentTime();
+    QCOMPARE(anim->currentTime(), currentTime);
+
+    group.pause();
+    QCOMPARE(group.state(), QAnimationGroup::Paused);
+    QCOMPARE(group.currentTime(), currentTime);
+    QCOMPARE(anim->state(), QAnimationGroup::Paused);
+    QCOMPARE(anim->currentTime(), currentTime);
+    QCOMPARE(spy.count(), 1);
+    spy.clear();
+
+    group.resume();
+    QCOMPARE(group.state(), QAnimationGroup::Running);
+    QCOMPARE(group.currentTime(), currentTime);
+    QCOMPARE(anim->state(), QAnimationGroup::Running);
+    QCOMPARE(anim->currentTime(), currentTime);
+    QCOMPARE(spy.count(), 1);
+}
+
 QTEST_MAIN(tst_QSequentialAnimationGroup)
 #include "tst_qsequentialanimationgroup.moc"
-- 
cgit v0.12


From bcf41cf9dbe9921bb50b8cf2fcdcd9884e94412f Mon Sep 17 00:00:00 2001
From: Volker Hilsheimer <volker.hilsheimer@nokia.com>
Date: Wed, 5 Aug 2009 11:03:55 +0200
Subject: Make \annotatedlist <group> work also in pages that are not \group
 pages.

The command right now only lists the classes in the group, in alphabetical
order. Not ideal for integrating into overviews, where the list should be
ordered by relevance.
---
 tools/qdoc3/htmlgenerator.cpp | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index 425c50b..6b15f96 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -539,16 +539,13 @@ int HtmlGenerator::generateAtom(const Atom *atom,
         break;
     case Atom::AnnotatedList:
         {
-            const FakeNode *fake = static_cast<const FakeNode *>(relative);
-            if (fake && !fake->groupMembers().isEmpty()) {
-                QList<Node*> values = tre->groups().values(atom->string());
-                QMap<QString, const Node*> nodeMap;
-                for (int i = 0; i < values.size(); ++i) {
-                    const Node* n = values.at(i);
-                    nodeMap.insert(n->name(),n);
-                }
-                generateAnnotatedList(fake, marker, nodeMap);
+            QList<Node*> values = tre->groups().values(atom->string());
+            QMap<QString, const Node*> nodeMap;
+            for (int i = 0; i < values.size(); ++i) {
+                const Node* n = values.at(i);
+                nodeMap.insert(n->name(),n);
             }
+            generateAnnotatedList(relative, marker, nodeMap);
         }
         break;
     case Atom::GeneratedList:
-- 
cgit v0.12


From 118c82b0988c671045de448ffabc7ba95f015a69 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@trolltech.com>
Date: Wed, 5 Aug 2009 10:42:46 +0200
Subject: Fixes  hangup when pressing key in QListWidget

If there is severals matching items but all of them are disabled, it
would have produced an infinite loop.
Block the loop once we reach an already matched item.

Task-number: 258949
Reviewed-by: Thierry
---
 src/gui/itemviews/qabstractitemview.cpp    |  7 +++++++
 tests/auto/qlistwidget/tst_qlistwidget.cpp | 23 ++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 8594968..f7d5f1b 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -2666,6 +2666,7 @@ void QAbstractItemView::keyboardSearch(const QString &search)
     QModelIndex current = start;
     QModelIndexList match;
     QModelIndex firstMatch;
+    QModelIndex startMatch;
     QModelIndexList previous;
     do {
         match = d->model->match(current, Qt::DisplayRole, searchString);
@@ -2682,6 +2683,12 @@ void QAbstractItemView::keyboardSearch(const QString &search)
 	    if (row >= d->model->rowCount(firstMatch.parent()))
 	        row = 0;
             current = firstMatch.sibling(row, firstMatch.column());
+
+            //avoid infinite loop if all the matching items are disabled.
+            if (!startMatch.isValid())
+                startMatch = firstMatch;
+            else if (startMatch == firstMatch)
+                break;
         }
     } while (current != start && firstMatch.isValid());
 }
diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp
index a56a470..e38ef20 100644
--- a/tests/auto/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp
@@ -128,6 +128,8 @@ private slots:
     void setSortingEnabled();
     void task199503_crashWhenCleared();
     void task217070_scrollbarsAdjusted();
+    void task258949_keypressHangup();
+
 
 protected slots:
     void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last)
@@ -994,7 +996,7 @@ void tst_QListWidget::sortHiddenItems()
 
     for (int k = 0; k < tw->count(); ++k)
         QCOMPARE(persistent.at(k).row(), expectedRows.at(k));
-        
+
     delete tw;
 }
 
@@ -1498,5 +1500,24 @@ void tst_QListWidget::task217070_scrollbarsAdjusted()
     }
 }
 
+void tst_QListWidget::task258949_keypressHangup()
+{
+    QListWidget lw;
+    for (int y = 0; y < 5; y++) {
+        QListWidgetItem *lwi = new QListWidgetItem(&lw);
+        lwi->setText(y ? "1" : "0");
+        if (y)
+            lwi->setFlags(Qt::ItemIsSelectable);
+    }
+
+    lw.show();
+    lw.setCurrentIndex(lw.model()->index(0,0));
+    QCOMPARE(lw.currentIndex(), lw.model()->index(0,0));
+    QTest::qWait(30);
+    QTest::keyPress(&lw, '1'); //this used to freeze
+    QTest::qWait(30);
+    QCOMPARE(lw.currentIndex(), lw.model()->index(0,0));
+}
+
 QTEST_MAIN(tst_QListWidget)
 #include "tst_qlistwidget.moc"
-- 
cgit v0.12


From e3e1ea6c52473f120f8baee57e189ddc1c8671cb Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Wed, 5 Aug 2009 11:11:37 +0200
Subject: QMenu: fix a crash depending on styles

We were calling pixelMetric and sizeFromContents with a NULL styleoption
That crashes on mac and might also with other styles.
---
 src/gui/widgets/qmenu.cpp | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 67bb10a..05426a0 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -225,13 +225,17 @@ void QMenuPrivate::updateActionRects() const
         dh = popupGeometry(QApplication::desktop()->screenNumber(q)).height(),
         y = 0;
     QStyle *style = q->style();
-    const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, 0, q),
-              vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, 0, q),
-              icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
-    const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
-
-    const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, 0, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
+    QStyleOption opt;
+    opt.init(q);
+    const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q),
+              vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q),
+              icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q);
+    const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);
+    const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
+
+    const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
     const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
+    const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
 
     //for compatability now - will have to refactor this away..
     tabWidth = 0;
@@ -307,7 +311,7 @@ void QMenuPrivate::updateActionRects() const
             max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width()));
             //wrapping
             if (!scroll &&
-               y+sz.height()+vmargin > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) {
+               y+sz.height()+vmargin > dh - (deskFw * 2)) {
                 ncols++;
                 y = vmargin;
             }
@@ -322,7 +326,7 @@ void QMenuPrivate::updateActionRects() const
     //calculate position
     const int base_y = vmargin + fw + topmargin +
         (scroll ? scroll->scrollOffset : 0) +
-        (tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q) : 0);
+        tearoffHeight;
     int x = hmargin + fw + leftmargin;
     y = base_y;
 
@@ -331,7 +335,7 @@ void QMenuPrivate::updateActionRects() const
         if (rect.isNull())
             continue;
         if (!scroll &&
-           y+rect.height() > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) {
+           y+rect.height() > dh - deskFw * 2) {
             x += max_column_width + hmargin;
             y = base_y;
         }
-- 
cgit v0.12


From 5f52d473eec0f1b46200b06dd7f5e16cb5c57c05 Mon Sep 17 00:00:00 2001
From: Markus Goetz <Markus.Goetz@nokia.com>
Date: Wed, 5 Aug 2009 10:57:13 +0200
Subject: Fix compilation when QT_NO_HTTP is defined

Note however you still need to -nomake examples -nomake demos
when configuring Qt.

Reviewed-by: Thiago
Task: 259179
---
 src/network/access/qhttpnetworkheader.cpp         | 3 +++
 src/network/access/qhttpnetworkreply_p.h          | 1 +
 src/network/access/qhttpnetworkrequest.cpp        | 4 ++++
 src/qt3support/network/q3http.cpp                 | 2 +-
 src/qt3support/network/q3http.h                   | 5 ++---
 src/qt3support/network/q3network.cpp              | 2 +-
 tools/assistant/tools/assistant/installdialog.cpp | 2 ++
 tools/assistant/tools/assistant/installdialog.h   | 4 ++++
 8 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp
index 5af9764..88cc484 100644
--- a/src/network/access/qhttpnetworkheader.cpp
+++ b/src/network/access/qhttpnetworkheader.cpp
@@ -41,6 +41,7 @@
 
 #include "qhttpnetworkheader_p.h"
 
+#ifndef QT_NO_HTTP
 
 QT_BEGIN_NAMESPACE
 
@@ -121,3 +122,5 @@ bool QHttpNetworkHeaderPrivate::operator==(const QHttpNetworkHeaderPrivate &othe
 
 
 QT_END_NAMESPACE
+
+#endif
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
index 76aa947..65ed4ce 100644
--- a/src/network/access/qhttpnetworkreply_p.h
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -52,6 +52,7 @@
 //
 // We mean it.
 //
+#include <qplatformdefs.h>
 #ifndef QT_NO_HTTP
 
 #ifndef QT_NO_COMPRESS
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
index 02ba629..32d51f3 100644
--- a/src/network/access/qhttpnetworkrequest.cpp
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -41,6 +41,8 @@
 
 #include "qhttpnetworkrequest_p.h"
 
+#ifndef QT_NO_HTTP
+
 QT_BEGIN_NAMESPACE
 
 QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op,
@@ -259,3 +261,5 @@ int QHttpNetworkRequest::minorVersion() const
 
 QT_END_NAMESPACE
 
+#endif
+
diff --git a/src/qt3support/network/q3http.cpp b/src/qt3support/network/q3http.cpp
index a38edad..e44dfe8 100644
--- a/src/qt3support/network/q3http.cpp
+++ b/src/qt3support/network/q3http.cpp
@@ -42,7 +42,7 @@
 #include <qplatformdefs.h>
 #include "q3http.h"
 
-#ifndef QT_NO_NETWORKPROTOCOL_HTTP
+#ifndef QT_NO_HTTP
 
 #include "q3socket.h"
 #include "qtextstream.h"
diff --git a/src/qt3support/network/q3http.h b/src/qt3support/network/q3http.h
index 93ab00e..5311764 100644
--- a/src/qt3support/network/q3http.h
+++ b/src/qt3support/network/q3http.h
@@ -52,8 +52,7 @@ QT_BEGIN_HEADER
 QT_BEGIN_NAMESPACE
 
 QT_MODULE(Qt3Support)
-
-#ifndef QT_NO_NETWORKPROTOCOL_HTTP
+#ifndef QT_NO_HTTP
 
 class Q3Socket;
 class QTimerEvent;
@@ -269,7 +268,7 @@ private:
     friend class Q3HttpPGHRequest;
 };
 
-#endif // QT_NO_NETWORKPROTOCOL_HTTP
+#endif // QT_NO_HTTP
 
 QT_END_NAMESPACE
 
diff --git a/src/qt3support/network/q3network.cpp b/src/qt3support/network/q3network.cpp
index 3a6a6f0..1f918d1 100644
--- a/src/qt3support/network/q3network.cpp
+++ b/src/qt3support/network/q3network.cpp
@@ -63,7 +63,7 @@ void q3InitNetworkProtocols()
 #ifndef QT_NO_NETWORKPROTOCOL_FTP
     Q3NetworkProtocol::registerNetworkProtocol( QLatin1String("ftp"), new Q3NetworkProtocolFactory< Q3Ftp > );
 #endif
-#ifndef QT_NO_NETWORKPROTOCOL_HTTP
+#ifndef QT_NO_HTTP
     Q3NetworkProtocol::registerNetworkProtocol( QLatin1String("http"), new Q3NetworkProtocolFactory< Q3Http > );
 #endif
 }
diff --git a/tools/assistant/tools/assistant/installdialog.cpp b/tools/assistant/tools/assistant/installdialog.cpp
index 5a8dfea..2574f1f 100644
--- a/tools/assistant/tools/assistant/installdialog.cpp
+++ b/tools/assistant/tools/assistant/installdialog.cpp
@@ -56,6 +56,7 @@
 #include <QtNetwork/QHttp>
 
 QT_BEGIN_NAMESPACE
+#ifndef QT_NO_HTTP
 
 #define QCH_FILENAME  92943
 #define QCH_NAMESPACE 92944
@@ -335,4 +336,5 @@ void InstallDialog::browseDirectories()
         m_ui.pathLineEdit->setText(dir);
 }
 
+#endif
 QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/installdialog.h b/tools/assistant/tools/assistant/installdialog.h
index 62759ec..9e18a22b9 100644
--- a/tools/assistant/tools/assistant/installdialog.h
+++ b/tools/assistant/tools/assistant/installdialog.h
@@ -47,6 +47,8 @@
 #include <QtNetwork/QHttpResponseHeader>
 #include "ui_installdialog.h"
 
+#ifndef QT_NO_HTTP
+
 QT_BEGIN_NAMESPACE
 
 class QHttp;
@@ -98,4 +100,6 @@ private:
 
 QT_END_NAMESPACE
 
+#endif
+
 #endif // INSTALLDIALOG_H
-- 
cgit v0.12


From c379e151adc9c781f8f1e3d33cf68b3137868185 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Wed, 5 Aug 2009 11:11:52 +0200
Subject: cetest: add support for cetcpsync (our simple ActiveSync replacement)

Reviewed-By: mauricek
---
 .../qtestlib/wince/cetest/cetcpsyncconnection.cpp  | 198 +++++++++++++++++++++
 tools/qtestlib/wince/cetest/cetcpsyncconnection.h  |  82 +++++++++
 tools/qtestlib/wince/cetest/cetest.pro             |  19 +-
 tools/qtestlib/wince/cetest/deployment.cpp         |   2 +
 tools/qtestlib/wince/cetest/main.cpp               |  11 +-
 5 files changed, 305 insertions(+), 7 deletions(-)
 create mode 100644 tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
 create mode 100644 tools/qtestlib/wince/cetest/cetcpsyncconnection.h

diff --git a/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
new file mode 100644
index 0000000..bebcd1c
--- /dev/null
+++ b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
@@ -0,0 +1,198 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "CeTcpSyncConnection.h"
+#include <qdir.h>
+#include <qfile.h>
+#include <qfileinfo>
+
+extern void debugOutput(const QString& text, int level);
+
+CeTcpSyncConnection::CeTcpSyncConnection()
+        : AbstractRemoteConnection()
+        , connected(false)
+{
+}
+
+CeTcpSyncConnection::~CeTcpSyncConnection()
+{
+    if (isConnected())
+        disconnect();
+}
+
+bool CeTcpSyncConnection::connect(QVariantList&)
+{
+    // We connect with each command, so this is always true
+    // The command itself will fail then
+    if (system("cetcpsync noop") != 0)
+        return false;
+    connected = true;
+    return true;
+}
+
+void CeTcpSyncConnection::disconnect()
+{
+    connected = false;
+}
+
+bool CeTcpSyncConnection::isConnected() const
+{
+    return connected;
+}
+
+inline QString boolToString(bool b)
+{
+    return b ? "true" : "false";
+}
+
+static bool fileTimeFromString(FILETIME& ft, const QString& str)
+{
+    int idx = str.indexOf("*");
+    if (idx <= 0)
+        return false;
+    bool ok;
+    ft.dwLowDateTime = str.left(idx).toULong(&ok);
+    if (!ok)
+        return false;
+    ft.dwHighDateTime = str.mid(idx+1).toULong(&ok);
+    return ok;
+}
+
+static QString fileTimeToString(FILETIME& ft)
+{
+    return QString::number(ft.dwLowDateTime) + "*" + QString::number(ft.dwHighDateTime);
+}
+
+bool CeTcpSyncConnection::copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists)
+{
+    QString cmd = "cetcpsync copyFileToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(failIfExists);
+    return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive)
+{
+    QString cmd = "cetcpsync copyDirectoryToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(recursive);
+    return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists)
+{
+    QString cmd = "cetcpsync copyFileFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(failIfExists);
+    return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive)
+{
+    QString cmd = "cetcpsync copyDirectoryFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(recursive);
+    return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyFile(const QString &srcFile, const QString &destFile, bool failIfExists)
+{
+    QString cmd = "cetcpsync copyFile \"" + srcFile + "\" \"" + destFile + "\" " + boolToString(failIfExists);
+    return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyDirectory(const QString &srcDirectory, const QString &destDirectory,
+                                        bool recursive)
+{
+    QString cmd = "cetcpsync copyDirectory \"" + srcDirectory + "\" \"" + destDirectory + "\" " + boolToString(recursive);
+    return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::deleteFile(const QString &fileName)
+{
+    QString cmd = "cetcpsync deleteFile \"" + fileName + "\"";
+    return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::deleteDirectory(const QString &directory, bool recursive, bool failIfContentExists)
+{
+    QString cmd = "cetcpsync deleteDirectory \"" + directory + "\" " + boolToString(recursive) + " " + boolToString(failIfContentExists);
+    return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::execute(QString program, QString arguments, int timeout, int *returnValue)
+{
+    QString cmd = "cetcpsync execute \"" + program + "\" \"" + arguments + "\" " + QString::number(timeout);
+    int exitCode = system(qPrintable(cmd));
+    if (returnValue)
+        *returnValue = exitCode;
+    return true;
+}
+
+bool CeTcpSyncConnection::createDirectory(const QString &path, bool deleteBefore)
+{
+    QString cmd = "cetcpsync createDirectory \"" + path + "\" " + boolToString(deleteBefore);
+    return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::timeStampForLocalFileTime(FILETIME* fTime) const
+{
+    QString cmd = "cetcpsync timeStampForLocalFileTime " + fileTimeToString(*fTime) + " >filetime.txt";
+    if (system(qPrintable(cmd)) != 0)
+        return false;
+
+    QFile file("filetime.txt");
+    if (!file.open(QIODevice::ReadOnly))
+        return false;
+
+    bool result = fileTimeFromString(*fTime, file.readLine());
+    file.close();
+    file.remove();
+    return result;
+}
+
+bool CeTcpSyncConnection::fileCreationTime(const QString &fileName, FILETIME* deviceCreationTime) const
+{
+    QString cmd = "cetcpsync fileCreationTime \"" + fileName + "\" >filetime.txt";
+    if (system(qPrintable(cmd)) != 0)
+        return false;
+
+    QFile file("filetime.txt");
+    if (!file.open(QIODevice::ReadOnly))
+        return false;
+
+    bool result = fileTimeFromString(*deviceCreationTime, file.readLine());
+    file.close();
+    file.remove();
+    return result;
+}
diff --git a/tools/qtestlib/wince/cetest/cetcpsyncconnection.h b/tools/qtestlib/wince/cetest/cetcpsyncconnection.h
new file mode 100644
index 0000000..1ef8423
--- /dev/null
+++ b/tools/qtestlib/wince/cetest/cetcpsyncconnection.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CETCPSYNC_REMOTECONNECTION_H
+#define CETCPSYNC_REMOTECONNECTION_H
+
+#include "remoteconnection.h"
+
+class CeTcpSyncConnection : public AbstractRemoteConnection
+{
+public:
+    CeTcpSyncConnection();
+    virtual ~CeTcpSyncConnection();
+
+    bool connect(QVariantList &list = QVariantList());
+    void disconnect();
+    bool isConnected() const;
+
+    // These functions are designed for transfer between desktop and device
+    // Caution: deviceDest path has to be device specific (eg. no drive letters for CE)
+    bool copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists = false);
+    bool copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive = true);
+    bool copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists = false);
+    bool copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive = true);
+
+    bool timeStampForLocalFileTime(FILETIME*) const;
+    bool fileCreationTime(const QString &fileName, FILETIME*) const;
+
+    // These functions only work on files existing on the device
+    bool copyFile(const QString&, const QString&, bool failIfExists = false);
+    bool copyDirectory(const QString&, const QString&, bool recursive = true);
+    bool deleteFile(const QString&);
+    bool deleteDirectory(const QString&, bool recursive = true, bool failIfContentExists = false);
+    bool moveFile(const QString&, const QString&, bool FailIfExists = false);
+    bool moveDirectory(const QString&, const QString&, bool recursive = true);
+
+    bool createDirectory(const QString&, bool deleteBefore=false);
+
+    bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL);
+private:
+    bool connected;
+};
+
+#endif
diff --git a/tools/qtestlib/wince/cetest/cetest.pro b/tools/qtestlib/wince/cetest/cetest.pro
index d66fa33..c6eba7f 100644
--- a/tools/qtestlib/wince/cetest/cetest.pro
+++ b/tools/qtestlib/wince/cetest/cetest.pro
@@ -28,20 +28,27 @@ DEPENDPATH += $$QT_BUILD_TREE/src/corelib/tools $$QT_BUILD_TREE/src/corelib/io
 # Input
 HEADERS += \
         remoteconnection.h \
-        activesyncconnection.h \
         deployment.h
 
 SOURCES += \
         remoteconnection.cpp \
-        activesyncconnection.cpp \
         deployment.cpp \
         main.cpp
 
-win32-msvc*:LIBS += ole32.lib advapi32.lib rapi.lib
+win32-msvc*:LIBS += ole32.lib advapi32.lib
+
+isEmpty(QT_CE_RAPI_INC) {
+    DEFINES += QT_CETEST_NO_ACTIVESYNC
+    HEADERS += cetcpsyncconnection.h
+    SOURCES += cetcpsyncconnection.cpp
+} else {
+    HEADERS += activesyncconnection.h
+    SOURCES += activesyncconnection.cpp
+    win32-msvc*:LIBS += rapi.lib
+    INCLUDEPATH += $$QT_CE_RAPI_INC
+    LIBS += -L$$QT_CE_RAPI_LIB
+}
 
 include(qmake_include.pri)
 include(bootstrapped.pri)
 include($$QT_SOURCE_TREE/src/script/script.pri)
-
-INCLUDEPATH += $$QT_CE_RAPI_INC
-LIBS += -L$$QT_CE_RAPI_LIB
diff --git a/tools/qtestlib/wince/cetest/deployment.cpp b/tools/qtestlib/wince/cetest/deployment.cpp
index 68f0197..c64ae26 100644
--- a/tools/qtestlib/wince/cetest/deployment.cpp
+++ b/tools/qtestlib/wince/cetest/deployment.cpp
@@ -168,6 +168,7 @@ void DeploymentHandler::initQtDeploy(QMakeProject *project, DeploymentList &depl
         }
     }
 
+#ifndef QT_CETEST_NO_ACTIVESYNC
     // QtRemote deployment. We always deploy to \Windows
     if (!project->values("QMAKE_LIBDIR").isEmpty()) {
         QString remoteLibName = QLatin1String("QtRemote.dll");
@@ -177,6 +178,7 @@ void DeploymentHandler::initQtDeploy(QMakeProject *project, DeploymentList &depl
         else
             debugOutput(QString::fromLatin1("Could not find QtRemote. Might not be able to launch target executable"),0);
     }
+#endif
 
     // C-runtime deployment
     QString runtime = project->values("QT_CE_C_RUNTIME").join(QLatin1String(" "));
diff --git a/tools/qtestlib/wince/cetest/main.cpp b/tools/qtestlib/wince/cetest/main.cpp
index 782f6d9..e0e475c 100644
--- a/tools/qtestlib/wince/cetest/main.cpp
+++ b/tools/qtestlib/wince/cetest/main.cpp
@@ -39,7 +39,12 @@
 **
 ****************************************************************************/
 
-#include "activesyncconnection.h"
+#ifdef QT_CETEST_NO_ACTIVESYNC
+#   include "cetcpsyncconnection.h"
+#else
+#   include "activesyncconnection.h"
+#endif
+
 #include "deployment.h"
 #include <option.h>
 #include <project.h>
@@ -290,7 +295,11 @@ int main(int argc, char **argv)
     projectDeploymentList.append(CopyItem(TestConfiguration::localExecutable , TestConfiguration::remoteExecutable));
 
     // deploy
+#ifdef QT_CETEST_NO_ACTIVESYNC
+    CeTcpSyncConnection connection;
+#else
     ActiveSyncConnection connection;
+#endif
     if (!connection.connect()) {
         cout << "Error: Could not connect to device!" << endl;
         return -1;
-- 
cgit v0.12


From ad8247fcbe7d7e3e3c0227d54f6abc2ef6160f9b Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Wed, 5 Aug 2009 11:33:22 +0200
Subject: initial revision of cetcpsyncserver

cetcpsync is our simple ActiveSync replacement for Windows CE devices.
This is the server which has to run on the device.

Reviewed-By: mauricek
---
 .../wince/cetcpsyncserver/cetcpsyncserver.pro      |  17 +
 tools/qtestlib/wince/cetcpsyncserver/commands.cpp  | 646 +++++++++++++++++++++
 tools/qtestlib/wince/cetcpsyncserver/commands.h    | 292 ++++++++++
 .../wince/cetcpsyncserver/connectionmanager.cpp    | 138 +++++
 .../wince/cetcpsyncserver/connectionmanager.h      |  83 +++
 tools/qtestlib/wince/cetcpsyncserver/main.cpp      |  63 ++
 .../wince/cetcpsyncserver/transfer_global.h        | 159 +++++
 7 files changed, 1398 insertions(+)
 create mode 100644 tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro
 create mode 100644 tools/qtestlib/wince/cetcpsyncserver/commands.cpp
 create mode 100644 tools/qtestlib/wince/cetcpsyncserver/commands.h
 create mode 100644 tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp
 create mode 100644 tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h
 create mode 100644 tools/qtestlib/wince/cetcpsyncserver/main.cpp
 create mode 100644 tools/qtestlib/wince/cetcpsyncserver/transfer_global.h

diff --git a/tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro b/tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro
new file mode 100644
index 0000000..bd01d2d
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+TARGET = cetcpsyncsvr
+DEPENDPATH += .
+QT -= gui
+QT += network
+
+CONFIG += console
+
+HEADERS +=  \
+            connectionmanager.h \
+            commands.h \
+            transfer_global.h
+
+SOURCES +=  \
+            connectionmanager.cpp \
+            commands.cpp \
+            main.cpp
diff --git a/tools/qtestlib/wince/cetcpsyncserver/commands.cpp b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp
new file mode 100644
index 0000000..64869c4
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp
@@ -0,0 +1,646 @@
+#include "commands.h"
+#include <QtCore/QDebug>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
+#include <QtCore/QProcess>
+
+#ifdef Q_OS_WINCE
+#include <windows.h>
+#endif
+
+/////////////////////////////////////////////////////
+//       Abstract Command Implementation           //
+/////////////////////////////////////////////////////
+AbstractCommand::AbstractCommand()
+: m_socket(0)
+{
+}
+
+AbstractCommand::~AbstractCommand()
+{
+}
+
+void AbstractCommand::reportSuccess()
+{
+    m_socket->write(COMMAND_SUCCESS, strlen(COMMAND_SUCCESS));
+    m_socket->waitForBytesWritten();
+}
+
+void AbstractCommand::reportError()
+{
+    m_socket->write(COMMAND_ERROR, strlen(COMMAND_ERROR));
+    m_socket->waitForBytesWritten();
+}
+
+void AbstractCommand::dataReceived(QByteArray&)
+{
+    debugOutput(1, "AbstractCommand::dataReceived NOT SUPPOSED TO BE HERE");
+}
+
+void AbstractCommand::commandFinished()
+{
+    debugOutput(1, "AbstractCommand::commandFinished()NOT SUPPOSED TO BE HERE");
+}
+
+void AbstractCommand::setSocket(QTcpSocket* socket) 
+{
+    debugOutput(0, "AbstractCommand::setSocket()");
+    Q_ASSERT(socket);
+    m_socket = socket;
+    connect(m_socket, SIGNAL(readyRead()), this, SLOT(_readData()));
+    reportSuccess();
+}
+
+QTcpSocket* AbstractCommand::socket() 
+{ 
+    return m_socket; 
+}
+
+void AbstractCommand::_readData()
+{
+    QByteArray arr = m_socket->readAll();
+    dataReceived(arr);
+}
+
+void AbstractCommand::_disconnect()
+{
+}
+
+/////////////////////////////////////////////////////
+//       Create File Command Implementation        //
+/////////////////////////////////////////////////////
+CreateFileCommand::CreateFileCommand()
+: m_dataCount(0)
+{
+    debugOutput(0, "CreateFileCommand::CreateFileCommand");
+    m_options.fileSize= -1;
+}
+
+CreateFileCommand::~CreateFileCommand()
+{
+    debugOutput(0, "CreateFileCommand::~CreateFileCommand");
+    if (m_file.isOpen()) {
+        fprintf(stderr, "****************FILE IS STILL OPENED AND HAVENT FINISHED WRITING**********************\n");
+        fprintf(stderr, "Current: %d Expected: %d\n", m_dataCount , m_options.fileSize);
+        m_file.close();
+    }
+}
+
+void CreateFileCommand::dataReceived(QByteArray &data)
+{
+    bool successful = true;
+    // If we haven't received the options yet
+    if (m_options.fileSize == -1) {
+        CreateFileOptions* opt = (CreateFileOptions*) data.data();
+        memcpy(&m_options , opt , sizeof(CreateFileOptions));
+
+        if (QFileInfo(QString::fromLatin1(m_options.fileName)).exists()) {
+            if (m_options.overwriteExisting) {
+#ifdef Q_OS_WINCE
+                SetFileAttributes(QFileInfo(m_options.fileName).absoluteFilePath().utf16(), FILE_ATTRIBUTE_NORMAL);
+#endif
+                QFile::remove(m_options.fileName);
+            } else
+                successful = false;
+        }
+        m_file.setFileName(QString::fromLatin1(m_options.fileName));
+        if (!m_file.open(QIODevice::WriteOnly))
+            successful = false;
+        else
+            debugOutput(3, QString::fromLatin1("Creating file: %1").arg(m_options.fileName));
+    } else { // write buffer on disc
+        if (!m_file.isOpen())
+            return;
+        m_file.write(data);
+        m_dataCount += data.size();
+        if (m_dataCount >= m_options.fileSize) {
+            // We do not care about more data than announced
+            m_file.close();
+        }
+    }
+    
+    if (successful)
+        reportSuccess();
+    else
+        reportError();
+}
+
+void CreateFileCommand::commandFinished()
+{
+    debugOutput(0, "CreateFileCommand::commandFinished");
+#ifdef Q_OS_WIN
+    // We need to set the file attributes for intelligent time comparisons
+    QString tmpFile = QString::fromLatin1(m_options.fileName);
+    HANDLE handle = CreateFile(tmpFile.utf16(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
+    if (handle != INVALID_HANDLE_VALUE) {
+        SetFileTime(handle, &(m_options.fileTime), NULL, NULL);
+        CloseHandle(handle);
+    }
+    SetFileAttributes(tmpFile.utf16(), m_options.fileAttributes);
+#endif
+}
+
+/////////////////////////////////////////////////////
+//    Create Directory Command Implementation      //
+/////////////////////////////////////////////////////
+CreateDirectoryCommand::CreateDirectoryCommand()
+        : AbstractCommand()
+{
+    debugOutput(0, "CreateDirectoryCommand::CreateDirectoryCommand");
+}
+
+CreateDirectoryCommand::~CreateDirectoryCommand()
+{
+    debugOutput(0, "CreateDirectoryCommand::~CreateDirectoryCommand()");
+}
+
+void CreateDirectoryCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "CreateDirectoryCommand::dataReceived()");
+    CreateDirectoryOptions* options = (CreateDirectoryOptions*) data.data();
+    debugOutput(3, QString::fromLatin1("Creating directory: %1").arg(options->dirName));
+    bool success = true;
+    QDir dir;
+    if (options->recursively)
+        success = dir.mkpath(options->dirName);
+    else
+        success = dir.mkdir(options->dirName);
+    
+    if (success)
+        reportSuccess();
+    else
+        reportError();
+}
+
+void CreateDirectoryCommand::commandFinished()
+{
+    debugOutput(0, "CreateDirectoryCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+//        Copy File Command Implementation         //
+/////////////////////////////////////////////////////
+CopyFileCommand::CopyFileCommand()
+        : AbstractCommand()
+{
+    debugOutput(0, "CopyFileCommand::CopyFileCommand()");
+}
+
+CopyFileCommand::~CopyFileCommand()
+{
+    debugOutput(0, "CopyFileCommand::~CopyFileCommand()");
+}
+
+void CopyFileCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "CopyFileCommand::dataReceived()");
+    CopyFileOptions* options = (CopyFileOptions*) data.data();
+    debugOutput(3, QString::fromLatin1("Copy File: %1 ->  %2").arg(options->from).arg(options->to));
+    bool success = true;
+    if (QFileInfo(options->to).exists()) {
+        if (options->overwriteExisting)
+            QFile::remove(options->to);
+        else
+            success = false;
+    }
+    if (success)
+        if (!QFile::copy(options->from , options->to))
+            success = false;
+    
+    if (success)
+        reportSuccess();
+    else
+        reportError();
+}
+
+void CopyFileCommand::commandFinished()
+{
+    debugOutput(0, "CopyFileCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+//      Copy Directory Command Implementation      //
+/////////////////////////////////////////////////////
+CopyDirectoryCommand::CopyDirectoryCommand()
+        : AbstractCommand()
+{
+    debugOutput(0, "CopyDirectoryCommand::CopyDirectoryCommand()");
+}
+
+CopyDirectoryCommand::~CopyDirectoryCommand()
+{
+    debugOutput(0, "CopyDirectoryCommand::~CopyDirectoryCommand()");
+}
+
+void CopyDirectoryCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "CopyDirectoryCommand::dataReceived()");
+    CopyDirectoryOptions* options = (CopyDirectoryOptions*) data.data();
+    debugOutput(3, QString::fromLatin1("Copy Directory: %1 %2").arg(options->from).arg(options->to));
+    if (copyDir(QLatin1String(options->from) , QLatin1String(options->to) , options->recursive))
+        reportSuccess();
+    else
+        reportError();
+}
+
+void CopyDirectoryCommand::commandFinished()
+{
+    debugOutput(0, "CopyDirectoryCommand::commandFinished()");
+}
+
+bool CopyDirectoryCommand::copyDir(const QString &from, const QString &to, bool recursive)
+{
+    QDir().mkpath(to);
+    QDir sourceDir(from);
+    QDir destDir(to);
+    QStringList entries = sourceDir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
+    foreach (QString item , entries) {
+        QString itemFrom = sourceDir.absoluteFilePath(item);
+        QString itemTo = destDir.absoluteFilePath(item);
+        if (QFileInfo(item).isDir()) {
+            if (recursive && !copyDir(itemFrom, itemTo, recursive))
+                return false;
+        } else {
+            if (!QFile::copy(itemFrom, itemTo))
+                return false;
+        }
+    }
+    return true;
+}
+
+/////////////////////////////////////////////////////
+//        Delete File Command Implementation       //
+/////////////////////////////////////////////////////
+DeleteFileCommand::DeleteFileCommand()
+        : AbstractCommand()
+{
+    debugOutput(0, "DeleteFileCommand::DeleteFileCommand()");
+}
+
+DeleteFileCommand::~DeleteFileCommand()
+{
+    debugOutput(0, "DeleteFileCommand::~DeleteFileCommand()");
+}
+
+void DeleteFileCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "DeleteFileCommand::dataReceived()");
+    DeleteFileOptions* options = (DeleteFileOptions*) data.data();
+    debugOutput(3, QString::fromLatin1("Delete File: %1").arg(options->fileName));
+    bool success = true;
+    QFile file(options->fileName);
+    if (file.exists()) {
+#ifdef Q_OS_WINCE
+        SetFileAttributes(QFileInfo(options->fileName).absoluteFilePath().utf16(), FILE_ATTRIBUTE_NORMAL);
+#endif
+        success = file.remove();
+    } else
+        success = false;
+
+    if (success)
+        reportSuccess();
+    else
+        reportError();
+}
+
+void DeleteFileCommand::commandFinished()
+{
+    debugOutput(0, "DeleteFileCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+//     Delete Directory Command Implementation     //
+/////////////////////////////////////////////////////
+DeleteDirectoryCommand::DeleteDirectoryCommand()
+        : AbstractCommand()
+{
+    debugOutput(0, "DeleteDirectoryCommand::DeleteDirectoryCommand()");
+}
+
+DeleteDirectoryCommand::~DeleteDirectoryCommand()
+{
+    debugOutput(0, "DeleteDirectoryCommand::~DeleteDirectoryCommand()");
+}
+
+void DeleteDirectoryCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "DeleteDirectoryCommand::dataReceived()");
+    DeleteDirectoryOptions* options = (DeleteDirectoryOptions*) data.data();
+    debugOutput(3, QString::fromLatin1("Delete directory: %1").arg(options->dirName));
+    if (deleteDirectory(QLatin1String(options->dirName), options->recursive, options->failIfContentExists))
+        reportSuccess();
+    else
+        reportError();
+}
+
+void DeleteDirectoryCommand::commandFinished()
+{
+    debugOutput(0, "DeleteDirectoryCommand::commandFinished()");
+}
+
+bool DeleteDirectoryCommand::deleteDirectory(const QString &dirName, bool recursive, bool failIfContentExists)
+{
+    QDir dir(dirName);
+    if (!dir.exists())
+        return false;
+
+    QStringList itemList = dir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+    if (itemList.size() > 0 && failIfContentExists)
+        return false;
+
+    foreach (QString item, itemList) {
+        QString itemName = dir.absoluteFilePath(item);
+        if (QFileInfo(itemName).isDir()) {
+            if (recursive && !deleteDirectory(itemName, recursive, failIfContentExists))
+                return false;
+        } else {
+            if (!dir.remove(item))
+                return false;
+        }
+    }
+    QString lastName = dir.dirName();
+    dir.cdUp();
+    dir.rmpath(lastName);
+    return true;
+}
+
+/////////////////////////////////////////////////////
+//         Execute Command Implementation          //
+/////////////////////////////////////////////////////
+ExecuteCommand::ExecuteCommand()
+        : AbstractCommand()
+        , m_argumentCount(0)
+        , m_timeout(-1)
+{
+    debugOutput(0, "ExecuteCommand::ExecuteCommand()");
+}
+
+ExecuteCommand::~ExecuteCommand()
+{
+    debugOutput(0, "ExecuteCommand::~ExecuteCommand()");
+}
+
+void ExecuteCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "ExecuteCommand::dataReceived()");
+    
+    if (m_argumentCount == 0) {
+        ExecuteOptions* options = (ExecuteOptions*) data.data();
+        if (!QFileInfo(options->appName).exists()) {
+            debugOutput(1, "Error execute: application does not exist");
+            reportError();
+            return;
+        }
+    
+        m_program = QLatin1String(options->appName);
+        m_argumentCount = options->argumentsCount;
+        m_waitFinished = options->waitForFinished;
+        m_timeout = options->timeout;
+        if (m_argumentCount == 0)
+            m_argumentCount = -1; // to trigger startup on next receive
+        reportSuccess();
+    } else if (m_arguments.size() < m_argumentCount) {
+        m_arguments += data;
+        reportSuccess();
+    } else { // do the execution
+        if (data == COMMAND_SUCCESS)
+            _doExecute();
+    }
+}
+
+void ExecuteCommand::_doExecute()
+{
+    debugOutput(0, "ExecuteCommand::_doExecute()");
+    debugOutput(3, QString::fromLatin1("Execute: %1 %2").arg(m_program).arg(m_arguments.join(" ")));
+    if (m_waitFinished) {
+        QProcess process;
+        process.start(m_program, m_arguments);
+        if (process.waitForFinished(m_timeout) == false || process.exitCode() < 0)
+            reportError();
+        else
+            reportSuccess();
+    } else {
+        if (QProcess::startDetached(m_program, m_arguments))
+            reportSuccess();
+        else
+            reportError();
+    }
+}
+void ExecuteCommand::commandFinished()
+{
+    debugOutput(0,"ExecuteCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+//           Read File Implementation              //
+/////////////////////////////////////////////////////
+ReadFileCommand::ReadFileCommand()
+        : AbstractCommand()
+        , m_currentPos(0)
+{
+    debugOutput(0, "ReadFileCommand::ReadFileCommand()");
+    m_fileName.clear();
+}
+
+ReadFileCommand::~ReadFileCommand()
+{
+    debugOutput(0, "ReadFileCommand::~ReadFileCommand()");
+    if (m_file.isOpen())
+        m_file.close();
+}
+
+void ReadFileCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "ReadFileCommand::dataReceived()");
+    if (m_fileName.isEmpty()) {
+        ReadFileOptions* option = (ReadFileOptions*) data.data();
+        m_fileName = QLatin1String(option->fileName);
+        QFileInfo info(m_fileName);
+        m_file.setFileName(m_fileName);
+        ReadFileReply reply;
+        if (!info.exists() || !info.isFile() || !m_file.open(QIODevice::ReadOnly))
+            reply.fileValid = false;
+        else
+            reply.fileValid = true;
+        reply.fileSize = info.size();
+        m_fileSize = reply.fileSize;
+        socket()->write((char*) &reply, sizeof(reply));
+        debugOutput(3, QString::fromLatin1("Reading file: %1").arg(m_fileName));
+    } else {
+        QTcpSocket* sock = socket(); // design failure???
+        if (data != COMMAND_SUCCESS || m_currentPos >= m_fileSize) {
+            sock->disconnectFromHost();
+            return;
+        }
+        const int bufferSize = 1024;
+        QByteArray buffer = m_file.read(bufferSize);
+        m_currentPos += buffer.size();
+        sock->write(buffer);
+        sock->waitForBytesWritten();
+    }
+}
+
+void ReadFileCommand::commandFinished()
+{
+    debugOutput(0, "ReadFileCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+//        Read Directory Implementation            //
+/////////////////////////////////////////////////////
+ReadDirectoryCommand::ReadDirectoryCommand()
+        : AbstractCommand()
+        , m_iterator(0)
+{
+    debugOutput(0, "ReadDirectoryCommand::ReadDirectoryCommand");
+    m_dirName.clear();
+}
+
+ReadDirectoryCommand::~ReadDirectoryCommand()
+{
+    debugOutput(0, "ReadDirectoryCommand::~ReadDirectoryCommand()");
+    delete m_iterator;
+}
+
+void ReadDirectoryCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "ReadDirectoryCommand::dataReceived()");
+    QTcpSocket* sock = socket();
+    if (m_dirName.isEmpty()) {
+        ReadDirectoryOptions* option = (ReadDirectoryOptions*) data.data();
+        QFileInfo info(QLatin1String(option->dirName));
+        debugOutput(3, QString::fromLatin1("Reading Directory entries: %1").arg(option->dirName));
+        ReadDirectoryReply reply;
+        if (!info.exists() || !info.isDir()) {
+            reply.itemCount = -1;
+            reply.entryValid = false;
+        } else {
+            m_dirName = QLatin1String(option->dirName);
+            m_dir.setPath(m_dirName);
+            m_iterator = new QDirIterator(m_dir);
+            reply.itemCount = m_dir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot).size();
+            reply.entryValid = true;
+        }
+        sock->write((char*) &reply, sizeof(reply));
+        sock->waitForBytesWritten();
+    } else {
+        if (data != COMMAND_SUCCESS) {
+            qDebug() << "Something went wrong in the meantime";
+            return;
+        }
+        ReadDirectoryItem reply;
+        if (m_iterator->hasNext()) {
+            m_iterator->next();
+            QFileInfo info = m_iterator->fileInfo();
+            strcpy(reply.name, qPrintable(info.absoluteFilePath()));
+            reply.isDirectory = info.isDir();
+            if (!reply.isDirectory)
+                reply.size = info.size();
+        }
+        reply.hasMore = m_iterator->hasNext();
+        sock->write((char*) &reply, sizeof(reply));
+        sock->waitForBytesWritten();
+    }
+}
+
+void ReadDirectoryCommand::commandFinished()
+{
+    debugOutput(0, "ReadDirectoryCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+//           File Time Implementation              //
+/////////////////////////////////////////////////////
+FileTimeCommand::FileTimeCommand()
+        : AbstractCommand()
+{
+    debugOutput(0, "FileTimeCommand::FileTimeCommand()");
+}
+
+FileTimeCommand::~FileTimeCommand()
+{
+    debugOutput(0, "FileTimeCommand::~FileTimeCommand()");
+}
+
+void FileTimeCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "FileTimeCommand::dataReceived()");
+    FileTimeOptions* option = (FileTimeOptions*) data.data();
+
+    FILETIME resultTime;
+    resultTime.dwLowDateTime = -1;
+    resultTime.dwHighDateTime = -1;
+    
+#ifdef Q_OS_WIN
+    QString fileName = QLatin1String(option->fileName);
+    HANDLE deviceHandle = CreateFile(fileName.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
+    debugOutput(3, QString::fromLatin1("Asking FileTime: %1").arg(fileName));
+    if (deviceHandle != INVALID_HANDLE_VALUE) {
+        FILETIME deviceCreationTime;
+        if (GetFileTime(deviceHandle, &deviceCreationTime, NULL, NULL)) {
+            resultTime = deviceCreationTime;
+        }
+        CloseHandle(deviceHandle);
+    }
+#endif
+    QTcpSocket* sock = socket();
+    sock->write((char*) &resultTime, sizeof(resultTime));
+    sock->waitForBytesWritten();
+}
+
+void FileTimeCommand::commandFinished()
+{
+    debugOutput(0, "FileTimeCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+//           Time Stamp Implementation             //
+/////////////////////////////////////////////////////
+TimeStampCommand::TimeStampCommand()
+        : AbstractCommand()
+{
+    debugOutput(0, "TimeStampCommand::TimeStampCommand()");
+}
+
+TimeStampCommand::~TimeStampCommand()
+{
+    debugOutput(0, "TimeStampCommand::~TimeStampCommand()");
+}
+
+void TimeStampCommand::dataReceived(QByteArray &data)
+{
+    debugOutput(0, "TimeStampCommand::dataReceived()");
+    FILETIME resultTime;
+    resultTime.dwLowDateTime = -1;
+    resultTime.dwHighDateTime = -1;
+    
+#ifdef Q_OS_WIN
+    FILETIME stampTime = *((FILETIME*)data.data());
+    
+    QString tmpFile = QString::fromLatin1("\\qt_tmp_ftime_convert");
+    HANDLE remoteHandle = CreateFile(tmpFile.utf16(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+    if (remoteHandle != INVALID_HANDLE_VALUE) {
+        if (!SetFileTime(remoteHandle, &stampTime, NULL, NULL)) {
+            CloseHandle(remoteHandle);
+        } else {
+            CloseHandle(remoteHandle);
+            remoteHandle = CreateFile(tmpFile.utf16(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
+            if (remoteHandle != INVALID_HANDLE_VALUE) {
+                if (GetFileTime(remoteHandle, &stampTime, NULL, NULL))
+                    resultTime = stampTime;
+                CloseHandle(remoteHandle);
+                DeleteFile(tmpFile.utf16());
+            }
+        }
+    }
+    debugOutput(3, QString::fromLatin1("Asking TimeStamp"));
+#endif
+    QTcpSocket* sock = socket();
+    sock->write((char*) &resultTime, sizeof(resultTime));
+    sock->waitForBytesWritten();
+}
+
+void TimeStampCommand::commandFinished()
+{
+    debugOutput(0, "TimeStampCommand::commandFinished()");
+}
diff --git a/tools/qtestlib/wince/cetcpsyncserver/commands.h b/tools/qtestlib/wince/cetcpsyncserver/commands.h
new file mode 100644
index 0000000..356c1aa
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/commands.h
@@ -0,0 +1,292 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef COMMANDS_INCL
+#define COMMANDS_INCL
+
+#include "transfer_global.h"
+
+#include <QtNetwork/QTcpSocket>
+#include <QtCore/QString>
+#include <QtCore/QFile>
+#include <QtCore/QDir>
+#include <QtCore/QDirIterator>
+#include <windows.h>
+
+// debug output
+#define DEBUG_LEVEL 2
+inline void debugOutput(int level, const char* text)
+{
+    if (level >= DEBUG_LEVEL)
+        qDebug() << text;
+}
+
+inline void debugOutput(int level, const QString &text)
+{
+    if (level >= DEBUG_LEVEL)
+        qDebug() << text;
+}
+// Basic abtract command class
+class AbstractCommand : public QObject
+{
+    Q_OBJECT
+public:
+    AbstractCommand();
+    virtual ~AbstractCommand();
+
+    void setSocket(QTcpSocket*);
+    QTcpSocket* socket();
+
+    void reportSuccess();
+    void reportError();
+
+public slots:
+    virtual void dataReceived(QByteArray&);
+    virtual void commandFinished();
+
+private slots:
+    void _readData();
+    void _disconnect();
+
+private:
+    QTcpSocket* m_socket;
+};
+
+// File Creation class
+class CreateFileCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    CreateFileCommand();
+    ~CreateFileCommand();
+
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+
+private:
+    CreateFileOptions m_options;
+    QFile m_file;
+    int m_dataCount;
+};
+
+inline AbstractCommand* instCreateFile() { return new CreateFileCommand(); }
+
+// Directory Creation class
+class CreateDirectoryCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    CreateDirectoryCommand();
+    ~CreateDirectoryCommand();
+    
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+};
+inline AbstractCommand* instCreateDirectory() { return new CreateDirectoryCommand(); }
+
+// File copy class
+class CopyFileCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    CopyFileCommand();
+    ~CopyFileCommand();
+    
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+};
+inline AbstractCommand* instCopyFile() { return new CopyFileCommand(); }
+
+// Copy directory class
+class CopyDirectoryCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    CopyDirectoryCommand();
+    ~CopyDirectoryCommand();
+
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+private:
+    bool copyDir(const QString &from, const QString &to, bool recursive);
+};
+inline AbstractCommand* instCopyDirectory() { return new CopyDirectoryCommand(); }
+
+// Delete File class
+class DeleteFileCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    DeleteFileCommand();
+    ~DeleteFileCommand();
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+};
+inline AbstractCommand* instDeleteFile() { return new DeleteFileCommand(); }
+
+// Delete Directory class
+class DeleteDirectoryCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    DeleteDirectoryCommand();
+    ~DeleteDirectoryCommand();
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+private:
+    bool deleteDirectory(const QString &dirName, bool recursive, bool failIfContentExists);
+};
+inline AbstractCommand* instDeleteDirectory() { return new DeleteDirectoryCommand(); }
+
+// Execute application class
+class ExecuteCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    ExecuteCommand();
+    ~ExecuteCommand();
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+private:
+    void _doExecute();
+    QString m_program;
+    QStringList m_arguments;
+    int m_argumentCount;
+    bool m_waitFinished;
+    int m_timeout;
+};
+inline AbstractCommand* instExecution() { return new ExecuteCommand(); }
+
+// Read File class
+class ReadFileCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    ReadFileCommand();
+    ~ReadFileCommand();
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+private:
+    QString m_fileName;
+    QFile m_file;
+    qint64 m_currentPos;
+    qint64 m_fileSize;
+};
+inline AbstractCommand* instReadFile() { return new ReadFileCommand(); }
+
+// Read Directory class
+class ReadDirectoryCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    ReadDirectoryCommand();
+    ~ReadDirectoryCommand();
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+private:
+    QString m_dirName;
+    QDir m_dir;
+    QDirIterator* m_iterator;
+};
+inline AbstractCommand* instReadDirectory() { return new ReadDirectoryCommand(); }
+
+// Read File Time class
+class FileTimeCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    FileTimeCommand();
+    ~FileTimeCommand();
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+};
+inline AbstractCommand* instFileTime() { return new FileTimeCommand(); }
+
+// Time stamp class
+class TimeStampCommand : public AbstractCommand
+{
+    Q_OBJECT
+public:
+    TimeStampCommand();
+    ~TimeStampCommand();
+public slots:
+    void dataReceived(QByteArray&);
+    void commandFinished();
+};
+inline AbstractCommand* instTimeStamp() { return new TimeStampCommand(); }
+
+// Access part
+typedef AbstractCommand* (*instantiator)();
+
+struct CommandInfo
+{
+    CommandInfo(const QString &name, instantiator func) : commandName(name) , commandFunc(func) { }
+    QString commandName;
+    instantiator commandFunc;
+};
+
+inline QList<CommandInfo> availableCommands()
+{
+    QList<CommandInfo> list;
+    list.append(CommandInfo(QLatin1String(COMMAND_CREATE_FILE), instCreateFile));
+    list.append(CommandInfo(QLatin1String(COMMAND_CREATE_DIRECTORY), instCreateDirectory));
+    list.append(CommandInfo(QLatin1String(COMMAND_COPY_FILE), instCopyFile));
+    list.append(CommandInfo(QLatin1String(COMMAND_COPY_DIRECTORY), instCopyDirectory));
+    list.append(CommandInfo(QLatin1String(COMMAND_DELETE_FILE), instDeleteFile));
+    list.append(CommandInfo(QLatin1String(COMMAND_DELETE_DIRECTORY), instDeleteDirectory));
+    list.append(CommandInfo(QLatin1String(COMMAND_EXECUTE), instExecution));
+    list.append(CommandInfo(QLatin1String(COMMAND_READ_FILE), instReadFile));
+    list.append(CommandInfo(QLatin1String(COMMAND_READ_DIRECTORY), instReadDirectory));
+    list.append(CommandInfo(QLatin1String(COMMAND_FILE_TIME), instFileTime));
+    list.append(CommandInfo(QLatin1String(COMMAND_TIME_STAMP), instTimeStamp));
+    return list;
+}
+
+#endif
diff --git a/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp
new file mode 100644
index 0000000..901cd12
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "connectionmanager.h"
+#include "commands.h"
+#include <QtCore/QDebug>
+
+ConnectionManager::ConnectionManager()
+    : QObject()
+    , m_server(0)
+{
+    debugOutput(0, "ConnectionManager::ConnectionManager()");
+}
+
+ConnectionManager::~ConnectionManager()
+{
+    debugOutput(0, "ConnectionManager::~ConnectionManager()");
+    cleanUp();
+}
+
+bool ConnectionManager::init()
+{
+    debugOutput(0, "ConnectionManager::init()");
+    debugOutput(3, "Initializing server...");
+    cleanUp();
+    m_server = new QTcpServer(this);
+    connect(m_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
+    bool result = m_server->listen(QHostAddress::Any, SERVER_PORT);
+    if (!result)
+        debugOutput(3, QString::fromLatin1("   Error: Server start failed:") + m_server->errorString());
+    debugOutput(3, "   Waiting for action");
+    return result;
+}
+
+void ConnectionManager::cleanUp()
+{
+    debugOutput(0, "ConnectionManager::cleanUp()");
+
+    if (m_server) {
+        debugOutput(1, "Removing server instance...");
+        disconnect(m_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
+        delete m_server;
+        m_server = 0;
+    }
+}
+
+void ConnectionManager::newConnection()
+{
+    debugOutput(0, "ConnectionManager::newConnection()");
+
+    QTcpSocket* connection = m_server->nextPendingConnection();
+    if (!connection) {
+        debugOutput(3, "Received connection has empty socket");
+        return;
+    }
+    debugOutput(0, QString::fromLatin1("   received a connection: %1").arg((int) connection));
+    new Connection(connection);
+}
+
+Connection::Connection(QTcpSocket *socket)
+        : QObject()
+        , m_connection(socket)
+        , m_command(0)
+{
+    connect(m_connection, SIGNAL(readyRead()), this, SLOT(receiveCommand()));
+    connect(m_connection, SIGNAL(disconnected()), this, SLOT(closedConnection()));
+}
+
+Connection::~Connection()
+{
+    if (m_command) {
+        m_command->commandFinished();
+        delete m_command;
+        m_command = 0;
+    }
+    delete m_connection;
+}
+
+void Connection::receiveCommand()
+{
+    QByteArray arr = m_connection->readAll();
+    debugOutput(1, QString::fromLatin1("Command received: ") + (arr));
+    QList<CommandInfo> commands = availableCommands();
+    for(QList<CommandInfo>::iterator it = commands.begin(); it != commands.end(); ++it) {
+        if (it->commandName == QString::fromLatin1(arr)) {
+            debugOutput(1, "Found command in list");
+            disconnect(m_connection, SIGNAL(readyRead()), this, SLOT(receiveCommand()));
+            AbstractCommand* command = (*it).commandFunc();
+            command->setSocket(m_connection);
+            m_command = command;
+            return;
+        }
+    }
+    debugOutput(2, QString::fromLatin1("Unknown command received: ") + (arr));
+}
+
+void Connection::closedConnection()
+{
+    debugOutput(0, "connection being closed...");
+    this->deleteLater();
+}
diff --git a/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h
new file mode 100644
index 0000000..21183ac
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef CONNECTION_MANAGER_INCL
+#define CONNECTION_MANAGER_INCL
+
+#include "transfer_global.h"
+#include "commands.h"
+
+#include <QtNetwork/QTcpServer>
+#include <QtNetwork/QTcpSocket>
+
+class Connection : public QObject
+{
+    Q_OBJECT
+public:
+    Connection(QTcpSocket* socket);
+    ~Connection();
+
+public slots:
+    void receiveCommand();
+    void closedConnection();
+
+private:
+    QTcpSocket* m_connection;
+    AbstractCommand* m_command;
+};
+
+class ConnectionManager : public QObject
+{
+    Q_OBJECT
+public:
+    ConnectionManager();
+    ~ConnectionManager();
+
+    bool init();
+
+public slots:
+    void cleanUp();
+    void newConnection();
+
+private:
+    QTcpServer* m_server;
+};
+
+#endif
diff --git a/tools/qtestlib/wince/cetcpsyncserver/main.cpp b/tools/qtestlib/wince/cetcpsyncserver/main.cpp
new file mode 100644
index 0000000..19d38ea
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "connectionmanager.h"
+
+#include <QtCore>
+#include <QtNetwork>
+
+void messageOutput(QtMsgType type, const char *msg)
+{
+    switch(type) {
+        case QtDebugMsg: fprintf(stderr, "Debug: %s\n", msg); break;
+        case QtWarningMsg: fprintf(stderr, "Warning: %s\n", msg); break;
+        default: fprintf(stderr, "Some Msg: %s\n", msg); break;
+    }
+}
+
+int main(int argc, char **argv)
+{
+    qInstallMsgHandler(messageOutput);
+    
+    QCoreApplication app(argc, argv);
+    ConnectionManager manager;
+    manager.init();
+    return app.exec();
+}
diff --git a/tools/qtestlib/wince/cetcpsyncserver/transfer_global.h b/tools/qtestlib/wince/cetcpsyncserver/transfer_global.h
new file mode 100644
index 0000000..5b6ff23
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/transfer_global.h
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TRANSFER_GLOBAL_H
+#define TRANSFER_GLOBAL_H
+
+#include <QtCore/qglobal.h>
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
+
+#define SERVER_PORT 12145
+
+#define MAX_NAME_LENGTH 512
+#define MAX_ARGUMENTS 10
+
+// Defines for commands sent/received
+#define COMMAND_CREATE_FILE "CREATEFILE"
+#define COMMAND_CREATE_DIRECTORY "CREATEDIR"
+#define COMMAND_COPY_FILE "COPYFILE"
+#define COMMAND_COPY_DIRECTORY "COPYDIR"
+#define COMMAND_DELETE_FILE "DELETEFILE"
+#define COMMAND_DELETE_DIRECTORY "DELETEDIR"
+#define COMMAND_EXECUTE "EXECUTE"
+#define COMMAND_QUIT_SERVER "QUIT"
+#define COMMAND_FILE_TIME "FILETIME"
+#define COMMAND_TIME_STAMP "TIMESTAMP"
+
+// Report back commands
+#define COMMAND_SUCCESS "SUCCESS"
+#define COMMAND_ERROR "ERROR"
+
+// Defines for commands that send data back to requester
+#define COMMAND_READ_FILE "READFILE"
+#define COMMAND_READ_DIRECTORY "READDIR"
+
+#include <QtCore/qglobal.h>
+// Option-Structures for commands
+
+struct CreateFileOptions
+{
+    char fileName[MAX_NAME_LENGTH];
+#ifdef Q_OS_WIN
+    FILETIME fileTime;
+    DWORD fileAttributes;
+#endif
+    int fileSize;
+    bool overwriteExisting;
+};
+
+struct CreateDirectoryOptions
+{
+    char dirName[MAX_NAME_LENGTH];
+    bool recursively; // in case of \foo\bar create \foo if it does not exist
+};
+
+struct CopyFileOptions
+{
+    char from[MAX_NAME_LENGTH];
+    char to[MAX_NAME_LENGTH];
+    bool overwriteExisting;
+};
+
+struct CopyDirectoryOptions
+{
+    char from[MAX_NAME_LENGTH];
+    char to[MAX_NAME_LENGTH];
+    bool recursive;
+};
+
+struct DeleteFileOptions
+{
+    char fileName[MAX_NAME_LENGTH];
+};
+
+struct DeleteDirectoryOptions
+{
+    char dirName[MAX_NAME_LENGTH];
+    bool recursive;
+    bool failIfContentExists;
+};
+
+struct ExecuteOptions
+{
+    char appName[MAX_NAME_LENGTH];
+    int argumentsCount;
+    bool waitForFinished;
+    int timeout;
+};
+
+struct ReadFileOptions
+{
+    char fileName[MAX_NAME_LENGTH];
+};
+
+struct ReadFileReply
+{
+    qint64 fileSize;
+    bool fileValid;
+};
+
+struct ReadDirectoryOptions
+{
+    char dirName[MAX_NAME_LENGTH];
+};
+
+struct ReadDirectoryItem
+{
+    char name[MAX_NAME_LENGTH];
+    qint64 size;
+    bool isDirectory;
+    bool hasMore;
+};
+
+#define FileTimeOptions ReadFileOptions
+
+struct ReadDirectoryReply
+{
+    bool entryValid;
+    int itemCount; // might change during iteration
+};
+#endif
-- 
cgit v0.12


From a34ec3bf9d6077bdc62cb48e116751788996fd99 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Wed, 5 Aug 2009 11:34:48 +0200
Subject: initial revision of cetcpsync

This is the desktop client for communicating with a Windows CE device
that runs the cetcpsync server.

Reviewed-By: mauricek
---
 tools/qtestlib/wince/cetcpsync/cetcpsync.pro       |  22 +
 tools/qtestlib/wince/cetcpsync/main.cpp            | 191 +++++++
 .../wince/cetcpsync/qtcesterconnection.cpp         | 551 +++++++++++++++++++++
 .../qtestlib/wince/cetcpsync/qtcesterconnection.h  |  86 ++++
 .../qtestlib/wince/cetcpsync/remoteconnection.cpp  |  65 +++
 tools/qtestlib/wince/cetcpsync/remoteconnection.h  |  81 +++
 6 files changed, 996 insertions(+)
 create mode 100644 tools/qtestlib/wince/cetcpsync/cetcpsync.pro
 create mode 100644 tools/qtestlib/wince/cetcpsync/main.cpp
 create mode 100644 tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp
 create mode 100644 tools/qtestlib/wince/cetcpsync/qtcesterconnection.h
 create mode 100644 tools/qtestlib/wince/cetcpsync/remoteconnection.cpp
 create mode 100644 tools/qtestlib/wince/cetcpsync/remoteconnection.h

diff --git a/tools/qtestlib/wince/cetcpsync/cetcpsync.pro b/tools/qtestlib/wince/cetcpsync/cetcpsync.pro
new file mode 100644
index 0000000..d1d7c99
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/cetcpsync.pro
@@ -0,0 +1,22 @@
+TARGET   = cetcpsync
+DESTDIR = ../../../../bin
+CONFIG   += console
+CONFIG   -= app_bundle
+QT       += network
+QT       -= gui
+TEMPLATE = app
+
+build_all:!build_pass {
+    CONFIG -= build_all
+    CONFIG += release
+}
+
+INCLUDEPATH += ../cetcpsyncserver
+
+SOURCES += main.cpp \
+           remoteconnection.cpp \
+           qtcesterconnection.cpp
+
+HEADERS += \
+           remoteconnection.h \
+           qtcesterconnection.h
diff --git a/tools/qtestlib/wince/cetcpsync/main.cpp b/tools/qtestlib/wince/cetcpsync/main.cpp
new file mode 100644
index 0000000..73c7350
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/main.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <iostream>
+#include "qtcesterconnection.h"
+
+using namespace std;
+
+static void showUsage()
+{
+    cout    << "cetcpsync is meant to be used by cetest internally." << endl
+            << "For usage instructions remoteconnection.h could be useful." << endl;
+}
+
+const int debugLevel = 0;
+void debugOutput(const QString& text, int level)
+{
+    if (level <= debugLevel)
+        cout << qPrintable(text) << endl;
+}
+
+class Exception
+{
+public:
+    Exception(const QString& msg = QString())
+        : m_message(msg)
+    {}
+
+    QString message() { return m_message; }
+
+protected:
+    QString m_message;
+};
+
+class TooFewParametersException : public Exception
+{
+public:
+    TooFewParametersException(const QLatin1String& cmd, int expectedParameterCount)
+    {
+        m_message = QLatin1String("Command ") + cmd + QLatin1String(" needs at least ");
+        m_message.append(QString::number(expectedParameterCount));
+        m_message.append(QLatin1String(" parameters."));
+    }
+};
+
+static void fileTimeFromString(FILETIME& ft, const QString& str)
+{
+    int idx = str.indexOf("*");
+    if (idx <= 0)
+        return;
+    ft.dwLowDateTime = str.left(idx).toULong();
+    ft.dwHighDateTime = str.mid(idx+1).toULong();
+}
+
+static QString fileTimeToString(FILETIME& ft)
+{
+    return QString::number(ft.dwLowDateTime) + "*" + QString::number(ft.dwHighDateTime);
+}
+
+static int execCommand(const QLatin1String& cmd, int argc, char* argv[])
+{
+    int retval = 0;
+    bool success = true;
+    QtCesterConnection connection;
+    if (cmd == "copyFileToDevice") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        success = connection.copyFileToDevice(argv[0], argv[1], argv[2] == "true");
+    } else if (cmd == "copyDirectoryToDevice") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        success = connection.copyDirectoryToDevice(argv[0], argv[1], argv[2] == "true");
+    } else if (cmd == "copyFileFromDevice") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        success = connection.copyFileFromDevice(argv[0], argv[1], argv[2] == "true");
+    } else if (cmd == "copyDirectoryFromDevice") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        success = connection.copyDirectoryFromDevice(argv[0], argv[1], argv[2] == "true");
+    } else if (cmd == "timeStampForLocalFileTime") {
+        if (argc < 1)
+            throw TooFewParametersException(cmd, 1);
+        FILETIME ft;
+        fileTimeFromString(ft, argv[0]);
+        success = connection.timeStampForLocalFileTime(&ft);
+        if (success)
+            cout << qPrintable(fileTimeToString(ft));
+    } else if (cmd == "fileCreationTime") {
+        if (argc < 1)
+            throw TooFewParametersException(cmd, 1);
+        FILETIME ft;
+        success = connection.fileCreationTime(argv[0], &ft);
+        if (success)
+            cout << qPrintable(fileTimeToString(ft));
+    } else if (cmd == "copyFile") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        success = connection.copyFile(argv[0], argv[1], argv[2] == "true");
+    } else if (cmd == "copyDirectory") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        success = connection.copyDirectory(argv[0], argv[1], argv[2] == "true");
+    } else if (cmd == "deleteFile") {
+        if (argc < 1)
+            throw TooFewParametersException(cmd, 1);
+        success = connection.deleteFile(argv[0]);
+    } else if (cmd == "deleteDirectory") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        success = connection.deleteDirectory(argv[0], argv[1] == "true", argv[2] == "true");
+    } else if (cmd == "moveFile") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        success = connection.moveFile(argv[0], argv[1], argv[2] == "true");
+    } else if (cmd == "moveDirectory") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        success = connection.moveDirectory(argv[0], argv[1], argv[2] == "true");
+    } else if (cmd == "createDirectory") {
+        if (argc < 2)
+            throw TooFewParametersException(cmd, 2);
+        success = connection.createDirectory(argv[0], argv[1] == "true");
+    } else if (cmd == "execute") {
+        if (argc < 3)
+            throw TooFewParametersException(cmd, 3);
+        int timeout = QString(argv[2]).toInt();
+        success = connection.execute(argv[0], argv[1], timeout, &retval);
+    } else if (cmd == "noop") {
+        // do nothing :)
+        success = true;
+    } else {
+        throw Exception("unknown command");
+    }
+
+    return success ? retval : 1;
+}
+
+int main(int argc, char *argv[])
+{
+    if (argc <= 1) {
+        showUsage();
+        return 0;
+    }
+
+    QLatin1String param(argv[1]);
+    int result = 1;
+    try {
+        result = execCommand(param, argc - 2, argv + 2);
+    } catch (Exception e) {
+        cerr << "Error: " << qPrintable(e.message());
+    }
+    return result;
+}
diff --git a/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp
new file mode 100644
index 0000000..4a8ae2b
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp
@@ -0,0 +1,551 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qtcesterconnection.h"
+#include <transfer_global.h>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QtNetwork/QTcpSocket>
+#include <QtNetwork/QHostAddress>
+
+extern void debugOutput(const QString& text, int level);
+
+#pragma warning(disable:4996)
+
+#define END_ERROR(s, a) \
+            if(a) qDebug() << a; \
+            _freeSocket(s); \
+            return false;
+
+QtCesterConnection::QtCesterConnection()
+        : AbstractRemoteConnection()
+{
+}
+
+QtCesterConnection::~QtCesterConnection()
+{
+}
+
+bool QtCesterConnection::connect(QVariantList&)
+{
+    // We connect with each command, so this is always true
+    // The command itself will fail then
+    connected = true;
+    return true;
+}
+
+void QtCesterConnection::disconnect()
+{
+    connected = false;
+}
+
+bool QtCesterConnection::isConnected() const
+{
+    return connected;
+}
+
+bool QtCesterConnection::copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists)
+{
+    debugOutput( qPrintable(QString::fromLatin1("Copy File: %1 -> %2").arg(localSource).arg(deviceDest)),0);
+    QFile localFile(localSource);
+    QFileInfo info(localSource);
+    if (!localFile.exists() || !localFile.open(QIODevice::ReadOnly)) {
+        qDebug() << "Could not open File!";
+        return false;
+    }
+    
+    QTcpSocket* socket = 0;
+    if (!_initCommand(socket, COMMAND_CREATE_FILE)) {
+        END_ERROR(socket, "Could not initialized command");
+    }
+    
+    CreateFileOptions option;
+    strcpy(option.fileName, qPrintable(deviceDest));
+#ifdef Q_OS_WIN
+    // Copy FileTime for update verification
+    FILETIME creationTime, accessTime, writeTime;
+    HANDLE localHandle = CreateFile(localSource.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
+    if (localHandle != INVALID_HANDLE_VALUE) {
+        if (GetFileTime(localHandle, &creationTime, &accessTime, &writeTime)) {
+            LocalFileTimeToFileTime(&writeTime, &writeTime);
+            option.fileTime = writeTime;
+        }
+        CloseHandle(localHandle);
+    }
+    DWORD attributes = GetFileAttributes(localSource.utf16());
+    if (attributes != -1 )
+        option.fileAttributes = attributes;
+#endif
+    option.fileSize = info.size();
+    option.overwriteExisting = !failIfExists;
+    
+    if (!_sendData(socket, (char*) &option, sizeof(option))) {
+        END_ERROR(socket, "Could not send options...");
+    }
+
+    if (!_checkResult(socket)) {
+        END_ERROR(socket, "Server did not accept configuration");
+    }
+    
+    int bytesWritten = 0;
+    const int bufferSize = 1024;
+    QByteArray data;
+    while (bytesWritten < option.fileSize) {
+        data = localFile.read(bufferSize);
+        bytesWritten += data.size();
+#ifdef Q_OS_WIN
+        wprintf( L"%s -> %s (%d / %d) %d %%\r", localSource.utf16() , deviceDest.utf16(),
+                 bytesWritten , option.fileSize, (100*bytesWritten)/option.fileSize );
+#endif
+        if (!_sendData(socket, data.constData(), data.size())) {
+            END_ERROR(socket, "Error during file transfer");
+        }
+        if (!_checkResult(socket)) {
+            END_ERROR(socket, "Got some strange result");
+        }
+    }
+#ifdef Q_OS_WIN
+    wprintf( L"\n"); // We should jump to next line...
+#endif
+    if (bytesWritten != option.fileSize) {
+        END_ERROR(socket, "Did not send sufficient data");
+    }
+    _freeSocket(socket);
+    return true;
+}
+
+bool QtCesterConnection::copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive)
+{
+    QTcpSocket* socket = NULL;
+    QFileInfo info(localSource);
+    if (!info.exists() || !info.isDir()) {
+        END_ERROR(socket, "Input directory invalid");
+    }
+    
+    createDirectory(deviceDest, true);
+    QDir dir(localSource);
+    QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+    foreach(QFileInfo item, list) {
+        QString targetName = deviceDest + QLatin1String("\\") + item.fileName();
+        if (item.isDir()) {
+            if (recursive) {
+                if (!copyDirectoryToDevice(item.absoluteFilePath() , targetName, recursive))
+                    return false;
+            }
+        } else {
+            if (!copyFileToDevice(item.absoluteFilePath(), targetName))
+                return false;
+        }
+    }
+    return true;
+}
+
+bool QtCesterConnection::copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists)
+{
+    QFile targetFile(localDest);
+    QTcpSocket* socket = 0;
+    if (targetFile.exists() && failIfExists) {
+        END_ERROR(socket, "Local file not supposed to be overwritten");
+    }
+    
+    if (!targetFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
+        END_ERROR(socket, "Could not open local file for writing");
+    }
+    
+    if (!_initCommand(socket, COMMAND_READ_FILE)) {
+        END_ERROR(socket, "Could not establish connection");
+    }
+    
+    ReadFileOptions option;
+    strcpy(option.fileName, qPrintable(deviceSource));
+    if (!_sendData(socket, (char*) &option, sizeof(option))) {
+        END_ERROR(socket, "Could not send options");
+    }
+    
+    QByteArray data;
+    if (!_receiveData(socket, data)) {
+        END_ERROR(socket, "Did not receive any data");
+    }
+    
+    ReadFileReply* reply = (ReadFileReply*) data.data();
+    if (!reply->fileValid) {
+        END_ERROR(socket, "Requested file invalid");
+    }
+    
+    int fileSize = reply->fileSize;
+    int currentSize = 0;
+    // ### TODO: make a little bit more error-prone
+    do {
+        _sendData(socket, COMMAND_SUCCESS, strlen(COMMAND_SUCCESS));
+        _receiveData(socket, data);
+        currentSize += data.size();
+        targetFile.write(data);
+    } while(currentSize < fileSize);
+    
+    _freeSocket(socket);
+    targetFile.close();
+    return true;
+}
+ 
+bool QtCesterConnection::copyDirectoryFromDevice(const QString& /*deviceSource*/
+                                                 , const QString& /*localDest*/
+                                                 , bool /*recursive*/)
+{
+    qDebug() << "To be implemented!! Should not be needed for autotest system";
+    exit(-1);
+    return false;
+}
+
+bool QtCesterConnection::copyFile(const QString &srcFile, const QString &destFile, bool failIfExists)
+{
+    QTcpSocket* socket = 0;
+    if (!_initCommand(socket, COMMAND_COPY_FILE)) {
+        END_ERROR(socket, "Could not establish connection for copy");
+    }
+    
+    CopyFileOptions option;
+    strcpy(option.from, qPrintable(srcFile));
+    strcpy(option.to, qPrintable(destFile));
+    option.overwriteExisting = !failIfExists;
+    if (!_sendData(socket, (char*) &option, sizeof(option))) {
+        END_ERROR(socket, "Could not send copy options");
+    }
+    
+    if (!_checkResult(socket)) {
+        END_ERROR(socket, "Copy failed");
+    }
+    
+    _freeSocket(socket);
+    return true;
+}
+
+bool QtCesterConnection::copyDirectory(const QString &srcDirectory, const QString &destDirectory,
+                                      bool recursive)
+{
+    QTcpSocket* socket = 0;
+    if (!_initCommand(socket, COMMAND_COPY_DIRECTORY)) {
+        END_ERROR(socket, "Could not establish connection for dir copy");
+    }
+    
+    CopyDirectoryOptions option;
+    strcpy(option.from, qPrintable(srcDirectory));
+    strcpy(option.to, qPrintable(destDirectory));
+    option.recursive = recursive;
+    if (!_sendData(socket, (char*) &option, sizeof(option))) {
+        END_ERROR(socket, "Could not send dir copy options");
+    }
+    
+    if (!_checkResult(socket)) {
+        END_ERROR(socket, "Dir Copy failed");
+    }
+    
+    _freeSocket(socket);
+    return true;
+}
+
+bool QtCesterConnection::deleteFile(const QString &fileName)
+{
+    QTcpSocket* socket = 0;
+    if (!_initCommand(socket, COMMAND_DELETE_FILE)) {
+        END_ERROR(socket, "Could not establish connection for file deletion");
+    }
+    
+    DeleteFileOptions option;
+    strcpy(option.fileName, qPrintable(fileName));
+    if (!_sendData(socket, (char*) &option, sizeof(option))) {
+        END_ERROR(socket, "Could not send file options");
+    }
+    
+    if (!_checkResult(socket)) {
+        END_ERROR(socket, "File Deletion failed");
+    }
+    
+    _freeSocket(socket);
+    return true;
+}
+
+bool QtCesterConnection::deleteDirectory(const QString &directory, bool recursive, bool failIfContentExists)
+{
+    QTcpSocket* socket = 0;
+    if (!_initCommand(socket, COMMAND_DELETE_DIRECTORY)) {
+        END_ERROR(socket, "Could not establish connection for dir deletion");
+    }
+    
+    DeleteDirectoryOptions option;
+    strcpy(option.dirName, qPrintable(directory));
+    option.recursive = recursive;
+    option.failIfContentExists = failIfContentExists;
+    if (!_sendData(socket, (char*) &option, sizeof(option))) {
+        END_ERROR(socket, "Could not send dir options");
+    }
+    
+    if (!_checkResult(socket)) {
+        // we do not write an error as this will fail a lot on recursive.
+        END_ERROR(socket, 0);
+    }
+    
+    _freeSocket(socket);
+    return true;
+}
+
+bool QtCesterConnection::execute(QString program,
+                                 QString arguments,
+                                 int timeout,
+                                 int *returnValue)
+{
+    QTcpSocket* socket = 0;
+    if (!_initCommand(socket, COMMAND_EXECUTE)) {
+        END_ERROR(socket, "Could not establish connection for dir deletion");
+    }
+
+    ExecuteOptions options;
+    strcpy(options.appName, qPrintable(program));
+    QStringList argList = arguments.split(QLatin1Char(' '));
+    options.argumentsCount = qMin(argList.size(), MAX_ARGUMENTS);
+    options.waitForFinished = true;
+    options.timeout = timeout;
+    if (!_sendData(socket, (char*) &options, sizeof(options))) {
+        END_ERROR(socket, "Could not send dir options");
+    }
+    if (!_checkResult(socket)) {
+        END_ERROR(socket, "Did not receive an answer");
+    }
+
+    for (int i=0; i < options.argumentsCount; ++i) {
+        char someData[MAX_NAME_LENGTH];
+        strcpy(someData, qPrintable(argList[i]));
+        if (!_sendData(socket, someData, MAX_NAME_LENGTH)) {
+            END_ERROR(socket, "Could not send argument");
+        }
+        if (!_checkResult(socket)) {
+            END_ERROR(socket, "Failure in argument send");
+        }
+    }
+
+    // trigger the startup
+    if (!_sendData(socket, COMMAND_SUCCESS, strlen(COMMAND_SUCCESS))) {
+        END_ERROR(socket, "Could not trigger startup");
+    }
+    
+    const int waitTime = 60 * 60 * 1000;
+    if (!socket->waitForReadyRead(waitTime)) {
+        END_ERROR(socket, "Process timed out");
+    }
+    
+    QByteArray result = socket->readAll();
+    if (result != COMMAND_SUCCESS) {
+        if (returnValue)
+            *returnValue = -1; // just some at least
+        END_ERROR(socket, "Application did not start or returned error");
+    }
+    
+    if (returnValue)
+        *returnValue = 0;
+    _freeSocket(socket);
+    return true;
+}
+
+bool QtCesterConnection::createDirectory(const QString &path, bool deleteBefore)
+{
+    if (deleteBefore)
+        deleteDirectory(path, true, true);
+    
+    QTcpSocket* socket = 0;
+    if (!_initCommand(socket, COMMAND_CREATE_DIRECTORY)) {
+        END_ERROR(socket, "Could not establish connection for dir creation");
+    }
+    
+    CreateDirectoryOptions option;
+    strcpy(option.dirName, qPrintable(path));
+    option.recursively = true;
+    if (!_sendData(socket, (char*) &option, sizeof(option))) {
+        END_ERROR(socket, "Could not send dir options");
+    }
+    
+    if (!_checkResult(socket)) {
+        END_ERROR(socket, "Dir creation failed");
+    }
+    
+    _freeSocket(socket);
+    return true;
+}
+
+bool QtCesterConnection::timeStampForLocalFileTime(FILETIME* fTime) const
+{
+    if (!fTime)
+        return false;
+    
+    FILETIME copyTime = *fTime;
+    LocalFileTimeToFileTime(&copyTime, &copyTime);
+    
+    QTcpSocket* socket = 0;
+    if (!_initCommand(socket, COMMAND_TIME_STAMP)) {
+        END_ERROR(socket, "Could not establish time stamp connection");
+    }
+    
+    if (!_sendData(socket, (char*) &copyTime, sizeof(copyTime))) {
+        END_ERROR(socket, "Could not send stamp time");
+    }
+    
+    QByteArray data;
+    if (!_receiveData(socket, data)) {
+        END_ERROR(socket, "Did not receive time stamp or connection interrupted");
+    }
+    
+    copyTime = *((FILETIME*)data.data());
+    if (copyTime.dwLowDateTime == -1 && copyTime.dwHighDateTime == -1) {
+        END_ERROR(socket, "remote Time stamp failed!");
+    }
+    
+    *fTime = copyTime;
+    _freeSocket(socket);
+    return true;
+}
+
+bool QtCesterConnection::fileCreationTime(const QString &fileName, FILETIME* deviceCreationTime) const
+{
+    if (!deviceCreationTime)
+        return false;
+    
+    QTcpSocket* socket = 0;
+    if (!_initCommand(socket, COMMAND_FILE_TIME)) {
+        END_ERROR(socket, "Could not establish connection for file time access");
+    }
+    
+    FileTimeOptions option;
+    strcpy(option.fileName, qPrintable(fileName));
+    if (!_sendData(socket, (char*) &option, sizeof(option))) {
+        END_ERROR(socket, "Could not send file time name");
+    }
+    
+    QByteArray data;
+    if (!_receiveData(socket, data)) {
+        END_ERROR(socket, "File Time request failed");
+    }
+    
+    FILETIME* resultTime = (FILETIME*) data.data();
+    if (resultTime->dwLowDateTime == -1 && resultTime->dwHighDateTime == -1) {
+        END_ERROR(socket, 0);
+        debugOutput("Could not access file time", 0);
+    }
+    
+    *deviceCreationTime = *resultTime;
+    _freeSocket(socket);
+    return true;
+}
+
+bool QtCesterConnection::_createSocket(QTcpSocket*& result) const
+{
+    QTcpSocket* sock = new QTcpSocket();
+    QByteArray ipAddress = qgetenv("DEVICE_IP");
+    if (ipAddress.isEmpty()) {
+        qWarning("Error: You need to have DEVICE_IP set");
+        exit(0);
+    }
+    sock->connectToHost(QHostAddress(QString(ipAddress)), 12145);
+    
+    if (!sock->waitForConnected()) {
+        qDebug() << "connection timeout...";
+        result = NULL;
+        return false;
+    }
+    result = sock;
+    return true;
+}
+
+void QtCesterConnection::_freeSocket(QTcpSocket*& sock) const
+{
+    if (!sock)
+        return;
+    if (sock->state() == QAbstractSocket::ConnectedState) {
+        sock->disconnectFromHost();
+        // seems like no need to wait
+        //sock->waitForDisconnected();
+    }
+    delete sock;
+    sock = NULL;
+#ifdef Q_OS_WIN
+    Sleep(100);
+#endif
+}
+
+bool QtCesterConnection::_initCommand(QTcpSocket*& sock, const char* command) const
+{
+    QTcpSocket* socket = NULL;
+    if (!_createSocket(socket)) {
+        END_ERROR(socket, "Could not connect to server");
+    }
+    
+    if (!_sendData(socket, command, strlen(command)) || 
+        !_checkResult(socket)) {
+        END_ERROR(socket, "Cound not send command");
+    }
+    sock = socket;
+    return true;
+}
+
+bool QtCesterConnection::_sendData(QTcpSocket*& sock, const char* data, int dataSize) const
+{
+    int amount = sock->write(data, dataSize);
+    if (amount != dataSize) {
+        fprintf(stderr, "*******COULD NOT SEND ENOUGH DATA*************\n");
+    }
+    return sock->waitForBytesWritten();
+}
+
+bool QtCesterConnection::_receiveData(QTcpSocket*& sock, QByteArray& data) const
+{
+    if (!sock->waitForReadyRead()) {
+        qDebug() << "did not receive any data";
+        return false;
+    }
+    data = sock->readAll();
+    return true;
+}
+
+bool QtCesterConnection::_checkResult(QTcpSocket*& sock) const
+{
+    QByteArray response;
+    if (!_receiveData(sock, response) || response != COMMAND_SUCCESS)
+        return false;
+    return true;
+}
+
diff --git a/tools/qtestlib/wince/cetcpsync/qtcesterconnection.h b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.h
new file mode 100644
index 0000000..d7b8393
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef ACTIVESYNC_REMOTECONNECTION_H
+#define ACTIVESYNC_REMOTECONNECTION_H
+
+#include "remoteconnection.h"
+
+class QTcpSocket;
+
+class QtCesterConnection : public AbstractRemoteConnection
+{
+public:
+    QtCesterConnection();
+    virtual ~QtCesterConnection();
+
+    bool connect(QVariantList &list = QVariantList());
+    void disconnect();
+    bool isConnected() const;
+
+    // These functions are designed for transfer between desktop and device
+    // Caution: deviceDest path has to be device specific (eg. no drive letters for CE)
+    bool copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists = false);
+    bool copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive = true);
+    bool copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists = false);
+    bool copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive = true);
+
+    bool timeStampForLocalFileTime(FILETIME*) const;
+    bool fileCreationTime(const QString &fileName, FILETIME*) const;
+
+    // These functions only work on files existing on the device
+    bool copyFile(const QString&, const QString&, bool failIfExists = false);
+    bool copyDirectory(const QString&, const QString&, bool recursive = true);
+    bool deleteFile(const QString&);
+    bool deleteDirectory(const QString&, bool recursive = true, bool failIfContentExists = false);
+    bool createDirectory(const QString&, bool deleteBefore=false);
+
+    bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL);
+private:
+    bool _createSocket(QTcpSocket*&) const;
+    void _freeSocket(QTcpSocket*&) const;
+    bool _initCommand(QTcpSocket*&, const char*) const;
+    bool _sendData(QTcpSocket*&, const char* data, int dataSize) const;
+    bool _receiveData(QTcpSocket*&, QByteArray&) const;
+    bool _checkResult(QTcpSocket*&) const;
+    bool connected;
+};
+
+#endif
diff --git a/tools/qtestlib/wince/cetcpsync/remoteconnection.cpp b/tools/qtestlib/wince/cetcpsync/remoteconnection.cpp
new file mode 100644
index 0000000..b197c5c
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/remoteconnection.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "remoteconnection.h"
+
+AbstractRemoteConnection::AbstractRemoteConnection()
+{
+}
+
+AbstractRemoteConnection::~AbstractRemoteConnection()
+{
+}
+
+// Slow but should be ok...
+bool AbstractRemoteConnection::moveFile(const QString &src, const QString &dest, bool FailIfExists)
+{
+    bool result = copyFile(src, dest, FailIfExists);
+    deleteFile(src);
+    return result;
+}
+
+// Slow but should be ok...
+bool AbstractRemoteConnection::moveDirectory(const QString &src, const QString &dest, bool recursive)
+{
+    bool result = copyDirectory(src, dest, true);
+    deleteDirectory(src, recursive);
+    return result;
+}
diff --git a/tools/qtestlib/wince/cetcpsync/remoteconnection.h b/tools/qtestlib/wince/cetcpsync/remoteconnection.h
new file mode 100644
index 0000000..fae6f7f
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/remoteconnection.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef REMOTECONNECTION_H
+#define REMOTECONNECTION_H
+
+#include <QtCore/QString>
+#include <QtCore/QVariant>
+#include <windows.h>
+class AbstractRemoteConnection
+{
+public:
+    AbstractRemoteConnection();
+    virtual ~AbstractRemoteConnection();
+
+    virtual bool connect(QVariantList&) = 0;
+    virtual void disconnect() = 0;
+    virtual bool isConnected() const = 0;
+
+    // These functions are designed for transfer between desktop and device
+    // Caution: deviceDest path has to be device specific (eg. no drive letters for CE)
+    virtual bool copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists = false) = 0;
+    virtual bool copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive = true) = 0;
+    virtual bool copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists = false) = 0;
+    virtual bool copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive = true) = 0;
+
+    // For "intelligent deployment" we need to investigate on filetimes on the device
+    virtual bool timeStampForLocalFileTime(FILETIME*) const = 0;
+    virtual bool fileCreationTime(const QString &fileName, FILETIME*) const = 0;
+    
+    // These functions only work on files existing on the device
+    virtual bool copyFile(const QString&, const QString&, bool failIfExists = false) = 0;
+    virtual bool copyDirectory(const QString&, const QString&, bool recursive = true) = 0;
+    virtual bool deleteFile(const QString&) = 0;
+    virtual bool deleteDirectory(const QString&, bool recursive = true, bool failIfContentExists = false) = 0;
+    bool moveFile(const QString&, const QString&, bool FailIfExists = false);
+    bool moveDirectory(const QString&, const QString&, bool recursive = true);
+
+    virtual bool createDirectory(const QString&, bool deleteBefore=false) = 0;
+
+    virtual bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL) = 0;
+};
+
+#endif
-- 
cgit v0.12


From f78bd88cbb8fd4c32e487eed716f089b6f5cfe28 Mon Sep 17 00:00:00 2001
From: Volker Hilsheimer <volker.hilsheimer@nokia.com>
Date: Wed, 5 Aug 2009 12:58:39 +0200
Subject: Workaround a crash in qdoc.

Caused by an odd number of classes it seems.
---
 tools/qdoc3/htmlgenerator.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index 6b15f96..df63138 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -2097,6 +2097,11 @@ void HtmlGenerator::generateCompactList(const Node *relative,
                     currentOffsetInParagraph[i] = 0;
                 }
 
+                if (currentParagraphNo[i] >= NumParagraphs) {
+                    qDebug() << "### Internal error ###" << __FILE__ << __LINE__;
+                    currentParagraphNo[i] = NumParagraphs - 1;
+                }
+
                 out() << "<td align=\"right\">";
                 if (currentOffsetInParagraph[i] == 0) {
                     // start a new paragraph
-- 
cgit v0.12


From 0002516329cbbf5fb0b677835353bf7ccd4e425f Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Wed, 5 Aug 2009 13:01:02 +0200
Subject: missing license header added in cetcpsyncsvr

Reviewed-by: TrustMe
---
 tools/qtestlib/wince/cetcpsyncserver/commands.cpp | 40 +++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/tools/qtestlib/wince/cetcpsyncserver/commands.cpp b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp
index 64869c4..0c4d3bc 100644
--- a/tools/qtestlib/wince/cetcpsyncserver/commands.cpp
+++ b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp
@@ -1,3 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
 #include "commands.h"
 #include <QtCore/QDebug>
 #include <QtCore/QFileInfo>
-- 
cgit v0.12


From 770ce0a8cd7493e3be3e7accf7133778336c6f5d Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Wed, 5 Aug 2009 13:02:18 +0200
Subject: small cleanup in cetest

Reviewed-by: TrustMe
---
 .../qtestlib/wince/cetest/cetcpsyncconnection.cpp  | 31 +++++++++++-----------
 tools/qtestlib/wince/cetest/cetest.pro             |  4 +--
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
index bebcd1c..f00d2b8 100644
--- a/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
+++ b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
@@ -44,6 +44,7 @@
 #include <qfile.h>
 #include <qfileinfo>
 
+static const QString ceTcpSyncProgram = ceTcpSyncProgram + "";
 extern void debugOutput(const QString& text, int level);
 
 CeTcpSyncConnection::CeTcpSyncConnection()
@@ -62,7 +63,7 @@ bool CeTcpSyncConnection::connect(QVariantList&)
 {
     // We connect with each command, so this is always true
     // The command itself will fail then
-    if (system("cetcpsync noop") != 0)
+    if (system(ceTcpSyncProgram + " noop") != 0)
         return false;
     connected = true;
     return true;
@@ -103,56 +104,56 @@ static QString fileTimeToString(FILETIME& ft)
 
 bool CeTcpSyncConnection::copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists)
 {
-    QString cmd = "cetcpsync copyFileToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(failIfExists);
+    QString cmd = ceTcpSyncProgram + " copyFileToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(failIfExists);
     return system(qPrintable(cmd)) == 0;
 }
 
 bool CeTcpSyncConnection::copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive)
 {
-    QString cmd = "cetcpsync copyDirectoryToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(recursive);
+    QString cmd = ceTcpSyncProgram + " copyDirectoryToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(recursive);
     return system(qPrintable(cmd)) == 0;
 }
 
 bool CeTcpSyncConnection::copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists)
 {
-    QString cmd = "cetcpsync copyFileFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(failIfExists);
+    QString cmd = ceTcpSyncProgram + " copyFileFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(failIfExists);
     return system(qPrintable(cmd)) == 0;
 }
 
 bool CeTcpSyncConnection::copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive)
 {
-    QString cmd = "cetcpsync copyDirectoryFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(recursive);
+    QString cmd = ceTcpSyncProgram + " copyDirectoryFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(recursive);
     return system(qPrintable(cmd)) == 0;
 }
 
 bool CeTcpSyncConnection::copyFile(const QString &srcFile, const QString &destFile, bool failIfExists)
 {
-    QString cmd = "cetcpsync copyFile \"" + srcFile + "\" \"" + destFile + "\" " + boolToString(failIfExists);
+    QString cmd = ceTcpSyncProgram + " copyFile \"" + srcFile + "\" \"" + destFile + "\" " + boolToString(failIfExists);
     return system(qPrintable(cmd)) == 0;
 }
 
 bool CeTcpSyncConnection::copyDirectory(const QString &srcDirectory, const QString &destDirectory,
                                         bool recursive)
 {
-    QString cmd = "cetcpsync copyDirectory \"" + srcDirectory + "\" \"" + destDirectory + "\" " + boolToString(recursive);
+    QString cmd = ceTcpSyncProgram + " copyDirectory \"" + srcDirectory + "\" \"" + destDirectory + "\" " + boolToString(recursive);
     return system(qPrintable(cmd)) == 0;
 }
 
 bool CeTcpSyncConnection::deleteFile(const QString &fileName)
 {
-    QString cmd = "cetcpsync deleteFile \"" + fileName + "\"";
+    QString cmd = ceTcpSyncProgram + " deleteFile \"" + fileName + "\"";
     return system(qPrintable(cmd)) == 0;
 }
 
 bool CeTcpSyncConnection::deleteDirectory(const QString &directory, bool recursive, bool failIfContentExists)
 {
-    QString cmd = "cetcpsync deleteDirectory \"" + directory + "\" " + boolToString(recursive) + " " + boolToString(failIfContentExists);
+    QString cmd = ceTcpSyncProgram + " deleteDirectory \"" + directory + "\" " + boolToString(recursive) + " " + boolToString(failIfContentExists);
     return system(qPrintable(cmd)) == 0;
 }
 
 bool CeTcpSyncConnection::execute(QString program, QString arguments, int timeout, int *returnValue)
 {
-    QString cmd = "cetcpsync execute \"" + program + "\" \"" + arguments + "\" " + QString::number(timeout);
+    QString cmd = ceTcpSyncProgram + " execute \"" + program + "\" \"" + arguments + "\" " + QString::number(timeout);
     int exitCode = system(qPrintable(cmd));
     if (returnValue)
         *returnValue = exitCode;
@@ -161,17 +162,17 @@ bool CeTcpSyncConnection::execute(QString program, QString arguments, int timeou
 
 bool CeTcpSyncConnection::createDirectory(const QString &path, bool deleteBefore)
 {
-    QString cmd = "cetcpsync createDirectory \"" + path + "\" " + boolToString(deleteBefore);
+    QString cmd = ceTcpSyncProgram + " createDirectory \"" + path + "\" " + boolToString(deleteBefore);
     return system(qPrintable(cmd)) == 0;
 }
 
 bool CeTcpSyncConnection::timeStampForLocalFileTime(FILETIME* fTime) const
 {
-    QString cmd = "cetcpsync timeStampForLocalFileTime " + fileTimeToString(*fTime) + " >filetime.txt";
+    QString cmd = ceTcpSyncProgram + " timeStampForLocalFileTime " + fileTimeToString(*fTime) + " >qt_cetcpsyncdata.txt";
     if (system(qPrintable(cmd)) != 0)
         return false;
 
-    QFile file("filetime.txt");
+    QFile file("qt_cetcpsyncdata.txt");
     if (!file.open(QIODevice::ReadOnly))
         return false;
 
@@ -183,11 +184,11 @@ bool CeTcpSyncConnection::timeStampForLocalFileTime(FILETIME* fTime) const
 
 bool CeTcpSyncConnection::fileCreationTime(const QString &fileName, FILETIME* deviceCreationTime) const
 {
-    QString cmd = "cetcpsync fileCreationTime \"" + fileName + "\" >filetime.txt";
+    QString cmd = ceTcpSyncProgram + " fileCreationTime \"" + fileName + "\" >qt_cetcpsyncdata.txt";
     if (system(qPrintable(cmd)) != 0)
         return false;
 
-    QFile file("filetime.txt");
+    QFile file("qt_cetcpsyncdata.txt");
     if (!file.open(QIODevice::ReadOnly))
         return false;
 
diff --git a/tools/qtestlib/wince/cetest/cetest.pro b/tools/qtestlib/wince/cetest/cetest.pro
index c6eba7f..a6b79da 100644
--- a/tools/qtestlib/wince/cetest/cetest.pro
+++ b/tools/qtestlib/wince/cetest/cetest.pro
@@ -35,7 +35,7 @@ SOURCES += \
         deployment.cpp \
         main.cpp
 
-win32-msvc*:LIBS += ole32.lib advapi32.lib
+LIBS += ole32.lib advapi32.lib
 
 isEmpty(QT_CE_RAPI_INC) {
     DEFINES += QT_CETEST_NO_ACTIVESYNC
@@ -44,7 +44,7 @@ isEmpty(QT_CE_RAPI_INC) {
 } else {
     HEADERS += activesyncconnection.h
     SOURCES += activesyncconnection.cpp
-    win32-msvc*:LIBS += rapi.lib
+    LIBS += rapi.lib
     INCLUDEPATH += $$QT_CE_RAPI_INC
     LIBS += -L$$QT_CE_RAPI_LIB
 }
-- 
cgit v0.12


From 0ba2e3c4fa088a5467279cf851b2b49697ccad5c Mon Sep 17 00:00:00 2001
From: Prasanth Ullattil <prasanth.ullattil@nokia.com>
Date: Wed, 5 Aug 2009 13:14:16 +0200
Subject: Re-enable the use of Common Item Dialog

This was disabled by patch bf305bc2e488ad4f08c49767246f31a81218991e

Reviewed-by: Thomas Hartmann
---
 src/gui/dialogs/qfiledialog_win.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp
index 9bf82c3..c542ff0 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/gui/dialogs/qfiledialog_win.cpp
@@ -59,7 +59,9 @@
 #endif
 
 #include <shlobj.h>
-
+#if !defined(Q_WS_WINCE)
+#include <shobjidl.h>
+#endif
 #include <objbase.h>
 
 #if defined(__IFileDialog_INTERFACE_DEFINED__) \
-- 
cgit v0.12


From cb599c5ea32e8e5ff81318038b432272f107b1fe Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Thu, 30 Jul 2009 12:58:06 +0200
Subject: Fix compilation on AIX: -I/usr/include cannot be used.

The reason is that the C++ compiler needs to add -I/usr/vacpp/include
before -I/usr/include, so our adding of -I/usr/include changes the order.
This causes a compilation error in the C++ header xlocinfo.h.

In any case, these checks done in qmake are unnecessary. If the OpenSSL
headers are in one of those include paths, they will be found on their
own already.

Reviewed-By: Bradley T. Hughes
(cherry picked from commit 04f7834fcd8db4ecb6a4c53de42ac83f571b37c8)
---
 config.tests/unix/openssl/openssl.pri | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/config.tests/unix/openssl/openssl.pri b/config.tests/unix/openssl/openssl.pri
index bc95479..f069396 100644
--- a/config.tests/unix/openssl/openssl.pri
+++ b/config.tests/unix/openssl/openssl.pri
@@ -1,9 +1,3 @@
-!cross_compile {
-    TRY_INCLUDEPATHS = /include /usr/include /usr/local/include $$QMAKE_INCDIR $$INCLUDEPATH
-    # LSB doesn't allow using headers from /include or /usr/include
-    linux-lsb-g++:TRY_INCLUDEPATHS = $$QMAKE_INCDIR $$INCLUDEPATH
-    for(p, TRY_INCLUDEPATHS) {
-        pp = $$join(p, "", "", "/openssl")
-        exists($$pp):INCLUDEPATH *= $$p
-    }
-}
+# Empty file since Qt 4.6
+# I'm too lazy to find all places where this file is included
+
-- 
cgit v0.12


From b4f1f4de1a0df7028440faaff146ac1560dc6169 Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Wed, 5 Aug 2009 13:17:39 +0200
Subject: MainWindow: fixed an update issue when moving a separator

A non painted (ie. garbage) area could appear if you had a fixed size
dock widget and you moved the separator. The previous place where the
separator was painted was not updated
---
 src/gui/widgets/qmainwindowlayout.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp
index 3936a67..55afa70 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/gui/widgets/qmainwindowlayout.cpp
@@ -1988,6 +1988,9 @@ void QMainWindowLayout::timerEvent(QTimerEvent *e)
         if (movingSeparatorOrigin == movingSeparatorPos)
             return;
 
+        //when moving the separator, we need to update the previous position
+        parentWidget()->update(layoutState.dockAreaLayout.separatorRegion());
+
         layoutState = savedState;
         layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin,
                                                     movingSeparatorPos);
-- 
cgit v0.12


From 90480b9a25568858d1383e0aab6f5708a7dabd4f Mon Sep 17 00:00:00 2001
From: Alexis Menard <alexis.menard@nokia.com>
Date: Wed, 5 Aug 2009 13:19:29 +0200
Subject: Fix a bug when activating HideNameFilterDetails on Windows
 filedialog.

The HideNameFilterDetails was not taken in account for windows
file dialog. This patch fix that. For Windows Vista and later we use
now the new COMMON_ITEM_DIALOG API (in master) where it add always
the filter extension like *.txt so no point to take that flag in account.

Task-number: None, during testing
Reviewed-by: prasanth
---
 src/gui/dialogs/qfiledialog.cpp     |  2 +-
 src/gui/dialogs/qfiledialog_win.cpp | 28 ++++++++++++++++++----------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index c8ce162..6977731 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -219,7 +219,7 @@ Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook
     the native file dialog is used unless you use a subclass of QFileDialog that contains the
     Q_OBJECT macro.
     \value ReadOnly Indicates that the model is readonly.
-    \value HideNameFilterDetails Indicates if the is hidden or not.
+    \value HideNameFilterDetails Indicates if the filter extension (e.g. *.bmp) is hidden or not.
 
     This value is obsolete and does nothing since Qt 4.5:
 
diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp
index 9a478aa..37a25e5 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/gui/dialogs/qfiledialog_win.cpp
@@ -163,15 +163,22 @@ static QStringList qt_win_make_filters_list(const QString &filter)
 }
 
 // Makes a NUL-oriented Windows filter from a Qt filter.
-static QString qt_win_filter(const QString &filter)
+static QString qt_win_filter(const QString &filter, bool hideFiltersDetails)
 {
     QStringList filterLst = qt_win_make_filters_list(filter);
     QStringList::Iterator it = filterLst.begin();
     QString winfilters;
+    QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
     for (; it != filterLst.end(); ++it) {
         QString subfilter = *it;
         if (!subfilter.isEmpty()) {
-            winfilters += subfilter;
+            if (hideFiltersDetails) {
+                int index = r.indexIn(subfilter);
+                if (index >= 0)
+                    winfilters += r.cap(1);
+            } else {
+                winfilters += subfilter;
+            }
             winfilters += QChar();
             winfilters += qt_win_extract_filter(subfilter);
             winfilters += QChar();
@@ -377,11 +384,12 @@ QString qt_win_get_open_file_name(const QFileDialogArgs &args,
     modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
     modal_widget.setParent(args.parent, Qt::Window);
     QApplicationPrivate::enterModal(&modal_widget);
+    bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
     QT_WA({
         // Use Unicode strings and API
         OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
                                             args.directory, args.caption,
-                                            qt_win_filter(args.filter),
+                                            qt_win_filter(args.filter, hideFiltersDetails),
 					    QFileDialog::ExistingFile,
 					    args.options);
         if (idx)
@@ -395,7 +403,7 @@ QString qt_win_get_open_file_name(const QFileDialogArgs &args,
         // Use ANSI strings and API
         OPENFILENAMEA* ofn = qt_win_make_OFNA(args.parent, args.selection,
                                               args.directory, args.caption,
-                                              qt_win_filter(args.filter),
+                                              qt_win_filter(args.filter, hideFiltersDetails),
 					      QFileDialog::ExistingFile,
 					      args.options);
         if (idx)
@@ -452,7 +460,7 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args,
     modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
     modal_widget.setParent(args.parent, Qt::Window);
     QApplicationPrivate::enterModal(&modal_widget);
-
+    bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
     // This block is used below for the lpstrDefExt member.
     // Note that the current MSDN docs document this member wrong.
     // It should rather be documented as "the default extension if no extension was given and if the
@@ -469,12 +477,11 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args,
             defaultSaveExt.clear();
         }
     }
-
     QT_WA({
         // Use Unicode strings and API
         OPENFILENAME *ofn = qt_win_make_OFN(args.parent, args.selection,
                                             args.directory, args.caption,
-                                            qt_win_filter(args.filter),
+                                            qt_win_filter(args.filter, hideFiltersDetails),
 					    QFileDialog::AnyFile,
 					    args.options);
 
@@ -491,7 +498,7 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args,
         // Use ANSI strings and API
         OPENFILENAMEA *ofn = qt_win_make_OFNA(args.parent, args.selection,
                                               args.directory, args.caption,
-                                              qt_win_filter(args.filter),
+                                              qt_win_filter(args.filter, hideFiltersDetails),
 					      QFileDialog::AnyFile,
 					      args.options);
         QByteArray asciiExt = defaultSaveExt.toAscii();
@@ -558,10 +565,11 @@ QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
     modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
     modal_widget.setParent(args.parent, Qt::Window);
     QApplicationPrivate::enterModal(&modal_widget);
+    bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
     QT_WA({
         OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
                                             args.directory, args.caption,
-                                            qt_win_filter(args.filter),
+                                            qt_win_filter(args.filter, hideFiltersDetails),
 					    QFileDialog::ExistingFiles,
 					    args.options);
         if (idx)
@@ -594,7 +602,7 @@ QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
     } , {
         OPENFILENAMEA* ofn = qt_win_make_OFNA(args.parent, args.selection,
                                               args.directory, args.caption,
-                                              qt_win_filter(args.filter),
+                                              qt_win_filter(args.filter, hideFiltersDetails),
 					      QFileDialog::ExistingFiles,
 					      args.options);
         if (idx)
-- 
cgit v0.12


From ca2a9d87d81095f6ff7b821e3d8cbe120a6d9b23 Mon Sep 17 00:00:00 2001
From: Alexis Menard <alexis.menard@nokia.com>
Date: Wed, 5 Aug 2009 13:13:33 +0200
Subject: Fix regressions introduced by
 31edb4d5a63b9b3c28cce1c4ca6eb99f62a09759

The commit 31edb4d5a63b9b3c28cce1c4ca6eb99f62a09759 introduced
regressions in filters which breaks the mac native dialog, the non
native dialog with HideNameFilterDetails activated.

Task-number:259105
Reviewed-by:olivier
Reviewed-by:prasanth
---
 src/gui/dialogs/qfiledialog.cpp            | 14 ++++++----
 src/gui/dialogs/qfiledialog_win.cpp        |  2 ++
 tests/auto/qfiledialog/tst_qfiledialog.cpp | 43 ++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index 1ec94b6..f000033 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -394,6 +394,9 @@ QList<QUrl> QFileDialog::sidebarUrls() const
 
 static const qint32 QFileDialogMagic = 0xbe;
 
+const char *qt_file_dialog_filter_reg_exp =
+"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
+
 /*!
     \since 4.3
     Saves the state of the dialog's layout, history and current directory.
@@ -984,8 +987,13 @@ void QFileDialog::setNameFilters(const QStringList &filters)
 
     if (testOption(HideNameFilterDetails)) {
         QStringList strippedFilters;
+        QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
         for (int i = 0; i < cleanedFilters.count(); ++i) {
-            strippedFilters.append(cleanedFilters[i].mid(0, cleanedFilters[i].indexOf(QLatin1String(" ("))));
+            QString filterName;
+            int index = r.indexIn(cleanedFilters[i]);
+            if (index >= 0)
+                filterName = r.cap(1);
+            strippedFilters.append(filterName.simplified());
         }
         d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters);
     } else {
@@ -2837,10 +2845,6 @@ void QFileDialogPrivate::_q_goToDirectory(const QString &path)
     }
 }
 
-const char *qt_file_dialog_filter_reg_exp =
-"(\\W|[a-zA-Z0-9 -]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
-
-
 // Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)"
 QStringList qt_clean_filter_list(const QString &filter)
 {
diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp
index c542ff0..02469b2 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/gui/dialogs/qfiledialog_win.cpp
@@ -443,6 +443,8 @@ static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd,
         QString subfilter = *it;
         if (!subfilter.isEmpty()) {
             offsets<<currentOffset;
+            //Here the COMMON_ITEM_DIALOG API always add the details for the filter (e.g. *.txt)
+            //so we don't need to handle the flag HideNameFilterDetails.
             winfilters += subfilter; // The name of the filter.
             winfilters += QChar();
             currentOffset += subfilter.size()+1;
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index c31ecf2..0f307dc 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -161,6 +161,7 @@ private slots:
     void task251341_sideBarRemoveEntries();
     void task254490_selectFileMultipleTimes();
     void task257579_sideBarWithNonCleanUrls();
+    void task259105_filtersCornerCases();
 
 private:
     QByteArray userSettings;
@@ -2057,6 +2058,48 @@ void tst_QFiledialog::task257579_sideBarWithNonCleanUrls()
 #endif
 }
 
+void tst_QFiledialog::task259105_filtersCornerCases()
+{
+    QNonNativeFileDialog fd(0, "TestFileDialog");
+    fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
+    fd.setOption(QFileDialog::HideNameFilterDetails, true);
+    fd.show();
+    QTest::qWait(250);
+
+    //Extensions are hidden
+    QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
+    QVERIFY(filters);
+    QCOMPARE(filters->currentText(), QLatin1String("All Files!"));
+    filters->setCurrentIndex(1);
+    QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+
+    //We should have the full names
+    fd.setOption(QFileDialog::HideNameFilterDetails, false);
+    QTest::qWait(250);
+    filters->setCurrentIndex(0);
+    QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)"));
+    filters->setCurrentIndex(1);
+    QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
+
+    //Corner case undocumented of the task
+    fd.setNameFilter(QLatin1String("\352 (I like cheese) All Files! (*);;Text Files (*.txt)"));
+    QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files! (*)"));
+    filters->setCurrentIndex(1);
+    QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
+
+    fd.setOption(QFileDialog::HideNameFilterDetails, true);
+    filters->setCurrentIndex(0);
+    QTest::qWait(500);
+    QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
+    filters->setCurrentIndex(1);
+    QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
 
+    fd.setOption(QFileDialog::HideNameFilterDetails, true);
+    filters->setCurrentIndex(0);
+    QTest::qWait(500);
+    QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
+    filters->setCurrentIndex(1);
+    QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+}
 QTEST_MAIN(tst_QFiledialog)
 #include "tst_qfiledialog.moc"
-- 
cgit v0.12


From e80dc7d3a8ab098627c9c81ea390de7db0ec264e Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@trolltech.com>
Date: Wed, 5 Aug 2009 13:53:44 +0200
Subject: Fixed setting a style shet on a QSpinBox to change the arrow
 possition

If you only set the position, of the button without setting a geometry,
it did not work.

Task-number: 259226
---
 src/gui/styles/qstylesheetstyle.cpp                |  8 +--
 .../uiloader/baseline/css_task259226_spinboxes.ui  | 83 ++++++++++++++++++++++
 2 files changed, 87 insertions(+), 4 deletions(-)
 create mode 100644 tests/auto/uiloader/baseline/css_task259226_spinboxes.ui

diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 2efa4a7..5f6d4ab 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -2891,8 +2891,8 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
             bool customUp = true, customDown = true;
             QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
             QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
-            bool upRuleMatch = upRule.hasGeometry();
-            bool downRuleMatch = downRule.hasGeometry();
+            bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
+            bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
             if (rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) {
                 rule.drawBackgroundImage(p, spinOpt.rect);
                 customUp = (opt->subControls & QStyle::SC_SpinBoxUp)
@@ -5167,8 +5167,8 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
             QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
             QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
             bool ruleMatch = rule.hasBox() || !rule.hasNativeBorder();
-            bool upRuleMatch = upRule.hasGeometry();
-            bool downRuleMatch = downRule.hasGeometry();
+            bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
+            bool downRuleMatch = downRule.hasGeometry() || upRule.hasPosition();
             if (ruleMatch || upRuleMatch || downRuleMatch) {
                 switch (sc) {
                 case SC_SpinBoxFrame:
diff --git a/tests/auto/uiloader/baseline/css_task259226_spinboxes.ui b/tests/auto/uiloader/baseline/css_task259226_spinboxes.ui
new file mode 100644
index 0000000..eb9ade3
--- /dev/null
+++ b/tests/auto/uiloader/baseline/css_task259226_spinboxes.ui
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>320</width>
+    <height>116</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <property name="styleSheet">
+   <string notr="true">#spinbox1::up-button{
+    subcontrol-origin: border;
+    subcontrol-position: top left; 
+  }
+#spinbox1::down-button {
+    subcontrol-origin: border;
+     subcontrol-position: bottom left; 
+  }
+
+
+#spinbox2::up-button{
+    subcontrol-origin: border;
+    subcontrol-position: center left; 
+    left: 0px;
+    height: 100%;
+    top: 0px;
+  }
+#spinbox2::down-button {
+    subcontrol-origin: border;
+    subcontrol-position: center right; 
+    right: 0px;
+    height: 100%;
+    top: 0px;
+  }
+
+
+
+#spinbox3::up-button{
+    subcontrol-origin: border;
+     subcontrol-position: top left; 
+  }
+
+
+#spinbox4 { padding: 20px 1px; }
+#spinbox4::up-button{
+    subcontrol-origin: border;
+    subcontrol-position: top center; 
+   width:100%;
+   height:  20px;
+  }
+#spinbox4::down-button {
+    subcontrol-origin: border;
+    subcontrol-position: bottom center; 
+   width:100%;
+   height:  20px;
+  }
+
+</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QSpinBox" name="spinbox1"/>
+   </item>
+   <item row="0" column="1">
+    <widget class="QSpinBox" name="spinbox2"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QSpinBox" name="spinbox3"/>
+   </item>
+   <item row="1" column="1">
+    <widget class="QSpinBox" name="spinbox4"/>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
-- 
cgit v0.12


From d8d85c9a482fb83161964a8925e2daf490c44007 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Wed, 5 Aug 2009 14:11:40 +0200
Subject: cetest compile fix

Reviewed-by: TrustMe
---
 tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
index f00d2b8..621a6ac 100644
--- a/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
+++ b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
@@ -44,7 +44,7 @@
 #include <qfile.h>
 #include <qfileinfo>
 
-static const QString ceTcpSyncProgram = ceTcpSyncProgram + "";
+static const QString ceTcpSyncProgram = "cetcpsync";
 extern void debugOutput(const QString& text, int level);
 
 CeTcpSyncConnection::CeTcpSyncConnection()
@@ -63,7 +63,8 @@ bool CeTcpSyncConnection::connect(QVariantList&)
 {
     // We connect with each command, so this is always true
     // The command itself will fail then
-    if (system(ceTcpSyncProgram + " noop") != 0)
+    const QString cmd = ceTcpSyncProgram + " noop";
+    if (system(qPrintable(cmd)) != 0)
         return false;
     connected = true;
     return true;
-- 
cgit v0.12


From 56b2195b4fe06bab51be3ca7e52e7cb669ba9147 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Wed, 5 Aug 2009 14:27:32 +0200
Subject: Fix compilation for compilers that don't have template friends.

GCC has template friends, so I wasn't seeing the error that d is
protected. Thanks to Robert for pointing out.

Reviewed-by: Robert Loehning <robert.loehning@nokia.com>
---
 src/corelib/tools/qsharedpointer_impl.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index e8e3812..3ee407c 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -387,7 +387,6 @@ namespace QtSharedPointer {
             this->value = d && d->strongref ? actual : 0;
         }
 
-    protected:
         Data *d;
 
     private:
-- 
cgit v0.12


From dced21168b2d5d2cbcc3ce999a85f1e59e7934b1 Mon Sep 17 00:00:00 2001
From: mae <qt-info@nokia.com>
Date: Wed, 5 Aug 2009 14:27:40 +0200
Subject: Fix failing autotest tst_QPlainTextEdit::lineWrapModes()

QPlainText edit does lazy line wrapping only for the visible blocks.
Resizing the editor in the auto test thus has to make it wide enough
that at least some characters are visible for the block to be laid out.
---
 tests/auto/qplaintextedit/tst_qplaintextedit.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
index 40ad539..e8350e3 100644
--- a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
@@ -856,7 +856,12 @@ void tst_QPlainTextEdit::lineWrapModes()
     ed->setLineWrapMode(QPlainTextEdit::NoWrap);
     QCOMPARE(lineCount(), 1);
     ed->setLineWrapMode(QPlainTextEdit::WidgetWidth);
-    ed->resize(1, 1000);
+
+    // QPlainTextEdit does lazy line layout on resize, only for the visible blocks.
+    // We thus need to make it wide enough to show something visible.
+    int minimumWidth = 2 * ed->document()->documentMargin();
+    minimumWidth += ed->fontMetrics().width(QLatin1Char('a'));
+    ed->resize(minimumWidth, 1000);
     QCOMPARE(lineCount(), 26);
     ed->setParent(0);
     delete window;
-- 
cgit v0.12


From e95166da34d1f5f383e9595d4042ce3e835efdc2 Mon Sep 17 00:00:00 2001
From: Volker Hilsheimer <volker.hilsheimer@nokia.com>
Date: Wed, 5 Aug 2009 14:32:58 +0200
Subject: QTapAndHoldGesture is gone, remove reference

---
 src/gui/kernel/qgesture.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index 32ac4f8..8075ad9 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -97,7 +97,7 @@ private:
     This is a base class, to create a custom gesture type, you should subclass
     it and implement its pure virtual functions.
 
-    \sa QPanGesture, QTapAndHoldGesture
+    \sa QPanGesture
 */
 
 /*! \fn bool QGesture::filterEvent(QEvent *event)
-- 
cgit v0.12


From 435bbd4be73768f617e4a4083a345d1d8d62daa3 Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Wed, 5 Aug 2009 15:06:49 +0200
Subject: ItemViews: make it possible for chekcable items to get
 partiallyChecked

Previously it was only switching between checked and unchecked.

Task-number: 259008
Reviewed-by: ogoffart
---
 src/gui/itemviews/qitemdelegate.cpp       | 8 +++++++-
 src/gui/itemviews/qstyleditemdelegate.cpp | 7 ++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index 962ce54..bd6dc62 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -1296,8 +1296,14 @@ bool QItemDelegate::editorEvent(QEvent *event,
         return false;
     }
 
-    Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
+    Qt::CheckState state;
+    if ( flags & Qt::ItemIsTristate ) {
+        state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 );
+    } else {
+        state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
                             ? Qt::Unchecked : Qt::Checked);
+    }
+
     return model->setData(index, state, Qt::CheckStateRole);
 }
 
diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp
index 8faf0be..34667ee 100644
--- a/src/gui/itemviews/qstyleditemdelegate.cpp
+++ b/src/gui/itemviews/qstyleditemdelegate.cpp
@@ -746,8 +746,13 @@ bool QStyledItemDelegate::editorEvent(QEvent *event,
         return false;
     }
 
-    Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
+    Qt::CheckState state;
+    if ( flags & Qt::ItemIsTristate ) {
+        state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 );
+    } else {
+        state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
                             ? Qt::Unchecked : Qt::Checked);
+    }
     return model->setData(index, state, Qt::CheckStateRole);
 }
 
-- 
cgit v0.12


From 021a116d48a1df3624ad2221a418f1585f7ec4f8 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Mon, 3 Aug 2009 18:49:16 +0200
Subject: Add support for using QWeakPointer with QObject, replacing QPointer.

The problem with QPointer is that it's a simple QObject*. So the only
way for QPointer to do what it's supposed to do is if the object it's
pointing to clears all QPointers when getting deleted. That means the
QObject must know each and every QPointer pointing to it. To make
matters worse, QPointers can be deleted while the object they're
pointing to also gets deleted. So deleting QObjects must do locking.

The solution to the QPointer problem is that both QObject and the
"QPointer" reference something outside the QObject. This way,
QObject doesn't have to lock anything to destroy itself: it's simply
setting a volatile integer to zero when it gets deleted. Since the
integer is outside the QObject, the integer is also refcounted. It's also
O(1), so there's no problem having as many "QPointer".

The two-atomic-ints structure is exactly what QSharedPointer and
QWeakPointer use internally. We just abuse this structure for QObject
needs, setting the strong reference count to -1 to indicate that it's
a QObject that cannot be managed by a QSharedPointer. But QWeakPointer
can still work and replace QPointer neatly.

Reviewed-by: Bradley T. Hughes
Reviewed-by: Jarek Kobus
---
 src/corelib/kernel/qobject.cpp                   |   8 ++
 src/corelib/kernel/qobject_p.h                   |   2 +
 src/corelib/tools/qsharedpointer.cpp             |  27 ++++++
 src/corelib/tools/qsharedpointer_impl.h          |  28 ++++--
 tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 110 +++++++++++++++++++++++
 5 files changed, 170 insertions(+), 5 deletions(-)

diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 7e7dcaf..3417232 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -56,6 +56,7 @@
 #include <qvarlengtharray.h>
 #include <qset.h>
 #include <qsemaphore.h>
+#include <qsharedpointer.h>
 
 #include <private/qorderedmutexlocker_p.h>
 #include <private/qmutexpool_p.h>
@@ -768,6 +769,13 @@ QObject::~QObject()
         QObjectPrivate::clearGuards(this);
     }
 
+    if (d->sharedRefcount) {
+        // indicate to all QWeakPointers that this QObject has now been deleted
+        d->sharedRefcount->strongref = 0;
+        if (!d->sharedRefcount->weakref.deref())
+            delete d->sharedRefcount;
+    }
+
     emit destroyed(this);
     if (d->declarativeData)
         d->declarativeData->destroyed(this);
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index e58ee6c..056dee3 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -67,6 +67,7 @@ QT_BEGIN_NAMESPACE
 class QVariant;
 class QThreadData;
 class QObjectConnectionListVector;
+namespace QtSharedPointer { class ExternalRefCountData; }
 
 /* mirrored in QtTestLib, DON'T CHANGE without prior warning */
 struct QSignalSpyCallbackSet
@@ -187,6 +188,7 @@ public:
     // plus QPointer, which keeps a separate list
     QDeclarativeData *declarativeData;
     QGuard<QObject> *objectGuards;
+    QAtomicPointer<QtSharedPointer::ExternalRefCountData> sharedRefcount;
     int *deleteWatch;
 };
 
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index ef4dfac..e2c5e95 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -864,6 +864,33 @@
 #include <qset.h>
 #include <qmutex.h>
 
+#if !defined(QT_NO_QOBJECT)
+#include "../kernel/qobject_p.h"
+
+QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::getAndRef(const QObject *obj)
+{
+    Q_ASSERT(obj);
+    QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj));
+    ExternalRefCountData *that = d->sharedRefcount;
+    if (that) {
+        that->weakref.ref();
+        return that;
+    }
+
+    // we can create the refcount data because it doesn't exist
+    ExternalRefCountData *x = new ExternalRefCountData(Qt::Uninitialized);
+    x->strongref = -1;
+    x->weakref = 2;  // the QWeakPointer that called us plus the QObject itself
+    if (!d->sharedRefcount.testAndSetRelease(0, x)) {
+        delete x;
+        d->sharedRefcount->weakref.ref();
+    }
+    return d->sharedRefcount;
+}
+#endif
+
+
+
 #if !defined(QT_NO_MEMBER_TEMPLATES)
 
 //#  define QT_SHARED_POINTER_BACKTRACE_SUPPORT
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 3ee407c..1fed024 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -162,13 +162,22 @@ namespace QtSharedPointer {
 
     struct ExternalRefCountData
     {
-        QAtomicInt weakref;
-        QAtomicInt strongref;
+        QBasicAtomicInt weakref;
+        QBasicAtomicInt strongref;
 
-        inline ExternalRefCountData() : weakref(1), strongref(1) { }
-        virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref); Q_ASSERT(!strongref); }
+        inline ExternalRefCountData()
+        {
+            QBasicAtomicInt proto = Q_BASIC_ATOMIC_INITIALIZER(1);
+            weakref = strongref = proto;
+        }
+        inline ExternalRefCountData(Qt::Initialization) { }
+        virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref); Q_ASSERT(strongref <= 0); }
 
         virtual inline bool destroy() { return false; }
+
+#ifndef QT_NO_QOBJECT
+        Q_CORE_EXPORT static ExternalRefCountData *getAndRef(const QObject *);
+#endif
     };
     // sizeof(ExternalRefCount) = 12 (32-bit) / 16 (64-bit)
 
@@ -376,7 +385,7 @@ namespace QtSharedPointer {
                     tmp = o->strongref;  // failed, try again
                 }
 
-                if (tmp)
+                if (tmp > 0)
                     o->weakref.ref();
                 else
                     o = 0;
@@ -495,6 +504,15 @@ public:
 
     inline QWeakPointer() : d(0), value(0) { }
     inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }
+
+    // special constructor that is enabled only if X derives from QObject
+    template <class X>
+    inline QWeakPointer(X *ptr) : d(ptr ? d->getAndRef(ptr) : 0), value(ptr)
+    { }
+    template <class X>
+    inline QWeakPointer &operator=(X *ptr)
+    { return *this = QWeakPointer(ptr); }
+
     inline QWeakPointer(const QWeakPointer<T> &o) : d(o.d), value(o.value)
     { if (d) d->weakref.ref(); }
     inline QWeakPointer<T> &operator=(const QWeakPointer<T> &o)
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index 210f3fa..8fd2116 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -67,6 +67,8 @@ private slots:
     void memoryManagement();
     void downCast();
     void upCast();
+    void qobjectWeakManagement();
+    void noSharedPointerFromWeakQObject();
     void objectCast();
     void differentPointers();
     void virtualBaseDifferentPointers();
@@ -503,6 +505,109 @@ class OtherObject: public QObject
     Q_OBJECT
 };
 
+void tst_QSharedPointer::qobjectWeakManagement()
+{
+    {
+        QObject *obj = new QObject;
+        QWeakPointer<QObject> weak(obj);
+        QVERIFY(!weak.isNull());
+        QVERIFY(weak.data() == obj);
+
+        // now delete
+        delete obj;
+        QVERIFY(weak.isNull());
+    }
+    check();
+
+    {
+        // same, bit with operator=
+        QObject *obj = new QObject;
+        QWeakPointer<QObject> weak;
+        weak = obj;
+        QVERIFY(!weak.isNull());
+        QVERIFY(weak.data() == obj);
+
+        // now delete
+        delete obj;
+        QVERIFY(weak.isNull());
+    }
+    check();
+
+    {
+        // delete triggered by parent
+        QObject *obj, *parent;
+        parent = new QObject;
+        obj = new QObject(parent);
+        QWeakPointer<QObject> weak(obj);
+
+        // now delete the parent
+        delete parent;
+        QVERIFY(weak.isNull());
+    }
+    check();
+
+    {
+        // same as above, but set the parent after QWeakPointer is created
+        QObject *obj, *parent;
+        obj = new QObject;
+        QWeakPointer<QObject> weak(obj);
+
+        parent = new QObject;
+        obj->setParent(parent);
+
+        // now delete the parent
+        delete parent;
+        QVERIFY(weak.isNull());
+    }
+    check();
+
+    {
+        // with two QWeakPointers
+        QObject *obj = new QObject;
+        QWeakPointer<QObject> weak(obj);
+
+        {
+            QWeakPointer<QObject> weak2(obj);
+            QVERIFY(!weak2.isNull());
+            QVERIFY(weak == weak2);
+        }
+        QVERIFY(!weak.isNull());
+
+        delete obj;
+        QVERIFY(weak.isNull());
+    }
+    check();
+
+    {
+        // same, but delete the pointer while two QWeakPointers exist
+        QObject *obj = new QObject;
+        QWeakPointer<QObject> weak(obj);
+
+        {
+            QWeakPointer<QObject> weak2(obj);
+            QVERIFY(!weak2.isNull());
+
+            delete obj;
+            QVERIFY(weak.isNull());
+            QVERIFY(weak2.isNull());
+        }
+        QVERIFY(weak.isNull());
+    }
+    check();
+}
+
+void tst_QSharedPointer::noSharedPointerFromWeakQObject()
+{
+    // you're not allowed to create a QSharedPointer from an unmanaged QObject
+    QObject obj;
+    QWeakPointer<QObject> weak(&obj);
+
+    QSharedPointer<QObject> strong = weak.toStrongRef();
+    QVERIFY(strong.isNull());
+
+    // is something went wrong, we'll probably crash here
+}
+
 void tst_QSharedPointer::objectCast()
 {
     {
@@ -1446,6 +1551,11 @@ void tst_QSharedPointer::invalidConstructs_data()
         << &QTest::QExternalTest::tryCompileFail
         << "QSharedPointer<Data> ptr1;\n"
            "QSharedPointer<int> ptr2 = qSharedPointerObjectCast<int>(ptr1);";
+
+    QTest::newRow("weak-pointer-from-regular-pointer")
+        << &QTest::QExternalTest::tryCompileFail
+        << "Data *ptr = 0;\n"
+           "QWeakPointer<Data> weakptr(ptr);\n";
 }
 
 void tst_QSharedPointer::invalidConstructs()
-- 
cgit v0.12


From 520cfa6b6cf4b53a02cc08f01323da036d5b9bea Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Mon, 3 Aug 2009 17:25:16 +0200
Subject: Performance improvements by avoiding creation of temporary
 QSharedPointers with d=value=0

---
 src/corelib/tools/qsharedpointer_impl.h | 68 ++++++++++++---------------------
 1 file changed, 25 insertions(+), 43 deletions(-)

diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 1fed024..421db34 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -94,7 +94,6 @@ namespace QtSharedPointer {
     template <class T> class InternalRefCount;
     template <class T> class ExternalRefCount;
 
-    template <class X, class T> QSharedPointer<X> strongRefFromWeakHelper(const QWeakPointer<T> &, X*);
     template <class X, class Y> QSharedPointer<X> copyAndSetPointer(X * ptr, const QSharedPointer<Y> &src);
 
     // used in debug mode to verify the reuse of pointers
@@ -131,21 +130,10 @@ namespace QtSharedPointer {
         inline T *operator->() const { return data(); }
 
     protected:
-        inline Basic() : value(0) { }
+        inline Basic(T *ptr = 0) : value(ptr) { }
+        inline Basic(Qt::Initialization) { }
         // ~Basic();
 
-        inline void verifyReconstruction(const T *ptr)
-        {
-            Q_ASSERT_X(!ptr || value != ptr, "QSharedPointer",
-                       "QSharedPointer violation: you cannot create two QSharedPointer objects "
-                       "from the same pointer");
-
-            // make use of the "ptr" variable in the no-op statement below
-            // since this function is in a public header, we don't
-            // want warnings on "unused variables" to show up everywhere
-            ptr = 0;
-        }
-
         inline void internalConstruct(T *ptr)
         {
             value = ptr;
@@ -312,9 +300,10 @@ namespace QtSharedPointer {
 #ifdef QT_SHAREDPOINTER_TRACK_POINTERS
             internalConstruct<void (*)(T *)>(ptr, normalDeleter);
 #else
-            Q_ASSERT(!d);
             if (ptr)
                 d = new Data;
+            else
+                d = 0;
             internalFinishConstruction(ptr);
 #endif
         }
@@ -322,9 +311,10 @@ namespace QtSharedPointer {
         template <typename Deleter>
         inline void internalConstruct(T *ptr, Deleter deleter)
         {
-            Q_ASSERT(!d);
             if (ptr)
                 d = ExternalRefCountWithCustomDeleter<T, Deleter>::create(ptr, deleter);
+            else
+                d = 0;
             internalFinishConstruction(ptr);
         }
 
@@ -344,9 +334,13 @@ namespace QtSharedPointer {
         }
 
         inline ExternalRefCount() : d(0) { }
-        inline ~ExternalRefCount() { if (d && !deref()) delete d; }
+        inline ExternalRefCount(Qt::Initialization i) : Basic<T>(i) { }
         inline ExternalRefCount(const ExternalRefCount<T> &other) : Basic<T>(other), d(other.d)
         { if (d) ref(); }
+        template <class X>
+        inline ExternalRefCount(const ExternalRefCount<X> &other) : Basic<T>(other.value), d(other.d)
+        { if (d) ref(); }
+        inline ~ExternalRefCount() { if (d && !deref()) delete d; }
 
         template <class X>
         inline void internalCopy(const ExternalRefCount<X> &other)
@@ -360,23 +354,19 @@ namespace QtSharedPointer {
                 delete this->value;
         }
 
-    private:
 #if defined(Q_NO_TEMPLATE_FRIENDS)
     public:
 #else
         template <class X> friend class ExternalRefCount;
         template <class X> friend class QWeakPointer;
         template <class X, class Y> friend QSharedPointer<X> copyAndSetPointer(X * ptr, const QSharedPointer<Y> &src);
-        template <class X, class Y> friend QSharedPointer<X> QtSharedPointer::strongRefFromWeakHelper(const QWeakPointer<Y> &src, X *);
 #endif
 
         inline void internalSet(Data *o, T *actual)
         {
-            if (d == o) return;
             if (o) {
-                verifyReconstruction(actual);
-
                 // increase the strongref, but never up from zero
+                // or less (-1 is used by QWeakPointer on untracked QObject)
                 register int tmp = o->strongref;
                 while (tmp > 0) {
                     // try to increment from "tmp" to "tmp + 1"
@@ -411,7 +401,8 @@ public:
     inline QSharedPointer() { }
     // inline ~QSharedPointer() { }
 
-    inline explicit QSharedPointer(T *ptr) { internalConstruct(ptr); }
+    inline explicit QSharedPointer(T *ptr) : BaseClass(Qt::Uninitialized)
+    { internalConstruct(ptr); }
 
     template <typename Deleter>
     inline QSharedPointer(T *ptr, Deleter d) { internalConstruct(ptr, d); }
@@ -423,13 +414,9 @@ public:
         return *this;
     }
 
-    inline QSharedPointer(const QWeakPointer<T> &other)
-    { *this = QtSharedPointer::strongRefFromWeakHelper(other, static_cast<T*>(0)); }
-    inline QSharedPointer<T> &operator=(const QWeakPointer<T> &other)
-    { *this = QtSharedPointer::strongRefFromWeakHelper(other, static_cast<T*>(0)); return *this; }
-
     template <class X>
-    inline QSharedPointer(const QSharedPointer<X> &other) { *this = other; }
+    inline QSharedPointer(const QSharedPointer<X> &other) : BaseClass(other)
+    { }
 
     template <class X>
     inline QSharedPointer<T> &operator=(const QSharedPointer<X> &other)
@@ -440,12 +427,12 @@ public:
     }
 
     template <class X>
-    inline QSharedPointer(const QWeakPointer<X> &other)
-    { *this = QtSharedPointer::strongRefFromWeakHelper(other, static_cast<T *>(0)); }
+    inline QSharedPointer(const QWeakPointer<X> &other) : BaseClass(Qt::Uninitialized)
+    { this->d = 0; *this = other; }
 
     template <class X>
     inline QSharedPointer<T> &operator=(const QWeakPointer<X> &other)
-    { *this = strongRefFromWeakHelper(other, static_cast<T *>(0)); return *this; }
+    { internalSet(other.d, other.value); return *this; }
 
     template <class X>
     QSharedPointer<X> staticCast() const
@@ -477,10 +464,13 @@ public:
 
     QWeakPointer<T> toWeakRef() const;
 
+protected:
+    inline QSharedPointer(Qt::Initialization i) : BaseClass(i) {}
+
 public:
     static inline QSharedPointer<T> create()
     {
-        QSharedPointer<T> result;
+        QSharedPointer<T> result(Qt::Uninitialized);
         result.internalCreate();
 
         // now initialize the data
@@ -564,7 +554,7 @@ public:
 
     template <class X>
     inline bool operator==(const QSharedPointer<X> &o) const
-    { return d == o.d && value == static_cast<const T *>(o.data()); }
+    { return d == o.d; }
 
     template <class X>
     inline bool operator!=(const QSharedPointer<X> &o) const
@@ -579,7 +569,7 @@ private:
 #if defined(Q_NO_TEMPLATE_FRIENDS)
 public:
 #else
-    template <class X, class Y> friend QSharedPointer<X> QtSharedPointer::strongRefFromWeakHelper(const QWeakPointer<Y> &src, X *);
+    template <class X> friend class QSharedPointer;
 #endif
 
     inline void internalSet(Data *o, T *actual)
@@ -656,14 +646,6 @@ namespace QtSharedPointer {
         result.internalSet(src.d, ptr);
         return result;
     }
-    template <class X, class T>
-    Q_INLINE_TEMPLATE QSharedPointer<X> strongRefFromWeakHelper
-        (const QT_PREPEND_NAMESPACE(QWeakPointer<T>) &src, X *)
-    {
-        QSharedPointer<X> result;
-        result.internalSet(src.d, src.value);
-        return result;
-    }
 }
 
 // cast operators
-- 
cgit v0.12


From d1150c5bbf6be125d496ce71570140ea28836ba5 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Wed, 5 Aug 2009 11:26:34 +0200
Subject: Restore symmetry between QSharedPointer and QWeakPointer on QObjects.

With the previous commit, you could create a QWeakPointer from any
QObject-derived object. It's possible because QObject now has a
pointer to the QWeakPointer's d-pointer.

However, if you did:
    QSharedPointer<QObject> obj(new QObject);
    QWeakPointer<QObject> weak1(obj);
    QWeakPointer<QObject> weak2(obj.data());

Then weak1 would shared d-pointers with QSharedPointer, but weak2
wouldn't. Also, weak1.toStrongRef() would work, but
weak2.toStrongRef() wouldn't.

This change makes QObject know where the d-pointer created by
QSharedPointer is, so weak2 would get the same d-pointer.

As a nice side-effect, you can check if a given QObject is shared by
trying to promote its QWeakPointer to QSharedPointer.

Reviewed-by: Bradley T. Hughes
---
 src/corelib/kernel/qobject.cpp                   |  5 ++++
 src/corelib/tools/qsharedpointer.cpp             | 23 ++++++++++++++++++
 src/corelib/tools/qsharedpointer_impl.h          |  3 +++
 tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 31 ++++++++++++++++++++++++
 4 files changed, 62 insertions(+)

diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 3417232..e37b6d3 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -770,6 +770,11 @@ QObject::~QObject()
     }
 
     if (d->sharedRefcount) {
+        if (d->sharedRefcount->strongref > 0) {
+            qWarning("QObject: shared QObject was deleted directly. The program is malformed and may crash.");
+            // but continue deleting, it's too late to stop anyway
+        }
+
         // indicate to all QWeakPointers that this QObject has now been deleted
         d->sharedRefcount->strongref = 0;
         if (!d->sharedRefcount->weakref.deref())
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index e2c5e95..10f35c7 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -867,6 +867,29 @@
 #if !defined(QT_NO_QOBJECT)
 #include "../kernel/qobject_p.h"
 
+/*!
+    \internal
+    This function is called for a just-created QObject \a obj, to enable
+    the use of QSharedPointer and QWeakPointer.
+
+    When QSharedPointer is active in a QObject, the object must not be deleted
+    directly: the lifetime is managed by the QSharedPointer object. In that case,
+    the deleteLater() and parent-child relationship in QObject only decrease
+    the strong reference count, instead of deleting the object.
+*/
+void QtSharedPointer::ExternalRefCountData::setQObjectShared(const QObject *obj, bool)
+{
+    Q_ASSERT(obj);
+    QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj));
+
+    if (d->sharedRefcount)
+        qFatal("QSharedPointer: pointer %p already has reference counting", obj);
+    d->sharedRefcount = this;
+
+    // QObject decreases the refcount too, so increase it up
+    weakref.ref();
+}
+
 QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::getAndRef(const QObject *obj)
 {
     Q_ASSERT(obj);
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 421db34..8a34362 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -165,7 +165,9 @@ namespace QtSharedPointer {
 
 #ifndef QT_NO_QOBJECT
         Q_CORE_EXPORT static ExternalRefCountData *getAndRef(const QObject *);
+        Q_CORE_EXPORT void setQObjectShared(const QObject *, bool enable);
 #endif
+        inline void setQObjectShared(...) { }
     };
     // sizeof(ExternalRefCount) = 12 (32-bit) / 16 (64-bit)
 
@@ -328,6 +330,7 @@ namespace QtSharedPointer {
         inline void internalFinishConstruction(T *ptr)
         {
             Basic<T>::internalConstruct(ptr);
+            if (ptr) d->setQObjectShared(ptr, true);
 #ifdef QT_SHAREDPOINTER_TRACK_POINTERS
             if (ptr) internalSafetyCheckAdd2(d, ptr);
 #endif
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index 8fd2116..5214edb 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -69,6 +69,7 @@ private slots:
     void upCast();
     void qobjectWeakManagement();
     void noSharedPointerFromWeakQObject();
+    void weakQObjectFromSharedPointer();
     void objectCast();
     void differentPointers();
     void virtualBaseDifferentPointers();
@@ -81,6 +82,7 @@ private slots:
     void constCorrectness();
     void customDeleter();
     void creating();
+    void creatingQObject();
     void mixTrackingPointerCode();
     void threadStressTest_data();
     void threadStressTest();
@@ -608,6 +610,19 @@ void tst_QSharedPointer::noSharedPointerFromWeakQObject()
     // is something went wrong, we'll probably crash here
 }
 
+void tst_QSharedPointer::weakQObjectFromSharedPointer()
+{
+    // this is the inverse of the above: you're allowed to create a QWeakPointer
+    // from a managed QObject
+    QSharedPointer<QObject> shared(new QObject);
+    QWeakPointer<QObject> weak = shared.data();
+    QVERIFY(!weak.isNull());
+
+    // delete:
+    shared.clear();
+    QVERIFY(weak.isNull());
+}
+
 void tst_QSharedPointer::objectCast()
 {
     {
@@ -1186,6 +1201,13 @@ void tst_QSharedPointer::customDeleter()
     QCOMPARE(dataDeleter.callCount, 0);
     QCOMPARE(derivedDataDeleter.callCount, 1);
     QCOMPARE(refcount, 2);
+    check();
+}
+
+void customQObjectDeleterFn(QObject *obj)
+{
+    ++customDeleterFnCallCount;
+    delete obj;
 }
 
 void tst_QSharedPointer::creating()
@@ -1252,7 +1274,10 @@ void tst_QSharedPointer::creating()
         QCOMPARE(baseptr->classLevel(), 4);
     }
     check();
+}
 
+void tst_QSharedPointer::creatingQObject()
+{
     {
         QSharedPointer<QObject> ptr = QSharedPointer<QObject>::create();
         QCOMPARE(ptr->metaObject(), &QObject::staticMetaObject);
@@ -1556,6 +1581,12 @@ void tst_QSharedPointer::invalidConstructs_data()
         << &QTest::QExternalTest::tryCompileFail
         << "Data *ptr = 0;\n"
            "QWeakPointer<Data> weakptr(ptr);\n";
+
+    QTest::newRow("shared-pointer-from-unmanaged-qobject")
+        << &QTest::QExternalTest::tryRunFail
+        << "QObject *ptr = new QObject;\n"
+           "QWeakPointer<QObject> weak = ptr;\n"    // this makes the object unmanaged
+           "QSharedPointer<QObject> shared(ptr);\n";
 }
 
 void tst_QSharedPointer::invalidConstructs()
-- 
cgit v0.12


From 3d3bf7cf3c94225be59966d1c6b79559cc251f95 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Wed, 5 Aug 2009 12:11:42 +0200
Subject: Autotest: add QSharedPointer and QWeakPointer tests for QWidget too

I don't want to link the tst_qsharedpointer test to QtGui, so I
created a new test.

This is testing only the basic manipulations. In special, it's not
testing invalid constructs.
---
 tests/auto/auto.pro                                |   3 +-
 .../qsharedpointer_and_qwidget.pro                 |   3 +
 .../tst_qsharedpointer_and_qwidget.cpp             | 150 +++++++++++++++++++++
 3 files changed, 155 insertions(+), 1 deletion(-)
 create mode 100644 tests/auto/qsharedpointer_and_qwidget/qsharedpointer_and_qwidget.pro
 create mode 100644 tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp

diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 2550dcd..c923dee 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -270,7 +270,8 @@ SUBDIRS += _networkselftest \
            qscriptenginedebugger \
            qscrollarea \
            qsemaphore \
-	   qsharedpointer \
+           qsharedpointer \
+           qsharedpointer_and_qwidget \
            qsequentialanimationgroup \
            qset \
            qsettings \
diff --git a/tests/auto/qsharedpointer_and_qwidget/qsharedpointer_and_qwidget.pro b/tests/auto/qsharedpointer_and_qwidget/qsharedpointer_and_qwidget.pro
new file mode 100644
index 0000000..db647a5
--- /dev/null
+++ b/tests/auto/qsharedpointer_and_qwidget/qsharedpointer_and_qwidget.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+SOURCES += tst_qsharedpointer_and_qwidget.cpp
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
diff --git a/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp b/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp
new file mode 100644
index 0000000..66727c2
--- /dev/null
+++ b/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QWidget>
+#include <QtGui/QPushButton>
+#include <QtTest/QtTest>
+
+namespace QtSharedPointer {
+    Q_CORE_EXPORT void internalSafetyCheckCleanCheck();
+}
+
+class tst_QSharedPointer_and_QWidget: public QObject
+{
+    Q_OBJECT
+private slots:
+    void weak_externalDelete();
+    void weak_parentDelete();
+    void weak_parentDelete_setParent();
+
+    void strong_weak();
+
+    void strong_sharedptrDelete();
+
+public slots:
+    void cleanup() { check(); }
+
+public:
+    inline void check()
+    {
+#ifdef QT_BUILD_INTERNAL
+        QtSharedPointer::internalSafetyCheckCleanCheck();
+#endif
+    }
+};
+
+void tst_QSharedPointer_and_QWidget::weak_externalDelete()
+{
+    QWidget *w = new QWidget;
+    QWeakPointer<QWidget> ptr = w;
+
+    QVERIFY(!ptr.isNull());
+
+    delete w;
+    QVERIFY(ptr.isNull());
+}
+
+void tst_QSharedPointer_and_QWidget::weak_parentDelete()
+{
+    QWidget *parent = new QWidget;
+    QWidget *w = new QWidget(parent);
+    QWeakPointer<QWidget> ptr = w;
+
+    QVERIFY(!ptr.isNull());
+
+    delete parent;
+    QVERIFY(ptr.isNull());
+}
+
+void tst_QSharedPointer_and_QWidget::weak_parentDelete_setParent()
+{
+    QWidget *parent = new QWidget;
+    QWidget *w = new QWidget;
+    QWeakPointer<QWidget> ptr = w;
+    w->setParent(parent);
+
+    QVERIFY(!ptr.isNull());
+
+    delete parent;
+    QVERIFY(ptr.isNull());
+}
+
+// -- mixed --
+
+void tst_QSharedPointer_and_QWidget::strong_weak()
+{
+    QSharedPointer<QWidget> ptr(new QWidget);
+    QWeakPointer<QWidget> weak = ptr.data();
+    QWeakPointer<QWidget> weak2 = ptr;
+
+    QVERIFY(!weak.isNull());
+    QVERIFY(!weak2.isNull());
+
+    ptr.clear(); // deletes
+
+    QVERIFY(weak.isNull());
+    QVERIFY(weak2.isNull());
+}
+
+
+// ---- strong management ----
+
+void tst_QSharedPointer_and_QWidget::strong_sharedptrDelete()
+{
+    QWidget *parent = new QWidget;
+    QSharedPointer<QWidget> ptr(new QWidget(parent));
+    QWeakPointer<QWidget> weak = ptr;
+    QPointer<QWidget> check = ptr.data();
+
+    QVERIFY(!check.isNull());
+    QVERIFY(!weak.isNull());
+
+    ptr.clear();  // deletes
+
+    QVERIFY(check.isNull());
+    QVERIFY(weak.isNull());
+
+    delete parent; // mustn't crash
+}
+
+QTEST_MAIN(tst_QSharedPointer_and_QWidget)
+
+#include "tst_qsharedpointer_and_qwidget.moc"
-- 
cgit v0.12


From e9210d6882a5a2d07492b4f98576f3465d2f0aa1 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Wed, 5 Aug 2009 14:34:12 +0200
Subject: Doc: fix qdoc errors in QSharedPointer documentation.

I added the documentation to QWeakPointer::data, but I forgot to
declare the class in the qdoc stub.

Also, apparently I cannot link to a specific overload of a given
function.

Reviewed-by: Volker Hilsheimer
---
 src/corelib/tools/qsharedpointer.cpp | 4 ++--
 src/corelib/tools/qsharedpointer.h   | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 10f35c7..f18dee8 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -365,7 +365,7 @@
     Returns a weak reference object that shares the pointer referenced
     by this object.
 
-    \sa QWeakPointer::QWeakPointer(const QSharedPointer<T> &)
+    \sa QWeakPointer::QWeakPointer()
 */
 
 /*!
@@ -553,7 +553,7 @@
             qDebug() << "The value has already been deleted";
     \endcode
 
-    \sa QSharedPointer::QSharedPointer(const QWeakPointer<T> &)
+    \sa QSharedPointer::QSharedPointer()
 */
 
 /*!
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index abd83ad..2f86ce7 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -115,6 +115,7 @@ public:
     QWeakPointer<T> operator=(const QWeakPointer<T> &other);
     QWeakPointer<T> operator=(const QSharedPointer<T> &other);
 
+    T *data() const;
     void clear();
 
     QSharedPointer<T> toStrongRef() const;
-- 
cgit v0.12


From fb8bb148affec842e8fa1a70616c64c7d3066ee8 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Wed, 5 Aug 2009 15:36:47 +0200
Subject: cetcpsync: unneeded error message removed

If file deletion fails then I don't want to know it.
cetest tries to delete files more than once.
---
 tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp
index 4a8ae2b..76d3b4b 100644
--- a/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp
+++ b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp
@@ -295,7 +295,8 @@ bool QtCesterConnection::deleteFile(const QString &fileName)
     }
     
     if (!_checkResult(socket)) {
-        END_ERROR(socket, "File Deletion failed");
+        //END_ERROR(socket, "File Deletion failed");
+        // This is actually not an error so ignore it.
     }
     
     _freeSocket(socket);
-- 
cgit v0.12


From 8f839bb7b18e9140af7842daa142b0224d8680d7 Mon Sep 17 00:00:00 2001
From: Leonardo Sobral Cunha <leo.cunha@nokia.com>
Date: Wed, 5 Aug 2009 17:46:01 +0200
Subject: Adds qgraphicsgridlayout & qgraphicstransform to autotest build

Also removed tabs from auto.pro

Reviewed-by: trustme
---
 tests/auto/auto.pro | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index c923dee..3d7abdc 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -13,8 +13,8 @@ SUBDIRS += _networkselftest \
            linguist \
            macgui \
            macplist \
-	   mediaobject \
-#	   mediaobject_wince_ds9 \   This is Windows CE only (we test the second phonon backend ds9 here)
+           mediaobject \
+#           mediaobject_wince_ds9 \   This is Windows CE only (we test the second phonon backend ds9 here)
            moc \
            modeltest \
            q3accel \
@@ -105,8 +105,8 @@ SUBDIRS += _networkselftest \
            qdate \
            qdatetime \
            qdatetimeedit \
-	   qdbuspendingcall \
-	   qdbuspendingreply \
+           qdbuspendingcall \
+           qdbuspendingreply \
            qdebug \
            qdesktopservices \
            qdesktopwidget \
@@ -140,6 +140,7 @@ SUBDIRS += _networkselftest \
            qgetputenv \
            qgl \
            qglobal \
+           qgraphicsgridlayout \
            qgraphicsitem \
            qgraphicsitemanimation \
            qgraphicslayout \
@@ -147,13 +148,14 @@ SUBDIRS += _networkselftest \
            qgraphicslinearlayout \
            qgraphicsobject \
            qgraphicspixmapitem \
-	   qgraphicspolygonitem \
-	   qgraphicsproxywidget \
+           qgraphicspolygonitem \
+           qgraphicsproxywidget \
            qgraphicsscene \
            qgraphicssceneindex \
+           qgraphicstransform \
            qgraphicsview \
            qgraphicswidget \
-	   qgridlayout \
+           qgridlayout \
            qgroupbox \
            qguivariant \
            qhash \
@@ -166,8 +168,8 @@ SUBDIRS += _networkselftest \
            qhostaddress \
            qhostinfo \
            qhttp \
-	   qhttpnetworkreply \
-	   qhttpnetworkconnection \
+           qhttpnetworkreply \
+           qhttpnetworkconnection \
            qicon \
            qicoimageformat \
            qimage \
@@ -190,7 +192,7 @@ SUBDIRS += _networkselftest \
            qlibrary \
            qline \
            qlineedit \
-           qlist \           
+           qlist \
            q3listbox \
            qlistview \
            qlistwidget \
@@ -212,12 +214,12 @@ SUBDIRS += _networkselftest \
            qmutex \
            qmutexlocker \
            qnativesocketengine \
-	   qnetworkcookie \
-	   qnetworkcookiejar \
+           qnetworkcookie \
+           qnetworkcookiejar \
            qnetworkinterface \
            qnetworkproxy \
-	   qnetworkrequest \
-	   qnetworkreply \
+           qnetworkrequest \
+           qnetworkreply \
            qnetworkaccessmanager_and_qprogressdialog \
            qnumeric \
            qobject \
@@ -352,7 +354,7 @@ SUBDIRS += _networkselftest \
            qtextstream \
            qtexttable \
            qthread \
-	   qthreadonce \
+           qthreadonce \
            qthreadstorage \
            qtime \
            qtimeline \
@@ -454,7 +456,7 @@ unix:!embedded:contains(QT_CONFIG, dbus):SUBDIRS += \
            qdbusmarshall \
            qdbusmetaobject \
            qdbusmetatype \
-	   qdbusperformance \
+           qdbusperformance \
            qdbusreply \
            qdbusthreading \
            qdbusxmlparser
-- 
cgit v0.12


From 64031a8a69d5f71d73208447e0b1f7108aabd2fc Mon Sep 17 00:00:00 2001
From: Alan Alpert <alan.alpert@nokia.com>
Date: Thu, 6 Aug 2009 11:19:16 +1000
Subject: Compile Fix for QT_KEYPAD_NAVIGATION

---
 src/gui/widgets/qdatetimeedit.cpp |  4 ----
 src/gui/widgets/qlinecontrol.cpp  | 10 +++++-----
 src/gui/widgets/qlinecontrol_p.h  |  3 +++
 src/gui/widgets/qlineedit.cpp     |  5 +++--
 src/gui/widgets/qlineedit.h       |  3 +++
 src/gui/widgets/qlineedit_p.cpp   | 12 ++++++++++++
 src/gui/widgets/qlineedit_p.h     |  3 +++
 7 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp
index 5ddf7f7..cb76876 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/gui/widgets/qdatetimeedit.cpp
@@ -1086,10 +1086,6 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
 
                 //hide cursor
                 d->edit->d_func()->setCursorVisible(false);
-                if (d->edit->d_func()->cursorTimer > 0)
-                    killTimer(d->edit->d_func()->cursorTimer);
-                d->edit->d_func()->cursorTimer = 0;
-
                 d->setSelected(0);
             }
         }
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index f68d287..d90d53b 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -1295,7 +1295,7 @@ bool QLineControl::processEvent(QEvent* ev)
                 }
                 if ((ev->type() == QEvent::KeyRelease)
                     && !isReadOnly()
-                    && deleteAllTimer) {
+                    && m_deleteAllTimer) {
                     killTimer(m_deleteAllTimer);
                     m_deleteAllTimer = 0;
                     backspace();
@@ -1701,12 +1701,12 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
                     if (text().length() == 0) {
                         setText(m_cancelText);
 
-                        if (passwordEchoEditing)
+                        if (passwordEchoEditing())
                             updatePasswordEchoEditing(false);
 
-                        setEditFocus(false);
-                    } else if (!deleteAllTimer) {
-                        deleteAllTimer = startTimer(750);
+                        emit editFocusChange(false);
+                    } else if (!m_deleteAllTimer) {
+                        m_deleteAllTimer = startTimer(750);
                     }
                 } else {
                     unknown = true;
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index 9cad857..e047cb0 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -343,6 +343,9 @@ Q_SIGNALS:
     void editingFinished();
     void updateNeeded(const QRect &);
 
+#ifdef QT_KEYPAD_NAVIGATION
+    void editFocusChange(bool);
+#endif
 protected:
     virtual void timerEvent(QTimerEvent *event);
 
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index e0f5bc9..9f315fd 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1669,7 +1669,7 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
             selectAll();
     }
 #ifdef QT_KEYPAD_NAVIGATION
-    if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason))
+    if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)){
 #endif
     int cft = QApplication::cursorFlashTime();
     d->control->setCursorBlinkPeriod(cft/2);
@@ -1683,7 +1683,8 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
         qt_mac_secure_keyboard(true);
 #endif
 #ifdef QT_KEYPAD_NAVIGATION
-    d->control->setCancelText(d->text);
+        d->control->setCancelText(d->control->text());
+    }
 #endif
 #ifndef QT_NO_COMPLETER
     if (d->control->completer()) {
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
index daac6a7..32ef6a4 100644
--- a/src/gui/widgets/qlineedit.h
+++ b/src/gui/widgets/qlineedit.h
@@ -273,6 +273,9 @@ private:
 #ifndef QT_NO_COMPLETER
     Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(QString))
 #endif
+#ifdef QT_KEYPAD_NAVIGATION
+    Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool))
+#endif
 };
 
 #endif // QT_NO_LINEEDIT
diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp
index f0ec8ad..aed454e 100644
--- a/src/gui/widgets/qlineedit_p.cpp
+++ b/src/gui/widgets/qlineedit_p.cpp
@@ -126,6 +126,14 @@ void QLineEditPrivate::_q_cursorPositionChanged(int from, int to)
     emit q->cursorPositionChanged(from, to);
 }
 
+#ifdef QT_KEYPAD_NAVIGATION
+void QLineEditPrivate::_q_editFocusChange(bool e)
+{
+    Q_Q(QLineEdit);
+    q->setEditFocus(e);
+}
+#endif
+
 void QLineEditPrivate::init(const QString& txt)
 {
     Q_Q(QLineEdit);
@@ -142,6 +150,10 @@ void QLineEditPrivate::init(const QString& txt)
             q, SIGNAL(returnPressed()));
     QObject::connect(control, SIGNAL(editingFinished()),
             q, SIGNAL(editingFinished()));
+#ifdef QT_KEYPAD_NAVIGATION
+    QObject::connect(control, SIGNAL(editFocusChange(bool)),
+            q, SLOT(_q_editFocusChange(bool)));
+#endif
 
     // for now, going completely overboard with updates.
     QObject::connect(control, SIGNAL(selectionChanged()),
diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h
index 230023d..976e31f 100644
--- a/src/gui/widgets/qlineedit_p.h
+++ b/src/gui/widgets/qlineedit_p.h
@@ -125,6 +125,9 @@ public:
     void _q_deleteSelected();
     void _q_textEdited(const QString &);
     void _q_cursorPositionChanged(int, int);
+#ifdef QT_KEYPAD_NAVIGATION
+    void _q_editFocusChange(bool);
+#endif
 
 #ifndef QT_NO_COMPLETER
     void _q_completionHighlighted(QString);
-- 
cgit v0.12


From 31fa1d0f6144e7e92748b33f8633eeb2f52483a1 Mon Sep 17 00:00:00 2001
From: Alan Alpert <alan.alpert@nokia.com>
Date: Thu, 6 Aug 2009 13:24:51 +1000
Subject: Make QLineEdit cursor blink again

Somehow forgot to hook up the blinking signal (in the new QLineControl)
to QLineEdit.

Reviewed-by: Trust Me
---
 src/gui/widgets/qlineedit_p.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp
index aed454e..d907233 100644
--- a/src/gui/widgets/qlineedit_p.cpp
+++ b/src/gui/widgets/qlineedit_p.cpp
@@ -161,6 +161,9 @@ void QLineEditPrivate::init(const QString& txt)
 
     QObject::connect(control, SIGNAL(displayTextChanged(const QString &)),
             q, SLOT(update()));
+
+    QObject::connect(control, SIGNAL(updateNeeded(const QRect &)),
+            q, SLOT(update()));
     control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter));
 #ifndef QT_NO_CURSOR
     q->setCursor(Qt::IBeamCursor);
-- 
cgit v0.12


From 56b349951a70f3ab95e334e41e37f017e91cf481 Mon Sep 17 00:00:00 2001
From: Rohan McGovern <rohan.mcgovern@nokia.com>
Date: Thu, 6 Aug 2009 11:04:23 +1000
Subject: Cleaned up test naming and platform-specific tests.

When an autotest fails to compile, there's no way to determine which
testcase(s) have been prevented from running.

Our results parsing tools have been guessing, under the assumption that
a directory called `qdogwalker' always contains a testcase named
`tst_qdogwalker'.  That wasn't true for all our tests, so let's make it
true.

Also changed the platform-specific tests so that qmake will simply skip
those tests on unsupported platforms, instead of wasting time compiling
a useless QTEST_NOOP_MAIN test.
---
 tests/auto/_networkselftest/_networkselftest.pro   |    6 -
 .../auto/_networkselftest/tst_networkselftest.cpp  |  586 -----
 tests/auto/auto.pro                                |    7 +-
 tests/auto/macgui/macgui.pro                       |   10 +-
 tests/auto/macgui/tst_gui.cpp                      |  277 --
 tests/auto/macgui/tst_macgui.cpp                   |  278 ++
 tests/auto/networkselftest/networkselftest.pro     |    6 +
 tests/auto/networkselftest/tst_networkselftest.cpp |  586 +++++
 .../auto/qaccessibility_mac/qaccessibility_mac.pro |   23 +-
 .../qaccessibility_mac/tst_qaccessibility_mac.cpp  |   64 +-
 tests/auto/qcopchannel/qcopchannel.pro             |    1 +
 tests/auto/qcopchannel/test/test.pro               |    8 -
 tests/auto/qcopchannel/testSend/testSend.pro       |    1 +
 tests/auto/qcssparser/qcssparser.pro               |    2 +-
 tests/auto/qcssparser/tst_cssparser.cpp            | 1616 ------------
 tests/auto/qcssparser/tst_qcssparser.cpp           | 1617 ++++++++++++
 tests/auto/qdbuspendingcall/qdbuspendingcall.pro   |    5 +-
 tests/auto/qdbuspendingreply/qdbuspendingreply.pro |    4 +-
 tests/auto/qdirectpainter/qdirectpainter.pro       |    4 +-
 .../runDirectPainter/runDirectPainter.pro          |    1 +
 tests/auto/qdirectpainter/test/test.pro            |    9 +-
 tests/auto/qicoimageformat/qicoimageformat.pro     |    2 +-
 tests/auto/qicoimageformat/tst_qicoimageformat.cpp |  299 +++
 .../auto/qicoimageformat/tst_qticoimageformat.cpp  |  298 ---
 tests/auto/qmultiscreen/qmultiscreen.pro           |    2 +-
 tests/auto/qpointarray/.gitignore                  |    1 -
 tests/auto/qpointarray/qpointarray.pro             |    6 -
 tests/auto/qpointarray/tst_qpointarray.cpp         |   95 -
 tests/auto/qpolygon/.gitignore                     |    1 +
 tests/auto/qpolygon/qpolygon.pro                   |    6 +
 tests/auto/qpolygon/tst_qpolygon.cpp               |   95 +
 tests/auto/qresourceengine/qresourceengine.pro     |    2 +-
 tests/auto/qresourceengine/tst_qresourceengine.cpp |  462 ++++
 tests/auto/qresourceengine/tst_resourceengine.cpp  |  461 ----
 tests/auto/qscriptextqobject/.gitignore            |    1 +
 tests/auto/qscriptextqobject/qscriptextqobject.pro |    5 +
 .../qscriptextqobject/tst_qscriptextqobject.cpp    | 2734 ++++++++++++++++++++
 .../qscriptjstestsuite/tst_qscriptjstestsuite.cpp  |    9 +-
 tests/auto/qscriptqobject/.gitignore               |    1 -
 tests/auto/qscriptqobject/qscriptqobject.pro       |    5 -
 tests/auto/qscriptqobject/tst_qscriptqobject.cpp   | 2734 --------------------
 .../qscriptv8testsuite/tst_qscriptv8testsuite.cpp  |    7 +-
 .../qtextscriptengine/tst_qtextscriptengine.cpp    |   36 +-
 43 files changed, 6183 insertions(+), 6190 deletions(-)
 delete mode 100644 tests/auto/_networkselftest/_networkselftest.pro
 delete mode 100644 tests/auto/_networkselftest/tst_networkselftest.cpp
 delete mode 100644 tests/auto/macgui/tst_gui.cpp
 create mode 100644 tests/auto/macgui/tst_macgui.cpp
 create mode 100644 tests/auto/networkselftest/networkselftest.pro
 create mode 100644 tests/auto/networkselftest/tst_networkselftest.cpp
 delete mode 100644 tests/auto/qcssparser/tst_cssparser.cpp
 create mode 100644 tests/auto/qcssparser/tst_qcssparser.cpp
 create mode 100644 tests/auto/qicoimageformat/tst_qicoimageformat.cpp
 delete mode 100644 tests/auto/qicoimageformat/tst_qticoimageformat.cpp
 delete mode 100644 tests/auto/qpointarray/.gitignore
 delete mode 100644 tests/auto/qpointarray/qpointarray.pro
 delete mode 100644 tests/auto/qpointarray/tst_qpointarray.cpp
 create mode 100644 tests/auto/qpolygon/.gitignore
 create mode 100644 tests/auto/qpolygon/qpolygon.pro
 create mode 100644 tests/auto/qpolygon/tst_qpolygon.cpp
 create mode 100644 tests/auto/qresourceengine/tst_qresourceengine.cpp
 delete mode 100644 tests/auto/qresourceengine/tst_resourceengine.cpp
 create mode 100644 tests/auto/qscriptextqobject/.gitignore
 create mode 100644 tests/auto/qscriptextqobject/qscriptextqobject.pro
 create mode 100644 tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
 delete mode 100644 tests/auto/qscriptqobject/.gitignore
 delete mode 100644 tests/auto/qscriptqobject/qscriptqobject.pro
 delete mode 100644 tests/auto/qscriptqobject/tst_qscriptqobject.cpp

diff --git a/tests/auto/_networkselftest/_networkselftest.pro b/tests/auto/_networkselftest/_networkselftest.pro
deleted file mode 100644
index 9e2ad0e..0000000
--- a/tests/auto/_networkselftest/_networkselftest.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-
-SOURCES += tst_networkselftest.cpp
-QT = core network
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
diff --git a/tests/auto/_networkselftest/tst_networkselftest.cpp b/tests/auto/_networkselftest/tst_networkselftest.cpp
deleted file mode 100644
index cb82733..0000000
--- a/tests/auto/_networkselftest/tst_networkselftest.cpp
+++ /dev/null
@@ -1,586 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtNetwork/QtNetwork>
-#include "../network-settings.h"
-
-class tst_NetworkSelfTest: public QObject
-{
-    Q_OBJECT
-private slots:
-    void hostTest();
-    void dnsResolution_data();
-    void dnsResolution();
-    void serverReachability();
-    void remotePortsOpen_data();
-    void remotePortsOpen();
-
-    // specific protocol tests
-    void ftpServer();
-    void imapServer();
-    void httpServer();
-    void httpsServer();
-    void httpProxy();
-    void httpProxyBasicAuth();
-    void httpProxyNtlmAuth();
-    void socks5Proxy();
-    void socks5ProxyAuth();
-};
-
-class Chat
-{
-public:
-    enum Type {
-        Reconnect,
-        Send,
-        Expect,
-        SkipBytes,
-        DiscardUntil,
-        DiscardUntilDisconnect,
-        Disconnect,
-        RemoteDisconnect,
-        StartEncryption
-    };
-    Chat(Type t, const QByteArray &d)
-        : data(d), type(t)
-    {
-    }
-    Chat(Type t, int val = 0)
-        : value(val), type(t)
-    {
-    }
-
-    static inline Chat send(const QByteArray &data)
-    { return Chat(Send, data); }
-    static inline Chat expect(const QByteArray &data)
-    { return Chat(Expect, data); }
-    static inline Chat discardUntil(const QByteArray &data)
-    { return Chat(DiscardUntil, data); }
-    static inline Chat skipBytes(int count)
-    { return Chat(SkipBytes, count); }
-
-    QByteArray data;
-    int value;
-    Type type;
-};
-
-static QString prettyByteArray(const QByteArray &array)
-{
-    // any control chars?
-    QString result;
-    result.reserve(array.length() + array.length() / 3);
-    for (int i = 0; i < array.length(); ++i) {
-        char c = array.at(i);
-        switch (c) {
-        case '\n':
-            result += "\\n";
-            continue;
-        case '\r':
-            result += "\\r";
-            continue;
-        case '\t':
-            result += "\\t";
-            continue;
-        case '"':
-            result += "\\\"";
-            continue;
-        default:
-            break;
-        }
-
-        if (c < 0x20 || uchar(c) >= 0x7f) {
-            result += '\\';
-            result += QString::number(uchar(c), 8);
-        } else {
-            result += c;
-        }
-    }
-    return result;
-}
-
-static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 2000)
-{
-    QTime timer;
-    timer.start();
-    forever {
-        if (socket->bytesAvailable() >= minBytesAvailable)
-            return true;
-        if (socket->state() == QAbstractSocket::UnconnectedState
-            || timer.elapsed() >= timeout)
-            return false;
-        if (!socket->waitForReadyRead(timeout - timer.elapsed()))
-            return false;
-    }
-}
-
-static bool doSocketFlush(QTcpSocket *socket, int timeout = 2000)
-{
-#ifndef QT_NO_OPENSSL
-    QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket);
-#endif
-    QTime timer;
-    timer.start();
-    forever {
-        if (socket->bytesToWrite() == 0
-#ifndef QT_NO_OPENSSL
-            && sslSocket->encryptedBytesToWrite() == 0
-#endif
-            )
-            return true;
-        if (socket->state() == QAbstractSocket::UnconnectedState
-            || timer.elapsed() >= timeout)
-            return false;
-        if (!socket->waitForBytesWritten(timeout - timer.elapsed()))
-            return false;
-    }
-}
-
-static void netChat(int port, const QList<Chat> &chat)
-{
-#ifndef QT_NO_OPENSSL
-    QSslSocket socket;
-#else
-    QTcpSocket socket;
-#endif
-
-    socket.connectToHost(QtNetworkSettings::serverName(), port);
-    qDebug() << 0 << "Connecting to server on port" << port;
-    QVERIFY2(socket.waitForConnected(10000),
-             QString("Failed to connect to server in step 0: %1").arg(socket.errorString()).toLocal8Bit());
-
-    // now start the chat
-    QList<Chat>::ConstIterator it = chat.constBegin();
-    for (int i = 1; it != chat.constEnd(); ++it, ++i) {
-        switch (it->type) {
-            case Chat::Expect: {
-                    qDebug() << i << "Expecting" << prettyByteArray(it->data);
-                    if (!doSocketRead(&socket, it->data.length()))
-                        QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
-
-                    // pop that many bytes off the socket
-                    QByteArray received = socket.read(it->data.length());
-
-                    // is it what we expected?
-                    QVERIFY2(received == it->data,
-                             QString("Did not receive expected data in step %1: data received was:\n%2")
-                             .arg(i).arg(prettyByteArray(received)).toLocal8Bit());
-
-                    break;
-                }
-
-            case Chat::DiscardUntil:
-                qDebug() << i << "Discarding until" << prettyByteArray(it->data);
-                while (true) {
-                    // scan the buffer until we have our string
-                    if (!doSocketRead(&socket, it->data.length()))
-                        QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
-
-                    QByteArray buffer;
-                    buffer.resize(socket.bytesAvailable());
-                    socket.peek(buffer.data(), socket.bytesAvailable());
-
-                    int pos = buffer.indexOf(it->data);
-                    if (pos == -1) {
-                        // data not found, keep trying
-                        continue;
-                    }
-
-                    buffer = socket.read(pos + it->data.length());
-                    qDebug() << i << "Discarded" << prettyByteArray(buffer);
-                    break;
-                }
-                break;
-
-            case Chat::SkipBytes: {
-                    qDebug() << i << "Skipping" << it->value << "bytes";
-                    if (!doSocketRead(&socket, it->value))
-                        QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
-
-                    // now discard the bytes
-                    QByteArray buffer = socket.read(it->value);
-                    qDebug() << i << "Skipped" << prettyByteArray(buffer);
-                    break;
-                }
-
-            case Chat::Send: {
-                    qDebug() << i << "Sending" << prettyByteArray(it->data);
-                    socket.write(it->data);
-                    if (!doSocketFlush(&socket)) {
-                        QVERIFY2(socket.state() == QAbstractSocket::ConnectedState,
-                                 QString("Socket disconnected while sending data in step %1").arg(i).toLocal8Bit());
-                        QFAIL(QString("Failed to send data in step %1: timeout").arg(i).toLocal8Bit());
-                    }
-                    break;
-                }
-
-            case Chat::Disconnect:
-                qDebug() << i << "Disconnecting from host";
-                socket.disconnectFromHost();
-
-                // is this the last command?
-                if (it + 1 != chat.constEnd())
-                    break;
-
-                // fall through:
-            case Chat::RemoteDisconnect:
-            case Chat::DiscardUntilDisconnect:
-                qDebug() << i << "Waiting for remote disconnect";
-                if (socket.state() != QAbstractSocket::UnconnectedState)
-                    socket.waitForDisconnected(10000);
-                QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState,
-                         QString("Socket did not disconnect as expected in step %1").arg(i).toLocal8Bit());
-
-                // any data left?
-                if (it->type == Chat::DiscardUntilDisconnect) {
-                    QByteArray buffer = socket.readAll();
-                    qDebug() << i << "Discarded in the process:" << prettyByteArray(buffer);
-                }
-
-                if (socket.bytesAvailable() != 0)
-                    QFAIL(QString("Unexpected bytes still on buffer when disconnecting in step %1:\n%2")
-                          .arg(i).arg(prettyByteArray(socket.readAll())).toLocal8Bit());
-                break;
-
-            case Chat::Reconnect:
-                qDebug() << i << "Reconnecting to server on port" << port;
-                socket.connectToHost(QtNetworkSettings::serverName(), port);
-                QVERIFY2(socket.waitForConnected(10000),
-                         QString("Failed to reconnect to server in step %1: %2").arg(i).arg(socket.errorString()).toLocal8Bit());
-                break;
-
-            case Chat::StartEncryption:
-#ifdef QT_NO_OPENSSL
-                QFAIL("Internal error: SSL required for this test");
-#else
-                qDebug() << i << "Starting client encryption";
-                socket.ignoreSslErrors();
-                socket.startClientEncryption();
-                QVERIFY2(socket.waitForEncrypted(5000),
-                         QString("Failed to start client encryption in step %1: %2").arg(i)
-                         .arg(socket.errorString()).toLocal8Bit());
-                break;
-#endif
-            }
-    }
-}
-
-void tst_NetworkSelfTest::hostTest()
-{
-    // this is a localhost self-test
-    QHostInfo localhost = QHostInfo::fromName("localhost");
-    QCOMPARE(localhost.error(), QHostInfo::NoError);
-    QVERIFY(!localhost.addresses().isEmpty());
-
-    QTcpServer server;
-    QVERIFY(server.listen());
-
-    QTcpSocket socket;
-    socket.connectToHost("127.0.0.1", server.serverPort());
-    QVERIFY(socket.waitForConnected(10000));
-}
-
-void tst_NetworkSelfTest::dnsResolution_data()
-{
-    QTest::addColumn<QString>("hostName");
-    QTest::newRow("local-name") << QtNetworkSettings::serverLocalName();
-    QTest::newRow("fqdn") << QtNetworkSettings::serverName();
-}
-
-void tst_NetworkSelfTest::dnsResolution()
-{
-    QFETCH(QString, hostName);
-    QHostInfo resolved = QHostInfo::fromName(hostName);
-    QVERIFY2(resolved.error() == QHostInfo::NoError,
-             QString("Failed to resolve hostname %1: %2").arg(hostName, resolved.errorString()).toLocal8Bit());
-}
-
-void tst_NetworkSelfTest::serverReachability()
-{
-    // check that we get a proper error connecting to port 1
-    QTcpSocket socket;
-    socket.connectToHost(QtNetworkSettings::serverName(), 1);
-    socket.waitForConnected(10000);
-    QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
-    QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
-             QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
-}
-
-void tst_NetworkSelfTest::remotePortsOpen_data()
-{
-    QTest::addColumn<int>("portNumber");
-    QTest::newRow("ftp") << 21;
-    QTest::newRow("ssh") << 22;
-    QTest::newRow("imap") << 143;
-    QTest::newRow("http") << 80;
-    QTest::newRow("https") << 443;
-    QTest::newRow("http-proxy") << 3128;
-    QTest::newRow("http-proxy-auth-basic") << 3129;
-    QTest::newRow("http-proxy-auth-ntlm") << 3130;
-    QTest::newRow("socks5-proxy") << 1080;
-    QTest::newRow("socks5-proxy-auth") << 1081;
-}
-
-void tst_NetworkSelfTest::remotePortsOpen()
-{
-    QFETCH(int, portNumber);
-    QTcpSocket socket;
-    socket.connectToHost(QtNetworkSettings::serverName(), portNumber);
-
-    if (!socket.waitForConnected(10000)) {
-        if (socket.error() == QAbstractSocket::SocketTimeoutError)
-            QFAIL(QString("Network timeout connecting to the server on port %1").arg(portNumber).toLocal8Bit());
-        else
-            QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit());
-    }
-    QVERIFY(socket.state() == QAbstractSocket::ConnectedState);
-}
-
-static QList<Chat> ftpChat()
-{
-    return QList<Chat>() << Chat::expect("220")
-            << Chat::discardUntil("\r\n")
-            << Chat::send("USER anonymous\r\n")
-            << Chat::expect("331")
-            << Chat::discardUntil("\r\n")
-            << Chat::send("PASS user@hostname\r\n")
-            << Chat::expect("230")
-            << Chat::discardUntil("\r\n")
-            << Chat::send("QUIT\r\n")
-            << Chat::expect("221")
-            << Chat::discardUntil("\r\n")
-            << Chat::RemoteDisconnect;
-}
-
-void tst_NetworkSelfTest::ftpServer()
-{
-    netChat(21, ftpChat());
-}
-
-void tst_NetworkSelfTest::imapServer()
-{
-    netChat(143, QList<Chat>()
-            << Chat::expect("* OK ")
-            << Chat::discardUntil("\r\n")
-            << Chat::send("1 CAPABILITY\r\n")
-            << Chat::expect("* CAPABILITY ")
-            << Chat::discardUntil("1 OK")
-            << Chat::discardUntil("\r\n")
-            << Chat::send("2 LOGOUT\r\n")
-            << Chat::discardUntil("2 OK")
-            << Chat::discardUntil("\r\n")
-            << Chat::RemoteDisconnect);
-}
-
-void tst_NetworkSelfTest::httpServer()
-{
-    netChat(80, QList<Chat>()
-            // HTTP/0.9 chat:
-            << Chat::send("GET /\r\n")
-            << Chat::DiscardUntilDisconnect
-
-            // HTTP/1.0 chat:
-            << Chat::Reconnect
-            << Chat::send("GET / HTTP/1.0\r\n"
-                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
-                          "Connection: close\r\n"
-                          "\r\n")
-            << Chat::expect("HTTP/1.")
-            << Chat::discardUntil(" ")
-            << Chat::expect("200 ")
-            << Chat::DiscardUntilDisconnect
-
-            // HTTP/1.0 POST:
-            << Chat::Reconnect
-            << Chat::send("POST / HTTP/1.0\r\n"
-                          "Content-Length: 5\r\n"
-                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
-                          "Connection: close\r\n"
-                          "\r\n"
-                          "Hello")
-            << Chat::expect("HTTP/1.")
-            << Chat::discardUntil(" ")
-            << Chat::expect("200 ")
-            << Chat::DiscardUntilDisconnect
-            );
-}
-
-void tst_NetworkSelfTest::httpsServer()
-{
-#ifndef QT_NO_OPENSSL
-    netChat(443, QList<Chat>()
-            << Chat::StartEncryption
-            << Chat::send("GET / HTTP/1.0\r\n"
-                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
-                          "Connection: close\r\n"
-                          "\r\n")
-            << Chat::expect("HTTP/1.")
-            << Chat::discardUntil(" ")
-            << Chat::expect("200 ")
-            << Chat::DiscardUntilDisconnect);
-#else
-    QSKIP("SSL not enabled, cannot test", SkipAll);
-#endif
-}
-
-void tst_NetworkSelfTest::httpProxy()
-{
-    netChat(3128, QList<Chat>()
-            // proxy GET
-            << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
-                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
-                          "Proxy-connection: close\r\n"
-                          "\r\n")
-            << Chat::expect("HTTP/1.")
-            << Chat::discardUntil(" ")
-            << Chat::expect("200 ")
-            << Chat::DiscardUntilDisconnect
-
-            // proxy CONNECT
-            << Chat::Reconnect
-            << Chat::send("CONNECT " + QtNetworkSettings::serverName().toLatin1() + ":21 HTTP/1.0\r\n"
-                          "\r\n")
-            << Chat::expect("HTTP/1.")
-            << Chat::discardUntil(" ")
-            << Chat::expect("200 ")
-            << Chat::discardUntil("\r\n\r\n")
-            << ftpChat());
-}
-
-void tst_NetworkSelfTest::httpProxyBasicAuth()
-{
-    netChat(3129, QList<Chat>()
-            // test auth required response
-            << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
-                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
-                          "Proxy-connection: close\r\n"
-                          "\r\n")
-            << Chat::expect("HTTP/1.")
-            << Chat::discardUntil(" ")
-            << Chat::expect("407 ")
-            << Chat::discardUntil("\r\nProxy-Authenticate: Basic realm=\"")
-            << Chat::DiscardUntilDisconnect
-
-            // now try sending our credentials
-            << Chat::Reconnect
-            << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
-                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
-                          "Proxy-connection: close\r\n"
-                          "Proxy-Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n"
-                          "\r\n")
-            << Chat::expect("HTTP/1.")
-            << Chat::discardUntil(" ")
-            << Chat::expect("200 ")
-            << Chat::DiscardUntilDisconnect);
-}
-
-void tst_NetworkSelfTest::httpProxyNtlmAuth()
-{
-    netChat(3130, QList<Chat>()
-            // test auth required response
-            << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
-                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
-                          "Proxy-connection: keep-alive\r\n" // NTLM auth will disconnect
-                          "\r\n")
-            << Chat::expect("HTTP/1.")
-            << Chat::discardUntil(" ")
-            << Chat::expect("407 ")
-            << Chat::discardUntil("\r\nProxy-Authenticate: NTLM\r\n")
-            << Chat::DiscardUntilDisconnect
-            );
-}
-
-// SOCKSv5 is a binary protocol
-static const char handshakeNoAuth[] = "\5\1\0";
-static const char handshakeOkNoAuth[] = "\5\0";
-static const char handshakeAuthPassword[] = "\5\1\2\1\12qsockstest\10password";
-static const char handshakeOkPasswdAuth[] = "\5\2\1\0";
-static const char handshakeAuthNotOk[] = "\5\377";
-static const char connect1[] = "\5\1\0\1\177\0\0\1\0\25"; // Connect IPv4 127.0.0.1 port 21
-static const char connect2[] = "\5\1\0\3\11localhost\0\25"; // Connect hostname localhost 21
-static const char connected[] = "\5\0\0";
-
-void tst_NetworkSelfTest::socks5Proxy()
-{
-    netChat(1080, QList<Chat>()
-            // IP address connection
-            << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth))
-            << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth))
-            << Chat::send(QByteArray(connect1, -1 + sizeof connect1))
-            << Chat::expect(QByteArray(connected, -1 + sizeof connected))
-            << Chat::expect("\1") // IPv4 address following
-            << Chat::skipBytes(6) // the server's local address and port
-            << ftpChat()
-
-            // hostname connection
-            << Chat::Reconnect
-            << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth))
-            << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth))
-            << Chat::send(QByteArray(connect2, -1 + sizeof connect2))
-            << Chat::expect(QByteArray(connected, -1 + sizeof connected))
-            << Chat::expect("\1") // IPv4 address following
-            << Chat::skipBytes(6) // the server's local address and port
-            << ftpChat()
-            );
-}
-
-void tst_NetworkSelfTest::socks5ProxyAuth()
-{
-    netChat(1081, QList<Chat>()
-            // unauthenticated connect -- will get error
-            << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth))
-            << Chat::expect(QByteArray(handshakeAuthNotOk, -1 + sizeof handshakeAuthNotOk))
-            << Chat::RemoteDisconnect
-
-            // now try to connect with authentication
-            << Chat::Reconnect
-            << Chat::send(QByteArray(handshakeAuthPassword, -1 + sizeof handshakeAuthPassword))
-            << Chat::expect(QByteArray(handshakeOkPasswdAuth, -1 + sizeof handshakeOkPasswdAuth))
-            << Chat::send(QByteArray(connect1, -1 + sizeof connect1))
-            << Chat::expect(QByteArray(connected, -1 + sizeof connected))
-            << Chat::expect("\1") // IPv4 address following
-            << Chat::skipBytes(6) // the server's local address and port
-            << ftpChat()
-            );
-}
-
-QTEST_MAIN(tst_NetworkSelfTest)
-#include "tst_networkselftest.moc"
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index fd887fd..10257d9 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -4,7 +4,7 @@ TEMPLATE = subdirs
 !wince*:SUBDIRS += \
            headers
 
-SUBDIRS += _networkselftest \
+SUBDIRS += \
            bic \
            collections \
            compile \
@@ -17,6 +17,7 @@ SUBDIRS += _networkselftest \
 #	   mediaobject_wince_ds9 \   This is Windows CE only (we test the second phonon backend ds9 here)
            moc \
            modeltest \
+           networkselftest \
            q3accel \
            q3action \
            q3actiongroup \
@@ -224,8 +225,8 @@ SUBDIRS += _networkselftest \
            qpixmapfilter \
            qplaintextedit \
            qpoint \
-           qpointarray \
            qpointer \
+           qpolygon \
            qprinter \
            qprinterinfo \
            qprocess \
@@ -247,9 +248,9 @@ SUBDIRS += _networkselftest \
            qscriptcontextinfo \
            qscriptengine \
            qscriptengineagent \
+           qscriptextqobject \
            qscriptjstestsuite \
            qscriptv8testsuite \
-           qscriptqobject \
            qscriptstring \
            qscriptvalue \
            qscriptvalueiterator \
diff --git a/tests/auto/macgui/macgui.pro b/tests/auto/macgui/macgui.pro
index dc64627..0ed2350 100644
--- a/tests/auto/macgui/macgui.pro
+++ b/tests/auto/macgui/macgui.pro
@@ -4,12 +4,8 @@ DEPENDPATH += .
 INCLUDEPATH += .
 
 # Input
-SOURCES += tst_gui.cpp 
-
-mac {
-    SOURCES += guitest.cpp
-    HEADERS += guitest.h
-}
-
+SOURCES += tst_macgui.cpp guitest.cpp
+HEADERS += guitest.h
 
+requires(mac)
 
diff --git a/tests/auto/macgui/tst_gui.cpp b/tests/auto/macgui/tst_gui.cpp
deleted file mode 100644
index 635023a..0000000
--- a/tests/auto/macgui/tst_gui.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QApplication>
-#include <QMessageBox> 
-#include <QtTest/QtTest>
-#include <QSplashScreen>
-#include <QScrollBar>
-#include <QProgressDialog>
-#include <QSpinBox>
-
-#include <guitest.h>
-
-#ifdef Q_OS_MAC
-
-class tst_gui : public GuiTester
-{
-Q_OBJECT
-private slots:
-    void scrollbarPainting();
-    
-    void dummy();
-    void splashScreenModality();
-    void dialogModality();
-    void nonModalOrder();
-
-    void spinBoxArrowButtons();
-};
-
-
-QPixmap grabWindowContents(QWidget * widget)
-{
-    return QPixmap::grabWindow(widget->winId());
-}
-
-/*
-    Test that vertical and horizontal mac-style scrollbars paint their
-    entire area.
-*/
-void tst_gui::scrollbarPainting()
-{
-    ColorWidget colorWidget;
-    colorWidget.resize(400, 400);
-
-    QSize scrollBarSize;
-
-    QScrollBar verticalScrollbar(&colorWidget);
-    verticalScrollbar.move(10, 10);
-    scrollBarSize = verticalScrollbar.sizeHint();
-    scrollBarSize.setHeight(200);
-    verticalScrollbar.resize(scrollBarSize);
-
-    QScrollBar horizontalScrollbar(&colorWidget);
-    horizontalScrollbar.move(30, 10);
-    horizontalScrollbar.setOrientation(Qt::Horizontal);
-    scrollBarSize = horizontalScrollbar.sizeHint();
-    scrollBarSize.setWidth(200);
-    horizontalScrollbar.resize(scrollBarSize);
-
-    colorWidget.show();
-    colorWidget.raise();
-    QTest::qWait(100);
-
-    QPixmap pixmap = grabWindowContents(&colorWidget);
-
-    QVERIFY(isContent(pixmap.toImage(), verticalScrollbar.geometry(), GuiTester::Horizontal));
-    QVERIFY(isContent(pixmap.toImage(), horizontalScrollbar.geometry(), GuiTester::Vertical));
-}
-
-// When running the auto-tests on scruffy, the first enter-the-event-loop-and-wait-for-a-click
-// test that runs always times out, so we have this dummy test.
-void tst_gui::dummy()
-{
-    QPixmap pix(100, 100);
-    QSplashScreen splash(pix);
-    splash.show();
-
-    QMessageBox *box = new QMessageBox();
-    box->setText("accessible?");
-    box->show();
-
-    // Find the "OK" button and schedule a press.
-    InterfaceChildPair interface = wn.find(QAccessible::Name, "OK", box);
-    QVERIFY(interface.iface);
-    const int delay = 1000;
-    clickLater(interface, Qt::LeftButton, delay);
-
-    // Show dialog and and enter event loop.
-    connect(wn.getWidget(interface), SIGNAL(clicked()), SLOT(exitLoopSlot()));
-    const int timeout = 4;
-    QTestEventLoop::instance().enterLoop(timeout);
-}
-
-/*
-    Test that a message box pops up in front of a QSplashScreen.
-*/
-void tst_gui::splashScreenModality()
-{
-    QPixmap pix(300, 300);
-    QSplashScreen splash(pix);
-    splash.show();
-
-    QMessageBox box;
-    //box.setWindowFlags(box.windowFlags() | Qt::WindowStaysOnTopHint);
-    box.setText("accessible?");
-    box.show();
-
-    // Find the "OK" button and schedule a press.
-    InterfaceChildPair interface = wn.find(QAccessible::Name, "OK", &box);
-    QVERIFY(interface.iface);
-    const int delay = 1000;
-    clickLater(interface, Qt::LeftButton, delay);
-
-    // Show dialog and and enter event loop.
-    connect(wn.getWidget(interface), SIGNAL(clicked()), SLOT(exitLoopSlot()));
-    const int timeout = 4;
-    QTestEventLoop::instance().enterLoop(timeout);
-    QVERIFY(QTestEventLoop::instance().timeout() == false);
-}
-
-
-/*
-    Test that a non-modal dialog created as a child of a modal dialog is
-    shown in front.
-*/
-void tst_gui::dialogModality()
-{ 
-    QDialog d;
-    d.setModal(true);
-    d.show();
-    
-    QProgressDialog progress(&d);
-    progress.setValue(2);
-
-    InterfaceChildPair interface = wn.find(QAccessible::Name, "Cancel", &progress);
-    QVERIFY(interface.iface);
-    const int delay = 2000;
-    clickLater(interface, Qt::LeftButton, delay);
-    
-    connect(&progress, SIGNAL(canceled()), SLOT(exitLoopSlot()));
-
-    const int timeout = 3;
-    QTestEventLoop::instance().enterLoop(timeout);
-    QVERIFY(QTestEventLoop::instance().timeout() == false);
-}
-
-class PrimaryWindowDialog : public QDialog
-{
-Q_OBJECT
-public:
-    PrimaryWindowDialog();
-    QWidget *secondaryWindow;
-    QWidget *frontWidget;
-public slots:
-    void showSecondaryWindow();
-    void test();
-};
-
-PrimaryWindowDialog::PrimaryWindowDialog() : QDialog(0)
-{
-    frontWidget = 0;
-    secondaryWindow = new ColorWidget(this);
-    secondaryWindow->setWindowFlags(Qt::Window);
-    secondaryWindow->resize(400, 400);
-    secondaryWindow->move(100, 100);
-    QTimer::singleShot(1000, this, SLOT(showSecondaryWindow()));
-    QTimer::singleShot(2000, this, SLOT(test()));
-    QTimer::singleShot(3000, this, SLOT(close()));
-}
-
-void PrimaryWindowDialog::showSecondaryWindow()
-{
-    secondaryWindow->show();
-}
-
-void PrimaryWindowDialog::test()
-{
-    frontWidget = QApplication::widgetAt(secondaryWindow->mapToGlobal(QPoint(100, 100)));
-}
-
-/*
-    Test that a non-modal child window of a modal dialog is shown in front
-    of the dialog even if the dialog becomes modal after the child window
-    is created.
-*/
-void tst_gui::nonModalOrder()
-{
-    clearSequence();
-    PrimaryWindowDialog primary;
-    primary.resize(400, 400);
-    primary.move(100, 100);
-    primary.exec();
-    QCOMPARE(primary.frontWidget, primary.secondaryWindow);
-}
-
-/*
-    Test that the QSpinBox buttons are correctly positioned with the Mac style.
-*/
-void tst_gui::spinBoxArrowButtons()
-{
-    ColorWidget colorWidget;
-    colorWidget.resize(200, 200);
-    QSpinBox spinBox(&colorWidget);
-    QSpinBox spinBox2(&colorWidget);
-    spinBox2.move(0, 100);
-    colorWidget.show();
-    QTest::qWait(100);
-    
-    // Grab an unfocused spin box.
-    const QImage noFocus = grabWindowContents(&colorWidget).toImage();
-
-    // Set focus by clicking the less button.
-    InterfaceChildPair lessInterface = wn.find(QAccessible::Name, "Less", &spinBox);
-    QVERIFY(lessInterface.iface);
-    const int delay = 500;
-    clickLater(lessInterface, Qt::LeftButton, delay);
-    const int timeout = 1;
-    QTestEventLoop::instance().enterLoop(timeout);
-
-    // Grab a focused spin box.
-    const QImage focus = grabWindowContents(&colorWidget).toImage();
-
-    // Compare the arrow area of the less button to see if it moved.
-    const QRect lessRect = lessInterface.iface->rect(lessInterface.possibleChild);
-    const QRect lessLocalRect(colorWidget.mapFromGlobal(lessRect.topLeft()), colorWidget.mapFromGlobal(lessRect.bottomRight()));
-    const QRect compareRect = lessLocalRect.adjusted(5, 3, -5, -7);
-    QVERIFY(noFocus.copy(compareRect) == focus.copy(compareRect));
-}
-
-QTEST_MAIN(tst_gui)
-
-#else
-
-QTEST_NOOP_MAIN
-
-#endif
-
-#include "tst_gui.moc"
diff --git a/tests/auto/macgui/tst_macgui.cpp b/tests/auto/macgui/tst_macgui.cpp
new file mode 100644
index 0000000..627dc82
--- /dev/null
+++ b/tests/auto/macgui/tst_macgui.cpp
@@ -0,0 +1,278 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QApplication>
+#include <QMessageBox> 
+#include <QtTest/QtTest>
+#include <QSplashScreen>
+#include <QScrollBar>
+#include <QProgressDialog>
+#include <QSpinBox>
+
+#include <guitest.h>
+
+#ifdef Q_OS_MAC
+
+class tst_MacGui : public GuiTester
+{
+Q_OBJECT
+private slots:
+    void scrollbarPainting();
+    
+    void dummy();
+    void splashScreenModality();
+    void dialogModality();
+    void nonModalOrder();
+
+    void spinBoxArrowButtons();
+};
+
+
+QPixmap grabWindowContents(QWidget * widget)
+{
+    return QPixmap::grabWindow(widget->winId());
+}
+
+/*
+    Test that vertical and horizontal mac-style scrollbars paint their
+    entire area.
+*/
+void tst_MacGui::scrollbarPainting()
+{
+    ColorWidget colorWidget;
+    colorWidget.resize(400, 400);
+
+    QSize scrollBarSize;
+
+    QScrollBar verticalScrollbar(&colorWidget);
+    verticalScrollbar.move(10, 10);
+    scrollBarSize = verticalScrollbar.sizeHint();
+    scrollBarSize.setHeight(200);
+    verticalScrollbar.resize(scrollBarSize);
+
+    QScrollBar horizontalScrollbar(&colorWidget);
+    horizontalScrollbar.move(30, 10);
+    horizontalScrollbar.setOrientation(Qt::Horizontal);
+    scrollBarSize = horizontalScrollbar.sizeHint();
+    scrollBarSize.setWidth(200);
+    horizontalScrollbar.resize(scrollBarSize);
+
+    colorWidget.show();
+    colorWidget.raise();
+    QTest::qWait(100);
+
+    QPixmap pixmap = grabWindowContents(&colorWidget);
+
+    QVERIFY(isContent(pixmap.toImage(), verticalScrollbar.geometry(), GuiTester::Horizontal));
+    QVERIFY(isContent(pixmap.toImage(), horizontalScrollbar.geometry(), GuiTester::Vertical));
+}
+
+// When running the auto-tests on scruffy, the first enter-the-event-loop-and-wait-for-a-click
+// test that runs always times out, so we have this dummy test.
+void tst_MacGui::dummy()
+{
+    QPixmap pix(100, 100);
+    QSplashScreen splash(pix);
+    splash.show();
+
+    QMessageBox *box = new QMessageBox();
+    box->setText("accessible?");
+    box->show();
+
+    // Find the "OK" button and schedule a press.
+    InterfaceChildPair interface = wn.find(QAccessible::Name, "OK", box);
+    QVERIFY(interface.iface);
+    const int delay = 1000;
+    clickLater(interface, Qt::LeftButton, delay);
+
+    // Show dialog and and enter event loop.
+    connect(wn.getWidget(interface), SIGNAL(clicked()), SLOT(exitLoopSlot()));
+    const int timeout = 4;
+    QTestEventLoop::instance().enterLoop(timeout);
+}
+
+/*
+    Test that a message box pops up in front of a QSplashScreen.
+*/
+void tst_MacGui::splashScreenModality()
+{
+    QPixmap pix(300, 300);
+    QSplashScreen splash(pix);
+    splash.show();
+
+    QMessageBox box;
+    //box.setWindowFlags(box.windowFlags() | Qt::WindowStaysOnTopHint);
+    box.setText("accessible?");
+    box.show();
+
+    // Find the "OK" button and schedule a press.
+    InterfaceChildPair interface = wn.find(QAccessible::Name, "OK", &box);
+    QVERIFY(interface.iface);
+    const int delay = 1000;
+    clickLater(interface, Qt::LeftButton, delay);
+
+    // Show dialog and and enter event loop.
+    connect(wn.getWidget(interface), SIGNAL(clicked()), SLOT(exitLoopSlot()));
+    const int timeout = 4;
+    QTestEventLoop::instance().enterLoop(timeout);
+    QVERIFY(QTestEventLoop::instance().timeout() == false);
+}
+
+
+/*
+    Test that a non-modal dialog created as a child of a modal dialog is
+    shown in front.
+*/
+void tst_MacGui::dialogModality()
+{ 
+    QDialog d;
+    d.setModal(true);
+    d.show();
+    
+    QProgressDialog progress(&d);
+    progress.setValue(2);
+
+    InterfaceChildPair interface = wn.find(QAccessible::Name, "Cancel", &progress);
+    QVERIFY(interface.iface);
+    const int delay = 2000;
+    clickLater(interface, Qt::LeftButton, delay);
+    
+    connect(&progress, SIGNAL(canceled()), SLOT(exitLoopSlot()));
+
+    const int timeout = 3;
+    QTestEventLoop::instance().enterLoop(timeout);
+    QVERIFY(QTestEventLoop::instance().timeout() == false);
+}
+
+class PrimaryWindowDialog : public QDialog
+{
+Q_OBJECT
+public:
+    PrimaryWindowDialog();
+    QWidget *secondaryWindow;
+    QWidget *frontWidget;
+public slots:
+    void showSecondaryWindow();
+    void test();
+};
+
+PrimaryWindowDialog::PrimaryWindowDialog() : QDialog(0)
+{
+    frontWidget = 0;
+    secondaryWindow = new ColorWidget(this);
+    secondaryWindow->setWindowFlags(Qt::Window);
+    secondaryWindow->resize(400, 400);
+    secondaryWindow->move(100, 100);
+    QTimer::singleShot(1000, this, SLOT(showSecondaryWindow()));
+    QTimer::singleShot(2000, this, SLOT(test()));
+    QTimer::singleShot(3000, this, SLOT(close()));
+}
+
+void PrimaryWindowDialog::showSecondaryWindow()
+{
+    secondaryWindow->show();
+}
+
+void PrimaryWindowDialog::test()
+{
+    frontWidget = QApplication::widgetAt(secondaryWindow->mapToGlobal(QPoint(100, 100)));
+}
+
+/*
+    Test that a non-modal child window of a modal dialog is shown in front
+    of the dialog even if the dialog becomes modal after the child window
+    is created.
+*/
+void tst_MacGui::nonModalOrder()
+{
+    clearSequence();
+    PrimaryWindowDialog primary;
+    primary.resize(400, 400);
+    primary.move(100, 100);
+    primary.exec();
+    QCOMPARE(primary.frontWidget, primary.secondaryWindow);
+}
+
+/*
+    Test that the QSpinBox buttons are correctly positioned with the Mac style.
+*/
+void tst_MacGui::spinBoxArrowButtons()
+{
+    ColorWidget colorWidget;
+    colorWidget.resize(200, 200);
+    QSpinBox spinBox(&colorWidget);
+    QSpinBox spinBox2(&colorWidget);
+    spinBox2.move(0, 100);
+    colorWidget.show();
+    QTest::qWait(100);
+    
+    // Grab an unfocused spin box.
+    const QImage noFocus = grabWindowContents(&colorWidget).toImage();
+
+    // Set focus by clicking the less button.
+    InterfaceChildPair lessInterface = wn.find(QAccessible::Name, "Less", &spinBox);
+    QVERIFY(lessInterface.iface);
+    const int delay = 500;
+    clickLater(lessInterface, Qt::LeftButton, delay);
+    const int timeout = 1;
+    QTestEventLoop::instance().enterLoop(timeout);
+
+    // Grab a focused spin box.
+    const QImage focus = grabWindowContents(&colorWidget).toImage();
+
+    // Compare the arrow area of the less button to see if it moved.
+    const QRect lessRect = lessInterface.iface->rect(lessInterface.possibleChild);
+    const QRect lessLocalRect(colorWidget.mapFromGlobal(lessRect.topLeft()), colorWidget.mapFromGlobal(lessRect.bottomRight()));
+    const QRect compareRect = lessLocalRect.adjusted(5, 3, -5, -7);
+    QVERIFY(noFocus.copy(compareRect) == focus.copy(compareRect));
+}
+
+QTEST_MAIN(tst_MacGui)
+
+#else
+
+QTEST_NOOP_MAIN
+
+#endif
+
+#include "tst_macgui.moc"
+
diff --git a/tests/auto/networkselftest/networkselftest.pro b/tests/auto/networkselftest/networkselftest.pro
new file mode 100644
index 0000000..9e2ad0e
--- /dev/null
+++ b/tests/auto/networkselftest/networkselftest.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES += tst_networkselftest.cpp
+QT = core network
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp
new file mode 100644
index 0000000..cb82733
--- /dev/null
+++ b/tests/auto/networkselftest/tst_networkselftest.cpp
@@ -0,0 +1,586 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtNetwork/QtNetwork>
+#include "../network-settings.h"
+
+class tst_NetworkSelfTest: public QObject
+{
+    Q_OBJECT
+private slots:
+    void hostTest();
+    void dnsResolution_data();
+    void dnsResolution();
+    void serverReachability();
+    void remotePortsOpen_data();
+    void remotePortsOpen();
+
+    // specific protocol tests
+    void ftpServer();
+    void imapServer();
+    void httpServer();
+    void httpsServer();
+    void httpProxy();
+    void httpProxyBasicAuth();
+    void httpProxyNtlmAuth();
+    void socks5Proxy();
+    void socks5ProxyAuth();
+};
+
+class Chat
+{
+public:
+    enum Type {
+        Reconnect,
+        Send,
+        Expect,
+        SkipBytes,
+        DiscardUntil,
+        DiscardUntilDisconnect,
+        Disconnect,
+        RemoteDisconnect,
+        StartEncryption
+    };
+    Chat(Type t, const QByteArray &d)
+        : data(d), type(t)
+    {
+    }
+    Chat(Type t, int val = 0)
+        : value(val), type(t)
+    {
+    }
+
+    static inline Chat send(const QByteArray &data)
+    { return Chat(Send, data); }
+    static inline Chat expect(const QByteArray &data)
+    { return Chat(Expect, data); }
+    static inline Chat discardUntil(const QByteArray &data)
+    { return Chat(DiscardUntil, data); }
+    static inline Chat skipBytes(int count)
+    { return Chat(SkipBytes, count); }
+
+    QByteArray data;
+    int value;
+    Type type;
+};
+
+static QString prettyByteArray(const QByteArray &array)
+{
+    // any control chars?
+    QString result;
+    result.reserve(array.length() + array.length() / 3);
+    for (int i = 0; i < array.length(); ++i) {
+        char c = array.at(i);
+        switch (c) {
+        case '\n':
+            result += "\\n";
+            continue;
+        case '\r':
+            result += "\\r";
+            continue;
+        case '\t':
+            result += "\\t";
+            continue;
+        case '"':
+            result += "\\\"";
+            continue;
+        default:
+            break;
+        }
+
+        if (c < 0x20 || uchar(c) >= 0x7f) {
+            result += '\\';
+            result += QString::number(uchar(c), 8);
+        } else {
+            result += c;
+        }
+    }
+    return result;
+}
+
+static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 2000)
+{
+    QTime timer;
+    timer.start();
+    forever {
+        if (socket->bytesAvailable() >= minBytesAvailable)
+            return true;
+        if (socket->state() == QAbstractSocket::UnconnectedState
+            || timer.elapsed() >= timeout)
+            return false;
+        if (!socket->waitForReadyRead(timeout - timer.elapsed()))
+            return false;
+    }
+}
+
+static bool doSocketFlush(QTcpSocket *socket, int timeout = 2000)
+{
+#ifndef QT_NO_OPENSSL
+    QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket);
+#endif
+    QTime timer;
+    timer.start();
+    forever {
+        if (socket->bytesToWrite() == 0
+#ifndef QT_NO_OPENSSL
+            && sslSocket->encryptedBytesToWrite() == 0
+#endif
+            )
+            return true;
+        if (socket->state() == QAbstractSocket::UnconnectedState
+            || timer.elapsed() >= timeout)
+            return false;
+        if (!socket->waitForBytesWritten(timeout - timer.elapsed()))
+            return false;
+    }
+}
+
+static void netChat(int port, const QList<Chat> &chat)
+{
+#ifndef QT_NO_OPENSSL
+    QSslSocket socket;
+#else
+    QTcpSocket socket;
+#endif
+
+    socket.connectToHost(QtNetworkSettings::serverName(), port);
+    qDebug() << 0 << "Connecting to server on port" << port;
+    QVERIFY2(socket.waitForConnected(10000),
+             QString("Failed to connect to server in step 0: %1").arg(socket.errorString()).toLocal8Bit());
+
+    // now start the chat
+    QList<Chat>::ConstIterator it = chat.constBegin();
+    for (int i = 1; it != chat.constEnd(); ++it, ++i) {
+        switch (it->type) {
+            case Chat::Expect: {
+                    qDebug() << i << "Expecting" << prettyByteArray(it->data);
+                    if (!doSocketRead(&socket, it->data.length()))
+                        QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
+
+                    // pop that many bytes off the socket
+                    QByteArray received = socket.read(it->data.length());
+
+                    // is it what we expected?
+                    QVERIFY2(received == it->data,
+                             QString("Did not receive expected data in step %1: data received was:\n%2")
+                             .arg(i).arg(prettyByteArray(received)).toLocal8Bit());
+
+                    break;
+                }
+
+            case Chat::DiscardUntil:
+                qDebug() << i << "Discarding until" << prettyByteArray(it->data);
+                while (true) {
+                    // scan the buffer until we have our string
+                    if (!doSocketRead(&socket, it->data.length()))
+                        QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
+
+                    QByteArray buffer;
+                    buffer.resize(socket.bytesAvailable());
+                    socket.peek(buffer.data(), socket.bytesAvailable());
+
+                    int pos = buffer.indexOf(it->data);
+                    if (pos == -1) {
+                        // data not found, keep trying
+                        continue;
+                    }
+
+                    buffer = socket.read(pos + it->data.length());
+                    qDebug() << i << "Discarded" << prettyByteArray(buffer);
+                    break;
+                }
+                break;
+
+            case Chat::SkipBytes: {
+                    qDebug() << i << "Skipping" << it->value << "bytes";
+                    if (!doSocketRead(&socket, it->value))
+                        QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
+
+                    // now discard the bytes
+                    QByteArray buffer = socket.read(it->value);
+                    qDebug() << i << "Skipped" << prettyByteArray(buffer);
+                    break;
+                }
+
+            case Chat::Send: {
+                    qDebug() << i << "Sending" << prettyByteArray(it->data);
+                    socket.write(it->data);
+                    if (!doSocketFlush(&socket)) {
+                        QVERIFY2(socket.state() == QAbstractSocket::ConnectedState,
+                                 QString("Socket disconnected while sending data in step %1").arg(i).toLocal8Bit());
+                        QFAIL(QString("Failed to send data in step %1: timeout").arg(i).toLocal8Bit());
+                    }
+                    break;
+                }
+
+            case Chat::Disconnect:
+                qDebug() << i << "Disconnecting from host";
+                socket.disconnectFromHost();
+
+                // is this the last command?
+                if (it + 1 != chat.constEnd())
+                    break;
+
+                // fall through:
+            case Chat::RemoteDisconnect:
+            case Chat::DiscardUntilDisconnect:
+                qDebug() << i << "Waiting for remote disconnect";
+                if (socket.state() != QAbstractSocket::UnconnectedState)
+                    socket.waitForDisconnected(10000);
+                QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState,
+                         QString("Socket did not disconnect as expected in step %1").arg(i).toLocal8Bit());
+
+                // any data left?
+                if (it->type == Chat::DiscardUntilDisconnect) {
+                    QByteArray buffer = socket.readAll();
+                    qDebug() << i << "Discarded in the process:" << prettyByteArray(buffer);
+                }
+
+                if (socket.bytesAvailable() != 0)
+                    QFAIL(QString("Unexpected bytes still on buffer when disconnecting in step %1:\n%2")
+                          .arg(i).arg(prettyByteArray(socket.readAll())).toLocal8Bit());
+                break;
+
+            case Chat::Reconnect:
+                qDebug() << i << "Reconnecting to server on port" << port;
+                socket.connectToHost(QtNetworkSettings::serverName(), port);
+                QVERIFY2(socket.waitForConnected(10000),
+                         QString("Failed to reconnect to server in step %1: %2").arg(i).arg(socket.errorString()).toLocal8Bit());
+                break;
+
+            case Chat::StartEncryption:
+#ifdef QT_NO_OPENSSL
+                QFAIL("Internal error: SSL required for this test");
+#else
+                qDebug() << i << "Starting client encryption";
+                socket.ignoreSslErrors();
+                socket.startClientEncryption();
+                QVERIFY2(socket.waitForEncrypted(5000),
+                         QString("Failed to start client encryption in step %1: %2").arg(i)
+                         .arg(socket.errorString()).toLocal8Bit());
+                break;
+#endif
+            }
+    }
+}
+
+void tst_NetworkSelfTest::hostTest()
+{
+    // this is a localhost self-test
+    QHostInfo localhost = QHostInfo::fromName("localhost");
+    QCOMPARE(localhost.error(), QHostInfo::NoError);
+    QVERIFY(!localhost.addresses().isEmpty());
+
+    QTcpServer server;
+    QVERIFY(server.listen());
+
+    QTcpSocket socket;
+    socket.connectToHost("127.0.0.1", server.serverPort());
+    QVERIFY(socket.waitForConnected(10000));
+}
+
+void tst_NetworkSelfTest::dnsResolution_data()
+{
+    QTest::addColumn<QString>("hostName");
+    QTest::newRow("local-name") << QtNetworkSettings::serverLocalName();
+    QTest::newRow("fqdn") << QtNetworkSettings::serverName();
+}
+
+void tst_NetworkSelfTest::dnsResolution()
+{
+    QFETCH(QString, hostName);
+    QHostInfo resolved = QHostInfo::fromName(hostName);
+    QVERIFY2(resolved.error() == QHostInfo::NoError,
+             QString("Failed to resolve hostname %1: %2").arg(hostName, resolved.errorString()).toLocal8Bit());
+}
+
+void tst_NetworkSelfTest::serverReachability()
+{
+    // check that we get a proper error connecting to port 1
+    QTcpSocket socket;
+    socket.connectToHost(QtNetworkSettings::serverName(), 1);
+    socket.waitForConnected(10000);
+    QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
+    QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
+             QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
+}
+
+void tst_NetworkSelfTest::remotePortsOpen_data()
+{
+    QTest::addColumn<int>("portNumber");
+    QTest::newRow("ftp") << 21;
+    QTest::newRow("ssh") << 22;
+    QTest::newRow("imap") << 143;
+    QTest::newRow("http") << 80;
+    QTest::newRow("https") << 443;
+    QTest::newRow("http-proxy") << 3128;
+    QTest::newRow("http-proxy-auth-basic") << 3129;
+    QTest::newRow("http-proxy-auth-ntlm") << 3130;
+    QTest::newRow("socks5-proxy") << 1080;
+    QTest::newRow("socks5-proxy-auth") << 1081;
+}
+
+void tst_NetworkSelfTest::remotePortsOpen()
+{
+    QFETCH(int, portNumber);
+    QTcpSocket socket;
+    socket.connectToHost(QtNetworkSettings::serverName(), portNumber);
+
+    if (!socket.waitForConnected(10000)) {
+        if (socket.error() == QAbstractSocket::SocketTimeoutError)
+            QFAIL(QString("Network timeout connecting to the server on port %1").arg(portNumber).toLocal8Bit());
+        else
+            QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit());
+    }
+    QVERIFY(socket.state() == QAbstractSocket::ConnectedState);
+}
+
+static QList<Chat> ftpChat()
+{
+    return QList<Chat>() << Chat::expect("220")
+            << Chat::discardUntil("\r\n")
+            << Chat::send("USER anonymous\r\n")
+            << Chat::expect("331")
+            << Chat::discardUntil("\r\n")
+            << Chat::send("PASS user@hostname\r\n")
+            << Chat::expect("230")
+            << Chat::discardUntil("\r\n")
+            << Chat::send("QUIT\r\n")
+            << Chat::expect("221")
+            << Chat::discardUntil("\r\n")
+            << Chat::RemoteDisconnect;
+}
+
+void tst_NetworkSelfTest::ftpServer()
+{
+    netChat(21, ftpChat());
+}
+
+void tst_NetworkSelfTest::imapServer()
+{
+    netChat(143, QList<Chat>()
+            << Chat::expect("* OK ")
+            << Chat::discardUntil("\r\n")
+            << Chat::send("1 CAPABILITY\r\n")
+            << Chat::expect("* CAPABILITY ")
+            << Chat::discardUntil("1 OK")
+            << Chat::discardUntil("\r\n")
+            << Chat::send("2 LOGOUT\r\n")
+            << Chat::discardUntil("2 OK")
+            << Chat::discardUntil("\r\n")
+            << Chat::RemoteDisconnect);
+}
+
+void tst_NetworkSelfTest::httpServer()
+{
+    netChat(80, QList<Chat>()
+            // HTTP/0.9 chat:
+            << Chat::send("GET /\r\n")
+            << Chat::DiscardUntilDisconnect
+
+            // HTTP/1.0 chat:
+            << Chat::Reconnect
+            << Chat::send("GET / HTTP/1.0\r\n"
+                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+                          "Connection: close\r\n"
+                          "\r\n")
+            << Chat::expect("HTTP/1.")
+            << Chat::discardUntil(" ")
+            << Chat::expect("200 ")
+            << Chat::DiscardUntilDisconnect
+
+            // HTTP/1.0 POST:
+            << Chat::Reconnect
+            << Chat::send("POST / HTTP/1.0\r\n"
+                          "Content-Length: 5\r\n"
+                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+                          "Connection: close\r\n"
+                          "\r\n"
+                          "Hello")
+            << Chat::expect("HTTP/1.")
+            << Chat::discardUntil(" ")
+            << Chat::expect("200 ")
+            << Chat::DiscardUntilDisconnect
+            );
+}
+
+void tst_NetworkSelfTest::httpsServer()
+{
+#ifndef QT_NO_OPENSSL
+    netChat(443, QList<Chat>()
+            << Chat::StartEncryption
+            << Chat::send("GET / HTTP/1.0\r\n"
+                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+                          "Connection: close\r\n"
+                          "\r\n")
+            << Chat::expect("HTTP/1.")
+            << Chat::discardUntil(" ")
+            << Chat::expect("200 ")
+            << Chat::DiscardUntilDisconnect);
+#else
+    QSKIP("SSL not enabled, cannot test", SkipAll);
+#endif
+}
+
+void tst_NetworkSelfTest::httpProxy()
+{
+    netChat(3128, QList<Chat>()
+            // proxy GET
+            << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
+                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+                          "Proxy-connection: close\r\n"
+                          "\r\n")
+            << Chat::expect("HTTP/1.")
+            << Chat::discardUntil(" ")
+            << Chat::expect("200 ")
+            << Chat::DiscardUntilDisconnect
+
+            // proxy CONNECT
+            << Chat::Reconnect
+            << Chat::send("CONNECT " + QtNetworkSettings::serverName().toLatin1() + ":21 HTTP/1.0\r\n"
+                          "\r\n")
+            << Chat::expect("HTTP/1.")
+            << Chat::discardUntil(" ")
+            << Chat::expect("200 ")
+            << Chat::discardUntil("\r\n\r\n")
+            << ftpChat());
+}
+
+void tst_NetworkSelfTest::httpProxyBasicAuth()
+{
+    netChat(3129, QList<Chat>()
+            // test auth required response
+            << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
+                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+                          "Proxy-connection: close\r\n"
+                          "\r\n")
+            << Chat::expect("HTTP/1.")
+            << Chat::discardUntil(" ")
+            << Chat::expect("407 ")
+            << Chat::discardUntil("\r\nProxy-Authenticate: Basic realm=\"")
+            << Chat::DiscardUntilDisconnect
+
+            // now try sending our credentials
+            << Chat::Reconnect
+            << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
+                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+                          "Proxy-connection: close\r\n"
+                          "Proxy-Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n"
+                          "\r\n")
+            << Chat::expect("HTTP/1.")
+            << Chat::discardUntil(" ")
+            << Chat::expect("200 ")
+            << Chat::DiscardUntilDisconnect);
+}
+
+void tst_NetworkSelfTest::httpProxyNtlmAuth()
+{
+    netChat(3130, QList<Chat>()
+            // test auth required response
+            << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
+                          "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+                          "Proxy-connection: keep-alive\r\n" // NTLM auth will disconnect
+                          "\r\n")
+            << Chat::expect("HTTP/1.")
+            << Chat::discardUntil(" ")
+            << Chat::expect("407 ")
+            << Chat::discardUntil("\r\nProxy-Authenticate: NTLM\r\n")
+            << Chat::DiscardUntilDisconnect
+            );
+}
+
+// SOCKSv5 is a binary protocol
+static const char handshakeNoAuth[] = "\5\1\0";
+static const char handshakeOkNoAuth[] = "\5\0";
+static const char handshakeAuthPassword[] = "\5\1\2\1\12qsockstest\10password";
+static const char handshakeOkPasswdAuth[] = "\5\2\1\0";
+static const char handshakeAuthNotOk[] = "\5\377";
+static const char connect1[] = "\5\1\0\1\177\0\0\1\0\25"; // Connect IPv4 127.0.0.1 port 21
+static const char connect2[] = "\5\1\0\3\11localhost\0\25"; // Connect hostname localhost 21
+static const char connected[] = "\5\0\0";
+
+void tst_NetworkSelfTest::socks5Proxy()
+{
+    netChat(1080, QList<Chat>()
+            // IP address connection
+            << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth))
+            << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth))
+            << Chat::send(QByteArray(connect1, -1 + sizeof connect1))
+            << Chat::expect(QByteArray(connected, -1 + sizeof connected))
+            << Chat::expect("\1") // IPv4 address following
+            << Chat::skipBytes(6) // the server's local address and port
+            << ftpChat()
+
+            // hostname connection
+            << Chat::Reconnect
+            << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth))
+            << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth))
+            << Chat::send(QByteArray(connect2, -1 + sizeof connect2))
+            << Chat::expect(QByteArray(connected, -1 + sizeof connected))
+            << Chat::expect("\1") // IPv4 address following
+            << Chat::skipBytes(6) // the server's local address and port
+            << ftpChat()
+            );
+}
+
+void tst_NetworkSelfTest::socks5ProxyAuth()
+{
+    netChat(1081, QList<Chat>()
+            // unauthenticated connect -- will get error
+            << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth))
+            << Chat::expect(QByteArray(handshakeAuthNotOk, -1 + sizeof handshakeAuthNotOk))
+            << Chat::RemoteDisconnect
+
+            // now try to connect with authentication
+            << Chat::Reconnect
+            << Chat::send(QByteArray(handshakeAuthPassword, -1 + sizeof handshakeAuthPassword))
+            << Chat::expect(QByteArray(handshakeOkPasswdAuth, -1 + sizeof handshakeOkPasswdAuth))
+            << Chat::send(QByteArray(connect1, -1 + sizeof connect1))
+            << Chat::expect(QByteArray(connected, -1 + sizeof connected))
+            << Chat::expect("\1") // IPv4 address following
+            << Chat::skipBytes(6) // the server's local address and port
+            << ftpChat()
+            );
+}
+
+QTEST_MAIN(tst_NetworkSelfTest)
+#include "tst_networkselftest.moc"
diff --git a/tests/auto/qaccessibility_mac/qaccessibility_mac.pro b/tests/auto/qaccessibility_mac/qaccessibility_mac.pro
index b6829dc..b32a7e5 100644
--- a/tests/auto/qaccessibility_mac/qaccessibility_mac.pro
+++ b/tests/auto/qaccessibility_mac/qaccessibility_mac.pro
@@ -4,21 +4,20 @@ TARGET = tst_qaccessibility_mac
 
 RESOURCES = qaccessibility_mac.qrc
 
-mac {
+requires(mac)
+
 # this setup should support both building as an autotest
 # (where uilib isn't built by default), and when running shadow
 # builds (where QTDIR points to the build directory).
 # autotest + shadow build is not supported :)
-    exists($$(QTDIR)/tools/designer/src/lib/uilib/uilib.pri) {
-       include($$(QTDIR)/tools/designer/src/lib/uilib/uilib.pri)
-       INCLUDEPATH += $$(QTDIR)/tools/designer/src/uitools
-       SOURCES += $$(QTDIR)/tools/designer/src/uitools/quiloader.cpp
-       HEADERS += $$(QTDIR)/tools/designer/src/uitools/quiloader.h
-    } else {
-        CONFIG += uitools
-    }
-    QT += xml
-    LIBS += -framework ApplicationServices -framework Carbon
+exists($$(QTDIR)/tools/designer/src/lib/uilib/uilib.pri) {
+   include($$(QTDIR)/tools/designer/src/lib/uilib/uilib.pri)
+   INCLUDEPATH += $$(QTDIR)/tools/designer/src/uitools
+   SOURCES += $$(QTDIR)/tools/designer/src/uitools/quiloader.cpp
+   HEADERS += $$(QTDIR)/tools/designer/src/uitools/quiloader.h
+} else {
+    CONFIG += uitools
 }
-
+QT += xml
+LIBS += -framework ApplicationServices -framework Carbon
 
diff --git a/tests/auto/qaccessibility_mac/tst_qaccessibility_mac.cpp b/tests/auto/qaccessibility_mac/tst_qaccessibility_mac.cpp
index b81fa12..2af6813 100644
--- a/tests/auto/qaccessibility_mac/tst_qaccessibility_mac.cpp
+++ b/tests/auto/qaccessibility_mac/tst_qaccessibility_mac.cpp
@@ -73,7 +73,7 @@ Q_DECLARE_METATYPE(AXUIElementRef);
 
 typedef QCFType<CFArrayRef> QCFArrayRef;
 
-class tst_accessibility_mac : public QObject
+class tst_qaccessibility_mac : public QObject
 {
 Q_OBJECT
 public slots:
@@ -665,7 +665,7 @@ void testAppAndForm(AXUIElementRef application)
     VERIFY_ELEMENT(form, application, "AXWindow");
 }
 
-void tst_accessibility_mac::printInfo()
+void tst_qaccessibility_mac::printInfo()
 {
     AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
     printElementInfo(currentApplication);
@@ -674,7 +674,7 @@ void tst_accessibility_mac::printInfo()
 /*
     Tests for form.ui
 */
-void tst_accessibility_mac::testForm()
+void tst_qaccessibility_mac::testForm()
 {
     // Get reference to the current application.
     AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
@@ -685,7 +685,7 @@ void tst_accessibility_mac::testForm()
 /*
     Tests for buttons.ui
 */
-void tst_accessibility_mac::testButtons()
+void tst_qaccessibility_mac::testButtons()
 {
     // Get reference to the current application.
     AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
@@ -714,7 +714,7 @@ void tst_accessibility_mac::testButtons()
     VERIFY_ROLE_DESCRIPTION(brain, "button");
 }
 
-void tst_accessibility_mac::testLabel()
+void tst_qaccessibility_mac::testLabel()
 {
     // Get reference to the current application.
     AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
@@ -731,7 +731,7 @@ void tst_accessibility_mac::testLabel()
 /*
     Tests for lineedit.ui
 */
-void tst_accessibility_mac::testLineEdit()
+void tst_qaccessibility_mac::testLineEdit()
 {
     // Get reference to the current application.
     AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
@@ -746,7 +746,7 @@ void tst_accessibility_mac::testLineEdit()
 /*
     Tests for groups.ui
 */
-void tst_accessibility_mac::testGroups()
+void tst_qaccessibility_mac::testGroups()
 {
     // Get reference to the current application.
     AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
@@ -769,7 +769,7 @@ void tst_accessibility_mac::testGroups()
 /*
     Tests for tabs.ui
 */
-void tst_accessibility_mac::testTabWidget()
+void tst_qaccessibility_mac::testTabWidget()
 {
     {   // Test that the QTabWidget hierarchy is what we expect it to be.
         QTabWidget tabWidget;
@@ -873,7 +873,7 @@ void tst_accessibility_mac::testTabWidget()
     }
 }
 
-void tst_accessibility_mac::testTabBar()
+void tst_qaccessibility_mac::testTabBar()
 {
     QTabBar tabBar;
     tabBar.addTab("Tab A");
@@ -924,7 +924,7 @@ void tst_accessibility_mac::testTabBar()
     }
 }
 
-void tst_accessibility_mac::testComboBox()
+void tst_qaccessibility_mac::testComboBox()
 {
     // Get reference to the current application.
     AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
@@ -940,7 +940,7 @@ void tst_accessibility_mac::testComboBox()
     QVERIFY(performAction(comboBox, "AXPress"));
 }
 
-void tst_accessibility_mac::testDeleteWidget()
+void tst_qaccessibility_mac::testDeleteWidget()
 {
     const QString buttonTitle = "Hi there";
     QWidget *form = new QWidget(0, Qt::Window);
@@ -964,7 +964,7 @@ void tst_accessibility_mac::testDeleteWidget()
     delete form;
 }
 
-void tst_accessibility_mac::testDeleteWidgets()
+void tst_qaccessibility_mac::testDeleteWidgets()
 {
     const QString buttonTitle = "Hi there";
     const int repeats = 10;
@@ -1047,7 +1047,7 @@ void tst_accessibility_mac::testDeleteWidgets()
 
 }
 
-void tst_accessibility_mac::testMultipleWindows()
+void tst_qaccessibility_mac::testMultipleWindows()
 {
     const QString formATitle("FormA");
     const QString formBTitle("FormB");
@@ -1077,7 +1077,7 @@ void tst_accessibility_mac::testMultipleWindows()
     delete formA;
 }
 
-void tst_accessibility_mac::testHiddenWidgets()
+void tst_qaccessibility_mac::testHiddenWidgets()
 {
     const QString windowTitle ="a widget";
     QWidget * const window = new QWidget(0);
@@ -1108,7 +1108,7 @@ void tst_accessibility_mac::testHiddenWidgets()
     delete window;
 };
 
-void tst_accessibility_mac::testActions()
+void tst_qaccessibility_mac::testActions()
 {
     // create a window with a push button
     const QString windowTitle ="a widget";
@@ -1145,7 +1145,7 @@ void tst_accessibility_mac::testActions()
     delete window;
 };
 
-void tst_accessibility_mac::testChangeState()
+void tst_qaccessibility_mac::testChangeState()
 {
     const QString windowTitle ="a widget";
     QWidget * const window = new QWidget();
@@ -1215,7 +1215,7 @@ void tst_accessibility_mac::testChangeState()
     delete window;
 }
 
-void tst_accessibility_mac::testSlider()
+void tst_qaccessibility_mac::testSlider()
 {
     const QString windowTitle = "a widget";
     QWidget * const window = new QWidget();
@@ -1241,7 +1241,7 @@ void tst_accessibility_mac::testSlider()
     delete slider;
 }
 
-void tst_accessibility_mac::testScrollArea()
+void tst_qaccessibility_mac::testScrollArea()
 {
     QWidget window;
     const QString windowTitle = "window";
@@ -1368,7 +1368,7 @@ void tst_accessibility_mac::testScrollArea()
     }
 }
 
-void tst_accessibility_mac::testListView()
+void tst_qaccessibility_mac::testListView()
 {
     QWidget window;
     const QString windowTitle("window");
@@ -1451,7 +1451,7 @@ void tst_accessibility_mac::testListView()
     QVERIFY(contains(listElement, C));
 }
 
-void tst_accessibility_mac::testTableView()
+void tst_qaccessibility_mac::testTableView()
 {
     QWidget window;
     const QString windowTitle("window");
@@ -1647,7 +1647,7 @@ void tst_accessibility_mac::testTableView()
 //    QTest::qWait(1000000);
 }
 
-void tst_accessibility_mac::testScrollBar()
+void tst_qaccessibility_mac::testScrollBar()
 {
     {
         QScrollBar scrollBar;
@@ -1693,7 +1693,7 @@ void tst_accessibility_mac::testScrollBar()
     }
 }
 
-void tst_accessibility_mac::testSplitter()
+void tst_qaccessibility_mac::testSplitter()
 {
     const AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
     testAppAndForm(currentApplication);
@@ -1730,7 +1730,7 @@ void tst_accessibility_mac::testSplitter()
     }
 }
 
-void tst_accessibility_mac::testTextEdit()
+void tst_qaccessibility_mac::testTextEdit()
 {
     QWidget window;
     const QString windowTitle("window");
@@ -1796,13 +1796,13 @@ void testModelLessItemView(QAbstractItemView *itemView, const QByteArray &role)
     delete itemView;
 }
 
-void tst_accessibility_mac::testItemViewsWithoutModel()
+void tst_qaccessibility_mac::testItemViewsWithoutModel()
 {
     testModelLessItemView(new QListView(), "AXList");
     testModelLessItemView(new QTableView(), "AXTable");
 }
 
-void tst_accessibility_mac::testQAElement()
+void tst_qaccessibility_mac::testQAElement()
 {
     {
         QAElement element;
@@ -1825,7 +1825,7 @@ void tst_accessibility_mac::testQAElement()
 
 }
 
-void tst_accessibility_mac::testQAInterface()
+void tst_qaccessibility_mac::testQAInterface()
 {
     {
         QAInterface interface;
@@ -1855,7 +1855,7 @@ void tst_accessibility_mac::testQAInterface()
     }
 }
 
-void tst_accessibility_mac::uitests_data()
+void tst_qaccessibility_mac::uitests_data()
 {
     QTest::addColumn<QString>("uiFilename");
     QTest::addColumn<QString>("testSlot");
@@ -1871,7 +1871,7 @@ void tst_accessibility_mac::uitests_data()
     QTest::newRow("splitters") << "splitters.ui" << SLOT(testSplitter());
 }
 
-void tst_accessibility_mac::uitests()
+void tst_qaccessibility_mac::uitests()
 {
     QFETCH(QString, uiFilename);
     QFETCH(QString, testSlot);
@@ -1901,7 +1901,7 @@ void tst_accessibility_mac::uitests()
     delete window;
 }
 
-void tst_accessibility_mac::tests_data()
+void tst_qaccessibility_mac::tests_data()
 {
     QTest::addColumn<QString>("testSlot");
     QTest::newRow("deleteWidget") << SLOT(testDeleteWidget());
@@ -1919,7 +1919,7 @@ void tst_accessibility_mac::tests_data()
     QTest::newRow("tabbar") << SLOT(testTabBar());
 }
 
-void tst_accessibility_mac::tests()
+void tst_qaccessibility_mac::tests()
 {
     QFETCH(QString, testSlot);
     runTest(testSlot);
@@ -1930,7 +1930,7 @@ void tst_accessibility_mac::tests()
     kAXErrorAPIDisabled error, indicating that the accessible API is disabled, which it isn't.)
     To work around this, we run the tests in a callback slot called from the main event loop.
 */
-void tst_accessibility_mac::runTest(const QString &testSlot)
+void tst_qaccessibility_mac::runTest(const QString &testSlot)
 {
     // The Accessibility interface must be enabled to run this test.
     if (!AXAPIEnabled())
@@ -1947,7 +1947,7 @@ void tst_accessibility_mac::runTest(const QString &testSlot)
 
 }
 
-QTEST_APPLESS_MAIN(tst_accessibility_mac)
+QTEST_APPLESS_MAIN(tst_qaccessibility_mac)
 
 #else // defined(Q_WS_MAC) && !defined (QT_MAC_USE_COCOA)
 
diff --git a/tests/auto/qcopchannel/qcopchannel.pro b/tests/auto/qcopchannel/qcopchannel.pro
index 29f7834..427430f 100644
--- a/tests/auto/qcopchannel/qcopchannel.pro
+++ b/tests/auto/qcopchannel/qcopchannel.pro
@@ -3,4 +3,5 @@ SUBDIRS = testSend
 
 SUBDIRS += test
 
+requires(embedded)
 
diff --git a/tests/auto/qcopchannel/test/test.pro b/tests/auto/qcopchannel/test/test.pro
index 48a218e..8c7cc5b 100644
--- a/tests/auto/qcopchannel/test/test.pro
+++ b/tests/auto/qcopchannel/test/test.pro
@@ -3,12 +3,4 @@ load(qttest_p4)
 SOURCES += ../tst_qcopchannel.cpp
 TARGET = ../tst_qcopchannel
 
-win32 {
-  CONFIG(debug, debug|release) {
-    TARGET = ../../debug/tst_qcopchannel
-} else {
-    TARGET = ../../release/tst_qcopchannel
-  }
-}
-
 
diff --git a/tests/auto/qcopchannel/testSend/testSend.pro b/tests/auto/qcopchannel/testSend/testSend.pro
index f78341c..ebce3dd 100644
--- a/tests/auto/qcopchannel/testSend/testSend.pro
+++ b/tests/auto/qcopchannel/testSend/testSend.pro
@@ -2,4 +2,5 @@ load(qttest_p4)
 SOURCES = main.cpp
 TARGET = testSend
 
+requires(embedded)
 
diff --git a/tests/auto/qcssparser/qcssparser.pro b/tests/auto/qcssparser/qcssparser.pro
index 57d6804..2f99142 100644
--- a/tests/auto/qcssparser/qcssparser.pro
+++ b/tests/auto/qcssparser/qcssparser.pro
@@ -1,5 +1,5 @@
 load(qttest_p4)
-SOURCES += tst_cssparser.cpp
+SOURCES += tst_qcssparser.cpp
 DEFINES += SRCDIR=\\\"$$PWD\\\"
 QT += xml
 
diff --git a/tests/auto/qcssparser/tst_cssparser.cpp b/tests/auto/qcssparser/tst_cssparser.cpp
deleted file mode 100644
index c905688..0000000
--- a/tests/auto/qcssparser/tst_cssparser.cpp
+++ /dev/null
@@ -1,1616 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <QtXml/QtXml>
-
-//TESTED_CLASS=QCss
-//TESTED_FILES=gui/text/qcssparser.cpp gui/text/qcssparser_p.h
-
-#include "private/qcssparser_p.h"
-
-class tst_CssParser : public QObject
-{
-    Q_OBJECT
-private slots:
-    void scanner_data();
-    void scanner();
-    void term_data();
-    void term();
-    void expr_data();
-    void expr();
-    void import();
-    void media();
-    void page();
-    void ruleset();
-    void selector_data();
-    void selector();
-    void prio();
-    void escapes();
-    void malformedDeclarations_data();
-    void malformedDeclarations();
-    void invalidAtKeywords();
-    void marginValue();
-    void marginValue_data();
-    void colorValue_data();
-    void colorValue();
-    void styleSelector_data();
-    void styleSelector();
-    void specificity_data();
-    void specificity();
-    void specificitySort_data();
-    void specificitySort();
-    void rulesForNode_data();
-    void rulesForNode();
-    void shorthandBackgroundProperty_data();
-    void shorthandBackgroundProperty();
-    void pseudoElement_data();
-    void pseudoElement();
-    void gradient_data();
-    void gradient();
-    void extractFontFamily_data();
-    void extractFontFamily();
-    void extractBorder_data();
-    void extractBorder();
-    void noTextDecoration();
-    void quotedAndUnquotedIdentifiers();
-};
-
-void tst_CssParser::scanner_data()
-{
-    QTest::addColumn<QString>("input");
-    QTest::addColumn<QString>("output");
-
-#if !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE)
-    QDir d(SRCDIR);
-#else
-    QDir d(QDir::current());
-#endif
-    d.cd("testdata");
-    d.cd("scanner");
-    foreach (QFileInfo test, d.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
-        QString dir = test.absoluteFilePath() + QDir::separator();
-        QTest::newRow(qPrintable(test.baseName()))
-            << dir + "input"
-            << dir + "output"
-            ;
-    }
-}
-
-static void debug(const QVector<QCss::Symbol> &symbols, int index = -1)
-{
-    qDebug() << "all symbols:";
-    for (int i = 0; i < symbols.count(); ++i)
-        qDebug() << "(" << i << "); Token:" << QCss::Scanner::tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem();
-    if (index != -1)
-        qDebug() << "failure at index" << index;
-}
-
-//static void debug(const QCss::Parser &p) { debug(p.symbols); }
-
-void tst_CssParser::scanner()
-{
-    QFETCH(QString, input);
-    QFETCH(QString, output);
-
-    QFile inputFile(input);
-    QVERIFY(inputFile.open(QIODevice::ReadOnly|QIODevice::Text));
-    QVector<QCss::Symbol> symbols;
-    QCss::Scanner::scan(QCss::Scanner::preprocess(QString::fromUtf8(inputFile.readAll())), &symbols);
-
-    QVERIFY(symbols.count() > 1);
-    QVERIFY(symbols.last().token == QCss::S);
-    QVERIFY(symbols.last().lexem() == QLatin1String("\n"));
-    symbols.remove(symbols.count() - 1, 1);
-
-    QFile outputFile(output);
-    QVERIFY(outputFile.open(QIODevice::ReadOnly|QIODevice::Text));
-    QStringList lines;
-    while (!outputFile.atEnd()) {
-        QString line = QString::fromUtf8(outputFile.readLine());
-        if (line.endsWith(QLatin1Char('\n')))
-            line.chop(1);
-        lines.append(line);
-    }
-
-    if (lines.count() != symbols.count()) {
-        debug(symbols);
-        QCOMPARE(lines.count(), symbols.count());
-    }
-
-    for (int i = 0; i < lines.count(); ++i) {
-        QStringList l = lines.at(i).split(QChar::fromLatin1('|'));
-        QCOMPARE(l.count(), 2);
-        const QString expectedToken = l.at(0);
-        const QString expectedLexem = l.at(1);
-        QString actualToken = QString::fromLatin1(QCss::Scanner::tokenName(symbols.at(i).token));
-        if (actualToken != expectedToken) {
-            debug(symbols, i);
-            QCOMPARE(actualToken, expectedToken);
-        }
-        if (symbols.at(i).lexem() != expectedLexem) {
-            debug(symbols, i);
-            QCOMPARE(symbols.at(i).lexem(), expectedLexem);
-        }
-    }
-}
-
-Q_DECLARE_METATYPE(QCss::Value)
-
-void tst_CssParser::term_data()
-{
-    QTest::addColumn<bool>("parseSuccess");
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<QCss::Value>("expectedValue");
-
-    QCss::Value val;
-
-    val.type = QCss::Value::Percentage;
-    val.variant = QVariant(double(200));
-    QTest::newRow("percentage") << true << "200%" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10px");
-    QTest::newRow("px") << true << "10px" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10cm");
-    QTest::newRow("cm") << true << "10cm" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10mm");
-    QTest::newRow("mm") << true << "10mm" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10pt");
-    QTest::newRow("pt") << true << "10pt" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10pc");
-    QTest::newRow("pc") << true << "10pc" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("42in");
-    QTest::newRow("inch") << true << "42in" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10deg");
-    QTest::newRow("deg") << true << "10deg" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10rad");
-    QTest::newRow("rad") << true << "10rad" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10grad");
-    QTest::newRow("grad") << true << "10grad" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10ms");
-    QTest::newRow("time") << true << "10ms" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10s");
-    QTest::newRow("times") << true << "10s" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10hz");
-    QTest::newRow("hz") << true << "10hz" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10khz");
-    QTest::newRow("khz") << true << "10khz" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10myunit");
-    QTest::newRow("dimension") << true << "10myunit" << val;
-
-    val.type = QCss::Value::Percentage;
-
-    val.type = QCss::Value::Percentage;
-    val.variant = QVariant(double(-200));
-    QTest::newRow("minuspercentage") << true << "-200%" << val;
-
-    val.type = QCss::Value::Length;
-    val.variant = QString("10em");
-    QTest::newRow("ems") << true << "10em" << val;
-
-    val.type = QCss::Value::String;
-    val.variant = QVariant(QString("foo"));
-    QTest::newRow("string") << true << "\"foo\"" << val;
-
-    val.type = QCss::Value::Function;
-    val.variant = QVariant(QStringList() << "myFunc" << "23, (nested text)");
-    QTest::newRow("function") << true << "myFunc(23, (nested text))" << val;
-
-    QTest::newRow("function_failure") << false << "myFunction((blah)" << val;
-    QTest::newRow("function_failure2") << false << "+myFunc(23, (nested text))" << val;
-
-    val.type = QCss::Value::Color;
-    val.variant = QVariant(QColor("#12ff34"));
-    QTest::newRow("hexcolor") << true << "#12ff34" << val;
-
-    val.type = QCss::Value::Color;
-    val.variant = QVariant(QColor("#ffbb00"));
-    QTest::newRow("hexcolor2") << true << "#fb0" << val;
-
-    QTest::ignoreMessage(QtWarningMsg, "QCssParser::parseHexColor: Unknown color name '#cafebabe'");
-    QTest::newRow("hexcolor_failure") << false << "#cafebabe" << val;
-
-    val.type = QCss::Value::Uri;
-    val.variant = QString("www.kde.org");
-    QTest::newRow("uri1") << true << "url(\"www.kde.org\")" << val;
-
-    QTest::newRow("uri2") << true << "url(www.kde.org)" << val;
-
-    val.type = QCss::Value::KnownIdentifier;
-    val.variant = int(QCss::Value_Italic);
-    QTest::newRow("italic") << true << "italic" << val;
-
-    val.type = QCss::Value::KnownIdentifier;
-    val.variant = int(QCss::Value_Italic);
-    QTest::newRow("ItaLIc") << true << "ItaLIc" << val;
-}
-
-void tst_CssParser::term()
-{
-    QFETCH(bool, parseSuccess);
-    QFETCH(QString, css);
-    QFETCH(QCss::Value, expectedValue);
-
-    QCss::Parser parser(css);
-    QCss::Value val;
-    QVERIFY(parser.testTerm());
-    QCOMPARE(parser.parseTerm(&val), parseSuccess);
-    if (parseSuccess) {
-        QCOMPARE(int(val.type), int(expectedValue.type));
-        if (val.variant != expectedValue.variant) {
-            qDebug() << "val.variant:" << val.variant << "expectedValue.variant:" << expectedValue.variant;
-            QCOMPARE(val.variant, expectedValue.variant);
-        }
-    }
-}
-
-Q_DECLARE_METATYPE(QVector<QCss::Value>)
-
-void tst_CssParser::expr_data()
-{
-    QTest::addColumn<bool>("parseSuccess");
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<QVector<QCss::Value> >("expectedValues");
-
-    QVector<QCss::Value> values;
-    QCss::Value val;
-
-    QCss::Value comma;
-    comma.type = QCss::Value::TermOperatorComma;
-
-    val.type = QCss::Value::Identifier;
-    val.variant = QLatin1String("foo");
-    values << val;
-    values << comma;
-    val.variant = QLatin1String("bar");
-    values << val;
-    values << comma;
-    val.variant = QLatin1String("baz");
-    values << val;
-    QTest::newRow("list") << true << "foo, bar, baz" << values;
-    values.clear();
-}
-
-void tst_CssParser::expr()
-{
-    QFETCH(bool, parseSuccess);
-    QFETCH(QString, css);
-    QFETCH(QVector<QCss::Value>, expectedValues);
-
-    QCss::Parser parser(css);
-    QVector<QCss::Value> values;
-    QVERIFY(parser.testExpr());
-    QCOMPARE(parser.parseExpr(&values), parseSuccess);
-    if (parseSuccess) {
-        QCOMPARE(values.count(), expectedValues.count());
-
-        for (int i = 0; i < values.count(); ++i) {
-            QCOMPARE(int(values.at(i).type), int(expectedValues.at(i).type));
-            QCOMPARE(values.at(i).variant, expectedValues.at(i).variant);
-        }
-    }
-}
-
-void tst_CssParser::import()
-{
-    QCss::Parser parser("@import \"plainstring\";");
-    QVERIFY(parser.testImport());
-    QCss::ImportRule rule;
-    QVERIFY(parser.parseImport(&rule));
-    QCOMPARE(rule.href, QString("plainstring"));
-
-    parser = QCss::Parser("@import url(\"www.kde.org\") print/*comment*/,screen;");
-    QVERIFY(parser.testImport());
-    QVERIFY(parser.parseImport(&rule));
-    QCOMPARE(rule.href, QString("www.kde.org"));
-    QCOMPARE(rule.media.count(), 2);
-    QCOMPARE(rule.media.at(0), QString("print"));
-    QCOMPARE(rule.media.at(1), QString("screen"));
-}
-
-void tst_CssParser::media()
-{
-    QCss::Parser parser("@media print/*comment*/,screen /*comment to ignore*/{ }");
-    QVERIFY(parser.testMedia());
-    QCss::MediaRule rule;
-    QVERIFY(parser.parseMedia(&rule));
-    QCOMPARE(rule.media.count(), 2);
-    QCOMPARE(rule.media.at(0), QString("print"));
-    QCOMPARE(rule.media.at(1), QString("screen"));
-    QVERIFY(rule.styleRules.isEmpty());
-}
-
-void tst_CssParser::page()
-{
-    QCss::Parser parser("@page :first/*comment to ignore*/{ }");
-    QVERIFY(parser.testPage());
-    QCss::PageRule rule;
-    QVERIFY(parser.parsePage(&rule));
-    QCOMPARE(rule.selector, QString("first"));
-    QVERIFY(rule.declarations.isEmpty());
-}
-
-void tst_CssParser::ruleset()
-{
-    {
-        QCss::Parser parser("p/*foo*/{ }");
-        QVERIFY(parser.testRuleset());
-        QCss::StyleRule rule;
-        QVERIFY(parser.parseRuleset(&rule));
-        QCOMPARE(rule.selectors.count(), 1);
-        QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
-        QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p"));
-        QVERIFY(rule.declarations.isEmpty());
-    }
-
-    {
-        QCss::Parser parser("p/*comment*/,div{ }");
-        QVERIFY(parser.testRuleset());
-        QCss::StyleRule rule;
-        QVERIFY(parser.parseRuleset(&rule));
-        QCOMPARE(rule.selectors.count(), 2);
-        QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
-        QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p"));
-        QCOMPARE(rule.selectors.at(1).basicSelectors.count(), 1);
-        QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).elementName, QString("div"));
-        QVERIFY(rule.declarations.isEmpty());
-    }
-
-    {
-        QCss::Parser parser(":before, :after { }");
-        QVERIFY(parser.testRuleset());
-        QCss::StyleRule rule;
-        QVERIFY(parser.parseRuleset(&rule));
-        QCOMPARE(rule.selectors.count(), 2);
-
-        QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
-        QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.count(), 1);
-        QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.at(0).name, QString("before"));
-
-        QCOMPARE(rule.selectors.at(1).basicSelectors.count(), 1);
-        QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.count(), 1);
-        QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.at(0).name, QString("after"));
-
-        QVERIFY(rule.declarations.isEmpty());
-    }
-
-}
-
-Q_DECLARE_METATYPE(QCss::Selector)
-
-void tst_CssParser::selector_data()
-{
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<QCss::Selector>("expectedSelector");
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "p";
-        basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfPreceeds;
-        sel.basicSelectors << basic;
-
-        basic = QCss::BasicSelector();
-        basic.elementName = "div";
-        sel.basicSelectors << basic;
-
-        QTest::newRow("comment") << QString("p/* */+ div") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = QString();
-        sel.basicSelectors << basic;
-
-        QTest::newRow("any") << QString("*") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        sel.basicSelectors << basic;
-
-        QTest::newRow("element") << QString("e") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfAncestor;
-        sel.basicSelectors << basic;
-
-        basic.elementName = "f";
-        basic.relationToNext = QCss::BasicSelector::NoRelation;
-        sel.basicSelectors << basic;
-
-        QTest::newRow("descendant") << QString("e f") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfParent;
-        sel.basicSelectors << basic;
-
-        basic.elementName = "f";
-        basic.relationToNext = QCss::BasicSelector::NoRelation;
-        sel.basicSelectors << basic;
-
-        QTest::newRow("parent") << QString("e > f") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        QCss::Pseudo pseudo;
-        pseudo.name = "first-child";
-        basic.pseudos.append(pseudo);
-        sel.basicSelectors << basic;
-
-        QTest::newRow("first-child") << QString("e:first-child") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        QCss::Pseudo pseudo;
-        pseudo.name = "c";
-        pseudo.function = "lang";
-        basic.pseudos.append(pseudo);
-        sel.basicSelectors << basic;
-
-        QTest::newRow("lang") << QString("e:lang(c)") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfPreceeds;
-        sel.basicSelectors << basic;
-
-        basic.elementName = "f";
-        basic.relationToNext = QCss::BasicSelector::NoRelation;
-        sel.basicSelectors << basic;
-
-        QTest::newRow("precede") << QString("e + f") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        QCss::AttributeSelector attrSel;
-        attrSel.name = "foo";
-        basic.attributeSelectors << attrSel;
-        sel.basicSelectors << basic;
-
-        QTest::newRow("attr") << QString("e[foo]") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        QCss::AttributeSelector attrSel;
-        attrSel.name = "foo";
-        attrSel.value = "warning";
-        attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchEqual;
-        basic.attributeSelectors << attrSel;
-        sel.basicSelectors << basic;
-
-        QTest::newRow("attr-equal") << QString("e[foo=\"warning\"]") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        QCss::AttributeSelector attrSel;
-        attrSel.name = "foo";
-        attrSel.value = "warning";
-        attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchContains;
-        basic.attributeSelectors << attrSel;
-        sel.basicSelectors << basic;
-
-        QTest::newRow("attr-contains") << QString("e[foo~=\"warning\"]") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        QCss::AttributeSelector attrSel;
-        attrSel.name = "lang";
-        attrSel.value = "en";
-        attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchBeginsWith;
-        basic.attributeSelectors << attrSel;
-        sel.basicSelectors << basic;
-
-        QTest::newRow("attr-contains") << QString("e[lang|=\"en\"]") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "div";
-
-        QCss::AttributeSelector attrSel;
-        attrSel.name = "class";
-        attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchContains;
-        attrSel.value = "warning";
-        basic.attributeSelectors.append(attrSel);
-
-        attrSel.value = "foo";
-        basic.attributeSelectors.append(attrSel);
-
-        sel.basicSelectors << basic;
-
-        QTest::newRow("class") << QString("div.warning.foo") << sel;
-    }
-
-    {
-        QCss::Selector sel;
-        QCss::BasicSelector basic;
-
-        basic.elementName = "e";
-        basic.ids << "myid";
-        sel.basicSelectors << basic;
-
-        QTest::newRow("id") << QString("e#myid") << sel;
-    }
-}
-
-void tst_CssParser::selector()
-{
-    QFETCH(QString, css);
-    QFETCH(QCss::Selector, expectedSelector);
-
-    QCss::Parser parser(css);
-    QVERIFY(parser.testSelector());
-    QCss::Selector selector;
-    QVERIFY(parser.parseSelector(&selector));
-
-    QCOMPARE(selector.basicSelectors.count(), expectedSelector.basicSelectors.count());
-    for (int i = 0; i < selector.basicSelectors.count(); ++i) {
-        const QCss::BasicSelector sel = selector.basicSelectors.at(i);
-        const QCss::BasicSelector expectedSel = expectedSelector.basicSelectors.at(i);
-        QCOMPARE(sel.elementName, expectedSel.elementName);
-        QCOMPARE(int(sel.relationToNext), int(expectedSel.relationToNext));
-
-        QCOMPARE(sel.pseudos.count(), expectedSel.pseudos.count());
-        for (int i = 0; i < sel.pseudos.count(); ++i) {
-            QCOMPARE(sel.pseudos.at(i).name, expectedSel.pseudos.at(i).name);
-            QCOMPARE(sel.pseudos.at(i).function, expectedSel.pseudos.at(i).function);
-        }
-
-        QCOMPARE(sel.attributeSelectors.count(), expectedSel.attributeSelectors.count());
-        for (int i = 0; i < sel.attributeSelectors.count(); ++i) {
-            QCOMPARE(sel.attributeSelectors.at(i).name, expectedSel.attributeSelectors.at(i).name);
-            QCOMPARE(sel.attributeSelectors.at(i).value, expectedSel.attributeSelectors.at(i).value);
-            QCOMPARE(int(sel.attributeSelectors.at(i).valueMatchCriterium), int(expectedSel.attributeSelectors.at(i).valueMatchCriterium));
-        }
-    }
-}
-
-void tst_CssParser::prio()
-{
-    {
-        QCss::Parser parser("!important");
-        QVERIFY(parser.testPrio());
-    }
-    {
-        QCss::Parser parser("!impOrTAnt");
-        QVERIFY(parser.testPrio());
-    }
-    {
-        QCss::Parser parser("!\"important\"");
-        QVERIFY(!parser.testPrio());
-        QCOMPARE(parser.index, 0);
-    }
-    {
-        QCss::Parser parser("!importbleh");
-        QVERIFY(!parser.testPrio());
-        QCOMPARE(parser.index, 0);
-    }
-}
-
-void tst_CssParser::escapes()
-{
-    QCss::Parser parser("\\hello");
-    parser.test(QCss::IDENT);
-    QCOMPARE(parser.lexem(), QString("hello"));
-}
-
-void tst_CssParser::malformedDeclarations_data()
-{
-    QTest::addColumn<QString>("css");
-
-    QTest::newRow("1") << QString("p { color:green }");
-    QTest::newRow("2") << QString("p { color:green; color }  /* malformed declaration missing ':', value */");
-    QTest::newRow("3") << QString("p { color:red;   color; color:green }  /* same with expected recovery */");
-    QTest::newRow("4") << QString("p { color:green; color: } /* malformed declaration missing value */");
-    QTest::newRow("5") << QString("p { color:red;   color:; color:green } /* same with expected recovery */");
-    QTest::newRow("6") << QString("p { color:green; color{;color:maroon} } /* unexpected tokens { } */");
-    QTest::newRow("7") << QString("p { color:red;   color{;color:maroon}; color:green } /* same with recovery */");
-}
-
-void tst_CssParser::malformedDeclarations()
-{
-    QFETCH(QString, css);
-    QCss::Parser parser(css);
-    QVERIFY(parser.testRuleset());
-    QCss::StyleRule rule;
-    QVERIFY(parser.parseRuleset(&rule));
-
-    QCOMPARE(rule.selectors.count(), 1);
-    QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
-    QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p"));
-
-    QVERIFY(rule.declarations.count() >= 1);
-    QCOMPARE(int(rule.declarations.last().d->propertyId), int(QCss::Color));
-    QCOMPARE(rule.declarations.last().d->values.count(), 1);
-    QCOMPARE(int(rule.declarations.last().d->values.at(0).type), int(QCss::Value::Identifier));
-    QCOMPARE(rule.declarations.last().d->values.at(0).variant.toString(), QString("green"));
-}
-
-void tst_CssParser::invalidAtKeywords()
-{
-    QCss::Parser parser(""
-    "@three-dee {"
-    "  @background-lighting {"
-    "    azimuth: 30deg;"
-    "    elevation: 190deg;"
-    "  }"
-    "  h1 { color: red }"
-    "}"
-    "h1 { color: blue }");
-
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
-    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ?
-            sheet.styleRules.at(0) : *sheet.nameIndex.begin();
-
-    QCOMPARE(rule.selectors.count(), 1);
-    QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
-    QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("h1"));
-
-    QCOMPARE(rule.declarations.count(), 1);
-    QCOMPARE(int(rule.declarations.at(0).d->propertyId), int(QCss::Color));
-    QCOMPARE(rule.declarations.at(0).d->values.count(), 1);
-    QCOMPARE(int(rule.declarations.at(0).d->values.at(0).type), int(QCss::Value::Identifier));
-    QCOMPARE(rule.declarations.at(0).d->values.at(0).variant.toString(), QString("blue"));
-}
-
-Q_DECLARE_METATYPE(QColor)
-
-void tst_CssParser::colorValue_data()
-{
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<QColor>("expectedColor");
-
-    QTest::newRow("identifier") << "color: black" << QColor("black");
-    QTest::newRow("string") << "color: \"green\"" << QColor("green");
-    QTest::newRow("hexcolor") << "color: #12af0e" << QColor(0x12, 0xaf, 0x0e);
-    QTest::newRow("functional1") << "color: rgb(21, 45, 73)" << QColor(21, 45, 73);
-    QTest::newRow("functional2") << "color: rgb(100%, 0%, 100%)" << QColor(0xff, 0, 0xff);
-    QTest::newRow("rgba") << "color: rgba(10, 20, 30, 40)" << QColor(10, 20, 30, 40);
-    QTest::newRow("rgb") << "color: rgb(10, 20, 30, 40)" << QColor(10, 20, 30, 40);
-    QTest::newRow("hsl") << "color: hsv(10, 20, 30)" << QColor::fromHsv(10, 20, 30, 255);
-    QTest::newRow("hsla") << "color: hsva(10, 20, 30, 40)" << QColor::fromHsv(10, 20, 30, 40);
-    QTest::newRow("invalid1") << "color: rgb(why, does, it, always, rain, on, me)" << QColor();
-    QTest::newRow("invalid2") << "color: rgba(i, meant, norway)" << QColor();
-    QTest::newRow("role") << "color: palette(base)" << qApp->palette().color(QPalette::Base);
-    QTest::newRow("role2") << "color: palette( window-text ) " << qApp->palette().color(QPalette::WindowText);
-    QTest::newRow("transparent") << "color: transparent" << QColor(Qt::transparent);
-}
-
-void tst_CssParser::colorValue()
-{
-    QFETCH(QString, css);
-    QFETCH(QColor, expectedColor);
-
-    QCss::Parser parser(css);
-    QCss::Declaration decl;
-    QVERIFY(parser.parseNextDeclaration(&decl));
-    const QColor col = decl.colorValue();
-    QVERIFY(expectedColor.isValid() == col.isValid());
-    QCOMPARE(col, expectedColor);
-}
-
-class DomStyleSelector : public QCss::StyleSelector
-{
-public:
-    inline DomStyleSelector(const QDomDocument &doc, const QCss::StyleSheet &sheet)
-        : doc(doc)
-    {
-        styleSheets.append(sheet);
-    }
-
-    virtual QStringList nodeNames(NodePtr node) const { return QStringList(reinterpret_cast<QDomElement *>(node.ptr)->tagName()); }
-    virtual QString attribute(NodePtr node, const QString &name) const { return reinterpret_cast<QDomElement *>(node.ptr)->attribute(name); }
-    virtual bool hasAttribute(NodePtr node, const QString &name) const { return reinterpret_cast<QDomElement *>(node.ptr)->hasAttribute(name); }
-    virtual bool hasAttributes(NodePtr node) const { return reinterpret_cast<QDomElement *>(node.ptr)->hasAttributes(); }
-
-    virtual bool isNullNode(NodePtr node) const {
-        return reinterpret_cast<QDomElement *>(node.ptr)->isNull();
-    }
-    virtual NodePtr parentNode(NodePtr node) const {
-        NodePtr parent;
-        parent.ptr = new QDomElement(reinterpret_cast<QDomElement *>(node.ptr)->parentNode().toElement());
-        return parent;
-    }
-    virtual NodePtr duplicateNode(NodePtr node) const {
-        NodePtr n;
-        n.ptr = new QDomElement(*reinterpret_cast<QDomElement *>(node.ptr));
-        return n;
-    }
-    virtual NodePtr previousSiblingNode(NodePtr node) const {
-        NodePtr sibling;
-        sibling.ptr = new QDomElement(reinterpret_cast<QDomElement *>(node.ptr)->previousSiblingElement());
-        return sibling;
-    }
-    virtual void freeNode(NodePtr node) const {
-        delete reinterpret_cast<QDomElement *>(node.ptr);
-    }
-
-private:
-    QDomDocument doc;
-};
-
-Q_DECLARE_METATYPE(QDomDocument);
-
-void tst_CssParser::marginValue_data()
-{
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<QString>("expectedMargin");
-
-    QFont f;
-    int ex = QFontMetrics(f).xHeight();
-    int em = QFontMetrics(f).height();
-
-    QTest::newRow("one value") << "margin: 1px" << "1 1 1 1";
-    QTest::newRow("two values") << "margin: 1px 2px" << "1 2 1 2";
-    QTest::newRow("three value") << "margin: 1px 2px 3px" << "1 2 3 2";
-    QTest::newRow("four values") << "margin: 1px 2px 3px 4px" << "1 2 3 4";
-    QTest::newRow("default px") << "margin: 1 2 3 4" << "1 2 3 4";
-    QTest::newRow("no unit") << "margin: 1 2 3 4" << "1 2 3 4";
-    QTest::newRow("em") << "margin: 1ex 2ex 3ex 4ex" << QString("%1 %2 %3 %4").arg(ex).arg(2*ex).arg(3*ex).arg(4*ex);
-    QTest::newRow("ex") << "margin: 1 2em 3px 4ex" << QString("%1 %2 %3 %4").arg(1).arg(2*em).arg(3).arg(4*ex);
-
-    f.setPointSize(20);
-    f.setBold(true);
-    ex = QFontMetrics(f).xHeight();
-    em = QFontMetrics(f).height();
-    QTest::newRow("em2") << "font: bold 20pt; margin: 1ex 2ex 3ex 4ex" << QString("%1 %2 %3 %4").arg(ex).arg(2*ex).arg(3*ex).arg(4*ex);
-    QTest::newRow("ex2") << "margin: 1 2em 3px 4ex; font-size: 20pt; font-weight: bold;" << QString("%1 %2 %3 %4").arg(1).arg(2*em).arg(3).arg(4*ex);
-
-    QTest::newRow("crap") << "margin: crap" << "0 0 0 0";
-}
-
-void tst_CssParser::marginValue()
-{
-    QFETCH(QString, css);
-    QFETCH(QString, expectedMargin);
-
-    QDomDocument doc;
-    QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
-
-    css.prepend("dummy {");
-    css.append("}");
-
-    QCss::Parser parser(css);
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    DomStyleSelector testSelector(doc, sheet);
-    QDomElement e = doc.documentElement().firstChildElement();
-    QCss::StyleSelector::NodePtr n;
-    n.ptr = &e;
-    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
-    QVector<QCss::Declaration> decls = rules.at(0).declarations;
-    QCss::ValueExtractor v(decls);
-
-    {
-    int m[4];
-    int p[4];
-    int spacing;
-    v.extractBox(m, p, &spacing);
-    QString str = QString("%1 %2 %3 %4").arg(m[0]).arg(m[1]).arg(m[2]).arg(m[3]);
-    QCOMPARE(str, expectedMargin);
-    }
-}
-
-void tst_CssParser::styleSelector_data()
-{
-    QTest::addColumn<bool>("match");
-    QTest::addColumn<QString>("selector");
-    QTest::addColumn<QString>("xml");
-    QTest::addColumn<QString>("elementToCheck");
-
-    QTest::newRow("plain") << true << QString("p") << QString("<p />") << QString();
-    QTest::newRow("noplain") << false << QString("bar") << QString("<p />") << QString();
-
-    QTest::newRow("class") << true << QString(".foo") << QString("<p class=\"foo\" />") << QString();
-    QTest::newRow("noclass") << false << QString(".bar") << QString("<p class=\"foo\" />") << QString();
-
-    QTest::newRow("attrset") << true << QString("[justset]") << QString("<p justset=\"bar\" />") << QString();
-    QTest::newRow("notattrset") << false << QString("[justset]") << QString("<p otherattribute=\"blub\" />") << QString();
-
-    QTest::newRow("attrmatch") << true << QString("[foo=bar]") << QString("<p foo=\"bar\" />") << QString();
-    QTest::newRow("noattrmatch") << false << QString("[foo=bar]") << QString("<p foo=\"xyz\" />") << QString();
-
-    QTest::newRow("contains") << true << QString("[foo~=bar]") << QString("<p foo=\"baz bleh bar\" />") << QString();
-    QTest::newRow("notcontains") << false << QString("[foo~=bar]") << QString("<p foo=\"test\" />") << QString();
-
-    QTest::newRow("beingswith") << true << QString("[foo|=bar]") << QString("<p foo=\"bar-bleh\" />") << QString();
-    QTest::newRow("notbeingswith") << false << QString("[foo|=bar]") << QString("<p foo=\"bleh-bar\" />") << QString();
-
-    QTest::newRow("attr2") << true << QString("[bar=foo]") << QString("<p bleh=\"bar\" bar=\"foo\" />") << QString();
-
-    QTest::newRow("universal1") << true << QString("*") << QString("<p />") << QString();
-
-    QTest::newRow("universal3") << false << QString("*[foo=bar]") << QString("<p foo=\"bleh\" />") << QString();
-    QTest::newRow("universal4") << true << QString("*[foo=bar]") << QString("<p foo=\"bar\" />") << QString();
-
-    QTest::newRow("universal5") << false << QString("[foo=bar]") << QString("<p foo=\"bleh\" />") << QString();
-    QTest::newRow("universal6") << true << QString("[foo=bar]") << QString("<p foo=\"bar\" />") << QString();
-
-    QTest::newRow("universal7") << true << QString(".charfmt1") << QString("<p class=\"charfmt1\" />") << QString();
-
-    QTest::newRow("id") << true << QString("#blub") << QString("<p id=\"blub\" />") << QString();
-    QTest::newRow("noid") << false << QString("#blub") << QString("<p id=\"other\" />") << QString();
-
-    QTest::newRow("childselector") << true << QString("parent > child")
-                                   << QString("<parent><child /></parent>")
-                                   << QString("parent/child");
-
-    QTest::newRow("nochildselector2") << false << QString("parent > child")
-                                   << QString("<child><parent /></child>")
-                                   << QString("child/parent");
-
-    QTest::newRow("nochildselector3") << false << QString("parent > child")
-                                   << QString("<parent><intermediate><child /></intermediate></parent>")
-                                   << QString("parent/intermediate/child");
-
-    QTest::newRow("childselector2") << true << QString("parent[foo=bar] > child")
-                                   << QString("<parent foo=\"bar\"><child /></parent>")
-                                   << QString("parent/child");
-
-    QTest::newRow("nochildselector4") << false << QString("parent[foo=bar] > child")
-                                   << QString("<parent><child /></parent>")
-                                   << QString("parent/child");
-
-    QTest::newRow("nochildselector5") << false << QString("parent[foo=bar] > child")
-                                   << QString("<parent foo=\"bar\"><parent><child /></parent></parent>")
-                                   << QString("parent/parent/child");
-
-    QTest::newRow("childselectors") << true << QString("grandparent > parent > child")
-                                   << QString("<grandparent><parent><child /></parent></grandparent>")
-                                   << QString("grandparent/parent/child");
-
-    QTest::newRow("descendant") << true << QString("grandparent child")
-                                   << QString("<grandparent><parent><child /></parent></grandparent>")
-                                   << QString("grandparent/parent/child");
-
-    QTest::newRow("nodescendant") << false << QString("grandparent child")
-                                   << QString("<other><parent><child /></parent></other>")
-                                   << QString("other/parent/child");
-
-    QTest::newRow("descendant2") << true << QString("grandgrandparent grandparent child")
-                                   << QString("<grandgrandparent><inbetween><grandparent><parent><child /></parent></grandparent></inbetween></grandgrandparent>")
-                                   << QString("grandgrandparent/inbetween/grandparent/parent/child");
-
-    QTest::newRow("combined") << true << QString("grandparent parent > child")
-                              << QString("<grandparent><inbetween><parent><child /></parent></inbetween></grandparent>")
-                              << QString("grandparent/inbetween/parent/child");
-
-    QTest::newRow("combined2") << true << QString("grandparent > parent child")
-                              << QString("<grandparent><parent><inbetween><child /></inbetween></parent></grandparent>")
-                              << QString("grandparent/parent/inbetween/child");
-
-    QTest::newRow("combined3") << true << QString("grandparent > parent child")
-                              << QString("<grandparent><parent><inbetween><child /></inbetween></parent></grandparent>")
-                              << QString("grandparent/parent/inbetween/child");
-
-    QTest::newRow("nocombined") << false << QString("grandparent parent > child")
-                              << QString("<inbetween><parent><child /></parent></inbetween>")
-                              << QString("inbetween/parent/child");
-
-    QTest::newRow("nocombined2") << false << QString("grandparent parent > child")
-                              << QString("<parent><child /></parent>")
-                              << QString("parent/child");
-
-    QTest::newRow("previoussibling") << true << QString("p1 + p2")
-                                     << QString("<p1 /><p2 />")
-                                     << QString("p2");
-
-    QTest::newRow("noprevioussibling") << false << QString("p2 + p1")
-                                     << QString("<p1 /><p2 />")
-                                     << QString("p2");
-
-    QTest::newRow("ancestry_firstmismatch") << false << QString("parent child[foo=bar]")
-                                            << QString("<parent><child /></parent>")
-                                            << QString("parent/child");
-
-    QTest::newRow("unknown-pseudo") << false << QString("p:enabled:foobar") << QString("<p/>") << QString();
-}
-
-void tst_CssParser::styleSelector()
-{
-    QFETCH(bool, match);
-    QFETCH(QString, selector);
-    QFETCH(QString, xml);
-    QFETCH(QString, elementToCheck);
-
-    QString css = QString("%1 { background-color: green }").arg(selector);
-    QCss::Parser parser(css);
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    QDomDocument doc;
-    xml.prepend("<!DOCTYPE test><test>");
-    xml.append("</test>");
-    QVERIFY(doc.setContent(xml));
-
-    DomStyleSelector testSelector(doc, sheet);
-
-    QDomElement e = doc.documentElement();
-    if (elementToCheck.isEmpty()) {
-        e = e.firstChildElement();
-    } else {
-        QStringList path = elementToCheck.split(QLatin1Char('/'));
-        do {
-            e = e.namedItem(path.takeFirst()).toElement();
-        } while (!path.isEmpty());
-    }
-    QVERIFY(!e.isNull());
-    QCss::StyleSelector::NodePtr n;
-    n.ptr = &e;
-    QVector<QCss::Declaration> decls = testSelector.declarationsForNode(n);
-
-    if (match) {
-        QCOMPARE(decls.count(), 1);
-        QCOMPARE(int(decls.at(0).d->propertyId), int(QCss::BackgroundColor));
-        QCOMPARE(decls.at(0).d->values.count(), 1);
-        QCOMPARE(int(decls.at(0).d->values.at(0).type), int(QCss::Value::Identifier));
-        QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), QString("green"));
-    } else {
-        QVERIFY(decls.isEmpty());
-    }
-}
-
-void tst_CssParser::specificity_data()
-{
-    QTest::addColumn<QString>("selector");
-    QTest::addColumn<int>("specificity");
-
-    QTest::newRow("universal") << QString("*") << 0;
-
-    QTest::newRow("elements+pseudos1") << QString("foo") << 1;
-    QTest::newRow("elements+pseudos2") << QString("foo *[blah]") << 1 + (1 * 0x10);
-
-    // should strictly speaking be '2', but we don't support pseudo-elements yet,
-    // only pseudo-classes
-    QTest::newRow("elements+pseudos3") << QString("li:first-line") << 1 + (1 * 0x10);
-
-    QTest::newRow("elements+pseudos4") << QString("ul li") << 2;
-    QTest::newRow("elements+pseudos5") << QString("ul ol+li") << 3;
-    QTest::newRow("elements+pseudos6") << QString("h1 + *[rel=up]") << 1 + (1 * 0x10);
-
-    QTest::newRow("elements+pseudos7") << QString("ul ol li.red") << 3 + (1 * 0x10);
-    QTest::newRow("elements+pseudos8") << QString("li.red.level") << 1 + (2 * 0x10);
-    QTest::newRow("id") << QString("#x34y") << 1 * 0x100;
-}
-
-void tst_CssParser::specificity()
-{
-    QFETCH(QString, selector);
-
-    QString css = QString("%1 { }").arg(selector);
-    QCss::Parser parser(css);
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count() + sheet.idIndex.count() , 1);
-    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0) 
-                        :  (!sheet.nameIndex.isEmpty())  ? *sheet.nameIndex.begin() 
-                        :  *sheet.idIndex.begin();
-    QCOMPARE(rule.selectors.count(), 1);
-    QTEST(rule.selectors.at(0).specificity(), "specificity");
-}
-
-void tst_CssParser::specificitySort_data()
-{
-    QTest::addColumn<QString>("firstSelector");
-    QTest::addColumn<QString>("secondSelector");
-    QTest::addColumn<QString>("xml");
-
-    QTest::newRow("universal1") << QString("*") << QString("p") << QString("<p />");
-    QTest::newRow("attr") << QString("p") << QString("p[foo=bar]") << QString("<p foo=\"bar\" />");
-    QTest::newRow("id") << QString("p") << QString("#hey") << QString("<p id=\"hey\" />");
-    QTest::newRow("id2") << QString("[id=hey]") << QString("#hey") << QString("<p id=\"hey\" />");
-    QTest::newRow("class") << QString("p") << QString(".hey") << QString("<p class=\"hey\" />");
-}
-
-void tst_CssParser::specificitySort()
-{
-    QFETCH(QString, firstSelector);
-    QFETCH(QString, secondSelector);
-    QFETCH(QString, xml);
-
-    firstSelector.append(" { color: green; }");
-    secondSelector.append(" { color: red; }");
-
-    QDomDocument doc;
-    xml.prepend("<!DOCTYPE test><test>");
-    xml.append("</test>");
-    QVERIFY(doc.setContent(xml));
-
-    for (int i = 0; i < 2; ++i) {
-        QString css;
-        if (i == 0)
-            css = firstSelector + secondSelector;
-        else
-            css = secondSelector + firstSelector;
-
-        QCss::Parser parser(css);
-        QCss::StyleSheet sheet;
-        QVERIFY(parser.parse(&sheet));
-
-        DomStyleSelector testSelector(doc, sheet);
-
-        QDomElement e = doc.documentElement().firstChildElement();
-        QCss::StyleSelector::NodePtr n;
-        n.ptr = &e;
-        QVector<QCss::Declaration> decls = testSelector.declarationsForNode(n);
-
-        QCOMPARE(decls.count(), 2);
-
-        QCOMPARE(int(decls.at(0).d->propertyId), int(QCss::Color));
-        QCOMPARE(decls.at(0).d->values.count(), 1);
-        QCOMPARE(int(decls.at(0).d->values.at(0).type), int(QCss::Value::Identifier));
-        QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), QString("green"));
-
-        QCOMPARE(int(decls.at(1).d->propertyId), int(QCss::Color));
-        QCOMPARE(decls.at(1).d->values.count(), 1);
-        QCOMPARE(int(decls.at(1).d->values.at(0).type), int(QCss::Value::Identifier));
-        QCOMPARE(decls.at(1).d->values.at(0).variant.toString(), QString("red"));
-    }
-}
-
-void tst_CssParser::rulesForNode_data()
-{
-    QTest::addColumn<QString>("xml");
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<quint64>("pseudoClass");
-    QTest::addColumn<int>("declCount");
-    QTest::addColumn<QString>("value0");
-    QTest::addColumn<QString>("value1");
-
-    QTest::newRow("universal1") << QString("<p/>") << QString("* { color: red }")
-                                << (quint64)QCss::PseudoClass_Unspecified << 1 << "red" << "";
-
-    QTest::newRow("basic") << QString("<p/>") << QString("p:enabled { color: red; bg:blue; }")
-        << (quint64)QCss::PseudoClass_Enabled << 2 << "red" << "blue";
-
-    QTest::newRow("single") << QString("<p/>")
-        << QString("p:enabled { color: red; } *:hover { color: white }")
-        << (quint64)QCss::PseudoClass_Hover << 1 << "white" << "";
-
-    QTest::newRow("multisel") << QString("<p/>")
-        << QString("p:enabled { color: red; } p:hover { color: gray } *:hover { color: white } ")
-        << (quint64)QCss::PseudoClass_Hover << 2 << "white" << "gray";
-
-    QTest::newRow("multisel2") << QString("<p/>")
-        << QString("p:enabled { color: red; } p:hover:focus { color: gray } *:hover { color: white } ")
-        << quint64(QCss::PseudoClass_Hover|QCss::PseudoClass_Focus) << 2 << "white" << "gray";
-
-    QTest::newRow("multisel3-diffspec") << QString("<p/>")
-        << QString("p:enabled { color: red; } p:hover:focus { color: gray } *:hover { color: white } ")
-        << quint64(QCss::PseudoClass_Hover) << 1 << "white" << "";
-
-    QTest::newRow("!-1") << QString("<p/>")
-        << QString("p:checked:!hover { color: red; } p:checked:hover { color: gray } p:checked { color: white }")
-        << quint64(QCss::PseudoClass_Hover|QCss::PseudoClass_Checked) << 2 << "white" << "gray";
-
-    QTest::newRow("!-2") << QString("<p/>")
-        << QString("p:checked:!hover:!pressed { color: red; } p:!checked:hover { color: gray } p:!focus { color: blue }")
-        << quint64(QCss::PseudoClass_Focus) << 0 << "" << "";
-
-    QTest::newRow("!-3") << QString("<p/>")
-        << QString("p:checked:!hover:!pressed { color: red; } p:!checked:hover { color: gray } p:!focus { color: blue; }")
-        << quint64(QCss::PseudoClass_Pressed) << 1 << "blue" << "";
-}
-
-void tst_CssParser::rulesForNode()
-{
-    QFETCH(QString, xml);
-    QFETCH(QString, css);
-    QFETCH(quint64, pseudoClass);
-    QFETCH(int, declCount);
-    QFETCH(QString, value0);
-    QFETCH(QString, value1);
-
-    QDomDocument doc;
-    xml.prepend("<!DOCTYPE test><test>");
-    xml.append("</test>");
-    QVERIFY(doc.setContent(xml));
-
-    QCss::Parser parser(css);
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    DomStyleSelector testSelector(doc, sheet);
-    QDomElement e = doc.documentElement().firstChildElement();
-    QCss::StyleSelector::NodePtr n;
-    n.ptr = &e;
-    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
-
-    QVector<QCss::Declaration> decls;
-    for (int i = 0; i < rules.count(); i++) {
-        const QCss::Selector &selector = rules.at(i).selectors.at(0);
-        quint64 negated = 0;
-        quint64 cssClass = selector.pseudoClass(&negated);
-        if ((cssClass == QCss::PseudoClass_Unspecified)
-            || ((((cssClass & pseudoClass) == cssClass)) && ((negated & pseudoClass) == 0)))
-            decls += rules.at(i).declarations;
-    }
-
-    QVERIFY(decls.count() == declCount);
-
-    if (declCount > 0)
-        QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), value0);
-    if (declCount > 1)
-        QCOMPARE(decls.at(1).d->values.at(0).variant.toString(), value1);
-}
-
-void tst_CssParser::shorthandBackgroundProperty_data()
-{
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<QBrush>("expectedBrush");
-    QTest::addColumn<QString>("expectedImage");
-    QTest::addColumn<int>("expectedRepeatValue");
-    QTest::addColumn<int>("expectedAlignment");
-
-    QTest::newRow("simple color") << "background: red" << QBrush(QColor("red")) << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignTop);
-    QTest::newRow("plain color") << "background-color: red" << QBrush(QColor("red")) << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignTop);
-    QTest::newRow("palette color") << "background-color: palette(mid)" << qApp->palette().mid() << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignTop);
-    QTest::newRow("multiple") << "background: url(chess.png) blue repeat-y" << QBrush(QColor("blue")) << QString("chess.png") << int(QCss::Repeat_Y) << int(Qt::AlignLeft | Qt::AlignTop);
-    QTest::newRow("plain alignment") << "background-position: center" << QBrush() << QString() << int(QCss::Repeat_XY) << int(Qt::AlignCenter);
-    QTest::newRow("plain alignment2") << "background-position: left top" << QBrush() << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignTop);
-    QTest::newRow("plain alignment3") << "background-position: left" << QBrush() << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignVCenter);
-    QTest::newRow("multi") << "background: left url(blah.png) repeat-x" << QBrush() << QString("blah.png") << int(QCss::Repeat_X) << int(Qt::AlignLeft | Qt::AlignVCenter);
-    QTest::newRow("multi2") << "background: url(blah.png) repeat-x top" << QBrush() << QString("blah.png") << int(QCss::Repeat_X) << int(Qt::AlignTop | Qt::AlignHCenter);
-    QTest::newRow("multi3") << "background: url(blah.png) top right" << QBrush() << QString("blah.png") << int(QCss::Repeat_XY) << int(Qt::AlignTop | Qt::AlignRight);
-}
-
-void tst_CssParser::shorthandBackgroundProperty()
-{
-    QFETCH(QString, css);
-
-    QDomDocument doc;
-    QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
-
-    css.prepend("dummy {");
-    css.append("}");
-
-    QCss::Parser parser(css);
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    DomStyleSelector testSelector(doc, sheet);
-    QDomElement e = doc.documentElement().firstChildElement();
-    QCss::StyleSelector::NodePtr n;
-    n.ptr = &e;
-    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
-    QVector<QCss::Declaration> decls = rules.at(0).declarations;
-    QCss::ValueExtractor v(decls);
-
-    QBrush brush;
-    QString image;
-    QCss::Repeat repeat = QCss::Repeat_XY;
-    Qt::Alignment alignment = Qt::AlignTop | Qt::AlignLeft;
-    QCss::Origin origin = QCss::Origin_Padding;
-    QCss::Attachment attachment;
-    QCss::Origin ignoredOrigin;
-    v.extractBackground(&brush, &image, &repeat, &alignment, &origin, &attachment, &ignoredOrigin);
-
-    QFETCH(QBrush, expectedBrush);
-    QVERIFY(expectedBrush.color() == brush.color());
-
-    QTEST(image, "expectedImage");
-    QTEST(int(repeat), "expectedRepeatValue");
-    QTEST(int(alignment), "expectedAlignment");
-}
-
-void tst_CssParser::pseudoElement_data()
-{
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<QString>("pseudoElement");
-    QTest::addColumn<int>("declCount");
-
-    // QComboBox::dropDown { border-image: blah; }
-    QTest::newRow("no pseudo-elements") << QString("dummy:hover { color: red }") << "" << 1;
-    QTest::newRow("no pseudo-elements") << QString("dummy:hover { color: red }") << "pe" << 0;
-
-    QTest::newRow("1 pseudo-element (1)") << QString("dummy::pe:hover { color: red }") << "pe" << 1;
-    QTest::newRow("1 pseudo-element (2)") << QString("dummy::pe:hover { color: red }") << "x" << 0;
-    QTest::newRow("1 pseudo-element (2)") << QString("whatever::pe:hover { color: red }") << "pe" << 0;
-
-    QTest::newRow("1 pseudo-element (3)")
-        << QString("dummy { color: white; } dummy::pe:hover { color: red }") << "x" << 0;
-    QTest::newRow("1 pseudo-element (4)")
-        << QString("dummy { color: white; } dummy::pe:hover { color: red } dummy { x:y }") << "" << 2;
-    QTest::newRow("1 pseudo-element (5)")
-        << QString("dummy { color: white; } dummy::pe:hover { color: red }") << "pe" << 1;
-    QTest::newRow("1 pseudo-element (6)")
-      << QString("dummy { color: white; } dummy::pe:hover { color: red } dummy::pe:checked { x: y} ") << "pe" << 2;
-
-    QTest::newRow("2 pseudo-elements (1)")
-      << QString("dummy { color: white; } dummy::pe1:hover { color: red } dummy::pe2:checked { x: y} ")
-      << "" << 1;
-    QTest::newRow("2 pseudo-elements (1)")
-      << QString("dummy { color: white; } dummy::pe1:hover { color: red } dummy::pe2:checked { x: y} ")
-      << "pe1" << 1;
-    QTest::newRow("2 pseudo-elements (2)")
-      << QString("dummy { color: white; } dummy::pe1:hover { color: red } dummy::pe2:checked { x: y} ")
-      << "pe2" << 1;
-}
-
-void tst_CssParser::pseudoElement()
-{
-    QFETCH(QString, css);
-    QFETCH(QString, pseudoElement);
-    QFETCH(int, declCount);
-
-    QDomDocument doc;
-    QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
-
-    QCss::Parser parser(css);
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    DomStyleSelector testSelector(doc, sheet);
-    QDomElement e = doc.documentElement().firstChildElement();
-    QCss::StyleSelector::NodePtr n;
-    n.ptr = &e;
-    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
-    QVector<QCss::Declaration> decls;
-    for (int i = 0; i < rules.count(); i++) {
-        const QCss::Selector& selector = rules.at(i).selectors.at(0);
-        if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) != 0)
-            continue;
-        decls += rules.at(i).declarations;
-
-    }
-    QVERIFY(decls.count() == declCount);
-}
-
-void tst_CssParser::gradient_data()
-{
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<QString>("type");
-    QTest::addColumn<QPointF>("start");
-    QTest::addColumn<QPointF>("finalStop");
-    QTest::addColumn<int>("spread");
-    QTest::addColumn<qreal>("stop0");
-    QTest::addColumn<QColor>("color0");
-    QTest::addColumn<qreal>("stop1");
-    QTest::addColumn<QColor>("color1");
-
-    QTest::newRow("color-string") <<
-     "selection-background-color: qlineargradient(x1:1, y1:2, x2:3, y2:4, "
-         "stop:0.2 red, stop:0.5 green)" << "linear" << QPointF(1, 2) << QPointF(3, 4)
-                                  << 0 << qreal(0.2) << QColor("red") << qreal(0.5) << QColor("green");
-
-    QTest::newRow("color-#") <<
-     "selection-background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
-         "spread: reflect, stop:0.2 #123, stop:0.5 #456)" << "linear" << QPointF(0, 0) << QPointF(0, 1)
-                             << 1 << qreal(0.2) << QColor("#123") << qreal(0.5) << QColor("#456");
-
-    QTest::newRow("color-rgb") <<
-     "selection-background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
-         "spread: reflect, stop:0.2 rgb(1, 2, 3), stop:0.5 rgba(1, 2, 3, 4))" << "linear" << QPointF(0, 0) << QPointF(0, 1)
-                             << 1 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
-
-    QTest::newRow("color-spaces") <<
-     "selection-background-color: qlineargradient(x1: 0, y1 :0,x2:0, y2 : 1 , "
-         "spread: reflect, stop:0.2 rgb(1, 2, 3), stop: 0.5   rgba(1, 2, 3, 4))" << "linear" << QPointF(0, 0) << QPointF(0, 1)
-                             << 1 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
-
-    QTest::newRow("conical gradient") <<
-     "selection-background-color: qconicalgradient(cx: 4, cy : 2, angle: 23, "
-         "spread: repeat, stop:0.2 rgb(1, 2, 3), stop:0.5 rgba(1, 2, 3, 4))" << "conical" << QPointF(4, 2) << QPointF()
-                             << 2 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
-
-    /* wont pass: stop values are expected to be sorted
-     QTest::newRow("unsorted-stop") <<
-     "selection-background: lineargradient(x1:0, y1:0, x2:0, y2:1, "
-         "stop:0.5 green, stop:0.2 red)" << QPointF(0, 0) << QPointF(0, 1)
-         0 << 0.2 << QColor("red") << 0.5 << QColor("green");
-    */
-}
-
-void tst_CssParser::gradient()
-{
-    QFETCH(QString, css);
-    QFETCH(QString, type);
-    QFETCH(QPointF, finalStop);
-    QFETCH(QPointF, start);
-    QFETCH(int, spread);
-    QFETCH(qreal, stop0); QFETCH(QColor, color0);
-    QFETCH(qreal, stop1); QFETCH(QColor, color1);
-
-    QDomDocument doc;
-    QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
-
-    css.prepend("dummy {");
-    css.append("}");
-
-    QCss::Parser parser(css);
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    DomStyleSelector testSelector(doc, sheet);
-    QDomElement e = doc.documentElement().firstChildElement();
-    QCss::StyleSelector::NodePtr n;
-    n.ptr = &e;
-    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
-    QVector<QCss::Declaration> decls = rules.at(0).declarations;
-    QCss::ValueExtractor ve(decls);
-    QBrush fg, sfg;
-    QBrush sbg, abg;
-    QVERIFY(ve.extractPalette(&fg, &sfg, &sbg, &abg));
-    if (type == "linear") {
-        QVERIFY(sbg.style() == Qt::LinearGradientPattern);
-        const QLinearGradient *lg = static_cast<const QLinearGradient *>(sbg.gradient());
-        QCOMPARE(lg->start(), start);
-        QCOMPARE(lg->finalStop(), finalStop);
-    } else if (type == "conical") {
-        QVERIFY(sbg.style() == Qt::ConicalGradientPattern);
-        const QConicalGradient *cg = static_cast<const QConicalGradient *>(sbg.gradient());
-        QCOMPARE(cg->center(), start);
-    }
-    const QGradient *g = sbg.gradient();
-    QCOMPARE(g->spread(), QGradient::Spread(spread));
-    QVERIFY(g->stops().at(0).first == stop0);
-    QVERIFY(g->stops().at(0).second == color0);
-    QVERIFY(g->stops().at(1).first == stop1);
-    QVERIFY(g->stops().at(1).second == color1);
-}
-
-void tst_CssParser::extractFontFamily_data()
-{
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<QString>("expectedFamily");
-
-    QTest::newRow("quoted-family-name") << "font-family: 'Times New Roman'" << QString("Times New Roman");
-    QTest::newRow("unquoted-family-name") << "font-family: Times New Roman" << QString("Times New Roman");
-    QTest::newRow("unquoted-family-name2") << "font-family: Times        New     Roman" << QString("Times New Roman");
-    QTest::newRow("multiple") << "font-family: Times New Roman  , foobar, 'baz'" << QString("Times New Roman");
-    QTest::newRow("multiple2") << "font-family: invalid,  Times New   Roman " << QString("Times New Roman");
-    QTest::newRow("invalid") << "font-family: invalid" << QFontInfo(QFont("invalid font")).family();
-    QTest::newRow("shorthand") << "font: 12pt Times New Roman" << QString("Times New Roman");
-    QTest::newRow("shorthand multiple quote") << "font: 12pt invalid, \"Times New Roman\" " << QString("Times New Roman");
-    QTest::newRow("shorthand multiple") << "font: 12pt invalid, Times New Roman " << QString("Times New Roman");
-}
-
-void tst_CssParser::extractFontFamily()
-{
-    QFETCH(QString, css);
-    css.prepend("dummy {");
-    css.append("}");
-
-    QCss::Parser parser(css);
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
-    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ?
-            sheet.styleRules.at(0) : *sheet.nameIndex.begin();
-
-    const QVector<QCss::Declaration> decls = rule.declarations;
-    QVERIFY(!decls.isEmpty());
-    QCss::ValueExtractor extractor(decls);
-
-    int adjustment = 0;
-    QFont fnt;
-    extractor.extractFont(&fnt, &adjustment);
-    QFontInfo info(fnt);
-    QTEST(info.family(), "expectedFamily");
-}
-
-void tst_CssParser::extractBorder_data()
-{
-    QTest::addColumn<QString>("css");
-    QTest::addColumn<int>("expectedTopWidth");
-    QTest::addColumn<int>("expectedTopStyle");
-    QTest::addColumn<QColor>("expectedTopColor");
-
-    QTest::newRow("all values") << "border: 2px solid green" << 2 << (int)QCss::BorderStyle_Solid << QColor("green");
-    QTest::newRow("palette") << "border: 2px solid palette(highlight)" << 2 << (int)QCss::BorderStyle_Solid << qApp->palette().color(QPalette::Highlight);
-    QTest::newRow("just width") << "border: 2px" << 2 << (int)QCss::BorderStyle_None << QColor();
-    QTest::newRow("just style") << "border: solid" << 0 << (int)QCss::BorderStyle_Solid << QColor();
-    QTest::newRow("just color") << "border: green" << 0 << (int)QCss::BorderStyle_None << QColor("green");
-    QTest::newRow("width+style") << "border: 2px solid" << 2 << (int)QCss::BorderStyle_Solid << QColor();
-    QTest::newRow("style+color") << "border: solid green" << 0 << (int)QCss::BorderStyle_Solid << QColor("green");
-    QTest::newRow("width+color") << "border: 3px green" << 3 << (int)QCss::BorderStyle_None << QColor("green");
-    QTest::newRow("groove style") << "border: groove" << 0 << (int)QCss::BorderStyle_Groove << QColor();
-    QTest::newRow("ridge style") << "border: ridge" << 0 << (int)QCss::BorderStyle_Ridge << QColor();
-    QTest::newRow("double style") << "border: double" << 0 << (int)QCss::BorderStyle_Double << QColor();
-    QTest::newRow("inset style") << "border: inset" << 0 << (int)QCss::BorderStyle_Inset << QColor();
-    QTest::newRow("outset style") << "border: outset" << 0 << (int)QCss::BorderStyle_Outset << QColor();
-    QTest::newRow("dashed style") << "border: dashed" << 0 << (int)QCss::BorderStyle_Dashed << QColor();
-    QTest::newRow("dotted style") << "border: dotted" << 0 << (int)QCss::BorderStyle_Dotted << QColor();
-    QTest::newRow("dot-dash style") << "border: dot-dash" << 0 << (int)QCss::BorderStyle_DotDash << QColor();
-    QTest::newRow("dot-dot-dash style") << "border: dot-dot-dash" << 0 << (int)QCss::BorderStyle_DotDotDash << QColor();
-
-    QTest::newRow("top-width+color") << "border-top: 3px green" << 3 << (int)QCss::BorderStyle_None << QColor("green");
-}
-
-void tst_CssParser::extractBorder()
-{
-    QFETCH(QString, css);
-    QFETCH(int, expectedTopWidth);
-    QFETCH(int, expectedTopStyle);
-    QFETCH(QColor, expectedTopColor);
-
-    css.prepend("dummy {");
-    css.append("}");
-
-    QCss::Parser parser(css);
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
-    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ?
-            sheet.styleRules.at(0) : *sheet.nameIndex.begin();
-    const QVector<QCss::Declaration> decls = rule.declarations;
-    QVERIFY(!decls.isEmpty());
-    QCss::ValueExtractor extractor(decls);
-
-    int widths[4];
-    QBrush colors[4];
-    QCss::BorderStyle styles[4];
-    QSize radii[4];
-
-    extractor.extractBorder(widths, colors, styles, radii);
-    QVERIFY(widths[QCss::TopEdge] == expectedTopWidth);
-    QVERIFY(styles[QCss::TopEdge] == expectedTopStyle);
-    QVERIFY(colors[QCss::TopEdge] == expectedTopColor);
-}
-
-void tst_CssParser::noTextDecoration()
-{
-    QCss::Parser parser("dummy { text-decoration: none; }");
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
-    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ?
-            sheet.styleRules.at(0) : *sheet.nameIndex.begin();
-    const QVector<QCss::Declaration> decls = rule.declarations;
-    QVERIFY(!decls.isEmpty());
-    QCss::ValueExtractor extractor(decls);
-
-    int adjustment = 0;
-    QFont f;
-    f.setUnderline(true);
-    f.setOverline(true);
-    f.setStrikeOut(true);
-    QVERIFY(extractor.extractFont(&f, &adjustment));
-
-    QVERIFY(!f.underline());
-    QVERIFY(!f.overline());
-    QVERIFY(!f.strikeOut());
-}
-
-void tst_CssParser::quotedAndUnquotedIdentifiers()
-{
-    QCss::Parser parser("foo { font-style: \"italic\"; font-weight: bold }");
-    QCss::StyleSheet sheet;
-    QVERIFY(parser.parse(&sheet));
-
-    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
-    QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
-           sheet.styleRules.at(0) : *sheet.nameIndex.begin();
-    const QVector<QCss::Declaration> decls = rule.declarations;
-    QCOMPARE(decls.size(), 2);
-
-    QCOMPARE(decls.at(0).d->values.first().type, QCss::Value::String);
-    QCOMPARE(decls.at(0).d->property, QLatin1String("font-style"));
-    QCOMPARE(decls.at(0).d->values.first().toString(), QLatin1String("italic"));
-
-    QCOMPARE(decls.at(1).d->values.first().type, QCss::Value::KnownIdentifier);
-    QCOMPARE(decls.at(1).d->property, QLatin1String("font-weight"));
-    QCOMPARE(decls.at(1).d->values.first().toString(), QLatin1String("bold"));
-}
-
-QTEST_MAIN(tst_CssParser)
-#include "tst_cssparser.moc"
diff --git a/tests/auto/qcssparser/tst_qcssparser.cpp b/tests/auto/qcssparser/tst_qcssparser.cpp
new file mode 100644
index 0000000..33d85fa
--- /dev/null
+++ b/tests/auto/qcssparser/tst_qcssparser.cpp
@@ -0,0 +1,1617 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QtXml/QtXml>
+
+//TESTED_CLASS=QCss
+//TESTED_FILES=gui/text/qcssparser.cpp gui/text/qcssparser_p.h
+
+#include "private/qcssparser_p.h"
+
+class tst_QCssParser : public QObject
+{
+    Q_OBJECT
+private slots:
+    void scanner_data();
+    void scanner();
+    void term_data();
+    void term();
+    void expr_data();
+    void expr();
+    void import();
+    void media();
+    void page();
+    void ruleset();
+    void selector_data();
+    void selector();
+    void prio();
+    void escapes();
+    void malformedDeclarations_data();
+    void malformedDeclarations();
+    void invalidAtKeywords();
+    void marginValue();
+    void marginValue_data();
+    void colorValue_data();
+    void colorValue();
+    void styleSelector_data();
+    void styleSelector();
+    void specificity_data();
+    void specificity();
+    void specificitySort_data();
+    void specificitySort();
+    void rulesForNode_data();
+    void rulesForNode();
+    void shorthandBackgroundProperty_data();
+    void shorthandBackgroundProperty();
+    void pseudoElement_data();
+    void pseudoElement();
+    void gradient_data();
+    void gradient();
+    void extractFontFamily_data();
+    void extractFontFamily();
+    void extractBorder_data();
+    void extractBorder();
+    void noTextDecoration();
+    void quotedAndUnquotedIdentifiers();
+};
+
+void tst_QCssParser::scanner_data()
+{
+    QTest::addColumn<QString>("input");
+    QTest::addColumn<QString>("output");
+
+#if !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE)
+    QDir d(SRCDIR);
+#else
+    QDir d(QDir::current());
+#endif
+    d.cd("testdata");
+    d.cd("scanner");
+    foreach (QFileInfo test, d.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
+        QString dir = test.absoluteFilePath() + QDir::separator();
+        QTest::newRow(qPrintable(test.baseName()))
+            << dir + "input"
+            << dir + "output"
+            ;
+    }
+}
+
+static void debug(const QVector<QCss::Symbol> &symbols, int index = -1)
+{
+    qDebug() << "all symbols:";
+    for (int i = 0; i < symbols.count(); ++i)
+        qDebug() << "(" << i << "); Token:" << QCss::Scanner::tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem();
+    if (index != -1)
+        qDebug() << "failure at index" << index;
+}
+
+//static void debug(const QCss::Parser &p) { debug(p.symbols); }
+
+void tst_QCssParser::scanner()
+{
+    QFETCH(QString, input);
+    QFETCH(QString, output);
+
+    QFile inputFile(input);
+    QVERIFY(inputFile.open(QIODevice::ReadOnly|QIODevice::Text));
+    QVector<QCss::Symbol> symbols;
+    QCss::Scanner::scan(QCss::Scanner::preprocess(QString::fromUtf8(inputFile.readAll())), &symbols);
+
+    QVERIFY(symbols.count() > 1);
+    QVERIFY(symbols.last().token == QCss::S);
+    QVERIFY(symbols.last().lexem() == QLatin1String("\n"));
+    symbols.remove(symbols.count() - 1, 1);
+
+    QFile outputFile(output);
+    QVERIFY(outputFile.open(QIODevice::ReadOnly|QIODevice::Text));
+    QStringList lines;
+    while (!outputFile.atEnd()) {
+        QString line = QString::fromUtf8(outputFile.readLine());
+        if (line.endsWith(QLatin1Char('\n')))
+            line.chop(1);
+        lines.append(line);
+    }
+
+    if (lines.count() != symbols.count()) {
+        debug(symbols);
+        QCOMPARE(lines.count(), symbols.count());
+    }
+
+    for (int i = 0; i < lines.count(); ++i) {
+        QStringList l = lines.at(i).split(QChar::fromLatin1('|'));
+        QCOMPARE(l.count(), 2);
+        const QString expectedToken = l.at(0);
+        const QString expectedLexem = l.at(1);
+        QString actualToken = QString::fromLatin1(QCss::Scanner::tokenName(symbols.at(i).token));
+        if (actualToken != expectedToken) {
+            debug(symbols, i);
+            QCOMPARE(actualToken, expectedToken);
+        }
+        if (symbols.at(i).lexem() != expectedLexem) {
+            debug(symbols, i);
+            QCOMPARE(symbols.at(i).lexem(), expectedLexem);
+        }
+    }
+}
+
+Q_DECLARE_METATYPE(QCss::Value)
+
+void tst_QCssParser::term_data()
+{
+    QTest::addColumn<bool>("parseSuccess");
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<QCss::Value>("expectedValue");
+
+    QCss::Value val;
+
+    val.type = QCss::Value::Percentage;
+    val.variant = QVariant(double(200));
+    QTest::newRow("percentage") << true << "200%" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10px");
+    QTest::newRow("px") << true << "10px" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10cm");
+    QTest::newRow("cm") << true << "10cm" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10mm");
+    QTest::newRow("mm") << true << "10mm" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10pt");
+    QTest::newRow("pt") << true << "10pt" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10pc");
+    QTest::newRow("pc") << true << "10pc" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("42in");
+    QTest::newRow("inch") << true << "42in" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10deg");
+    QTest::newRow("deg") << true << "10deg" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10rad");
+    QTest::newRow("rad") << true << "10rad" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10grad");
+    QTest::newRow("grad") << true << "10grad" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10ms");
+    QTest::newRow("time") << true << "10ms" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10s");
+    QTest::newRow("times") << true << "10s" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10hz");
+    QTest::newRow("hz") << true << "10hz" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10khz");
+    QTest::newRow("khz") << true << "10khz" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10myunit");
+    QTest::newRow("dimension") << true << "10myunit" << val;
+
+    val.type = QCss::Value::Percentage;
+
+    val.type = QCss::Value::Percentage;
+    val.variant = QVariant(double(-200));
+    QTest::newRow("minuspercentage") << true << "-200%" << val;
+
+    val.type = QCss::Value::Length;
+    val.variant = QString("10em");
+    QTest::newRow("ems") << true << "10em" << val;
+
+    val.type = QCss::Value::String;
+    val.variant = QVariant(QString("foo"));
+    QTest::newRow("string") << true << "\"foo\"" << val;
+
+    val.type = QCss::Value::Function;
+    val.variant = QVariant(QStringList() << "myFunc" << "23, (nested text)");
+    QTest::newRow("function") << true << "myFunc(23, (nested text))" << val;
+
+    QTest::newRow("function_failure") << false << "myFunction((blah)" << val;
+    QTest::newRow("function_failure2") << false << "+myFunc(23, (nested text))" << val;
+
+    val.type = QCss::Value::Color;
+    val.variant = QVariant(QColor("#12ff34"));
+    QTest::newRow("hexcolor") << true << "#12ff34" << val;
+
+    val.type = QCss::Value::Color;
+    val.variant = QVariant(QColor("#ffbb00"));
+    QTest::newRow("hexcolor2") << true << "#fb0" << val;
+
+    QTest::ignoreMessage(QtWarningMsg, "QCssParser::parseHexColor: Unknown color name '#cafebabe'");
+    QTest::newRow("hexcolor_failure") << false << "#cafebabe" << val;
+
+    val.type = QCss::Value::Uri;
+    val.variant = QString("www.kde.org");
+    QTest::newRow("uri1") << true << "url(\"www.kde.org\")" << val;
+
+    QTest::newRow("uri2") << true << "url(www.kde.org)" << val;
+
+    val.type = QCss::Value::KnownIdentifier;
+    val.variant = int(QCss::Value_Italic);
+    QTest::newRow("italic") << true << "italic" << val;
+
+    val.type = QCss::Value::KnownIdentifier;
+    val.variant = int(QCss::Value_Italic);
+    QTest::newRow("ItaLIc") << true << "ItaLIc" << val;
+}
+
+void tst_QCssParser::term()
+{
+    QFETCH(bool, parseSuccess);
+    QFETCH(QString, css);
+    QFETCH(QCss::Value, expectedValue);
+
+    QCss::Parser parser(css);
+    QCss::Value val;
+    QVERIFY(parser.testTerm());
+    QCOMPARE(parser.parseTerm(&val), parseSuccess);
+    if (parseSuccess) {
+        QCOMPARE(int(val.type), int(expectedValue.type));
+        if (val.variant != expectedValue.variant) {
+            qDebug() << "val.variant:" << val.variant << "expectedValue.variant:" << expectedValue.variant;
+            QCOMPARE(val.variant, expectedValue.variant);
+        }
+    }
+}
+
+Q_DECLARE_METATYPE(QVector<QCss::Value>)
+
+void tst_QCssParser::expr_data()
+{
+    QTest::addColumn<bool>("parseSuccess");
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<QVector<QCss::Value> >("expectedValues");
+
+    QVector<QCss::Value> values;
+    QCss::Value val;
+
+    QCss::Value comma;
+    comma.type = QCss::Value::TermOperatorComma;
+
+    val.type = QCss::Value::Identifier;
+    val.variant = QLatin1String("foo");
+    values << val;
+    values << comma;
+    val.variant = QLatin1String("bar");
+    values << val;
+    values << comma;
+    val.variant = QLatin1String("baz");
+    values << val;
+    QTest::newRow("list") << true << "foo, bar, baz" << values;
+    values.clear();
+}
+
+void tst_QCssParser::expr()
+{
+    QFETCH(bool, parseSuccess);
+    QFETCH(QString, css);
+    QFETCH(QVector<QCss::Value>, expectedValues);
+
+    QCss::Parser parser(css);
+    QVector<QCss::Value> values;
+    QVERIFY(parser.testExpr());
+    QCOMPARE(parser.parseExpr(&values), parseSuccess);
+    if (parseSuccess) {
+        QCOMPARE(values.count(), expectedValues.count());
+
+        for (int i = 0; i < values.count(); ++i) {
+            QCOMPARE(int(values.at(i).type), int(expectedValues.at(i).type));
+            QCOMPARE(values.at(i).variant, expectedValues.at(i).variant);
+        }
+    }
+}
+
+void tst_QCssParser::import()
+{
+    QCss::Parser parser("@import \"plainstring\";");
+    QVERIFY(parser.testImport());
+    QCss::ImportRule rule;
+    QVERIFY(parser.parseImport(&rule));
+    QCOMPARE(rule.href, QString("plainstring"));
+
+    parser = QCss::Parser("@import url(\"www.kde.org\") print/*comment*/,screen;");
+    QVERIFY(parser.testImport());
+    QVERIFY(parser.parseImport(&rule));
+    QCOMPARE(rule.href, QString("www.kde.org"));
+    QCOMPARE(rule.media.count(), 2);
+    QCOMPARE(rule.media.at(0), QString("print"));
+    QCOMPARE(rule.media.at(1), QString("screen"));
+}
+
+void tst_QCssParser::media()
+{
+    QCss::Parser parser("@media print/*comment*/,screen /*comment to ignore*/{ }");
+    QVERIFY(parser.testMedia());
+    QCss::MediaRule rule;
+    QVERIFY(parser.parseMedia(&rule));
+    QCOMPARE(rule.media.count(), 2);
+    QCOMPARE(rule.media.at(0), QString("print"));
+    QCOMPARE(rule.media.at(1), QString("screen"));
+    QVERIFY(rule.styleRules.isEmpty());
+}
+
+void tst_QCssParser::page()
+{
+    QCss::Parser parser("@page :first/*comment to ignore*/{ }");
+    QVERIFY(parser.testPage());
+    QCss::PageRule rule;
+    QVERIFY(parser.parsePage(&rule));
+    QCOMPARE(rule.selector, QString("first"));
+    QVERIFY(rule.declarations.isEmpty());
+}
+
+void tst_QCssParser::ruleset()
+{
+    {
+        QCss::Parser parser("p/*foo*/{ }");
+        QVERIFY(parser.testRuleset());
+        QCss::StyleRule rule;
+        QVERIFY(parser.parseRuleset(&rule));
+        QCOMPARE(rule.selectors.count(), 1);
+        QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
+        QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p"));
+        QVERIFY(rule.declarations.isEmpty());
+    }
+
+    {
+        QCss::Parser parser("p/*comment*/,div{ }");
+        QVERIFY(parser.testRuleset());
+        QCss::StyleRule rule;
+        QVERIFY(parser.parseRuleset(&rule));
+        QCOMPARE(rule.selectors.count(), 2);
+        QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
+        QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p"));
+        QCOMPARE(rule.selectors.at(1).basicSelectors.count(), 1);
+        QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).elementName, QString("div"));
+        QVERIFY(rule.declarations.isEmpty());
+    }
+
+    {
+        QCss::Parser parser(":before, :after { }");
+        QVERIFY(parser.testRuleset());
+        QCss::StyleRule rule;
+        QVERIFY(parser.parseRuleset(&rule));
+        QCOMPARE(rule.selectors.count(), 2);
+
+        QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
+        QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.count(), 1);
+        QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).pseudos.at(0).name, QString("before"));
+
+        QCOMPARE(rule.selectors.at(1).basicSelectors.count(), 1);
+        QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.count(), 1);
+        QCOMPARE(rule.selectors.at(1).basicSelectors.at(0).pseudos.at(0).name, QString("after"));
+
+        QVERIFY(rule.declarations.isEmpty());
+    }
+
+}
+
+Q_DECLARE_METATYPE(QCss::Selector)
+
+void tst_QCssParser::selector_data()
+{
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<QCss::Selector>("expectedSelector");
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "p";
+        basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfPreceeds;
+        sel.basicSelectors << basic;
+
+        basic = QCss::BasicSelector();
+        basic.elementName = "div";
+        sel.basicSelectors << basic;
+
+        QTest::newRow("comment") << QString("p/* */+ div") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = QString();
+        sel.basicSelectors << basic;
+
+        QTest::newRow("any") << QString("*") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        sel.basicSelectors << basic;
+
+        QTest::newRow("element") << QString("e") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfAncestor;
+        sel.basicSelectors << basic;
+
+        basic.elementName = "f";
+        basic.relationToNext = QCss::BasicSelector::NoRelation;
+        sel.basicSelectors << basic;
+
+        QTest::newRow("descendant") << QString("e f") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfParent;
+        sel.basicSelectors << basic;
+
+        basic.elementName = "f";
+        basic.relationToNext = QCss::BasicSelector::NoRelation;
+        sel.basicSelectors << basic;
+
+        QTest::newRow("parent") << QString("e > f") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        QCss::Pseudo pseudo;
+        pseudo.name = "first-child";
+        basic.pseudos.append(pseudo);
+        sel.basicSelectors << basic;
+
+        QTest::newRow("first-child") << QString("e:first-child") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        QCss::Pseudo pseudo;
+        pseudo.name = "c";
+        pseudo.function = "lang";
+        basic.pseudos.append(pseudo);
+        sel.basicSelectors << basic;
+
+        QTest::newRow("lang") << QString("e:lang(c)") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        basic.relationToNext = QCss::BasicSelector::MatchNextSelectorIfPreceeds;
+        sel.basicSelectors << basic;
+
+        basic.elementName = "f";
+        basic.relationToNext = QCss::BasicSelector::NoRelation;
+        sel.basicSelectors << basic;
+
+        QTest::newRow("precede") << QString("e + f") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        QCss::AttributeSelector attrSel;
+        attrSel.name = "foo";
+        basic.attributeSelectors << attrSel;
+        sel.basicSelectors << basic;
+
+        QTest::newRow("attr") << QString("e[foo]") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        QCss::AttributeSelector attrSel;
+        attrSel.name = "foo";
+        attrSel.value = "warning";
+        attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchEqual;
+        basic.attributeSelectors << attrSel;
+        sel.basicSelectors << basic;
+
+        QTest::newRow("attr-equal") << QString("e[foo=\"warning\"]") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        QCss::AttributeSelector attrSel;
+        attrSel.name = "foo";
+        attrSel.value = "warning";
+        attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchContains;
+        basic.attributeSelectors << attrSel;
+        sel.basicSelectors << basic;
+
+        QTest::newRow("attr-contains") << QString("e[foo~=\"warning\"]") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        QCss::AttributeSelector attrSel;
+        attrSel.name = "lang";
+        attrSel.value = "en";
+        attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchBeginsWith;
+        basic.attributeSelectors << attrSel;
+        sel.basicSelectors << basic;
+
+        QTest::newRow("attr-contains") << QString("e[lang|=\"en\"]") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "div";
+
+        QCss::AttributeSelector attrSel;
+        attrSel.name = "class";
+        attrSel.valueMatchCriterium = QCss::AttributeSelector::MatchContains;
+        attrSel.value = "warning";
+        basic.attributeSelectors.append(attrSel);
+
+        attrSel.value = "foo";
+        basic.attributeSelectors.append(attrSel);
+
+        sel.basicSelectors << basic;
+
+        QTest::newRow("class") << QString("div.warning.foo") << sel;
+    }
+
+    {
+        QCss::Selector sel;
+        QCss::BasicSelector basic;
+
+        basic.elementName = "e";
+        basic.ids << "myid";
+        sel.basicSelectors << basic;
+
+        QTest::newRow("id") << QString("e#myid") << sel;
+    }
+}
+
+void tst_QCssParser::selector()
+{
+    QFETCH(QString, css);
+    QFETCH(QCss::Selector, expectedSelector);
+
+    QCss::Parser parser(css);
+    QVERIFY(parser.testSelector());
+    QCss::Selector selector;
+    QVERIFY(parser.parseSelector(&selector));
+
+    QCOMPARE(selector.basicSelectors.count(), expectedSelector.basicSelectors.count());
+    for (int i = 0; i < selector.basicSelectors.count(); ++i) {
+        const QCss::BasicSelector sel = selector.basicSelectors.at(i);
+        const QCss::BasicSelector expectedSel = expectedSelector.basicSelectors.at(i);
+        QCOMPARE(sel.elementName, expectedSel.elementName);
+        QCOMPARE(int(sel.relationToNext), int(expectedSel.relationToNext));
+
+        QCOMPARE(sel.pseudos.count(), expectedSel.pseudos.count());
+        for (int i = 0; i < sel.pseudos.count(); ++i) {
+            QCOMPARE(sel.pseudos.at(i).name, expectedSel.pseudos.at(i).name);
+            QCOMPARE(sel.pseudos.at(i).function, expectedSel.pseudos.at(i).function);
+        }
+
+        QCOMPARE(sel.attributeSelectors.count(), expectedSel.attributeSelectors.count());
+        for (int i = 0; i < sel.attributeSelectors.count(); ++i) {
+            QCOMPARE(sel.attributeSelectors.at(i).name, expectedSel.attributeSelectors.at(i).name);
+            QCOMPARE(sel.attributeSelectors.at(i).value, expectedSel.attributeSelectors.at(i).value);
+            QCOMPARE(int(sel.attributeSelectors.at(i).valueMatchCriterium), int(expectedSel.attributeSelectors.at(i).valueMatchCriterium));
+        }
+    }
+}
+
+void tst_QCssParser::prio()
+{
+    {
+        QCss::Parser parser("!important");
+        QVERIFY(parser.testPrio());
+    }
+    {
+        QCss::Parser parser("!impOrTAnt");
+        QVERIFY(parser.testPrio());
+    }
+    {
+        QCss::Parser parser("!\"important\"");
+        QVERIFY(!parser.testPrio());
+        QCOMPARE(parser.index, 0);
+    }
+    {
+        QCss::Parser parser("!importbleh");
+        QVERIFY(!parser.testPrio());
+        QCOMPARE(parser.index, 0);
+    }
+}
+
+void tst_QCssParser::escapes()
+{
+    QCss::Parser parser("\\hello");
+    parser.test(QCss::IDENT);
+    QCOMPARE(parser.lexem(), QString("hello"));
+}
+
+void tst_QCssParser::malformedDeclarations_data()
+{
+    QTest::addColumn<QString>("css");
+
+    QTest::newRow("1") << QString("p { color:green }");
+    QTest::newRow("2") << QString("p { color:green; color }  /* malformed declaration missing ':', value */");
+    QTest::newRow("3") << QString("p { color:red;   color; color:green }  /* same with expected recovery */");
+    QTest::newRow("4") << QString("p { color:green; color: } /* malformed declaration missing value */");
+    QTest::newRow("5") << QString("p { color:red;   color:; color:green } /* same with expected recovery */");
+    QTest::newRow("6") << QString("p { color:green; color{;color:maroon} } /* unexpected tokens { } */");
+    QTest::newRow("7") << QString("p { color:red;   color{;color:maroon}; color:green } /* same with recovery */");
+}
+
+void tst_QCssParser::malformedDeclarations()
+{
+    QFETCH(QString, css);
+    QCss::Parser parser(css);
+    QVERIFY(parser.testRuleset());
+    QCss::StyleRule rule;
+    QVERIFY(parser.parseRuleset(&rule));
+
+    QCOMPARE(rule.selectors.count(), 1);
+    QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
+    QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("p"));
+
+    QVERIFY(rule.declarations.count() >= 1);
+    QCOMPARE(int(rule.declarations.last().d->propertyId), int(QCss::Color));
+    QCOMPARE(rule.declarations.last().d->values.count(), 1);
+    QCOMPARE(int(rule.declarations.last().d->values.at(0).type), int(QCss::Value::Identifier));
+    QCOMPARE(rule.declarations.last().d->values.at(0).variant.toString(), QString("green"));
+}
+
+void tst_QCssParser::invalidAtKeywords()
+{
+    QCss::Parser parser(""
+    "@three-dee {"
+    "  @background-lighting {"
+    "    azimuth: 30deg;"
+    "    elevation: 190deg;"
+    "  }"
+    "  h1 { color: red }"
+    "}"
+    "h1 { color: blue }");
+
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ?
+            sheet.styleRules.at(0) : *sheet.nameIndex.begin();
+
+    QCOMPARE(rule.selectors.count(), 1);
+    QCOMPARE(rule.selectors.at(0).basicSelectors.count(), 1);
+    QCOMPARE(rule.selectors.at(0).basicSelectors.at(0).elementName, QString("h1"));
+
+    QCOMPARE(rule.declarations.count(), 1);
+    QCOMPARE(int(rule.declarations.at(0).d->propertyId), int(QCss::Color));
+    QCOMPARE(rule.declarations.at(0).d->values.count(), 1);
+    QCOMPARE(int(rule.declarations.at(0).d->values.at(0).type), int(QCss::Value::Identifier));
+    QCOMPARE(rule.declarations.at(0).d->values.at(0).variant.toString(), QString("blue"));
+}
+
+Q_DECLARE_METATYPE(QColor)
+
+void tst_QCssParser::colorValue_data()
+{
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<QColor>("expectedColor");
+
+    QTest::newRow("identifier") << "color: black" << QColor("black");
+    QTest::newRow("string") << "color: \"green\"" << QColor("green");
+    QTest::newRow("hexcolor") << "color: #12af0e" << QColor(0x12, 0xaf, 0x0e);
+    QTest::newRow("functional1") << "color: rgb(21, 45, 73)" << QColor(21, 45, 73);
+    QTest::newRow("functional2") << "color: rgb(100%, 0%, 100%)" << QColor(0xff, 0, 0xff);
+    QTest::newRow("rgba") << "color: rgba(10, 20, 30, 40)" << QColor(10, 20, 30, 40);
+    QTest::newRow("rgb") << "color: rgb(10, 20, 30, 40)" << QColor(10, 20, 30, 40);
+    QTest::newRow("hsl") << "color: hsv(10, 20, 30)" << QColor::fromHsv(10, 20, 30, 255);
+    QTest::newRow("hsla") << "color: hsva(10, 20, 30, 40)" << QColor::fromHsv(10, 20, 30, 40);
+    QTest::newRow("invalid1") << "color: rgb(why, does, it, always, rain, on, me)" << QColor();
+    QTest::newRow("invalid2") << "color: rgba(i, meant, norway)" << QColor();
+    QTest::newRow("role") << "color: palette(base)" << qApp->palette().color(QPalette::Base);
+    QTest::newRow("role2") << "color: palette( window-text ) " << qApp->palette().color(QPalette::WindowText);
+    QTest::newRow("transparent") << "color: transparent" << QColor(Qt::transparent);
+}
+
+void tst_QCssParser::colorValue()
+{
+    QFETCH(QString, css);
+    QFETCH(QColor, expectedColor);
+
+    QCss::Parser parser(css);
+    QCss::Declaration decl;
+    QVERIFY(parser.parseNextDeclaration(&decl));
+    const QColor col = decl.colorValue();
+    QVERIFY(expectedColor.isValid() == col.isValid());
+    QCOMPARE(col, expectedColor);
+}
+
+class DomStyleSelector : public QCss::StyleSelector
+{
+public:
+    inline DomStyleSelector(const QDomDocument &doc, const QCss::StyleSheet &sheet)
+        : doc(doc)
+    {
+        styleSheets.append(sheet);
+    }
+
+    virtual QStringList nodeNames(NodePtr node) const { return QStringList(reinterpret_cast<QDomElement *>(node.ptr)->tagName()); }
+    virtual QString attribute(NodePtr node, const QString &name) const { return reinterpret_cast<QDomElement *>(node.ptr)->attribute(name); }
+    virtual bool hasAttribute(NodePtr node, const QString &name) const { return reinterpret_cast<QDomElement *>(node.ptr)->hasAttribute(name); }
+    virtual bool hasAttributes(NodePtr node) const { return reinterpret_cast<QDomElement *>(node.ptr)->hasAttributes(); }
+
+    virtual bool isNullNode(NodePtr node) const {
+        return reinterpret_cast<QDomElement *>(node.ptr)->isNull();
+    }
+    virtual NodePtr parentNode(NodePtr node) const {
+        NodePtr parent;
+        parent.ptr = new QDomElement(reinterpret_cast<QDomElement *>(node.ptr)->parentNode().toElement());
+        return parent;
+    }
+    virtual NodePtr duplicateNode(NodePtr node) const {
+        NodePtr n;
+        n.ptr = new QDomElement(*reinterpret_cast<QDomElement *>(node.ptr));
+        return n;
+    }
+    virtual NodePtr previousSiblingNode(NodePtr node) const {
+        NodePtr sibling;
+        sibling.ptr = new QDomElement(reinterpret_cast<QDomElement *>(node.ptr)->previousSiblingElement());
+        return sibling;
+    }
+    virtual void freeNode(NodePtr node) const {
+        delete reinterpret_cast<QDomElement *>(node.ptr);
+    }
+
+private:
+    QDomDocument doc;
+};
+
+Q_DECLARE_METATYPE(QDomDocument);
+
+void tst_QCssParser::marginValue_data()
+{
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<QString>("expectedMargin");
+
+    QFont f;
+    int ex = QFontMetrics(f).xHeight();
+    int em = QFontMetrics(f).height();
+
+    QTest::newRow("one value") << "margin: 1px" << "1 1 1 1";
+    QTest::newRow("two values") << "margin: 1px 2px" << "1 2 1 2";
+    QTest::newRow("three value") << "margin: 1px 2px 3px" << "1 2 3 2";
+    QTest::newRow("four values") << "margin: 1px 2px 3px 4px" << "1 2 3 4";
+    QTest::newRow("default px") << "margin: 1 2 3 4" << "1 2 3 4";
+    QTest::newRow("no unit") << "margin: 1 2 3 4" << "1 2 3 4";
+    QTest::newRow("em") << "margin: 1ex 2ex 3ex 4ex" << QString("%1 %2 %3 %4").arg(ex).arg(2*ex).arg(3*ex).arg(4*ex);
+    QTest::newRow("ex") << "margin: 1 2em 3px 4ex" << QString("%1 %2 %3 %4").arg(1).arg(2*em).arg(3).arg(4*ex);
+
+    f.setPointSize(20);
+    f.setBold(true);
+    ex = QFontMetrics(f).xHeight();
+    em = QFontMetrics(f).height();
+    QTest::newRow("em2") << "font: bold 20pt; margin: 1ex 2ex 3ex 4ex" << QString("%1 %2 %3 %4").arg(ex).arg(2*ex).arg(3*ex).arg(4*ex);
+    QTest::newRow("ex2") << "margin: 1 2em 3px 4ex; font-size: 20pt; font-weight: bold;" << QString("%1 %2 %3 %4").arg(1).arg(2*em).arg(3).arg(4*ex);
+
+    QTest::newRow("crap") << "margin: crap" << "0 0 0 0";
+}
+
+void tst_QCssParser::marginValue()
+{
+    QFETCH(QString, css);
+    QFETCH(QString, expectedMargin);
+
+    QDomDocument doc;
+    QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
+
+    css.prepend("dummy {");
+    css.append("}");
+
+    QCss::Parser parser(css);
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    DomStyleSelector testSelector(doc, sheet);
+    QDomElement e = doc.documentElement().firstChildElement();
+    QCss::StyleSelector::NodePtr n;
+    n.ptr = &e;
+    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
+    QVector<QCss::Declaration> decls = rules.at(0).declarations;
+    QCss::ValueExtractor v(decls);
+
+    {
+    int m[4];
+    int p[4];
+    int spacing;
+    v.extractBox(m, p, &spacing);
+    QString str = QString("%1 %2 %3 %4").arg(m[0]).arg(m[1]).arg(m[2]).arg(m[3]);
+    QCOMPARE(str, expectedMargin);
+    }
+}
+
+void tst_QCssParser::styleSelector_data()
+{
+    QTest::addColumn<bool>("match");
+    QTest::addColumn<QString>("selector");
+    QTest::addColumn<QString>("xml");
+    QTest::addColumn<QString>("elementToCheck");
+
+    QTest::newRow("plain") << true << QString("p") << QString("<p />") << QString();
+    QTest::newRow("noplain") << false << QString("bar") << QString("<p />") << QString();
+
+    QTest::newRow("class") << true << QString(".foo") << QString("<p class=\"foo\" />") << QString();
+    QTest::newRow("noclass") << false << QString(".bar") << QString("<p class=\"foo\" />") << QString();
+
+    QTest::newRow("attrset") << true << QString("[justset]") << QString("<p justset=\"bar\" />") << QString();
+    QTest::newRow("notattrset") << false << QString("[justset]") << QString("<p otherattribute=\"blub\" />") << QString();
+
+    QTest::newRow("attrmatch") << true << QString("[foo=bar]") << QString("<p foo=\"bar\" />") << QString();
+    QTest::newRow("noattrmatch") << false << QString("[foo=bar]") << QString("<p foo=\"xyz\" />") << QString();
+
+    QTest::newRow("contains") << true << QString("[foo~=bar]") << QString("<p foo=\"baz bleh bar\" />") << QString();
+    QTest::newRow("notcontains") << false << QString("[foo~=bar]") << QString("<p foo=\"test\" />") << QString();
+
+    QTest::newRow("beingswith") << true << QString("[foo|=bar]") << QString("<p foo=\"bar-bleh\" />") << QString();
+    QTest::newRow("notbeingswith") << false << QString("[foo|=bar]") << QString("<p foo=\"bleh-bar\" />") << QString();
+
+    QTest::newRow("attr2") << true << QString("[bar=foo]") << QString("<p bleh=\"bar\" bar=\"foo\" />") << QString();
+
+    QTest::newRow("universal1") << true << QString("*") << QString("<p />") << QString();
+
+    QTest::newRow("universal3") << false << QString("*[foo=bar]") << QString("<p foo=\"bleh\" />") << QString();
+    QTest::newRow("universal4") << true << QString("*[foo=bar]") << QString("<p foo=\"bar\" />") << QString();
+
+    QTest::newRow("universal5") << false << QString("[foo=bar]") << QString("<p foo=\"bleh\" />") << QString();
+    QTest::newRow("universal6") << true << QString("[foo=bar]") << QString("<p foo=\"bar\" />") << QString();
+
+    QTest::newRow("universal7") << true << QString(".charfmt1") << QString("<p class=\"charfmt1\" />") << QString();
+
+    QTest::newRow("id") << true << QString("#blub") << QString("<p id=\"blub\" />") << QString();
+    QTest::newRow("noid") << false << QString("#blub") << QString("<p id=\"other\" />") << QString();
+
+    QTest::newRow("childselector") << true << QString("parent > child")
+                                   << QString("<parent><child /></parent>")
+                                   << QString("parent/child");
+
+    QTest::newRow("nochildselector2") << false << QString("parent > child")
+                                   << QString("<child><parent /></child>")
+                                   << QString("child/parent");
+
+    QTest::newRow("nochildselector3") << false << QString("parent > child")
+                                   << QString("<parent><intermediate><child /></intermediate></parent>")
+                                   << QString("parent/intermediate/child");
+
+    QTest::newRow("childselector2") << true << QString("parent[foo=bar] > child")
+                                   << QString("<parent foo=\"bar\"><child /></parent>")
+                                   << QString("parent/child");
+
+    QTest::newRow("nochildselector4") << false << QString("parent[foo=bar] > child")
+                                   << QString("<parent><child /></parent>")
+                                   << QString("parent/child");
+
+    QTest::newRow("nochildselector5") << false << QString("parent[foo=bar] > child")
+                                   << QString("<parent foo=\"bar\"><parent><child /></parent></parent>")
+                                   << QString("parent/parent/child");
+
+    QTest::newRow("childselectors") << true << QString("grandparent > parent > child")
+                                   << QString("<grandparent><parent><child /></parent></grandparent>")
+                                   << QString("grandparent/parent/child");
+
+    QTest::newRow("descendant") << true << QString("grandparent child")
+                                   << QString("<grandparent><parent><child /></parent></grandparent>")
+                                   << QString("grandparent/parent/child");
+
+    QTest::newRow("nodescendant") << false << QString("grandparent child")
+                                   << QString("<other><parent><child /></parent></other>")
+                                   << QString("other/parent/child");
+
+    QTest::newRow("descendant2") << true << QString("grandgrandparent grandparent child")
+                                   << QString("<grandgrandparent><inbetween><grandparent><parent><child /></parent></grandparent></inbetween></grandgrandparent>")
+                                   << QString("grandgrandparent/inbetween/grandparent/parent/child");
+
+    QTest::newRow("combined") << true << QString("grandparent parent > child")
+                              << QString("<grandparent><inbetween><parent><child /></parent></inbetween></grandparent>")
+                              << QString("grandparent/inbetween/parent/child");
+
+    QTest::newRow("combined2") << true << QString("grandparent > parent child")
+                              << QString("<grandparent><parent><inbetween><child /></inbetween></parent></grandparent>")
+                              << QString("grandparent/parent/inbetween/child");
+
+    QTest::newRow("combined3") << true << QString("grandparent > parent child")
+                              << QString("<grandparent><parent><inbetween><child /></inbetween></parent></grandparent>")
+                              << QString("grandparent/parent/inbetween/child");
+
+    QTest::newRow("nocombined") << false << QString("grandparent parent > child")
+                              << QString("<inbetween><parent><child /></parent></inbetween>")
+                              << QString("inbetween/parent/child");
+
+    QTest::newRow("nocombined2") << false << QString("grandparent parent > child")
+                              << QString("<parent><child /></parent>")
+                              << QString("parent/child");
+
+    QTest::newRow("previoussibling") << true << QString("p1 + p2")
+                                     << QString("<p1 /><p2 />")
+                                     << QString("p2");
+
+    QTest::newRow("noprevioussibling") << false << QString("p2 + p1")
+                                     << QString("<p1 /><p2 />")
+                                     << QString("p2");
+
+    QTest::newRow("ancestry_firstmismatch") << false << QString("parent child[foo=bar]")
+                                            << QString("<parent><child /></parent>")
+                                            << QString("parent/child");
+
+    QTest::newRow("unknown-pseudo") << false << QString("p:enabled:foobar") << QString("<p/>") << QString();
+}
+
+void tst_QCssParser::styleSelector()
+{
+    QFETCH(bool, match);
+    QFETCH(QString, selector);
+    QFETCH(QString, xml);
+    QFETCH(QString, elementToCheck);
+
+    QString css = QString("%1 { background-color: green }").arg(selector);
+    QCss::Parser parser(css);
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    QDomDocument doc;
+    xml.prepend("<!DOCTYPE test><test>");
+    xml.append("</test>");
+    QVERIFY(doc.setContent(xml));
+
+    DomStyleSelector testSelector(doc, sheet);
+
+    QDomElement e = doc.documentElement();
+    if (elementToCheck.isEmpty()) {
+        e = e.firstChildElement();
+    } else {
+        QStringList path = elementToCheck.split(QLatin1Char('/'));
+        do {
+            e = e.namedItem(path.takeFirst()).toElement();
+        } while (!path.isEmpty());
+    }
+    QVERIFY(!e.isNull());
+    QCss::StyleSelector::NodePtr n;
+    n.ptr = &e;
+    QVector<QCss::Declaration> decls = testSelector.declarationsForNode(n);
+
+    if (match) {
+        QCOMPARE(decls.count(), 1);
+        QCOMPARE(int(decls.at(0).d->propertyId), int(QCss::BackgroundColor));
+        QCOMPARE(decls.at(0).d->values.count(), 1);
+        QCOMPARE(int(decls.at(0).d->values.at(0).type), int(QCss::Value::Identifier));
+        QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), QString("green"));
+    } else {
+        QVERIFY(decls.isEmpty());
+    }
+}
+
+void tst_QCssParser::specificity_data()
+{
+    QTest::addColumn<QString>("selector");
+    QTest::addColumn<int>("specificity");
+
+    QTest::newRow("universal") << QString("*") << 0;
+
+    QTest::newRow("elements+pseudos1") << QString("foo") << 1;
+    QTest::newRow("elements+pseudos2") << QString("foo *[blah]") << 1 + (1 * 0x10);
+
+    // should strictly speaking be '2', but we don't support pseudo-elements yet,
+    // only pseudo-classes
+    QTest::newRow("elements+pseudos3") << QString("li:first-line") << 1 + (1 * 0x10);
+
+    QTest::newRow("elements+pseudos4") << QString("ul li") << 2;
+    QTest::newRow("elements+pseudos5") << QString("ul ol+li") << 3;
+    QTest::newRow("elements+pseudos6") << QString("h1 + *[rel=up]") << 1 + (1 * 0x10);
+
+    QTest::newRow("elements+pseudos7") << QString("ul ol li.red") << 3 + (1 * 0x10);
+    QTest::newRow("elements+pseudos8") << QString("li.red.level") << 1 + (2 * 0x10);
+    QTest::newRow("id") << QString("#x34y") << 1 * 0x100;
+}
+
+void tst_QCssParser::specificity()
+{
+    QFETCH(QString, selector);
+
+    QString css = QString("%1 { }").arg(selector);
+    QCss::Parser parser(css);
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count() + sheet.idIndex.count() , 1);
+    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0) 
+                        :  (!sheet.nameIndex.isEmpty())  ? *sheet.nameIndex.begin() 
+                        :  *sheet.idIndex.begin();
+    QCOMPARE(rule.selectors.count(), 1);
+    QTEST(rule.selectors.at(0).specificity(), "specificity");
+}
+
+void tst_QCssParser::specificitySort_data()
+{
+    QTest::addColumn<QString>("firstSelector");
+    QTest::addColumn<QString>("secondSelector");
+    QTest::addColumn<QString>("xml");
+
+    QTest::newRow("universal1") << QString("*") << QString("p") << QString("<p />");
+    QTest::newRow("attr") << QString("p") << QString("p[foo=bar]") << QString("<p foo=\"bar\" />");
+    QTest::newRow("id") << QString("p") << QString("#hey") << QString("<p id=\"hey\" />");
+    QTest::newRow("id2") << QString("[id=hey]") << QString("#hey") << QString("<p id=\"hey\" />");
+    QTest::newRow("class") << QString("p") << QString(".hey") << QString("<p class=\"hey\" />");
+}
+
+void tst_QCssParser::specificitySort()
+{
+    QFETCH(QString, firstSelector);
+    QFETCH(QString, secondSelector);
+    QFETCH(QString, xml);
+
+    firstSelector.append(" { color: green; }");
+    secondSelector.append(" { color: red; }");
+
+    QDomDocument doc;
+    xml.prepend("<!DOCTYPE test><test>");
+    xml.append("</test>");
+    QVERIFY(doc.setContent(xml));
+
+    for (int i = 0; i < 2; ++i) {
+        QString css;
+        if (i == 0)
+            css = firstSelector + secondSelector;
+        else
+            css = secondSelector + firstSelector;
+
+        QCss::Parser parser(css);
+        QCss::StyleSheet sheet;
+        QVERIFY(parser.parse(&sheet));
+
+        DomStyleSelector testSelector(doc, sheet);
+
+        QDomElement e = doc.documentElement().firstChildElement();
+        QCss::StyleSelector::NodePtr n;
+        n.ptr = &e;
+        QVector<QCss::Declaration> decls = testSelector.declarationsForNode(n);
+
+        QCOMPARE(decls.count(), 2);
+
+        QCOMPARE(int(decls.at(0).d->propertyId), int(QCss::Color));
+        QCOMPARE(decls.at(0).d->values.count(), 1);
+        QCOMPARE(int(decls.at(0).d->values.at(0).type), int(QCss::Value::Identifier));
+        QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), QString("green"));
+
+        QCOMPARE(int(decls.at(1).d->propertyId), int(QCss::Color));
+        QCOMPARE(decls.at(1).d->values.count(), 1);
+        QCOMPARE(int(decls.at(1).d->values.at(0).type), int(QCss::Value::Identifier));
+        QCOMPARE(decls.at(1).d->values.at(0).variant.toString(), QString("red"));
+    }
+}
+
+void tst_QCssParser::rulesForNode_data()
+{
+    QTest::addColumn<QString>("xml");
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<quint64>("pseudoClass");
+    QTest::addColumn<int>("declCount");
+    QTest::addColumn<QString>("value0");
+    QTest::addColumn<QString>("value1");
+
+    QTest::newRow("universal1") << QString("<p/>") << QString("* { color: red }")
+                                << (quint64)QCss::PseudoClass_Unspecified << 1 << "red" << "";
+
+    QTest::newRow("basic") << QString("<p/>") << QString("p:enabled { color: red; bg:blue; }")
+        << (quint64)QCss::PseudoClass_Enabled << 2 << "red" << "blue";
+
+    QTest::newRow("single") << QString("<p/>")
+        << QString("p:enabled { color: red; } *:hover { color: white }")
+        << (quint64)QCss::PseudoClass_Hover << 1 << "white" << "";
+
+    QTest::newRow("multisel") << QString("<p/>")
+        << QString("p:enabled { color: red; } p:hover { color: gray } *:hover { color: white } ")
+        << (quint64)QCss::PseudoClass_Hover << 2 << "white" << "gray";
+
+    QTest::newRow("multisel2") << QString("<p/>")
+        << QString("p:enabled { color: red; } p:hover:focus { color: gray } *:hover { color: white } ")
+        << quint64(QCss::PseudoClass_Hover|QCss::PseudoClass_Focus) << 2 << "white" << "gray";
+
+    QTest::newRow("multisel3-diffspec") << QString("<p/>")
+        << QString("p:enabled { color: red; } p:hover:focus { color: gray } *:hover { color: white } ")
+        << quint64(QCss::PseudoClass_Hover) << 1 << "white" << "";
+
+    QTest::newRow("!-1") << QString("<p/>")
+        << QString("p:checked:!hover { color: red; } p:checked:hover { color: gray } p:checked { color: white }")
+        << quint64(QCss::PseudoClass_Hover|QCss::PseudoClass_Checked) << 2 << "white" << "gray";
+
+    QTest::newRow("!-2") << QString("<p/>")
+        << QString("p:checked:!hover:!pressed { color: red; } p:!checked:hover { color: gray } p:!focus { color: blue }")
+        << quint64(QCss::PseudoClass_Focus) << 0 << "" << "";
+
+    QTest::newRow("!-3") << QString("<p/>")
+        << QString("p:checked:!hover:!pressed { color: red; } p:!checked:hover { color: gray } p:!focus { color: blue; }")
+        << quint64(QCss::PseudoClass_Pressed) << 1 << "blue" << "";
+}
+
+void tst_QCssParser::rulesForNode()
+{
+    QFETCH(QString, xml);
+    QFETCH(QString, css);
+    QFETCH(quint64, pseudoClass);
+    QFETCH(int, declCount);
+    QFETCH(QString, value0);
+    QFETCH(QString, value1);
+
+    QDomDocument doc;
+    xml.prepend("<!DOCTYPE test><test>");
+    xml.append("</test>");
+    QVERIFY(doc.setContent(xml));
+
+    QCss::Parser parser(css);
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    DomStyleSelector testSelector(doc, sheet);
+    QDomElement e = doc.documentElement().firstChildElement();
+    QCss::StyleSelector::NodePtr n;
+    n.ptr = &e;
+    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
+
+    QVector<QCss::Declaration> decls;
+    for (int i = 0; i < rules.count(); i++) {
+        const QCss::Selector &selector = rules.at(i).selectors.at(0);
+        quint64 negated = 0;
+        quint64 cssClass = selector.pseudoClass(&negated);
+        if ((cssClass == QCss::PseudoClass_Unspecified)
+            || ((((cssClass & pseudoClass) == cssClass)) && ((negated & pseudoClass) == 0)))
+            decls += rules.at(i).declarations;
+    }
+
+    QVERIFY(decls.count() == declCount);
+
+    if (declCount > 0)
+        QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), value0);
+    if (declCount > 1)
+        QCOMPARE(decls.at(1).d->values.at(0).variant.toString(), value1);
+}
+
+void tst_QCssParser::shorthandBackgroundProperty_data()
+{
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<QBrush>("expectedBrush");
+    QTest::addColumn<QString>("expectedImage");
+    QTest::addColumn<int>("expectedRepeatValue");
+    QTest::addColumn<int>("expectedAlignment");
+
+    QTest::newRow("simple color") << "background: red" << QBrush(QColor("red")) << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignTop);
+    QTest::newRow("plain color") << "background-color: red" << QBrush(QColor("red")) << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignTop);
+    QTest::newRow("palette color") << "background-color: palette(mid)" << qApp->palette().mid() << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignTop);
+    QTest::newRow("multiple") << "background: url(chess.png) blue repeat-y" << QBrush(QColor("blue")) << QString("chess.png") << int(QCss::Repeat_Y) << int(Qt::AlignLeft | Qt::AlignTop);
+    QTest::newRow("plain alignment") << "background-position: center" << QBrush() << QString() << int(QCss::Repeat_XY) << int(Qt::AlignCenter);
+    QTest::newRow("plain alignment2") << "background-position: left top" << QBrush() << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignTop);
+    QTest::newRow("plain alignment3") << "background-position: left" << QBrush() << QString() << int(QCss::Repeat_XY) << int(Qt::AlignLeft | Qt::AlignVCenter);
+    QTest::newRow("multi") << "background: left url(blah.png) repeat-x" << QBrush() << QString("blah.png") << int(QCss::Repeat_X) << int(Qt::AlignLeft | Qt::AlignVCenter);
+    QTest::newRow("multi2") << "background: url(blah.png) repeat-x top" << QBrush() << QString("blah.png") << int(QCss::Repeat_X) << int(Qt::AlignTop | Qt::AlignHCenter);
+    QTest::newRow("multi3") << "background: url(blah.png) top right" << QBrush() << QString("blah.png") << int(QCss::Repeat_XY) << int(Qt::AlignTop | Qt::AlignRight);
+}
+
+void tst_QCssParser::shorthandBackgroundProperty()
+{
+    QFETCH(QString, css);
+
+    QDomDocument doc;
+    QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
+
+    css.prepend("dummy {");
+    css.append("}");
+
+    QCss::Parser parser(css);
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    DomStyleSelector testSelector(doc, sheet);
+    QDomElement e = doc.documentElement().firstChildElement();
+    QCss::StyleSelector::NodePtr n;
+    n.ptr = &e;
+    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
+    QVector<QCss::Declaration> decls = rules.at(0).declarations;
+    QCss::ValueExtractor v(decls);
+
+    QBrush brush;
+    QString image;
+    QCss::Repeat repeat = QCss::Repeat_XY;
+    Qt::Alignment alignment = Qt::AlignTop | Qt::AlignLeft;
+    QCss::Origin origin = QCss::Origin_Padding;
+    QCss::Attachment attachment;
+    QCss::Origin ignoredOrigin;
+    v.extractBackground(&brush, &image, &repeat, &alignment, &origin, &attachment, &ignoredOrigin);
+
+    QFETCH(QBrush, expectedBrush);
+    QVERIFY(expectedBrush.color() == brush.color());
+
+    QTEST(image, "expectedImage");
+    QTEST(int(repeat), "expectedRepeatValue");
+    QTEST(int(alignment), "expectedAlignment");
+}
+
+void tst_QCssParser::pseudoElement_data()
+{
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<QString>("pseudoElement");
+    QTest::addColumn<int>("declCount");
+
+    // QComboBox::dropDown { border-image: blah; }
+    QTest::newRow("no pseudo-elements") << QString("dummy:hover { color: red }") << "" << 1;
+    QTest::newRow("no pseudo-elements") << QString("dummy:hover { color: red }") << "pe" << 0;
+
+    QTest::newRow("1 pseudo-element (1)") << QString("dummy::pe:hover { color: red }") << "pe" << 1;
+    QTest::newRow("1 pseudo-element (2)") << QString("dummy::pe:hover { color: red }") << "x" << 0;
+    QTest::newRow("1 pseudo-element (2)") << QString("whatever::pe:hover { color: red }") << "pe" << 0;
+
+    QTest::newRow("1 pseudo-element (3)")
+        << QString("dummy { color: white; } dummy::pe:hover { color: red }") << "x" << 0;
+    QTest::newRow("1 pseudo-element (4)")
+        << QString("dummy { color: white; } dummy::pe:hover { color: red } dummy { x:y }") << "" << 2;
+    QTest::newRow("1 pseudo-element (5)")
+        << QString("dummy { color: white; } dummy::pe:hover { color: red }") << "pe" << 1;
+    QTest::newRow("1 pseudo-element (6)")
+      << QString("dummy { color: white; } dummy::pe:hover { color: red } dummy::pe:checked { x: y} ") << "pe" << 2;
+
+    QTest::newRow("2 pseudo-elements (1)")
+      << QString("dummy { color: white; } dummy::pe1:hover { color: red } dummy::pe2:checked { x: y} ")
+      << "" << 1;
+    QTest::newRow("2 pseudo-elements (1)")
+      << QString("dummy { color: white; } dummy::pe1:hover { color: red } dummy::pe2:checked { x: y} ")
+      << "pe1" << 1;
+    QTest::newRow("2 pseudo-elements (2)")
+      << QString("dummy { color: white; } dummy::pe1:hover { color: red } dummy::pe2:checked { x: y} ")
+      << "pe2" << 1;
+}
+
+void tst_QCssParser::pseudoElement()
+{
+    QFETCH(QString, css);
+    QFETCH(QString, pseudoElement);
+    QFETCH(int, declCount);
+
+    QDomDocument doc;
+    QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
+
+    QCss::Parser parser(css);
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    DomStyleSelector testSelector(doc, sheet);
+    QDomElement e = doc.documentElement().firstChildElement();
+    QCss::StyleSelector::NodePtr n;
+    n.ptr = &e;
+    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
+    QVector<QCss::Declaration> decls;
+    for (int i = 0; i < rules.count(); i++) {
+        const QCss::Selector& selector = rules.at(i).selectors.at(0);
+        if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) != 0)
+            continue;
+        decls += rules.at(i).declarations;
+
+    }
+    QVERIFY(decls.count() == declCount);
+}
+
+void tst_QCssParser::gradient_data()
+{
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<QString>("type");
+    QTest::addColumn<QPointF>("start");
+    QTest::addColumn<QPointF>("finalStop");
+    QTest::addColumn<int>("spread");
+    QTest::addColumn<qreal>("stop0");
+    QTest::addColumn<QColor>("color0");
+    QTest::addColumn<qreal>("stop1");
+    QTest::addColumn<QColor>("color1");
+
+    QTest::newRow("color-string") <<
+     "selection-background-color: qlineargradient(x1:1, y1:2, x2:3, y2:4, "
+         "stop:0.2 red, stop:0.5 green)" << "linear" << QPointF(1, 2) << QPointF(3, 4)
+                                  << 0 << qreal(0.2) << QColor("red") << qreal(0.5) << QColor("green");
+
+    QTest::newRow("color-#") <<
+     "selection-background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
+         "spread: reflect, stop:0.2 #123, stop:0.5 #456)" << "linear" << QPointF(0, 0) << QPointF(0, 1)
+                             << 1 << qreal(0.2) << QColor("#123") << qreal(0.5) << QColor("#456");
+
+    QTest::newRow("color-rgb") <<
+     "selection-background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
+         "spread: reflect, stop:0.2 rgb(1, 2, 3), stop:0.5 rgba(1, 2, 3, 4))" << "linear" << QPointF(0, 0) << QPointF(0, 1)
+                             << 1 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
+
+    QTest::newRow("color-spaces") <<
+     "selection-background-color: qlineargradient(x1: 0, y1 :0,x2:0, y2 : 1 , "
+         "spread: reflect, stop:0.2 rgb(1, 2, 3), stop: 0.5   rgba(1, 2, 3, 4))" << "linear" << QPointF(0, 0) << QPointF(0, 1)
+                             << 1 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
+
+    QTest::newRow("conical gradient") <<
+     "selection-background-color: qconicalgradient(cx: 4, cy : 2, angle: 23, "
+         "spread: repeat, stop:0.2 rgb(1, 2, 3), stop:0.5 rgba(1, 2, 3, 4))" << "conical" << QPointF(4, 2) << QPointF()
+                             << 2 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
+
+    /* wont pass: stop values are expected to be sorted
+     QTest::newRow("unsorted-stop") <<
+     "selection-background: lineargradient(x1:0, y1:0, x2:0, y2:1, "
+         "stop:0.5 green, stop:0.2 red)" << QPointF(0, 0) << QPointF(0, 1)
+         0 << 0.2 << QColor("red") << 0.5 << QColor("green");
+    */
+}
+
+void tst_QCssParser::gradient()
+{
+    QFETCH(QString, css);
+    QFETCH(QString, type);
+    QFETCH(QPointF, finalStop);
+    QFETCH(QPointF, start);
+    QFETCH(int, spread);
+    QFETCH(qreal, stop0); QFETCH(QColor, color0);
+    QFETCH(qreal, stop1); QFETCH(QColor, color1);
+
+    QDomDocument doc;
+    QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
+
+    css.prepend("dummy {");
+    css.append("}");
+
+    QCss::Parser parser(css);
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    DomStyleSelector testSelector(doc, sheet);
+    QDomElement e = doc.documentElement().firstChildElement();
+    QCss::StyleSelector::NodePtr n;
+    n.ptr = &e;
+    QVector<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
+    QVector<QCss::Declaration> decls = rules.at(0).declarations;
+    QCss::ValueExtractor ve(decls);
+    QBrush fg, sfg;
+    QBrush sbg, abg;
+    QVERIFY(ve.extractPalette(&fg, &sfg, &sbg, &abg));
+    if (type == "linear") {
+        QVERIFY(sbg.style() == Qt::LinearGradientPattern);
+        const QLinearGradient *lg = static_cast<const QLinearGradient *>(sbg.gradient());
+        QCOMPARE(lg->start(), start);
+        QCOMPARE(lg->finalStop(), finalStop);
+    } else if (type == "conical") {
+        QVERIFY(sbg.style() == Qt::ConicalGradientPattern);
+        const QConicalGradient *cg = static_cast<const QConicalGradient *>(sbg.gradient());
+        QCOMPARE(cg->center(), start);
+    }
+    const QGradient *g = sbg.gradient();
+    QCOMPARE(g->spread(), QGradient::Spread(spread));
+    QVERIFY(g->stops().at(0).first == stop0);
+    QVERIFY(g->stops().at(0).second == color0);
+    QVERIFY(g->stops().at(1).first == stop1);
+    QVERIFY(g->stops().at(1).second == color1);
+}
+
+void tst_QCssParser::extractFontFamily_data()
+{
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<QString>("expectedFamily");
+
+    QTest::newRow("quoted-family-name") << "font-family: 'Times New Roman'" << QString("Times New Roman");
+    QTest::newRow("unquoted-family-name") << "font-family: Times New Roman" << QString("Times New Roman");
+    QTest::newRow("unquoted-family-name2") << "font-family: Times        New     Roman" << QString("Times New Roman");
+    QTest::newRow("multiple") << "font-family: Times New Roman  , foobar, 'baz'" << QString("Times New Roman");
+    QTest::newRow("multiple2") << "font-family: invalid,  Times New   Roman " << QString("Times New Roman");
+    QTest::newRow("invalid") << "font-family: invalid" << QFontInfo(QFont("invalid font")).family();
+    QTest::newRow("shorthand") << "font: 12pt Times New Roman" << QString("Times New Roman");
+    QTest::newRow("shorthand multiple quote") << "font: 12pt invalid, \"Times New Roman\" " << QString("Times New Roman");
+    QTest::newRow("shorthand multiple") << "font: 12pt invalid, Times New Roman " << QString("Times New Roman");
+}
+
+void tst_QCssParser::extractFontFamily()
+{
+    QFETCH(QString, css);
+    css.prepend("dummy {");
+    css.append("}");
+
+    QCss::Parser parser(css);
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ?
+            sheet.styleRules.at(0) : *sheet.nameIndex.begin();
+
+    const QVector<QCss::Declaration> decls = rule.declarations;
+    QVERIFY(!decls.isEmpty());
+    QCss::ValueExtractor extractor(decls);
+
+    int adjustment = 0;
+    QFont fnt;
+    extractor.extractFont(&fnt, &adjustment);
+    QFontInfo info(fnt);
+    QTEST(info.family(), "expectedFamily");
+}
+
+void tst_QCssParser::extractBorder_data()
+{
+    QTest::addColumn<QString>("css");
+    QTest::addColumn<int>("expectedTopWidth");
+    QTest::addColumn<int>("expectedTopStyle");
+    QTest::addColumn<QColor>("expectedTopColor");
+
+    QTest::newRow("all values") << "border: 2px solid green" << 2 << (int)QCss::BorderStyle_Solid << QColor("green");
+    QTest::newRow("palette") << "border: 2px solid palette(highlight)" << 2 << (int)QCss::BorderStyle_Solid << qApp->palette().color(QPalette::Highlight);
+    QTest::newRow("just width") << "border: 2px" << 2 << (int)QCss::BorderStyle_None << QColor();
+    QTest::newRow("just style") << "border: solid" << 0 << (int)QCss::BorderStyle_Solid << QColor();
+    QTest::newRow("just color") << "border: green" << 0 << (int)QCss::BorderStyle_None << QColor("green");
+    QTest::newRow("width+style") << "border: 2px solid" << 2 << (int)QCss::BorderStyle_Solid << QColor();
+    QTest::newRow("style+color") << "border: solid green" << 0 << (int)QCss::BorderStyle_Solid << QColor("green");
+    QTest::newRow("width+color") << "border: 3px green" << 3 << (int)QCss::BorderStyle_None << QColor("green");
+    QTest::newRow("groove style") << "border: groove" << 0 << (int)QCss::BorderStyle_Groove << QColor();
+    QTest::newRow("ridge style") << "border: ridge" << 0 << (int)QCss::BorderStyle_Ridge << QColor();
+    QTest::newRow("double style") << "border: double" << 0 << (int)QCss::BorderStyle_Double << QColor();
+    QTest::newRow("inset style") << "border: inset" << 0 << (int)QCss::BorderStyle_Inset << QColor();
+    QTest::newRow("outset style") << "border: outset" << 0 << (int)QCss::BorderStyle_Outset << QColor();
+    QTest::newRow("dashed style") << "border: dashed" << 0 << (int)QCss::BorderStyle_Dashed << QColor();
+    QTest::newRow("dotted style") << "border: dotted" << 0 << (int)QCss::BorderStyle_Dotted << QColor();
+    QTest::newRow("dot-dash style") << "border: dot-dash" << 0 << (int)QCss::BorderStyle_DotDash << QColor();
+    QTest::newRow("dot-dot-dash style") << "border: dot-dot-dash" << 0 << (int)QCss::BorderStyle_DotDotDash << QColor();
+
+    QTest::newRow("top-width+color") << "border-top: 3px green" << 3 << (int)QCss::BorderStyle_None << QColor("green");
+}
+
+void tst_QCssParser::extractBorder()
+{
+    QFETCH(QString, css);
+    QFETCH(int, expectedTopWidth);
+    QFETCH(int, expectedTopStyle);
+    QFETCH(QColor, expectedTopColor);
+
+    css.prepend("dummy {");
+    css.append("}");
+
+    QCss::Parser parser(css);
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ?
+            sheet.styleRules.at(0) : *sheet.nameIndex.begin();
+    const QVector<QCss::Declaration> decls = rule.declarations;
+    QVERIFY(!decls.isEmpty());
+    QCss::ValueExtractor extractor(decls);
+
+    int widths[4];
+    QBrush colors[4];
+    QCss::BorderStyle styles[4];
+    QSize radii[4];
+
+    extractor.extractBorder(widths, colors, styles, radii);
+    QVERIFY(widths[QCss::TopEdge] == expectedTopWidth);
+    QVERIFY(styles[QCss::TopEdge] == expectedTopStyle);
+    QVERIFY(colors[QCss::TopEdge] == expectedTopColor);
+}
+
+void tst_QCssParser::noTextDecoration()
+{
+    QCss::Parser parser("dummy { text-decoration: none; }");
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ?
+            sheet.styleRules.at(0) : *sheet.nameIndex.begin();
+    const QVector<QCss::Declaration> decls = rule.declarations;
+    QVERIFY(!decls.isEmpty());
+    QCss::ValueExtractor extractor(decls);
+
+    int adjustment = 0;
+    QFont f;
+    f.setUnderline(true);
+    f.setOverline(true);
+    f.setStrikeOut(true);
+    QVERIFY(extractor.extractFont(&f, &adjustment));
+
+    QVERIFY(!f.underline());
+    QVERIFY(!f.overline());
+    QVERIFY(!f.strikeOut());
+}
+
+void tst_QCssParser::quotedAndUnquotedIdentifiers()
+{
+    QCss::Parser parser("foo { font-style: \"italic\"; font-weight: bold }");
+    QCss::StyleSheet sheet;
+    QVERIFY(parser.parse(&sheet));
+
+    QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
+    QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
+           sheet.styleRules.at(0) : *sheet.nameIndex.begin();
+    const QVector<QCss::Declaration> decls = rule.declarations;
+    QCOMPARE(decls.size(), 2);
+
+    QCOMPARE(decls.at(0).d->values.first().type, QCss::Value::String);
+    QCOMPARE(decls.at(0).d->property, QLatin1String("font-style"));
+    QCOMPARE(decls.at(0).d->values.first().toString(), QLatin1String("italic"));
+
+    QCOMPARE(decls.at(1).d->values.first().type, QCss::Value::KnownIdentifier);
+    QCOMPARE(decls.at(1).d->property, QLatin1String("font-weight"));
+    QCOMPARE(decls.at(1).d->values.first().toString(), QLatin1String("bold"));
+}
+
+QTEST_MAIN(tst_QCssParser)
+#include "tst_qcssparser.moc"
+
diff --git a/tests/auto/qdbuspendingcall/qdbuspendingcall.pro b/tests/auto/qdbuspendingcall/qdbuspendingcall.pro
index 65e8f13..dd8f141 100644
--- a/tests/auto/qdbuspendingcall/qdbuspendingcall.pro
+++ b/tests/auto/qdbuspendingcall/qdbuspendingcall.pro
@@ -1,4 +1,5 @@
 load(qttest_p4)
-QT = core
-contains(QT_CONFIG, dbus):QT += dbus
+requires(contains(QT_CONFIG, dbus))
+QT = core dbus
 SOURCES += tst_qdbuspendingcall.cpp
+
diff --git a/tests/auto/qdbuspendingreply/qdbuspendingreply.pro b/tests/auto/qdbuspendingreply/qdbuspendingreply.pro
index 94e7acf..c649e4a 100644
--- a/tests/auto/qdbuspendingreply/qdbuspendingreply.pro
+++ b/tests/auto/qdbuspendingreply/qdbuspendingreply.pro
@@ -1,4 +1,4 @@
 load(qttest_p4)
-QT = core
-contains(QT_CONFIG, dbus):QT += dbus
+requires(contains(QT_CONFIG, dbus))
+QT = core dbus
 SOURCES += tst_qdbuspendingreply.cpp
diff --git a/tests/auto/qdirectpainter/qdirectpainter.pro b/tests/auto/qdirectpainter/qdirectpainter.pro
index 8967194..e86b342 100644
--- a/tests/auto/qdirectpainter/qdirectpainter.pro
+++ b/tests/auto/qdirectpainter/qdirectpainter.pro
@@ -1,7 +1,5 @@
-load(qttest_p4)
-SOURCES += tst_qdirectpainter.cpp
-
 TEMPLATE = subdirs
 SUBDIRS = test runDirectPainter
 
+requires(embedded)
 
diff --git a/tests/auto/qdirectpainter/runDirectPainter/runDirectPainter.pro b/tests/auto/qdirectpainter/runDirectPainter/runDirectPainter.pro
index 9e5131c..09524e9 100644
--- a/tests/auto/qdirectpainter/runDirectPainter/runDirectPainter.pro
+++ b/tests/auto/qdirectpainter/runDirectPainter/runDirectPainter.pro
@@ -2,4 +2,5 @@ load(qttest_p4)
 SOURCES = main.cpp
 TARGET = runDirectPainter
 
+requires(embedded)
 
diff --git a/tests/auto/qdirectpainter/test/test.pro b/tests/auto/qdirectpainter/test/test.pro
index 98c74e4..6d820b1 100644
--- a/tests/auto/qdirectpainter/test/test.pro
+++ b/tests/auto/qdirectpainter/test/test.pro
@@ -3,12 +3,5 @@ load(qttest_p4)
 SOURCES += ../tst_qdirectpainter.cpp
 TARGET = ../tst_qdirectpainter
 
-win32 {
-  CONFIG(debug, debug|release) {
-    TARGET = ../../debug/tst_qdirectpainter
-} else {
-    TARGET = ../../release/tst_qdirectpainter
-  }
-}
-
+requires(embedded)
 
diff --git a/tests/auto/qicoimageformat/qicoimageformat.pro b/tests/auto/qicoimageformat/qicoimageformat.pro
index 19c13b7..9a347d7 100644
--- a/tests/auto/qicoimageformat/qicoimageformat.pro
+++ b/tests/auto/qicoimageformat/qicoimageformat.pro
@@ -1,5 +1,5 @@
 load(qttest_p4)
-SOURCES+= tst_qticoimageformat.cpp
+SOURCES+= tst_qicoimageformat.cpp
 
 wince*: {
    DEFINES += SRCDIR=\\\".\\\"
diff --git a/tests/auto/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/qicoimageformat/tst_qicoimageformat.cpp
new file mode 100644
index 0000000..799a20b
--- /dev/null
+++ b/tests/auto/qicoimageformat/tst_qicoimageformat.cpp
@@ -0,0 +1,299 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QtGui>
+#include <QtCore>
+
+class tst_QIcoImageFormat : public QObject
+{
+    Q_OBJECT
+
+public:
+    tst_QIcoImageFormat();
+    virtual ~tst_QIcoImageFormat();
+
+
+public slots:
+    void initTestCase();
+    void cleanupTestCase();
+    void init();
+    void cleanup();
+private slots:
+    void format();
+    void canRead_data();
+    void canRead();
+    void SequentialFile_data();
+    void SequentialFile();
+    void imageCount_data();
+    void imageCount();
+    void jumpToNextImage_data();
+    void jumpToNextImage();
+    void loopCount_data();
+    void loopCount();
+    void nextImageDelay_data();
+    void nextImageDelay();
+
+private:
+    QString m_IconPath;
+};
+
+
+tst_QIcoImageFormat::tst_QIcoImageFormat()
+{
+    m_IconPath = QLatin1String(SRCDIR) + "/icons";
+    qDebug() << m_IconPath;
+}
+
+tst_QIcoImageFormat::~tst_QIcoImageFormat()
+{
+
+}
+
+void tst_QIcoImageFormat::init()
+{
+
+}
+
+void tst_QIcoImageFormat::cleanup()
+{
+
+}
+
+void tst_QIcoImageFormat::initTestCase()
+{
+
+}
+
+void tst_QIcoImageFormat::cleanupTestCase()
+{
+
+}
+
+void tst_QIcoImageFormat::format()
+{
+    QImageReader reader(m_IconPath + "/valid/35FLOPPY.ICO", "ico");
+    QByteArray fmt = reader.format();
+    QCOMPARE(const_cast<const char*>(fmt.data()), "ico" );
+}
+
+void tst_QIcoImageFormat::canRead_data()
+{
+    QTest::addColumn<QString>("fileName");
+    QTest::addColumn<int>("isValid");
+
+    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 1;
+    QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 1;
+    QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1;
+    QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 1;
+    QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 1;
+    QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 1;
+    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 1;
+    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 1;
+    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
+    QTest::newRow("103x16px, 24BPP") << "valid/trolltechlogo_tiny.ico" << 1;
+    QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 1;
+}
+
+void tst_QIcoImageFormat::canRead()
+{
+    QFETCH(QString, fileName);
+    QFETCH(int, isValid);
+
+    QImageReader reader(m_IconPath + "/" + fileName);
+    QCOMPARE(reader.canRead(), (isValid == 0 ? false : true));
+}
+
+class QSequentialFile : public QFile
+{
+public:
+    QSequentialFile(const QString &name) : QFile(name) {}
+
+    virtual ~QSequentialFile() {}
+
+    virtual bool isSequential() const {
+        return true;
+    }
+
+};
+
+void tst_QIcoImageFormat::SequentialFile_data()
+{
+    QTest::addColumn<QString>("fileName");
+    QTest::addColumn<int>("isValid");
+
+    QTest::newRow("floppy (16,32 pixels - 16 colors)") << "valid/35FLOPPY.ICO" << 1;
+
+    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
+
+
+}
+
+void tst_QIcoImageFormat::SequentialFile()
+{
+    QFETCH(QString, fileName);
+    QFETCH(int, isValid);
+
+    QSequentialFile *file = new QSequentialFile(m_IconPath + "/" + fileName);
+    QVERIFY(file);
+    QVERIFY(file->open(QFile::ReadOnly));
+    QImageReader reader(file);
+
+    // Perform the check twice. If canRead() does not restore the sequential device back to its original state,
+    // it will fail on the second try.
+    QCOMPARE(reader.canRead(), (isValid == 0 ? false : true));
+    QCOMPARE(reader.canRead(), (isValid == 0 ? false : true));
+    file->close();
+}
+
+
+void tst_QIcoImageFormat::imageCount_data()
+{
+    QTest::addColumn<QString>("fileName");
+    QTest::addColumn<int>("count");
+
+    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 2;
+    QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 6;
+    QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1;
+    QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 9;
+    QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 3;
+    QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 2;
+    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 3;
+    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3;
+    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
+    QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
+
+}
+
+void tst_QIcoImageFormat::imageCount()
+{
+    QFETCH(QString, fileName);
+    QFETCH(int, count);
+
+    QImageReader reader(m_IconPath + "/" + fileName);
+    QCOMPARE(reader.imageCount(), count);
+
+}
+
+void tst_QIcoImageFormat::jumpToNextImage_data()
+{
+    QTest::addColumn<QString>("fileName");
+    QTest::addColumn<int>("count");
+
+    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 2;
+    QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 6;
+    QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1;
+    QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 9;
+    QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 3;
+    QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 2;
+    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 3;
+    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3;
+    QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
+}
+
+void tst_QIcoImageFormat::jumpToNextImage()
+{
+    QFETCH(QString, fileName);
+    QFETCH(int, count);
+
+    QImageReader reader(m_IconPath + "/" + fileName);
+    bool bJumped = reader.jumpToImage(0);
+    while (bJumped) {
+        count--;
+        bJumped = reader.jumpToNextImage();
+    }
+    QCOMPARE(count, 0);
+}
+
+void tst_QIcoImageFormat::loopCount_data()
+{
+    QTest::addColumn<QString>("fileName");
+    QTest::addColumn<int>("count");
+
+    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 0;
+    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
+}
+
+void tst_QIcoImageFormat::loopCount()
+{
+    QFETCH(QString, fileName);
+    QFETCH(int, count);
+
+    QImageReader reader(m_IconPath + "/" + fileName);
+    QCOMPARE(reader.loopCount(), count);
+}
+
+void tst_QIcoImageFormat::nextImageDelay_data()
+{
+    QTest::addColumn<QString>("fileName");
+    QTest::addColumn<int>("count");
+
+    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 2;
+    QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 6;
+    QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1;
+    QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 9;
+    QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 3;
+    QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 2;
+    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 3;
+    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3;
+    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << -1;
+    QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
+}
+
+void tst_QIcoImageFormat::nextImageDelay()
+{
+    QFETCH(QString, fileName);
+    QFETCH(int, count);
+
+    QImageReader reader(m_IconPath + "/" + fileName);
+    if (count == -1) {
+        QCOMPARE(reader.nextImageDelay(), 0);
+    } else {
+        int i;
+        for (i = 0; i < count; i++) {
+            QVERIFY(reader.jumpToImage(i));
+            QCOMPARE(reader.nextImageDelay(), 0);
+        }
+    }
+}
+
+QTEST_MAIN(tst_QIcoImageFormat)
+#include "tst_qicoimageformat.moc"
+
diff --git a/tests/auto/qicoimageformat/tst_qticoimageformat.cpp b/tests/auto/qicoimageformat/tst_qticoimageformat.cpp
deleted file mode 100644
index 51ee4aa..0000000
--- a/tests/auto/qicoimageformat/tst_qticoimageformat.cpp
+++ /dev/null
@@ -1,298 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <QtGui>
-#include <QtCore>
-
-class tst_QtIcoImageFormat : public QObject
-{
-    Q_OBJECT
-
-public:
-    tst_QtIcoImageFormat();
-    virtual ~tst_QtIcoImageFormat();
-
-
-public slots:
-    void initTestCase();
-    void cleanupTestCase();
-    void init();
-    void cleanup();
-private slots:
-    void format();
-    void canRead_data();
-    void canRead();
-    void SequentialFile_data();
-    void SequentialFile();
-    void imageCount_data();
-    void imageCount();
-    void jumpToNextImage_data();
-    void jumpToNextImage();
-    void loopCount_data();
-    void loopCount();
-    void nextImageDelay_data();
-    void nextImageDelay();
-
-private:
-    QString m_IconPath;
-};
-
-
-tst_QtIcoImageFormat::tst_QtIcoImageFormat()
-{
-    m_IconPath = QLatin1String(SRCDIR) + "/icons";
-    qDebug() << m_IconPath;
-}
-
-tst_QtIcoImageFormat::~tst_QtIcoImageFormat()
-{
-
-}
-
-void tst_QtIcoImageFormat::init()
-{
-
-}
-
-void tst_QtIcoImageFormat::cleanup()
-{
-
-}
-
-void tst_QtIcoImageFormat::initTestCase()
-{
-
-}
-
-void tst_QtIcoImageFormat::cleanupTestCase()
-{
-
-}
-
-void tst_QtIcoImageFormat::format()
-{
-    QImageReader reader(m_IconPath + "/valid/35FLOPPY.ICO", "ico");
-    QByteArray fmt = reader.format();
-    QCOMPARE(const_cast<const char*>(fmt.data()), "ico" );
-}
-
-void tst_QtIcoImageFormat::canRead_data()
-{
-    QTest::addColumn<QString>("fileName");
-    QTest::addColumn<int>("isValid");
-
-    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 1;
-    QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 1;
-    QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1;
-    QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 1;
-    QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 1;
-    QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 1;
-    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 1;
-    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 1;
-    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
-    QTest::newRow("103x16px, 24BPP") << "valid/trolltechlogo_tiny.ico" << 1;
-    QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 1;
-}
-
-void tst_QtIcoImageFormat::canRead()
-{
-    QFETCH(QString, fileName);
-    QFETCH(int, isValid);
-
-    QImageReader reader(m_IconPath + "/" + fileName);
-    QCOMPARE(reader.canRead(), (isValid == 0 ? false : true));
-}
-
-class QSequentialFile : public QFile
-{
-public:
-    QSequentialFile(const QString &name) : QFile(name) {}
-
-    virtual ~QSequentialFile() {}
-
-    virtual bool isSequential() const {
-        return true;
-    }
-
-};
-
-void tst_QtIcoImageFormat::SequentialFile_data()
-{
-    QTest::addColumn<QString>("fileName");
-    QTest::addColumn<int>("isValid");
-
-    QTest::newRow("floppy (16,32 pixels - 16 colors)") << "valid/35FLOPPY.ICO" << 1;
-
-    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
-
-
-}
-
-void tst_QtIcoImageFormat::SequentialFile()
-{
-    QFETCH(QString, fileName);
-    QFETCH(int, isValid);
-
-    QSequentialFile *file = new QSequentialFile(m_IconPath + "/" + fileName);
-    QVERIFY(file);
-    QVERIFY(file->open(QFile::ReadOnly));
-    QImageReader reader(file);
-
-    // Perform the check twice. If canRead() does not restore the sequential device back to its original state,
-    // it will fail on the second try.
-    QCOMPARE(reader.canRead(), (isValid == 0 ? false : true));
-    QCOMPARE(reader.canRead(), (isValid == 0 ? false : true));
-    file->close();
-}
-
-
-void tst_QtIcoImageFormat::imageCount_data()
-{
-    QTest::addColumn<QString>("fileName");
-    QTest::addColumn<int>("count");
-
-    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 2;
-    QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 6;
-    QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1;
-    QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 9;
-    QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 3;
-    QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 2;
-    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 3;
-    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3;
-    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
-    QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
-
-}
-
-void tst_QtIcoImageFormat::imageCount()
-{
-    QFETCH(QString, fileName);
-    QFETCH(int, count);
-
-    QImageReader reader(m_IconPath + "/" + fileName);
-    QCOMPARE(reader.imageCount(), count);
-
-}
-
-void tst_QtIcoImageFormat::jumpToNextImage_data()
-{
-    QTest::addColumn<QString>("fileName");
-    QTest::addColumn<int>("count");
-
-    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 2;
-    QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 6;
-    QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1;
-    QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 9;
-    QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 3;
-    QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 2;
-    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 3;
-    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3;
-    QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
-}
-
-void tst_QtIcoImageFormat::jumpToNextImage()
-{
-    QFETCH(QString, fileName);
-    QFETCH(int, count);
-
-    QImageReader reader(m_IconPath + "/" + fileName);
-    bool bJumped = reader.jumpToImage(0);
-    while (bJumped) {
-        count--;
-        bJumped = reader.jumpToNextImage();
-    }
-    QCOMPARE(count, 0);
-}
-
-void tst_QtIcoImageFormat::loopCount_data()
-{
-    QTest::addColumn<QString>("fileName");
-    QTest::addColumn<int>("count");
-
-    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 0;
-    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0;
-}
-
-void tst_QtIcoImageFormat::loopCount()
-{
-    QFETCH(QString, fileName);
-    QFETCH(int, count);
-
-    QImageReader reader(m_IconPath + "/" + fileName);
-    QCOMPARE(reader.loopCount(), count);
-}
-
-void tst_QtIcoImageFormat::nextImageDelay_data()
-{
-    QTest::addColumn<QString>("fileName");
-    QTest::addColumn<int>("count");
-
-    QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 2;
-    QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 6;
-    QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1;
-    QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 9;
-    QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 3;
-    QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 2;
-    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 3;
-    QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3;
-    QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << -1;
-    QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
-}
-
-void tst_QtIcoImageFormat::nextImageDelay()
-{
-    QFETCH(QString, fileName);
-    QFETCH(int, count);
-
-    QImageReader reader(m_IconPath + "/" + fileName);
-    if (count == -1) {
-        QCOMPARE(reader.nextImageDelay(), 0);
-    } else {
-        int i;
-        for (i = 0; i < count; i++) {
-            QVERIFY(reader.jumpToImage(i));
-            QCOMPARE(reader.nextImageDelay(), 0);
-        }
-    }
-}
-
-QTEST_MAIN(tst_QtIcoImageFormat)
-#include "tst_qticoimageformat.moc"
diff --git a/tests/auto/qmultiscreen/qmultiscreen.pro b/tests/auto/qmultiscreen/qmultiscreen.pro
index 810c05f..30666d7 100644
--- a/tests/auto/qmultiscreen/qmultiscreen.pro
+++ b/tests/auto/qmultiscreen/qmultiscreen.pro
@@ -1,5 +1,5 @@
 load(qttest_p4)
 SOURCES += tst_qmultiscreen.cpp
 
-
+requires(embedded)
 
diff --git a/tests/auto/qpointarray/.gitignore b/tests/auto/qpointarray/.gitignore
deleted file mode 100644
index 7c9d48c..0000000
--- a/tests/auto/qpointarray/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tst_qpointarray
diff --git a/tests/auto/qpointarray/qpointarray.pro b/tests/auto/qpointarray/qpointarray.pro
deleted file mode 100644
index d864337..0000000
--- a/tests/auto/qpointarray/qpointarray.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-SOURCES  += tst_qpointarray.cpp
-
-unix:!mac:LIBS+=-lm
-
-
diff --git a/tests/auto/qpointarray/tst_qpointarray.cpp b/tests/auto/qpointarray/tst_qpointarray.cpp
deleted file mode 100644
index f46c96d..0000000
--- a/tests/auto/qpointarray/tst_qpointarray.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest/QtTest>
-
-#include <qpolygon.h>
-#include <qpainterpath.h>
-#include <math.h>
-
-#include <qpainter.h>
-#include <qdialog.h>
-
-
-
-//TESTED_CLASS=
-//TESTED_FILES=gui/painting/qpolygon.h gui/painting/qpolygon.cpp
-
-class tst_QPolygon : public QObject
-{
-    Q_OBJECT
-
-public:
-    tst_QPolygon();
-
-private slots:
-    void makeEllipse();
-};
-
-tst_QPolygon::tst_QPolygon()
-{
-}
-
-void tst_QPolygon::makeEllipse()
-{
-    // create an ellipse with R1 = R2 = R, i.e. a circle
-    QPolygon pa;
-    const int R = 50; // radius
-    QPainterPath path;
-    path.addEllipse(0, 0, 2*R, 2*R);
-    pa = path.toSubpathPolygons().at(0).toPolygon();
-
-    int i;
-    // make sure that all points are R+-1 away from the center
-    bool err = FALSE;
-    for (i = 1; i < pa.size(); i++) {
-	QPoint p = pa.at( i );
-	double r = sqrt( pow( double(p.x() - R), 2.0 ) + pow( double(p.y() - R), 2.0 ) );
-	// ### too strict ? at least from visual inspection it looks
-	// quite odd around the main axes. 2.0 passes easily.
-	err |= ( qAbs( r - double(R) ) > 2.0 );
-    }
-    QVERIFY( !err );
-}
-
-QTEST_APPLESS_MAIN(tst_QPolygon)
-#include "tst_qpointarray.moc"
diff --git a/tests/auto/qpolygon/.gitignore b/tests/auto/qpolygon/.gitignore
new file mode 100644
index 0000000..7c9d48c
--- /dev/null
+++ b/tests/auto/qpolygon/.gitignore
@@ -0,0 +1 @@
+tst_qpointarray
diff --git a/tests/auto/qpolygon/qpolygon.pro b/tests/auto/qpolygon/qpolygon.pro
new file mode 100644
index 0000000..311958d
--- /dev/null
+++ b/tests/auto/qpolygon/qpolygon.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+SOURCES  += tst_qpolygon.cpp
+
+unix:!mac:LIBS+=-lm
+
+
diff --git a/tests/auto/qpolygon/tst_qpolygon.cpp b/tests/auto/qpolygon/tst_qpolygon.cpp
new file mode 100644
index 0000000..6b20dae
--- /dev/null
+++ b/tests/auto/qpolygon/tst_qpolygon.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qpolygon.h>
+#include <qpainterpath.h>
+#include <math.h>
+
+#include <qpainter.h>
+#include <qdialog.h>
+
+
+
+//TESTED_CLASS=
+//TESTED_FILES=gui/painting/qpolygon.h gui/painting/qpolygon.cpp
+
+class tst_QPolygon : public QObject
+{
+    Q_OBJECT
+
+public:
+    tst_QPolygon();
+
+private slots:
+    void makeEllipse();
+};
+
+tst_QPolygon::tst_QPolygon()
+{
+}
+
+void tst_QPolygon::makeEllipse()
+{
+    // create an ellipse with R1 = R2 = R, i.e. a circle
+    QPolygon pa;
+    const int R = 50; // radius
+    QPainterPath path;
+    path.addEllipse(0, 0, 2*R, 2*R);
+    pa = path.toSubpathPolygons().at(0).toPolygon();
+
+    int i;
+    // make sure that all points are R+-1 away from the center
+    bool err = FALSE;
+    for (i = 1; i < pa.size(); i++) {
+	QPoint p = pa.at( i );
+	double r = sqrt( pow( double(p.x() - R), 2.0 ) + pow( double(p.y() - R), 2.0 ) );
+	// ### too strict ? at least from visual inspection it looks
+	// quite odd around the main axes. 2.0 passes easily.
+	err |= ( qAbs( r - double(R) ) > 2.0 );
+    }
+    QVERIFY( !err );
+}
+
+QTEST_APPLESS_MAIN(tst_QPolygon)
+#include "tst_qpolygon.moc"
diff --git a/tests/auto/qresourceengine/qresourceengine.pro b/tests/auto/qresourceengine/qresourceengine.pro
index cdbbbd2..f897d60 100644
--- a/tests/auto/qresourceengine/qresourceengine.pro
+++ b/tests/auto/qresourceengine/qresourceengine.pro
@@ -6,7 +6,7 @@ load(qttest_p4)
 load(resources)
 
 # Input
-SOURCES += tst_resourceengine.cpp
+SOURCES += tst_qresourceengine.cpp
 RESOURCES += testqrc/test.qrc 
 
 runtime_resource.target = runtime_resource.rcc 
diff --git a/tests/auto/qresourceengine/tst_qresourceengine.cpp b/tests/auto/qresourceengine/tst_qresourceengine.cpp
new file mode 100644
index 0000000..d446562
--- /dev/null
+++ b/tests/auto/qresourceengine/tst_qresourceengine.cpp
@@ -0,0 +1,462 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QtCore>
+
+class tst_QResourceEngine: public QObject
+{
+    Q_OBJECT
+
+private slots:
+    void initTestCase();
+    void cleanupTestCase();
+
+    void checkUnregisterResource_data();
+    void checkUnregisterResource();
+    void checkStructure_data();
+    void checkStructure();
+    void searchPath_data();
+    void searchPath();
+    void doubleSlashInRoot();
+
+private:
+    QString builddir;
+};
+
+Q_DECLARE_METATYPE(QLocale)
+Q_DECLARE_METATYPE(qlonglong)
+
+void tst_QResourceEngine::initTestCase()
+{
+    QVERIFY(QResource::registerResource("runtime_resource.rcc"));
+    QVERIFY(QResource::registerResource("runtime_resource.rcc", "/secondary_root/"));
+    QString srcdir(QLatin1String(SRCDIR));
+    if (!srcdir.isEmpty()) {
+        builddir = QDir::current().absolutePath();
+        if (!builddir.endsWith(QDir::separator()))
+            builddir.append(QDir::separator());
+        QDir::setCurrent(srcdir);
+    }
+}
+
+void tst_QResourceEngine::cleanupTestCase()
+{
+    if (!builddir.isEmpty()) {
+        QDir::setCurrent(builddir);
+    }
+
+    // make sure we don't leak memory
+    QVERIFY(QResource::unregisterResource("runtime_resource.rcc"));
+    QVERIFY(QResource::unregisterResource("runtime_resource.rcc", "/secondary_root/"));
+}
+
+void tst_QResourceEngine::checkStructure_data()
+{
+    QTest::addColumn<QString>("pathName");
+    QTest::addColumn<QString>("contents");
+    QTest::addColumn<QStringList>("containedFiles");
+    QTest::addColumn<QStringList>("containedDirs");
+    QTest::addColumn<QLocale>("locale");
+    QTest::addColumn<qlonglong>("contentsSize");
+
+    QFileInfo info;
+
+    QTest::newRow("root dir")          << QString(":/")
+                                       << QString()
+                                       << (QStringList() << "search_file.txt")
+                                       << (QStringList() << QLatin1String("aliasdir") << QLatin1String("otherdir")
+                                           << QLatin1String("runtime_resource")
+                                           << QLatin1String("searchpath1") << QLatin1String("searchpath2")
+                                           << QLatin1String("secondary_root")
+                                           << QLatin1String("test") << QLatin1String("trolltech")
+                                           << QLatin1String("withoutslashes"))
+                                       << QLocale::c()
+                                       << qlonglong(0);
+
+    QTest::newRow("secondary root")  << QString(":/secondary_root/")
+                                     << QString()
+                                     << QStringList()
+                                     << (QStringList() << QLatin1String("runtime_resource"))
+                                     << QLocale::c()
+                                     << qlonglong(0);
+
+    QStringList roots;
+    roots << QString(":/") << QString(":/runtime_resource/") << QString(":/secondary_root/runtime_resource/");
+    for(int i = 0; i < roots.size(); ++i) {
+        const QString root = roots.at(i);
+
+        QTest::newRow(QString(root + "prefix dir").toLatin1().constData())  << QString(root + "test/abc/123/+++")
+                                            << QString()
+                                            << (QStringList() << QLatin1String("currentdir.txt") << QLatin1String("currentdir2.txt") << QLatin1String("parentdir.txt"))
+                                            << (QStringList() << QLatin1String("subdir"))
+                                            << QLocale::c()
+                                            << qlonglong(0);
+
+        QTest::newRow(QString(root + "parent to prefix").toLatin1().constData())  << QString(root + "test/abc/123")
+                                                  << QString()
+                                                  << QStringList()
+                                                  << (QStringList() << QLatin1String("+++"))
+                                                  << QLocale::c()
+                                                  << qlonglong(0);
+
+        QTest::newRow(QString(root + "two parents prefix").toLatin1().constData()) << QString(root + "test/abc")
+                                                   << QString()
+                                                   << QStringList()
+                                                   << QStringList(QLatin1String("123"))
+                                                   << QLocale::c()
+                                                   << qlonglong(0);
+
+        QTest::newRow(QString(root + "test dir ").toLatin1().constData())          << QString(root + "test")
+                                                   << QString()
+                                                   << (QStringList() << QLatin1String("testdir.txt"))
+                                                   << (QStringList() << QLatin1String("abc") << QLatin1String("test"))
+                                                   << QLocale::c()
+                                                   << qlonglong(0);
+
+        QTest::newRow(QString(root + "prefix no slashes").toLatin1().constData()) << QString(root + "withoutslashes")
+                                                  << QString()
+                                                  << QStringList("blahblah.txt")
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(0);
+
+        QTest::newRow(QString(root + "other dir").toLatin1().constData())         << QString(root + "otherdir")
+                                                  << QString()
+                                                  << QStringList(QLatin1String("otherdir.txt"))
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(0);
+
+        QTest::newRow(QString(root + "alias dir").toLatin1().constData())         << QString(root + "aliasdir")
+                                                  << QString()
+                                                  << QStringList(QLatin1String("aliasdir.txt"))
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(0);
+
+        QTest::newRow(QString(root + "second test dir").toLatin1().constData())   << QString(root + "test/test")
+                                                  << QString()
+                                                  << (QStringList() << QLatin1String("test1.txt") << QLatin1String("test2.txt"))
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(0);
+
+        info = QFileInfo("testqrc/test/test/test1.txt");
+        QTest::newRow(QString(root + "test1 text").toLatin1().constData())        << QString(root + "test/test/test1.txt")
+                                                  << QString("abc")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/blahblah.txt");
+        QTest::newRow(QString(root + "text no slashes").toLatin1().constData())   << QString(root + "withoutslashes/blahblah.txt")
+                                                  << QString("qwerty")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+
+        info = QFileInfo("testqrc/test/test/test2.txt");
+        QTest::newRow(QString(root + "test1 text").toLatin1().constData())        << QString(root + "test/test/test2.txt")
+                                                  << QString("def")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/currentdir.txt");
+        QTest::newRow(QString(root + "currentdir text").toLatin1().constData())   << QString(root + "test/abc/123/+++/currentdir.txt")
+                                                  << QString("\"This is the current dir\" ")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/currentdir2.txt");
+        QTest::newRow(QString(root + "currentdir text2").toLatin1().constData())  << QString(root + "test/abc/123/+++/currentdir2.txt")
+                                                  << QString("\"This is also the current dir\" ")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("parentdir.txt");
+        QTest::newRow(QString(root + "parentdir text").toLatin1().constData())    << QString(root + "test/abc/123/+++/parentdir.txt")
+                                                  << QString("abcdefgihklmnopqrstuvwxyz ")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/subdir/subdir.txt");
+        QTest::newRow(QString(root + "subdir text").toLatin1().constData())       << QString(root + "test/abc/123/+++/subdir/subdir.txt")
+                                                  << QString("\"This is in the sub directory\" ")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/test/testdir.txt");
+        QTest::newRow(QString(root + "testdir text").toLatin1().constData())      << QString(root + "test/testdir.txt")
+                                                  << QString("\"This is in the test directory\" ")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/otherdir/otherdir.txt");
+        QTest::newRow(QString(root + "otherdir text").toLatin1().constData())     << QString(root + "otherdir/otherdir.txt")
+                                                  << QString("\"This is the other dir\" ")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/test/testdir2.txt");
+        QTest::newRow(QString(root + "alias text").toLatin1().constData())        << QString(root + "aliasdir/aliasdir.txt")
+                                                  << QString("\"This is another file in this directory\" ")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale::c()
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/aliasdir/aliasdir.txt");
+        QTest::newRow(QString(root + "korean text").toLatin1().constData())       << QString(root + "aliasdir/aliasdir.txt")
+                                                  << QString("\"This is a korean text file\" ")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale("ko")
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/aliasdir/aliasdir.txt");
+        QTest::newRow(QString(root + "korean text 2").toLatin1().constData())     << QString(root + "aliasdir/aliasdir.txt")
+                                                  << QString("\"This is a korean text file\" ")
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale("ko_KR")
+                                                  << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/test/german.txt");
+        QTest::newRow(QString(root + "german text").toLatin1().constData())   << QString(root + "aliasdir/aliasdir.txt")
+                                              << QString("Deutsch")
+                                              << QStringList()
+                                              << QStringList()
+                                              << QLocale("de")
+                                              << qlonglong(info.size());
+
+        info = QFileInfo("testqrc/test/german.txt");
+        QTest::newRow(QString(root + "german text 2").toLatin1().constData())   << QString(root + "aliasdir/aliasdir.txt")
+                                                << QString("Deutsch")
+                                                << QStringList()
+                                                << QStringList()
+                                                << QLocale("de_DE")
+                                                << qlonglong(info.size());
+
+        QFile file("testqrc/aliasdir/compressme.txt");
+        file.open(QFile::ReadOnly);
+        info = QFileInfo("testqrc/aliasdir/compressme.txt");
+        QTest::newRow(QString(root + "compressed text").toLatin1().constData())   << QString(root + "aliasdir/aliasdir.txt")
+                                                  << QString(file.readAll())
+                                                  << QStringList()
+                                                  << QStringList()
+                                                  << QLocale("de_CH")
+                                                  << qlonglong(info.size());
+    }
+}
+
+void tst_QResourceEngine::checkStructure()
+{
+    QFETCH(QString, pathName);
+    QFETCH(QString, contents);
+    QFETCH(QStringList, containedFiles);
+    QFETCH(QStringList, containedDirs);
+    QFETCH(QLocale, locale);
+    QFETCH(qlonglong, contentsSize);
+
+    bool directory = (containedDirs.size() + containedFiles.size() > 0);
+    QLocale::setDefault(locale);
+
+    QFileInfo fileInfo(pathName);
+
+    QVERIFY(fileInfo.exists());
+    QCOMPARE(fileInfo.isDir(), directory);
+    QCOMPARE(fileInfo.size(), contentsSize);
+    //QVERIFY(fileInfo.isReadable());
+    QVERIFY(!fileInfo.isWritable());
+    QVERIFY(!fileInfo.isExecutable());
+
+    if (directory) {
+        QDir dir(pathName);
+
+        // Test the Dir filter
+        QFileInfoList list = dir.entryInfoList(QDir::Dirs, QDir::Name);
+//           for(int i = 0; i < list.size(); ++i)
+//               qDebug() << "one" << i << list.at(i).fileName();
+//           for(int i = 0; i < containedDirs.size(); ++i)
+//               qDebug() << "two" << i << containedDirs.at(i);
+//           qDebug() << "one" << list.size() << containedDirs.size();
+       QCOMPARE(list.size(), containedDirs.size());
+//         qDebug() << "two";
+
+        int i;
+        for (i=0; i<list.size(); ++i) {
+            QVERIFY(list.at(i).isDir());
+            QCOMPARE(list.at(i).fileName(), containedDirs.at(i));
+        }
+
+        list = dir.entryInfoList(QDir::Files, QDir::Name);
+        QCOMPARE(containedFiles.size(), list.size());
+
+        for (i=0; i<list.size(); ++i) {
+            QVERIFY(!list.at(i).isDir());
+            QCOMPARE(list.at(i).fileName(), containedFiles.at(i));
+        }
+
+        list = dir.entryInfoList(QDir::NoFilter, QDir::SortFlags(QDir::Name | QDir::DirsFirst));
+        QCOMPARE(containedFiles.size() + containedDirs.size(), list.size());
+
+        for (i=0; i<list.size(); ++i) {
+            QString expectedName;
+            if (i < containedDirs.size())
+                expectedName = containedDirs.at(i);
+            else
+                expectedName = containedFiles.at(i - containedDirs.size());
+
+            QCOMPARE(list.at(i).fileName(), expectedName);
+        }
+    } else {
+        QFile file(pathName);
+        QVERIFY(file.open(QFile::ReadOnly));
+
+        QByteArray ba = file.readAll();
+        QVERIFY(QString(ba).startsWith(contents));
+    }
+    QLocale::setDefault(QLocale::system());
+}
+
+void tst_QResourceEngine::searchPath_data()
+{
+    QTest::addColumn<QString>("searchPath");
+    QTest::addColumn<QString>("file");
+    QTest::addColumn<QByteArray>("expected");
+
+    QTest::newRow("no_search_path")  << QString()
+                                  << ":search_file.txt"
+                                  << QByteArray("root\n");
+    QTest::newRow("path1")  << "/searchpath1"
+                         << ":search_file.txt"
+                         << QByteArray("path1\n");
+    QTest::newRow("no_search_path2")  << QString()
+                                  << ":/search_file.txt"
+                                  << QByteArray("root\n");
+    QTest::newRow("path2")  << "/searchpath2"
+                         << ":search_file.txt"
+                         << QByteArray("path2\n");
+}
+
+void tst_QResourceEngine::searchPath()
+{
+    QFETCH(QString, searchPath);
+    QFETCH(QString, file);
+    QFETCH(QByteArray, expected);
+
+    if(!searchPath.isEmpty())
+        QDir::addResourceSearchPath(searchPath);
+    QFile qf(file);
+    QVERIFY(qf.open(QFile::ReadOnly));
+    QByteArray actual = qf.readAll();
+
+    actual.replace('\r', "");
+
+    QCOMPARE(actual, expected);
+    qf.close();
+}
+
+void tst_QResourceEngine::checkUnregisterResource_data()
+{
+    QTest::addColumn<QString>("rcc_file");
+    QTest::addColumn<QString>("root");
+    QTest::addColumn<QString>("file_check");
+    QTest::addColumn<int>("size");
+
+    QTest::newRow("currentdir.txt") << builddir + QString("runtime_resource.rcc") << QString("/check_unregister/")
+                                    << QString(":/check_unregister/runtime_resource/test/abc/123/+++/currentdir.txt") 
+                                    << (int)QFileInfo("testqrc/currentdir.txt").size();
+}
+
+void tst_QResourceEngine::checkUnregisterResource()
+{
+    QFETCH(QString, rcc_file);
+    QFETCH(QString, root);
+    QFETCH(QString, file_check);
+    QFETCH(int, size);
+
+
+
+    QVERIFY(!QFile::exists(file_check));
+    QVERIFY(QResource::registerResource(rcc_file, root));
+    QVERIFY(QFile::exists(file_check));
+    QVERIFY(QResource::unregisterResource(rcc_file, root));
+    QVERIFY(!QFile::exists(file_check));
+    QVERIFY(QResource::registerResource(rcc_file, root));
+    QVERIFY(QFile::exists(file_check));
+    QFileInfo fileInfo(file_check);
+    fileInfo.setCaching(false);
+    QVERIFY(fileInfo.exists());
+    QVERIFY(!QResource::unregisterResource(rcc_file, root));
+    QVERIFY(!QFile::exists(file_check));
+    QCOMPARE((int)fileInfo.size(), size);
+}
+
+void tst_QResourceEngine::doubleSlashInRoot()
+{
+    QVERIFY(QFile::exists(":/secondary_root/runtime_resource/search_file.txt"));
+    QVERIFY(QFile::exists("://secondary_root/runtime_resource/search_file.txt"));
+}
+
+QTEST_MAIN(tst_QResourceEngine)
+
+#include "tst_qresourceengine.moc"
+
diff --git a/tests/auto/qresourceengine/tst_resourceengine.cpp b/tests/auto/qresourceengine/tst_resourceengine.cpp
deleted file mode 100644
index a5e701a..0000000
--- a/tests/auto/qresourceengine/tst_resourceengine.cpp
+++ /dev/null
@@ -1,461 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest/QtTest>
-#include <QtCore>
-
-class tst_ResourceEngine: public QObject
-{
-    Q_OBJECT
-
-private slots:
-    void initTestCase();
-    void cleanupTestCase();
-
-    void checkUnregisterResource_data();
-    void checkUnregisterResource();
-    void checkStructure_data();
-    void checkStructure();
-    void searchPath_data();
-    void searchPath();
-    void doubleSlashInRoot();
-
-private:
-    QString builddir;
-};
-
-Q_DECLARE_METATYPE(QLocale)
-Q_DECLARE_METATYPE(qlonglong)
-
-void tst_ResourceEngine::initTestCase()
-{
-    QVERIFY(QResource::registerResource("runtime_resource.rcc"));
-    QVERIFY(QResource::registerResource("runtime_resource.rcc", "/secondary_root/"));
-    QString srcdir(QLatin1String(SRCDIR));
-    if (!srcdir.isEmpty()) {
-        builddir = QDir::current().absolutePath();
-        if (!builddir.endsWith(QDir::separator()))
-            builddir.append(QDir::separator());
-        QDir::setCurrent(srcdir);
-    }
-}
-
-void tst_ResourceEngine::cleanupTestCase()
-{
-    if (!builddir.isEmpty()) {
-        QDir::setCurrent(builddir);
-    }
-
-    // make sure we don't leak memory
-    QVERIFY(QResource::unregisterResource("runtime_resource.rcc"));
-    QVERIFY(QResource::unregisterResource("runtime_resource.rcc", "/secondary_root/"));
-}
-
-void tst_ResourceEngine::checkStructure_data()
-{
-    QTest::addColumn<QString>("pathName");
-    QTest::addColumn<QString>("contents");
-    QTest::addColumn<QStringList>("containedFiles");
-    QTest::addColumn<QStringList>("containedDirs");
-    QTest::addColumn<QLocale>("locale");
-    QTest::addColumn<qlonglong>("contentsSize");
-
-    QFileInfo info;
-
-    QTest::newRow("root dir")          << QString(":/")
-                                       << QString()
-                                       << (QStringList() << "search_file.txt")
-                                       << (QStringList() << QLatin1String("aliasdir") << QLatin1String("otherdir")
-                                           << QLatin1String("runtime_resource")
-                                           << QLatin1String("searchpath1") << QLatin1String("searchpath2")
-                                           << QLatin1String("secondary_root")
-                                           << QLatin1String("test") << QLatin1String("trolltech")
-                                           << QLatin1String("withoutslashes"))
-                                       << QLocale::c()
-                                       << qlonglong(0);
-
-    QTest::newRow("secondary root")  << QString(":/secondary_root/")
-                                     << QString()
-                                     << QStringList()
-                                     << (QStringList() << QLatin1String("runtime_resource"))
-                                     << QLocale::c()
-                                     << qlonglong(0);
-
-    QStringList roots;
-    roots << QString(":/") << QString(":/runtime_resource/") << QString(":/secondary_root/runtime_resource/");
-    for(int i = 0; i < roots.size(); ++i) {
-        const QString root = roots.at(i);
-
-        QTest::newRow(QString(root + "prefix dir").toLatin1().constData())  << QString(root + "test/abc/123/+++")
-                                            << QString()
-                                            << (QStringList() << QLatin1String("currentdir.txt") << QLatin1String("currentdir2.txt") << QLatin1String("parentdir.txt"))
-                                            << (QStringList() << QLatin1String("subdir"))
-                                            << QLocale::c()
-                                            << qlonglong(0);
-
-        QTest::newRow(QString(root + "parent to prefix").toLatin1().constData())  << QString(root + "test/abc/123")
-                                                  << QString()
-                                                  << QStringList()
-                                                  << (QStringList() << QLatin1String("+++"))
-                                                  << QLocale::c()
-                                                  << qlonglong(0);
-
-        QTest::newRow(QString(root + "two parents prefix").toLatin1().constData()) << QString(root + "test/abc")
-                                                   << QString()
-                                                   << QStringList()
-                                                   << QStringList(QLatin1String("123"))
-                                                   << QLocale::c()
-                                                   << qlonglong(0);
-
-        QTest::newRow(QString(root + "test dir ").toLatin1().constData())          << QString(root + "test")
-                                                   << QString()
-                                                   << (QStringList() << QLatin1String("testdir.txt"))
-                                                   << (QStringList() << QLatin1String("abc") << QLatin1String("test"))
-                                                   << QLocale::c()
-                                                   << qlonglong(0);
-
-        QTest::newRow(QString(root + "prefix no slashes").toLatin1().constData()) << QString(root + "withoutslashes")
-                                                  << QString()
-                                                  << QStringList("blahblah.txt")
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(0);
-
-        QTest::newRow(QString(root + "other dir").toLatin1().constData())         << QString(root + "otherdir")
-                                                  << QString()
-                                                  << QStringList(QLatin1String("otherdir.txt"))
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(0);
-
-        QTest::newRow(QString(root + "alias dir").toLatin1().constData())         << QString(root + "aliasdir")
-                                                  << QString()
-                                                  << QStringList(QLatin1String("aliasdir.txt"))
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(0);
-
-        QTest::newRow(QString(root + "second test dir").toLatin1().constData())   << QString(root + "test/test")
-                                                  << QString()
-                                                  << (QStringList() << QLatin1String("test1.txt") << QLatin1String("test2.txt"))
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(0);
-
-        info = QFileInfo("testqrc/test/test/test1.txt");
-        QTest::newRow(QString(root + "test1 text").toLatin1().constData())        << QString(root + "test/test/test1.txt")
-                                                  << QString("abc")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/blahblah.txt");
-        QTest::newRow(QString(root + "text no slashes").toLatin1().constData())   << QString(root + "withoutslashes/blahblah.txt")
-                                                  << QString("qwerty")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-
-        info = QFileInfo("testqrc/test/test/test2.txt");
-        QTest::newRow(QString(root + "test1 text").toLatin1().constData())        << QString(root + "test/test/test2.txt")
-                                                  << QString("def")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/currentdir.txt");
-        QTest::newRow(QString(root + "currentdir text").toLatin1().constData())   << QString(root + "test/abc/123/+++/currentdir.txt")
-                                                  << QString("\"This is the current dir\" ")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/currentdir2.txt");
-        QTest::newRow(QString(root + "currentdir text2").toLatin1().constData())  << QString(root + "test/abc/123/+++/currentdir2.txt")
-                                                  << QString("\"This is also the current dir\" ")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("parentdir.txt");
-        QTest::newRow(QString(root + "parentdir text").toLatin1().constData())    << QString(root + "test/abc/123/+++/parentdir.txt")
-                                                  << QString("abcdefgihklmnopqrstuvwxyz ")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/subdir/subdir.txt");
-        QTest::newRow(QString(root + "subdir text").toLatin1().constData())       << QString(root + "test/abc/123/+++/subdir/subdir.txt")
-                                                  << QString("\"This is in the sub directory\" ")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/test/testdir.txt");
-        QTest::newRow(QString(root + "testdir text").toLatin1().constData())      << QString(root + "test/testdir.txt")
-                                                  << QString("\"This is in the test directory\" ")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/otherdir/otherdir.txt");
-        QTest::newRow(QString(root + "otherdir text").toLatin1().constData())     << QString(root + "otherdir/otherdir.txt")
-                                                  << QString("\"This is the other dir\" ")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/test/testdir2.txt");
-        QTest::newRow(QString(root + "alias text").toLatin1().constData())        << QString(root + "aliasdir/aliasdir.txt")
-                                                  << QString("\"This is another file in this directory\" ")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale::c()
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/aliasdir/aliasdir.txt");
-        QTest::newRow(QString(root + "korean text").toLatin1().constData())       << QString(root + "aliasdir/aliasdir.txt")
-                                                  << QString("\"This is a korean text file\" ")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale("ko")
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/aliasdir/aliasdir.txt");
-        QTest::newRow(QString(root + "korean text 2").toLatin1().constData())     << QString(root + "aliasdir/aliasdir.txt")
-                                                  << QString("\"This is a korean text file\" ")
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale("ko_KR")
-                                                  << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/test/german.txt");
-        QTest::newRow(QString(root + "german text").toLatin1().constData())   << QString(root + "aliasdir/aliasdir.txt")
-                                              << QString("Deutsch")
-                                              << QStringList()
-                                              << QStringList()
-                                              << QLocale("de")
-                                              << qlonglong(info.size());
-
-        info = QFileInfo("testqrc/test/german.txt");
-        QTest::newRow(QString(root + "german text 2").toLatin1().constData())   << QString(root + "aliasdir/aliasdir.txt")
-                                                << QString("Deutsch")
-                                                << QStringList()
-                                                << QStringList()
-                                                << QLocale("de_DE")
-                                                << qlonglong(info.size());
-
-        QFile file("testqrc/aliasdir/compressme.txt");
-        file.open(QFile::ReadOnly);
-        info = QFileInfo("testqrc/aliasdir/compressme.txt");
-        QTest::newRow(QString(root + "compressed text").toLatin1().constData())   << QString(root + "aliasdir/aliasdir.txt")
-                                                  << QString(file.readAll())
-                                                  << QStringList()
-                                                  << QStringList()
-                                                  << QLocale("de_CH")
-                                                  << qlonglong(info.size());
-    }
-}
-
-void tst_ResourceEngine::checkStructure()
-{
-    QFETCH(QString, pathName);
-    QFETCH(QString, contents);
-    QFETCH(QStringList, containedFiles);
-    QFETCH(QStringList, containedDirs);
-    QFETCH(QLocale, locale);
-    QFETCH(qlonglong, contentsSize);
-
-    bool directory = (containedDirs.size() + containedFiles.size() > 0);
-    QLocale::setDefault(locale);
-
-    QFileInfo fileInfo(pathName);
-
-    QVERIFY(fileInfo.exists());
-    QCOMPARE(fileInfo.isDir(), directory);
-    QCOMPARE(fileInfo.size(), contentsSize);
-    //QVERIFY(fileInfo.isReadable());
-    QVERIFY(!fileInfo.isWritable());
-    QVERIFY(!fileInfo.isExecutable());
-
-    if (directory) {
-        QDir dir(pathName);
-
-        // Test the Dir filter
-        QFileInfoList list = dir.entryInfoList(QDir::Dirs, QDir::Name);
-//           for(int i = 0; i < list.size(); ++i)
-//               qDebug() << "one" << i << list.at(i).fileName();
-//           for(int i = 0; i < containedDirs.size(); ++i)
-//               qDebug() << "two" << i << containedDirs.at(i);
-//           qDebug() << "one" << list.size() << containedDirs.size();
-       QCOMPARE(list.size(), containedDirs.size());
-//         qDebug() << "two";
-
-        int i;
-        for (i=0; i<list.size(); ++i) {
-            QVERIFY(list.at(i).isDir());
-            QCOMPARE(list.at(i).fileName(), containedDirs.at(i));
-        }
-
-        list = dir.entryInfoList(QDir::Files, QDir::Name);
-        QCOMPARE(containedFiles.size(), list.size());
-
-        for (i=0; i<list.size(); ++i) {
-            QVERIFY(!list.at(i).isDir());
-            QCOMPARE(list.at(i).fileName(), containedFiles.at(i));
-        }
-
-        list = dir.entryInfoList(QDir::NoFilter, QDir::SortFlags(QDir::Name | QDir::DirsFirst));
-        QCOMPARE(containedFiles.size() + containedDirs.size(), list.size());
-
-        for (i=0; i<list.size(); ++i) {
-            QString expectedName;
-            if (i < containedDirs.size())
-                expectedName = containedDirs.at(i);
-            else
-                expectedName = containedFiles.at(i - containedDirs.size());
-
-            QCOMPARE(list.at(i).fileName(), expectedName);
-        }
-    } else {
-        QFile file(pathName);
-        QVERIFY(file.open(QFile::ReadOnly));
-
-        QByteArray ba = file.readAll();
-        QVERIFY(QString(ba).startsWith(contents));
-    }
-    QLocale::setDefault(QLocale::system());
-}
-
-void tst_ResourceEngine::searchPath_data()
-{
-    QTest::addColumn<QString>("searchPath");
-    QTest::addColumn<QString>("file");
-    QTest::addColumn<QByteArray>("expected");
-
-    QTest::newRow("no_search_path")  << QString()
-                                  << ":search_file.txt"
-                                  << QByteArray("root\n");
-    QTest::newRow("path1")  << "/searchpath1"
-                         << ":search_file.txt"
-                         << QByteArray("path1\n");
-    QTest::newRow("no_search_path2")  << QString()
-                                  << ":/search_file.txt"
-                                  << QByteArray("root\n");
-    QTest::newRow("path2")  << "/searchpath2"
-                         << ":search_file.txt"
-                         << QByteArray("path2\n");
-}
-
-void tst_ResourceEngine::searchPath()
-{
-    QFETCH(QString, searchPath);
-    QFETCH(QString, file);
-    QFETCH(QByteArray, expected);
-
-    if(!searchPath.isEmpty())
-        QDir::addResourceSearchPath(searchPath);
-    QFile qf(file);
-    QVERIFY(qf.open(QFile::ReadOnly));
-    QByteArray actual = qf.readAll();
-
-    actual.replace('\r', "");
-
-    QCOMPARE(actual, expected);
-    qf.close();
-}
-
-void tst_ResourceEngine::checkUnregisterResource_data()
-{
-    QTest::addColumn<QString>("rcc_file");
-    QTest::addColumn<QString>("root");
-    QTest::addColumn<QString>("file_check");
-    QTest::addColumn<int>("size");
-
-    QTest::newRow("currentdir.txt") << builddir + QString("runtime_resource.rcc") << QString("/check_unregister/")
-                                    << QString(":/check_unregister/runtime_resource/test/abc/123/+++/currentdir.txt") 
-                                    << (int)QFileInfo("testqrc/currentdir.txt").size();
-}
-
-void tst_ResourceEngine::checkUnregisterResource()
-{
-    QFETCH(QString, rcc_file);
-    QFETCH(QString, root);
-    QFETCH(QString, file_check);
-    QFETCH(int, size);
-
-
-
-    QVERIFY(!QFile::exists(file_check));
-    QVERIFY(QResource::registerResource(rcc_file, root));
-    QVERIFY(QFile::exists(file_check));
-    QVERIFY(QResource::unregisterResource(rcc_file, root));
-    QVERIFY(!QFile::exists(file_check));
-    QVERIFY(QResource::registerResource(rcc_file, root));
-    QVERIFY(QFile::exists(file_check));
-    QFileInfo fileInfo(file_check);
-    fileInfo.setCaching(false);
-    QVERIFY(fileInfo.exists());
-    QVERIFY(!QResource::unregisterResource(rcc_file, root));
-    QVERIFY(!QFile::exists(file_check));
-    QCOMPARE((int)fileInfo.size(), size);
-}
-
-void tst_ResourceEngine::doubleSlashInRoot()
-{
-    QVERIFY(QFile::exists(":/secondary_root/runtime_resource/search_file.txt"));
-    QVERIFY(QFile::exists("://secondary_root/runtime_resource/search_file.txt"));
-}
-
-QTEST_MAIN(tst_ResourceEngine)
-
-#include "tst_resourceengine.moc"
diff --git a/tests/auto/qscriptextqobject/.gitignore b/tests/auto/qscriptextqobject/.gitignore
new file mode 100644
index 0000000..bff799f
--- /dev/null
+++ b/tests/auto/qscriptextqobject/.gitignore
@@ -0,0 +1 @@
+tst_qscriptqobject
diff --git a/tests/auto/qscriptextqobject/qscriptextqobject.pro b/tests/auto/qscriptextqobject/qscriptextqobject.pro
new file mode 100644
index 0000000..a5e9cab
--- /dev/null
+++ b/tests/auto/qscriptextqobject/qscriptextqobject.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += script
+SOURCES  += tst_qscriptextqobject.cpp
+
+
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
new file mode 100644
index 0000000..0d0f927
--- /dev/null
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -0,0 +1,2734 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qscriptengine.h>
+#include <qscriptcontext.h>
+#include <qscriptvalueiterator.h>
+#include <qwidget.h>
+#include <qpushbutton.h>
+#include <qlineedit.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=script/qscriptextqobject_p.h script/qscriptextqobject.cpp
+
+struct CustomType
+{
+    QString string;
+};
+Q_DECLARE_METATYPE(CustomType)
+
+Q_DECLARE_METATYPE(QBrush*)
+Q_DECLARE_METATYPE(QObjectList)
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(Qt::BrushStyle)
+Q_DECLARE_METATYPE(QDir)
+
+static void dirFromScript(const QScriptValue &in, QDir &out)
+{
+    QScriptValue path = in.property("path");
+    if (!path.isValid())
+        in.engine()->currentContext()->throwError("No path");
+    else
+        out.setPath(path.toString());
+}
+
+namespace MyNS
+{
+    class A : public QObject
+    {
+        Q_OBJECT
+    public:
+        enum Type {
+            Foo,
+            Bar
+        };
+        Q_ENUMS(Type)
+    public Q_SLOTS:
+        int slotTakingScopedEnumArg(MyNS::A::Type t) {
+            return t;
+        }
+    };
+}
+
+class MyQObject : public QObject
+{
+    Q_OBJECT
+
+    Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
+    Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
+    Q_PROPERTY(QVariantList variantListProperty READ variantListProperty WRITE setVariantListProperty)
+    Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
+    Q_PROPERTY(QStringList stringListProperty READ stringListProperty WRITE setStringListProperty)
+    Q_PROPERTY(QByteArray byteArrayProperty READ byteArrayProperty WRITE setByteArrayProperty)
+    Q_PROPERTY(QBrush brushProperty READ brushProperty WRITE setBrushProperty)
+    Q_PROPERTY(double hiddenProperty READ hiddenProperty WRITE setHiddenProperty SCRIPTABLE false)
+    Q_PROPERTY(int writeOnlyProperty WRITE setWriteOnlyProperty)
+    Q_PROPERTY(int readOnlyProperty READ readOnlyProperty)
+    Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
+    Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType)
+    Q_ENUMS(Policy Strategy)
+    Q_FLAGS(Ability)
+
+public:
+    enum Policy {
+        FooPolicy = 0,
+        BarPolicy,
+        BazPolicy
+    };
+
+    enum Strategy {
+        FooStrategy = 10,
+        BarStrategy,
+        BazStrategy
+    };
+
+    enum AbilityFlag {
+        NoAbility  = 0x000,
+        FooAbility = 0x001,
+        BarAbility = 0x080,
+        BazAbility = 0x200,
+        AllAbility = FooAbility | BarAbility | BazAbility
+    };
+
+    Q_DECLARE_FLAGS(Ability, AbilityFlag)
+
+    MyQObject(QObject *parent = 0)
+        : QObject(parent),
+          m_intValue(123),
+          m_variantValue(QLatin1String("foo")),
+          m_variantListValue(QVariantList() << QVariant(123) << QVariant(QLatin1String("foo"))),
+          m_stringValue(QLatin1String("bar")),
+          m_stringListValue(QStringList() << QLatin1String("zig") << QLatin1String("zag")),
+          m_brushValue(QColor(10, 20, 30, 40)),
+          m_hiddenValue(456.0),
+          m_writeOnlyValue(789),
+          m_readOnlyValue(987),
+          m_qtFunctionInvoked(-1)
+        { }
+
+    int intProperty() const
+        { return m_intValue; }
+    void setIntProperty(int value)
+        { m_intValue = value; }
+
+    QVariant variantProperty() const
+        { return m_variantValue; }
+    void setVariantProperty(const QVariant &value)
+        { m_variantValue = value; }
+
+    QVariantList variantListProperty() const
+        { return m_variantListValue; }
+    void setVariantListProperty(const QVariantList &value)
+        { m_variantListValue = value; }
+
+    QString stringProperty() const
+        { return m_stringValue; }
+    void setStringProperty(const QString &value)
+        { m_stringValue = value; }
+
+    QStringList stringListProperty() const
+        { return m_stringListValue; }
+    void setStringListProperty(const QStringList &value)
+        { m_stringListValue = value; }
+
+    QByteArray byteArrayProperty() const
+        { return m_byteArrayValue; }
+    void setByteArrayProperty(const QByteArray &value)
+        { m_byteArrayValue = value; }
+
+    QBrush brushProperty() const
+        { return m_brushValue; }
+    Q_INVOKABLE void setBrushProperty(const QBrush &value)
+        { m_brushValue = value; }
+
+    double hiddenProperty() const
+        { return m_hiddenValue; }
+    void setHiddenProperty(double value)
+        { m_hiddenValue = value; }
+
+    int writeOnlyProperty() const
+        { return m_writeOnlyValue; }
+    void setWriteOnlyProperty(int value)
+        { m_writeOnlyValue = value; }
+
+    int readOnlyProperty() const
+        { return m_readOnlyValue; }
+
+    QKeySequence shortcut() const
+        { return m_shortcut; }
+    void setShortcut(const QKeySequence &seq)
+        { m_shortcut = seq; }
+
+    CustomType propWithCustomType() const
+        { return m_customType; }
+    void setPropWithCustomType(const CustomType &c)
+        { m_customType = c; }
+
+    int qtFunctionInvoked() const
+        { return m_qtFunctionInvoked; }
+
+    QVariantList qtFunctionActuals() const
+        { return m_actuals; }
+
+    void resetQtFunctionInvoked()
+        { m_qtFunctionInvoked = -1; m_actuals.clear(); }
+
+    void clearConnectedSignal()
+        { m_connectedSignal = QByteArray(); }
+    void clearDisconnectedSignal()
+        { m_disconnectedSignal = QByteArray(); }
+    QByteArray connectedSignal() const
+        { return m_connectedSignal; }
+    QByteArray disconnectedSignal() const
+        { return m_disconnectedSignal; }
+
+    Q_INVOKABLE void myInvokable()
+        { m_qtFunctionInvoked = 0; }
+    Q_INVOKABLE void myInvokableWithIntArg(int arg)
+        { m_qtFunctionInvoked = 1; m_actuals << arg; }
+    Q_INVOKABLE void myInvokableWithLonglongArg(qlonglong arg)
+        { m_qtFunctionInvoked = 2; m_actuals << arg; }
+    Q_INVOKABLE void myInvokableWithFloatArg(float arg)
+        { m_qtFunctionInvoked = 3; m_actuals << arg; }
+    Q_INVOKABLE void myInvokableWithDoubleArg(double arg)
+        { m_qtFunctionInvoked = 4; m_actuals << arg; }
+    Q_INVOKABLE void myInvokableWithStringArg(const QString &arg)
+        { m_qtFunctionInvoked = 5; m_actuals << arg; }
+    Q_INVOKABLE void myInvokableWithIntArgs(int arg1, int arg2)
+        { m_qtFunctionInvoked = 6; m_actuals << arg1 << arg2; }
+    Q_INVOKABLE int myInvokableReturningInt()
+        { m_qtFunctionInvoked = 7; return 123; }
+    Q_INVOKABLE qlonglong myInvokableReturningLongLong()
+        { m_qtFunctionInvoked = 39; return 456; }
+    Q_INVOKABLE QString myInvokableReturningString()
+        { m_qtFunctionInvoked = 8; return QLatin1String("ciao"); }
+    Q_INVOKABLE QVariant myInvokableReturningVariant()
+        { m_qtFunctionInvoked = 60; return 123; }
+    Q_INVOKABLE QScriptValue myInvokableReturningScriptValue()
+        { m_qtFunctionInvoked = 61; return 456; }
+    Q_INVOKABLE void myInvokableWithIntArg(int arg1, int arg2) // overload
+        { m_qtFunctionInvoked = 9; m_actuals << arg1 << arg2; }
+    Q_INVOKABLE void myInvokableWithEnumArg(Policy policy)
+        { m_qtFunctionInvoked = 10; m_actuals << policy; }
+    Q_INVOKABLE void myInvokableWithQualifiedEnumArg(MyQObject::Policy policy)
+        { m_qtFunctionInvoked = 36; m_actuals << policy; }
+    Q_INVOKABLE Policy myInvokableReturningEnum()
+        { m_qtFunctionInvoked = 37; return BazPolicy; }
+    Q_INVOKABLE MyQObject::Policy myInvokableReturningQualifiedEnum()
+        { m_qtFunctionInvoked = 38; return BazPolicy; }
+    Q_INVOKABLE QVector<int> myInvokableReturningVectorOfInt()
+        { m_qtFunctionInvoked = 11; return QVector<int>(); }
+    Q_INVOKABLE void myInvokableWithVectorOfIntArg(const QVector<int> &)
+        { m_qtFunctionInvoked = 12; }
+    Q_INVOKABLE QObject *myInvokableReturningQObjectStar()
+        { m_qtFunctionInvoked = 13; return this; }
+    Q_INVOKABLE QObjectList myInvokableWithQObjectListArg(const QObjectList &lst)
+        { m_qtFunctionInvoked = 14; m_actuals << qVariantFromValue(lst); return lst; }
+    Q_INVOKABLE QVariant myInvokableWithVariantArg(const QVariant &v)
+        { m_qtFunctionInvoked = 15; m_actuals << v; return v; }
+    Q_INVOKABLE QVariantMap myInvokableWithVariantMapArg(const QVariantMap &vm)
+        { m_qtFunctionInvoked = 16; m_actuals << vm; return vm; }
+    Q_INVOKABLE QList<int> myInvokableWithListOfIntArg(const QList<int> &lst)
+        { m_qtFunctionInvoked = 17; m_actuals << qVariantFromValue(lst); return lst; }
+    Q_INVOKABLE QObject* myInvokableWithQObjectStarArg(QObject *obj)
+        { m_qtFunctionInvoked = 18; m_actuals << qVariantFromValue(obj); return obj; }
+    Q_INVOKABLE QBrush myInvokableWithQBrushArg(const QBrush &brush)
+        { m_qtFunctionInvoked = 19; m_actuals << qVariantFromValue(brush); return brush; }
+    Q_INVOKABLE void myInvokableWithBrushStyleArg(Qt::BrushStyle style)
+        { m_qtFunctionInvoked = 43; m_actuals << qVariantFromValue(style); }
+    Q_INVOKABLE void myInvokableWithVoidStarArg(void *arg)
+        { m_qtFunctionInvoked = 44; m_actuals << qVariantFromValue(arg); }
+    Q_INVOKABLE void myInvokableWithAmbiguousArg(int arg)
+        { m_qtFunctionInvoked = 45; m_actuals << qVariantFromValue(arg); }
+    Q_INVOKABLE void myInvokableWithAmbiguousArg(uint arg)
+        { m_qtFunctionInvoked = 46; m_actuals << qVariantFromValue(arg); }
+    Q_INVOKABLE void myInvokableWithDefaultArgs(int arg1, const QString &arg2 = "")
+        { m_qtFunctionInvoked = 47; m_actuals << qVariantFromValue(arg1) << qVariantFromValue(arg2); }
+    Q_INVOKABLE QObject& myInvokableReturningRef()
+        { m_qtFunctionInvoked = 48; return *this; }
+    Q_INVOKABLE const QObject& myInvokableReturningConstRef() const
+        { const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 49; return *this; }
+    Q_INVOKABLE void myInvokableWithPointArg(const QPoint &arg)
+        { const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 50; m_actuals << qVariantFromValue(arg); }
+    Q_INVOKABLE void myInvokableWithPointArg(const QPointF &arg)
+        { const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 51; m_actuals << qVariantFromValue(arg); }
+    Q_INVOKABLE void myInvokableWithMyQObjectArg(MyQObject *arg)
+        { m_qtFunctionInvoked = 52; m_actuals << qVariantFromValue((QObject*)arg); }
+    Q_INVOKABLE MyQObject* myInvokableReturningMyQObject()
+        { m_qtFunctionInvoked = 53; return this; }
+    Q_INVOKABLE void myInvokableWithConstMyQObjectArg(const MyQObject *arg)
+        { m_qtFunctionInvoked = 54; m_actuals << qVariantFromValue((QObject*)arg); }
+    Q_INVOKABLE void myInvokableWithQDirArg(const QDir &arg)
+        { m_qtFunctionInvoked = 55; m_actuals << qVariantFromValue(arg); }
+    Q_INVOKABLE QScriptValue myInvokableWithScriptValueArg(const QScriptValue &arg)
+        { m_qtFunctionInvoked = 56; return arg; }
+    Q_INVOKABLE QObject* myInvokableReturningMyQObjectAsQObject()
+        { m_qtFunctionInvoked = 57; return this; }
+
+    void emitMySignal()
+        { emit mySignal(); }
+    void emitMySignalWithIntArg(int arg)
+        { emit mySignalWithIntArg(arg); }
+    void emitMySignal2(bool arg)
+        { emit mySignal2(arg); }
+    void emitMySignal2()
+        { emit mySignal2(); }
+    void emitMyOverloadedSignal(int arg)
+        { emit myOverloadedSignal(arg); }
+    void emitMyOverloadedSignal(const QString &arg)
+        { emit myOverloadedSignal(arg); }
+    void emitMyOtherOverloadedSignal(const QString &arg)
+        { emit myOtherOverloadedSignal(arg); }
+    void emitMyOtherOverloadedSignal(int arg)
+        { emit myOtherOverloadedSignal(arg); }
+    void emitMySignalWithDefaultArgWithArg(int arg)
+        { emit mySignalWithDefaultArg(arg); }
+    void emitMySignalWithDefaultArg()
+        { emit mySignalWithDefaultArg(); }
+
+public Q_SLOTS:
+    void mySlot()
+        { m_qtFunctionInvoked = 20; }
+    void mySlotWithIntArg(int arg)
+        { m_qtFunctionInvoked = 21; m_actuals << arg; }
+    void mySlotWithDoubleArg(double arg)
+        { m_qtFunctionInvoked = 22; m_actuals << arg; }
+    void mySlotWithStringArg(const QString &arg)
+        { m_qtFunctionInvoked = 23; m_actuals << arg; }
+
+    void myOverloadedSlot()
+        { m_qtFunctionInvoked = 24; }
+    void myOverloadedSlot(QObject *arg)
+        { m_qtFunctionInvoked = 41; m_actuals << qVariantFromValue(arg); }
+    void myOverloadedSlot(bool arg)
+        { m_qtFunctionInvoked = 25; m_actuals << arg; }
+    void myOverloadedSlot(const QStringList &arg)
+        { m_qtFunctionInvoked = 42; m_actuals << arg; }
+    void myOverloadedSlot(double arg)
+        { m_qtFunctionInvoked = 26; m_actuals << arg; }
+    void myOverloadedSlot(float arg)
+        { m_qtFunctionInvoked = 27; m_actuals << arg; }
+    void myOverloadedSlot(int arg)
+        { m_qtFunctionInvoked = 28; m_actuals << arg; }
+    void myOverloadedSlot(const QString &arg)
+        { m_qtFunctionInvoked = 29; m_actuals << arg; }
+    void myOverloadedSlot(const QColor &arg)
+        { m_qtFunctionInvoked = 30; m_actuals << arg; }
+    void myOverloadedSlot(const QBrush &arg)
+        { m_qtFunctionInvoked = 31; m_actuals << arg; }
+    void myOverloadedSlot(const QDateTime &arg)
+        { m_qtFunctionInvoked = 32; m_actuals << arg; }
+    void myOverloadedSlot(const QDate &arg)
+        { m_qtFunctionInvoked = 33; m_actuals << arg; }
+    void myOverloadedSlot(const QRegExp &arg)
+        { m_qtFunctionInvoked = 34; m_actuals << arg; }
+    void myOverloadedSlot(const QVariant &arg)
+        { m_qtFunctionInvoked = 35; m_actuals << arg; }
+
+    virtual int myVirtualSlot(int arg)
+        { m_qtFunctionInvoked = 58; return arg; }
+
+    void qscript_call(int arg)
+        { m_qtFunctionInvoked = 40; m_actuals << arg; }
+
+protected Q_SLOTS:
+    void myProtectedSlot() { m_qtFunctionInvoked = 36; }
+
+private Q_SLOTS:
+    void myPrivateSlot() { }
+
+Q_SIGNALS:
+    void mySignal();
+    void mySignalWithIntArg(int arg);
+    void mySignalWithDoubleArg(double arg);
+    void mySignal2(bool arg = false);
+    void myOverloadedSignal(int arg);
+    void myOverloadedSignal(const QString &arg);
+    void myOtherOverloadedSignal(const QString &arg);
+    void myOtherOverloadedSignal(int arg);
+    void mySignalWithDefaultArg(int arg = 123);
+
+protected:
+    void connectNotify(const char *signal) {
+        m_connectedSignal = signal;
+    }
+    void disconnectNotify(const char *signal) {
+        m_disconnectedSignal = signal;
+    }
+
+protected:
+    int m_intValue;
+    QVariant m_variantValue;
+    QVariantList m_variantListValue;
+    QString m_stringValue;
+    QStringList m_stringListValue;
+    QByteArray m_byteArrayValue;
+    QBrush m_brushValue;
+    double m_hiddenValue;
+    int m_writeOnlyValue;
+    int m_readOnlyValue;
+    QKeySequence m_shortcut;
+    CustomType m_customType;
+    int m_qtFunctionInvoked;
+    QVariantList m_actuals;
+    QByteArray m_connectedSignal;
+    QByteArray m_disconnectedSignal;
+};
+
+Q_DECLARE_METATYPE(MyQObject*)
+
+class MyOtherQObject : public MyQObject
+{
+    Q_OBJECT
+public:
+    MyOtherQObject(QObject *parent = 0)
+        : MyQObject(parent)
+        { }
+public Q_SLOTS:
+    virtual int myVirtualSlot(int arg)
+        { m_qtFunctionInvoked = 59; return arg; }
+};
+
+class MyEnumTestQObject : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(QString p1 READ p1)
+    Q_PROPERTY(QString p2 READ p2)
+    Q_PROPERTY(QString p3 READ p3 SCRIPTABLE false)
+    Q_PROPERTY(QString p4 READ p4)
+    Q_PROPERTY(QString p5 READ p5 SCRIPTABLE false)
+    Q_PROPERTY(QString p6 READ p6)
+public:
+    MyEnumTestQObject(QObject *parent = 0)
+        : QObject(parent) { }
+    QString p1() const { return QLatin1String("p1"); }
+    QString p2() const { return QLatin1String("p2"); }
+    QString p3() const { return QLatin1String("p3"); }
+    QString p4() const { return QLatin1String("p4"); }
+    QString p5() const { return QLatin1String("p5"); }
+    QString p6() const { return QLatin1String("p5"); }
+public Q_SLOTS:
+    void mySlot() { }
+    void myOtherSlot() { }
+Q_SIGNALS:
+    void mySignal();
+};
+
+class tst_QScriptExtQObject : public QObject
+{
+    Q_OBJECT
+
+public:
+    tst_QScriptExtQObject();
+    virtual ~tst_QScriptExtQObject();
+
+public slots:
+    void init();
+    void cleanup();
+
+protected slots:
+    void onSignalHandlerException(const QScriptValue &exception)
+    {
+        m_signalHandlerException = exception;
+    }
+
+private slots:
+    void getSetStaticProperty();
+    void getSetDynamicProperty();
+    void getSetChildren();
+    void callQtInvokable();
+    void connectAndDisconnect();
+    void cppConnectAndDisconnect();
+    void classEnums();
+    void classConstructor();
+    void overrideInvokable();
+    void transferInvokable();
+    void findChild();
+    void findChildren();
+    void overloadedSlots();
+    void enumerate_data();
+    void enumerate();
+    void enumerateSpecial();
+    void wrapOptions();
+    void prototypes();
+    void objectDeleted();
+    void connectToDestroyedSignal();
+
+private:
+    QScriptEngine *m_engine;
+    MyQObject *m_myObject;
+    QScriptValue m_signalHandlerException;
+};
+
+tst_QScriptExtQObject::tst_QScriptExtQObject()
+{
+}
+
+tst_QScriptExtQObject::~tst_QScriptExtQObject()
+{
+}
+
+void tst_QScriptExtQObject::init()
+{
+    m_engine = new QScriptEngine();
+    m_myObject = new MyQObject();
+    m_engine->globalObject().setProperty("myObject", m_engine->newQObject(m_myObject));
+    m_engine->globalObject().setProperty("global", m_engine->globalObject());
+}
+
+void tst_QScriptExtQObject::cleanup()
+{
+    delete m_engine;
+    delete m_myObject;
+}
+
+static QScriptValue getSetProperty(QScriptContext *ctx, QScriptEngine *)
+{
+    if (ctx->argumentCount() != 0)
+        ctx->callee().setProperty("value", ctx->argument(0));
+    return ctx->callee().property("value");
+}
+
+void tst_QScriptExtQObject::getSetStaticProperty()
+{
+    QCOMPARE(m_engine->evaluate("myObject.noSuchProperty").isUndefined(), true);
+
+    // initial value (set in MyQObject constructor)
+    QCOMPARE(m_engine->evaluate("myObject.intProperty")
+             .strictlyEquals(QScriptValue(m_engine, 123.0)), true);
+    QCOMPARE(m_engine->evaluate("myObject.variantProperty")
+             .toVariant(), QVariant(QLatin1String("foo")));
+    QCOMPARE(m_engine->evaluate("myObject.stringProperty")
+             .strictlyEquals(QScriptValue(m_engine, QLatin1String("bar"))), true);
+    QCOMPARE(m_engine->evaluate("myObject.variantListProperty").isArray(), true);
+    QCOMPARE(m_engine->evaluate("myObject.variantListProperty.length")
+             .strictlyEquals(QScriptValue(m_engine, 2)), true);
+    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[0]")
+             .strictlyEquals(QScriptValue(m_engine, 123)), true);
+    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[1]")
+             .strictlyEquals(QScriptValue(m_engine, QLatin1String("foo"))), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty").isArray(), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty.length")
+             .strictlyEquals(QScriptValue(m_engine, 2)), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[0]").isString(), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[0]").toString(),
+             QLatin1String("zig"));
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[1]").isString(), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[1]").toString(),
+             QLatin1String("zag"));
+
+    // default flags for "normal" properties
+    {
+        QScriptValue mobj = m_engine->globalObject().property("myObject");
+        QVERIFY(!(mobj.propertyFlags("intProperty") & QScriptValue::ReadOnly));
+        QVERIFY(mobj.propertyFlags("intProperty") & QScriptValue::Undeletable);
+        QVERIFY(mobj.propertyFlags("intProperty") & QScriptValue::PropertyGetter);
+        QVERIFY(mobj.propertyFlags("intProperty") & QScriptValue::PropertySetter);
+        QVERIFY(!(mobj.propertyFlags("intProperty") & QScriptValue::SkipInEnumeration));
+        QVERIFY(mobj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
+
+        QVERIFY(!(mobj.propertyFlags("mySlot") & QScriptValue::ReadOnly));
+        QVERIFY(!(mobj.propertyFlags("mySlot") & QScriptValue::Undeletable));
+        QVERIFY(!(mobj.propertyFlags("mySlot") & QScriptValue::SkipInEnumeration));
+        QVERIFY(mobj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
+    }
+
+    // property change in C++ should be reflected in script
+    m_myObject->setIntProperty(456);
+    QCOMPARE(m_engine->evaluate("myObject.intProperty")
+             .strictlyEquals(QScriptValue(m_engine, 456)), true);
+    m_myObject->setIntProperty(789);
+    QCOMPARE(m_engine->evaluate("myObject.intProperty")
+             .strictlyEquals(QScriptValue(m_engine, 789)), true);
+
+    m_myObject->setVariantProperty(QLatin1String("bar"));
+    QVERIFY(m_engine->evaluate("myObject.variantProperty")
+            .strictlyEquals(QScriptValue(m_engine, QLatin1String("bar"))));
+    m_myObject->setVariantProperty(42);
+    QCOMPARE(m_engine->evaluate("myObject.variantProperty")
+             .toVariant(), QVariant(42));
+    m_myObject->setVariantProperty(qVariantFromValue(QBrush()));
+    QVERIFY(m_engine->evaluate("myObject.variantProperty").isVariant());
+
+    m_myObject->setStringProperty(QLatin1String("baz"));
+    QCOMPARE(m_engine->evaluate("myObject.stringProperty")
+             .equals(QScriptValue(m_engine, QLatin1String("baz"))), true);
+    m_myObject->setStringProperty(QLatin1String("zab"));
+    QCOMPARE(m_engine->evaluate("myObject.stringProperty")
+             .equals(QScriptValue(m_engine, QLatin1String("zab"))), true);
+
+    // property change in script should be reflected in C++
+    QCOMPARE(m_engine->evaluate("myObject.intProperty = 123")
+             .strictlyEquals(QScriptValue(m_engine, 123)), true);
+    QCOMPARE(m_engine->evaluate("myObject.intProperty")
+             .strictlyEquals(QScriptValue(m_engine, 123)), true);
+    QCOMPARE(m_myObject->intProperty(), 123);
+    QCOMPARE(m_engine->evaluate("myObject.intProperty = 'ciao!';"
+                                "myObject.intProperty")
+             .strictlyEquals(QScriptValue(m_engine, 0)), true);
+    QCOMPARE(m_myObject->intProperty(), 0);
+    QCOMPARE(m_engine->evaluate("myObject.intProperty = '123';"
+                                "myObject.intProperty")
+             .strictlyEquals(QScriptValue(m_engine, 123)), true);
+    QCOMPARE(m_myObject->intProperty(), 123);
+
+    QCOMPARE(m_engine->evaluate("myObject.stringProperty = 'ciao'")
+             .strictlyEquals(QScriptValue(m_engine, QLatin1String("ciao"))), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringProperty")
+             .strictlyEquals(QScriptValue(m_engine, QLatin1String("ciao"))), true);
+    QCOMPARE(m_myObject->stringProperty(), QLatin1String("ciao"));
+    QCOMPARE(m_engine->evaluate("myObject.stringProperty = 123;"
+                                "myObject.stringProperty")
+             .strictlyEquals(QScriptValue(m_engine, QLatin1String("123"))), true);
+    QCOMPARE(m_myObject->stringProperty(), QLatin1String("123"));
+    QVERIFY(m_engine->evaluate("myObject.stringProperty = null;"
+                               "myObject.stringProperty")
+            .strictlyEquals(QScriptValue(m_engine, QString())));
+    QCOMPARE(m_myObject->stringProperty(), QString());
+    QVERIFY(m_engine->evaluate("myObject.stringProperty = undefined;"
+                               "myObject.stringProperty")
+            .strictlyEquals(QScriptValue(m_engine, QString())));
+    QCOMPARE(m_myObject->stringProperty(), QString());
+
+    QCOMPARE(m_engine->evaluate("myObject.variantProperty = 'foo';"
+                                "myObject.variantProperty.valueOf()").toString(), QLatin1String("foo"));
+    QCOMPARE(m_myObject->variantProperty(), QVariant(QLatin1String("foo")));
+    QVERIFY(m_engine->evaluate("myObject.variantProperty = undefined;"
+                               "myObject.variantProperty").isUndefined());
+    QVERIFY(!m_myObject->variantProperty().isValid());
+    QVERIFY(m_engine->evaluate("myObject.variantProperty = null;"
+                               "myObject.variantProperty").isUndefined());
+    QVERIFY(!m_myObject->variantProperty().isValid());
+    QCOMPARE(m_engine->evaluate("myObject.variantProperty = 42;"
+                                "myObject.variantProperty").toNumber(), 42.0);
+    QCOMPARE(m_myObject->variantProperty().toDouble(), 42.0);
+
+    QCOMPARE(m_engine->evaluate("myObject.variantListProperty = [1, 'two', true];"
+                                "myObject.variantListProperty.length")
+             .strictlyEquals(QScriptValue(m_engine, 3)), true);
+    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[0]")
+             .strictlyEquals(QScriptValue(m_engine, 1)), true);
+    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[1]")
+             .strictlyEquals(QScriptValue(m_engine, QLatin1String("two"))), true);
+    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[2]")
+             .strictlyEquals(QScriptValue(m_engine, true)), true);
+    {
+        QVariantList vl = qscriptvalue_cast<QVariantList>(m_engine->evaluate("myObject.variantListProperty"));
+        QCOMPARE(vl, QVariantList()
+                 << QVariant(1)
+                 << QVariant(QLatin1String("two"))
+                 << QVariant(true));
+    }
+
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty = [1, 'two', true];"
+                                "myObject.stringListProperty.length")
+             .strictlyEquals(QScriptValue(m_engine, 3)), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[0]").isString(), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[0]").toString(),
+             QLatin1String("1"));
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[1]").isString(), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[1]").toString(),
+             QLatin1String("two"));
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[2]").isString(), true);
+    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[2]").toString(),
+             QLatin1String("true"));
+    {
+        QStringList sl = qscriptvalue_cast<QStringList>(m_engine->evaluate("myObject.stringListProperty"));
+        QCOMPARE(sl, QStringList()
+                 << QLatin1String("1")
+                 << QLatin1String("two")
+                 << QLatin1String("true"));
+    }
+
+    // test setting properties where we can't convert the type natively but where the
+    // types happen to be compatible variant types already
+    {
+        QKeySequence sequence(Qt::ControlModifier + Qt::AltModifier + Qt::Key_Delete);
+        QScriptValue mobj = m_engine->globalObject().property("myObject");
+
+        QVERIFY(m_myObject->shortcut().isEmpty());
+        mobj.setProperty("shortcut", m_engine->newVariant(sequence));
+        QVERIFY(m_myObject->shortcut() == sequence);
+    }
+    {
+        CustomType t; t.string = "hello";
+        QScriptValue mobj = m_engine->globalObject().property("myObject");
+
+        QVERIFY(m_myObject->propWithCustomType().string.isEmpty());
+        mobj.setProperty("propWithCustomType", m_engine->newVariant(qVariantFromValue(t)));
+        QVERIFY(m_myObject->propWithCustomType().string == t.string);
+    }
+
+    // test that we do value conversion if necessary when setting properties
+    {
+        QScriptValue br = m_engine->evaluate("myObject.brushProperty");
+        QCOMPARE(qscriptvalue_cast<QBrush>(br), m_myObject->brushProperty());
+        QCOMPARE(qscriptvalue_cast<QColor>(br), m_myObject->brushProperty().color());
+
+        QColor newColor(40, 30, 20, 10);
+        QScriptValue val = qScriptValueFromValue(m_engine, newColor);
+        m_engine->globalObject().setProperty("myColor", val);
+        QScriptValue ret = m_engine->evaluate("myObject.brushProperty = myColor");
+        QCOMPARE(ret.strictlyEquals(val), true);
+        br = m_engine->evaluate("myObject.brushProperty");
+        QCOMPARE(qscriptvalue_cast<QBrush>(br), QBrush(newColor));
+        QCOMPARE(qscriptvalue_cast<QColor>(br), newColor);
+
+        m_engine->globalObject().setProperty("myColor", QScriptValue());
+    }
+
+    // try to delete
+    QCOMPARE(m_engine->evaluate("delete myObject.intProperty").toBoolean(), false);
+    QCOMPARE(m_engine->evaluate("myObject.intProperty").toNumber(), 123.0);
+
+    QCOMPARE(m_engine->evaluate("delete myObject.variantProperty").toBoolean(), false);
+    QCOMPARE(m_engine->evaluate("myObject.variantProperty").toNumber(), 42.0);
+
+    // non-scriptable property
+    QCOMPARE(m_myObject->hiddenProperty(), 456.0);
+    QCOMPARE(m_engine->evaluate("myObject.hiddenProperty").isUndefined(), true);
+    QCOMPARE(m_engine->evaluate("myObject.hiddenProperty = 123;"
+                                "myObject.hiddenProperty").toInt32(), 123);
+    QCOMPARE(m_myObject->hiddenProperty(), 456.0);
+
+    // write-only property
+    QCOMPARE(m_myObject->writeOnlyProperty(), 789);
+    QCOMPARE(m_engine->evaluate("myObject.writeOnlyProperty").isUndefined(), true);
+    QCOMPARE(m_engine->evaluate("myObject.writeOnlyProperty = 123;"
+                                "myObject.writeOnlyProperty").isUndefined(), true);
+    QCOMPARE(m_myObject->writeOnlyProperty(), 123);
+
+    // read-only property
+    QCOMPARE(m_myObject->readOnlyProperty(), 987);
+    QCOMPARE(m_engine->evaluate("myObject.readOnlyProperty").toInt32(), 987);
+    QCOMPARE(m_engine->evaluate("myObject.readOnlyProperty = 654;"
+                                "myObject.readOnlyProperty").toInt32(), 987);
+    QCOMPARE(m_myObject->readOnlyProperty(), 987);
+    {
+        QScriptValue mobj = m_engine->globalObject().property("myObject");
+        QCOMPARE(mobj.propertyFlags("readOnlyProperty") & QScriptValue::ReadOnly,
+                 QScriptValue::ReadOnly);
+    }
+
+    // auto-dereferencing of pointers
+    {
+        QBrush b = QColor(0xCA, 0xFE, 0xBA, 0xBE);
+        QBrush *bp = &b;
+        QScriptValue bpValue = m_engine->newVariant(qVariantFromValue(bp));
+        m_engine->globalObject().setProperty("brushPointer", bpValue);
+        {
+            QScriptValue ret = m_engine->evaluate("myObject.setBrushProperty(brushPointer)");
+            QCOMPARE(ret.isUndefined(), true);
+            QCOMPARE(qscriptvalue_cast<QBrush>(m_engine->evaluate("myObject.brushProperty")), b);
+        }
+        {
+            b = QColor(0xDE, 0xAD, 0xBE, 0xEF);
+            QScriptValue ret = m_engine->evaluate("myObject.brushProperty = brushPointer");
+            QCOMPARE(ret.strictlyEquals(bpValue), true);
+            QCOMPARE(qscriptvalue_cast<QBrush>(m_engine->evaluate("myObject.brushProperty")), b);
+        }
+        m_engine->globalObject().setProperty("brushPointer", QScriptValue());
+    }
+
+    // try to install custom property getter+setter
+    {
+        QScriptValue mobj = m_engine->globalObject().property("myObject");
+        QTest::ignoreMessage(QtWarningMsg, "QScriptValue::setProperty() failed: "
+                             "cannot set getter or setter of native property "
+                             "`intProperty'");
+        mobj.setProperty("intProperty", m_engine->newFunction(getSetProperty),
+                         QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
+    }
+}
+
+void tst_QScriptExtQObject::getSetDynamicProperty()
+{
+    // initially the object does not have the property
+    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('dynamicProperty')")
+             .strictlyEquals(QScriptValue(m_engine, false)), true);
+
+    // add a dynamic property in C++
+    QCOMPARE(m_myObject->setProperty("dynamicProperty", 123), false);
+    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('dynamicProperty')")
+             .strictlyEquals(QScriptValue(m_engine, true)), true);
+    QCOMPARE(m_engine->evaluate("myObject.dynamicProperty")
+             .strictlyEquals(QScriptValue(m_engine, 123)), true);
+
+    // check the flags
+    {
+        QScriptValue mobj = m_engine->globalObject().property("myObject");
+        QVERIFY(!(mobj.propertyFlags("dynamicProperty") & QScriptValue::ReadOnly));
+        QVERIFY(!(mobj.propertyFlags("dynamicProperty") & QScriptValue::Undeletable));
+        QVERIFY(!(mobj.propertyFlags("dynamicProperty") & QScriptValue::SkipInEnumeration));
+        QVERIFY(mobj.propertyFlags("dynamicProperty") & QScriptValue::QObjectMember);
+    }
+
+    // property change in script should be reflected in C++
+    QCOMPARE(m_engine->evaluate("myObject.dynamicProperty = 'foo';"
+                                "myObject.dynamicProperty")
+             .strictlyEquals(QScriptValue(m_engine, QLatin1String("foo"))), true);
+    QCOMPARE(m_myObject->property("dynamicProperty").toString(), QLatin1String("foo"));
+
+    // delete the property
+    QCOMPARE(m_engine->evaluate("delete myObject.dynamicProperty").toBoolean(), true);
+    QCOMPARE(m_myObject->property("dynamicProperty").isValid(), false);
+    QCOMPARE(m_engine->evaluate("myObject.dynamicProperty").isUndefined(), true);
+    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('dynamicProperty')").toBoolean(), false);
+}
+
+void tst_QScriptExtQObject::getSetChildren()
+{
+    // initially the object does not have the child
+    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('child')")
+             .strictlyEquals(QScriptValue(m_engine, false)), true);
+
+    // add a child
+    MyQObject *child = new MyQObject(m_myObject);
+    child->setObjectName("child");
+    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('child')")
+             .strictlyEquals(QScriptValue(m_engine, true)), true);
+
+    // add a grandchild
+    MyQObject *grandChild = new MyQObject(child);
+    grandChild->setObjectName("grandChild");
+    QCOMPARE(m_engine->evaluate("myObject.child.hasOwnProperty('grandChild')")
+             .strictlyEquals(QScriptValue(m_engine, true)), true);
+
+    // delete grandchild
+    delete grandChild;
+    QCOMPARE(m_engine->evaluate("myObject.child.hasOwnProperty('grandChild')")
+             .strictlyEquals(QScriptValue(m_engine, false)), true);
+
+    // delete child
+    delete child;
+    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('child')")
+             .strictlyEquals(QScriptValue(m_engine, false)), true);
+
+}
+
+Q_DECLARE_METATYPE(QVector<int>)
+Q_DECLARE_METATYPE(QVector<double>)
+Q_DECLARE_METATYPE(QVector<QString>)
+
+template <class T>
+static QScriptValue qobjectToScriptValue(QScriptEngine *engine, T* const &in)
+{ return engine->newQObject(in); }
+
+template <class T>
+static void qobjectFromScriptValue(const QScriptValue &object, T* &out)
+{ out = qobject_cast<T*>(object.toQObject()); }
+
+void tst_QScriptExtQObject::callQtInvokable()
+{
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokable()").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+    // extra arguments should silently be ignored
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokable(10, 20, 30)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithIntArg(123)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithIntArg('123')").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithLonglongArg(123)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 2);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toLongLong(), qlonglong(123));
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithFloatArg(123.5)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 3);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5);
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithDoubleArg(123.5)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 4);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5);
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithStringArg('ciao')").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("ciao"));
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithStringArg(123)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123"));
+
+    m_myObject->resetQtFunctionInvoked();
+    QVERIFY(m_engine->evaluate("myObject.myInvokableWithStringArg(null)").isUndefined());
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).type(), QVariant::String);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QString());
+
+    m_myObject->resetQtFunctionInvoked();
+    QVERIFY(m_engine->evaluate("myObject.myInvokableWithStringArg(undefined)").isUndefined());
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).type(), QVariant::String);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QString());
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithIntArgs(123, 456)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 6);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456);
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningInt()")
+             .strictlyEquals(QScriptValue(m_engine, 123)), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 7);
+    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningLongLong()")
+             .strictlyEquals(QScriptValue(m_engine, 456)), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 39);
+    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningString()")
+             .strictlyEquals(QScriptValue(m_engine, QLatin1String("ciao"))), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 8);
+    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+    m_myObject->resetQtFunctionInvoked();
+    QVERIFY(m_engine->evaluate("myObject.myInvokableReturningVariant()")
+             .strictlyEquals(QScriptValue(m_engine, 123)));
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 60);
+
+    m_myObject->resetQtFunctionInvoked();
+    QVERIFY(m_engine->evaluate("myObject.myInvokableReturningScriptValue()")
+             .strictlyEquals(QScriptValue(m_engine, 456)));
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 61);
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithIntArg(123, 456)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 9);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456);
+
+    m_myObject->resetQtFunctionInvoked();
+    QVERIFY(m_engine->evaluate("myObject.myInvokableWithVoidStarArg(null)").isUndefined());
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 44);
+    m_myObject->resetQtFunctionInvoked();
+    QVERIFY(m_engine->evaluate("myObject.myInvokableWithVoidStarArg(123)").isError());
+    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithAmbiguousArg(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: ambiguous call of overloaded function myInvokableWithAmbiguousArg(); candidates were\n    myInvokableWithAmbiguousArg(int)\n    myInvokableWithAmbiguousArg(uint)"));
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithDefaultArgs(123, 'hello')");
+        QVERIFY(ret.isUndefined());
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 47);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
+        QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+        QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QLatin1String("hello"));
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithDefaultArgs(456)");
+        QVERIFY(ret.isUndefined());
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 47);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
+        QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456);
+        QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QString());
+    }
+
+    {
+        QScriptValue fun = m_engine->evaluate("myObject.myInvokableWithPointArg");
+        QVERIFY(fun.isFunction());
+        m_myObject->resetQtFunctionInvoked();
+        {
+            QScriptValue ret = fun.call(m_engine->evaluate("myObject"),
+                                        QScriptValueList() << qScriptValueFromValue(m_engine, QPoint(10, 20)));
+            QVERIFY(ret.isUndefined());
+            QCOMPARE(m_myObject->qtFunctionInvoked(), 50);
+            QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+            QCOMPARE(m_myObject->qtFunctionActuals().at(0).toPoint(), QPoint(10, 20));
+        }
+        m_myObject->resetQtFunctionInvoked();
+        {
+            QScriptValue ret = fun.call(m_engine->evaluate("myObject"),
+                                        QScriptValueList() << qScriptValueFromValue(m_engine, QPointF(30, 40)));
+            QVERIFY(ret.isUndefined());
+            QCOMPARE(m_myObject->qtFunctionInvoked(), 51);
+            QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+            QCOMPARE(m_myObject->qtFunctionActuals().at(0).toPointF(), QPointF(30, 40));
+        }
+    }
+
+    // calling function that returns (const)ref
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningRef()");
+        QVERIFY(ret.isUndefined());
+        QVERIFY(!m_engine->hasUncaughtException());
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 48);
+    }
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningConstRef()");
+        QVERIFY(ret.isUndefined());
+        QVERIFY(!m_engine->hasUncaughtException());
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 49);
+    }
+
+    // first time we expect failure because the metatype is not registered
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningVectorOfInt()").isError(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithVectorOfIntArg(0)").isError(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+
+    // now we register it, and it should work
+    qScriptRegisterSequenceMetaType<QVector<int> >(m_engine);
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningVectorOfInt()");
+        QCOMPARE(ret.isArray(), true);
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 11);
+    }
+
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVectorOfIntArg(myObject.myInvokableReturningVectorOfInt())");
+        QCOMPARE(ret.isUndefined(), true);
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 12);
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningQObjectStar()");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 13);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 0);
+        QCOMPARE(ret.isQObject(), true);
+        QCOMPARE(ret.toQObject(), (QObject *)m_myObject);
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQObjectListArg([myObject])");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 14);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QCOMPARE(ret.isArray(), true);
+        QCOMPARE(ret.property(QLatin1String("length"))
+                 .strictlyEquals(QScriptValue(m_engine, 1)), true);
+        QCOMPARE(ret.property(QLatin1String("0")).isQObject(), true);
+        QCOMPARE(ret.property(QLatin1String("0")).toQObject(), (QObject *)m_myObject);
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        m_myObject->setVariantProperty(QVariant(123));
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(myObject.variantProperty)");
+        QVERIFY(ret.isNumber());
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QCOMPARE(m_myObject->qtFunctionActuals().at(0), m_myObject->variantProperty());
+        QVERIFY(ret.strictlyEquals(QScriptValue(m_engine, 123)));
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        m_myObject->setVariantProperty(qVariantFromValue(QBrush()));
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(myObject.variantProperty)");
+        QVERIFY(ret.isVariant());
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QCOMPARE(ret.toVariant(), m_myObject->qtFunctionActuals().at(0));
+        QCOMPARE(ret.toVariant(), m_myObject->variantProperty());
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(123)");
+        QVERIFY(ret.isNumber());
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant(123));
+        QVERIFY(ret.strictlyEquals(QScriptValue(m_engine, 123)));
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg('ciao')");
+        QVERIFY(ret.isString());
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant(QString::fromLatin1("ciao")));
+        QVERIFY(ret.strictlyEquals(QScriptValue(m_engine, QString::fromLatin1("ciao"))));
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(null)");
+        QVERIFY(ret.isUndefined()); // invalid QVariant is converted to Undefined
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant());
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(undefined)");
+        QVERIFY(ret.isUndefined());
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant());
+    }
+
+    m_engine->globalObject().setProperty("fishy", m_engine->newVariant(123));
+    m_engine->evaluate("myObject.myInvokableWithStringArg(fishy)");
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantMapArg({ a:123, b:'ciao' })");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 16);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QVariant v = m_myObject->qtFunctionActuals().at(0);
+        QCOMPARE(v.userType(), int(QMetaType::QVariantMap));
+        QVariantMap vmap = qvariant_cast<QVariantMap>(v);
+        QCOMPARE(vmap.keys().size(), 2);
+        QCOMPARE(vmap.keys().at(0), QLatin1String("a"));
+        QCOMPARE(vmap.value("a"), QVariant(123));
+        QCOMPARE(vmap.keys().at(1), QLatin1String("b"));
+        QCOMPARE(vmap.value("b"), QVariant("ciao"));
+
+        QCOMPARE(ret.isObject(), true);
+        QCOMPARE(ret.property("a").strictlyEquals(QScriptValue(m_engine, 123)), true);
+        QCOMPARE(ret.property("b").strictlyEquals(QScriptValue(m_engine, "ciao")), true);
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithListOfIntArg([1, 5])");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 17);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QVariant v = m_myObject->qtFunctionActuals().at(0);
+        QCOMPARE(v.userType(), qMetaTypeId<QList<int> >());
+        QList<int> ilst = qvariant_cast<QList<int> >(v);
+        QCOMPARE(ilst.size(), 2);
+        QCOMPARE(ilst.at(0), 1);
+        QCOMPARE(ilst.at(1), 5);
+
+        QCOMPARE(ret.isArray(), true);
+        QCOMPARE(ret.property("0").strictlyEquals(QScriptValue(m_engine, 1)), true);
+        QCOMPARE(ret.property("1").strictlyEquals(QScriptValue(m_engine, 5)), true);
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQObjectStarArg(myObject)");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 18);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QVariant v = m_myObject->qtFunctionActuals().at(0);
+        QCOMPARE(v.userType(), int(QMetaType::QObjectStar));
+        QCOMPARE(qvariant_cast<QObject*>(v), (QObject *)m_myObject);
+
+        QCOMPARE(ret.isQObject(), true);
+        QCOMPARE(qscriptvalue_cast<QObject*>(ret), (QObject *)m_myObject);
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        // no implicit conversion from integer to QObject*
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQObjectStarArg(123)");
+        QCOMPARE(ret.isError(), true);
+    }
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue fun = m_engine->evaluate("myObject.myInvokableWithQBrushArg");
+        QVERIFY(fun.isFunction());
+        QColor color(10, 20, 30, 40);
+        // QColor should be converted to a QBrush
+        QScriptValue ret = fun.call(QScriptValue(), QScriptValueList()
+                                    << qScriptValueFromValue(m_engine, color));
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 19);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QVariant v = m_myObject->qtFunctionActuals().at(0);
+        QCOMPARE(v.userType(), int(QMetaType::QBrush));
+        QCOMPARE(qvariant_cast<QColor>(v), color);
+
+        QCOMPARE(qscriptvalue_cast<QColor>(ret), color);
+    }
+
+    // private slots should not be part of the QObject binding
+    QCOMPARE(m_engine->evaluate("myObject.myPrivateSlot").isUndefined(), true);
+
+    // protected slots should be fine
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myProtectedSlot()");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 36);
+
+    // call with too few arguments
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithIntArg()");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("SyntaxError: too few arguments in call to myInvokableWithIntArg(); candidates are\n    myInvokableWithIntArg(int,int)\n    myInvokableWithIntArg(int)"));
+    }
+
+    // call function where not all types have been registered
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithBrushStyleArg(0)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: cannot call myInvokableWithBrushStyleArg(): argument 1 has unknown type `Qt::BrushStyle' (register the type with qScriptRegisterMetaType())"));
+        QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+    }
+
+    // call function with incompatible argument type
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQBrushArg(null)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: incompatible type of argument(s) in call to myInvokableWithQBrushArg(); candidates were\n    myInvokableWithQBrushArg(QBrush)"));
+        QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+    }
+
+    // ability to call a slot with QObject-based arguments, even if those types haven't been registered
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithMyQObjectArg(myObject)");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 52);
+        QVERIFY(ret.isUndefined());
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QCOMPARE(qvariant_cast<QObject*>(m_myObject->qtFunctionActuals().at(0)), (QObject*)m_myObject);
+    }
+
+    // inability to call a slot returning QObject-based type, when that type hasn't been registered
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningMyQObject()");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: cannot call myInvokableReturningMyQObject(): unknown return type `MyQObject*' (register the type with qScriptRegisterMetaType())"));
+    }
+
+    // ability to call a slot returning QObject-based type when that type has been registered
+    qRegisterMetaType<MyQObject*>("MyQObject*");
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningMyQObject()");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 53);
+        QVERIFY(ret.isVariant());
+        QCOMPARE(*reinterpret_cast<MyQObject* const *>(ret.toVariant().constData()), m_myObject);
+    }
+
+    // ability to call a slot with QObject-based argument, when the argument is const
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithConstMyQObjectArg(myObject)");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 54);
+        QVERIFY(ret.isUndefined());
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+        QCOMPARE(qvariant_cast<QObject*>(m_myObject->qtFunctionActuals().at(0)), (QObject*)m_myObject);
+    }
+
+    // QScriptValue arguments should be passed on without conversion
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithScriptValueArg(123)");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 56);
+        QVERIFY(ret.isNumber());
+        QCOMPARE(ret.toInt32(), 123);
+    }
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithScriptValueArg('ciao')");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 56);
+        QVERIFY(ret.isString());
+        QCOMPARE(ret.toString(), QString::fromLatin1("ciao"));
+    }
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithScriptValueArg(this)");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 56);
+        QVERIFY(ret.isObject());
+        QVERIFY(ret.strictlyEquals(m_engine->globalObject()));
+    }
+
+    // the prototype specified by a conversion function should not be "down-graded"
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue qobjectProto = m_engine->newObject();
+        qScriptRegisterMetaType<QObject*>(m_engine, qobjectToScriptValue,
+                                          qobjectFromScriptValue, qobjectProto);
+        QScriptValue myQObjectProto = m_engine->newObject();
+        myQObjectProto.setPrototype(qobjectProto);
+        qScriptRegisterMetaType<MyQObject*>(m_engine, qobjectToScriptValue,
+                                          qobjectFromScriptValue, myQObjectProto);
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningMyQObjectAsQObject()");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 57);
+        QVERIFY(ret.isQObject());
+        QVERIFY(ret.prototype().strictlyEquals(myQObjectProto));
+
+        qScriptRegisterMetaType<QObject*>(m_engine, 0, 0, QScriptValue());
+        qScriptRegisterMetaType<MyQObject*>(m_engine, 0, 0, QScriptValue());
+    }
+
+    // detect exceptions during argument conversion
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue (*dummy)(QScriptEngine *, const QDir &) = 0;
+        qScriptRegisterMetaType<QDir>(m_engine, dummy, dirFromScript);
+        {
+            QVERIFY(!m_engine->hasUncaughtException());
+            QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQDirArg({})");
+            QVERIFY(m_engine->hasUncaughtException());
+            QVERIFY(ret.isError());
+            QCOMPARE(ret.toString(), QString::fromLatin1("Error: No path"));
+            QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+        }
+        m_engine->clearExceptions();
+        {
+            QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQDirArg({path:'.'})");
+            QVERIFY(!m_engine->hasUncaughtException());
+            QVERIFY(ret.isUndefined());
+            QCOMPARE(m_myObject->qtFunctionInvoked(), 55);
+        }
+    }
+
+    // qscript_call()
+    {
+        m_myObject->resetQtFunctionInvoked();
+        QScriptValue ret = m_engine->evaluate("new myObject(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: myObject is not a constructor"));
+    }
+    {
+        m_myObject->resetQtFunctionInvoked();
+        QScriptValue ret = m_engine->evaluate("myObject(123)");
+        QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: myObject is not a function"));
+    }
+
+    // task 233624
+    {
+        MyNS::A a;
+        m_engine->globalObject().setProperty("anObject", m_engine->newQObject(&a));
+        QScriptValue ret = m_engine->evaluate("anObject.slotTakingScopedEnumArg(1)");
+        QVERIFY(!ret.isError());
+        QVERIFY(ret.isNumber());
+        QCOMPARE(ret.toInt32(), 1);
+        m_engine->globalObject().setProperty("anObject", QScriptValue());
+    }
+
+    // virtual slot redeclared in subclass (task 236467)
+    {
+        MyOtherQObject moq;
+        m_engine->globalObject().setProperty("myOtherQObject", m_engine->newQObject(&moq));
+        moq.resetQtFunctionInvoked();
+        QScriptValue ret = m_engine->evaluate("myOtherQObject.myVirtualSlot(123)");
+        QCOMPARE(moq.qtFunctionInvoked(), 59);
+        QVERIFY(!ret.isError());
+        QVERIFY(ret.isNumber());
+        QCOMPARE(ret.toInt32(), 123);
+    }
+}
+
+void tst_QScriptExtQObject::connectAndDisconnect()
+{
+    // connect(function)
+    QCOMPARE(m_engine->evaluate("myObject.mySignal.connect(123)").isError(), true);
+
+    m_engine->evaluate("myHandler = function() { global.gotSignal = true; global.signalArgs = arguments; global.slotThisObject = this; global.signalSender = __qt_sender__; }");
+
+    m_myObject->clearConnectedSignal();
+    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myHandler)").isUndefined());
+    QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignal()));
+
+    m_engine->evaluate("gotSignal = false");
+    m_engine->evaluate("myObject.mySignal()");
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 0.0);
+    QCOMPARE(m_engine->evaluate("signalSender").toQObject(), (QObject *)m_myObject);
+    QVERIFY(m_engine->evaluate("slotThisObject").strictlyEquals(m_engine->globalObject()));
+
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignal();
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 0.0);
+
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myHandler)").isUndefined());
+
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignalWithIntArg(123);
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
+    QCOMPARE(m_engine->evaluate("signalArgs[0]").toNumber(), 123.0);
+
+    m_myObject->clearDisconnectedSignal();
+    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myHandler)").isUndefined());
+    QCOMPARE(m_myObject->disconnectedSignal().constData(), SIGNAL(mySignal()));
+
+    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myHandler)").isError());
+
+    QVERIFY(m_engine->evaluate("myObject.mySignal2.connect(myHandler)").isUndefined());
+
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignal2(false);
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
+    QCOMPARE(m_engine->evaluate("signalArgs[0]").toBoolean(), false);
+
+    m_engine->evaluate("gotSignal = false");
+    QVERIFY(m_engine->evaluate("myObject.mySignal2.connect(myHandler)").isUndefined());
+    m_myObject->emitMySignal2(true);
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
+    QCOMPARE(m_engine->evaluate("signalArgs[0]").toBoolean(), true);
+
+    QVERIFY(m_engine->evaluate("myObject.mySignal2.disconnect(myHandler)").isUndefined());
+
+    QVERIFY(m_engine->evaluate("myObject['mySignal2()'].connect(myHandler)").isUndefined());
+
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignal2();
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+
+    QVERIFY(m_engine->evaluate("myObject['mySignal2()'].disconnect(myHandler)").isUndefined());
+
+    // connecting to signal with default args should pick the most generic version (i.e. with all args)
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithDefaultArg.connect(myHandler)").isUndefined());
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignalWithDefaultArgWithArg(456);
+    QVERIFY(m_engine->evaluate("gotSignal").toBoolean());
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toInt32(), 1);
+    QCOMPARE(m_engine->evaluate("signalArgs[0]").toInt32(), 456);
+
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignalWithDefaultArg();
+    QVERIFY(m_engine->evaluate("gotSignal").toBoolean());
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toInt32(), 1);
+    QCOMPARE(m_engine->evaluate("signalArgs[0]").toInt32(), 123);
+
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithDefaultArg.disconnect(myHandler)").isUndefined());
+
+    m_engine->evaluate("gotSignal = false");
+    // connecting to overloaded signal should throw an error
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myOverloadedSignal.connect(myHandler)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QString::fromLatin1("Error: Function.prototype.connect: ambiguous connect to MyQObject::myOverloadedSignal(); candidates are\n"
+                                                     "    myOverloadedSignal(int)\n"
+                                                     "    myOverloadedSignal(QString)\n"
+                                                     "Use e.g. object['myOverloadedSignal(QString)'].connect() to connect to a particular overload"));
+    }
+    m_myObject->emitMyOverloadedSignal(123);
+    QVERIFY(!m_engine->evaluate("gotSignal").toBoolean());
+    m_myObject->emitMyOverloadedSignal("ciao");
+    QVERIFY(!m_engine->evaluate("gotSignal").toBoolean());
+
+    m_engine->evaluate("gotSignal = false");
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myOtherOverloadedSignal.connect(myHandler)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QString::fromLatin1("Error: Function.prototype.connect: ambiguous connect to MyQObject::myOtherOverloadedSignal(); candidates are\n"
+                                                     "    myOtherOverloadedSignal(QString)\n"
+                                                     "    myOtherOverloadedSignal(int)\n"
+                                                     "Use e.g. object['myOtherOverloadedSignal(int)'].connect() to connect to a particular overload"));
+    }
+    m_myObject->emitMyOtherOverloadedSignal("ciao");
+    QVERIFY(!m_engine->evaluate("gotSignal").toBoolean());
+    m_myObject->emitMyOtherOverloadedSignal(123);
+    QVERIFY(!m_engine->evaluate("gotSignal").toBoolean());
+
+    // connect(object, function)
+    m_engine->evaluate("otherObject = { name:'foo' }");
+    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(otherObject, myHandler)").isUndefined());
+    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(otherObject, myHandler)").isUndefined());
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignal();
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), false);
+
+    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(otherObject, myHandler)").isError());
+
+    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(otherObject, myHandler)").isUndefined());
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignal();
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 0.0);
+    QVERIFY(m_engine->evaluate("slotThisObject").strictlyEquals(m_engine->evaluate("otherObject")));
+    QVERIFY(m_engine->evaluate("signalSender").strictlyEquals(m_engine->evaluate("myObject")));
+    QCOMPARE(m_engine->evaluate("slotThisObject").property("name").toString(), QLatin1String("foo"));
+    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(otherObject, myHandler)").isUndefined());
+
+    m_engine->evaluate("yetAnotherObject = { name:'bar', func : function() { } }");
+    QVERIFY(m_engine->evaluate("myObject.mySignal2.connect(yetAnotherObject, myHandler)").isUndefined());
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignal2(true);
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
+    QVERIFY(m_engine->evaluate("slotThisObject").strictlyEquals(m_engine->evaluate("yetAnotherObject")));
+    QVERIFY(m_engine->evaluate("signalSender").strictlyEquals(m_engine->evaluate("myObject")));
+    QCOMPARE(m_engine->evaluate("slotThisObject").property("name").toString(), QLatin1String("bar"));
+    QVERIFY(m_engine->evaluate("myObject.mySignal2.disconnect(yetAnotherObject, myHandler)").isUndefined());
+
+    QVERIFY(m_engine->evaluate("myObject.mySignal2.connect(myObject, myHandler)").isUndefined());
+    m_engine->evaluate("gotSignal = false");
+    m_myObject->emitMySignal2(true);
+    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
+    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
+    QCOMPARE(m_engine->evaluate("slotThisObject").toQObject(), (QObject *)m_myObject);
+    QVERIFY(m_engine->evaluate("signalSender").strictlyEquals(m_engine->evaluate("myObject")));
+    QVERIFY(m_engine->evaluate("myObject.mySignal2.disconnect(myObject, myHandler)").isUndefined());
+
+    // connect(obj, string)
+    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(yetAnotherObject, 'func')").isUndefined());
+    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject, 'mySlot')").isUndefined());
+    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(yetAnotherObject, 'func')").isUndefined());
+    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myObject, 'mySlot')").isUndefined());
+
+    // check that emitting signals from script works
+
+    // no arguments
+    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject.mySlot)").isUndefined());
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.mySignal()").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
+    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myObject.mySlot)").isUndefined());
+
+    // one argument
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject.mySlotWithIntArg)").isUndefined());
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(123)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 21);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithIntArg)").isUndefined());
+
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject.mySlotWithDoubleArg)").isUndefined());
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(123)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 22);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.0);
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithDoubleArg)").isUndefined());
+
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject.mySlotWithStringArg)").isUndefined());
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(123)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 23);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123"));
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithStringArg)").isUndefined());
+
+    // connecting to overloaded slot
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject.myOverloadedSlot)").isUndefined());
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(123)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 26); // double overload
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject.myOverloadedSlot)").isUndefined());
+
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject['myOverloadedSlot(int)'])").isUndefined());
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(456)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 28); // int overload
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456);
+    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject['myOverloadedSlot(int)'])").isUndefined());
+
+    // erroneous input
+    {
+        QScriptValue ret = m_engine->evaluate("(function() { }).connect()");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.connect: no arguments given"));
+    }
+    {
+        QScriptValue ret = m_engine->evaluate("var o = { }; o.connect = Function.prototype.connect;  o.connect()");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.connect: no arguments given"));
+    }
+
+    {
+        QScriptValue ret = m_engine->evaluate("(function() { }).connect(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: this object is not a signal"));
+    }
+    {
+        QScriptValue ret = m_engine->evaluate("var o = { }; o.connect = Function.prototype.connect;  o.connect(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: this object is not a signal"));
+    }
+
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokable.connect(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: MyQObject::myInvokable() is not a signal"));
+    }
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokable.connect(function() { })");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: MyQObject::myInvokable() is not a signal"));
+    }
+
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.mySignal.connect(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: target is not a function"));
+    }
+
+    {
+        QScriptValue ret = m_engine->evaluate("(function() { }).disconnect()");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.disconnect: no arguments given"));
+    }
+    {
+        QScriptValue ret = m_engine->evaluate("var o = { }; o.disconnect = Function.prototype.disconnect;  o.disconnect()");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.disconnect: no arguments given"));
+    }
+
+    {
+        QScriptValue ret = m_engine->evaluate("(function() { }).disconnect(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: this object is not a signal"));
+    }
+    {
+        QScriptValue ret = m_engine->evaluate("var o = { }; o.disconnect = Function.prototype.disconnect;  o.disconnect(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: this object is not a signal"));
+    }
+
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokable.disconnect(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: MyQObject::myInvokable() is not a signal"));
+    }
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokable.disconnect(function() { })");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: MyQObject::myInvokable() is not a signal"));
+    }
+
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.mySignal.disconnect(123)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: target is not a function"));
+    }
+
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.mySignal.disconnect(function() { })");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.disconnect: failed to disconnect from MyQObject::mySignal()"));
+    }
+
+    // when the wrapper dies, the connection stays alive
+    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject.mySlot)").isUndefined());
+    m_myObject->resetQtFunctionInvoked();
+    m_myObject->emitMySignal();
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
+    m_engine->evaluate("myObject = null");
+    m_engine->collectGarbage();
+    m_myObject->resetQtFunctionInvoked();
+    m_myObject->emitMySignal();
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
+}
+
+void tst_QScriptExtQObject::cppConnectAndDisconnect()
+{
+    QScriptEngine eng;
+    QLineEdit edit;
+    QLineEdit edit2;
+    QScriptValue fun = eng.evaluate("function fun(text) { signalObject = this; signalArg = text; }; fun");
+    QVERIFY(fun.isFunction());
+    for (int z = 0; z < 2; ++z) {
+        QScriptValue receiver;
+        if (z == 0)
+            receiver = QScriptValue();
+        else
+            receiver = eng.newObject();
+        for (int y = 0; y < 2; ++y) {
+            QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), receiver, fun));
+            QVERIFY(qScriptConnect(&edit2, SIGNAL(textChanged(const QString &)), receiver, fun));
+            // check signal emission
+            for (int x = 0; x < 4; ++x) {
+                QLineEdit *ed = (x < 2) ? &edit : &edit2;
+                ed->setText((x % 2) ? "foo" : "bar");
+                {
+                    QScriptValue ret = eng.globalObject().property("signalObject");
+                    if (receiver.isObject())
+                        QVERIFY(ret.strictlyEquals(receiver));
+                    else
+                        QVERIFY(ret.strictlyEquals(eng.globalObject()));
+                }
+                {
+                    QScriptValue ret = eng.globalObject().property("signalArg");
+                    QVERIFY(ret.isString());
+                    QCOMPARE(ret.toString(), ed->text());
+                }
+                eng.collectGarbage();
+            }
+
+            // check disconnect
+            QVERIFY(qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), receiver, fun));
+            eng.globalObject().setProperty("signalObject", QScriptValue());
+            eng.globalObject().setProperty("signalArg", QScriptValue());
+            edit.setText("something else");
+            QVERIFY(!eng.globalObject().property("signalObject").isValid());
+            QVERIFY(!eng.globalObject().property("signalArg").isValid());
+            QVERIFY(!qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), receiver, fun));
+
+            // other object's connection should remain
+            edit2.setText(edit.text());
+            {
+                QScriptValue ret = eng.globalObject().property("signalObject");
+                if (receiver.isObject())
+                    QVERIFY(ret.strictlyEquals(receiver));
+                else
+                    QVERIFY(ret.strictlyEquals(eng.globalObject()));
+            }
+            {
+                QScriptValue ret = eng.globalObject().property("signalArg");
+                QVERIFY(ret.isString());
+                QCOMPARE(ret.toString(), edit2.text());
+            }
+
+            // disconnect other object too
+            QVERIFY(qScriptDisconnect(&edit2, SIGNAL(textChanged(const QString &)), receiver, fun));
+            eng.globalObject().setProperty("signalObject", QScriptValue());
+            eng.globalObject().setProperty("signalArg", QScriptValue());
+            edit2.setText("even more different");
+            QVERIFY(!eng.globalObject().property("signalObject").isValid());
+            QVERIFY(!eng.globalObject().property("signalArg").isValid());
+            QVERIFY(!qScriptDisconnect(&edit2, SIGNAL(textChanged(const QString &)), receiver, fun));
+        }
+    }
+
+    // make sure we don't crash when engine is deleted
+    {
+        QScriptEngine *eng2 = new QScriptEngine;
+        QScriptValue fun2 = eng2->evaluate("function(text) { signalObject = this; signalArg = text; }");
+        QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun2));
+        delete eng2;
+        edit.setText("ciao");
+        QVERIFY(!qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun2));
+    }
+
+    // mixing script-side and C++-side connect
+    {
+        eng.globalObject().setProperty("edit", eng.newQObject(&edit));
+        QVERIFY(eng.evaluate("edit.textChanged.connect(fun)").isUndefined());
+        QVERIFY(qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun));
+
+        QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun));
+        QVERIFY(eng.evaluate("edit.textChanged.disconnect(fun)").isUndefined());
+    }
+
+    // signalHandlerException()
+    {
+        connect(&eng, SIGNAL(signalHandlerException(QScriptValue)),
+                this, SLOT(onSignalHandlerException(QScriptValue)));
+
+        eng.globalObject().setProperty("edit", eng.newQObject(&edit));
+        QScriptValue fun = eng.evaluate("function() { nonExistingFunction(); }");
+        QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun));
+
+        m_signalHandlerException = QScriptValue();
+        QScriptValue ret = eng.evaluate("edit.text = 'trigger a signal handler exception from script'");
+        QVERIFY(ret.isError());
+        QVERIFY(m_signalHandlerException.strictlyEquals(ret));
+
+        m_signalHandlerException = QScriptValue();
+        edit.setText("trigger a signal handler exception from C++");
+        QVERIFY(m_signalHandlerException.isError());
+
+        QVERIFY(qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun));
+
+        m_signalHandlerException = QScriptValue();
+        eng.evaluate("edit.text = 'no more exception from script'");
+        QVERIFY(!m_signalHandlerException.isValid());
+        edit.setText("no more exception from C++");
+        QVERIFY(!m_signalHandlerException.isValid());
+
+        disconnect(&eng, SIGNAL(signalHandlerException(QScriptValue)),
+                   this, SLOT(onSignalHandlerException(QScriptValue)));
+    }
+
+    // check that connectNotify() and disconnectNotify() are called (task 232987)
+    {
+        m_myObject->clearConnectedSignal();
+        QVERIFY(qScriptConnect(m_myObject, SIGNAL(mySignal()), QScriptValue(), fun));
+        QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignal()));
+
+        m_myObject->clearDisconnectedSignal();
+        QVERIFY(qScriptDisconnect(m_myObject, SIGNAL(mySignal()), QScriptValue(), fun));
+        QCOMPARE(m_myObject->disconnectedSignal().constData(), SIGNAL(mySignal()));
+    }
+}
+
+void tst_QScriptExtQObject::classEnums()
+{
+    QScriptValue myClass = m_engine->newQMetaObject(m_myObject->metaObject(), m_engine->undefinedValue());
+    m_engine->globalObject().setProperty("MyQObject", myClass);
+
+    QCOMPARE(static_cast<MyQObject::Policy>(m_engine->evaluate("MyQObject.FooPolicy").toInt32()),
+             MyQObject::FooPolicy);
+    QCOMPARE(static_cast<MyQObject::Policy>(m_engine->evaluate("MyQObject.BarPolicy").toInt32()),
+             MyQObject::BarPolicy);
+    QCOMPARE(static_cast<MyQObject::Policy>(m_engine->evaluate("MyQObject.BazPolicy").toInt32()),
+             MyQObject::BazPolicy);
+
+    QCOMPARE(static_cast<MyQObject::Strategy>(m_engine->evaluate("MyQObject.FooStrategy").toInt32()),
+             MyQObject::FooStrategy);
+    QCOMPARE(static_cast<MyQObject::Strategy>(m_engine->evaluate("MyQObject.BarStrategy").toInt32()),
+             MyQObject::BarStrategy);
+    QCOMPARE(static_cast<MyQObject::Strategy>(m_engine->evaluate("MyQObject.BazStrategy").toInt32()),
+             MyQObject::BazStrategy);
+
+    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.NoAbility").toInt32()),
+             MyQObject::NoAbility);
+    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.FooAbility").toInt32()),
+             MyQObject::FooAbility);
+    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.BarAbility").toInt32()),
+             MyQObject::BarAbility);
+    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.BazAbility").toInt32()),
+             MyQObject::BazAbility);
+    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.AllAbility").toInt32()),
+             MyQObject::AllAbility);
+
+    QScriptValue::PropertyFlags expectedEnumFlags = QScriptValue::ReadOnly;
+    QCOMPARE(myClass.propertyFlags("FooPolicy"), expectedEnumFlags);
+    QCOMPARE(myClass.propertyFlags("BarPolicy"), expectedEnumFlags);
+    QCOMPARE(myClass.propertyFlags("BazPolicy"), expectedEnumFlags);
+
+    // enums from Qt are inherited through prototype
+    QCOMPARE(static_cast<Qt::FocusPolicy>(m_engine->evaluate("MyQObject.StrongFocus").toInt32()),
+             Qt::StrongFocus);
+    QCOMPARE(static_cast<Qt::Key>(m_engine->evaluate("MyQObject.Key_Left").toInt32()),
+             Qt::Key_Left);
+
+    QCOMPARE(m_engine->evaluate("MyQObject.className()").toString(), QLatin1String("MyQObject"));
+
+    qRegisterMetaType<MyQObject::Policy>("Policy");
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithEnumArg(MyQObject.BazPolicy)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 10);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::BazPolicy));
+
+    m_myObject->resetQtFunctionInvoked();
+    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithQualifiedEnumArg(MyQObject.BazPolicy)").isUndefined(), true);
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 36);
+    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::BazPolicy));
+
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningEnum()");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 37);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 0);
+        QCOMPARE(ret.isVariant(), true);
+    }
+    m_myObject->resetQtFunctionInvoked();
+    {
+        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningQualifiedEnum()");
+        QCOMPARE(m_myObject->qtFunctionInvoked(), 38);
+        QCOMPARE(m_myObject->qtFunctionActuals().size(), 0);
+        QCOMPARE(ret.isNumber(), true);
+    }
+}
+
+QT_BEGIN_NAMESPACE
+Q_SCRIPT_DECLARE_QMETAOBJECT(MyQObject, QObject*)
+Q_SCRIPT_DECLARE_QMETAOBJECT(QObject, QObject*)
+QT_END_NAMESPACE
+
+class ConstructorTest : public QObject
+{
+    Q_OBJECT
+public:
+    Q_INVOKABLE ConstructorTest(QObject *parent)
+        : QObject(parent)
+    {
+        setProperty("ctorIndex", 0);
+    }
+    Q_INVOKABLE ConstructorTest(int arg, QObject *parent = 0)
+        : QObject(parent)
+    {
+        setProperty("ctorIndex", 1);
+        setProperty("arg", arg);
+    }
+    Q_INVOKABLE ConstructorTest(const QString &arg, QObject *parent = 0)
+        : QObject(parent)
+    {
+        setProperty("ctorIndex", 2);
+        setProperty("arg", arg);
+    }
+    Q_INVOKABLE ConstructorTest(int arg, const QString &arg2, QObject *parent = 0)
+        : QObject(parent)
+    {
+        setProperty("ctorIndex", 3);
+        setProperty("arg", arg);
+        setProperty("arg2", arg2);
+    }
+    Q_INVOKABLE ConstructorTest(const QBrush &arg, QObject *parent = 0)
+        : QObject(parent)
+    {
+        setProperty("ctorIndex", 4);
+        setProperty("arg", arg);
+    }
+};
+
+void tst_QScriptExtQObject::classConstructor()
+{
+    QScriptValue myClass = qScriptValueFromQMetaObject<MyQObject>(m_engine);
+    m_engine->globalObject().setProperty("MyQObject", myClass);
+
+    QScriptValue myObj = m_engine->evaluate("myObj = MyQObject()");
+    QObject *qobj = myObj.toQObject();
+    QVERIFY(qobj != 0);
+    QCOMPARE(qobj->metaObject()->className(), "MyQObject");
+    QCOMPARE(qobj->parent(), (QObject *)0);
+
+    QScriptValue qobjectClass = qScriptValueFromQMetaObject<QObject>(m_engine);
+    m_engine->globalObject().setProperty("QObject", qobjectClass);
+
+    QScriptValue otherObj = m_engine->evaluate("otherObj = QObject(myObj)");
+    QObject *qqobj = otherObj.toQObject();
+    QVERIFY(qqobj != 0);
+    QCOMPARE(qqobj->metaObject()->className(), "QObject");
+    QCOMPARE(qqobj->parent(), qobj);
+
+    delete qobj;
+
+    // Q_INVOKABLE constructors
+    {
+        QScriptValue klazz = m_engine->newQMetaObject(&ConstructorTest::staticMetaObject);
+        {
+            QScriptValue obj = klazz.construct();
+            QVERIFY(obj.isError());
+            QCOMPARE(obj.toString(), QString::fromLatin1("SyntaxError: too few arguments in call to ConstructorTest(); candidates are\n"
+                                                         "    ConstructorTest(QBrush)\n"
+                                                         "    ConstructorTest(QBrush,QObject*)\n"
+                                                         "    ConstructorTest(int,QString)\n"
+                                                         "    ConstructorTest(int,QString,QObject*)\n"
+                                                         "    ConstructorTest(QString)\n"
+                                                         "    ConstructorTest(QString,QObject*)\n"
+                                                         "    ConstructorTest(int)\n"
+                                                         "    ConstructorTest(int,QObject*)\n"
+                                                         "    ConstructorTest(QObject*)"));
+        }
+        {
+            QObject objobj;
+            QScriptValue arg = m_engine->newQObject(&objobj);
+            QScriptValue obj = klazz.construct(QScriptValueList() << arg);
+            QVERIFY(!obj.isError());
+            QVERIFY(obj.instanceOf(klazz));
+            QVERIFY(obj.property("ctorIndex").isNumber());
+            QCOMPARE(obj.property("ctorIndex").toInt32(), 0);
+        }
+        {
+            int arg = 123;
+            QScriptValue obj = klazz.construct(QScriptValueList() << arg);
+            QVERIFY(!obj.isError());
+            QVERIFY(obj.instanceOf(klazz));
+            QVERIFY(obj.property("ctorIndex").isNumber());
+            QCOMPARE(obj.property("ctorIndex").toInt32(), 1);
+            QVERIFY(obj.property("arg").isNumber());
+            QCOMPARE(obj.property("arg").toInt32(), arg);
+        }
+        {
+            QString arg = "foo";
+            QScriptValue obj = klazz.construct(QScriptValueList() << arg);
+            QVERIFY(!obj.isError());
+            QVERIFY(obj.instanceOf(klazz));
+            QVERIFY(obj.property("ctorIndex").isNumber());
+            QCOMPARE(obj.property("ctorIndex").toInt32(), 2);
+            QVERIFY(obj.property("arg").isString());
+            QCOMPARE(obj.property("arg").toString(), arg);
+        }
+        {
+            int arg = 123;
+            QString arg2 = "foo";
+            QScriptValue obj = klazz.construct(QScriptValueList() << arg << arg2);
+            QVERIFY(!obj.isError());
+            QVERIFY(obj.instanceOf(klazz));
+            QVERIFY(obj.property("ctorIndex").isNumber());
+            QCOMPARE(obj.property("ctorIndex").toInt32(), 3);
+            QVERIFY(obj.property("arg").isNumber());
+            QCOMPARE(obj.property("arg").toInt32(), arg);
+            QVERIFY(obj.property("arg2").isString());
+            QCOMPARE(obj.property("arg2").toString(), arg2);
+        }
+        {
+            QBrush arg(Qt::red);
+            QScriptValue obj = klazz.construct(QScriptValueList() << qScriptValueFromValue(m_engine, arg));
+            QVERIFY(!obj.isError());
+            QVERIFY(obj.instanceOf(klazz));
+            QVERIFY(obj.property("ctorIndex").isNumber());
+            QCOMPARE(obj.property("ctorIndex").toInt32(), 4);
+            QVERIFY(obj.property("arg").isVariant());
+            QCOMPARE(qvariant_cast<QBrush>(obj.property("arg").toVariant()), arg);
+        }
+        {
+            QDir arg;
+            QScriptValue obj = klazz.construct(QScriptValueList()
+                                               << qScriptValueFromValue(m_engine, arg));
+            QVERIFY(obj.isError());
+            QCOMPARE(obj.toString(), QString::fromLatin1("TypeError: ambiguous call of overloaded function ConstructorTest(); candidates were\n"
+                                                         "    ConstructorTest(int)\n"
+                                                         "    ConstructorTest(QString)"));
+        }
+    }
+}
+
+void tst_QScriptExtQObject::overrideInvokable()
+{
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myInvokable()");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myInvokable = function() { global.a = 123; }");
+    m_engine->evaluate("myObject.myInvokable()");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+    QCOMPARE(m_engine->evaluate("global.a").toNumber(), 123.0);
+
+    m_engine->evaluate("myObject.myInvokable = function() { global.a = 456; }");
+    m_engine->evaluate("myObject.myInvokable()");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+    QCOMPARE(m_engine->evaluate("global.a").toNumber(), 456.0);
+
+    m_engine->evaluate("delete myObject.myInvokable");
+    m_engine->evaluate("myObject.myInvokable()");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myInvokable = myObject.myInvokableWithIntArg");
+    m_engine->evaluate("myObject.myInvokable(123)");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+
+    m_engine->evaluate("delete myObject.myInvokable");
+    m_myObject->resetQtFunctionInvoked();
+    // this form (with the '()') is read-only
+    m_engine->evaluate("myObject['myInvokable()'] = function() { global.a = 123; }");
+    m_engine->evaluate("myObject.myInvokable()");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+}
+
+void tst_QScriptExtQObject::transferInvokable()
+{
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.foozball = myObject.myInvokable");
+    m_engine->evaluate("myObject.foozball()");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.foozball = myObject.myInvokableWithIntArg");
+    m_engine->evaluate("myObject.foozball(123)");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myInvokable = myObject.myInvokableWithIntArg");
+    m_engine->evaluate("myObject.myInvokable(123)");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+
+    MyOtherQObject other;
+    m_engine->globalObject().setProperty(
+        "myOtherObject", m_engine->newQObject(&other));
+    m_engine->evaluate("myOtherObject.foo = myObject.foozball");
+    other.resetQtFunctionInvoked();
+    m_engine->evaluate("myOtherObject.foo(456)");
+    QCOMPARE(other.qtFunctionInvoked(), 1);
+}
+
+void tst_QScriptExtQObject::findChild()
+{
+    QObject *child = new QObject(m_myObject);
+    child->setObjectName(QLatin1String("myChildObject"));
+
+    {
+        QScriptValue result = m_engine->evaluate("myObject.findChild('noSuchChild')");
+        QCOMPARE(result.isNull(), true);
+    }
+
+    {    
+        QScriptValue result = m_engine->evaluate("myObject.findChild('myChildObject')");
+        QCOMPARE(result.isQObject(), true);
+        QCOMPARE(result.toQObject(), child);
+    }
+
+    delete child;
+}
+
+void tst_QScriptExtQObject::findChildren()
+{
+    QObject *child = new QObject(m_myObject);
+    child->setObjectName(QLatin1String("myChildObject"));
+
+    {
+        QScriptValue result = m_engine->evaluate("myObject.findChildren('noSuchChild')");
+        QCOMPARE(result.isArray(), true);
+        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 0.0);
+    }
+
+    {
+        QScriptValue result = m_engine->evaluate("myObject.findChildren('myChildObject')");
+        QCOMPARE(result.isArray(), true);
+        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 1.0);
+        QCOMPARE(result.property(QLatin1String("0")).toQObject(), child);
+    }
+
+    QObject *namelessChild = new QObject(m_myObject);
+
+    {
+        QScriptValue result = m_engine->evaluate("myObject.findChildren('myChildObject')");
+        QCOMPARE(result.isArray(), true);
+        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 1.0);
+        QCOMPARE(result.property(QLatin1String("0")).toQObject(), child);
+    }
+
+    QObject *anotherChild = new QObject(m_myObject);
+    anotherChild->setObjectName(QLatin1String("anotherChildObject"));
+
+    {
+        QScriptValue result = m_engine->evaluate("myObject.findChildren('anotherChildObject')");
+        QCOMPARE(result.isArray(), true);
+        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 1.0);
+        QCOMPARE(result.property(QLatin1String("0")).toQObject(), anotherChild);
+    }
+
+    anotherChild->setObjectName(QLatin1String("myChildObject"));
+    {
+        QScriptValue result = m_engine->evaluate("myObject.findChildren('myChildObject')");
+        QCOMPARE(result.isArray(), true);
+        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 2.0);
+        QObject *o1 = result.property(QLatin1String("0")).toQObject();
+        QObject *o2 = result.property(QLatin1String("1")).toQObject();
+        if (o1 != child) {
+            QCOMPARE(o1, anotherChild);
+            QCOMPARE(o2, child);
+        } else {
+            QCOMPARE(o1, child);
+            QCOMPARE(o2, anotherChild);
+        }
+    }
+
+    // find all
+    {
+        QScriptValue result = m_engine->evaluate("myObject.findChildren()");
+        QVERIFY(result.isArray());
+        int count = 3;
+        QCOMPARE(result.property("length").toInt32(), count);
+        for (int i = 0; i < 3; ++i) {
+            QObject *o = result.property(i).toQObject();
+            if (o == namelessChild || o == child || o == anotherChild)
+                --count;
+        }
+        QVERIFY(count == 0);
+    }
+
+    delete anotherChild;
+    delete namelessChild;
+    delete child;
+}
+
+void tst_QScriptExtQObject::overloadedSlots()
+{
+    // should pick myOverloadedSlot(double)
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myOverloadedSlot(10)");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 26);
+
+    // should pick myOverloadedSlot(double)
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myOverloadedSlot(10.0)");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 26);
+
+    // should pick myOverloadedSlot(QString)
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myOverloadedSlot('10')");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 29);
+
+    // should pick myOverloadedSlot(bool)
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myOverloadedSlot(true)");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 25);
+
+    // should pick myOverloadedSlot(QDateTime)
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myOverloadedSlot(new Date())");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 32);
+
+    // should pick myOverloadedSlot(QRegExp)
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myOverloadedSlot(new RegExp())");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 34);
+
+    // should pick myOverloadedSlot(QVariant)
+    m_myObject->resetQtFunctionInvoked();
+    QScriptValue f = m_engine->evaluate("myObject.myOverloadedSlot");
+    f.call(QScriptValue(), QScriptValueList() << m_engine->newVariant(QVariant("ciao")));
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 35);
+
+    // should pick myOverloadedSlot(QObject*)
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myOverloadedSlot(myObject)");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 41);
+
+    // should pick myOverloadedSlot(QObject*)
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myOverloadedSlot(null)");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 41);
+
+    // should pick myOverloadedSlot(QStringList)
+    m_myObject->resetQtFunctionInvoked();
+    m_engine->evaluate("myObject.myOverloadedSlot(['hello'])");
+    QCOMPARE(m_myObject->qtFunctionInvoked(), 42);
+}
+
+void tst_QScriptExtQObject::enumerate_data()
+{
+    QTest::addColumn<int>("wrapOptions");
+    QTest::addColumn<QStringList>("expectedNames");
+
+    QTest::newRow( "enumerate all" )
+        << 0
+        << (QStringList()
+            // meta-object-defined properties:
+            //   inherited
+            << "objectName"
+            //   non-inherited
+            << "p1" << "p2" << "p4" << "p6"
+            // dynamic properties
+            << "dp1" << "dp2" << "dp3"
+            // inherited slots
+            << "destroyed(QObject*)" << "destroyed()"
+            << "deleteLater()"
+            // not included because it's private:
+            // << "_q_reregisterTimers(void*)"
+            // signals
+            << "mySignal()"
+            // slots
+            << "mySlot()" << "myOtherSlot()");
+
+    QTest::newRow( "don't enumerate inherited properties" )
+        << int(QScriptEngine::ExcludeSuperClassProperties)
+        << (QStringList()
+            // meta-object-defined properties:
+            //   non-inherited
+            << "p1" << "p2" << "p4" << "p6"
+            // dynamic properties
+            << "dp1" << "dp2" << "dp3"
+            // inherited slots
+            << "destroyed(QObject*)" << "destroyed()"
+            << "deleteLater()"
+            // not included because it's private:
+            // << "_q_reregisterTimers(void*)"
+            // signals
+            << "mySignal()"
+            // slots
+            << "mySlot()" << "myOtherSlot()");
+
+    QTest::newRow( "don't enumerate inherited methods" )
+        << int(QScriptEngine::ExcludeSuperClassMethods)
+        << (QStringList()
+            // meta-object-defined properties:
+            //   inherited
+            << "objectName"
+            //   non-inherited
+            << "p1" << "p2" << "p4" << "p6"
+            // dynamic properties
+            << "dp1" << "dp2" << "dp3"
+            // signals
+            << "mySignal()"
+            // slots
+            << "mySlot()" << "myOtherSlot()");
+
+    QTest::newRow( "don't enumerate inherited members" )
+        << int(QScriptEngine::ExcludeSuperClassMethods
+               | QScriptEngine::ExcludeSuperClassProperties)
+        << (QStringList()
+            // meta-object-defined properties
+            << "p1" << "p2" << "p4" << "p6"
+            // dynamic properties
+            << "dp1" << "dp2" << "dp3"
+            // signals
+            << "mySignal()"
+            // slots
+            << "mySlot()" << "myOtherSlot()");
+
+    QTest::newRow( "enumerate properties, not methods" )
+        << int(QScriptEngine::SkipMethodsInEnumeration)
+        << (QStringList()
+            // meta-object-defined properties:
+            //   inherited
+            << "objectName"
+            //   non-inherited
+            << "p1" << "p2" << "p4" << "p6"
+            // dynamic properties
+            << "dp1" << "dp2" << "dp3");
+
+    QTest::newRow( "don't enumerate inherited properties + methods" )
+        << int(QScriptEngine::ExcludeSuperClassProperties
+            | QScriptEngine::SkipMethodsInEnumeration)
+        << (QStringList()
+            // meta-object-defined properties:
+            //   non-inherited
+            << "p1" << "p2" << "p4" << "p6"
+            // dynamic properties
+            << "dp1" << "dp2" << "dp3");
+
+    QTest::newRow( "don't enumerate inherited members" )
+        << int(QScriptEngine::ExcludeSuperClassContents)
+        << (QStringList()
+            // meta-object-defined properties
+            << "p1" << "p2" << "p4" << "p6"
+            // dynamic properties
+            << "dp1" << "dp2" << "dp3"
+            // signals
+            << "mySignal()"
+            // slots
+            << "mySlot()" << "myOtherSlot()");
+
+    QTest::newRow( "don't enumerate deleteLater()" )
+        << int(QScriptEngine::ExcludeDeleteLater)
+        << (QStringList()
+            // meta-object-defined properties:
+            //   inherited
+            << "objectName"
+            //   non-inherited
+            << "p1" << "p2" << "p4" << "p6"
+            // dynamic properties
+            << "dp1" << "dp2" << "dp3"
+            // inherited slots
+            << "destroyed(QObject*)" << "destroyed()"
+            // not included because it's private:
+            // << "_q_reregisterTimers(void*)"
+            // signals
+            << "mySignal()"
+            // slots
+            << "mySlot()" << "myOtherSlot()");
+}
+
+void tst_QScriptExtQObject::enumerate()
+{
+    QFETCH( int, wrapOptions );
+    QFETCH( QStringList, expectedNames );
+
+    QScriptEngine eng;
+    MyEnumTestQObject enumQObject;
+    // give it some dynamic properties
+    enumQObject.setProperty("dp1", "dp1");
+    enumQObject.setProperty("dp2", "dp2");
+    enumQObject.setProperty("dp3", "dp3");
+    QScriptValue obj = eng.newQObject(&enumQObject, QScriptEngine::QtOwnership,
+                                      QScriptEngine::QObjectWrapOptions(wrapOptions));
+
+    // enumerate in script
+    {
+        eng.globalObject().setProperty("myEnumObject", obj);
+        eng.evaluate("var enumeratedProperties = []");
+        eng.evaluate("for (var p in myEnumObject) { enumeratedProperties.push(p); }");
+        QStringList result = qscriptvalue_cast<QStringList>(eng.evaluate("enumeratedProperties"));
+        QCOMPARE(result.size(), expectedNames.size());
+        for (int i = 0; i < expectedNames.size(); ++i)
+            QCOMPARE(result.at(i), expectedNames.at(i));
+    }
+    // enumerate in C++
+    {
+        QScriptValueIterator it(obj);
+        QStringList result;
+        while (it.hasNext()) {
+            it.next();
+            QCOMPARE(it.flags(), obj.propertyFlags(it.name()));
+            result.append(it.name());
+        }
+        QCOMPARE(result.size(), expectedNames.size());
+        for (int i = 0; i < expectedNames.size(); ++i)
+            QCOMPARE(result.at(i), expectedNames.at(i));
+    }
+}
+
+class SpecialEnumTestObject : public QObject
+{
+    Q_OBJECT
+    // overriding a property in the super-class to make it non-scriptable
+    Q_PROPERTY(QString objectName READ objectName SCRIPTABLE false)
+public:
+    SpecialEnumTestObject(QObject *parent = 0)
+        : QObject(parent) {}
+};
+
+class SpecialEnumTestObject2 : public QObject
+{
+    Q_OBJECT
+    // overriding a property in the super-class to make it non-designable (but still scriptable)
+    Q_PROPERTY(QString objectName READ objectName DESIGNABLE false)
+public:
+    SpecialEnumTestObject2(QObject *parent = 0)
+        : QObject(parent) {}
+};
+
+void tst_QScriptExtQObject::enumerateSpecial()
+{
+    QScriptEngine eng;
+    {
+        SpecialEnumTestObject testObj;
+        QScriptValueIterator it(eng.newQObject(&testObj));
+        bool objectNameEncountered = false;
+        while (it.hasNext()) {
+            it.next();
+            if (it.name() == QLatin1String("objectName")) {
+                objectNameEncountered = true;
+                break;
+            }
+        }
+        QVERIFY(!objectNameEncountered);
+    }
+    {
+        SpecialEnumTestObject2 testObj;
+        testObj.setObjectName("foo");
+        QScriptValueList values;
+        QScriptValueIterator it(eng.newQObject(&testObj));
+        while (it.hasNext()) {
+            it.next();
+            if (it.name() == "objectName")
+                values.append(it.value());
+        }
+        QCOMPARE(values.size(), 1);
+        QCOMPARE(values.at(0).toString(), QString::fromLatin1("foo"));
+    }
+}
+
+void tst_QScriptExtQObject::wrapOptions()
+{
+    QCOMPARE(m_myObject->setProperty("dynamicProperty", 123), false);
+    MyQObject *child = new MyQObject(m_myObject);
+    child->setObjectName("child");
+    // exclude child objects
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
+                                                QScriptEngine::ExcludeChildObjects);
+        QCOMPARE(obj.property("child").isValid(), false);
+        obj.setProperty("child", QScriptValue(m_engine, 123));
+        QCOMPARE(obj.property("child")
+                 .strictlyEquals(QScriptValue(m_engine, 123)), true);
+    }
+    // don't auto-create dynamic properties
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject);
+        QVERIFY(!m_myObject->dynamicPropertyNames().contains("anotherDynamicProperty"));
+        obj.setProperty("anotherDynamicProperty", QScriptValue(m_engine, 123));
+        QVERIFY(!m_myObject->dynamicPropertyNames().contains("anotherDynamicProperty"));
+        QCOMPARE(obj.property("anotherDynamicProperty")
+                 .strictlyEquals(QScriptValue(m_engine, 123)), true);
+    }
+    // auto-create dynamic properties
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
+                                                QScriptEngine::AutoCreateDynamicProperties);
+        QVERIFY(!m_myObject->dynamicPropertyNames().contains("anotherDynamicProperty"));
+        obj.setProperty("anotherDynamicProperty", QScriptValue(m_engine, 123));
+        QVERIFY(m_myObject->dynamicPropertyNames().contains("anotherDynamicProperty"));
+        QCOMPARE(obj.property("anotherDynamicProperty")
+                 .strictlyEquals(QScriptValue(m_engine, 123)), true);
+        // task 236685
+        {
+            QScriptValue obj2 = m_engine->newObject();
+            obj2.setProperty("notADynamicProperty", 456);
+            obj.setPrototype(obj2);
+            QScriptValue ret = obj.property("notADynamicProperty");
+            QVERIFY(ret.isNumber());
+            QVERIFY(ret.strictlyEquals(obj2.property("notADynamicProperty")));
+        }
+    }
+    // don't exclude super-class properties
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject);
+        QVERIFY(obj.property("objectName").isValid());
+        QVERIFY(obj.propertyFlags("objectName") & QScriptValue::QObjectMember);
+    }
+    // exclude super-class properties
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
+                                                QScriptEngine::ExcludeSuperClassProperties);
+        QVERIFY(!obj.property("objectName").isValid());
+        QVERIFY(!(obj.propertyFlags("objectName") & QScriptValue::QObjectMember));
+        QVERIFY(obj.property("intProperty").isValid());
+        QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
+    }
+    // don't exclude super-class methods
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject);
+        QVERIFY(obj.property("deleteLater").isValid());
+        QVERIFY(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember);
+    }
+    // exclude super-class methods
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
+                                                QScriptEngine::ExcludeSuperClassMethods);
+        QVERIFY(!obj.property("deleteLater").isValid());
+        QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
+        QVERIFY(obj.property("mySlot").isValid());
+        QVERIFY(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
+    }
+    // exclude all super-class contents
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
+                                                QScriptEngine::ExcludeSuperClassContents);
+        QVERIFY(!obj.property("deleteLater").isValid());
+        QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
+        QVERIFY(obj.property("mySlot").isValid());
+        QVERIFY(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
+
+        QVERIFY(!obj.property("objectName").isValid());
+        QVERIFY(!(obj.propertyFlags("objectName") & QScriptValue::QObjectMember));
+        QVERIFY(obj.property("intProperty").isValid());
+        QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
+    }
+    // exclude deleteLater()
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
+                                                QScriptEngine::ExcludeDeleteLater);
+        QVERIFY(!obj.property("deleteLater").isValid());
+        QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
+        QVERIFY(obj.property("mySlot").isValid());
+        QVERIFY(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
+
+        QVERIFY(obj.property("objectName").isValid());
+        QVERIFY(obj.propertyFlags("objectName") & QScriptValue::QObjectMember);
+        QVERIFY(obj.property("intProperty").isValid());
+        QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
+    }
+    // exclude all that we can
+    {
+        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
+                                                QScriptEngine::ExcludeSuperClassMethods
+                                                | QScriptEngine::ExcludeSuperClassProperties
+                                                | QScriptEngine::ExcludeChildObjects);
+        QVERIFY(!obj.property("deleteLater").isValid());
+        QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
+        QVERIFY(obj.property("mySlot").isValid());
+        QVERIFY(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
+
+        QVERIFY(!obj.property("objectName").isValid());
+        QVERIFY(!(obj.propertyFlags("objectName") & QScriptValue::QObjectMember));
+        QVERIFY(obj.property("intProperty").isValid());
+        QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
+
+        QCOMPARE(obj.property("child").isValid(), false);
+        obj.setProperty("child", QScriptValue(m_engine, 123));
+        QCOMPARE(obj.property("child")
+                 .strictlyEquals(QScriptValue(m_engine, 123)), true);
+    }
+
+    delete child;
+}
+
+Q_DECLARE_METATYPE(QWidget*)
+Q_DECLARE_METATYPE(QPushButton*)
+
+void tst_QScriptExtQObject::prototypes()
+{
+    QScriptEngine eng;
+    QScriptValue widgetProto = eng.newQObject(new QWidget(), QScriptEngine::ScriptOwnership);
+    eng.setDefaultPrototype(qMetaTypeId<QWidget*>(), widgetProto);
+    QPushButton *pbp = new QPushButton();
+    QScriptValue buttonProto = eng.newQObject(pbp, QScriptEngine::ScriptOwnership);
+    buttonProto.setPrototype(widgetProto);
+    eng.setDefaultPrototype(qMetaTypeId<QPushButton*>(), buttonProto);
+    QPushButton *pb = new QPushButton();
+    QScriptValue button = eng.newQObject(pb, QScriptEngine::ScriptOwnership);
+    QVERIFY(button.prototype().strictlyEquals(buttonProto));
+
+    buttonProto.setProperty("text", QScriptValue(&eng, "prototype button"));
+    QCOMPARE(pbp->text(), QLatin1String("prototype button"));
+    button.setProperty("text", QScriptValue(&eng, "not the prototype button"));
+    QCOMPARE(pb->text(), QLatin1String("not the prototype button"));
+    QCOMPARE(pbp->text(), QLatin1String("prototype button"));
+
+    buttonProto.setProperty("objectName", QScriptValue(&eng, "prototype button"));
+    QCOMPARE(pbp->objectName(), QLatin1String("prototype button"));
+    button.setProperty("objectName", QScriptValue(&eng, "not the prototype button"));
+    QCOMPARE(pb->objectName(), QLatin1String("not the prototype button"));
+    QCOMPARE(pbp->objectName(), QLatin1String("prototype button"));
+}
+
+void tst_QScriptExtQObject::objectDeleted()
+{
+    QScriptEngine eng;
+    MyQObject *qobj = new MyQObject();
+    QScriptValue v = eng.newQObject(qobj);
+    v.setProperty("objectName", QScriptValue(&eng, "foo"));
+    QCOMPARE(qobj->objectName(), QLatin1String("foo"));
+    v.setProperty("intProperty", QScriptValue(&eng, 123));
+    QCOMPARE(qobj->intProperty(), 123);
+    qobj->resetQtFunctionInvoked();
+    v.property("myInvokable").call(v);
+    QCOMPARE(qobj->qtFunctionInvoked(), 0);
+
+    // now delete the object
+    delete qobj;
+
+    // the documented behavior is: isQObject() should still return true,
+    // but toQObject() should return 0
+    QVERIFY(v.isQObject());
+    QCOMPARE(v.toQObject(), (QObject *)0);
+
+    // any attempt to access properties of the object should result in an exception
+    {
+        QScriptValue ret = v.property("objectName");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: cannot access member `objectName' of deleted QObject"));
+    }
+    {
+        eng.evaluate("Object");
+        QVERIFY(!eng.hasUncaughtException());
+        v.setProperty("objectName", QScriptValue(&eng, "foo"));
+        QVERIFY(eng.hasUncaughtException());
+        QVERIFY(eng.uncaughtException().isError());
+        QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: cannot access member `objectName' of deleted QObject"));
+    }
+
+    {
+        QScriptValue ret = v.call();
+        QVERIFY(!ret.isValid());
+    }
+
+    // myInvokable is stored in member table (since we've accessed it before deletion)
+    QVERIFY(v.property("myInvokable").isFunction());
+    {
+        QScriptValue ret = v.property("myInvokable").call(v);
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: cannot call function of deleted QObject"));
+    }
+    // myInvokableWithIntArg is not stored in member table (since we've not accessed it)
+    {
+        QScriptValue ret = v.property("myInvokableWithIntArg");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject"));
+    }
+
+    // access from script
+    eng.globalObject().setProperty("o", v);
+    {
+        QScriptValue ret = eng.evaluate("o()");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("TypeError: o is not a function"));
+    }
+    {
+        QScriptValue ret = eng.evaluate("o.objectName");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: cannot access member `objectName' of deleted QObject"));
+    }
+    {
+        QScriptValue ret = eng.evaluate("o.myInvokable()");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: cannot call function of deleted QObject"));
+    }
+    {
+        QScriptValue ret = eng.evaluate("o.myInvokableWithIntArg(10)");
+        QVERIFY(ret.isError());
+        QCOMPARE(ret.toString(), QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject"));
+    }
+}
+
+void tst_QScriptExtQObject::connectToDestroyedSignal()
+{
+    // ### the following test currently depends on signal emission order
+#if 0
+    {
+        // case 1: deleted when the engine is not doing GC
+        QScriptEngine eng;
+        QObject *obj = new QObject();
+        eng.globalObject().setProperty("o", eng.newQObject(obj, QScriptEngine::QtOwnership));
+        eng.evaluate("o.destroyed.connect(function() { wasDestroyed = true; })");
+        eng.evaluate("wasDestroyed = false");
+        delete obj;
+        QVERIFY(eng.evaluate("wasDestroyed").toBoolean());
+    }
+    {
+        // case 2: deleted when the engine is doing GC
+        QScriptEngine eng;
+        QObject *obj = new QObject();
+        eng.globalObject().setProperty("o", eng.newQObject(obj, QScriptEngine::ScriptOwnership));
+        eng.evaluate("o.destroyed.connect(function() { wasDestroyed = true; })");
+        eng.evaluate("wasDestroyed = false");
+        eng.evaluate("o = null");
+        eng.collectGarbage();
+        QVERIFY(eng.evaluate("wasDestroyed").toBoolean());
+    }
+    {
+        // case 3: deleted when the engine is destroyed
+        QScriptEngine eng;
+        QObject *obj = new QObject();
+        eng.globalObject().setProperty("o", eng.newQObject(obj, QScriptEngine::ScriptOwnership));
+        eng.evaluate("o.destroyed.connect(function() { })");
+        // the signal handler won't get called -- we don't want to crash
+    }
+#endif
+}
+
+QTEST_MAIN(tst_QScriptExtQObject)
+#include "tst_qscriptextqobject.moc"
diff --git a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp
index 66004f8..4f6f38e 100644
--- a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp
+++ b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp
@@ -785,6 +785,8 @@ tst_Suite::tst_Suite()
     addFileExclusion("regress-322135-04.js", "takes forever");
     addFileExclusion("ecma_3/RegExp/regress-375715-04.js", "bug");
 
+    static const char klass[] = "tst_QScriptJsTestSuite";
+
     QVector<uint> *data = qt_meta_data_tst_Suite();
     // content:
     *data << 1 // revision
@@ -796,7 +798,7 @@ tst_Suite::tst_Suite()
         ;
 
     QVector<char> *stringdata = qt_meta_stringdata_tst_Suite();
-    appendCString(stringdata, "tst_Suite");
+    appendCString(stringdata, klass);
     appendCString(stringdata, "");
 
 // don't execute any tests on slow machines
@@ -814,11 +816,12 @@ tst_Suite::tst_Suite()
             // slot: signature, parameters, type, tag, flags
             QString data_slot = QString::fromLatin1("%0/%1_data()")
                            .arg(testSuiteDir.dirName()).arg(ssdi.fileName());
-            *data << stringdata->size() << 10 << 10 << 10 << 0x08;
+            static const int nullbyte = sizeof(klass);
+            *data << stringdata->size() << nullbyte << nullbyte << nullbyte << 0x08;
             appendCString(stringdata, data_slot.toLatin1());
             QString slot = QString::fromLatin1("%0/%1()")
                            .arg(testSuiteDir.dirName()).arg(ssdi.fileName());
-            *data << stringdata->size() << 10 << 10 << 10 << 0x08;
+            *data << stringdata->size() << nullbyte << nullbyte << nullbyte << 0x08;
             appendCString(stringdata, slot.toLatin1());
         }
     }
diff --git a/tests/auto/qscriptqobject/.gitignore b/tests/auto/qscriptqobject/.gitignore
deleted file mode 100644
index bff799f..0000000
--- a/tests/auto/qscriptqobject/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tst_qscriptqobject
diff --git a/tests/auto/qscriptqobject/qscriptqobject.pro b/tests/auto/qscriptqobject/qscriptqobject.pro
deleted file mode 100644
index e4e2b56..0000000
--- a/tests/auto/qscriptqobject/qscriptqobject.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-QT += script
-SOURCES  += tst_qscriptqobject.cpp
-
-
diff --git a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
deleted file mode 100644
index 73400b2..0000000
--- a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp
+++ /dev/null
@@ -1,2734 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite 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 either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest/QtTest>
-
-#include <qscriptengine.h>
-#include <qscriptcontext.h>
-#include <qscriptvalueiterator.h>
-#include <qwidget.h>
-#include <qpushbutton.h>
-#include <qlineedit.h>
-
-//TESTED_CLASS=
-//TESTED_FILES=script/qscriptextqobject_p.h script/qscriptextqobject.cpp
-
-struct CustomType
-{
-    QString string;
-};
-Q_DECLARE_METATYPE(CustomType)
-
-Q_DECLARE_METATYPE(QBrush*)
-Q_DECLARE_METATYPE(QObjectList)
-Q_DECLARE_METATYPE(QList<int>)
-Q_DECLARE_METATYPE(Qt::BrushStyle)
-Q_DECLARE_METATYPE(QDir)
-
-static void dirFromScript(const QScriptValue &in, QDir &out)
-{
-    QScriptValue path = in.property("path");
-    if (!path.isValid())
-        in.engine()->currentContext()->throwError("No path");
-    else
-        out.setPath(path.toString());
-}
-
-namespace MyNS
-{
-    class A : public QObject
-    {
-        Q_OBJECT
-    public:
-        enum Type {
-            Foo,
-            Bar
-        };
-        Q_ENUMS(Type)
-    public Q_SLOTS:
-        int slotTakingScopedEnumArg(MyNS::A::Type t) {
-            return t;
-        }
-    };
-}
-
-class MyQObject : public QObject
-{
-    Q_OBJECT
-
-    Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
-    Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
-    Q_PROPERTY(QVariantList variantListProperty READ variantListProperty WRITE setVariantListProperty)
-    Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
-    Q_PROPERTY(QStringList stringListProperty READ stringListProperty WRITE setStringListProperty)
-    Q_PROPERTY(QByteArray byteArrayProperty READ byteArrayProperty WRITE setByteArrayProperty)
-    Q_PROPERTY(QBrush brushProperty READ brushProperty WRITE setBrushProperty)
-    Q_PROPERTY(double hiddenProperty READ hiddenProperty WRITE setHiddenProperty SCRIPTABLE false)
-    Q_PROPERTY(int writeOnlyProperty WRITE setWriteOnlyProperty)
-    Q_PROPERTY(int readOnlyProperty READ readOnlyProperty)
-    Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
-    Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType)
-    Q_ENUMS(Policy Strategy)
-    Q_FLAGS(Ability)
-
-public:
-    enum Policy {
-        FooPolicy = 0,
-        BarPolicy,
-        BazPolicy
-    };
-
-    enum Strategy {
-        FooStrategy = 10,
-        BarStrategy,
-        BazStrategy
-    };
-
-    enum AbilityFlag {
-        NoAbility  = 0x000,
-        FooAbility = 0x001,
-        BarAbility = 0x080,
-        BazAbility = 0x200,
-        AllAbility = FooAbility | BarAbility | BazAbility
-    };
-
-    Q_DECLARE_FLAGS(Ability, AbilityFlag)
-
-    MyQObject(QObject *parent = 0)
-        : QObject(parent),
-          m_intValue(123),
-          m_variantValue(QLatin1String("foo")),
-          m_variantListValue(QVariantList() << QVariant(123) << QVariant(QLatin1String("foo"))),
-          m_stringValue(QLatin1String("bar")),
-          m_stringListValue(QStringList() << QLatin1String("zig") << QLatin1String("zag")),
-          m_brushValue(QColor(10, 20, 30, 40)),
-          m_hiddenValue(456.0),
-          m_writeOnlyValue(789),
-          m_readOnlyValue(987),
-          m_qtFunctionInvoked(-1)
-        { }
-
-    int intProperty() const
-        { return m_intValue; }
-    void setIntProperty(int value)
-        { m_intValue = value; }
-
-    QVariant variantProperty() const
-        { return m_variantValue; }
-    void setVariantProperty(const QVariant &value)
-        { m_variantValue = value; }
-
-    QVariantList variantListProperty() const
-        { return m_variantListValue; }
-    void setVariantListProperty(const QVariantList &value)
-        { m_variantListValue = value; }
-
-    QString stringProperty() const
-        { return m_stringValue; }
-    void setStringProperty(const QString &value)
-        { m_stringValue = value; }
-
-    QStringList stringListProperty() const
-        { return m_stringListValue; }
-    void setStringListProperty(const QStringList &value)
-        { m_stringListValue = value; }
-
-    QByteArray byteArrayProperty() const
-        { return m_byteArrayValue; }
-    void setByteArrayProperty(const QByteArray &value)
-        { m_byteArrayValue = value; }
-
-    QBrush brushProperty() const
-        { return m_brushValue; }
-    Q_INVOKABLE void setBrushProperty(const QBrush &value)
-        { m_brushValue = value; }
-
-    double hiddenProperty() const
-        { return m_hiddenValue; }
-    void setHiddenProperty(double value)
-        { m_hiddenValue = value; }
-
-    int writeOnlyProperty() const
-        { return m_writeOnlyValue; }
-    void setWriteOnlyProperty(int value)
-        { m_writeOnlyValue = value; }
-
-    int readOnlyProperty() const
-        { return m_readOnlyValue; }
-
-    QKeySequence shortcut() const
-        { return m_shortcut; }
-    void setShortcut(const QKeySequence &seq)
-        { m_shortcut = seq; }
-
-    CustomType propWithCustomType() const
-        { return m_customType; }
-    void setPropWithCustomType(const CustomType &c)
-        { m_customType = c; }
-
-    int qtFunctionInvoked() const
-        { return m_qtFunctionInvoked; }
-
-    QVariantList qtFunctionActuals() const
-        { return m_actuals; }
-
-    void resetQtFunctionInvoked()
-        { m_qtFunctionInvoked = -1; m_actuals.clear(); }
-
-    void clearConnectedSignal()
-        { m_connectedSignal = QByteArray(); }
-    void clearDisconnectedSignal()
-        { m_disconnectedSignal = QByteArray(); }
-    QByteArray connectedSignal() const
-        { return m_connectedSignal; }
-    QByteArray disconnectedSignal() const
-        { return m_disconnectedSignal; }
-
-    Q_INVOKABLE void myInvokable()
-        { m_qtFunctionInvoked = 0; }
-    Q_INVOKABLE void myInvokableWithIntArg(int arg)
-        { m_qtFunctionInvoked = 1; m_actuals << arg; }
-    Q_INVOKABLE void myInvokableWithLonglongArg(qlonglong arg)
-        { m_qtFunctionInvoked = 2; m_actuals << arg; }
-    Q_INVOKABLE void myInvokableWithFloatArg(float arg)
-        { m_qtFunctionInvoked = 3; m_actuals << arg; }
-    Q_INVOKABLE void myInvokableWithDoubleArg(double arg)
-        { m_qtFunctionInvoked = 4; m_actuals << arg; }
-    Q_INVOKABLE void myInvokableWithStringArg(const QString &arg)
-        { m_qtFunctionInvoked = 5; m_actuals << arg; }
-    Q_INVOKABLE void myInvokableWithIntArgs(int arg1, int arg2)
-        { m_qtFunctionInvoked = 6; m_actuals << arg1 << arg2; }
-    Q_INVOKABLE int myInvokableReturningInt()
-        { m_qtFunctionInvoked = 7; return 123; }
-    Q_INVOKABLE qlonglong myInvokableReturningLongLong()
-        { m_qtFunctionInvoked = 39; return 456; }
-    Q_INVOKABLE QString myInvokableReturningString()
-        { m_qtFunctionInvoked = 8; return QLatin1String("ciao"); }
-    Q_INVOKABLE QVariant myInvokableReturningVariant()
-        { m_qtFunctionInvoked = 60; return 123; }
-    Q_INVOKABLE QScriptValue myInvokableReturningScriptValue()
-        { m_qtFunctionInvoked = 61; return 456; }
-    Q_INVOKABLE void myInvokableWithIntArg(int arg1, int arg2) // overload
-        { m_qtFunctionInvoked = 9; m_actuals << arg1 << arg2; }
-    Q_INVOKABLE void myInvokableWithEnumArg(Policy policy)
-        { m_qtFunctionInvoked = 10; m_actuals << policy; }
-    Q_INVOKABLE void myInvokableWithQualifiedEnumArg(MyQObject::Policy policy)
-        { m_qtFunctionInvoked = 36; m_actuals << policy; }
-    Q_INVOKABLE Policy myInvokableReturningEnum()
-        { m_qtFunctionInvoked = 37; return BazPolicy; }
-    Q_INVOKABLE MyQObject::Policy myInvokableReturningQualifiedEnum()
-        { m_qtFunctionInvoked = 38; return BazPolicy; }
-    Q_INVOKABLE QVector<int> myInvokableReturningVectorOfInt()
-        { m_qtFunctionInvoked = 11; return QVector<int>(); }
-    Q_INVOKABLE void myInvokableWithVectorOfIntArg(const QVector<int> &)
-        { m_qtFunctionInvoked = 12; }
-    Q_INVOKABLE QObject *myInvokableReturningQObjectStar()
-        { m_qtFunctionInvoked = 13; return this; }
-    Q_INVOKABLE QObjectList myInvokableWithQObjectListArg(const QObjectList &lst)
-        { m_qtFunctionInvoked = 14; m_actuals << qVariantFromValue(lst); return lst; }
-    Q_INVOKABLE QVariant myInvokableWithVariantArg(const QVariant &v)
-        { m_qtFunctionInvoked = 15; m_actuals << v; return v; }
-    Q_INVOKABLE QVariantMap myInvokableWithVariantMapArg(const QVariantMap &vm)
-        { m_qtFunctionInvoked = 16; m_actuals << vm; return vm; }
-    Q_INVOKABLE QList<int> myInvokableWithListOfIntArg(const QList<int> &lst)
-        { m_qtFunctionInvoked = 17; m_actuals << qVariantFromValue(lst); return lst; }
-    Q_INVOKABLE QObject* myInvokableWithQObjectStarArg(QObject *obj)
-        { m_qtFunctionInvoked = 18; m_actuals << qVariantFromValue(obj); return obj; }
-    Q_INVOKABLE QBrush myInvokableWithQBrushArg(const QBrush &brush)
-        { m_qtFunctionInvoked = 19; m_actuals << qVariantFromValue(brush); return brush; }
-    Q_INVOKABLE void myInvokableWithBrushStyleArg(Qt::BrushStyle style)
-        { m_qtFunctionInvoked = 43; m_actuals << qVariantFromValue(style); }
-    Q_INVOKABLE void myInvokableWithVoidStarArg(void *arg)
-        { m_qtFunctionInvoked = 44; m_actuals << qVariantFromValue(arg); }
-    Q_INVOKABLE void myInvokableWithAmbiguousArg(int arg)
-        { m_qtFunctionInvoked = 45; m_actuals << qVariantFromValue(arg); }
-    Q_INVOKABLE void myInvokableWithAmbiguousArg(uint arg)
-        { m_qtFunctionInvoked = 46; m_actuals << qVariantFromValue(arg); }
-    Q_INVOKABLE void myInvokableWithDefaultArgs(int arg1, const QString &arg2 = "")
-        { m_qtFunctionInvoked = 47; m_actuals << qVariantFromValue(arg1) << qVariantFromValue(arg2); }
-    Q_INVOKABLE QObject& myInvokableReturningRef()
-        { m_qtFunctionInvoked = 48; return *this; }
-    Q_INVOKABLE const QObject& myInvokableReturningConstRef() const
-        { const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 49; return *this; }
-    Q_INVOKABLE void myInvokableWithPointArg(const QPoint &arg)
-        { const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 50; m_actuals << qVariantFromValue(arg); }
-    Q_INVOKABLE void myInvokableWithPointArg(const QPointF &arg)
-        { const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 51; m_actuals << qVariantFromValue(arg); }
-    Q_INVOKABLE void myInvokableWithMyQObjectArg(MyQObject *arg)
-        { m_qtFunctionInvoked = 52; m_actuals << qVariantFromValue((QObject*)arg); }
-    Q_INVOKABLE MyQObject* myInvokableReturningMyQObject()
-        { m_qtFunctionInvoked = 53; return this; }
-    Q_INVOKABLE void myInvokableWithConstMyQObjectArg(const MyQObject *arg)
-        { m_qtFunctionInvoked = 54; m_actuals << qVariantFromValue((QObject*)arg); }
-    Q_INVOKABLE void myInvokableWithQDirArg(const QDir &arg)
-        { m_qtFunctionInvoked = 55; m_actuals << qVariantFromValue(arg); }
-    Q_INVOKABLE QScriptValue myInvokableWithScriptValueArg(const QScriptValue &arg)
-        { m_qtFunctionInvoked = 56; return arg; }
-    Q_INVOKABLE QObject* myInvokableReturningMyQObjectAsQObject()
-        { m_qtFunctionInvoked = 57; return this; }
-
-    void emitMySignal()
-        { emit mySignal(); }
-    void emitMySignalWithIntArg(int arg)
-        { emit mySignalWithIntArg(arg); }
-    void emitMySignal2(bool arg)
-        { emit mySignal2(arg); }
-    void emitMySignal2()
-        { emit mySignal2(); }
-    void emitMyOverloadedSignal(int arg)
-        { emit myOverloadedSignal(arg); }
-    void emitMyOverloadedSignal(const QString &arg)
-        { emit myOverloadedSignal(arg); }
-    void emitMyOtherOverloadedSignal(const QString &arg)
-        { emit myOtherOverloadedSignal(arg); }
-    void emitMyOtherOverloadedSignal(int arg)
-        { emit myOtherOverloadedSignal(arg); }
-    void emitMySignalWithDefaultArgWithArg(int arg)
-        { emit mySignalWithDefaultArg(arg); }
-    void emitMySignalWithDefaultArg()
-        { emit mySignalWithDefaultArg(); }
-
-public Q_SLOTS:
-    void mySlot()
-        { m_qtFunctionInvoked = 20; }
-    void mySlotWithIntArg(int arg)
-        { m_qtFunctionInvoked = 21; m_actuals << arg; }
-    void mySlotWithDoubleArg(double arg)
-        { m_qtFunctionInvoked = 22; m_actuals << arg; }
-    void mySlotWithStringArg(const QString &arg)
-        { m_qtFunctionInvoked = 23; m_actuals << arg; }
-
-    void myOverloadedSlot()
-        { m_qtFunctionInvoked = 24; }
-    void myOverloadedSlot(QObject *arg)
-        { m_qtFunctionInvoked = 41; m_actuals << qVariantFromValue(arg); }
-    void myOverloadedSlot(bool arg)
-        { m_qtFunctionInvoked = 25; m_actuals << arg; }
-    void myOverloadedSlot(const QStringList &arg)
-        { m_qtFunctionInvoked = 42; m_actuals << arg; }
-    void myOverloadedSlot(double arg)
-        { m_qtFunctionInvoked = 26; m_actuals << arg; }
-    void myOverloadedSlot(float arg)
-        { m_qtFunctionInvoked = 27; m_actuals << arg; }
-    void myOverloadedSlot(int arg)
-        { m_qtFunctionInvoked = 28; m_actuals << arg; }
-    void myOverloadedSlot(const QString &arg)
-        { m_qtFunctionInvoked = 29; m_actuals << arg; }
-    void myOverloadedSlot(const QColor &arg)
-        { m_qtFunctionInvoked = 30; m_actuals << arg; }
-    void myOverloadedSlot(const QBrush &arg)
-        { m_qtFunctionInvoked = 31; m_actuals << arg; }
-    void myOverloadedSlot(const QDateTime &arg)
-        { m_qtFunctionInvoked = 32; m_actuals << arg; }
-    void myOverloadedSlot(const QDate &arg)
-        { m_qtFunctionInvoked = 33; m_actuals << arg; }
-    void myOverloadedSlot(const QRegExp &arg)
-        { m_qtFunctionInvoked = 34; m_actuals << arg; }
-    void myOverloadedSlot(const QVariant &arg)
-        { m_qtFunctionInvoked = 35; m_actuals << arg; }
-
-    virtual int myVirtualSlot(int arg)
-        { m_qtFunctionInvoked = 58; return arg; }
-
-    void qscript_call(int arg)
-        { m_qtFunctionInvoked = 40; m_actuals << arg; }
-
-protected Q_SLOTS:
-    void myProtectedSlot() { m_qtFunctionInvoked = 36; }
-
-private Q_SLOTS:
-    void myPrivateSlot() { }
-
-Q_SIGNALS:
-    void mySignal();
-    void mySignalWithIntArg(int arg);
-    void mySignalWithDoubleArg(double arg);
-    void mySignal2(bool arg = false);
-    void myOverloadedSignal(int arg);
-    void myOverloadedSignal(const QString &arg);
-    void myOtherOverloadedSignal(const QString &arg);
-    void myOtherOverloadedSignal(int arg);
-    void mySignalWithDefaultArg(int arg = 123);
-
-protected:
-    void connectNotify(const char *signal) {
-        m_connectedSignal = signal;
-    }
-    void disconnectNotify(const char *signal) {
-        m_disconnectedSignal = signal;
-    }
-
-protected:
-    int m_intValue;
-    QVariant m_variantValue;
-    QVariantList m_variantListValue;
-    QString m_stringValue;
-    QStringList m_stringListValue;
-    QByteArray m_byteArrayValue;
-    QBrush m_brushValue;
-    double m_hiddenValue;
-    int m_writeOnlyValue;
-    int m_readOnlyValue;
-    QKeySequence m_shortcut;
-    CustomType m_customType;
-    int m_qtFunctionInvoked;
-    QVariantList m_actuals;
-    QByteArray m_connectedSignal;
-    QByteArray m_disconnectedSignal;
-};
-
-Q_DECLARE_METATYPE(MyQObject*)
-
-class MyOtherQObject : public MyQObject
-{
-    Q_OBJECT
-public:
-    MyOtherQObject(QObject *parent = 0)
-        : MyQObject(parent)
-        { }
-public Q_SLOTS:
-    virtual int myVirtualSlot(int arg)
-        { m_qtFunctionInvoked = 59; return arg; }
-};
-
-class MyEnumTestQObject : public QObject
-{
-    Q_OBJECT
-    Q_PROPERTY(QString p1 READ p1)
-    Q_PROPERTY(QString p2 READ p2)
-    Q_PROPERTY(QString p3 READ p3 SCRIPTABLE false)
-    Q_PROPERTY(QString p4 READ p4)
-    Q_PROPERTY(QString p5 READ p5 SCRIPTABLE false)
-    Q_PROPERTY(QString p6 READ p6)
-public:
-    MyEnumTestQObject(QObject *parent = 0)
-        : QObject(parent) { }
-    QString p1() const { return QLatin1String("p1"); }
-    QString p2() const { return QLatin1String("p2"); }
-    QString p3() const { return QLatin1String("p3"); }
-    QString p4() const { return QLatin1String("p4"); }
-    QString p5() const { return QLatin1String("p5"); }
-    QString p6() const { return QLatin1String("p5"); }
-public Q_SLOTS:
-    void mySlot() { }
-    void myOtherSlot() { }
-Q_SIGNALS:
-    void mySignal();
-};
-
-class tst_QScriptExtQObject : public QObject
-{
-    Q_OBJECT
-
-public:
-    tst_QScriptExtQObject();
-    virtual ~tst_QScriptExtQObject();
-
-public slots:
-    void init();
-    void cleanup();
-
-protected slots:
-    void onSignalHandlerException(const QScriptValue &exception)
-    {
-        m_signalHandlerException = exception;
-    }
-
-private slots:
-    void getSetStaticProperty();
-    void getSetDynamicProperty();
-    void getSetChildren();
-    void callQtInvokable();
-    void connectAndDisconnect();
-    void cppConnectAndDisconnect();
-    void classEnums();
-    void classConstructor();
-    void overrideInvokable();
-    void transferInvokable();
-    void findChild();
-    void findChildren();
-    void overloadedSlots();
-    void enumerate_data();
-    void enumerate();
-    void enumerateSpecial();
-    void wrapOptions();
-    void prototypes();
-    void objectDeleted();
-    void connectToDestroyedSignal();
-
-private:
-    QScriptEngine *m_engine;
-    MyQObject *m_myObject;
-    QScriptValue m_signalHandlerException;
-};
-
-tst_QScriptExtQObject::tst_QScriptExtQObject()
-{
-}
-
-tst_QScriptExtQObject::~tst_QScriptExtQObject()
-{
-}
-
-void tst_QScriptExtQObject::init()
-{
-    m_engine = new QScriptEngine();
-    m_myObject = new MyQObject();
-    m_engine->globalObject().setProperty("myObject", m_engine->newQObject(m_myObject));
-    m_engine->globalObject().setProperty("global", m_engine->globalObject());
-}
-
-void tst_QScriptExtQObject::cleanup()
-{
-    delete m_engine;
-    delete m_myObject;
-}
-
-static QScriptValue getSetProperty(QScriptContext *ctx, QScriptEngine *)
-{
-    if (ctx->argumentCount() != 0)
-        ctx->callee().setProperty("value", ctx->argument(0));
-    return ctx->callee().property("value");
-}
-
-void tst_QScriptExtQObject::getSetStaticProperty()
-{
-    QCOMPARE(m_engine->evaluate("myObject.noSuchProperty").isUndefined(), true);
-
-    // initial value (set in MyQObject constructor)
-    QCOMPARE(m_engine->evaluate("myObject.intProperty")
-             .strictlyEquals(QScriptValue(m_engine, 123.0)), true);
-    QCOMPARE(m_engine->evaluate("myObject.variantProperty")
-             .toVariant(), QVariant(QLatin1String("foo")));
-    QCOMPARE(m_engine->evaluate("myObject.stringProperty")
-             .strictlyEquals(QScriptValue(m_engine, QLatin1String("bar"))), true);
-    QCOMPARE(m_engine->evaluate("myObject.variantListProperty").isArray(), true);
-    QCOMPARE(m_engine->evaluate("myObject.variantListProperty.length")
-             .strictlyEquals(QScriptValue(m_engine, 2)), true);
-    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[0]")
-             .strictlyEquals(QScriptValue(m_engine, 123)), true);
-    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[1]")
-             .strictlyEquals(QScriptValue(m_engine, QLatin1String("foo"))), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty").isArray(), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty.length")
-             .strictlyEquals(QScriptValue(m_engine, 2)), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[0]").isString(), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[0]").toString(),
-             QLatin1String("zig"));
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[1]").isString(), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[1]").toString(),
-             QLatin1String("zag"));
-
-    // default flags for "normal" properties
-    {
-        QScriptValue mobj = m_engine->globalObject().property("myObject");
-        QVERIFY(!(mobj.propertyFlags("intProperty") & QScriptValue::ReadOnly));
-        QVERIFY(mobj.propertyFlags("intProperty") & QScriptValue::Undeletable);
-        QVERIFY(mobj.propertyFlags("intProperty") & QScriptValue::PropertyGetter);
-        QVERIFY(mobj.propertyFlags("intProperty") & QScriptValue::PropertySetter);
-        QVERIFY(!(mobj.propertyFlags("intProperty") & QScriptValue::SkipInEnumeration));
-        QVERIFY(mobj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
-
-        QVERIFY(!(mobj.propertyFlags("mySlot") & QScriptValue::ReadOnly));
-        QVERIFY(!(mobj.propertyFlags("mySlot") & QScriptValue::Undeletable));
-        QVERIFY(!(mobj.propertyFlags("mySlot") & QScriptValue::SkipInEnumeration));
-        QVERIFY(mobj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
-    }
-
-    // property change in C++ should be reflected in script
-    m_myObject->setIntProperty(456);
-    QCOMPARE(m_engine->evaluate("myObject.intProperty")
-             .strictlyEquals(QScriptValue(m_engine, 456)), true);
-    m_myObject->setIntProperty(789);
-    QCOMPARE(m_engine->evaluate("myObject.intProperty")
-             .strictlyEquals(QScriptValue(m_engine, 789)), true);
-
-    m_myObject->setVariantProperty(QLatin1String("bar"));
-    QVERIFY(m_engine->evaluate("myObject.variantProperty")
-            .strictlyEquals(QScriptValue(m_engine, QLatin1String("bar"))));
-    m_myObject->setVariantProperty(42);
-    QCOMPARE(m_engine->evaluate("myObject.variantProperty")
-             .toVariant(), QVariant(42));
-    m_myObject->setVariantProperty(qVariantFromValue(QBrush()));
-    QVERIFY(m_engine->evaluate("myObject.variantProperty").isVariant());
-
-    m_myObject->setStringProperty(QLatin1String("baz"));
-    QCOMPARE(m_engine->evaluate("myObject.stringProperty")
-             .equals(QScriptValue(m_engine, QLatin1String("baz"))), true);
-    m_myObject->setStringProperty(QLatin1String("zab"));
-    QCOMPARE(m_engine->evaluate("myObject.stringProperty")
-             .equals(QScriptValue(m_engine, QLatin1String("zab"))), true);
-
-    // property change in script should be reflected in C++
-    QCOMPARE(m_engine->evaluate("myObject.intProperty = 123")
-             .strictlyEquals(QScriptValue(m_engine, 123)), true);
-    QCOMPARE(m_engine->evaluate("myObject.intProperty")
-             .strictlyEquals(QScriptValue(m_engine, 123)), true);
-    QCOMPARE(m_myObject->intProperty(), 123);
-    QCOMPARE(m_engine->evaluate("myObject.intProperty = 'ciao!';"
-                                "myObject.intProperty")
-             .strictlyEquals(QScriptValue(m_engine, 0)), true);
-    QCOMPARE(m_myObject->intProperty(), 0);
-    QCOMPARE(m_engine->evaluate("myObject.intProperty = '123';"
-                                "myObject.intProperty")
-             .strictlyEquals(QScriptValue(m_engine, 123)), true);
-    QCOMPARE(m_myObject->intProperty(), 123);
-
-    QCOMPARE(m_engine->evaluate("myObject.stringProperty = 'ciao'")
-             .strictlyEquals(QScriptValue(m_engine, QLatin1String("ciao"))), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringProperty")
-             .strictlyEquals(QScriptValue(m_engine, QLatin1String("ciao"))), true);
-    QCOMPARE(m_myObject->stringProperty(), QLatin1String("ciao"));
-    QCOMPARE(m_engine->evaluate("myObject.stringProperty = 123;"
-                                "myObject.stringProperty")
-             .strictlyEquals(QScriptValue(m_engine, QLatin1String("123"))), true);
-    QCOMPARE(m_myObject->stringProperty(), QLatin1String("123"));
-    QVERIFY(m_engine->evaluate("myObject.stringProperty = null;"
-                               "myObject.stringProperty")
-            .strictlyEquals(QScriptValue(m_engine, QString())));
-    QCOMPARE(m_myObject->stringProperty(), QString());
-    QVERIFY(m_engine->evaluate("myObject.stringProperty = undefined;"
-                               "myObject.stringProperty")
-            .strictlyEquals(QScriptValue(m_engine, QString())));
-    QCOMPARE(m_myObject->stringProperty(), QString());
-
-    QCOMPARE(m_engine->evaluate("myObject.variantProperty = 'foo';"
-                                "myObject.variantProperty.valueOf()").toString(), QLatin1String("foo"));
-    QCOMPARE(m_myObject->variantProperty(), QVariant(QLatin1String("foo")));
-    QVERIFY(m_engine->evaluate("myObject.variantProperty = undefined;"
-                               "myObject.variantProperty").isUndefined());
-    QVERIFY(!m_myObject->variantProperty().isValid());
-    QVERIFY(m_engine->evaluate("myObject.variantProperty = null;"
-                               "myObject.variantProperty").isUndefined());
-    QVERIFY(!m_myObject->variantProperty().isValid());
-    QCOMPARE(m_engine->evaluate("myObject.variantProperty = 42;"
-                                "myObject.variantProperty").toNumber(), 42.0);
-    QCOMPARE(m_myObject->variantProperty().toDouble(), 42.0);
-
-    QCOMPARE(m_engine->evaluate("myObject.variantListProperty = [1, 'two', true];"
-                                "myObject.variantListProperty.length")
-             .strictlyEquals(QScriptValue(m_engine, 3)), true);
-    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[0]")
-             .strictlyEquals(QScriptValue(m_engine, 1)), true);
-    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[1]")
-             .strictlyEquals(QScriptValue(m_engine, QLatin1String("two"))), true);
-    QCOMPARE(m_engine->evaluate("myObject.variantListProperty[2]")
-             .strictlyEquals(QScriptValue(m_engine, true)), true);
-    {
-        QVariantList vl = qscriptvalue_cast<QVariantList>(m_engine->evaluate("myObject.variantListProperty"));
-        QCOMPARE(vl, QVariantList()
-                 << QVariant(1)
-                 << QVariant(QLatin1String("two"))
-                 << QVariant(true));
-    }
-
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty = [1, 'two', true];"
-                                "myObject.stringListProperty.length")
-             .strictlyEquals(QScriptValue(m_engine, 3)), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[0]").isString(), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[0]").toString(),
-             QLatin1String("1"));
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[1]").isString(), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[1]").toString(),
-             QLatin1String("two"));
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[2]").isString(), true);
-    QCOMPARE(m_engine->evaluate("myObject.stringListProperty[2]").toString(),
-             QLatin1String("true"));
-    {
-        QStringList sl = qscriptvalue_cast<QStringList>(m_engine->evaluate("myObject.stringListProperty"));
-        QCOMPARE(sl, QStringList()
-                 << QLatin1String("1")
-                 << QLatin1String("two")
-                 << QLatin1String("true"));
-    }
-
-    // test setting properties where we can't convert the type natively but where the
-    // types happen to be compatible variant types already
-    {
-        QKeySequence sequence(Qt::ControlModifier + Qt::AltModifier + Qt::Key_Delete);
-        QScriptValue mobj = m_engine->globalObject().property("myObject");
-
-        QVERIFY(m_myObject->shortcut().isEmpty());
-        mobj.setProperty("shortcut", m_engine->newVariant(sequence));
-        QVERIFY(m_myObject->shortcut() == sequence);
-    }
-    {
-        CustomType t; t.string = "hello";
-        QScriptValue mobj = m_engine->globalObject().property("myObject");
-
-        QVERIFY(m_myObject->propWithCustomType().string.isEmpty());
-        mobj.setProperty("propWithCustomType", m_engine->newVariant(qVariantFromValue(t)));
-        QVERIFY(m_myObject->propWithCustomType().string == t.string);
-    }
-
-    // test that we do value conversion if necessary when setting properties
-    {
-        QScriptValue br = m_engine->evaluate("myObject.brushProperty");
-        QCOMPARE(qscriptvalue_cast<QBrush>(br), m_myObject->brushProperty());
-        QCOMPARE(qscriptvalue_cast<QColor>(br), m_myObject->brushProperty().color());
-
-        QColor newColor(40, 30, 20, 10);
-        QScriptValue val = qScriptValueFromValue(m_engine, newColor);
-        m_engine->globalObject().setProperty("myColor", val);
-        QScriptValue ret = m_engine->evaluate("myObject.brushProperty = myColor");
-        QCOMPARE(ret.strictlyEquals(val), true);
-        br = m_engine->evaluate("myObject.brushProperty");
-        QCOMPARE(qscriptvalue_cast<QBrush>(br), QBrush(newColor));
-        QCOMPARE(qscriptvalue_cast<QColor>(br), newColor);
-
-        m_engine->globalObject().setProperty("myColor", QScriptValue());
-    }
-
-    // try to delete
-    QCOMPARE(m_engine->evaluate("delete myObject.intProperty").toBoolean(), false);
-    QCOMPARE(m_engine->evaluate("myObject.intProperty").toNumber(), 123.0);
-
-    QCOMPARE(m_engine->evaluate("delete myObject.variantProperty").toBoolean(), false);
-    QCOMPARE(m_engine->evaluate("myObject.variantProperty").toNumber(), 42.0);
-
-    // non-scriptable property
-    QCOMPARE(m_myObject->hiddenProperty(), 456.0);
-    QCOMPARE(m_engine->evaluate("myObject.hiddenProperty").isUndefined(), true);
-    QCOMPARE(m_engine->evaluate("myObject.hiddenProperty = 123;"
-                                "myObject.hiddenProperty").toInt32(), 123);
-    QCOMPARE(m_myObject->hiddenProperty(), 456.0);
-
-    // write-only property
-    QCOMPARE(m_myObject->writeOnlyProperty(), 789);
-    QCOMPARE(m_engine->evaluate("myObject.writeOnlyProperty").isUndefined(), true);
-    QCOMPARE(m_engine->evaluate("myObject.writeOnlyProperty = 123;"
-                                "myObject.writeOnlyProperty").isUndefined(), true);
-    QCOMPARE(m_myObject->writeOnlyProperty(), 123);
-
-    // read-only property
-    QCOMPARE(m_myObject->readOnlyProperty(), 987);
-    QCOMPARE(m_engine->evaluate("myObject.readOnlyProperty").toInt32(), 987);
-    QCOMPARE(m_engine->evaluate("myObject.readOnlyProperty = 654;"
-                                "myObject.readOnlyProperty").toInt32(), 987);
-    QCOMPARE(m_myObject->readOnlyProperty(), 987);
-    {
-        QScriptValue mobj = m_engine->globalObject().property("myObject");
-        QCOMPARE(mobj.propertyFlags("readOnlyProperty") & QScriptValue::ReadOnly,
-                 QScriptValue::ReadOnly);
-    }
-
-    // auto-dereferencing of pointers
-    {
-        QBrush b = QColor(0xCA, 0xFE, 0xBA, 0xBE);
-        QBrush *bp = &b;
-        QScriptValue bpValue = m_engine->newVariant(qVariantFromValue(bp));
-        m_engine->globalObject().setProperty("brushPointer", bpValue);
-        {
-            QScriptValue ret = m_engine->evaluate("myObject.setBrushProperty(brushPointer)");
-            QCOMPARE(ret.isUndefined(), true);
-            QCOMPARE(qscriptvalue_cast<QBrush>(m_engine->evaluate("myObject.brushProperty")), b);
-        }
-        {
-            b = QColor(0xDE, 0xAD, 0xBE, 0xEF);
-            QScriptValue ret = m_engine->evaluate("myObject.brushProperty = brushPointer");
-            QCOMPARE(ret.strictlyEquals(bpValue), true);
-            QCOMPARE(qscriptvalue_cast<QBrush>(m_engine->evaluate("myObject.brushProperty")), b);
-        }
-        m_engine->globalObject().setProperty("brushPointer", QScriptValue());
-    }
-
-    // try to install custom property getter+setter
-    {
-        QScriptValue mobj = m_engine->globalObject().property("myObject");
-        QTest::ignoreMessage(QtWarningMsg, "QScriptValue::setProperty() failed: "
-                             "cannot set getter or setter of native property "
-                             "`intProperty'");
-        mobj.setProperty("intProperty", m_engine->newFunction(getSetProperty),
-                         QScriptValue::PropertyGetter | QScriptValue::PropertySetter);
-    }
-}
-
-void tst_QScriptExtQObject::getSetDynamicProperty()
-{
-    // initially the object does not have the property
-    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('dynamicProperty')")
-             .strictlyEquals(QScriptValue(m_engine, false)), true);
-
-    // add a dynamic property in C++
-    QCOMPARE(m_myObject->setProperty("dynamicProperty", 123), false);
-    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('dynamicProperty')")
-             .strictlyEquals(QScriptValue(m_engine, true)), true);
-    QCOMPARE(m_engine->evaluate("myObject.dynamicProperty")
-             .strictlyEquals(QScriptValue(m_engine, 123)), true);
-
-    // check the flags
-    {
-        QScriptValue mobj = m_engine->globalObject().property("myObject");
-        QVERIFY(!(mobj.propertyFlags("dynamicProperty") & QScriptValue::ReadOnly));
-        QVERIFY(!(mobj.propertyFlags("dynamicProperty") & QScriptValue::Undeletable));
-        QVERIFY(!(mobj.propertyFlags("dynamicProperty") & QScriptValue::SkipInEnumeration));
-        QVERIFY(mobj.propertyFlags("dynamicProperty") & QScriptValue::QObjectMember);
-    }
-
-    // property change in script should be reflected in C++
-    QCOMPARE(m_engine->evaluate("myObject.dynamicProperty = 'foo';"
-                                "myObject.dynamicProperty")
-             .strictlyEquals(QScriptValue(m_engine, QLatin1String("foo"))), true);
-    QCOMPARE(m_myObject->property("dynamicProperty").toString(), QLatin1String("foo"));
-
-    // delete the property
-    QCOMPARE(m_engine->evaluate("delete myObject.dynamicProperty").toBoolean(), true);
-    QCOMPARE(m_myObject->property("dynamicProperty").isValid(), false);
-    QCOMPARE(m_engine->evaluate("myObject.dynamicProperty").isUndefined(), true);
-    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('dynamicProperty')").toBoolean(), false);
-}
-
-void tst_QScriptExtQObject::getSetChildren()
-{
-    // initially the object does not have the child
-    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('child')")
-             .strictlyEquals(QScriptValue(m_engine, false)), true);
-
-    // add a child
-    MyQObject *child = new MyQObject(m_myObject);
-    child->setObjectName("child");
-    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('child')")
-             .strictlyEquals(QScriptValue(m_engine, true)), true);
-
-    // add a grandchild
-    MyQObject *grandChild = new MyQObject(child);
-    grandChild->setObjectName("grandChild");
-    QCOMPARE(m_engine->evaluate("myObject.child.hasOwnProperty('grandChild')")
-             .strictlyEquals(QScriptValue(m_engine, true)), true);
-
-    // delete grandchild
-    delete grandChild;
-    QCOMPARE(m_engine->evaluate("myObject.child.hasOwnProperty('grandChild')")
-             .strictlyEquals(QScriptValue(m_engine, false)), true);
-
-    // delete child
-    delete child;
-    QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('child')")
-             .strictlyEquals(QScriptValue(m_engine, false)), true);
-
-}
-
-Q_DECLARE_METATYPE(QVector<int>)
-Q_DECLARE_METATYPE(QVector<double>)
-Q_DECLARE_METATYPE(QVector<QString>)
-
-template <class T>
-static QScriptValue qobjectToScriptValue(QScriptEngine *engine, T* const &in)
-{ return engine->newQObject(in); }
-
-template <class T>
-static void qobjectFromScriptValue(const QScriptValue &object, T* &out)
-{ out = qobject_cast<T*>(object.toQObject()); }
-
-void tst_QScriptExtQObject::callQtInvokable()
-{
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokable()").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
-    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
-
-    // extra arguments should silently be ignored
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokable(10, 20, 30)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
-    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithIntArg(123)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithIntArg('123')").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithLonglongArg(123)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 2);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toLongLong(), qlonglong(123));
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithFloatArg(123.5)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 3);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5);
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithDoubleArg(123.5)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 4);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5);
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithStringArg('ciao')").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("ciao"));
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithStringArg(123)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123"));
-
-    m_myObject->resetQtFunctionInvoked();
-    QVERIFY(m_engine->evaluate("myObject.myInvokableWithStringArg(null)").isUndefined());
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).type(), QVariant::String);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QString());
-
-    m_myObject->resetQtFunctionInvoked();
-    QVERIFY(m_engine->evaluate("myObject.myInvokableWithStringArg(undefined)").isUndefined());
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).type(), QVariant::String);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QString());
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithIntArgs(123, 456)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 6);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456);
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningInt()")
-             .strictlyEquals(QScriptValue(m_engine, 123)), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 7);
-    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningLongLong()")
-             .strictlyEquals(QScriptValue(m_engine, 456)), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 39);
-    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningString()")
-             .strictlyEquals(QScriptValue(m_engine, QLatin1String("ciao"))), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 8);
-    QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
-
-    m_myObject->resetQtFunctionInvoked();
-    QVERIFY(m_engine->evaluate("myObject.myInvokableReturningVariant()")
-             .strictlyEquals(QScriptValue(m_engine, 123)));
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 60);
-
-    m_myObject->resetQtFunctionInvoked();
-    QVERIFY(m_engine->evaluate("myObject.myInvokableReturningScriptValue()")
-             .strictlyEquals(QScriptValue(m_engine, 456)));
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 61);
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithIntArg(123, 456)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 9);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456);
-
-    m_myObject->resetQtFunctionInvoked();
-    QVERIFY(m_engine->evaluate("myObject.myInvokableWithVoidStarArg(null)").isUndefined());
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 44);
-    m_myObject->resetQtFunctionInvoked();
-    QVERIFY(m_engine->evaluate("myObject.myInvokableWithVoidStarArg(123)").isError());
-    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithAmbiguousArg(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: ambiguous call of overloaded function myInvokableWithAmbiguousArg(); candidates were\n    myInvokableWithAmbiguousArg(int)\n    myInvokableWithAmbiguousArg(uint)"));
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithDefaultArgs(123, 'hello')");
-        QVERIFY(ret.isUndefined());
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 47);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
-        QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
-        QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QLatin1String("hello"));
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithDefaultArgs(456)");
-        QVERIFY(ret.isUndefined());
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 47);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
-        QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456);
-        QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QString());
-    }
-
-    {
-        QScriptValue fun = m_engine->evaluate("myObject.myInvokableWithPointArg");
-        QVERIFY(fun.isFunction());
-        m_myObject->resetQtFunctionInvoked();
-        {
-            QScriptValue ret = fun.call(m_engine->evaluate("myObject"),
-                                        QScriptValueList() << qScriptValueFromValue(m_engine, QPoint(10, 20)));
-            QVERIFY(ret.isUndefined());
-            QCOMPARE(m_myObject->qtFunctionInvoked(), 50);
-            QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-            QCOMPARE(m_myObject->qtFunctionActuals().at(0).toPoint(), QPoint(10, 20));
-        }
-        m_myObject->resetQtFunctionInvoked();
-        {
-            QScriptValue ret = fun.call(m_engine->evaluate("myObject"),
-                                        QScriptValueList() << qScriptValueFromValue(m_engine, QPointF(30, 40)));
-            QVERIFY(ret.isUndefined());
-            QCOMPARE(m_myObject->qtFunctionInvoked(), 51);
-            QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-            QCOMPARE(m_myObject->qtFunctionActuals().at(0).toPointF(), QPointF(30, 40));
-        }
-    }
-
-    // calling function that returns (const)ref
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningRef()");
-        QVERIFY(ret.isUndefined());
-        QVERIFY(!m_engine->hasUncaughtException());
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 48);
-    }
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningConstRef()");
-        QVERIFY(ret.isUndefined());
-        QVERIFY(!m_engine->hasUncaughtException());
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 49);
-    }
-
-    // first time we expect failure because the metatype is not registered
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningVectorOfInt()").isError(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
-
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithVectorOfIntArg(0)").isError(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
-
-    // now we register it, and it should work
-    qScriptRegisterSequenceMetaType<QVector<int> >(m_engine);
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningVectorOfInt()");
-        QCOMPARE(ret.isArray(), true);
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 11);
-    }
-
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVectorOfIntArg(myObject.myInvokableReturningVectorOfInt())");
-        QCOMPARE(ret.isUndefined(), true);
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 12);
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningQObjectStar()");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 13);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 0);
-        QCOMPARE(ret.isQObject(), true);
-        QCOMPARE(ret.toQObject(), (QObject *)m_myObject);
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQObjectListArg([myObject])");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 14);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QCOMPARE(ret.isArray(), true);
-        QCOMPARE(ret.property(QLatin1String("length"))
-                 .strictlyEquals(QScriptValue(m_engine, 1)), true);
-        QCOMPARE(ret.property(QLatin1String("0")).isQObject(), true);
-        QCOMPARE(ret.property(QLatin1String("0")).toQObject(), (QObject *)m_myObject);
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        m_myObject->setVariantProperty(QVariant(123));
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(myObject.variantProperty)");
-        QVERIFY(ret.isNumber());
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QCOMPARE(m_myObject->qtFunctionActuals().at(0), m_myObject->variantProperty());
-        QVERIFY(ret.strictlyEquals(QScriptValue(m_engine, 123)));
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        m_myObject->setVariantProperty(qVariantFromValue(QBrush()));
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(myObject.variantProperty)");
-        QVERIFY(ret.isVariant());
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QCOMPARE(ret.toVariant(), m_myObject->qtFunctionActuals().at(0));
-        QCOMPARE(ret.toVariant(), m_myObject->variantProperty());
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(123)");
-        QVERIFY(ret.isNumber());
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant(123));
-        QVERIFY(ret.strictlyEquals(QScriptValue(m_engine, 123)));
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg('ciao')");
-        QVERIFY(ret.isString());
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant(QString::fromLatin1("ciao")));
-        QVERIFY(ret.strictlyEquals(QScriptValue(m_engine, QString::fromLatin1("ciao"))));
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(null)");
-        QVERIFY(ret.isUndefined()); // invalid QVariant is converted to Undefined
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant());
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantArg(undefined)");
-        QVERIFY(ret.isUndefined());
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant());
-    }
-
-    m_engine->globalObject().setProperty("fishy", m_engine->newVariant(123));
-    m_engine->evaluate("myObject.myInvokableWithStringArg(fishy)");
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVariantMapArg({ a:123, b:'ciao' })");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 16);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QVariant v = m_myObject->qtFunctionActuals().at(0);
-        QCOMPARE(v.userType(), int(QMetaType::QVariantMap));
-        QVariantMap vmap = qvariant_cast<QVariantMap>(v);
-        QCOMPARE(vmap.keys().size(), 2);
-        QCOMPARE(vmap.keys().at(0), QLatin1String("a"));
-        QCOMPARE(vmap.value("a"), QVariant(123));
-        QCOMPARE(vmap.keys().at(1), QLatin1String("b"));
-        QCOMPARE(vmap.value("b"), QVariant("ciao"));
-
-        QCOMPARE(ret.isObject(), true);
-        QCOMPARE(ret.property("a").strictlyEquals(QScriptValue(m_engine, 123)), true);
-        QCOMPARE(ret.property("b").strictlyEquals(QScriptValue(m_engine, "ciao")), true);
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithListOfIntArg([1, 5])");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 17);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QVariant v = m_myObject->qtFunctionActuals().at(0);
-        QCOMPARE(v.userType(), qMetaTypeId<QList<int> >());
-        QList<int> ilst = qvariant_cast<QList<int> >(v);
-        QCOMPARE(ilst.size(), 2);
-        QCOMPARE(ilst.at(0), 1);
-        QCOMPARE(ilst.at(1), 5);
-
-        QCOMPARE(ret.isArray(), true);
-        QCOMPARE(ret.property("0").strictlyEquals(QScriptValue(m_engine, 1)), true);
-        QCOMPARE(ret.property("1").strictlyEquals(QScriptValue(m_engine, 5)), true);
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQObjectStarArg(myObject)");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 18);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QVariant v = m_myObject->qtFunctionActuals().at(0);
-        QCOMPARE(v.userType(), int(QMetaType::QObjectStar));
-        QCOMPARE(qvariant_cast<QObject*>(v), (QObject *)m_myObject);
-
-        QCOMPARE(ret.isQObject(), true);
-        QCOMPARE(qscriptvalue_cast<QObject*>(ret), (QObject *)m_myObject);
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        // no implicit conversion from integer to QObject*
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQObjectStarArg(123)");
-        QCOMPARE(ret.isError(), true);
-    }
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue fun = m_engine->evaluate("myObject.myInvokableWithQBrushArg");
-        QVERIFY(fun.isFunction());
-        QColor color(10, 20, 30, 40);
-        // QColor should be converted to a QBrush
-        QScriptValue ret = fun.call(QScriptValue(), QScriptValueList()
-                                    << qScriptValueFromValue(m_engine, color));
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 19);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QVariant v = m_myObject->qtFunctionActuals().at(0);
-        QCOMPARE(v.userType(), int(QMetaType::QBrush));
-        QCOMPARE(qvariant_cast<QColor>(v), color);
-
-        QCOMPARE(qscriptvalue_cast<QColor>(ret), color);
-    }
-
-    // private slots should not be part of the QObject binding
-    QCOMPARE(m_engine->evaluate("myObject.myPrivateSlot").isUndefined(), true);
-
-    // protected slots should be fine
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myProtectedSlot()");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 36);
-
-    // call with too few arguments
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithIntArg()");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("SyntaxError: too few arguments in call to myInvokableWithIntArg(); candidates are\n    myInvokableWithIntArg(int,int)\n    myInvokableWithIntArg(int)"));
-    }
-
-    // call function where not all types have been registered
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithBrushStyleArg(0)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: cannot call myInvokableWithBrushStyleArg(): argument 1 has unknown type `Qt::BrushStyle' (register the type with qScriptRegisterMetaType())"));
-        QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
-    }
-
-    // call function with incompatible argument type
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQBrushArg(null)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: incompatible type of argument(s) in call to myInvokableWithQBrushArg(); candidates were\n    myInvokableWithQBrushArg(QBrush)"));
-        QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
-    }
-
-    // ability to call a slot with QObject-based arguments, even if those types haven't been registered
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithMyQObjectArg(myObject)");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 52);
-        QVERIFY(ret.isUndefined());
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QCOMPARE(qvariant_cast<QObject*>(m_myObject->qtFunctionActuals().at(0)), (QObject*)m_myObject);
-    }
-
-    // inability to call a slot returning QObject-based type, when that type hasn't been registered
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningMyQObject()");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: cannot call myInvokableReturningMyQObject(): unknown return type `MyQObject*' (register the type with qScriptRegisterMetaType())"));
-    }
-
-    // ability to call a slot returning QObject-based type when that type has been registered
-    qRegisterMetaType<MyQObject*>("MyQObject*");
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningMyQObject()");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 53);
-        QVERIFY(ret.isVariant());
-        QCOMPARE(*reinterpret_cast<MyQObject* const *>(ret.toVariant().constData()), m_myObject);
-    }
-
-    // ability to call a slot with QObject-based argument, when the argument is const
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithConstMyQObjectArg(myObject)");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 54);
-        QVERIFY(ret.isUndefined());
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-        QCOMPARE(qvariant_cast<QObject*>(m_myObject->qtFunctionActuals().at(0)), (QObject*)m_myObject);
-    }
-
-    // QScriptValue arguments should be passed on without conversion
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithScriptValueArg(123)");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 56);
-        QVERIFY(ret.isNumber());
-        QCOMPARE(ret.toInt32(), 123);
-    }
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithScriptValueArg('ciao')");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 56);
-        QVERIFY(ret.isString());
-        QCOMPARE(ret.toString(), QString::fromLatin1("ciao"));
-    }
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithScriptValueArg(this)");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 56);
-        QVERIFY(ret.isObject());
-        QVERIFY(ret.strictlyEquals(m_engine->globalObject()));
-    }
-
-    // the prototype specified by a conversion function should not be "down-graded"
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue qobjectProto = m_engine->newObject();
-        qScriptRegisterMetaType<QObject*>(m_engine, qobjectToScriptValue,
-                                          qobjectFromScriptValue, qobjectProto);
-        QScriptValue myQObjectProto = m_engine->newObject();
-        myQObjectProto.setPrototype(qobjectProto);
-        qScriptRegisterMetaType<MyQObject*>(m_engine, qobjectToScriptValue,
-                                          qobjectFromScriptValue, myQObjectProto);
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningMyQObjectAsQObject()");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 57);
-        QVERIFY(ret.isQObject());
-        QVERIFY(ret.prototype().strictlyEquals(myQObjectProto));
-
-        qScriptRegisterMetaType<QObject*>(m_engine, 0, 0, QScriptValue());
-        qScriptRegisterMetaType<MyQObject*>(m_engine, 0, 0, QScriptValue());
-    }
-
-    // detect exceptions during argument conversion
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue (*dummy)(QScriptEngine *, const QDir &) = 0;
-        qScriptRegisterMetaType<QDir>(m_engine, dummy, dirFromScript);
-        {
-            QVERIFY(!m_engine->hasUncaughtException());
-            QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQDirArg({})");
-            QVERIFY(m_engine->hasUncaughtException());
-            QVERIFY(ret.isError());
-            QCOMPARE(ret.toString(), QString::fromLatin1("Error: No path"));
-            QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
-        }
-        m_engine->clearExceptions();
-        {
-            QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQDirArg({path:'.'})");
-            QVERIFY(!m_engine->hasUncaughtException());
-            QVERIFY(ret.isUndefined());
-            QCOMPARE(m_myObject->qtFunctionInvoked(), 55);
-        }
-    }
-
-    // qscript_call()
-    {
-        m_myObject->resetQtFunctionInvoked();
-        QScriptValue ret = m_engine->evaluate("new myObject(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: myObject is not a constructor"));
-    }
-    {
-        m_myObject->resetQtFunctionInvoked();
-        QScriptValue ret = m_engine->evaluate("myObject(123)");
-        QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: myObject is not a function"));
-    }
-
-    // task 233624
-    {
-        MyNS::A a;
-        m_engine->globalObject().setProperty("anObject", m_engine->newQObject(&a));
-        QScriptValue ret = m_engine->evaluate("anObject.slotTakingScopedEnumArg(1)");
-        QVERIFY(!ret.isError());
-        QVERIFY(ret.isNumber());
-        QCOMPARE(ret.toInt32(), 1);
-        m_engine->globalObject().setProperty("anObject", QScriptValue());
-    }
-
-    // virtual slot redeclared in subclass (task 236467)
-    {
-        MyOtherQObject moq;
-        m_engine->globalObject().setProperty("myOtherQObject", m_engine->newQObject(&moq));
-        moq.resetQtFunctionInvoked();
-        QScriptValue ret = m_engine->evaluate("myOtherQObject.myVirtualSlot(123)");
-        QCOMPARE(moq.qtFunctionInvoked(), 59);
-        QVERIFY(!ret.isError());
-        QVERIFY(ret.isNumber());
-        QCOMPARE(ret.toInt32(), 123);
-    }
-}
-
-void tst_QScriptExtQObject::connectAndDisconnect()
-{
-    // connect(function)
-    QCOMPARE(m_engine->evaluate("myObject.mySignal.connect(123)").isError(), true);
-
-    m_engine->evaluate("myHandler = function() { global.gotSignal = true; global.signalArgs = arguments; global.slotThisObject = this; global.signalSender = __qt_sender__; }");
-
-    m_myObject->clearConnectedSignal();
-    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myHandler)").isUndefined());
-    QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignal()));
-
-    m_engine->evaluate("gotSignal = false");
-    m_engine->evaluate("myObject.mySignal()");
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 0.0);
-    QCOMPARE(m_engine->evaluate("signalSender").toQObject(), (QObject *)m_myObject);
-    QVERIFY(m_engine->evaluate("slotThisObject").strictlyEquals(m_engine->globalObject()));
-
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignal();
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 0.0);
-
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myHandler)").isUndefined());
-
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignalWithIntArg(123);
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
-    QCOMPARE(m_engine->evaluate("signalArgs[0]").toNumber(), 123.0);
-
-    m_myObject->clearDisconnectedSignal();
-    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myHandler)").isUndefined());
-    QCOMPARE(m_myObject->disconnectedSignal().constData(), SIGNAL(mySignal()));
-
-    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myHandler)").isError());
-
-    QVERIFY(m_engine->evaluate("myObject.mySignal2.connect(myHandler)").isUndefined());
-
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignal2(false);
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
-    QCOMPARE(m_engine->evaluate("signalArgs[0]").toBoolean(), false);
-
-    m_engine->evaluate("gotSignal = false");
-    QVERIFY(m_engine->evaluate("myObject.mySignal2.connect(myHandler)").isUndefined());
-    m_myObject->emitMySignal2(true);
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
-    QCOMPARE(m_engine->evaluate("signalArgs[0]").toBoolean(), true);
-
-    QVERIFY(m_engine->evaluate("myObject.mySignal2.disconnect(myHandler)").isUndefined());
-
-    QVERIFY(m_engine->evaluate("myObject['mySignal2()'].connect(myHandler)").isUndefined());
-
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignal2();
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
-
-    QVERIFY(m_engine->evaluate("myObject['mySignal2()'].disconnect(myHandler)").isUndefined());
-
-    // connecting to signal with default args should pick the most generic version (i.e. with all args)
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithDefaultArg.connect(myHandler)").isUndefined());
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignalWithDefaultArgWithArg(456);
-    QVERIFY(m_engine->evaluate("gotSignal").toBoolean());
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toInt32(), 1);
-    QCOMPARE(m_engine->evaluate("signalArgs[0]").toInt32(), 456);
-
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignalWithDefaultArg();
-    QVERIFY(m_engine->evaluate("gotSignal").toBoolean());
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toInt32(), 1);
-    QCOMPARE(m_engine->evaluate("signalArgs[0]").toInt32(), 123);
-
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithDefaultArg.disconnect(myHandler)").isUndefined());
-
-    m_engine->evaluate("gotSignal = false");
-    // connecting to overloaded signal should throw an error
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myOverloadedSignal.connect(myHandler)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QString::fromLatin1("Error: Function.prototype.connect: ambiguous connect to MyQObject::myOverloadedSignal(); candidates are\n"
-                                                     "    myOverloadedSignal(int)\n"
-                                                     "    myOverloadedSignal(QString)\n"
-                                                     "Use e.g. object['myOverloadedSignal(QString)'].connect() to connect to a particular overload"));
-    }
-    m_myObject->emitMyOverloadedSignal(123);
-    QVERIFY(!m_engine->evaluate("gotSignal").toBoolean());
-    m_myObject->emitMyOverloadedSignal("ciao");
-    QVERIFY(!m_engine->evaluate("gotSignal").toBoolean());
-
-    m_engine->evaluate("gotSignal = false");
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myOtherOverloadedSignal.connect(myHandler)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QString::fromLatin1("Error: Function.prototype.connect: ambiguous connect to MyQObject::myOtherOverloadedSignal(); candidates are\n"
-                                                     "    myOtherOverloadedSignal(QString)\n"
-                                                     "    myOtherOverloadedSignal(int)\n"
-                                                     "Use e.g. object['myOtherOverloadedSignal(int)'].connect() to connect to a particular overload"));
-    }
-    m_myObject->emitMyOtherOverloadedSignal("ciao");
-    QVERIFY(!m_engine->evaluate("gotSignal").toBoolean());
-    m_myObject->emitMyOtherOverloadedSignal(123);
-    QVERIFY(!m_engine->evaluate("gotSignal").toBoolean());
-
-    // connect(object, function)
-    m_engine->evaluate("otherObject = { name:'foo' }");
-    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(otherObject, myHandler)").isUndefined());
-    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(otherObject, myHandler)").isUndefined());
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignal();
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), false);
-
-    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(otherObject, myHandler)").isError());
-
-    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(otherObject, myHandler)").isUndefined());
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignal();
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 0.0);
-    QVERIFY(m_engine->evaluate("slotThisObject").strictlyEquals(m_engine->evaluate("otherObject")));
-    QVERIFY(m_engine->evaluate("signalSender").strictlyEquals(m_engine->evaluate("myObject")));
-    QCOMPARE(m_engine->evaluate("slotThisObject").property("name").toString(), QLatin1String("foo"));
-    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(otherObject, myHandler)").isUndefined());
-
-    m_engine->evaluate("yetAnotherObject = { name:'bar', func : function() { } }");
-    QVERIFY(m_engine->evaluate("myObject.mySignal2.connect(yetAnotherObject, myHandler)").isUndefined());
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignal2(true);
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
-    QVERIFY(m_engine->evaluate("slotThisObject").strictlyEquals(m_engine->evaluate("yetAnotherObject")));
-    QVERIFY(m_engine->evaluate("signalSender").strictlyEquals(m_engine->evaluate("myObject")));
-    QCOMPARE(m_engine->evaluate("slotThisObject").property("name").toString(), QLatin1String("bar"));
-    QVERIFY(m_engine->evaluate("myObject.mySignal2.disconnect(yetAnotherObject, myHandler)").isUndefined());
-
-    QVERIFY(m_engine->evaluate("myObject.mySignal2.connect(myObject, myHandler)").isUndefined());
-    m_engine->evaluate("gotSignal = false");
-    m_myObject->emitMySignal2(true);
-    QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true);
-    QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0);
-    QCOMPARE(m_engine->evaluate("slotThisObject").toQObject(), (QObject *)m_myObject);
-    QVERIFY(m_engine->evaluate("signalSender").strictlyEquals(m_engine->evaluate("myObject")));
-    QVERIFY(m_engine->evaluate("myObject.mySignal2.disconnect(myObject, myHandler)").isUndefined());
-
-    // connect(obj, string)
-    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(yetAnotherObject, 'func')").isUndefined());
-    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject, 'mySlot')").isUndefined());
-    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(yetAnotherObject, 'func')").isUndefined());
-    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myObject, 'mySlot')").isUndefined());
-
-    // check that emitting signals from script works
-
-    // no arguments
-    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject.mySlot)").isUndefined());
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.mySignal()").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
-    QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myObject.mySlot)").isUndefined());
-
-    // one argument
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject.mySlotWithIntArg)").isUndefined());
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(123)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 21);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithIntArg)").isUndefined());
-
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject.mySlotWithDoubleArg)").isUndefined());
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(123)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 22);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.0);
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithDoubleArg)").isUndefined());
-
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject.mySlotWithStringArg)").isUndefined());
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(123)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 23);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123"));
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithStringArg)").isUndefined());
-
-    // connecting to overloaded slot
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject.myOverloadedSlot)").isUndefined());
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(123)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 26); // double overload
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject.myOverloadedSlot)").isUndefined());
-
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.connect(myObject['myOverloadedSlot(int)'])").isUndefined());
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.mySignalWithIntArg(456)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 28); // int overload
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456);
-    QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject['myOverloadedSlot(int)'])").isUndefined());
-
-    // erroneous input
-    {
-        QScriptValue ret = m_engine->evaluate("(function() { }).connect()");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.connect: no arguments given"));
-    }
-    {
-        QScriptValue ret = m_engine->evaluate("var o = { }; o.connect = Function.prototype.connect;  o.connect()");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.connect: no arguments given"));
-    }
-
-    {
-        QScriptValue ret = m_engine->evaluate("(function() { }).connect(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: this object is not a signal"));
-    }
-    {
-        QScriptValue ret = m_engine->evaluate("var o = { }; o.connect = Function.prototype.connect;  o.connect(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: this object is not a signal"));
-    }
-
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokable.connect(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: MyQObject::myInvokable() is not a signal"));
-    }
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokable.connect(function() { })");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: MyQObject::myInvokable() is not a signal"));
-    }
-
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.mySignal.connect(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.connect: target is not a function"));
-    }
-
-    {
-        QScriptValue ret = m_engine->evaluate("(function() { }).disconnect()");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.disconnect: no arguments given"));
-    }
-    {
-        QScriptValue ret = m_engine->evaluate("var o = { }; o.disconnect = Function.prototype.disconnect;  o.disconnect()");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.disconnect: no arguments given"));
-    }
-
-    {
-        QScriptValue ret = m_engine->evaluate("(function() { }).disconnect(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: this object is not a signal"));
-    }
-    {
-        QScriptValue ret = m_engine->evaluate("var o = { }; o.disconnect = Function.prototype.disconnect;  o.disconnect(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: this object is not a signal"));
-    }
-
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokable.disconnect(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: MyQObject::myInvokable() is not a signal"));
-    }
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokable.disconnect(function() { })");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: MyQObject::myInvokable() is not a signal"));
-    }
-
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.mySignal.disconnect(123)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: Function.prototype.disconnect: target is not a function"));
-    }
-
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.mySignal.disconnect(function() { })");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.disconnect: failed to disconnect from MyQObject::mySignal()"));
-    }
-
-    // when the wrapper dies, the connection stays alive
-    QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject.mySlot)").isUndefined());
-    m_myObject->resetQtFunctionInvoked();
-    m_myObject->emitMySignal();
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
-    m_engine->evaluate("myObject = null");
-    m_engine->collectGarbage();
-    m_myObject->resetQtFunctionInvoked();
-    m_myObject->emitMySignal();
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
-}
-
-void tst_QScriptExtQObject::cppConnectAndDisconnect()
-{
-    QScriptEngine eng;
-    QLineEdit edit;
-    QLineEdit edit2;
-    QScriptValue fun = eng.evaluate("function fun(text) { signalObject = this; signalArg = text; }; fun");
-    QVERIFY(fun.isFunction());
-    for (int z = 0; z < 2; ++z) {
-        QScriptValue receiver;
-        if (z == 0)
-            receiver = QScriptValue();
-        else
-            receiver = eng.newObject();
-        for (int y = 0; y < 2; ++y) {
-            QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), receiver, fun));
-            QVERIFY(qScriptConnect(&edit2, SIGNAL(textChanged(const QString &)), receiver, fun));
-            // check signal emission
-            for (int x = 0; x < 4; ++x) {
-                QLineEdit *ed = (x < 2) ? &edit : &edit2;
-                ed->setText((x % 2) ? "foo" : "bar");
-                {
-                    QScriptValue ret = eng.globalObject().property("signalObject");
-                    if (receiver.isObject())
-                        QVERIFY(ret.strictlyEquals(receiver));
-                    else
-                        QVERIFY(ret.strictlyEquals(eng.globalObject()));
-                }
-                {
-                    QScriptValue ret = eng.globalObject().property("signalArg");
-                    QVERIFY(ret.isString());
-                    QCOMPARE(ret.toString(), ed->text());
-                }
-                eng.collectGarbage();
-            }
-
-            // check disconnect
-            QVERIFY(qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), receiver, fun));
-            eng.globalObject().setProperty("signalObject", QScriptValue());
-            eng.globalObject().setProperty("signalArg", QScriptValue());
-            edit.setText("something else");
-            QVERIFY(!eng.globalObject().property("signalObject").isValid());
-            QVERIFY(!eng.globalObject().property("signalArg").isValid());
-            QVERIFY(!qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), receiver, fun));
-
-            // other object's connection should remain
-            edit2.setText(edit.text());
-            {
-                QScriptValue ret = eng.globalObject().property("signalObject");
-                if (receiver.isObject())
-                    QVERIFY(ret.strictlyEquals(receiver));
-                else
-                    QVERIFY(ret.strictlyEquals(eng.globalObject()));
-            }
-            {
-                QScriptValue ret = eng.globalObject().property("signalArg");
-                QVERIFY(ret.isString());
-                QCOMPARE(ret.toString(), edit2.text());
-            }
-
-            // disconnect other object too
-            QVERIFY(qScriptDisconnect(&edit2, SIGNAL(textChanged(const QString &)), receiver, fun));
-            eng.globalObject().setProperty("signalObject", QScriptValue());
-            eng.globalObject().setProperty("signalArg", QScriptValue());
-            edit2.setText("even more different");
-            QVERIFY(!eng.globalObject().property("signalObject").isValid());
-            QVERIFY(!eng.globalObject().property("signalArg").isValid());
-            QVERIFY(!qScriptDisconnect(&edit2, SIGNAL(textChanged(const QString &)), receiver, fun));
-        }
-    }
-
-    // make sure we don't crash when engine is deleted
-    {
-        QScriptEngine *eng2 = new QScriptEngine;
-        QScriptValue fun2 = eng2->evaluate("function(text) { signalObject = this; signalArg = text; }");
-        QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun2));
-        delete eng2;
-        edit.setText("ciao");
-        QVERIFY(!qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun2));
-    }
-
-    // mixing script-side and C++-side connect
-    {
-        eng.globalObject().setProperty("edit", eng.newQObject(&edit));
-        QVERIFY(eng.evaluate("edit.textChanged.connect(fun)").isUndefined());
-        QVERIFY(qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun));
-
-        QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun));
-        QVERIFY(eng.evaluate("edit.textChanged.disconnect(fun)").isUndefined());
-    }
-
-    // signalHandlerException()
-    {
-        connect(&eng, SIGNAL(signalHandlerException(QScriptValue)),
-                this, SLOT(onSignalHandlerException(QScriptValue)));
-
-        eng.globalObject().setProperty("edit", eng.newQObject(&edit));
-        QScriptValue fun = eng.evaluate("function() { nonExistingFunction(); }");
-        QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun));
-
-        m_signalHandlerException = QScriptValue();
-        QScriptValue ret = eng.evaluate("edit.text = 'trigger a signal handler exception from script'");
-        QVERIFY(ret.isError());
-        QVERIFY(m_signalHandlerException.strictlyEquals(ret));
-
-        m_signalHandlerException = QScriptValue();
-        edit.setText("trigger a signal handler exception from C++");
-        QVERIFY(m_signalHandlerException.isError());
-
-        QVERIFY(qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun));
-
-        m_signalHandlerException = QScriptValue();
-        eng.evaluate("edit.text = 'no more exception from script'");
-        QVERIFY(!m_signalHandlerException.isValid());
-        edit.setText("no more exception from C++");
-        QVERIFY(!m_signalHandlerException.isValid());
-
-        disconnect(&eng, SIGNAL(signalHandlerException(QScriptValue)),
-                   this, SLOT(onSignalHandlerException(QScriptValue)));
-    }
-
-    // check that connectNotify() and disconnectNotify() are called (task 232987)
-    {
-        m_myObject->clearConnectedSignal();
-        QVERIFY(qScriptConnect(m_myObject, SIGNAL(mySignal()), QScriptValue(), fun));
-        QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignal()));
-
-        m_myObject->clearDisconnectedSignal();
-        QVERIFY(qScriptDisconnect(m_myObject, SIGNAL(mySignal()), QScriptValue(), fun));
-        QCOMPARE(m_myObject->disconnectedSignal().constData(), SIGNAL(mySignal()));
-    }
-}
-
-void tst_QScriptExtQObject::classEnums()
-{
-    QScriptValue myClass = m_engine->newQMetaObject(m_myObject->metaObject(), m_engine->undefinedValue());
-    m_engine->globalObject().setProperty("MyQObject", myClass);
-
-    QCOMPARE(static_cast<MyQObject::Policy>(m_engine->evaluate("MyQObject.FooPolicy").toInt32()),
-             MyQObject::FooPolicy);
-    QCOMPARE(static_cast<MyQObject::Policy>(m_engine->evaluate("MyQObject.BarPolicy").toInt32()),
-             MyQObject::BarPolicy);
-    QCOMPARE(static_cast<MyQObject::Policy>(m_engine->evaluate("MyQObject.BazPolicy").toInt32()),
-             MyQObject::BazPolicy);
-
-    QCOMPARE(static_cast<MyQObject::Strategy>(m_engine->evaluate("MyQObject.FooStrategy").toInt32()),
-             MyQObject::FooStrategy);
-    QCOMPARE(static_cast<MyQObject::Strategy>(m_engine->evaluate("MyQObject.BarStrategy").toInt32()),
-             MyQObject::BarStrategy);
-    QCOMPARE(static_cast<MyQObject::Strategy>(m_engine->evaluate("MyQObject.BazStrategy").toInt32()),
-             MyQObject::BazStrategy);
-
-    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.NoAbility").toInt32()),
-             MyQObject::NoAbility);
-    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.FooAbility").toInt32()),
-             MyQObject::FooAbility);
-    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.BarAbility").toInt32()),
-             MyQObject::BarAbility);
-    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.BazAbility").toInt32()),
-             MyQObject::BazAbility);
-    QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.AllAbility").toInt32()),
-             MyQObject::AllAbility);
-
-    QScriptValue::PropertyFlags expectedEnumFlags = QScriptValue::ReadOnly;
-    QCOMPARE(myClass.propertyFlags("FooPolicy"), expectedEnumFlags);
-    QCOMPARE(myClass.propertyFlags("BarPolicy"), expectedEnumFlags);
-    QCOMPARE(myClass.propertyFlags("BazPolicy"), expectedEnumFlags);
-
-    // enums from Qt are inherited through prototype
-    QCOMPARE(static_cast<Qt::FocusPolicy>(m_engine->evaluate("MyQObject.StrongFocus").toInt32()),
-             Qt::StrongFocus);
-    QCOMPARE(static_cast<Qt::Key>(m_engine->evaluate("MyQObject.Key_Left").toInt32()),
-             Qt::Key_Left);
-
-    QCOMPARE(m_engine->evaluate("MyQObject.className()").toString(), QLatin1String("MyQObject"));
-
-    qRegisterMetaType<MyQObject::Policy>("Policy");
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithEnumArg(MyQObject.BazPolicy)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 10);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::BazPolicy));
-
-    m_myObject->resetQtFunctionInvoked();
-    QCOMPARE(m_engine->evaluate("myObject.myInvokableWithQualifiedEnumArg(MyQObject.BazPolicy)").isUndefined(), true);
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 36);
-    QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
-    QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::BazPolicy));
-
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningEnum()");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 37);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 0);
-        QCOMPARE(ret.isVariant(), true);
-    }
-    m_myObject->resetQtFunctionInvoked();
-    {
-        QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningQualifiedEnum()");
-        QCOMPARE(m_myObject->qtFunctionInvoked(), 38);
-        QCOMPARE(m_myObject->qtFunctionActuals().size(), 0);
-        QCOMPARE(ret.isNumber(), true);
-    }
-}
-
-QT_BEGIN_NAMESPACE
-Q_SCRIPT_DECLARE_QMETAOBJECT(MyQObject, QObject*)
-Q_SCRIPT_DECLARE_QMETAOBJECT(QObject, QObject*)
-QT_END_NAMESPACE
-
-class ConstructorTest : public QObject
-{
-    Q_OBJECT
-public:
-    Q_INVOKABLE ConstructorTest(QObject *parent)
-        : QObject(parent)
-    {
-        setProperty("ctorIndex", 0);
-    }
-    Q_INVOKABLE ConstructorTest(int arg, QObject *parent = 0)
-        : QObject(parent)
-    {
-        setProperty("ctorIndex", 1);
-        setProperty("arg", arg);
-    }
-    Q_INVOKABLE ConstructorTest(const QString &arg, QObject *parent = 0)
-        : QObject(parent)
-    {
-        setProperty("ctorIndex", 2);
-        setProperty("arg", arg);
-    }
-    Q_INVOKABLE ConstructorTest(int arg, const QString &arg2, QObject *parent = 0)
-        : QObject(parent)
-    {
-        setProperty("ctorIndex", 3);
-        setProperty("arg", arg);
-        setProperty("arg2", arg2);
-    }
-    Q_INVOKABLE ConstructorTest(const QBrush &arg, QObject *parent = 0)
-        : QObject(parent)
-    {
-        setProperty("ctorIndex", 4);
-        setProperty("arg", arg);
-    }
-};
-
-void tst_QScriptExtQObject::classConstructor()
-{
-    QScriptValue myClass = qScriptValueFromQMetaObject<MyQObject>(m_engine);
-    m_engine->globalObject().setProperty("MyQObject", myClass);
-
-    QScriptValue myObj = m_engine->evaluate("myObj = MyQObject()");
-    QObject *qobj = myObj.toQObject();
-    QVERIFY(qobj != 0);
-    QCOMPARE(qobj->metaObject()->className(), "MyQObject");
-    QCOMPARE(qobj->parent(), (QObject *)0);
-
-    QScriptValue qobjectClass = qScriptValueFromQMetaObject<QObject>(m_engine);
-    m_engine->globalObject().setProperty("QObject", qobjectClass);
-
-    QScriptValue otherObj = m_engine->evaluate("otherObj = QObject(myObj)");
-    QObject *qqobj = otherObj.toQObject();
-    QVERIFY(qqobj != 0);
-    QCOMPARE(qqobj->metaObject()->className(), "QObject");
-    QCOMPARE(qqobj->parent(), qobj);
-
-    delete qobj;
-
-    // Q_INVOKABLE constructors
-    {
-        QScriptValue klazz = m_engine->newQMetaObject(&ConstructorTest::staticMetaObject);
-        {
-            QScriptValue obj = klazz.construct();
-            QVERIFY(obj.isError());
-            QCOMPARE(obj.toString(), QString::fromLatin1("SyntaxError: too few arguments in call to ConstructorTest(); candidates are\n"
-                                                         "    ConstructorTest(QBrush)\n"
-                                                         "    ConstructorTest(QBrush,QObject*)\n"
-                                                         "    ConstructorTest(int,QString)\n"
-                                                         "    ConstructorTest(int,QString,QObject*)\n"
-                                                         "    ConstructorTest(QString)\n"
-                                                         "    ConstructorTest(QString,QObject*)\n"
-                                                         "    ConstructorTest(int)\n"
-                                                         "    ConstructorTest(int,QObject*)\n"
-                                                         "    ConstructorTest(QObject*)"));
-        }
-        {
-            QObject objobj;
-            QScriptValue arg = m_engine->newQObject(&objobj);
-            QScriptValue obj = klazz.construct(QScriptValueList() << arg);
-            QVERIFY(!obj.isError());
-            QVERIFY(obj.instanceOf(klazz));
-            QVERIFY(obj.property("ctorIndex").isNumber());
-            QCOMPARE(obj.property("ctorIndex").toInt32(), 0);
-        }
-        {
-            int arg = 123;
-            QScriptValue obj = klazz.construct(QScriptValueList() << arg);
-            QVERIFY(!obj.isError());
-            QVERIFY(obj.instanceOf(klazz));
-            QVERIFY(obj.property("ctorIndex").isNumber());
-            QCOMPARE(obj.property("ctorIndex").toInt32(), 1);
-            QVERIFY(obj.property("arg").isNumber());
-            QCOMPARE(obj.property("arg").toInt32(), arg);
-        }
-        {
-            QString arg = "foo";
-            QScriptValue obj = klazz.construct(QScriptValueList() << arg);
-            QVERIFY(!obj.isError());
-            QVERIFY(obj.instanceOf(klazz));
-            QVERIFY(obj.property("ctorIndex").isNumber());
-            QCOMPARE(obj.property("ctorIndex").toInt32(), 2);
-            QVERIFY(obj.property("arg").isString());
-            QCOMPARE(obj.property("arg").toString(), arg);
-        }
-        {
-            int arg = 123;
-            QString arg2 = "foo";
-            QScriptValue obj = klazz.construct(QScriptValueList() << arg << arg2);
-            QVERIFY(!obj.isError());
-            QVERIFY(obj.instanceOf(klazz));
-            QVERIFY(obj.property("ctorIndex").isNumber());
-            QCOMPARE(obj.property("ctorIndex").toInt32(), 3);
-            QVERIFY(obj.property("arg").isNumber());
-            QCOMPARE(obj.property("arg").toInt32(), arg);
-            QVERIFY(obj.property("arg2").isString());
-            QCOMPARE(obj.property("arg2").toString(), arg2);
-        }
-        {
-            QBrush arg(Qt::red);
-            QScriptValue obj = klazz.construct(QScriptValueList() << qScriptValueFromValue(m_engine, arg));
-            QVERIFY(!obj.isError());
-            QVERIFY(obj.instanceOf(klazz));
-            QVERIFY(obj.property("ctorIndex").isNumber());
-            QCOMPARE(obj.property("ctorIndex").toInt32(), 4);
-            QVERIFY(obj.property("arg").isVariant());
-            QCOMPARE(qvariant_cast<QBrush>(obj.property("arg").toVariant()), arg);
-        }
-        {
-            QDir arg;
-            QScriptValue obj = klazz.construct(QScriptValueList()
-                                               << qScriptValueFromValue(m_engine, arg));
-            QVERIFY(obj.isError());
-            QCOMPARE(obj.toString(), QString::fromLatin1("TypeError: ambiguous call of overloaded function ConstructorTest(); candidates were\n"
-                                                         "    ConstructorTest(int)\n"
-                                                         "    ConstructorTest(QString)"));
-        }
-    }
-}
-
-void tst_QScriptExtQObject::overrideInvokable()
-{
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myInvokable()");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
-
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myInvokable = function() { global.a = 123; }");
-    m_engine->evaluate("myObject.myInvokable()");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
-    QCOMPARE(m_engine->evaluate("global.a").toNumber(), 123.0);
-
-    m_engine->evaluate("myObject.myInvokable = function() { global.a = 456; }");
-    m_engine->evaluate("myObject.myInvokable()");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
-    QCOMPARE(m_engine->evaluate("global.a").toNumber(), 456.0);
-
-    m_engine->evaluate("delete myObject.myInvokable");
-    m_engine->evaluate("myObject.myInvokable()");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
-
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myInvokable = myObject.myInvokableWithIntArg");
-    m_engine->evaluate("myObject.myInvokable(123)");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
-
-    m_engine->evaluate("delete myObject.myInvokable");
-    m_myObject->resetQtFunctionInvoked();
-    // this form (with the '()') is read-only
-    m_engine->evaluate("myObject['myInvokable()'] = function() { global.a = 123; }");
-    m_engine->evaluate("myObject.myInvokable()");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
-}
-
-void tst_QScriptExtQObject::transferInvokable()
-{
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.foozball = myObject.myInvokable");
-    m_engine->evaluate("myObject.foozball()");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.foozball = myObject.myInvokableWithIntArg");
-    m_engine->evaluate("myObject.foozball(123)");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myInvokable = myObject.myInvokableWithIntArg");
-    m_engine->evaluate("myObject.myInvokable(123)");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
-
-    MyOtherQObject other;
-    m_engine->globalObject().setProperty(
-        "myOtherObject", m_engine->newQObject(&other));
-    m_engine->evaluate("myOtherObject.foo = myObject.foozball");
-    other.resetQtFunctionInvoked();
-    m_engine->evaluate("myOtherObject.foo(456)");
-    QCOMPARE(other.qtFunctionInvoked(), 1);
-}
-
-void tst_QScriptExtQObject::findChild()
-{
-    QObject *child = new QObject(m_myObject);
-    child->setObjectName(QLatin1String("myChildObject"));
-
-    {
-        QScriptValue result = m_engine->evaluate("myObject.findChild('noSuchChild')");
-        QCOMPARE(result.isNull(), true);
-    }
-
-    {    
-        QScriptValue result = m_engine->evaluate("myObject.findChild('myChildObject')");
-        QCOMPARE(result.isQObject(), true);
-        QCOMPARE(result.toQObject(), child);
-    }
-
-    delete child;
-}
-
-void tst_QScriptExtQObject::findChildren()
-{
-    QObject *child = new QObject(m_myObject);
-    child->setObjectName(QLatin1String("myChildObject"));
-
-    {
-        QScriptValue result = m_engine->evaluate("myObject.findChildren('noSuchChild')");
-        QCOMPARE(result.isArray(), true);
-        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 0.0);
-    }
-
-    {
-        QScriptValue result = m_engine->evaluate("myObject.findChildren('myChildObject')");
-        QCOMPARE(result.isArray(), true);
-        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 1.0);
-        QCOMPARE(result.property(QLatin1String("0")).toQObject(), child);
-    }
-
-    QObject *namelessChild = new QObject(m_myObject);
-
-    {
-        QScriptValue result = m_engine->evaluate("myObject.findChildren('myChildObject')");
-        QCOMPARE(result.isArray(), true);
-        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 1.0);
-        QCOMPARE(result.property(QLatin1String("0")).toQObject(), child);
-    }
-
-    QObject *anotherChild = new QObject(m_myObject);
-    anotherChild->setObjectName(QLatin1String("anotherChildObject"));
-
-    {
-        QScriptValue result = m_engine->evaluate("myObject.findChildren('anotherChildObject')");
-        QCOMPARE(result.isArray(), true);
-        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 1.0);
-        QCOMPARE(result.property(QLatin1String("0")).toQObject(), anotherChild);
-    }
-
-    anotherChild->setObjectName(QLatin1String("myChildObject"));
-    {
-        QScriptValue result = m_engine->evaluate("myObject.findChildren('myChildObject')");
-        QCOMPARE(result.isArray(), true);
-        QCOMPARE(result.property(QLatin1String("length")).toNumber(), 2.0);
-        QObject *o1 = result.property(QLatin1String("0")).toQObject();
-        QObject *o2 = result.property(QLatin1String("1")).toQObject();
-        if (o1 != child) {
-            QCOMPARE(o1, anotherChild);
-            QCOMPARE(o2, child);
-        } else {
-            QCOMPARE(o1, child);
-            QCOMPARE(o2, anotherChild);
-        }
-    }
-
-    // find all
-    {
-        QScriptValue result = m_engine->evaluate("myObject.findChildren()");
-        QVERIFY(result.isArray());
-        int count = 3;
-        QCOMPARE(result.property("length").toInt32(), count);
-        for (int i = 0; i < 3; ++i) {
-            QObject *o = result.property(i).toQObject();
-            if (o == namelessChild || o == child || o == anotherChild)
-                --count;
-        }
-        QVERIFY(count == 0);
-    }
-
-    delete anotherChild;
-    delete namelessChild;
-    delete child;
-}
-
-void tst_QScriptExtQObject::overloadedSlots()
-{
-    // should pick myOverloadedSlot(double)
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myOverloadedSlot(10)");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 26);
-
-    // should pick myOverloadedSlot(double)
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myOverloadedSlot(10.0)");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 26);
-
-    // should pick myOverloadedSlot(QString)
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myOverloadedSlot('10')");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 29);
-
-    // should pick myOverloadedSlot(bool)
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myOverloadedSlot(true)");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 25);
-
-    // should pick myOverloadedSlot(QDateTime)
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myOverloadedSlot(new Date())");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 32);
-
-    // should pick myOverloadedSlot(QRegExp)
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myOverloadedSlot(new RegExp())");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 34);
-
-    // should pick myOverloadedSlot(QVariant)
-    m_myObject->resetQtFunctionInvoked();
-    QScriptValue f = m_engine->evaluate("myObject.myOverloadedSlot");
-    f.call(QScriptValue(), QScriptValueList() << m_engine->newVariant(QVariant("ciao")));
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 35);
-
-    // should pick myOverloadedSlot(QObject*)
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myOverloadedSlot(myObject)");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 41);
-
-    // should pick myOverloadedSlot(QObject*)
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myOverloadedSlot(null)");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 41);
-
-    // should pick myOverloadedSlot(QStringList)
-    m_myObject->resetQtFunctionInvoked();
-    m_engine->evaluate("myObject.myOverloadedSlot(['hello'])");
-    QCOMPARE(m_myObject->qtFunctionInvoked(), 42);
-}
-
-void tst_QScriptExtQObject::enumerate_data()
-{
-    QTest::addColumn<int>("wrapOptions");
-    QTest::addColumn<QStringList>("expectedNames");
-
-    QTest::newRow( "enumerate all" )
-        << 0
-        << (QStringList()
-            // meta-object-defined properties:
-            //   inherited
-            << "objectName"
-            //   non-inherited
-            << "p1" << "p2" << "p4" << "p6"
-            // dynamic properties
-            << "dp1" << "dp2" << "dp3"
-            // inherited slots
-            << "destroyed(QObject*)" << "destroyed()"
-            << "deleteLater()"
-            // not included because it's private:
-            // << "_q_reregisterTimers(void*)"
-            // signals
-            << "mySignal()"
-            // slots
-            << "mySlot()" << "myOtherSlot()");
-
-    QTest::newRow( "don't enumerate inherited properties" )
-        << int(QScriptEngine::ExcludeSuperClassProperties)
-        << (QStringList()
-            // meta-object-defined properties:
-            //   non-inherited
-            << "p1" << "p2" << "p4" << "p6"
-            // dynamic properties
-            << "dp1" << "dp2" << "dp3"
-            // inherited slots
-            << "destroyed(QObject*)" << "destroyed()"
-            << "deleteLater()"
-            // not included because it's private:
-            // << "_q_reregisterTimers(void*)"
-            // signals
-            << "mySignal()"
-            // slots
-            << "mySlot()" << "myOtherSlot()");
-
-    QTest::newRow( "don't enumerate inherited methods" )
-        << int(QScriptEngine::ExcludeSuperClassMethods)
-        << (QStringList()
-            // meta-object-defined properties:
-            //   inherited
-            << "objectName"
-            //   non-inherited
-            << "p1" << "p2" << "p4" << "p6"
-            // dynamic properties
-            << "dp1" << "dp2" << "dp3"
-            // signals
-            << "mySignal()"
-            // slots
-            << "mySlot()" << "myOtherSlot()");
-
-    QTest::newRow( "don't enumerate inherited members" )
-        << int(QScriptEngine::ExcludeSuperClassMethods
-               | QScriptEngine::ExcludeSuperClassProperties)
-        << (QStringList()
-            // meta-object-defined properties
-            << "p1" << "p2" << "p4" << "p6"
-            // dynamic properties
-            << "dp1" << "dp2" << "dp3"
-            // signals
-            << "mySignal()"
-            // slots
-            << "mySlot()" << "myOtherSlot()");
-
-    QTest::newRow( "enumerate properties, not methods" )
-        << int(QScriptEngine::SkipMethodsInEnumeration)
-        << (QStringList()
-            // meta-object-defined properties:
-            //   inherited
-            << "objectName"
-            //   non-inherited
-            << "p1" << "p2" << "p4" << "p6"
-            // dynamic properties
-            << "dp1" << "dp2" << "dp3");
-
-    QTest::newRow( "don't enumerate inherited properties + methods" )
-        << int(QScriptEngine::ExcludeSuperClassProperties
-            | QScriptEngine::SkipMethodsInEnumeration)
-        << (QStringList()
-            // meta-object-defined properties:
-            //   non-inherited
-            << "p1" << "p2" << "p4" << "p6"
-            // dynamic properties
-            << "dp1" << "dp2" << "dp3");
-
-    QTest::newRow( "don't enumerate inherited members" )
-        << int(QScriptEngine::ExcludeSuperClassContents)
-        << (QStringList()
-            // meta-object-defined properties
-            << "p1" << "p2" << "p4" << "p6"
-            // dynamic properties
-            << "dp1" << "dp2" << "dp3"
-            // signals
-            << "mySignal()"
-            // slots
-            << "mySlot()" << "myOtherSlot()");
-
-    QTest::newRow( "don't enumerate deleteLater()" )
-        << int(QScriptEngine::ExcludeDeleteLater)
-        << (QStringList()
-            // meta-object-defined properties:
-            //   inherited
-            << "objectName"
-            //   non-inherited
-            << "p1" << "p2" << "p4" << "p6"
-            // dynamic properties
-            << "dp1" << "dp2" << "dp3"
-            // inherited slots
-            << "destroyed(QObject*)" << "destroyed()"
-            // not included because it's private:
-            // << "_q_reregisterTimers(void*)"
-            // signals
-            << "mySignal()"
-            // slots
-            << "mySlot()" << "myOtherSlot()");
-}
-
-void tst_QScriptExtQObject::enumerate()
-{
-    QFETCH( int, wrapOptions );
-    QFETCH( QStringList, expectedNames );
-
-    QScriptEngine eng;
-    MyEnumTestQObject enumQObject;
-    // give it some dynamic properties
-    enumQObject.setProperty("dp1", "dp1");
-    enumQObject.setProperty("dp2", "dp2");
-    enumQObject.setProperty("dp3", "dp3");
-    QScriptValue obj = eng.newQObject(&enumQObject, QScriptEngine::QtOwnership,
-                                      QScriptEngine::QObjectWrapOptions(wrapOptions));
-
-    // enumerate in script
-    {
-        eng.globalObject().setProperty("myEnumObject", obj);
-        eng.evaluate("var enumeratedProperties = []");
-        eng.evaluate("for (var p in myEnumObject) { enumeratedProperties.push(p); }");
-        QStringList result = qscriptvalue_cast<QStringList>(eng.evaluate("enumeratedProperties"));
-        QCOMPARE(result.size(), expectedNames.size());
-        for (int i = 0; i < expectedNames.size(); ++i)
-            QCOMPARE(result.at(i), expectedNames.at(i));
-    }
-    // enumerate in C++
-    {
-        QScriptValueIterator it(obj);
-        QStringList result;
-        while (it.hasNext()) {
-            it.next();
-            QCOMPARE(it.flags(), obj.propertyFlags(it.name()));
-            result.append(it.name());
-        }
-        QCOMPARE(result.size(), expectedNames.size());
-        for (int i = 0; i < expectedNames.size(); ++i)
-            QCOMPARE(result.at(i), expectedNames.at(i));
-    }
-}
-
-class SpecialEnumTestObject : public QObject
-{
-    Q_OBJECT
-    // overriding a property in the super-class to make it non-scriptable
-    Q_PROPERTY(QString objectName READ objectName SCRIPTABLE false)
-public:
-    SpecialEnumTestObject(QObject *parent = 0)
-        : QObject(parent) {}
-};
-
-class SpecialEnumTestObject2 : public QObject
-{
-    Q_OBJECT
-    // overriding a property in the super-class to make it non-designable (but still scriptable)
-    Q_PROPERTY(QString objectName READ objectName DESIGNABLE false)
-public:
-    SpecialEnumTestObject2(QObject *parent = 0)
-        : QObject(parent) {}
-};
-
-void tst_QScriptExtQObject::enumerateSpecial()
-{
-    QScriptEngine eng;
-    {
-        SpecialEnumTestObject testObj;
-        QScriptValueIterator it(eng.newQObject(&testObj));
-        bool objectNameEncountered = false;
-        while (it.hasNext()) {
-            it.next();
-            if (it.name() == QLatin1String("objectName")) {
-                objectNameEncountered = true;
-                break;
-            }
-        }
-        QVERIFY(!objectNameEncountered);
-    }
-    {
-        SpecialEnumTestObject2 testObj;
-        testObj.setObjectName("foo");
-        QScriptValueList values;
-        QScriptValueIterator it(eng.newQObject(&testObj));
-        while (it.hasNext()) {
-            it.next();
-            if (it.name() == "objectName")
-                values.append(it.value());
-        }
-        QCOMPARE(values.size(), 1);
-        QCOMPARE(values.at(0).toString(), QString::fromLatin1("foo"));
-    }
-}
-
-void tst_QScriptExtQObject::wrapOptions()
-{
-    QCOMPARE(m_myObject->setProperty("dynamicProperty", 123), false);
-    MyQObject *child = new MyQObject(m_myObject);
-    child->setObjectName("child");
-    // exclude child objects
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
-                                                QScriptEngine::ExcludeChildObjects);
-        QCOMPARE(obj.property("child").isValid(), false);
-        obj.setProperty("child", QScriptValue(m_engine, 123));
-        QCOMPARE(obj.property("child")
-                 .strictlyEquals(QScriptValue(m_engine, 123)), true);
-    }
-    // don't auto-create dynamic properties
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject);
-        QVERIFY(!m_myObject->dynamicPropertyNames().contains("anotherDynamicProperty"));
-        obj.setProperty("anotherDynamicProperty", QScriptValue(m_engine, 123));
-        QVERIFY(!m_myObject->dynamicPropertyNames().contains("anotherDynamicProperty"));
-        QCOMPARE(obj.property("anotherDynamicProperty")
-                 .strictlyEquals(QScriptValue(m_engine, 123)), true);
-    }
-    // auto-create dynamic properties
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
-                                                QScriptEngine::AutoCreateDynamicProperties);
-        QVERIFY(!m_myObject->dynamicPropertyNames().contains("anotherDynamicProperty"));
-        obj.setProperty("anotherDynamicProperty", QScriptValue(m_engine, 123));
-        QVERIFY(m_myObject->dynamicPropertyNames().contains("anotherDynamicProperty"));
-        QCOMPARE(obj.property("anotherDynamicProperty")
-                 .strictlyEquals(QScriptValue(m_engine, 123)), true);
-        // task 236685
-        {
-            QScriptValue obj2 = m_engine->newObject();
-            obj2.setProperty("notADynamicProperty", 456);
-            obj.setPrototype(obj2);
-            QScriptValue ret = obj.property("notADynamicProperty");
-            QVERIFY(ret.isNumber());
-            QVERIFY(ret.strictlyEquals(obj2.property("notADynamicProperty")));
-        }
-    }
-    // don't exclude super-class properties
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject);
-        QVERIFY(obj.property("objectName").isValid());
-        QVERIFY(obj.propertyFlags("objectName") & QScriptValue::QObjectMember);
-    }
-    // exclude super-class properties
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
-                                                QScriptEngine::ExcludeSuperClassProperties);
-        QVERIFY(!obj.property("objectName").isValid());
-        QVERIFY(!(obj.propertyFlags("objectName") & QScriptValue::QObjectMember));
-        QVERIFY(obj.property("intProperty").isValid());
-        QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
-    }
-    // don't exclude super-class methods
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject);
-        QVERIFY(obj.property("deleteLater").isValid());
-        QVERIFY(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember);
-    }
-    // exclude super-class methods
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
-                                                QScriptEngine::ExcludeSuperClassMethods);
-        QVERIFY(!obj.property("deleteLater").isValid());
-        QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
-        QVERIFY(obj.property("mySlot").isValid());
-        QVERIFY(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
-    }
-    // exclude all super-class contents
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
-                                                QScriptEngine::ExcludeSuperClassContents);
-        QVERIFY(!obj.property("deleteLater").isValid());
-        QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
-        QVERIFY(obj.property("mySlot").isValid());
-        QVERIFY(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
-
-        QVERIFY(!obj.property("objectName").isValid());
-        QVERIFY(!(obj.propertyFlags("objectName") & QScriptValue::QObjectMember));
-        QVERIFY(obj.property("intProperty").isValid());
-        QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
-    }
-    // exclude deleteLater()
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
-                                                QScriptEngine::ExcludeDeleteLater);
-        QVERIFY(!obj.property("deleteLater").isValid());
-        QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
-        QVERIFY(obj.property("mySlot").isValid());
-        QVERIFY(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
-
-        QVERIFY(obj.property("objectName").isValid());
-        QVERIFY(obj.propertyFlags("objectName") & QScriptValue::QObjectMember);
-        QVERIFY(obj.property("intProperty").isValid());
-        QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
-    }
-    // exclude all that we can
-    {
-        QScriptValue obj = m_engine->newQObject(m_myObject, QScriptEngine::QtOwnership,
-                                                QScriptEngine::ExcludeSuperClassMethods
-                                                | QScriptEngine::ExcludeSuperClassProperties
-                                                | QScriptEngine::ExcludeChildObjects);
-        QVERIFY(!obj.property("deleteLater").isValid());
-        QVERIFY(!(obj.propertyFlags("deleteLater") & QScriptValue::QObjectMember));
-        QVERIFY(obj.property("mySlot").isValid());
-        QVERIFY(obj.propertyFlags("mySlot") & QScriptValue::QObjectMember);
-
-        QVERIFY(!obj.property("objectName").isValid());
-        QVERIFY(!(obj.propertyFlags("objectName") & QScriptValue::QObjectMember));
-        QVERIFY(obj.property("intProperty").isValid());
-        QVERIFY(obj.propertyFlags("intProperty") & QScriptValue::QObjectMember);
-
-        QCOMPARE(obj.property("child").isValid(), false);
-        obj.setProperty("child", QScriptValue(m_engine, 123));
-        QCOMPARE(obj.property("child")
-                 .strictlyEquals(QScriptValue(m_engine, 123)), true);
-    }
-
-    delete child;
-}
-
-Q_DECLARE_METATYPE(QWidget*)
-Q_DECLARE_METATYPE(QPushButton*)
-
-void tst_QScriptExtQObject::prototypes()
-{
-    QScriptEngine eng;
-    QScriptValue widgetProto = eng.newQObject(new QWidget(), QScriptEngine::ScriptOwnership);
-    eng.setDefaultPrototype(qMetaTypeId<QWidget*>(), widgetProto);
-    QPushButton *pbp = new QPushButton();
-    QScriptValue buttonProto = eng.newQObject(pbp, QScriptEngine::ScriptOwnership);
-    buttonProto.setPrototype(widgetProto);
-    eng.setDefaultPrototype(qMetaTypeId<QPushButton*>(), buttonProto);
-    QPushButton *pb = new QPushButton();
-    QScriptValue button = eng.newQObject(pb, QScriptEngine::ScriptOwnership);
-    QVERIFY(button.prototype().strictlyEquals(buttonProto));
-
-    buttonProto.setProperty("text", QScriptValue(&eng, "prototype button"));
-    QCOMPARE(pbp->text(), QLatin1String("prototype button"));
-    button.setProperty("text", QScriptValue(&eng, "not the prototype button"));
-    QCOMPARE(pb->text(), QLatin1String("not the prototype button"));
-    QCOMPARE(pbp->text(), QLatin1String("prototype button"));
-
-    buttonProto.setProperty("objectName", QScriptValue(&eng, "prototype button"));
-    QCOMPARE(pbp->objectName(), QLatin1String("prototype button"));
-    button.setProperty("objectName", QScriptValue(&eng, "not the prototype button"));
-    QCOMPARE(pb->objectName(), QLatin1String("not the prototype button"));
-    QCOMPARE(pbp->objectName(), QLatin1String("prototype button"));
-}
-
-void tst_QScriptExtQObject::objectDeleted()
-{
-    QScriptEngine eng;
-    MyQObject *qobj = new MyQObject();
-    QScriptValue v = eng.newQObject(qobj);
-    v.setProperty("objectName", QScriptValue(&eng, "foo"));
-    QCOMPARE(qobj->objectName(), QLatin1String("foo"));
-    v.setProperty("intProperty", QScriptValue(&eng, 123));
-    QCOMPARE(qobj->intProperty(), 123);
-    qobj->resetQtFunctionInvoked();
-    v.property("myInvokable").call(v);
-    QCOMPARE(qobj->qtFunctionInvoked(), 0);
-
-    // now delete the object
-    delete qobj;
-
-    // the documented behavior is: isQObject() should still return true,
-    // but toQObject() should return 0
-    QVERIFY(v.isQObject());
-    QCOMPARE(v.toQObject(), (QObject *)0);
-
-    // any attempt to access properties of the object should result in an exception
-    {
-        QScriptValue ret = v.property("objectName");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: cannot access member `objectName' of deleted QObject"));
-    }
-    {
-        eng.evaluate("Object");
-        QVERIFY(!eng.hasUncaughtException());
-        v.setProperty("objectName", QScriptValue(&eng, "foo"));
-        QVERIFY(eng.hasUncaughtException());
-        QVERIFY(eng.uncaughtException().isError());
-        QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: cannot access member `objectName' of deleted QObject"));
-    }
-
-    {
-        QScriptValue ret = v.call();
-        QVERIFY(!ret.isValid());
-    }
-
-    // myInvokable is stored in member table (since we've accessed it before deletion)
-    QVERIFY(v.property("myInvokable").isFunction());
-    {
-        QScriptValue ret = v.property("myInvokable").call(v);
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: cannot call function of deleted QObject"));
-    }
-    // myInvokableWithIntArg is not stored in member table (since we've not accessed it)
-    {
-        QScriptValue ret = v.property("myInvokableWithIntArg");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject"));
-    }
-
-    // access from script
-    eng.globalObject().setProperty("o", v);
-    {
-        QScriptValue ret = eng.evaluate("o()");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("TypeError: o is not a function"));
-    }
-    {
-        QScriptValue ret = eng.evaluate("o.objectName");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: cannot access member `objectName' of deleted QObject"));
-    }
-    {
-        QScriptValue ret = eng.evaluate("o.myInvokable()");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: cannot call function of deleted QObject"));
-    }
-    {
-        QScriptValue ret = eng.evaluate("o.myInvokableWithIntArg(10)");
-        QVERIFY(ret.isError());
-        QCOMPARE(ret.toString(), QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject"));
-    }
-}
-
-void tst_QScriptExtQObject::connectToDestroyedSignal()
-{
-    // ### the following test currently depends on signal emission order
-#if 0
-    {
-        // case 1: deleted when the engine is not doing GC
-        QScriptEngine eng;
-        QObject *obj = new QObject();
-        eng.globalObject().setProperty("o", eng.newQObject(obj, QScriptEngine::QtOwnership));
-        eng.evaluate("o.destroyed.connect(function() { wasDestroyed = true; })");
-        eng.evaluate("wasDestroyed = false");
-        delete obj;
-        QVERIFY(eng.evaluate("wasDestroyed").toBoolean());
-    }
-    {
-        // case 2: deleted when the engine is doing GC
-        QScriptEngine eng;
-        QObject *obj = new QObject();
-        eng.globalObject().setProperty("o", eng.newQObject(obj, QScriptEngine::ScriptOwnership));
-        eng.evaluate("o.destroyed.connect(function() { wasDestroyed = true; })");
-        eng.evaluate("wasDestroyed = false");
-        eng.evaluate("o = null");
-        eng.collectGarbage();
-        QVERIFY(eng.evaluate("wasDestroyed").toBoolean());
-    }
-    {
-        // case 3: deleted when the engine is destroyed
-        QScriptEngine eng;
-        QObject *obj = new QObject();
-        eng.globalObject().setProperty("o", eng.newQObject(obj, QScriptEngine::ScriptOwnership));
-        eng.evaluate("o.destroyed.connect(function() { })");
-        // the signal handler won't get called -- we don't want to crash
-    }
-#endif
-}
-
-QTEST_MAIN(tst_QScriptExtQObject)
-#include "tst_qscriptqobject.moc"
diff --git a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
index 77bfeb5..2dfd157 100644
--- a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
+++ b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
@@ -254,6 +254,8 @@ tst_Suite::tst_Suite()
     addTestExclusion("mul-exhaustive", "Demands too much memory on WinCE");
 #endif
 
+    static const char klass[] = "tst_QScriptV8TestSuite";
+
     QVector<uint> *data = qt_meta_data_tst_Suite();
     // content:
     *data << 1 // revision
@@ -265,7 +267,7 @@ tst_Suite::tst_Suite()
         ;
 
     QVector<char> *stringdata = qt_meta_stringdata_tst_Suite();
-    appendCString(stringdata, "tst_Suite");
+    appendCString(stringdata, klass);
     appendCString(stringdata, "");
 
     QFileInfoList testFileInfos;
@@ -275,7 +277,8 @@ tst_Suite::tst_Suite()
         QString name = tfi.baseName();
         // slot: signature, parameters, type, tag, flags
         QString slot = QString::fromLatin1("%0()").arg(name);
-        *data << stringdata->size() << 10 << 10 << 10 << 0x08;
+        static const int nullbyte = sizeof(klass);
+        *data << stringdata->size() << nullbyte << nullbyte << nullbyte << 0x08;
         appendCString(stringdata, slot.toLatin1());
         testNames.append(name);
     }
diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
index 30f97ba..13d0f34 100644
--- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -76,13 +76,13 @@
 // This test depends on the fonts in the following package being installed:
 // http://people.freedesktop.org/~hausmann/harfbuzz-test-fonts-0.1.tar.bz2
 
-class tst_QScriptEngine : public QObject
+class tst_QTextScriptEngine : public QObject
 {
 Q_OBJECT
 
 public:
-    tst_QScriptEngine();
-    virtual ~tst_QScriptEngine();
+    tst_QTextScriptEngine();
+    virtual ~tst_QTextScriptEngine();
 
 
 public slots:
@@ -104,19 +104,19 @@ private slots:
     void linearB();
 };
 
-tst_QScriptEngine::tst_QScriptEngine()
+tst_QTextScriptEngine::tst_QTextScriptEngine()
 {
 }
 
-tst_QScriptEngine::~tst_QScriptEngine()
+tst_QTextScriptEngine::~tst_QTextScriptEngine()
 {
 }
 
-void tst_QScriptEngine::init()
+void tst_QTextScriptEngine::init()
 {
 }
 
-void tst_QScriptEngine::cleanup()
+void tst_QTextScriptEngine::cleanup()
 {
 }
 
@@ -172,7 +172,7 @@ static bool shaping( const QFont &f, const ShapeTable *s)
 }
 #endif
 
-void tst_QScriptEngine::devanagari()
+void tst_QTextScriptEngine::devanagari()
 {
 #if defined(Q_WS_X11)
     {
@@ -284,7 +284,7 @@ void tst_QScriptEngine::devanagari()
 #endif
 }
 
-void tst_QScriptEngine::bengali()
+void tst_QTextScriptEngine::bengali()
 {
 #if defined(Q_WS_X11)
     {
@@ -531,7 +531,7 @@ void tst_QScriptEngine::bengali()
 #endif
 }
 
-void tst_QScriptEngine::gurmukhi()
+void tst_QTextScriptEngine::gurmukhi()
 {
 #if defined(Q_WS_X11)
     {
@@ -556,7 +556,7 @@ void tst_QScriptEngine::gurmukhi()
 #endif
 }
 
-void tst_QScriptEngine::oriya()
+void tst_QTextScriptEngine::oriya()
 {
 #if defined(Q_WS_X11)
     {
@@ -596,7 +596,7 @@ void tst_QScriptEngine::oriya()
 }
 
 
-void tst_QScriptEngine::tamil()
+void tst_QTextScriptEngine::tamil()
 {
 #if defined(Q_WS_X11)
     {
@@ -667,7 +667,7 @@ void tst_QScriptEngine::tamil()
 }
 
 
-void tst_QScriptEngine::telugu()
+void tst_QTextScriptEngine::telugu()
 {
 #if defined(Q_WS_X11)
     {
@@ -713,7 +713,7 @@ void tst_QScriptEngine::telugu()
 }
 
 
-void tst_QScriptEngine::kannada()
+void tst_QTextScriptEngine::kannada()
 {
 #if defined(Q_WS_X11)
     {
@@ -783,7 +783,7 @@ void tst_QScriptEngine::kannada()
 
 
 
-void tst_QScriptEngine::malayalam()
+void tst_QTextScriptEngine::malayalam()
 {
 #if defined(Q_WS_X11)
     {
@@ -838,7 +838,7 @@ void tst_QScriptEngine::malayalam()
 
 
 
-void tst_QScriptEngine::khmer()
+void tst_QTextScriptEngine::khmer()
 {
 #if defined(Q_WS_X11)
     {
@@ -881,7 +881,7 @@ void tst_QScriptEngine::khmer()
 #endif
 }
 
-void tst_QScriptEngine::linearB()
+void tst_QTextScriptEngine::linearB()
 {
 #if defined(Q_WS_X11)
     {
@@ -909,5 +909,5 @@ void tst_QScriptEngine::linearB()
 }
 
 
-QTEST_MAIN(tst_QScriptEngine)
+QTEST_MAIN(tst_QTextScriptEngine)
 #include "tst_qtextscriptengine.moc"
-- 
cgit v0.12


From 4dcc603919779bda9f5dc052c459d914bdc4949b Mon Sep 17 00:00:00 2001
From: Morten Sorvig <msorvig@trolltech.com>
Date: Thu, 6 Aug 2009 08:16:50 +0200
Subject: Replace instances of weak linking for 10.3 with 10.4.

---
 mkspecs/common/mac.conf           | 5 ++---
 qmake/qmake.pri                   | 2 +-
 src/tools/bootstrap/bootstrap.pro | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf
index 818b450..5d88ac4 100644
--- a/mkspecs/common/mac.conf
+++ b/mkspecs/common/mac.conf
@@ -38,8 +38,7 @@ QMAKE_DEL_FILE		= rm -f
 QMAKE_DEL_DIR		= rmdir
 QMAKE_CHK_DIR_EXISTS	= test -d
 QMAKE_MKDIR		= mkdir -p
-# Need to enable the correct deployment target for Cocoa (should be 10.3 for Carbon).
-macx-icc: QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
-else: QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3
+QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 # overridden to 10.5 for Cocoa on the compiler command line
+
 
 include(unix.conf)
diff --git a/qmake/qmake.pri b/qmake/qmake.pri
index 9ba8506..1f9243b 100644
--- a/qmake/qmake.pri
+++ b/qmake/qmake.pri
@@ -107,7 +107,7 @@ bootstrap { #Qt code
         SOURCES += qfsfileengine_unix.cpp qfsfileengine_iterator_unix.cpp
         mac {
           SOURCES += qcore_mac.cpp qsettings_mac.cpp
-          QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3 #enables weak linking for 10.3 (exported)
+          QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported)
           LIBS += -framework ApplicationServices
         }
     } else:win32 {
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index d8a1f96..396e9ae 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -89,7 +89,7 @@ win32:SOURCES += ../../corelib/io/qfsfileengine_win.cpp \
                  ../../corelib/io/qfsfileengine_iterator_win.cpp
 
 macx: {
-   QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3 #enables weak linking for 10.3 (exported)
+   QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported)
    SOURCES += ../../corelib/kernel/qcore_mac.cpp
    LIBS += -framework CoreServices
 }
-- 
cgit v0.12


From 34e2cd4e715a9760b2829cff13fd2526f6a290ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= <jan-arve.saether@nokia.com>
Date: Thu, 6 Aug 2009 09:41:56 +0200
Subject: Update baseline (project.ts.result) for the good:backslashes case.

---
 .../auto/linguist/lupdate/testdata/good/backslashes/project.ts.result | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result
index 151a18e..f2d109b 100644
--- a/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
-<TS version="1.1">
+<TS version="2.0">
 <context>
     <name>QApplication</name>
     <message>
-        <location filename="../src/main.cpp" line="13"/>
+        <location filename="../src/main.cpp" line="10"/>
         <source>QT_LAYOUT_DIRECTION</source>
         <comment>Translate this string to the string &apos;LTR&apos; in left-to-right languages or to &apos;RTL&apos; in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout.</comment>
         <translation type="unfinished"></translation>
-- 
cgit v0.12


From 0588b9c8c57fd204372556c7fc376b8d44672fa6 Mon Sep 17 00:00:00 2001
From: Keith Isdale <keith.isdale@nokia.com>
Date: Thu, 6 Aug 2009 17:58:21 +1000
Subject: Add hints that a qmake generated .pro will need to be edited

When qmake run with the -project option to generate a .pro for the
project it is possible that the generated .pro file will need to be
edited and add variables such as "QT" to specify what QT modules
the project needs. To hints to qmake's help and HTML documentation to
that effect.

Reviewed-by: Marius Storm-Olsen
---
 doc/src/qmake-manual.qdoc | 3 ++-
 qmake/option.cpp          | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/src/qmake-manual.qdoc b/doc/src/qmake-manual.qdoc
index 0921ae7..211d7e9 100644
--- a/doc/src/qmake-manual.qdoc
+++ b/doc/src/qmake-manual.qdoc
@@ -558,7 +558,8 @@
     \o \c -makefile \BR
         \c qmake output will be a Makefile.
     \o \c -project \BR
-        \c qmake output will be a project file.
+        \c qmake output will be a project file. \BR
+\bold{Note:} It is likely that the created file will need to be edited for example adding the \c QT variable to suit what modules are required for the project.
     \endlist
 
     The following \c options are used to specify both general and mode-specific
diff --git a/qmake/option.cpp b/qmake/option.cpp
index 2308017..5d7cb9b 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -150,6 +150,9 @@ bool usage(const char *a0)
             "                 In this mode qmake interprets files as files to\n"
             "                 be built,\n"
             "                 defaults to %s\n"
+            "                 Note: The created .pro file probably will \n"
+            "                 need to be edited. For example add the QT variable to \n"
+            "                 specify what modules are required.\n"
             "  -makefile      Put qmake into makefile generation mode%s\n"
             "                 In this mode qmake interprets files as project files to\n"
             "                 be processed, if skipped qmake will try to find a project\n"
-- 
cgit v0.12


From de63f4572096b652cd8d445ae0ea0c880197b6d3 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@trolltech.com>
Date: Thu, 6 Aug 2009 10:00:28 +0200
Subject: Resolved tst_QCssParser::extractFontFamily_data on jackychan

That machine has no 'Times New Roman' the test was reliying in
---
 tests/auto/qcssparser/tst_qcssparser.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/auto/qcssparser/tst_qcssparser.cpp b/tests/auto/qcssparser/tst_qcssparser.cpp
index c3bcdf2..be1a212 100644
--- a/tests/auto/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/qcssparser/tst_qcssparser.cpp
@@ -1139,8 +1139,8 @@ void tst_QCssParser::specificity()
     QVERIFY(parser.parse(&sheet));
 
     QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count() + sheet.idIndex.count() , 1);
-    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0) 
-                        :  (!sheet.nameIndex.isEmpty())  ? *sheet.nameIndex.begin() 
+    QCss::StyleRule rule =  (!sheet.styleRules.isEmpty()) ? sheet.styleRules.at(0)
+                        :  (!sheet.nameIndex.isEmpty())  ? *sheet.nameIndex.begin()
                         :  *sheet.idIndex.begin();
     QCOMPARE(rule.selectors.count(), 1);
     QTEST(rule.selectors.at(0).specificity(), "specificity");
@@ -1508,6 +1508,9 @@ void tst_QCssParser::gradient()
 
 void tst_QCssParser::extractFontFamily_data()
 {
+    if (QFontInfo(QFont("Times New Roman")).family() != "Times New Roman")
+        QSKIP("'Times New Roman' font not found ", SkipAll);
+
     QTest::addColumn<QString>("css");
     QTest::addColumn<QString>("expectedFamily");
 
-- 
cgit v0.12


From 2be8aa471585d7aff5701c945c83f855ca3bfd59 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= <jan-arve.saether@nokia.com>
Date: Thu, 6 Aug 2009 10:38:07 +0200
Subject: Normalize line endings before comparing the lines.

We already trimmed away any \r from the expected line, but we did not
trim away \r from the actual line. That caused some false negatives on
windows.
---
 tests/auto/linguist/lupdate/tst_lupdate.cpp | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp
index fcf8582..97400d9 100644
--- a/tests/auto/linguist/lupdate/tst_lupdate.cpp
+++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp
@@ -93,13 +93,24 @@ void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn
         } else if (i == ei) {
             ei = 0;
             break;
-        } else if (err ? !QRegExp(expected.at(i)).exactMatch(actual.at(i)) :
-                         (actual.at(i) != expected.at(i))) {
-            while ((ei - 1) >= i && (gi - 1) >= i &&
-                     (err ? QRegExp(expected.at(ei - 1)).exactMatch(actual.at(gi - 1)) :
-                            (actual.at(gi - 1) == expected.at(ei - 1))))
-                ei--, gi--;
-            break;
+        } else {
+            QString act = actual.at(i);
+            act.remove('\r');
+            if (err ? !QRegExp(expected.at(i)).exactMatch(act) :
+                         (act != expected.at(i))) {
+                bool cond = true;
+                while (cond) {
+                    act = actual.at(gi - 1);
+                    act.remove('\r');
+                    cond = (ei - 1) >= i && (gi - 1) >= i &&
+                         (err ? QRegExp(expected.at(ei - 1)).exactMatch(act) :
+                                (act == expected.at(ei - 1)));
+                    if (cond) {
+                        ei--, gi--;
+                    }
+                }
+                break;
+            }
         }
     }
     QByteArray diff;
-- 
cgit v0.12


From 68ad89d69e03731a2a5f7c6c8623b62cc1098e79 Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Date: Thu, 6 Aug 2009 09:59:25 +0200
Subject: Test fail resolved. Waiting time after dialog.exec() was too short.

---
 tests/auto/qitemdelegate/tst_qitemdelegate.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 6714de3..06018b9 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -1153,7 +1153,7 @@ void tst_QItemDelegate::task257859_finalizeEdit()
     QTimer::singleShot(100, &dialog, SLOT(close()));
     dialog.exec();
 
-    QTest::qWait(10);
+    QTest::qWait(100);
 
     QVERIFY(!editor);
 }
-- 
cgit v0.12


From 4511c0b35517707542a3f32f82125c9d33a6000b Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Date: Thu, 6 Aug 2009 10:34:31 +0200
Subject: Fixed crash in tst_qitemview.

QAbstractItemViewPrivate::selectionModel may be null.

Reviewed-by: olivier
---
 src/gui/itemviews/qabstractitemview.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index ed2b3c5..d929590 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -960,7 +960,8 @@ void QAbstractItemView::reset()
     d->currentIndexSet = false;
     setState(NoState);
     setRootIndex(QModelIndex());
-    d->selectionModel->reset();
+    if (d->selectionModel)
+        d->selectionModel->reset();
 }
 
 /*!
-- 
cgit v0.12


From 886656afe0bd1101efbb0054c64f57326bb0a2ee Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Date: Thu, 6 Aug 2009 10:36:59 +0200
Subject: Useless Q_ASSERTs made test crash.

Reviewed-by: thierry
Reviewed-by: olivier
---
 tests/auto/qitemview/tst_qitemview.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/auto/qitemview/tst_qitemview.cpp b/tests/auto/qitemview/tst_qitemview.cpp
index 73c08d1..2f9ac96 100644
--- a/tests/auto/qitemview/tst_qitemview.cpp
+++ b/tests/auto/qitemview/tst_qitemview.cpp
@@ -173,8 +173,6 @@ public:
     }
 
     QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const {
-        Q_ASSERT(row >= 0 && row <= rowCount(parent));
-        Q_ASSERT(column >= 0 && column <= columnCount(parent));
         return QStandardItemModel::index(row, column, parent);
     };
 
-- 
cgit v0.12


From ede24aab6793fc524a4660a8d092309a82a5ccff Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 10:47:00 +0200
Subject: Q3ProgressBar autotest fixed on mac

- We need to process events in order to leave time to mac to update
the widget.
- When in undefined case, the progressbar is animated, so the number
of paintevents might be bigger than 1.
---
 tests/auto/q3progressbar/tst_q3progressbar.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/auto/q3progressbar/tst_q3progressbar.cpp b/tests/auto/q3progressbar/tst_q3progressbar.cpp
index 0378d15..549c8a4 100644
--- a/tests/auto/q3progressbar/tst_q3progressbar.cpp
+++ b/tests/auto/q3progressbar/tst_q3progressbar.cpp
@@ -102,7 +102,7 @@ void tst_Q3ProgressBar::setProgress()
 {
     MyCustomProgressBar * m_progressBar = new MyCustomProgressBar();
     m_progressBar->show();
-    QTest::qWait(500);
+    QApplication::processEvents();
 
     //case with total steps = 0
     m_progressBar->setTotalSteps(0);
@@ -110,15 +110,16 @@ void tst_Q3ProgressBar::setProgress()
     m_progressBar->paintNumber = 0;
     m_progressBar->setProgress(m_progressBar->progress() + 1);
     QCOMPARE(oldValue + 1,m_progressBar->progress());
-    QCOMPARE(m_progressBar->paintNumber,1);
+    QApplication::processEvents();
+    QVERIFY(m_progressBar->paintNumber >= 1); //it might be more than 1 because it is animated
 
     //standard case
     m_progressBar->setTotalSteps(3);
     m_progressBar->setProgress(0);
     m_progressBar->paintNumber = 0;
     m_progressBar->setProgress(m_progressBar->progress() + 1);
+    QApplication::processEvents();
     QCOMPARE(m_progressBar->paintNumber,1);
-
 }
 
 QTEST_MAIN(tst_Q3ProgressBar)
-- 
cgit v0.12


From c8eca7e16bc8c48d2b24dd72d5d3082b6e348714 Mon Sep 17 00:00:00 2001
From: Gunnar Sletta <gunnar@trolltech.com>
Date: Thu, 6 Aug 2009 11:05:05 +0200
Subject: A small hack to enable gles2 at configure time

Reviewed-by: Trond
---
 mkspecs/linux-g++-gles2-experimental/qmake.conf    |  22 +++
 .../linux-g++-gles2-experimental/qplatformdefs.h   | 164 +++++++++++++++++++++
 2 files changed, 186 insertions(+)
 create mode 100644 mkspecs/linux-g++-gles2-experimental/qmake.conf
 create mode 100644 mkspecs/linux-g++-gles2-experimental/qplatformdefs.h

diff --git a/mkspecs/linux-g++-gles2-experimental/qmake.conf b/mkspecs/linux-g++-gles2-experimental/qmake.conf
new file mode 100644
index 0000000..9c28d17
--- /dev/null
+++ b/mkspecs/linux-g++-gles2-experimental/qmake.conf
@@ -0,0 +1,22 @@
+#
+# Experimental qmake configuration for GLES2
+#
+
+MAKEFILE_GENERATOR	= UNIX
+TEMPLATE		= app
+CONFIG			+= qt warn_on release incremental link_prl
+QT			+= core gui
+QMAKE_INCREMENTAL_STYLE = sublib
+
+include(../common/g++.conf)
+
+QMAKE_LFLAGS += -Wl,-rpath-link=/usr/lib
+
+include(../common/linux.conf)
+
+QMAKE_LIBS_EGL        = -lEGL
+QMAKE_LIBS_OPENGL     = -lGLESv2
+QMAKE_LIBS_OPENGL_QT  = -lGLESv2 -lEGL
+
+
+load(qt_config)
diff --git a/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h b/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h
new file mode 100644
index 0000000..b9a94e2
--- /dev/null
+++ b/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake spec 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMDEFS_H
+#define QPLATFORMDEFS_H
+
+// Get Qt defines/settings
+
+#include "qglobal.h"
+
+// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
+
+// 1) need to reset default environment if _BSD_SOURCE is defined
+// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0
+// 3) it seems older glibc need this to include the X/Open stuff
+#ifndef _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
+
+#include <unistd.h>
+
+
+// We are hot - unistd.h should have turned on the specific APIs we requested
+
+#include <features.h>
+#include <pthread.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <pwd.h>
+#include <signal.h>
+#include <dlfcn.h>
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/ipc.h>
+#include <sys/time.h>
+#include <sys/shm.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <netinet/in.h>
+#ifndef QT_NO_IPV6IFNAME
+#include <net/if.h>
+#endif
+
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_STATBUF              struct stat64
+#define QT_STATBUF4TSTAT        struct stat64
+#define QT_STAT                 ::stat64
+#define QT_FSTAT                ::fstat64
+#define QT_LSTAT                ::lstat64
+#define QT_OPEN                 ::open64
+#define QT_TRUNCATE             ::truncate64
+#define QT_FTRUNCATE            ::ftruncate64
+#define QT_LSEEK                ::lseek64
+#else
+#define QT_STATBUF              struct stat
+#define QT_STATBUF4TSTAT        struct stat
+#define QT_STAT                 ::stat
+#define QT_FSTAT                ::fstat
+#define QT_LSTAT                ::lstat
+#define QT_OPEN                 ::open
+#define QT_TRUNCATE             ::truncate
+#define QT_FTRUNCATE            ::ftruncate
+#define QT_LSEEK                ::lseek
+#endif
+
+#ifdef QT_LARGEFILE_SUPPORT
+#define QT_FOPEN                ::fopen64
+#define QT_FSEEK                ::fseeko64
+#define QT_FTELL                ::ftello64
+#define QT_FGETPOS              ::fgetpos64
+#define QT_FSETPOS              ::fsetpos64
+#define QT_FPOS_T               fpos64_t
+#define QT_OFF_T                off64_t
+#else
+#define QT_FOPEN                ::fopen
+#define QT_FSEEK                ::fseek
+#define QT_FTELL                ::ftell
+#define QT_FGETPOS              ::fgetpos
+#define QT_FSETPOS              ::fsetpos
+#define QT_FPOS_T               fpos_t
+#define QT_OFF_T                long
+#endif
+
+#define QT_STAT_REG		S_IFREG
+#define QT_STAT_DIR		S_IFDIR
+#define QT_STAT_MASK		S_IFMT
+#define QT_STAT_LNK		S_IFLNK
+#define QT_SOCKET_CONNECT	::connect
+#define QT_SOCKET_BIND		::bind
+#define QT_FILENO		fileno
+#define QT_CLOSE		::close
+#define QT_READ			::read
+#define QT_WRITE		::write
+#define QT_ACCESS		::access
+#define QT_GETCWD		::getcwd
+#define QT_CHDIR		::chdir
+#define QT_MKDIR		::mkdir
+#define QT_RMDIR		::rmdir
+#define QT_OPEN_LARGEFILE       O_LARGEFILE
+#define QT_OPEN_RDONLY		O_RDONLY
+#define QT_OPEN_WRONLY		O_WRONLY
+#define QT_OPEN_RDWR		O_RDWR
+#define QT_OPEN_CREAT		O_CREAT
+#define QT_OPEN_TRUNC		O_TRUNC
+#define QT_OPEN_APPEND		O_APPEND
+
+#define QT_SIGNAL_RETTYPE	void
+#define QT_SIGNAL_ARGS		int
+#define QT_SIGNAL_IGNORE	SIG_IGN
+
+#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+#define QT_SOCKLEN_T		socklen_t
+#else
+#define QT_SOCKLEN_T		int
+#endif
+
+#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+#define QT_SNPRINTF		::snprintf
+#define QT_VSNPRINTF		::vsnprintf
+#endif
+
+
+#endif // QPLATFORMDEFS_H
-- 
cgit v0.12


From 52e1c36f13a41883231880fab3f0160b02d3878e Mon Sep 17 00:00:00 2001
From: Leonardo Sobral Cunha <leo.cunha@nokia.com>
Date: Thu, 6 Aug 2009 11:20:59 +0200
Subject: Fixes autotest task253125_lineEditCompletion in QCompleter

Reviewed-by: paul
---
 tests/auto/qcompleter/tst_qcompleter.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index a65490d..4010752 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -1316,14 +1316,20 @@ void tst_QCompleter::task253125_lineEditCompletion()
     edit.show();
     edit.setFocus();
 
-    QTest::qWait(100);
+#ifdef Q_WS_X11
+    qt_x11_wait_for_window_manager(&edit);
+#endif
 
+    QTest::qWait(100);
     QTest::keyClick(&edit, 'i');
     QCOMPARE(edit.completer()->currentCompletion(), QString("iota"));
     QTest::keyClick(edit.completer()->popup(), Qt::Key_Down);
     QTest::keyClick(edit.completer()->popup(), Qt::Key_Enter);
 
     QCOMPARE(edit.text(), QString("iota"));
+
+    delete completer;
+    delete model;
 }
 
 void tst_QCompleter::task247560_keyboardNavigation()
-- 
cgit v0.12


From b743da8cff8b72a371214c1959e34d8cf9086aa3 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@trolltech.com>
Date: Thu, 6 Aug 2009 10:51:53 +0200
Subject: Fixed QComboBox test on slow window manager

---
 tests/auto/qcombobox/tst_qcombobox.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 67c9ac9..bd11fa4 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -2092,7 +2092,7 @@ void tst_QComboBox::task190205_setModelAdjustToContents()
 #endif
 
     // box should be resized to the same size as correctBox
-    QCOMPARE(box.size(), correctBox.size());
+    QTRY_COMPARE(box.size(), correctBox.size());
 }
 
 void tst_QComboBox::task248169_popupWithMinimalSize()
@@ -2199,7 +2199,7 @@ void tst_QComboBox::noScrollbar()
         QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible());
         QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible());
     }
-    
+
     {
         QTableWidget *table = new QTableWidget(2,2);
         QComboBox comboBox;
-- 
cgit v0.12


From dc4211f350e8d8cce19546b770c28b2a7a643042 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@trolltech.com>
Date: Thu, 6 Aug 2009 11:24:35 +0200
Subject: Fix compilation of the test

view doesn't exist anymore and the qWait should be enough to make the
x11 call useless
---
 tests/auto/qtableview/tst_qtableview.cpp | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 6fa57f0..eb39dd7 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -2542,7 +2542,7 @@ void tst_QTableView::span_data()
       << 2 << 1
       << false;
 
-  /* This makes no sens. 
+  /* This makes no sens.
     QTest::newRow("top left 2x0")
       << 10 << 10
       << -1 << -1
@@ -2631,7 +2631,7 @@ void tst_QTableView::span()
     view.hideRow(hiddenRow);
     view.hideColumn(hiddenColumn);
     view.show();
-    
+
     QCOMPARE(view.rowSpan(row, column), expectedRowSpan);
     QCOMPARE(view.columnSpan(row, column), expectedColumnSpan);
 
@@ -3110,14 +3110,14 @@ void tst_QTableView::task227953_setRootIndex()
     }
 
     tableView.setModel(&model);
-    
+
     //show the first 10 rows of the first table
     QModelIndex root = model.indexFromItem(&item1);
 	tableView.setRootIndex(root);
 	for (int i = 10; i != 40; ++i) {
 		tableView.setRowHidden(i, true);
 	}
-	
+
     QCOMPARE(tableView.verticalHeader()->count(), 40);
     QCOMPARE(tableView.verticalHeader()->hiddenSectionCount(), 30);
 
@@ -3139,16 +3139,13 @@ void tst_QTableView::task240266_veryBigColumn()
     table.setColumnWidth(1, 100); //normal column
     table.setColumnWidth(2, 9000); //very big column
     table.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
     QTest::qWait(100);
 
     QScrollBar *scroll = table.horizontalScrollBar();
     QCOMPARE(scroll->minimum(), 0);
     QCOMPARE(scroll->maximum(), model.columnCount() - 1);
     QCOMPARE(scroll->singleStep(), 1);
-    
+
     //1 is not always a very correct value for pageStep. Ideally this should be dynamic.
     //Maybe something for Qt 5 ;-)
     QCOMPARE(scroll->pageStep(), 1);
-- 
cgit v0.12


From 703844cffdfacca68fe5bff9e562997eea1568ab Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 11:24:05 +0200
Subject: Fix build for mingw

Unfortunately mingw doesn't know about the IFileDialog interface.
So it might have issues on Vista with a file dialog with search enabled.
---
 src/gui/dialogs/qfiledialog_win.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp
index 5fd341a..114456d 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/gui/dialogs/qfiledialog_win.cpp
@@ -59,7 +59,8 @@
 #endif
 
 #include <shlobj.h>
-#if !defined(Q_WS_WINCE)
+//At some point we can hope that mingw will support that interface
+#if !defined(Q_WS_WINCE) && !defined(Q_CC_MINGW)
 #include <shobjidl.h>
 #endif
 #include <objbase.h>
-- 
cgit v0.12


From 62d87f9144728251450066dc41a06ad176fb4379 Mon Sep 17 00:00:00 2001
From: Leonardo Sobral Cunha <leo.cunha@nokia.com>
Date: Thu, 6 Aug 2009 11:26:22 +0200
Subject: Fixes one more autotest in QCompleter: task247560_keyboardNavigation

Reviewed-by: paul
---
 tests/auto/qcompleter/tst_qcompleter.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 4010752..9c436fa 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -1351,6 +1351,10 @@ void tst_QCompleter::task247560_keyboardNavigation()
     edit.show();
     edit.setFocus();
 
+#ifdef Q_WS_X11
+    qt_x11_wait_for_window_manager(&edit);
+#endif
+
     QTest::qWait(100);
 
     QTest::keyClick(&edit, 'r');
-- 
cgit v0.12


From 5e7c47537f0f9599959388670ebd8fe910d9c0f1 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@trolltech.com>
Date: Thu, 6 Aug 2009 11:31:03 +0200
Subject: Fix the setStyleShouldChangeSpacing test function for Mac.

---
 tests/auto/qboxlayout/tst_qboxlayout.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/auto/qboxlayout/tst_qboxlayout.cpp b/tests/auto/qboxlayout/tst_qboxlayout.cpp
index be6f3dd..642bc77 100644
--- a/tests/auto/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/qboxlayout/tst_qboxlayout.cpp
@@ -222,6 +222,8 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing()
     QHBoxLayout *hbox = new QHBoxLayout(window);
     QPushButton *pb1 = new QPushButton(tr("The spacing between this"));
     QPushButton *pb2 = new QPushButton(tr("and this button should depend on the style of the parent widget"));;
+    pb1->setAttribute(Qt::WA_LayoutUsesWidgetRect);
+    pb2->setAttribute(Qt::WA_LayoutUsesWidgetRect);
     hbox->addWidget(pb1);
     hbox->addWidget(pb2);
     CustomLayoutStyle *style1 = new CustomLayoutStyle;
-- 
cgit v0.12


From d90f1e4ff7a077daf59f5f035cf6744fe732f843 Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Wed, 5 Aug 2009 14:29:14 +0200
Subject: Rearranged the gesture code a bit for future native gestures on
 Windows.

Moved the code that subscribes to native gestures on Windows to a private
function in QWidget which will check which gestures the widget is subscribed to
and enable native gestures as requested.

Reviewed-by: trustme
---
 src/gui/kernel/qapplication_p.h         | 14 +++++----
 src/gui/kernel/qapplication_win.cpp     |  2 --
 src/gui/kernel/qstandardgestures.cpp    | 22 ++++++++++-----
 src/gui/kernel/qwidget.cpp              |  2 --
 src/gui/kernel/qwidget_p.h              |  1 +
 src/gui/kernel/qwidget_win.cpp          | 50 +++++++++++++++++++++++++++++++++
 src/gui/widgets/qabstractscrollarea.cpp | 32 ++++-----------------
 src/gui/widgets/qabstractscrollarea.h   |  1 +
 src/gui/widgets/qabstractscrollarea_p.h |  1 -
 9 files changed, 80 insertions(+), 45 deletions(-)

diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 595f220..700d1ab 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -234,6 +234,8 @@ typedef struct tagGESTUREINFO
 #  define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY        0x00000002
 #  define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY      0x00000004
 
+#  define GC_ZOOM                                     0x00000001
+
 typedef struct tagGESTURECONFIG
 {
     DWORD dwID;
@@ -247,11 +249,12 @@ typedef struct tagGESTURECONFIG
 
 class QPanGesture;
 class QPinchGesture;
-struct StandardGestures
+struct QStandardGestures
 {
     QPanGesture *pan;
     QPinchGesture *pinch;
-    StandardGestures() : pan(0), pinch(0) { }
+
+    QStandardGestures() : pan(0), pinch(0) { }
 };
 
 
@@ -513,6 +516,9 @@ public:
                                        QTouchEvent::DeviceType deviceType,
                                        const QList<QTouchEvent::TouchPoint> &touchPoints);
 
+    typedef QMap<QWidget*, QStandardGestures> WidgetStandardGesturesMap;
+    WidgetStandardGesturesMap widgetGestures;
+
 #if defined(Q_WS_WIN)
     static PtrRegisterTouchWindow RegisterTouchWindow;
     static PtrGetTouchInputInfo GetTouchInputInfo;
@@ -522,10 +528,6 @@ public:
     QList<QTouchEvent::TouchPoint> appAllTouchPoints;
     bool translateTouchEvent(const MSG &msg);
 
-    typedef QMap<QWidget*, StandardGestures> WidgetStandardGesturesMap;
-    WidgetStandardGesturesMap widgetGestures;
-    ulong lastGestureId;
-
     PtrGetGestureInfo GetGestureInfo;
     PtrGetGestureExtraArgs GetGestureExtraArgs;
     PtrCloseGestureInfoHandle CloseGestureInfoHandle;
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 2bded5c..3177cc1 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -815,8 +815,6 @@ void qt_init(QApplicationPrivate *priv, int)
         ptrSetProcessDPIAware();
 #endif
 
-    priv->lastGestureId = 0;
-
     priv->GetGestureInfo =
         (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"),
                                              "GetGestureInfo");
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 4753416..2a5e7e8 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -46,11 +46,13 @@
 #include <qscrollbar.h>
 #include <private/qapplication_p.h>
 #include <private/qevent_p.h>
+#include <private/qwidget_p.h>
 
 QT_BEGIN_NAMESPACE
 
 #ifdef Q_WS_WIN
 QApplicationPrivate* getQApplicationPrivateInternal();
+QWidgetPrivate *qt_widget_private(QWidget *widget);
 #endif
 
 /*!
@@ -71,32 +73,38 @@ QApplicationPrivate* getQApplicationPrivateInternal();
 QPanGesture::QPanGesture(QWidget *parent)
     : QGesture(*new QPanGesturePrivate, parent)
 {
-#ifdef Q_WS_WIN
     if (parent) {
         QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
         qAppPriv->widgetGestures[parent].pan = this;
-    }
+#ifdef Q_WS_WIN
+        qt_widget_private(parent)->winSetupGestures();
 #endif
+    }
 }
 
 /*! \internal */
 bool QPanGesture::event(QEvent *event)
 {
-#ifdef Q_WS_WIN
-    QApplicationPrivate* getQApplicationPrivateInternal();
     switch (event->type()) {
     case QEvent::ParentAboutToChange:
-        if (QWidget *w = qobject_cast<QWidget*>(parent()))
+        if (QWidget *w = qobject_cast<QWidget*>(parent())) {
             getQApplicationPrivateInternal()->widgetGestures[w].pan = 0;
+#ifdef Q_WS_WIN
+            qt_widget_private(w)->winSetupGestures();
+#endif
+        }
         break;
     case QEvent::ParentChange:
-        if (QWidget *w = qobject_cast<QWidget*>(parent()))
+        if (QWidget *w = qobject_cast<QWidget*>(parent())) {
             getQApplicationPrivateInternal()->widgetGestures[w].pan = this;
+#ifdef Q_WS_WIN
+            qt_widget_private(w)->winSetupGestures();
+#endif
+        }
         break;
     default:
         break;
     }
-#endif
 
 #if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
     Q_D(QPanGesture);
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index a827967..50343fc 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -11114,8 +11114,6 @@ Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget)
 }
 
 
-
-
 #ifndef QT_NO_GRAPHICSVIEW
 /*!
    \since 4.5
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 998181e..ac145b7 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -558,6 +558,7 @@ public:
 #endif
     void grabMouseWhileInWindow();
     void registerTouchWindow();
+    void winSetupGestures();
 #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
     // This is new stuff
     uint needWindowChange : 1;
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index b11b661..ce853d2 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -56,6 +56,10 @@
 #include "private/qbackingstore_p.h"
 #include "private/qwindowsurface_raster_p.h"
 
+#include "qscrollbar.h"
+#include "qabstractscrollarea.h"
+#include <private/qabstractscrollarea_p.h>
+
 #include <qdebug.h>
 
 #include <private/qapplication_p.h>
@@ -2049,6 +2053,52 @@ void QWidgetPrivate::registerTouchWindow()
         QApplicationPrivate::RegisterTouchWindow(q->effectiveWinId(), 0);
 }
 
+void QWidgetPrivate::winSetupGestures()
+{
+    Q_Q(QWidget);
+    QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+    bool needh = false;
+    bool needv = false;
+    bool singleFingerPanEnabled = false;
+    QStandardGestures gestures = qAppPriv->widgetGestures[q];
+    WId winid = 0;
+
+    if (QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea*>(q)) {
+        winid = asa->viewport()->winId();
+        QScrollBar *hbar = asa->horizontalScrollBar();
+        QScrollBar *vbar = asa->verticalScrollBar();
+        Qt::ScrollBarPolicy hbarpolicy = asa->horizontalScrollBarPolicy();
+        Qt::ScrollBarPolicy vbarpolicy = asa->verticalScrollBarPolicy();
+        needh = (hbarpolicy == Qt::ScrollBarAlwaysOn
+                 || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum()));
+        needv = (vbarpolicy == Qt::ScrollBarAlwaysOn
+                 || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
+        singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled;
+    }
+    if (qAppPriv->SetGestureConfig) {
+        GESTURECONFIG gc[2];
+        gc[0].dwID = GID_PAN;
+        if (gestures.pan || needh || needv) {
+            gc[0].dwWant = GC_PAN;
+            gc[0].dwBlock = 0;
+            if (needv && singleFingerPanEnabled)
+                gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
+            if (needh && singleFingerPanEnabled)
+                gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
+        } else {
+            gc[0].dwWant = 0;
+            gc[0].dwBlock = GC_PAN;
+        }
+
+        gc[1].dwID = GID_ZOOM;
+        if (gestures.pinch) {
+            gc[1].dwWant = GC_ZOOM;
+            gc[1].dwBlock = 0;
+        }
+        qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0]));
+    }
+}
+
 QT_END_NAMESPACE
 
 #ifdef Q_WS_WINCE
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index dd92e17..e803afc 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -296,32 +296,6 @@ void QAbstractScrollAreaPrivate::init()
     layoutChildren();
 }
 
-void QAbstractScrollAreaPrivate::setupGestures()
-{
-#ifdef Q_OS_WIN
-    if (!viewport)
-        return;
-    QApplicationPrivate* getQApplicationPrivateInternal();
-    QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
-    bool needh = (hbarpolicy == Qt::ScrollBarAlwaysOn
-                  || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum()));
-
-    bool needv = (vbarpolicy == Qt::ScrollBarAlwaysOn
-                  || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
-    if (qAppPriv->SetGestureConfig && (needh || needv)) {
-        GESTURECONFIG gc[1];
-        gc[0].dwID = GID_PAN;
-        gc[0].dwWant = GC_PAN;
-        gc[0].dwBlock = 0;
-        if (needv && singleFingerPanEnabled)
-            gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
-        if (needh && singleFingerPanEnabled)
-            gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
-        qAppPriv->SetGestureConfig(viewport->winId(), 0, 1, gc, sizeof(gc));
-    }
-#endif // Q_OS_WIN
-}
-
 void QAbstractScrollAreaPrivate::layoutChildren()
 {
     Q_Q(QAbstractScrollArea);
@@ -1267,7 +1241,11 @@ void QAbstractScrollAreaPrivate::_q_vslide(int y)
 void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars()
 {
     layoutChildren();
-    setupGestures();
+#ifdef Q_OS_WIN
+    // Need to re-subscribe to gestures as the content changes to make sure we
+    // enable/disable panning when needed.
+    winSetupGestures();
+#endif // Q_OS_WIN
 }
 
 QPoint QAbstractScrollAreaPrivate::contentsOffset() const
diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h
index 3ec41d1..c7441c1 100644
--- a/src/gui/widgets/qabstractscrollarea.h
+++ b/src/gui/widgets/qabstractscrollarea.h
@@ -130,6 +130,7 @@ private:
     Q_PRIVATE_SLOT(d_func(), void _q_showOrHideScrollBars())
 
     friend class QStyleSheetStyle;
+    friend class QWidgetPrivate;
 };
 
 #endif // QT_NO_SCROLLAREA
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index aef8ac5..9a6b923 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -103,7 +103,6 @@ public:
 #ifdef Q_WS_WIN
     bool singleFingerPanEnabled;
 #endif
-    void setupGestures();
 };
 
 class QAbstractScrollAreaFilter : public QObject
-- 
cgit v0.12


From 1a97230e908193c9a260ae68635301c0e9f9f8de Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Wed, 5 Aug 2009 16:25:08 +0200
Subject: Changed setting state in a QGesture

Instead of having a protected setter for the state and forcing the application
developer to emit signals manually (which leads to misunderstanding - i.e. if
the started() signal should be emitted only once, or of the triggered() signal
should be emitted before the finished() signal, etc). So I've added an
protected updateState(state) function that sets the internal state and emits
appropriate signals depending on the old and new states.

Reviewed-by: Volker Hilsheimer
Reviewed-by: Richard Moe Gustavsen
---
 src/gui/kernel/qgesture.cpp          | 48 ++++++++++++++++++++++++++++++------
 src/gui/kernel/qgesture.h            |  2 +-
 src/gui/kernel/qstandardgestures.cpp | 43 +++++++++-----------------------
 src/gui/kernel/qwidget_win.cpp       |  2 ++
 4 files changed, 55 insertions(+), 40 deletions(-)

diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index 8075ad9..38e8851 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -197,11 +197,44 @@ Qt::GestureState QGesture::state() const
 }
 
 /*!
-  Sets this gesture's recognition state to \a state.
+  Sets this gesture's recognition state to \a state and emits appropriate
+  signals.
+
+  This functions emits the signals according to the old state and the new
+  \a state, and it should be called after all the internal properties have been
+  initialized.
+
+  \sa started, triggered, finished, cancelled
  */
-void QGesture::setState(Qt::GestureState state)
+void QGesture::updateState(Qt::GestureState state)
 {
-    d_func()->state = state;
+    Q_D(QGesture);
+    if (d->state == state) {
+        if (state == Qt::GestureUpdated)
+            emit triggered();
+        return;
+    }
+    const Qt::GestureState oldState = d->state;
+    d->state = state;
+    if (state != Qt::NoGesture && oldState > state) {
+        // comparing the state as ints: state should only be changed from
+        // started to (optionally) updated and to finished.
+        qWarning("QGesture::updateState: incorrect new state");
+        return;
+    }
+    if (oldState == Qt::NoGesture)
+        emit started();
+    if (state == Qt::GestureUpdated)
+        emit triggered();
+    else if (state == Qt::GestureFinished)
+        emit finished();
+    else if (state == Qt::NoGesture)
+        emit cancelled();
+
+    if (state == Qt::GestureFinished) {
+        // gesture is finished, so we reset the internal state.
+        d->state = Qt::NoGesture;
+    }
 }
 
 /*!
@@ -238,14 +271,13 @@ QGraphicsItem* QGesture::graphicsItem() const
 
     Resets the internal state of the gesture. This function might be called by
     the filterEvent() implementation in a derived class, or by the user to
-    cancel a gesture.  The base class implementation emits the cancelled()
-    signal if the state() of the gesture wasn't empty.
+    cancel a gesture.  The base class implementation calls
+    updateState(Qt::NoGesture) which emits the cancelled()
+    signal if the state() of the gesture indicated it was active.
 */
 void QGesture::reset()
 {
-    if (state() != Qt::NoGesture)
-        emit cancelled();
-    setState(Qt::NoGesture);
+    updateState(Qt::NoGesture);
 }
 
 QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
index 0735160..7da37c4 100644
--- a/src/gui/kernel/qgesture.h
+++ b/src/gui/kernel/qgesture.h
@@ -81,7 +81,7 @@ protected:
     QGesture(QGesturePrivate &dd, QObject *parent);
     bool eventFilter(QObject*, QEvent*);
 
-    void setState(Qt::GestureState state);
+    void updateState(Qt::GestureState state);
 
 Q_SIGNALS:
     void started();
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 2a5e7e8..89de7c8 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -114,9 +114,7 @@ bool QPanGesture::event(QEvent *event)
             killTimer(d->panFinishedTimer);
             d->panFinishedTimer = 0;
             d->lastOffset = QSize(0, 0);
-            setState(Qt::GestureFinished);
-            emit triggered();
-            setState(Qt::NoGesture);
+            updateState(Qt::GestureFinished);
         }
     }
 #endif
@@ -127,6 +125,7 @@ bool QPanGesture::event(QEvent *event)
 bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
 {
 #ifdef Q_WS_WIN
+    Q_D(QPanGesture);
     if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) {
         QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
         QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
@@ -135,30 +134,28 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
         if (it == qAppPriv->widgetGestures.end())
             return false;
         QPanGesture *gesture = it.value().pan;
-        if (!gesture)
+        if (this != gesture)
             return false;
-        Qt::GestureState nextState = state();
+        Qt::GestureState nextState = Qt::NoGesture;
         switch(ev->gestureType) {
         case QNativeGestureEvent::GestureBegin:
             // next we might receive the first gesture update event, so we
             // prepare for it.
-            setState(Qt::GestureStarted);
+            d->state = Qt::NoGesture;
             return false;
         case QNativeGestureEvent::Pan:
             nextState = Qt::GestureUpdated;
+            event->accept();
             break;
         case QNativeGestureEvent::GestureEnd:
-            if (state() != QNativeGestureEvent::Pan)
+            if (state() == Qt::NoGesture)
                 return false; // some other gesture has ended
-            setState(Qt::GestureFinished);
             nextState = Qt::GestureFinished;
             break;
         default:
             return false;
         }
-        QPanGesturePrivate *d = gesture->d_func();
-        if (state() == Qt::GestureStarted) {
-            d->lastPosition = ev->position;
+        if (state() == Qt::NoGesture) {
             d->lastOffset = d->totalOffset = QSize();
         } else {
             d->lastOffset = QSize(ev->position.x() - d->lastPosition.x(),
@@ -166,14 +163,7 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
             d->totalOffset += d->lastOffset;
         }
         d->lastPosition = ev->position;
-
-        if (state() == Qt::GestureStarted)
-            emit gesture->started();
-        emit gesture->triggered();
-        if (state() == Qt::GestureFinished)
-            emit gesture->finished();
-        event->accept();
-        gesture->setState(nextState);
+        gesture->updateState(nextState);
         return true;
     }
 #endif
@@ -193,7 +183,6 @@ bool QPanGesture::filterEvent(QEvent *event)
         d->lastOffset = d->totalOffset = QSize();
     } else if (event->type() == QEvent::TouchEnd) {
         if (state() != Qt::NoGesture) {
-            setState(Qt::GestureFinished);
             if (!ev->touchPoints().isEmpty()) {
                 QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
                 const QPoint pos = p.pos().toPoint();
@@ -202,10 +191,8 @@ bool QPanGesture::filterEvent(QEvent *event)
                 d->lastOffset = QSize(pos.x() - lastPos.x(), pos.y() - lastPos.y());
                 d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y());
             }
-            emit triggered();
-            emit finished();
+            updateState(Qt::GestureFinished);
         }
-        setState(Qt::NoGesture);
         reset();
     } else if (event->type() == QEvent::TouchUpdate) {
         QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
@@ -216,11 +203,7 @@ bool QPanGesture::filterEvent(QEvent *event)
         d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y());
         if (d->totalOffset.width() > 10  || d->totalOffset.height() > 10 ||
             d->totalOffset.width() < -10 || d->totalOffset.height() < -10) {
-            if (state() == Qt::NoGesture)
-                setState(Qt::GestureStarted);
-            else
-                setState(Qt::GestureUpdated);
-            emit triggered();
+            updateState(Qt::GestureUpdated);
         }
     }
 #ifdef Q_OS_MAC
@@ -239,16 +222,14 @@ bool QPanGesture::filterEvent(QEvent *event)
         d->lastOffset = wev->orientation() == Qt::Horizontal ? QSize(offset, 0) : QSize(0, offset);
 
         if (state() == Qt::NoGesture) {
-            setState(Qt::GestureStarted);
             d->totalOffset = d->lastOffset;
         } else {
-            setState(Qt::GestureUpdated);
             d->totalOffset += d->lastOffset;
         }
 
         killTimer(d->panFinishedTimer);
         d->panFinishedTimer = startTimer(200);
-        emit triggered();
+        updateState(Qt::GestureUpdated);
 #endif
         return true;
     }
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index ce853d2..6647f3f 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -2074,6 +2074,8 @@ void QWidgetPrivate::winSetupGestures()
         needv = (vbarpolicy == Qt::ScrollBarAlwaysOn
                  || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
         singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled;
+    } else {
+        winid = q->winId();
     }
     if (qAppPriv->SetGestureConfig) {
         GESTURECONFIG gc[2];
-- 
cgit v0.12


From 241e5cbe235953c60a6d8db2a8b6aacd909c2d28 Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Wed, 5 Aug 2009 16:58:50 +0200
Subject: Enable pan gesture on all QAbstractScrollArea-based widgets.

Two-finger panning will work on all QAbstractScrollArea based widgets, however
single-finger panning will be enabled only on some special widgets that always
wants it - for example we don't want it on QGraphicsView, and we might want it
on itemviews *sometimes*.

Reviewed-by: trustme
---
 src/gui/kernel/qwidget_win.cpp          |  3 +++
 src/gui/widgets/qabstractscrollarea.cpp | 32 +++++++++++++++++++++++++++++++-
 src/gui/widgets/qabstractscrollarea.h   |  1 +
 src/gui/widgets/qabstractscrollarea_p.h |  4 ++++
 src/gui/widgets/qtextedit.cpp           | 24 +-----------------------
 src/gui/widgets/qtextedit.h             |  1 -
 src/gui/widgets/qtextedit_p.h           |  4 ----
 7 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 6647f3f..d8bee55 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -2056,6 +2056,8 @@ void QWidgetPrivate::registerTouchWindow()
 void QWidgetPrivate::winSetupGestures()
 {
     Q_Q(QWidget);
+    if (!q)
+        return;
     QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
     bool needh = false;
     bool needv = false;
@@ -2097,6 +2099,7 @@ void QWidgetPrivate::winSetupGestures()
             gc[1].dwWant = GC_ZOOM;
             gc[1].dwBlock = 0;
         }
+        Q_ASSERT(winid);
         qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0]));
     }
 }
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index e803afc..f6c1892 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE
 QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
     :hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),
      viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0),
-     xoffset(0), yoffset(0), viewportFilter(0)
+     xoffset(0), yoffset(0), viewportFilter(0), panGesture(0)
 #ifdef Q_WS_WIN
      , singleFingerPanEnabled(false)
 #endif
@@ -294,7 +294,18 @@ void QAbstractScrollAreaPrivate::init()
     q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
     q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     layoutChildren();
+
+    panGesture = new QPanGesture(q);
+    QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
+}
+
+#ifdef Q_WS_WIN
+void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on)
+{
+    singleFingerPanEnabled = on;
+    winSetupGestures();
 }
+#endif // Q_WS_WIN
 
 void QAbstractScrollAreaPrivate::layoutChildren()
 {
@@ -1310,6 +1321,25 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport)
     Q_UNUSED(viewport);
 }
 
+void QAbstractScrollAreaPrivate::_q_gestureTriggered()
+{
+    Q_Q(QAbstractScrollArea);
+    QPanGesture *g = qobject_cast<QPanGesture*>(q->sender());
+    if (!g)
+        return;
+    QScrollBar *hBar = q->horizontalScrollBar();
+    QScrollBar *vBar = q->verticalScrollBar();
+    QSize delta = g->lastOffset();
+    if (!delta.isNull()) {
+        if (QApplication::isRightToLeft())
+            delta.rwidth() *= -1;
+        int newX = hBar->value() - delta.width();
+        int newY = vBar->value() - delta.height();
+        hbar->setValue(newX);
+        vbar->setValue(newY);
+    }
+}
+
 QT_END_NAMESPACE
 
 #include "moc_qabstractscrollarea.cpp"
diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h
index c7441c1..9178629 100644
--- a/src/gui/widgets/qabstractscrollarea.h
+++ b/src/gui/widgets/qabstractscrollarea.h
@@ -128,6 +128,7 @@ private:
     Q_PRIVATE_SLOT(d_func(), void _q_hslide(int))
     Q_PRIVATE_SLOT(d_func(), void _q_vslide(int))
     Q_PRIVATE_SLOT(d_func(), void _q_showOrHideScrollBars())
+    Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered())
 
     friend class QStyleSheetStyle;
     friend class QWidgetPrivate;
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index 9a6b923..8011ed5 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE
 
 #ifndef QT_NO_SCROLLAREA
 
+class QPanGesture;
 class QScrollBar;
 class QAbstractScrollAreaScrollBarContainer;
 class Q_AUTOTEST_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
@@ -100,8 +101,11 @@ public:
     { return q_func()->viewportEvent(event); }
     QObject *viewportFilter;
 
+    virtual void _q_gestureTriggered();
+    QPanGesture *panGesture;
 #ifdef Q_WS_WIN
     bool singleFingerPanEnabled;
+    void setSingleFingerPanEnabled(bool on = true);
 #endif
 };
 
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index c095f5c..0a41d74 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -114,7 +114,7 @@ QTextEditPrivate::QTextEditPrivate()
     showCursorOnInitialShow = true;
     inDrag = false;
 #ifdef Q_WS_WIN
-    singleFingerPanEnabled = true;
+    setSingleFingerPanEnabled(true);
 #endif
 }
 
@@ -183,8 +183,6 @@ void QTextEditPrivate::init(const QString &html)
 #ifndef QT_NO_CURSOR
     viewport->setCursor(Qt::IBeamCursor);
 #endif
-    panGesture = new QPanGesture(q);
-    QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
 }
 
 void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
@@ -2617,26 +2615,6 @@ void QTextEdit::ensureCursorVisible()
     d->control->ensureCursorVisible();
 }
 
-void QTextEditPrivate::_q_gestureTriggered()
-{
-    Q_Q(QTextEdit);
-    QPanGesture *g = qobject_cast<QPanGesture*>(q->sender());
-    if (!g)
-        return;
-    QScrollBar *hBar = q->horizontalScrollBar();
-    QScrollBar *vBar = q->verticalScrollBar();
-    QSize delta = g->lastOffset();
-    if (!delta.isNull()) {
-        if (QApplication::isRightToLeft())
-            delta.rwidth() *= -1;
-        int newX = hBar->value() - delta.width();
-        int newY = vBar->value() - delta.height();
-        hbar->setValue(newX);
-        vbar->setValue(newY);
-    }
-}
-
-
 /*!
     \enum QTextEdit::KeyboardAction
 
diff --git a/src/gui/widgets/qtextedit.h b/src/gui/widgets/qtextedit.h
index 9e10e07..617822a 100644
--- a/src/gui/widgets/qtextedit.h
+++ b/src/gui/widgets/qtextedit.h
@@ -414,7 +414,6 @@ private:
     Q_PRIVATE_SLOT(d_func(), void _q_currentCharFormatChanged(const QTextCharFormat &))
     Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
     Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &))
-    Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered())
     friend class QTextEditControl;
     friend class QTextDocument;
     friend class QTextControl;
diff --git a/src/gui/widgets/qtextedit_p.h b/src/gui/widgets/qtextedit_p.h
index 249331e..3d14af6 100644
--- a/src/gui/widgets/qtextedit_p.h
+++ b/src/gui/widgets/qtextedit_p.h
@@ -70,7 +70,6 @@ QT_BEGIN_NAMESPACE
 #ifndef QT_NO_TEXTEDIT
 
 class QMimeData;
-class QPanGesture;
 class QTextEditPrivate : public QAbstractScrollAreaPrivate
 {
     Q_DECLARE_PUBLIC(QTextEdit)
@@ -129,9 +128,6 @@ public:
 
     QString anchorToScrollToWhenVisible;
 
-    void _q_gestureTriggered();
-    QPanGesture *panGesture;
-
 #ifdef QT_KEYPAD_NAVIGATION
     QBasicTimer deleteAllTimer;
 #endif
-- 
cgit v0.12


From 32f1e151cb66da08b8c7578b0701408fcb009ea2 Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Wed, 5 Aug 2009 18:02:48 +0200
Subject: Small fix for native gestures on windows.

We should close the gestureinfo handle only we managed to open successfully.

Reviewed-by: trustme
---
 src/gui/kernel/qapplication_win.cpp | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 3177cc1..6421ed9 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -3716,13 +3716,8 @@ bool QETWidget::translateCloseEvent(const MSG &)
 bool QETWidget::translateGestureEvent(const MSG &msg)
 {
     GESTUREINFO gi;
+    memset(&gi, 0, sizeof(GESTUREINFO));
     gi.cbSize = sizeof(GESTUREINFO);
-    gi.dwFlags       = 0;
-    gi.ptsLocation.x = 0;
-    gi.ptsLocation.y = 0;
-    gi.dwID          = 0;
-    gi.dwInstanceID  = 0;
-    gi.dwSequenceID  = 0;
 
     QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
     BOOL bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi);
@@ -3756,6 +3751,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
         default:
             break;
         }
+        qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
         if (event.gestureType != QNativeGestureEvent::None)
             qt_sendSpontaneousEvent(widget, &event);
     } else {
@@ -3763,7 +3759,6 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
         if (dwErr > 0)
             qWarning() << "translateGestureEvent: error = " << dwErr;
     }
-    qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
     return true;
 }
 
-- 
cgit v0.12


From 552a7cf157da9c8d2b811b3123138b52dde072f7 Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Fri, 31 Jul 2009 14:47:07 +0200
Subject: Added some debug output to the qdesktopwidget manualtest

To make sure we don't receive same signals several times from a
QDesktopWidget, added the debug output whenever the signal is emitted.

Reviewed-by: trustme
---
 tests/manual/qdesktopwidget/main.cpp | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tests/manual/qdesktopwidget/main.cpp b/tests/manual/qdesktopwidget/main.cpp
index 2cbdfb9..653a5fc 100644
--- a/tests/manual/qdesktopwidget/main.cpp
+++ b/tests/manual/qdesktopwidget/main.cpp
@@ -53,8 +53,11 @@ public:
 
         QDesktopWidget *desktop = QApplication::desktop();
         connect(desktop, SIGNAL(resized(int)), this, SLOT(updateScene()));
+        connect(desktop, SIGNAL(resized(int)), this, SLOT(desktopResized(int)));
         connect(desktop, SIGNAL(workAreaResized(int)), this, SLOT(updateScene()));
+        connect(desktop, SIGNAL(workAreaResized(int)), this, SLOT(desktopWorkAreaResized(int)));
         connect(desktop, SIGNAL(screenCountChanged(int)), this, SLOT(updateScene()));
+        connect(desktop, SIGNAL(screenCountChanged(int)), this, SLOT(desktopScreenCountChanged(int)));
 
         updateScene();
 
@@ -63,6 +66,7 @@ public:
         setTransform(transform);
 
         setBackgroundBrush(Qt::darkGray);
+        desktopScreenCountChanged(-1);
     }
 
 protected:
@@ -169,6 +173,33 @@ private slots:
         return rect;
     }
 
+    void desktopResized(int screen)
+    {
+        qDebug() << "Screen was resized: " << screen
+                << ", new size =" << QApplication::desktop()->screenGeometry(screen);
+    }
+    void desktopWorkAreaResized(int screen)
+    {
+        qDebug() << "Screen workarea was resized: " << screen
+                << ", new size =" << QApplication::desktop()->availableGeometry(screen);
+    }
+    void desktopScreenCountChanged(int screenCount)
+    {
+        QDesktopWidget *desktop = QApplication::desktop();
+        qDebug() << "";
+        if (screenCount != -1) {
+            qDebug() << "Screen count was changed to " << screenCount;
+        } else {
+            screenCount = desktop->screenCount();
+            qDebug() << "Screen count: " << screenCount;
+        }
+        for (int i = 0; i < screenCount; ++i) {
+            qDebug() << "  #" << i << ": geometry =" << desktop->screenGeometry(i)
+                    << "; available geometry =" << desktop->availableGeometry(i);
+        }
+        qDebug() << "";
+    }
+
 private:
     QGraphicsScene *scene;
     QGraphicsRectItem *that;
-- 
cgit v0.12


From 69597149e606a3d8a22a2ea7c2964b799751d898 Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Thu, 6 Aug 2009 11:52:01 +0200
Subject: Fixes a regression in qwidget when setting a large minimum size.

Setting a minimum size to a value that is larger then the biggest
allowed widget size, we should costrain the widget to that max allowed
size as we did before. Change 6a2621b6832dbdd349f77cf1f3242b4a6ba3c740
broke it.

Reviewed-by: Bradley T. Hughes
---
 src/gui/kernel/qwidget.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 50343fc..60a6b7a 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -3480,27 +3480,27 @@ bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh)
         }
     }
 #endif
+    int mw = minw, mh = minh;
+    if (mw == QWIDGETSIZE_MAX)
+        mw = 0;
+    if (mh == QWIDGETSIZE_MAX)
+        mh = 0;
     if (minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX) {
         qWarning("QWidget::setMinimumSize: (%s/%s) "
                 "The largest allowed size is (%d,%d)",
                  q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX,
                 QWIDGETSIZE_MAX);
-        minw = qMin<int>(minw, QWIDGETSIZE_MAX);
-        minh = qMin<int>(minh, QWIDGETSIZE_MAX);
+        minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX);
+        minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX);
     }
     if (minw < 0 || minh < 0) {
         qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) "
                 "are not possible",
                 q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh);
-        minw = qMax(minw, 0);
-        minh = qMax(minh, 0);
+        minw = mw = qMax(minw, 0);
+        minh = mh = qMax(minh, 0);
     }
     createExtra();
-    int mw = minw, mh = minh;
-    if (mw == QWIDGETSIZE_MAX)
-        mw = 0;
-    if (mh == QWIDGETSIZE_MAX)
-        mh = 0;
     if (extra->minw == mw && extra->minh == mh)
         return false;
     extra->minw = mw;
-- 
cgit v0.12


From cb484634624d227feacc71c0463899968317c2d1 Mon Sep 17 00:00:00 2001
From: "Bradley T. Hughes" <bradley.hughes@nokia.com>
Date: Thu, 6 Aug 2009 12:17:40 +0200
Subject: Support _NET_WORKAREA on Xinerama setups in QDesktopWidget

Instead of ignoring _NET_WORKAREA, merge it with each screen geometry
to give a meaningful availableGeometry() for all screens.

Reviewed-by: denis
---
 src/gui/kernel/qdesktopwidget_x11.cpp            | 26 ++++++++++++++++--------
 tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp | 12 +++++++++--
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/gui/kernel/qdesktopwidget_x11.cpp
index 1555fc0..8b0c215 100644
--- a/src/gui/kernel/qdesktopwidget_x11.cpp
+++ b/src/gui/kernel/qdesktopwidget_x11.cpp
@@ -285,26 +285,36 @@ const QRect QDesktopWidget::availableGeometry(int screen) const
     if (d->workareas[screen].isValid())
         return d->workareas[screen];
 
-    if ((d->screenCount == 1 || !isVirtualDesktop())
-        && X11->isSupportedByWM(ATOM(_NET_WORKAREA))) {
+    if (X11->isSupportedByWM(ATOM(_NET_WORKAREA))) {
+        int x11Screen = isVirtualDesktop() ? DefaultScreen(X11->display) : screen;
+
         Atom ret;
         int format, e;
         unsigned char *data = 0;
         unsigned long nitems, after;
 
         e = XGetWindowProperty(X11->display,
-                                QX11Info::appRootWindow(screen),
-                                ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
-                                &ret, &format, &nitems, &after, &data);
+                               QX11Info::appRootWindow(x11Screen),
+                               ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
+                               &ret, &format, &nitems, &after, &data);
 
+        QRect workArea;
         if (e == Success && ret == XA_CARDINAL &&
             format == 32 && nitems == 4) {
             long *workarea = (long *) data;
-            d->workareas[screen].setRect(workarea[0], workarea[1],
-                                          workarea[2], workarea[3]);
+            workArea = QRect(workarea[0], workarea[1], workarea[2], workarea[3]);
         } else {
-            d->workareas[screen] = screenGeometry(screen);
+            workArea = screenGeometry(screen);
+        }
+
+        if (isVirtualDesktop()) {
+            // intersect the workarea (which spawns all Xinerama screens) with the rect for the
+            // requested screen
+            workArea &= screenGeometry(screen);
         }
+
+        d->workareas[screen] = workArea;
+
         if (data)
             XFree(data);
     } else {
diff --git a/tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp b/tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp
index c6fac8d..d2b0d8a 100644
--- a/tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp
+++ b/tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp
@@ -99,9 +99,17 @@ void tst_QDesktopWidget::availableGeometry()
 {
     QDesktopWidget desktop;
 
-    QRect total = desktop.screenGeometry();
-    QRect available = desktop.availableGeometry();
+    QRect total;
+    QRect available;
 
+    for (int i = 0; i < desktop.screenCount(); ++i) {
+        total = desktop.screenGeometry(i);
+        available = desktop.availableGeometry(i);
+        QVERIFY(total.contains(available));
+    }
+
+    total = desktop.screenGeometry();
+    available = desktop.availableGeometry();
     QVERIFY(total.contains(available));
     QCOMPARE(desktop.availableGeometry(desktop.primaryScreen()), available);
     QCOMPARE(desktop.screenGeometry(desktop.primaryScreen()), total);
-- 
cgit v0.12


From 8fa64f0311af6373a8c258df390d39cc98ca8b2f Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Thu, 6 Aug 2009 12:09:50 +0200
Subject: Compile fix for gestures.

Reviewed-by: trustme
---
 src/gui/kernel/qstandardgestures.cpp | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 89de7c8..7078dbf 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -51,7 +51,6 @@
 QT_BEGIN_NAMESPACE
 
 #ifdef Q_WS_WIN
-QApplicationPrivate* getQApplicationPrivateInternal();
 QWidgetPrivate *qt_widget_private(QWidget *widget);
 #endif
 
@@ -74,7 +73,7 @@ QPanGesture::QPanGesture(QWidget *parent)
     : QGesture(*new QPanGesturePrivate, parent)
 {
     if (parent) {
-        QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+        QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
         qAppPriv->widgetGestures[parent].pan = this;
 #ifdef Q_WS_WIN
         qt_widget_private(parent)->winSetupGestures();
@@ -88,7 +87,7 @@ bool QPanGesture::event(QEvent *event)
     switch (event->type()) {
     case QEvent::ParentAboutToChange:
         if (QWidget *w = qobject_cast<QWidget*>(parent())) {
-            getQApplicationPrivateInternal()->widgetGestures[w].pan = 0;
+            QApplicationPrivate::instance()->widgetGestures[w].pan = 0;
 #ifdef Q_WS_WIN
             qt_widget_private(w)->winSetupGestures();
 #endif
@@ -96,7 +95,7 @@ bool QPanGesture::event(QEvent *event)
         break;
     case QEvent::ParentChange:
         if (QWidget *w = qobject_cast<QWidget*>(parent())) {
-            getQApplicationPrivateInternal()->widgetGestures[w].pan = this;
+            QApplicationPrivate::instance()->widgetGestures[w].pan = this;
 #ifdef Q_WS_WIN
             qt_widget_private(w)->winSetupGestures();
 #endif
@@ -128,7 +127,7 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
     Q_D(QPanGesture);
     if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) {
         QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
-        QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+        QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
         QApplicationPrivate::WidgetStandardGesturesMap::iterator it;
         it = qAppPriv->widgetGestures.find(static_cast<QWidget*>(receiver));
         if (it == qAppPriv->widgetGestures.end())
-- 
cgit v0.12


From e3f3ced70f80369439200b7d7bc3e4e11222c81f Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Date: Thu, 6 Aug 2009 12:36:14 +0200
Subject: task256322_highlight() failed due to lack of delays before QVERIFYs.

Last QVERIFY still failing.

Reviewed-by: olivier
---
 tests/auto/qmenubar/tst_qmenubar.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp
index 1245de1..67e088b 100644
--- a/tests/auto/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/qmenubar/tst_qmenubar.cpp
@@ -59,6 +59,8 @@
 
 #include <qobject.h>
 
+#include "../../shared/util.h"
+
 QT_FORWARD_DECLARE_CLASS(QMainWindow)
 
 #include <qmenubar.h>
@@ -1536,25 +1538,26 @@ void tst_QMenuBar::task256322_highlight()
     QAction *nothing = win.menuBar()->addAction("nothing");
 
     win.show();
+    QTest::qWait(50);
 
+    QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file).center());
     QTest::mouseClick(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center());
-    QVERIFY(menu.isVisible());
+    QTRY_VERIFY(menu.isVisible());
     QVERIFY(!menu2.isVisible());
     QCOMPARE(win.menuBar()->activeAction(), file);
 
     QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file2).center());
-    QVERIFY(!menu.isVisible());
+    QTRY_VERIFY(!menu.isVisible());
     QVERIFY(menu2.isVisible());
     QCOMPARE(win.menuBar()->activeAction(), file2);
 
     QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(nothing).center());
+    QTRY_VERIFY(!menu2.isVisible());
     QVERIFY(!menu.isVisible());
-    QVERIFY(!menu2.isVisible());
     QCOMPARE(win.menuBar()->activeAction(), nothing);
 
     QTest::mouseMove(&win, win.menuBar()->geometry().bottomLeft() + QPoint(1,1));
-
-    QVERIFY(!menu.isVisible());
+    QTRY_VERIFY(!menu.isVisible());
     QVERIFY(!menu2.isVisible());
     QVERIFY(!win.menuBar()->activeAction());
 }
-- 
cgit v0.12


From 00b8ac87e4f6bb8b185799cf9e01427c9975005c Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 12:01:43 +0200
Subject: QMenu: fix multi column autotest for styles which don't support it

---
 tests/auto/qmenu/tst_qmenu.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 6ba6466..8ff2b5c 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -692,6 +692,12 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition()
     };
 
     QMenu sub;
+	
+    if (sub.style()->styleHint(QStyle::SH_Menu_Scrollable, 0, &sub)) {
+        //the style prevents the menus from getting columns
+        QSKIP("the style doesn't support multiple columns, it makes the menu scrollable", SkipSingle);
+    }
+	
     sub.addAction("Sub-Item1");
     QAction *subAction = sub.addAction("Sub-Item2");
 
@@ -703,6 +709,7 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition()
     uint i = 2;
     while (main.columnCount() < 2) {
         main.addAction(QString("Item %1").arg(i));
+        qDebug() << "adding action" << i;
         ++i;
         Q_ASSERT(i<1000);
     }
-- 
cgit v0.12


From fec575841b1caced96a2c2f2789e38afe73da3aa Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 12:51:56 +0200
Subject: QMenu could return wrong geometries for its actions

We needed to call ensurePolished before updating the
action rects.
---
 src/gui/widgets/qmenu.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 05426a0..3b6743a 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -204,6 +204,8 @@ void QMenuPrivate::updateActionRects() const
     Q_Q(const QMenu);
     if (!itemsDirty)
         return;
+		
+    q->ensurePolished();
 
     //let's reinitialize the buffer
     actionRects.resize(actions.count());
-- 
cgit v0.12


From cbc229081a9df67a577b4bea61ad6aac52d470cb Mon Sep 17 00:00:00 2001
From: Ariya Hidayat <ariya.hidayat@nokia.com>
Date: Tue, 30 Jun 2009 11:18:03 +0200
Subject: Faster quaternion multiplications.

Use the known factorization trick to speed-up quaternion multiplication.
Now we need only 9 floating-point multiplications, instead of 16 (but
at the cost of extra additions and subtractions).

Callgrind shows that the function now takes 299 instructions instead of
318 instructions, which is not a big win. However I assume the speed-up
has a better effect for mobile CPU, where multiplications are more
expensive.

Reviewed-by: Rhys Weatherley
---
 src/gui/math3d/qquaternion.h | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 55c871d..9a1b590 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -198,24 +198,17 @@ inline QQuaternion &QQuaternion::operator*=(qreal factor)
 
 inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2)
 {
-    // Algorithm from:
-    // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q53
-    float x = q1.wp * q2.xp +
-                    q1.xp * q2.wp +
-                    q1.yp * q2.zp -
-                    q1.zp * q2.yp;
-    float y = q1.wp * q2.yp +
-                    q1.yp * q2.wp +
-                    q1.zp * q2.xp -
-                    q1.xp * q2.zp;
-    float z = q1.wp * q2.zp +
-                    q1.zp * q2.wp +
-                    q1.xp * q2.yp -
-                    q1.yp * q2.xp;
-    float w = q1.wp * q2.wp -
-                    q1.xp * q2.xp -
-                    q1.yp * q2.yp -
-                    q1.zp * q2.zp;
+    float ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
+    float yy = (q1.wp - q1.yp) * (q2.wp + q2.zp);
+    float zz = (q1.wp + q1.yp) * (q2.wp - q2.zp);
+    float xx = ww + yy + zz;
+    float qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));
+
+    float w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp);
+    float x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp);
+    float y = qq - yy + (q1.wp - q1.xp) * (q2.yp + q2.zp);
+    float z = qq - zz + (q1.zp + q1.yp) * (q2.wp - q2.xp);
+
     return QQuaternion(w, x, y, z, 1);
 }
 
-- 
cgit v0.12


From a02efd252df18c1869663d774743781e228fd73c Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Thu, 6 Aug 2009 12:58:53 +0200
Subject: Tests: Adapted uic baseline to
 33604fb02fa463f36fa78e515bb42a34a746f0f2

---
 tests/auto/uic/baseline/Dialog_with_Buttons_Bottom.ui.h | 4 ++--
 tests/auto/uic/baseline/Dialog_with_Buttons_Right.ui.h  | 4 ++--
 tests/auto/uic/baseline/Dialog_without_Buttons.ui.h     | 4 ++--
 tests/auto/uic/baseline/Main_Window.ui.h                | 4 ++--
 tests/auto/uic/baseline/Widget.ui.h                     | 4 ++--
 tests/auto/uic/baseline/addlinkdialog.ui.h              | 4 ++--
 tests/auto/uic/baseline/addtorrentform.ui.h             | 4 ++--
 tests/auto/uic/baseline/authenticationdialog.ui.h       | 4 ++--
 tests/auto/uic/baseline/backside.ui.h                   | 4 ++--
 tests/auto/uic/baseline/batchtranslation.ui.h           | 4 ++--
 tests/auto/uic/baseline/bookmarkdialog.ui.h             | 4 ++--
 tests/auto/uic/baseline/bookwindow.ui.h                 | 4 ++--
 tests/auto/uic/baseline/browserwidget.ui.h              | 4 ++--
 tests/auto/uic/baseline/calculator.ui.h                 | 4 ++--
 tests/auto/uic/baseline/calculatorform.ui.h             | 4 ++--
 tests/auto/uic/baseline/certificateinfo.ui.h            | 4 ++--
 tests/auto/uic/baseline/chatdialog.ui.h                 | 4 ++--
 tests/auto/uic/baseline/chatmainwindow.ui.h             | 4 ++--
 tests/auto/uic/baseline/chatsetnickname.ui.h            | 4 ++--
 tests/auto/uic/baseline/config.ui.h                     | 4 ++--
 tests/auto/uic/baseline/connectdialog.ui.h              | 4 ++--
 tests/auto/uic/baseline/controller.ui.h                 | 4 ++--
 tests/auto/uic/baseline/cookies.ui.h                    | 4 ++--
 tests/auto/uic/baseline/cookiesexceptions.ui.h          | 4 ++--
 tests/auto/uic/baseline/default.ui.h                    | 4 ++--
 tests/auto/uic/baseline/dialog.ui.h                     | 4 ++--
 tests/auto/uic/baseline/downloaditem.ui.h               | 4 ++--
 tests/auto/uic/baseline/downloads.ui.h                  | 4 ++--
 tests/auto/uic/baseline/embeddeddialog.ui.h             | 4 ++--
 tests/auto/uic/baseline/filespage.ui.h                  | 4 ++--
 tests/auto/uic/baseline/filternamedialog.ui.h           | 4 ++--
 tests/auto/uic/baseline/filterpage.ui.h                 | 4 ++--
 tests/auto/uic/baseline/finddialog.ui.h                 | 4 ++--
 tests/auto/uic/baseline/form.ui.h                       | 4 ++--
 tests/auto/uic/baseline/formwindowsettings.ui.h         | 4 ++--
 tests/auto/uic/baseline/generalpage.ui.h                | 4 ++--
 tests/auto/uic/baseline/gridpanel.ui.h                  | 4 ++--
 tests/auto/uic/baseline/helpdialog.ui.h                 | 4 ++--
 tests/auto/uic/baseline/history.ui.h                    | 4 ++--
 tests/auto/uic/baseline/identifierpage.ui.h             | 4 ++--
 tests/auto/uic/baseline/imagedialog.ui.h                | 4 ++--
 tests/auto/uic/baseline/inputpage.ui.h                  | 4 ++--
 tests/auto/uic/baseline/installdialog.ui.h              | 4 ++--
 tests/auto/uic/baseline/languagesdialog.ui.h            | 4 ++--
 tests/auto/uic/baseline/listwidgeteditor.ui.h           | 4 ++--
 tests/auto/uic/baseline/mainwindow.ui.h                 | 4 ++--
 tests/auto/uic/baseline/mainwindowbase.ui.h             | 4 ++--
 tests/auto/uic/baseline/mydialog.ui.h                   | 4 ++--
 tests/auto/uic/baseline/myform.ui.h                     | 4 ++--
 tests/auto/uic/baseline/newactiondialog.ui.h            | 4 ++--
 tests/auto/uic/baseline/newdynamicpropertydialog.ui.h   | 4 ++--
 tests/auto/uic/baseline/newform.ui.h                    | 4 ++--
 tests/auto/uic/baseline/orderdialog.ui.h                | 4 ++--
 tests/auto/uic/baseline/outputpage.ui.h                 | 4 ++--
 tests/auto/uic/baseline/pagefold.ui.h                   | 4 ++--
 tests/auto/uic/baseline/paletteeditor.ui.h              | 4 ++--
 tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h  | 4 ++--
 tests/auto/uic/baseline/passworddialog.ui.h             | 4 ++--
 tests/auto/uic/baseline/pathpage.ui.h                   | 4 ++--
 tests/auto/uic/baseline/phrasebookbox.ui.h              | 4 ++--
 tests/auto/uic/baseline/plugindialog.ui.h               | 4 ++--
 tests/auto/uic/baseline/preferencesdialog.ui.h          | 4 ++--
 tests/auto/uic/baseline/previewconfigurationwidget.ui.h | 4 ++--
 tests/auto/uic/baseline/previewdialogbase.ui.h          | 4 ++--
 tests/auto/uic/baseline/previewwidget.ui.h              | 4 ++--
 tests/auto/uic/baseline/previewwidgetbase.ui.h          | 4 ++--
 tests/auto/uic/baseline/proxy.ui.h                      | 4 ++--
 tests/auto/uic/baseline/qfiledialog.ui.h                | 4 ++--
 tests/auto/uic/baseline/qpagesetupwidget.ui.h           | 4 ++--
 tests/auto/uic/baseline/qprintpropertieswidget.ui.h     | 4 ++--
 tests/auto/uic/baseline/qprintsettingsoutput.ui.h       | 4 ++--
 tests/auto/uic/baseline/qprintwidget.ui.h               | 4 ++--
 tests/auto/uic/baseline/qsqlconnectiondialog.ui.h       | 4 ++--
 tests/auto/uic/baseline/qtgradientdialog.ui.h           | 4 ++--
 tests/auto/uic/baseline/qtgradienteditor.ui.h           | 4 ++--
 tests/auto/uic/baseline/qtgradientview.ui.h             | 4 ++--
 tests/auto/uic/baseline/qtgradientviewdialog.ui.h       | 4 ++--
 tests/auto/uic/baseline/qtresourceeditordialog.ui.h     | 4 ++--
 tests/auto/uic/baseline/qttoolbardialog.ui.h            | 4 ++--
 tests/auto/uic/baseline/querywidget.ui.h                | 4 ++--
 tests/auto/uic/baseline/remotecontrol.ui.h              | 4 ++--
 tests/auto/uic/baseline/saveformastemplate.ui.h         | 4 ++--
 tests/auto/uic/baseline/settings.ui.h                   | 4 ++--
 tests/auto/uic/baseline/signalslotdialog.ui.h           | 4 ++--
 tests/auto/uic/baseline/sslclient.ui.h                  | 4 ++--
 tests/auto/uic/baseline/sslerrors.ui.h                  | 4 ++--
 tests/auto/uic/baseline/statistics.ui.h                 | 4 ++--
 tests/auto/uic/baseline/stringlisteditor.ui.h           | 4 ++--
 tests/auto/uic/baseline/stylesheeteditor.ui.h           | 4 ++--
 tests/auto/uic/baseline/tabbedbrowser.ui.h              | 4 ++--
 tests/auto/uic/baseline/tablewidgeteditor.ui.h          | 4 ++--
 tests/auto/uic/baseline/tetrixwindow.ui.h               | 4 ++--
 tests/auto/uic/baseline/textfinder.ui.h                 | 4 ++--
 tests/auto/uic/baseline/topicchooser.ui.h               | 4 ++--
 tests/auto/uic/baseline/translatedialog.ui.h            | 4 ++--
 tests/auto/uic/baseline/translationsettings.ui.h        | 4 ++--
 tests/auto/uic/baseline/treewidgeteditor.ui.h           | 4 ++--
 tests/auto/uic/baseline/trpreviewtool.ui.h              | 4 ++--
 tests/auto/uic/baseline/validators.ui.h                 | 4 ++--
 tests/auto/uic/baseline/wateringconfigdialog.ui.h       | 4 ++--
 100 files changed, 200 insertions(+), 200 deletions(-)

diff --git a/tests/auto/uic/baseline/Dialog_with_Buttons_Bottom.ui.h b/tests/auto/uic/baseline/Dialog_with_Buttons_Bottom.ui.h
index 6ce3579..166dc60 100644
--- a/tests/auto/uic/baseline/Dialog_with_Buttons_Bottom.ui.h
+++ b/tests/auto/uic/baseline/Dialog_with_Buttons_Bottom.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'Dialog_with_Buttons_Bottom.ui'
+** Form generated from reading UI file 'Dialog_with_Buttons_Bottom.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef DIALOG_WITH_BUTTONS_BOTTOM_H
diff --git a/tests/auto/uic/baseline/Dialog_with_Buttons_Right.ui.h b/tests/auto/uic/baseline/Dialog_with_Buttons_Right.ui.h
index a2a9078..cbb3cc4 100644
--- a/tests/auto/uic/baseline/Dialog_with_Buttons_Right.ui.h
+++ b/tests/auto/uic/baseline/Dialog_with_Buttons_Right.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'Dialog_with_Buttons_Right.ui'
+** Form generated from reading UI file 'Dialog_with_Buttons_Right.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef DIALOG_WITH_BUTTONS_RIGHT_H
diff --git a/tests/auto/uic/baseline/Dialog_without_Buttons.ui.h b/tests/auto/uic/baseline/Dialog_without_Buttons.ui.h
index d89bbef..bb06a54 100644
--- a/tests/auto/uic/baseline/Dialog_without_Buttons.ui.h
+++ b/tests/auto/uic/baseline/Dialog_without_Buttons.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'Dialog_without_Buttons.ui'
+** Form generated from reading UI file 'Dialog_without_Buttons.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef DIALOG_WITHOUT_BUTTONS_H
diff --git a/tests/auto/uic/baseline/Main_Window.ui.h b/tests/auto/uic/baseline/Main_Window.ui.h
index 7404eca..07a8389 100644
--- a/tests/auto/uic/baseline/Main_Window.ui.h
+++ b/tests/auto/uic/baseline/Main_Window.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'Main_Window.ui'
+** Form generated from reading UI file 'Main_Window.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef MAIN_WINDOW_H
diff --git a/tests/auto/uic/baseline/Widget.ui.h b/tests/auto/uic/baseline/Widget.ui.h
index a7a3198..bba9fd9 100644
--- a/tests/auto/uic/baseline/Widget.ui.h
+++ b/tests/auto/uic/baseline/Widget.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'Widget.ui'
+** Form generated from reading UI file 'Widget.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef WIDGET_H
diff --git a/tests/auto/uic/baseline/addlinkdialog.ui.h b/tests/auto/uic/baseline/addlinkdialog.ui.h
index 34caca9..920a8f7 100644
--- a/tests/auto/uic/baseline/addlinkdialog.ui.h
+++ b/tests/auto/uic/baseline/addlinkdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'addlinkdialog.ui'
+** Form generated from reading UI file 'addlinkdialog.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef ADDLINKDIALOG_H
diff --git a/tests/auto/uic/baseline/addtorrentform.ui.h b/tests/auto/uic/baseline/addtorrentform.ui.h
index fafcb16..185ce2e 100644
--- a/tests/auto/uic/baseline/addtorrentform.ui.h
+++ b/tests/auto/uic/baseline/addtorrentform.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'addtorrentform.ui'
+** Form generated from reading UI file 'addtorrentform.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef ADDTORRENTFORM_H
diff --git a/tests/auto/uic/baseline/authenticationdialog.ui.h b/tests/auto/uic/baseline/authenticationdialog.ui.h
index 33acd91..b46c05d 100644
--- a/tests/auto/uic/baseline/authenticationdialog.ui.h
+++ b/tests/auto/uic/baseline/authenticationdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'authenticationdialog.ui'
+** Form generated from reading UI file 'authenticationdialog.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef AUTHENTICATIONDIALOG_H
diff --git a/tests/auto/uic/baseline/backside.ui.h b/tests/auto/uic/baseline/backside.ui.h
index 7cc5ee9..6fdab4b 100644
--- a/tests/auto/uic/baseline/backside.ui.h
+++ b/tests/auto/uic/baseline/backside.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'backside.ui'
+** Form generated from reading UI file 'backside.ui'
 **
 ** Created: Tue Jun 17 09:18:47 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef BACKSIDE_H
diff --git a/tests/auto/uic/baseline/batchtranslation.ui.h b/tests/auto/uic/baseline/batchtranslation.ui.h
index 4cdad44..2567fd9 100644
--- a/tests/auto/uic/baseline/batchtranslation.ui.h
+++ b/tests/auto/uic/baseline/batchtranslation.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'batchtranslation.ui'
+** Form generated from reading UI file 'batchtranslation.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef BATCHTRANSLATION_H
diff --git a/tests/auto/uic/baseline/bookmarkdialog.ui.h b/tests/auto/uic/baseline/bookmarkdialog.ui.h
index b5af0cf..1db7dca 100644
--- a/tests/auto/uic/baseline/bookmarkdialog.ui.h
+++ b/tests/auto/uic/baseline/bookmarkdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'bookmarkdialog.ui'
+** Form generated from reading UI file 'bookmarkdialog.ui'
 **
 ** Created: Mon Jun 16 18:01:55 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef BOOKMARKDIALOG_H
diff --git a/tests/auto/uic/baseline/bookwindow.ui.h b/tests/auto/uic/baseline/bookwindow.ui.h
index eae06d9..776f9e9 100644
--- a/tests/auto/uic/baseline/bookwindow.ui.h
+++ b/tests/auto/uic/baseline/bookwindow.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'bookwindow.ui'
+** Form generated from reading UI file 'bookwindow.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef BOOKWINDOW_H
diff --git a/tests/auto/uic/baseline/browserwidget.ui.h b/tests/auto/uic/baseline/browserwidget.ui.h
index 67f637f..c1ca60f 100644
--- a/tests/auto/uic/baseline/browserwidget.ui.h
+++ b/tests/auto/uic/baseline/browserwidget.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'browserwidget.ui'
+** Form generated from reading UI file 'browserwidget.ui'
 **
 ** Created: Mon Jun 16 18:01:09 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef BROWSERWIDGET_H
diff --git a/tests/auto/uic/baseline/calculator.ui.h b/tests/auto/uic/baseline/calculator.ui.h
index aa70aff..f476d9b 100644
--- a/tests/auto/uic/baseline/calculator.ui.h
+++ b/tests/auto/uic/baseline/calculator.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'calculator.ui'
+** Form generated from reading UI file 'calculator.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef CALCULATOR_H
diff --git a/tests/auto/uic/baseline/calculatorform.ui.h b/tests/auto/uic/baseline/calculatorform.ui.h
index 8e9e620..1c575e8 100644
--- a/tests/auto/uic/baseline/calculatorform.ui.h
+++ b/tests/auto/uic/baseline/calculatorform.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'calculatorform.ui'
+** Form generated from reading UI file 'calculatorform.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef CALCULATORFORM_H
diff --git a/tests/auto/uic/baseline/certificateinfo.ui.h b/tests/auto/uic/baseline/certificateinfo.ui.h
index bbb5d5f..548bec5 100644
--- a/tests/auto/uic/baseline/certificateinfo.ui.h
+++ b/tests/auto/uic/baseline/certificateinfo.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'certificateinfo.ui'
+** Form generated from reading UI file 'certificateinfo.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef CERTIFICATEINFO_H
diff --git a/tests/auto/uic/baseline/chatdialog.ui.h b/tests/auto/uic/baseline/chatdialog.ui.h
index 7d19376..c9f2693 100644
--- a/tests/auto/uic/baseline/chatdialog.ui.h
+++ b/tests/auto/uic/baseline/chatdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'chatdialog.ui'
+** Form generated from reading UI file 'chatdialog.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef CHATDIALOG_H
diff --git a/tests/auto/uic/baseline/chatmainwindow.ui.h b/tests/auto/uic/baseline/chatmainwindow.ui.h
index 93ce435..87ac882 100644
--- a/tests/auto/uic/baseline/chatmainwindow.ui.h
+++ b/tests/auto/uic/baseline/chatmainwindow.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'chatmainwindow.ui'
+** Form generated from reading UI file 'chatmainwindow.ui'
 **
 ** Created: Mon Sep 1 09:31:02 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef CHATMAINWINDOW_H
diff --git a/tests/auto/uic/baseline/chatsetnickname.ui.h b/tests/auto/uic/baseline/chatsetnickname.ui.h
index c1fd62b..54f48e7 100644
--- a/tests/auto/uic/baseline/chatsetnickname.ui.h
+++ b/tests/auto/uic/baseline/chatsetnickname.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'chatsetnickname.ui'
+** Form generated from reading UI file 'chatsetnickname.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef CHATSETNICKNAME_H
diff --git a/tests/auto/uic/baseline/config.ui.h b/tests/auto/uic/baseline/config.ui.h
index 20de66f..7933178 100644
--- a/tests/auto/uic/baseline/config.ui.h
+++ b/tests/auto/uic/baseline/config.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'config.ui'
+** Form generated from reading UI file 'config.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef CONFIG_H
diff --git a/tests/auto/uic/baseline/connectdialog.ui.h b/tests/auto/uic/baseline/connectdialog.ui.h
index b90de56..d7e0eaf 100644
--- a/tests/auto/uic/baseline/connectdialog.ui.h
+++ b/tests/auto/uic/baseline/connectdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'connectdialog.ui'
+** Form generated from reading UI file 'connectdialog.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef CONNECTDIALOG_H
diff --git a/tests/auto/uic/baseline/controller.ui.h b/tests/auto/uic/baseline/controller.ui.h
index 29985c1..c5cd1fe 100644
--- a/tests/auto/uic/baseline/controller.ui.h
+++ b/tests/auto/uic/baseline/controller.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'controller.ui'
+** Form generated from reading UI file 'controller.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef CONTROLLER_H
diff --git a/tests/auto/uic/baseline/cookies.ui.h b/tests/auto/uic/baseline/cookies.ui.h
index e4c70ec..0b4d88a 100644
--- a/tests/auto/uic/baseline/cookies.ui.h
+++ b/tests/auto/uic/baseline/cookies.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'cookies.ui'
+** Form generated from reading UI file 'cookies.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef COOKIES_H
diff --git a/tests/auto/uic/baseline/cookiesexceptions.ui.h b/tests/auto/uic/baseline/cookiesexceptions.ui.h
index 5a436eb..12e80d8 100644
--- a/tests/auto/uic/baseline/cookiesexceptions.ui.h
+++ b/tests/auto/uic/baseline/cookiesexceptions.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'cookiesexceptions.ui'
+** Form generated from reading UI file 'cookiesexceptions.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef COOKIESEXCEPTIONS_H
diff --git a/tests/auto/uic/baseline/default.ui.h b/tests/auto/uic/baseline/default.ui.h
index 7717694..f68a93e 100644
--- a/tests/auto/uic/baseline/default.ui.h
+++ b/tests/auto/uic/baseline/default.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'default.ui'
+** Form generated from reading UI file 'default.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef DEFAULT_H
diff --git a/tests/auto/uic/baseline/dialog.ui.h b/tests/auto/uic/baseline/dialog.ui.h
index 307f2fc..d65c10a 100644
--- a/tests/auto/uic/baseline/dialog.ui.h
+++ b/tests/auto/uic/baseline/dialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'dialog.ui'
+** Form generated from reading UI file 'dialog.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef DIALOG_H
diff --git a/tests/auto/uic/baseline/downloaditem.ui.h b/tests/auto/uic/baseline/downloaditem.ui.h
index 7df99df..341fdd2 100644
--- a/tests/auto/uic/baseline/downloaditem.ui.h
+++ b/tests/auto/uic/baseline/downloaditem.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'downloaditem.ui'
+** Form generated from reading UI file 'downloaditem.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef DOWNLOADITEM_H
diff --git a/tests/auto/uic/baseline/downloads.ui.h b/tests/auto/uic/baseline/downloads.ui.h
index b4739f6..70a038a 100644
--- a/tests/auto/uic/baseline/downloads.ui.h
+++ b/tests/auto/uic/baseline/downloads.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'downloads.ui'
+** Form generated from reading UI file 'downloads.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef DOWNLOADS_H
diff --git a/tests/auto/uic/baseline/embeddeddialog.ui.h b/tests/auto/uic/baseline/embeddeddialog.ui.h
index 7df8ab8..3dd36a6 100644
--- a/tests/auto/uic/baseline/embeddeddialog.ui.h
+++ b/tests/auto/uic/baseline/embeddeddialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'embeddeddialog.ui'
+** Form generated from reading UI file 'embeddeddialog.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef EMBEDDEDDIALOG_H
diff --git a/tests/auto/uic/baseline/filespage.ui.h b/tests/auto/uic/baseline/filespage.ui.h
index f946002..15a0f5b 100644
--- a/tests/auto/uic/baseline/filespage.ui.h
+++ b/tests/auto/uic/baseline/filespage.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'filespage.ui'
+** Form generated from reading UI file 'filespage.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef FILESPAGE_H
diff --git a/tests/auto/uic/baseline/filternamedialog.ui.h b/tests/auto/uic/baseline/filternamedialog.ui.h
index f4306ea..ad435c1 100644
--- a/tests/auto/uic/baseline/filternamedialog.ui.h
+++ b/tests/auto/uic/baseline/filternamedialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'filternamedialog.ui'
+** Form generated from reading UI file 'filternamedialog.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef FILTERNAMEDIALOG_H
diff --git a/tests/auto/uic/baseline/filterpage.ui.h b/tests/auto/uic/baseline/filterpage.ui.h
index ebac375..e7fb7fb 100644
--- a/tests/auto/uic/baseline/filterpage.ui.h
+++ b/tests/auto/uic/baseline/filterpage.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'filterpage.ui'
+** Form generated from reading UI file 'filterpage.ui'
 **
 ** Created: Mon Jun 16 17:58:59 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef FILTERPAGE_H
diff --git a/tests/auto/uic/baseline/finddialog.ui.h b/tests/auto/uic/baseline/finddialog.ui.h
index 091c54a..7a3620a 100644
--- a/tests/auto/uic/baseline/finddialog.ui.h
+++ b/tests/auto/uic/baseline/finddialog.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'finddialog.ui'
+** Form generated from reading UI file 'finddialog.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef FINDDIALOG_H
diff --git a/tests/auto/uic/baseline/form.ui.h b/tests/auto/uic/baseline/form.ui.h
index 3f85b03..60f5a14 100644
--- a/tests/auto/uic/baseline/form.ui.h
+++ b/tests/auto/uic/baseline/form.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'form.ui'
+** Form generated from reading UI file 'form.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef FORM_H
diff --git a/tests/auto/uic/baseline/formwindowsettings.ui.h b/tests/auto/uic/baseline/formwindowsettings.ui.h
index 9e97b48..2e29290 100644
--- a/tests/auto/uic/baseline/formwindowsettings.ui.h
+++ b/tests/auto/uic/baseline/formwindowsettings.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'formwindowsettings.ui'
+** Form generated from reading UI file 'formwindowsettings.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef FORMWINDOWSETTINGS_H
diff --git a/tests/auto/uic/baseline/generalpage.ui.h b/tests/auto/uic/baseline/generalpage.ui.h
index 0289f50..0dcc6ec 100644
--- a/tests/auto/uic/baseline/generalpage.ui.h
+++ b/tests/auto/uic/baseline/generalpage.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'generalpage.ui'
+** Form generated from reading UI file 'generalpage.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef GENERALPAGE_H
diff --git a/tests/auto/uic/baseline/gridpanel.ui.h b/tests/auto/uic/baseline/gridpanel.ui.h
index f79ffa9..1bc2f04 100644
--- a/tests/auto/uic/baseline/gridpanel.ui.h
+++ b/tests/auto/uic/baseline/gridpanel.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'gridpanel.ui'
+** Form generated from reading UI file 'gridpanel.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef GRIDPANEL_H
diff --git a/tests/auto/uic/baseline/helpdialog.ui.h b/tests/auto/uic/baseline/helpdialog.ui.h
index 608dba3..b003e7d 100644
--- a/tests/auto/uic/baseline/helpdialog.ui.h
+++ b/tests/auto/uic/baseline/helpdialog.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'helpdialog.ui'
+** Form generated from reading UI file 'helpdialog.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef HELPDIALOG_H
diff --git a/tests/auto/uic/baseline/history.ui.h b/tests/auto/uic/baseline/history.ui.h
index 4b84e68..16553df 100644
--- a/tests/auto/uic/baseline/history.ui.h
+++ b/tests/auto/uic/baseline/history.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'history.ui'
+** Form generated from reading UI file 'history.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef HISTORY_H
diff --git a/tests/auto/uic/baseline/identifierpage.ui.h b/tests/auto/uic/baseline/identifierpage.ui.h
index 7839600..24aecf8 100644
--- a/tests/auto/uic/baseline/identifierpage.ui.h
+++ b/tests/auto/uic/baseline/identifierpage.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'identifierpage.ui'
+** Form generated from reading UI file 'identifierpage.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef IDENTIFIERPAGE_H
diff --git a/tests/auto/uic/baseline/imagedialog.ui.h b/tests/auto/uic/baseline/imagedialog.ui.h
index 001532e..2f51b65 100644
--- a/tests/auto/uic/baseline/imagedialog.ui.h
+++ b/tests/auto/uic/baseline/imagedialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'imagedialog.ui'
+** Form generated from reading UI file 'imagedialog.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef IMAGEDIALOG_H
diff --git a/tests/auto/uic/baseline/inputpage.ui.h b/tests/auto/uic/baseline/inputpage.ui.h
index 917f91b..23f2a0b 100644
--- a/tests/auto/uic/baseline/inputpage.ui.h
+++ b/tests/auto/uic/baseline/inputpage.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'inputpage.ui'
+** Form generated from reading UI file 'inputpage.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef INPUTPAGE_H
diff --git a/tests/auto/uic/baseline/installdialog.ui.h b/tests/auto/uic/baseline/installdialog.ui.h
index d61377d..e6180f7 100644
--- a/tests/auto/uic/baseline/installdialog.ui.h
+++ b/tests/auto/uic/baseline/installdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'installdialog.ui'
+** Form generated from reading UI file 'installdialog.ui'
 **
 ** Created: Thu Jul 10 09:47:34 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef INSTALLDIALOG_H
diff --git a/tests/auto/uic/baseline/languagesdialog.ui.h b/tests/auto/uic/baseline/languagesdialog.ui.h
index fbe57ca..ff837c1 100644
--- a/tests/auto/uic/baseline/languagesdialog.ui.h
+++ b/tests/auto/uic/baseline/languagesdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'languagesdialog.ui'
+** Form generated from reading UI file 'languagesdialog.ui'
 **
 ** Created: Fri May 15 16:58:03 2009
 **      by: Qt User Interface Compiler version 4.5.2
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef LANGUAGESDIALOG_H
diff --git a/tests/auto/uic/baseline/listwidgeteditor.ui.h b/tests/auto/uic/baseline/listwidgeteditor.ui.h
index 127228c..50adea0 100644
--- a/tests/auto/uic/baseline/listwidgeteditor.ui.h
+++ b/tests/auto/uic/baseline/listwidgeteditor.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'listwidgeteditor.ui'
+** Form generated from reading UI file 'listwidgeteditor.ui'
 **
 ** Created: Mon Jun 16 17:54:30 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef LISTWIDGETEDITOR_H
diff --git a/tests/auto/uic/baseline/mainwindow.ui.h b/tests/auto/uic/baseline/mainwindow.ui.h
index 73a9de2..11b0196 100644
--- a/tests/auto/uic/baseline/mainwindow.ui.h
+++ b/tests/auto/uic/baseline/mainwindow.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'mainwindow.ui'
+** Form generated from reading UI file 'mainwindow.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef MAINWINDOW_H
diff --git a/tests/auto/uic/baseline/mainwindowbase.ui.h b/tests/auto/uic/baseline/mainwindowbase.ui.h
index 4a49f95..aef2f3a 100644
--- a/tests/auto/uic/baseline/mainwindowbase.ui.h
+++ b/tests/auto/uic/baseline/mainwindowbase.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'mainwindowbase.ui'
+** Form generated from reading UI file 'mainwindowbase.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef MAINWINDOWBASE_H
diff --git a/tests/auto/uic/baseline/mydialog.ui.h b/tests/auto/uic/baseline/mydialog.ui.h
index 17cf6c5..ac7b458 100644
--- a/tests/auto/uic/baseline/mydialog.ui.h
+++ b/tests/auto/uic/baseline/mydialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'mydialog.ui'
+** Form generated from reading UI file 'mydialog.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef MYDIALOG_H
diff --git a/tests/auto/uic/baseline/myform.ui.h b/tests/auto/uic/baseline/myform.ui.h
index 07e1663..74c83f5 100644
--- a/tests/auto/uic/baseline/myform.ui.h
+++ b/tests/auto/uic/baseline/myform.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'myform.ui'
+** Form generated from reading UI file 'myform.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef MYFORM_H
diff --git a/tests/auto/uic/baseline/newactiondialog.ui.h b/tests/auto/uic/baseline/newactiondialog.ui.h
index 69f13fd..9c78f7b 100644
--- a/tests/auto/uic/baseline/newactiondialog.ui.h
+++ b/tests/auto/uic/baseline/newactiondialog.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'newactiondialog.ui'
+** Form generated from reading UI file 'newactiondialog.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef NEWACTIONDIALOG_H
diff --git a/tests/auto/uic/baseline/newdynamicpropertydialog.ui.h b/tests/auto/uic/baseline/newdynamicpropertydialog.ui.h
index 69f1ed5..f8e5b51 100644
--- a/tests/auto/uic/baseline/newdynamicpropertydialog.ui.h
+++ b/tests/auto/uic/baseline/newdynamicpropertydialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'newdynamicpropertydialog.ui'
+** Form generated from reading UI file 'newdynamicpropertydialog.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef NEWDYNAMICPROPERTYDIALOG_H
diff --git a/tests/auto/uic/baseline/newform.ui.h b/tests/auto/uic/baseline/newform.ui.h
index 37eb709..a011e9b 100644
--- a/tests/auto/uic/baseline/newform.ui.h
+++ b/tests/auto/uic/baseline/newform.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'newform.ui'
+** Form generated from reading UI file 'newform.ui'
 **
 ** Created: Mon Jun 16 17:56:52 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef NEWFORM_H
diff --git a/tests/auto/uic/baseline/orderdialog.ui.h b/tests/auto/uic/baseline/orderdialog.ui.h
index 7460475..304a3df 100644
--- a/tests/auto/uic/baseline/orderdialog.ui.h
+++ b/tests/auto/uic/baseline/orderdialog.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'orderdialog.ui'
+** Form generated from reading UI file 'orderdialog.ui'
 **
 ** Created: Mon Jun 16 17:55:54 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef ORDERDIALOG_H
diff --git a/tests/auto/uic/baseline/outputpage.ui.h b/tests/auto/uic/baseline/outputpage.ui.h
index 8199c57..0b68cb9 100644
--- a/tests/auto/uic/baseline/outputpage.ui.h
+++ b/tests/auto/uic/baseline/outputpage.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'outputpage.ui'
+** Form generated from reading UI file 'outputpage.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef OUTPUTPAGE_H
diff --git a/tests/auto/uic/baseline/pagefold.ui.h b/tests/auto/uic/baseline/pagefold.ui.h
index 9c2a453..5cc5836 100644
--- a/tests/auto/uic/baseline/pagefold.ui.h
+++ b/tests/auto/uic/baseline/pagefold.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'pagefold.ui'
+** Form generated from reading UI file 'pagefold.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PAGEFOLD_H
diff --git a/tests/auto/uic/baseline/paletteeditor.ui.h b/tests/auto/uic/baseline/paletteeditor.ui.h
index 0dcefb3..9ef3920 100644
--- a/tests/auto/uic/baseline/paletteeditor.ui.h
+++ b/tests/auto/uic/baseline/paletteeditor.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'paletteeditor.ui'
+** Form generated from reading UI file 'paletteeditor.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PALETTEEDITOR_H
diff --git a/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h b/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h
index bb2a959..419bc0f 100644
--- a/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h
+++ b/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'paletteeditoradvancedbase.ui'
+** Form generated from reading UI file 'paletteeditoradvancedbase.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PALETTEEDITORADVANCEDBASE_H
diff --git a/tests/auto/uic/baseline/passworddialog.ui.h b/tests/auto/uic/baseline/passworddialog.ui.h
index 267b5f2..be80298 100644
--- a/tests/auto/uic/baseline/passworddialog.ui.h
+++ b/tests/auto/uic/baseline/passworddialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'passworddialog.ui'
+** Form generated from reading UI file 'passworddialog.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PASSWORDDIALOG_H
diff --git a/tests/auto/uic/baseline/pathpage.ui.h b/tests/auto/uic/baseline/pathpage.ui.h
index 528fed8..257c191 100644
--- a/tests/auto/uic/baseline/pathpage.ui.h
+++ b/tests/auto/uic/baseline/pathpage.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'pathpage.ui'
+** Form generated from reading UI file 'pathpage.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PATHPAGE_H
diff --git a/tests/auto/uic/baseline/phrasebookbox.ui.h b/tests/auto/uic/baseline/phrasebookbox.ui.h
index f4abb1b..8c53463 100644
--- a/tests/auto/uic/baseline/phrasebookbox.ui.h
+++ b/tests/auto/uic/baseline/phrasebookbox.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'phrasebookbox.ui'
+** Form generated from reading UI file 'phrasebookbox.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PHRASEBOOKBOX_H
diff --git a/tests/auto/uic/baseline/plugindialog.ui.h b/tests/auto/uic/baseline/plugindialog.ui.h
index bb51f4a..961155b 100644
--- a/tests/auto/uic/baseline/plugindialog.ui.h
+++ b/tests/auto/uic/baseline/plugindialog.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'plugindialog.ui'
+** Form generated from reading UI file 'plugindialog.ui'
 **
 ** Created: Mon Jun 16 17:52:32 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PLUGINDIALOG_H
diff --git a/tests/auto/uic/baseline/preferencesdialog.ui.h b/tests/auto/uic/baseline/preferencesdialog.ui.h
index 5412fe1..a1f5ac2 100644
--- a/tests/auto/uic/baseline/preferencesdialog.ui.h
+++ b/tests/auto/uic/baseline/preferencesdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'preferencesdialog.ui'
+** Form generated from reading UI file 'preferencesdialog.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PREFERENCESDIALOG_H
diff --git a/tests/auto/uic/baseline/previewconfigurationwidget.ui.h b/tests/auto/uic/baseline/previewconfigurationwidget.ui.h
index 6d5247d..4a7b694 100644
--- a/tests/auto/uic/baseline/previewconfigurationwidget.ui.h
+++ b/tests/auto/uic/baseline/previewconfigurationwidget.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'previewconfigurationwidget.ui'
+** Form generated from reading UI file 'previewconfigurationwidget.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PREVIEWCONFIGURATIONWIDGET_H
diff --git a/tests/auto/uic/baseline/previewdialogbase.ui.h b/tests/auto/uic/baseline/previewdialogbase.ui.h
index 93bfb69..822990c 100644
--- a/tests/auto/uic/baseline/previewdialogbase.ui.h
+++ b/tests/auto/uic/baseline/previewdialogbase.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'previewdialogbase.ui'
+** Form generated from reading UI file 'previewdialogbase.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PREVIEWDIALOGBASE_H
diff --git a/tests/auto/uic/baseline/previewwidget.ui.h b/tests/auto/uic/baseline/previewwidget.ui.h
index b76aa56..d8a596e 100644
--- a/tests/auto/uic/baseline/previewwidget.ui.h
+++ b/tests/auto/uic/baseline/previewwidget.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'previewwidget.ui'
+** Form generated from reading UI file 'previewwidget.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PREVIEWWIDGET_H
diff --git a/tests/auto/uic/baseline/previewwidgetbase.ui.h b/tests/auto/uic/baseline/previewwidgetbase.ui.h
index 82899b7..e131cd5 100644
--- a/tests/auto/uic/baseline/previewwidgetbase.ui.h
+++ b/tests/auto/uic/baseline/previewwidgetbase.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'previewwidgetbase.ui'
+** Form generated from reading UI file 'previewwidgetbase.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PREVIEWWIDGETBASE_H
diff --git a/tests/auto/uic/baseline/proxy.ui.h b/tests/auto/uic/baseline/proxy.ui.h
index 2ec63fa..d22edef 100644
--- a/tests/auto/uic/baseline/proxy.ui.h
+++ b/tests/auto/uic/baseline/proxy.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'proxy.ui'
+** Form generated from reading UI file 'proxy.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef PROXY_H
diff --git a/tests/auto/uic/baseline/qfiledialog.ui.h b/tests/auto/uic/baseline/qfiledialog.ui.h
index 3b3a626..ea5814f 100644
--- a/tests/auto/uic/baseline/qfiledialog.ui.h
+++ b/tests/auto/uic/baseline/qfiledialog.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'qfiledialog.ui'
+** Form generated from reading UI file 'qfiledialog.ui'
 **
 ** Created: Mon Jun 16 17:51:48 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QFILEDIALOG_H
diff --git a/tests/auto/uic/baseline/qpagesetupwidget.ui.h b/tests/auto/uic/baseline/qpagesetupwidget.ui.h
index f2a68bd..4694409 100644
--- a/tests/auto/uic/baseline/qpagesetupwidget.ui.h
+++ b/tests/auto/uic/baseline/qpagesetupwidget.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'qpagesetupwidget.ui'
+** Form generated from reading UI file 'qpagesetupwidget.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QPAGESETUPWIDGET_H
diff --git a/tests/auto/uic/baseline/qprintpropertieswidget.ui.h b/tests/auto/uic/baseline/qprintpropertieswidget.ui.h
index 16148ef..626fee7 100644
--- a/tests/auto/uic/baseline/qprintpropertieswidget.ui.h
+++ b/tests/auto/uic/baseline/qprintpropertieswidget.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'qprintpropertieswidget.ui'
+** Form generated from reading UI file 'qprintpropertieswidget.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QPRINTPROPERTIESWIDGET_H
diff --git a/tests/auto/uic/baseline/qprintsettingsoutput.ui.h b/tests/auto/uic/baseline/qprintsettingsoutput.ui.h
index 307582a..a6360ee 100644
--- a/tests/auto/uic/baseline/qprintsettingsoutput.ui.h
+++ b/tests/auto/uic/baseline/qprintsettingsoutput.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'qprintsettingsoutput.ui'
+** Form generated from reading UI file 'qprintsettingsoutput.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QPRINTSETTINGSOUTPUT_H
diff --git a/tests/auto/uic/baseline/qprintwidget.ui.h b/tests/auto/uic/baseline/qprintwidget.ui.h
index 7fa0b4f..99d6486 100644
--- a/tests/auto/uic/baseline/qprintwidget.ui.h
+++ b/tests/auto/uic/baseline/qprintwidget.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'qprintwidget.ui'
+** Form generated from reading UI file 'qprintwidget.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QPRINTWIDGET_H
diff --git a/tests/auto/uic/baseline/qsqlconnectiondialog.ui.h b/tests/auto/uic/baseline/qsqlconnectiondialog.ui.h
index 846f34d..165c7d7 100644
--- a/tests/auto/uic/baseline/qsqlconnectiondialog.ui.h
+++ b/tests/auto/uic/baseline/qsqlconnectiondialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'qsqlconnectiondialog.ui'
+** Form generated from reading UI file 'qsqlconnectiondialog.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QSQLCONNECTIONDIALOG_H
diff --git a/tests/auto/uic/baseline/qtgradientdialog.ui.h b/tests/auto/uic/baseline/qtgradientdialog.ui.h
index 8a5d18c..0f2f581 100644
--- a/tests/auto/uic/baseline/qtgradientdialog.ui.h
+++ b/tests/auto/uic/baseline/qtgradientdialog.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'qtgradientdialog.ui'
+** Form generated from reading UI file 'qtgradientdialog.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QTGRADIENTDIALOG_H
diff --git a/tests/auto/uic/baseline/qtgradienteditor.ui.h b/tests/auto/uic/baseline/qtgradienteditor.ui.h
index 5eab3a8..4468552 100644
--- a/tests/auto/uic/baseline/qtgradienteditor.ui.h
+++ b/tests/auto/uic/baseline/qtgradienteditor.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'qtgradienteditor.ui'
+** Form generated from reading UI file 'qtgradienteditor.ui'
 **
 ** Created: Mon Jun 16 17:50:21 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QTGRADIENTEDITOR_H
diff --git a/tests/auto/uic/baseline/qtgradientview.ui.h b/tests/auto/uic/baseline/qtgradientview.ui.h
index 6be5ed5..809cf5b 100644
--- a/tests/auto/uic/baseline/qtgradientview.ui.h
+++ b/tests/auto/uic/baseline/qtgradientview.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'qtgradientview.ui'
+** Form generated from reading UI file 'qtgradientview.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QTGRADIENTVIEW_H
diff --git a/tests/auto/uic/baseline/qtgradientviewdialog.ui.h b/tests/auto/uic/baseline/qtgradientviewdialog.ui.h
index 8836301..fd57bc6 100644
--- a/tests/auto/uic/baseline/qtgradientviewdialog.ui.h
+++ b/tests/auto/uic/baseline/qtgradientviewdialog.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'qtgradientviewdialog.ui'
+** Form generated from reading UI file 'qtgradientviewdialog.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QTGRADIENTVIEWDIALOG_H
diff --git a/tests/auto/uic/baseline/qtresourceeditordialog.ui.h b/tests/auto/uic/baseline/qtresourceeditordialog.ui.h
index 03e7362..a08a16c 100644
--- a/tests/auto/uic/baseline/qtresourceeditordialog.ui.h
+++ b/tests/auto/uic/baseline/qtresourceeditordialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'qtresourceeditordialog.ui'
+** Form generated from reading UI file 'qtresourceeditordialog.ui'
 **
 ** Created: Mon Jun 16 17:45:38 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QTRESOURCEEDITORDIALOG_H
diff --git a/tests/auto/uic/baseline/qttoolbardialog.ui.h b/tests/auto/uic/baseline/qttoolbardialog.ui.h
index 7225eda..9099553 100644
--- a/tests/auto/uic/baseline/qttoolbardialog.ui.h
+++ b/tests/auto/uic/baseline/qttoolbardialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'qttoolbardialog.ui'
+** Form generated from reading UI file 'qttoolbardialog.ui'
 **
 ** Created: Mon Jun 16 17:42:37 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QTTOOLBARDIALOG_H
diff --git a/tests/auto/uic/baseline/querywidget.ui.h b/tests/auto/uic/baseline/querywidget.ui.h
index 7697328..8afcf54 100644
--- a/tests/auto/uic/baseline/querywidget.ui.h
+++ b/tests/auto/uic/baseline/querywidget.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'querywidget.ui'
+** Form generated from reading UI file 'querywidget.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef QUERYWIDGET_H
diff --git a/tests/auto/uic/baseline/remotecontrol.ui.h b/tests/auto/uic/baseline/remotecontrol.ui.h
index 854a994..3d183f7 100644
--- a/tests/auto/uic/baseline/remotecontrol.ui.h
+++ b/tests/auto/uic/baseline/remotecontrol.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'remotecontrol.ui'
+** Form generated from reading UI file 'remotecontrol.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef REMOTECONTROL_H
diff --git a/tests/auto/uic/baseline/saveformastemplate.ui.h b/tests/auto/uic/baseline/saveformastemplate.ui.h
index 1bad01e..483239d 100644
--- a/tests/auto/uic/baseline/saveformastemplate.ui.h
+++ b/tests/auto/uic/baseline/saveformastemplate.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'saveformastemplate.ui'
+** Form generated from reading UI file 'saveformastemplate.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef SAVEFORMASTEMPLATE_H
diff --git a/tests/auto/uic/baseline/settings.ui.h b/tests/auto/uic/baseline/settings.ui.h
index 8fb0ef2..98cb6ee 100644
--- a/tests/auto/uic/baseline/settings.ui.h
+++ b/tests/auto/uic/baseline/settings.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'settings.ui'
+** Form generated from reading UI file 'settings.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef SETTINGS_H
diff --git a/tests/auto/uic/baseline/signalslotdialog.ui.h b/tests/auto/uic/baseline/signalslotdialog.ui.h
index 6adcf21..f3ce8bc 100644
--- a/tests/auto/uic/baseline/signalslotdialog.ui.h
+++ b/tests/auto/uic/baseline/signalslotdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'signalslotdialog.ui'
+** Form generated from reading UI file 'signalslotdialog.ui'
 **
 ** Created: Mon Jun 16 16:18:52 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef SIGNALSLOTDIALOG_H
diff --git a/tests/auto/uic/baseline/sslclient.ui.h b/tests/auto/uic/baseline/sslclient.ui.h
index 1ca1c3f..aee0224 100644
--- a/tests/auto/uic/baseline/sslclient.ui.h
+++ b/tests/auto/uic/baseline/sslclient.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'sslclient.ui'
+** Form generated from reading UI file 'sslclient.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef SSLCLIENT_H
diff --git a/tests/auto/uic/baseline/sslerrors.ui.h b/tests/auto/uic/baseline/sslerrors.ui.h
index a1a46a1..f999be0 100644
--- a/tests/auto/uic/baseline/sslerrors.ui.h
+++ b/tests/auto/uic/baseline/sslerrors.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'sslerrors.ui'
+** Form generated from reading UI file 'sslerrors.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef SSLERRORS_H
diff --git a/tests/auto/uic/baseline/statistics.ui.h b/tests/auto/uic/baseline/statistics.ui.h
index b8257c4..713c1c2 100644
--- a/tests/auto/uic/baseline/statistics.ui.h
+++ b/tests/auto/uic/baseline/statistics.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'statistics.ui'
+** Form generated from reading UI file 'statistics.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef STATISTICS_H
diff --git a/tests/auto/uic/baseline/stringlisteditor.ui.h b/tests/auto/uic/baseline/stringlisteditor.ui.h
index e6daa52..23655d9 100644
--- a/tests/auto/uic/baseline/stringlisteditor.ui.h
+++ b/tests/auto/uic/baseline/stringlisteditor.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'stringlisteditor.ui'
+** Form generated from reading UI file 'stringlisteditor.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef STRINGLISTEDITOR_H
diff --git a/tests/auto/uic/baseline/stylesheeteditor.ui.h b/tests/auto/uic/baseline/stylesheeteditor.ui.h
index 7633d5b..a99f274 100644
--- a/tests/auto/uic/baseline/stylesheeteditor.ui.h
+++ b/tests/auto/uic/baseline/stylesheeteditor.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'stylesheeteditor.ui'
+** Form generated from reading UI file 'stylesheeteditor.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef STYLESHEETEDITOR_H
diff --git a/tests/auto/uic/baseline/tabbedbrowser.ui.h b/tests/auto/uic/baseline/tabbedbrowser.ui.h
index 1106f13..c234f64 100644
--- a/tests/auto/uic/baseline/tabbedbrowser.ui.h
+++ b/tests/auto/uic/baseline/tabbedbrowser.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'tabbedbrowser.ui'
+** Form generated from reading UI file 'tabbedbrowser.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef TABBEDBROWSER_H
diff --git a/tests/auto/uic/baseline/tablewidgeteditor.ui.h b/tests/auto/uic/baseline/tablewidgeteditor.ui.h
index 4769c42..38fb832 100644
--- a/tests/auto/uic/baseline/tablewidgeteditor.ui.h
+++ b/tests/auto/uic/baseline/tablewidgeteditor.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'tablewidgeteditor.ui'
+** Form generated from reading UI file 'tablewidgeteditor.ui'
 **
 ** Created: Mon Jun 16 17:48:45 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef TABLEWIDGETEDITOR_H
diff --git a/tests/auto/uic/baseline/tetrixwindow.ui.h b/tests/auto/uic/baseline/tetrixwindow.ui.h
index a848545..50ed416 100644
--- a/tests/auto/uic/baseline/tetrixwindow.ui.h
+++ b/tests/auto/uic/baseline/tetrixwindow.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'tetrixwindow.ui'
+** Form generated from reading UI file 'tetrixwindow.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef TETRIXWINDOW_H
diff --git a/tests/auto/uic/baseline/textfinder.ui.h b/tests/auto/uic/baseline/textfinder.ui.h
index f1d51f9..546ff17 100644
--- a/tests/auto/uic/baseline/textfinder.ui.h
+++ b/tests/auto/uic/baseline/textfinder.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'textfinder.ui'
+** Form generated from reading UI file 'textfinder.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef TEXTFINDER_H
diff --git a/tests/auto/uic/baseline/topicchooser.ui.h b/tests/auto/uic/baseline/topicchooser.ui.h
index 8404d0c..65cf205 100644
--- a/tests/auto/uic/baseline/topicchooser.ui.h
+++ b/tests/auto/uic/baseline/topicchooser.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'topicchooser.ui'
+** Form generated from reading UI file 'topicchooser.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef TOPICCHOOSER_H
diff --git a/tests/auto/uic/baseline/translatedialog.ui.h b/tests/auto/uic/baseline/translatedialog.ui.h
index b0df4b5..a85f5ed 100644
--- a/tests/auto/uic/baseline/translatedialog.ui.h
+++ b/tests/auto/uic/baseline/translatedialog.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'translatedialog.ui'
+** Form generated from reading UI file 'translatedialog.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef TRANSLATEDIALOG_H
diff --git a/tests/auto/uic/baseline/translationsettings.ui.h b/tests/auto/uic/baseline/translationsettings.ui.h
index 7ce0485..e36545e 100644
--- a/tests/auto/uic/baseline/translationsettings.ui.h
+++ b/tests/auto/uic/baseline/translationsettings.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'translationsettings.ui'
+** Form generated from reading UI file 'translationsettings.ui'
 **
 ** Created: Mon Sep 1 09:31:03 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef TRANSLATIONSETTINGS_H
diff --git a/tests/auto/uic/baseline/treewidgeteditor.ui.h b/tests/auto/uic/baseline/treewidgeteditor.ui.h
index eb4875d..2fe6344 100644
--- a/tests/auto/uic/baseline/treewidgeteditor.ui.h
+++ b/tests/auto/uic/baseline/treewidgeteditor.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'treewidgeteditor.ui'
+** Form generated from reading UI file 'treewidgeteditor.ui'
 **
 ** Created: Mon Jun 16 17:47:26 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef TREEWIDGETEDITOR_H
diff --git a/tests/auto/uic/baseline/trpreviewtool.ui.h b/tests/auto/uic/baseline/trpreviewtool.ui.h
index 2575cda..5f92583 100644
--- a/tests/auto/uic/baseline/trpreviewtool.ui.h
+++ b/tests/auto/uic/baseline/trpreviewtool.ui.h
@@ -41,12 +41,12 @@
 */
 
 /********************************************************************************
-** Form generated from reading ui file 'trpreviewtool.ui'
+** Form generated from reading UI file 'trpreviewtool.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef TRPREVIEWTOOL_H
diff --git a/tests/auto/uic/baseline/validators.ui.h b/tests/auto/uic/baseline/validators.ui.h
index 03bc898..07e114a 100644
--- a/tests/auto/uic/baseline/validators.ui.h
+++ b/tests/auto/uic/baseline/validators.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'validators.ui'
+** Form generated from reading UI file 'validators.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef VALIDATORS_H
diff --git a/tests/auto/uic/baseline/wateringconfigdialog.ui.h b/tests/auto/uic/baseline/wateringconfigdialog.ui.h
index 02de59b..43120a5 100644
--- a/tests/auto/uic/baseline/wateringconfigdialog.ui.h
+++ b/tests/auto/uic/baseline/wateringconfigdialog.ui.h
@@ -1,10 +1,10 @@
 /********************************************************************************
-** Form generated from reading ui file 'wateringconfigdialog.ui'
+** Form generated from reading UI file 'wateringconfigdialog.ui'
 **
 ** Created: Thu Jul 10 09:47:35 2008
 **      by: Qt User Interface Compiler version 4.5.0
 **
-** WARNING! All changes made in this file will be lost when recompiling ui file!
+** WARNING! All changes made in this file will be lost when recompiling UI file!
 ********************************************************************************/
 
 #ifndef WATERINGCONFIGDIALOG_H
-- 
cgit v0.12


From 97ee0644d4a0c3e03e835c07d99d0bc4dd2d5974 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Thu, 6 Aug 2009 12:59:26 +0200
Subject: lalala ... forgot to add test data

---
 tests/auto/linguist/lrelease/testdata/idbased.ts | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 tests/auto/linguist/lrelease/testdata/idbased.ts

diff --git a/tests/auto/linguist/lrelease/testdata/idbased.ts b/tests/auto/linguist/lrelease/testdata/idbased.ts
new file mode 100644
index 0000000..61497de
--- /dev/null
+++ b/tests/auto/linguist/lrelease/testdata/idbased.ts
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+    <name></name>
+    <message id="test_id">
+        <source>Completely irrelevant source text</source>
+        <translation>This is a test string.</translation>
+    </message>
+    <message id="untranslated_id">
+        <source>This has no translation.</source>
+    </message>
+    <message id="this_another_id">
+        <source>Foo bar.</source>
+        <comment>Warn me!</comment>
+    </message>
+    <message>
+        <source>Drop me!</source>
+    </message>
+</context>
+</TS>
-- 
cgit v0.12


From 419079fb47c90d487b4e1f42029b70d5ec8f0d2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@nokia.com>
Date: Thu, 6 Aug 2009 11:15:20 +0200
Subject: Fix QMacStyle subControlRect()-reporting for CC_SpinBox

The mac style ignored the QAbstractSpinBox::NoButtons flag for the
SC_SpinBoxEditField sub-control, effectivly always making room for
the spinner buttons. Now it's in line with both the Cleanlooks
style and the Windows (common) style.

Reviewed-by: Jens Bache-Wiig <jbache@trolltech.com>
---
 src/gui/styles/qmacstyle_mac.mm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 2f93034..235cba6 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -5510,9 +5510,15 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
                 break;
             }
             case SC_SpinBoxEditField:
-                ret.setRect(fw, fw,
-                            spin->rect.width() - spinner_w - fw * 2 - spinBoxSep,
-                            spin->rect.height() - fw * 2);
+                if (spin->buttonSymbols == QAbstractSpinBox::NoButtons) {
+                    ret.setRect(fw, fw,
+                                spin->rect.width() - fw * 2,
+                                spin->rect.height() - fw * 2);
+                } else {
+                    ret.setRect(fw, fw,
+                                spin->rect.width() - fw * 2 - spinBoxSep - spinner_w,
+                                spin->rect.height() - fw * 2);
+                }
                 ret = visualRect(spin->direction, spin->rect, ret);
                 break;
             default:
-- 
cgit v0.12


From b78d252137aa592f5998b1adea278f066e518ec6 Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 13:01:41 +0200
Subject: QMenu: fixed a menu poppping up behind the menubar

---
 tests/auto/qmenu/tst_qmenu.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 8ff2b5c..23bb0c2 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -50,6 +50,7 @@
 #include <QStatusBar>
 #include <QListWidget>
 #include <QWidgetAction>
+#include <QDesktopWidget>
 
 #include <qmenu.h>
 #include <qstyle.h>
@@ -791,7 +792,7 @@ void tst_QMenu::task258920_mouseBorder()
     Menu258920 menu;
     QAction *action = menu.addAction("test");
 
-    menu.popup(QPoint());
+    menu.popup(QApplication::desktop()->availableGeometry().center());
     QTest::qWait(100);
     QRect actionRect = menu.actionGeometry(action);
     QTest::mouseMove(&menu, actionRect.center());
-- 
cgit v0.12


From 5fe595a0275f035ceaef1c3078b63eafda21fbf4 Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 13:17:51 +0200
Subject: QMenu: small little code simplification

Reviewed-by: trustme
---
 src/gui/widgets/qmenu.cpp | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 3b6743a..ccf81f8 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -1707,12 +1707,9 @@ QRect QMenu::actionGeometry(QAction *act) const
 QSize QMenu::sizeHint() const
 {
     Q_D(const QMenu);
-    ensurePolished();
     d->updateActionRects();
 
     QSize s;
-    QStyleOption opt(0);
-    opt.init(this);
     for (int i = 0; i < d->actionRects.count(); ++i) {
         const QRect &rect = d->actionRects.at(i);
         if (rect.isNull())
@@ -1725,15 +1722,11 @@ QSize QMenu::sizeHint() const
     // Note that the action rects calculated above already include
     // the top and left margins, so we only need to add margins for
     // the bottom and right.
-    if (const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this)) {
-        s.rwidth() += fw;
-        s.rheight() += fw;
-    }
-
-    s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this);
-    s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this);
-
-    s += QSize(d->rightmargin, d->bottommargin);
+    QStyleOption opt(0);
+    opt.init(this);
+    const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this);
+    s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this) + fw + d->rightmargin;
+    s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) + fw + d->bottommargin;
 
     return style()->sizeFromContents(QStyle::CT_Menu, &opt,
                                     s.expandedTo(QApplication::globalStrut()), this);
-- 
cgit v0.12


From 718ed1f03de370b23968cc02fcb52d5d14486e75 Mon Sep 17 00:00:00 2001
From: Andre Pedralho <andre.pedralho@openbossa.org>
Date: Thu, 6 Aug 2009 13:25:07 +0200
Subject: Added example that uses WebKit to capture Web page frames.

The framecapture is based on GraphicsDojo/WebCapture
and shows how to use WebKit toolkit to capture a web
page and save its internal frames in different image
files using the new property QWebFrame::clipRenderToViewPort.

Merge-request: 1103
Reviewed-by: Ariya Hidayat <ariya.hidayat@nokia.com>
---
 examples/webkit/framecapture/framecapture.cpp | 121 ++++++++++++++++++++++++++
 examples/webkit/framecapture/framecapture.h   |  70 +++++++++++++++
 examples/webkit/framecapture/framecapture.pro |  11 +++
 examples/webkit/framecapture/main.cpp         |  76 ++++++++++++++++
 4 files changed, 278 insertions(+)
 create mode 100644 examples/webkit/framecapture/framecapture.cpp
 create mode 100644 examples/webkit/framecapture/framecapture.h
 create mode 100644 examples/webkit/framecapture/framecapture.pro
 create mode 100644 examples/webkit/framecapture/main.cpp

diff --git a/examples/webkit/framecapture/framecapture.cpp b/examples/webkit/framecapture/framecapture.cpp
new file mode 100644
index 0000000..ef31f6d
--- /dev/null
+++ b/examples/webkit/framecapture/framecapture.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "framecapture.h"
+
+#include <iostream>
+#include <QtWebKit>
+
+FrameCapture::FrameCapture(): QObject(), m_percent(0)
+{
+    connect(&m_page, SIGNAL(loadProgress(int)), this, SLOT(printProgress(int)));
+    connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool)));
+}
+
+void FrameCapture::load(const QUrl &url, const QString &outputFileName)
+{
+    std::cout << "Loading " << qPrintable(url.toString()) << std::endl;
+    m_percent = 0;
+    int index = outputFileName.lastIndexOf('.');
+    m_fileName = (index == -1) ? outputFileName + ".png" : outputFileName;
+    m_page.mainFrame()->load(url);
+    m_page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
+    m_page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
+}
+
+void FrameCapture::printProgress(int percent)
+{
+    if (m_percent >= percent)
+        return;
+
+    while (m_percent++ < percent)
+        std::cout << "#" << std::flush;
+}
+
+void FrameCapture::saveResult(bool ok)
+{
+    std::cout << std::endl;
+
+    // crude error-checking
+    if (!ok) {
+        std::cerr << "Failed loading " << qPrintable(m_page.mainFrame()->url().toString()) << std::endl;
+        emit finished();
+        return;
+    }
+
+    // save each internal frame in different image files
+    int frameCounter = 0;
+    foreach(QWebFrame *frame, m_page.mainFrame()->childFrames()) {
+        QString fileName(m_fileName);
+        int index = m_fileName.lastIndexOf('.');
+        fileName = fileName.insert(index, "_frame" + QString::number(++frameCounter));
+
+        frame->setClipRenderToViewport(false);
+
+        QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied);
+        image.fill(Qt::transparent);
+
+        saveFrame(frame, image, fileName);
+    }
+
+    // save the main frame
+    m_page.setViewportSize(m_page.mainFrame()->contentsSize());
+    QImage image(m_page.mainFrame()->contentsSize(), QImage::Format_ARGB32_Premultiplied);
+    image.fill(Qt::transparent);
+    saveFrame(m_page.mainFrame(), image, m_fileName);
+
+    emit finished();
+}
+
+void FrameCapture::saveFrame(QWebFrame *frame, QImage image, QString fileName)
+{
+    QPainter painter(&image);
+    painter.setRenderHint(QPainter::Antialiasing, true);
+    painter.setRenderHint(QPainter::TextAntialiasing, true);
+    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
+
+    frame->render(&painter);
+
+    painter.end();
+
+    image.save(fileName);
+}
+
diff --git a/examples/webkit/framecapture/framecapture.h b/examples/webkit/framecapture/framecapture.h
new file mode 100644
index 0000000..ffc93ac
--- /dev/null
+++ b/examples/webkit/framecapture/framecapture.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FRAMECAPTURE_H
+#define FRAMECAPTURE_H
+
+#include <QtWebKit>
+
+class FrameCapture : public QObject
+{
+    Q_OBJECT
+
+public:
+    FrameCapture();
+    void load(const QUrl &url, const QString &outputFileName);
+
+signals:
+    void finished();
+
+private slots:
+    void printProgress(int percent);
+    void saveResult(bool ok);
+
+private:
+    QWebPage m_page;
+    QString m_fileName;
+    int m_percent;
+
+    void saveFrame(QWebFrame *frame, QImage image, QString fileName);
+};
+
+#endif
diff --git a/examples/webkit/framecapture/framecapture.pro b/examples/webkit/framecapture/framecapture.pro
new file mode 100644
index 0000000..6f2f093
--- /dev/null
+++ b/examples/webkit/framecapture/framecapture.pro
@@ -0,0 +1,11 @@
+QT      += webkit
+
+HEADERS = framecapture.h
+SOURCES = main.cpp \
+          framecapture.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/webkit/framecapture
+sources.files = $$SOURCES $$HEADERS
+sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/framecapture
+INSTALLS += target sources
diff --git a/examples/webkit/framecapture/main.cpp b/examples/webkit/framecapture/main.cpp
new file mode 100644
index 0000000..fcdb62a
--- /dev/null
+++ b/examples/webkit/framecapture/main.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "framecapture.h"
+
+#include <iostream>
+#include <QtGui>
+
+int main(int argc, char * argv[])
+{
+    if (argc != 3) {
+        std::cout << "Capture a web page and save its internal frames in different images" << std::endl << std::endl;
+        std::cout << "  framecapture <url> <outputfile>" << std::endl;
+        std::cout << std::endl;
+        std::cout << "Notes:" << std::endl;
+        std::cout << "  'url' is the URL of the web page to be captured" << std::endl;
+        std::cout << "  'outputfile' is the prefix of the image files to be generated" << std::endl;
+        std::cout << std::endl;
+        std::cout << "Example: " << std::endl;
+        std::cout << "  framecapture www.trolltech.com trolltech.png" << std::endl;
+        std::cout << std::endl;
+        std::cout << "Result:" << std::endl;
+        std::cout << "  trolltech.png (full page)" << std::endl;
+        std::cout << "  trolltech_frame1.png (...) trolltech_frameN.png ('N' number of internal frames)" << std::endl;
+        return 0;
+    }
+
+    QUrl url = QWebView::guessUrlFromString(QString::fromLatin1(argv[1]));
+    QString fileName = QString::fromLatin1(argv[2]);
+
+    QApplication a(argc, argv);
+    FrameCapture capture;
+    QObject::connect(&capture, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
+    capture.load(url, fileName);
+
+    return a.exec();
+}
+
-- 
cgit v0.12


From 620e7d82b34624f6765daf32917b12ab0e2249b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= <jan-arve.saether@nokia.com>
Date: Thu, 6 Aug 2009 13:18:24 +0200
Subject: Make sure QWidget::setStyle() relayouts its children.

Changing a style on a widget should invalidate the widget's layout,
since the layouts spacings and margins may depend on the style.

One optimization could be to check to see if the spacing and margins
have changed due to the style change, but the old style is not available
in changeEvent, so we'll keep it simple for now.

RevBy: paul
Task: 256986
---
 src/gui/kernel/qwidget.cpp               | 4 +++-
 tests/auto/qboxlayout/tst_qboxlayout.cpp | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 60a6b7a..f705761 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -7990,10 +7990,12 @@ void QWidget::changeEvent(QEvent * event)
 
     case QEvent::FontChange:
     case QEvent::StyleChange: {
+        Q_D(QWidget);
         update();
         updateGeometry();
+        if (d->layout)
+            d->layout->invalidate();
 #ifdef Q_WS_QWS
-        Q_D(QWidget);
         if (isWindow())
             d->data.fstrut_dirty = true;
 #endif
diff --git a/tests/auto/qboxlayout/tst_qboxlayout.cpp b/tests/auto/qboxlayout/tst_qboxlayout.cpp
index 642bc77..5803985 100644
--- a/tests/auto/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/qboxlayout/tst_qboxlayout.cpp
@@ -240,7 +240,6 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing()
     window->setStyle(style2);
     QTest::qWait(100);
     spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
-    QEXPECT_FAIL("", "Fix for next minor release", Continue);
     QCOMPARE(spacing, 10);
 
     delete window;
-- 
cgit v0.12


From bcf834abc2ff2a97be94f1c287753fb4c58e8da8 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Thu, 6 Aug 2009 13:35:14 +0200
Subject: ignore some

---
 tests/auto/linguist/lconvert/.gitignore | 2 ++
 tests/auto/linguist/lrelease/.gitignore | 2 ++
 tests/auto/linguist/lupdate/.gitignore  | 4 ++++
 3 files changed, 8 insertions(+)
 create mode 100644 tests/auto/linguist/lconvert/.gitignore
 create mode 100644 tests/auto/linguist/lrelease/.gitignore
 create mode 100644 tests/auto/linguist/lupdate/.gitignore

diff --git a/tests/auto/linguist/lconvert/.gitignore b/tests/auto/linguist/lconvert/.gitignore
new file mode 100644
index 0000000..042d7ac
--- /dev/null
+++ b/tests/auto/linguist/lconvert/.gitignore
@@ -0,0 +1,2 @@
+tst_lconvert
+data/plural-?.po
diff --git a/tests/auto/linguist/lrelease/.gitignore b/tests/auto/linguist/lrelease/.gitignore
new file mode 100644
index 0000000..cf7059c
--- /dev/null
+++ b/tests/auto/linguist/lrelease/.gitignore
@@ -0,0 +1,2 @@
+tst_lrelease
+testdata/*.qm
diff --git a/tests/auto/linguist/lupdate/.gitignore b/tests/auto/linguist/lupdate/.gitignore
new file mode 100644
index 0000000..4ba5b79
--- /dev/null
+++ b/tests/auto/linguist/lupdate/.gitignore
@@ -0,0 +1,4 @@
+tst_lupdate
+testdata/good/*/project.ts
+testdata/output_ts/toplevel/library/tools/translations/project.ts
+testdata/recursivescan/*.ts
-- 
cgit v0.12


From 504866ffcf57461774bc39357b23954df3a2d9ee Mon Sep 17 00:00:00 2001
From: Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
Date: Thu, 6 Aug 2009 13:25:43 +0200
Subject: Skip tst_QWindowSurface::flushOutsidePaintEvent() when using
 composition manager

The first VERIFY_COLOR(w.geometry(), w.color); call was failing because
the window was mapped but not yet painted on the screen.

Reviewed-by: Bradley T. Hughes
---
 tests/auto/qwindowsurface/tst_qwindowsurface.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp
index ddd1930..b03cd05 100644
--- a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp
+++ b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp
@@ -48,6 +48,7 @@
 
 #include <private/qwindowsurface_p.h>
 #include <QDesktopWidget>
+#include <QX11Info>
 
 class tst_QWindowSurface : public QObject
 {
@@ -138,6 +139,11 @@ void tst_QWindowSurface::getSetWindowSurface()
 
 void tst_QWindowSurface::flushOutsidePaintEvent()
 {
+#ifdef Q_WS_X11
+    if (QX11Info::isCompositingManagerRunning())
+        QSKIP("Test is unreliable with composition manager", SkipAll);
+#endif
+
 #ifdef Q_WS_WIN
     if (QSysInfo::WindowsVersion & QSysInfo::WV_VISTA) {
         QTest::qWait(1000);
-- 
cgit v0.12


From 576af5e57831c7065d621f468c067fca8ebc2fe5 Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Thu, 6 Aug 2009 13:14:52 +0200
Subject: Fixed compilation of the gestures/imagewidget example.

Also improved an example a bit to optionally support TapAndHold
gesture with plain mouse events.

Reviewed-by: trustme
---
 examples/gestures/imageviewer/imagewidget.cpp      | 13 +++++----
 .../gestures/imageviewer/tapandholdgesture.cpp     | 33 +++++++++++++++++-----
 examples/gestures/imageviewer/tapandholdgesture.h  |  1 +
 3 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/examples/gestures/imageviewer/imagewidget.cpp b/examples/gestures/imageviewer/imagewidget.cpp
index 99889ed..c0d1e2d 100644
--- a/examples/gestures/imageviewer/imagewidget.cpp
+++ b/examples/gestures/imageviewer/imagewidget.cpp
@@ -67,6 +67,7 @@ ImageWidget::ImageWidget(QWidget *parent)
 
     tapAndHoldGesture = new TapAndHoldGesture(this);
     connect(tapAndHoldGesture, SIGNAL(triggered()), this, SLOT(gestureTriggered()));
+    connect(tapAndHoldGesture, SIGNAL(finished()), this, SLOT(gestureTriggered()));
 }
 
 void ImageWidget::paintEvent(QPaintEvent*)
@@ -112,7 +113,7 @@ void ImageWidget::paintEvent(QPaintEvent*)
                 touchFeedback.position + QPoint(-10,  10),
                 touchFeedback.position + QPoint(-15,   0)
             };
-            for (int i = 0; i < (touchFeedback.tapAndHoldState-20)/10; ++i)
+            for (int i = 0; i < touchFeedback.tapAndHoldState/5; ++i)
                 p.drawEllipse(pts[i], 3, 3);
         }
     } else if (touchFeedback.sliding) {
@@ -156,10 +157,9 @@ void ImageWidget::mouseDoubleClickEvent(QMouseEvent *event)
 
 void ImageWidget::gestureTriggered()
 {
-    touchFeedback.tapped = false;
-    touchFeedback.doubleTapped = false;
-
     if (sender() == panGesture) {
+        touchFeedback.tapped = false;
+        touchFeedback.doubleTapped = false;
         QPanGesture *pg = qobject_cast<QPanGesture*>(sender());
         if (zoomedIn) {
 #ifndef QT_NO_CURSOR
@@ -174,7 +174,6 @@ void ImageWidget::gestureTriggered()
 #endif
             horizontalOffset += pg->lastOffset().width();
             verticalOffset += pg->lastOffset().height();
-            update();
         } else {
             // only slide gesture should be accepted
             if (pg->state() == Qt::GestureFinished) {
@@ -187,6 +186,7 @@ void ImageWidget::gestureTriggered()
                 updateImage();
             }
         }
+        update();
         feedbackFadeOutTimer.start(500, this);
     } else if (sender() == tapAndHoldGesture) {
         if (tapAndHoldGesture->state() == Qt::GestureFinished) {
@@ -199,6 +199,9 @@ void ImageWidget::gestureTriggered()
             menu.addAction("Action 2");
             menu.addAction("Action 3");
             menu.exec(mapToGlobal(tapAndHoldGesture->pos()));
+        } else {
+            ++touchFeedback.tapAndHoldState;
+            update();
         }
         feedbackFadeOutTimer.start(500, this);
     }
diff --git a/examples/gestures/imageviewer/tapandholdgesture.cpp b/examples/gestures/imageviewer/tapandholdgesture.cpp
index ff5284e..5fe52cc 100644
--- a/examples/gestures/imageviewer/tapandholdgesture.cpp
+++ b/examples/gestures/imageviewer/tapandholdgesture.cpp
@@ -43,6 +43,8 @@
 
 #include <QtGui/qevent.h>
 
+// #define TAPANDHOLD_USING_MOUSE
+
 /*!
     \class TapAndHoldGesture
     \since 4.6
@@ -95,6 +97,26 @@ bool TapAndHoldGesture::filterEvent(QEvent *event)
     case QEvent::TouchEnd:
         reset();
         break;
+#ifdef TAPANDHOLD_USING_MOUSE
+    case QEvent::MouseButtonPress: {
+        if (timer.isActive())
+            timer.stop();
+        timer.start(TapAndHoldGesture::iterationTimeout, this);
+        const QPoint p = static_cast<QMouseEvent*>(event)->pos();
+        position = startPosition = p;
+        break;
+    }
+    case QEvent::MouseMove: {
+        const QPoint startPos = startPosition;
+        const QPoint pos = static_cast<QMouseEvent*>(event)->pos();
+        if ((startPos - pos).manhattanLength() > 15)
+            reset();
+        break;
+    }
+    case QEvent::MouseButtonRelease:
+        reset();
+        break;
+#endif // TAPANDHOLD_USING_MOUSE
     default:
         break;
     }
@@ -108,11 +130,9 @@ void TapAndHoldGesture::timerEvent(QTimerEvent *event)
         return;
     if (iteration == TapAndHoldGesture::iterationCount) {
         timer.stop();
-        setState(Qt::GestureFinished);
-        emit triggered();
+        updateState(Qt::GestureFinished);
     } else {
-        setState(Qt::GestureStarted);
-        emit triggered();
+        updateState(Qt::GestureUpdated);
     }
     ++iteration;
 }
@@ -120,11 +140,10 @@ void TapAndHoldGesture::timerEvent(QTimerEvent *event)
 /*! \internal */
 void TapAndHoldGesture::reset()
 {
-    if (state() != Qt::NoGesture)
-        emit cancelled();
-    setState(Qt::NoGesture);
     timer.stop();
     iteration = 0;
+    position = startPosition = QPoint();
+    updateState(Qt::NoGesture);
 }
 
 /*!
diff --git a/examples/gestures/imageviewer/tapandholdgesture.h b/examples/gestures/imageviewer/tapandholdgesture.h
index e0d50b5..61fabc2 100644
--- a/examples/gestures/imageviewer/tapandholdgesture.h
+++ b/examples/gestures/imageviewer/tapandholdgesture.h
@@ -66,6 +66,7 @@ private:
     QBasicTimer timer;
     int iteration;
     QPoint position;
+    QPoint startPosition;
     static const int iterationCount;
     static const int iterationTimeout;
 };
-- 
cgit v0.12


From e1fe84cb8a16e4ea9425f1f6533dc75afe2fd4c4 Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Date: Thu, 6 Aug 2009 13:54:58 +0200
Subject: QStandardItem::takeRow() would crash when it had no columns.

Reviewed-by: olivier
---
 src/gui/itemviews/qstandarditemmodel.cpp | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp
index e71d8f9..6f99fb5 100644
--- a/src/gui/itemviews/qstandarditemmodel.cpp
+++ b/src/gui/itemviews/qstandarditemmodel.cpp
@@ -1745,15 +1745,17 @@ QList<QStandardItem*> QStandardItem::takeRow(int row)
     if (d->model)
         d->model->d_func()->rowsAboutToBeRemoved(this, row, row);
     QList<QStandardItem*> items;
-    int index = d->childIndex(row, 0);
-    int col_count = d->columnCount();
-    for (int column = 0; column < col_count; ++column) {
-        QStandardItem *ch = d->children.at(index + column);
-        if (ch)
-            ch->d_func()->setParentAndModel(0, 0);
-        items.append(ch);
+    int index = d->childIndex(row, 0);  // Will return -1 if there are no columns
+    if (index != -1) {
+        int col_count = d->columnCount();
+        for (int column = 0; column < col_count; ++column) {
+            QStandardItem *ch = d->children.at(index + column);
+            if (ch)
+                ch->d_func()->setParentAndModel(0, 0);
+            items.append(ch);
+        }
+        d->children.remove(index, col_count);
     }
-    d->children.remove(index, col_count);
     d->rows--;
     if (d->model)
         d->model->d_func()->rowsRemoved(this, row, 1);
-- 
cgit v0.12


From 2f289b2a3e7c217c1e5c85e68cde81951a9fbcd7 Mon Sep 17 00:00:00 2001
From: Martin Smith <msmith@trolltech.com>
Date: Thu, 6 Aug 2009 14:08:10 +0200
Subject: qdoc: Fixed a Windows crash in HtmlGenerator::generateCompactList().

---
 tools/qdoc3/htmlgenerator.cpp | 43 +++++++++++++++++--------------------------
 1 file changed, 17 insertions(+), 26 deletions(-)

diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index df63138..d3a1459 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -2018,8 +2018,8 @@ void HtmlGenerator::generateCompactList(const Node *relative,
       assume that NumParagraphs is 37. Each paragraph is a
       QMap<QString, const Node *>.
     */
-    QMap<QString, const Node *> paragraph[NumParagraphs];
-    QString paragraphName[NumParagraphs];
+    QMap<QString, const Node *> paragraph[NumParagraphs+1];
+    QString paragraphName[NumParagraphs+1];
 
     QMap<QString, const Node *>::ConstIterator c = classMap.begin();
     while (c != classMap.end()) {
@@ -2052,22 +2052,22 @@ void HtmlGenerator::generateCompactList(const Node *relative,
       We now want to compute the paragraph offset. Paragraphs 0 to 6
       start at offsets 0, 3, 4, 8, 9, 14, 23.
     */
-    int paragraphOffset[NumParagraphs + 1];
+    int paragraphOffset[NumParagraphs + 1];     // 37 + 1
     int i, j, k;
 
     paragraphOffset[0] = 0;
-    for (j = 0; j < NumParagraphs; j++)
+    for (j = 0; j < NumParagraphs; j++)         // j = 0..36
         paragraphOffset[j + 1] = paragraphOffset[j] + paragraph[j].count();
 
-    int firstOffset[NumColumns + 1];
-    int currentOffset[NumColumns];
-    int currentParagraphNo[NumColumns];
-    int currentOffsetInParagraph[NumColumns];
+    int firstOffset[NumColumns + 1];            // 4 + 1
+    int currentOffset[NumColumns];              // 4
+    int currentParagraphNo[NumColumns];         // 4
+    int currentOffsetInParagraph[NumColumns];   // 4
 
     int numRows = (classMap.count() + NumColumns - 1) / NumColumns;
     int curParagNo = 0;
 
-    for (i = 0; i < NumColumns; i++) {
+    for (i = 0; i < NumColumns; i++) {          // i = 0..3
         firstOffset[i] = qMin(i * numRows, classMap.size());
         currentOffset[i] = firstOffset[i];
 
@@ -2092,16 +2092,18 @@ void HtmlGenerator::generateCompactList(const Node *relative,
                 out() << "<td>\n</td>\n";
             }
             else {
-                while (currentOffsetInParagraph[i] == paragraph[currentParagraphNo[i]].count()) {
+                while ((currentParagraphNo[i] < NumParagraphs) &&
+                       (currentOffsetInParagraph[i] == paragraph[currentParagraphNo[i]].count())) {
                     ++currentParagraphNo[i];
                     currentOffsetInParagraph[i] = 0;
                 }
-
+#if 0
                 if (currentParagraphNo[i] >= NumParagraphs) {
-                    qDebug() << "### Internal error ###" << __FILE__ << __LINE__;
+                    qDebug() << "### Internal error ###" << __FILE__ << __LINE__
+                             << currentParagraphNo[i] << NumParagraphs;
                     currentParagraphNo[i] = NumParagraphs - 1;
                 }
-
+#endif
                 out() << "<td align=\"right\">";
                 if (currentOffsetInParagraph[i] == 0) {
                     // start a new paragraph
@@ -2111,7 +2113,8 @@ void HtmlGenerator::generateCompactList(const Node *relative,
                 }
                 out() << "</td>\n";
                     
-                if (!paragraphName[currentParagraphNo[i]].isEmpty()) {
+                if ((currentParagraphNo[i] < NumParagraphs) &&
+                    !paragraphName[currentParagraphNo[i]].isEmpty()) {
                     QMap<QString, const Node *>::Iterator it;
                     it = paragraph[currentParagraphNo[i]].begin();
                     for (j = 0; j < currentOffsetInParagraph[i]; j++)
@@ -3710,12 +3713,6 @@ QString HtmlGenerator::getLink(const Atom *atom,
                                 }
                                 inObsoleteLink = true;
                             }
-#if 0                            
-                            qDebug() << "Link to Obsolete entity"
-                                     << (*node)->name();
-                            qDebug() << "  relative entity"
-                                     << relative->name();
-#endif                            
                         }
                     }
                 }
@@ -3731,8 +3728,6 @@ QString HtmlGenerator::getLink(const Atom *atom,
             else if ((*node)->status() == Node::Internal) {
                 qDebug() << "Link to Internal entity";
             }
-            //else
-            //qDebug() << "Node Status:" << (*node)->status();
 #endif                
         }
 
@@ -4016,10 +4011,6 @@ void HtmlGenerator::generateQmlInherits(const QmlClassNode* cn,
                 generateText(text, cn, marker);
                 out() << "</p>";
             }
-//            else
-//                qDebug() << "generateQmlInherits(): "
-//                         << "Inherited element not documented -->"
-//                         << linkPair.first;
         }
     }
 }
-- 
cgit v0.12


From 13998901f7831beaaeca6ada4def3e29af4e251d Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 13:43:42 +0200
Subject: QMenuBar: we can't test the action geometries when it is native

---
 src/gui/widgets/qmenubar.cpp         | 3 +++
 tests/auto/qmenubar/tst_qmenubar.cpp | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index 4a900d6..389b65f 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -272,6 +272,9 @@ QRect QMenuBarPrivate::actionRect(QAction *act) const
     //makes sure the geometries are up-to-date
     const_cast<QMenuBarPrivate*>(this)->updateGeometries();
 
+    if (index >= actionRects.count())
+        return QRect(); // that can happen in case of native menubar
+
     QRect ret = actionRects.at(index);
     return QStyle::visualRect(q->layoutDirection(), q->rect(), ret);
 }
diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp
index 67e088b..f8f536c 100644
--- a/tests/auto/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/qmenubar/tst_qmenubar.cpp
@@ -1586,6 +1586,9 @@ void tst_QMenuBar::menubarSizeHint()
     } style;
 
     QMenuBar mb;
+    if (mb.isNativeMenuBar())
+	    QSKIP("we can't check the geometry of native menubars", SkipAll);
+		
     mb.setStyle(&style);
     //this is a list of arbitrary strings so that we check the geometry
     QStringList list = QStringList() << "trer" << "ezrfgtgvqd" << "sdgzgzerzerzer" << "eerzertz"  << "er";
-- 
cgit v0.12


From 8dbc32699dec7aa928eb9518c05437f481d11a43 Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 14:11:53 +0200
Subject: QMenuBar: autotests fixed

Apperently we don't get the leave event when simply moving the
mouse with the testlib
---
 tests/auto/qmenubar/tst_qmenubar.cpp | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp
index f8f536c..3ccd0c8 100644
--- a/tests/auto/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/qmenubar/tst_qmenubar.cpp
@@ -1529,6 +1529,7 @@ void tst_QMenuBar::task223138_triggered()
 void tst_QMenuBar::task256322_highlight()
 {
     QMainWindow win;
+	win.menuBar()->setNativeMenuBar(false);  //we can't check the geometry of native menubars
     QMenu menu;
     QAction *file = win.menuBar()->addMenu(&menu);
     file->setText("file");
@@ -1538,7 +1539,7 @@ void tst_QMenuBar::task256322_highlight()
     QAction *nothing = win.menuBar()->addAction("nothing");
 
     win.show();
-    QTest::qWait(50);
+    QTest::qWait(200);
 
     QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file).center());
     QTest::mouseClick(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center());
@@ -1551,15 +1552,11 @@ void tst_QMenuBar::task256322_highlight()
     QVERIFY(menu2.isVisible());
     QCOMPARE(win.menuBar()->activeAction(), file2);
 
-    QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(nothing).center());
+    QPoint nothingCenter = win.menuBar()->actionGeometry(nothing).center();
+    QTest::mouseMove(win.menuBar(), nothingCenter);
     QTRY_VERIFY(!menu2.isVisible());
     QVERIFY(!menu.isVisible());
     QCOMPARE(win.menuBar()->activeAction(), nothing);
-
-    QTest::mouseMove(&win, win.menuBar()->geometry().bottomLeft() + QPoint(1,1));
-    QTRY_VERIFY(!menu.isVisible());
-    QVERIFY(!menu2.isVisible());
-    QVERIFY(!win.menuBar()->activeAction());
 }
 
 void tst_QMenuBar::menubarSizeHint()
@@ -1586,8 +1583,7 @@ void tst_QMenuBar::menubarSizeHint()
     } style;
 
     QMenuBar mb;
-    if (mb.isNativeMenuBar())
-	    QSKIP("we can't check the geometry of native menubars", SkipAll);
+    mb.setNativeMenuBar(false); //we can't check the geometry of native menubars
 		
     mb.setStyle(&style);
     //this is a list of arbitrary strings so that we check the geometry
-- 
cgit v0.12


From 2228e670ca89d3292452673f2630aa2f88e1873b Mon Sep 17 00:00:00 2001
From: Leonardo Sobral Cunha <leo.cunha@nokia.com>
Date: Thu, 6 Aug 2009 14:29:54 +0200
Subject: Fixes autotests in QFileSystemWatcher: watchFileAndItsDirectory

dnotify is something from older linux kernels and cannot be trusted, therefore
we skip some tests. Also we cannot guarantee that 1 operation on the file give only
1 notification in general, so we relaxed the conditions.

Reviewed-by: paul
---
 .../qfilesystemwatcher/tst_qfilesystemwatcher.cpp  | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index c883c63..b89890e 100644
--- a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -399,6 +399,15 @@ void tst_QFileSystemWatcher::removePaths()
     watcher.removePaths(paths);
 }
 
+#if 0
+class SignalTest : public QObject {
+    Q_OBJECT;
+    public slots:
+        void fileSlot(const QString &file) { qDebug() << "file " << file;}
+        void dirSlot(const QString &dir) { qDebug() << "dir" << dir;}
+};
+#endif
+
 void tst_QFileSystemWatcher::watchFileAndItsDirectory()
 {
     QFETCH(QString, backend);
@@ -423,6 +432,12 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
     watcher.addPath(testDir.dirName());
     watcher.addPath(testFileName);
 
+    /*
+    SignalTest signalTest;
+    QObject::connect(&watcher, SIGNAL(fileChanged(const QString &)), &signalTest, SLOT(fileSlot(const QString &)));
+    QObject::connect(&watcher, SIGNAL(directoryChanged(const QString &)), &signalTest, SLOT(dirSlot(const QString &)));
+    */
+
     QSignalSpy fileChangedSpy(&watcher, SIGNAL(fileChanged(const QString &)));
     QSignalSpy dirChangedSpy(&watcher, SIGNAL(directoryChanged(const QString &)));
     QEventLoop eventLoop;
@@ -440,9 +455,12 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
 
     timer.start(3000);
     eventLoop.exec();
-    QCOMPARE(fileChangedSpy.count(), 1);
+    QVERIFY(fileChangedSpy.count() > 0);
     QCOMPARE(dirChangedSpy.count(), 0);
 
+    if (backend == "dnotify")
+        QSKIP("dnotify is broken, skipping the rest of the test.", SkipSingle);
+
     fileChangedSpy.clear();
     QFile secondFile(secondFileName);
     secondFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
@@ -460,7 +478,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
 
     timer.start(3000);
     eventLoop.exec();
-    QCOMPARE(fileChangedSpy.count(), 1);
+    QVERIFY(fileChangedSpy.count() > 0);
     QCOMPARE(dirChangedSpy.count(), 1);
 
     fileChangedSpy.clear();
-- 
cgit v0.12


From 555e5be0e8bd46a351e200cc3af9f93a0d91e87b Mon Sep 17 00:00:00 2001
From: Peter Hartmann <peter.hartmann@trolltech.com>
Date: Thu, 6 Aug 2009 14:35:26 +0200
Subject: Fix QXmlQuery autotests

before, it asserted; now, the test is not asserting anymore but
still failing, because the fix is not yet checked in. Additionally,
it now runs from a shadow directory.

Reviewed-by: TrustMe
---
 tests/auto/qxmlquery/qxmlquery.pro     |  6 ++++++
 tests/auto/qxmlquery/tst_qxmlquery.cpp | 30 +++++++++++++++---------------
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/tests/auto/qxmlquery/qxmlquery.pro b/tests/auto/qxmlquery/qxmlquery.pro
index e8ab641..3db3734 100644
--- a/tests/auto/qxmlquery/qxmlquery.pro
+++ b/tests/auto/qxmlquery/qxmlquery.pro
@@ -10,6 +10,12 @@ RESOURCES = input.qrc
 
 QT += network
 
+!wince* {
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+} else {
+DEFINES += SRCDIR=\\\"./\\\"
+}
+
 include (../xmlpatterns.pri)
 
 wince*: {
diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp
index 5c14329..6563240 100644
--- a/tests/auto/qxmlquery/tst_qxmlquery.cpp
+++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp
@@ -259,7 +259,7 @@ void tst_QXmlQuery::checkBaseURI(const QUrl &baseURI, const QString &candidate)
     QVERIFY(QDir(baseURI.toLocalFile()).relativeFilePath(QFileInfo(candidate).canonicalFilePath()).startsWith("../"));
 }
 
-const char *const tst_QXmlQuery::queriesDirectory = "../xmlpatterns/queries/";
+const char *const tst_QXmlQuery::queriesDirectory = SRCDIR "../xmlpatterns/queries/";
 
 QStringList tst_QXmlQuery::queries()
 {
@@ -738,7 +738,7 @@ void tst_QXmlQuery::bindVariableQStringQIODeviceWithString() const
 void tst_QXmlQuery::bindVariableQStringQIODeviceWithQFile() const
 {
     QXmlQuery query;
-    QFile inDevice(QLatin1String("input.xml"));
+    QFile inDevice(QLatin1String(SRCDIR "input.xml"));
 
     QVERIFY(inDevice.open(QIODevice::ReadOnly));
 
@@ -852,7 +852,7 @@ void tst_QXmlQuery::bindVariableXSLTSuccess() const
     stylesheet.bindVariable(QLatin1String("paramSelectWithTypeIntBoundWithBindVariableRequired"),
                                           QVariant(QLatin1String("param5")));
 
-    stylesheet.setQuery(QUrl(inputFile(QLatin1String("../xmlpatterns/stylesheets/parameters.xsl"))));
+    stylesheet.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/parameters.xsl"))));
 
     QVERIFY(stylesheet.isValid());
 
@@ -960,7 +960,7 @@ void tst_QXmlQuery::evaluateToReceiver()
     PushBaseliner push(stream, query.namePool());
     query.evaluateTo(&push);
 
-    const QString baselineName(inputFile(QLatin1String("pushBaselines/") + inputQuery.left(inputQuery.length() - 2) + QString::fromLatin1("ref")));
+    const QString baselineName(inputFile(QLatin1String(SRCDIR "pushBaselines/") + inputQuery.left(inputQuery.length() - 2) + QString::fromLatin1("ref")));
     QFile baseline(baselineName);
 
     if(baseline.exists())
@@ -1300,7 +1300,7 @@ void tst_QXmlQuery::basicQtToXQueryTypeCheck() const
     // TODO Do with different QDateTime time specs
     query.bindVariable(QLatin1String("fromQDateTime"), QXmlItem(QDateTime(QDate(2001, 9, 10), QTime(1, 2, 3))));
     query.bindVariable(QLatin1String("fromDouble"), QXmlItem(double(3)));
-    query.bindVariable(QLatin1String("fromFloat"), QXmlItem(float(4)));
+//    query.bindVariable(QLatin1String("fromFloat"), QXmlItem(float(4)));
     query.bindVariable(QLatin1String("integer"), QXmlItem(5));
     query.bindVariable(QLatin1String("fromQString"), QXmlItem(QString::fromLatin1("A QString")));
     query.bindVariable(QLatin1String("fromQChar"), QXmlItem(QChar::fromLatin1('C')));
@@ -1793,11 +1793,11 @@ void tst_QXmlQuery::setFocusQUrl() const
     {
         QXmlQuery query(QXmlQuery::XSLT20);
 
-        const TestURIResolver resolver(QUrl(inputFile(QLatin1String("../xmlpatterns/stylesheets/documentElement.xml"))));
+        const TestURIResolver resolver(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
         query.setUriResolver(&resolver);
 
         QVERIFY(query.setFocus(QUrl(QLatin1String("arbitraryURI"))));
-        query.setQuery(QUrl(inputFile(QLatin1String("../xmlpatterns/stylesheets/copyWholeDocument.xsl"))));
+        query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/copyWholeDocument.xsl"))));
         QVERIFY(query.isValid());
 
         QBuffer result;
@@ -2011,7 +2011,7 @@ void tst_QXmlQuery::fnDocNetworkAccessSuccess_data() const
     QTest::addColumn<QByteArray>("expectedOutput");
 
     QTest::newRow("file scheme")
-        << inputFileAsURI(QLatin1String("input.xml"))
+        << inputFileAsURI(QLatin1String(SRCDIR "input.xml"))
         << QByteArray("<!-- This is just a file for testing. --><input/>");
 
     QTest::newRow("data scheme with ASCII")
@@ -2992,7 +2992,7 @@ void tst_QXmlQuery::setInitialTemplateNameQXmlName() const
 
     QCOMPARE(query.initialTemplateName(), name);
 
-    query.setQuery(QUrl(inputFile(QLatin1String("../xmlpatterns/stylesheets/namedTemplate.xsl"))));
+    query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/namedTemplate.xsl"))));
     QVERIFY(query.isValid());
 
     QBuffer result;
@@ -3054,7 +3054,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const
     /* Ensure fn:doc() picks up the right QNetworkAccessManager. */
     {
         NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")),
-                                          QUrl(inputFile(QLatin1String("../xmlpatterns/queries/simpleDocument.xml"))));
+                                          QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml"))));
 
         QXmlQuery query;
         query.setNetworkAccessManager(&networkOverrider);
@@ -3070,7 +3070,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const
     /* Ensure setQuery() is using the right network manager. */
     {
         NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")),
-                                          QUrl(inputFile(QLatin1String("../xmlpatterns/queries/concat.xq"))));
+                                          QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/concat.xq"))));
 
         QXmlQuery query;
         query.setNetworkAccessManager(&networkOverrider);
@@ -3128,9 +3128,9 @@ void tst_QXmlQuery::multipleDocsAndFocus() const
     /* We use string concatenation, since variable bindings might disturb what
      * we're testing. */
     query.setQuery(QLatin1String("string(doc('") +
-                   inputFile(QLatin1String("../xmlpatterns/queries/simpleDocument.xml")) +
+                   inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")) +
                    QLatin1String("'))"));
-    query.setFocus(QUrl(inputFile(QLatin1String("../xmlpatterns/stylesheets/documentElement.xml"))));
+    query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
     query.setQuery(QLatin1String("string(.)"));
 
     QStringList result;
@@ -3154,11 +3154,11 @@ void tst_QXmlQuery::multipleEvaluationsWithDifferentFocus() const
     QXmlQuery query;
     QStringList result;
 
-    query.setFocus(QUrl(inputFile(QLatin1String("../xmlpatterns/stylesheets/documentElement.xml"))));
+    query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
     query.setQuery(QLatin1String("string(.)"));
     QVERIFY(query.evaluateTo(&result));
 
-    query.setFocus(QUrl(inputFile(QLatin1String("../xmlpatterns/stylesheets/documentElement.xml"))));
+    query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
     QVERIFY(query.evaluateTo(&result));
 }
 
-- 
cgit v0.12


From ef07fa46ed352176eba3c58268fd6bb1512cd70f Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Date: Thu, 6 Aug 2009 14:19:04 +0200
Subject: Delay too short after fullscreen window shown.

---
 tests/auto/qtreeview/tst_qtreeview.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index b21a973..6b42821 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -2917,8 +2917,7 @@ void tst_QTreeView::styleOptionViewItem()
 
     delegate.count = 0;
     view.showMaximized();
-    QTest::qWait(30);
-    QVERIFY(delegate.count >= 13);
+    QTRY_VERIFY(delegate.count >= 13);
 }
 
 class task174627_TreeView : public QTreeView
-- 
cgit v0.12


From d738bfe0f06448d9a6bc2ee1a32225c076c67334 Mon Sep 17 00:00:00 2001
From: Eskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>
Date: Thu, 6 Aug 2009 15:05:32 +0200
Subject: Make sure cursorPositionChanged is emitted when cursor position
 changes

When selecting the text and setting the cursor position, we need to
emit the cursorPositionChanged signal. This seems to be a copy-paste
error from refactoring QLineEdit, as the function call is there in the
original version of setSelection(). The effect was two test breakages
in tst_QDateTimeEdit, because the section and cursor position of the
QDateTimeEdit would be out of sync.

Reviewed-by: Gunnar
---
 src/gui/widgets/qlinecontrol.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index d90d53b..f4a2348 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -257,6 +257,7 @@ void QLineControl::setSelection(int start, int length)
         m_cursor = m_selstart;
     }
     emit selectionChanged();
+    emitCursorPositionChanged();
 }
 
 void QLineControl::_q_clipboardChanged()
-- 
cgit v0.12


From 986ac2b13eb60e10496ecf63dca1ed0de0990da9 Mon Sep 17 00:00:00 2001
From: Leonardo Sobral Cunha <leo.cunha@nokia.com>
Date: Thu, 6 Aug 2009 15:13:42 +0200
Subject: Fixes autotests in QTreeWidget: setHeaderItem & defaultRowSizes

defaultRowSizes was broken on oxygen style because of missing icons.

Reviewed-by: paul
---
 tests/auto/qtreewidget/tst_qtreewidget.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp
index 7d79d56..fd0fdb1 100644
--- a/tests/auto/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp
@@ -238,6 +238,9 @@ void tst_QTreeWidget::initTestCase()
 
     testWidget = new CustomTreeWidget();
     testWidget->show();
+#ifdef Q_WS_X11
+    qt_x11_wait_for_window_manager(testWidget);
+#endif
 }
 
 void tst_QTreeWidget::cleanupTestCase()
@@ -2017,7 +2020,7 @@ void tst_QTreeWidget::setHeaderItem()
     headerItem->setText(0, "0");
     headerItem->setText(1, "1");
     testWidget->setHeaderItem(headerItem);
-    qApp->processEvents();
+    QTest::qWait(100);
     QCOMPARE(testWidget->headerItem(), headerItem);
     QCOMPARE(headerItem->treeWidget(), static_cast<QTreeWidget *>(testWidget));
 
@@ -2762,16 +2765,18 @@ void tst_QTreeWidget::defaultRowSizes()
         for (int j=0; j<tw->columnCount() - 1; ++j) {
             it->setText(j, "This is a test");
         }
+        QPixmap icon = tw->style()->standardPixmap((QStyle::StandardPixmap)(i + QStyle::SP_TitleBarMenuButton));
+        if (icon.isNull())
+            QSKIP("No pixmap found on current style, skipping this test.", SkipSingle);
         it->setIcon(tw->columnCount() - 1,
-                    tw->style()->standardPixmap((QStyle::StandardPixmap)(i + QStyle::SP_TitleBarMenuButton)).
-                    scaled(tw->iconSize()));
+                    icon.scaled(tw->iconSize()));
     }
     tw->resize(100,100);
     tw->show();
     QApplication::processEvents();
 
     QRect visualRect = tw->visualItemRect(tw->topLevelItem(0));
-    QVERIFY(visualRect.height() >=50);
+    QVERIFY(visualRect.height() >= 50);
 }
 
 void tst_QTreeWidget::task191552_rtl()
-- 
cgit v0.12


From af5cb732ac6caf370f98dd41129a723a81d55e9b Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@trolltech.com>
Date: Thu, 6 Aug 2009 15:16:00 +0200
Subject: Fix QObjectRace test

We should not unlock too early, or node might get deleted.
---
 src/corelib/kernel/qobject.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index e37b6d3..6520170 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -843,9 +843,9 @@ QObject::~QObject()
             if (senderLists)
                 senderLists->dirty = true;
 
+            node = node->next;
             if (needToUnlock)
                 m->unlock();
-            node = node->next;
         }
     }
 
-- 
cgit v0.12


From 4b22dc7d36e9ef38bbfc709c63e73718110ce385 Mon Sep 17 00:00:00 2001
From: Martin Smith <msmith@trolltech.com>
Date: Thu, 6 Aug 2009 15:18:01 +0200
Subject: qdoc: Don't include internal or private classes in annotated lists.

---
 tools/qdoc3/htmlgenerator.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index d3a1459..26874e1 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -543,7 +543,8 @@ int HtmlGenerator::generateAtom(const Atom *atom,
             QMap<QString, const Node*> nodeMap;
             for (int i = 0; i < values.size(); ++i) {
                 const Node* n = values.at(i);
-                nodeMap.insert(n->name(),n);
+                if ((n->status() != Node::Internal) && (n->access() != Node::Private))
+                    nodeMap.insert(n->name(),n);
             }
             generateAnnotatedList(relative, marker, nodeMap);
         }
-- 
cgit v0.12


From e1c47a1d3cd8c2a0f6b40fddc2f1fae1cc7e7307 Mon Sep 17 00:00:00 2001
From: Eskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>
Date: Thu, 6 Aug 2009 15:23:39 +0200
Subject: Fix test failure in tst_QDateTimeEdit::task118867

setCursorPosition() should be able to set the cursor at the end of the
string. This is a copy-paste error made when refactoring QLineEdit.

Reviewed-by: Gunnar
---
 src/gui/widgets/qlinecontrol_p.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index e047cb0..ad4e4e4 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -641,7 +641,7 @@ inline void QLineControl::setCursorPosition(int pos)
 {
     if (pos < 0)
         pos = 0;
-    if (pos < m_text.length())
+    if (pos <= m_text.length())
         moveCursor(pos);
 }
 
-- 
cgit v0.12


From 6fb50f9180f990ffa68feb6b5c43030aa36a7093 Mon Sep 17 00:00:00 2001
From: Kent Hansen <khansen@trolltech.com>
Date: Tue, 30 Jun 2009 18:03:36 +0200
Subject: make the calculator example use only standard JS

__qt_sender__ is evil. Gah.
---
 examples/script/calculator/calculator.js | 107 ++++++++++++++++++-------------
 1 file changed, 62 insertions(+), 45 deletions(-)

diff --git a/examples/script/calculator/calculator.js b/examples/script/calculator/calculator.js
index 62c2cba..ac3c1b6 100644
--- a/examples/script/calculator/calculator.js
+++ b/examples/script/calculator/calculator.js
@@ -1,10 +1,19 @@
+Function.prototype.bind = function() {
+    var func = this;
+    var thisObject = arguments[0];
+    var args = Array.prototype.slice.call(arguments, 1);
+    return function() {
+        return func.apply(thisObject, args);
+    }
+}
+
 //! [0]
 function Calculator(ui)
 {
     this.ui = ui;
 
-    this.pendingAdditiveOperator = "";
-    this.pendingMultiplicativeOperator = "";
+    this.pendingAdditiveOperator = Calculator.NO_OPERATOR;
+    this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR;
     this.sumInMemory = 0;
     this.sumSoFar = 0;
     this.factorSoFar = 0;
@@ -13,16 +22,16 @@ function Calculator(ui)
     with (ui) {
         display.text = "0";
 
-        zeroButton.clicked.connect(this, this.digitClicked);
-        oneButton.clicked.connect(this, "digitClicked");
-        twoButton.clicked.connect(this, "digitClicked");
-        threeButton.clicked.connect(this, "digitClicked");
-        fourButton.clicked.connect(this, "digitClicked");
-        fiveButton.clicked.connect(this, "digitClicked");
-        sixButton.clicked.connect(this, "digitClicked");
-        sevenButton.clicked.connect(this, "digitClicked");
-        eightButton.clicked.connect(this, "digitClicked");
-        nineButton.clicked.connect(this, "digitClicked");
+        zeroButton.clicked.connect(this.digitClicked.bind(this, 0));
+        oneButton.clicked.connect(this.digitClicked.bind(this, 1));
+        twoButton.clicked.connect(this.digitClicked.bind(this, 2));
+        threeButton.clicked.connect(this.digitClicked.bind(this, 3));
+        fourButton.clicked.connect(this.digitClicked.bind(this, 4));
+        fiveButton.clicked.connect(this.digitClicked.bind(this, 5));
+        sixButton.clicked.connect(this.digitClicked.bind(this, 6));
+        sevenButton.clicked.connect(this.digitClicked.bind(this, 7));
+        eightButton.clicked.connect(this.digitClicked.bind(this, 8));
+        nineButton.clicked.connect(this.digitClicked.bind(this, 9));
 
         pointButton.clicked.connect(this, "pointClicked");
         changeSignButton.clicked.connect(this, "changeSignClicked");
@@ -36,19 +45,28 @@ function Calculator(ui)
         setMemoryButton.clicked.connect(this, "setMemory");
         addToMemoryButton.clicked.connect(this, "addToMemory");
   
-        divisionButton.clicked.connect(this, "multiplicativeOperatorClicked");
-        timesButton.clicked.connect(this, "multiplicativeOperatorClicked");
-        minusButton.clicked.connect(this, "additiveOperatorClicked");
-        plusButton.clicked.connect(this, "additiveOperatorClicked");
-
-        squareRootButton.clicked.connect(this, "unaryOperatorClicked");
-        powerButton.clicked.connect(this, "unaryOperatorClicked");
-        reciprocalButton.clicked.connect(this, "unaryOperatorClicked");
+        divisionButton.clicked.connect(this.multiplicativeOperatorClicked.bind(this, Calculator.DIVISION_OPERATOR));
+        timesButton.clicked.connect(this.multiplicativeOperatorClicked.bind(this, Calculator.TIMES_OPERATOR));
+        minusButton.clicked.connect(this.additiveOperatorClicked.bind(this, Calculator.MINUS_OPERATOR));
+        plusButton.clicked.connect(this.additiveOperatorClicked.bind(this, Calculator.PLUS_OPERATOR));
+
+        squareRootButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.SQUARE_OPERATOR));
+        powerButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.POWER_OPERATOR));
+        reciprocalButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.RECIPROCAL_OPERATOR));
         equalButton.clicked.connect(this, "equalClicked");
     }
 }
 //! [0]
 
+Calculator.NO_OPERATOR = 0;
+Calculator.SQUARE_OPERATOR = 1;
+Calculator.POWER_OPERATOR = 2;
+Calculator.RECIPROCAL_OPERATOR = 3;
+Calculator.DIVISION_OPERATOR = 4;
+Calculator.TIMES_OPERATOR = 5;
+Calculator.MINUS_OPERATOR = 6;
+Calculator.PLUS_OPERATOR = 7;
+
 Calculator.prototype.abortOperation = function()
 {
     this.clearAll();
@@ -57,24 +75,23 @@ Calculator.prototype.abortOperation = function()
 
 Calculator.prototype.calculate = function(rightOperand, pendingOperator)
 {
-    if (pendingOperator == "+") {
+    if (pendingOperator == Calculator.PLUS_OPERATOR) {
         this.sumSoFar += rightOperand;
-    } else if (pendingOperator == "-") {
+    } else if (pendingOperator == Calculator.MINUS_OPERATOR) {
         this.sumSoFar -= rightOperand;
-    } else if (pendingOperator == "*") {
+    } else if (pendingOperator == Calculator.TIMES_OPERATOR) {
         this.factorSoFar *= rightOperand;
-    } else if (pendingOperator == "/") {
+    } else if (pendingOperator == Calculator.DIVISION_OPERATOR) {
         if (rightOperand == 0)
-        return false;
+            return false;
         this.factorSoFar /= rightOperand;
     }
     return true;
 }
 
 //! [1]
-Calculator.prototype.digitClicked = function()
+Calculator.prototype.digitClicked = function(digitValue)
 {
-    var digitValue = __qt_sender__.text - 0;
     if ((digitValue == 0) && (this.ui.display.text == "0"))
         return;
     if (this.waitingForOperand) {
@@ -85,19 +102,19 @@ Calculator.prototype.digitClicked = function()
 }
 //! [1]
 
-Calculator.prototype.unaryOperatorClicked = function()
+Calculator.prototype.unaryOperatorClicked = function(op)
 {
     var operand = this.ui.display.text - 0;
     var result = 0;
-    if (__qt_sender__.text == "Sqrt") {
+    if (op == Calculator.SQUARE_OPERATOR) {
         if (operand < 0) {
             this.abortOperation();
             return;
         }
         result = Math.sqrt(operand);
-    } else if (__qt_sender__.text == "x^2") {
+    } else if (op == Calculator.POWER_OPERATOR) {
         result = Math.pow(operand, 2);
-    } else if (__qt_sender__.text == "1/x") {
+    } else if (op == Calculator.RECIPROCAL_OPERATOR) {
         if (operand == 0.0) {
             this.abortOperation();
             return;
@@ -108,11 +125,11 @@ Calculator.prototype.unaryOperatorClicked = function()
     this.waitingForOperand = true;
 }
 
-Calculator.prototype.additiveOperatorClicked = function()
+Calculator.prototype.additiveOperatorClicked = function(op)
 {
     var operand = this.ui.display.text - 0;
 
-    if (this.pendingMultiplicativeOperator.length != 0) {
+    if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) {
         if (!this.calculate(operand, this.pendingMultiplicativeOperator)) {
             this.abortOperation();
             return;
@@ -120,10 +137,10 @@ Calculator.prototype.additiveOperatorClicked = function()
         this.ui.display.text = this.factorSoFar + "";
         operand = this.factorSoFar;
         this.factorSoFar = 0;
-        this.pendingMultiplicativeOperator = "";
+        this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR;
     }
 
-    if (this.pendingAdditiveOperator.length != 0) {
+    if (this.pendingAdditiveOperator != Calculator.NO_OPERATOR) {
         if (!this.calculate(operand, this.pendingAdditiveOperator)) {
             this.abortOperation();
             return;
@@ -133,15 +150,15 @@ Calculator.prototype.additiveOperatorClicked = function()
         this.sumSoFar = operand;
     }
 
-    this.pendingAdditiveOperator = __qt_sender__.text;
+    this.pendingAdditiveOperator = op;
     this.waitingForOperand = true;
 }
 
-Calculator.prototype.multiplicativeOperatorClicked = function()
+Calculator.prototype.multiplicativeOperatorClicked = function(op)
 {
     var operand = this.ui.display.text - 0;
 
-    if (this.pendingMultiplicativeOperator.length != 0) {
+    if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) {
         if (!this.calculate(operand, this.pendingMultiplicativeOperator)) {
             this.abortOperation();
             return;
@@ -151,7 +168,7 @@ Calculator.prototype.multiplicativeOperatorClicked = function()
         this.factorSoFar = operand;
     }
 
-    this.pendingMultiplicativeOperator = __qt_sender__.text;
+    this.pendingMultiplicativeOperator = op;
     this.waitingForOperand = true;
 }
 
@@ -159,21 +176,21 @@ Calculator.prototype.equalClicked = function()
 {
     var operand = this.ui.display.text - 0;
 
-    if (this.pendingMultiplicativeOperator.length != 0) {
+    if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) {
         if (!this.calculate(operand, this.pendingMultiplicativeOperator)) {
             this.abortOperation();
             return;
         }
         operand = this.factorSoFar;
         this.factorSoFar = 0.0;
-        this.pendingMultiplicativeOperator = "";
+        this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR;
     }
-    if (this.pendingAdditiveOperator.length != 0) {
+    if (this.pendingAdditiveOperator != Calculator.NO_OPERATOR) {
         if (!this.calculate(operand, this.pendingAdditiveOperator)) {
             this.abortOperation();
             return;
         }
-        this.pendingAdditiveOperator = "";
+        this.pendingAdditiveOperator = Calculator.NO_OPERATOR;
     } else {
         this.sumSoFar = operand;
     }
@@ -234,8 +251,8 @@ Calculator.prototype.clearAll = function()
 {
     this.sumSoFar = 0.0;
     this.factorSoFar = 0.0;
-    this.pendingAdditiveOperator = "";
-    this.pendingMultiplicativeOperator = "";
+    this.pendingAdditiveOperator = Calculator.NO_OPERATOR;
+    this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR;
     this.ui.display.text = "0";
     this.waitingForOperand = true;
 }
-- 
cgit v0.12


From b4264b12a51ecea93517a84f94c15f8e97b2f50f Mon Sep 17 00:00:00 2001
From: Kent Hansen <khansen@trolltech.com>
Date: Wed, 15 Jul 2009 10:59:29 +0200
Subject: implement name() function of custom property iterator

---
 examples/script/customclass/bytearrayclass.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp
index 2044a16..8fe1a96 100644
--- a/examples/script/customclass/bytearrayclass.cpp
+++ b/examples/script/customclass/bytearrayclass.cpp
@@ -297,7 +297,7 @@ void ByteArrayClassPropertyIterator::toBack()
 
 QScriptString ByteArrayClassPropertyIterator::name() const
 {
-    return QScriptString();
+    return object().engine()->toStringHandle(QString::number(m_last));
 }
 
 uint ByteArrayClassPropertyIterator::id() const
-- 
cgit v0.12


From 443a7b6f3eb1191b20240b5068da386d669045fc Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 16:02:59 +0200
Subject: Fix warnings on MSVC

---
 src/corelib/kernel/qobject_p.h   | 2 +-
 src/gui/dialogs/qcolordialog.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 056dee3..5d17bfd 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
 class QVariant;
 class QThreadData;
 class QObjectConnectionListVector;
-namespace QtSharedPointer { class ExternalRefCountData; }
+namespace QtSharedPointer { struct ExternalRefCountData; }
 
 /* mirrored in QtTestLib, DON'T CHANGE without prior warning */
 struct QSignalSpyCallbackSet
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index aee592c..0357a7a 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1836,8 +1836,8 @@ QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent)
 
 QColorDialog::~QColorDialog()
 {
-    Q_D(QColorDialog);
 #if defined(Q_WS_MAC)
+    Q_D(QColorDialog);
     if (d->delegate) {
         d->releaseCocoaColorPanelDelegate();
         QColorDialogPrivate::sharedColorPanelAvailable = true;
-- 
cgit v0.12


From c53004694b49d8e4e6c4cfd294efb6589559c2f3 Mon Sep 17 00:00:00 2001
From: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
Date: Thu, 6 Aug 2009 12:10:16 +0200
Subject: Cocoa: Add support for native gestures

Cocoa: Add support for native gestures
---
 src/gui/kernel/qcocoaview_mac.mm | 54 ++++++++++++++++++++++++++++++++--------
 src/gui/kernel/qevent_p.h        | 10 +++++---
 2 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 1d352cb..8c6f394 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -50,6 +50,7 @@
 #include <private/qdnd_p.h>
 #include <private/qmacinputcontext_p.h>
 #include <private/qmultitouch_mac_p.h>
+#include <private/qevent_p.h>
 
 #include <qscrollarea.h>
 #include <qhash.h>
@@ -868,32 +869,65 @@ extern "C" {
 
 - (void)magnifyWithEvent:(NSEvent *)event;
 {
-    Q_UNUSED(event);
-//    qDebug() << "magnifyWithEvent";
+    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+        return;
+
+    QNativeGestureEvent qNGEvent;
+    qNGEvent.gestureType = QNativeGestureEvent::Zoom;
+    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+    qNGEvent.position = flipPoint(p).toPoint();
+    qNGEvent.percentage = [event magnification];
+    qApp->sendEvent(qwidget, &qNGEvent);
 }
 
 - (void)rotateWithEvent:(NSEvent *)event;
 {
-    Q_UNUSED(event);
-//    qDebug() << "rotateWithEvent";
+    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+        return;
+
+    QNativeGestureEvent qNGEvent;
+    qNGEvent.gestureType = QNativeGestureEvent::Rotate;
+    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+    qNGEvent.position = flipPoint(p).toPoint();
+    qNGEvent.percentage = [event rotation];
+    qApp->sendEvent(qwidget, &qNGEvent);
 }
 
 - (void)swipeWithEvent:(NSEvent *)event;
 {
-    Q_UNUSED(event);
-//    qDebug() << "swipeWithEvent";
+    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+        return;
+
+    QNativeGestureEvent qNGEvent;
+    qNGEvent.gestureType = QNativeGestureEvent::Swipe;
+    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+    qNGEvent.position = flipPoint(p).toPoint();
+    qNGEvent.direction = QSize(-[event deltaX], -[event deltaY]);
+    qApp->sendEvent(qwidget, &qNGEvent);
 }
 
 - (void)beginGestureWithEvent:(NSEvent *)event;
 {
-    Q_UNUSED(event);
-//    qDebug() << "beginGestureWithEvent";
+    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+        return;
+
+    QNativeGestureEvent qNGEvent;
+    qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
+    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+    qNGEvent.position = flipPoint(p).toPoint();
+    qApp->sendEvent(qwidget, &qNGEvent);
 }
 
 - (void)endGestureWithEvent:(NSEvent *)event;
 {
-    Q_UNUSED(event);
-//    qDebug() << "endGestureWithEvent";
+    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+        return;
+
+    QNativeGestureEvent qNGEvent;
+    qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
+    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+    qNGEvent.position = flipPoint(p).toPoint();
+    qApp->sendEvent(qwidget, &qNGEvent);
 }
 #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
 
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 92c4fc1..b21b35c 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -127,11 +127,13 @@ public:
         GestureBegin,
         GestureEnd,
         Pan,
-        Pinch
+        Zoom,
+        Rotate,
+        Swipe
     };
 
     QNativeGestureEvent()
-        : QEvent(QEvent::NativeGesture), gestureType(None)
+        : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0), direction(0, 0)
 #ifdef Q_WS_WIN
         , sequenceId(0)
 #endif
@@ -139,8 +141,10 @@ public:
     }
 
     Type gestureType;
-#ifdef Q_WS_WIN
+    float percentage;
     QPoint position;
+    QSize direction;
+#ifdef Q_WS_WIN
     ulong sequenceId;
 #endif
 };
-- 
cgit v0.12


From af44be42cfacb85ef783cdd051f5d106d25c6b50 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Thu, 6 Aug 2009 16:19:18 +0200
Subject: Designer: Cannot edit menus in an RTL form when Designer uses LTR.

Use widget->layoutDirection() instead of QApplication::layoutDirection()
where applicable, which caused it to break for the case that Designer's
layoutDirection does not match that of a widget [property].
In addition, position the submenu correctly on the left side in the case
of RTL.

Reviewed-by: Jarek Kobus <jkobus@trolltech.com>
Task-number: 259238
---
 .../src/components/buddyeditor/buddyeditor.cpp     |  2 +-
 .../formeditor/default_actionprovider.cpp          | 15 ++--
 .../components/formeditor/default_actionprovider.h |  4 +-
 tools/designer/src/lib/shared/actionprovider_p.h   |  2 +-
 tools/designer/src/lib/shared/qdesigner_menu.cpp   | 86 +++++++++++++++-------
 tools/designer/src/lib/shared/qdesigner_menu_p.h   |  3 +
 .../designer/src/lib/shared/qdesigner_menubar.cpp  | 58 +++++++++------
 .../designer/src/lib/shared/qdesigner_menubar_p.h  |  4 +-
 .../designer/src/lib/shared/qdesigner_toolbar.cpp  |  2 +-
 9 files changed, 114 insertions(+), 62 deletions(-)

diff --git a/tools/designer/src/components/buddyeditor/buddyeditor.cpp b/tools/designer/src/components/buddyeditor/buddyeditor.cpp
index 9984b0d..d5c8670 100644
--- a/tools/designer/src/components/buddyeditor/buddyeditor.cpp
+++ b/tools/designer/src/components/buddyeditor/buddyeditor.cpp
@@ -404,7 +404,7 @@ QWidget *BuddyEditor::findBuddy(QLabel *l, const QWidgetList &existingBuddies) c
     const QRect geom = l->geometry();
     const int y = geom.center().y();
     QWidget *neighbour = 0;
-    switch (QApplication::layoutDirection()) {
+    switch (l->layoutDirection()) {
     case Qt::LeftToRight: { // Walk right to find next managed neighbour
         const int xEnd = parent->size().width();
         for (int x = geom.right() + 1; x < xEnd; x += DeltaX)
diff --git a/tools/designer/src/components/formeditor/default_actionprovider.cpp b/tools/designer/src/components/formeditor/default_actionprovider.cpp
index 42d1f81..41333f8 100644
--- a/tools/designer/src/components/formeditor/default_actionprovider.cpp
+++ b/tools/designer/src/components/formeditor/default_actionprovider.cpp
@@ -73,9 +73,8 @@ enum { indicatorSize = 2 };
 
 // Position an indicator horizontally over the rectangle, indicating
 // 'Insert before' (left or right according to layout direction)
-static inline QRect horizontalIndicatorRect(const QRect &rect)
+static inline QRect horizontalIndicatorRect(const QRect &rect, Qt::LayoutDirection layoutDirection)
 {
-    const Qt::LayoutDirection layoutDirection = QApplication::layoutDirection();
     // Position right?
     QRect rc = QRect(rect.x(), 0, indicatorSize, rect.height() - 1);
     if (layoutDirection == Qt::RightToLeft)
@@ -91,13 +90,13 @@ static inline QRect verticalIndicatorRect(const QRect &rect)
 
 // Determine the geometry of the indicator by retrieving
 // the action under mouse and positioning the bar within its geometry.
-QRect ActionProviderBase::indicatorGeometry(const QPoint &pos) const
+QRect ActionProviderBase::indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const
 {
     QAction *action = actionAt(pos);
     if (!action)
         return QRect();
     QRect rc = actionGeometry(action);
-    return orientation() == Qt::Horizontal ? horizontalIndicatorRect(rc) : verticalIndicatorRect(rc);
+    return orientation() == Qt::Horizontal ? horizontalIndicatorRect(rc, layoutDirection) : verticalIndicatorRect(rc);
 }
 
 // Adjust the indicator while dragging. (-1,1) is called to finish a DND operation
@@ -107,7 +106,7 @@ void ActionProviderBase::adjustIndicator(const QPoint &pos)
         m_indicator->hide();
         return;
     }
-    const QRect ig = indicatorGeometry(pos);
+    const QRect ig = indicatorGeometry(pos, m_indicator->layoutDirection());
     if (ig.isValid()) {
         m_indicator->setGeometry(ig);
         QPalette p = m_indicator->palette();
@@ -145,9 +144,9 @@ Qt::Orientation QToolBarActionProvider::orientation() const
     return m_widget->orientation();
 }
 
-QRect QToolBarActionProvider::indicatorGeometry(const QPoint &pos) const
+QRect QToolBarActionProvider::indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const
 {
-    const QRect actionRect = ActionProviderBase::indicatorGeometry(pos);
+    const QRect actionRect = ActionProviderBase::indicatorGeometry(pos, layoutDirection);
     if (actionRect.isValid())
         return actionRect;
     // Toolbar differs in that is has no dummy placeholder to 'insert before'
@@ -155,7 +154,7 @@ QRect QToolBarActionProvider::indicatorGeometry(const QPoint &pos) const
     const QRect freeArea = ToolBarEventFilter::freeArea(m_widget);
     if (!freeArea.contains(pos))
         return QRect();
-    return orientation() == Qt::Horizontal ? horizontalIndicatorRect(freeArea) : verticalIndicatorRect(freeArea);
+    return orientation() == Qt::Horizontal ? horizontalIndicatorRect(freeArea, layoutDirection) : verticalIndicatorRect(freeArea);
 }
 
 // ------------- QMenuBarActionProvider
diff --git a/tools/designer/src/components/formeditor/default_actionprovider.h b/tools/designer/src/components/formeditor/default_actionprovider.h
index 3660f11..270ea36 100644
--- a/tools/designer/src/components/formeditor/default_actionprovider.h
+++ b/tools/designer/src/components/formeditor/default_actionprovider.h
@@ -66,7 +66,7 @@ public:
     virtual Qt::Orientation orientation() const = 0;
 
 protected:
-    virtual QRect indicatorGeometry(const QPoint &pos) const;
+    virtual QRect indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const;
 
 private:
     QWidget *m_indicator;
@@ -84,7 +84,7 @@ public:
     Qt::Orientation orientation() const;
 
 protected:
-    virtual QRect indicatorGeometry(const QPoint &pos) const;
+    virtual QRect indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const;
 
 private:
     QToolBar *m_widget;
diff --git a/tools/designer/src/lib/shared/actionprovider_p.h b/tools/designer/src/lib/shared/actionprovider_p.h
index b43dee9..5f9b7a0 100644
--- a/tools/designer/src/lib/shared/actionprovider_p.h
+++ b/tools/designer/src/lib/shared/actionprovider_p.h
@@ -86,7 +86,7 @@ template <class Widget>
     // actionGeometry() can be wrong sometimes; it returns a geometry that
     // stretches to the end of the toolbar/menu bar. So, check from the beginning
     // in the case of a horizontal right-to-left orientation.
-    const bool checkTopRight = orientation == Qt::Horizontal && QApplication::layoutDirection() == Qt::RightToLeft;
+    const bool checkTopRight = orientation == Qt::Horizontal && w->layoutDirection() == Qt::RightToLeft;
     const QPoint topRight = QPoint(w->rect().width(), 0);
     for (int index = 0; index < actionCount; ++index) {
         QRect g = w->actionGeometry(actions.at(index));
diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp
index c727d8e..6aba65b 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp
@@ -73,6 +73,19 @@ QT_BEGIN_NAMESPACE
 
 using namespace qdesigner_internal;
 
+// give the user a little more space to click on the sub menu rectangle
+static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection dir)
+{
+    switch (dir) {
+    case Qt::LeftToRight:
+        subMenuRect->setLeft(subMenuRect->left() - 20);
+        break;
+    case Qt::RightToLeft:
+        subMenuRect->setRight(subMenuRect->right() + 20);
+        break;
+    }
+}
+
 QDesignerMenu::QDesignerMenu(QWidget *parent) :
     QMenu(parent),
     m_currentIndex(0),
@@ -325,8 +338,7 @@ bool QDesignerMenu::handleMouseDoubleClickEvent(QWidget *, QMouseEvent *event)
     QRect pm_rect;
     if (action->menu() || hasSubMenuPixmap(action)) {
         pm_rect = subMenuPixmapRect(action);
-        pm_rect.setLeft(pm_rect.left() - 20); // give the user a little more
-                                              // space to click
+        extendClickableArea(&pm_rect, layoutDirection());
     }
 
     if (!pm_rect.contains(event->pos()) && m_currentIndex != -1)
@@ -381,7 +393,7 @@ bool QDesignerMenu::handleMousePressEvent(QWidget * /*widget*/, QMouseEvent *eve
 
     QAction *action = safeActionAt(index);
     QRect pm_rect = subMenuPixmapRect(action);
-    pm_rect.setLeft(pm_rect.left() - 20); // give the user a little more space to click
+    extendClickableArea(&pm_rect, layoutDirection());
 
     const int old_index = m_currentIndex;
     m_currentIndex = index;
@@ -540,7 +552,7 @@ QRect QDesignerMenu::subMenuPixmapRect(QAction *action) const
 {
     static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png"));
     const QRect g = actionGeometry(action);
-    const int x = g.right() - pm.width() - 2;
+    const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - pm.width() - 2) : 2;
     const int y = g.top() + (g.height() - pm.height())/2 + 1;
     return QRect(x, y, pm.width(), pm.height());
 }
@@ -863,38 +875,52 @@ void QDesignerMenu::closeMenuChain()
     m_lastSubMenuIndex = -1;
 }
 
-void QDesignerMenu::moveLeft()
+// Close submenu using the left/right keys according to layoutDirection().
+// Return false to indicate the event must be propagated to the menu bar.
+bool QDesignerMenu::hideSubMenuOnCursorKey()
 {
     if (parentMenu()) {
         hide();
-    } else {
-        closeMenuChain();
-        if (QDesignerMenuBar *mb = parentMenuBar()) {
-            if (QApplication::layoutDirection() == Qt::LeftToRight)
-                mb->moveLeft();
-            else
-                mb->moveRight();
-        }
+        return true;
     }
+    closeMenuChain();
     update();
+    if (parentMenuBar())
+        return false;
+    return true;
 }
 
-void QDesignerMenu::moveRight()
+// Open a submenu using the left/right keys according to layoutDirection().
+// Return false to indicate the event must be propagated to the menu bar.
+bool QDesignerMenu::showSubMenuOnCursorKey()
 {
-    QAction *action = currentAction();
+    const QAction *action = currentAction();
 
-    if (qobject_cast<SpecialMenuAction*>(action) || action->isSeparator()) {
+    if (qobject_cast<const SpecialMenuAction*>(action) || action->isSeparator()) {
         closeMenuChain();
-        if (QDesignerMenuBar *mb = parentMenuBar()) {
-            if (QApplication::layoutDirection() == Qt::LeftToRight)
-                mb->moveRight();
-            else
-                mb->moveLeft();
-        }
-    } else {
-        m_lastSubMenuIndex = -1; // force a refresh
-        slotShowSubMenuNow();
+        if (parentMenuBar())
+            return false;
+        return true;
     }
+    m_lastSubMenuIndex = -1; // force a refresh
+    slotShowSubMenuNow();
+    return true;
+}
+
+void QDesignerMenu::moveLeft()
+{
+    const bool handled = layoutDirection() == Qt::LeftToRight ?
+                         hideSubMenuOnCursorKey() : showSubMenuOnCursorKey();
+    if (!handled)
+        parentMenuBar()->moveLeft();
+}
+
+void QDesignerMenu::moveRight()
+{
+    const bool handled = layoutDirection() == Qt::LeftToRight ?
+                         showSubMenuOnCursorKey() : hideSubMenuOnCursorKey();
+    if (!handled)
+        parentMenuBar()->moveRight();
 }
 
 void QDesignerMenu::moveUp(bool ctrl)
@@ -1053,7 +1079,15 @@ void QDesignerMenu::slotShowSubMenuNow()
             if ((menu->windowFlags() & Qt::Popup) != Qt::Popup)
                 menu->setWindowFlags(Qt::Popup);
             const QRect g = actionGeometry(action);
-            menu->move(mapToGlobal(g.topRight()));
+            if (layoutDirection() == Qt::LeftToRight) {
+                menu->move(mapToGlobal(g.topRight()));
+            } else {
+                // The position is not initially correct due to the unknown width,
+                // causing it to overlap a bit the first time it is invoked.
+                const QSize menuSize = menu->size();
+                QPoint point = g.topLeft() - QPoint(menu->width() + 10, 0);
+                menu->move(mapToGlobal(point));
+            }
             menu->show();
             menu->setFocus();
         } else {
diff --git a/tools/designer/src/lib/shared/qdesigner_menu_p.h b/tools/designer/src/lib/shared/qdesigner_menu_p.h
index 55d8bcd..93735e6 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_menu_p.h
@@ -181,6 +181,9 @@ protected:
     void selectCurrentAction();
 
 private:
+    bool hideSubMenuOnCursorKey();
+    bool showSubMenuOnCursorKey();
+
     QPoint m_startPosition;
     int m_currentIndex;
     QAction *m_addItem;
diff --git a/tools/designer/src/lib/shared/qdesigner_menubar.cpp b/tools/designer/src/lib/shared/qdesigner_menubar.cpp
index b53bb8d..2b19142 100644
--- a/tools/designer/src/lib/shared/qdesigner_menubar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menubar.cpp
@@ -219,18 +219,12 @@ bool QDesignerMenuBar::handleKeyPressEvent(QWidget *, QKeyEvent *e)
 
         case Qt::Key_Left:
             e->accept();
-            if (QApplication::layoutDirection() == Qt::LeftToRight)
-                moveLeft(e->modifiers() & Qt::ControlModifier);
-            else
-                moveRight(e->modifiers() & Qt::ControlModifier);
+            moveLeft(e->modifiers() & Qt::ControlModifier);
             return true;
 
         case Qt::Key_Right:
             e->accept();
-            if (QApplication::layoutDirection() == Qt::LeftToRight)
-                moveRight(e->modifiers() & Qt::ControlModifier);
-            else
-                moveLeft(e->modifiers() & Qt::ControlModifier);
+            moveRight(e->modifiers() & Qt::ControlModifier);
             return true; // no update
 
         case Qt::Key_Up:
@@ -741,28 +735,48 @@ int QDesignerMenuBar::realActionCount() const
     return actions().count() - 1; // 1 fake actions
 }
 
-void QDesignerMenuBar::moveLeft(bool ctrl)
+bool QDesignerMenuBar::dragging() const
 {
-    if (ctrl)
-        (void) swap(m_currentIndex, m_currentIndex - 1);
-
-    m_currentIndex = qMax(0, --m_currentIndex);
-    // Always re-select, swapping destroys order
-    updateCurrentAction(true);
+    return m_dragging;
 }
 
-bool QDesignerMenuBar::dragging() const
+void QDesignerMenuBar::moveLeft(bool ctrl)
 {
-    return m_dragging;
+    if (layoutDirection() == Qt::LeftToRight) {
+        movePrevious(ctrl);
+    } else {
+        moveNext(ctrl);
+    }
 }
 
 void QDesignerMenuBar::moveRight(bool ctrl)
 {
-    if (ctrl)
-        (void) swap(m_currentIndex + 1, m_currentIndex);
+    if (layoutDirection() == Qt::LeftToRight) {
+        moveNext(ctrl);
+    } else {
+        movePrevious(ctrl);
+    }
+}
+
+void QDesignerMenuBar::movePrevious(bool ctrl)
+{
+    const bool swapped = ctrl && swapActions(m_currentIndex, m_currentIndex - 1);
+    const int newIndex = qMax(0, m_currentIndex - 1);
+    // Always re-select, swapping destroys order
+    if (swapped || newIndex != m_currentIndex) {
+        m_currentIndex = newIndex;
+        updateCurrentAction(true);
+    }
+}
 
-    m_currentIndex = qMin(actions().count() - 1, ++m_currentIndex);
-    updateCurrentAction(!ctrl);
+void QDesignerMenuBar::moveNext(bool ctrl)
+{
+    const bool swapped = ctrl && swapActions(m_currentIndex + 1, m_currentIndex);
+    const int newIndex = qMin(actions().count() - 1, m_currentIndex + 1);
+    if (swapped || newIndex != m_currentIndex) {
+        m_currentIndex = newIndex;
+        updateCurrentAction(!ctrl);
+    }
 }
 
 void QDesignerMenuBar::moveUp()
@@ -869,7 +883,7 @@ QAction *QDesignerMenuBar::safeActionAt(int index) const
     return actions().at(index);
 }
 
-bool QDesignerMenuBar::swap(int a, int b)
+bool QDesignerMenuBar::swapActions(int a, int b)
 {
     const int left = qMin(a, b);
     int right = qMax(a, b);
diff --git a/tools/designer/src/lib/shared/qdesigner_menubar_p.h b/tools/designer/src/lib/shared/qdesigner_menubar_p.h
index 97a655b..fb820e1 100644
--- a/tools/designer/src/lib/shared/qdesigner_menubar_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_menubar_p.h
@@ -155,10 +155,12 @@ protected:
 
     QAction *safeActionAt(int index) const;
 
-    bool swap(int a, int b);
+    bool swapActions(int a, int b);
 
 private:
     void updateCurrentAction(bool selectAction);
+    void movePrevious(bool ctrl);
+    void moveNext(bool ctrl);
 
     QAction *m_addMenu;
     QPointer<QMenu> m_activeMenu;
diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
index 2693452..8c0c61d 100644
--- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
@@ -466,7 +466,7 @@ QRect ToolBarEventFilter::freeArea(const QToolBar *tb)
     QRect exclusionRectangle = actionList.empty() ? handleArea(tb) : tb->actionGeometry(actionList.back());
     switch (tb->orientation()) {
     case Qt::Horizontal:
-        switch (QApplication::layoutDirection()) {
+        switch (tb->layoutDirection()) {
         case Qt::LeftToRight:
             rc.setX(exclusionRectangle.right() + 1);
             break;
-- 
cgit v0.12


From 7d605af42a72f35481e5dad9f279f6b5d5cda2f2 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Thu, 6 Aug 2009 16:45:23 +0200
Subject: nicer way to deal with missing support for template class friends

---
 tools/linguist/shared/profileevaluator.cpp |  2 --
 tools/linguist/shared/profileevaluator.h   | 15 +++++++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp
index 5a9095a..fe22067 100644
--- a/tools/linguist/shared/profileevaluator.cpp
+++ b/tools/linguist/shared/profileevaluator.cpp
@@ -256,10 +256,8 @@ public:
     ProFile *m_prevProFile;                         // See m_prevLineNo
 };
 
-#if (!defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) && !defined(__SUNPRO_CC)
 Q_DECLARE_TYPEINFO(ProFileEvaluator::Private::State, Q_PRIMITIVE_TYPE);
 Q_DECLARE_TYPEINFO(ProFileEvaluator::Private::ProLoop, Q_MOVABLE_TYPE);
-#endif
 
 ProFileEvaluator::Private::Private(ProFileEvaluator *q_)
   : q(q_)
diff --git a/tools/linguist/shared/profileevaluator.h b/tools/linguist/shared/profileevaluator.h
index f3498c1..ba525b2 100644
--- a/tools/linguist/shared/profileevaluator.h
+++ b/tools/linguist/shared/profileevaluator.h
@@ -50,10 +50,21 @@
 #include <QtCore/QStringList>
 #include <QtCore/QStack>
 
+#if (!defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) && !defined(__SUNPRO_CC)
+# define HAVE_TEMPLATE_CLASS_FRIENDS
+#endif
+
 QT_BEGIN_NAMESPACE
 
 class ProFileEvaluator
 {
+#ifdef HAVE_TEMPLATE_CLASS_FRIENDS
+private:
+#else
+public:
+#endif
+    class Private;
+
 public:
     enum TemplateType {
         TT_Unknown = 0,
@@ -93,11 +104,11 @@ public:
     virtual void fileMessage(const QString &msg); // error() and message() from .pro file
 
 private:
-    class Private;
     Private *d;
 
-    // This doesn't help gcc 3.3 and sunpro ...
+#ifdef HAVE_TEMPLATE_CLASS_FRIENDS
     template<typename T> friend class QTypeInfo;
+#endif
 };
 
 QT_END_NAMESPACE
-- 
cgit v0.12


From e5f6edf86de20f86a028842ed6b7c472bbd1d08b Mon Sep 17 00:00:00 2001
From: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
Date: Thu, 6 Aug 2009 16:48:42 +0200
Subject: Fix compile on Windows Reviewed-by: jesper

---
 src/gui/kernel/qapplication_win.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 6421ed9..bdee6ec 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -3740,7 +3740,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
             event.gestureType = QNativeGestureEvent::GestureEnd;
             break;
         case GID_ZOOM:
-            event.gestureType = QNativeGestureEvent::Pinch;
+            event.gestureType = QNativeGestureEvent::Zoom;
             break;
         case GID_PAN:
             event.gestureType = QNativeGestureEvent::Pan;
-- 
cgit v0.12


From 36ed34763d2ba4d8f5cd71b22224bf1245ed2000 Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 15:24:27 +0200
Subject: build fix for mingw

getQApplicationPrivateInternal was not declared
---
 src/gui/kernel/qwidget_win.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index d8bee55..7cfa111 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -2058,6 +2058,7 @@ void QWidgetPrivate::winSetupGestures()
     Q_Q(QWidget);
     if (!q)
         return;
+    extern QApplicationPrivate* getQApplicationPrivateInternal();
     QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
     bool needh = false;
     bool needv = false;
-- 
cgit v0.12


From 02db4405cd34b4366b4ba7ddb10b54dfb60957f5 Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 16:20:58 +0200
Subject: multimedia: fix warnings on mingw

moved static CRITICAL_SECTIONs to cpp files. In header they would be
declared more than once depending on what file includes those headers.
---
 src/multimedia/audio/qaudioinput_win32_p.cpp  | 1 +
 src/multimedia/audio/qaudioinput_win32_p.h    | 2 --
 src/multimedia/audio/qaudiooutput_win32_p.cpp | 2 ++
 src/multimedia/audio/qaudiooutput_win32_p.h   | 2 --
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index e5b6e0d..3478e51 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -55,6 +55,7 @@
 
 //#define DEBUG_AUDIO 1
 
+static CRITICAL_SECTION waveInCriticalSection;
 
 QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat):
     settings(audioFormat)
diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h
index 32464f0..aa0d0b3 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.h
+++ b/src/multimedia/audio/qaudioinput_win32_p.h
@@ -68,8 +68,6 @@
 #include <QtMultimedia/qaudioengine.h>
 
 
-static CRITICAL_SECTION waveInCriticalSection;
-
 class QAudioInputPrivate : public QAbstractAudioInput
 {
     Q_OBJECT
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index f681936..dbf0a66 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -54,6 +54,8 @@
 
 //#define DEBUG_AUDIO 1
 
+static CRITICAL_SECTION waveOutCriticalSection;
+
 QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat):
     settings(audioFormat)
 {
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h
index 91f14f5..50a3992 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.h
+++ b/src/multimedia/audio/qaudiooutput_win32_p.h
@@ -67,8 +67,6 @@
 #include <QtMultimedia/qaudioengine.h>
 
 
-static CRITICAL_SECTION waveOutCriticalSection;
-
 class QAudioOutputPrivate : public QAbstractAudioOutput
 {
     Q_OBJECT
-- 
cgit v0.12


From 8bd1ac790c9b336d64e407a94b1ae6a4e195fc30 Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Thu, 6 Aug 2009 16:34:41 +0200
Subject: Fix warnings on mingw

mingw doesn't support format with %llu or %ll. So I used a QString
---
 src/tools/uic/uic.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp
index bbb3af7..f789980 100644
--- a/src/tools/uic/uic.cpp
+++ b/src/tools/uic/uic.cpp
@@ -184,9 +184,9 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
     if (reader.hasError()) {
         delete ui;
         ui = 0;
-        fprintf(stderr, "uic: Error in line %llu, column %llu : %s\n",
-                reader.lineNumber(), reader.columnNumber(),
-                reader.errorString().toAscii().constData());
+        fprintf(stderr, qPrintable(QString::fromLatin1("uic: Error in line %1, column %2 : %3\n")
+                                    .arg(reader.lineNumber()).arg(reader.columnNumber())
+                                    .arg(reader.errorString())));
     }
 
     return ui;
-- 
cgit v0.12


From a488f0784b265d350441f5e38dc9021e9c2a50fc Mon Sep 17 00:00:00 2001
From: Benjamin Poulain <benjamin.poulain@nokia.com>
Date: Thu, 6 Aug 2009 16:37:07 +0200
Subject: Fix a bug in QProcess. QProcess was not reentrant on Unix

QProcess is supposed to be reentrant but was not on Unix. The
constructor of QProcessManager could be exectued several time when
QProcess is created. The construction is now protected by a mutex.

Task-number: 254246
Reviewed-by: Olivier Goffart
---
 src/corelib/io/qprocess_unix.cpp     | 12 +++++++++++-
 tests/auto/qprocess/tst_qprocess.cpp |  2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 607b734..168eac2 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -162,7 +162,17 @@ private:
     QMap<int, QProcessInfo *> children;
 };
 
-Q_GLOBAL_STATIC(QProcessManager, processManager)
+
+Q_GLOBAL_STATIC(QMutex, processManagerGlobalMutex)
+
+static QProcessManager *processManager() {
+    // The constructor of QProcessManager should be called only once
+    // so we cannot use Q_GLOBAL_STATIC directly for QProcessManager
+    QMutex *mutex = processManagerGlobalMutex();
+    QMutexLocker locker(mutex);
+    static QProcessManager processManager;
+    return &processManager;
+}
 
 QProcessManager::QProcessManager()
 {
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp
index d235dff..1ffa360 100644
--- a/tests/auto/qprocess/tst_qprocess.cpp
+++ b/tests/auto/qprocess/tst_qprocess.cpp
@@ -1224,7 +1224,7 @@ private:
 //-----------------------------------------------------------------------------
 void tst_QProcess::processInAThread()
 {
-    for (int i = 0; i < 3; ++i) {
+    for (int i = 0; i < 10; ++i) {
         TestThread thread;
         thread.start();
         QVERIFY(thread.wait(10000));
-- 
cgit v0.12


From da913bba1a0ecb4b5b8008b120d3951f1b69a2e5 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Thu, 6 Aug 2009 12:42:23 +0200
Subject: fix warning in tst_qlocalsocket

Reviewed-by: thartman
---
 tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index a41eecd..b861e62 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -918,6 +918,7 @@ void tst_QLocalSocket::writeOnlySocket()
 
     QVERIFY(server.waitForNewConnection());
     QLocalSocket* serverSocket = server.nextPendingConnection();
+    QVERIFY(serverSocket);
 
     QCOMPARE(client.bytesAvailable(), qint64(0));
     QCOMPARE(client.state(), QLocalSocket::ConnectedState);
-- 
cgit v0.12


From 2aeaf16a1e31856a3051e6727c5ff2695fec9625 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Thu, 6 Aug 2009 14:33:23 +0200
Subject: fix tst_qlocalsocket::readBufferOverflow for Windows CE

The TCP socket must get the chance to read data into its read buffer
after the first read operation emptied it.

Reviewed-by: thartman
---
 tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index b861e62..177648d 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -555,14 +555,17 @@ void tst_QLocalSocket::readBufferOverflow()
     QVERIFY(server.hasPendingConnections());
 
     QLocalSocket* serverSocket = server.nextPendingConnection();
-    char* buffer = (char*)qMalloc(dataBufferSize);
+    char buffer[dataBufferSize];
     memset(buffer, 0, dataBufferSize);
     serverSocket->write(buffer, dataBufferSize);
     serverSocket->flush();
-    qFree(buffer);
 
     QVERIFY(client.waitForReadyRead());
-    QCOMPARE(client.readAll().size(), dataBufferSize);
+    QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
+#ifdef QT_LOCALSOCKET_TCP
+    QTest::qWait(250);
+#endif
+    QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
 }
 
 // QLocalSocket/Server can take a name or path, check that it works as expected
-- 
cgit v0.12


From 68423a4642917122c3902dca4ee2710b95c9fa51 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Thu, 6 Aug 2009 16:34:26 +0200
Subject: fixing outputMessage in qplaintestlogger.cpp for Windows CE

There's a restriction to output only 255 characters per line.
The loop we had before was wrong and did some read operations somewhere
behinde the end of the message string.

Reviewed-by: thartman
---
 src/testlib/qplaintestlogger.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index 7bebaa1..e075b36 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -148,11 +148,13 @@ namespace QTest {
     static void outputMessage(const char *str)
     {
 #if defined(Q_OS_WINCE)
-        int length = strlen(str);
-        for (int pos = 0; pos < length; pos +=255) {
-            QString uniText = QString::fromLatin1(str + pos, 255);
-            OutputDebugString((wchar_t*)uniText.utf16());
-        }
+        QString strUtf16 = QString::fromLatin1(str);
+        const int maxOutputLength = 255;
+        do {
+            QString tmp = strUtf16.left(maxOutputLength);
+            OutputDebugString((wchar_t*)tmp.utf16());
+            strUtf16.remove(0, maxOutputLength);
+        } while (!strUtf16.isEmpty());
         if (QTestLog::outputFileName())
 #elif defined(Q_OS_WIN)
         EnterCriticalSection(&outputCriticalSection);
-- 
cgit v0.12


From 4be8bdb4ad95263cd9c9c75efe98418c20c4987a Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Thu, 6 Aug 2009 16:46:24 +0200
Subject: tst_qstyle compile fix

Reviewed-by: thartman
---
 tests/auto/qstyle/tst_qstyle.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp
index 2cb5080..3c63a50 100644
--- a/tests/auto/qstyle/tst_qstyle.cpp
+++ b/tests/auto/qstyle/tst_qstyle.cpp
@@ -351,7 +351,7 @@ void tst_QStyle::testAllFunctions(QStyle *style)
     testScrollBarSubControls(style);
 }
 
-void tst_QStyle::testScrollBarSubControls(QStyle *)
+void tst_QStyle::testScrollBarSubControls(QStyle* style)
 {
 #ifdef Q_OS_WINCE_WM
     if (qobject_cast<QWindowsMobileStyle*>(style) && qt_wince_is_smartphone())
-- 
cgit v0.12


From 30655da0d7b41899b10ef662622292be8571f9c4 Mon Sep 17 00:00:00 2001
From: Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
Date: Thu, 6 Aug 2009 17:25:04 +0200
Subject: tst_QHostInfo: Disable short name tests for lookupIPv4.

These tests run against domain names in troll.no and to allow shorter
names the machine has to be in this domain.
Removing them since this specific case test the OS more than Qt itself.

Reviewed-by: Thiago
---
 tests/auto/qhostinfo/tst_qhostinfo.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp
index c3d7c2d..86b70e1 100644
--- a/tests/auto/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp
@@ -214,10 +214,7 @@ void tst_QHostInfo::lookupIPv4_data()
 
     QTest::newRow("empty") << "" << "" << int(QHostInfo::HostNotFound);
 
-    QTest::newRow("lupinella_00") << "l" << lupinellaIp << int(QHostInfo::NoError);
-    QTest::newRow("lupinella_01") << "lupinella" << lupinellaIp << int(QHostInfo::NoError);
-    QTest::newRow("lupinella_02") << "lupinella.troll.no" << lupinellaIp << int(QHostInfo::NoError);
-    QTest::newRow("lupinella_03") << "lupinella.trolltech.com" << lupinellaIp << int(QHostInfo::NoError);
+    QTest::newRow("single_ip4") << "lupinella.troll.no" << lupinellaIp << int(QHostInfo::NoError);
     QTest::newRow("multiple_ip4") << "multi.dev.troll.no" << "1.2.3.4 1.2.3.5 10.3.3.31" << int(QHostInfo::NoError);
     QTest::newRow("literal_ip4") << lupinellaIp << lupinellaIp << int(QHostInfo::NoError);
     QTest::newRow("notfound") << "this-name-does-not-exist-hopefully." << "" << int(QHostInfo::HostNotFound);
-- 
cgit v0.12


From 7ab03e0565bef0f38ff70c069a4b0b0bdb234d68 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Thu, 6 Aug 2009 18:12:28 +0200
Subject: tst_qfileinfo fixed for Windows CE

Win CE doesn't support real file permissions (FAT only).
Further, we don't have pagefile.sys.

Reviewed-by: thartman
---
 tests/auto/qfileinfo/tst_qfileinfo.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index 512f2b6..a87e306 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -749,7 +749,7 @@ void tst_QFileInfo::size()
 
 void tst_QFileInfo::systemFiles()
 {
-#ifndef Q_OS_WIN
+#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)
     QSKIP("This is a Windows only test", SkipAll);
 #endif
     QFileInfo fi("c:\\pagefile.sys");
@@ -1077,7 +1077,13 @@ void tst_QFileInfo::isWritable()
 {
     QVERIFY(QFileInfo("tst_qfileinfo.cpp").isWritable());
 #ifdef Q_OS_WIN
-    QVERIFY(!QFileInfo("c:\\pagefile.sys").isWritable());
+#ifdef Q_OS_WINCE
+    QFileInfo fi("\\Windows\\wince.nls");
+#else
+    QFileInfo fi("c:\\pagefile.sys");
+#endif
+    QVERIFY(fi.exists());
+    QVERIFY(!fi.isWritable());
 #endif
 #ifdef Q_OS_UNIX
     if (::getuid() == 0)
-- 
cgit v0.12


From 16b3825bc4ec3335bac412e7070b12f7340477e0 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Thu, 6 Aug 2009 18:51:28 +0200
Subject: tst_qsharedpointer compile fix for Windows CE

There's no time() on Windows CE.

Reviewed-by: Daniel Molkentin
---
 tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index 5214edb..1101a08 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -1407,7 +1407,11 @@ void tst_QSharedPointer::threadStressTest()
 
         base.clear();
 
+#ifdef Q_OS_WINCE
+        srand(QDateTime::currentDateTime().toTime_t());
+#else
         srand(time(NULL));
+#endif
         // start threads
         for (int i = 0; i < allThreads.count(); ++i)
             if (allThreads[i]) allThreads[i]->start();
-- 
cgit v0.12


From 281d3dc3cfff77c185912365130af36f8be632d3 Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@trolltech.com>
Date: Thu, 6 Aug 2009 19:20:16 +0200
Subject: tst_QFile::copyAfterFail fixed on Windows

We cannot remove a file that's still opened.

Reviewed-by: ossi
---
 tests/auto/qfile/tst_qfile.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 66f29dd..249b702 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -915,6 +915,7 @@ void tst_QFile::copyAfterFail()
 
     QVERIFY(file1.open(QIODevice::ReadWrite) && "(test-precondition)");
     QVERIFY(file2.open(QIODevice::ReadWrite) && "(test-precondition)");
+    file2.close();
     QVERIFY(!QFile::exists("copied-file-1.txt") && "(test-precondition)");
     QVERIFY(!QFile::exists("copied-file-2.txt") && "(test-precondition)");
 
-- 
cgit v0.12


From 01f6bb95151f1852020aa7b149f33c49c1229a39 Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Fri, 7 Aug 2009 14:21:49 +1000
Subject: Store QObject*'s in the QVariant data structure

Rather than requiring an allocation of the "shared data" region,
QObject *'s should be stored directly in the data structure.  This very
marginally, but measurably, improves QVariant performance.

Reviewed-by: Thiago Macieira
---
 src/corelib/kernel/qvariant.cpp | 16 +++++++++++++---
 src/corelib/kernel/qvariant.h   |  1 +
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 2b5ea0a..4166944 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -161,6 +161,9 @@ static void construct(QVariant::Private *x, const void *copy)
     case QMetaType::Float:
         x->data.f = copy ? *static_cast<const float*>(copy) : 0.0f;
         break;
+    case QMetaType::QObjectStar:
+        x->data.o = copy ? *static_cast<QObject *const*>(copy) : 0;
+        break;
     case QVariant::LongLong:
         x->data.ll = copy ? *static_cast<const qlonglong *>(copy) : Q_INT64_C(0);
         break;
@@ -257,6 +260,7 @@ static void clear(QVariant::Private *d)
     case QVariant::ULongLong:
     case QVariant::Double:
     case QMetaType::Float:
+    case QMetaType::QObjectStar:
         break;
     case QVariant::Invalid:
     case QVariant::UserType:
@@ -326,6 +330,7 @@ static bool isNull(const QVariant::Private *d)
     case QVariant::Bool:
     case QVariant::Double:
     case QMetaType::Float:
+    case QMetaType::QObjectStar:
         break;
     }
     return d->is_null;
@@ -419,6 +424,8 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
         return a->data.d == b->data.d;
     case QMetaType::Float:
         return a->data.f == b->data.f;
+    case QMetaType::QObjectStar:
+        return a->data.o == b->data.o;
     case QVariant::Date:
         return *v_cast<QDate>(a) == *v_cast<QDate>(b);
     case QVariant::Time:
@@ -1048,6 +1055,9 @@ static void streamDebug(QDebug dbg, const QVariant &v)
     case QMetaType::Float:
         dbg.nospace() << qVariantValue<float>(v);
         break;
+    case QMetaType::QObjectStar:
+        dbg.nospace() << qVariantValue<QObject *>(v);
+        break;
     case QVariant::Double:
         dbg.nospace() << v.toDouble();
         break;
@@ -1361,7 +1371,7 @@ void QVariant::create(int type, const void *copy)
 
 QVariant::~QVariant()
 {
-    if (d.type > Char && d.type != QMetaType::Float && (!d.is_shared || !d.data.shared->ref.deref()))
+    if (d.type > Char && d.type != QMetaType::Float && d.type != QMetaType::QObjectStar && (!d.is_shared || !d.data.shared->ref.deref()))
         handler->clear(&d);
 }
 
@@ -1377,7 +1387,7 @@ QVariant::QVariant(const QVariant &p)
 {
     if (d.is_shared) {
         d.data.shared->ref.ref();
-    } else if (p.d.type > Char && p.d.type != QMetaType::Float) {
+    } else if (p.d.type > Char && p.d.type != QMetaType::Float && p.d.type != QMetaType::QObjectStar) {
         handler->construct(&d, p.constData());
         d.is_null = p.d.is_null;
     }
@@ -1733,7 +1743,7 @@ QVariant& QVariant::operator=(const QVariant &variant)
     if (variant.d.is_shared) {
         variant.d.data.shared->ref.ref();
         d = variant.d;
-    } else if (variant.d.type > Char && variant.d.type != QMetaType::Float) {
+    } else if (variant.d.type > Char && variant.d.type != QMetaType::Float && variant.d.type != QMetaType::QObjectStar) {
         d.type = variant.d.type;
         handler->construct(&d, variant.constData());
         d.is_null = variant.d.is_null;
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index a68939d..4489e95 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -358,6 +358,7 @@ class Q_CORE_EXPORT QVariant
             float f;
             qlonglong ll;
             qulonglong ull;
+            QObject *o;
             void *ptr;
             PrivateShared *shared;
         } data;
-- 
cgit v0.12


From cfa7d8608283a012887e7ecbe42c50ff56cc153e Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Date: Thu, 6 Aug 2009 16:56:41 +0200
Subject: Fixing deployment for shadow builds on Windows CE

Reviewed-by: Joerg
---
 tests/auto/qpluginloader/tst/tst.pro   | 2 +-
 tests/auto/windowsmobile/test/test.pro | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/auto/qpluginloader/tst/tst.pro b/tests/auto/qpluginloader/tst/tst.pro
index 5331f09..28f74d4 100644
--- a/tests/auto/qpluginloader/tst/tst.pro
+++ b/tests/auto/qpluginloader/tst/tst.pro
@@ -13,7 +13,7 @@ win32 {
 
 
 wince*: {
-   addFiles.sources = ../bin/*.dll
+   addFiles.sources = $$OUT_PWD/../bin/*.dll
    addFiles.path = bin
    DEPLOYMENT += addFiles
 }
diff --git a/tests/auto/windowsmobile/test/test.pro b/tests/auto/windowsmobile/test/test.pro
index 2420bf1..b7f65a9 100644
--- a/tests/auto/windowsmobile/test/test.pro
+++ b/tests/auto/windowsmobile/test/test.pro
@@ -8,8 +8,7 @@ RESOURCES += windowsmobile.qrc
 TARGET = tst_windowsmobile
 
 wincewm*: {
-   addFiles.sources = \
-                ../testQMenuBar/*.exe
+   addFiles.sources = $$OUT_PWD/../testQMenuBar/*.exe
                 
 
    addFiles.path = "\Program Files\tst_windowsmobile"
-- 
cgit v0.12


From c10c20c5fc69ac5f0e406ecdc58d072a846e6743 Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Date: Thu, 6 Aug 2009 16:57:46 +0200
Subject: Adding QApplication::processEvents to autotest

Windows CE is sometimes a little bit slow

Reviewed-by: Joerg
---
 tests/auto/qpushbutton/tst_qpushbutton.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp
index 7a81dbf..528f3bb 100644
--- a/tests/auto/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp
@@ -661,6 +661,7 @@ void tst_QPushButton::sizeHint()
         tabWidget->setCurrentWidget(tab2);
         tabWidget->setCurrentWidget(tab1);
         QTest::qWait(100);
+        QApplication::processEvents();
 
         QCOMPARE(button1_2->size(), button2_2->size());
     }
-- 
cgit v0.12


From 478d4dde9f0f6f232136935d93f0b5e3cca9db61 Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Date: Thu, 6 Aug 2009 16:59:09 +0200
Subject: Extra check in pluginloader autotest

This extra check prevents a crash if plugin loading fails

Reviewed-by: Joerg
---
 tests/auto/qpluginloader/tst_qpluginloader.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/auto/qpluginloader/tst_qpluginloader.cpp b/tests/auto/qpluginloader/tst_qpluginloader.cpp
index 8221325..0b8ae45 100644
--- a/tests/auto/qpluginloader/tst_qpluginloader.cpp
+++ b/tests/auto/qpluginloader/tst_qpluginloader.cpp
@@ -264,6 +264,7 @@ void tst_QPluginLoader::deleteinstanceOnUnload()
         if (pass == 0)
             loader1.load(); // not recommended, instance() should do the job.
         PluginInterface *instance1 = qobject_cast<PluginInterface*>(loader1.instance());
+        QVERIFY(instance1);
         QCOMPARE(instance1->pluginName(), QLatin1String("Plugin ok"));
 
         QPluginLoader loader2;
-- 
cgit v0.12


From 592462f4101bb2a9d7be58fb72b8f11714490cd5 Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Date: Thu, 6 Aug 2009 17:00:34 +0200
Subject: fixing qmainwindow autotest

On windows mobile with native menubar integration the menubar is not
a child of the mainwindow

Reviewed-by: Joerg
---
 tests/auto/qmainwindow/tst_qmainwindow.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp
index 6ae7a3e..f81dd82 100644
--- a/tests/auto/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp
@@ -550,6 +550,9 @@ void tst_QMainWindow::menuBar()
         mw.setMenuBar(mb1);
         QVERIFY(mw.menuBar() != 0);
         QCOMPARE(mw.menuBar(), (QMenuBar *)mb1);
+#ifdef Q_WS_WINCE_WM
+        QSKIP("With native menubar integration the menubar is not a child", SkipSingle);
+#endif
         QCOMPARE(mb1->parentWidget(), (QWidget *)&mw);
 
         mw.setMenuBar(0);
-- 
cgit v0.12


From aed3faca7dafdc697402cfc99dc5e9ad2fcbdd45 Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Date: Fri, 7 Aug 2009 09:29:56 +0200
Subject: qmake - add error message if files for deployment are missing

If files for deployment for windows ce are missing we get an error
message now. Wilcards have to behandled special because
QFileInfo::exists() does not work with wildcards.
QFileInfo::absoluteFilePath() does work with wildcards

Reviewed-by: Mauricek
---
 qmake/generators/win32/msvc_vcproj.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 5f250bf..9759e7d 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1261,7 +1261,13 @@ void VcprojGenerator::initDeploymentTool()
                 searchPath = info.absoluteFilePath();
             } else {
                 nameFilter = source.split('\\').last();
-                searchPath = info.absolutePath();
+                if (source.contains('*')) {                    
+                    source = source.split('*').first();                    
+                    info = QFileInfo(source);
+                 }
+                 searchPath = info.absolutePath();
+                 if (!info.exists())
+                    fprintf(stderr, "Deployment file is missing %s\n", source.toLatin1().constData());
             }
 
             int pathSize = searchPath.size();
-- 
cgit v0.12


From 43a98b3ddd8d01b8e6453efd49bb6a9064e1ba08 Mon Sep 17 00:00:00 2001
From: Peter Hartmann <peter.hartmann@trolltech.com>
Date: Fri, 7 Aug 2009 10:19:11 +0200
Subject: xmlpatterns autotest: make tests work from shadow directory

... by prepending SRCDIR to the loaded files.

Reviewed-by: TrustMe
---
 tests/auto/xmlpatterns/tst_xmlpatterns.cpp | 134 ++++++++++++++---------------
 tests/auto/xmlpatterns/xmlpatterns.pro     |   6 ++
 2 files changed, 73 insertions(+), 67 deletions(-)

diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
index 2069d03..26dc280 100644
--- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
+++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
@@ -154,7 +154,7 @@ void tst_XmlPatterns::xquerySupport()
     const QByteArray rawProducedStderr((process.readAllStandardError()));
     const QString fixedStderr(QString::fromLocal8Bit(rawProducedStderr).remove(m_filenameInStderr));
 
-    const QString errorFileName(inputFile(QLatin1String("stderrBaselines/") +
+    const QString errorFileName(inputFile(QLatin1String(SRCDIR "stderrBaselines/") +
                                           QString::fromUtf8(QTest::currentDataTag()).remove(m_normalizeTestName) +
                                           QLatin1String(".txt")));
 
@@ -221,7 +221,7 @@ void tst_XmlPatterns::xquerySupport_data() const
 #endif
 
     /* Check one file for existence, to avoid possible false positives. */
-    QVERIFY(QFile::exists(inputFile(QLatin1String("queries/onePlusOne.xq"))));
+    QVERIFY(QFile::exists(inputFile(QLatin1String(SRCDIR "queries/onePlusOne.xq"))));
 
     QTest::addColumn<int>("expectedExitCode");
     QTest::addColumn<QByteArray>("expectedQueryOutput");
@@ -232,21 +232,21 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("A simple math query")
         << 0
         << QByteArray("2\n")
-        << QStringList((QLatin1String("queries/onePlusOne.xq")))
+        << QStringList((QLatin1String(SRCDIR "queries/onePlusOne.xq")))
         << QString()
         << QString();
 
     QTest::newRow("An unbound external variable")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/externalVariable.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/externalVariable.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Bind an external variable")
         << 0
         << QByteArray("1 4<e>1</e>true\n")
-        << (QStringList() << QLatin1String("queries/externalVariable.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/externalVariable.xq")
                           << QLatin1String("-param")
                           << QLatin1String("externalVariable=1"))
         << QString()
@@ -257,21 +257,21 @@ void tst_XmlPatterns::xquerySupport_data() const
         << QByteArray("1 4<e>1</e>true\n")
         << (QStringList() << QLatin1String("-param")
                           << QLatin1String("externalVariable=1")
-                          << QLatin1String("queries/externalVariable.xq"))
+                          << QLatin1String(SRCDIR "queries/externalVariable.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Use fn:doc")
         << 0
         << QByteArray("<e xmlns=\"http://example.com\" xmlns:p=\"http://example.com/P\" attr=\"1\" p:attr=\"\">\n    <?target data?>\n    <!-- a comment -->\n    <e/>text <f/>text node</e>\n")
-        << QStringList(QLatin1String("queries/openDocument.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/openDocument.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Use fn:doc, together with -no-format, last")
         << 0
         << QByteArray("<e xmlns=\"http://example.com\" xmlns:p=\"http://example.com/P\" attr=\"1\" p:attr=\"\"><?target data?><!-- a comment --><e/>text <f/>text node</e>")
-        << (QStringList() << QLatin1String("queries/openDocument.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/openDocument.xq")
                           << QLatin1String("-no-format"))
         << QString()
         << QString();
@@ -280,7 +280,7 @@ void tst_XmlPatterns::xquerySupport_data() const
         << 0
         << QByteArray("<e xmlns=\"http://example.com\" xmlns:p=\"http://example.com/P\" attr=\"1\" p:attr=\"\"><?target data?><!-- a comment --><e/>text <f/>text node</e>")
         << (QStringList() << QLatin1String("-no-format")
-                          << QLatin1String("queries/openDocument.xq"))
+                          << QLatin1String(SRCDIR "queries/openDocument.xq"))
         << QString()
         << QString();
 
@@ -288,28 +288,28 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Make sure query paths are resolved against CWD, not the location of the executable.")
         << 0
         << QByteArray("2\n")
-        << QStringList(QLatin1String("onePlusOne.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/onePlusOne.xq"))
         << QString::fromLatin1("queries")
         << QString();
 
     QTest::newRow("Call fn:error()")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/errorFunction.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/errorFunction.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Evaluate a library module")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/simpleLibraryModule.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/simpleLibraryModule.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Trigger a static error.")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/staticError.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/staticError.xq"))
         << QString()
         << QString();
 
@@ -323,7 +323,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Open an nonexistent file")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/ThisFileDoesNotExist.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/ThisFileDoesNotExist.xq"))
         << QString()
         << QString();
 
@@ -332,63 +332,63 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("XQuery-function message markups")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/wrongArity.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/wrongArity.xq"))
         << QString()
         << QString();
 
     QTest::newRow("XQuery-type message markups")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/typeError.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/typeError.xq"))
         << QString()
         << QString();
 
     QTest::newRow("XQuery-data & XQuery-keyword message markups")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/zeroDivision.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/zeroDivision.xq"))
         << QString()
         << QString();
 
     QTest::newRow("XQuery-uri message markups")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/unsupportedCollation.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/unsupportedCollation.xq"))
         << QString()
         << QString();
 
     QTest::newRow("XQuery-expression message markups")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/invalidRegexp.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/invalidRegexp.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Print a list of available regexp flags(The available flags are formatted in a complex way.)")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/invalidRegexpFlag.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/invalidRegexpFlag.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Trigger an assert in QPatternist::ColorOutput. The query naturally contains an error; XPTY0004.")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/flwor.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/flwor.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Trigger a second assert in QPatternist::ColorOutput. The query naturally contains XPST0003.")
         << 2
         << QByteArray()
-        << QStringList(QLatin1String("queries/syntaxError.xq"))
+        << QStringList(QLatin1String(SRCDIR "queries/syntaxError.xq"))
         << QString()
         << QString();
 
     QTest::newRow("-param is missing so multiple queries appear")
         << 2
         << QByteArray()
-        << (QStringList() << QLatin1String("queries/reportGlobals.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/reportGlobals.xq")
                           << QLatin1String("fileToOpen=globals.gccxml"))
         << QString()
         << QString();
@@ -403,7 +403,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Basic use of -output, query first")
         << 0
         << QByteArray("2\n")
-        << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq")
                           << QLatin1String("-output")
                           << QLatin1String("basicOutput.out"))
         << QString()
@@ -414,22 +414,22 @@ void tst_XmlPatterns::xquerySupport_data() const
         << QByteArray("<e/>\n")
         << (QStringList() << QLatin1String("-output")
                           << QLatin1String("basicOutput2.out")
-                          << QLatin1String("queries/oneElement.xq"))
+                          << QLatin1String(SRCDIR "queries/oneElement.xq"))
         << QString()
         << QString::fromLatin1("basicOutput2.out");
 
     QTest::newRow("A single query, that does not exist")
         << 2
         << QByteArray()
-        << (QStringList() << QLatin1String("doesNotExist.xq"))
+        << (QStringList() << QLatin1String(SRCDIR "doesNotExist.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Specify two identical query names")
         << 2
         << QByteArray()
-        << (QStringList() << QLatin1String("query.xq")
-                          << QLatin1String("query.xq"))
+        << (QStringList() << QLatin1String(SRCDIR "query.xq")
+                          << QLatin1String(SRCDIR "query.xq"))
         << QString()
         << QString();
 
@@ -459,7 +459,7 @@ void tst_XmlPatterns::xquerySupport_data() const
             << QByteArray()
             << (QStringList() << QLatin1String("-output")
                               << filename
-                              << QLatin1String("queries/onePlusOne.xq"))
+                              << QLatin1String(SRCDIR "queries/onePlusOne.xq"))
             << QString()
             << filename;
     }
@@ -476,7 +476,7 @@ void tst_XmlPatterns::xquerySupport_data() const
             << QByteArray("2\n")
             << (QStringList() << QLatin1String("-output")
                               << outName
-                              << QLatin1String("queries/onePlusOne.xq"))
+                              << QLatin1String(SRCDIR "queries/onePlusOne.xq"))
             << QString()
             << outName;
     }
@@ -484,7 +484,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("one query, and a terminating dash at the end")
         << 0
         << QByteArray("2\n")
-        << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq")
                           << QLatin1String("-"))
         << QString()
         << QString();
@@ -493,7 +493,7 @@ void tst_XmlPatterns::xquerySupport_data() const
         << 0
         << QByteArray("2\n")
         << (QStringList() << QLatin1String("-")
-                          << QLatin1String("queries/onePlusOne.xq"))
+                          << QLatin1String(SRCDIR "queries/onePlusOne.xq"))
         << QString()
         << QString();
 
@@ -580,21 +580,21 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Run a query which evaluates to the empty sequence.")
         << 0
         << QByteArray("\n")
-        << (QStringList() << QLatin1String("queries/emptySequence.xq"))
+        << (QStringList() << QLatin1String(SRCDIR "queries/emptySequence.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Run a query which evaluates to a single document node with no children.")
         << 0
         << QByteArray("\n")
-        << (QStringList() << QLatin1String("queries/onlyDocumentNode.xq"))
+        << (QStringList() << QLatin1String(SRCDIR "queries/onlyDocumentNode.xq"))
         << QString()
         << QString();
 
     QTest::newRow("Invoke with invalid -param value.")
         << 1
         << QByteArray()
-        << (QStringList() << QLatin1String("queries/externalVariable.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/externalVariable.xq")
                           << QLatin1String("-param")
                           << QLatin1String("EqualSignIsMissing"))
         << QString()
@@ -603,7 +603,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Invoke with colon in variable name.")
         << 1
         << QByteArray()
-        << (QStringList() << QLatin1String("queries/externalVariable.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/externalVariable.xq")
                           << QLatin1String("-param")
                           << QLatin1String("xs:name=value"))
         << QString()
@@ -612,7 +612,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Invoke with missing name in -param arg.")
         << 1
         << QByteArray()
-        << (QStringList() << QLatin1String("queries/externalVariable.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/externalVariable.xq")
                           << QLatin1String("-param")
                           << QLatin1String("=value"))
         << QString()
@@ -621,7 +621,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Invoke with -param that has two adjacent equal signs.")
         << 0
         << QByteArray("START =text END\n")
-        << (QStringList() << QLatin1String("queries/externalStringVariable.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/externalStringVariable.xq")
                           << QLatin1String("-param")
                           << QLatin1String("externalString==text"))
         << QString()
@@ -630,7 +630,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Pass in an external variable, but the query doesn't use it.")
         << 0
         << QByteArray("2\n")
-        << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq")
                           << QLatin1String("-param")
                           << QLatin1String("externalString==text"))
         << QString()
@@ -640,7 +640,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Invoke with -param that has no value.")
         << 0
         << QByteArray("START  END\n")
-        << (QStringList() << QLatin1String("queries/externalStringVariable.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/externalStringVariable.xq")
                           << QLatin1String("-param")
                           << QLatin1String("externalString="))
         << QString()
@@ -656,7 +656,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Use a native path")
         << 0
         << QByteArray("2\n")
-        << (QStringList() << QDir::toNativeSeparators(QLatin1String("queries/onePlusOne.xq")))
+        << (QStringList() << QDir::toNativeSeparators(QLatin1String(SRCDIR "queries/onePlusOne.xq")))
         << QString()
         << QString();
 
@@ -671,8 +671,8 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("A valid, existing query, followed by a bogus one")
         << 1
         << QByteArray()
-        << (QStringList() << QLatin1String("queries/onePlusOne.xq")
-                          << QLatin1String("doesNotExist.xq"))
+        << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq")
+                          << QLatin1String(SRCDIR "doesNotExist.xq"))
         << QString()
         << QString();
         */
@@ -681,8 +681,8 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Specify two different query names")
         << 1
         << QByteArray()
-        << (QStringList() << QLatin1String("query1.xq")
-                          << QLatin1String("query2.xq"))
+        << (QStringList() << QLatin1String(SRCDIR "query1.xq")
+                          << QLatin1String(SRCDIR "query2.xq"))
         << QString()
         << QString();
         */
@@ -696,7 +696,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Use -param twice")
         << 0
         << QByteArray("param1 param2\n")
-        << (QStringList() << QLatin1String("queries/twoVariables.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/twoVariables.xq")
                           << QLatin1String("-param")
                           << QLatin1String("var1=param1")
                           << QLatin1String("-param")
@@ -707,7 +707,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Use -param thrice")
         << 0
         << QByteArray("param1 param2 third\n")
-        << (QStringList() << QLatin1String("queries/threeVariables.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/threeVariables.xq")
                           << QLatin1String("-param")
                           << QLatin1String("var1=param1")
                           << QLatin1String("-param")
@@ -720,7 +720,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Specify the same parameter twice, different values")
         << 1
         << QByteArray()
-        << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq")
                           << QLatin1String("-param")
                           << QLatin1String("duplicated=param1")
                           << QLatin1String("-param")
@@ -731,7 +731,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Specify the same parameter twice, same values")
         << 1
         << QByteArray()
-        << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+        << (QStringList() << QLatin1String(SRCDIR "queries/onePlusOne.xq")
                           << QLatin1String("-param")
                           << QLatin1String("duplicated=param1")
                           << QLatin1String("-param")
@@ -742,7 +742,7 @@ void tst_XmlPatterns::xquerySupport_data() const
     QTest::newRow("Open a non-existing collection.")
         << 2
         << QByteArray()
-        << (QStringList() << QLatin1String("queries/nonexistingCollection.xq"))
+        << (QStringList() << QLatin1String(SRCDIR "queries/nonexistingCollection.xq"))
         << QString()
         << QString();
 
@@ -804,7 +804,7 @@ void tst_XmlPatterns::stdoutFailure() const
     //process.setStandardOutputFile(outName);
 
     process.setWorkingDirectory(QDir::current().absoluteFilePath(QString()));
-    process.start(m_command, QStringList("queries/onePlusOne.xq"));
+    process.start(m_command, QStringList(SRCDIR "queries/onePlusOne.xq"));
 
     QCOMPARE(process.exitStatus(), QProcess::NormalExit);
     QVERIFY(process.waitForFinished());
@@ -865,8 +865,8 @@ void tst_XmlPatterns::xsltSupport_data() const
     QTest::newRow("Pass in a stylesheet file which contains an XQuery query")
         << 2
         << QByteArray()
-        << (QStringList() << QLatin1String("stylesheets/queryAsStylesheet.xsl")
-                          << QLatin1String("queries/simpleDocument.xml"))
+        << (QStringList() << QLatin1String(SRCDIR "stylesheets/queryAsStylesheet.xsl")
+                          << QLatin1String(SRCDIR "queries/simpleDocument.xml"))
         << QString()
         << QString();
 
@@ -883,7 +883,7 @@ void tst_XmlPatterns::xsltSupport_data() const
         << QByteArray()
         << (QStringList() << QLatin1String("-initial-template")
                           << QLatin1String("name")
-                          << QLatin1String("queries/onePlusOne.xq"))
+                          << QLatin1String(SRCDIR "queries/onePlusOne.xq"))
         << QString()
         << QString();
 
@@ -918,8 +918,8 @@ void tst_XmlPatterns::xsltSupport_data() const
         << (QStringList() << QLatin1String("-no-format")
                           << QLatin1String("-initial-template")
                           << QLatin1String("main")
-                          << QLatin1String("stylesheets/namedAndRootTemplate.xsl")
-                          << QLatin1String("stylesheets/documentElement.xml"))
+                          << QLatin1String(SRCDIR "stylesheets/namedAndRootTemplate.xsl")
+                          << QLatin1String(SRCDIR "stylesheets/documentElement.xml"))
         << QString()
         << QString();
 
@@ -929,8 +929,8 @@ void tst_XmlPatterns::xsltSupport_data() const
         << (QStringList() << QLatin1String("-no-format")
                           << QLatin1String("-initial-template")
                           << QLatin1String("no-template-by-this-name")
-                          << QLatin1String("stylesheets/namedAndRootTemplate.xsl")
-                          << QLatin1String("stylesheets/documentElement.xml"))
+                          << QLatin1String(SRCDIR "stylesheets/namedAndRootTemplate.xsl")
+                          << QLatin1String(SRCDIR "stylesheets/documentElement.xml"))
         << QString()
         << QString();
 
@@ -940,7 +940,7 @@ void tst_XmlPatterns::xsltSupport_data() const
         << (QStringList() << QLatin1String("-no-format")
                           << QLatin1String("-initial-template")
                           << QLatin1String("main")
-                          << QLatin1String("stylesheets/namedAndRootTemplate.xsl"))
+                          << QLatin1String(SRCDIR "stylesheets/namedAndRootTemplate.xsl"))
         << QString()
         << QString();
 
@@ -950,7 +950,7 @@ void tst_XmlPatterns::xsltSupport_data() const
         << (QStringList() << QLatin1String("-no-format")
                           << QLatin1String("-initial-template")
                           << QLatin1String("{http://example.com/NS}main")
-                          << QLatin1String("stylesheets/namedAndRootTemplate.xsl"))
+                          << QLatin1String(SRCDIR "stylesheets/namedAndRootTemplate.xsl"))
         << QString()
         << QString();
 
@@ -959,7 +959,7 @@ void tst_XmlPatterns::xsltSupport_data() const
         << QByteArray("defParam overridedDefaultedParam implicitlyRequiredValue\n")
         << (QStringList() << QLatin1String("-initial-template")
                           << QLatin1String("main")
-                          << QLatin1String("stylesheets/useParameters.xsl")
+                          << QLatin1String(SRCDIR "stylesheets/useParameters.xsl")
                           << QLatin1String("-param")
                           << QLatin1String("overridedDefaultedParam=overridedDefaultedParam")
                           << QLatin1String("-param")
@@ -970,24 +970,24 @@ void tst_XmlPatterns::xsltSupport_data() const
     QTest::newRow("Use a simplified stylesheet module")
         << 0
         << QByteArray("<output>some text</output>\n")
-        << (QStringList() << QLatin1String("stylesheets/simplifiedStylesheetModule.xsl")
-                          << QLatin1String("stylesheets/simplifiedStylesheetModule.xml"))
+        << (QStringList() << QLatin1String(SRCDIR "stylesheets/simplifiedStylesheetModule.xsl")
+                          << QLatin1String(SRCDIR "stylesheets/simplifiedStylesheetModule.xml"))
         << QString()
         << QString();
 
     QTest::newRow("Not well-formed stylesheet, causes crash in coloring code.")
         << 2
         << QByteArray()
-        << (QStringList() << QLatin1String("stylesheets/notWellformed.xsl")
-                          << QLatin1String("queries/simpleDocument.xml"))
+        << (QStringList() << QLatin1String(SRCDIR "stylesheets/notWellformed.xsl")
+                          << QLatin1String(SRCDIR "queries/simpleDocument.xml"))
         << QString()
         << QString();
 
     QTest::newRow("Not well-formed instance document, causes crash in coloring code.")
         << 2
         << QByteArray()
-        << (QStringList() << QLatin1String("stylesheets/bool070.xsl")
-                          << QLatin1String("stylesheets/bool070.xml"))
+        << (QStringList() << QLatin1String(SRCDIR "stylesheets/bool070.xsl")
+                          << QLatin1String(SRCDIR "stylesheets/bool070.xml"))
         << QString()
         << QString();
 
diff --git a/tests/auto/xmlpatterns/xmlpatterns.pro b/tests/auto/xmlpatterns/xmlpatterns.pro
index 569e23f..01e3b2b 100644
--- a/tests/auto/xmlpatterns/xmlpatterns.pro
+++ b/tests/auto/xmlpatterns/xmlpatterns.pro
@@ -2,4 +2,10 @@ load(qttest_p4)
 SOURCES += tst_xmlpatterns.cpp \
            ../qxmlquery/TestFundament.cpp
 
+!wince* {
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+} else {
+DEFINES += SRCDIR=\\\"./\\\"
+}
+
 include (../xmlpatterns.pri)
-- 
cgit v0.12


From 93c883b5388a5ed6e9dbd01ca6b314163576ede5 Mon Sep 17 00:00:00 2001
From: Leonardo Sobral Cunha <leo.cunha@nokia.com>
Date: Wed, 5 Aug 2009 17:49:23 +0200
Subject: Refactors QGraphicsItemGroup::addToGroup to use
 QGraphicsItem::itemTransform

This does not change the behavior of the method.

Reviewed-by: andreas
---
 src/gui/graphicsview/qgraphicsitem.cpp | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index beaf42b..8d9a1f8 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -9837,20 +9837,25 @@ void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)
     }
 
     // COMBINE
-    // ### Use itemTransform() instead.
-    QTransform oldSceneMatrix = item->sceneTransform();
+    bool ok;
+    QTransform itemTransform = item->itemTransform(this, &ok);
+
+    if (!ok) {
+        qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates");
+        return;
+    }
+
+    QTransform newItemTransform(itemTransform);
     item->setPos(mapFromItem(item, 0, 0));
     item->setParentItem(this);
-    QTransform newItemTransform(oldSceneMatrix);
-    newItemTransform *= sceneTransform().inverted();
+
+    // removing position from translation component of the new transform
     if (!item->pos().isNull())
         newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
+
     item->setTransform(newItemTransform);
     item->d_func()->setIsMemberOfGroup(true);
     prepareGeometryChange();
-    QTransform itemTransform(item->transform());
-    if (!item->pos().isNull())
-        itemTransform *= QTransform::fromTranslate(item->x(), item->y());
     d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
     update();
 }
-- 
cgit v0.12


From 8c621378e79a417fc7512691bf07023c1496aac0 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@trolltech.com>
Date: Fri, 7 Aug 2009 09:58:29 +0200
Subject: Fixes: QComboBox keyboard search not working properly when current
 index is -1

If the current index is invalid,  start would be (0,0) but would be
skiped

Task-number: 220195
Reviewed-by: thierry
---
 src/gui/itemviews/qabstractitemview.cpp |  2 +-
 tests/auto/qcombobox/tst_qcombobox.cpp  | 36 +++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index d929590..421d511 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -2650,7 +2650,7 @@ void QAbstractItemView::keyboardSearch(const QString &search)
     if (search.isEmpty()
         || (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) {
         d->keyboardInput = search;
-        skipRow = true;
+        skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)
     } else {
         d->keyboardInput += search;
     }
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index bd11fa4..4797698 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -139,6 +139,7 @@ private slots:
     void task190205_setModelAdjustToContents();
     void task248169_popupWithMinimalSize();
     void task247863_keyBoardSelection();
+    void task220195_keyBoardSelection2();
     void setModelColumn();
     void noScrollbar_data();
     void noScrollbar();
@@ -2138,6 +2139,40 @@ void tst_QComboBox::task247863_keyBoardSelection()
   QCOMPARE(spy.count(), 1);
 }
 
+void tst_QComboBox::task220195_keyBoardSelection2()
+{
+    QComboBox combo;
+    combo.setEditable(false);
+    combo.addItem( QLatin1String("foo1"));
+    combo.addItem( QLatin1String("foo2"));
+    combo.addItem( QLatin1String("foo3"));
+    combo.show();
+    QApplication::setActiveWindow(&combo);
+    QTest::qWait(100);
+
+    combo.setCurrentIndex(-1);
+    QVERIFY(combo.currentText().isNull());
+
+    QTest::keyClick(&combo, 'f');
+    QCOMPARE(combo.currentText(), QLatin1String("foo1"));
+    QTest::qWait(QApplication::keyboardInputInterval() + 30);
+    QTest::keyClick(&combo, 'f');
+    QCOMPARE(combo.currentText(), QLatin1String("foo2"));
+    QTest::qWait(QApplication::keyboardInputInterval() + 30);
+    QTest::keyClick(&combo, 'f');
+    QCOMPARE(combo.currentText(), QLatin1String("foo3"));
+    QTest::qWait(QApplication::keyboardInputInterval() + 30);
+    QTest::keyClick(&combo, 'f');
+    QCOMPARE(combo.currentText(), QLatin1String("foo1"));
+    QTest::qWait(QApplication::keyboardInputInterval() + 30);
+
+    combo.setCurrentIndex(1);
+    QCOMPARE(combo.currentText(), QLatin1String("foo2"));
+    QTest::keyClick(&combo, 'f');
+    QCOMPARE(combo.currentText(), QLatin1String("foo3"));
+}
+
+
 void tst_QComboBox::setModelColumn()
 {
     QStandardItemModel model(5,3);
@@ -2238,5 +2273,6 @@ void tst_QComboBox::task253944_itemDelegateIsReset()
     QCOMPARE(comboBox.itemDelegate(), itemDelegate);
 }
 
+
 QTEST_MAIN(tst_QComboBox)
 #include "tst_qcombobox.moc"
-- 
cgit v0.12


From 490f135caa35831646dac7e00f1c9422cb09aca9 Mon Sep 17 00:00:00 2001
From: Geir Vattekar <geir.vattekar@trolltech.com>
Date: Fri, 7 Aug 2009 11:37:33 +0200
Subject: Doc: Integrated the Rogue (state machine) example.

Reviewed-by: Kent Hansen
---
 demos/qtdemo/xml/examples.xml                    |   1 +
 doc/src/examples.qdoc                            |   1 +
 doc/src/examples/rogue.qdoc                      | 222 +++++++++++++++++++++++
 doc/src/images/rogue-example.png                 | Bin 0 -> 10364 bytes
 doc/src/images/rogue-statechart.png              | Bin 0 -> 2490 bytes
 examples/statemachine/rogue/main.cpp             |  55 ++++++
 examples/statemachine/rogue/movementtransition.h | 108 +++++++++++
 examples/statemachine/rogue/rogue.pro            |  11 ++
 examples/statemachine/rogue/window.cpp           | 201 ++++++++++++++++++++
 examples/statemachine/rogue/window.h             |  89 +++++++++
 examples/statemachine/statemachine.pro           |   1 +
 11 files changed, 689 insertions(+)
 create mode 100644 doc/src/examples/rogue.qdoc
 create mode 100644 doc/src/images/rogue-example.png
 create mode 100644 doc/src/images/rogue-statechart.png
 create mode 100644 examples/statemachine/rogue/main.cpp
 create mode 100644 examples/statemachine/rogue/movementtransition.h
 create mode 100644 examples/statemachine/rogue/rogue.pro
 create mode 100644 examples/statemachine/rogue/window.cpp
 create mode 100644 examples/statemachine/rogue/window.h

diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml
index 1b0b533..6c8ddb0 100644
--- a/demos/qtdemo/xml/examples.xml
+++ b/demos/qtdemo/xml/examples.xml
@@ -183,6 +183,7 @@
   </category>
   <category dirname="statemachine" name="State Machine">
     <example filename="eventtransitions" name="Event Transitions" />
+    <example filename="rogue" name="Rogue" />
     <example filename="tankgame" name="Tank Game" />
     <example filename="trafficlight" name="Traffic Light" />
     <example filename="twowaybutton" name="Two-way Button" />
diff --git a/doc/src/examples.qdoc b/doc/src/examples.qdoc
index 74a9bd8..7f9264b 100644
--- a/doc/src/examples.qdoc
+++ b/doc/src/examples.qdoc
@@ -330,6 +330,7 @@
     \o \l{statemachine/eventtransitions}{Event Transitions}\raisedaster
     \o \l{statemachine/factorial}{Factorial States}\raisedaster
     \o \l{statemachine/pingpong}{Ping Pong States}\raisedaster
+    \o \l{statemachine/rogue}{Rogue}\raisedaster
     \o \l{statemachine/trafficlight}{Traffic Light}\raisedaster
     \o \l{statemachine/twowaybutton}{Two-way Button}\raisedaster
     \endlist
diff --git a/doc/src/examples/rogue.qdoc b/doc/src/examples/rogue.qdoc
new file mode 100644
index 0000000..8fa2c69
--- /dev/null
+++ b/doc/src/examples/rogue.qdoc
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+    \example statemachine/rogue
+    \title Rogue Example
+
+    The Rogue example shows how to use the Qt state machine for event
+    handling.
+
+    \image rogue-example.png
+
+    This example implements a simple text based game. Do you see the
+    \c{@} in the screenshot? That's you, the rogue. The \c{#}
+    characters are walls, and the dots represent floor. In a real
+    game, other ASCII characters would represent all kinds of objects
+    and creatures. For instance, ancient dragons (\c{D}'s) or food
+    rations (\c{%}'s). But let's not get carried away. In this game,
+    the rogue is simply running around in an empty room.
+
+    The rogue is moved with the keypad (2, 4, 8, 6). That aside, we
+    have implemented a \c quit command that triggers if the player
+    types \c {q}. The player is then asked if he/she really wants to
+    quit.
+
+    Most games have commands that need more than one key press and
+    that may require a different sequence of keys based on questions
+    asked the user. In this game, only the \c quit command falls under
+    this category, but for the sake of argument, let's imagine a
+    fully-fledged game with a rich set of commands. If we were to
+    implement these by catching key events in
+    \l{QWidget::}{keyPressEvent()}, we would have to keep a lot of
+    class member variables to track the sequence of keys already typed
+    (or find some other way of deducing the current state of a
+    command). This can easily lead to spaghetti, which is--as we all
+    well know, I'm sure--unpleasant. With a state machine, on the
+    other hand, separate states can wait for a single key press, and
+    that makes our lives a lot simpler.
+
+    The example consists of two classes:
+
+    \list
+        \o \c Window draws the text display of the game and sets
+            up the state machine. The window also has a status bar
+            above the area in which the rouge moves.
+        \o \c MovementTransition is a transition that carries out
+            a single move of the rogue.
+    \endlist
+
+    Before we embark on a code walkthrough, it is necessary to take a
+    closer look at the design of the machine. Here is a state chart
+    that shows what we want to achieve:
+
+    \image rogue-statechart.png
+
+    The input state waits for a key press to start a new command.
+    When receiving a key it recognizes, it transitions to one of the
+    two commands of the game; though, as we will see, movement is
+    handled by the transition itself. The quit state waits for the
+    player to answer yes or no (by typing \c y or \c n) when asked
+    whether he/she really wants to quit the game.
+
+    The chart demonstrates how we use one state to wait for a single
+    key press. The press received may trigger one of the transitions
+    connected to the state.
+
+    \section1 Window Class Definition
+
+    The \c Window class is a widget that draws the text display of the
+    game. It also sets up the state machine, i.e., creates and
+    connects the states in the machine. It is the key events from this
+    widget that are used by the machine.
+
+    \snippet examples/statemachine/rogue/window.h 0
+
+    \c Direction specifies the direction in which the rogue is to
+    move. We use this in \c movePlayer(), which moves the rogue and
+    repaints the window. The game has a status line above the area in
+    which the rogue moves. The \c status property contains the text of
+    this line. We use a property because the QState class allows
+    setting any Qt \l{Qt's Property System}{property} when entered.
+    More on this later.
+
+    \snippet examples/statemachine/rogue/window.h 1
+
+    The \c map is an array with the characters that are currently
+    displayed. We set up the array in \c setupMap(), and update it
+    when the rogue is moved. \c pX and \c pY is the current position
+    of the rogue. \c WIDTH and \c HEIGHT are macros specifying the
+    dimensions of the map.
+
+    The \c paintEvent() function is left out of this walkthrough. We
+    also do not discuss other code that does not concern the state
+    machine (the \c setupMap(), \c status(), \c setStatus(), \c
+    movePlayer(), and \c sizeHint() functions). If you wish to take a
+    look at the code, click on the link for the \c window.cpp file at
+    the top of this page.
+
+    \section1 Window Class Implementation
+
+    Here is the constructor of \c Window:
+
+    \snippet examples/statemachine/rogue/window.cpp 0
+    \dots
+    \snippet examples/statemachine/rogue/window.cpp 1
+
+    The player starts off at position (5, 5). We then set up the map
+    and statemachine. Let's proceed with the \c buildMachine()
+    function:
+
+    \snippet examples/statemachine/rogue/window.cpp 2
+
+    We enter \c inputState when the machine is started and from the \c
+    quitState if the user wants to continue playing. We then set the
+    status to a helpful reminder of how to play the game.
+
+    First, the \c Movement transition is added to the input state.
+    This will enable the rogue to be moved with the keypad.  Notice
+    that we don't set a target state for the movement transition. This
+    will cause the transition to be triggered (and the
+    \l{QAbstractTransition::}{onTransition()} function to be invoked),
+    but the machine will not leave the \c inputState. If we had set \c
+    inputState as the target state, we would first have left and then
+    entered the \c inputState again.
+
+    \snippet examples/statemachine/rogue/window.cpp 3
+
+    When we enter \c quitState, we update the status bar of the
+    window.
+    
+    \c QKeyEventTransition is a utility class that removes the hassle
+    of implementing transitions for \l{QKeyEvent}s. We simply need to
+    specify the key on which the transition should trigger and the
+    target state of the transition.
+
+    \snippet examples/statemachine/rogue/window.cpp 4
+
+    The transition from \c inputState allows triggering the quit state
+    when the player types \c {q}.
+    
+    \snippet examples/statemachine/rogue/window.cpp 5
+
+    The machine is set up, so it's time to start it.
+
+    \section1 The MovementTransition Class
+
+    \c MovementTransition is triggered when the player request the
+    rogue to be moved (by typing 2, 4, 6, or 8) when the machine is in
+    the \c inputState.
+
+    \snippet examples/statemachine/rogue/movementtransition.h 0
+
+    In the constructor, we tell QEventTransition to only send
+    \l{QEvent::}{KeyPress} events to the
+    \l{QAbstractTransition::}{eventTest()} function:
+
+    \snippet examples/statemachine/rogue/movementtransition.h 1
+
+    The KeyPress events come wrapped in \l{QWrappedEvent}s. \c event
+    must be confirmed to be a wrapped event because Qt uses other
+    events internally. After that, it is simply a matter of checking
+    which key has been pressed.
+
+    Let's move on to the \c onTransition() function:
+
+    \snippet examples/statemachine/rogue/movementtransition.h 2
+
+    When \c onTransition() is invoked, we know that we have a
+    \l{QEvent::}{KeyPress} event with 2, 4, 6, or 8, i.e., the event
+    is already unwrapped.
+
+    \section1 The Roguelike Tradition
+
+    You might have been wondering why the game features a rogue. Well,
+    these kinds of text based dungeon exploration games date back to a
+    game called, yes, "Rogue". Although outflanked by the technology
+    of modern 3D computer games, roguelikes have a solid community of
+    hard-core, devoted followers.
+
+    Playing these games can be surprisingly addictive (despite the
+    lack of graphics). Angband, the perhaps most well-known rougelike,
+    is found here: \l{http://rephial.org/}.
+*/
+
diff --git a/doc/src/images/rogue-example.png b/doc/src/images/rogue-example.png
new file mode 100644
index 0000000..7aeb0e5
Binary files /dev/null and b/doc/src/images/rogue-example.png differ
diff --git a/doc/src/images/rogue-statechart.png b/doc/src/images/rogue-statechart.png
new file mode 100644
index 0000000..c5f4048
Binary files /dev/null and b/doc/src/images/rogue-statechart.png differ
diff --git a/examples/statemachine/rogue/main.cpp b/examples/statemachine/rogue/main.cpp
new file mode 100644
index 0000000..0c2fb2d
--- /dev/null
+++ b/examples/statemachine/rogue/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argv, char **args)
+{
+    QApplication app(argv, args);
+
+    Window window;
+    window.show();
+
+    return app.exec();
+}
+
diff --git a/examples/statemachine/rogue/movementtransition.h b/examples/statemachine/rogue/movementtransition.h
new file mode 100644
index 0000000..929077d
--- /dev/null
+++ b/examples/statemachine/rogue/movementtransition.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOVEMENTTRANSITION_H
+#define MOVEMENTTRANSITION_H
+
+#include <QtGui>
+
+#include "window.h"
+
+//![0]
+class MovementTransition : public QEventTransition
+{
+    Q_OBJECT
+
+public:
+    MovementTransition(Window *window) :
+        QEventTransition(window, QEvent::KeyPress) {
+        this->window = window;
+    }
+//![0]
+
+//![1]
+protected:
+    bool eventTest(QEvent *event) {
+        if (event->type() == QEvent::Wrapped &&
+            static_cast<QWrappedEvent *>(event)->event()->type() == QEvent::KeyPress) {
+            QEvent *wrappedEvent = static_cast<QWrappedEvent *>(event)->event();
+
+            QKeyEvent *keyEvent = static_cast<QKeyEvent *>(wrappedEvent);
+            int key = keyEvent->key();
+
+            return key == Qt::Key_2 || key == Qt::Key_8 || key == Qt::Key_6 ||
+                   key == Qt::Key_4;
+        }
+        return false;
+    }
+//![1]
+
+//![2]
+    void onTransition(QEvent *event) {
+        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(
+            static_cast<QWrappedEvent *>(event)->event());
+
+        int key = keyEvent->key();
+        switch (key) {
+            case Qt::Key_4:
+                window->movePlayer(Window::Left);
+                break;
+            case Qt::Key_8:
+                window->movePlayer(Window::Up);
+                break;
+            case Qt::Key_6:
+                window->movePlayer(Window::Right);
+                break;
+            case Qt::Key_2:
+                window->movePlayer(Window::Down);
+                break;
+            default:
+                ;
+        }
+    }
+//![2]
+
+private:
+    Window *window;
+};
+
+#endif
+
diff --git a/examples/statemachine/rogue/rogue.pro b/examples/statemachine/rogue/rogue.pro
new file mode 100644
index 0000000..1571854
--- /dev/null
+++ b/examples/statemachine/rogue/rogue.pro
@@ -0,0 +1,11 @@
+HEADERS       = window.h \
+                movementtransition.h
+SOURCES       = main.cpp \
+                window.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/rogue
+sources.files = $$SOURCES $$HEADERS *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/rogue
+INSTALLS += target sources
+
diff --git a/examples/statemachine/rogue/window.cpp b/examples/statemachine/rogue/window.cpp
new file mode 100644
index 0000000..39565a3
--- /dev/null
+++ b/examples/statemachine/rogue/window.cpp
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+#include "movementtransition.h"
+
+//![0]
+Window::Window()
+{
+    pX = 5;
+    pY = 5;
+//![0]
+
+    QFontDatabase database;
+    QFont font;
+    if (database.families().contains("Monospace"))
+        font = QFont("Monospace", 12);
+    else {
+        foreach (QString family, database.families()) {
+            if (database.isFixedPitch(family)) {
+                font = QFont(family, 12);
+                break;
+            }
+        }
+    }
+    setFont(font);
+
+//![1]
+    setupMap();
+    buildMachine();
+}
+//![1]
+
+void Window::setStatus(const QString &status)
+{
+    myStatus = status;
+    repaint();
+}
+
+QString Window::status() const
+{
+    return myStatus;
+}
+
+void Window::paintEvent(QPaintEvent * /* event */)
+{
+    QFontMetrics metrics(font());
+    QPainter painter(this);
+    int fontHeight = metrics.height();
+    int fontWidth = metrics.width('X');
+    int yPos = fontHeight;
+    int xPos;
+
+    painter.fillRect(rect(), Qt::black);
+    painter.setPen(Qt::white);
+
+    painter.drawText(QPoint(0, yPos), status());
+    
+    for (int y = 0; y < HEIGHT; ++y) {
+        yPos += fontHeight;
+        xPos = 0;
+
+        for (int x = 0; x < WIDTH; ++x) {
+            if (y == pY && x == pX) {
+                xPos += fontWidth;
+                continue;
+            }
+
+            painter.drawText(QPoint(xPos, yPos), map[x][y]);
+            xPos += fontWidth;
+        }
+    }
+    painter.drawText(QPoint(pX * fontWidth, (pY + 2) * fontHeight), QChar('@'));
+}
+
+QSize Window::sizeHint() const
+{
+    QFontMetrics metrics(font());
+
+    return QSize(metrics.width('X') * WIDTH, metrics.height() * (HEIGHT + 1));
+}
+
+//![2]
+void Window::buildMachine()
+{
+    machine = new QStateMachine;
+
+    QState *inputState = new QState(machine);
+    inputState->assignProperty(this, "status", "Move the rogue with 2, 4, 6, and 8");
+
+    MovementTransition *transition = new MovementTransition(this);
+    inputState->addTransition(transition);
+//![2]
+
+//![3]
+    QState *quitState = new QState(machine);
+    quitState->assignProperty(this, "status", "Really quit(y/n)?"); 
+
+    QKeyEventTransition *yesTransition = new
+        QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Y);
+    yesTransition->setTargetState(new QFinalState(machine));
+    quitState->addTransition(yesTransition);
+
+    QKeyEventTransition *noTransition =
+        new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_N);
+    noTransition->setTargetState(inputState);
+    quitState->addTransition(noTransition);
+//![3]
+
+//![4]
+    QKeyEventTransition *quitTransition =
+        new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Q);
+    quitTransition->setTargetState(quitState);
+    inputState->addTransition(quitTransition);
+//![4]
+
+//![5]
+    machine->setInitialState(inputState);
+
+    connect(machine, SIGNAL(finished()), qApp, SLOT(quit()));
+
+    machine->start();
+}
+//![5]
+
+void Window::movePlayer(Direction direction)
+{
+    switch (direction) {
+        case Left:
+            if (map[pX - 1][pY] != '#')
+                --pX;            
+            break;
+        case Right:
+            if (map[pX + 1][pY] != '#')
+                ++pX;
+            break;
+        case Up:
+            if (map[pX][pY - 1] != '#')
+                --pY;
+            break;
+        case Down:
+            if (map[pX][pY + 1] != '#')
+                ++pY;
+            break;        
+    }
+    repaint();
+}
+
+void Window::setupMap()
+{
+    qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
+
+    for (int x = 0; x < WIDTH; ++x)
+        for (int y = 0; y < HEIGHT; ++y) {
+        if (x == 0 || x == WIDTH - 1 || y == 0 || y == HEIGHT - 1 || qrand() % 40 == 0)
+            map[x][y] = '#';
+        else
+            map[x][y] = '.';
+    }
+}
+
diff --git a/examples/statemachine/rogue/window.h b/examples/statemachine/rogue/window.h
new file mode 100644
index 0000000..bcd86bd
--- /dev/null
+++ b/examples/statemachine/rogue/window.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QWidget>
+
+class QState;
+class QStateMachine;
+class QTransition;
+
+#define WIDTH 35
+#define HEIGHT 20
+
+//![0]
+class Window : public QWidget
+{
+    Q_OBJECT
+    Q_PROPERTY(QString status READ status WRITE setStatus)
+
+public:
+    enum Direction { Up, Down, Left, Right };
+
+    Window();
+
+    void movePlayer(Direction direction);
+    void setStatus(const QString &status);
+    QString status() const;
+
+    QSize sizeHint() const;
+
+protected:
+    void paintEvent(QPaintEvent *event);
+//![0]
+
+//![1]
+private:
+    void buildMachine();
+    void setupMap();
+
+    QChar map[WIDTH][HEIGHT];
+    int pX, pY;
+
+    QStateMachine *machine;
+    QString myStatus;
+};
+//![1]
+
+#endif
+
diff --git a/examples/statemachine/statemachine.pro b/examples/statemachine/statemachine.pro
index ea3e7a8..298c0ae 100644
--- a/examples/statemachine/statemachine.pro
+++ b/examples/statemachine/statemachine.pro
@@ -3,6 +3,7 @@ SUBDIRS       = \
                 eventtransitions \
                 factorial \
                 pingpong \
+                rogue \
                 trafficlight \
                 twowaybutton
 
-- 
cgit v0.12


From 3c2b9047be4f4f835e59c13d5038b907c629451f Mon Sep 17 00:00:00 2001
From: Kent Hansen <khansen@trolltech.com>
Date: Fri, 7 Aug 2009 14:01:11 +0200
Subject: adjust some ifdefs so they are easy to remove with a script

In preparation of making the old QtScript back-end a separate
package/solution.
---
 src/script/qscriptable.cpp      | 4 ++--
 src/script/qscriptable_p.h      | 4 ++--
 src/script/qscriptclassdata.cpp | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/script/qscriptable.cpp b/src/script/qscriptable.cpp
index 5da9e95..94468de 100644
--- a/src/script/qscriptable.cpp
+++ b/src/script/qscriptable.cpp
@@ -39,10 +39,10 @@
 **
 ****************************************************************************/
 
-#ifndef QT_NO_QOBJECT
-
 #include "qscriptable.h"
 
+#ifndef QT_NO_QOBJECT
+
 #ifndef QT_NO_SCRIPT
 
 #include "qscriptable_p.h"
diff --git a/src/script/qscriptable_p.h b/src/script/qscriptable_p.h
index 8ea65ed..1d297d9 100644
--- a/src/script/qscriptable_p.h
+++ b/src/script/qscriptable_p.h
@@ -55,7 +55,7 @@
 // We mean it.
 //
 
-#if !defined(QT_NO_QOBJECT) && !defined(QT_NO_SCRIPT)
+#ifndef QT_NO_SCRIPT
 
 QT_BEGIN_NAMESPACE
 
@@ -79,6 +79,6 @@ public:
 
 QT_END_NAMESPACE
 
-#endif // QT_NO_QOBJECT && QT_NO_SCRIPT
+#endif // QT_NO_SCRIPT
 
 #endif
diff --git a/src/script/qscriptclassdata.cpp b/src/script/qscriptclassdata.cpp
index 08e7220..576a519 100644
--- a/src/script/qscriptclassdata.cpp
+++ b/src/script/qscriptclassdata.cpp
@@ -114,4 +114,4 @@ QScriptClassDataIterator::~QScriptClassDataIterator()
 
 QT_END_NAMESPACE
 
-#endif
+#endif // QT_NO_SCRIPT
-- 
cgit v0.12


From f37b4ab8c8116abc2f71128e308b938c90ec5b8a Mon Sep 17 00:00:00 2001
From: Thierry Bastian <thierry.bastian@nokia.com>
Date: Fri, 7 Aug 2009 14:01:26 +0200
Subject: QDockWidget: Make visibilityChanged more accurate

Task-number: 258459
---
 src/gui/widgets/qdockarealayout.cpp        |  2 +-
 src/gui/widgets/qdockwidget.cpp            |  2 +-
 tests/auto/qdockwidget/tst_qdockwidget.cpp | 19 ++++++++++++++++++-
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index ee29b55..cad6903 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -1545,7 +1545,7 @@ void QDockAreaLayoutInfo::apply(bool animate)
 
         QRect geo = w->geometry();
         widgetAnimator.animate(w, r, animate);
-        if (!w->isHidden()) {
+        if (!w->isHidden() && w->window()->isVisible()) {
             QDockWidget *dw = qobject_cast<QDockWidget*>(w);
             if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) {
                 dw->lower();
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index 5810c81..e60f099 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/gui/widgets/qdockwidget.cpp
@@ -1390,7 +1390,7 @@ bool QDockWidget::event(QEvent *event)
         break;
     case QEvent::Show:
         d->toggleViewAction->setChecked(true);
-        emit visibilityChanged(true);
+        emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
         break;
 #endif
     case QEvent::ApplicationLayoutDirectionChange:
diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp
index 9b0e706..16bb12d 100644
--- a/tests/auto/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp
@@ -91,6 +91,7 @@ private slots:
     void task169808_setFloating();
     void task237438_setFloatingCrash();
     void task248604_infiniteResize();
+    void task258459_visibilityChanged();
 };
 
 // Testing get/set functions
@@ -730,7 +731,7 @@ void tst_QDockWidget::task169808_setFloating()
             return QSize(20,20);
         }
 
-        void paintEvent(QPaintEvent *e)
+        void paintEvent(QPaintEvent *)
         {
             QPainter p(this);
             p.fillRect(rect(), Qt::red);
@@ -798,5 +799,21 @@ void tst_QDockWidget::task248604_infiniteResize()
 }
 
 
+void tst_QDockWidget::task258459_visibilityChanged()
+{
+    QMainWindow win;
+    QDockWidget dock1, dock2;
+    win.addDockWidget(Qt::RightDockWidgetArea, &dock1);
+    win.tabifyDockWidget(&dock1, &dock2);
+    QSignalSpy spy1(&dock1, SIGNAL(visibilityChanged(bool)));
+    QSignalSpy spy2(&dock2, SIGNAL(visibilityChanged(bool)));
+    win.show();
+    QTest::qWait(200);
+    QCOMPARE(spy1.count(), 1);
+    QCOMPARE(spy1.first().first().toBool(), false); //dock1 is invisible
+    QCOMPARE(spy2.count(), 1);
+    QCOMPARE(spy2.first().first().toBool(), true); //dock1 is visible
+}
+
 QTEST_MAIN(tst_QDockWidget)
 #include "tst_qdockwidget.moc"
-- 
cgit v0.12


From f419f3f229444f31ca879276713799f6af73195e Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@trolltech.com>
Date: Tue, 12 May 2009 20:26:58 +0200
Subject: Refactor the code that reads the KDE config in one file

Move the code out of qapplication_x11.cpp, and qcommonstyle.cpp
to qkde.cpp into the QKde namespace.

This removes few of the code duplication, and is much cleaner.

This will also let us install hook easily later.

Reviewed-by: Jens Bache-Wiig
---
 src/gui/kernel/kernel.pri           |   6 +-
 src/gui/kernel/qapplication_p.h     |   1 -
 src/gui/kernel/qapplication_x11.cpp | 202 ++++++------------------------------
 src/gui/kernel/qkde.cpp             | 159 ++++++++++++++++++++++++++++
 src/gui/kernel/qkde_p.h             |  76 ++++++++++++++
 src/gui/kernel/qt_x11_p.h           |   3 +-
 src/gui/styles/qcommonstyle.cpp     |  39 ++++---
 7 files changed, 297 insertions(+), 189 deletions(-)
 create mode 100644 src/gui/kernel/qkde.cpp
 create mode 100644 src/gui/kernel/qkde_p.h

diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index e6eff6e..d9deefe 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -100,7 +100,8 @@ unix:x11 {
 	INCLUDEPATH += ../3rdparty/xorg
 	HEADERS += \
 		kernel/qx11embed_x11.h \
-		kernel/qx11info_x11.h
+		kernel/qx11info_x11.h \
+        kernel/qkde_p.h
 
 	SOURCES += \
 		kernel/qapplication_x11.cpp \
@@ -114,7 +115,8 @@ unix:x11 {
 		kernel/qwidgetcreate_x11.cpp \
 		kernel/qx11embed_x11.cpp \
 		kernel/qx11info_x11.cpp \
-		kernel/qkeymapper_x11.cpp
+		kernel/qkeymapper_x11.cpp \
+		kernel/qkde.cpp
 
         contains(QT_CONFIG, glib) {
             SOURCES += \
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 700d1ab..c4ce2ea 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -284,7 +284,6 @@ public:
 
 #if defined(Q_WS_X11)
 #ifndef QT_NO_SETTINGS
-    static QString kdeHome();
     static QString x11_desktop_style();
     static bool x11_apply_settings();
 #endif
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 4016563..32e7e3c 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -83,6 +83,7 @@
 #include "qtimer.h"
 #include "qlibrary.h"
 #include <private/qgraphicssystemfactory_p.h>
+#include "qkde_p.h"
 
 #if !defined (QT_NO_TABLET)
 extern "C" {
@@ -813,33 +814,6 @@ Q_GUI_EXPORT void qt_x11_apply_settings_in_all_apps()
                     PropModeReplace, (unsigned char *)stamp.data(), stamp.size());
 }
 
-static int kdeSessionVersion()
-{
-    static int kdeVersion = 0;
-    if (!kdeVersion)
-        kdeVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
-    return kdeVersion;
-}
-
-/*! \internal
-    Gets the current KDE 3 or 4 home path
-*/
-QString QApplicationPrivate::kdeHome()
-{
-    static QString kdeHomePath;
-    if (kdeHomePath.isEmpty()) {
-        kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
-        if (kdeHomePath.isEmpty()) {
-            QDir homeDir(QDir::homePath());
-            QString kdeConfDir(QLatin1String("/.kde"));
-            if (4 == kdeSessionVersion() && homeDir.exists(QLatin1String(".kde4")))
-                kdeConfDir = QLatin1String("/.kde4");
-            kdeHomePath = QDir::homePath() + kdeConfDir;
-        }
-    }
-    return kdeHomePath;
-}
-
 /*! \internal
     apply the settings to the application
 */
@@ -905,8 +879,8 @@ bool QApplicationPrivate::x11_apply_settings()
         QFont font(QApplication::font());
         QString fontDescription;
         // Override Qt font if KDE4 settings can be used
-        if (4 == kdeSessionVersion()) {
-            QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
+        if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4) {
+            QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
             fontDescription = kdeSettings.value(QLatin1String("font")).toString();
             if (fontDescription.isEmpty()) {
                 // KDE stores fonts without quotes
@@ -936,7 +910,6 @@ bool QApplicationPrivate::x11_apply_settings()
     // read new QStyle
     QString stylename = settings.value(QLatin1String("style")).toString();
 
-
     if (stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull() && X11->use_xrender) {
         stylename = x11_desktop_style();
     }
@@ -1094,22 +1067,6 @@ static void qt_set_input_encoding()
         XFree((char *)data);
 }
 
-// Reads a KDE color setting
-static QColor kdeColor(const QString &key, const QSettings &kdeSettings)
-{
-    QVariant variant = kdeSettings.value(key);
-    if (variant.isValid()) {
-        QStringList values = variant.toStringList();
-        if (values.size() == 3) {
-            int r = values[0].toInt();
-            int g = values[1].toInt();
-            int b = values[2].toInt();
-            return QColor(r, g, b);
-        }
-    }
-    return QColor();
-}
-
 // set font, foreground and background from x11 resources. The
 // arguments may override the resource settings.
 static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
@@ -1276,9 +1233,10 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
 
         QApplicationPrivate::setSystemFont(fnt);
     }
+    // QGtkStyle sets it's own system palette
+    bool gtkStyle = QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle");
     bool kdeColors = (QApplication::desktopSettingsAware() && X11->desktopEnvironment == DE_KDE);
-
-    if (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty())) {// set app colors
+    if (!gtkStyle && (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty()))) {// set app colors
         bool allowX11ColorNames = QColor::allowX11ColorNames();
         QColor::setAllowX11ColorNames(true);
 
@@ -1314,45 +1272,6 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
             bright_mode = true;
         }
 
-        if (kdeColors) {
-            const QSettings theKdeSettings(
-                QApplicationPrivate::kdeHome()
-                + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
-
-            // Setup KDE palette
-            QColor color;
-            color = kdeColor(QLatin1String("buttonBackground"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:Button/BackgroundNormal"), theKdeSettings);
-            if (color.isValid())
-                btn = color;
-
-            color = kdeColor(QLatin1String("background"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:Window/BackgroundNormal"), theKdeSettings);
-            if (color.isValid())
-                bg = color;
-
-            color = kdeColor(QLatin1String("foreground"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:View/ForegroundNormal"), theKdeSettings);
-            if (color.isValid()) {
-                fg = color;
-            }
-
-            color = kdeColor(QLatin1String("windowForeground"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:Window/ForegroundNormal"), theKdeSettings);
-            if (color.isValid())
-                wfg = color;
-
-            color = kdeColor(QLatin1String("windowBackground"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:View/BackgroundNormal"), theKdeSettings);
-            if (color.isValid())
-                base = color;
-        }
-
         QPalette pal(fg, btn, btn.lighter(125), btn.darker(130), btn.darker(120), wfg.isValid() ? wfg : fg, Qt::white, base, bg);
         QColor disabled((fg.red()   + btn.red())  / 2,
                         (fg.green() + btn.green())/ 2,
@@ -1365,50 +1284,6 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
             highlight = QColor(selectBackground);
             highlightText = QColor(selectForeground);
         }
-        // Use KDE3 or KDE4 color settings if present
-        if (kdeColors) {
-            const QSettings theKdeSettings(
-                QApplicationPrivate::kdeHome()
-                + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
-
-            QColor color = kdeColor(QLatin1String("selectBackground"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:Selection/BackgroundNormal"), theKdeSettings);
-            if (color.isValid())
-                highlight = color;
-
-            color = kdeColor(QLatin1String("selectForeground"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:Selection/ForegroundNormal"), theKdeSettings);
-            if (color.isValid())
-                highlightText = color;
-
-            color = kdeColor(QLatin1String("alternateBackground"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:View/BackgroundAlternate"), theKdeSettings);
-            if (color.isValid())
-                pal.setColor(QPalette::AlternateBase, color);
-            else
-                pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(110));
-
-            color = kdeColor(QLatin1String("buttonForeground"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:Button/ForegroundNormal"), theKdeSettings);
-            if (color.isValid())
-                pal.setColor(QPalette::ButtonText, color);
-
-            color = kdeColor(QLatin1String("linkColor"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:View/ForegroundLink"), theKdeSettings);
-            if (color.isValid())
-                pal.setColor(QPalette::Link, color);
-
-            color = kdeColor(QLatin1String("visitedLinkColor"), theKdeSettings);
-            if (!color.isValid())
-                color = kdeColor(QLatin1String("Colors:View/ForegroundVisited"), theKdeSettings);
-            if (color.isValid())
-                pal.setColor(QPalette::LinkVisited, color);
-        }
 
         if (highlight.isValid() && highlightText.isValid()) {
             pal.setColor(QPalette::Highlight, highlight);
@@ -1431,10 +1306,9 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
             pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::darkBlue);
         }
 
-        // QGtkStyle sets it's own system palette
-        if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) {
-            QApplicationPrivate::setSystemPalette(pal);
-        }
+        if (kdeColors)
+            pal = QKde::kdePalette().resolve(pal);
+        QApplicationPrivate::setSystemPalette(pal);
         QColor::setAllowX11ColorNames(allowX11ColorNames);
     }
 
@@ -2315,6 +2189,7 @@ void qt_init(QApplicationPrivate *priv, int,
         X11->compositingManagerRunning = XGetSelectionOwner(X11->display,
                                                             ATOM(_NET_WM_CM_S0));
         X11->desktopEnvironment = DE_UNKNOWN;
+        X11->desktopVersion = 0;
 
         // See if the current window manager is using the freedesktop.org spec to give its name
         Window windowManagerWindow = XNone;
@@ -2390,6 +2265,9 @@ void qt_init(QApplicationPrivate *priv, int,
                 XFree((char *)data);
         }
 
+        if (X11->desktopEnvironment == DE_KDE)
+            X11->desktopVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
+
         qt_set_input_encoding();
 
         qt_set_x11_resources(appFont, appFGCol, appBGCol, appBTNCol);
@@ -2657,44 +2535,30 @@ void qt_init(QApplicationPrivate *priv, int,
 QString QApplicationPrivate::x11_desktop_style()
 {
     QString stylename;
-    QStringList availableStyles = QStyleFactory::keys();
-    // Override Qt style if KDE4 settings can be used
-    if (4 == kdeSessionVersion()) {
-        QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
-        QString kde4Style = kdeSettings.value(QLatin1String("widgetStyle"),
-                                              QLatin1String("Oxygen")).toString();
-        foreach (const QString &style, availableStyles) {
-            if (style.toLower() == kde4Style.toLower())
-                stylename = kde4Style;
-        }
-    // Set QGtkStyle for GNOME
-    } else if (X11->desktopEnvironment == DE_GNOME) {
+    switch(X11->desktopEnvironment) {
+    case DE_KDE:
+        stylename = QKde::kdeStyle();
+        break;
+    case DE_GNOME: {
+        QStringList availableStyles = QStyleFactory::keys();
+        // Set QGtkStyle for GNOME if available
         QString gtkStyleKey = QString::fromLatin1("GTK+");
-        if (availableStyles.contains(gtkStyleKey))
+        if (availableStyles.contains(gtkStyleKey)) {
             stylename = gtkStyleKey;
-    }
-
-    if (stylename.isEmpty()) {
-        switch(X11->desktopEnvironment) {
-        case DE_KDE:
-            if (X11->use_xrender)
-                stylename = QLatin1String("plastique");
-            else
-                stylename = QLatin1String("windows");
-            break;
-        case DE_GNOME:
-            if (X11->use_xrender)
-                stylename = QLatin1String("cleanlooks");
-            else
-                stylename = QLatin1String("windows");
-            break;
-        case DE_CDE:
-            stylename = QLatin1String("cde");
-            break;
-        default:
-            // Don't do anything
             break;
         }
+        if (X11->use_xrender)
+            stylename = QLatin1String("cleanlooks");
+        else
+            stylename = QLatin1String("windows");
+        break;
+        }
+    case DE_CDE:
+        stylename = QLatin1String("cde");
+        break;
+    default:
+        // Don't do anything
+        break;
     }
     return stylename;
 }
diff --git a/src/gui/kernel/qkde.cpp b/src/gui/kernel/qkde.cpp
new file mode 100644
index 0000000..96ff21e
--- /dev/null
+++ b/src/gui/kernel/qkde.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qkde_p.h"
+#include <QtCore/QLibrary>
+#include <QtCore/QDir>
+#include <QtCore/qdebug.h>
+#include <QtCore/QSettings>
+#include "QtGui/qstylefactory.h"
+#include "qt_x11_p.h"
+
+#if defined(Q_WS_X11)
+
+QT_BEGIN_NAMESPACE
+
+/*! \internal
+Gets the current KDE home path
+like "/home/troll/.kde"
+*/
+QString QKde::kdeHome()
+{
+    static QString kdeHomePath;
+    if (kdeHomePath.isEmpty()) {
+        kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
+        if (kdeHomePath.isEmpty()) {
+            QDir homeDir(QDir::homePath());
+            QString kdeConfDir(QLatin1String("/.kde"));
+            if (4 == X11->desktopVersion && homeDir.exists(QLatin1String(".kde4")))
+            kdeConfDir = QLatin1String("/.kde4");
+            kdeHomePath = QDir::homePath() + kdeConfDir;
+        }
+    }
+    return kdeHomePath;
+}
+
+/*!\internal
+  Reads the color from the config, and store it in the palette with the given color role if found
+  */
+static bool kdeColor(QPalette *pal, QPalette::ColorRole role, const QSettings &kdeSettings, const QString &kde4Key, const QString &kde3Key = QString())
+{
+    QVariant variant = kdeSettings.value(kde4Key);
+    if (!variant.isValid())
+        QVariant variant = kdeSettings.value(kde3Key);
+    if (variant.isValid()) {
+        QStringList values = variant.toStringList();
+        if (values.size() == 3) {
+            int r = values[0].toInt();
+            int g = values[1].toInt();
+            int b = values[2].toInt();
+            pal->setBrush(role, QColor(r, g, b));
+            return true;
+        }
+    }
+    return false;
+}
+
+
+/*!\internal
+    Returns the KDE palette
+*/
+QPalette QKde::kdePalette()
+{
+    const QSettings theKdeSettings(QKde::kdeHome() +
+        QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
+    QPalette pal;
+
+    // Setup KDE palette
+    kdeColor(&pal, QPalette::Button, theKdeSettings, QLatin1String("Colors:Button/BackgroundNormal"), QLatin1String("buttonBackground"));
+    kdeColor(&pal, QPalette::Window, theKdeSettings, QLatin1String("Colors:Window/BackgroundNormal"), QLatin1String("background"));
+    kdeColor(&pal, QPalette::Text, theKdeSettings, QLatin1String("Colors:View/ForegroundNormal"), QLatin1String("foreground"));
+    kdeColor(&pal, QPalette::WindowText, theKdeSettings, QLatin1String("Colors:Window/ForegroundNormal"), QLatin1String("windowForeground"));
+    kdeColor(&pal, QPalette::Base, theKdeSettings, QLatin1String("Colors:View/BackgroundNormal"), QLatin1String("windowBackground"));
+    kdeColor(&pal, QPalette::Highlight, theKdeSettings, QLatin1String("Colors:Selection/BackgroundNormal"), QLatin1String("selectBackground"));
+    kdeColor(&pal, QPalette::HighlightedText, theKdeSettings, QLatin1String("Colors:Selection/ForegroundNormal"), QLatin1String("selectForeground"));
+    kdeColor(&pal, QPalette::AlternateBase, theKdeSettings, QLatin1String("Colors:View/BackgroundAlternate"), QLatin1String("alternateBackground"));
+    kdeColor(&pal, QPalette::ButtonText, theKdeSettings, QLatin1String("Colors:Button/ForegroundNormal"), QLatin1String("buttonForeground"));
+    kdeColor(&pal, QPalette::Link, theKdeSettings, QLatin1String("Colors:View/ForegroundLink"), QLatin1String("linkColor"));
+    kdeColor(&pal, QPalette::LinkVisited, theKdeSettings, QLatin1String("Colors:View/ForegroundVisited"), QLatin1String("visitedLinkColor"));
+   //## TODO tooltip color
+
+    return pal;
+}
+
+/*!\internal
+    Returns the name of the QStyle to use.
+    (read from the kde config if needed)
+*/
+QString QKde::kdeStyle()
+{
+    if (X11->desktopVersion >= 4) {
+        QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
+        QString style = kdeSettings.value(QLatin1String("widgetStyle"), QLatin1String("Oxygen")).toString();
+
+        QStringList availableStyles = QStyleFactory::keys();
+        if(availableStyles.contains(style, Qt::CaseInsensitive))
+            return style;
+    }
+
+    if (X11->use_xrender)
+        return QLatin1String("plastique");
+    else
+        return QLatin1String("windows");
+
+    return QString();
+}
+
+/*!\internal
+  placeholder to load icon from kde.
+  to be implemented
+ */
+QIcon QKde::kdeIcon(const QString &name)
+{
+    //###todo
+    return QIcon();
+}
+
+QT_END_NAMESPACE
+
+#endif //Q_WS_X11
+
diff --git a/src/gui/kernel/qkde_p.h b/src/gui/kernel/qkde_p.h
new file mode 100644
index 0000000..ac760bd
--- /dev/null
+++ b/src/gui/kernel/qkde_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QKDE_H
+#define QKDE_H
+
+#include <QtCore/qglobal.h>
+#include <QtGui/QPalette>
+#include <QtGui/QIcon>
+
+//
+//  W A R N I N G
+//  -------------
+//
+// This file is not part of the Qt API.  It exists purely as an
+// implementation detail.  This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+#if defined(Q_WS_X11)
+
+
+QT_BEGIN_NAMESPACE
+
+// This namespace contains helper function to help KDE integration
+namespace QKde {
+    QString kdeHome();
+    QString kdeStyle();
+    QPalette kdePalette();
+    QIcon kdeIcon(const QString &name);
+}
+
+
+QT_END_NAMESPACE
+
+#endif // Q_WS_X11
+#endif // QKDE_H
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 1ac51e0..44652d3 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -515,7 +515,8 @@ struct QX11Data
 
     char *startupId;
 
-    DesktopEnvironment desktopEnvironment;
+    DesktopEnvironment desktopEnvironment : 8;
+    uint desktopVersion : 8;  /* Used only for KDE */
 
     /* Warning: if you modify this list, modify the names of atoms in qapplication_x11.cpp as well! */
     enum X11Atom {
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index ba28e75..c7feb25 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -63,7 +63,7 @@
 #include <qtoolbar.h>
 #include <qtoolbutton.h>
 #include <qrubberband.h>
-#include <private/qapplication_p.h>
+#include <../kernel/qkde_p.h>
 #include <private/qcommonstylepixmaps_p.h>
 #include <private/qmath_p.h>
 #include <private/qstylehelper_p.h>
@@ -842,12 +842,6 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut
 
 
 #ifdef Q_WS_X11 // These functions are used to parse the X11 freedesktop icon spec
-static int kdeVersion()
-{
-    static int kdeVersion = qgetenv("KDE_SESSION_VERSION").toInt();
-    return kdeVersion;
-}
-
 void QCommonStylePrivate::lookupIconTheme() const
 {
     if (!themeName.isEmpty())
@@ -856,7 +850,7 @@ void QCommonStylePrivate::lookupIconTheme() const
     QString dataDirs = QString::fromLocal8Bit(getenv("XDG_DATA_DIRS"));
     if (dataDirs.isEmpty())
         dataDirs = QLatin1String("/usr/local/share/:/usr/share/");
-    dataDirs += QLatin1Char(':') + QApplicationPrivate::kdeHome() + QLatin1String("/share");
+    dataDirs += QLatin1Char(':') + QKde::kdeHome() + QLatin1String("/share");
     dataDirs.prepend(QDir::homePath() + QLatin1String("/:"));
     QStringList kdeDirs = QString::fromLocal8Bit(getenv("KDEDIRS")).split(QLatin1Char(':'), QString::SkipEmptyParts);
     foreach (const QString &dirName, kdeDirs)
@@ -865,9 +859,10 @@ void QCommonStylePrivate::lookupIconTheme() const
 
     QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde"));
     QDir dir(fileInfo.canonicalFilePath());
-    QString kdeDefault = kdeVersion() >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg");
+    QString kdeDefault = (X11->desktopEnvironment != DE_KDE || X11->desktopVersion >= 4)
+                         ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg");
     QString defaultTheme = fileInfo.exists() ? dir.dirName() : kdeDefault;
-    QSettings settings(QApplicationPrivate::kdeHome() +
+    QSettings settings(QKde::kdeHome() +
                        QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
     settings.beginGroup(QLatin1String("Icons"));
     themeName = settings.value(QLatin1String("Theme"), defaultTheme).toString();
@@ -979,8 +974,15 @@ QPixmap QCommonStylePrivate::findIconHelper(int size,
     return pixmap;
 }
 
+/*! \internal
+    find a pixmap with the given size and name from the freedesktop theme.
+*/
 QPixmap QCommonStylePrivate::findIcon(int size, const QString &name) const
 {
+    QIcon icon = QKde::kdeIcon(name);
+    if (!icon.isNull())
+        return icon.pixmap(size);
+
     QPixmap pixmap;
     QString pixmapName = QLatin1String("$qt") + name + QString::number(size);
 
@@ -995,12 +997,17 @@ QPixmap QCommonStylePrivate::findIcon(int size, const QString &name) const
     return pixmap;
 }
 
+/*! \internal
+  create an Icon from the freedesktop theme.
+ */
 QIcon QCommonStylePrivate::createIcon(const QString &name) const
 {
-    QIcon icon;
-    icon.addPixmap(findIcon(16, name));
-    icon.addPixmap(findIcon(24, name));
-    icon.addPixmap(findIcon(32, name));
+    QIcon icon = QKde::kdeIcon(name);
+    if (icon.isNull()) {
+        icon.addPixmap(findIcon(16, name));
+        icon.addPixmap(findIcon(24, name));
+        icon.addPixmap(findIcon(32, name));
+    }
     return icon;
 }
 /*!internal
@@ -1012,8 +1019,8 @@ from the KDE configuration file
 int QCommonStylePrivate::lookupToolButtonStyle() const
 {
     int result = Qt::ToolButtonIconOnly;
-    if (kdeVersion() >= 4) {
-        QSettings settings(QApplicationPrivate::kdeHome() +
+    if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4) {
+        QSettings settings(QKde::kdeHome() +
                            QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
         settings.beginGroup(QLatin1String("Toolbar style"));
         QString toolbarStyle = settings.value(QLatin1String("ToolButtonStyle"), QLatin1String("TextBesideIcon")).toString();
-- 
cgit v0.12


From 6993e77d2cd147098c6ddab187469a9177ea134e Mon Sep 17 00:00:00 2001
From: Kavindra Devi Palaraja <kavindra.palaraja@nokia.com>
Date: Fri, 7 Aug 2009 15:06:23 +0200
Subject: Doc - Improving the documentation for QListWidget and QListWidgetItem

Reviewed-By: TrustMe
---
 src/gui/itemviews/qlistwidget.cpp | 446 +++++++++++++++++++-------------------
 1 file changed, 228 insertions(+), 218 deletions(-)

diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp
index 2565657..6351496 100644
--- a/src/gui/itemviews/qlistwidget.cpp
+++ b/src/gui/itemviews/qlistwidget.cpp
@@ -447,21 +447,20 @@ Qt::DropActions QListModel::supportedDropActions() const
 
     \ingroup model-view
 
-    QListWidgetItem is used to represent items in a list provided by the
-    QListWidget class. Each item can hold several pieces of information,
-    and will display these appropriately.
+    A QListWidgetItem represents a single item in a QListWidget. Each item can
+    hold several pieces of information, and will display them appropriately.
 
-    The item view convenience classes use a classic item-based interface
-    rather than a pure model/view approach. For a more flexible list view
-    widget, consider using the QListView class with a standard model.
+    The item view convenience classes use a classic item-based interface rather
+    than a pure model/view approach. For a more flexible list view widget,
+    consider using the QListView class with a standard model.
 
-    List items can be automatically inserted into a list when they are
-    constructed by specifying the list widget:
+    List items can be inserted automatically into a list, when they are
+    constructed, by specifying the list widget:
 
     \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 2
 
-    They can also be created without a parent widget, and later inserted into
-    a list (see \l{QListWidget::insertItem()}).
+    Alternatively, list items can also be created without a parent widget, and
+    later inserted into a list using QListWidget::insertItem().
 
     List items are typically used to display text() and an icon(). These are
     set with the setText() and setIcon() functions. The appearance of the text
@@ -471,22 +470,24 @@ Qt::DropActions QListModel::supportedDropActions() const
     with setToolTip(), setStatusTip(), and setWhatsThis().
 
     By default, items are enabled, selectable, checkable, and can be the source
-    of a drag and drop operation.
+    of drag and drop operations.
+
     Each item's flags can be changed by calling setFlags() with the appropriate
-    value (see \l{Qt::ItemFlags}). Checkable items can be checked, unchecked and
+    value (see Qt::ItemFlags). Checkable items can be checked, unchecked and
     partially checked with the setCheckState() function. The corresponding
-    checkState() function indicates what check state the item currently has.
+    checkState() function indicates the item's current check state.
+
+    The isHidden() function can be used to determine whether the item is
+    hidden. To hide an item, use setHidden().
 
-    The isHidden() function can be used to determine whether the
-    item is hidden.  Items can be hidden with setHidden().
 
     \section1 Subclassing
 
     When subclassing QListWidgetItem to provide custom items, it is possible to
-    define new types for them so that they can be distinguished from standard
-    items. The constructors for subclasses that require this feature need to
-    call the base class constructor with a new type value equal to or greater
-    than \l UserType.
+    define new types for them enabling them to be distinguished from standard
+    items. For subclasses that require this feature, ensure that you call the
+    base class constructor with a new type value equal to or greater than
+    \l UserType, within \e your constructor.
 
     \sa QListWidget, {Model/View Programming}, QTreeWidgetItem, QTableWidgetItem
 */
@@ -515,59 +516,58 @@ Qt::DropActions QListModel::supportedDropActions() const
 /*!
     \fn QListWidget *QListWidgetItem::listWidget() const
 
-    Returns the list widget that contains the item.
+    Returns the list widget containing the item.
 */
 
 /*!
-  \fn void QListWidgetItem::setSelected(bool select)
-  \since 4.2
+    \fn void QListWidgetItem::setSelected(bool select)
+    \since 4.2
 
-  Sets the selected state of the item to \a select.
+    Sets the selected state of the item to \a select.
 
-  \sa isSelected()
+    \sa isSelected()
 */
 
 /*!
-  \fn bool QListWidgetItem::isSelected() const
-  \since 4.2
+    \fn bool QListWidgetItem::isSelected() const
+    \since 4.2
 
-  Returns true if the item is selected, otherwise returns false.
+    Returns true if the item is selected; otherwise returns false.
 
-  \sa setSelected()
+    \sa setSelected()
 */
 
 /*!
-  \fn void QListWidgetItem::setHidden(bool hide)
-  \since 4.2
+    \fn void QListWidgetItem::setHidden(bool hide)
+    \since 4.2
 
-  Hides the item if \a hide is true, otherwise shows the item.
+    Hides the item if \a hide is true; otherwise shows the item.
 
-  \sa isHidden()
+    \sa isHidden()
 */
 
 /*!
-  \fn bool QListWidgetItem::isHidden() const
-  \since 4.2
+    \fn bool QListWidgetItem::isHidden() const
+    \since 4.2
 
-  Returns true if the item is hidden, otherwise returns false.
+    Returns true if the item is hidden; otherwise returns false.
 
-  \sa setHidden()
+    \sa setHidden()
 */
 
 /*!
     \fn QListWidgetItem::QListWidgetItem(QListWidget *parent, int type)
 
     Constructs an empty list widget item of the specified \a type with the
-    given \a parent.
-    If the parent is not specified, the item will need to be inserted into a
-    list widget with QListWidget::insertItem().
+    given \a parent. If \a parent is not specified, the item will need to be
+    inserted into a list widget with QListWidget::insertItem().
     
-    \note that this constructor inserts this same object into the model of 
-    the parent that is passed to the constructor. If the model is sorted then 
-    the behavior of the insert is undetermined since the model will call 
-    the '<' operator method on this object which has still not yet been 
-    constructed. In this case it would be better not to specify the parent
-    and use the QListWidget::insertItem method to insert the item instead.
+    This constructor inserts the item into the model of the parent that is
+    passed to the constructor. If the model is sorted then the behavior of the
+    insert is undetermined since the model will call the \c '<' operator method
+    on the item which, at this point, is not yet constructed. To avoid the
+    undetermined behavior, we recommend not to specify the parent and use
+    QListWidget::insertItem() instead.
 
     \sa type()
 */
@@ -586,16 +586,15 @@ QListWidgetItem::QListWidgetItem(QListWidget *view, int type)
     \fn QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *parent, int type)
 
     Constructs an empty list widget item of the specified \a type with the
-    given \a text and \a parent.
-    If the parent is not specified, the item will need to be inserted into a
-    list widget with QListWidget::insertItem().
+    given \a text and \a parent. If the parent is not specified, the item will
+    need to be inserted into a list widget with QListWidget::insertItem().
     
-    \note that this constructor inserts this same object into the model of 
-    the parent that is passed to the constructor. If the model is sorted then 
-    the behavior of the insert is undetermined since the model will call 
-    the '<' operator method on this object which has still not yet been 
-    constructed. In this case it would be better not to specify the parent
-    and use the QListWidget::insertItem method to insert the item instead.
+    This constructor inserts the item into the model of the parent that is
+    passed to the constructor. If the model is sorted then the behavior of the
+    insert is undetermined since the model will call the \c '<' operator method
+    on the item which, at this point, is not yet constructed. To avoid the
+    undetermined behavior, we recommend not to specify the parent and use
+    QListWidget::insertItem() instead.
 
     \sa type()
 */
@@ -616,16 +615,16 @@ QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *view, int typ
     \fn QListWidgetItem::QListWidgetItem(const QIcon &icon, const QString &text, QListWidget *parent, int type)
 
     Constructs an empty list widget item of the specified \a type with the
-    given \a icon, \a text and \a parent.
-    If the parent is not specified, the item will need to be inserted into a
-    list widget with QListWidget::insertItem().
+    given \a icon, \a text and \a parent. If the parent is not specified, the
+    item will need to be inserted into a list widget with
+    QListWidget::insertItem().
     
-    \note that this constructor inserts this same object into the model of 
-    the parent that is passed to the constructor. If the model is sorted then 
-    the behavior of the insert is undetermined since the model will call 
-    the '<' operator method on this object which has still not yet been 
-    constructed. In this case it would be better not to specify the parent
-    and use the QListWidget::insertItem method to insert the item instead.
+    This constructor inserts the item into the model of the parent that is
+    passed to the constructor. If the model is sorted then the behavior of the
+    insert is undetermined since the model will call the \c '<' operator method
+    on the item which, at this point, is not yet constructed. To avoid the
+    undetermined behavior, we recommend not to specify the parent and use
+    QListWidget::insertItem() instead.
     
     \sa type()
 */
@@ -645,7 +644,7 @@ QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text,
 }
 
 /*!
-  Destroys the list item.
+    Destroys the list item.
 */
 QListWidgetItem::~QListWidgetItem()
 {
@@ -655,7 +654,7 @@ QListWidgetItem::~QListWidgetItem()
 }
 
 /*!
-  Creates an exact copy of the item.
+    Creates an exact copy of the item.
 */
 QListWidgetItem *QListWidgetItem::clone() const
 {
@@ -663,11 +662,10 @@ QListWidgetItem *QListWidgetItem::clone() const
 }
 
 /*!
-  This function sets the data for a given \a role to the given \a value (see
-  \l{Qt::ItemDataRole}). Reimplement this function if you need
-  extra roles or special behavior for certain roles.
+    Sets the data for a given \a role to the given \a value. Reimplement this
+    function if you need extra roles or special behavior for certain roles.
 
-  \sa Qt::ItemDataRole, data()
+    \sa Qt::ItemDataRole, data()
 */
 void QListWidgetItem::setData(int role, const QVariant &value)
 {
@@ -689,9 +687,10 @@ void QListWidgetItem::setData(int role, const QVariant &value)
 }
 
 /*!
-   This function returns the item's data for a given \a role (see
-   Qt::ItemDataRole). Reimplement this function if you need
-   extra roles or special behavior for certain roles.
+    Returns the item's data for a given \a role. Reimplement this function if
+    you need extra roles or special behavior for certain roles.
+
+    \sa Qt::ItemDataRole, setData()
 */
 QVariant QListWidgetItem::data(int role) const
 {
@@ -703,8 +702,8 @@ QVariant QListWidgetItem::data(int role) const
 }
 
 /*!
-  Returns true if this item's text is less then \a other item's text;
-  otherwise returns false.
+    Returns true if this item's text is less then \a other item's text;
+    otherwise returns false.
 */
 bool QListWidgetItem::operator<(const QListWidgetItem &other) const
 {
@@ -740,8 +739,8 @@ void QListWidgetItem::write(QDataStream &out) const
 /*!
     \since 4.1
 
-    Constructs a copy of \a other. Note that type() and listWidget()
-    are not copied.
+    Constructs a copy of \a other. Note that type() and listWidget() are not
+    copied.
 
     This function is useful when reimplementing clone().
 
@@ -756,8 +755,8 @@ QListWidgetItem::QListWidgetItem(const QListWidgetItem &other)
 }
 
 /*!
-    Assigns \a other's data and flags to this item. Note that type()
-    and listWidget() are not copied.
+    Assigns \a other's data and flags to this item. Note that type() and
+    listWidget() are not copied.
 
     This function is useful when reimplementing clone().
 
@@ -805,9 +804,9 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
 #endif // QT_NO_DATASTREAM
 
 /*!
-  \fn Qt::ItemFlags QListWidgetItem::flags() const
+    \fn Qt::ItemFlags QListWidgetItem::flags() const
 
-  Returns the item flags for this item (see \l{Qt::ItemFlags}).
+    Returns the item flags for this item (see \l{Qt::ItemFlags}).
 */
 
 /*!
@@ -851,15 +850,17 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
 */
 
 /*!
-  \fn QFont QListWidgetItem::font() const
+    \fn QFont QListWidgetItem::font() const
 
-  Returns the font used to display this list item's text.
+    Returns the font used to display this list item's text.
 */
 
 /*!
-  \fn int QListWidgetItem::textAlignment() const
+    \fn int QListWidgetItem::textAlignment() const
+
+    Returns the text alignment for the list item.
 
-  Returns the text alignment for the list item (see \l{Qt::AlignmentFlag}).
+    \sa Qt::AlignmentFlag
 */
 
 /*!
@@ -905,26 +906,26 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
 */
 
 /*!
-  \fn QSize QListWidgetItem::sizeHint() const
-  \since 4.1
+    \fn QSize QListWidgetItem::sizeHint() const
+    \since 4.1
 
-  Returns the size hint set for the list item.
+    Returns the size hint set for the list item.
 */
 
 /*!
-  \fn void QListWidgetItem::setSizeHint(const QSize &size)
-  \since 4.1
+    \fn void QListWidgetItem::setSizeHint(const QSize &size)
+    \since 4.1
 
-  Sets the size hint for the list item to be \a size.
-  If no size hint is set, the item delegate will compute the
-  size hint based on the item data.
+    Sets the size hint for the list item to be \a size. If no size hint is set,
+    the item delegate will compute the size hint based on the item data.
 */
 
 /*!
-  \fn void QListWidgetItem::setFlags(Qt::ItemFlags flags)
+    \fn void QListWidgetItem::setFlags(Qt::ItemFlags flags)
+
+    Sets the item flags for the list item to \a flags.
 
-  Sets the item flags for the list item to \a flags (see
-  \l{Qt::ItemFlags}).
+    \sa Qt::ItemFlags
 */
 void QListWidgetItem::setFlags(Qt::ItemFlags aflags) {
     itemFlags = aflags;
@@ -953,10 +954,10 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) {
     \fn void QListWidgetItem::setStatusTip(const QString &statusTip)
 
     Sets the status tip for the list item to the text specified by
-    \a statusTip. QListWidget mouse tracking needs to be enabled for this
+    \a statusTip. QListWidget mouseTracking needs to be enabled for this
     feature to work.
 
-    \sa statusTip() setToolTip() setWhatsThis()
+    \sa statusTip(), setToolTip(), setWhatsThis(), QWidget::setMouseTracking()
 */
 
 /*!
@@ -964,29 +965,30 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) {
 
     Sets the tooltip for the list item to the text specified by \a toolTip.
 
-    \sa toolTip() setStatusTip() setWhatsThis()
+    \sa toolTip(), setStatusTip(), setWhatsThis()
 */
 
 /*!
     \fn void QListWidgetItem::setWhatsThis(const QString &whatsThis)
 
-    Sets the "What's This?" help for the list item to the text specified
-    by \a whatsThis.
+    Sets the "What's This?" help for the list item to the text specified by
+    \a whatsThis.
 
-    \sa whatsThis() setStatusTip() setToolTip()
+    \sa whatsThis(), setStatusTip(), setToolTip()
 */
 
 /*!
-  \fn void QListWidgetItem::setFont(const QFont &font)
+    \fn void QListWidgetItem::setFont(const QFont &font)
 
-  Sets the font used when painting the item to the given \a font.
+    Sets the font used when painting the item to the given \a font.
 */
 
 /*!
-  \fn void QListWidgetItem::setTextAlignment(int alignment)
+    \fn void QListWidgetItem::setTextAlignment(int alignment)
+
+    Sets the list item's text alignment to \a alignment.
 
-  Sets the list item's text alignment to \a alignment (see
-  \l{Qt::AlignmentFlag}).
+    \sa Qt::AlignmentFlag
 */
 
 /*!
@@ -1127,10 +1129,10 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
     \ingroup model-view
     \mainclass
 
-    QListWidget is a convenience class that provides a list view similar to
-    the one supplied by QListView, but with a classic item-based interface
-    for adding and removing items. QListWidget uses an internal model to
-    manage each QListWidgetItem in the list.
+    QListWidget is a convenience class that provides a list view similar to the
+    one supplied by QListView, but with a classic item-based interface for
+    adding and removing items. QListWidget uses an internal model to manage
+    each QListWidgetItem in the list.
 
     For a more flexible list view widget, use the QListView class with a
     standard model.
@@ -1145,23 +1147,23 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
     function.
 
     There are two ways to add items to the list: they can be constructed with
-    the list widget as their parent widget, or they can be constructed with
-    no parent widget and added to the list later. If a list widget already
-    exists when the items are constructed, the first method is easier to use:
+    the list widget as their parent widget, or they can be constructed with no
+    parent widget and added to the list later. If a list widget already exists
+    when the items are constructed, the first method is easier to use:
 
     \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 1
 
-    If you need to insert a new item into the list at a particular position,
-    it is more required to construct the item without a parent widget and
-    use the insertItem() function to place it within the list.  The list
-    widget will take ownership of the item.
+    If you need to insert a new item into the list at a particular position, it
+    is more required to construct the item without a parent widget and use the
+    insertItem() function to place it within the list. The list widget will
+    take ownership of the item.
 
     \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 6
     \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 7
 
-    For multiple items, insertItems() can be used instead. The number of
-    items in the list is found with the count() function.
-    To remove items from the list, use takeItem().
+    For multiple items, insertItems() can be used instead. The number of items
+    in the list is found with the count() function. To remove items from the
+    list, use takeItem().
 
     The current item in the list can be found with currentItem(), and changed
     with setCurrentItem(). The user can also change the current item by
@@ -1187,9 +1189,9 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
 
     Inserts the \a item at the end of the list widget.
 
-    \warning A QListWidgetItem can only be added to a
-    QListWidget once. Adding the same QListWidgetItem multiple
-    times to a QListWidget will result in undefined behavior.
+    \warning A QListWidgetItem can only be added to a QListWidget once. Adding
+    the same QListWidgetItem multiple times to a QListWidget will result in
+    undefined behavior.
 
     \sa insertItem()
 */
@@ -1197,8 +1199,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
 /*!
     \fn void QListWidget::addItem(const QString &label)
 
-    Inserts an item with the text \a label at the end of the list
-    widget.
+    Inserts an item with the text \a label at the end of the list widget.
 */
 
 /*!
@@ -1212,8 +1213,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
 /*!
     \fn void QListWidget::itemPressed(QListWidgetItem *item)
 
-    This signal is emitted with the specified \a item when a mouse button is pressed
-    on an item in the widget.
+    This signal is emitted with the specified \a item when a mouse button is
+    pressed on an item in the widget.
 
     \sa itemClicked(), itemDoubleClicked()
 */
@@ -1221,8 +1222,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
 /*!
     \fn void QListWidget::itemClicked(QListWidgetItem *item)
 
-    This signal is emitted with the specified \a item when a mouse button is clicked
-    on an item in the widget.
+    This signal is emitted with the specified \a item when a mouse button is
+    clicked on an item in the widget.
 
     \sa itemPressed(), itemDoubleClicked()
 */
@@ -1230,8 +1231,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
 /*!
     \fn void QListWidget::itemDoubleClicked(QListWidgetItem *item)
 
-    This signal is emitted with the specified \a item when a mouse button is double
-    clicked on an item in the widget.
+    This signal is emitted with the specified \a item when a mouse button is
+    double clicked on an item in the widget.
 
     \sa itemClicked(), itemPressed()
 */
@@ -1239,20 +1240,21 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
 /*!
     \fn void QListWidget::itemActivated(QListWidgetItem *item)
 
-    This signal is emitted when the \a item is activated. The \a item
-    is activated when the user clicks or double clicks on it,
-    depending on the system configuration. It is also activated when
-    the user presses the activation key (on Windows and X11 this is
-    the \gui Return key, on Mac OS X it is \key{Ctrl+0}).
+    This signal is emitted when the \a item is activated. The \a item is
+    activated when the user clicks or double clicks on it, depending on the
+    system configuration. It is also activated when the user presses the
+    activation key (on Windows and X11 this is the \gui Return key, on Mac OS
+    X it is \key{Ctrl+0}).
 */
 
 /*!
     \fn void QListWidget::itemEntered(QListWidgetItem *item)
 
-    This signal is emitted when the mouse cursor enters an item. The
-    \a item is the item entered. This signal is only emitted when
-    mouseTracking is turned on, or when a mouse button is pressed
-    while moving into an item.
+    This signal is emitted when the mouse cursor enters an item. The \a item is
+    the item entered. This signal is only emitted when mouseTracking is turned
+    on, or when a mouse button is pressed while moving into an item.
+
+    \sa QWidget::setMouseTracking()
 */
 
 /*!
@@ -1264,24 +1266,28 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
 /*!
     \fn void QListWidget::currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
 
-    This signal is emitted whenever the current item changes. The \a
-    previous item is the item that previously had the focus, \a
-    current is the new current item.
+    This signal is emitted whenever the current item changes.
+ 
+    \a previous is the item that previously had the focus; \a current is the
+    new current item.
 */
 
 /*!
-  \fn void QListWidget::currentTextChanged(const QString &currentText)
+    \fn void QListWidget::currentTextChanged(const QString &currentText)
 
-  This signal is emitted whenever the current item changes. The \a currentText
-  is the text data in the current item. If there is no current item, the \a currentText
-  is invalid.
+    This signal is emitted whenever the current item changes.
+    
+    \a currentText is the text data in the current item. If there is no current
+    item, the \a currentText is invalid.
 */
 
 /*!
-  \fn void QListWidget::currentRowChanged(int currentRow)
+    \fn void QListWidget::currentRowChanged(int currentRow)
 
-  This signal is emitted whenever the current item changes. The \a currentRow
-  is the row of the current item. If there is no current item, the \a currentRow is -1.
+    This signal is emitted whenever the current item changes.
+    
+    \a currentRow is the row of the current item. If there is no current item,
+    the \a currentRow is -1.
 */
 
 /*!
@@ -1289,15 +1295,15 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
 
     This signal is emitted whenever the selection changes.
 
-    \sa selectedItems() QListWidgetItem::isSelected() currentItemChanged()
+    \sa selectedItems(), QListWidgetItem::isSelected(), currentItemChanged()
 */
 
 /*!
-  \since 4.3
+    \since 4.3
 
-  \fn void QListWidget::removeItemWidget(QListWidgetItem *item)
+    \fn void QListWidget::removeItemWidget(QListWidgetItem *item)
 
-  Removes the widget set on the given \a item.
+    Removes the widget set on the given \a item.
 */
 
 /*!
@@ -1361,8 +1367,8 @@ void QListWidget::insertItem(int row, QListWidgetItem *item)
 }
 
 /*!
-    Inserts an item with the text \a label in the list widget at the
-    position given by \a row.
+    Inserts an item with the text \a label in the list widget at the position
+    given by \a row.
 
     \sa addItem()
 */
@@ -1387,11 +1393,11 @@ void QListWidget::insertItems(int row, const QStringList &labels)
 }
 
 /*!
-    Removes and returns the item from the given \a row in the list widget; otherwise
-    returns 0.
+    Removes and returns the item from the given \a row in the list widget;
+    otherwise returns 0.
 
-    Items removed from a list widget will not be managed by Qt, and will need to be
-    deleted manually.
+    Items removed from a list widget will not be managed by Qt, and will need
+    to be deleted manually.
 
     \sa insertItem(), addItem()
 */
@@ -1405,8 +1411,8 @@ QListWidgetItem *QListWidget::takeItem(int row)
 }
 
 /*!
-  \property QListWidget::count
-  \brief the number of items in the list including any hidden items.
+    \property QListWidget::count
+    \brief the number of items in the list including any hidden items.
 */
 
 int QListWidget::count() const
@@ -1416,7 +1422,7 @@ int QListWidget::count() const
 }
 
 /*!
-  Returns the current item.
+    Returns the current item.
 */
 QListWidgetItem *QListWidget::currentItem() const
 {
@@ -1426,9 +1432,9 @@ QListWidgetItem *QListWidget::currentItem() const
 
 
 /*!
-  Sets the current item to \a item.
+    Sets the current item to \a item.
 
-  Depending on the current selection mode, the item may also be selected.
+    Depending on the current selection mode, the item may also be selected.
 */
 void QListWidget::setCurrentItem(QListWidgetItem *item)
 {
@@ -1436,8 +1442,8 @@ void QListWidget::setCurrentItem(QListWidgetItem *item)
 }
 
 /*!
-  \since 4.4
-  Set the current item to \a item, using the given \a command.
+    \since 4.4
+    Set the current item to \a item, using the given \a command.
 */
 void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::SelectionFlags command)
 {
@@ -1445,10 +1451,10 @@ void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::Sel
 }
 
 /*!
-  \property QListWidget::currentRow
-  \brief the row of the current item.
+    \property QListWidget::currentRow
+    \brief the row of the current item.
 
-  Depending on the current selection mode, the row may also be selected.
+    Depending on the current selection mode, the row may also be selected.
 */
 
 int QListWidget::currentRow() const
@@ -1469,9 +1475,9 @@ void QListWidget::setCurrentRow(int row)
 }
 
 /*!
-  \since 4.4
+    \since 4.4
 
-  Sets the current row to be the given \a row, using the given \a command,
+    Sets the current row to be the given \a row, using the given \a command,
 */
 void QListWidget::setCurrentRow(int row, QItemSelectionModel::SelectionFlags command)
 {
@@ -1498,7 +1504,7 @@ QListWidgetItem *QListWidget::itemAt(const QPoint &p) const
 
 
 /*!
-  Returns the rectangle on the viewport occupied by the item at \a item.
+    Returns the rectangle on the viewport occupied by the item at \a item.
 */
 QRect QListWidget::visualItemRect(const QListWidgetItem *item) const
 {
@@ -1508,7 +1514,7 @@ QRect QListWidget::visualItemRect(const QListWidgetItem *item) const
 }
 
 /*!
-  Sorts all the items in the list widget according to the specified \a order.
+    Sorts all the items in the list widget according to the specified \a order.
 */
 void QListWidget::sortItems(Qt::SortOrder order)
 {
@@ -1522,8 +1528,10 @@ void QListWidget::sortItems(Qt::SortOrder order)
     \property QListWidget::sortingEnabled
     \brief whether sorting is enabled
 
-    If this property is true, sorting is enabled for the list; if the
-    property is false, sorting is not enabled. The default value is false.
+    If this property is true, sorting is enabled for the list; if the property
+    is false, sorting is not enabled.
+
+    The default value is false.
 */
 void QListWidget::setSortingEnabled(bool enable)
 {
@@ -1538,7 +1546,7 @@ bool QListWidget::isSortingEnabled() const
 }
 
 /*!
-  \internal
+    \internal
 */
 Qt::SortOrder QListWidget::sortOrder() const
 {
@@ -1547,7 +1555,7 @@ Qt::SortOrder QListWidget::sortOrder() const
 }
 
 /*!
-  Starts editing the \a item if it is editable.
+    Starts editing the \a item if it is editable.
 */
 
 void QListWidget::editItem(QListWidgetItem *item)
@@ -1557,9 +1565,10 @@ void QListWidget::editItem(QListWidgetItem *item)
 }
 
 /*!
-  Opens an editor for the given \a item. The editor remains open after editing.
+    Opens an editor for the given \a item. The editor remains open after
+    editing.
 
-  \sa closePersistentEditor()
+    \sa closePersistentEditor()
 */
 void QListWidget::openPersistentEditor(QListWidgetItem *item)
 {
@@ -1569,9 +1578,9 @@ void QListWidget::openPersistentEditor(QListWidgetItem *item)
 }
 
 /*!
-  Closes the persistent editor for the given \a item.
+    Closes the persistent editor for the given \a item.
 
-  \sa openPersistentEditor()
+    \sa openPersistentEditor()
 */
 void QListWidget::closePersistentEditor(QListWidgetItem *item)
 {
@@ -1597,9 +1606,10 @@ QWidget *QListWidget::itemWidget(QListWidgetItem *item) const
 
     Sets the \a widget to be displayed in the give \a item.
 
-    This function should only be used to display static content in the place of a list
-    widget item. If you want to display custom dynamic content or implement a custom
-    editor widget, use QListView and subclass QItemDelegate instead.
+    This function should only be used to display static content in the place of
+    a list widget item. If you want to display custom dynamic content or
+    implement a custom editor widget, use QListView and subclass QItemDelegate
+    instead.
 
     \sa {Delegate Classes}
 */
@@ -1611,11 +1621,11 @@ void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget)
 }
 
 /*!
-  Returns true if \a item is selected; otherwise returns false.
+    Returns true if \a item is selected; otherwise returns false.
 
-  \obsolete
+    \obsolete
 
-  This function is deprecated. Use \l{QListWidgetItem::isSelected()} instead.
+    This function is deprecated. Use QListWidgetItem::isSelected() instead.
 */
 bool QListWidget::isItemSelected(const QListWidgetItem *item) const
 {
@@ -1625,12 +1635,12 @@ bool QListWidget::isItemSelected(const QListWidgetItem *item) const
 }
 
 /*!
-  Selects or deselects the given \a item depending on whether \a select is
-  true of false.
+    Selects or deselects the given \a item depending on whether \a select is
+    true of false.
 
-  \obsolete
+    \obsolete
 
-  This function is deprecated. Use \l{QListWidgetItem::setSelected()} instead.
+    This function is deprecated. Use QListWidgetItem::setSelected() instead.
 */
 void QListWidget::setItemSelected(const QListWidgetItem *item, bool select)
 {
@@ -1650,7 +1660,7 @@ void QListWidget::setItemSelected(const QListWidgetItem *item, bool select)
 }
 
 /*!
-  Returns a list of all selected items in the list widget.
+    Returns a list of all selected items in the list widget.
 */
 
 QList<QListWidgetItem*> QListWidget::selectedItems() const
@@ -1664,7 +1674,8 @@ QList<QListWidgetItem*> QListWidget::selectedItems() const
 }
 
 /*!
-  Finds items with the text that matches the string \a text using the given \a flags.
+    Finds items with the text that matches the string \a text using the given
+    \a flags.
 */
 
 QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFlags flags) const
@@ -1679,11 +1690,11 @@ QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFla
 }
 
 /*!
-  Returns true if the \a item is explicitly hidden; otherwise returns false.
+    Returns true if the \a item is explicitly hidden; otherwise returns false.
 
-  \obsolete
+    \obsolete
 
-  This function is deprecated. Use \l{QListWidgetItem::isHidden()} instead.
+    This function is deprecated. Use QListWidgetItem::isHidden() instead.
 */
 bool QListWidget::isItemHidden(const QListWidgetItem *item) const
 {
@@ -1691,11 +1702,11 @@ bool QListWidget::isItemHidden(const QListWidgetItem *item) const
 }
 
 /*!
-  If \a hide is true, the \a item will be hidden; otherwise it will be shown.
+    If \a hide is true, the \a item will be hidden; otherwise it will be shown.
 
-  \obsolete
+    \obsolete
 
-  This function is deprecated. Use \l{QListWidgetItem::setHidden()} instead.
+    This function is deprecated. Use QListWidgetItem::setHidden() instead.
 */
 void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide)
 {
@@ -1703,9 +1714,9 @@ void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide)
 }
 
 /*!
-    Scrolls the view if necessary to ensure that the \a item is
-    visible. The \a hint parameter specifies more precisely where the
-    \a item should be located after the operation.
+    Scrolls the view if necessary to ensure that the \a item is visible.
+
+    \a hint specifies where the \a item should be located after the operation.
 */
 
 void QListWidget::scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint)
@@ -1718,7 +1729,7 @@ void QListWidget::scrollToItem(const QListWidgetItem *item, QAbstractItemView::S
 /*!
     Removes all items and selections in the view.
 
-    \note All items will be permanently deleted.
+    \warning All items will be permanently deleted.
 */
 void QListWidget::clear()
 {
@@ -1743,8 +1754,8 @@ QStringList QListWidget::mimeTypes() const
     \a items. The format used to describe the items is obtained from the
     mimeTypes() function.
 
-    If the list of items is empty, 0 is returned rather than a serialized
-    empty list.
+    If the list of items is empty, 0 is returned instead of a serialized empty
+    list.
 */
 QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*>) const
 {
@@ -1753,10 +1764,9 @@ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*>) const
 
 #ifndef QT_NO_DRAGANDDROP
 /*!
-    Handles the \a data supplied by an external drag and drop operation
-    that ended with the given \a action in the given \a index.
-    Returns true if the data and action can be handled by the model;
-    otherwise returns false.
+    Handles \a data supplied by an external drag and drop operation that ended
+    with the given \a action in the given \a index. Returns true if \a data and
+    \a action can be handled by the model; otherwise returns false.
 
     \sa supportedDropActions()
 */
@@ -1823,9 +1833,9 @@ void QListWidget::dropEvent(QDropEvent *event) {
 }
 
 /*!
-  Returns the drop actions supported by this view.
+    Returns the drop actions supported by this view.
 
-  \sa Qt::DropActions
+    \sa Qt::DropActions
 */
 Qt::DropActions QListWidget::supportedDropActions() const
 {
@@ -1835,9 +1845,9 @@ Qt::DropActions QListWidget::supportedDropActions() const
 #endif // QT_NO_DRAGANDDROP
 
 /*!
-  Returns a list of pointers to the items contained in the \a data object.
-  If the object was not created by a QListWidget in the same process, the list
-  is empty.
+    Returns a list of pointers to the items contained in the \a data object. If
+    the object was not created by a QListWidget in the same process, the list
+    is empty.
 */
 QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const
 {
@@ -1848,7 +1858,7 @@ QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const
 }
 
 /*!
-  Returns the QModelIndex assocated with the given \a item.
+    Returns the QModelIndex assocated with the given \a item.
 */
 
 QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const
@@ -1858,7 +1868,7 @@ QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const
 }
 
 /*!
-  Returns a pointer to the QListWidgetItem assocated with the given \a index.
+    Returns a pointer to the QListWidgetItem assocated with the given \a index.
 */
 
 QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const
@@ -1870,7 +1880,7 @@ QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const
 }
 
 /*!
-  \internal
+    \internal
 */
 void QListWidget::setModel(QAbstractItemModel * /*model*/)
 {
-- 
cgit v0.12


From 658c30c214070e8ff05ddaf1cb7b161c1b73f5ce Mon Sep 17 00:00:00 2001
From: Kavindra Devi Palaraja <kavindra.palaraja@nokia.com>
Date: Fri, 7 Aug 2009 15:09:30 +0200
Subject: Doc - Removing trailing whitespaces

Reviewed-By: TrustMe
---
 src/gui/itemviews/qlistwidget.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp
index 6351496..b518ff2 100644
--- a/src/gui/itemviews/qlistwidget.cpp
+++ b/src/gui/itemviews/qlistwidget.cpp
@@ -561,7 +561,7 @@ Qt::DropActions QListModel::supportedDropActions() const
     Constructs an empty list widget item of the specified \a type with the
     given \a parent. If \a parent is not specified, the item will need to be
     inserted into a list widget with QListWidget::insertItem().
-    
+
     This constructor inserts the item into the model of the parent that is
     passed to the constructor. If the model is sorted then the behavior of the
     insert is undetermined since the model will call the \c '<' operator method
@@ -588,7 +588,7 @@ QListWidgetItem::QListWidgetItem(QListWidget *view, int type)
     Constructs an empty list widget item of the specified \a type with the
     given \a text and \a parent. If the parent is not specified, the item will
     need to be inserted into a list widget with QListWidget::insertItem().
-    
+
     This constructor inserts the item into the model of the parent that is
     passed to the constructor. If the model is sorted then the behavior of the
     insert is undetermined since the model will call the \c '<' operator method
@@ -618,14 +618,14 @@ QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *view, int typ
     given \a icon, \a text and \a parent. If the parent is not specified, the
     item will need to be inserted into a list widget with
     QListWidget::insertItem().
-    
+
     This constructor inserts the item into the model of the parent that is
     passed to the constructor. If the model is sorted then the behavior of the
     insert is undetermined since the model will call the \c '<' operator method
     on the item which, at this point, is not yet constructed. To avoid the
     undetermined behavior, we recommend not to specify the parent and use
     QListWidget::insertItem() instead.
-    
+
     \sa type()
 */
 QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text,
@@ -1267,7 +1267,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
     \fn void QListWidget::currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
 
     This signal is emitted whenever the current item changes.
- 
+
     \a previous is the item that previously had the focus; \a current is the
     new current item.
 */
@@ -1276,7 +1276,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
     \fn void QListWidget::currentTextChanged(const QString &currentText)
 
     This signal is emitted whenever the current item changes.
-    
+
     \a currentText is the text data in the current item. If there is no current
     item, the \a currentText is invalid.
 */
@@ -1285,7 +1285,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
     \fn void QListWidget::currentRowChanged(int currentRow)
 
     This signal is emitted whenever the current item changes.
-    
+
     \a currentRow is the row of the current item. If there is no current item,
     the \a currentRow is -1.
 */
-- 
cgit v0.12


From dfa284220498a1e32ab3133f203bcb41cfa136b7 Mon Sep 17 00:00:00 2001
From: Harald Fernengel <harald@trolltech.com>
Date: Fri, 7 Aug 2009 15:08:09 +0200
Subject: Refactor QTestCharBuffer a bit

Use a static buffer for small strings, and making it oom safe.
We can now see messages up to 512 bytes even if we run out of memory
(important for OOM tests). Also, testlogging (< 512 bytes per line)
should again work without a single allocation.

Reviewed-By: Rohan McGovern <rohan.mcgovern@nokia.com>
---
 src/testlib/qabstracttestlogger.cpp   | 47 ++++++++++++++++++++++
 src/testlib/qabstracttestlogger_p.h   | 52 +++++++++++++++++++-----
 src/testlib/qplaintestlogger.cpp      | 10 ++---
 src/testlib/qtest_global.h            |  1 -
 src/testlib/qtestbasicstreamer.cpp    | 40 +++++++++----------
 src/testlib/qtestbasicstreamer.h      | 11 ++---
 src/testlib/qtestcase.cpp             | 37 -----------------
 src/testlib/qtestlightxmlstreamer.cpp | 70 ++++++++++++++++----------------
 src/testlib/qtestlightxmlstreamer.h   |  6 +--
 src/testlib/qtestxmlstreamer.cpp      | 61 ++++++++++++++--------------
 src/testlib/qtestxmlstreamer.h        |  6 +--
 src/testlib/qtestxunitstreamer.cpp    | 43 ++++++++++----------
 src/testlib/qtestxunitstreamer.h      |  8 ++--
 src/testlib/qxmltestlogger.cpp        | 75 ++++++++++++++++++-----------------
 src/testlib/qxmltestlogger_p.h        |  8 ++--
 15 files changed, 257 insertions(+), 218 deletions(-)

diff --git a/src/testlib/qabstracttestlogger.cpp b/src/testlib/qabstracttestlogger.cpp
index 6482ec9..2fa535e 100644
--- a/src/testlib/qabstracttestlogger.cpp
+++ b/src/testlib/qabstracttestlogger.cpp
@@ -43,8 +43,11 @@
 #include "QtTest/private/qtestlog_p.h"
 #include "QtTest/qtestassert.h"
 
+#include "QtCore/qbytearray.h"
+
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 
 #ifndef Q_OS_WIN
 #include <unistd.h>
@@ -106,4 +109,48 @@ void QAbstractTestLogger::stopLogging()
     QTest::stream = 0;
 }
 
+namespace QTest
+{
+
+extern void filter_unprintable(char *str);
+
+/*! \internal
+ */
+int qt_asprintf(QTestCharBuffer *str, const char *format, ...)
+{
+    static const int MAXSIZE = 1024*1024*2;
+
+    Q_ASSERT(str);
+
+    int size = str->size();
+
+    va_list ap;
+    int res = 0;
+
+    for (;;) {
+        va_start(ap, format);
+        res = qvsnprintf(str->data(), size, format, ap);
+        va_end(ap);
+        str->data()[size - 1] = '\0';
+        if (res >= 0 && res < size) {
+            // We succeeded
+            break;
+        }
+        // buffer wasn't big enough, try again.
+        // Note, we're assuming that a result of -1 is always due to running out of space.
+        size *= 2;
+        if (size > MAXSIZE) {
+            break;
+        }
+        if (!str->reset(size))
+            break; // out of memory - take what we have
+    }
+
+    filter_unprintable(str->data());
+
+    return res;
+}
+
+}
+
 QT_END_NAMESPACE
diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h
index 588184e..1834086 100644
--- a/src/testlib/qabstracttestlogger_p.h
+++ b/src/testlib/qabstracttestlogger_p.h
@@ -101,27 +101,26 @@ public:
 
 struct QTestCharBuffer
 {
-    inline QTestCharBuffer()
-            : buf(0)
-    {}
+    enum { InitialSize = 512 };
 
-    inline ~QTestCharBuffer()
+    inline QTestCharBuffer()
+            : _size(InitialSize), buf(staticBuf)
     {
-        delete[] buf;
-        buf = 0;
+        staticBuf[0] = '\0';
     }
 
-    inline operator void*()
+    inline ~QTestCharBuffer()
     {
-        return buf;
+        if (buf != staticBuf)
+            qFree(buf);
     }
 
-    inline operator char*()
+    inline char *data()
     {
         return buf;
     }
 
-    inline operator char**()
+    inline char **buffer()
     {
         return &buf;
     }
@@ -131,10 +130,43 @@ struct QTestCharBuffer
         return buf;
     }
 
+    inline int size() const
+    {
+        return _size;
+    }
+
+    inline bool reset(int newSize)
+    {
+        char *newBuf = 0;
+        if (buf == staticBuf) {
+            // if we point to our internal buffer, we need to malloc first
+            newBuf = reinterpret_cast<char *>(qMalloc(newSize));
+        } else {
+            // if we already malloc'ed, just realloc
+            newBuf = reinterpret_cast<char *>(qRealloc(buf, newSize));
+        }
+
+        // if the allocation went wrong (newBuf == 0), we leave the object as is
+        if (!newBuf)
+            return false;
+
+        _size = newSize;
+        buf = newBuf;
+        return true;
+    }
+
 private:
+    int _size;
     char* buf;
+    char staticBuf[InitialSize];
 };
 
+namespace QTest
+{
+    int qt_asprintf(QTestCharBuffer *buf, const char *format, ...);
+}
+
+
 QT_END_NAMESPACE
 
 #endif
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index e075b36..2515c51 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -180,7 +180,7 @@ namespace QTest {
                          : "";
         const char *filler = (tag[0] && gtag[0]) ? ":" : "";
         if (file) {
-            QTest::qt_asprintf(buf, "%s: %s::%s(%s%s%s)%s%s\n"
+            QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n"
 #ifdef Q_OS_WIN
                           "%s(%d) : failure location\n"
 #else
@@ -189,14 +189,14 @@ namespace QTest {
                           , type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
                           msg[0] ? " " : "", msg, file, line);
         } else {
-            QTest::qt_asprintf(buf, "%s: %s::%s(%s%s%s)%s%s\n",
+            QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n",
                     type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
                     msg[0] ? " " : "", msg);
         }
         // In colored mode, printf above stripped our nonprintable control characters.
         // Put them back.
-        memcpy(buf, type, strlen(type));
-        outputMessage(buf);
+        memcpy(buf.data(), type, strlen(type));
+        outputMessage(buf.data());
     }
 
     template <typename T>
@@ -207,7 +207,7 @@ namespace QTest {
 
         int digits = 0;
         qreal divisor = 1;
-        
+
         while (num / divisor >= 1) {
             divisor *= 10;
             ++digits;
diff --git a/src/testlib/qtest_global.h b/src/testlib/qtest_global.h
index c40f0ad..b5b0fc0 100644
--- a/src/testlib/qtest_global.h
+++ b/src/testlib/qtest_global.h
@@ -82,7 +82,6 @@ namespace QTest
     enum TestFailMode { Abort = 1, Continue = 2 };
 
     int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format, ...);
-    int qt_asprintf(char **str, const char *format, ...);
 }
 
 QT_END_NAMESPACE
diff --git a/src/testlib/qtestbasicstreamer.cpp b/src/testlib/qtestbasicstreamer.cpp
index aac57ba..89de7d8 100644
--- a/src/testlib/qtestbasicstreamer.cpp
+++ b/src/testlib/qtestbasicstreamer.cpp
@@ -68,39 +68,39 @@ QTestBasicStreamer::QTestBasicStreamer()
 QTestBasicStreamer::~QTestBasicStreamer()
 {}
 
-void QTestBasicStreamer::formatStart(const QTestElement *element, char **formatted) const
+void QTestBasicStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted )
         return;
-    QTest::qt_asprintf(formatted, "");
+    formatted->data()[0] = '\0';
 }
 
-void QTestBasicStreamer::formatEnd(const QTestElement *element, char **formatted) const
+void QTestBasicStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted )
         return;
-    QTest::qt_asprintf(formatted, "");
+    formatted->data()[0] = '\0';
 }
 
-void QTestBasicStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const
+void QTestBasicStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted )
         return;
-    QTest::qt_asprintf(formatted, "");
+    formatted->data()[0] = '\0';
 }
 
-void QTestBasicStreamer::formatAfterAttributes(const QTestElement *element, char **formatted) const
+void QTestBasicStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted )
         return;
-    QTest::qt_asprintf(formatted, "");
+    formatted->data()[0] = '\0';
 }
 
-void QTestBasicStreamer::formatAttributes(const QTestElement *, const QTestElementAttribute *attribute, char **formatted) const
+void QTestBasicStreamer::formatAttributes(const QTestElement *, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
 {
     if(!attribute || !formatted )
         return;
-    QTest::qt_asprintf(formatted, "");
+    formatted->data()[0] = '\0';
 }
 
 void QTestBasicStreamer::output(QTestElement *element) const
@@ -125,22 +125,22 @@ void QTestBasicStreamer::outputElements(QTestElement *element, bool) const
     while (element) {
         hasChildren = element->childElements();
 
-        formatStart(element, buf);
-        outputString(buf);
+        formatStart(element, &buf);
+        outputString(buf.data());
 
-        formatBeforeAttributes(element, buf);
-        outputString(buf);
+        formatBeforeAttributes(element, &buf);
+        outputString(buf.data());
 
         outputElementAttributes(element, element->attributes());
 
-        formatAfterAttributes(element, buf);
-        outputString(buf);
+        formatAfterAttributes(element, &buf);
+        outputString(buf.data());
 
         if(hasChildren)
             outputElements(element->childElements(), true);
 
-        formatEnd(element, buf);
-        outputString(buf);
+        formatEnd(element, &buf);
+        outputString(buf.data());
 
         element = element->previousElement();
     }
@@ -150,8 +150,8 @@ void QTestBasicStreamer::outputElementAttributes(const QTestElement* element, QT
 {
     QTestCharBuffer buf;
     while(attribute){
-        formatAttributes(element, attribute, buf);
-        outputString(buf);
+        formatAttributes(element, attribute, &buf);
+        outputString(buf.data());
         attribute = attribute->nextElement();
     }
 }
diff --git a/src/testlib/qtestbasicstreamer.h b/src/testlib/qtestbasicstreamer.h
index 432dd22..cabbf34 100644
--- a/src/testlib/qtestbasicstreamer.h
+++ b/src/testlib/qtestbasicstreamer.h
@@ -53,6 +53,7 @@ QT_MODULE(Test)
 class QTestElement;
 class QTestElementAttribute;
 class QTestLogger;
+class QTestCharBuffer;
 
 class QTestBasicStreamer
 {
@@ -71,11 +72,11 @@ class QTestBasicStreamer
         const QTestLogger *logger() const;
 
     protected:
-        virtual void formatStart(const QTestElement *element, char **formatted) const;
-        virtual void formatEnd(const QTestElement *element, char **formatted) const;
-        virtual void formatBeforeAttributes(const QTestElement *element, char **formatted) const;
-        virtual void formatAfterAttributes(const QTestElement *element, char **formatted) const;
-        virtual void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, char **formatted) const;
+        virtual void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
+        virtual void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
+        virtual void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
+        virtual void formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
+        virtual void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const;
         virtual void outputElements(QTestElement *element, bool isChildElement = false) const;
         virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const;
 
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index ac4ca83..1866197 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -820,43 +820,6 @@ void filter_unprintable(char *str)
 
 /*! \internal
  */
-int qt_asprintf(char **str, const char *format, ...)
-{
-    static const int MAXSIZE = 1024*1024*2;
-
-    int size = 32;
-    delete[] *str;
-    *str = new char[size];
-
-    va_list ap;
-    int res = 0;
-
-    for (;;) {
-        va_start(ap, format);
-        res = qvsnprintf(*str, size, format, ap);
-        va_end(ap);
-        (*str)[size - 1] = '\0';
-        if (res >= 0 && res < size) {
-            // We succeeded
-            break;
-        }
-        // buffer wasn't big enough, try again.
-        // Note, we're assuming that a result of -1 is always due to running out of space.
-        size *= 2;
-        if (size > MAXSIZE) {
-            break;
-        }
-        delete[] *str;
-        *str = new char[size];
-    }
-
-    filter_unprintable(*str);
-
-    return res;
-}
-
-/*! \internal
- */
 int qt_snprintf(char *str, int size, const char *format, ...)
 {
     va_list ap;
diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp
index e176201..b84f531 100644
--- a/src/testlib/qtestlightxmlstreamer.cpp
+++ b/src/testlib/qtestlightxmlstreamer.cpp
@@ -59,7 +59,7 @@ QTestLightXmlStreamer::QTestLightXmlStreamer()
 QTestLightXmlStreamer::~QTestLightXmlStreamer()
 {}
 
-void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **formatted) const
+void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted)
         return;
@@ -67,14 +67,14 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **form
     switch(element->elementType()){
     case QTest::LET_TestCase: {
         QTestCharBuffer quotedTf;
-        QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name));
+        QXmlTestLogger::xmlQuote(&quotedTf, element->attributeValue(QTest::AI_Name));
 
         QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
         break;
     }
     case QTest::LET_Failure: {
         QTestCharBuffer cdataDesc;
-        QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+        QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
 
         QTest::qt_asprintf(formatted, "    <Description><![CDATA[%s]]></Description>\n",
                            cdataDesc.constData());
@@ -84,8 +84,8 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **form
         // assuming type and attribute names don't need quoting
         QTestCharBuffer quotedFile;
         QTestCharBuffer cdataDesc;
-        QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
-        QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+        QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
+        QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
 
         QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n    <Description><![CDATA[%s]]></Description>\n</Message>\n",
                            element->attributeValue(QTest::AI_Type),
@@ -100,8 +100,8 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **form
         // assuming value and iterations don't need quoting
         QTestCharBuffer quotedMetric;
         QTestCharBuffer quotedTag;
-        QXmlTestLogger::xmlQuote(quotedMetric, element->attributeValue(QTest::AI_Metric));
-        QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag));
+        QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
+        QXmlTestLogger::xmlQuote(&quotedTag, element->attributeValue(QTest::AI_Tag));
 
         QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
                            element->attributeName(QTest::AI_Metric),
@@ -115,11 +115,11 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **form
         break;
     }
     default:
-        QTest::qt_asprintf(formatted, "");
+        formatted->data()[0] = '\0';
     }
 }
 
-void QTestLightXmlStreamer::formatEnd(const QTestElement *element, char **formatted) const
+void QTestLightXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted)
         return;
@@ -129,47 +129,47 @@ void QTestLightXmlStreamer::formatEnd(const QTestElement *element, char **format
             QTest::qt_asprintf(formatted, "</Incident>\n</TestFunction>\n");
         else
             QTest::qt_asprintf(formatted, "</TestFunction>\n");
+    } else {
+        formatted->data()[0] = '\0';
     }
-    else
-        QTest::qt_asprintf(formatted, "");
 }
 
-void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const
+void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted)
         return;
 
-    if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){
-    QTestCharBuffer buf;
-    QTestCharBuffer quotedFile;
-    QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
-
-    QTest::qt_asprintf(buf, "%s=\"%s\" %s=\"%s\"",
-                       element->attributeName(QTest::AI_File),
-                       quotedFile.constData(),
-                       element->attributeName(QTest::AI_Line),
-                       element->attributeValue(QTest::AI_Line));
-
-    if( !element->childElements() )
-        QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
-                           element->attributeValue(QTest::AI_Result), buf.constData());
-    else
-        QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n",
-                               element->attributeValue(QTest::AI_Result), buf.constData());
-    }else{
-        QTest::qt_asprintf(formatted, "");
+    if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)) {
+        QTestCharBuffer buf;
+        QTestCharBuffer quotedFile;
+        QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
+
+        QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"",
+                element->attributeName(QTest::AI_File),
+                quotedFile.constData(),
+                element->attributeName(QTest::AI_Line),
+                element->attributeValue(QTest::AI_Line));
+
+        if( !element->childElements() )
+            QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
+                    element->attributeValue(QTest::AI_Result), buf.constData());
+        else
+            QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n",
+                    element->attributeValue(QTest::AI_Result), buf.constData());
+    } else {
+        formatted->data()[0] = '\0';
     }
 }
 
 void QTestLightXmlStreamer::output(QTestElement *element) const
 {
     QTestCharBuffer buf;
-    QTest::qt_asprintf(buf, "<Environment>\n    <QtVersion>%s</QtVersion>\n    <QTestVersion>%s</QTestVersion>\n",
+    QTest::qt_asprintf(&buf, "<Environment>\n    <QtVersion>%s</QtVersion>\n    <QTestVersion>%s</QTestVersion>\n",
                        qVersion(), QTEST_VERSION_STR );
-    outputString(buf);
+    outputString(buf.constData());
 
-    QTest::qt_asprintf(buf, "</Environment>\n");
-    outputString(buf);
+    QTest::qt_asprintf(&buf, "</Environment>\n");
+    outputString(buf.constData());
 
     QTestBasicStreamer::output(element);
 }
diff --git a/src/testlib/qtestlightxmlstreamer.h b/src/testlib/qtestlightxmlstreamer.h
index 6dafdcc..e147e5c 100644
--- a/src/testlib/qtestlightxmlstreamer.h
+++ b/src/testlib/qtestlightxmlstreamer.h
@@ -59,9 +59,9 @@ class QTestLightXmlStreamer: public QTestBasicStreamer
         QTestLightXmlStreamer();
         ~QTestLightXmlStreamer();
 
-        void formatStart(const QTestElement *element, char **formatted) const;
-        void formatEnd(const QTestElement *element, char **formatted) const;
-        void formatBeforeAttributes(const QTestElement *element, char **formatted) const;
+        void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
+        void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
+        void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
         void output(QTestElement *element) const;
 };
 
diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp
index 1b6e674..c72d648 100644
--- a/src/testlib/qtestxmlstreamer.cpp
+++ b/src/testlib/qtestxmlstreamer.cpp
@@ -60,7 +60,7 @@ QTestXmlStreamer::QTestXmlStreamer()
 QTestXmlStreamer::~QTestXmlStreamer()
 {}
 
-void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted) const
+void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted)
         return;
@@ -68,20 +68,20 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
     switch(element->elementType()){
     case QTest::LET_TestCase: {
         QTestCharBuffer quotedTf;
-        QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name));
+        QXmlTestLogger::xmlQuote(&quotedTf, element->attributeValue(QTest::AI_Name));
 
         QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
         break;
     }
     case QTest::LET_Failure: {
         QTestCharBuffer cdataDesc;
-        QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+        QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
 
         QTestCharBuffer location;
         QTestCharBuffer quotedFile;
-        QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
+        QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
 
-        QTest::qt_asprintf(location, "%s=\"%s\" %s=\"%s\"",
+        QTest::qt_asprintf(&location, "%s=\"%s\" %s=\"%s\"",
                            element->attributeName(QTest::AI_File),
                            quotedFile.constData(),
                            element->attributeName(QTest::AI_Line),
@@ -89,7 +89,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
 
         if (element->attribute(QTest::AI_Tag)) {
             QTestCharBuffer cdataTag;
-            QXmlTestLogger::xmlCdata(cdataTag, element->attributeValue(QTest::AI_Tag));
+            QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag));
             QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
                 "    <DataTag><![CDATA[%s]]></DataTag>\n"
                 "    <Description><![CDATA[%s]]></Description>\n"
@@ -108,8 +108,8 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
         // assuming type and attribute names don't need quoting
         QTestCharBuffer quotedFile;
         QTestCharBuffer cdataDesc;
-        QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
-        QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+        QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
+        QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
 
         QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n    <Description><![CDATA[%s]]></Description>\n</Message>\n",
                            element->attributeValue(QTest::AI_Type),
@@ -124,8 +124,8 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
         // assuming value and iterations don't need quoting
         QTestCharBuffer quotedMetric;
         QTestCharBuffer quotedTag;
-        QXmlTestLogger::xmlQuote(quotedMetric, element->attributeValue(QTest::AI_Metric));
-        QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag));
+        QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
+        QXmlTestLogger::xmlQuote(&quotedTag, element->attributeValue(QTest::AI_Tag));
 
         QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
                            element->attributeName(QTest::AI_Metric),
@@ -139,23 +139,23 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
         break;
     }
     default:
-        QTest::qt_asprintf(formatted, "");
+        formatted->data()[0] = '\0';
     }
 }
 
-void QTestXmlStreamer::formatEnd(const QTestElement *element, char **formatted) const
+void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted)
         return;
 
     if (element->elementType() == QTest::LET_TestCase) {
         QTest::qt_asprintf(formatted, "</TestFunction>\n");
+    } else {
+        formatted->data()[0] = '\0';
     }
-    else
-        QTest::qt_asprintf(formatted, "");
 }
 
-void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const
+void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted)
         return;
@@ -163,9 +163,9 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char
     if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){
         QTestCharBuffer buf;
         QTestCharBuffer quotedFile;
-        QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
+        QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
 
-        QTest::qt_asprintf(buf, "%s=\"%s\" %s=\"%s\"",
+        QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"",
                            element->attributeName(QTest::AI_File),
                            quotedFile.constData(),
                            element->attributeName(QTest::AI_Line),
@@ -174,12 +174,11 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char
         if( !element->childElements() ) {
             QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
                                element->attributeValue(QTest::AI_Result), buf.constData());
+        } else {
+            formatted->data()[0] = '\0';
         }
-        else {
-            QTest::qt_asprintf(formatted, "");
-        }
-    }else{
-        QTest::qt_asprintf(formatted, "");
+    } else {
+        formatted->data()[0] = '\0';
     }
 }
 
@@ -187,23 +186,23 @@ void QTestXmlStreamer::output(QTestElement *element) const
 {
     QTestCharBuffer buf;
     QTestCharBuffer quotedTc;
-    QXmlTestLogger::xmlQuote(quotedTc, QTestResult::currentTestObjectName());
+    QXmlTestLogger::xmlQuote(&quotedTc, QTestResult::currentTestObjectName());
 
-    QTest::qt_asprintf(buf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<TestCase name=\"%s\">\n",
+    QTest::qt_asprintf(&buf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<TestCase name=\"%s\">\n",
                        quotedTc.constData());
-    outputString(buf);
+    outputString(buf.constData());
 
-    QTest::qt_asprintf(buf, "<Environment>\n    <QtVersion>%s</QtVersion>\n    <QTestVersion>%s</QTestVersion>\n",
+    QTest::qt_asprintf(&buf, "<Environment>\n    <QtVersion>%s</QtVersion>\n    <QTestVersion>%s</QTestVersion>\n",
                        qVersion(), QTEST_VERSION_STR );
-    outputString(buf);
+    outputString(buf.constData());
 
-    QTest::qt_asprintf(buf, "</Environment>\n");
-    outputString(buf);
+    QTest::qt_asprintf(&buf, "</Environment>\n");
+    outputString(buf.constData());
 
     QTestBasicStreamer::output(element);
 
-    QTest::qt_asprintf(buf, "</TestCase>\n");
-    outputString(buf);
+    QTest::qt_asprintf(&buf, "</TestCase>\n");
+    outputString(buf.constData());
 }
 
 QT_END_NAMESPACE
diff --git a/src/testlib/qtestxmlstreamer.h b/src/testlib/qtestxmlstreamer.h
index a601f60..6e1ae84 100644
--- a/src/testlib/qtestxmlstreamer.h
+++ b/src/testlib/qtestxmlstreamer.h
@@ -59,9 +59,9 @@ class QTestXmlStreamer: public QTestBasicStreamer
         QTestXmlStreamer();
         ~QTestXmlStreamer();
 
-        void formatStart(const QTestElement *element, char **formatted) const;
-        void formatEnd(const QTestElement *element, char **formatted) const;
-        void formatBeforeAttributes(const QTestElement *element, char **formatted) const;
+        void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
+        void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
+        void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
         void output(QTestElement *element) const;
 };
 
diff --git a/src/testlib/qtestxunitstreamer.cpp b/src/testlib/qtestxunitstreamer.cpp
index d5d2631..932b70b 100644
--- a/src/testlib/qtestxunitstreamer.cpp
+++ b/src/testlib/qtestxunitstreamer.cpp
@@ -73,7 +73,7 @@ void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf
     }
 }
 
-void QTestXunitStreamer::formatStart(const QTestElement *element, char **formatted) const
+void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted )
         return;
@@ -85,8 +85,7 @@ void QTestXunitStreamer::formatStart(const QTestElement *element, char **formatt
     if (element->elementType() == QTest::LET_Error) {
         if (element->parentElement()->elementType() == QTest::LET_SystemError) {
             QTest::qt_asprintf(formatted, "<![CDATA[");
-        }
-        else {
+        } else {
             QTest::qt_asprintf(formatted, "%s<!--", indent);
         }
         return;
@@ -95,13 +94,13 @@ void QTestXunitStreamer::formatStart(const QTestElement *element, char **formatt
     QTest::qt_asprintf(formatted, "%s<%s", indent, element->elementName());
 }
 
-void QTestXunitStreamer::formatEnd(const QTestElement *element, char **formatted) const
+void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
 {
-    if(!element || !formatted )
+    if (!element || !formatted )
         return;
 
-    if(!element->childElements()){
-        QTest::qt_asprintf(formatted, "");
+    if (!element->childElements()){
+        formatted->data()[0] = '\0';
         return;
     }
 
@@ -111,7 +110,7 @@ void QTestXunitStreamer::formatEnd(const QTestElement *element, char **formatted
     QTest::qt_asprintf(formatted, "%s</%s>\n", indent, element->elementName());
 }
 
-void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, char **formatted) const
+void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
 {
     if(!attribute || !formatted )
         return;
@@ -136,15 +135,14 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe
 
     if (key) {
         QTestCharBuffer quotedValue;
-        QXmlTestLogger::xmlQuote(quotedValue, attribute->value());
+        QXmlTestLogger::xmlQuote(&quotedValue, attribute->value());
         QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue.constData());
-    }
-    else {
-        QTest::qt_asprintf(formatted, "");
+    } else {
+        formatted->data()[0] = '\0';
     }
 }
 
-void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char **formatted) const
+void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
 {
     if(!element || !formatted )
         return;
@@ -153,8 +151,7 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char
     if (element->elementType() == QTest::LET_Error) {
         if (element->parentElement()->elementType() == QTest::LET_SystemError) {
             QTest::qt_asprintf(formatted, "]]>\n");
-        }
-        else {
+        } else {
             QTest::qt_asprintf(formatted, " -->\n");
         }
         return;
@@ -187,22 +184,22 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
         hasChildren = element->childElements();
 
         if(element->elementType() != QTest::LET_Benchmark){
-            formatStart(element, buf);
-            outputString(buf);
+            formatStart(element, &buf);
+            outputString(buf.data());
 
-            formatBeforeAttributes(element, buf);
-            outputString(buf);
+            formatBeforeAttributes(element, &buf);
+            outputString(buf.data());
 
             outputElementAttributes(element, element->attributes());
 
-            formatAfterAttributes(element, buf);
-            outputString(buf);
+            formatAfterAttributes(element, &buf);
+            outputString(buf.data());
 
             if(hasChildren)
                 outputElements(element->childElements(), true);
 
-            formatEnd(element, buf);
-            outputString(buf);
+            formatEnd(element, &buf);
+            outputString(buf.data());
         }
         element = element->previousElement();
     }
diff --git a/src/testlib/qtestxunitstreamer.h b/src/testlib/qtestxunitstreamer.h
index 044307f..43ff03d 100644
--- a/src/testlib/qtestxunitstreamer.h
+++ b/src/testlib/qtestxunitstreamer.h
@@ -58,10 +58,10 @@ class QTestXunitStreamer: public QTestBasicStreamer
         QTestXunitStreamer();
         ~QTestXunitStreamer();
 
-        void formatStart(const QTestElement *element, char **formatted) const;
-        void formatEnd(const QTestElement *element, char **formatted) const;
-        void formatAfterAttributes(const QTestElement *element, char **formatted) const;
-        void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, char **formatted) const;
+        void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
+        void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
+        void formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
+        void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const;
         void output(QTestElement *element) const;
         void outputElements(QTestElement *element, bool isChildElement = false) const;
 
diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp
index fca7bfc..494acb4 100644
--- a/src/testlib/qxmltestlogger.cpp
+++ b/src/testlib/qxmltestlogger.cpp
@@ -108,19 +108,19 @@ void QXmlTestLogger::startLogging()
 
     if (xmlmode == QXmlTestLogger::Complete) {
         QTestCharBuffer quotedTc;
-        xmlQuote(quotedTc, QTestResult::currentTestObjectName());
-        QTest::qt_asprintf(buf,
+        xmlQuote(&quotedTc, QTestResult::currentTestObjectName());
+        QTest::qt_asprintf(&buf,
                 "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
                 "<TestCase name=\"%s\">\n", quotedTc.constData());
-        outputString(buf);
+        outputString(buf.constData());
     }
 
-    QTest::qt_asprintf(buf,
+    QTest::qt_asprintf(&buf,
             "<Environment>\n"
             "    <QtVersion>%s</QtVersion>\n"
             "    <QTestVersion>"QTEST_VERSION_STR"</QTestVersion>\n"
             "</Environment>\n", qVersion());
-    outputString(buf);
+    outputString(buf.constData());
 }
 
 void QXmlTestLogger::stopLogging()
@@ -136,9 +136,9 @@ void QXmlTestLogger::enterTestFunction(const char *function)
 {
     QTestCharBuffer buf;
     QTestCharBuffer quotedFunction;
-    xmlQuote(quotedFunction, function);
-    QTest::qt_asprintf(buf, "<TestFunction name=\"%s\">\n", quotedFunction.constData());
-    outputString(buf);
+    xmlQuote(&quotedFunction, function);
+    QTest::qt_asprintf(&buf, "<TestFunction name=\"%s\">\n", quotedFunction.constData());
+    outputString(buf.constData());
 }
 
 void QXmlTestLogger::leaveTestFunction()
@@ -219,12 +219,12 @@ void QXmlTestLogger::addIncident(IncidentTypes type, const char *description,
     QTestCharBuffer cdataTag;
     QTestCharBuffer cdataDescription;
 
-    xmlQuote(quotedFile, file);
-    xmlCdata(cdataGtag, gtag);
-    xmlCdata(cdataTag, tag);
-    xmlCdata(cdataDescription, description);
+    xmlQuote(&quotedFile, file);
+    xmlCdata(&cdataGtag, gtag);
+    xmlCdata(&cdataTag, tag);
+    xmlCdata(&cdataDescription, description);
 
-    QTest::qt_asprintf(buf,
+    QTest::qt_asprintf(&buf,
             QTest::incidentFormatString(QTest::isEmpty(description), notag),
             QTest::xmlIncidentType2String(type),
             quotedFile.constData(), line,
@@ -233,7 +233,7 @@ void QXmlTestLogger::addIncident(IncidentTypes type, const char *description,
             cdataTag.constData(),
             cdataDescription.constData());
 
-    outputString(buf);
+    outputString(buf.constData());
 }
 
 void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
@@ -242,18 +242,18 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
     QTestCharBuffer quotedMetric;
     QTestCharBuffer quotedTag;
 
-    xmlQuote(quotedMetric,
+    xmlQuote(&quotedMetric,
         QBenchmarkGlobalData::current->measurer->metricText().toAscii().constData());
-    xmlQuote(quotedTag, result.context.tag.toAscii().constData());
+    xmlQuote(&quotedTag, result.context.tag.toAscii().constData());
 
     QTest::qt_asprintf(
-        buf,
+        &buf,
         QTest::benchmarkResultFormatString(),
         quotedMetric.constData(),
         quotedTag.constData(),
         QByteArray::number(result.value).constData(),  //no 64-bit qt_snprintf support
         result.iterations);
-    outputString(buf);
+    outputString(buf.constData());
 }
 
 void QXmlTestLogger::addMessage(MessageTypes type, const char *message,
@@ -270,12 +270,12 @@ void QXmlTestLogger::addMessage(MessageTypes type, const char *message,
     QTestCharBuffer cdataTag;
     QTestCharBuffer cdataDescription;
 
-    xmlQuote(quotedFile, file);
-    xmlCdata(cdataGtag, gtag);
-    xmlCdata(cdataTag, tag);
-    xmlCdata(cdataDescription, message);
+    xmlQuote(&quotedFile, file);
+    xmlCdata(&cdataGtag, gtag);
+    xmlCdata(&cdataTag, tag);
+    xmlCdata(&cdataDescription, message);
 
-    QTest::qt_asprintf(buf,
+    QTest::qt_asprintf(&buf,
             QTest::messageFormatString(QTest::isEmpty(message), notag),
             QTest::xmlMessageType2String(type),
             quotedFile.constData(), line,
@@ -284,7 +284,7 @@ void QXmlTestLogger::addMessage(MessageTypes type, const char *message,
             cdataTag.constData(),
             cdataDescription.constData());
 
-    outputString(buf);
+    outputString(buf.constData());
 }
 
 /*
@@ -292,10 +292,11 @@ void QXmlTestLogger::addMessage(MessageTypes type, const char *message,
     XML characters as necessary so that dest is suitable for use in an XML
     quoted attribute string.
 */
-int QXmlTestLogger::xmlQuote(char* dest, char const* src, size_t n)
+int QXmlTestLogger::xmlQuote(QTestCharBuffer* destBuf, char const* src, size_t n)
 {
     if (n == 0) return 0;
 
+    char *dest = destBuf->data();
     *dest = 0;
     if (!src) return 0;
 
@@ -351,10 +352,12 @@ int QXmlTestLogger::xmlQuote(char* dest, char const* src, size_t n)
     Copy up to n characters from the src string into dest, escaping any
     special strings such that dest is suitable for use in an XML CDATA section.
 */
-int QXmlTestLogger::xmlCdata(char* dest, char const* src, size_t n)
+int QXmlTestLogger::xmlCdata(QTestCharBuffer *destBuf, char const* src, size_t n)
 {
     if (!n) return 0;
 
+    char *dest = destBuf->data();
+
     if (!src || n == 1) {
         *dest = 0;
         return 0;
@@ -394,25 +397,23 @@ int QXmlTestLogger::xmlCdata(char* dest, char const* src, size_t n)
     return (dest-begin);
 }
 
-typedef int (*StringFormatFunction)(char*,char const*,size_t);
+typedef int (*StringFormatFunction)(QTestCharBuffer*,char const*,size_t);
 
 /*
     A wrapper for string functions written to work with a fixed size buffer so they can be called
     with a dynamically allocated buffer.
 */
-int allocateStringFn(char** str, char const* src, StringFormatFunction func)
+int allocateStringFn(QTestCharBuffer* str, char const* src, StringFormatFunction func)
 {
     static const int MAXSIZE = 1024*1024*2;
 
-    int size = 32;
-    delete[] *str;
-    *str = new char[size];
+    int size = str->size();
 
     int res = 0;
 
     for (;;) {
-        res = func(*str, src, size);
-        (*str)[size - 1] = '\0';
+        res = func(str, src, size);
+        str->data()[size - 1] = '\0';
         if (res < size) {
             // We succeeded or fatally failed
             break;
@@ -422,19 +423,19 @@ int allocateStringFn(char** str, char const* src, StringFormatFunction func)
         if (size > MAXSIZE) {
             break;
         }
-        delete[] *str;
-        *str = new char[size];
+        if (!str->reset(size))
+            break; // ran out of memory - bye
     }
 
     return res;
 }
 
-int QXmlTestLogger::xmlQuote(char** str, char const* src)
+int QXmlTestLogger::xmlQuote(QTestCharBuffer* str, char const* src)
 {
     return allocateStringFn(str, src, QXmlTestLogger::xmlQuote);
 }
 
-int QXmlTestLogger::xmlCdata(char** str, char const* src)
+int QXmlTestLogger::xmlCdata(QTestCharBuffer* str, char const* src)
 {
     return allocateStringFn(str, src, QXmlTestLogger::xmlCdata);
 }
diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h
index a7cc00a..e14504c 100644
--- a/src/testlib/qxmltestlogger_p.h
+++ b/src/testlib/qxmltestlogger_p.h
@@ -79,10 +79,10 @@ public:
     void addMessage(MessageTypes type, const char *message,
                     const char *file = 0, int line = 0);
 
-    static int xmlCdata(char** dest, char const* src);
-    static int xmlQuote(char** dest, char const* src);
-    static int xmlCdata(char* dest, char const* src, size_t n);
-    static int xmlQuote(char* dest, char const* src, size_t n);
+    static int xmlCdata(QTestCharBuffer *dest, char const* src);
+    static int xmlQuote(QTestCharBuffer *dest, char const* src);
+    static int xmlCdata(QTestCharBuffer *dest, char const* src, size_t n);
+    static int xmlQuote(QTestCharBuffer *dest, char const* src, size_t n);
 
 private:
     XmlMode xmlmode;
-- 
cgit v0.12


From 56d84a7dcbbaee6402d1d43bba879b135839ad61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= <jan-arve.saether@nokia.com>
Date: Fri, 7 Aug 2009 15:34:31 +0200
Subject: Don't crash if we are drawing an empty image.

Reviewed-by: gunnar
---
 src/gui/painting/qpaintengine_raster.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 74456dd..b260f41 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2542,6 +2542,9 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
     qDebug() << " - QRasterPaintEngine::drawImage(), r=" << r << " sr=" << sr << " image=" << img.size() << "depth=" << img.depth();
 #endif
 
+    if (r.isEmpty())
+        return;
+
     Q_D(QRasterPaintEngine);
     QRasterPaintEngineState *s = state();
     const bool aa = s->flags.antialiased || s->flags.bilinear;
-- 
cgit v0.12


From f99e01bccb5e2b686c0d98ea3743e9fcf48ce8d2 Mon Sep 17 00:00:00 2001
From: Harald Fernengel <harald@trolltech.com>
Date: Fri, 7 Aug 2009 16:09:45 +0200
Subject: Fix build warning

gcc was complaining about format string not being a string literal.
Also fixes the small chance that error messages would be bogus if
they contain printf control characters.

Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
---
 src/tools/uic/uic.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp
index f789980..14576e2 100644
--- a/src/tools/uic/uic.cpp
+++ b/src/tools/uic/uic.cpp
@@ -184,7 +184,7 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
     if (reader.hasError()) {
         delete ui;
         ui = 0;
-        fprintf(stderr, qPrintable(QString::fromLatin1("uic: Error in line %1, column %2 : %3\n")
+        fprintf(stderr, "%s\n", qPrintable(QString::fromLatin1("uic: Error in line %1, column %2 : %3")
                                     .arg(reader.lineNumber()).arg(reader.columnNumber())
                                     .arg(reader.errorString())));
     }
-- 
cgit v0.12


From 132a319dc782ef1feebe6582fb6f05dc91df74bb Mon Sep 17 00:00:00 2001
From: Anders Bakken <anders@trolltech.com>
Date: Fri, 7 Aug 2009 07:28:27 -0700
Subject: Fix compiler error on GCC 4.2.0 mips/sh3

Before this patch gcc would fail with this message:
internal compiler error: in add_virtual_operand, at tree-ssa-operands.c:1317

Reviewed-by: Volker Hilsheimer <volker.hilsheimer@nokia.com>
---
 src/gui/graphicsview/qgraphicsview.cpp | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index ca55f2e..92f8816 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -2209,8 +2209,7 @@ QPolygonF QGraphicsView::mapToScene(const QRect &rect) const
     QPointF br = scrollOffset + r.bottomRight();
     QPointF bl = scrollOffset + r.bottomLeft();
 
-    QPolygonF poly;
-    poly.resize(4);
+    QPolygonF poly(4);
     if (!d->identityMatrix) {
         QTransform x = d->matrix.inverted();
         poly[0] = x.map(tl);
@@ -2313,8 +2312,7 @@ QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const
     br -= scrollOffset;
     bl -= scrollOffset;
 
-    QPolygon poly;
-    poly.resize(4);
+    QPolygon poly(4);
     poly[0] = tl.toPoint();
     poly[1] = tr.toPoint();
     poly[2] = br.toPoint();
@@ -3647,8 +3645,7 @@ QRectF QGraphicsViewPrivate::mapToScene(const QRectF &rect) const
     QPointF br = scrollOffset + rect.bottomRight();
     QPointF bl = scrollOffset + rect.bottomLeft();
 
-    QPolygonF poly;
-    poly.resize(4);
+    QPolygonF poly(4);
     if (!identityMatrix) {
         QTransform x = matrix.inverted();
         poly[0] = x.map(tl);
-- 
cgit v0.12


From d13418effc5f00474541ae513a30c9a42c2a1cb3 Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Date: Fri, 7 Aug 2009 17:14:31 +0200
Subject: QItemSelectionModel did not send selectionChanged signal when
 deleting an item in a tree-like model with one of its grand-children being
 selected.

Added recursive deselection for the model.

Task-number: 232634
Reviewed-by: thierry
---
 src/gui/itemviews/qitemselectionmodel.cpp          | 22 +++++++++++++++++++-
 src/gui/itemviews/qitemselectionmodel_p.h          |  2 ++
 .../tst_qitemselectionmodel.cpp                    | 24 ++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index 9dad95f..0f35ac1 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -593,10 +593,30 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
     // update selectionsx
     QModelIndex tl = model->index(start, 0, parent);
     QModelIndex br = model->index(end, model->columnCount(parent) - 1, parent);
-    q->select(QItemSelection(tl, br), QItemSelectionModel::Deselect);
+    recursiveDeselect(QItemSelectionRange(tl, br));
     finalize();
 }
 
+void QItemSelectionModelPrivate::recursiveDeselect(const QItemSelectionRange &range)
+{
+    Q_Q(QItemSelectionModel);
+
+    QItemSelection sel(range.topLeft(), range.bottomRight());
+    q->select(sel, QItemSelectionModel::Deselect);
+
+    QModelIndexList idxList = range.indexes();
+    QModelIndexList::const_iterator it = idxList.begin();
+    for (; it != idxList.end(); ++it)
+    {
+        if (!model->hasChildren(*it))
+            continue;
+
+        const QModelIndex &firstChild = it->child(0,0);
+        const QModelIndex &lastChild = it->child(model->rowCount(*it) - 1, model->columnCount(*it) - 1);
+        recursiveDeselect(QItemSelectionRange(firstChild, lastChild));
+    }
+}
+
 /*!
     \internal
 */
diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/gui/itemviews/qitemselectionmodel_p.h
index 18ad506..8176d4c 100644
--- a/src/gui/itemviews/qitemselectionmodel_p.h
+++ b/src/gui/itemviews/qitemselectionmodel_p.h
@@ -77,6 +77,8 @@ public:
     void _q_layoutAboutToBeChanged();
     void _q_layoutChanged();
 
+    void recursiveDeselect(const QItemSelectionRange &range);
+
     inline void remove(QList<QItemSelectionRange> &r)
     {
         QList<QItemSelectionRange>::const_iterator it = r.constBegin();
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 0541b46..05e23f1 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -90,6 +90,7 @@ private slots:
     void merge();
     void task119433_isRowSelected();
     void task252069_rowIntersectsSelection();
+    void task232634_childrenDeselectionSignal();
 
 private:
     QAbstractItemModel *model;
@@ -2187,5 +2188,28 @@ void tst_QItemSelectionModel::task252069_rowIntersectsSelection()
     QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex()));
 }
 
+void tst_QItemSelectionModel::task232634_childrenDeselectionSignal()
+{
+    QStandardItemModel model;
+
+    QStandardItem *parentItem = model.invisibleRootItem();
+    for (int i = 0; i < 4; ++i) {
+        QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
+        parentItem->appendRow(item);
+        parentItem = item;
+    }
+
+    QModelIndex root = model.index(0,0);
+    QModelIndex par = root.child(0,0);
+    QModelIndex sel = par.child(0,0);
+
+    QItemSelectionModel selectionModel(&model);
+    selectionModel.select(sel, QItemSelectionModel::SelectCurrent);
+
+    QSignalSpy deselectSpy(&selectionModel, SIGNAL(selectionChanged(const QItemSelection& , const QItemSelection&)));
+    model.removeRows(0, 1, root);
+    QVERIFY(deselectSpy.count() == 1);
+}
+
 QTEST_MAIN(tst_QItemSelectionModel)
 #include "tst_qitemselectionmodel.moc"
-- 
cgit v0.12