summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-07-29 06:45:10 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-07-29 06:45:10 (GMT)
commit77bd318b2892ad2a6beefee84c8e1436f4f7f386 (patch)
tree0de55e09200679501da73babed5cce1d4b558781
parent7eba68adc4a7862d9474179592e5c8393a7acdbb (diff)
parentd22d08f3f8a70edfc66c0f6c2fd952688b64fcc2 (diff)
downloadQt-77bd318b2892ad2a6beefee84c8e1436f4f7f386.zip
Qt-77bd318b2892ad2a6beefee84c8e1436f4f7f386.tar.gz
Qt-77bd318b2892ad2a6beefee84c8e1436f4f7f386.tar.bz2
Merge commit 'qt/master-stable'
-rw-r--r--config.tests/unix/stl/stltest.cpp61
-rw-r--r--doc/src/datastreamformat.qdoc56
-rw-r--r--doc/src/examples.qdoc1
-rw-r--r--doc/src/examples/tankgame.qdoc117
-rw-r--r--doc/src/i18n.qdoc12
-rw-r--r--doc/src/paintsystem.qdoc2
-rw-r--r--doc/src/plugins-howto.qdoc1
-rw-r--r--examples/statemachine/statemachine.pro4
-rw-r--r--examples/statemachine/tankgame/gameitem.cpp129
-rw-r--r--examples/statemachine/tankgame/gameovertransition.cpp80
-rw-r--r--examples/statemachine/tankgame/gameovertransition.h63
-rw-r--r--examples/statemachine/tankgame/main.cpp53
-rw-r--r--examples/statemachine/tankgame/mainwindow.cpp342
-rw-r--r--examples/statemachine/tankgame/plugin.h62
-rw-r--r--examples/statemachine/tankgame/rocketitem.cpp101
-rw-r--r--examples/statemachine/tankgame/rocketitem.h66
-rw-r--r--examples/statemachine/tankgame/tankgame.pro19
-rw-r--r--examples/statemachine/tankgame/tankitem.cpp302
-rw-r--r--examples/statemachine/tankgame/tankitem.h109
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai.pro13
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp78
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h105
-rw-r--r--examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp89
-rw-r--r--examples/statemachine/tankgameplugins/seek_ai/seek_ai.h249
-rw-r--r--examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro13
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp70
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.h92
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro13
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp70
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h92
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro13
-rw-r--r--examples/statemachine/tankgameplugins/tankgameplugins.pro11
-rw-r--r--qmake/generators/makefiledeps.cpp14
-rw-r--r--qmake/qmake.pro1
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp2
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebview.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentthreadengine.h6
-rw-r--r--src/corelib/global/qglobal.h4
-rw-r--r--src/corelib/kernel/qcore_unix.cpp75
-rw-r--r--src/corelib/kernel/qcore_unix_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp101
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h4
-rw-r--r--src/corelib/tools/qbytearraymatcher.h11
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp45
-rw-r--r--src/gui/image/qbitmap.cpp3
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm20
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
-rw-r--r--src/gui/kernel/qevent.cpp20
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm11
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac_p.h1
-rw-r--r--src/gui/painting/qmatrix.cpp1
-rw-r--r--src/gui/painting/qpainter.cpp98
-rw-r--r--src/gui/painting/qtransform.cpp4
-rw-r--r--src/gui/styles/qstyleoption.cpp4
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp5
-rw-r--r--src/gui/text/qfontmetrics.cpp12
-rw-r--r--src/gui/widgets/qtabbar.cpp10
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp6
-rw-r--r--src/opengl/qgl_x11.cpp14
-rw-r--r--src/script/qscriptengine.cpp2
-rw-r--r--src/script/qscriptvalue.cpp2
-rw-r--r--src/xmlpatterns/parser/qmaintainingreader.cpp3
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp86
-rw-r--r--tools/assistant/lib/lib.pro96
-rw-r--r--tools/assistant/lib/qhelpsearchengine.cpp14
-rw-r--r--tools/assistant/lib/qhelpsearchindexreader.cpp (renamed from examples/statemachine/tankgame/gameitem.h)78
-rw-r--r--tools/assistant/lib/qhelpsearchindexreader_clucene.cpp60
-rw-r--r--tools/assistant/lib/qhelpsearchindexreader_clucene_p.h36
-rw-r--r--tools/assistant/lib/qhelpsearchindexreader_default.cpp49
-rw-r--r--tools/assistant/lib/qhelpsearchindexreader_default_p.h37
-rw-r--r--tools/assistant/lib/qhelpsearchindexreader_p.h (renamed from examples/statemachine/tankgame/mainwindow.h)91
71 files changed, 639 insertions, 2880 deletions
diff --git a/config.tests/unix/stl/stltest.cpp b/config.tests/unix/stl/stltest.cpp
index ff653a4..4d74ed1 100644
--- a/config.tests/unix/stl/stltest.cpp
+++ b/config.tests/unix/stl/stltest.cpp
@@ -9,6 +9,53 @@ templates for common STL container classes.
#include <algorithm>
#include <iostream>
+// something mean to see if the compiler and C++ standard lib are good enough
+template<class K, class T>
+class DummyClass
+{
+ // everything in std namespace ?
+ typedef std::bidirectional_iterator_tag i;
+ typedef std::ptrdiff_t d;
+ // typename implemented ?
+ typedef typename std::map<K,T>::iterator MyIterator;
+};
+
+// extracted from QVector's strict iterator
+template<class T>
+class DummyIterator
+{
+ typedef DummyIterator<int> iterator;
+public:
+ T *i;
+ typedef std::random_access_iterator_tag iterator_category;
+ typedef ptrdiff_t difference_type;
+ typedef T value_type;
+ typedef T *pointer;
+ typedef T &reference;
+
+ inline DummyIterator() : i(0) {}
+ inline DummyIterator(T *n) : i(n) {}
+ inline DummyIterator(const DummyIterator &o): i(o.i){}
+ inline T &operator*() const { return *i; }
+ inline T *operator->() const { return i; }
+ inline T &operator[](int j) const { return *(i + j); }
+ inline bool operator==(const DummyIterator &o) const { return i == o.i; }
+ inline bool operator!=(const DummyIterator &o) const { return i != o.i; }
+ inline bool operator<(const DummyIterator& other) const { return i < other.i; }
+ inline bool operator<=(const DummyIterator& other) const { return i <= other.i; }
+ inline bool operator>(const DummyIterator& other) const { return i > other.i; }
+ inline bool operator>=(const DummyIterator& other) const { return i >= other.i; }
+ inline DummyIterator &operator++() { ++i; return *this; }
+ inline DummyIterator operator++(int) { T *n = i; ++i; return n; }
+ inline DummyIterator &operator--() { i--; return *this; }
+ inline DummyIterator operator--(int) { T *n = i; i--; return n; }
+ inline DummyIterator &operator+=(int j) { i+=j; return *this; }
+ inline DummyIterator &operator-=(int j) { i-=j; return *this; }
+ inline DummyIterator operator+(int j) const { return DummyIterator(i+j); }
+ inline DummyIterator operator-(int j) const { return DummyIterator(i-j); }
+ inline int operator-(DummyIterator j) const { return i - j.i; }
+};
+
int main()
{
std::vector<int> v1;
@@ -53,16 +100,10 @@ int main()
int m2size = m2.size();
m2size = 0;
+ DummyIterator<int> it1, it2;
+ int n = std::distance(it1, it2);
+ std::advance(it1, 3);
+
return 0;
}
-// something mean to see if the compiler and C++ standard lib are good enough
-template<class K, class T>
-class DummyClass
-{
- // everything in std namespace ?
- typedef std::bidirectional_iterator_tag i;
- typedef std::ptrdiff_t d;
- // typename implemented ?
- typedef typename std::map<K,T>::iterator MyIterator;
-};
diff --git a/doc/src/datastreamformat.qdoc b/doc/src/datastreamformat.qdoc
index dea193f..5db85cb 100644
--- a/doc/src/datastreamformat.qdoc
+++ b/doc/src/datastreamformat.qdoc
@@ -220,6 +220,25 @@
\o dx (double)
\o dy (double)
\endlist
+ \row \o QMatrix4x4
+ \o \list
+ \o m11 (double)
+ \o m12 (double)
+ \o m13 (double)
+ \o m14 (double)
+ \o m21 (double)
+ \o m22 (double)
+ \o m23 (double)
+ \o m24 (double)
+ \o m31 (double)
+ \o m32 (double)
+ \o m33 (double)
+ \o m34 (double)
+ \o m41 (double)
+ \o m42 (double)
+ \o m43 (double)
+ \o m44 (double)
+ \endlist
\row \o QPair<T1, T2>
\o \list
\o first (T1)
@@ -266,6 +285,13 @@
\o The x coordinate (qint32)
\o The y coordinate (qint32)
\endlist
+ \row \o QQuaternion
+ \o \list
+ \o The scalar component (double)
+ \o The x coordinate (double)
+ \o The y coordinate (double)
+ \o The z coordinate (double)
+ \endlist
\row \o QRect
\o \list
\o left (qint32)
@@ -301,6 +327,18 @@
\o \list
\o Milliseconds since midnight (quint32)
\endlist
+ \row \o QTransform
+ \o \list
+ \o m11 (double)
+ \o m12 (double)
+ \o m13 (double)
+ \o m21 (double)
+ \o m22 (double)
+ \o m23 (double)
+ \o m31 (double)
+ \o m32 (double)
+ \o m33 (double)
+ \endlist
\row \o QUrl
\o \list
\o Holds an URL (QString)
@@ -311,6 +349,24 @@
\o The null flag (qint8)
\o The data of the specified type
\endlist
+ \row \o QVector2D
+ \o \list
+ \o the x coordinate (double)
+ \o the y coordinate (double)
+ \endlist
+ \row \o QVector3D
+ \o \list
+ \o the x coordinate (double)
+ \o the y coordinate (double)
+ \o the z coordinate (double)
+ \endlist
+ \row \o QVector4D
+ \o \list
+ \o the x coordinate (double)
+ \o the y coordinate (double)
+ \o the z coordinate (double)
+ \o the w coordinate (double)
+ \endlist
\row \o QVector<T>
\o \list
\o The number of items (quint32)
diff --git a/doc/src/examples.qdoc b/doc/src/examples.qdoc
index 7cb4430..67f58c3 100644
--- a/doc/src/examples.qdoc
+++ b/doc/src/examples.qdoc
@@ -324,7 +324,6 @@
\o \l{statemachine/pingpong}{Ping Pong States}\raisedaster
\o \l{statemachine/trafficlight}{Traffic Light}\raisedaster
\o \l{statemachine/twowaybutton}{Two-way Button}\raisedaster
- \o \l{statemachine/tankgame}{Tank Game}\raisedaster
\endlist
\section1 Threads
diff --git a/doc/src/examples/tankgame.qdoc b/doc/src/examples/tankgame.qdoc
deleted file mode 100644
index 536e582..0000000
--- a/doc/src/examples/tankgame.qdoc
+++ /dev/null
@@ -1,117 +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 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/tankgame
- \title Tank Game Example
-
- The Tank Game example is part of the in \l{The State Machine Framework}. It shows how to use
- parallel states to implement artificial intelligence controllers that run in parallel, and error
- states to handle run-time errors in parts of the state graph created by external plugins.
-
- \image tankgame-example.png
-
- In this example we write a simple game. The application runs a state machine with two main
- states: A "stopped" state and a "running" state. The user can load plugins from the disk by
- selecting the "Add tank" menu item.
-
- When the "Add tank" menu item is selected, the "plugins" subdirectory in the example's
- directory is searched for compatible plugins. If any are found, they will be listed in a
- dialog box created using QInputDialog::getItem().
-
- \snippet examples/statemachine/tankgame/mainwindow.cpp 1
-
- If the user selects a plugin, the application will construct a TankItem object, which inherits
- from QGraphicsItem and QObject, and which implements an agreed-upon interface using the
- meta-object mechanism.
-
- \snippet examples/statemachine/tankgame/tankitem.h 0
-
- The tank item will be passed to the plugin's create() function. This will in turn return a
- QState object which is expected to implement an artificial intelligence which controls the
- tank and attempts to destroy other tanks it detects.
-
- \snippet examples/statemachine/tankgame/mainwindow.cpp 2
-
- Each returned QState object becomes a descendant of a \c region in the "running" state, which is
- defined as a parallel state. This means that entering the "running" state will cause each of the
- plugged-in QState objects to be entered simultaneously, allowing the tanks to run independently
- of each other.
-
- \snippet examples/statemachine/tankgame/mainwindow.cpp 0
-
- The maximum number of tanks on the map is four, and when this number is reached, the
- "Add tank" menu item should be disabled. This is implemented by giving the "stopped" state two
- children which define whether the map is full or not.
-
- \snippet examples/statemachine/tankgame/mainwindow.cpp 5
-
- To make sure that we go into the correct child state when returning from the "running" state
- (if the "Stop game" menu item is selected while the game is running) we also give the "stopped"
- state a history state which we make the initial state of "stopped" state.
-
- \snippet examples/statemachine/tankgame/mainwindow.cpp 3
-
- Since part of the state graph is defined by external plugins, we have no way of controlling
- whether they contain errors. By default, run-time errors are handled in the state machine by
- entering a top level state which prints out an error message and never exits. If we were to
- use this default behavior, a run-time error in any of the plugins would cause the "running"
- state to exit, and thus all the other tanks to stop running as well. A better solution would
- be if the broken plugin was disabled and the rest of the tanks allowed to continue as before.
-
- This is done by setting the error state of the plugin's top-most state to a special error state
- defined specifically for the plugin in question.
-
- \snippet examples/statemachine/tankgame/mainwindow.cpp 4
-
- If a run-time error occurs in \c pluginState or any of its descendants, the state machine will
- search the hierarchy of ancestors until it finds a state whose error state is different from
- \c null. (Note that if we are worried that a plugin could inadvertedly be overriding our
- error state, we could search the descendants of \c pluginState and verify that their error
- states are set to \c null before accepting the plugin.)
-
- The specialized \c errorState sets the "enabled" property of the tank item in question to false,
- causing it to be painted with a red cross over it to indicate that it is no longer running.
- Since the error state is a child of the same region in the parallel "running" state as
- \c pluginState, it will not exit the "running" state, and the other tanks will continue running
- without disruption.
-
-*/
diff --git a/doc/src/i18n.qdoc b/doc/src/i18n.qdoc
index 5964926..d043f45 100644
--- a/doc/src/i18n.qdoc
+++ b/doc/src/i18n.qdoc
@@ -144,13 +144,13 @@
aligned, so for these languages use the version of drawText() that
takes a QRect since this will align in accordance with the language.
- \o When you write your own text input controls, use \l
- QFontMetrics::charWidth() to determine the width of a character in a
- string. In some languages (e.g. Arabic or languages from the Indian
+ \o When you write your own text input controls, use QTextLayout.
+ In some languages (e.g. Arabic or languages from the Indian
subcontinent), the width and shape of a glyph changes depending on the
- surrounding characters. Writing input controls usually requires a
- certain knowledge of the scripts it is going to be used in. Usually
- the easiest way is to subclass QLineEdit or QTextEdit.
+ surrounding characters, which QTextLayout takes into account.
+ Writing input controls usually requires a certain knowledge of the
+ scripts it is going to be used in. Usually the easiest way is to
+ subclass QLineEdit or QTextEdit.
\endlist
diff --git a/doc/src/paintsystem.qdoc b/doc/src/paintsystem.qdoc
index a75908b..c2434e0 100644
--- a/doc/src/paintsystem.qdoc
+++ b/doc/src/paintsystem.qdoc
@@ -121,7 +121,7 @@
Normally, QPainter draws in a "natural" coordinate system, but it
is able to perform view and world transformations using the
- QMatrix class. For more information, see \l {The Coordinate
+ QTransform class. For more information, see \l {The Coordinate
System} documentation which also describes the rendering process,
i.e. the relation between the logical representation and the
rendered pixels, and the benefits of anti-aliased painting.
diff --git a/doc/src/plugins-howto.qdoc b/doc/src/plugins-howto.qdoc
index dff8ed9..ab2e294 100644
--- a/doc/src/plugins-howto.qdoc
+++ b/doc/src/plugins-howto.qdoc
@@ -92,7 +92,6 @@
\row \o QInputContextPlugin \o \c inputmethods \o Case Sensitive
\row \o QKbdDriverPlugin \o \c kbddrivers \o Case Insensitive
\row \o QMouseDriverPlugin \o \c mousedrivers \o Case Insensitive
- \row \o QPictureFormatPlugin \o \c pictureformats \o Case Sensitive
\row \o QScreenDriverPlugin \o \c gfxdrivers \o Case Insensitive
\row \o QScriptExtensionPlugin \o \c script \o Case Sensitive
\row \o QSqlDriverPlugin \o \c sqldrivers \o Case Sensitive
diff --git a/examples/statemachine/statemachine.pro b/examples/statemachine/statemachine.pro
index 5074a3c..ea3e7a8 100644
--- a/examples/statemachine/statemachine.pro
+++ b/examples/statemachine/statemachine.pro
@@ -4,9 +4,7 @@ SUBDIRS = \
factorial \
pingpong \
trafficlight \
- twowaybutton \
- tankgame \
- tankgameplugins
+ twowaybutton
# install
target.path = $$[QT_INSTALL_EXAMPLES]/statemachine
diff --git a/examples/statemachine/tankgame/gameitem.cpp b/examples/statemachine/tankgame/gameitem.cpp
deleted file mode 100644
index 94affb4..0000000
--- a/examples/statemachine/tankgame/gameitem.cpp
+++ /dev/null
@@ -1,129 +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 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 "gameitem.h"
-
-#include <QGraphicsScene>
-#include <QDebug>
-
-GameItem::GameItem(QObject *parent) : QObject(parent)
-{
-}
-
-QPointF GameItem::tryMove(const QPointF &requestedPosition, QLineF *collidedLine,
- QGraphicsItem **collidedItem) const
-{
- QLineF movementPath(pos(), requestedPosition);
-
- qreal cannonLength = 0.0;
- {
- QPointF p1 = boundingRect().center();
- QPointF p2 = QPointF(boundingRect().right() + 10.0, p1.y());
-
- cannonLength = QLineF(mapToScene(p1), mapToScene(p2)).length();
- }
-
- movementPath.setLength(movementPath.length() + cannonLength);
-
- QRectF boundingRectPath(QPointF(qMin(movementPath.x1(), movementPath.x2()), qMin(movementPath.y1(), movementPath.y2())),
- QPointF(qMax(movementPath.x1(), movementPath.x2()), qMax(movementPath.y1(), movementPath.y2())));
-
- QList<QGraphicsItem *> itemsInRect = scene()->items(boundingRectPath, Qt::IntersectsItemBoundingRect);
-
- QPointF nextPoint = requestedPosition;
- QRectF sceneRect = scene()->sceneRect();
-
- foreach (QGraphicsItem *item, itemsInRect) {
- if (item == static_cast<const QGraphicsItem *>(this))
- continue;
-
- QPolygonF mappedBoundingRect = item->mapToScene(item->boundingRect());
- for (int i=0; i<mappedBoundingRect.size(); ++i) {
- QPointF p1 = mappedBoundingRect.at(i == 0 ? mappedBoundingRect.size()-1 : i-1);
- QPointF p2 = mappedBoundingRect.at(i);
-
- QLineF rectLine(p1, p2);
- QPointF intersectionPoint;
- QLineF::IntersectType intersectType = movementPath.intersect(rectLine, &intersectionPoint);
-
- if (intersectType == QLineF::BoundedIntersection) {
- movementPath.setP2(intersectionPoint);
- movementPath.setLength(movementPath.length() - cannonLength);
- nextPoint = movementPath.p2();
-
- if (collidedLine != 0)
- *collidedLine = rectLine;
-
- if (collidedItem != 0)
- *collidedItem = item;
- }
- }
- }
-
-
- // Don't go outside of map
- if (nextPoint.x() < sceneRect.left()) {
- nextPoint.rx() = sceneRect.left();
- if (collidedLine != 0)
- *collidedLine = QLineF(scene()->sceneRect().topLeft(), scene()->sceneRect().bottomLeft());
- }
-
- if (nextPoint.x() > sceneRect.right()) {
- nextPoint.rx() = sceneRect.right();
- if (collidedLine != 0)
- *collidedLine = QLineF(scene()->sceneRect().topRight(), scene()->sceneRect().bottomRight());
- }
-
- if (nextPoint.y() < sceneRect.top()) {
- nextPoint.ry() = sceneRect.top();
- if (collidedLine != 0)
- *collidedLine = QLineF(scene()->sceneRect().topLeft(), scene()->sceneRect().topRight());
- }
-
- if (nextPoint.y() > sceneRect.bottom()) {
- nextPoint.ry() = sceneRect.bottom();
- if (collidedLine != 0)
- *collidedLine = QLineF(scene()->sceneRect().bottomLeft(), scene()->sceneRect().bottomRight());
- }
-
- return nextPoint;
-}
-
diff --git a/examples/statemachine/tankgame/gameovertransition.cpp b/examples/statemachine/tankgame/gameovertransition.cpp
deleted file mode 100644
index 634fbce..0000000
--- a/examples/statemachine/tankgame/gameovertransition.cpp
+++ /dev/null
@@ -1,80 +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 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 "gameovertransition.h"
-#include "tankitem.h"
-
-#include <QSignalEvent>
-#include <QSignalMapper>
-
-GameOverTransition::GameOverTransition(QAbstractState *targetState)
- : QSignalTransition(new QSignalMapper(), SIGNAL(mapped(QObject*)))
-{
- setTargetState(targetState);
-
- QSignalMapper *mapper = qobject_cast<QSignalMapper *>(senderObject());
- mapper->setParent(this);
-}
-
-void GameOverTransition::addTankItem(TankItem *tankItem)
-{
- m_tankItems.append(tankItem);
-
- QSignalMapper *mapper = qobject_cast<QSignalMapper *>(senderObject());
- mapper->setMapping(tankItem, tankItem);
- connect(tankItem, SIGNAL(aboutToBeDestroyed()), mapper, SLOT(map()));
-}
-
-bool GameOverTransition::eventTest(QEvent *e)
-{
- bool ret = QSignalTransition::eventTest(e);
-
- if (ret) {
- QSignalEvent *signalEvent = static_cast<QSignalEvent *>(e);
- QObject *sender = qvariant_cast<QObject *>(signalEvent->arguments().at(0));
- TankItem *tankItem = qobject_cast<TankItem *>(sender);
- m_tankItems.removeAll(tankItem);
-
- return m_tankItems.size() <= 1;
- } else {
- return false;
- }
-}
diff --git a/examples/statemachine/tankgame/gameovertransition.h b/examples/statemachine/tankgame/gameovertransition.h
deleted file mode 100644
index e918359..0000000
--- a/examples/statemachine/tankgame/gameovertransition.h
+++ /dev/null
@@ -1,63 +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 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 GAMEOVERTRANSITION_H
-#define GAMEOVERTRANSITION_H
-
-#include <QSignalTransition>
-
-class TankItem;
-class GameOverTransition: public QSignalTransition
-{
- Q_OBJECT
-public:
- GameOverTransition(QAbstractState *targetState);
-
- void addTankItem(TankItem *tankItem);
-
-protected:
- bool eventTest(QEvent *event);
-
-private:
- QList<TankItem *> m_tankItems;
-};
-
-#endif
diff --git a/examples/statemachine/tankgame/main.cpp b/examples/statemachine/tankgame/main.cpp
deleted file mode 100644
index 85e2747..0000000
--- a/examples/statemachine/tankgame/main.cpp
+++ /dev/null
@@ -1,53 +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 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 <QApplication>
-#include "mainwindow.h"
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- MainWindow mainWindow;
- mainWindow.show();
-
- return app.exec();
-}
diff --git a/examples/statemachine/tankgame/mainwindow.cpp b/examples/statemachine/tankgame/mainwindow.cpp
deleted file mode 100644
index 596cdfe..0000000
--- a/examples/statemachine/tankgame/mainwindow.cpp
+++ /dev/null
@@ -1,342 +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 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 "mainwindow.h"
-#include "tankitem.h"
-#include "rocketitem.h"
-#include "plugin.h"
-#include "gameovertransition.h"
-
-#include <QStateMachine>
-#include <QGraphicsView>
-#include <QAction>
-#include <QMenuBar>
-#include <QState>
-#include <QHistoryState>
-#include <QTimer>
-#include <QFileDialog>
-#include <QPluginLoader>
-#include <QApplication>
-#include <QInputDialog>
-#include <QMessageBox>
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent), m_scene(0), m_machine(0), m_runningState(0), m_started(false)
-{
- init();
-}
-
-MainWindow::~MainWindow()
-{
-}
-
-void MainWindow::addWall(const QRectF &wall)
-{
- QGraphicsRectItem *item = new QGraphicsRectItem;
- item->setRect(wall);
- item->setBrush(Qt::darkGreen);
- item->setPen(QPen(Qt::black, 0));
-
- m_scene->addItem(item);
-}
-
-void MainWindow::init()
-{
- setWindowTitle("Pluggable Tank Game");
-
- QGraphicsView *view = new QGraphicsView(this);
- view->setRenderHints(QPainter::Antialiasing);
- setCentralWidget(view);
-
- m_scene = new QGraphicsScene(this);
- view->setScene(m_scene);
-
- QRectF sceneRect = QRectF(-200.0, -200.0, 400.0, 400.0);
- m_scene->setSceneRect(sceneRect);
-
- {
- TankItem *item = new TankItem(this);
-
- item->setPos(m_scene->sceneRect().topLeft() + QPointF(30.0, 30.0));
- item->setDirection(45.0);
- item->setColor(Qt::red);
-
- m_spawns.append(item);
- }
-
- {
- TankItem *item = new TankItem(this);
-
- item->setPos(m_scene->sceneRect().topRight() + QPointF(-30.0, 30.0));
- item->setDirection(135.0);
- item->setColor(Qt::green);
-
- m_spawns.append(item);
- }
-
- {
- TankItem *item = new TankItem(this);
-
- item->setPos(m_scene->sceneRect().bottomRight() + QPointF(-30.0, -30.0));
- item->setDirection(225.0);
- item->setColor(Qt::blue);
-
- m_spawns.append(item);
- }
-
- {
- TankItem *item = new TankItem(this);
-
- item->setPos(m_scene->sceneRect().bottomLeft() + QPointF(30.0, -30.0));
- item->setDirection(315.0);
- item->setColor(Qt::yellow);
-
- m_spawns.append(item);
- }
-
- QPointF centerOfMap = sceneRect.center();
-
- addWall(QRectF(centerOfMap + QPointF(-50.0, -60.0), centerOfMap + QPointF(50.0, -50.0)));
- addWall(QRectF(centerOfMap - QPointF(-50.0, -60.0), centerOfMap - QPointF(50.0, -50.0)));
- addWall(QRectF(centerOfMap + QPointF(-50.0, -50.0), centerOfMap + QPointF(-40.0, 50.0)));
- addWall(QRectF(centerOfMap - QPointF(-50.0, -50.0), centerOfMap - QPointF(-40.0, 50.0)));
-
- addWall(QRectF(sceneRect.topLeft() + QPointF(sceneRect.width() / 2.0 - 5.0, -10.0),
- sceneRect.topLeft() + QPointF(sceneRect.width() / 2.0 + 5.0, 100.0)));
- addWall(QRectF(sceneRect.bottomLeft() + QPointF(sceneRect.width() / 2.0 - 5.0, 10.0),
- sceneRect.bottomLeft() + QPointF(sceneRect.width() / 2.0 + 5.0, -100.0)));
- addWall(QRectF(sceneRect.topLeft() + QPointF(-10.0, sceneRect.height() / 2.0 - 5.0),
- sceneRect.topLeft() + QPointF(100.0, sceneRect.height() / 2.0 + 5.0)));
- addWall(QRectF(sceneRect.topRight() + QPointF(10.0, sceneRect.height() / 2.0 - 5.0),
- sceneRect.topRight() + QPointF(-100.0, sceneRect.height() / 2.0 + 5.0)));
-
-
- QAction *addTankAction = menuBar()->addAction("&Add tank");
- QAction *runGameAction = menuBar()->addAction("&Run game");
- runGameAction->setObjectName("runGameAction");
- QAction *stopGameAction = menuBar()->addAction("&Stop game");
- menuBar()->addSeparator();
- QAction *quitAction = menuBar()->addAction("&Quit");
-
- connect(addTankAction, SIGNAL(triggered()), this, SLOT(addTank()));
- connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
-
- m_machine = new QStateMachine(this);
- QState *stoppedState = new QState(m_machine);
- stoppedState->setObjectName("stoppedState");
- stoppedState->assignProperty(runGameAction, "enabled", true);
- stoppedState->assignProperty(stopGameAction, "enabled", false);
- stoppedState->assignProperty(this, "started", false);
- m_machine->setInitialState(stoppedState);
-
-//! [5]
- QState *spawnsAvailable = new QState(stoppedState);
- spawnsAvailable->assignProperty(addTankAction, "enabled", true);
-
- QState *noSpawnsAvailable = new QState(stoppedState);
- noSpawnsAvailable->assignProperty(addTankAction, "enabled", false);
-//! [5]
- spawnsAvailable->setObjectName("spawnsAvailable");
- noSpawnsAvailable->setObjectName("noSpawnsAvailable");
-
- spawnsAvailable->addTransition(this, SIGNAL(mapFull()), noSpawnsAvailable);
-
-//! [3]
- QHistoryState *hs = new QHistoryState(stoppedState);
- hs->setDefaultState(spawnsAvailable);
-//! [3]
- hs->setObjectName("hs");
-
- stoppedState->setInitialState(hs);
-
-//! [0]
- m_runningState = new QState(QState::ParallelStates, m_machine);
-//! [0]
- m_runningState->setObjectName("runningState");
- m_runningState->assignProperty(addTankAction, "enabled", false);
- m_runningState->assignProperty(runGameAction, "enabled", false);
- m_runningState->assignProperty(stopGameAction, "enabled", true);
-
- QState *gameOverState = new QState(m_machine);
- gameOverState->setObjectName("gameOverState");
- gameOverState->assignProperty(stopGameAction, "enabled", false);
- connect(gameOverState, SIGNAL(entered()), this, SLOT(gameOver()));
-
- stoppedState->addTransition(runGameAction, SIGNAL(triggered()), m_runningState);
- m_runningState->addTransition(stopGameAction, SIGNAL(triggered()), stoppedState);
-
- m_gameOverTransition = new GameOverTransition(gameOverState);
- m_runningState->addTransition(m_gameOverTransition);
-
- QTimer *timer = new QTimer(this);
- timer->setInterval(100);
- connect(timer, SIGNAL(timeout()), this, SLOT(runStep()));
- connect(m_runningState, SIGNAL(entered()), timer, SLOT(start()));
- connect(m_runningState, SIGNAL(exited()), timer, SLOT(stop()));
-
- m_machine->start();
- m_time.start();
-}
-
-void MainWindow::runStep()
-{
- if (!m_started) {
- m_time.restart();
- m_started = true;
- } else {
- int elapsed = m_time.elapsed();
- if (elapsed > 0) {
- m_time.restart();
- qreal elapsedSecs = elapsed / 1000.0;
- QList<QGraphicsItem *> items = m_scene->items();
- foreach (QGraphicsItem *item, items) {
- if (GameItem *gameItem = qgraphicsitem_cast<GameItem *>(item))
- gameItem->idle(elapsedSecs);
- }
- }
- }
-}
-
-void MainWindow::gameOver()
-{
- QList<QGraphicsItem *> items = m_scene->items();
-
- TankItem *lastTankStanding = 0;
- foreach (QGraphicsItem *item, items) {
- if (GameItem *gameItem = qgraphicsitem_cast<GameItem *>(item)) {
- if ((lastTankStanding = qobject_cast<TankItem *>(gameItem)) != 0)
- break;
- }
- }
-
- QMessageBox::information(this, "Game over!",
- QString::fromLatin1("The tank played by '%1' has won!").arg(lastTankStanding->objectName()));
-}
-
-void MainWindow::addRocket()
-{
- TankItem *tankItem = qobject_cast<TankItem *>(sender());
- if (tankItem != 0) {
- RocketItem *rocketItem = new RocketItem;
-
- QPointF s = tankItem->mapToScene(QPointF(tankItem->boundingRect().right() + 10.0,
- tankItem->boundingRect().center().y()));
- rocketItem->setPos(s);
- rocketItem->setDirection(tankItem->direction());
- m_scene->addItem(rocketItem);
- }
-}
-
-void MainWindow::addTank()
-{
- Q_ASSERT(!m_spawns.isEmpty());
-
- QDir pluginsDir(qApp->applicationDirPath());
-#if defined(Q_OS_WIN)
- if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
- pluginsDir.cdUp();
-#elif defined(Q_OS_MAC)
- if (pluginsDir.dirName() == "MacOS") {
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- }
-#endif
-
- pluginsDir.cd("plugins");
-
- QStringList itemNames;
- QList<Plugin *> items;
- foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
- QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
- QObject *possiblePlugin = loader.instance();
- if (Plugin *plugin = qobject_cast<Plugin *>(possiblePlugin)) {
- QString objectName = possiblePlugin->objectName();
- if (objectName.isEmpty())
- objectName = fileName;
-
- itemNames.append(objectName);
- items.append(plugin);
- }
- }
-
- if (items.isEmpty()) {
- QMessageBox::information(this, "No tank types found", "Please build the errorstateplugins directory");
- return;
- }
-
- bool ok;
-//! [1]
- QString selectedName = QInputDialog::getItem(this, "Select a tank type", "Tank types",
- itemNames, 0, false, &ok);
-//! [1]
-
- if (ok && !selectedName.isEmpty()) {
- int idx = itemNames.indexOf(selectedName);
- if (Plugin *plugin = idx >= 0 ? items.at(idx) : 0) {
- TankItem *tankItem = m_spawns.takeLast();
- tankItem->setObjectName(selectedName);
- tankItem->setToolTip(selectedName);
- m_scene->addItem(tankItem);
- connect(tankItem, SIGNAL(cannonFired()), this, SLOT(addRocket()));
- if (m_spawns.isEmpty())
- emit mapFull();
-
- m_gameOverTransition->addTankItem(tankItem);
-
- QState *region = new QState(m_runningState);
- region->setObjectName(QString::fromLatin1("region%1").arg(m_spawns.size()));
-//! [2]
- QState *pluginState = plugin->create(region, tankItem);
-//! [2]
- region->setInitialState(pluginState);
-
- // If the plugin has an error it is disabled
-//! [4]
- QState *errorState = new QState(region);
- errorState->setObjectName(QString::fromLatin1("errorState%1").arg(m_spawns.size()));
- errorState->assignProperty(tankItem, "enabled", false);
- pluginState->setErrorState(errorState);
-//! [4]
- }
- }
-}
-
diff --git a/examples/statemachine/tankgame/plugin.h b/examples/statemachine/tankgame/plugin.h
deleted file mode 100644
index 97e4640..0000000
--- a/examples/statemachine/tankgame/plugin.h
+++ /dev/null
@@ -1,62 +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 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 PLUGIN_H
-#define PLUGIN_H
-
-#include <QtPlugin>
-
-QT_BEGIN_NAMESPACE
-class QState;
-QT_END_NAMESPACE
-class Plugin
-{
-public:
- virtual ~Plugin() {}
-
- virtual QState *create(QState *parentState, QObject *tank) = 0;
-};
-
-QT_BEGIN_NAMESPACE
-Q_DECLARE_INTERFACE(Plugin, "TankPlugin")
-QT_END_NAMESPACE
-
-#endif
diff --git a/examples/statemachine/tankgame/rocketitem.cpp b/examples/statemachine/tankgame/rocketitem.cpp
deleted file mode 100644
index d286e5d..0000000
--- a/examples/statemachine/tankgame/rocketitem.cpp
+++ /dev/null
@@ -1,101 +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 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 "rocketitem.h"
-#include "tankitem.h"
-
-#include <QPainter>
-#include <QGraphicsScene>
-
-#include <math.h>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-RocketItem::RocketItem(QObject *parent)
- : GameItem(parent), m_direction(0.0), m_distance(300.0)
-{
-}
-
-QRectF RocketItem::boundingRect() const
-{
- return QRectF(-1.0, -1.0, 2.0, 2.0);
-}
-
-void RocketItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
-{
- painter->setBrush(Qt::black);
- painter->drawEllipse(boundingRect());
-}
-
-void RocketItem::idle(qreal elapsed)
-{
- qreal dist = elapsed * speed();
-
- m_distance -= dist;
- if (m_distance < 0.0) {
- scene()->removeItem(this);
- delete this;
- return;
- }
-
- qreal a = m_direction * M_PI / 180.0;
-
- qreal yd = dist * sin(a);
- qreal xd = dist * sin(M_PI / 2.0 - a);
-
- QPointF requestedPosition = pos() + QPointF(xd, yd);
- QGraphicsItem *collidedItem = 0;
- QPointF nextPosition = tryMove(requestedPosition, 0, &collidedItem);
- if (requestedPosition == nextPosition) {
- setPos(nextPosition);
- } else {
- if (GameItem *gameItem = qgraphicsitem_cast<GameItem *>(collidedItem)) {
- TankItem *tankItem = qobject_cast<TankItem *>(gameItem);
- if (tankItem != 0)
- tankItem->hitByRocket();
- }
-
- scene()->removeItem(this);
- delete this;
- }
-}
diff --git a/examples/statemachine/tankgame/rocketitem.h b/examples/statemachine/tankgame/rocketitem.h
deleted file mode 100644
index a485d03..0000000
--- a/examples/statemachine/tankgame/rocketitem.h
+++ /dev/null
@@ -1,66 +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 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 ROCKETITEM_H
-#define ROCKETITEM_H
-
-#include "gameitem.h"
-
-class RocketItem: public GameItem
-{
- Q_OBJECT
-public:
- RocketItem(QObject *parent = 0);
-
- virtual void idle(qreal elapsed);
- qreal speed() const { return 100.0; }
- void setDirection(qreal direction) { m_direction = direction; }
-
-protected:
- virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
- QRectF boundingRect() const;
-
-private:
- qreal m_direction;
- qreal m_distance;
-};
-
-#endif
diff --git a/examples/statemachine/tankgame/tankgame.pro b/examples/statemachine/tankgame/tankgame.pro
deleted file mode 100644
index 59415be..0000000
--- a/examples/statemachine/tankgame/tankgame.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-HEADERS += mainwindow.h \
- plugin.h \
- tankitem.h \
- rocketitem.h \
- gameitem.h \
- gameovertransition.h
-SOURCES += main.cpp \
- mainwindow.cpp \
- tankitem.cpp \
- rocketitem.cpp \
- gameitem.cpp \
- gameovertransition.cpp
-CONFIG += console
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS tankgame.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame
-INSTALLS += target sources
diff --git a/examples/statemachine/tankgame/tankitem.cpp b/examples/statemachine/tankgame/tankitem.cpp
deleted file mode 100644
index 192b272..0000000
--- a/examples/statemachine/tankgame/tankitem.cpp
+++ /dev/null
@@ -1,302 +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 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 "tankitem.h"
-
-#include <QPainter>
-#include <QGraphicsScene>
-#include <QDebug>
-
-#include <math.h>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-class Action
-{
-public:
- Action(TankItem *item) : m_item(item)
- {
- }
-
- TankItem *item() const { return m_item; }
- void setItem(TankItem *item) { m_item = item; }
-
- virtual bool apply(qreal timeDelta) = 0;
-
-private:
- TankItem *m_item;
-};
-
-class MoveAction: public Action
-{
-public:
- MoveAction(TankItem *item, qreal distance)
- : Action(item), m_distance(distance)
- {
- m_reverse = m_distance < 0.0;
- }
-
- bool apply(qreal timeDelta)
- {
- qreal dist = timeDelta * item()->speed() * (m_reverse ? -1.0 : 1.0);
-
- bool done = false;
- if (qAbs(m_distance) < qAbs(dist)) {
- done = true;
- dist = m_distance;
- }
- m_distance -= dist;
-
- qreal a = item()->direction() * M_PI / 180.0;
-
- qreal yd = dist * sin(a);
- qreal xd = dist * sin(M_PI / 2.0 - a);
-
- item()->setPos(item()->pos() + QPointF(xd, yd));
- return !done;
- }
-
-private:
- qreal m_distance;
- bool m_reverse;
-};
-
-class TurnAction: public Action
-{
-public:
- TurnAction(TankItem *item, qreal distance)
- : Action(item), m_distance(distance)
- {
- m_reverse = m_distance < 0.0;
- }
-
- bool apply(qreal timeDelta)
- {
- qreal dist = timeDelta * item()->angularSpeed() * (m_reverse ? -1.0 : 1.0);
- bool done = false;
- if (qAbs(m_distance) < qAbs(dist)) {
- done = true;
- dist = m_distance;
- }
- m_distance -= dist;
-
- item()->setDirection(item()->direction() + dist);
- return !done;
- }
-
-private:
- qreal m_distance;
- bool m_reverse;
-};
-
-TankItem::TankItem(QObject *parent)
- : GameItem(parent), m_currentAction(0), m_currentDirection(0.0), m_enabled(true)
-{
- connect(this, SIGNAL(cannonFired()), this, SIGNAL(actionCompleted()));
-}
-
-void TankItem::idle(qreal elapsed)
-{
- if (m_enabled) {
- if (m_currentAction != 0) {
- if (!m_currentAction->apply(elapsed)) {
- setAction(0);
- emit actionCompleted();
- }
-
- QGraphicsItem *item = 0;
- qreal distance = distanceToObstacle(&item);
- if (TankItem *tankItem = qgraphicsitem_cast<TankItem *>(item))
- emit tankSpotted(tankItem->direction(), distance);
- }
- }
-}
-
-void TankItem::hitByRocket()
-{
- emit aboutToBeDestroyed();
- deleteLater();
-}
-
-void TankItem::setAction(Action *newAction)
-{
- if (m_currentAction != 0)
- delete m_currentAction;
-
- m_currentAction = newAction;
-}
-
-void TankItem::fireCannon()
-{
- emit cannonFired();
-}
-
-void TankItem::moveForwards(qreal length)
-{
- setAction(new MoveAction(this, length));
-}
-
-void TankItem::moveBackwards(qreal length)
-{
- setAction(new MoveAction(this, -length));
-}
-
-void TankItem::turn(qreal degrees)
-{
- setAction(new TurnAction(this, degrees));
-}
-
-void TankItem::turnTo(qreal degrees)
-{
- setAction(new TurnAction(this, degrees - direction()));
-}
-
-void TankItem::stop()
-{
- setAction(0);
-}
-
-QVariant TankItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
-{
- if (change == ItemPositionChange && scene()) {
- QPointF requestedPosition = value.toPointF();
- QLineF collidedLine;
- QPointF nextPoint = tryMove(requestedPosition, &collidedLine);
- if (nextPoint != requestedPosition)
- emit collision(collidedLine);
- return nextPoint;
- } else {
- return QGraphicsItem::itemChange(change, value);
- }
-}
-
-
-void TankItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
-{
- QRectF brect = boundingRect();
-
- painter->setBrush(m_color);
- painter->setPen(Qt::black);
-
- // body
- painter->drawRect(brect.adjusted(0.0, 4.0, -2.0, -4.0));
-
- // cannon
- QRectF cannonBase = brect.adjusted(10.0, 6.0, -12.0, -6.0);
- painter->drawEllipse(cannonBase);
-
- painter->drawRect(QRectF(QPointF(cannonBase.center().x(), cannonBase.center().y() - 2.0),
- QPointF(brect.right(), cannonBase.center().y() + 2.0)));
-
- // left track
- painter->setBrush(QBrush(Qt::black, Qt::VerPattern));
- QRectF leftTrackRect = QRectF(brect.topLeft(), QPointF(brect.right() - 2.0, brect.top() + 4.0));
- painter->fillRect(leftTrackRect, Qt::darkYellow);
- painter->drawRect(leftTrackRect);
-
- // right track
- QRectF rightTrackRect = QRectF(QPointF(brect.left(), brect.bottom() - 4.0),
- QPointF(brect.right() - 2.0, brect.bottom()));
- painter->fillRect(rightTrackRect, Qt::darkYellow);
- painter->drawRect(rightTrackRect);
-
- if (!m_enabled) {
- painter->setPen(QPen(Qt::red, 5));
-
- painter->drawEllipse(brect);
-
- QPainterPath path;
- path.addEllipse(brect);
- painter->setClipPath(path);
- painter->drawLine(brect.topRight(), brect.bottomLeft());
- }
-}
-
-QRectF TankItem::boundingRect() const
-{
- return QRectF(-20.0, -10.0, 40.0, 20.0);
-}
-
-qreal TankItem::direction() const
-{
- return m_currentDirection;
-}
-
-void TankItem::setDirection(qreal newDirection)
-{
- int fullRotations = int(newDirection) / 360;
- newDirection -= fullRotations * 360.0;
-
- qreal diff = newDirection - m_currentDirection;
- m_currentDirection = newDirection;
- rotate(diff);
-}
-
-qreal TankItem::distanceToObstacle(QGraphicsItem **obstacle) const
-{
- qreal dist = sqrt(pow(scene()->sceneRect().width(), 2) + pow(scene()->sceneRect().height(), 2));
-
- qreal a = m_currentDirection * M_PI / 180.0;
-
- qreal yd = dist * sin(a);
- qreal xd = dist * sin(M_PI / 2.0 - a);
-
- QPointF requestedPosition = pos() + QPointF(xd, yd);
- QGraphicsItem *collidedItem = 0;
- QPointF nextPosition = tryMove(requestedPosition, 0, &collidedItem);
- if (collidedItem != 0) {
- if (obstacle != 0)
- *obstacle = collidedItem;
-
- QPointF d = nextPosition - pos();
- return sqrt(pow(d.x(), 2) + pow(d.y(), 2));
- } else {
- return 0.0;
- }
-}
-
-qreal TankItem::distanceToObstacle() const
-{
- return distanceToObstacle(0);
-}
-
diff --git a/examples/statemachine/tankgame/tankitem.h b/examples/statemachine/tankgame/tankitem.h
deleted file mode 100644
index a2f72de..0000000
--- a/examples/statemachine/tankgame/tankitem.h
+++ /dev/null
@@ -1,109 +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 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 TANKITEM_H
-#define TANKITEM_H
-
-#include "gameitem.h"
-
-#include <QColor>
-
-class Action;
-class TankItem: public GameItem
-{
- Q_OBJECT
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
- Q_PROPERTY(qreal direction READ direction WRITE turnTo)
- Q_PROPERTY(qreal distanceToObstacle READ distanceToObstacle)
-public:
- TankItem(QObject *parent = 0);
-
- void setColor(const QColor &color) { m_color = color; }
- QColor color() const { return m_color; }
-
- void idle(qreal elapsed);
- void setDirection(qreal newDirection);
-
- qreal speed() const { return 90.0; }
- qreal angularSpeed() const { return 90.0; }
-
- QRectF boundingRect() const;
-
- void hitByRocket();
-
- void setEnabled(bool b) { m_enabled = b; }
- bool enabled() const { return m_enabled; }
-
- qreal direction() const;
- qreal distanceToObstacle() const;
- qreal distanceToObstacle(QGraphicsItem **item) const;
-
-//! [0]
-signals:
- void tankSpotted(qreal direction, qreal distance);
- void collision(const QLineF &collidedLine);
- void actionCompleted();
- void cannonFired();
- void aboutToBeDestroyed();
-
-public slots:
- void moveForwards(qreal length = 10.0);
- void moveBackwards(qreal length = 10.0);
- void turn(qreal degrees = 30.0);
- void turnTo(qreal degrees = 0.0);
- void stop();
- void fireCannon();
-//! [0]
-
-protected:
- virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
- QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
-
-private:
- void setAction(Action *newAction);
-
- Action *m_currentAction;
- qreal m_currentDirection;
- QColor m_color;
- bool m_enabled;
-};
-
-#endif
diff --git a/examples/statemachine/tankgameplugins/random_ai/random_ai.pro b/examples/statemachine/tankgameplugins/random_ai/random_ai.pro
deleted file mode 100644
index 5bc0b26..0000000
--- a/examples/statemachine/tankgameplugins/random_ai/random_ai.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-INCLUDEPATH += ../..
-HEADERS = random_ai_plugin.h
-SOURCES = random_ai_plugin.cpp
-TARGET = $$qtLibraryTarget(random_ai)
-DESTDIR = ../../tankgame/plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS random_ai.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/random_ai \ No newline at end of file
diff --git a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp
deleted file mode 100644
index ddfd1c5..0000000
--- a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp
+++ /dev/null
@@ -1,78 +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 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 "random_ai_plugin.h"
-
-#include <QState>
-#include <QTime>
-#include <QtPlugin>
-
-QState *RandomAiPlugin::create(QState *parentState, QObject *tank)
-{
- qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
-
- QState *topLevel = new QState(parentState);
-
- QState *selectNextActionState = new SelectActionState(topLevel);
- topLevel->setInitialState(selectNextActionState);
-
- QState *fireState = new RandomDistanceState(topLevel);
- connect(fireState, SIGNAL(distanceComputed(qreal)), tank, SLOT(fireCannon()));
- selectNextActionState->addTransition(selectNextActionState, SIGNAL(fireSelected()), fireState);
-
- QState *moveForwardsState = new RandomDistanceState(topLevel);
- connect(moveForwardsState, SIGNAL(distanceComputed(qreal)), tank, SLOT(moveForwards(qreal)));
- selectNextActionState->addTransition(selectNextActionState, SIGNAL(moveForwardsSelected()), moveForwardsState);
-
- QState *moveBackwardsState = new RandomDistanceState(topLevel);
- connect(moveBackwardsState, SIGNAL(distanceComputed(qreal)), tank, SLOT(moveBackwards(qreal)));
- selectNextActionState->addTransition(selectNextActionState, SIGNAL(moveBackwardsSelected()), moveBackwardsState);
-
- QState *turnState = new RandomDistanceState(topLevel);
- connect(turnState, SIGNAL(distanceComputed(qreal)), tank, SLOT(turn(qreal)));
- selectNextActionState->addTransition(selectNextActionState, SIGNAL(turnSelected()), turnState);
-
- topLevel->addTransition(tank, SIGNAL(actionCompleted()), selectNextActionState);
-
- return topLevel;
-}
-
-Q_EXPORT_PLUGIN2(random_ai, RandomAiPlugin)
diff --git a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h
deleted file mode 100644
index 4c3fc0f..0000000
--- a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h
+++ /dev/null
@@ -1,105 +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 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 RANDOM_AI_PLUGIN_H
-#define RANDOM_AI_PLUGIN_H
-
-#include <QObject>
-#include <QState>
-
-#include <tankgame/plugin.h>
-
-class SelectActionState: public QState
-{
- Q_OBJECT
-public:
- SelectActionState(QState *parent = 0) : QState(parent)
- {
- }
-
-signals:
- void fireSelected();
- void moveForwardsSelected();
- void moveBackwardsSelected();
- void turnSelected();
-
-protected:
- void onEntry(QEvent *)
- {
- int rand = qrand() % 4;
- switch (rand) {
- case 0: emit fireSelected(); break;
- case 1: emit moveForwardsSelected(); break;
- case 2: emit moveBackwardsSelected(); break;
- case 3: emit turnSelected(); break;
- };
- }
-};
-
-class RandomDistanceState: public QState
-{
- Q_OBJECT
-public:
- RandomDistanceState(QState *parent = 0) : QState(parent)
- {
- }
-
-signals:
- void distanceComputed(qreal distance);
-
-protected:
- void onEntry(QEvent *)
- {
- emit distanceComputed(qreal(qrand() % 180));
- }
-};
-
-class RandomAiPlugin: public QObject, public Plugin
-{
- Q_OBJECT
- Q_INTERFACES(Plugin)
-public:
- RandomAiPlugin() { setObjectName("Random"); }
-
- virtual QState *create(QState *parentState, QObject *tank);
-};
-
-#endif // RANDOM_AI_PLUGIN_H
diff --git a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp
deleted file mode 100644
index 79d7d0c..0000000
--- a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp
+++ /dev/null
@@ -1,89 +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 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 "seek_ai.h"
-
-QState *SeekAi::create(QState *parentState, QObject *tank)
-{
- QState *topLevel = new QState(parentState);
- topLevel->setObjectName("topLevel");
-
- QState *seek = new QState(topLevel);
- seek->setObjectName("seek");
- topLevel->setInitialState(seek);
-
- QState *lookForNearestWall = new SearchState(tank, seek);
- lookForNearestWall->setObjectName("lookForNearestWall");
- seek->setInitialState(lookForNearestWall);
-
- QState *driveToFirstObstacle = new QState(seek);
- driveToFirstObstacle->setObjectName("driveToFirstObstacle");
- lookForNearestWall->addTransition(lookForNearestWall, SIGNAL(nearestObstacleStraightAhead()),
- driveToFirstObstacle);
-
- QState *drive = new QState(driveToFirstObstacle);
- drive->setObjectName("drive");
- driveToFirstObstacle->setInitialState(drive);
- connect(drive, SIGNAL(entered()), tank, SLOT(moveForwards()));
- connect(drive, SIGNAL(exited()), tank, SLOT(stop()));
-
- // Go in loop
- QState *finishedDriving = new QState(driveToFirstObstacle);
- finishedDriving->setObjectName("finishedDriving");
- drive->addTransition(tank, SIGNAL(actionCompleted()), finishedDriving);
- finishedDriving->addTransition(drive);
-
- QState *turnTo = new QState(seek);
- turnTo->setObjectName("turnTo");
- driveToFirstObstacle->addTransition(new CollisionTransition(tank, turnTo));
-
- turnTo->addTransition(tank, SIGNAL(actionCompleted()), driveToFirstObstacle);
-
- ChaseState *chase = new ChaseState(tank, topLevel);
- chase->setObjectName("chase");
- seek->addTransition(new TankSpottedTransition(tank, chase));
- chase->addTransition(chase, SIGNAL(finished()), driveToFirstObstacle);
- chase->addTransition(new TankSpottedTransition(tank, chase));
-
- return topLevel;
-}
-
-Q_EXPORT_PLUGIN2(seek_ai, SeekAi)
diff --git a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h
deleted file mode 100644
index 1bc5b26..0000000
--- a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h
+++ /dev/null
@@ -1,249 +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 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 SEEK_AI_H
-#define SEEK_AI_H
-
-#include <tankgame/plugin.h>
-
-#include <QState>
-#include <QFinalState>
-#include <QSignalTransition>
-#include <QSignalEvent>
-#include <QVariant>
-#include <QLineF>
-#include <QDebug>
-
-class SearchState: public QState
-{
- Q_OBJECT
-public:
- SearchState(QObject *tank, QState *parentState = 0)
- : QState(parentState),
- m_tank(tank),
- m_distanceToTurn(360.0),
- m_nearestDistance(-1.0),
- m_directionOfNearestObstacle(0.0)
- {
- }
-
-public slots:
- void turnAlittle()
- {
- qreal dist = m_tank->property("distanceToObstacle").toDouble();
-
- if (m_nearestDistance < 0.0 || dist < m_nearestDistance) {
- m_nearestDistance = dist;
- m_directionOfNearestObstacle = m_tank->property("direction").toDouble();
- }
-
- m_distanceToTurn -= 10.0;
- if (m_distanceToTurn < 0.0) {
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(turnAlittle()));
- connect(m_tank, SIGNAL(actionCompleted()), this, SIGNAL(nearestObstacleStraightAhead()));
- m_tank->setProperty("direction", m_directionOfNearestObstacle);
- }
-
- qreal currentDirection = m_tank->property("direction").toDouble();
- m_tank->setProperty("direction", currentDirection + 10.0);
- }
-
-signals:
- void nearestObstacleStraightAhead();
-
-protected:
- void onEntry(QEvent *)
- {
- connect(m_tank, SIGNAL(actionCompleted()), this, SLOT(turnAlittle()));
- turnAlittle();
- }
-
- void onExit(QEvent *)
- {
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(turnAlittle()));
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(nearestObstacleStraightAhead()));
- }
-
-private:
- QObject *m_tank;
-
- qreal m_distanceToTurn;
- qreal m_nearestDistance;
- qreal m_directionOfNearestObstacle;
-};
-
-class CollisionTransition: public QSignalTransition
-{
-public:
- CollisionTransition(QObject *tank, QState *turnTo)
- : QSignalTransition(tank, SIGNAL(collision(QLineF))),
- m_tank(tank),
- m_turnTo(turnTo)
- {
- setTargetState(turnTo);
- }
-
-protected:
- bool eventTest(QEvent *event)
- {
- bool b = QSignalTransition::eventTest(event);
- if (b) {
- QSignalEvent *se = static_cast<QSignalEvent *>(event);
- m_lastLine = se->arguments().at(0).toLineF();
- }
- return b;
- }
-
- void onTransition(QEvent *)
- {
- qreal angleOfWall = m_lastLine.angle();
-
- qreal newDirection;
- if (qrand() % 2 == 0)
- newDirection = angleOfWall;
- else
- newDirection = angleOfWall - 180.0;
-
- m_turnTo->assignProperty(m_tank, "direction", newDirection);
- }
-
-private:
- QLineF m_lastLine;
- QObject *m_tank;
- QState *m_turnTo;
-};
-
-class ChaseState: public QState
-{
- class GoToLocationState: public QState
- {
- public:
- GoToLocationState(QObject *tank, QState *parentState = 0)
- : QState(parentState), m_tank(tank), m_distance(0.0)
- {
- }
-
- void setDistance(qreal distance) { m_distance = distance; }
-
- protected:
- void onEntry()
- {
- QMetaObject::invokeMethod(m_tank, "moveForwards", Q_ARG(qreal, m_distance));
- }
-
- private:
- QObject *m_tank;
- qreal m_distance;
- };
-
-public:
- ChaseState(QObject *tank, QState *parentState = 0) : QState(parentState), m_tank(tank)
- {
- QState *fireCannon = new QState(this);
- fireCannon->setObjectName("fireCannon");
- connect(fireCannon, SIGNAL(entered()), tank, SLOT(fireCannon()));
- setInitialState(fireCannon);
-
- m_goToLocation = new GoToLocationState(tank, this);
- m_goToLocation->setObjectName("goToLocation");
- fireCannon->addTransition(tank, SIGNAL(actionCompleted()), m_goToLocation);
-
- m_turnToDirection = new QState(this);
- m_turnToDirection->setObjectName("turnToDirection");
- m_goToLocation->addTransition(tank, SIGNAL(actionCompleted()), m_turnToDirection);
-
- QFinalState *finalState = new QFinalState(this);
- finalState->setObjectName("finalState");
- m_turnToDirection->addTransition(tank, SIGNAL(actionCompleted()), finalState);
- }
-
- void setDirection(qreal direction)
- {
- m_turnToDirection->assignProperty(m_tank, "direction", direction);
- }
-
- void setDistance(qreal distance)
- {
- m_goToLocation->setDistance(distance);
- }
-
-private:
- QObject *m_tank;
- GoToLocationState *m_goToLocation;
- QState *m_turnToDirection;
-
-};
-
-class TankSpottedTransition: public QSignalTransition
-{
-public:
- TankSpottedTransition(QObject *tank, ChaseState *target) : QSignalTransition(tank, SIGNAL(tankSpotted(qreal,qreal))), m_chase(target)
- {
- setTargetState(target);
- }
-
-protected:
- bool eventTest(QEvent *event)
- {
- bool b = QSignalTransition::eventTest(event);
- if (b) {
- QSignalEvent *se = static_cast<QSignalEvent *>(event);
- m_chase->setDirection(se->arguments().at(0).toDouble());
- m_chase->setDistance(se->arguments().at(1).toDouble());
- }
- return b;
- }
-
-private:
- ChaseState *m_chase;
-};
-
-class SeekAi: public QObject, public Plugin
-{
- Q_OBJECT
- Q_INTERFACES(Plugin)
-public:
- SeekAi() { setObjectName("Seek and destroy"); }
-
- virtual QState *create(QState *parentState, QObject *tank);
-};
-
-#endif
diff --git a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro
deleted file mode 100644
index 0d8bf2e..0000000
--- a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-INCLUDEPATH += ../..
-HEADERS = seek_ai.h
-SOURCES = seek_ai.cpp
-TARGET = $$qtLibraryTarget(seek_ai)
-DESTDIR = ../../tankgame/plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS seek_ai.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/seek_ai \ No newline at end of file
diff --git a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp
deleted file mode 100644
index 4e71285..0000000
--- a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp
+++ /dev/null
@@ -1,70 +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 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 "spin_ai.h"
-
-#include <QtPlugin>
-
-QState *SpinAi::create(QState *parentState, QObject *tank)
-{
- QState *topLevel = new QState(parentState);
- QState *spinState = new SpinState(tank, topLevel);
- topLevel->setInitialState(spinState);
-
- // When tank is spotted, fire two times and go back to spin state
- QState *fireState = new QState(topLevel);
-
- QState *fireOnce = new QState(fireState);
- fireState->setInitialState(fireOnce);
- connect(fireOnce, SIGNAL(entered()), tank, SLOT(fireCannon()));
-
- QState *fireTwice = new QState(fireState);
- connect(fireTwice, SIGNAL(entered()), tank, SLOT(fireCannon()));
-
- fireOnce->addTransition(tank, SIGNAL(actionCompleted()), fireTwice);
- fireTwice->addTransition(tank, SIGNAL(actionCompleted()), spinState);
-
- spinState->addTransition(tank, SIGNAL(tankSpotted(qreal,qreal)), fireState);
-
- return topLevel;
-}
-
-Q_EXPORT_PLUGIN2(spin_ai, SpinAi)
diff --git a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h
deleted file mode 100644
index a97024d..0000000
--- a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h
+++ /dev/null
@@ -1,92 +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 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 SPIN_AI_H
-#define SPIN_AI_H
-
-#include <tankgame/plugin.h>
-
-#include <QObject>
-#include <QState>
-#include <QVariant>
-
-class SpinState: public QState
-{
- Q_OBJECT
-public:
- SpinState(QObject *tank, QState *parent) : QState(parent), m_tank(tank)
- {
- }
-
-public slots:
- void spin()
- {
- m_tank->setProperty("direction", m_tank->property("direction").toDouble() + 90.0);
- }
-
-protected:
- void onEntry(QEvent *)
- {
- connect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
- spin();
- }
-
- void onExit(QEvent *)
- {
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
- }
-
-private:
- QObject *m_tank;
-
-};
-
-class SpinAi: public QObject, public Plugin
-{
- Q_OBJECT
- Q_INTERFACES(Plugin)
-public:
- SpinAi() { setObjectName("Spin and destroy"); }
-
- virtual QState *create(QState *parentState, QObject *tank);
-};
-
-#endif
diff --git a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro
deleted file mode 100644
index 8ab4da0..0000000
--- a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-INCLUDEPATH += ../..
-HEADERS = spin_ai.h
-SOURCES = spin_ai.cpp
-TARGET = $$qtLibraryTarget(spin_ai)
-DESTDIR = ../../tankgame/plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS spin_ai.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/spin_ai \ No newline at end of file
diff --git a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp
deleted file mode 100644
index 12a9656..0000000
--- a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp
+++ /dev/null
@@ -1,70 +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 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 "spin_ai_with_error.h"
-
-#include <QtPlugin>
-
-QState *SpinAiWithError::create(QState *parentState, QObject *tank)
-{
- QState *topLevel = new QState(parentState);
- QState *spinState = new SpinState(tank, topLevel);
- topLevel->setInitialState(spinState);
-
- // When tank is spotted, fire two times and go back to spin state
- // (no initial state set for fireState will lead to run-time error in machine)
- QState *fireState = new QState(topLevel);
-
- QState *fireOnce = new QState(fireState);
- connect(fireOnce, SIGNAL(entered()), tank, SLOT(fireCannon()));
-
- QState *fireTwice = new QState(fireState);
- connect(fireTwice, SIGNAL(entered()), tank, SLOT(fireCannon()));
-
- fireOnce->addTransition(tank, SIGNAL(actionCompleted()), fireTwice);
- fireTwice->addTransition(tank, SIGNAL(actionCompleted()), spinState);
-
- spinState->addTransition(tank, SIGNAL(tankSpotted(qreal,qreal)), fireState);
-
- return topLevel;
-}
-
-Q_EXPORT_PLUGIN2(spin_ai_with_error, SpinAiWithError)
diff --git a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h
deleted file mode 100644
index f35da26..0000000
--- a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h
+++ /dev/null
@@ -1,92 +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 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 SPIN_AI_WITH_ERROR_H
-#define SPIN_AI_WITH_ERROR_H
-
-#include <tankgame/plugin.h>
-
-#include <QObject>
-#include <QState>
-#include <QVariant>
-
-class SpinState: public QState
-{
- Q_OBJECT
-public:
- SpinState(QObject *tank, QState *parent) : QState(parent), m_tank(tank)
- {
- }
-
-public slots:
- void spin()
- {
- m_tank->setProperty("direction", m_tank->property("direction").toDouble() + 90.0);
- }
-
-protected:
- void onEntry(QEvent *)
- {
- connect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
- spin();
- }
-
- void onExit(QEvent *)
- {
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
- }
-
-private:
- QObject *m_tank;
-
-};
-
-class SpinAiWithError: public QObject, public Plugin
-{
- Q_OBJECT
- Q_INTERFACES(Plugin)
-public:
- SpinAiWithError() { setObjectName("Spin and destroy with runtime error in state machine"); }
-
- virtual QState *create(QState *parentState, QObject *tank);
-};
-
-#endif
diff --git a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro
deleted file mode 100644
index 124cf98..0000000
--- a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-INCLUDEPATH += ../..
-HEADERS = spin_ai_with_error.h
-SOURCES = spin_ai_with_error.cpp
-TARGET = $$qtLibraryTarget(spin_ai_with_error)
-DESTDIR = ../../tankgame/plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS spin_ai_with_error.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/spin_ai_with_error \ No newline at end of file
diff --git a/examples/statemachine/tankgameplugins/tankgameplugins.pro b/examples/statemachine/tankgameplugins/tankgameplugins.pro
deleted file mode 100644
index a098e03..0000000
--- a/examples/statemachine/tankgameplugins/tankgameplugins.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = random_ai \
- spin_ai_with_error \
- spin_ai \
- seek_ai
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS tankgameplugins.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins
-INSTALLS += target sources
diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp
index 34a5322..d907394 100644
--- a/qmake/generators/makefiledeps.cpp
+++ b/qmake/generators/makefiledeps.cpp
@@ -378,17 +378,19 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
files_changed = true;
file->dep_checked = true;
+ const QMakeLocalFileName sourceFile = fixPathForFile(file->file, true);
+
struct stat fst;
char *buffer = 0;
int buffer_len = 0;
{
int fd;
#if defined(_MSC_VER) && _MSC_VER >= 1400
- if (_sopen_s(&fd, fixPathForFile(file->file, true).local().toLatin1().constData(),
+ if (_sopen_s(&fd, sourceFile.local().toLatin1().constData(),
_O_RDONLY, _SH_DENYNO, _S_IREAD) != 0)
fd = -1;
#else
- fd = open(fixPathForFile(file->file, true).local().toLatin1().constData(), O_RDONLY);
+ fd = open(sourceFile.local().toLatin1().constData(), O_RDONLY);
#endif
if(fd == -1 || fstat(fd, &fst) || S_ISDIR(fst.st_mode))
return false;
@@ -623,12 +625,8 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
QMakeLocalFileName lfn(inc);
if(QDir::isRelativePath(lfn.real())) {
if(try_local) {
- QString dir = findFileInfo(file->file).path();
- if(QDir::isRelativePath(dir))
- dir.prepend(qmake_getpwd() + "/");
- if(!dir.endsWith("/"))
- dir += "/";
- QMakeLocalFileName f(dir + lfn.local());
+ QDir sourceDir = findFileInfo(sourceFile).dir();
+ QMakeLocalFileName f(sourceDir.absoluteFilePath(lfn.local()));
if(findFileInfo(f).exists()) {
lfn = fixPathForFile(f);
exists = true;
diff --git a/qmake/qmake.pro b/qmake/qmake.pro
index 594e698..acf7718 100644
--- a/qmake/qmake.pro
+++ b/qmake/qmake.pro
@@ -15,6 +15,7 @@ MOC_DIR = .
VPATH += $$QT_SOURCE_TREE/src/corelib/global \
$$QT_SOURCE_TREE/src/corelib/tools \
$$QT_SOURCE_TREE/src/corelib/kernel \
+ $$QT_SOURCE_TREE/src/corelib/codecs \
$$QT_SOURCE_TREE/src/corelib/plugin \
$$QT_SOURCE_TREE/src/corelib/io \
$$QT_SOURCE_TREE/src/corelib/xml \
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
index 34da644..6c5860c 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp
@@ -617,6 +617,8 @@ qreal QWebView::textSizeMultiplier() const
These hints are used to initialize QPainter before painting the web page.
QPainter::TextAntialiasing is enabled by default.
+
+ \sa QPainter::renderHints()
*/
QPainter::RenderHints QWebView::renderHints() const
{
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h
index 5c2c7a0..0dab925 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h
@@ -106,7 +106,7 @@ public:
QPainter::RenderHints renderHints() const;
void setRenderHints(QPainter::RenderHints hints);
- void setRenderHint(QPainter::RenderHint hint, bool enabled);
+ void setRenderHint(QPainter::RenderHint hint, bool enabled = true);
bool findText(const QString &subString, QWebPage::FindFlags options = 0);
diff --git a/src/corelib/concurrent/qtconcurrentthreadengine.h b/src/corelib/concurrent/qtconcurrentthreadengine.h
index 1f359fc..2f610de 100644
--- a/src/corelib/concurrent/qtconcurrentthreadengine.h
+++ b/src/corelib/concurrent/qtconcurrentthreadengine.h
@@ -238,9 +238,11 @@ protected:
template <typename T>
class ThreadEngineStarter : public ThreadEngineStarterBase<T>
{
+ typedef ThreadEngineStarterBase<T> Base;
+ typedef ThreadEngine<T> TypedThreadEngine;
public:
- ThreadEngineStarter(ThreadEngine<T> *threadEngine)
- :ThreadEngineStarterBase<T>(threadEngine) {}
+ ThreadEngineStarter(TypedThreadEngine *eng)
+ : Base(eng) { }
T startBlocking()
{
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index a767c31..5e5ce49 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -672,9 +672,7 @@ namespace QT_NAMESPACE {}
in which case _BOOL is not defined
this is the default in 4.2 compatibility mode triggered by -compat=4 */
# if __SUNPRO_CC >= 0x500
-# if __SUNPRO_CC < 0x570
-# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
-# endif
+# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
/* see http://developers.sun.com/sunstudio/support/Ccompare.html */
# if __SUNPRO_CC >= 0x590
# define Q_ALIGNOF(type) __alignof__(type)
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index c5b0fc7..28c1d9c 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -47,6 +47,10 @@
#include "qeventdispatcher_unix_p.h" // for the timeval operators
+#ifdef Q_OS_MAC
+#include <mach/mach_time.h>
+#endif
+
#if !defined(QT_NO_CLOCK_MONOTONIC)
# if defined(QT_BOOTSTRAPPED)
# define QT_NO_CLOCK_MONOTONIC
@@ -55,37 +59,72 @@
QT_BEGIN_NAMESPACE
-static inline timeval gettime()
+bool qt_gettime_is_monotonic()
{
- timeval tv;
-#ifndef QT_NO_CLOCK_MONOTONIC
- // use the monotonic clock
- static volatile bool monotonicClockDisabled = false;
- struct timespec ts;
- if (!monotonicClockDisabled) {
- if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) {
- monotonicClockDisabled = true;
- } else {
- tv.tv_sec = ts.tv_sec;
- tv.tv_usec = ts.tv_nsec / 1000;
- return tv;
- }
+#if (_POSIX_MONOTONIC_CLOCK-0 > 0) || defined(Q_OS_MAC)
+ return true;
+#else
+ static int returnValue = 0;
+
+ if (returnValue == 0) {
+# if (_POSIX_MONOTONIC_CLOCK-0 < 0)
+ returnValue = -1;
+# elif (_POSIX_MONOTONIC_CLOCK == 0)
+ // detect if the system support monotonic timers
+ long x = sysconf(_SC_MONOTONIC_CLOCK);
+ returnValue = (x >= 200112L) ? 1 : -1;
+# endif
}
+
+ return returnValue != -1;
#endif
+}
+
+timeval qt_gettime()
+{
+ timeval tv;
+#if defined(Q_OS_MAC)
+ static mach_timebase_info_data_t info = {0,0};
+ if (info.denom == 0)
+ mach_timebase_info(&info);
+
+ uint64_t cpu_time = mach_absolute_time();
+ uint64_t nsecs = cpu_time * (info.numer / info.denom);
+ tv.tv_sec = nsecs / 1000000000ull;
+ tv.tv_usec = (nsecs / 1000) - (tv.tv_sec * 1000000);
+ return tv;
+#elif (_POSIX_MONOTONIC_CLOCK-0 > 0)
+ timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ tv.tv_sec = ts.tv_sec;
+ tv.tv_usec = ts.tv_nsec / 1000;
+ return tv;
+#else
+# if !defined(QT_NO_CLOCK_MONOTONIC) && !defined(QT_BOOTSTRAPPED)
+ if (qt_gettime_is_monotonic()) {
+ timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ tv.tv_sec = ts.tv_sec;
+ tv.tv_usec = ts.tv_nsec / 1000;
+ return tv;
+ }
+# endif
// use gettimeofday
::gettimeofday(&tv, 0);
return tv;
+#endif
}
static inline bool time_update(struct timeval *tv, const struct timeval &start,
const struct timeval &timeout)
{
- struct timeval now = gettime();
- if (now < start) {
- // clock reset, give up
+ if (!qt_gettime_is_monotonic()) {
+ // we cannot recalculate the timeout without a monotonic clock as the time may have changed
return false;
}
+ // clock source is monotonic, so we can recalculate how much timeout is left
+ struct timeval now = qt_gettime();
*tv = timeout + start - now;
return true;
}
@@ -100,7 +139,7 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
return ret;
}
- timeval start = gettime();
+ timeval start = qt_gettime();
timeval timeout = *orig_timeout;
// loop and recalculate the timeout as needed
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index 565c895..28bc34a 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -270,6 +270,8 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options)
return ret;
}
+bool qt_gettime_is_monotonic();
+timeval qt_gettime();
Q_CORE_EXPORT int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
const struct timeval *tv);
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index 288b381..c3979e8 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -59,33 +59,10 @@
# include <sys/times.h>
#endif
-#ifdef Q_OS_MAC
-#include <mach/mach_time.h>
-#endif
-
QT_BEGIN_NAMESPACE
Q_CORE_EXPORT bool qt_disable_lowpriority_timers=false;
-// check for _POSIX_MONOTONIC_CLOCK support
-static bool supportsMonotonicClock()
-{
- bool returnValue;
-
-#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)
- returnValue = false;
-# if (_POSIX_MONOTONIC_CLOCK == 0)
- // detect if the system support monotonic timers
- long x = sysconf(_SC_MONOTONIC_CLOCK);
- returnValue = x >= 200112L;
-# endif
-#else
- returnValue = true;
-#endif
-
- return returnValue;
-}
-
/*****************************************************************************
UNIX signal handling
*****************************************************************************/
@@ -281,12 +258,11 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
*/
QTimerInfoList::QTimerInfoList()
- : useMonotonicTimers(supportsMonotonicClock())
{
- getTime(currentTime);
+ currentTime = qt_gettime();
#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)
- if (!useMonotonicTimers) {
+ if (!qt_gettime_is_monotonic()) {
// not using monotonic timers, initialize the timeChanged() machinery
previousTime = currentTime;
@@ -309,8 +285,7 @@ QTimerInfoList::QTimerInfoList()
timeval QTimerInfoList::updateCurrentTime()
{
- getTime(currentTime);
- return currentTime;
+ return (currentTime = qt_gettime());
}
#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED)
@@ -364,38 +339,9 @@ bool QTimerInfoList::timeChanged(timeval *delta)
return elapsedTimeTicks < ((qAbs(*delta) - tickGranularity) * 10);
}
-void QTimerInfoList::getTime(timeval &t)
-{
-#if !defined(QT_NO_CLOCK_MONOTONIC) && !defined(QT_BOOTSTRAPPED)
- if (useMonotonicTimers) {
- timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- t.tv_sec = ts.tv_sec;
- t.tv_usec = ts.tv_nsec / 1000;
- return;
- }
-#endif
-
- gettimeofday(&t, 0);
- // NTP-related fix
- while (t.tv_usec >= 1000000l) {
- t.tv_usec -= 1000000l;
- ++t.tv_sec;
- }
- while (t.tv_usec < 0l) {
- if (t.tv_sec > 0l) {
- t.tv_usec += 1000000l;
- --t.tv_sec;
- } else {
- t.tv_usec = 0l;
- break;
- }
- }
-}
-
void QTimerInfoList::repairTimersIfNeeded()
{
- if (useMonotonicTimers)
+ if (qt_gettime_is_monotonic())
return;
timeval delta;
if (timeChanged(&delta))
@@ -404,25 +350,6 @@ void QTimerInfoList::repairTimersIfNeeded()
#else // !(_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(QT_BOOTSTRAPPED)
-void QTimerInfoList::getTime(timeval &t)
-{
-#if defined(Q_OS_MAC)
- static mach_timebase_info_data_t info = {0,0};
- if (info.denom == 0)
- mach_timebase_info(&info);
-
- uint64_t cpu_time = mach_absolute_time();
- uint64_t nsecs = cpu_time * (info.numer / info.denom);
- t.tv_sec = nsecs * 1e-9;
- t.tv_usec = nsecs * 1e-3 - (t.tv_sec * 1e6);
-#else
- timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- t.tv_sec = ts.tv_sec;
- t.tv_usec = ts.tv_nsec / 1000;
-#endif
-}
-
void QTimerInfoList::repairTimersIfNeeded()
{
}
@@ -651,25 +578,7 @@ QEventDispatcherUNIX::~QEventDispatcherUNIX()
int QEventDispatcherUNIX::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
timeval *timeout)
{
- Q_D(QEventDispatcherUNIX);
- if (timeout && d->timerList.useMonotonicTimers) {
- // handle the case where select returns with a timeout, too
- // soon.
- timeval tvStart = d->timerList.currentTime;
- timeval tvCurrent = tvStart;
- timeval originalTimeout = *timeout;
-
- int nsel;
- do {
- timeval tvRest = originalTimeout + tvStart - tvCurrent;
- nsel = ::select(nfds, readfds, writefds, exceptfds, &tvRest);
- d->timerList.getTime(tvCurrent);
- } while (nsel == 0 && (tvCurrent - tvStart) < originalTimeout);
-
- return nsel;
- }
-
- return ::select(nfds, readfds, writefds, exceptfds, timeout);
+ return ::qt_safe_select(nfds, readfds, writefds, exceptfds, timeout);
}
/*!
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index 88d645e..fedbccf 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -142,10 +142,6 @@ class QTimerInfoList : public QList<QTimerInfo*>
public:
QTimerInfoList();
- const bool useMonotonicTimers;
-
- void getTime(timeval &t);
-
timeval currentTime;
timeval updateCurrentTime();
diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h
index 697b6ff..4bad24c 100644
--- a/src/corelib/tools/qbytearraymatcher.h
+++ b/src/corelib/tools/qbytearraymatcher.h
@@ -81,13 +81,14 @@ private:
// explicitely allow anonymous unions for RVCT to prevent compiler warnings
#pragma anon_unions
#endif
+ struct Data {
+ uchar q_skiptable[256];
+ const uchar *p;
+ int l;
+ };
union {
uint dummy[256];
- struct {
- uchar q_skiptable[256];
- const uchar *p;
- int l;
- } p;
+ Data p;
};
};
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index c4ff7c6..5b769ab 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -2465,10 +2465,10 @@ void QGraphicsItem::setHandlesChildEvents(bool enabled)
}
/*!
- Returns true if this item has keyboard input focus; otherwise, returns
- false.
+ Returns true if this item or its \l{focusProxy()}{focus proxy} has keyboard
+ input focus; otherwise, returns false.
- \sa QGraphicsScene::focusItem(), setFocus(), QGraphicsScene::setFocusItem()
+ \sa focusItem(), setFocus(), QGraphicsScene::setFocusItem()
*/
bool QGraphicsItem::hasFocus() const
{
@@ -2479,8 +2479,8 @@ bool QGraphicsItem::hasFocus() const
/*!
Gives keyboard input focus to this item. The \a focusReason argument will
- be passed into any focus event generated by this function; it is used to
- give an explanation of what caused the item to get focus.
+ be passed into any \l{QFocusEvent}{focus event} generated by this function;
+ it is used to give an explanation of what caused the item to get focus.
Only enabled items that set the ItemIsFocusable flag can accept keyboard
focus.
@@ -2489,12 +2489,12 @@ bool QGraphicsItem::hasFocus() const
gain immediate input focus. However, it will be registered as the preferred
focus item for its subtree of items, should it later become visible.
- As a result of calling this function, this item will receive a focus in
- event with \a focusReason. If another item already has focus, that item
- will first receive a focus out event indicating that it has lost input
- focus.
+ As a result of calling this function, this item will receive a
+ \l{focusInEvent()}{focus in event} with \a focusReason. If another item
+ already has focus, that item will first receive a \l{focusOutEvent()}
+ {focus out event} indicating that it has lost input focus.
- \sa clearFocus(), hasFocus(), focusItem()
+ \sa clearFocus(), hasFocus(), focusItem(), focusProxy()
*/
void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
{
@@ -2527,13 +2527,13 @@ void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
/*!
Takes keyboard input focus from the item.
- If it has focus, a focus out event is sent to this item to tell it that it
- is about to lose the focus.
+ If it has focus, a \l{focusOutEvent()}{focus out event} is sent to this item
+ to tell it that it is about to lose the focus.
Only items that set the ItemIsFocusable flag, or widgets that set an
appropriate focus policy, can accept keyboard focus.
- \sa setFocus(), QGraphicsWidget::focusPolicy
+ \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy
*/
void QGraphicsItem::clearFocus()
{
@@ -2550,10 +2550,10 @@ void QGraphicsItem::clearFocus()
/*!
\since 4.6
- Returns this item's focus proxy, or 0 if the item
- does not have any focus proxy.
+ Returns this item's focus proxy, or 0 if this item has no
+ focus proxy.
- \sa setFocusProxy()
+ \sa setFocusProxy(), ItemAutoDetectsFocusProxy, setFocus(), hasFocus()
*/
QGraphicsItem *QGraphicsItem::focusProxy() const
{
@@ -2574,7 +2574,10 @@ QGraphicsItem *QGraphicsItem::focusProxy() const
such case, keyboard input will be handled by the outermost
focus proxy.
- \sa focusProxy()
+ The focus proxy \a item must belong to the same scene as
+ this item.
+
+ \sa focusProxy(), ItemAutoDetectsFocusProxy, setFocus(), hasFocus()
*/
void QGraphicsItem::setFocusProxy(QGraphicsItem *item)
{
@@ -2608,11 +2611,13 @@ void QGraphicsItem::setFocusProxy(QGraphicsItem *item)
}
/*!
+ \since 4.6
+
If this item, a child or descendant of this item currently has input
focus, this function will return a pointer to that item. If
no descendant has input focus, 0 is returned.
- \sa QWidget::focusWidget()
+ \sa hasFocus(), setFocus(), QWidget::focusWidget()
*/
QGraphicsItem *QGraphicsItem::focusItem() const
{
@@ -6102,7 +6107,7 @@ void QGraphicsItem::dropEvent(QGraphicsSceneDragDropEvent *event)
focus in events for this item. The default implementation calls
ensureVisible().
- \sa focusOutEvent(), sceneEvent()
+ \sa focusOutEvent(), sceneEvent(), setFocus()
*/
void QGraphicsItem::focusInEvent(QFocusEvent *event)
{
@@ -6113,7 +6118,7 @@ void QGraphicsItem::focusInEvent(QFocusEvent *event)
This event handler, for event \a event, can be reimplemented to receive
focus out events for this item. The default implementation does nothing.
- \sa focusInEvent(), sceneEvent()
+ \sa focusInEvent(), sceneEvent(), setFocus()
*/
void QGraphicsItem::focusOutEvent(QFocusEvent *event)
{
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp
index 6bca504..78c3396 100644
--- a/src/gui/image/qbitmap.cpp
+++ b/src/gui/image/qbitmap.cpp
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
0 for black and 1 for white.
The QBitmap class provides the transformed() function returning a
- transformed copy of the bitmap; use the QMatrix argument to
+ transformed copy of the bitmap; use the QTransform argument to
translate, scale, shear, and rotate the bitmap. In addition,
QBitmap provides the static fromData() function which returns a
bitmap constructed from the given \c uchar data, and the static
@@ -318,6 +318,7 @@ QBitmap QBitmap::transformed(const QTransform &matrix) const
/*!
\overload
+ \obsolete
This convenience function converts the \a matrix to a QTransform
and calls the overloaded function.
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 3bc348c..57c9117 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -200,6 +200,7 @@ extern "C" {
composingText = new QString();
composing = false;
sendKeyEvents = true;
+ inKeyDown = false;
currentCustomTypes = 0;
[self setHidden:YES];
return self;
@@ -983,6 +984,7 @@ extern "C" {
- (void)keyDown:(NSEvent *)theEvent
{
+ inKeyDown = true;
sendKeyEvents = true;
QWidget *widgetToGetKey = qwidget;
@@ -1002,6 +1004,7 @@ extern "C" {
if (!keyOK && !sendToPopup)
[super keyDown:theEvent];
}
+ inKeyDown = false;
}
@@ -1039,14 +1042,23 @@ extern "C" {
- (void) insertText:(id)aString
{
- if ([aString length] && composing) {
- // Send the commit string to the widget.
- QString commitText;
+ QString commitText;
+ if ([aString length]) {
if ([aString isKindOfClass:[NSAttributedString class]]) {
- commitText = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
+ commitText = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
} else {
commitText = QCFString::toQString(reinterpret_cast<CFStringRef>(aString));
};
+ }
+
+ if ([aString length] && !inKeyDown) {
+ // Handle the case where insertText is called from somewhere else than the keyDown
+ // implementation, for example when inserting text from the character palette.
+ QInputMethodEvent e;
+ e.setCommitString(commitText);
+ qt_sendSpontaneousEvent(qwidget, &e);
+ } else if ([aString length] && composing) {
+ // Send the commit string to the widget.
composing = false;
sendKeyEvents = false;
QInputMethodEvent e;
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 4762b17..932c6ca 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -85,6 +85,7 @@ Q_GUI_EXPORT
bool composing;
int composingLength;
bool sendKeyEvents;
+ bool inKeyDown;
QString *composingText;
QStringList *currentCustomTypes;
NSInteger dragEnterSequence;
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index a6a87b7..2a91181 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -675,8 +675,9 @@ QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
The QWidget::setEnable() function can be used to enable or disable
mouse and keyboard events for a widget.
- The event handlers QWidget::keyPressEvent() and
- QWidget::keyReleaseEvent() receive key events.
+ The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
+ QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
+ receive key events.
\sa QFocusEvent, QWidget::grabKeyboard()
*/
@@ -992,8 +993,9 @@ bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
The reason for a particular focus event is returned by reason()
in the appropriate event handler.
- The event handlers QWidget::focusInEvent() and
- QWidget::focusOutEvent() receive focus events.
+ The event handlers QWidget::focusInEvent(),
+ QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
+ QGraphicsItem::focusOutEvent() receive focus events.
\sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
*/
@@ -1611,12 +1613,14 @@ Qt::ButtonState QContextMenuEvent::state() const
string is controlled by the widget only). The AttributeType enum
describes the different attributes that can be set.
- A class implementing QWidget::inputMethodEvent() should at least
- understand and honor the \l TextFormat and \l Cursor attributes.
+ A class implementing QWidget::inputMethodEvent() or
+ QGraphicsItem::inputMethodEvent() should at least understand and
+ honor the \l TextFormat and \l Cursor attributes.
Since input methods need to be able to query certain properties
- from the widget, the widget must also implement
- QWidget::inputMethodQuery().
+ from the widget or graphics item, subclasses must also implement
+ QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
+ respectively.
When receiving an input method event, the text widget has to performs the
following steps:
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 3d4164a..1c4177e 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -1069,6 +1069,17 @@ void qt_mac_updateContentBorderMetricts(void * /*OSWindowRef */window, const ::H
#endif
}
+void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show)
+{
+#if QT_MAC_USE_COCOA
+ QMacCocoaAutoReleasePool pool;
+ OSWindowRef theWindow = static_cast<OSWindowRef>(window);
+ NSToolbar *macToolbar = [theWindow toolbar];
+ if (macToolbar)
+ [macToolbar setShowsBaselineSeparator: show];
+#endif
+}
+
QStringList qt_mac_NSArrayToQStringList(void *nsarray)
{
QStringList result;
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
index 2cc7dee..741edd6 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h
+++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
@@ -125,6 +125,7 @@ void macWindowSetHasShadow( void * /*OSWindowRef*/ window, bool hasShadow );
void macWindowFlush(void * /*OSWindowRef*/ window);
void macSendToolbarChangeEvent(QWidget *widget);
void qt_mac_updateContentBorderMetricts(void * /*OSWindowRef */window, const ::HIContentBorderMetrics &metrics);
+void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show);
void * /*NSImage */qt_mac_create_nsimage(const QPixmap &pm);
void qt_mac_update_mouseTracking(QWidget *widget);
OSStatus qt_mac_drawCGImage(CGContextRef cg, const CGRect *inbounds, CGImageRef);
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index bc08235..39f4d95 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE
\class QMatrix
\brief The QMatrix class specifies 2D transformations of a
coordinate system.
+ \obsolete
\ingroup multimedia
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 1b128bd..76e2fcc 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1020,7 +1020,7 @@ void QPainterPrivate::updateState(QPainterState *newState)
\o brushOrigin() defines the origin of the tiled brushes, normally
the origin of widget's background.
- \o viewport(), window(), worldMatrix() make up the painter's coordinate
+ \o viewport(), window(), worldTransform() make up the painter's coordinate
transformation system. For more information, see the \l
{Coordinate Transformations} section and the \l {The Coordinate
System} documentation.
@@ -1227,15 +1227,15 @@ void QPainterPrivate::updateState(QPainterState *newState)
\endtable
All the tranformation operations operate on the transformation
- worldMatrix(). A matrix transforms a point in the plane to another
+ worldTransform(). A matrix transforms a point in the plane to another
point. For more information about the transformation matrix, see
- the \l {The Coordinate System} and QMatrix documentation.
+ the \l {The Coordinate System} and QTransform documentation.
- The setWorldMatrix() function can replace or add to the currently
- set worldMatrix(). The resetMatrix() function resets any
+ The setWorldTransform() function can replace or add to the currently
+ set worldTransform(). The resetTransform() function resets any
transformations that were made using translate(), scale(),
- shear(), rotate(), setWorldMatrix(), setViewport() and setWindow()
- functions. The deviceMatrix() returns the matrix that transforms
+ shear(), rotate(), setWorldTransform(), setViewport() and setWindow()
+ functions. The deviceTransform() returns the matrix that transforms
from logical coordinates to device coordinates of the platform
dependent paint device. The latter function is only needed when
using platform painting commands on the platform dependent handle,
@@ -1244,11 +1244,11 @@ void QPainterPrivate::updateState(QPainterState *newState)
When drawing with QPainter, we specify points using logical
coordinates which then are converted into the physical coordinates
of the paint device. The mapping of the logical coordinates to the
- physical coordinates are handled by QPainter's combinedMatrix(), a
- combination of viewport() and window() and worldMatrix(). The
+ physical coordinates are handled by QPainter's combinedTransform(), a
+ combination of viewport() and window() and worldTransform(). The
viewport() represents the physical coordinates specifying an
arbitrary rectangle, the window() describes the same rectangle in
- logical coordinates, and the worldMatrix() is identical with the
+ logical coordinates, and the worldTransform() is identical with the
transformation matrix.
See also \l {The Coordinate System} documentation.
@@ -2694,6 +2694,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)
/*!
\since 4.2
+ \obsolete
Sets the transformation matrix to \a matrix and enables transformations.
@@ -2732,7 +2733,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)
and window-viewport conversion, see \l {The Coordinate System}
documentation.
- \sa worldMatrixEnabled(), QMatrix
+ \sa setWorldTransform(), QTransform
*/
void QPainter::setWorldMatrix(const QMatrix &matrix, bool combine)
@@ -2742,6 +2743,7 @@ void QPainter::setWorldMatrix(const QMatrix &matrix, bool combine)
/*!
\since 4.2
+ \obsolete
Returns the world transformation matrix.
@@ -2791,6 +2793,7 @@ const QMatrix &QPainter::matrix() const
/*!
\since 4.2
+ \obsolete
Returns the transformation matrix combining the current
window/viewport and world transformation.
@@ -2798,7 +2801,7 @@ const QMatrix &QPainter::matrix() const
It is advisable to use combinedTransform() instead of this
function to preserve the properties of perspective transformations.
- \sa setWorldMatrix(), setWindow(), setViewport()
+ \sa setWorldTransform(), setWindow(), setViewport()
*/
QMatrix QPainter::combinedMatrix() const
{
@@ -2807,6 +2810,8 @@ QMatrix QPainter::combinedMatrix() const
/*!
+ \obsolete
+
Returns the matrix that transforms from logical coordinates to
device coordinates of the platform dependent paint device.
@@ -2834,6 +2839,8 @@ const QMatrix &QPainter::deviceMatrix() const
}
/*!
+ \obsolete
+
Resets any transformations that were made using translate(), scale(),
shear(), rotate(), setWorldMatrix(), setViewport() and
setWindow().
@@ -2858,7 +2865,7 @@ void QPainter::resetMatrix()
transformations if \a enable is false. The world transformation
matrix is not changed.
- \sa worldMatrixEnabled(), worldMatrix(), {QPainter#Coordinate
+ \sa worldMatrixEnabled(), worldTransform(), {QPainter#Coordinate
Transformations}{Coordinate Transformations}
*/
@@ -2887,7 +2894,7 @@ void QPainter::setWorldMatrixEnabled(bool enable)
Returns true if world transformation is enabled; otherwise returns
false.
- \sa setWorldMatrixEnabled(), worldMatrix(), {The Coordinate System}
+ \sa setWorldMatrixEnabled(), worldTransform(), {The Coordinate System}
*/
bool QPainter::worldMatrixEnabled() const
@@ -2929,7 +2936,7 @@ bool QPainter::matrixEnabled() const
/*!
Scales the coordinate system by (\a{sx}, \a{sy}).
- \sa setWorldMatrix() {QPainter#Coordinate Transformations}{Coordinate
+ \sa setWorldTransform() {QPainter#Coordinate Transformations}{Coordinate
Transformations}
*/
@@ -2953,7 +2960,7 @@ void QPainter::scale(qreal sx, qreal sy)
/*!
Shears the coordinate system by (\a{sh}, \a{sv}).
- \sa setWorldMatrix(), {QPainter#Coordinate Transformations}{Coordinate
+ \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate
Transformations}
*/
@@ -2979,7 +2986,7 @@ void QPainter::shear(qreal sh, qreal sv)
Rotates the coordinate system the given \a angle clockwise.
- \sa setWorldMatrix(), {QPainter#Coordinate Transformations}{Coordinate
+ \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate
Transformations}
*/
@@ -3004,7 +3011,7 @@ void QPainter::rotate(qreal a)
Translates the coordinate system by the given \a offset; i.e. the
given \a offset is added to points.
- \sa setWorldMatrix(), {QPainter#Coordinate Transformations}{Coordinate
+ \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate
Transformations}
*/
void QPainter::translate(const QPointF &offset)
@@ -6785,7 +6792,7 @@ QPainter::RenderHints QPainter::renderHints() const
Returns true if view transformation is enabled; otherwise returns
false.
- \sa setViewTransformEnabled(), worldMatrix()
+ \sa setViewTransformEnabled(), worldTransform()
*/
bool QPainter::viewTransformEnabled() const
@@ -6941,7 +6948,7 @@ QRect QPainter::viewport() const
/*! \fn void QPainter::resetXForm()
\compat
- Use resetMatrix() instead.
+ Use resetTransform() instead.
*/
/*! \fn void QPainter::setViewXForm(bool enabled)
@@ -6987,14 +6994,16 @@ void QPainter::setViewTransformEnabled(bool enable)
#ifdef QT3_SUPPORT
/*!
- Use the worldMatrix() combined with QMatrix::dx() instead.
+ \obsolete
+
+ Use the worldTransform() combined with QTransform::dx() instead.
\oldcode
QPainter painter(this);
qreal x = painter.translationX();
\newcode
QPainter painter(this);
- qreal x = painter.worldMatrix().dx();
+ qreal x = painter.worldTransform().dx();
\endcode
*/
qreal QPainter::translationX() const
@@ -7008,14 +7017,16 @@ qreal QPainter::translationX() const
}
/*!
- Use the worldMatrix() combined with QMatrix::dy() instead.
+ \obsolete
+
+ Use the worldTransform() combined with QTransform::dy() instead.
\oldcode
QPainter painter(this);
qreal y = painter.translationY();
\newcode
QPainter painter(this);
- qreal y = painter.worldMatrix().dy();
+ qreal y = painter.worldTransform().dy();
\endcode
*/
qreal QPainter::translationY() const
@@ -7113,7 +7124,7 @@ QPolygon QPainter::xForm(const QPolygon &a) const
QPolygon transformed = painter.xForm(polygon, index, count)
\newcode
QPainter painter(this);
- QPolygon transformed = polygon.mid(index, count) * painter.combinedMatrix();
+ QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform();
\endcode
*/
@@ -7128,15 +7139,16 @@ QPolygon QPainter::xForm(const QPolygon &av, int index, int npoints) const
/*!
\fn QPoint QPainter::xFormDev(const QPoint &point) const
\overload
+ \obsolete
- Use combinedTransform() combined with QMatrix::inverted() instead.
+ Use combinedTransform() combined with QTransform::inverted() instead.
\oldcode
QPainter painter(this);
QPoint transformed = painter.xFormDev(point);
\newcode
QPainter painter(this);
- QPoint transformed = point * painter.combinedMatrix().inverted();
+ QPoint transformed = point * painter.combinedTransform().inverted();
\endcode
*/
@@ -7155,15 +7167,16 @@ QPoint QPainter::xFormDev(const QPoint &p) const
/*!
\fn QRect QPainter::xFormDev(const QRect &rectangle) const
\overload
+ \obsolete
- Use mapRect() combined with QMatrix::inverted() instead.
+ Use combinedTransform() combined with QTransform::inverted() instead.
\oldcode
QPainter painter(this);
QRect transformed = painter.xFormDev(rectangle);
\newcode
QPainter painter(this);
- QRect transformed = painter.combinedMatrix().inverted(rectangle);
+ QRect transformed = painter.combinedTransform().inverted(rectangle);
\endcode
*/
@@ -7183,16 +7196,16 @@ QRect QPainter::xFormDev(const QRect &r) const
\overload
\fn QPoint QPainter::xFormDev(const QPolygon &polygon) const
- \overload
+ \obsolete
- Use combinedMatrix() combined with QMatrix::inverted() instead.
+ Use combinedTransform() combined with QTransform::inverted() instead.
\oldcode
QPainter painter(this);
QPolygon transformed = painter.xFormDev(rectangle);
\newcode
QPainter painter(this);
- QPolygon transformed = polygon * painter.combinedMatrix().inverted();
+ QPolygon transformed = polygon * painter.combinedTransform().inverted();
\endcode
*/
@@ -7211,15 +7224,16 @@ QPolygon QPainter::xFormDev(const QPolygon &a) const
/*!
\fn QPolygon QPainter::xFormDev(const QPolygon &polygon, int index, int count) const
\overload
+ \obsolete
- Use combinedMatrix() combined with QPolygon::mid() and QMatrix::inverted() instead.
+ Use combinedTransform() combined with QPolygon::mid() and QTransform::inverted() instead.
\oldcode
QPainter painter(this);
QPolygon transformed = painter.xFormDev(polygon, index, count);
\newcode
QPainter painter(this);
- QPolygon transformed = polygon.mid(index, count) * painter.combinedMatrix().inverted();
+ QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform().inverted();
\endcode
*/
@@ -8136,7 +8150,7 @@ void bitBlt(QPaintDevice *dst, int dx, int dy,
\row \o QPaintEngine::DirtyClipRegion \o clipRegion()
\row \o QPaintEngine::DirtyCompositionMode \o compositionMode()
\row \o QPaintEngine::DirtyFont \o font()
- \row \o QPaintEngine::DirtyTransform \o matrix()
+ \row \o QPaintEngine::DirtyTransform \o transform()
\row \o QPaintEngine::DirtyClipEnabled \o isClipEnabled()
\row \o QPaintEngine::DirtyPen \o pen()
\row \o QPaintEngine::DirtyHints \o renderHints()
@@ -8255,10 +8269,14 @@ QFont QPaintEngineState::font() const
/*!
\since 4.2
+ \obsolete
Returns the matrix in the current paint engine
state.
+ \note It is advisable to use transform() instead of this function to
+ preserve the properties of perspective transformations.
+
This variable should only be used when the state() returns a
combination which includes the QPaintEngine::DirtyTransform flag.
@@ -8439,11 +8457,7 @@ qreal QPaintEngineState::opacity() const
If \a combine is true, the specified \a transform is combined with
the current matrix; otherwise it replaces the current matrix.
- This function has been added for compatibility with setMatrix(),
- but as with setMatrix() the preferred method of setting a
- transformation on the painter is through setWorldTransform().
-
- \sa transform()
+ \sa transform() setWorldTransform()
*/
void QPainter::setTransform(const QTransform &transform, bool combine )
@@ -8453,6 +8467,8 @@ void QPainter::setTransform(const QTransform &transform, bool combine )
/*!
Returns the world transformation matrix.
+
+ \sa worldTransform()
*/
const QTransform & QPainter::transform() const
@@ -8563,7 +8579,7 @@ const QTransform & QPainter::worldTransform() const
Returns the transformation matrix combining the current
window/viewport and world transformation.
- \sa setWorldMatrix(), setWindow(), setViewport()
+ \sa setWorldTransform(), setWindow(), setViewport()
*/
QTransform QPainter::combinedTransform() const
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index f0b2351..45939c1 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -52,7 +52,9 @@ QT_BEGIN_NAMESPACE
#define Q_NEAR_CLIP 0.000001
-
+#ifdef MAP
+# undef MAP
+#endif
#define MAP(x, y, nx, ny) \
do { \
qreal FX_ = x; \
diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp
index 0ff1ccf..7547dda 100644
--- a/src/gui/styles/qstyleoption.cpp
+++ b/src/gui/styles/qstyleoption.cpp
@@ -657,7 +657,7 @@ QStyleOptionFrameV2 &QStyleOptionFrameV2::operator=(const QStyleOptionFrame &oth
/*!
\enum QStyleOptionFrameV2::FrameFeature
- This enum describles the different types of features a frame can have.
+ This enum describes the different types of features a frame can have.
\value None Indicates a normal frame.
\value Flat Indicates a flat frame.
@@ -899,7 +899,7 @@ QStyleOptionViewItemV2 &QStyleOptionViewItemV2::operator=(const QStyleOptionView
/*!
\enum QStyleOptionViewItemV2::ViewItemFeature
- This enum describles the different types of features an item can have.
+ This enum describes the different types of features an item can have.
\value None Indicates a normal item.
\value WrapText Indicates an item with wrapped text.
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp
index f3d0f04..6f3017a 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/gui/styles/qwindowsvistastyle.cpp
@@ -364,7 +364,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
w->setProperty("_q_stylestate", (int)option->state);
w->setProperty("_q_stylerect", w->rect());
- bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) ||
+ bool doTransition = oldState &&
+ ((state & State_Sunken) != (oldState & State_Sunken) ||
(state & State_On) != (oldState & State_On) ||
(state & State_MouseOver) != (oldState & State_MouseOver));
@@ -2229,7 +2230,7 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt
rect = cb->rect;
break;
case SC_ComboBoxArrow:
- rect.setRect(cb->editable ? xpos : 0, y , wi - xpos, he);
+ rect.setRect(xpos, y , wi - xpos, he);
break;
case SC_ComboBoxEditField:
rect.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin);
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 9f19fd9..2f3a791 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -557,11 +557,10 @@ int QFontMetrics::width(const QString &text, int len) const
\warning This function will produce incorrect results for Arabic
characters or non-spacing marks in the middle of a string, as the
glyph shaping and positioning of marks that happens when
- processing strings cannot be taken into account. Use charWidth()
- instead if you aren't looking for the width of isolated
- characters.
+ processing strings cannot be taken into account. When implementing
+ an interactive text control, use QTextLayout instead.
- \sa boundingRect(), charWidth()
+ \sa boundingRect()
*/
int QFontMetrics::width(QChar ch) const
{
@@ -1386,9 +1385,8 @@ qreal QFontMetricsF::width(const QString &text) const
\warning This function will produce incorrect results for Arabic
characters or non-spacing marks in the middle of a string, as the
glyph shaping and positioning of marks that happens when
- processing strings cannot be taken into account. Use charWidth()
- instead if you aren't looking for the width of isolated
- characters.
+ processing strings cannot be taken into account. When implementing
+ an interactive text control, use QTextLayout instead.
\sa boundingRect()
*/
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 690e624..6b027b1 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -87,13 +87,17 @@ void QTabBarPrivate::updateMacBorderMetrics()
// TODO: get metrics to preserve the bottom value
// TODO: test tab bar position
- // push the black line at the bottom of the menu bar down to the client are so we can paint over it
+ OSWindowRef window = qt_mac_window_for(q);
+
+ // push base line separator down to the client are so we can paint over it (Carbon)
metrics.top = (documentMode && q->isVisible()) ? 1 : 0;
metrics.bottom = 0;
metrics.left = 0;
metrics.right = 0;
-
- qt_mac_updateContentBorderMetricts(qt_mac_window_for(q), metrics);
+ qt_mac_updateContentBorderMetricts(window, metrics);
+
+ // hide the base line separator if the tabs have docuemnt mode enabled (Cocoa)
+ qt_mac_showBaseLineSeparator(window, !documentMode);
}
#endif
}
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index d67f84b..e32c975 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -573,9 +573,6 @@ bool QHttpNetworkConnectionPrivate::expand(QAbstractSocket *socket, QHttpNetwork
// make sure that the reply is valid
if (channels[i].reply != reply)
return true;
- // emit dataReadProgress signal (signal is currently not connected
- // to the rest of QNAM) since readProgress of the
- // QNonContiguousByteDevice is used
emit reply->dataReadProgress(reply->d_func()->totalProgress, 0);
// make sure that the reply is valid
if (channels[i].reply != reply)
@@ -702,9 +699,6 @@ void QHttpNetworkConnectionPrivate::receiveReply(QAbstractSocket *socket, QHttpN
// make sure that the reply is valid
if (channels[i].reply != reply)
return;
- // emit dataReadProgress signal (signal is currently not connected
- // to the rest of QNAM) since readProgress of the
- // QNonContiguousByteDevice is used
emit reply->dataReadProgress(reply->d_func()->totalProgress, reply->d_func()->bodyLength);
// make sure that the reply is valid
if (channels[i].reply != reply)
diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp
index a95b7a0..6381bc2 100644
--- a/src/opengl/qgl_x11.cpp
+++ b/src/opengl/qgl_x11.cpp
@@ -1536,15 +1536,21 @@ void QGLExtensions::init()
}
}
-
+#if !defined(glXBindTexImageEXT)
typedef void (*qt_glXBindTexImageEXT)(Display*, GLXDrawable, int, const int*);
-typedef void (*qt_glXReleaseTexImageEXT)(Display*, GLXDrawable, int);
static qt_glXBindTexImageEXT glXBindTexImageEXT = 0;
+#endif
+#if !defined(glXReleaseTexImageEXT)
+typedef void (*qt_glXReleaseTexImageEXT)(Display*, GLXDrawable, int);
static qt_glXReleaseTexImageEXT glXReleaseTexImageEXT = 0;
+#endif
static bool qt_resolved_texture_from_pixmap = false;
QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qint64 key, bool canInvert)
{
+#if !defined(Q_OS_LINUX)
+ return 0;
+#else
Q_Q(QGLContext);
if (pm->data_ptr()->classId() != QPixmapData::X11Class)
@@ -1559,6 +1565,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qi
!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0))
return 0;
+
if (!qt_resolved_texture_from_pixmap) {
qt_resolved_texture_from_pixmap = true;
@@ -1644,11 +1651,12 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qi
return texture;
#endif //!defined(GLX_VERSION_1_3) || defined(Q_OS_HPUX)
+#endif //!defined(Q_OS_LINUX
}
void QGLTexture::deleteBoundPixmap()
{
-#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
+#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) && defined(Q_OS_LINUX)
if (boundPixmap) {
glXReleaseTexImageEXT(QX11Info::display(), boundPixmap, GLX_FRONT_LEFT_EXT);
glXDestroyPixmap(QX11Info::display(), boundPixmap);
diff --git a/src/script/qscriptengine.cpp b/src/script/qscriptengine.cpp
index 48ba459..744cf2a 100644
--- a/src/script/qscriptengine.cpp
+++ b/src/script/qscriptengine.cpp
@@ -931,7 +931,7 @@ QScriptSyntaxCheckResult QScriptEngine::checkSyntax(const QString &program)
the file name is accessible through the "fileName" property if it's
provided with this function.
- \sa canEvaluate(), hasUncaughtException(), isEvaluating(), abortEvaluation()
+ \sa checkSyntax(), hasUncaughtException(), isEvaluating(), abortEvaluation()
*/
QScriptValue QScriptEngine::evaluate(const QString &program, const QString &fileName, int lineNumber)
{
diff --git a/src/script/qscriptvalue.cpp b/src/script/qscriptvalue.cpp
index 0c8426f..884a4c0 100644
--- a/src/script/qscriptvalue.cpp
+++ b/src/script/qscriptvalue.cpp
@@ -1442,7 +1442,7 @@ bool QScriptValue::isUndefined() const
Note that function values, variant values, and QObject values are
objects, so this function returns true for such values.
- \sa toObject(), QScriptEngine::newObject()
+ \sa QScriptEngine::toObject(), QScriptEngine::newObject()
*/
bool QScriptValue::isObject() const
{
diff --git a/src/xmlpatterns/parser/qmaintainingreader.cpp b/src/xmlpatterns/parser/qmaintainingreader.cpp
index 8569f05..292e0fd 100644
--- a/src/xmlpatterns/parser/qmaintainingreader.cpp
+++ b/src/xmlpatterns/parser/qmaintainingreader.cpp
@@ -147,7 +147,8 @@ void MaintainingReader<TokenLookupClass, LookupKey>::validateElement(const Looku
if(m_elementDescriptions.contains(elementName))
{
- const ElementDescription<TokenLookupClass, LookupKey> &desc = m_elementDescriptions.value(elementName);
+ // QHash::value breaks in Metrowerks Compiler
+ const ElementDescription<TokenLookupClass, LookupKey> &desc = *m_elementDescriptions.find(elementName);
const int attCount = m_currentAttributes.count();
QSet<typename TokenLookupClass::NodeName> encounteredXSLTAtts;
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 6655021..a846d8f 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -59,9 +59,14 @@
#include <qimage.h>
#include <qicon.h>
#include <qmatrix.h>
-#include <qtransform.h>
+#include <qmatrix4x4.h>
#include <qpen.h>
#include <qpolygon.h>
+#include <qtransform.h>
+#include <qvector2d.h>
+#include <qvector3d.h>
+#include <qvector4d.h>
+#include <qquaternion.h>
#include <limits.h>
@@ -194,6 +199,12 @@ private slots:
void transform();
+ void matrix4x4();
+ void vector2D();
+ void vector3D();
+ void vector4D();
+ void quaternion();
+
void url();
void userType();
@@ -1404,6 +1415,19 @@ void tst_QVariant::matrix()
QMetaType::destroy(QVariant::Matrix, mmatrix);
}
+void tst_QVariant::matrix4x4()
+{
+ QVariant variant;
+ QMatrix4x4 matrix = qVariantValue<QMatrix4x4>(variant);
+ QVERIFY(matrix.isIdentity());
+ qVariantSetValue(variant, QMatrix4x4().scale(2.0));
+ QCOMPARE(QMatrix4x4().scale(2.0), qVariantValue<QMatrix4x4>(variant));
+
+ void *mmatrix = QMetaType::construct(QVariant::Matrix4x4, 0);
+ QVERIFY(mmatrix);
+ QMetaType::destroy(QVariant::Matrix4x4, mmatrix);
+}
+
void tst_QVariant::transform()
{
QVariant variant;
@@ -1417,6 +1441,59 @@ void tst_QVariant::transform()
QMetaType::destroy(QVariant::Transform, mmatrix);
}
+
+void tst_QVariant::vector2D()
+{
+ QVariant variant;
+ QVector2D vector = qVariantValue<QVector2D>(variant);
+ QVERIFY(vector.isNull());
+ qVariantSetValue(variant, QVector2D(0.1, 0.2));
+ QCOMPARE(QVector2D(0.1, 0.2), qVariantValue<QVector2D>(variant));
+
+ void *pvector = QMetaType::construct(QVariant::Vector2D, 0);
+ QVERIFY(pvector);
+ QMetaType::destroy(QVariant::Vector2D, pvector);
+}
+
+void tst_QVariant::vector3D()
+{
+ QVariant variant;
+ QVector3D vector = qVariantValue<QVector3D>(variant);
+ QVERIFY(vector.isNull());
+ qVariantSetValue(variant, QVector3D(0.1, 0.2, 0.3));
+ QCOMPARE(QVector3D(0.1, 0.2, 0.3), qVariantValue<QVector3D>(variant));
+
+ void *pvector = QMetaType::construct(QVariant::Vector3D, 0);
+ QVERIFY(pvector);
+ QMetaType::destroy(QVariant::Vector3D, pvector);
+}
+
+void tst_QVariant::vector4D()
+{
+ QVariant variant;
+ QVector4D vector = qVariantValue<QVector4D>(variant);
+ QVERIFY(vector.isNull());
+ qVariantSetValue(variant, QVector4D(0.1, 0.2, 0.3, 0.4));
+ QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qVariantValue<QVector4D>(variant));
+
+ void *pvector = QMetaType::construct(QVariant::Vector4D, 0);
+ QVERIFY(pvector);
+ QMetaType::destroy(QVariant::Vector4D, pvector);
+}
+
+void tst_QVariant::quaternion()
+{
+ QVariant variant;
+ QQuaternion quaternion = qVariantValue<QQuaternion>(variant);
+ QVERIFY(quaternion.isIdentity());
+ qVariantSetValue(variant, QQuaternion(0.1, 0.2, 0.3, 0.4));
+ QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qVariantValue<QQuaternion>(variant));
+
+ void *pquaternion = QMetaType::construct(QVariant::Quaternion, 0);
+ QVERIFY(pquaternion);
+ QMetaType::destroy(QVariant::Quaternion, pquaternion);
+}
+
void tst_QVariant::writeToReadFromDataStream_data()
{
@@ -1956,6 +2033,11 @@ void tst_QVariant::typeName_data()
QTest::newRow("45") << int(QVariant::Matrix) << QByteArray("QMatrix");
QTest::newRow("46") << int(QVariant::Transform) << QByteArray("QTransform");
QTest::newRow("47") << int(QVariant::Hash) << QByteArray("QVariantHash");
+ QTest::newRow("48") << int(QVariant::Matrix4x4) << QByteArray("QMatrix4x4");
+ QTest::newRow("49") << int(QVariant::Vector2D) << QByteArray("QVector2D");
+ QTest::newRow("50") << int(QVariant::Vector3D) << QByteArray("QVector3D");
+ QTest::newRow("51") << int(QVariant::Vector4D) << QByteArray("QVector4D");
+ QTest::newRow("52") << int(QVariant::Quaternion) << QByteArray("QQuaternion");
}
void tst_QVariant::typeName()
@@ -1973,7 +2055,7 @@ void tst_QVariant::typeToName()
QCOMPARE( QVariant::typeToName( v.type() ), (const char*)0 ); // Invalid
// assumes that QVariant::Type contains consecutive values
- int max = QVariant::Transform;
+ int max = QVariant::Quaternion;
for ( int t = 1; t <= max; t++ ) {
const char *n = QVariant::typeToName( (QVariant::Type)t );
if (n)
diff --git a/tools/assistant/lib/lib.pro b/tools/assistant/lib/lib.pro
index bd9ed53..5d6d436 100644
--- a/tools/assistant/lib/lib.pro
+++ b/tools/assistant/lib/lib.pro
@@ -1,65 +1,71 @@
-QT += sql xml network
+QT += sql \
+ xml \
+ network
TEMPLATE = lib
TARGET = QtHelp
-DEFINES += QHELP_LIB QT_CLUCENE_SUPPORT
-CONFIG += qt warn_on
-
+DEFINES += QHELP_LIB \
+ QT_CLUCENE_SUPPORT
+CONFIG += qt \
+ warn_on
include(../../../src/qbase.pri)
-
QMAKE_TARGET_PRODUCT = Help
-QMAKE_TARGET_DESCRIPTION = Help application framework.
+QMAKE_TARGET_DESCRIPTION = Help \
+ application \
+ framework.
DEFINES -= QT_ASCII_CAST_WARNINGS
-
qclucene = QtCLucene$${QT_LIBINFIX}
-if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
+if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
mac:qclucene = $${qclucene}_debug
win32:qclucene = $${qclucene}d
}
linux-lsb-g++:LIBS += --lsb-shared-libs=$$qclucene
-unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork QtSql QtXml
+unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \
+ QtSql \
+ QtXml
LIBS += -l$$qclucene
-unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork QtSql QtXml
-
+unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \
+ QtSql \
+ QtXml
RESOURCES += helpsystem.qrc
-
SOURCES += qhelpenginecore.cpp \
- qhelpengine.cpp \
- qhelpdbreader.cpp \
- qhelpcontentwidget.cpp \
- qhelpindexwidget.cpp \
- qhelpgenerator.cpp \
- qhelpdatainterface.cpp \
- qhelpprojectdata.cpp \
- qhelpcollectionhandler.cpp \
- qhelpsearchengine.cpp \
- qhelpsearchquerywidget.cpp \
- qhelpsearchresultwidget.cpp \
- qhelpsearchindex_default.cpp \
- qhelpsearchindexwriter_default.cpp \
- qhelpsearchindexreader_default.cpp
+ qhelpengine.cpp \
+ qhelpdbreader.cpp \
+ qhelpcontentwidget.cpp \
+ qhelpindexwidget.cpp \
+ qhelpgenerator.cpp \
+ qhelpdatainterface.cpp \
+ qhelpprojectdata.cpp \
+ qhelpcollectionhandler.cpp \
+ qhelpsearchengine.cpp \
+ qhelpsearchquerywidget.cpp \
+ qhelpsearchresultwidget.cpp \
+ qhelpsearchindex_default.cpp \
+ qhelpsearchindexwriter_default.cpp \
+ qhelpsearchindexreader_default.cpp \
+ qhelpsearchindexreader.cpp
# access to clucene
SOURCES += qhelpsearchindexwriter_clucene.cpp \
- qhelpsearchindexreader_clucene.cpp
-
+ qhelpsearchindexreader_clucene.cpp
HEADERS += qhelpenginecore.h \
- qhelpengine.h \
- qhelpengine_p.h \
- qhelp_global.h \
- qhelpdbreader_p.h \
- qhelpcontentwidget.h \
- qhelpindexwidget.h \
- qhelpgenerator_p.h \
- qhelpdatainterface_p.h \
- qhelpprojectdata_p.h \
- qhelpcollectionhandler_p.h \
- qhelpsearchengine.h \
- qhelpsearchquerywidget.h \
- qhelpsearchresultwidget.h \
- qhelpsearchindex_default_p.h \
- qhelpsearchindexwriter_default_p.h \
- qhelpsearchindexreader_default_p.h
+ qhelpengine.h \
+ qhelpengine_p.h \
+ qhelp_global.h \
+ qhelpdbreader_p.h \
+ qhelpcontentwidget.h \
+ qhelpindexwidget.h \
+ qhelpgenerator_p.h \
+ qhelpdatainterface_p.h \
+ qhelpprojectdata_p.h \
+ qhelpcollectionhandler_p.h \
+ qhelpsearchengine.h \
+ qhelpsearchquerywidget.h \
+ qhelpsearchresultwidget.h \
+ qhelpsearchindex_default_p.h \
+ qhelpsearchindexwriter_default_p.h \
+ qhelpsearchindexreader_default_p.h \
+ qhelpsearchindexreader_p.h
# access to clucene
HEADERS += qhelpsearchindexwriter_clucene_p.h \
- qhelpsearchindexreader_clucene_p.h
+ qhelpsearchindexreader_clucene_p.h
diff --git a/tools/assistant/lib/qhelpsearchengine.cpp b/tools/assistant/lib/qhelpsearchengine.cpp
index 2a41d04..94c5f7e 100644
--- a/tools/assistant/lib/qhelpsearchengine.cpp
+++ b/tools/assistant/lib/qhelpsearchengine.cpp
@@ -44,6 +44,7 @@
#include "qhelpsearchquerywidget.h"
#include "qhelpsearchresultwidget.h"
+#include "qhelpsearchindexreader_p.h"
#if defined(QT_CLUCENE_SUPPORT)
# include "qhelpsearchindexreader_clucene_p.h"
# include "qhelpsearchindexwriter_clucene_p.h"
@@ -147,8 +148,11 @@ private:
return;
if (!indexReader) {
- indexReader = new QHelpSearchIndexReader();
-
+#if defined(QT_CLUCENE_SUPPORT)
+ indexReader = new QHelpSearchIndexReaderClucene();
+#else
+ indexReader = new QHelpSearchIndexReaderDefault();
+#endif // QT_CLUCENE_SUPPORT
connect(indexReader, SIGNAL(searchingStarted()), this, SIGNAL(searchingStarted()));
connect(indexReader, SIGNAL(searchingFinished(int)), this, SIGNAL(searchingFinished(int)));
}
@@ -181,7 +185,7 @@ private slots:
{
#if defined(QT_CLUCENE_SUPPORT)
if (indexWriter && !helpEngine.isNull()) {
- indexWriter->optimizeIndex();
+ indexWriter->optimizeIndex();
}
#endif
}
@@ -192,7 +196,7 @@ private:
QHelpSearchQueryWidget *queryWidget;
QHelpSearchResultWidget *resultWidget;
- QHelpSearchIndexReader *indexReader;
+ qt::fulltextsearch::QHelpSearchIndexReader *indexReader;
QHelpSearchIndexWriter *indexWriter;
QPointer<QHelpEngineCore> helpEngine;
@@ -321,7 +325,7 @@ QHelpSearchEngine::QHelpSearchEngine(QHelpEngineCore *helpEngine, QObject *paren
: QObject(parent)
{
d = new QHelpSearchEnginePrivate(helpEngine);
-
+
connect(helpEngine, SIGNAL(setupFinished()), this, SLOT(indexDocumentation()));
connect(d, SIGNAL(indexingStarted()), this, SIGNAL(indexingStarted()));
diff --git a/examples/statemachine/tankgame/gameitem.h b/tools/assistant/lib/qhelpsearchindexreader.cpp
index af012bb..a0fcbe5 100644
--- a/examples/statemachine/tankgame/gameitem.h
+++ b/tools/assistant/lib/qhelpsearchindexreader.cpp
@@ -3,7 +3,7 @@
** 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.
+** This file is part of the Qt Assistant of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,28 +39,68 @@
**
****************************************************************************/
-#ifndef GAMEITEM_H
-#define GAMEITEM_H
-
-#include <QGraphicsItem>
+#include "qhelpsearchindexreader_p.h"
QT_BEGIN_NAMESPACE
-class QLineF;
-QT_END_NAMESPACE
-class GameItem: public QObject, public QGraphicsItem
+
+namespace qt {
+ namespace fulltextsearch {
+
+QHelpSearchIndexReader::QHelpSearchIndexReader()
+ : QThread()
+ , m_cancel(false)
{
- Q_OBJECT
-public:
- enum { Type = UserType + 1 };
- int type() const { return Type; }
+ // nothing todo
+}
- GameItem(QObject *parent = 0);
+QHelpSearchIndexReader::~QHelpSearchIndexReader()
+{
+ mutex.lock();
+ this->m_cancel = true;
+ mutex.unlock();
- virtual void idle(qreal elapsed) = 0;
+ wait();
+}
+
+void QHelpSearchIndexReader::cancelSearching()
+{
+ mutex.lock();
+ this->m_cancel = true;
+ mutex.unlock();
+}
+
+void QHelpSearchIndexReader::search(const QString &collectionFile, const QString &indexFilesFolder,
+ const QList<QHelpSearchQuery> &queryList)
+{
+ wait();
-protected:
- QPointF tryMove(const QPointF &requestedPosition, QLineF *collidedLine = 0,
- QGraphicsItem **collidedItem = 0) const;
-};
+ this->hitList.clear();
+ this->m_cancel = false;
+ this->m_query = queryList;
+ this->m_collectionFile = collectionFile;
+ this->m_indexFilesFolder = indexFilesFolder;
-#endif
+ start(QThread::NormalPriority);
+}
+
+int QHelpSearchIndexReader::hitsCount() const
+{
+ QMutexLocker lock(&mutex);
+ return hitList.count();
+}
+
+QList<QHelpSearchEngine::SearchHit> QHelpSearchIndexReader::hits(int start,
+ int end) const
+{
+ QList<QHelpSearchEngine::SearchHit> hits;
+ QMutexLocker lock(&mutex);
+ for (int i = start; i < end && i < hitList.count(); ++i)
+ hits.append(hitList.at(i));
+ return hits;
+}
+
+
+ } // namespace fulltextsearch
+} // namespace qt
+
+QT_END_NAMESPACE
diff --git a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
index 89d6040..b417078 100644
--- a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
+++ b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
@@ -59,60 +59,18 @@ namespace qt {
namespace fulltextsearch {
namespace clucene {
-QHelpSearchIndexReader::QHelpSearchIndexReader()
- : QThread()
- , m_cancel(false)
+QHelpSearchIndexReaderClucene::QHelpSearchIndexReaderClucene()
+ : QHelpSearchIndexReader()
{
// nothing todo
}
-QHelpSearchIndexReader::~QHelpSearchIndexReader()
+QHelpSearchIndexReaderClucene::~QHelpSearchIndexReaderClucene()
{
- mutex.lock();
- this->m_cancel = true;
- mutex.unlock();
-
- wait();
}
-void QHelpSearchIndexReader::cancelSearching()
-{
- mutex.lock();
- this->m_cancel = true;
- mutex.unlock();
-}
-void QHelpSearchIndexReader::search(const QString &collectionFile, const QString &indexFilesFolder,
- const QList<QHelpSearchQuery> &queryList)
-{
- wait();
-
- this->hitList.clear();
- this->m_cancel = false;
- this->m_query = queryList;
- this->m_collectionFile = collectionFile;
- this->m_indexFilesFolder = indexFilesFolder;
-
- start(QThread::NormalPriority);
-}
-
-int QHelpSearchIndexReader::hitsCount() const
-{
- QMutexLocker lock(&mutex);
- return hitList.count();
-}
-
-QList<QHelpSearchEngine::SearchHit> QHelpSearchIndexReader::hits(int start,
- int end) const
-{
- QList<QHelpSearchEngine::SearchHit> hits;
- QMutexLocker lock(&mutex);
- for (int i = start; i < end && i < hitList.count(); ++i)
- hits.append(hitList.at(i));
- return hits;
-}
-
-void QHelpSearchIndexReader::run()
+void QHelpSearchIndexReaderClucene::run()
{
mutex.lock();
@@ -140,7 +98,7 @@ void QHelpSearchIndexReader::run()
if(QCLuceneIndexReader::indexExists(indexPath)) {
mutex.lock();
if (m_cancel) {
- mutex.unlock();
+ mutex.unlock();
return;
}
mutex.unlock();
@@ -227,7 +185,7 @@ void QHelpSearchIndexReader::run()
}
}
-bool QHelpSearchIndexReader::defaultQuery(const QString &term, QCLuceneBooleanQuery &booleanQuery,
+bool QHelpSearchIndexReaderClucene::defaultQuery(const QString &term, QCLuceneBooleanQuery &booleanQuery,
QCLuceneStandardAnalyzer &analyzer)
{
const QLatin1String c("content");
@@ -244,7 +202,7 @@ bool QHelpSearchIndexReader::defaultQuery(const QString &term, QCLuceneBooleanQu
return false;
}
-bool QHelpSearchIndexReader::buildQuery(QCLuceneBooleanQuery &booleanQuery,
+bool QHelpSearchIndexReaderClucene::buildQuery(QCLuceneBooleanQuery &booleanQuery,
const QList<QHelpSearchQuery> &queryList, QCLuceneStandardAnalyzer &analyzer)
{
foreach (const QHelpSearchQuery query, queryList) {
@@ -344,7 +302,7 @@ bool QHelpSearchIndexReader::buildQuery(QCLuceneBooleanQuery &booleanQuery,
return true;
}
-bool QHelpSearchIndexReader::buildTryHarderQuery(QCLuceneBooleanQuery &booleanQuery,
+bool QHelpSearchIndexReaderClucene::buildTryHarderQuery(QCLuceneBooleanQuery &booleanQuery,
const QList<QHelpSearchQuery> &queryList, QCLuceneStandardAnalyzer &analyzer)
{
bool retVal = false;
@@ -367,7 +325,7 @@ bool QHelpSearchIndexReader::buildTryHarderQuery(QCLuceneBooleanQuery &booleanQu
return retVal;
}
-void QHelpSearchIndexReader::boostSearchHits(const QHelpEngineCore &engine,
+void QHelpSearchIndexReaderClucene::boostSearchHits(const QHelpEngineCore &engine,
QList<QHelpSearchEngine::SearchHit> &hitList, const QList<QHelpSearchQuery> &queryList)
{
foreach (const QHelpSearchQuery query, queryList) {
diff --git a/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h b/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h
index 8876d80..93ac6a8 100644
--- a/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h
+++ b/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h
@@ -53,44 +53,24 @@
// We mean it.
//
-#include "qhelpsearchengine.h"
+#include "qhelpsearchindexreader_p.h"
#include "fulltextsearch/qanalyzer_p.h"
#include "fulltextsearch/qquery_p.h"
-#include <QtCore/QList>
-#include <QtCore/QMutex>
-#include <QtCore/QObject>
-#include <QtCore/QString>
-#include <QtCore/QThread>
-#include <QtCore/QWaitCondition>
-
-class QHelpEngineCore;
-
QT_BEGIN_NAMESPACE
namespace qt {
namespace fulltextsearch {
namespace clucene {
-class QHelpSearchIndexReader : public QThread
+class QHelpSearchIndexReaderClucene : public QHelpSearchIndexReader
{
Q_OBJECT
public:
- QHelpSearchIndexReader();
- ~QHelpSearchIndexReader();
-
- void cancelSearching();
- void search(const QString &collectionFile,
- const QString &indexFilesFolder,
- const QList<QHelpSearchQuery> &queryList);
- int hitsCount() const;
- QList<QHelpSearchEngine::SearchHit> hits(int start, int end) const;
-
-signals:
- void searchingStarted();
- void searchingFinished(int hits);
+ QHelpSearchIndexReaderClucene();
+ ~QHelpSearchIndexReaderClucene();
private:
void run();
@@ -102,14 +82,6 @@ private:
const QList<QHelpSearchQuery> &queryList, QCLuceneStandardAnalyzer &analyzer);
void boostSearchHits(const QHelpEngineCore &engine, QList<QHelpSearchEngine::SearchHit> &hitList,
const QList<QHelpSearchQuery> &queryList);
-
-private:
- mutable QMutex mutex;
- QList<QHelpSearchEngine::SearchHit> hitList;
- bool m_cancel;
- QString m_collectionFile;
- QList<QHelpSearchQuery> m_query;
- QString m_indexFilesFolder;
};
} // namespace clucene
diff --git a/tools/assistant/lib/qhelpsearchindexreader_default.cpp b/tools/assistant/lib/qhelpsearchindexreader_default.cpp
index 91af925..fbf8a09 100644
--- a/tools/assistant/lib/qhelpsearchindexreader_default.cpp
+++ b/tools/assistant/lib/qhelpsearchindexreader_default.cpp
@@ -492,56 +492,17 @@ void Reader::cleanupIndex(EntryTable &entryTable)
}
-QHelpSearchIndexReader::QHelpSearchIndexReader()
- : QThread()
- , m_cancel(false)
+QHelpSearchIndexReaderDefault::QHelpSearchIndexReaderDefault()
+ : QHelpSearchIndexReader()
{
// nothing todo
}
-QHelpSearchIndexReader::~QHelpSearchIndexReader()
+QHelpSearchIndexReaderDefault::~QHelpSearchIndexReaderDefault()
{
- mutex.lock();
- this->m_cancel = true;
- waitCondition.wakeOne();
- mutex.unlock();
-
- wait();
-}
-
-void QHelpSearchIndexReader::cancelSearching()
-{
- mutex.lock();
- this->m_cancel = true;
- mutex.unlock();
-}
-
-void QHelpSearchIndexReader::search(const QString &collectionFile,
- const QString &indexFilesFolder,
- const QList<QHelpSearchQuery> &queryList)
-{
- QMutexLocker lock(&mutex);
-
- this->hitList.clear();
- this->m_cancel = false;
- this->m_query = queryList;
- this->m_collectionFile = collectionFile;
- this->m_indexFilesFolder = indexFilesFolder;
-
- start(QThread::NormalPriority);
-}
-
-int QHelpSearchIndexReader::hitsCount() const
-{
- return hitList.count();
}
-QHelpSearchEngine::SearchHit QHelpSearchIndexReader::hit(int index) const
-{
- return hitList.at(index);
-}
-
-void QHelpSearchIndexReader::run()
+void QHelpSearchIndexReaderDefault::run()
{
mutex.lock();
@@ -571,7 +532,7 @@ void QHelpSearchIndexReader::run()
QHelpEngineCore engine(collectionFile, 0);
if (!engine.setupData())
return;
-
+
const QStringList registeredDocs = engine.registeredDocumentations();
const QStringList indexedNamespaces = engine.customValue(key).toString().
split(QLatin1String("|"), QString::SkipEmptyParts);
diff --git a/tools/assistant/lib/qhelpsearchindexreader_default_p.h b/tools/assistant/lib/qhelpsearchindexreader_default_p.h
index f0e59b4..d21fc08 100644
--- a/tools/assistant/lib/qhelpsearchindexreader_default_p.h
+++ b/tools/assistant/lib/qhelpsearchindexreader_default_p.h
@@ -54,19 +54,10 @@
//
#include "qhelpsearchindex_default_p.h"
-#include "qhelpsearchengine.h"
+#include "qhelpsearchindexreader_p.h"
#include <QtCore/QHash>
#include <QtCore/QPair>
-#include <QtCore/QList>
-#include <QtCore/QMutex>
-#include <QtCore/QString>
-#include <QtCore/QThread>
-#include <QtCore/QObject>
-#include <QtCore/QVector>
-#include <QtCore/QByteArray>
-#include <QtCore/QStringList>
-#include <QtCore/QWaitCondition>
QT_BEGIN_NAMESPACE
@@ -121,39 +112,19 @@ private:
};
-class QHelpSearchIndexReader : public QThread
+class QHelpSearchIndexReaderDefault : public QHelpSearchIndexReader
{
Q_OBJECT
public:
- QHelpSearchIndexReader();
- ~QHelpSearchIndexReader();
-
- void cancelSearching();
- void search(const QString &collectionFile,
- const QString &indexFilesFolder,
- const QList<QHelpSearchQuery> &queryList);
-
- int hitsCount() const;
- QHelpSearchEngine::SearchHit hit(int index) const;
-
-signals:
- void searchingStarted();
- void searchingFinished(int hits);
+ QHelpSearchIndexReaderDefault();
+ ~QHelpSearchIndexReaderDefault();
private:
void run();
private:
- QMutex mutex;
Reader m_reader;
- QWaitCondition waitCondition;
- QList<QHelpSearchEngine::SearchHit> hitList;
-
- bool m_cancel;
- QList<QHelpSearchQuery> m_query;
- QString m_collectionFile;
- QString m_indexFilesFolder;
};
} // namespace std
diff --git a/examples/statemachine/tankgame/mainwindow.h b/tools/assistant/lib/qhelpsearchindexreader_p.h
index d42b7ac..c8f2b44 100644
--- a/examples/statemachine/tankgame/mainwindow.h
+++ b/tools/assistant/lib/qhelpsearchindexreader_p.h
@@ -3,7 +3,7 @@
** 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.
+** This file is part of the Qt Assistant of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,55 +39,70 @@
**
****************************************************************************/
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
+#ifndef QHELPSEARCHINDEXREADER_H
+#define QHELPSEARCHINDEXREADER_H
-#include <QMainWindow>
-#include <QTime>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the help generator tools. This header file may change from version
+// to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qhelpsearchengine.h"
+
+#include <QtCore/QList>
+#include <QtCore/QMutex>
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtCore/QThread>
+#include <QtCore/QWaitCondition>
QT_BEGIN_NAMESPACE
-class QGraphicsScene;
-class QStateMachine;
-class QState;
-QT_END_NAMESPACE
-class GameOverTransition;
-class TankItem;
-class MainWindow: public QMainWindow
+class QHelpEngineCore;
+
+namespace qt {
+ namespace fulltextsearch {
+
+class QHelpSearchIndexReader : public QThread
{
Q_OBJECT
- Q_PROPERTY(bool started READ started WRITE setStarted)
-public:
- MainWindow(QWidget *parent = 0);
- ~MainWindow();
- void setStarted(bool b) { m_started = b; }
- bool started() const { return m_started; }
+public:
+ QHelpSearchIndexReader();
+ ~QHelpSearchIndexReader();
-public slots:
- void addTank();
- void addRocket();
- void runStep();
- void gameOver();
+ void cancelSearching();
+ void search(const QString &collectionFile,
+ const QString &indexFilesFolder,
+ const QList<QHelpSearchQuery> &queryList);
+ int hitsCount() const;
+ QList<QHelpSearchEngine::SearchHit> hits(int start, int end) const;
signals:
- void mapFull();
+ void searchingStarted();
+ void searchingFinished(int hits);
-private:
- void init();
- void addWall(const QRectF &wall);
-
- QGraphicsScene *m_scene;
-
- QStateMachine *m_machine;
- QState *m_runningState;
- GameOverTransition *m_gameOverTransition;
-
- QList<TankItem *> m_spawns;
- QTime m_time;
+protected:
+ mutable QMutex mutex;
+ QList<QHelpSearchEngine::SearchHit> hitList;
+ bool m_cancel;
+ QString m_collectionFile;
+ QList<QHelpSearchQuery> m_query;
+ QString m_indexFilesFolder;
- bool m_started : 1;
+private:
+ virtual void run()=0;
};
-#endif
+ } // namespace fulltextsearch
+} // namespace qt
+
+QT_END_NAMESPACE
+#endif // QHELPSEARCHINDEXREADER_H