From e08ca6bcaf5fc746fdf8f3e379c17bf0a9daa771 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 18 Aug 2009 17:27:17 +0200 Subject: QGraphicsView test fix Reviewed-by: Olivier --- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index c12fb11..2506e70 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -3637,18 +3637,18 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins() VpGraphicsView view(&scene); view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif QPoint mouseViewPos(20, 20); sendMouseMove(view.viewport(), mouseViewPos); - QTest::qWait(125); QPointF mouseScenePos = view.mapToScene(mouseViewPos); - view.setTransform(QTransform().scale(5, 5)); - QTest::qWait(125); - view.setTransform(QTransform().rotate(5, Qt::ZAxis), true); - QTest::qWait(125); + view.setTransform(QTransform().scale(5, 5).rotate(5, Qt::ZAxis), true); QPointF newMouseScenePos = view.mapToScene(mouseViewPos); - qreal slack = 3; + + qreal slack = 1; QVERIFY(qAbs(newMouseScenePos.x() - mouseScenePos.x()) < slack); QVERIFY(qAbs(newMouseScenePos.y() - mouseScenePos.y()) < slack); } -- cgit v0.12 From 393f5d5b2705c0ed7e6e1a3a69cc9cdf16cf334d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 17 Aug 2009 16:55:58 +0200 Subject: Added two convenience functions to QXmlStreamReader QXmlStreamReader::readNextStartElement reads until the next start element within the current element, or returns false when no such element is encountered before the end element is reached. It simplifies the common case of iterating over the elements in an XML document. QXmlStreamReader::skipCurrentElement reads until the end element of the current element, skipping any child elements. This functionality was requested in two tasks, and a similar function 'readUnknownElement' was present in Qt's stream reader example. Autotest is included, example and documentation have been updated. Task-number: 238793 Reviewed-by: mae --- doc/src/examples/qxmlstreambookmarks.qdoc | 13 ++- examples/network/googlesuggest/googlesuggest.cpp | 7 +- examples/xml/streambookmarks/xbelreader.cpp | 107 +++++++---------------- examples/xml/streambookmarks/xbelreader.h | 1 - src/corelib/xml/qxmlstream.cpp | 49 +++++++++++ src/corelib/xml/qxmlstream.h | 3 + tests/auto/qxmlstream/tst_qxmlstream.cpp | 19 ++++ 7 files changed, 114 insertions(+), 85 deletions(-) diff --git a/doc/src/examples/qxmlstreambookmarks.qdoc b/doc/src/examples/qxmlstreambookmarks.qdoc index def4c47..26964c4 100644 --- a/doc/src/examples/qxmlstreambookmarks.qdoc +++ b/doc/src/examples/qxmlstreambookmarks.qdoc @@ -106,19 +106,18 @@ of reading only takes place if the file is a valid XBEL 1.0 file. Note that the XML input needs to be well-formed to be accepted by QXmlStreamReader. Otherwise, the \l{QXmlStreamReader::raiseError()} - {raiseError()} function is used to display an error message. + {raiseError()} function is used to display an error message. Since the + XBEL reader is only concerned with reading XML elements, it makes + extensive use of the \l{QXmlStreamReader::readNextStartElement()} + convenience function. \snippet examples/xml/streambookmarks/xbelreader.cpp 1 - The \c readUnknownElement() function reads an unknown element. The - Q_ASSERT() macro is used to provide a pre-condition for the function. - - \snippet examples/xml/streambookmarks/xbelreader.cpp 2 - The \c readXBEL() function reads the name of a startElement and calls the appropriate function to read it, depending on whether if its a "folder", "bookmark" or "separator". Otherwise, it calls - \c readUnknownElement(). + \l{QXmlStreamReader::skipCurrentElement()}. The Q_ASSERT() macro is used + to provide a pre-condition for the function. \snippet examples/xml/streambookmarks/xbelreader.cpp 3 diff --git a/examples/network/googlesuggest/googlesuggest.cpp b/examples/network/googlesuggest/googlesuggest.cpp index ada0edf..4142511 100644 --- a/examples/network/googlesuggest/googlesuggest.cpp +++ b/examples/network/googlesuggest/googlesuggest.cpp @@ -134,7 +134,6 @@ bool GSuggestCompletion::eventFilter(QObject *obj, QEvent *ev) void GSuggestCompletion::showCompletion(const QStringList &choices, const QStringList &hits) { - if (choices.isEmpty() || choices.count() != hits.count()) return; @@ -204,16 +203,16 @@ void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply) QXmlStreamReader xml(response); while (!xml.atEnd()) { xml.readNext(); - if (xml.tokenType() == QXmlStreamReader::StartElement) + if (xml.isStartElement()) { if (xml.name() == "suggestion") { QStringRef str = xml.attributes().value("data"); choices << str.toString(); } - if (xml.tokenType() == QXmlStreamReader::StartElement) - if (xml.name() == "num_queries") { + else if (xml.name() == "num_queries") { QStringRef str = xml.attributes().value("int"); hits << str.toString(); } + } } showCompletion(choices, hits); diff --git a/examples/xml/streambookmarks/xbelreader.cpp b/examples/xml/streambookmarks/xbelreader.cpp index 47c8c3d..729fcf8 100644 --- a/examples/xml/streambookmarks/xbelreader.cpp +++ b/examples/xml/streambookmarks/xbelreader.cpp @@ -62,59 +62,31 @@ bool XbelReader::read(QIODevice *device) { setDevice(device); - while (!atEnd()) { - readNext(); - - if (isStartElement()) { - if (name() == "xbel" && attributes().value("version") == "1.0") - readXBEL(); - else - raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); - } + if (readNextStartElement()) { + if (name() == "xbel" && attributes().value("version") == "1.0") + readXBEL(); + else + raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); } return !error(); } //! [1] -//! [2] -void XbelReader::readUnknownElement() -{ - Q_ASSERT(isStartElement()); - - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) - readUnknownElement(); - } -} -//! [2] - //! [3] void XbelReader::readXBEL() { Q_ASSERT(isStartElement() && name() == "xbel"); - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == "folder") - readFolder(0); - else if (name() == "bookmark") - readBookmark(0); - else if (name() == "separator") - readSeparator(0); - else - readUnknownElement(); - } + while (readNextStartElement()) { + if (name() == "folder") + readFolder(0); + else if (name() == "bookmark") + readBookmark(0); + else if (name() == "separator") + readSeparator(0); + else + readUnknownElement(); } } //! [3] @@ -132,10 +104,12 @@ void XbelReader::readTitle(QTreeWidgetItem *item) //! [5] void XbelReader::readSeparator(QTreeWidgetItem *item) { + Q_ASSERT(isStartElement() && name() == "separator"); + QTreeWidgetItem *separator = createChildItem(item); separator->setFlags(item->flags() & ~Qt::ItemIsSelectable); separator->setText(0, QString(30, 0xB7)); - readElementText(); + skipCurrentElement(); } //! [5] @@ -147,24 +121,17 @@ void XbelReader::readFolder(QTreeWidgetItem *item) bool folded = (attributes().value("folded") != "no"); treeWidget->setItemExpanded(folder, !folded); - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == "title") - readTitle(folder); - else if (name() == "folder") - readFolder(folder); - else if (name() == "bookmark") - readBookmark(folder); - else if (name() == "separator") - readSeparator(folder); - else - readUnknownElement(); - } + while (readNextStartElement()) { + if (name() == "title") + readTitle(folder); + else if (name() == "folder") + readFolder(folder); + else if (name() == "bookmark") + readBookmark(folder); + else if (name() == "separator") + readSeparator(folder); + else + skipCurrentElement(); } } @@ -177,18 +144,12 @@ void XbelReader::readBookmark(QTreeWidgetItem *item) bookmark->setIcon(0, bookmarkIcon); bookmark->setText(0, QObject::tr("Unknown title")); bookmark->setText(1, attributes().value("href").toString()); - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == "title") - readTitle(bookmark); - else - readUnknownElement(); - } + + while (readNextStartElement()) { + if (name() == "title") + readTitle(bookmark); + else + skipCurrentElement(); } } diff --git a/examples/xml/streambookmarks/xbelreader.h b/examples/xml/streambookmarks/xbelreader.h index 80f0a28..2debadc 100644 --- a/examples/xml/streambookmarks/xbelreader.h +++ b/examples/xml/streambookmarks/xbelreader.h @@ -62,7 +62,6 @@ public: private: //! [2] - void readUnknownElement(); void readXBEL(); void readTitle(QTreeWidgetItem *item); void readSeparator(QTreeWidgetItem *item); diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index a08b167..8b2462e 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -622,6 +622,55 @@ QXmlStreamReader::TokenType QXmlStreamReader::tokenType() const return d->type; } +/*! + Reads until the next start element within the current element. Returns true + when a start element was reached. When the end element was reached, or when + an error occurred, false is returned. + + The current element is the element matching the most recently parsed start + element of which a matching end element has not yet been reached. When the + parser has reached the end element, the current element becomes the parent + element. + + This is a convenience function for when you're only concerned with parsing + XML elements. The \l{QXmlStream Bookmarks Example} makes extensive use of + this function. + + \since 4.6 + */ +bool QXmlStreamReader::readNextStartElement() +{ + while (readNext() != Invalid) { + if (isEndElement()) + return false; + else if (isStartElement()) + return true; + } + return false; +} + +/*! + Reads until the end of the current element, skipping any child nodes. + This function is useful for skipping unknown elements. + + The current element is the element matching the most recently parsed start + element of which a matching end element has not yet been reached. When the + parser has reached the end element, the current element becomes the parent + element. + + \since 4.6 + */ +void QXmlStreamReader::skipCurrentElement() +{ + int depth = 1; + while (depth && readNext() != Invalid) { + if (isEndElement()) + --depth; + else if (isStartElement()) + ++depth; + } +} + /* * Use the following Perl script to generate the error string index list: ===== PERL SCRIPT ==== diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 420a66a..21dcb40 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -321,6 +321,9 @@ public: bool atEnd() const; TokenType readNext(); + bool readNextStartElement(); + void skipCurrentElement(); + TokenType tokenType() const; QString tokenString() const; diff --git a/tests/auto/qxmlstream/tst_qxmlstream.cpp b/tests/auto/qxmlstream/tst_qxmlstream.cpp index 375528c..f496dcf 100644 --- a/tests/auto/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/qxmlstream/tst_qxmlstream.cpp @@ -550,6 +550,7 @@ private slots: void setEntityResolver(); void readFromQBuffer() const; void readFromQBufferInvalid() const; + void readNextStartElement() const; void crashInUTF16Codec() const; void hasAttributeSignature() const; void hasAttribute() const; @@ -1107,6 +1108,24 @@ void tst_QXmlStream::readFromQBufferInvalid() const QVERIFY(reader.hasError()); } +void tst_QXmlStream::readNextStartElement() const +{ + QLatin1String in("text"); + QXmlStreamReader reader(in); + + QVERIFY(reader.readNextStartElement()); + QVERIFY(reader.isStartElement() && reader.name() == "A"); + + int amountOfB = 0; + while (reader.readNextStartElement()) { + QVERIFY(reader.isStartElement() && reader.name() == "B"); + ++amountOfB; + reader.skipCurrentElement(); + } + + QCOMPARE(amountOfB, 2); +} + void tst_QXmlStream::crashInUTF16Codec() const { QEventLoop eventLoop; -- cgit v0.12 From fdf8956419fc784b458ef1d42c98fde526f9f5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 18 Aug 2009 17:01:19 +0200 Subject: Added a behaviour parameter to QXmlStreamReader::readElementText This makes the function a bit more useful, since previously it was only safe to use if you were sure that it would not encounter an unexpected child element, or if you would be alright with canceling the parser on such an occurrence. Now it is also possible to have it ignore any unexpected child elements, or to have it include the text found in any child elements. Task-number: 231938 Reviewed-by: mae --- src/corelib/xml/qxmlstream.cpp | 58 +++++++++++++++++++++++++++----- src/corelib/xml/qxmlstream.h | 7 ++++ tests/auto/qxmlstream/tst_qxmlstream.cpp | 51 ++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 8 deletions(-) diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 8b2462e..a311b99 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -129,6 +129,21 @@ QT_BEGIN_NAMESPACE */ /*! + \enum QXmlStreamReader::ReadElementTextBehaviour + + This enum specifies the different behaviours of readElementText(). + + \value ErrorOnUnexpectedElement Raise an UnexpectedElementError and return + what was read so far when a child element is encountered. + + \value IncludeChildElements Recursively include the text from child elements. + + \value SkipChildElements Skip child elements. + + \since 4.6 +*/ + +/*! \enum QXmlStreamReader::Error This enum specifies different error cases @@ -637,6 +652,7 @@ QXmlStreamReader::TokenType QXmlStreamReader::tokenType() const this function. \since 4.6 + \sa readNext() */ bool QXmlStreamReader::readNextStartElement() { @@ -2070,12 +2086,17 @@ void QXmlStreamReader::addExtraNamespaceDeclarations(const QXmlStreamNamespaceDe The function concatenates text() when it reads either \l Characters or EntityReference tokens, but skips ProcessingInstruction and \l - Comment. In case anything else is read before reaching EndElement, - the function returns what it read so far and raises an - UnexpectedElementError. If the current token is not StartElement, an - empty string is returned. + Comment. If the current token is not StartElement, an empty string is + returned. + + The \a behaviour defines what happens in case anything else is + read before reaching EndElement. The function can include the text from + child elements (useful for example for HTML), ignore child elements, or + raise an UnexpectedElementError and return what was read so far. + + \since 4.6 */ -QString QXmlStreamReader::readElementText() +QString QXmlStreamReader::readElementText(ReadElementTextBehaviour behaviour) { Q_D(QXmlStreamReader); if (isStartElement()) { @@ -2091,16 +2112,37 @@ QString QXmlStreamReader::readElementText() case ProcessingInstruction: case Comment: break; + case StartElement: + if (behaviour == SkipChildElements) { + skipCurrentElement(); + break; + } else if (behaviour == IncludeChildElements) { + result += readElementText(behaviour); + break; + } + // Fall through (for ErrorOnUnexpectedElement) default: - if (!d->error) - d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data.")); - return result; + if (d->error || behaviour == ErrorOnUnexpectedElement) { + if (!d->error) + d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data.")); + return result; + } } } } return QString(); } +/*! + \overload readElementText() + + Calling this function is equivalent to calling readElementText(ErrorOnUnexpectedElement). + */ +QString QXmlStreamReader::readElementText() +{ + return readElementText(ErrorOnUnexpectedElement); +} + /*! Raises a custom error with an optional error \a message. \sa error(), errorString() diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 21dcb40..71deb66 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -351,6 +351,13 @@ public: qint64 characterOffset() const; QXmlStreamAttributes attributes() const; + + enum ReadElementTextBehaviour { + ErrorOnUnexpectedElement, + IncludeChildElements, + SkipChildElements + }; + QString readElementText(ReadElementTextBehaviour behaviour); QString readElementText(); QStringRef name() const; diff --git a/tests/auto/qxmlstream/tst_qxmlstream.cpp b/tests/auto/qxmlstream/tst_qxmlstream.cpp index f496dcf..04f990f 100644 --- a/tests/auto/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/qxmlstream/tst_qxmlstream.cpp @@ -55,6 +55,8 @@ //TESTED_CLASS=QXmlStreamReader QXmlStreamWriter //TESTED_FILES=corelib/xml/stream/qxmlutils.cpp corelib/xml/stream/qxmlstream.cpp corelib/xml/stream/qxmlstream_p.h +Q_DECLARE_METATYPE(QXmlStreamReader::ReadElementTextBehaviour) + static const char *const catalogFile = "XML-Test-Suite/xmlconf/finalCatalog.xml"; static const int expectedRunCount = 1646; static const int expectedSkipCount = 532; @@ -551,6 +553,8 @@ private slots: void readFromQBuffer() const; void readFromQBufferInvalid() const; void readNextStartElement() const; + void readElementText() const; + void readElementText_data() const; void crashInUTF16Codec() const; void hasAttributeSignature() const; void hasAttribute() const; @@ -1126,6 +1130,53 @@ void tst_QXmlStream::readNextStartElement() const QCOMPARE(amountOfB, 2); } +void tst_QXmlStream::readElementText() const +{ + QFETCH(QXmlStreamReader::ReadElementTextBehaviour, behaviour); + QFETCH(QString, input); + QFETCH(QString, expected); + + QXmlStreamReader reader(input); + + QVERIFY(reader.readNextStartElement()); + QCOMPARE(reader.readElementText(behaviour), expected); +} + +void tst_QXmlStream::readElementText_data() const +{ + QTest::addColumn("behaviour"); + QTest::addColumn("input"); + QTest::addColumn("expected"); + + QString validInput("

He was never going to admit his mistake.

"); + QString invalidInput("

invalid...

"); + QString invalidOutput("invalid..."); + + QTest::newRow("ErrorOnUnexpectedElement") + << QXmlStreamReader::ErrorOnUnexpectedElement + << validInput << QString("He was "); + + QTest::newRow("IncludeChildElements") + << QXmlStreamReader::IncludeChildElements + << validInput << QString("He was never going to admit his mistake."); + + QTest::newRow("SkipChildElements") + << QXmlStreamReader::SkipChildElements + << validInput << QString("He was going to admit his mistake."); + + QTest::newRow("ErrorOnUnexpectedElement Invalid") + << QXmlStreamReader::ErrorOnUnexpectedElement + << invalidInput << invalidOutput; + + QTest::newRow("IncludeChildElements Invalid") + << QXmlStreamReader::IncludeChildElements + << invalidInput << invalidOutput; + + QTest::newRow("SkipChildElements Invalid") + << QXmlStreamReader::SkipChildElements + << invalidInput << invalidOutput; +} + void tst_QXmlStream::crashInUTF16Codec() const { QEventLoop eventLoop; -- cgit v0.12 From 6e7675c8b7af9bd51796552fc4ce75612cbc41c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 18 Aug 2009 18:50:12 +0200 Subject: Made the browser demo use the new QXmlStreamReader functions Same as in the bookmarks example. --- demos/browser/xbel.cpp | 109 ++++++++++++++++--------------------------------- demos/browser/xbel.h | 1 - 2 files changed, 36 insertions(+), 74 deletions(-) diff --git a/demos/browser/xbel.cpp b/demos/browser/xbel.cpp index ed62868..66b49a4 100644 --- a/demos/browser/xbel.cpp +++ b/demos/browser/xbel.cpp @@ -133,16 +133,13 @@ BookmarkNode *XbelReader::read(QIODevice *device) { BookmarkNode *root = new BookmarkNode(BookmarkNode::Root); setDevice(device); - while (!atEnd()) { - readNext(); - if (isStartElement()) { - QString version = attributes().value(QLatin1String("version")).toString(); - if (name() == QLatin1String("xbel") - && (version.isEmpty() || version == QLatin1String("1.0"))) { - readXBEL(root); - } else { - raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); - } + if (readNextStartElement()) { + QString version = attributes().value(QLatin1String("version")).toString(); + if (name() == QLatin1String("xbel") + && (version.isEmpty() || version == QLatin1String("1.0"))) { + readXBEL(root); + } else { + raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); } } return root; @@ -152,21 +149,15 @@ void XbelReader::readXBEL(BookmarkNode *parent) { Q_ASSERT(isStartElement() && name() == QLatin1String("xbel")); - while (!atEnd()) { - readNext(); - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == QLatin1String("folder")) - readFolder(parent); - else if (name() == QLatin1String("bookmark")) - readBookmarkNode(parent); - else if (name() == QLatin1String("separator")) - readSeparator(parent); - else - skipUnknownElement(); - } + while (readNextStartElement()) { + if (name() == QLatin1String("folder")) + readFolder(parent); + else if (name() == QLatin1String("bookmark")) + readBookmarkNode(parent); + else if (name() == QLatin1String("separator")) + readSeparator(parent); + else + skipCurrentElement(); } } @@ -177,26 +168,19 @@ void XbelReader::readFolder(BookmarkNode *parent) BookmarkNode *folder = new BookmarkNode(BookmarkNode::Folder, parent); folder->expanded = (attributes().value(QLatin1String("folded")) == QLatin1String("no")); - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == QLatin1String("title")) - readTitle(folder); - else if (name() == QLatin1String("desc")) - readDescription(folder); - else if (name() == QLatin1String("folder")) - readFolder(folder); - else if (name() == QLatin1String("bookmark")) - readBookmarkNode(folder); - else if (name() == QLatin1String("separator")) - readSeparator(folder); - else - skipUnknownElement(); - } + while (readNextStartElement()) { + if (name() == QLatin1String("title")) + readTitle(folder); + else if (name() == QLatin1String("desc")) + readDescription(folder); + else if (name() == QLatin1String("folder")) + readFolder(folder); + else if (name() == QLatin1String("bookmark")) + readBookmarkNode(folder); + else if (name() == QLatin1String("separator")) + readSeparator(folder); + else + skipCurrentElement(); } } @@ -224,39 +208,18 @@ void XbelReader::readBookmarkNode(BookmarkNode *parent) Q_ASSERT(isStartElement() && name() == QLatin1String("bookmark")); BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark, parent); bookmark->url = attributes().value(QLatin1String("href")).toString(); - while (!atEnd()) { - readNext(); - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == QLatin1String("title")) - readTitle(bookmark); - else if (name() == QLatin1String("desc")) - readDescription(bookmark); - else - skipUnknownElement(); - } + while (readNextStartElement()) { + if (name() == QLatin1String("title")) + readTitle(bookmark); + else if (name() == QLatin1String("desc")) + readDescription(bookmark); + else + skipCurrentElement(); } if (bookmark->title.isEmpty()) bookmark->title = QObject::tr("Unknown title"); } -void XbelReader::skipUnknownElement() -{ - Q_ASSERT(isStartElement()); - - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) - skipUnknownElement(); - } -} - XbelWriter::XbelWriter() { diff --git a/demos/browser/xbel.h b/demos/browser/xbel.h index 2bdffe1..ec9008e 100644 --- a/demos/browser/xbel.h +++ b/demos/browser/xbel.h @@ -87,7 +87,6 @@ public: BookmarkNode *read(QIODevice *device); private: - void skipUnknownElement(); void readXBEL(BookmarkNode *parent); void readTitle(BookmarkNode *parent); void readDescription(BookmarkNode *parent); -- cgit v0.12 From 4a71fa599b0dfb71cc04fd45afeb95e780a7d2fb Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 18 Aug 2009 10:07:08 -0700 Subject: Fix bugs in DFBPE fillRect and drawTiledPixmap Make sure to call CLIPPED_PAINT so painting with a region clip works. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 131ff4b..741c4e4 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -586,7 +586,7 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, QRasterPaintEngine::drawTiledPixmap(r, pix, offset); } else { d->unlock(); - d->drawTiledPixmap(r, pixmap, offset); + CLIPPED_PAINT(d->drawTiledPixmap(r, pixmap, offset)); } } @@ -729,8 +729,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) d->unlock(); d->setDFBColor(color); const QRect r = state()->matrix.mapRect(rect).toRect(); - d->surface->FillRectangle(d->surface, r.x(), r.y(), - r.width(), r.height()); + CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); } } -- cgit v0.12 From 83cbb77ac9ef7f95e11dbd29b36d5d9660e778ea Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 5 Aug 2009 05:02:00 -0700 Subject: Simplify DirectFB clipping Instead of storing whether or not our clip is dirty and updating it in every paint operation we'll just update it whenever it changes. This is more intuitive and should be faster for the common case as well. Also make sure to implement clip(region). Prevent multiple updateClip() calls for a single clip operation by introducing a flag to check whether we recursed into the different clip() calls. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 60 +++++++++++++--------- .../gfxdrivers/directfb/qdirectfbpaintengine.h | 1 + 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 741c4e4..ba715c3 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -119,13 +119,14 @@ private: IDirectFB *fb; quint8 opacity; - bool dirtyClip; ClipType clipType; QDirectFBPaintDevice *dfbDevice; uint compositionModeStatus; - QDirectFBPaintEngine *q; + bool inClip; QRect currentClip; + + QDirectFBPaintEngine *q; friend class QDirectFBPaintEngine; }; @@ -236,7 +237,7 @@ static inline void drawRects(const T *rects, int n, const QTransform &transform, d->surface->SetClip(d->surface, &clipRegion); \ operation; \ } \ - d->dirtyClip = true; \ + d->updateClip(); \ break; } \ case QDirectFBPaintEnginePrivate::ComplexClip: \ case QDirectFBPaintEnginePrivate::ClipUnset: \ @@ -297,8 +298,8 @@ bool QDirectFBPaintEngine::end() void QDirectFBPaintEngine::clipEnabledChanged() { Q_D(QDirectFBPaintEngine); - d->dirtyClip = true; QRasterPaintEngine::clipEnabledChanged(); + d->updateClip(); } void QDirectFBPaintEngine::penChanged() @@ -341,26 +342,49 @@ void QDirectFBPaintEngine::setState(QPainterState *state) { Q_D(QDirectFBPaintEngine); QRasterPaintEngine::setState(state); - d->dirtyClip = true; d->setPen(state->pen); d->opacity = quint8(state->opacity * 255); d->setCompositionMode(state->compositionMode()); d->setTransform(state->transform()); d->setRenderHints(state->renderHints); + if (d->surface) + d->updateClip(); } void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); - d->dirtyClip = true; + const bool wasInClip = d->inClip; + d->inClip = true; QRasterPaintEngine::clip(path, op); + if (!wasInClip) { + d->inClip = false; + d->updateClip(); + } +} + +void QDirectFBPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) +{ + Q_D(QDirectFBPaintEngine); + const bool wasInClip = d->inClip; + d->inClip = true; + QRasterPaintEngine::clip(region, op); + if (!wasInClip) { + d->inClip = false; + d->updateClip(); + } } void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); - d->dirtyClip = true; + const bool wasInClip = d->inClip; + d->inClip = true; QRasterPaintEngine::clip(rect, op); + if (!wasInClip) { + d->inClip = false; + d->updateClip(); + } } void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) @@ -371,7 +395,6 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) if (brush == Qt::NoBrush && pen == Qt::NoPen) return; - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || !d->simplePen @@ -401,7 +424,6 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) if (brush == Qt::NoBrush && pen == Qt::NoPen) return; - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || !d->simplePen @@ -426,7 +448,6 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) { Q_D(QDirectFBPaintEngine); - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || !d->simplePen @@ -448,7 +469,6 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) { Q_D(QDirectFBPaintEngine); - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || !d->simplePen @@ -491,7 +511,6 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, than the max image cache size we fall back to raster engine. */ - d->updateClip(); #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) @@ -534,7 +553,6 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, { Q_D(QDirectFBPaintEngine); - d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); @@ -569,7 +587,6 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, const QPointF &offset) { Q_D(QDirectFBPaintEngine); - d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); d->lock(); @@ -674,7 +691,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) Q_D(QDirectFBPaintEngine); if (brush.style() == Qt::NoBrush) return; - d->updateClip(); if (d->clipType != QDirectFBPaintEnginePrivate::ComplexClip) { switch (brush.style()) { case Qt::SolidPattern: { @@ -718,7 +734,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) if (!color.isValid()) return; Q_D(QDirectFBPaintEngine); - d->updateClip(); if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) { @@ -764,9 +779,9 @@ void QDirectFBPaintEngine::initImageCache(int size) QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) : surface(0), antialiased(false), simplePen(false), - transformationType(0), opacity(255), dirtyClip(true), + transformationType(0), opacity(255), clipType(ClipUnset), dfbDevice(0), - compositionModeStatus(0), q(p) + compositionModeStatus(0), inClip(false), q(p) { fb = QDirectFBScreen::instance()->dfb(); surfaceCache = new SurfaceCache; @@ -977,7 +992,6 @@ static inline qreal fixCoord(qreal rect_pos, qreal pixmapSize, qreal offset) void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &off) { - Q_ASSERT(!dirtyClip); Q_ASSERT(!(transformationType & Matrix_BlitsUnsupported)); const QTransform &transform = q->state()->matrix; const QRect destinationRect = transform.mapRect(dest).toRect().normalized(); @@ -1070,9 +1084,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix void QDirectFBPaintEnginePrivate::updateClip() { - if (!dirtyClip) - return; - + Q_ASSERT(surface); currentClip = QRect(); const QClipData *clipData = clip(); if (!clipData || !clipData->enabled) { @@ -1094,14 +1106,12 @@ void QDirectFBPaintEnginePrivate::updateClip() } else { clipType = ComplexClip; } - - dirtyClip = false; } void QDirectFBPaintEnginePrivate::systemStateChanged() { - dirtyClip = true; QRasterPaintEnginePrivate::systemStateChanged(); + updateClip(); } IDirectFBSurface *SurfaceCache::getSurface(const uint *buf, int size) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h index b939b68..80108b2 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h @@ -101,6 +101,7 @@ public: virtual void setState(QPainterState *state); virtual void clip(const QVectorPath &path, Qt::ClipOperation op); + virtual void clip(const QRegion ®ion, Qt::ClipOperation op); virtual void clip(const QRect &rect, Qt::ClipOperation op); static void initImageCache(int size); -- cgit v0.12 From 8d314cd4eb39015a196bc4a4edfe44592d74f3c0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 18:05:26 +0200 Subject: Autotest: unbreak test after overeager trolltech.com -> qt.nokia.com replacement --- tests/auto/qurl/tst_qurl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 5d909d8..fea48ea 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -2047,7 +2047,7 @@ void tst_QUrl::compat_decode_data() QTest::newRow("NormalStringEncoded") << QByteArray("file%20name") << QString("file name"); QTest::newRow("JustEncoded") << QByteArray("%20") << QString(" "); QTest::newRow("HTTPUrl") << QByteArray("http://qt.nokia.com") << QString("http://qt.nokia.com"); - QTest::newRow("HTTPUrlEncoded") << QByteArray("http://www%20trolltech%20com") << QString("http://qt.nokia.com"); + QTest::newRow("HTTPUrlEncoded") << QByteArray("http://qt%20nokia%20com") << QString("http://qt nokia com"); QTest::newRow("EmptyString") << QByteArray("") << QString(""); QTest::newRow("Task27166") << QByteArray("Fran%C3%A7aise") << QString("Française"); } @@ -2069,7 +2069,7 @@ void tst_QUrl::compat_encode_data() QTest::newRow("NormalStringEncoded") << QString("file name") << QByteArray("file%20name"); QTest::newRow("JustEncoded") << QString(" ") << QByteArray("%20"); QTest::newRow("HTTPUrl") << QString("http://qt.nokia.com") << QByteArray("http%3A//qt.nokia.com"); - QTest::newRow("HTTPUrlEncoded") << QString("http://qt.nokia.com") << QByteArray("http%3A//www%20trolltech%20com"); + QTest::newRow("HTTPUrlEncoded") << QString("http://qt nokia com") << QByteArray("http%3A//qt%20nokia%20com"); QTest::newRow("EmptyString") << QString("") << QByteArray(""); QTest::newRow("Task27166") << QString::fromLatin1("Française") << QByteArray("Fran%C3%A7aise"); } -- cgit v0.12 From b4fc4e93391438cffa05631f6d9065bfab519e0a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 18:56:32 +0200 Subject: Doc: explain that QUrl::toAce may fail if its input is not correct. --- src/corelib/io/qurl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index acbac36..4aae53d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5699,6 +5699,10 @@ QString QUrl::fromAce(const QByteArray &domain) Applications (IDNA) specification, which allows for domain names (like \c "example.com") to be written using international characters. + + This function return an empty QByteArra if \a domain is not a valid + hostname. Note, in particular, that IPv6 literals are not valid domain + names. */ QByteArray QUrl::toAce(const QString &domain) { -- cgit v0.12 From d313b5c43f83d69d9a9009dfa0bb29afa9276768 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 19:05:10 +0200 Subject: Autotest: update uic baselines after license header update. The license header update in e12a03d5 changed the .ui templates, but not the baselines in all cases. --- .../uic/baseline/Dialog_with_Buttons_Bottom.ui.h | 4 +- .../uic/baseline/Dialog_with_Buttons_Right.ui.h | 4 +- .../auto/uic/baseline/Dialog_without_Buttons.ui.h | 4 +- tests/auto/uic/baseline/Main_Window.ui.h | 4 +- tests/auto/uic/baseline/Widget.ui.h | 4 +- tests/auto/uic/baseline/addlinkdialog.ui.h | 4 +- tests/auto/uic/baseline/addtorrentform.ui.h | 4 +- tests/auto/uic/baseline/authenticationdialog.ui.h | 4 +- tests/auto/uic/baseline/backside.ui.h | 4 +- tests/auto/uic/baseline/batchtranslation.ui.h | 10 ++-- tests/auto/uic/baseline/bookmarkdialog.ui.h | 4 +- tests/auto/uic/baseline/bookwindow.ui.h | 4 +- tests/auto/uic/baseline/browserwidget.ui.h | 4 +- tests/auto/uic/baseline/calculator.ui.h | 4 +- tests/auto/uic/baseline/calculatorform.ui.h | 4 +- tests/auto/uic/baseline/certificateinfo.ui.h | 4 +- tests/auto/uic/baseline/chatdialog.ui.h | 4 +- tests/auto/uic/baseline/chatmainwindow.ui.h | 4 +- tests/auto/uic/baseline/chatsetnickname.ui.h | 4 +- tests/auto/uic/baseline/config.ui.h | 10 ++-- tests/auto/uic/baseline/connectdialog.ui.h | 4 +- tests/auto/uic/baseline/controller.ui.h | 4 +- tests/auto/uic/baseline/cookies.ui.h | 4 +- tests/auto/uic/baseline/cookiesexceptions.ui.h | 4 +- tests/auto/uic/baseline/default.ui.h | 4 +- tests/auto/uic/baseline/dialog.ui.h | 4 +- tests/auto/uic/baseline/downloaditem.ui.h | 4 +- tests/auto/uic/baseline/downloads.ui.h | 4 +- tests/auto/uic/baseline/embeddeddialog.ui.h | 4 +- tests/auto/uic/baseline/filespage.ui.h | 4 +- tests/auto/uic/baseline/filternamedialog.ui.h | 4 +- tests/auto/uic/baseline/filterpage.ui.h | 4 +- tests/auto/uic/baseline/finddialog.ui.h | 10 ++-- tests/auto/uic/baseline/form.ui.h | 4 +- tests/auto/uic/baseline/formwindowsettings.ui.h | 10 ++-- tests/auto/uic/baseline/generalpage.ui.h | 4 +- tests/auto/uic/baseline/gridpanel.ui.h | 4 +- tests/auto/uic/baseline/helpdialog.ui.h | 10 ++-- tests/auto/uic/baseline/history.ui.h | 4 +- tests/auto/uic/baseline/identifierpage.ui.h | 4 +- tests/auto/uic/baseline/imagedialog.ui.h | 4 +- tests/auto/uic/baseline/inputpage.ui.h | 4 +- tests/auto/uic/baseline/installdialog.ui.h | 4 +- tests/auto/uic/baseline/languagesdialog.ui.h | 4 +- tests/auto/uic/baseline/listwidgeteditor.ui.h | 10 ++-- tests/auto/uic/baseline/mainwindow.ui.h | 4 +- tests/auto/uic/baseline/mainwindowbase.ui.h | 10 ++-- tests/auto/uic/baseline/mydialog.ui.h | 4 +- tests/auto/uic/baseline/myform.ui.h | 4 +- tests/auto/uic/baseline/newactiondialog.ui.h | 10 ++-- .../uic/baseline/newdynamicpropertydialog.ui.h | 4 +- tests/auto/uic/baseline/newform.ui.h | 10 ++-- tests/auto/uic/baseline/orderdialog.ui.h | 10 ++-- tests/auto/uic/baseline/outputpage.ui.h | 4 +- tests/auto/uic/baseline/pagefold.ui.h | 4 +- tests/auto/uic/baseline/paletteeditor.ui.h | 10 ++-- .../uic/baseline/paletteeditoradvancedbase.ui.h | 10 ++-- tests/auto/uic/baseline/passworddialog.ui.h | 4 +- tests/auto/uic/baseline/pathpage.ui.h | 4 +- tests/auto/uic/baseline/phrasebookbox.ui.h | 10 ++-- tests/auto/uic/baseline/plugindialog.ui.h | 10 ++-- tests/auto/uic/baseline/preferencesdialog.ui.h | 4 +- .../uic/baseline/previewconfigurationwidget.ui.h | 4 +- tests/auto/uic/baseline/previewdialogbase.ui.h | 4 +- tests/auto/uic/baseline/previewwidget.ui.h | 10 ++-- tests/auto/uic/baseline/previewwidgetbase.ui.h | 10 ++-- tests/auto/uic/baseline/proxy.ui.h | 4 +- tests/auto/uic/baseline/qfiledialog.ui.h | 12 ++-- tests/auto/uic/baseline/qpagesetupwidget.ui.h | 4 +- .../auto/uic/baseline/qprintpropertieswidget.ui.h | 4 +- tests/auto/uic/baseline/qprintsettingsoutput.ui.h | 4 +- tests/auto/uic/baseline/qprintwidget.ui.h | 4 +- tests/auto/uic/baseline/qsqlconnectiondialog.ui.h | 4 +- tests/auto/uic/baseline/qtgradientdialog.ui.h | 10 ++-- tests/auto/uic/baseline/qtgradienteditor.ui.h | 69 +++++++++++----------- tests/auto/uic/baseline/qtgradientview.ui.h | 4 +- tests/auto/uic/baseline/qtgradientviewdialog.ui.h | 10 ++-- .../auto/uic/baseline/qtresourceeditordialog.ui.h | 4 +- tests/auto/uic/baseline/qttoolbardialog.ui.h | 4 +- tests/auto/uic/baseline/querywidget.ui.h | 4 +- tests/auto/uic/baseline/remotecontrol.ui.h | 4 +- tests/auto/uic/baseline/saveformastemplate.ui.h | 10 ++-- tests/auto/uic/baseline/settings.ui.h | 4 +- tests/auto/uic/baseline/signalslotdialog.ui.h | 4 +- tests/auto/uic/baseline/sslclient.ui.h | 4 +- tests/auto/uic/baseline/sslerrors.ui.h | 4 +- tests/auto/uic/baseline/statistics.ui.h | 10 ++-- tests/auto/uic/baseline/stringlisteditor.ui.h | 10 ++-- tests/auto/uic/baseline/stylesheeteditor.ui.h | 4 +- tests/auto/uic/baseline/tabbedbrowser.ui.h | 10 ++-- tests/auto/uic/baseline/tablewidgeteditor.ui.h | 10 ++-- tests/auto/uic/baseline/tetrixwindow.ui.h | 4 +- tests/auto/uic/baseline/textfinder.ui.h | 4 +- tests/auto/uic/baseline/topicchooser.ui.h | 4 +- tests/auto/uic/baseline/translatedialog.ui.h | 10 ++-- tests/auto/uic/baseline/translationsettings.ui.h | 4 +- tests/auto/uic/baseline/treewidgeteditor.ui.h | 10 ++-- tests/auto/uic/baseline/trpreviewtool.ui.h | 10 ++-- tests/auto/uic/baseline/validators.ui.h | 4 +- tests/auto/uic/baseline/wateringconfigdialog.ui.h | 4 +- 100 files changed, 342 insertions(+), 287 deletions(-) diff --git a/tests/auto/uic/baseline/Dialog_with_Buttons_Bottom.ui.h b/tests/auto/uic/baseline/Dialog_with_Buttons_Bottom.ui.h index 166dc60..efbeb97 100644 --- a/tests/auto/uic/baseline/Dialog_with_Buttons_Bottom.ui.h +++ b/tests/auto/uic/baseline/Dialog_with_Buttons_Bottom.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'Dialog_with_Buttons_Bottom.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/Dialog_with_Buttons_Right.ui.h b/tests/auto/uic/baseline/Dialog_with_Buttons_Right.ui.h index cbb3cc4..0f23ee3 100644 --- a/tests/auto/uic/baseline/Dialog_with_Buttons_Right.ui.h +++ b/tests/auto/uic/baseline/Dialog_with_Buttons_Right.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'Dialog_with_Buttons_Right.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/Dialog_without_Buttons.ui.h b/tests/auto/uic/baseline/Dialog_without_Buttons.ui.h index bb06a54..ff88063 100644 --- a/tests/auto/uic/baseline/Dialog_without_Buttons.ui.h +++ b/tests/auto/uic/baseline/Dialog_without_Buttons.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'Dialog_without_Buttons.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/Main_Window.ui.h b/tests/auto/uic/baseline/Main_Window.ui.h index 07a8389..4fbc750 100644 --- a/tests/auto/uic/baseline/Main_Window.ui.h +++ b/tests/auto/uic/baseline/Main_Window.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'Main_Window.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/Widget.ui.h b/tests/auto/uic/baseline/Widget.ui.h index bba9fd9..e49646e 100644 --- a/tests/auto/uic/baseline/Widget.ui.h +++ b/tests/auto/uic/baseline/Widget.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'Widget.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/addlinkdialog.ui.h b/tests/auto/uic/baseline/addlinkdialog.ui.h index 920a8f7..1b174ad 100644 --- a/tests/auto/uic/baseline/addlinkdialog.ui.h +++ b/tests/auto/uic/baseline/addlinkdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'addlinkdialog.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/addtorrentform.ui.h b/tests/auto/uic/baseline/addtorrentform.ui.h index 185ce2e..a454da9 100644 --- a/tests/auto/uic/baseline/addtorrentform.ui.h +++ b/tests/auto/uic/baseline/addtorrentform.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'addtorrentform.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/authenticationdialog.ui.h b/tests/auto/uic/baseline/authenticationdialog.ui.h index b46c05d..dd27f5c 100644 --- a/tests/auto/uic/baseline/authenticationdialog.ui.h +++ b/tests/auto/uic/baseline/authenticationdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'authenticationdialog.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/backside.ui.h b/tests/auto/uic/baseline/backside.ui.h index 6fdab4b..1660846 100644 --- a/tests/auto/uic/baseline/backside.ui.h +++ b/tests/auto/uic/baseline/backside.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'backside.ui' ** -** Created: Tue Jun 17 09:18:47 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/batchtranslation.ui.h b/tests/auto/uic/baseline/batchtranslation.ui.h index d781c34..2285e1b 100644 --- a/tests/auto/uic/baseline/batchtranslation.ui.h +++ b/tests/auto/uic/baseline/batchtranslation.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'batchtranslation.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/bookmarkdialog.ui.h b/tests/auto/uic/baseline/bookmarkdialog.ui.h index 1db7dca..0c7764f 100644 --- a/tests/auto/uic/baseline/bookmarkdialog.ui.h +++ b/tests/auto/uic/baseline/bookmarkdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'bookmarkdialog.ui' ** -** Created: Mon Jun 16 18:01:55 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/bookwindow.ui.h b/tests/auto/uic/baseline/bookwindow.ui.h index 776f9e9..92639ec 100644 --- a/tests/auto/uic/baseline/bookwindow.ui.h +++ b/tests/auto/uic/baseline/bookwindow.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'bookwindow.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/browserwidget.ui.h b/tests/auto/uic/baseline/browserwidget.ui.h index c1ca60f..1a3a282 100644 --- a/tests/auto/uic/baseline/browserwidget.ui.h +++ b/tests/auto/uic/baseline/browserwidget.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'browserwidget.ui' ** -** Created: Mon Jun 16 18:01:09 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/calculator.ui.h b/tests/auto/uic/baseline/calculator.ui.h index f476d9b..ace5f44 100644 --- a/tests/auto/uic/baseline/calculator.ui.h +++ b/tests/auto/uic/baseline/calculator.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'calculator.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/calculatorform.ui.h b/tests/auto/uic/baseline/calculatorform.ui.h index 1c575e8..2a369c7 100644 --- a/tests/auto/uic/baseline/calculatorform.ui.h +++ b/tests/auto/uic/baseline/calculatorform.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'calculatorform.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/certificateinfo.ui.h b/tests/auto/uic/baseline/certificateinfo.ui.h index 548bec5..6d13787 100644 --- a/tests/auto/uic/baseline/certificateinfo.ui.h +++ b/tests/auto/uic/baseline/certificateinfo.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'certificateinfo.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/chatdialog.ui.h b/tests/auto/uic/baseline/chatdialog.ui.h index c9f2693..ba1b99f 100644 --- a/tests/auto/uic/baseline/chatdialog.ui.h +++ b/tests/auto/uic/baseline/chatdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'chatdialog.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/chatmainwindow.ui.h b/tests/auto/uic/baseline/chatmainwindow.ui.h index 87ac882..d4d4996 100644 --- a/tests/auto/uic/baseline/chatmainwindow.ui.h +++ b/tests/auto/uic/baseline/chatmainwindow.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'chatmainwindow.ui' ** -** Created: Mon Sep 1 09:31:02 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/chatsetnickname.ui.h b/tests/auto/uic/baseline/chatsetnickname.ui.h index 54f48e7..4b081b6 100644 --- a/tests/auto/uic/baseline/chatsetnickname.ui.h +++ b/tests/auto/uic/baseline/chatsetnickname.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'chatsetnickname.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/config.ui.h b/tests/auto/uic/baseline/config.ui.h index a14d7c8..f708f6b 100644 --- a/tests/auto/uic/baseline/config.ui.h +++ b/tests/auto/uic/baseline/config.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'config.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/connectdialog.ui.h b/tests/auto/uic/baseline/connectdialog.ui.h index d7e0eaf..880653e 100644 --- a/tests/auto/uic/baseline/connectdialog.ui.h +++ b/tests/auto/uic/baseline/connectdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'connectdialog.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/controller.ui.h b/tests/auto/uic/baseline/controller.ui.h index c5cd1fe..609c32c 100644 --- a/tests/auto/uic/baseline/controller.ui.h +++ b/tests/auto/uic/baseline/controller.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'controller.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/cookies.ui.h b/tests/auto/uic/baseline/cookies.ui.h index 0b4d88a..5e0bf88 100644 --- a/tests/auto/uic/baseline/cookies.ui.h +++ b/tests/auto/uic/baseline/cookies.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'cookies.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/cookiesexceptions.ui.h b/tests/auto/uic/baseline/cookiesexceptions.ui.h index 12e80d8..9eaf01c 100644 --- a/tests/auto/uic/baseline/cookiesexceptions.ui.h +++ b/tests/auto/uic/baseline/cookiesexceptions.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'cookiesexceptions.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/default.ui.h b/tests/auto/uic/baseline/default.ui.h index f68a93e..093e7b4 100644 --- a/tests/auto/uic/baseline/default.ui.h +++ b/tests/auto/uic/baseline/default.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'default.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/dialog.ui.h b/tests/auto/uic/baseline/dialog.ui.h index d65c10a..95fa40b 100644 --- a/tests/auto/uic/baseline/dialog.ui.h +++ b/tests/auto/uic/baseline/dialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'dialog.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/downloaditem.ui.h b/tests/auto/uic/baseline/downloaditem.ui.h index 341fdd2..c211fa0 100644 --- a/tests/auto/uic/baseline/downloaditem.ui.h +++ b/tests/auto/uic/baseline/downloaditem.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'downloaditem.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/downloads.ui.h b/tests/auto/uic/baseline/downloads.ui.h index 70a038a..f5028c8 100644 --- a/tests/auto/uic/baseline/downloads.ui.h +++ b/tests/auto/uic/baseline/downloads.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'downloads.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/embeddeddialog.ui.h b/tests/auto/uic/baseline/embeddeddialog.ui.h index 3dd36a6..050f0ab 100644 --- a/tests/auto/uic/baseline/embeddeddialog.ui.h +++ b/tests/auto/uic/baseline/embeddeddialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'embeddeddialog.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/filespage.ui.h b/tests/auto/uic/baseline/filespage.ui.h index 15a0f5b..3b4c156 100644 --- a/tests/auto/uic/baseline/filespage.ui.h +++ b/tests/auto/uic/baseline/filespage.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'filespage.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/filternamedialog.ui.h b/tests/auto/uic/baseline/filternamedialog.ui.h index ad435c1..64713b4d 100644 --- a/tests/auto/uic/baseline/filternamedialog.ui.h +++ b/tests/auto/uic/baseline/filternamedialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'filternamedialog.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/filterpage.ui.h b/tests/auto/uic/baseline/filterpage.ui.h index e7fb7fb..57beb6b 100644 --- a/tests/auto/uic/baseline/filterpage.ui.h +++ b/tests/auto/uic/baseline/filterpage.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'filterpage.ui' ** -** Created: Mon Jun 16 17:58:59 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/finddialog.ui.h b/tests/auto/uic/baseline/finddialog.ui.h index 7cd2b69..809657a 100644 --- a/tests/auto/uic/baseline/finddialog.ui.h +++ b/tests/auto/uic/baseline/finddialog.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'finddialog.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/form.ui.h b/tests/auto/uic/baseline/form.ui.h index 60f5a14..4edbc42 100644 --- a/tests/auto/uic/baseline/form.ui.h +++ b/tests/auto/uic/baseline/form.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'form.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/formwindowsettings.ui.h b/tests/auto/uic/baseline/formwindowsettings.ui.h index 99bb61c..71e6c6d 100644 --- a/tests/auto/uic/baseline/formwindowsettings.ui.h +++ b/tests/auto/uic/baseline/formwindowsettings.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'formwindowsettings.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/generalpage.ui.h b/tests/auto/uic/baseline/generalpage.ui.h index 0dcc6ec..ed72265 100644 --- a/tests/auto/uic/baseline/generalpage.ui.h +++ b/tests/auto/uic/baseline/generalpage.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'generalpage.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/gridpanel.ui.h b/tests/auto/uic/baseline/gridpanel.ui.h index 1bc2f04..b722753 100644 --- a/tests/auto/uic/baseline/gridpanel.ui.h +++ b/tests/auto/uic/baseline/gridpanel.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'gridpanel.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/helpdialog.ui.h b/tests/auto/uic/baseline/helpdialog.ui.h index 269f5b8..b64e251 100644 --- a/tests/auto/uic/baseline/helpdialog.ui.h +++ b/tests/auto/uic/baseline/helpdialog.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'helpdialog.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/history.ui.h b/tests/auto/uic/baseline/history.ui.h index 16553df..f151e53 100644 --- a/tests/auto/uic/baseline/history.ui.h +++ b/tests/auto/uic/baseline/history.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'history.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/identifierpage.ui.h b/tests/auto/uic/baseline/identifierpage.ui.h index 24aecf8..e60c277 100644 --- a/tests/auto/uic/baseline/identifierpage.ui.h +++ b/tests/auto/uic/baseline/identifierpage.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'identifierpage.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/imagedialog.ui.h b/tests/auto/uic/baseline/imagedialog.ui.h index 2f51b65..a22a85e 100644 --- a/tests/auto/uic/baseline/imagedialog.ui.h +++ b/tests/auto/uic/baseline/imagedialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'imagedialog.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/inputpage.ui.h b/tests/auto/uic/baseline/inputpage.ui.h index 23f2a0b..938eacb 100644 --- a/tests/auto/uic/baseline/inputpage.ui.h +++ b/tests/auto/uic/baseline/inputpage.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'inputpage.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/installdialog.ui.h b/tests/auto/uic/baseline/installdialog.ui.h index e6180f7..1a7166d 100644 --- a/tests/auto/uic/baseline/installdialog.ui.h +++ b/tests/auto/uic/baseline/installdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'installdialog.ui' ** -** Created: Thu Jul 10 09:47:34 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/languagesdialog.ui.h b/tests/auto/uic/baseline/languagesdialog.ui.h index ff837c1..ffdc9c0 100644 --- a/tests/auto/uic/baseline/languagesdialog.ui.h +++ b/tests/auto/uic/baseline/languagesdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'languagesdialog.ui' ** -** Created: Fri May 15 16:58:03 2009 -** by: Qt User Interface Compiler version 4.5.2 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/listwidgeteditor.ui.h b/tests/auto/uic/baseline/listwidgeteditor.ui.h index ac9f801..e848252 100644 --- a/tests/auto/uic/baseline/listwidgeteditor.ui.h +++ b/tests/auto/uic/baseline/listwidgeteditor.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'listwidgeteditor.ui' ** -** Created: Mon Jun 16 17:54:30 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/mainwindow.ui.h b/tests/auto/uic/baseline/mainwindow.ui.h index 11b0196..6a84b18 100644 --- a/tests/auto/uic/baseline/mainwindow.ui.h +++ b/tests/auto/uic/baseline/mainwindow.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'mainwindow.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/mainwindowbase.ui.h b/tests/auto/uic/baseline/mainwindowbase.ui.h index 10b028f..ce03ae9 100644 --- a/tests/auto/uic/baseline/mainwindowbase.ui.h +++ b/tests/auto/uic/baseline/mainwindowbase.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'mainwindowbase.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/mydialog.ui.h b/tests/auto/uic/baseline/mydialog.ui.h index ac7b458..d3da712 100644 --- a/tests/auto/uic/baseline/mydialog.ui.h +++ b/tests/auto/uic/baseline/mydialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'mydialog.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/myform.ui.h b/tests/auto/uic/baseline/myform.ui.h index 74c83f5..45ed883 100644 --- a/tests/auto/uic/baseline/myform.ui.h +++ b/tests/auto/uic/baseline/myform.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'myform.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/newactiondialog.ui.h b/tests/auto/uic/baseline/newactiondialog.ui.h index 3fecddb..fc13fbc 100644 --- a/tests/auto/uic/baseline/newactiondialog.ui.h +++ b/tests/auto/uic/baseline/newactiondialog.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'newactiondialog.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/newdynamicpropertydialog.ui.h b/tests/auto/uic/baseline/newdynamicpropertydialog.ui.h index f8e5b51..4ee3d98 100644 --- a/tests/auto/uic/baseline/newdynamicpropertydialog.ui.h +++ b/tests/auto/uic/baseline/newdynamicpropertydialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'newdynamicpropertydialog.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/newform.ui.h b/tests/auto/uic/baseline/newform.ui.h index 13b5572..2af4836 100644 --- a/tests/auto/uic/baseline/newform.ui.h +++ b/tests/auto/uic/baseline/newform.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'newform.ui' ** -** Created: Mon Jun 16 17:56:52 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/orderdialog.ui.h b/tests/auto/uic/baseline/orderdialog.ui.h index 12d551f..6d6efa7 100644 --- a/tests/auto/uic/baseline/orderdialog.ui.h +++ b/tests/auto/uic/baseline/orderdialog.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'orderdialog.ui' ** -** Created: Mon Jun 16 17:55:54 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/outputpage.ui.h b/tests/auto/uic/baseline/outputpage.ui.h index 0b68cb9..9f071f0 100644 --- a/tests/auto/uic/baseline/outputpage.ui.h +++ b/tests/auto/uic/baseline/outputpage.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'outputpage.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/pagefold.ui.h b/tests/auto/uic/baseline/pagefold.ui.h index 5cc5836..d713985 100644 --- a/tests/auto/uic/baseline/pagefold.ui.h +++ b/tests/auto/uic/baseline/pagefold.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'pagefold.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/paletteeditor.ui.h b/tests/auto/uic/baseline/paletteeditor.ui.h index ad34964..3b62872 100644 --- a/tests/auto/uic/baseline/paletteeditor.ui.h +++ b/tests/auto/uic/baseline/paletteeditor.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'paletteeditor.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h b/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h index 7072b6b..44d03be 100644 --- a/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h +++ b/tests/auto/uic/baseline/paletteeditoradvancedbase.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'paletteeditoradvancedbase.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/passworddialog.ui.h b/tests/auto/uic/baseline/passworddialog.ui.h index be80298..83beeac 100644 --- a/tests/auto/uic/baseline/passworddialog.ui.h +++ b/tests/auto/uic/baseline/passworddialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'passworddialog.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/pathpage.ui.h b/tests/auto/uic/baseline/pathpage.ui.h index 257c191..7c39073 100644 --- a/tests/auto/uic/baseline/pathpage.ui.h +++ b/tests/auto/uic/baseline/pathpage.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'pathpage.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/phrasebookbox.ui.h b/tests/auto/uic/baseline/phrasebookbox.ui.h index aa132b3..4826676 100644 --- a/tests/auto/uic/baseline/phrasebookbox.ui.h +++ b/tests/auto/uic/baseline/phrasebookbox.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'phrasebookbox.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/plugindialog.ui.h b/tests/auto/uic/baseline/plugindialog.ui.h index e4f58c1..4b99b6e 100644 --- a/tests/auto/uic/baseline/plugindialog.ui.h +++ b/tests/auto/uic/baseline/plugindialog.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'plugindialog.ui' ** -** Created: Mon Jun 16 17:52:32 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:31 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/preferencesdialog.ui.h b/tests/auto/uic/baseline/preferencesdialog.ui.h index a1f5ac2..56c5926 100644 --- a/tests/auto/uic/baseline/preferencesdialog.ui.h +++ b/tests/auto/uic/baseline/preferencesdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'preferencesdialog.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/previewconfigurationwidget.ui.h b/tests/auto/uic/baseline/previewconfigurationwidget.ui.h index 4a7b694..cc56b4c 100644 --- a/tests/auto/uic/baseline/previewconfigurationwidget.ui.h +++ b/tests/auto/uic/baseline/previewconfigurationwidget.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'previewconfigurationwidget.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/previewdialogbase.ui.h b/tests/auto/uic/baseline/previewdialogbase.ui.h index 822990c..4bb2980 100644 --- a/tests/auto/uic/baseline/previewdialogbase.ui.h +++ b/tests/auto/uic/baseline/previewdialogbase.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'previewdialogbase.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/previewwidget.ui.h b/tests/auto/uic/baseline/previewwidget.ui.h index 4832430..8076958 100644 --- a/tests/auto/uic/baseline/previewwidget.ui.h +++ b/tests/auto/uic/baseline/previewwidget.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'previewwidget.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/previewwidgetbase.ui.h b/tests/auto/uic/baseline/previewwidgetbase.ui.h index 6a5551e..b8d55c8 100644 --- a/tests/auto/uic/baseline/previewwidgetbase.ui.h +++ b/tests/auto/uic/baseline/previewwidgetbase.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'previewwidgetbase.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/proxy.ui.h b/tests/auto/uic/baseline/proxy.ui.h index d22edef..3542966 100644 --- a/tests/auto/uic/baseline/proxy.ui.h +++ b/tests/auto/uic/baseline/proxy.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'proxy.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qfiledialog.ui.h b/tests/auto/uic/baseline/qfiledialog.ui.h index 396e0d0..356183e 100644 --- a/tests/auto/uic/baseline/qfiledialog.ui.h +++ b/tests/auto/uic/baseline/qfiledialog.ui.h @@ -1,9 +1,10 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the autotests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'qfiledialog.ui' ** -** Created: Mon Jun 16 17:51:48 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qpagesetupwidget.ui.h b/tests/auto/uic/baseline/qpagesetupwidget.ui.h index 4694409..93f5eb4 100644 --- a/tests/auto/uic/baseline/qpagesetupwidget.ui.h +++ b/tests/auto/uic/baseline/qpagesetupwidget.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'qpagesetupwidget.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qprintpropertieswidget.ui.h b/tests/auto/uic/baseline/qprintpropertieswidget.ui.h index 626fee7..a2c2e1f 100644 --- a/tests/auto/uic/baseline/qprintpropertieswidget.ui.h +++ b/tests/auto/uic/baseline/qprintpropertieswidget.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'qprintpropertieswidget.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qprintsettingsoutput.ui.h b/tests/auto/uic/baseline/qprintsettingsoutput.ui.h index a6360ee..bb00a36 100644 --- a/tests/auto/uic/baseline/qprintsettingsoutput.ui.h +++ b/tests/auto/uic/baseline/qprintsettingsoutput.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'qprintsettingsoutput.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qprintwidget.ui.h b/tests/auto/uic/baseline/qprintwidget.ui.h index 99d6486..2600268 100644 --- a/tests/auto/uic/baseline/qprintwidget.ui.h +++ b/tests/auto/uic/baseline/qprintwidget.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'qprintwidget.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qsqlconnectiondialog.ui.h b/tests/auto/uic/baseline/qsqlconnectiondialog.ui.h index 165c7d7..37297bf 100644 --- a/tests/auto/uic/baseline/qsqlconnectiondialog.ui.h +++ b/tests/auto/uic/baseline/qsqlconnectiondialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'qsqlconnectiondialog.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qtgradientdialog.ui.h b/tests/auto/uic/baseline/qtgradientdialog.ui.h index 26ed776..43521e9 100644 --- a/tests/auto/uic/baseline/qtgradientdialog.ui.h +++ b/tests/auto/uic/baseline/qtgradientdialog.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'qtgradientdialog.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qtgradienteditor.ui.h b/tests/auto/uic/baseline/qtgradienteditor.ui.h index 00a72bd..e1365e4 100644 --- a/tests/auto/uic/baseline/qtgradienteditor.ui.h +++ b/tests/auto/uic/baseline/qtgradienteditor.ui.h @@ -1,49 +1,50 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the autotests of the Qt Toolkit. +** This file is part of the tools applications of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** This file may be used under the terms of the GNU General Public +** License versions 2.0 or 3.0 as published by the Free Software +** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Alternatively you may (at +** your option) use any later version of the GNU General Public +** License if such license has been publicly approved by Nokia Corporation and/or its subsidiary(-ies) +** (or its successors, if any) and the KDE Free Qt Foundation. In +** addition, as a special exception, Trolltech gives you certain +** additional rights. These rights are described in the Trolltech GPL +** Exception version 1.2, which can be found at +** http://qt.nokia.com/products/qt/gplexception/ and in the file +** GPL_EXCEPTION.txt in this package. ** -** 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. +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. If +** you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. ** -** 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. +** In addition, as a special exception, Trolltech, as the sole +** copyright holder for Qt Designer, grants users of the Qt/Eclipse +** Integration plug-in the right for the Qt/Eclipse Integration to +** link to functionality provided by Qt Designer and its related +** libraries. ** -** 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. +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly +** granted herein. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'qtgradienteditor.ui' ** -** Created: Mon Jun 16 17:50:21 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qtgradientview.ui.h b/tests/auto/uic/baseline/qtgradientview.ui.h index 809cf5b..d929d6f 100644 --- a/tests/auto/uic/baseline/qtgradientview.ui.h +++ b/tests/auto/uic/baseline/qtgradientview.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'qtgradientview.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qtgradientviewdialog.ui.h b/tests/auto/uic/baseline/qtgradientviewdialog.ui.h index 1f34727..8ace8b7 100644 --- a/tests/auto/uic/baseline/qtgradientviewdialog.ui.h +++ b/tests/auto/uic/baseline/qtgradientviewdialog.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'qtgradientviewdialog.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qtresourceeditordialog.ui.h b/tests/auto/uic/baseline/qtresourceeditordialog.ui.h index a08a16c..de52a62 100644 --- a/tests/auto/uic/baseline/qtresourceeditordialog.ui.h +++ b/tests/auto/uic/baseline/qtresourceeditordialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'qtresourceeditordialog.ui' ** -** Created: Mon Jun 16 17:45:38 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/qttoolbardialog.ui.h b/tests/auto/uic/baseline/qttoolbardialog.ui.h index 9099553..5651abc 100644 --- a/tests/auto/uic/baseline/qttoolbardialog.ui.h +++ b/tests/auto/uic/baseline/qttoolbardialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'qttoolbardialog.ui' ** -** Created: Mon Jun 16 17:42:37 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/querywidget.ui.h b/tests/auto/uic/baseline/querywidget.ui.h index 8afcf54..e078ed4 100644 --- a/tests/auto/uic/baseline/querywidget.ui.h +++ b/tests/auto/uic/baseline/querywidget.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'querywidget.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/remotecontrol.ui.h b/tests/auto/uic/baseline/remotecontrol.ui.h index 3d183f7..eb7adc9 100644 --- a/tests/auto/uic/baseline/remotecontrol.ui.h +++ b/tests/auto/uic/baseline/remotecontrol.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'remotecontrol.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/saveformastemplate.ui.h b/tests/auto/uic/baseline/saveformastemplate.ui.h index c46b5e6..ef709df 100644 --- a/tests/auto/uic/baseline/saveformastemplate.ui.h +++ b/tests/auto/uic/baseline/saveformastemplate.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'saveformastemplate.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/settings.ui.h b/tests/auto/uic/baseline/settings.ui.h index 98cb6ee..7df5c77 100644 --- a/tests/auto/uic/baseline/settings.ui.h +++ b/tests/auto/uic/baseline/settings.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'settings.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/signalslotdialog.ui.h b/tests/auto/uic/baseline/signalslotdialog.ui.h index f3ce8bc..f7e9820 100644 --- a/tests/auto/uic/baseline/signalslotdialog.ui.h +++ b/tests/auto/uic/baseline/signalslotdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'signalslotdialog.ui' ** -** Created: Mon Jun 16 16:18:52 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/sslclient.ui.h b/tests/auto/uic/baseline/sslclient.ui.h index aee0224..bf4014d 100644 --- a/tests/auto/uic/baseline/sslclient.ui.h +++ b/tests/auto/uic/baseline/sslclient.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'sslclient.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/sslerrors.ui.h b/tests/auto/uic/baseline/sslerrors.ui.h index f999be0..3131a21 100644 --- a/tests/auto/uic/baseline/sslerrors.ui.h +++ b/tests/auto/uic/baseline/sslerrors.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'sslerrors.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/statistics.ui.h b/tests/auto/uic/baseline/statistics.ui.h index 41c31fd..ea9ab00 100644 --- a/tests/auto/uic/baseline/statistics.ui.h +++ b/tests/auto/uic/baseline/statistics.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'statistics.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/stringlisteditor.ui.h b/tests/auto/uic/baseline/stringlisteditor.ui.h index 29f2e28..8f0ba8e 100644 --- a/tests/auto/uic/baseline/stringlisteditor.ui.h +++ b/tests/auto/uic/baseline/stringlisteditor.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'stringlisteditor.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/stylesheeteditor.ui.h b/tests/auto/uic/baseline/stylesheeteditor.ui.h index a99f274..697fbe0 100644 --- a/tests/auto/uic/baseline/stylesheeteditor.ui.h +++ b/tests/auto/uic/baseline/stylesheeteditor.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'stylesheeteditor.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/tabbedbrowser.ui.h b/tests/auto/uic/baseline/tabbedbrowser.ui.h index bebbc59..f347740 100644 --- a/tests/auto/uic/baseline/tabbedbrowser.ui.h +++ b/tests/auto/uic/baseline/tabbedbrowser.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'tabbedbrowser.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/tablewidgeteditor.ui.h b/tests/auto/uic/baseline/tablewidgeteditor.ui.h index 5cb0341..7e1a39f 100644 --- a/tests/auto/uic/baseline/tablewidgeteditor.ui.h +++ b/tests/auto/uic/baseline/tablewidgeteditor.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'tablewidgeteditor.ui' ** -** Created: Mon Jun 16 17:48:45 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/tetrixwindow.ui.h b/tests/auto/uic/baseline/tetrixwindow.ui.h index 50ed416..b6b048b 100644 --- a/tests/auto/uic/baseline/tetrixwindow.ui.h +++ b/tests/auto/uic/baseline/tetrixwindow.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'tetrixwindow.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/textfinder.ui.h b/tests/auto/uic/baseline/textfinder.ui.h index 546ff17..62c2447 100644 --- a/tests/auto/uic/baseline/textfinder.ui.h +++ b/tests/auto/uic/baseline/textfinder.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'textfinder.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/topicchooser.ui.h b/tests/auto/uic/baseline/topicchooser.ui.h index 65cf205..9c4cdf0 100644 --- a/tests/auto/uic/baseline/topicchooser.ui.h +++ b/tests/auto/uic/baseline/topicchooser.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'topicchooser.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/translatedialog.ui.h b/tests/auto/uic/baseline/translatedialog.ui.h index ab9604c..14b7c1b 100644 --- a/tests/auto/uic/baseline/translatedialog.ui.h +++ b/tests/auto/uic/baseline/translatedialog.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'translatedialog.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/translationsettings.ui.h b/tests/auto/uic/baseline/translationsettings.ui.h index e36545e..d0f5257 100644 --- a/tests/auto/uic/baseline/translationsettings.ui.h +++ b/tests/auto/uic/baseline/translationsettings.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'translationsettings.ui' ** -** Created: Mon Sep 1 09:31:03 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/treewidgeteditor.ui.h b/tests/auto/uic/baseline/treewidgeteditor.ui.h index 43b1fcd..e018974 100644 --- a/tests/auto/uic/baseline/treewidgeteditor.ui.h +++ b/tests/auto/uic/baseline/treewidgeteditor.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'treewidgeteditor.ui' ** -** Created: Mon Jun 16 17:47:26 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/trpreviewtool.ui.h b/tests/auto/uic/baseline/trpreviewtool.ui.h index 1d8bf5e..cd37fb6 100644 --- a/tests/auto/uic/baseline/trpreviewtool.ui.h +++ b/tests/auto/uic/baseline/trpreviewtool.ui.h @@ -1,4 +1,5 @@ -/**************************************************************************** +/* +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -37,13 +38,14 @@ ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** -****************************************************************************/ +********************************************************************* +*/ /******************************************************************************** ** Form generated from reading UI file 'trpreviewtool.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/validators.ui.h b/tests/auto/uic/baseline/validators.ui.h index 07e114a..c82cac5 100644 --- a/tests/auto/uic/baseline/validators.ui.h +++ b/tests/auto/uic/baseline/validators.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'validators.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/uic/baseline/wateringconfigdialog.ui.h b/tests/auto/uic/baseline/wateringconfigdialog.ui.h index 43120a5..0bac30d 100644 --- a/tests/auto/uic/baseline/wateringconfigdialog.ui.h +++ b/tests/auto/uic/baseline/wateringconfigdialog.ui.h @@ -1,8 +1,8 @@ /******************************************************************************** ** Form generated from reading UI file 'wateringconfigdialog.ui' ** -** Created: Thu Jul 10 09:47:35 2008 -** by: Qt User Interface Compiler version 4.5.0 +** Created: Tue Aug 18 19:03:32 2009 +** by: Qt User Interface Compiler version 4.6.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ -- cgit v0.12 From 8bea43ccb0f53234f87e4aa4d27371b741005222 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 19:15:33 +0200 Subject: Autotest: accept that the platform's UTF-8 codec can be buggy. We shouldn't fail in our autotests because the platform is buggy. But note the problem. We should report the bugs upstream... --- tests/auto/utf8/tst_utf8.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/auto/utf8/tst_utf8.cpp b/tests/auto/utf8/tst_utf8.cpp index 0d754b0..f255e6e 100644 --- a/tests/auto/utf8/tst_utf8.cpp +++ b/tests/auto/utf8/tst_utf8.cpp @@ -299,10 +299,19 @@ void tst_Utf8::invalidUtf8_data() void tst_Utf8::invalidUtf8() { QFETCH(QByteArray, utf8); + QFETCH_GLOBAL(bool, useLocale); QSharedPointer decoder = QSharedPointer(codec->makeDecoder()); QString decoded = decoder->toUnicode(utf8); - QVERIFY(decoder->hasFailure()); + + // Only enforce correctness on our UTF-8 decoder + // The system's UTF-8 codec is sometimes buggy + // GNU libc's iconv is known to accept U+FFFF and U+FFFE encoded as UTF-8 + // OS X's iconv is known to accept those, plus surrogates and codepoints above U+10FFFF + if (!useLocale) + QVERIFY(decoder->hasFailure()); + else if (!decoder->hasFailure()) + qWarning("System codec does not report failure when it should. Should report bug upstream."); } QTEST_MAIN(tst_Utf8) -- cgit v0.12 From 3ed5b5ebf5b360dedbba14c03f6ca5701b3b9290 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 19:22:52 +0200 Subject: Remove a global destructor from QtDBus. Instead, only run the unload code if we successfully loaded. --- src/dbus/qdbus_symbols.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index ca0147a..356b14c 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "qdbus_symbols_p.h" #include #include #include @@ -52,7 +53,7 @@ void *qdbus_resolve_me(const char *name); static QLibrary *qdbus_libdbus = 0; -void qdbus_unloadLibDBus() +static void qdbus_unloadLibDBus() { delete qdbus_libdbus; qdbus_libdbus = 0; @@ -76,8 +77,11 @@ bool qdbus_loadLibDBus() lib->setFileName(QLatin1String("dbus-1")); for (uint i = 0; i < sizeof(majorversions) / sizeof(majorversions[0]); ++i) { lib->setFileNameAndVersion(lib->fileName(), majorversions[i]); - if (lib->load() && lib->resolve("dbus_connection_open_private")) + if (lib->load() && lib->resolve("dbus_connection_open_private")) { + struct Unloader { ~Unloader() { qdbus_unloadLibDBus(); } }; + static Unloader unloader; return true; + } lib->unload(); } @@ -107,8 +111,6 @@ void *qdbus_resolve_me(const char *name) return ptr; } -Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus) - QT_END_NAMESPACE #endif -- cgit v0.12 From 981e6442b98a2377a60dd56c23491de922080ef7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 19:40:55 +0200 Subject: Remove a global static in QtTest: we can do the same with dynamic allocation. --- src/testlib/qtestcase.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index a144923..15c49e1 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -808,12 +808,12 @@ namespace QTest { static QObject *currentTestObject = 0; - struct TestFunction { + static struct TestFunction { TestFunction():function(0), data(0) {} ~TestFunction() { delete [] data; } int function; char *data; - } testFuncs[512]; + } *testFuncs; /** * Contains the count of test functions that was supplied @@ -1120,6 +1120,11 @@ static void qParseArgs(int argc, char *argv[]) exit(1); } ++QTest::lastTestFuncIdx; + if (!QTest::testFuncs) { + struct Cleanup { ~Cleanup() { delete[] QTest::testFuncs; } }; + static Cleanup cleanup; + QTest::testFuncs = new TestFunction[512]; + } QTest::testFuncs[QTest::lastTestFuncIdx].function = idx; QTest::testFuncs[QTest::lastTestFuncIdx].data = data; QTEST_ASSERT(QTest::lastTestFuncIdx < 512); -- cgit v0.12 From de1005fab824b134f36ea2b957f1ae219c2de6a5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 19:42:39 +0200 Subject: Autotest: don't check Qt3Support and QtCLucene for global statics. We won't fix any issues in those libraries anyway, so don't waste time checking. --- tests/auto/symbols/tst_symbols.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/auto/symbols/tst_symbols.cpp b/tests/auto/symbols/tst_symbols.cpp index 784c979..fea3380 100644 --- a/tests/auto/symbols/tst_symbols.cpp +++ b/tests/auto/symbols/tst_symbols.cpp @@ -111,11 +111,19 @@ void tst_Symbols::globalObjects() bool isFailed = false; - QDir dir(qgetenv("QTDIR") + "/lib", "*.so"); + QDir dir(QLibraryInfo::location(QLibraryInfo::LibrariesPath), "*.so"); QStringList files = dir.entryList(); QVERIFY(!files.isEmpty()); foreach (QString lib, files) { + if (lib == "libQtCLucene.so") { + // skip this library, it's 3rd-party C++ + continue; + } + if (lib == "libQt3Support.so") { + // we're not going to fix these issues anyway, so skip this library + continue; + } QProcess proc; proc.start("nm", -- cgit v0.12 From 9e075992bae92366c80764cc26702b7abc1a5977 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 19:46:53 +0200 Subject: Autotest: Revert 96b6a3c9cd8 in tst_qnetworkcookiejar The change of URLs in Qt broke the tests that operated on URLs. This wasn't properly done, so revert to the last working values. --- .../qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 92b7ae5..9bf43ea 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -227,17 +227,17 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() QTest::newRow("no-match-2") << allCookies << "http://foo.bar/web" << result; QTest::newRow("no-match-3") << allCookies << "http://foo.bar/web/wiki" << result; QTest::newRow("no-match-4") << allCookies << "http://trolltech.com" << result; - QTest::newRow("no-match-5") << allCookies << "http://qt.nokia.com" << result; + QTest::newRow("no-match-5") << allCookies << "http://www.trolltech.com" << result; QTest::newRow("no-match-6") << allCookies << "http://trolltech.com/webinar" << result; - QTest::newRow("no-match-7") << allCookies << "http://qt.nokia.com/webinar" << result; + QTest::newRow("no-match-7") << allCookies << "http://www.trolltech.com/webinar" << result; result = allCookies; QTest::newRow("match-1") << allCookies << "http://trolltech.com/web" << result; QTest::newRow("match-2") << allCookies << "http://trolltech.com/web/" << result; QTest::newRow("match-3") << allCookies << "http://trolltech.com/web/content" << result; - QTest::newRow("match-4") << allCookies << "http://qt.nokia.com/web" << result; - QTest::newRow("match-4") << allCookies << "http://qt.nokia.com/web/" << result; - QTest::newRow("match-6") << allCookies << "http://qt.nokia.com/web/content" << result; + QTest::newRow("match-4") << allCookies << "http://www.trolltech.com/web" << result; + QTest::newRow("match-4") << allCookies << "http://www.trolltech.com/web/" << result; + QTest::newRow("match-6") << allCookies << "http://www.trolltech.com/web/content" << result; cookie.setPath("/web/wiki"); allCookies += cookie; @@ -246,19 +246,19 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() QTest::newRow("one-match-1") << allCookies << "http://trolltech.com/web" << result; QTest::newRow("one-match-2") << allCookies << "http://trolltech.com/web/" << result; QTest::newRow("one-match-3") << allCookies << "http://trolltech.com/web/content" << result; - QTest::newRow("one-match-4") << allCookies << "http://qt.nokia.com/web" << result; - QTest::newRow("one-match-4") << allCookies << "http://qt.nokia.com/web/" << result; - QTest::newRow("one-match-6") << allCookies << "http://qt.nokia.com/web/content" << result; + QTest::newRow("one-match-4") << allCookies << "http://www.trolltech.com/web" << result; + QTest::newRow("one-match-4") << allCookies << "http://www.trolltech.com/web/" << result; + QTest::newRow("one-match-6") << allCookies << "http://www.trolltech.com/web/content" << result; result.prepend(cookie); // longer path, it must match first QTest::newRow("two-matches-1") << allCookies << "http://trolltech.com/web/wiki" << result; - QTest::newRow("two-matches-2") << allCookies << "http://qt.nokia.com/web/wiki" << result; + QTest::newRow("two-matches-2") << allCookies << "http://www.trolltech.com/web/wiki" << result; // invert the order; allCookies.clear(); allCookies << result.at(1) << result.at(0); QTest::newRow("two-matches-3") << allCookies << "http://trolltech.com/web/wiki" << result; - QTest::newRow("two-matches-4") << allCookies << "http://qt.nokia.com/web/wiki" << result; + QTest::newRow("two-matches-4") << allCookies << "http://www.trolltech.com/web/wiki" << result; // expired cookie allCookies.clear(); @@ -268,9 +268,9 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() QTest::newRow("exp-match-1") << allCookies << "http://trolltech.com/web" << result; QTest::newRow("exp-match-2") << allCookies << "http://trolltech.com/web/" << result; QTest::newRow("exp-match-3") << allCookies << "http://trolltech.com/web/content" << result; - QTest::newRow("exp-match-4") << allCookies << "http://qt.nokia.com/web" << result; - QTest::newRow("exp-match-4") << allCookies << "http://qt.nokia.com/web/" << result; - QTest::newRow("exp-match-6") << allCookies << "http://qt.nokia.com/web/content" << result; + QTest::newRow("exp-match-4") << allCookies << "http://www.trolltech.com/web" << result; + QTest::newRow("exp-match-4") << allCookies << "http://www.trolltech.com/web/" << result; + QTest::newRow("exp-match-6") << allCookies << "http://www.trolltech.com/web/content" << result; } void tst_QNetworkCookieJar::cookiesForUrl() -- cgit v0.12 From a1f2275772ba4ad8db0670ec6b41f99d9c2384f3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 19:49:28 +0200 Subject: Autotest: update the trolltech.com URLs to nokia.com properly. --- .../qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 9bf43ea..67b6d08 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -220,57 +220,57 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() QNetworkCookie cookie; cookie.setName("a"); cookie.setPath("/web"); - cookie.setDomain(".trolltech.com"); + cookie.setDomain(".nokia.com"); allCookies += cookie; QTest::newRow("no-match-1") << allCookies << "http://foo.bar/" << result; QTest::newRow("no-match-2") << allCookies << "http://foo.bar/web" << result; QTest::newRow("no-match-3") << allCookies << "http://foo.bar/web/wiki" << result; - QTest::newRow("no-match-4") << allCookies << "http://trolltech.com" << result; - QTest::newRow("no-match-5") << allCookies << "http://www.trolltech.com" << result; - QTest::newRow("no-match-6") << allCookies << "http://trolltech.com/webinar" << result; - QTest::newRow("no-match-7") << allCookies << "http://www.trolltech.com/webinar" << result; + QTest::newRow("no-match-4") << allCookies << "http://nokia.com" << result; + QTest::newRow("no-match-5") << allCookies << "http://qt.nokia.com" << result; + QTest::newRow("no-match-6") << allCookies << "http://nokia.com/webinar" << result; + QTest::newRow("no-match-7") << allCookies << "http://qt.nokia.com/webinar" << result; result = allCookies; - QTest::newRow("match-1") << allCookies << "http://trolltech.com/web" << result; - QTest::newRow("match-2") << allCookies << "http://trolltech.com/web/" << result; - QTest::newRow("match-3") << allCookies << "http://trolltech.com/web/content" << result; - QTest::newRow("match-4") << allCookies << "http://www.trolltech.com/web" << result; - QTest::newRow("match-4") << allCookies << "http://www.trolltech.com/web/" << result; - QTest::newRow("match-6") << allCookies << "http://www.trolltech.com/web/content" << result; + QTest::newRow("match-1") << allCookies << "http://nokia.com/web" << result; + QTest::newRow("match-2") << allCookies << "http://nokia.com/web/" << result; + QTest::newRow("match-3") << allCookies << "http://nokia.com/web/content" << result; + QTest::newRow("match-4") << allCookies << "http://qt.nokia.com/web" << result; + QTest::newRow("match-4") << allCookies << "http://qt.nokia.com/web/" << result; + QTest::newRow("match-6") << allCookies << "http://qt.nokia.com/web/content" << result; cookie.setPath("/web/wiki"); allCookies += cookie; // exact same results as before: - QTest::newRow("one-match-1") << allCookies << "http://trolltech.com/web" << result; - QTest::newRow("one-match-2") << allCookies << "http://trolltech.com/web/" << result; - QTest::newRow("one-match-3") << allCookies << "http://trolltech.com/web/content" << result; - QTest::newRow("one-match-4") << allCookies << "http://www.trolltech.com/web" << result; - QTest::newRow("one-match-4") << allCookies << "http://www.trolltech.com/web/" << result; - QTest::newRow("one-match-6") << allCookies << "http://www.trolltech.com/web/content" << result; + QTest::newRow("one-match-1") << allCookies << "http://nokia.com/web" << result; + QTest::newRow("one-match-2") << allCookies << "http://nokia.com/web/" << result; + QTest::newRow("one-match-3") << allCookies << "http://nokia.com/web/content" << result; + QTest::newRow("one-match-4") << allCookies << "http://qt.nokia.com/web" << result; + QTest::newRow("one-match-4") << allCookies << "http://qt.nokia.com/web/" << result; + QTest::newRow("one-match-6") << allCookies << "http://qt.nokia.com/web/content" << result; result.prepend(cookie); // longer path, it must match first - QTest::newRow("two-matches-1") << allCookies << "http://trolltech.com/web/wiki" << result; - QTest::newRow("two-matches-2") << allCookies << "http://www.trolltech.com/web/wiki" << result; + QTest::newRow("two-matches-1") << allCookies << "http://nokia.com/web/wiki" << result; + QTest::newRow("two-matches-2") << allCookies << "http://qt.nokia.com/web/wiki" << result; // invert the order; allCookies.clear(); allCookies << result.at(1) << result.at(0); - QTest::newRow("two-matches-3") << allCookies << "http://trolltech.com/web/wiki" << result; - QTest::newRow("two-matches-4") << allCookies << "http://www.trolltech.com/web/wiki" << result; + QTest::newRow("two-matches-3") << allCookies << "http://nokia.com/web/wiki" << result; + QTest::newRow("two-matches-4") << allCookies << "http://qt.nokia.com/web/wiki" << result; // expired cookie allCookies.clear(); cookie.setExpirationDate(QDateTime::fromString("09-Nov-1999", "dd-MMM-yyyy")); allCookies += cookie; result.clear(); - QTest::newRow("exp-match-1") << allCookies << "http://trolltech.com/web" << result; - QTest::newRow("exp-match-2") << allCookies << "http://trolltech.com/web/" << result; - QTest::newRow("exp-match-3") << allCookies << "http://trolltech.com/web/content" << result; - QTest::newRow("exp-match-4") << allCookies << "http://www.trolltech.com/web" << result; - QTest::newRow("exp-match-4") << allCookies << "http://www.trolltech.com/web/" << result; - QTest::newRow("exp-match-6") << allCookies << "http://www.trolltech.com/web/content" << result; + QTest::newRow("exp-match-1") << allCookies << "http://nokia.com/web" << result; + QTest::newRow("exp-match-2") << allCookies << "http://nokia.com/web/" << result; + QTest::newRow("exp-match-3") << allCookies << "http://nokia.com/web/content" << result; + QTest::newRow("exp-match-4") << allCookies << "http://qt.nokia.com/web" << result; + QTest::newRow("exp-match-4") << allCookies << "http://qt.nokia.com/web/" << result; + QTest::newRow("exp-match-6") << allCookies << "http://qt.nokia.com/web/content" << result; } void tst_QNetworkCookieJar::cookiesForUrl() -- cgit v0.12 From 1f4810fde9f4e2f3f0921ea1e57f44f5f823b383 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 20:15:54 +0200 Subject: Fixed toRawForm because the domains usually start with a dot. Like 9fea895d6, the series of commits ending in ff1280178 made QUrl::toAce more strict. Now it doesn't accept empty domain labels, which is exactly what a leading dot means. Interestingly, KDE 3's KURL had a long-standing hack to support the leading dot and which I broke on more than one occasion. And it had that feature exactly because of cookies. --- src/network/access/qnetworkcookie.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 0c13286..6884bee 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -504,7 +504,12 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const } if (!d->domain.isEmpty()) { result += "; domain="; - result += QUrl::toAce(d->domain); + QString domainNoDot = d->domain; + if (domainNoDot.startsWith(QLatin1Char('.'))) { + result += '.'; + domainNoDot = domainNoDot.mid(1); + } + result += QUrl::toAce(domainNoDot); } if (!d->path.isEmpty()) { result += "; path="; -- cgit v0.12 From d4421a5fb86b4fdac0e2148d1ad2ea47b38af3a9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 20:20:41 +0200 Subject: Autotest: cosmetic: change trolltech.com to qt.nokia.com --- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 54 ++++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 5519dee..abd1660 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -234,17 +234,17 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("path-with-utf8-2") << "a=b;path=/R%C3%A9sum%C3%A9" << cookie; cookie.setPath(QString()); - cookie.setDomain(".trolltech.com"); - QTest::newRow("plain-domain1") << "a=b;domain=trolltech.com" << cookie; - QTest::newRow("plain-domain2") << "a=b; domain=trolltech.com " << cookie; - QTest::newRow("plain-domain3") << "a=b;domain=TROLLTECH.COM" << cookie; - QTest::newRow("plain-domain4") << "a=b;DOMAIN = TROLLTECH.COM" << cookie; - - cookie.setDomain(".trolltech.com"); - QTest::newRow("dot-domain1") << "a=b;domain=.trolltech.com" << cookie; - QTest::newRow("dot-domain2") << "a=b; domain=.trolltech.com" << cookie; - QTest::newRow("dot-domain3") << "a=b; domain=.TROLLTECH.COM" << cookie; - QTest::newRow("dot-domain4") << "a=b; Domain = .TROLLTECH.COM" << cookie; + cookie.setDomain(".qt.nokia.com"); + QTest::newRow("plain-domain1") << "a=b;domain=qt.nokia.com" << cookie; + QTest::newRow("plain-domain2") << "a=b; domain=qt.nokia.com " << cookie; + QTest::newRow("plain-domain3") << "a=b;domain=QT.NOKIA.COM" << cookie; + QTest::newRow("plain-domain4") << "a=b;DOMAIN = QT.NOKIA.COM" << cookie; + + cookie.setDomain(".qt.nokia.com"); + QTest::newRow("dot-domain1") << "a=b;domain=.qt.nokia.com" << cookie; + QTest::newRow("dot-domain2") << "a=b; domain=.qt.nokia.com" << cookie; + QTest::newRow("dot-domain3") << "a=b; domain=.QT.NOKIA.COM" << cookie; + QTest::newRow("dot-domain4") << "a=b; Domain = .QT.NOKIA.COM" << cookie; cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no")); QTest::newRow("idn-domain1") << "a=b;domain=xn--dgnpent-gxa2o.troll.no" << cookie; @@ -259,20 +259,20 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("dot-idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie; QTest::newRow("dot-idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie; - cookie.setDomain(".trolltech.com"); + cookie.setDomain(".qt.nokia.com"); cookie.setPath("/"); - QTest::newRow("two-fields") << "a=b;domain=trolltech.com;path=/" << cookie; - QTest::newRow("two-fields2") << "a=b; domain=trolltech.com; path=/" << cookie; - QTest::newRow("two-fields3") << "a=b; domain=trolltech.com ; path=/ " << cookie; - QTest::newRow("two-fields4") << "a=b;path=/; domain=trolltech.com" << cookie; - QTest::newRow("two-fields5") << "a=b; path=/ ; domain=trolltech.com" << cookie; - QTest::newRow("two-fields6") << "a=b; path= / ; domain =trolltech.com" << cookie; + QTest::newRow("two-fields") << "a=b;domain=qt.nokia.com;path=/" << cookie; + QTest::newRow("two-fields2") << "a=b; domain=qt.nokia.com; path=/" << cookie; + QTest::newRow("two-fields3") << "a=b; domain=qt.nokia.com ; path=/ " << cookie; + QTest::newRow("two-fields4") << "a=b;path=/; domain=qt.nokia.com" << cookie; + QTest::newRow("two-fields5") << "a=b; path=/ ; domain=qt.nokia.com" << cookie; + QTest::newRow("two-fields6") << "a=b; path= / ; domain =qt.nokia.com" << cookie; cookie.setSecure(true); - QTest::newRow("three-fields") << "a=b;domain=trolltech.com;path=/;secure" << cookie; - QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=trolltech.com" << cookie; - QTest::newRow("three-fields3") << "a=b;secure;domain=trolltech.com; path=/" << cookie; - QTest::newRow("three-fields4") << "a = b;secure;domain=trolltech.com; path=/" << cookie; + QTest::newRow("three-fields") << "a=b;domain=qt.nokia.com;path=/;secure" << cookie; + QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=qt.nokia.com" << cookie; + QTest::newRow("three-fields3") << "a=b;secure;domain=qt.nokia.com; path=/" << cookie; + QTest::newRow("three-fields4") << "a = b;secure;domain=qt.nokia.com; path=/" << cookie; cookie = QNetworkCookie(); cookie.setName("a"); @@ -560,9 +560,9 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("expires+path") << "a=b; expires=Wed, 09-Nov-1999 23:12:40 GMT; path=/" << cookie; QTest::newRow("path+expires") << "a=b; path=/;expires=Wed, 09-Nov-1999 23:12:40 GMT " << cookie; - cookie.setDomain(".trolltech.com"); - QTest::newRow("full") << "a=b; domain=.trolltech.com;expires=Wed, 09-Nov-1999 23:12:40 GMT;path=/" << cookie; - QTest::newRow("full2") << "a=b;path=/; expires=Wed, 09-Nov-1999 23:12:40 GMT ;domain=.trolltech.com" << cookie; + cookie.setDomain(".qt.nokia.com"); + QTest::newRow("full") << "a=b; domain=.qt.nokia.com;expires=Wed, 09-Nov-1999 23:12:40 GMT;path=/" << cookie; + QTest::newRow("full2") << "a=b;path=/; expires=Wed, 09-Nov-1999 23:12:40 GMT ;domain=.qt.nokia.com" << cookie; // cookies obtained from the network: cookie = QNetworkCookie("__siteid", "1"); @@ -662,9 +662,9 @@ void tst_QNetworkCookie::parseMultipleCookies_data() QTest::newRow("complex-1") << "c=d, a=, foo=bar; path=/" << list; cookie.setName("baz"); - cookie.setDomain(".trolltech.com"); + cookie.setDomain(".qt.nokia.com"); list.prepend(cookie); - QTest::newRow("complex-2") << "baz=bar; path=/; domain=trolltech.com, c=d,a=,foo=bar; path=/" << list; + QTest::newRow("complex-2") << "baz=bar; path=/; domain=qt.nokia.com, c=d,a=,foo=bar; path=/" << list; // cookies obtained from the network: cookie = QNetworkCookie("id", "51706646077999719"); -- cgit v0.12 From 080862c8b2b5bb1f8202affc5b415f2a86b5abb6 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 18 Aug 2009 12:18:22 -0700 Subject: Disambiguate variable names s/lock/lockFlgs/ lock is also a function in QWSWindowSurface. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 10 +++++----- src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index d2fadcb..a962bf9 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -47,7 +47,7 @@ QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr) : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr), - lock(DFBSurfaceLockFlags(0)), mem(0), engine(0) + lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0) {} QDirectFBPaintDevice::~QDirectFBPaintDevice() @@ -65,15 +65,15 @@ IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const void QDirectFBPaintDevice::lockDirectFB(DFBSurfaceLockFlags flags) { - if (!(lock & flags)) { - if (lock) + if (!(lockFlgs & flags)) { + if (lockFlgs) unlockDirectFB(); mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl); Q_ASSERT(mem); const QSize s = size(); lockedImage = new QImage(mem, s.width(), s.height(), bpl, QDirectFBScreen::getImageFormat(dfbSurface)); - lock = flags; + lockFlgs = flags; } } @@ -87,7 +87,7 @@ void QDirectFBPaintDevice::unlockDirectFB() delete lockedImage; lockedImage = 0; mem = 0; - lock = DFBSurfaceLockFlags(0); + lockFlgs = DFBSurfaceLockFlags(0); } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index 3932403..688fd7b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -68,7 +68,7 @@ public: int bytesPerLine() const; QSize size() const; int metric(QPaintDevice::PaintDeviceMetric metric) const; - DFBSurfaceLockFlags lockFlags() const { return lock; } + DFBSurfaceLockFlags lockFlags() const { return lockFlgs; } QPaintEngine *paintEngine() const; protected: @@ -86,7 +86,7 @@ protected: QImage *lockedImage; QDirectFBScreen *screen; int bpl; - DFBSurfaceLockFlags lock; + DFBSurfaceLockFlags lockFlgs; uchar *mem; QDirectFBPaintEngine *engine; private: -- cgit v0.12 From 5019a4128ed22f2e4d5dd76c4a2fe1ca4d6c4bf4 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 18 Aug 2009 12:23:07 -0700 Subject: Initialize bpl in QDirectFBPaintDevice(...) Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index a962bf9..3979a8c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -47,7 +47,7 @@ QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr) : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr), - lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0) + bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0) {} QDirectFBPaintDevice::~QDirectFBPaintDevice() -- cgit v0.12 From 4377c9f6a593359b436f7c8186abac8dad772329 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 18 Aug 2009 12:42:19 -0700 Subject: Make sure windows raise properly when focused We never used to properly raise windows with DirectFB's window management. Somehow the event happens on a window surface that doesn't really have a IDirectFBWindow associated with it but using permanentState I can establish a sibling relationship to ensure raise gets called on the right window surface. Reviewed-By: Donald --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 25 ++++++++++- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 51 ++++++++++++---------- .../gfxdrivers/directfb/qdirectfbwindowsurface.h | 6 ++- 3 files changed, 57 insertions(+), 25 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 2541677..dc53847 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -56,13 +56,18 @@ class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem { + Q_OBJECT public: QDirectFBScreenPrivate(QDirectFBScreen *qptr); ~QDirectFBScreenPrivate(); void setFlipFlags(const QStringList &args); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - +public slots: +#ifdef QT_DIRECTFB_WM + void onWindowEvent(QWSWindow *window, QWSServer::WindowEvent event); +#endif +public: IDirectFB *dfb; DFBSurfaceFlipFlags flipFlags; QDirectFBScreen::DirectFBFlags directFBFlags; @@ -86,6 +91,8 @@ public: QDirectFBScreen *q; }; +#include "qdirectfbscreen.moc" + QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr) : QWSGraphicsSystem(qptr), dfb(0), flipFlags(DSFLIP_NONE), directFBFlags(QDirectFBScreen::NoFlags), alphaPixmapFormat(QImage::Format_Invalid), @@ -107,6 +114,10 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr) #ifndef QT_NO_QWS_SIGNALHANDLER QWSSignalHandler::instance()->addObject(this); #endif +#ifdef QT_DIRECTFB_WM + connect(QWSServer::instance(), SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), + this, SLOT(onWindowEvent(QWSWindow*, QWSServer::WindowEvent))); +#endif } QDirectFBScreenPrivate::~QDirectFBScreenPrivate() @@ -747,6 +758,18 @@ void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args) } } +#ifdef QT_DIRECTFB_WM +void QDirectFBScreenPrivate::onWindowEvent(QWSWindow *window, QWSServer::WindowEvent event) +{ + if (event == QWSServer::Raise) { + QWSWindowSurface *windowSurface = window->windowSurface(); + if (windowSurface && windowSurface->key() == QLatin1String("directfb")) { + static_cast(windowSurface)->raise(); + } + } +} +#endif + QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const { if (type == QPixmapData::BitmapType) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 584f334..441bac9 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -54,6 +54,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect : QDirectFBPaintDevice(scr) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) + , sibling(0) #endif , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) @@ -72,6 +73,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect : QWSWindowSurface(widget), QDirectFBPaintDevice(scr) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) + , sibling(0) #endif , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) @@ -98,6 +100,17 @@ QDirectFBWindowSurface::~QDirectFBWindowSurface() { } +#ifdef QT_DIRECTFB_WM +void QDirectFBWindowSurface::raise() +{ + if (dfbWindow) { + dfbWindow->RaiseToTop(dfbWindow); + } else if (sibling && (!sibling->sibling || sibling->dfbWindow)) { + sibling->raise(); + } +} +#endif + bool QDirectFBWindowSurface::isValid() const { return true; @@ -126,6 +139,7 @@ void QDirectFBWindowSurface::createWindow() description.surface_caps = DSCAPS_PREMULTIPLIED; DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow); + if (result != DFB_OK) DirectFBErrorFatal("QDirectFBWindowSurface::createWindow", result); @@ -231,34 +245,25 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) QByteArray QDirectFBWindowSurface::permanentState() const { - QByteArray array; -#ifdef QT_NO_DIRECTFB_WM - array.resize(sizeof(SurfaceFlags) + sizeof(IDirectFBSurface*)); -#else - array.resize(sizeof(SurfaceFlags)); -#endif - char *ptr = array.data(); - - *reinterpret_cast(ptr) = surfaceFlags(); - ptr += sizeof(SurfaceFlags); - -#ifdef QT_NO_DIRECTFB_WM - *reinterpret_cast(ptr) = dfbSurface; + QByteArray state; +#ifdef QT_DIRECTFB_WM + QDataStream ds(&state, QIODevice::WriteOnly); + ds << reinterpret_cast(this); #endif - return array; + return state; } void QDirectFBWindowSurface::setPermanentState(const QByteArray &state) { - SurfaceFlags flags; - const char *ptr = state.constData(); - - flags = *reinterpret_cast(ptr); - setSurfaceFlags(flags); - -#ifdef QT_NO_DIRECTFB_WM - ptr += sizeof(SurfaceFlags); - dfbSurface = *reinterpret_cast(ptr); +#ifdef QT_DIRECTFB_WM + if (state.size() == sizeof(quintptr)) { + QDataStream ds(state); + quintptr ptr; + ds >> ptr; + sibling = reinterpret_cast(ptr); + } +#else + Q_UNUSED(state); #endif } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index 64b1920..2c4bcdf 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -65,6 +65,9 @@ public: QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr, QWidget *widget); ~QDirectFBWindowSurface(); +#ifdef QT_DIRECTFB_WM + void raise(); +#endif bool isValid() const; void setGeometry(const QRect &rect); @@ -87,9 +90,10 @@ public: QImage *buffer(const QWidget *widget); private: -#ifndef QT_NO_DIRECTFB_WM +#ifdef QT_DIRECTFB_WM void createWindow(); IDirectFBWindow *dfbWindow; + QDirectFBWindowSurface *sibling; #endif #ifdef QT_NO_DIRECTFB_WM -- cgit v0.12 From f7af55e67711270286a1addf6a28399982647a62 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 19 Aug 2009 09:47:27 +1000 Subject: Move math3d unit tests up one level to tests/auto Some of the platform test infrastructure assumes that all unit tests are sub-directories under tests/auto, and the tests/auto/math3d sub-directory was confusing that infrastructure. Reviewed-by: trustme --- tests/auto/auto.pro | 5 +- tests/auto/math3d/math3d.pro | 2 - tests/auto/math3d/qmatrixnxn/qmatrixnxn.pro | 5 - tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 3383 --------------------- tests/auto/math3d/qquaternion/qquaternion.pro | 5 - tests/auto/math3d/qquaternion/tst_qquaternion.cpp | 882 ------ tests/auto/math3d/qvectornd/qvectornd.pro | 5 - tests/auto/math3d/qvectornd/tst_qvectornd.cpp | 2141 ------------- tests/auto/math3d/shared/math3dincludes.h | 52 - tests/auto/qmatrixnxn/qmatrixnxn.pro | 2 + tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp | 3383 +++++++++++++++++++++ tests/auto/qquaternion/qquaternion.pro | 2 + tests/auto/qquaternion/tst_qquaternion.cpp | 882 ++++++ tests/auto/qvectornd/qvectornd.pro | 2 + tests/auto/qvectornd/tst_qvectornd.cpp | 2143 +++++++++++++ 15 files changed, 6417 insertions(+), 6477 deletions(-) delete mode 100644 tests/auto/math3d/math3d.pro delete mode 100644 tests/auto/math3d/qmatrixnxn/qmatrixnxn.pro delete mode 100644 tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp delete mode 100644 tests/auto/math3d/qquaternion/qquaternion.pro delete mode 100644 tests/auto/math3d/qquaternion/tst_qquaternion.cpp delete mode 100644 tests/auto/math3d/qvectornd/qvectornd.pro delete mode 100644 tests/auto/math3d/qvectornd/tst_qvectornd.cpp delete mode 100644 tests/auto/math3d/shared/math3dincludes.h create mode 100644 tests/auto/qmatrixnxn/qmatrixnxn.pro create mode 100644 tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp create mode 100644 tests/auto/qquaternion/qquaternion.pro create mode 100644 tests/auto/qquaternion/tst_qquaternion.cpp create mode 100644 tests/auto/qvectornd/qvectornd.pro create mode 100644 tests/auto/qvectornd/tst_qvectornd.cpp diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 1ae6913..b3382bb 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -194,6 +194,7 @@ SUBDIRS += \ qmainwindow \ qmake \ qmap \ + qmatrixnxn \ qmdiarea \ qmdisubwindow \ qmenu \ @@ -240,6 +241,7 @@ SUBDIRS += \ qprogressdialog \ qpropertyanimation \ qpushbutton \ + qquaternion \ qqueue \ qradiobutton \ qreadlocker \ @@ -372,6 +374,7 @@ SUBDIRS += \ qvariant \ qvarlengtharray \ qvector \ + qvectornd \ qwaitcondition \ qwidget \ qwidgetaction \ @@ -476,5 +479,3 @@ contains(QT_CONFIG, webkit): SUBDIRS += \ qwebhistoryinterface \ qwebelement \ qwebhistory - -SUBDIRS += math3d diff --git a/tests/auto/math3d/math3d.pro b/tests/auto/math3d/math3d.pro deleted file mode 100644 index d6189ef..0000000 --- a/tests/auto/math3d/math3d.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = qmatrixnxn qquaternion qvectornd diff --git a/tests/auto/math3d/qmatrixnxn/qmatrixnxn.pro b/tests/auto/math3d/qmatrixnxn/qmatrixnxn.pro deleted file mode 100644 index 40c6cc0..0000000 --- a/tests/auto/math3d/qmatrixnxn/qmatrixnxn.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -VPATH += ../shared -INCLUDEPATH += ../shared -HEADERS += math3dincludes.h -SOURCES += tst_qmatrixnxn.cpp diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp deleted file mode 100644 index 5541162..0000000 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ /dev/null @@ -1,3383 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include "math3dincludes.h" - -class tst_QMatrixNxN : public QObject -{ - Q_OBJECT -public: - tst_QMatrixNxN() {} - ~tst_QMatrixNxN() {} - -private slots: - void create2x2(); - void create3x3(); - void create4x4(); - void create4x3(); - - void isIdentity2x2(); - void isIdentity3x3(); - void isIdentity4x4(); - void isIdentity4x3(); - - void compare2x2(); - void compare3x3(); - void compare4x4(); - void compare4x3(); - - void transposed2x2(); - void transposed3x3(); - void transposed4x4(); - void transposed4x3(); - - void add2x2_data(); - void add2x2(); - void add3x3_data(); - void add3x3(); - void add4x4_data(); - void add4x4(); - void add4x3_data(); - void add4x3(); - - void subtract2x2_data(); - void subtract2x2(); - void subtract3x3_data(); - void subtract3x3(); - void subtract4x4_data(); - void subtract4x4(); - void subtract4x3_data(); - void subtract4x3(); - - void multiply2x2_data(); - void multiply2x2(); - void multiply3x3_data(); - void multiply3x3(); - void multiply4x4_data(); - void multiply4x4(); - void multiply4x3_data(); - void multiply4x3(); - - void multiplyFactor2x2_data(); - void multiplyFactor2x2(); - void multiplyFactor3x3_data(); - void multiplyFactor3x3(); - void multiplyFactor4x4_data(); - void multiplyFactor4x4(); - void multiplyFactor4x3_data(); - void multiplyFactor4x3(); - - void divideFactor2x2_data(); - void divideFactor2x2(); - void divideFactor3x3_data(); - void divideFactor3x3(); - void divideFactor4x4_data(); - void divideFactor4x4(); - void divideFactor4x3_data(); - void divideFactor4x3(); - - void negate2x2_data(); - void negate2x2(); - void negate3x3_data(); - void negate3x3(); - void negate4x4_data(); - void negate4x4(); - void negate4x3_data(); - void negate4x3(); - - void inverted4x4_data(); - void inverted4x4(); - - void orthonormalInverse4x4(); - - void scale4x4_data(); - void scale4x4(); - - void translate4x4_data(); - void translate4x4(); - - void rotate4x4_data(); - void rotate4x4(); - - void normalMatrix_data(); - void normalMatrix(); - - void optimizedTransforms(); - - void ortho(); - void frustum(); - void perspective(); - void flipCoordinates(); - - void convertGeneric(); - - void extractAxisRotation_data(); - void extractAxisRotation(); - - void extractTranslation_data(); - void extractTranslation(); - - void inferSpecialType_data(); - void inferSpecialType(); - - void columnsAndRows(); - - void convertQMatrix(); - void convertQTransform(); - - void fill(); - - void mapRect_data(); - void mapRect(); - - void properties(); - void metaTypes(); - -private: - static void setMatrix(QMatrix2x2& m, const qreal *values); - static void setMatrixDirect(QMatrix2x2& m, const qreal *values); - static bool isSame(const QMatrix2x2& m, const qreal *values); - static bool isIdentity(const QMatrix2x2& m); - - static void setMatrix(QMatrix3x3& m, const qreal *values); - static void setMatrixDirect(QMatrix3x3& m, const qreal *values); - static bool isSame(const QMatrix3x3& m, const qreal *values); - static bool isIdentity(const QMatrix3x3& m); - - static void setMatrix(QMatrix4x4& m, const qreal *values); - static void setMatrixDirect(QMatrix4x4& m, const qreal *values); - static bool isSame(const QMatrix4x4& m, const qreal *values); - static bool isIdentity(const QMatrix4x4& m); - - static void setMatrix(QMatrix4x3& m, const qreal *values); - static void setMatrixDirect(QMatrix4x3& m, const qreal *values); - static bool isSame(const QMatrix4x3& m, const qreal *values); - static bool isIdentity(const QMatrix4x3& m); -}; - -static const qreal nullValues2[] = - {0.0f, 0.0f, - 0.0f, 0.0f}; - -static qreal const identityValues2[16] = - {1.0f, 0.0f, - 0.0f, 1.0f}; - -static const qreal doubleIdentity2[] = - {2.0f, 0.0f, - 0.0f, 2.0f}; - -static qreal const uniqueValues2[16] = - {1.0f, 2.0f, - 5.0f, 6.0f}; - -static qreal const transposedValues2[16] = - {1.0f, 5.0f, - 2.0f, 6.0f}; - -static const qreal nullValues3[] = - {0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f}; - -static qreal const identityValues3[16] = - {1.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f}; - -static const qreal doubleIdentity3[] = - {2.0f, 0.0f, 0.0f, - 0.0f, 2.0f, 0.0f, - 0.0f, 0.0f, 2.0f}; - -static qreal const uniqueValues3[16] = - {1.0f, 2.0f, 3.0f, - 5.0f, 6.0f, 7.0f, - 9.0f, 10.0f, 11.0f}; - -static qreal const transposedValues3[16] = - {1.0f, 5.0f, 9.0f, - 2.0f, 6.0f, 10.0f, - 3.0f, 7.0f, 11.0f}; - -static const qreal nullValues4[] = - {0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f}; - -static qreal const identityValues4[16] = - {1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - -static const qreal doubleIdentity4[] = - {2.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 2.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 2.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 2.0f}; - -static qreal const uniqueValues4[16] = - {1.0f, 2.0f, 3.0f, 4.0f, - 5.0f, 6.0f, 7.0f, 8.0f, - 9.0f, 10.0f, 11.0f, 12.0f, - 13.0f, 14.0f, 15.0f, 16.0f}; - -static qreal const transposedValues4[16] = - {1.0f, 5.0f, 9.0f, 13.0f, - 2.0f, 6.0f, 10.0f, 14.0f, - 3.0f, 7.0f, 11.0f, 15.0f, - 4.0f, 8.0f, 12.0f, 16.0f}; - -static const qreal nullValues4x3[] = - {0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f}; - -static qreal const identityValues4x3[12] = - {1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f}; - -static qreal const doubleIdentity4x3[12] = - {2.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 2.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 2.0f, 0.0f}; - -static qreal const uniqueValues4x3[12] = - {1.0f, 2.0f, 3.0f, 4.0f, - 5.0f, 6.0f, 7.0f, 8.0f, - 9.0f, 10.0f, 11.0f, 12.0f}; - -static qreal const transposedValues3x4[12] = - {1.0f, 5.0f, 9.0f, - 2.0f, 6.0f, 10.0f, - 3.0f, 7.0f, 11.0f, - 4.0f, 8.0f, 12.0f}; - -// Set a matrix to a specified array of values, which are assumed -// to be in row-major order. This sets the values using floating-point. -void tst_QMatrixNxN::setMatrix(QMatrix2x2& m, const qreal *values) -{ - for (int row = 0; row < 2; ++row) - for (int col = 0; col < 2; ++col) - m(row, col) = values[row * 2 + col]; -} -void tst_QMatrixNxN::setMatrix(QMatrix3x3& m, const qreal *values) -{ - for (int row = 0; row < 3; ++row) - for (int col = 0; col < 3; ++col) - m(row, col) = values[row * 3 + col]; -} -void tst_QMatrixNxN::setMatrix(QMatrix4x4& m, const qreal *values) -{ - for (int row = 0; row < 4; ++row) - for (int col = 0; col < 4; ++col) - m(row, col) = values[row * 4 + col]; -} -void tst_QMatrixNxN::setMatrix(QMatrix4x3& m, const qreal *values) -{ - for (int row = 0; row < 3; ++row) - for (int col = 0; col < 4; ++col) - m(row, col) = values[row * 4 + col]; -} - -// Set a matrix to a specified array of values, which are assumed -// to be in row-major order. This sets the values directly into -// the internal data() array. -void tst_QMatrixNxN::setMatrixDirect(QMatrix2x2& m, const qreal *values) -{ - float *data = m.data(); - for (int row = 0; row < 2; ++row) { - for (int col = 0; col < 2; ++col) { - data[row + col * 2] = values[row * 2 + col]; - } - } -} -void tst_QMatrixNxN::setMatrixDirect(QMatrix3x3& m, const qreal *values) -{ - float *data = m.data(); - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - data[row + col * 3] = values[row * 3 + col]; - } - } -} -void tst_QMatrixNxN::setMatrixDirect(QMatrix4x4& m, const qreal *values) -{ - float *data = m.data(); - for (int row = 0; row < 4; ++row) { - for (int col = 0; col < 4; ++col) { - data[row + col * 4] = values[row * 4 + col]; - } - } -} -void tst_QMatrixNxN::setMatrixDirect(QMatrix4x3& m, const qreal *values) -{ - float *data = m.data(); - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 4; ++col) { - data[row + col * 3] = values[row * 4 + col]; - } - } -} - -// qFuzzyCompare isn't always "fuzzy" enough to handle conversion -// between float, double, and qreal. So create "fuzzier" compares. -static bool fuzzyCompare(float x, float y, qreal epsilon = 0.001) -{ - float diff = x - y; - if (diff < 0.0f) - diff = -diff; - return (diff < epsilon); -} - -static bool fuzzyCompare(const QVector3D &v1, const QVector3D &v2, qreal epsilon = 0.001) -{ - if (!fuzzyCompare(v1.x(), v2.x(), epsilon)) - return false; - if (!fuzzyCompare(v1.y(), v2.y(), epsilon)) - return false; - if (!fuzzyCompare(v1.z(), v2.z(), epsilon)) - return false; - return true; -} - -static bool matrixFuzzyCompare(const QMatrix4x4 &m1, const QMatrix4x4 &m2) -{ - bool ret = true; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - ret = ret && fuzzyCompare(m1(i, j), m2(i, j)); - } - } - - return ret; -} - -// Determine if a matrix is the same as a specified array of values. -// The values are assumed to be specified in row-major order. -bool tst_QMatrixNxN::isSame(const QMatrix2x2& m, const qreal *values) -{ - const float *mv = m.constData(); - for (int row = 0; row < 2; ++row) { - for (int col = 0; col < 2; ++col) { - // Check the values using the operator() function. - if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 2 + col]))) { - qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 2 + col]; - return false; - } - - // Check the values using direct access, which verifies that the values - // are stored internally in column-major order. - if (!fuzzyCompare((float)(mv[col * 2 + row]), (float)(values[row * 2 + col]))) { - qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 2 + row] << "expected =" << values[row * 2 + col]; - return false; - } - } - } - return true; -} -bool tst_QMatrixNxN::isSame(const QMatrix3x3& m, const qreal *values) -{ - const float *mv = m.constData(); - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - // Check the values using the operator() access function. - if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 3 + col]))) { - qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 3 + col]; - return false; - } - - // Check the values using direct access, which verifies that the values - // are stored internally in column-major order. - if (!fuzzyCompare((float)(mv[col * 3 + row]), (float)(values[row * 3 + col]))) { - qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 3 + row] << "expected =" << values[row * 3 + col]; - return false; - } - } - } - return true; -} -bool tst_QMatrixNxN::isSame(const QMatrix4x4& m, const qreal *values) -{ - const float *mv = m.constData(); - for (int row = 0; row < 4; ++row) { - for (int col = 0; col < 4; ++col) { - // Check the values using the operator() access function. - if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 4 + col]))) { - qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 4 + col]; - return false; - } - - // Check the values using direct access, which verifies that the values - // are stored internally in column-major order. - if (!fuzzyCompare((float)(mv[col * 4 + row]), (float)(values[row * 4 + col]))) { - qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 4 + row] << "expected =" << values[row * 4 + col]; - return false; - } - } - } - return true; -} -bool tst_QMatrixNxN::isSame(const QMatrix4x3& m, const qreal *values) -{ - const float *mv = m.constData(); - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 4; ++col) { - // Check the values using the operator() access function. - if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 4 + col]))) { - qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 4 + col]; - return false; - } - - // Check the values using direct access, which verifies that the values - // are stored internally in column-major order. - if (!fuzzyCompare((float)(mv[col * 3 + row]), (float)(values[row * 4 + col]))) { - qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 3 + row] << "expected =" << values[row * 4 + col]; - return false; - } - } - } - return true; -} - -// Determine if a matrix is the identity. -bool tst_QMatrixNxN::isIdentity(const QMatrix2x2& m) -{ - return isSame(m, identityValues2); -} -bool tst_QMatrixNxN::isIdentity(const QMatrix3x3& m) -{ - return isSame(m, identityValues3); -} -bool tst_QMatrixNxN::isIdentity(const QMatrix4x4& m) -{ - return isSame(m, identityValues4); -} -bool tst_QMatrixNxN::isIdentity(const QMatrix4x3& m) -{ - return isSame(m, identityValues4x3); -} - -// Test the creation of QMatrix2x2 objects in various ways: -// construct, copy, and modify. -void tst_QMatrixNxN::create2x2() -{ - QMatrix2x2 m1; - QVERIFY(isIdentity(m1)); - QVERIFY(m1.isIdentity()); - - QMatrix2x2 m2; - setMatrix(m2, uniqueValues2); - QVERIFY(isSame(m2, uniqueValues2)); - QVERIFY(!m2.isIdentity()); - - QMatrix2x2 m3; - setMatrixDirect(m3, uniqueValues2); - QVERIFY(isSame(m3, uniqueValues2)); - - QMatrix2x2 m4(m3); - QVERIFY(isSame(m4, uniqueValues2)); - - QMatrix2x2 m5; - m5 = m3; - QVERIFY(isSame(m5, uniqueValues2)); - - m5.setIdentity(); - QVERIFY(isIdentity(m5)); - - QMatrix2x2 m6(uniqueValues2); - QVERIFY(isSame(m6, uniqueValues2)); - qreal vals[4]; - m6.toValueArray(vals); - for (int index = 0; index < 4; ++index) - QCOMPARE((float)(vals[index]), (float)(uniqueValues2[index])); -} - -// Test the creation of QMatrix3x3 objects in various ways: -// construct, copy, and modify. -void tst_QMatrixNxN::create3x3() -{ - QMatrix3x3 m1; - QVERIFY(isIdentity(m1)); - QVERIFY(m1.isIdentity()); - - QMatrix3x3 m2; - setMatrix(m2, uniqueValues3); - QVERIFY(isSame(m2, uniqueValues3)); - QVERIFY(!m2.isIdentity()); - - QMatrix3x3 m3; - setMatrixDirect(m3, uniqueValues3); - QVERIFY(isSame(m3, uniqueValues3)); - - QMatrix3x3 m4(m3); - QVERIFY(isSame(m4, uniqueValues3)); - - QMatrix3x3 m5; - m5 = m3; - QVERIFY(isSame(m5, uniqueValues3)); - - m5.setIdentity(); - QVERIFY(isIdentity(m5)); - - QMatrix3x3 m6(uniqueValues3); - QVERIFY(isSame(m6, uniqueValues3)); - qreal vals[9]; - m6.toValueArray(vals); - for (int index = 0; index < 9; ++index) - QCOMPARE((float)(vals[index]), (float)(uniqueValues3[index])); -} - -// Test the creation of QMatrix4x4 objects in various ways: -// construct, copy, and modify. -void tst_QMatrixNxN::create4x4() -{ - QMatrix4x4 m1; - QVERIFY(isIdentity(m1)); - QVERIFY(m1.isIdentity()); - - QMatrix4x4 m2; - setMatrix(m2, uniqueValues4); - QVERIFY(isSame(m2, uniqueValues4)); - QVERIFY(!m2.isIdentity()); - - QMatrix4x4 m3; - setMatrixDirect(m3, uniqueValues4); - QVERIFY(isSame(m3, uniqueValues4)); - - QMatrix4x4 m4(m3); - QVERIFY(isSame(m4, uniqueValues4)); - - QMatrix4x4 m5; - m5 = m3; - QVERIFY(isSame(m5, uniqueValues4)); - - m5.setIdentity(); - QVERIFY(isIdentity(m5)); - - QMatrix4x4 m6(uniqueValues4); - QVERIFY(isSame(m6, uniqueValues4)); - qreal vals[16]; - m6.toValueArray(vals); - for (int index = 0; index < 16; ++index) - QCOMPARE((float)(vals[index]), (float)(uniqueValues4[index])); - - QMatrix4x4 m8 - (uniqueValues4[0], uniqueValues4[1], uniqueValues4[2], uniqueValues4[3], - uniqueValues4[4], uniqueValues4[5], uniqueValues4[6], uniqueValues4[7], - uniqueValues4[8], uniqueValues4[9], uniqueValues4[10], uniqueValues4[11], - uniqueValues4[12], uniqueValues4[13], uniqueValues4[14], uniqueValues4[15]); - QVERIFY(isSame(m8, uniqueValues4)); -} - -// Test the creation of QMatrix4x3 objects in various ways: -// construct, copy, and modify. -void tst_QMatrixNxN::create4x3() -{ - QMatrix4x3 m1; - QVERIFY(isIdentity(m1)); - QVERIFY(m1.isIdentity()); - - QMatrix4x3 m2; - setMatrix(m2, uniqueValues4x3); - QVERIFY(isSame(m2, uniqueValues4x3)); - QVERIFY(!m2.isIdentity()); - - QMatrix4x3 m3; - setMatrixDirect(m3, uniqueValues4x3); - QVERIFY(isSame(m3, uniqueValues4x3)); - - QMatrix4x3 m4(m3); - QVERIFY(isSame(m4, uniqueValues4x3)); - - QMatrix4x3 m5; - m5 = m3; - QVERIFY(isSame(m5, uniqueValues4x3)); - - m5.setIdentity(); - QVERIFY(isIdentity(m5)); - - QMatrix4x3 m6(uniqueValues4x3); - QVERIFY(isSame(m6, uniqueValues4x3)); - qreal vals[12]; - m6.toValueArray(vals); - for (int index = 0; index < 12; ++index) - QCOMPARE((float)(vals[index]), (float)(uniqueValues4x3[index])); -} - -// Test isIdentity() for 2x2 matrices. -void tst_QMatrixNxN::isIdentity2x2() -{ - for (int i = 0; i < 2 * 2; ++i) { - QMatrix2x2 m; - QVERIFY(m.isIdentity()); - m.data()[i] = 42.0f; - QVERIFY(!m.isIdentity()); - } -} - -// Test isIdentity() for 3x3 matrices. -void tst_QMatrixNxN::isIdentity3x3() -{ - for (int i = 0; i < 3 * 3; ++i) { - QMatrix3x3 m; - QVERIFY(m.isIdentity()); - m.data()[i] = 42.0f; - QVERIFY(!m.isIdentity()); - } -} - -// Test isIdentity() for 4x4 matrices. -void tst_QMatrixNxN::isIdentity4x4() -{ - for (int i = 0; i < 4 * 4; ++i) { - QMatrix4x4 m; - QVERIFY(m.isIdentity()); - m.data()[i] = 42.0f; - QVERIFY(!m.isIdentity()); - } - - // Force the "Identity" flag bit to be lost and check again. - QMatrix4x4 m2; - m2.data()[0] = 1.0f; - QVERIFY(m2.isIdentity()); -} - -// Test isIdentity() for 4x3 matrices. -void tst_QMatrixNxN::isIdentity4x3() -{ - for (int i = 0; i < 4 * 3; ++i) { - QMatrix4x3 m; - QVERIFY(m.isIdentity()); - m.data()[i] = 42.0f; - QVERIFY(!m.isIdentity()); - } -} - -// Test 2x2 matrix comparisons. -void tst_QMatrixNxN::compare2x2() -{ - QMatrix2x2 m1(uniqueValues2); - QMatrix2x2 m2(uniqueValues2); - QMatrix2x2 m3(transposedValues2); - - QVERIFY(m1 == m2); - QVERIFY(!(m1 != m2)); - QVERIFY(m1 != m3); - QVERIFY(!(m1 == m3)); -} - -// Test 3x3 matrix comparisons. -void tst_QMatrixNxN::compare3x3() -{ - QMatrix3x3 m1(uniqueValues3); - QMatrix3x3 m2(uniqueValues3); - QMatrix3x3 m3(transposedValues3); - - QVERIFY(m1 == m2); - QVERIFY(!(m1 != m2)); - QVERIFY(m1 != m3); - QVERIFY(!(m1 == m3)); -} - -// Test 4x4 matrix comparisons. -void tst_QMatrixNxN::compare4x4() -{ - QMatrix4x4 m1(uniqueValues4); - QMatrix4x4 m2(uniqueValues4); - QMatrix4x4 m3(transposedValues4); - - QVERIFY(m1 == m2); - QVERIFY(!(m1 != m2)); - QVERIFY(m1 != m3); - QVERIFY(!(m1 == m3)); -} - -// Test 4x3 matrix comparisons. -void tst_QMatrixNxN::compare4x3() -{ - QMatrix4x3 m1(uniqueValues4x3); - QMatrix4x3 m2(uniqueValues4x3); - QMatrix4x3 m3(transposedValues3x4); - - QVERIFY(m1 == m2); - QVERIFY(!(m1 != m2)); - QVERIFY(m1 != m3); - QVERIFY(!(m1 == m3)); -} - -// Test matrix 2x2 transpose operations. -void tst_QMatrixNxN::transposed2x2() -{ - // Transposing the identity should result in the identity. - QMatrix2x2 m1; - QMatrix2x2 m2 = m1.transposed(); - QVERIFY(isIdentity(m2)); - - // Transpose a more interesting matrix that allows us to track - // exactly where each source element ends up. - QMatrix2x2 m3(uniqueValues2); - QMatrix2x2 m4 = m3.transposed(); - QVERIFY(isSame(m4, transposedValues2)); - - // Transpose in-place, just to check that the compiler is sane. - m3 = m3.transposed(); - QVERIFY(isSame(m3, transposedValues2)); -} - -// Test matrix 3x3 transpose operations. -void tst_QMatrixNxN::transposed3x3() -{ - // Transposing the identity should result in the identity. - QMatrix3x3 m1; - QMatrix3x3 m2 = m1.transposed(); - QVERIFY(isIdentity(m2)); - - // Transpose a more interesting matrix that allows us to track - // exactly where each source element ends up. - QMatrix3x3 m3(uniqueValues3); - QMatrix3x3 m4 = m3.transposed(); - QVERIFY(isSame(m4, transposedValues3)); - - // Transpose in-place, just to check that the compiler is sane. - m3 = m3.transposed(); - QVERIFY(isSame(m3, transposedValues3)); -} - -// Test matrix 4x4 transpose operations. -void tst_QMatrixNxN::transposed4x4() -{ - // Transposing the identity should result in the identity. - QMatrix4x4 m1; - QMatrix4x4 m2 = m1.transposed(); - QVERIFY(isIdentity(m2)); - - // Transpose a more interesting matrix that allows us to track - // exactly where each source element ends up. - QMatrix4x4 m3(uniqueValues4); - QMatrix4x4 m4 = m3.transposed(); - QVERIFY(isSame(m4, transposedValues4)); - - // Transpose in-place, just to check that the compiler is sane. - m3 = m3.transposed(); - QVERIFY(isSame(m3, transposedValues4)); -} - -// Test matrix 4x3 transpose operations. -void tst_QMatrixNxN::transposed4x3() -{ - QMatrix4x3 m3(uniqueValues4x3); - QMatrix3x4 m4 = m3.transposed(); - qreal values[12]; - m4.toValueArray(values); - for (int index = 0; index < 12; ++index) - QCOMPARE(values[index], transposedValues3x4[index]); -} - -// Test matrix addition for 2x2 matrices. -void tst_QMatrixNxN::add2x2_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("m2Values"); - QTest::addColumn("m3Values"); - - QTest::newRow("null") - << (void *)nullValues2 << (void *)nullValues2 << (void *)nullValues2; - - QTest::newRow("identity/null") - << (void *)identityValues2 << (void *)nullValues2 << (void *)identityValues2; - - QTest::newRow("identity/identity") - << (void *)identityValues2 << (void *)identityValues2 << (void *)doubleIdentity2; - - static qreal const sumValues[16] = - {2.0f, 7.0f, - 7.0f, 12.0f}; - QTest::newRow("unique") - << (void *)uniqueValues2 << (void *)transposedValues2 << (void *)sumValues; -} -void tst_QMatrixNxN::add2x2() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix2x2 m1((const qreal *)m1Values); - QMatrix2x2 m2((const qreal *)m2Values); - - QMatrix2x2 m4(m1); - m4 += m2; - QVERIFY(isSame(m4, (const qreal *)m3Values)); - - QMatrix2x2 m5; - m5 = m1 + m2; - QVERIFY(isSame(m5, (const qreal *)m3Values)); -} - -// Test matrix addition for 3x3 matrices. -void tst_QMatrixNxN::add3x3_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("m2Values"); - QTest::addColumn("m3Values"); - - QTest::newRow("null") - << (void *)nullValues3 << (void *)nullValues3 << (void *)nullValues3; - - QTest::newRow("identity/null") - << (void *)identityValues3 << (void *)nullValues3 << (void *)identityValues3; - - QTest::newRow("identity/identity") - << (void *)identityValues3 << (void *)identityValues3 << (void *)doubleIdentity3; - - static qreal const sumValues[16] = - {2.0f, 7.0f, 12.0f, - 7.0f, 12.0f, 17.0f, - 12.0f, 17.0f, 22.0f}; - QTest::newRow("unique") - << (void *)uniqueValues3 << (void *)transposedValues3 << (void *)sumValues; -} -void tst_QMatrixNxN::add3x3() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix3x3 m1((const qreal *)m1Values); - QMatrix3x3 m2((const qreal *)m2Values); - - QMatrix3x3 m4(m1); - m4 += m2; - QVERIFY(isSame(m4, (const qreal *)m3Values)); - - QMatrix3x3 m5; - m5 = m1 + m2; - QVERIFY(isSame(m5, (const qreal *)m3Values)); -} - -// Test matrix addition for 4x4 matrices. -void tst_QMatrixNxN::add4x4_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("m2Values"); - QTest::addColumn("m3Values"); - - QTest::newRow("null") - << (void *)nullValues4 << (void *)nullValues4 << (void *)nullValues4; - - QTest::newRow("identity/null") - << (void *)identityValues4 << (void *)nullValues4 << (void *)identityValues4; - - QTest::newRow("identity/identity") - << (void *)identityValues4 << (void *)identityValues4 << (void *)doubleIdentity4; - - static qreal const sumValues[16] = - {2.0f, 7.0f, 12.0f, 17.0f, - 7.0f, 12.0f, 17.0f, 22.0f, - 12.0f, 17.0f, 22.0f, 27.0f, - 17.0f, 22.0f, 27.0f, 32.0f}; - QTest::newRow("unique") - << (void *)uniqueValues4 << (void *)transposedValues4 << (void *)sumValues; -} -void tst_QMatrixNxN::add4x4() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix4x4 m1((const qreal *)m1Values); - QMatrix4x4 m2((const qreal *)m2Values); - - QMatrix4x4 m4(m1); - m4 += m2; - QVERIFY(isSame(m4, (const qreal *)m3Values)); - - QMatrix4x4 m5; - m5 = m1 + m2; - QVERIFY(isSame(m5, (const qreal *)m3Values)); -} - -// Test matrix addition for 4x3 matrices. -void tst_QMatrixNxN::add4x3_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("m2Values"); - QTest::addColumn("m3Values"); - - QTest::newRow("null") - << (void *)nullValues4x3 << (void *)nullValues4x3 << (void *)nullValues4x3; - - QTest::newRow("identity/null") - << (void *)identityValues4x3 << (void *)nullValues4x3 << (void *)identityValues4x3; - - QTest::newRow("identity/identity") - << (void *)identityValues4x3 << (void *)identityValues4x3 << (void *)doubleIdentity4x3; - - static qreal const sumValues[16] = - {2.0f, 7.0f, 12.0f, 6.0f, - 11.0f, 16.0f, 10.0f, 15.0f, - 20.0f, 14.0f, 19.0f, 24.0f}; - QTest::newRow("unique") - << (void *)uniqueValues4x3 << (void *)transposedValues3x4 << (void *)sumValues; -} -void tst_QMatrixNxN::add4x3() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix4x3 m1((const qreal *)m1Values); - QMatrix4x3 m2((const qreal *)m2Values); - - QMatrix4x3 m4(m1); - m4 += m2; - QVERIFY(isSame(m4, (const qreal *)m3Values)); - - QMatrix4x3 m5; - m5 = m1 + m2; - QVERIFY(isSame(m5, (const qreal *)m3Values)); -} - -// Test matrix subtraction for 2x2 matrices. -void tst_QMatrixNxN::subtract2x2_data() -{ - // Use the same test cases as the add test. - add2x2_data(); -} -void tst_QMatrixNxN::subtract2x2() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix2x2 m1((const qreal *)m1Values); - QMatrix2x2 m2((const qreal *)m2Values); - QMatrix2x2 m3((const qreal *)m3Values); - - QMatrix2x2 m4(m3); - m4 -= m1; - QVERIFY(isSame(m4, (const qreal *)m2Values)); - - QMatrix2x2 m5; - m5 = m3 - m1; - QVERIFY(isSame(m5, (const qreal *)m2Values)); - - QMatrix2x2 m6(m3); - m6 -= m2; - QVERIFY(isSame(m6, (const qreal *)m1Values)); - - QMatrix2x2 m7; - m7 = m3 - m2; - QVERIFY(isSame(m7, (const qreal *)m1Values)); -} - -// Test matrix subtraction for 3x3 matrices. -void tst_QMatrixNxN::subtract3x3_data() -{ - // Use the same test cases as the add test. - add3x3_data(); -} -void tst_QMatrixNxN::subtract3x3() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix3x3 m1((const qreal *)m1Values); - QMatrix3x3 m2((const qreal *)m2Values); - QMatrix3x3 m3((const qreal *)m3Values); - - QMatrix3x3 m4(m3); - m4 -= m1; - QVERIFY(isSame(m4, (const qreal *)m2Values)); - - QMatrix3x3 m5; - m5 = m3 - m1; - QVERIFY(isSame(m5, (const qreal *)m2Values)); - - QMatrix3x3 m6(m3); - m6 -= m2; - QVERIFY(isSame(m6, (const qreal *)m1Values)); - - QMatrix3x3 m7; - m7 = m3 - m2; - QVERIFY(isSame(m7, (const qreal *)m1Values)); -} - -// Test matrix subtraction for 4x4 matrices. -void tst_QMatrixNxN::subtract4x4_data() -{ - // Use the same test cases as the add test. - add4x4_data(); -} -void tst_QMatrixNxN::subtract4x4() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix4x4 m1((const qreal *)m1Values); - QMatrix4x4 m2((const qreal *)m2Values); - QMatrix4x4 m3((const qreal *)m3Values); - - QMatrix4x4 m4(m3); - m4 -= m1; - QVERIFY(isSame(m4, (const qreal *)m2Values)); - - QMatrix4x4 m5; - m5 = m3 - m1; - QVERIFY(isSame(m5, (const qreal *)m2Values)); - - QMatrix4x4 m6(m3); - m6 -= m2; - QVERIFY(isSame(m6, (const qreal *)m1Values)); - - QMatrix4x4 m7; - m7 = m3 - m2; - QVERIFY(isSame(m7, (const qreal *)m1Values)); -} - -// Test matrix subtraction for 4x3 matrices. -void tst_QMatrixNxN::subtract4x3_data() -{ - // Use the same test cases as the add test. - add4x3_data(); -} -void tst_QMatrixNxN::subtract4x3() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix4x3 m1((const qreal *)m1Values); - QMatrix4x3 m2((const qreal *)m2Values); - QMatrix4x3 m3((const qreal *)m3Values); - - QMatrix4x3 m4(m3); - m4 -= m1; - QVERIFY(isSame(m4, (const qreal *)m2Values)); - - QMatrix4x3 m5; - m5 = m3 - m1; - QVERIFY(isSame(m5, (const qreal *)m2Values)); - - QMatrix4x3 m6(m3); - m6 -= m2; - QVERIFY(isSame(m6, (const qreal *)m1Values)); - - QMatrix4x3 m7; - m7 = m3 - m2; - QVERIFY(isSame(m7, (const qreal *)m1Values)); -} - -// Test matrix multiplication for 2x2 matrices. -void tst_QMatrixNxN::multiply2x2_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("m2Values"); - QTest::addColumn("m3Values"); - - QTest::newRow("null") - << (void *)nullValues2 << (void *)nullValues2 << (void *)nullValues2; - - QTest::newRow("null/unique") - << (void *)nullValues2 << (void *)uniqueValues2 << (void *)nullValues2; - - QTest::newRow("unique/null") - << (void *)uniqueValues2 << (void *)nullValues2 << (void *)nullValues2; - - QTest::newRow("unique/identity") - << (void *)uniqueValues2 << (void *)identityValues2 << (void *)uniqueValues2; - - QTest::newRow("identity/unique") - << (void *)identityValues2 << (void *)uniqueValues2 << (void *)uniqueValues2; - - static qreal uniqueResult[4]; - for (int row = 0; row < 2; ++row) { - for (int col = 0; col < 2; ++col) { - qreal sum = 0.0f; - for (int j = 0; j < 2; ++j) - sum += uniqueValues2[row * 2 + j] * transposedValues2[j * 2 + col]; - uniqueResult[row * 2 + col] = sum; - } - } - - QTest::newRow("unique/transposed") - << (void *)uniqueValues2 << (void *)transposedValues2 << (void *)uniqueResult; -} -void tst_QMatrixNxN::multiply2x2() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix2x2 m1((const qreal *)m1Values); - QMatrix2x2 m2((const qreal *)m2Values); - - QMatrix2x2 m5; - m5 = m1 * m2; - QVERIFY(isSame(m5, (const qreal *)m3Values)); -} - -// Test matrix multiplication for 3x3 matrices. -void tst_QMatrixNxN::multiply3x3_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("m2Values"); - QTest::addColumn("m3Values"); - - QTest::newRow("null") - << (void *)nullValues3 << (void *)nullValues3 << (void *)nullValues3; - - QTest::newRow("null/unique") - << (void *)nullValues3 << (void *)uniqueValues3 << (void *)nullValues3; - - QTest::newRow("unique/null") - << (void *)uniqueValues3 << (void *)nullValues3 << (void *)nullValues3; - - QTest::newRow("unique/identity") - << (void *)uniqueValues3 << (void *)identityValues3 << (void *)uniqueValues3; - - QTest::newRow("identity/unique") - << (void *)identityValues3 << (void *)uniqueValues3 << (void *)uniqueValues3; - - static qreal uniqueResult[9]; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - qreal sum = 0.0f; - for (int j = 0; j < 3; ++j) - sum += uniqueValues3[row * 3 + j] * transposedValues3[j * 3 + col]; - uniqueResult[row * 3 + col] = sum; - } - } - - QTest::newRow("unique/transposed") - << (void *)uniqueValues3 << (void *)transposedValues3 << (void *)uniqueResult; -} -void tst_QMatrixNxN::multiply3x3() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix3x3 m1((const qreal *)m1Values); - QMatrix3x3 m2((const qreal *)m2Values); - - QMatrix3x3 m5; - m5 = m1 * m2; - QVERIFY(isSame(m5, (const qreal *)m3Values)); -} - -// Test matrix multiplication for 4x4 matrices. -void tst_QMatrixNxN::multiply4x4_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("m2Values"); - QTest::addColumn("m3Values"); - - QTest::newRow("null") - << (void *)nullValues4 << (void *)nullValues4 << (void *)nullValues4; - - QTest::newRow("null/unique") - << (void *)nullValues4 << (void *)uniqueValues4 << (void *)nullValues4; - - QTest::newRow("unique/null") - << (void *)uniqueValues4 << (void *)nullValues4 << (void *)nullValues4; - - QTest::newRow("unique/identity") - << (void *)uniqueValues4 << (void *)identityValues4 << (void *)uniqueValues4; - - QTest::newRow("identity/unique") - << (void *)identityValues4 << (void *)uniqueValues4 << (void *)uniqueValues4; - - static qreal uniqueResult[16]; - for (int row = 0; row < 4; ++row) { - for (int col = 0; col < 4; ++col) { - qreal sum = 0.0f; - for (int j = 0; j < 4; ++j) - sum += uniqueValues4[row * 4 + j] * transposedValues4[j * 4 + col]; - uniqueResult[row * 4 + col] = sum; - } - } - - QTest::newRow("unique/transposed") - << (void *)uniqueValues4 << (void *)transposedValues4 << (void *)uniqueResult; -} -void tst_QMatrixNxN::multiply4x4() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix4x4 m1((const qreal *)m1Values); - QMatrix4x4 m2((const qreal *)m2Values); - - QMatrix4x4 m4; - m4 = m1; - m4 *= m2; - QVERIFY(isSame(m4, (const qreal *)m3Values)); - - QMatrix4x4 m5; - m5 = m1 * m2; - QVERIFY(isSame(m5, (const qreal *)m3Values)); -} - -// Test matrix multiplication for 4x3 matrices. -void tst_QMatrixNxN::multiply4x3_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("m2Values"); - QTest::addColumn("m3Values"); - - QTest::newRow("null") - << (void *)nullValues4x3 << (void *)nullValues4x3 << (void *)nullValues3; - - QTest::newRow("null/unique") - << (void *)nullValues4x3 << (void *)uniqueValues4x3 << (void *)nullValues3; - - QTest::newRow("unique/null") - << (void *)uniqueValues4x3 << (void *)nullValues4x3 << (void *)nullValues3; - - static qreal uniqueResult[9]; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - qreal sum = 0.0f; - for (int j = 0; j < 4; ++j) - sum += uniqueValues4x3[row * 4 + j] * transposedValues3x4[j * 3 + col]; - uniqueResult[row * 3 + col] = sum; - } - } - - QTest::newRow("unique/transposed") - << (void *)uniqueValues4x3 << (void *)transposedValues3x4 << (void *)uniqueResult; -} -void tst_QMatrixNxN::multiply4x3() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(void *, m3Values); - - QMatrix4x3 m1((const qreal *)m1Values); - QMatrix3x4 m2((const qreal *)m2Values); - - QGenericMatrix<3, 3, qreal, float> m4; - m4 = m1 * m2; - qreal values[9]; - m4.toValueArray(values); - for (int index = 0; index < 9; ++index) - QCOMPARE(values[index], ((const qreal *)m3Values)[index]); -} - -// Test matrix multiplication by a factor for 2x2 matrices. -void tst_QMatrixNxN::multiplyFactor2x2_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("factor"); - QTest::addColumn("m2Values"); - - QTest::newRow("null") - << (void *)nullValues2 << (qreal)1.0f << (void *)nullValues2; - - QTest::newRow("double identity") - << (void *)identityValues2 << (qreal)2.0f << (void *)doubleIdentity2; - - static qreal const values[16] = - {1.0f, 2.0f, - 5.0f, 6.0f}; - static qreal const doubleValues[16] = - {2.0f, 4.0f, - 10.0f, 12.0f}; - static qreal const negDoubleValues[16] = - {-2.0f, -4.0f, - -10.0f, -12.0f}; - - QTest::newRow("unique") - << (void *)values << (qreal)2.0f << (void *)doubleValues; - - QTest::newRow("neg") - << (void *)values << (qreal)-2.0f << (void *)negDoubleValues; - - QTest::newRow("zero") - << (void *)values << (qreal)0.0f << (void *)nullValues4; -} -void tst_QMatrixNxN::multiplyFactor2x2() -{ - QFETCH(void *, m1Values); - QFETCH(qreal, factor); - QFETCH(void *, m2Values); - - QMatrix2x2 m1((const qreal *)m1Values); - - QMatrix2x2 m3; - m3 = m1; - m3 *= factor; - QVERIFY(isSame(m3, (const qreal *)m2Values)); - - QMatrix2x2 m4; - m4 = m1 * factor; - QVERIFY(isSame(m4, (const qreal *)m2Values)); - - QMatrix2x2 m5; - m5 = factor * m1; - QVERIFY(isSame(m5, (const qreal *)m2Values)); -} - -// Test matrix multiplication by a factor for 3x3 matrices. -void tst_QMatrixNxN::multiplyFactor3x3_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("factor"); - QTest::addColumn("m2Values"); - - QTest::newRow("null") - << (void *)nullValues3 << (qreal)1.0f << (void *)nullValues3; - - QTest::newRow("double identity") - << (void *)identityValues3 << (qreal)2.0f << (void *)doubleIdentity3; - - static qreal const values[16] = - {1.0f, 2.0f, 3.0f, - 5.0f, 6.0f, 7.0f, - 9.0f, 10.0f, 11.0f}; - static qreal const doubleValues[16] = - {2.0f, 4.0f, 6.0f, - 10.0f, 12.0f, 14.0f, - 18.0f, 20.0f, 22.0f}; - static qreal const negDoubleValues[16] = - {-2.0f, -4.0f, -6.0f, - -10.0f, -12.0f, -14.0f, - -18.0f, -20.0f, -22.0f}; - - QTest::newRow("unique") - << (void *)values << (qreal)2.0f << (void *)doubleValues; - - QTest::newRow("neg") - << (void *)values << (qreal)-2.0f << (void *)negDoubleValues; - - QTest::newRow("zero") - << (void *)values << (qreal)0.0f << (void *)nullValues4; -} -void tst_QMatrixNxN::multiplyFactor3x3() -{ - QFETCH(void *, m1Values); - QFETCH(qreal, factor); - QFETCH(void *, m2Values); - - QMatrix3x3 m1((const qreal *)m1Values); - - QMatrix3x3 m3; - m3 = m1; - m3 *= factor; - QVERIFY(isSame(m3, (const qreal *)m2Values)); - - QMatrix3x3 m4; - m4 = m1 * factor; - QVERIFY(isSame(m4, (const qreal *)m2Values)); - - QMatrix3x3 m5; - m5 = factor * m1; - QVERIFY(isSame(m5, (const qreal *)m2Values)); -} - -// Test matrix multiplication by a factor for 4x4 matrices. -void tst_QMatrixNxN::multiplyFactor4x4_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("factor"); - QTest::addColumn("m2Values"); - - QTest::newRow("null") - << (void *)nullValues4 << (qreal)1.0f << (void *)nullValues4; - - QTest::newRow("double identity") - << (void *)identityValues4 << (qreal)2.0f << (void *)doubleIdentity4; - - static qreal const values[16] = - {1.0f, 2.0f, 3.0f, 4.0f, - 5.0f, 6.0f, 7.0f, 8.0f, - 9.0f, 10.0f, 11.0f, 12.0f, - 13.0f, 14.0f, 15.0f, 16.0f}; - static qreal const doubleValues[16] = - {2.0f, 4.0f, 6.0f, 8.0f, - 10.0f, 12.0f, 14.0f, 16.0f, - 18.0f, 20.0f, 22.0f, 24.0f, - 26.0f, 28.0f, 30.0f, 32.0f}; - static qreal const negDoubleValues[16] = - {-2.0f, -4.0f, -6.0f, -8.0f, - -10.0f, -12.0f, -14.0f, -16.0f, - -18.0f, -20.0f, -22.0f, -24.0f, - -26.0f, -28.0f, -30.0f, -32.0f}; - - QTest::newRow("unique") - << (void *)values << (qreal)2.0f << (void *)doubleValues; - - QTest::newRow("neg") - << (void *)values << (qreal)-2.0f << (void *)negDoubleValues; - - QTest::newRow("zero") - << (void *)values << (qreal)0.0f << (void *)nullValues4; -} -void tst_QMatrixNxN::multiplyFactor4x4() -{ - QFETCH(void *, m1Values); - QFETCH(qreal, factor); - QFETCH(void *, m2Values); - - QMatrix4x4 m1((const qreal *)m1Values); - - QMatrix4x4 m3; - m3 = m1; - m3 *= factor; - QVERIFY(isSame(m3, (const qreal *)m2Values)); - - QMatrix4x4 m4; - m4 = m1 * factor; - QVERIFY(isSame(m4, (const qreal *)m2Values)); - - QMatrix4x4 m5; - m5 = factor * m1; - QVERIFY(isSame(m5, (const qreal *)m2Values)); -} - -// Test matrix multiplication by a factor for 4x3 matrices. -void tst_QMatrixNxN::multiplyFactor4x3_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("factor"); - QTest::addColumn("m2Values"); - - QTest::newRow("null") - << (void *)nullValues4x3 << (qreal)1.0f << (void *)nullValues4x3; - - QTest::newRow("double identity") - << (void *)identityValues4x3 << (qreal)2.0f << (void *)doubleIdentity4x3; - - static qreal const values[12] = - {1.0f, 2.0f, 3.0f, 4.0f, - 5.0f, 6.0f, 7.0f, 8.0f, - 9.0f, 10.0f, 11.0f, 12.0f}; - static qreal const doubleValues[12] = - {2.0f, 4.0f, 6.0f, 8.0f, - 10.0f, 12.0f, 14.0f, 16.0f, - 18.0f, 20.0f, 22.0f, 24.0f}; - static qreal const negDoubleValues[12] = - {-2.0f, -4.0f, -6.0f, -8.0f, - -10.0f, -12.0f, -14.0f, -16.0f, - -18.0f, -20.0f, -22.0f, -24.0f}; - - QTest::newRow("unique") - << (void *)values << (qreal)2.0f << (void *)doubleValues; - - QTest::newRow("neg") - << (void *)values << (qreal)-2.0f << (void *)negDoubleValues; - - QTest::newRow("zero") - << (void *)values << (qreal)0.0f << (void *)nullValues4x3; -} -void tst_QMatrixNxN::multiplyFactor4x3() -{ - QFETCH(void *, m1Values); - QFETCH(qreal, factor); - QFETCH(void *, m2Values); - - QMatrix4x3 m1((const qreal *)m1Values); - - QMatrix4x3 m3; - m3 = m1; - m3 *= factor; - QVERIFY(isSame(m3, (const qreal *)m2Values)); - - QMatrix4x3 m4; - m4 = m1 * factor; - QVERIFY(isSame(m4, (const qreal *)m2Values)); - - QMatrix4x3 m5; - m5 = factor * m1; - QVERIFY(isSame(m5, (const qreal *)m2Values)); -} - -// Test matrix division by a factor for 2x2 matrices. -void tst_QMatrixNxN::divideFactor2x2_data() -{ - // Use the same test cases as the multiplyFactor test. - multiplyFactor2x2_data(); -} -void tst_QMatrixNxN::divideFactor2x2() -{ - QFETCH(void *, m1Values); - QFETCH(qreal, factor); - QFETCH(void *, m2Values); - - if (factor == 0.0f) - return; - - QMatrix2x2 m2((const qreal *)m2Values); - - QMatrix2x2 m3; - m3 = m2; - m3 /= factor; - QVERIFY(isSame(m3, (const qreal *)m1Values)); - - QMatrix2x2 m4; - m4 = m2 / factor; - QVERIFY(isSame(m4, (const qreal *)m1Values)); -} - -// Test matrix division by a factor for 3x3 matrices. -void tst_QMatrixNxN::divideFactor3x3_data() -{ - // Use the same test cases as the multiplyFactor test. - multiplyFactor3x3_data(); -} -void tst_QMatrixNxN::divideFactor3x3() -{ - QFETCH(void *, m1Values); - QFETCH(qreal, factor); - QFETCH(void *, m2Values); - - if (factor == 0.0f) - return; - - QMatrix3x3 m2((const qreal *)m2Values); - - QMatrix3x3 m3; - m3 = m2; - m3 /= factor; - QVERIFY(isSame(m3, (const qreal *)m1Values)); - - QMatrix3x3 m4; - m4 = m2 / factor; - QVERIFY(isSame(m4, (const qreal *)m1Values)); -} - -// Test matrix division by a factor for 4x4 matrices. -void tst_QMatrixNxN::divideFactor4x4_data() -{ - // Use the same test cases as the multiplyFactor test. - multiplyFactor4x4_data(); -} -void tst_QMatrixNxN::divideFactor4x4() -{ - QFETCH(void *, m1Values); - QFETCH(qreal, factor); - QFETCH(void *, m2Values); - - if (factor == 0.0f) - return; - - QMatrix4x4 m2((const qreal *)m2Values); - - QMatrix4x4 m3; - m3 = m2; - m3 /= factor; - QVERIFY(isSame(m3, (const qreal *)m1Values)); - - QMatrix4x4 m4; - m4 = m2 / factor; - QVERIFY(isSame(m4, (const qreal *)m1Values)); -} - -// Test matrix division by a factor for 4x3 matrices. -void tst_QMatrixNxN::divideFactor4x3_data() -{ - // Use the same test cases as the multiplyFactor test. - multiplyFactor4x3_data(); -} -void tst_QMatrixNxN::divideFactor4x3() -{ - QFETCH(void *, m1Values); - QFETCH(qreal, factor); - QFETCH(void *, m2Values); - - if (factor == 0.0f) - return; - - QMatrix4x3 m2((const qreal *)m2Values); - - QMatrix4x3 m3; - m3 = m2; - m3 /= factor; - QVERIFY(isSame(m3, (const qreal *)m1Values)); - - QMatrix4x3 m4; - m4 = m2 / factor; - QVERIFY(isSame(m4, (const qreal *)m1Values)); -} - -// Test matrix negation for 2x2 matrices. -void tst_QMatrixNxN::negate2x2_data() -{ - // Use the same test cases as the multiplyFactor test. - multiplyFactor2x2_data(); -} -void tst_QMatrixNxN::negate2x2() -{ - QFETCH(void *, m1Values); - - const qreal *values = (const qreal *)m1Values; - - QMatrix2x2 m1(values); - - qreal negated[4]; - for (int index = 0; index < 4; ++index) - negated[index] = -values[index]; - - QMatrix2x2 m2; - m2 = -m1; - QVERIFY(isSame(m2, negated)); -} - -// Test matrix negation for 3x3 matrices. -void tst_QMatrixNxN::negate3x3_data() -{ - // Use the same test cases as the multiplyFactor test. - multiplyFactor3x3_data(); -} -void tst_QMatrixNxN::negate3x3() -{ - QFETCH(void *, m1Values); - - const qreal *values = (const qreal *)m1Values; - - QMatrix3x3 m1(values); - - qreal negated[9]; - for (int index = 0; index < 9; ++index) - negated[index] = -values[index]; - - QMatrix3x3 m2; - m2 = -m1; - QVERIFY(isSame(m2, negated)); -} - -// Test matrix negation for 4x4 matrices. -void tst_QMatrixNxN::negate4x4_data() -{ - // Use the same test cases as the multiplyFactor test. - multiplyFactor4x4_data(); -} -void tst_QMatrixNxN::negate4x4() -{ - QFETCH(void *, m1Values); - - const qreal *values = (const qreal *)m1Values; - - QMatrix4x4 m1(values); - - qreal negated[16]; - for (int index = 0; index < 16; ++index) - negated[index] = -values[index]; - - QMatrix4x4 m2; - m2 = -m1; - QVERIFY(isSame(m2, negated)); -} - -// Test matrix negation for 4x3 matrices. -void tst_QMatrixNxN::negate4x3_data() -{ - // Use the same test cases as the multiplyFactor test. - multiplyFactor4x3_data(); -} -void tst_QMatrixNxN::negate4x3() -{ - QFETCH(void *, m1Values); - - const qreal *values = (const qreal *)m1Values; - - QMatrix4x3 m1(values); - - qreal negated[12]; - for (int index = 0; index < 12; ++index) - negated[index] = -values[index]; - - QMatrix4x3 m2; - m2 = -m1; - QVERIFY(isSame(m2, negated)); -} - -// Matrix inverted. This is a more straight-forward implementation -// of the algorithm at http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q24 -// than the optimized version in the QMatrix4x4 code. Hopefully it is -// easier to verify that this version is the same as the reference. - -struct Matrix3 -{ - qreal v[9]; -}; -struct Matrix4 -{ - qreal v[16]; -}; - -static qreal m3Determinant(const Matrix3& m) -{ - return m.v[0] * (m.v[4] * m.v[8] - m.v[7] * m.v[5]) - - m.v[1] * (m.v[3] * m.v[8] - m.v[6] * m.v[5]) + - m.v[2] * (m.v[3] * m.v[7] - m.v[6] * m.v[4]); -} - -static bool m3Inverse(const Matrix3& min, Matrix3& mout) -{ - qreal det = m3Determinant(min); - if (det == 0.0f) - return false; - mout.v[0] = (min.v[4] * min.v[8] - min.v[5] * min.v[7]) / det; - mout.v[1] = -(min.v[1] * min.v[8] - min.v[2] * min.v[7]) / det; - mout.v[2] = (min.v[1] * min.v[5] - min.v[4] * min.v[2]) / det; - mout.v[3] = -(min.v[3] * min.v[8] - min.v[5] * min.v[6]) / det; - mout.v[4] = (min.v[0] * min.v[8] - min.v[6] * min.v[2]) / det; - mout.v[5] = -(min.v[0] * min.v[5] - min.v[3] * min.v[2]) / det; - mout.v[6] = (min.v[3] * min.v[7] - min.v[6] * min.v[4]) / det; - mout.v[7] = -(min.v[0] * min.v[7] - min.v[6] * min.v[1]) / det; - mout.v[8] = (min.v[0] * min.v[4] - min.v[1] * min.v[3]) / det; - return true; -} - -static void m3Transpose(Matrix3& m) -{ - qSwap(m.v[1], m.v[3]); - qSwap(m.v[2], m.v[6]); - qSwap(m.v[5], m.v[7]); -} - -static void m4Submatrix(const Matrix4& min, Matrix3& mout, int i, int j) -{ - for (int di = 0; di < 3; ++di) { - for (int dj = 0; dj < 3; ++dj) { - int si = di + ((di >= i) ? 1 : 0); - int sj = dj + ((dj >= j) ? 1 : 0); - mout.v[di * 3 + dj] = min.v[si * 4 + sj]; - } - } -} - -static qreal m4Determinant(const Matrix4& m) -{ - qreal det; - qreal result = 0.0f; - qreal i = 1.0f; - Matrix3 msub; - for (int n = 0; n < 4; ++n, i *= -1.0f) { - m4Submatrix(m, msub, 0, n); - det = m3Determinant(msub); - result += m.v[n] * det * i; - } - return result; -} - -static void m4Inverse(const Matrix4& min, Matrix4& mout) -{ - qreal det = m4Determinant(min); - Matrix3 msub; - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - qreal sign = 1.0f - ((i + j) % 2) * 2.0f; - m4Submatrix(min, msub, i, j); - mout.v[i + j * 4] = (m3Determinant(msub) * sign) / det; - } - } -} - -// Test matrix inverted for 4x4 matrices. -void tst_QMatrixNxN::inverted4x4_data() -{ - QTest::addColumn("m1Values"); - QTest::addColumn("m2Values"); - QTest::addColumn("invertible"); - - QTest::newRow("null") - << (void *)nullValues4 << (void *)identityValues4 << false; - - QTest::newRow("identity") - << (void *)identityValues4 << (void *)identityValues4 << true; - - QTest::newRow("unique") - << (void *)uniqueValues4 << (void *)identityValues4 << false; - - static Matrix4 const invertible = { - {5.0f, 0.0f, 0.0f, 2.0f, - 0.0f, 6.0f, 0.0f, 3.0f, - 0.0f, 0.0f, 7.0f, 4.0f, - 0.0f, 0.0f, 0.0f, 1.0f} - }; - static Matrix4 inverted; - m4Inverse(invertible, inverted); - - QTest::newRow("invertible") - << (void *)invertible.v << (void *)inverted.v << true; - - static Matrix4 const translate = { - {1.0f, 0.0f, 0.0f, 2.0f, - 0.0f, 1.0f, 0.0f, 3.0f, - 0.0f, 0.0f, 1.0f, 4.0f, - 0.0f, 0.0f, 0.0f, 1.0f} - }; - static Matrix4 const inverseTranslate = { - {1.0f, 0.0f, 0.0f, -2.0f, - 0.0f, 1.0f, 0.0f, -3.0f, - 0.0f, 0.0f, 1.0f, -4.0f, - 0.0f, 0.0f, 0.0f, 1.0f} - }; - - QTest::newRow("translate") - << (void *)translate.v << (void *)inverseTranslate.v << true; -} -void tst_QMatrixNxN::inverted4x4() -{ - QFETCH(void *, m1Values); - QFETCH(void *, m2Values); - QFETCH(bool, invertible); - - QMatrix4x4 m1((const qreal *)m1Values); - - if (invertible) - QVERIFY(m1.determinant() != 0.0f); - else - QVERIFY(m1.determinant() == 0.0f); - - Matrix4 m1alt; - memcpy(m1alt.v, (const qreal *)m1Values, sizeof(m1alt.v)); - - QCOMPARE((float)(m1.determinant()), (float)(m4Determinant(m1alt))); - - QMatrix4x4 m2; - bool inv; - m2 = m1.inverted(&inv); - QVERIFY(isSame(m2, (const qreal *)m2Values)); - - if (invertible) { - QVERIFY(inv); - - Matrix4 m2alt; - m4Inverse(m1alt, m2alt); - QVERIFY(isSame(m2, m2alt.v)); - - QMatrix4x4 m3; - m3 = m1 * m2; - QVERIFY(isIdentity(m3)); - - QMatrix4x4 m4; - m4 = m2 * m1; - QVERIFY(isIdentity(m4)); - } else { - QVERIFY(!inv); - } - - // Test again, after inferring the special matrix type. - m1.inferSpecialType(); - m2 = m1.inverted(&inv); - QVERIFY(isSame(m2, (const qreal *)m2Values)); - QCOMPARE(inv, invertible); -} - -void tst_QMatrixNxN::orthonormalInverse4x4() -{ - QMatrix4x4 m1; - QVERIFY(matrixFuzzyCompare(m1.inverted(), m1)); - - QMatrix4x4 m2; - m2.rotate(45.0, 1.0, 0.0, 0.0); - m2.translate(10.0, 0.0, 0.0); - - // Use inferSpecialType() to drop the internal flags that - // mark the matrix as orthonormal. This will force inverted() - // to compute m3.inverted() the long way. We can then compare - // the result to what the faster algorithm produces on m2. - QMatrix4x4 m3 = m2; - m3.inferSpecialType(); - bool invertible; - QVERIFY(matrixFuzzyCompare(m2.inverted(&invertible), m3.inverted())); - QVERIFY(invertible); - - QMatrix4x4 m4; - m4.rotate(45.0, 0.0, 1.0, 0.0); - QMatrix4x4 m5 = m4; - m5.inferSpecialType(); - QVERIFY(matrixFuzzyCompare(m4.inverted(), m5.inverted())); - - QMatrix4x4 m6; - m1.rotate(88, 0.0, 0.0, 1.0); - m1.translate(-20.0, 20.0, 15.0); - m1.rotate(25, 1.0, 0.0, 0.0); - QMatrix4x4 m7 = m6; - m7.inferSpecialType(); - QVERIFY(matrixFuzzyCompare(m6.inverted(), m7.inverted())); -} - -// Test the generation and use of 4x4 scale matrices. -void tst_QMatrixNxN::scale4x4_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("z"); - QTest::addColumn("resultValues"); - - static const qreal nullScale[] = - {0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (void *)nullScale; - - QTest::newRow("identity") - << (qreal)1.0f << (qreal)1.0f << (qreal)1.0f << (void *)identityValues4; - - static const qreal doubleScale[] = - {2.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 2.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 2.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("double") - << (qreal)2.0f << (qreal)2.0f << (qreal)2.0f << (void *)doubleScale; - - static const qreal complexScale[] = - {2.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 11.0f, 0.0f, 0.0f, - 0.0f, 0.0f, -6.5f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("complex") - << (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexScale; - - static const qreal complexScale2D[] = - {2.0f, 0.0f, 0.0f, 0.0f, - 0.0f, -11.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("complex2D") - << (qreal)2.0f << (qreal)-11.0f << (qreal)1.0f << (void *)complexScale2D; -} -void tst_QMatrixNxN::scale4x4() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(void *, resultValues); - - QMatrix4x4 result((const qreal *)resultValues); - - QMatrix4x4 m1; - m1.scale(QVector3D(x, y, z)); - QVERIFY(isSame(m1, (const qreal *)resultValues)); - - QMatrix4x4 m2; - m2.scale(x, y, z); - QVERIFY(isSame(m2, (const qreal *)resultValues)); - - if (z == 1.0f) { - QMatrix4x4 m2b; - m2b.scale(x, y); - QVERIFY(m2b == m2); - } - - QVector3D v1(2.0f, 3.0f, -4.0f); - QVector3D v2 = m1 * v1; - QCOMPARE(v2.x(), (qreal)(2.0f * x)); - QCOMPARE(v2.y(), (qreal)(3.0f * y)); - QCOMPARE(v2.z(), (qreal)(-4.0f * z)); - - v2 = v1 * m1; - QCOMPARE(v2.x(), (qreal)(2.0f * x)); - QCOMPARE(v2.y(), (qreal)(3.0f * y)); - QCOMPARE(v2.z(), (qreal)(-4.0f * z)); - - QVector4D v3(2.0f, 3.0f, -4.0f, 34.0f); - QVector4D v4 = m1 * v3; - QCOMPARE(v4.x(), (qreal)(2.0f * x)); - QCOMPARE(v4.y(), (qreal)(3.0f * y)); - QCOMPARE(v4.z(), (qreal)(-4.0f * z)); - QCOMPARE(v4.w(), (qreal)34.0f); - - v4 = v3 * m1; - QCOMPARE(v4.x(), (qreal)(2.0f * x)); - QCOMPARE(v4.y(), (qreal)(3.0f * y)); - QCOMPARE(v4.z(), (qreal)(-4.0f * z)); - QCOMPARE(v4.w(), (qreal)34.0f); - - QPoint p1(2, 3); - QPoint p2 = m1 * p1; - QCOMPARE(p2.x(), (int)(2.0f * x)); - QCOMPARE(p2.y(), (int)(3.0f * y)); - - p2 = p1 * m1; - QCOMPARE(p2.x(), (int)(2.0f * x)); - QCOMPARE(p2.y(), (int)(3.0f * y)); - - QPointF p3(2.0f, 3.0f); - QPointF p4 = m1 * p3; - QCOMPARE(p4.x(), (qreal)(2.0f * x)); - QCOMPARE(p4.y(), (qreal)(3.0f * y)); - - p4 = p3 * m1; - QCOMPARE(p4.x(), (qreal)(2.0f * x)); - QCOMPARE(p4.y(), (qreal)(3.0f * y)); - - QMatrix4x4 m3(uniqueValues4); - QMatrix4x4 m4(m3); - m4.scale(x, y, z); - QVERIFY(m4 == m3 * m1); - - if (x == y && y == z) { - QMatrix4x4 m5; - m5.scale(x); - QVERIFY(isSame(m5, (const qreal *)resultValues)); - } - - if (z == 1.0f) { - QMatrix4x4 m4b(m3); - m4b.scale(x, y); - QVERIFY(m4b == m4); - } - - // Test coverage when the special matrix type is unknown. - - QMatrix4x4 m6; - m6(0, 0) = 1.0f; - m6.scale(QVector3D(x, y, z)); - QVERIFY(isSame(m6, (const qreal *)resultValues)); - - QMatrix4x4 m7; - m7(0, 0) = 1.0f; - m7.scale(x, y, z); - QVERIFY(isSame(m7, (const qreal *)resultValues)); - - if (x == y && y == z) { - QMatrix4x4 m8; - m8(0, 0) = 1.0f; - m8.scale(x); - QVERIFY(isSame(m8, (const qreal *)resultValues)); - - m8.inferSpecialType(); - m8.scale(1.0f); - QVERIFY(isSame(m8, (const qreal *)resultValues)); - - QMatrix4x4 m9; - m9.translate(0.0f, 0.0f, 0.0f); - m9.scale(x); - QVERIFY(isSame(m9, (const qreal *)resultValues)); - } -} - -// Test the generation and use of 4x4 translation matrices. -void tst_QMatrixNxN::translate4x4_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("z"); - QTest::addColumn("resultValues"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (void *)identityValues4; - - static const qreal identityTranslate[] = - {1.0f, 0.0f, 0.0f, 1.0f, - 0.0f, 1.0f, 0.0f, 1.0f, - 0.0f, 0.0f, 1.0f, 1.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("identity") - << (qreal)1.0f << (qreal)1.0f << (qreal)1.0f << (void *)identityTranslate; - - static const qreal complexTranslate[] = - {1.0f, 0.0f, 0.0f, 2.0f, - 0.0f, 1.0f, 0.0f, 11.0f, - 0.0f, 0.0f, 1.0f, -6.5f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("complex") - << (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexTranslate; - - static const qreal complexTranslate2D[] = - {1.0f, 0.0f, 0.0f, 2.0f, - 0.0f, 1.0f, 0.0f, -11.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("complex2D") - << (qreal)2.0f << (qreal)-11.0f << (qreal)0.0f << (void *)complexTranslate2D; -} -void tst_QMatrixNxN::translate4x4() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(void *, resultValues); - - QMatrix4x4 result((const qreal *)resultValues); - - QMatrix4x4 m1; - m1.translate(QVector3D(x, y, z)); - QVERIFY(isSame(m1, (const qreal *)resultValues)); - - QMatrix4x4 m2; - m2.translate(x, y, z); - QVERIFY(isSame(m2, (const qreal *)resultValues)); - - if (z == 0.0f) { - QMatrix4x4 m2b; - m2b.translate(x, y); - QVERIFY(m2b == m2); - } - - QVector3D v1(2.0f, 3.0f, -4.0f); - QVector3D v2 = m1 * v1; - QCOMPARE(v2.x(), (qreal)(2.0f + x)); - QCOMPARE(v2.y(), (qreal)(3.0f + y)); - QCOMPARE(v2.z(), (qreal)(-4.0f + z)); - - QVector4D v3(2.0f, 3.0f, -4.0f, 1.0f); - QVector4D v4 = m1 * v3; - QCOMPARE(v4.x(), (qreal)(2.0f + x)); - QCOMPARE(v4.y(), (qreal)(3.0f + y)); - QCOMPARE(v4.z(), (qreal)(-4.0f + z)); - QCOMPARE(v4.w(), (qreal)1.0f); - - QVector4D v5(2.0f, 3.0f, -4.0f, 34.0f); - QVector4D v6 = m1 * v5; - QCOMPARE(v6.x(), (qreal)(2.0f + x * 34.0f)); - QCOMPARE(v6.y(), (qreal)(3.0f + y * 34.0f)); - QCOMPARE(v6.z(), (qreal)(-4.0f + z * 34.0f)); - QCOMPARE(v6.w(), (qreal)34.0f); - - QPoint p1(2, 3); - QPoint p2 = m1 * p1; - QCOMPARE(p2.x(), (int)(2.0f + x)); - QCOMPARE(p2.y(), (int)(3.0f + y)); - - QPointF p3(2.0f, 3.0f); - QPointF p4 = m1 * p3; - QCOMPARE(p4.x(), (qreal)(2.0f + x)); - QCOMPARE(p4.y(), (qreal)(3.0f + y)); - - QMatrix4x4 m3(uniqueValues4); - QMatrix4x4 m4(m3); - m4.translate(x, y, z); - QVERIFY(m4 == m3 * m1); - - if (z == 0.0f) { - QMatrix4x4 m4b(m3); - m4b.translate(x, y); - QVERIFY(m4b == m4); - } -} - -// Test the generation and use of 4x4 rotation matrices. -void tst_QMatrixNxN::rotate4x4_data() -{ - QTest::addColumn("angle"); - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("z"); - QTest::addColumn("resultValues"); - - static const qreal nullRotate[] = - {0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("null") - << (qreal)90.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (void *)nullRotate; - - static const qreal noRotate[] = - {1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("zerodegrees") - << (qreal)0.0f - << (qreal)2.0f << (qreal)3.0f << (qreal)-4.0f - << (void *)noRotate; - - static const qreal xRotate[] = - {1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, -1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("xrotate") - << (qreal)90.0f - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (void *)xRotate; - - static const qreal xRotateNeg[] = - {1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, -1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("-xrotate") - << (qreal)90.0f - << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f - << (void *)xRotateNeg; - - static const qreal yRotate[] = - {0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - -1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("yrotate") - << (qreal)90.0f - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (void *)yRotate; - - static const qreal yRotateNeg[] = - {0.0f, 0.0f, -1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("-yrotate") - << (qreal)90.0f - << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f - << (void *)yRotateNeg; - - static const qreal zRotate[] = - {0.0f, -1.0f, 0.0f, 0.0f, - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("zrotate") - << (qreal)90.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (void *)zRotate; - - static const qreal zRotateNeg[] = - {0.0f, 1.0f, 0.0f, 0.0f, - -1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - QTest::newRow("-zrotate") - << (qreal)90.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f - << (void *)zRotateNeg; - - // Algorithm from http://en.wikipedia.org/wiki/Rotation_matrix. - // Deliberately different from the one in the code for cross-checking. - static qreal complexRotate[16]; - qreal x = 1.0f; - qreal y = 2.0f; - qreal z = -6.0f; - qreal angle = -45.0f; - qreal c = qCos(angle * M_PI / 180.0f); - qreal s = qSin(angle * M_PI / 180.0f); - qreal len = qSqrt(x * x + y * y + z * z); - qreal xu = x / len; - qreal yu = y / len; - qreal zu = z / len; - complexRotate[0] = (qreal)((1 - xu * xu) * c + xu * xu); - complexRotate[1] = (qreal)(-zu * s - xu * yu * c + xu * yu); - complexRotate[2] = (qreal)(yu * s - xu * zu * c + xu * zu); - complexRotate[3] = 0; - complexRotate[4] = (qreal)(zu * s - xu * yu * c + xu * yu); - complexRotate[5] = (qreal)((1 - yu * yu) * c + yu * yu); - complexRotate[6] = (qreal)(-xu * s - yu * zu * c + yu * zu); - complexRotate[7] = 0; - complexRotate[8] = (qreal)(-yu * s - xu * zu * c + xu * zu); - complexRotate[9] = (qreal)(xu * s - yu * zu * c + yu * zu); - complexRotate[10] = (qreal)((1 - zu * zu) * c + zu * zu); - complexRotate[11] = 0; - complexRotate[12] = 0; - complexRotate[13] = 0; - complexRotate[14] = 0; - complexRotate[15] = 1; - - QTest::newRow("complex") - << (qreal)angle - << (qreal)x << (qreal)y << (qreal)z - << (void *)complexRotate; -} -void tst_QMatrixNxN::rotate4x4() -{ - QFETCH(qreal, angle); - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(void *, resultValues); - - QMatrix4x4 m1; - m1.rotate(angle, QVector3D(x, y, z)); - QVERIFY(isSame(m1, (const qreal *)resultValues)); - - QMatrix4x4 m2; - m2.rotate(angle, x, y, z); - QVERIFY(isSame(m2, (const qreal *)resultValues)); - - QMatrix4x4 m3(uniqueValues4); - QMatrix4x4 m4(m3); - m4.rotate(angle, x, y, z); - QVERIFY(matrixFuzzyCompare(m4, m3 * m1)); - - // Null vectors don't make sense for quaternion rotations. - if (x != 0 || y != 0 || z != 0) { - QMatrix4x4 m5; - m5.rotate(QQuaternion::fromAxisAndAngle(QVector3D(x, y, z), angle)); - QVERIFY(isSame(m5, (const qreal *)resultValues)); - } - -#define ROTATE4(xin,yin,zin,win,xout,yout,zout,wout) \ - do { \ - xout = ((const qreal *)resultValues)[0] * xin + \ - ((const qreal *)resultValues)[1] * yin + \ - ((const qreal *)resultValues)[2] * zin + \ - ((const qreal *)resultValues)[3] * win; \ - yout = ((const qreal *)resultValues)[4] * xin + \ - ((const qreal *)resultValues)[5] * yin + \ - ((const qreal *)resultValues)[6] * zin + \ - ((const qreal *)resultValues)[7] * win; \ - zout = ((const qreal *)resultValues)[8] * xin + \ - ((const qreal *)resultValues)[9] * yin + \ - ((const qreal *)resultValues)[10] * zin + \ - ((const qreal *)resultValues)[11] * win; \ - wout = ((const qreal *)resultValues)[12] * xin + \ - ((const qreal *)resultValues)[13] * yin + \ - ((const qreal *)resultValues)[14] * zin + \ - ((const qreal *)resultValues)[15] * win; \ - } while (0) - - // Rotate various test vectors using the straight-forward approach. - qreal v1x, v1y, v1z, v1w; - ROTATE4(2.0f, 3.0f, -4.0f, 1.0f, v1x, v1y, v1z, v1w); - v1x /= v1w; - v1y /= v1w; - v1z /= v1w; - qreal v3x, v3y, v3z, v3w; - ROTATE4(2.0f, 3.0f, -4.0f, 1.0f, v3x, v3y, v3z, v3w); - qreal v5x, v5y, v5z, v5w; - ROTATE4(2.0f, 3.0f, -4.0f, 34.0f, v5x, v5y, v5z, v5w); - qreal p1x, p1y, p1z, p1w; - ROTATE4(2.0f, 3.0f, 0.0f, 1.0f, p1x, p1y, p1z, p1w); - p1x /= p1w; - p1y /= p1w; - p1z /= p1w; - - QVector3D v1(2.0f, 3.0f, -4.0f); - QVector3D v2 = m1 * v1; - QVERIFY(fuzzyCompare(v2.x(), v1x)); - QVERIFY(fuzzyCompare(v2.y(), v1y)); - QVERIFY(fuzzyCompare(v2.z(), v1z)); - - QVector4D v3(2.0f, 3.0f, -4.0f, 1.0f); - QVector4D v4 = m1 * v3; - QVERIFY(fuzzyCompare(v4.x(), v3x)); - QVERIFY(fuzzyCompare(v4.y(), v3y)); - QVERIFY(fuzzyCompare(v4.z(), v3z)); - QVERIFY(fuzzyCompare(v4.w(), v3w)); - - QVector4D v5(2.0f, 3.0f, -4.0f, 34.0f); - QVector4D v6 = m1 * v5; - QVERIFY(fuzzyCompare(v6.x(), v5x)); - QVERIFY(fuzzyCompare(v6.y(), v5y)); - QVERIFY(fuzzyCompare(v6.z(), v5z)); - QVERIFY(fuzzyCompare(v6.w(), v5w)); - - QPoint p1(2, 3); - QPoint p2 = m1 * p1; - QCOMPARE(p2.x(), qRound(p1x)); - QCOMPARE(p2.y(), qRound(p1y)); - - QPointF p3(2.0f, 3.0f); - QPointF p4 = m1 * p3; - QVERIFY(fuzzyCompare((float)(p4.x()), p1x)); - QVERIFY(fuzzyCompare((float)(p4.y()), p1y)); - - if (x != 0 || y != 0 || z != 0) { - QQuaternion q = QQuaternion::fromAxisAndAngle(QVector3D(x, y, z), angle); - QVector3D vq = q.rotateVector(v1); - QVERIFY(fuzzyCompare(vq.x(), v1x)); - QVERIFY(fuzzyCompare(vq.y(), v1y)); - QVERIFY(fuzzyCompare(vq.z(), v1z)); - } -} - -static bool isSame(const QMatrix3x3& m1, const Matrix3& m2) -{ - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - if (!fuzzyCompare(m1(row, col), m2.v[row * 3 + col])) - return false; - } - } - return true; -} - -// Test the computation of normal matrices from 4x4 transformation matrices. -void tst_QMatrixNxN::normalMatrix_data() -{ - QTest::addColumn("mValues"); - - QTest::newRow("identity") - << (void *)identityValues4; - QTest::newRow("unique") - << (void *)uniqueValues4; // Not invertible because determinant == 0. - - static qreal const translateValues[16] = - {1.0f, 0.0f, 0.0f, 4.0f, - 0.0f, 1.0f, 0.0f, 5.0f, - 0.0f, 0.0f, 1.0f, -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const scaleValues[16] = - {2.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 7.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 9.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const bothValues[16] = - {2.0f, 0.0f, 0.0f, 4.0f, - 0.0f, 7.0f, 0.0f, 5.0f, - 0.0f, 0.0f, 9.0f, -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const nullScaleValues1[16] = - {0.0f, 0.0f, 0.0f, 4.0f, - 0.0f, 7.0f, 0.0f, 5.0f, - 0.0f, 0.0f, 9.0f, -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const nullScaleValues2[16] = - {2.0f, 0.0f, 0.0f, 4.0f, - 0.0f, 0.0f, 0.0f, 5.0f, - 0.0f, 0.0f, 9.0f, -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const nullScaleValues3[16] = - {2.0f, 0.0f, 0.0f, 4.0f, - 0.0f, 7.0f, 0.0f, 5.0f, - 0.0f, 0.0f, 0.0f, -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - - QTest::newRow("translate") << (void *)translateValues; - QTest::newRow("scale") << (void *)scaleValues; - QTest::newRow("both") << (void *)bothValues; - QTest::newRow("null scale 1") << (void *)nullScaleValues1; - QTest::newRow("null scale 2") << (void *)nullScaleValues2; - QTest::newRow("null scale 3") << (void *)nullScaleValues3; -} -void tst_QMatrixNxN::normalMatrix() -{ - QFETCH(void *, mValues); - const qreal *values = (const qreal *)mValues; - - // Compute the expected answer the long way. - Matrix3 min; - Matrix3 answer; - min.v[0] = values[0]; - min.v[1] = values[1]; - min.v[2] = values[2]; - min.v[3] = values[4]; - min.v[4] = values[5]; - min.v[5] = values[6]; - min.v[6] = values[8]; - min.v[7] = values[9]; - min.v[8] = values[10]; - bool invertible = m3Inverse(min, answer); - m3Transpose(answer); - - // Perform the test. - QMatrix4x4 m1(values); - QMatrix3x3 n1 = m1.normalMatrix(); - - if (invertible) - QVERIFY(::isSame(n1, answer)); - else - QVERIFY(isIdentity(n1)); - - // Perform the test again, after inferring special matrix types. - // This tests the optimized paths in the normalMatrix() function. - m1.inferSpecialType(); - n1 = m1.normalMatrix(); - - if (invertible) - QVERIFY(::isSame(n1, answer)); - else - QVERIFY(isIdentity(n1)); -} - -// Test optimized transformations on 4x4 matrices. -void tst_QMatrixNxN::optimizedTransforms() -{ - static qreal const translateValues[16] = - {1.0f, 0.0f, 0.0f, 4.0f, - 0.0f, 1.0f, 0.0f, 5.0f, - 0.0f, 0.0f, 1.0f, -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const translateDoubleValues[16] = - {1.0f, 0.0f, 0.0f, 8.0f, - 0.0f, 1.0f, 0.0f, 10.0f, - 0.0f, 0.0f, 1.0f, -6.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const scaleValues[16] = - {2.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 7.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 9.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const scaleDoubleValues[16] = - {4.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 49.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 81.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const bothValues[16] = - {2.0f, 0.0f, 0.0f, 4.0f, - 0.0f, 7.0f, 0.0f, 5.0f, - 0.0f, 0.0f, 9.0f, -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const bothReverseValues[16] = - {2.0f, 0.0f, 0.0f, 4.0f * 2.0f, - 0.0f, 7.0f, 0.0f, 5.0f * 7.0f, - 0.0f, 0.0f, 9.0f, -3.0f * 9.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const bothThenTranslateValues[16] = - {2.0f, 0.0f, 0.0f, 4.0f + 2.0f * 4.0f, - 0.0f, 7.0f, 0.0f, 5.0f + 7.0f * 5.0f, - 0.0f, 0.0f, 9.0f, -3.0f + 9.0f * -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - static qreal const bothThenScaleValues[16] = - {4.0f, 0.0f, 0.0f, 4.0f, - 0.0f, 49.0f, 0.0f, 5.0f, - 0.0f, 0.0f, 81.0f, -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - - QMatrix4x4 translate(translateValues); - QMatrix4x4 scale(scaleValues); - QMatrix4x4 both(bothValues); - - QMatrix4x4 m1; - m1.translate(4.0f, 5.0f, -3.0f); - QVERIFY(isSame(m1, translateValues)); - m1.translate(4.0f, 5.0f, -3.0f); - QVERIFY(isSame(m1, translateDoubleValues)); - - QMatrix4x4 m2; - m2.translate(QVector3D(4.0f, 5.0f, -3.0f)); - QVERIFY(isSame(m2, translateValues)); - m2.translate(QVector3D(4.0f, 5.0f, -3.0f)); - QVERIFY(isSame(m2, translateDoubleValues)); - - QMatrix4x4 m3; - m3.scale(2.0f, 7.0f, 9.0f); - QVERIFY(isSame(m3, scaleValues)); - m3.scale(2.0f, 7.0f, 9.0f); - QVERIFY(isSame(m3, scaleDoubleValues)); - - QMatrix4x4 m4; - m4.scale(QVector3D(2.0f, 7.0f, 9.0f)); - QVERIFY(isSame(m4, scaleValues)); - m4.scale(QVector3D(2.0f, 7.0f, 9.0f)); - QVERIFY(isSame(m4, scaleDoubleValues)); - - QMatrix4x4 m5; - m5.translate(4.0f, 5.0f, -3.0f); - m5.scale(2.0f, 7.0f, 9.0f); - QVERIFY(isSame(m5, bothValues)); - m5.translate(4.0f, 5.0f, -3.0f); - QVERIFY(isSame(m5, bothThenTranslateValues)); - - QMatrix4x4 m6; - m6.translate(QVector3D(4.0f, 5.0f, -3.0f)); - m6.scale(QVector3D(2.0f, 7.0f, 9.0f)); - QVERIFY(isSame(m6, bothValues)); - m6.translate(QVector3D(4.0f, 5.0f, -3.0f)); - QVERIFY(isSame(m6, bothThenTranslateValues)); - - QMatrix4x4 m7; - m7.scale(2.0f, 7.0f, 9.0f); - m7.translate(4.0f, 5.0f, -3.0f); - QVERIFY(isSame(m7, bothReverseValues)); - - QMatrix4x4 m8; - m8.scale(QVector3D(2.0f, 7.0f, 9.0f)); - m8.translate(QVector3D(4.0f, 5.0f, -3.0f)); - QVERIFY(isSame(m8, bothReverseValues)); - - QMatrix4x4 m9; - m9.translate(4.0f, 5.0f, -3.0f); - m9.scale(2.0f, 7.0f, 9.0f); - QVERIFY(isSame(m9, bothValues)); - m9.scale(2.0f, 7.0f, 9.0f); - QVERIFY(isSame(m9, bothThenScaleValues)); - - QMatrix4x4 m10; - m10.translate(QVector3D(4.0f, 5.0f, -3.0f)); - m10.scale(QVector3D(2.0f, 7.0f, 9.0f)); - QVERIFY(isSame(m10, bothValues)); - m10.scale(QVector3D(2.0f, 7.0f, 9.0f)); - QVERIFY(isSame(m10, bothThenScaleValues)); -} - -// Test orthographic projections. -void tst_QMatrixNxN::ortho() -{ - QMatrix4x4 m1; - m1.ortho(QRect(0, 0, 300, 150)); - QPointF p1 = m1 * QPointF(0, 0); - QPointF p2 = m1 * QPointF(300, 0); - QPointF p3 = m1 * QPointF(0, 150); - QPointF p4 = m1 * QPointF(300, 150); - QVector3D p5 = m1 * QVector3D(300, 150, 1); - QVERIFY(fuzzyCompare(p1.x(), -1.0)); - QVERIFY(fuzzyCompare(p1.y(), 1.0)); - QVERIFY(fuzzyCompare(p2.x(), 1.0)); - QVERIFY(fuzzyCompare(p2.y(), 1.0)); - QVERIFY(fuzzyCompare(p3.x(), -1.0)); - QVERIFY(fuzzyCompare(p3.y(), -1.0)); - QVERIFY(fuzzyCompare(p4.x(), 1.0)); - QVERIFY(fuzzyCompare(p4.y(), -1.0)); - QVERIFY(fuzzyCompare(p5.x(), (qreal)1.0)); - QVERIFY(fuzzyCompare(p5.y(), (qreal)-1.0)); - QVERIFY(fuzzyCompare(p5.z(), (qreal)-1.0)); - - QMatrix4x4 m2; - m2.ortho(QRectF(0, 0, 300, 150)); - p1 = m2 * QPointF(0, 0); - p2 = m2 * QPointF(300, 0); - p3 = m2 * QPointF(0, 150); - p4 = m2 * QPointF(300, 150); - p5 = m2 * QVector3D(300, 150, 1); - QVERIFY(fuzzyCompare(p1.x(), -1.0)); - QVERIFY(fuzzyCompare(p1.y(), 1.0)); - QVERIFY(fuzzyCompare(p2.x(), 1.0)); - QVERIFY(fuzzyCompare(p2.y(), 1.0)); - QVERIFY(fuzzyCompare(p3.x(), -1.0)); - QVERIFY(fuzzyCompare(p3.y(), -1.0)); - QVERIFY(fuzzyCompare(p4.x(), 1.0)); - QVERIFY(fuzzyCompare(p4.y(), -1.0)); - QVERIFY(fuzzyCompare(p5.x(), (qreal)1.0)); - QVERIFY(fuzzyCompare(p5.y(), (qreal)-1.0)); - QVERIFY(fuzzyCompare(p5.z(), (qreal)-1.0)); - - QMatrix4x4 m3; - m3.ortho(0, 300, 150, 0, -1, 1); - p1 = m3 * QPointF(0, 0); - p2 = m3 * QPointF(300, 0); - p3 = m3 * QPointF(0, 150); - p4 = m3 * QPointF(300, 150); - p5 = m3 * QVector3D(300, 150, 1); - QVERIFY(fuzzyCompare(p1.x(), -1.0)); - QVERIFY(fuzzyCompare(p1.y(), 1.0)); - QVERIFY(fuzzyCompare(p2.x(), 1.0)); - QVERIFY(fuzzyCompare(p2.y(), 1.0)); - QVERIFY(fuzzyCompare(p3.x(), -1.0)); - QVERIFY(fuzzyCompare(p3.y(), -1.0)); - QVERIFY(fuzzyCompare(p4.x(), 1.0)); - QVERIFY(fuzzyCompare(p4.y(), -1.0)); - QVERIFY(fuzzyCompare(p5.x(), (qreal)1.0)); - QVERIFY(fuzzyCompare(p5.y(), (qreal)-1.0)); - QVERIFY(fuzzyCompare(p5.z(), (qreal)-1.0)); - - QMatrix4x4 m4; - m4.ortho(0, 300, 150, 0, -2, 3); - p1 = m4 * QPointF(0, 0); - p2 = m4 * QPointF(300, 0); - p3 = m4 * QPointF(0, 150); - p4 = m4 * QPointF(300, 150); - p5 = m4 * QVector3D(300, 150, 1); - QVERIFY(fuzzyCompare(p1.x(), -1.0)); - QVERIFY(fuzzyCompare(p1.y(), 1.0)); - QVERIFY(fuzzyCompare(p2.x(), 1.0)); - QVERIFY(fuzzyCompare(p2.y(), 1.0)); - QVERIFY(fuzzyCompare(p3.x(), -1.0)); - QVERIFY(fuzzyCompare(p3.y(), -1.0)); - QVERIFY(fuzzyCompare(p4.x(), 1.0)); - QVERIFY(fuzzyCompare(p4.y(), -1.0)); - QVERIFY(fuzzyCompare(p5.x(), (qreal)1.0)); - QVERIFY(fuzzyCompare(p5.y(), (qreal)-1.0)); - QVERIFY(fuzzyCompare(p5.z(), (qreal)-0.6)); - - // An empty view volume should leave the matrix alone. - QMatrix4x4 m5; - m5.ortho(0, 0, 150, 0, -2, 3); - QVERIFY(m5.isIdentity()); - m5.ortho(0, 300, 150, 150, -2, 3); - QVERIFY(m5.isIdentity()); - m5.ortho(0, 300, 150, 0, 2, 2); - QVERIFY(m5.isIdentity()); -} - -// Test perspective frustum projections. -void tst_QMatrixNxN::frustum() -{ - QMatrix4x4 m1; - m1.frustum(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); - QVector3D p1 = m1 * QVector3D(-1.0f, -1.0f, 1.0f); - QVector3D p2 = m1 * QVector3D(1.0f, -1.0f, 1.0f); - QVector3D p3 = m1 * QVector3D(-1.0f, 1.0f, 1.0f); - QVector3D p4 = m1 * QVector3D(1.0f, 1.0f, 1.0f); - QVector3D p5 = m1 * QVector3D(0.0f, 0.0f, 2.0f); - QVERIFY(fuzzyCompare(p1.x(), -1.0f)); - QVERIFY(fuzzyCompare(p1.y(), -1.0f)); - QVERIFY(fuzzyCompare(p1.z(), -1.0f)); - QVERIFY(fuzzyCompare(p2.x(), 1.0f)); - QVERIFY(fuzzyCompare(p2.y(), -1.0f)); - QVERIFY(fuzzyCompare(p2.z(), -1.0f)); - QVERIFY(fuzzyCompare(p3.x(), -1.0f)); - QVERIFY(fuzzyCompare(p3.y(), 1.0f)); - QVERIFY(fuzzyCompare(p3.z(), -1.0f)); - QVERIFY(fuzzyCompare(p4.x(), 1.0f)); - QVERIFY(fuzzyCompare(p4.y(), 1.0f)); - QVERIFY(fuzzyCompare(p4.z(), -1.0f)); - QVERIFY(fuzzyCompare(p5.x(), 0.0f)); - QVERIFY(fuzzyCompare(p5.y(), 0.0f)); - QVERIFY(fuzzyCompare(p5.z(), -0.5f)); - - // An empty view volume should leave the matrix alone. - QMatrix4x4 m5; - m5.frustum(0, 0, 150, 0, -2, 3); - QVERIFY(m5.isIdentity()); - m5.frustum(0, 300, 150, 150, -2, 3); - QVERIFY(m5.isIdentity()); - m5.frustum(0, 300, 150, 0, 2, 2); - QVERIFY(m5.isIdentity()); -} - -// Test perspective field-of-view projections. -void tst_QMatrixNxN::perspective() -{ - QMatrix4x4 m1; - m1.perspective(45.0f, 1.0f, -1.0f, 1.0f); - QVector3D p1 = m1 * QVector3D(-1.0f, -1.0f, 1.0f); - QVector3D p2 = m1 * QVector3D(1.0f, -1.0f, 1.0f); - QVector3D p3 = m1 * QVector3D(-1.0f, 1.0f, 1.0f); - QVector3D p4 = m1 * QVector3D(1.0f, 1.0f, 1.0f); - QVector3D p5 = m1 * QVector3D(0.0f, 0.0f, 2.0f); - QVERIFY(fuzzyCompare(p1.x(), 2.41421)); - QVERIFY(fuzzyCompare(p1.y(), 2.41421)); - QVERIFY(fuzzyCompare(p1.z(), -1)); - QVERIFY(fuzzyCompare(p2.x(), -2.41421)); - QVERIFY(fuzzyCompare(p2.y(), 2.41421)); - QVERIFY(fuzzyCompare(p2.z(), -1.0f)); - QVERIFY(fuzzyCompare(p3.x(), 2.41421)); - QVERIFY(fuzzyCompare(p3.y(), -2.41421)); - QVERIFY(fuzzyCompare(p3.z(), -1.0f)); - QVERIFY(fuzzyCompare(p4.x(), -2.41421)); - QVERIFY(fuzzyCompare(p4.y(), -2.41421)); - QVERIFY(fuzzyCompare(p4.z(), -1.0f)); - QVERIFY(fuzzyCompare(p5.x(), 0.0f)); - QVERIFY(fuzzyCompare(p5.y(), 0.0f)); - QVERIFY(fuzzyCompare(p5.z(), -0.5f)); - - // An empty view volume should leave the matrix alone. - QMatrix4x4 m5; - m5.perspective(45.0f, 1.0f, 0.0f, 0.0f); - QVERIFY(m5.isIdentity()); - m5.perspective(45.0f, 0.0f, -1.0f, 1.0f); - QVERIFY(m5.isIdentity()); - m5.perspective(0.0f, 1.0f, -1.0f, 1.0f); - QVERIFY(m5.isIdentity()); -} - -// Test left-handed vs right-handed coordinate flipping. -void tst_QMatrixNxN::flipCoordinates() -{ - QMatrix4x4 m1; - m1.flipCoordinates(); - QVector3D p1 = m1 * QVector3D(2, 3, 4); - QVERIFY(p1 == QVector3D(2, -3, -4)); - - QMatrix4x4 m2; - m2.scale(2.0f, 3.0f, 1.0f); - m2.flipCoordinates(); - QVector3D p2 = m2 * QVector3D(2, 3, 4); - QVERIFY(p2 == QVector3D(4, -9, -4)); - - QMatrix4x4 m3; - m3.translate(2.0f, 3.0f, 1.0f); - m3.flipCoordinates(); - QVector3D p3 = m3 * QVector3D(2, 3, 4); - QVERIFY(p3 == QVector3D(4, 0, -3)); - - QMatrix4x4 m4; - m4.rotate(90.0f, 0.0f, 0.0f, 1.0f); - m4.flipCoordinates(); - QVector3D p4 = m4 * QVector3D(2, 3, 4); - QVERIFY(p4 == QVector3D(3, 2, -4)); -} - -// Test conversion of generic matrices to and from the non-generic types. -void tst_QMatrixNxN::convertGeneric() -{ - QMatrix4x3 m1(uniqueValues4x3); - - static qreal const unique4x4[16] = { - 1.0f, 2.0f, 3.0f, 4.0f, - 5.0f, 6.0f, 7.0f, 8.0f, - 9.0f, 10.0f, 11.0f, 12.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; -#if !defined(QT_NO_MEMBER_TEMPLATES) - QMatrix4x4 m4(m1); - QVERIFY(isSame(m4, unique4x4)); -#endif - QMatrix4x4 m5 = qGenericMatrixToMatrix4x4(m1); - QVERIFY(isSame(m5, unique4x4)); - - static qreal const conv4x4[12] = { - 1.0f, 2.0f, 3.0f, 4.0f, - 5.0f, 6.0f, 7.0f, 8.0f, - 9.0f, 10.0f, 11.0f, 12.0f - }; - QMatrix4x4 m9(uniqueValues4); -#if !defined(QT_NO_MEMBER_TEMPLATES) - QMatrix4x3 m10 = m9.toGenericMatrix<4, 3>(); - QVERIFY(isSame(m10, conv4x4)); -#endif - - QMatrix4x3 m11 = qGenericMatrixFromMatrix4x4<4, 3>(m9); - QVERIFY(isSame(m11, conv4x4)); -} - -void tst_QMatrixNxN::extractAxisRotation_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("z"); - QTest::addColumn("angle"); - - QTest::newRow("1, 0, 0, 0 deg") << 1.0f << 0.0f << 0.0f << 0.0f; - QTest::newRow("1, 0, 0, 90 deg") << 1.0f << 0.0f << 0.0f << 90.0f; - QTest::newRow("1, 0, 0, 270 deg") << 1.0f << 0.0f << 0.0f << 270.0f; - QTest::newRow("1, 0, 0, 45 deg") << 1.0f << 0.0f << 0.0f << 45.0f; - QTest::newRow("1, 0, 0, 120 deg") << 1.0f << 0.0f << 0.0f << 120.0f; - QTest::newRow("1, 0, 0, 300 deg") << 1.0f << 0.0f << 0.0f << 300.0f; - - QTest::newRow("0, 1, 0, 90 deg") << 0.0f << 1.0f << 0.0f << 90.0f; - QTest::newRow("0, 1, 0, 270 deg") << 0.0f << 1.0f << 0.0f << 270.0f; - QTest::newRow("0, 1, 0, 45 deg") << 0.0f << 1.0f << 0.0f << 45.0f; - QTest::newRow("0, 1, 0, 120 deg") << 0.0f << 1.0f << 0.0f << 120.0f; - QTest::newRow("0, 1, 0, 300 deg") << 0.0f << 1.0f << 0.0f << 300.0f; - - QTest::newRow("0, 0, 1, 90 deg") << 0.0f << 0.0f << 1.0f << 90.0f; - QTest::newRow("0, 0, 1, 270 deg") << 0.0f << 0.0f << 1.0f << 270.0f; - QTest::newRow("0, 0, 1, 45 deg") << 0.0f << 0.0f << 1.0f << 45.0f; - QTest::newRow("0, 0, 1, 120 deg") << 0.0f << 0.0f << 1.0f << 120.0f; - QTest::newRow("0, 0, 1, 300 deg") << 0.0f << 0.0f << 1.0f << 300.0f; - - QTest::newRow("1, 1, 1, 90 deg") << 1.0f << 1.0f << 1.0f << 90.0f; - QTest::newRow("1, 1, 1, 270 deg") << 1.0f << 1.0f << 1.0f << 270.0f; - QTest::newRow("1, 1, 1, 45 deg") << 1.0f << 1.0f << 1.0f << 45.0f; - QTest::newRow("1, 1, 1, 120 deg") << 1.0f << 1.0f << 1.0f << 120.0f; - QTest::newRow("1, 1, 1, 300 deg") << 1.0f << 1.0f << 1.0f << 300.0f; -} - -void tst_QMatrixNxN::extractAxisRotation() -{ - QFETCH(float, x); - QFETCH(float, y); - QFETCH(float, z); - QFETCH(float, angle); - - QMatrix4x4 m; - QVector3D origAxis(x, y, z); - - m.rotate(angle, x, y, z); - - origAxis.normalize(); - QVector3D extractedAxis; - qreal extractedAngle; - - m.extractAxisRotation(extractedAngle, extractedAxis); - - qreal epsilon = 0.001; - - if (angle > 180) { - QVERIFY(fuzzyCompare(360.0f - angle, extractedAngle, epsilon)); - QVERIFY(fuzzyCompare(extractedAxis, -origAxis, epsilon)); - } else { - QVERIFY(fuzzyCompare(angle, extractedAngle, epsilon)); - QVERIFY(fuzzyCompare(extractedAxis, origAxis, epsilon)); - } -} - -void tst_QMatrixNxN::extractTranslation_data() -{ - QTest::addColumn("rotation"); - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("z"); - - static QMatrix4x4 m1; - - QTest::newRow("identity, 100, 50, 25") - << m1 << 100.0f << 50.0f << 250.0f; - - m1.rotate(45.0, 1.0, 0.0, 0.0); - QTest::newRow("rotX 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f; - - m1.setIdentity(); - m1.rotate(45.0, 0.0, 1.0, 0.0); - QTest::newRow("rotY 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f; - - m1.setIdentity(); - m1.rotate(75, 0.0, 0.0, 1.0); - m1.rotate(25, 1.0, 0.0, 0.0); - m1.rotate(45, 0.0, 1.0, 0.0); - QTest::newRow("rotZ 75, rotX 25, rotY 45, 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f; -} - -void tst_QMatrixNxN::extractTranslation() -{ - QFETCH(QMatrix4x4, rotation); - QFETCH(float, x); - QFETCH(float, y); - QFETCH(float, z); - - rotation.translate(x, y, z); - - QVector3D vec = rotation.extractTranslation(); - - qreal epsilon = 0.001; - - QVERIFY(fuzzyCompare(vec.x(), x, epsilon)); - QVERIFY(fuzzyCompare(vec.y(), y, epsilon)); - QVERIFY(fuzzyCompare(vec.z(), z, epsilon)); - - QMatrix4x4 lookAt; - QVector3D eye(1.5f, -2.5f, 2.5f); - lookAt.lookAt(eye, - QVector3D(10.0f, 10.0f, 10.0f), - QVector3D(0.0f, 1.0f, 0.0f)); - - QVector3D extEye = lookAt.extractTranslation(); - - QVERIFY(fuzzyCompare(eye.x(), -extEye.x(), epsilon)); - QVERIFY(fuzzyCompare(eye.y(), -extEye.y(), epsilon)); - QVERIFY(fuzzyCompare(eye.z(), -extEye.z(), epsilon)); -} - -// Copy of "flagBits" in qmatrix4x4.h. -enum { - Identity = 0x0001, // Identity matrix - General = 0x0002, // General matrix, unknown contents - Translation = 0x0004, // Contains a simple translation - Scale = 0x0008, // Contains a simple scale - Rotation = 0x0010 // Contains a simple rotation -}; - -// Structure that allows direct access to "flagBits" for testing. -struct Matrix4x4 -{ - float m[4][4]; - int flagBits; -}; - -// Test the inferring of special matrix types. -void tst_QMatrixNxN::inferSpecialType_data() -{ - QTest::addColumn("mValues"); - QTest::addColumn("flagBits"); - - QTest::newRow("null") - << (void *)nullValues4 << (int)General; - QTest::newRow("identity") - << (void *)identityValues4 << (int)Identity; - QTest::newRow("unique") - << (void *)uniqueValues4 << (int)General; - - static qreal scaleValues[16] = { - 2.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 3.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 4.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; - QTest::newRow("scale") - << (void *)scaleValues << (int)Scale; - - static qreal translateValues[16] = { - 1.0f, 0.0f, 0.0f, 2.0f, - 0.0f, 1.0f, 0.0f, 3.0f, - 0.0f, 0.0f, 1.0f, 4.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; - QTest::newRow("scale") - << (void *)translateValues << (int)Translation; - - static qreal bothValues[16] = { - 1.0f, 0.0f, 0.0f, 2.0f, - 0.0f, 2.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 4.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; - QTest::newRow("both") - << (void *)bothValues << (int)(Scale | Translation); - - static qreal belowValues[16] = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 4.0f, 0.0f, 0.0f, 1.0f - }; - QTest::newRow("below") - << (void *)belowValues << (int)General; -} -void tst_QMatrixNxN::inferSpecialType() -{ - QFETCH(void *, mValues); - QFETCH(int, flagBits); - - QMatrix4x4 m((const qreal *)mValues); - m.inferSpecialType(); - - QCOMPARE(reinterpret_cast(&m)->flagBits, flagBits); -} - -void tst_QMatrixNxN::columnsAndRows() -{ - QMatrix4x4 m1(uniqueValues4); - - QVERIFY(m1.column(0) == QVector4D(1, 5, 9, 13)); - QVERIFY(m1.column(1) == QVector4D(2, 6, 10, 14)); - QVERIFY(m1.column(2) == QVector4D(3, 7, 11, 15)); - QVERIFY(m1.column(3) == QVector4D(4, 8, 12, 16)); - - QVERIFY(m1.row(0) == QVector4D(1, 2, 3, 4)); - QVERIFY(m1.row(1) == QVector4D(5, 6, 7, 8)); - QVERIFY(m1.row(2) == QVector4D(9, 10, 11, 12)); - QVERIFY(m1.row(3) == QVector4D(13, 14, 15, 16)); - - m1.setColumn(0, QVector4D(-1, -5, -9, -13)); - m1.setColumn(1, QVector4D(-2, -6, -10, -14)); - m1.setColumn(2, QVector4D(-3, -7, -11, -15)); - m1.setColumn(3, QVector4D(-4, -8, -12, -16)); - - QVERIFY(m1.column(0) == QVector4D(-1, -5, -9, -13)); - QVERIFY(m1.column(1) == QVector4D(-2, -6, -10, -14)); - QVERIFY(m1.column(2) == QVector4D(-3, -7, -11, -15)); - QVERIFY(m1.column(3) == QVector4D(-4, -8, -12, -16)); - - QVERIFY(m1.row(0) == QVector4D(-1, -2, -3, -4)); - QVERIFY(m1.row(1) == QVector4D(-5, -6, -7, -8)); - QVERIFY(m1.row(2) == QVector4D(-9, -10, -11, -12)); - QVERIFY(m1.row(3) == QVector4D(-13, -14, -15, -16)); - - m1.setRow(0, QVector4D(1, 5, 9, 13)); - m1.setRow(1, QVector4D(2, 6, 10, 14)); - m1.setRow(2, QVector4D(3, 7, 11, 15)); - m1.setRow(3, QVector4D(4, 8, 12, 16)); - - QVERIFY(m1.column(0) == QVector4D(1, 2, 3, 4)); - QVERIFY(m1.column(1) == QVector4D(5, 6, 7, 8)); - QVERIFY(m1.column(2) == QVector4D(9, 10, 11, 12)); - QVERIFY(m1.column(3) == QVector4D(13, 14, 15, 16)); - - QVERIFY(m1.row(0) == QVector4D(1, 5, 9, 13)); - QVERIFY(m1.row(1) == QVector4D(2, 6, 10, 14)); - QVERIFY(m1.row(2) == QVector4D(3, 7, 11, 15)); - QVERIFY(m1.row(3) == QVector4D(4, 8, 12, 16)); -} - -// Test converting QMatrix objects into QMatrix4x4 and then -// checking that transformations in the original perform the -// equivalent transformations in the new matrix. -void tst_QMatrixNxN::convertQMatrix() -{ - QMatrix m1; - m1.translate(-3.5, 2.0); - QPointF p1 = m1.map(QPointF(100.0, 150.0)); - QCOMPARE(p1.x(), 100.0 - 3.5); - QCOMPARE(p1.y(), 150.0 + 2.0); - - QMatrix4x4 m2(m1); - QPointF p2 = m2 * QPointF(100.0, 150.0); - QCOMPARE((double)p2.x(), 100.0 - 3.5); - QCOMPARE((double)p2.y(), 150.0 + 2.0); - QVERIFY(m1 == m2.toAffine()); - - QMatrix m3; - m3.scale(1.5, -2.0); - QPointF p3 = m3.map(QPointF(100.0, 150.0)); - QCOMPARE(p3.x(), 1.5 * 100.0); - QCOMPARE(p3.y(), -2.0 * 150.0); - - QMatrix4x4 m4(m3); - QPointF p4 = m4 * QPointF(100.0, 150.0); - QCOMPARE((double)p4.x(), 1.5 * 100.0); - QCOMPARE((double)p4.y(), -2.0 * 150.0); - QVERIFY(m3 == m4.toAffine()); - - QMatrix m5; - m5.rotate(45.0); - QPointF p5 = m5.map(QPointF(100.0, 150.0)); - - QMatrix4x4 m6(m5); - QPointF p6 = m6 * QPointF(100.0, 150.0); - QVERIFY(fuzzyCompare(p5.x(), p6.x(), 0.005)); - QVERIFY(fuzzyCompare(p5.y(), p6.y(), 0.005)); - - QMatrix m7 = m6.toAffine(); - QVERIFY(fuzzyCompare(m5.m11(), m7.m11())); - QVERIFY(fuzzyCompare(m5.m12(), m7.m12())); - QVERIFY(fuzzyCompare(m5.m21(), m7.m21())); - QVERIFY(fuzzyCompare(m5.m22(), m7.m22())); - QVERIFY(fuzzyCompare(m5.dx(), m7.dx())); - QVERIFY(fuzzyCompare(m5.dy(), m7.dy())); -} - -// Test converting QTransform objects into QMatrix4x4 and then -// checking that transformations in the original perform the -// equivalent transformations in the new matrix. -void tst_QMatrixNxN::convertQTransform() -{ - QTransform m1; - m1.translate(-3.5, 2.0); - QPointF p1 = m1.map(QPointF(100.0, 150.0)); - QCOMPARE(p1.x(), 100.0 - 3.5); - QCOMPARE(p1.y(), 150.0 + 2.0); - - QMatrix4x4 m2(m1); - QPointF p2 = m2 * QPointF(100.0, 150.0); - QCOMPARE((double)p2.x(), 100.0 - 3.5); - QCOMPARE((double)p2.y(), 150.0 + 2.0); - QVERIFY(m1 == m2.toTransform()); - - QTransform m3; - m3.scale(1.5, -2.0); - QPointF p3 = m3.map(QPointF(100.0, 150.0)); - QCOMPARE(p3.x(), 1.5 * 100.0); - QCOMPARE(p3.y(), -2.0 * 150.0); - - QMatrix4x4 m4(m3); - QPointF p4 = m4 * QPointF(100.0, 150.0); - QCOMPARE((double)p4.x(), 1.5 * 100.0); - QCOMPARE((double)p4.y(), -2.0 * 150.0); - QVERIFY(m3 == m4.toTransform()); - - QTransform m5; - m5.rotate(45.0); - QPointF p5 = m5.map(QPointF(100.0, 150.0)); - - QMatrix4x4 m6(m5); - QPointF p6 = m6 * QPointF(100.0, 150.0); - QVERIFY(fuzzyCompare(p5.x(), p6.x(), 0.005)); - QVERIFY(fuzzyCompare(p5.y(), p6.y(), 0.005)); - - QTransform m7 = m6.toTransform(); - QVERIFY(fuzzyCompare(m5.m11(), m7.m11())); - QVERIFY(fuzzyCompare(m5.m12(), m7.m12())); - QVERIFY(fuzzyCompare(m5.m21(), m7.m21())); - QVERIFY(fuzzyCompare(m5.m22(), m7.m22())); - QVERIFY(fuzzyCompare(m5.dx(), m7.dx())); - QVERIFY(fuzzyCompare(m5.dy(), m7.dy())); - QVERIFY(fuzzyCompare(m5.m13(), m7.m13())); - QVERIFY(fuzzyCompare(m5.m23(), m7.m23())); - QVERIFY(fuzzyCompare(m5.m33(), m7.m33())); -} - -// Test filling matrices with specific values. -void tst_QMatrixNxN::fill() -{ - QMatrix4x4 m1; - m1.fill(0.0f); - QVERIFY(isSame(m1, nullValues4)); - - static const qreal fillValues4[] = - {2.5f, 2.5f, 2.5f, 2.5f, - 2.5f, 2.5f, 2.5f, 2.5f, - 2.5f, 2.5f, 2.5f, 2.5f, - 2.5f, 2.5f, 2.5f, 2.5f}; - m1.fill(2.5f); - QVERIFY(isSame(m1, fillValues4)); - - QMatrix4x3 m2; - m2.fill(0.0f); - QVERIFY(isSame(m2, nullValues4x3)); - - static const qreal fillValues4x3[] = - {2.5f, 2.5f, 2.5f, 2.5f, - 2.5f, 2.5f, 2.5f, 2.5f, - 2.5f, 2.5f, 2.5f, 2.5f}; - m2.fill(2.5f); - QVERIFY(isSame(m2, fillValues4x3)); -} - -// Test the mapRect() function for QRect and QRectF. -void tst_QMatrixNxN::mapRect_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("width"); - QTest::addColumn("height"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - QTest::newRow("rect") - << (qreal)1.0f << (qreal)-20.5f << (qreal)100.0f << (qreal)63.75f; -} -void tst_QMatrixNxN::mapRect() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, width); - QFETCH(qreal, height); - - QRectF rect(x, y, width, height); - QRect recti(qRound(x), qRound(y), qRound(width), qRound(height)); - - QMatrix4x4 m1; - QVERIFY(m1.mapRect(rect) == rect); - QVERIFY(m1.mapRect(recti) == recti); - - QMatrix4x4 m2; - m2.translate(-100.5f, 64.0f); - QRectF translated = rect.translated(-100.5f, 64.0f); - QRect translatedi = QRect(qRound(recti.x() - 100.5f), recti.y() + 64, - recti.width(), recti.height()); - QVERIFY(m2.mapRect(rect) == translated); - QVERIFY(m2.mapRect(recti) == translatedi); - - QMatrix4x4 m3; - m3.scale(-100.5f, 64.0f); - qreal scalex = x * -100.5f; - qreal scaley = y * 64.0f; - qreal scalewid = width * -100.5f; - qreal scaleht = height * 64.0f; - if (scalewid < 0.0f) { - scalewid = -scalewid; - scalex -= scalewid; - } - if (scaleht < 0.0f) { - scaleht = -scaleht; - scaley -= scaleht; - } - QRectF scaled(scalex, scaley, scalewid, scaleht); - QVERIFY(m3.mapRect(rect) == scaled); - scalex = recti.x() * -100.5f; - scaley = recti.y() * 64.0f; - scalewid = recti.width() * -100.5f; - scaleht = recti.height() * 64.0f; - if (scalewid < 0.0f) { - scalewid = -scalewid; - scalex -= scalewid; - } - if (scaleht < 0.0f) { - scaleht = -scaleht; - scaley -= scaleht; - } - QRect scaledi(qRound(scalex), qRound(scaley), - qRound(scalewid), qRound(scaleht)); - QVERIFY(m3.mapRect(recti) == scaledi); - - QMatrix4x4 m4; - m4.translate(-100.5f, 64.0f); - m4.scale(-2.5f, 4.0f); - qreal transx1 = x * -2.5f - 100.5f; - qreal transy1 = y * 4.0f + 64.0f; - qreal transx2 = (x + width) * -2.5f - 100.5f; - qreal transy2 = (y + height) * 4.0f + 64.0f; - if (transx1 > transx2) - qSwap(transx1, transx2); - if (transy1 > transy2) - qSwap(transy1, transy2); - QRectF trans(transx1, transy1, transx2 - transx1, transy2 - transy1); - QVERIFY(m4.mapRect(rect) == trans); - transx1 = recti.x() * -2.5f - 100.5f; - transy1 = recti.y() * 4.0f + 64.0f; - transx2 = (recti.x() + recti.width()) * -2.5f - 100.5f; - transy2 = (recti.y() + recti.height()) * 4.0f + 64.0f; - if (transx1 > transx2) - qSwap(transx1, transx2); - if (transy1 > transy2) - qSwap(transy1, transy2); - QRect transi(qRound(transx1), qRound(transy1), - qRound(transx2) - qRound(transx1), - qRound(transy2) - qRound(transy1)); - QVERIFY(m4.mapRect(recti) == transi); - - m4.rotate(45.0f, 0.0f, 0.0f, 1.0f); - - QTransform t4; - t4.translate(-100.5f, 64.0f); - t4.scale(-2.5f, 4.0f); - t4.rotate(45.0f); - QRectF mr = m4.mapRect(rect); - QRectF tr = t4.mapRect(rect); - QVERIFY(fuzzyCompare(mr.x(), tr.x())); - QVERIFY(fuzzyCompare(mr.y(), tr.y())); - QVERIFY(fuzzyCompare(mr.width(), tr.width())); - QVERIFY(fuzzyCompare(mr.height(), tr.height())); - - QRect mri = m4.mapRect(recti); - QRect tri = t4.mapRect(recti); - QVERIFY(mri == tri); -} - -class tst_QMatrixNxN4x4Properties : public QObject -{ - Q_OBJECT - Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix) -public: - tst_QMatrixNxN4x4Properties(QObject *parent = 0) : QObject(parent) {} - - QMatrix4x4 matrix() const { return m; } - void setMatrix(const QMatrix4x4& value) { m = value; } - -private: - QMatrix4x4 m; -}; - -// Test getting and setting matrix properties via the metaobject system. -void tst_QMatrixNxN::properties() -{ - tst_QMatrixNxN4x4Properties obj; - - QMatrix4x4 m1(uniqueValues4); - obj.setMatrix(m1); - - QMatrix4x4 m2 = qVariantValue(obj.property("matrix")); - QVERIFY(isSame(m2, uniqueValues4)); - - QMatrix4x4 m3(transposedValues4); - obj.setProperty("matrix", qVariantFromValue(m3)); - - m2 = qVariantValue(obj.property("matrix")); - QVERIFY(isSame(m2, transposedValues4)); -} - -void tst_QMatrixNxN::metaTypes() -{ - QVERIFY(QMetaType::type("QMatrix4x4") == QMetaType::QMatrix4x4); - - QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QMatrix4x4)), - QByteArray("QMatrix4x4")); - - QVERIFY(QMetaType::isRegistered(QMetaType::QMatrix4x4)); - - QVERIFY(qMetaTypeId() == QMetaType::QMatrix4x4); -} - -QTEST_APPLESS_MAIN(tst_QMatrixNxN) - -#include "tst_qmatrixnxn.moc" diff --git a/tests/auto/math3d/qquaternion/qquaternion.pro b/tests/auto/math3d/qquaternion/qquaternion.pro deleted file mode 100644 index eea84f0..0000000 --- a/tests/auto/math3d/qquaternion/qquaternion.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -VPATH += ../shared -INCLUDEPATH += ../shared -HEADERS += math3dincludes.h -SOURCES += tst_qquaternion.cpp diff --git a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp deleted file mode 100644 index 899c5c2..0000000 --- a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp +++ /dev/null @@ -1,882 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include "math3dincludes.h" - -class tst_QQuaternion : public QObject -{ - Q_OBJECT -public: - tst_QQuaternion() {} - ~tst_QQuaternion() {} - -private slots: - void create(); - - void length_data(); - void length(); - - void normalized_data(); - void normalized(); - - void normalize_data(); - void normalize(); - - void compare(); - - void add_data(); - void add(); - - void subtract_data(); - void subtract(); - - void multiply_data(); - void multiply(); - - void multiplyFactor_data(); - void multiplyFactor(); - - void divide_data(); - void divide(); - - void negate_data(); - void negate(); - - void conjugate_data(); - void conjugate(); - - void fromAxisAndAngle_data(); - void fromAxisAndAngle(); - - void slerp_data(); - void slerp(); - - void nlerp_data(); - void nlerp(); - - void properties(); - void metaTypes(); -}; - -// qFuzzyCompare isn't always "fuzzy" enough to handle conversion -// between float, double, and qreal. So create "fuzzier" compares. -static bool fuzzyCompare(float x, float y) -{ - float diff = x - y; - if (diff < 0.0f) - diff = -diff; - return (diff < 0.001); -} - -// Test the creation of QQuaternion objects in various ways: -// construct, copy, and modify. -void tst_QQuaternion::create() -{ - QQuaternion identity; - QCOMPARE(identity.x(), (qreal)0.0f); - QCOMPARE(identity.y(), (qreal)0.0f); - QCOMPARE(identity.z(), (qreal)0.0f); - QCOMPARE(identity.scalar(), (qreal)1.0f); - QVERIFY(identity.isIdentity()); - - QQuaternion v1(34.0f, 1.0f, 2.5f, -89.25f); - QCOMPARE(v1.x(), (qreal)1.0f); - QCOMPARE(v1.y(), (qreal)2.5f); - QCOMPARE(v1.z(), (qreal)-89.25f); - QCOMPARE(v1.scalar(), (qreal)34.0f); - QVERIFY(!v1.isNull()); - - QQuaternion v1i(34, 1, 2, -89); - QCOMPARE(v1i.x(), (qreal)1.0f); - QCOMPARE(v1i.y(), (qreal)2.0f); - QCOMPARE(v1i.z(), (qreal)-89.0f); - QCOMPARE(v1i.scalar(), (qreal)34.0f); - QVERIFY(!v1i.isNull()); - - QQuaternion v2(v1); - QCOMPARE(v2.x(), (qreal)1.0f); - QCOMPARE(v2.y(), (qreal)2.5f); - QCOMPARE(v2.z(), (qreal)-89.25f); - QCOMPARE(v2.scalar(), (qreal)34.0f); - QVERIFY(!v2.isNull()); - - QQuaternion v4; - QCOMPARE(v4.x(), (qreal)0.0f); - QCOMPARE(v4.y(), (qreal)0.0f); - QCOMPARE(v4.z(), (qreal)0.0f); - QCOMPARE(v4.scalar(), (qreal)1.0f); - QVERIFY(v4.isIdentity()); - v4 = v1; - QCOMPARE(v4.x(), (qreal)1.0f); - QCOMPARE(v4.y(), (qreal)2.5f); - QCOMPARE(v4.z(), (qreal)-89.25f); - QCOMPARE(v4.scalar(), (qreal)34.0f); - QVERIFY(!v4.isNull()); - - QQuaternion v9(34, QVector3D(1.0f, 2.5f, -89.25f)); - QCOMPARE(v9.x(), (qreal)1.0f); - QCOMPARE(v9.y(), (qreal)2.5f); - QCOMPARE(v9.z(), (qreal)-89.25f); - QCOMPARE(v9.scalar(), (qreal)34.0f); - QVERIFY(!v9.isNull()); - - v1.setX(3.0f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)2.5f); - QCOMPARE(v1.z(), (qreal)-89.25f); - QCOMPARE(v1.scalar(), (qreal)34.0f); - QVERIFY(!v1.isNull()); - - v1.setY(10.5f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)10.5f); - QCOMPARE(v1.z(), (qreal)-89.25f); - QCOMPARE(v1.scalar(), (qreal)34.0f); - QVERIFY(!v1.isNull()); - - v1.setZ(15.5f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)10.5f); - QCOMPARE(v1.z(), (qreal)15.5f); - QCOMPARE(v1.scalar(), (qreal)34.0f); - QVERIFY(!v1.isNull()); - - v1.setScalar(6.0f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)10.5f); - QCOMPARE(v1.z(), (qreal)15.5f); - QCOMPARE(v1.scalar(), (qreal)6.0f); - QVERIFY(!v1.isNull()); - - v1.setVector(2.0f, 6.5f, -1.25f); - QCOMPARE(v1.x(), (qreal)2.0f); - QCOMPARE(v1.y(), (qreal)6.5f); - QCOMPARE(v1.z(), (qreal)-1.25f); - QCOMPARE(v1.scalar(), (qreal)6.0f); - QVERIFY(!v1.isNull()); - QVERIFY(v1.vector() == QVector3D(2.0f, 6.5f, -1.25f)); - - v1.setVector(QVector3D(-2.0f, -6.5f, 1.25f)); - QCOMPARE(v1.x(), (qreal)-2.0f); - QCOMPARE(v1.y(), (qreal)-6.5f); - QCOMPARE(v1.z(), (qreal)1.25f); - QCOMPARE(v1.scalar(), (qreal)6.0f); - QVERIFY(!v1.isNull()); - QVERIFY(v1.vector() == QVector3D(-2.0f, -6.5f, 1.25f)); - - v1.setX(0.0f); - v1.setY(0.0f); - v1.setZ(0.0f); - v1.setScalar(0.0f); - QCOMPARE(v1.x(), (qreal)0.0f); - QCOMPARE(v1.y(), (qreal)0.0f); - QCOMPARE(v1.z(), (qreal)0.0f); - QCOMPARE(v1.scalar(), (qreal)0.0f); - QVERIFY(v1.isNull()); - - QVector4D v10 = v9.toVector4D(); - QCOMPARE(v10.x(), (qreal)1.0f); - QCOMPARE(v10.y(), (qreal)2.5f); - QCOMPARE(v10.z(), (qreal)-89.25f); - QCOMPARE(v10.w(), (qreal)34.0f); -} - -// Test length computation for quaternions. -void tst_QQuaternion::length_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("z"); - QTest::addColumn("w"); - QTest::addColumn("len"); - - QTest::newRow("null") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - QTest::newRow("1x") << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("1y") << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("1z") << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)1.0f; - QTest::newRow("-1x") << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("-1z") << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("-1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; - QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)2.0f << (qreal)qSqrt(16.0f); -} -void tst_QQuaternion::length() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(qreal, w); - QFETCH(qreal, len); - - QQuaternion v(w, x, y, z); - QCOMPARE((float)(v.length()), (float)len); - QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y + z * z + w * w)); -} - -// Test the unit vector conversion for quaternions. -void tst_QQuaternion::normalized_data() -{ - // Use the same test data as the length test. - length_data(); -} -void tst_QQuaternion::normalized() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(qreal, w); - QFETCH(qreal, len); - - QQuaternion v(w, x, y, z); - QQuaternion u = v.normalized(); - if (v.isNull()) - QVERIFY(u.isNull()); - else - QCOMPARE((float)(u.length()), (float)1.0f); - QCOMPARE((float)(u.x() * len), (float)(v.x())); - QCOMPARE((float)(u.y() * len), (float)(v.y())); - QCOMPARE((float)(u.z() * len), (float)(v.z())); - QCOMPARE((float)(u.scalar() * len), (float)(v.scalar())); -} - -// Test the unit vector conversion for quaternions. -void tst_QQuaternion::normalize_data() -{ - // Use the same test data as the length test. - length_data(); -} -void tst_QQuaternion::normalize() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(qreal, w); - - QQuaternion v(w, x, y, z); - bool isNull = v.isNull(); - v.normalize(); - if (isNull) - QVERIFY(v.isNull()); - else - QCOMPARE((float)(v.length()), (float)1.0f); -} - -// Test the comparison operators for quaternions. -void tst_QQuaternion::compare() -{ - QQuaternion v1(8, 1, 2, 4); - QQuaternion v2(8, 1, 2, 4); - QQuaternion v3(8, 3, 2, 4); - QQuaternion v4(8, 1, 3, 4); - QQuaternion v5(8, 1, 2, 3); - QQuaternion v6(3, 1, 2, 4); - - QVERIFY(v1 == v2); - QVERIFY(v1 != v3); - QVERIFY(v1 != v4); - QVERIFY(v1 != v5); - QVERIFY(v1 != v6); -} - -// Test addition for quaternions. -void tst_QQuaternion::add_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("w1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("w2"); - QTest::addColumn("x3"); - QTest::addColumn("y3"); - QTest::addColumn("z3"); - QTest::addColumn("w3"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("zonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f; - - QTest::newRow("wonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)8.0f - << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f - << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f << (qreal)17.0f; -} -void tst_QQuaternion::add() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - QFETCH(qreal, w3); - - QQuaternion v1(w1, x1, y1, z1); - QQuaternion v2(w2, x2, y2, z2); - QQuaternion v3(w3, x3, y3, z3); - - QVERIFY((v1 + v2) == v3); - - QQuaternion v4(v1); - v4 += v2; - QVERIFY(v4 == v3); - - QCOMPARE(v4.x(), v1.x() + v2.x()); - QCOMPARE(v4.y(), v1.y() + v2.y()); - QCOMPARE(v4.z(), v1.z() + v2.z()); - QCOMPARE(v4.scalar(), v1.scalar() + v2.scalar()); -} - -// Test subtraction for quaternions. -void tst_QQuaternion::subtract_data() -{ - // Use the same test data as the add test. - add_data(); -} -void tst_QQuaternion::subtract() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - QFETCH(qreal, w3); - - QQuaternion v1(w1, x1, y1, z1); - QQuaternion v2(w2, x2, y2, z2); - QQuaternion v3(w3, x3, y3, z3); - - QVERIFY((v3 - v1) == v2); - QVERIFY((v3 - v2) == v1); - - QQuaternion v4(v3); - v4 -= v1; - QVERIFY(v4 == v2); - - QCOMPARE(v4.x(), v3.x() - v1.x()); - QCOMPARE(v4.y(), v3.y() - v1.y()); - QCOMPARE(v4.z(), v3.z() - v1.z()); - QCOMPARE(v4.scalar(), v3.scalar() - v1.scalar()); - - QQuaternion v5(v3); - v5 -= v2; - QVERIFY(v5 == v1); - - QCOMPARE(v5.x(), v3.x() - v2.x()); - QCOMPARE(v5.y(), v3.y() - v2.y()); - QCOMPARE(v5.z(), v3.z() - v2.z()); - QCOMPARE(v5.scalar(), v3.scalar() - v2.scalar()); -} - -// Test quaternion multiplication. -void tst_QQuaternion::multiply_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("w1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("w2"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("unitvec") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; - - QTest::newRow("complex") - << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)7.0f - << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f << (qreal)8.0f; -} -void tst_QQuaternion::multiply() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - - QQuaternion q1(w1, x1, y1, z1); - QQuaternion q2(w2, x2, y2, z2); - - // Use the simple algorithm at: - // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q53 - // to calculate the answer we expect to get. - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - qreal scalar = w1 * w2 - QVector3D::dotProduct(v1, v2); - QVector3D vector = w1 * v2 + w2 * v1 + QVector3D::crossProduct(v1, v2); - QQuaternion result(scalar, vector); - - QVERIFY((q1 * q2) == result); -} - -// Test multiplication by a factor for quaternions. -void tst_QQuaternion::multiplyFactor_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("w1"); - QTest::addColumn("factor"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("w2"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)100.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("zonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; - - QTest::newRow("wonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)4.0f - << (qreal)2.0f - << (qreal)2.0f << (qreal)4.0f << (qreal)-6.0f << (qreal)8.0f; - - QTest::newRow("allzero") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)4.0f - << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; -} -void tst_QQuaternion::multiplyFactor() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, factor); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - - QQuaternion v1(w1, x1, y1, z1); - QQuaternion v2(w2, x2, y2, z2); - - QVERIFY((v1 * factor) == v2); - QVERIFY((factor * v1) == v2); - - QQuaternion v3(v1); - v3 *= factor; - QVERIFY(v3 == v2); - - QCOMPARE(v3.x(), v1.x() * factor); - QCOMPARE(v3.y(), v1.y() * factor); - QCOMPARE(v3.z(), v1.z() * factor); - QCOMPARE(v3.scalar(), v1.scalar() * factor); -} - -// Test division by a factor for quaternions. -void tst_QQuaternion::divide_data() -{ - // Use the same test data as the multiply test. - multiplyFactor_data(); -} -void tst_QQuaternion::divide() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, factor); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - - QQuaternion v1(w1, x1, y1, z1); - QQuaternion v2(w2, x2, y2, z2); - - if (factor == (qreal)0.0f) - return; - - QVERIFY((v2 / factor) == v1); - - QQuaternion v3(v2); - v3 /= factor; - QVERIFY(v3 == v1); - - QCOMPARE(v3.x(), v2.x() / factor); - QCOMPARE(v3.y(), v2.y() / factor); - QCOMPARE(v3.z(), v2.z() / factor); - QCOMPARE(v3.scalar(), v2.scalar() / factor); -} - -// Test negation for quaternions. -void tst_QQuaternion::negate_data() -{ - // Use the same test data as the add test. - add_data(); -} -void tst_QQuaternion::negate() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - - QQuaternion v1(w1, x1, y1, z1); - QQuaternion v2(-w1, -x1, -y1, -z1); - - QVERIFY(-v1 == v2); -} - -// Test quaternion conjugate calculations. -void tst_QQuaternion::conjugate_data() -{ - // Use the same test data as the add test. - add_data(); -} -void tst_QQuaternion::conjugate() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - - QQuaternion v1(w1, x1, y1, z1); - QQuaternion v2(w1, -x1, -y1, -z1); - - QVERIFY(v1.conjugate() == v2); -} - -// Test quaternion creation from an axis and an angle. -void tst_QQuaternion::fromAxisAndAngle_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("angle"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)90.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)180.0f; - - QTest::newRow("zonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)270.0f; - - QTest::newRow("complex") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)45.0f; -} -void tst_QQuaternion::fromAxisAndAngle() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, angle); - - // Use a straight-forward implementation of the algorithm at: - // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56 - // to calculate the answer we expect to get. - QVector3D vector = QVector3D(x1, y1, z1).normalized(); - qreal sin_a = qSin((angle * M_PI / 180.0) / 2.0); - qreal cos_a = qCos((angle * M_PI / 180.0) / 2.0); - QQuaternion result((qreal)cos_a, - (qreal)(vector.x() * sin_a), - (qreal)(vector.y() * sin_a), - (qreal)(vector.z() * sin_a)); - result = result.normalized(); - - QQuaternion answer = QQuaternion::fromAxisAndAngle(QVector3D(x1, y1, z1), angle); - QVERIFY(fuzzyCompare(answer.x(), result.x())); - QVERIFY(fuzzyCompare(answer.y(), result.y())); - QVERIFY(fuzzyCompare(answer.z(), result.z())); - QVERIFY(fuzzyCompare(answer.scalar(), result.scalar())); - - answer = QQuaternion::fromAxisAndAngle(x1, y1, z1, angle); - QVERIFY(fuzzyCompare(answer.x(), result.x())); - QVERIFY(fuzzyCompare(answer.y(), result.y())); - QVERIFY(fuzzyCompare(answer.z(), result.z())); - QVERIFY(fuzzyCompare(answer.scalar(), result.scalar())); -} - -// Test spherical interpolation of quaternions. -void tst_QQuaternion::slerp_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("angle1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("angle2"); - QTest::addColumn("t"); - QTest::addColumn("x3"); - QTest::addColumn("y3"); - QTest::addColumn("z3"); - QTest::addColumn("angle3"); - - QTest::newRow("first") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f - << (qreal)0.0f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f; - QTest::newRow("first2") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f - << (qreal)-0.5f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f; - QTest::newRow("second") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f - << (qreal)1.0f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f; - QTest::newRow("second2") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f - << (qreal)1.5f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f; - QTest::newRow("middle") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f - << (qreal)0.5f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)135.0f; - QTest::newRow("wide angle") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)0.0f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)270.0f - << (qreal)0.5f - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)-45.0f; -} -void tst_QQuaternion::slerp() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, angle1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, angle2); - QFETCH(qreal, t); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - QFETCH(qreal, angle3); - - QQuaternion q1 = QQuaternion::fromAxisAndAngle(x1, y1, z1, angle1); - QQuaternion q2 = QQuaternion::fromAxisAndAngle(x2, y2, z2, angle2); - QQuaternion q3 = QQuaternion::fromAxisAndAngle(x3, y3, z3, angle3); - - QQuaternion result = QQuaternion::slerp(q1, q2, t); - - QVERIFY(fuzzyCompare(result.x(), q3.x())); - QVERIFY(fuzzyCompare(result.y(), q3.y())); - QVERIFY(fuzzyCompare(result.z(), q3.z())); - QVERIFY(fuzzyCompare(result.scalar(), q3.scalar())); -} - -// Test normalized linear interpolation of quaternions. -void tst_QQuaternion::nlerp_data() -{ - slerp_data(); -} -void tst_QQuaternion::nlerp() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, angle1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, angle2); - QFETCH(qreal, t); - - QQuaternion q1 = QQuaternion::fromAxisAndAngle(x1, y1, z1, angle1); - QQuaternion q2 = QQuaternion::fromAxisAndAngle(x2, y2, z2, angle2); - - QQuaternion result = QQuaternion::nlerp(q1, q2, t); - - qreal resultx, resulty, resultz, resultscalar; - if (t <= 0.0f) { - resultx = q1.x(); - resulty = q1.y(); - resultz = q1.z(); - resultscalar = q1.scalar(); - } else if (t >= 1.0f) { - resultx = q2.x(); - resulty = q2.y(); - resultz = q2.z(); - resultscalar = q2.scalar(); - } else if (qAbs(angle1 - angle2) <= 180.f) { - resultx = q1.x() * (1 - t) + q2.x() * t; - resulty = q1.y() * (1 - t) + q2.y() * t; - resultz = q1.z() * (1 - t) + q2.z() * t; - resultscalar = q1.scalar() * (1 - t) + q2.scalar() * t; - } else { - // Angle greater than 180 degrees: negate q2. - resultx = q1.x() * (1 - t) - q2.x() * t; - resulty = q1.y() * (1 - t) - q2.y() * t; - resultz = q1.z() * (1 - t) - q2.z() * t; - resultscalar = q1.scalar() * (1 - t) - q2.scalar() * t; - } - - QQuaternion q3 = QQuaternion(resultscalar, resultx, resulty, resultz).normalized(); - - QVERIFY(fuzzyCompare(result.x(), q3.x())); - QVERIFY(fuzzyCompare(result.y(), q3.y())); - QVERIFY(fuzzyCompare(result.z(), q3.z())); - QVERIFY(fuzzyCompare(result.scalar(), q3.scalar())); -} - -class tst_QQuaternionProperties : public QObject -{ - Q_OBJECT - Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion) -public: - tst_QQuaternionProperties(QObject *parent = 0) : QObject(parent) {} - - QQuaternion quaternion() const { return q; } - void setQuaternion(const QQuaternion& value) { q = value; } - -private: - QQuaternion q; -}; - -// Test getting and setting quaternion properties via the metaobject system. -void tst_QQuaternion::properties() -{ - tst_QQuaternionProperties obj; - - obj.setQuaternion(QQuaternion(6.0f, 7.0f, 8.0f, 9.0f)); - - QQuaternion q = qVariantValue(obj.property("quaternion")); - QCOMPARE(q.scalar(), (qreal)6.0f); - QCOMPARE(q.x(), (qreal)7.0f); - QCOMPARE(q.y(), (qreal)8.0f); - QCOMPARE(q.z(), (qreal)9.0f); - - obj.setProperty("quaternion", - qVariantFromValue(QQuaternion(-6.0f, -7.0f, -8.0f, -9.0f))); - - q = qVariantValue(obj.property("quaternion")); - QCOMPARE(q.scalar(), (qreal)-6.0f); - QCOMPARE(q.x(), (qreal)-7.0f); - QCOMPARE(q.y(), (qreal)-8.0f); - QCOMPARE(q.z(), (qreal)-9.0f); -} - -void tst_QQuaternion::metaTypes() -{ - QVERIFY(QMetaType::type("QQuaternion") == QMetaType::QQuaternion); - - QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QQuaternion)), - QByteArray("QQuaternion")); - - QVERIFY(QMetaType::isRegistered(QMetaType::QQuaternion)); - - QVERIFY(qMetaTypeId() == QMetaType::QQuaternion); -} - -QTEST_APPLESS_MAIN(tst_QQuaternion) - -#include "tst_qquaternion.moc" diff --git a/tests/auto/math3d/qvectornd/qvectornd.pro b/tests/auto/math3d/qvectornd/qvectornd.pro deleted file mode 100644 index 0981637..0000000 --- a/tests/auto/math3d/qvectornd/qvectornd.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -VPATH += ../shared -INCLUDEPATH += ../shared -HEADERS += math3dincludes.h -SOURCES += tst_qvectornd.cpp diff --git a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp deleted file mode 100644 index cfcce8e..0000000 --- a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp +++ /dev/null @@ -1,2141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include "math3dincludes.h" - -class tst_QVector : public QObject -{ - Q_OBJECT -public: - tst_QVector() {} - ~tst_QVector() {} - -private slots: - void create2(); - void create3(); - void create4(); - - void length2_data(); - void length2(); - void length3_data(); - void length3(); - void length4_data(); - void length4(); - - void normalized2_data(); - void normalized2(); - void normalized3_data(); - void normalized3(); - void normalized4_data(); - void normalized4(); - - void normalize2_data(); - void normalize2(); - void normalize3_data(); - void normalize3(); - void normalize4_data(); - void normalize4(); - - void compare2(); - void compare3(); - void compare4(); - - void add2_data(); - void add2(); - void add3_data(); - void add3(); - void add4_data(); - void add4(); - - void subtract2_data(); - void subtract2(); - void subtract3_data(); - void subtract3(); - void subtract4_data(); - void subtract4(); - - void multiply2_data(); - void multiply2(); - void multiply3_data(); - void multiply3(); - void multiply4_data(); - void multiply4(); - - void multiplyFactor2_data(); - void multiplyFactor2(); - void multiplyFactor3_data(); - void multiplyFactor3(); - void multiplyFactor4_data(); - void multiplyFactor4(); - - void divide2_data(); - void divide2(); - void divide3_data(); - void divide3(); - void divide4_data(); - void divide4(); - - void negate2_data(); - void negate2(); - void negate3_data(); - void negate3(); - void negate4_data(); - void negate4(); - - void crossProduct_data(); - void crossProduct(); - void normal_data(); - void normal(); - void distanceToPlane_data(); - void distanceToPlane(); - void distanceToLine_data(); - void distanceToLine(); - - void dotProduct2_data(); - void dotProduct2(); - void dotProduct3_data(); - void dotProduct3(); - void dotProduct4_data(); - void dotProduct4(); - - void properties(); - void metaTypes(); -}; - -// qFuzzyCompare isn't always "fuzzy" enough to handle conversion -// between float, double, and qreal. So create "fuzzier" compares. -static bool fuzzyCompare(float x, float y) -{ - float diff = x - y; - if (diff < 0.0f) - diff = -diff; - return (diff < 0.001); -} - -// Test the creation of QVector2D objects in various ways: -// construct, copy, and modify. -void tst_QVector::create2() -{ - QVector2D null; - QCOMPARE(null.x(), (qreal)0.0f); - QCOMPARE(null.y(), (qreal)0.0f); - QVERIFY(null.isNull()); - - QVector2D v1(1.0f, 2.5f); - QCOMPARE(v1.x(), (qreal)1.0f); - QCOMPARE(v1.y(), (qreal)2.5f); - QVERIFY(!v1.isNull()); - - QVector2D v1i(1, 2); - QCOMPARE(v1i.x(), (qreal)1.0f); - QCOMPARE(v1i.y(), (qreal)2.0f); - QVERIFY(!v1i.isNull()); - - QVector2D v2(v1); - QCOMPARE(v2.x(), (qreal)1.0f); - QCOMPARE(v2.y(), (qreal)2.5f); - QVERIFY(!v2.isNull()); - - QVector2D v4; - QCOMPARE(v4.x(), (qreal)0.0f); - QCOMPARE(v4.y(), (qreal)0.0f); - QVERIFY(v4.isNull()); - v4 = v1; - QCOMPARE(v4.x(), (qreal)1.0f); - QCOMPARE(v4.y(), (qreal)2.5f); - QVERIFY(!v4.isNull()); - - QVector2D v5(QPoint(1, 2)); - QCOMPARE(v5.x(), (qreal)1.0f); - QCOMPARE(v5.y(), (qreal)2.0f); - QVERIFY(!v5.isNull()); - - QVector2D v6(QPointF(1, 2.5)); - QCOMPARE(v6.x(), (qreal)1.0f); - QCOMPARE(v6.y(), (qreal)2.5f); - QVERIFY(!v6.isNull()); - - QVector2D v7(QVector3D(1.0f, 2.5f, 54.25f)); - QCOMPARE(v7.x(), (qreal)1.0f); - QCOMPARE(v7.y(), (qreal)2.5f); - QVERIFY(!v6.isNull()); - - QVector2D v8(QVector4D(1.0f, 2.5f, 54.25f, 34.0f)); - QCOMPARE(v8.x(), (qreal)1.0f); - QCOMPARE(v8.y(), (qreal)2.5f); - QVERIFY(!v6.isNull()); - - v1.setX(3.0f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)2.5f); - QVERIFY(!v1.isNull()); - - v1.setY(10.5f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)10.5f); - QVERIFY(!v1.isNull()); - - v1.setX(0.0f); - v1.setY(0.0f); - QCOMPARE(v1.x(), (qreal)0.0f); - QCOMPARE(v1.y(), (qreal)0.0f); - QVERIFY(v1.isNull()); - - QPoint p1 = v8.toPoint(); - QCOMPARE(p1.x(), 1); - QCOMPARE(p1.y(), 3); - - QPointF p2 = v8.toPointF(); - QCOMPARE((qreal)p2.x(), (qreal)1.0f); - QCOMPARE((qreal)p2.y(), (qreal)2.5f); - - QVector3D v9 = v8.toVector3D(); - QCOMPARE(v9.x(), (qreal)1.0f); - QCOMPARE(v9.y(), (qreal)2.5f); - QCOMPARE(v9.z(), (qreal)0.0f); - - QVector4D v10 = v8.toVector4D(); - QCOMPARE(v10.x(), (qreal)1.0f); - QCOMPARE(v10.y(), (qreal)2.5f); - QCOMPARE(v10.z(), (qreal)0.0f); - QCOMPARE(v10.w(), (qreal)0.0f); -} - -// Test the creation of QVector3D objects in various ways: -// construct, copy, and modify. -void tst_QVector::create3() -{ - QVector3D null; - QCOMPARE(null.x(), (qreal)0.0f); - QCOMPARE(null.y(), (qreal)0.0f); - QCOMPARE(null.z(), (qreal)0.0f); - QVERIFY(null.isNull()); - - QVector3D v1(1.0f, 2.5f, -89.25f); - QCOMPARE(v1.x(), (qreal)1.0f); - QCOMPARE(v1.y(), (qreal)2.5f); - QCOMPARE(v1.z(), (qreal)-89.25f); - QVERIFY(!v1.isNull()); - - QVector3D v1i(1, 2, -89); - QCOMPARE(v1i.x(), (qreal)1.0f); - QCOMPARE(v1i.y(), (qreal)2.0f); - QCOMPARE(v1i.z(), (qreal)-89.0f); - QVERIFY(!v1i.isNull()); - - QVector3D v2(v1); - QCOMPARE(v2.x(), (qreal)1.0f); - QCOMPARE(v2.y(), (qreal)2.5f); - QCOMPARE(v2.z(), (qreal)-89.25f); - QVERIFY(!v2.isNull()); - - QVector3D v3(1.0f, 2.5f, 0.0f); - QCOMPARE(v3.x(), (qreal)1.0f); - QCOMPARE(v3.y(), (qreal)2.5f); - QCOMPARE(v3.z(), (qreal)0.0f); - QVERIFY(!v3.isNull()); - - QVector3D v3i(1, 2, 0); - QCOMPARE(v3i.x(), (qreal)1.0f); - QCOMPARE(v3i.y(), (qreal)2.0f); - QCOMPARE(v3i.z(), (qreal)0.0f); - QVERIFY(!v3i.isNull()); - - QVector3D v4; - QCOMPARE(v4.x(), (qreal)0.0f); - QCOMPARE(v4.y(), (qreal)0.0f); - QCOMPARE(v4.z(), (qreal)0.0f); - QVERIFY(v4.isNull()); - v4 = v1; - QCOMPARE(v4.x(), (qreal)1.0f); - QCOMPARE(v4.y(), (qreal)2.5f); - QCOMPARE(v4.z(), (qreal)-89.25f); - QVERIFY(!v4.isNull()); - - QVector3D v5(QPoint(1, 2)); - QCOMPARE(v5.x(), (qreal)1.0f); - QCOMPARE(v5.y(), (qreal)2.0f); - QCOMPARE(v5.z(), (qreal)0.0f); - QVERIFY(!v5.isNull()); - - QVector3D v6(QPointF(1, 2.5)); - QCOMPARE(v6.x(), (qreal)1.0f); - QCOMPARE(v6.y(), (qreal)2.5f); - QCOMPARE(v6.z(), (qreal)0.0f); - QVERIFY(!v6.isNull()); - - QVector3D v7(QVector2D(1.0f, 2.5f)); - QCOMPARE(v7.x(), (qreal)1.0f); - QCOMPARE(v7.y(), (qreal)2.5f); - QCOMPARE(v7.z(), (qreal)0.0f); - QVERIFY(!v7.isNull()); - - QVector3D v8(QVector2D(1.0f, 2.5f), 54.25f); - QCOMPARE(v8.x(), (qreal)1.0f); - QCOMPARE(v8.y(), (qreal)2.5f); - QCOMPARE(v8.z(), (qreal)54.25f); - QVERIFY(!v8.isNull()); - - QVector3D v9(QVector4D(1.0f, 2.5f, 54.25f, 34.0f)); - QCOMPARE(v9.x(), (qreal)1.0f); - QCOMPARE(v9.y(), (qreal)2.5f); - QCOMPARE(v9.z(), (qreal)54.25f); - QVERIFY(!v9.isNull()); - - v1.setX(3.0f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)2.5f); - QCOMPARE(v1.z(), (qreal)-89.25f); - QVERIFY(!v1.isNull()); - - v1.setY(10.5f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)10.5f); - QCOMPARE(v1.z(), (qreal)-89.25f); - QVERIFY(!v1.isNull()); - - v1.setZ(15.5f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)10.5f); - QCOMPARE(v1.z(), (qreal)15.5f); - QVERIFY(!v1.isNull()); - - v1.setX(0.0f); - v1.setY(0.0f); - v1.setZ(0.0f); - QCOMPARE(v1.x(), (qreal)0.0f); - QCOMPARE(v1.y(), (qreal)0.0f); - QCOMPARE(v1.z(), (qreal)0.0f); - QVERIFY(v1.isNull()); - - QPoint p1 = v8.toPoint(); - QCOMPARE(p1.x(), 1); - QCOMPARE(p1.y(), 3); - - QPointF p2 = v8.toPointF(); - QCOMPARE((qreal)p2.x(), (qreal)1.0f); - QCOMPARE((qreal)p2.y(), (qreal)2.5f); - - QVector2D v10 = v8.toVector2D(); - QCOMPARE(v10.x(), (qreal)1.0f); - QCOMPARE(v10.y(), (qreal)2.5f); - - QVector4D v11 = v8.toVector4D(); - QCOMPARE(v11.x(), (qreal)1.0f); - QCOMPARE(v11.y(), (qreal)2.5f); - QCOMPARE(v11.z(), (qreal)54.25f); - QCOMPARE(v11.w(), (qreal)0.0f); -} - -// Test the creation of QVector4D objects in various ways: -// construct, copy, and modify. -void tst_QVector::create4() -{ - QVector4D null; - QCOMPARE(null.x(), (qreal)0.0f); - QCOMPARE(null.y(), (qreal)0.0f); - QCOMPARE(null.z(), (qreal)0.0f); - QCOMPARE(null.w(), (qreal)0.0f); - QVERIFY(null.isNull()); - - QVector4D v1(1.0f, 2.5f, -89.25f, 34.0f); - QCOMPARE(v1.x(), (qreal)1.0f); - QCOMPARE(v1.y(), (qreal)2.5f); - QCOMPARE(v1.z(), (qreal)-89.25f); - QCOMPARE(v1.w(), (qreal)34.0f); - QVERIFY(!v1.isNull()); - - QVector4D v1i(1, 2, -89, 34); - QCOMPARE(v1i.x(), (qreal)1.0f); - QCOMPARE(v1i.y(), (qreal)2.0f); - QCOMPARE(v1i.z(), (qreal)-89.0f); - QCOMPARE(v1i.w(), (qreal)34.0f); - QVERIFY(!v1i.isNull()); - - QVector4D v2(v1); - QCOMPARE(v2.x(), (qreal)1.0f); - QCOMPARE(v2.y(), (qreal)2.5f); - QCOMPARE(v2.z(), (qreal)-89.25f); - QCOMPARE(v2.w(), (qreal)34.0f); - QVERIFY(!v2.isNull()); - - QVector4D v3(1.0f, 2.5f, 0.0f, 0.0f); - QCOMPARE(v3.x(), (qreal)1.0f); - QCOMPARE(v3.y(), (qreal)2.5f); - QCOMPARE(v3.z(), (qreal)0.0f); - QCOMPARE(v3.w(), (qreal)0.0f); - QVERIFY(!v3.isNull()); - - QVector4D v3i(1, 2, 0, 0); - QCOMPARE(v3i.x(), (qreal)1.0f); - QCOMPARE(v3i.y(), (qreal)2.0f); - QCOMPARE(v3i.z(), (qreal)0.0f); - QCOMPARE(v3i.w(), (qreal)0.0f); - QVERIFY(!v3i.isNull()); - - QVector4D v3b(1.0f, 2.5f, -89.25f, 0.0f); - QCOMPARE(v3b.x(), (qreal)1.0f); - QCOMPARE(v3b.y(), (qreal)2.5f); - QCOMPARE(v3b.z(), (qreal)-89.25f); - QCOMPARE(v3b.w(), (qreal)0.0f); - QVERIFY(!v3b.isNull()); - - QVector4D v3bi(1, 2, -89, 0); - QCOMPARE(v3bi.x(), (qreal)1.0f); - QCOMPARE(v3bi.y(), (qreal)2.0f); - QCOMPARE(v3bi.z(), (qreal)-89.0f); - QCOMPARE(v3bi.w(), (qreal)0.0f); - QVERIFY(!v3bi.isNull()); - - QVector4D v4; - QCOMPARE(v4.x(), (qreal)0.0f); - QCOMPARE(v4.y(), (qreal)0.0f); - QCOMPARE(v4.z(), (qreal)0.0f); - QCOMPARE(v4.w(), (qreal)0.0f); - QVERIFY(v4.isNull()); - v4 = v1; - QCOMPARE(v4.x(), (qreal)1.0f); - QCOMPARE(v4.y(), (qreal)2.5f); - QCOMPARE(v4.z(), (qreal)-89.25f); - QCOMPARE(v4.w(), (qreal)34.0f); - QVERIFY(!v4.isNull()); - - QVector4D v5(QPoint(1, 2)); - QCOMPARE(v5.x(), (qreal)1.0f); - QCOMPARE(v5.y(), (qreal)2.0f); - QCOMPARE(v5.z(), (qreal)0.0f); - QCOMPARE(v5.w(), (qreal)0.0f); - QVERIFY(!v5.isNull()); - - QVector4D v6(QPointF(1, 2.5)); - QCOMPARE(v6.x(), (qreal)1.0f); - QCOMPARE(v6.y(), (qreal)2.5f); - QCOMPARE(v6.z(), (qreal)0.0f); - QCOMPARE(v6.w(), (qreal)0.0f); - QVERIFY(!v6.isNull()); - - QVector4D v7(QVector2D(1.0f, 2.5f)); - QCOMPARE(v7.x(), (qreal)1.0f); - QCOMPARE(v7.y(), (qreal)2.5f); - QCOMPARE(v7.z(), (qreal)0.0f); - QCOMPARE(v7.w(), (qreal)0.0f); - QVERIFY(!v7.isNull()); - - QVector4D v8(QVector3D(1.0f, 2.5f, -89.25f)); - QCOMPARE(v8.x(), (qreal)1.0f); - QCOMPARE(v8.y(), (qreal)2.5f); - QCOMPARE(v8.z(), (qreal)-89.25f); - QCOMPARE(v8.w(), (qreal)0.0f); - QVERIFY(!v8.isNull()); - - QVector4D v9(QVector3D(1.0f, 2.5f, -89.25f), 34); - QCOMPARE(v9.x(), (qreal)1.0f); - QCOMPARE(v9.y(), (qreal)2.5f); - QCOMPARE(v9.z(), (qreal)-89.25f); - QCOMPARE(v9.w(), (qreal)34.0f); - QVERIFY(!v9.isNull()); - - QVector4D v10(QVector2D(1.0f, 2.5f), 23.5f, -8); - QCOMPARE(v10.x(), (qreal)1.0f); - QCOMPARE(v10.y(), (qreal)2.5f); - QCOMPARE(v10.z(), (qreal)23.5f); - QCOMPARE(v10.w(), (qreal)-8.0f); - QVERIFY(!v10.isNull()); - - v1.setX(3.0f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)2.5f); - QCOMPARE(v1.z(), (qreal)-89.25f); - QCOMPARE(v1.w(), (qreal)34.0f); - QVERIFY(!v1.isNull()); - - v1.setY(10.5f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)10.5f); - QCOMPARE(v1.z(), (qreal)-89.25f); - QCOMPARE(v1.w(), (qreal)34.0f); - QVERIFY(!v1.isNull()); - - v1.setZ(15.5f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)10.5f); - QCOMPARE(v1.z(), (qreal)15.5f); - QCOMPARE(v1.w(), (qreal)34.0f); - QVERIFY(!v1.isNull()); - - v1.setW(6.0f); - QCOMPARE(v1.x(), (qreal)3.0f); - QCOMPARE(v1.y(), (qreal)10.5f); - QCOMPARE(v1.z(), (qreal)15.5f); - QCOMPARE(v1.w(), (qreal)6.0f); - QVERIFY(!v1.isNull()); - - v1.setX(0.0f); - v1.setY(0.0f); - v1.setZ(0.0f); - v1.setW(0.0f); - QCOMPARE(v1.x(), (qreal)0.0f); - QCOMPARE(v1.y(), (qreal)0.0f); - QCOMPARE(v1.z(), (qreal)0.0f); - QCOMPARE(v1.w(), (qreal)0.0f); - QVERIFY(v1.isNull()); - - QPoint p1 = v8.toPoint(); - QCOMPARE(p1.x(), 1); - QCOMPARE(p1.y(), 3); - - QPointF p2 = v8.toPointF(); - QCOMPARE((qreal)p2.x(), (qreal)1.0f); - QCOMPARE((qreal)p2.y(), (qreal)2.5f); - - QVector2D v11 = v8.toVector2D(); - QCOMPARE(v11.x(), (qreal)1.0f); - QCOMPARE(v11.y(), (qreal)2.5f); - - QVector3D v12 = v8.toVector3D(); - QCOMPARE(v12.x(), (qreal)1.0f); - QCOMPARE(v12.y(), (qreal)2.5f); - QCOMPARE(v12.z(), (qreal)-89.25f); - - QVector2D v13 = v9.toVector2DAffine(); - QVERIFY(fuzzyCompare(v13.x(), (qreal)(1.0f / 34.0f))); - QVERIFY(fuzzyCompare(v13.y(), (qreal)(2.5f / 34.0f))); - - QVector4D zerow(1.0f, 2.0f, 3.0f, 0.0f); - v13 = zerow.toVector2DAffine(); - QVERIFY(v13.isNull()); - - QVector3D v14 = v9.toVector3DAffine(); - QVERIFY(fuzzyCompare(v14.x(), (qreal)(1.0f / 34.0f))); - QVERIFY(fuzzyCompare(v14.y(), (qreal)(2.5f / 34.0f))); - QVERIFY(fuzzyCompare(v14.z(), (qreal)(-89.25f / 34.0f))); - - v14 = zerow.toVector3DAffine(); - QVERIFY(v14.isNull()); -} - -// Test vector length computation for 2D vectors. -void tst_QVector::length2_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("len"); - - QTest::newRow("null") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - QTest::newRow("1x") << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("1y") << (qreal)0.0f << (qreal)1.0f << (qreal)1.0f; - QTest::newRow("-1x") << (qreal)-1.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; - QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)qSqrt(8.0f); -} -void tst_QVector::length2() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, len); - - QVector2D v(x, y); - QCOMPARE((float)(v.length()), (float)len); - QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y)); -} - -// Test vector length computation for 3D vectors. -void tst_QVector::length3_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("z"); - QTest::addColumn("len"); - - QTest::newRow("null") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - QTest::newRow("1x") << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("1y") << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("1z") << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)1.0f; - QTest::newRow("-1x") << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("-1z") << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; - QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)qSqrt(12.0f); -} -void tst_QVector::length3() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(qreal, len); - - QVector3D v(x, y, z); - QCOMPARE((float)(v.length()), (float)len); - QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y + z * z)); -} - -// Test vector length computation for 4D vectors. -void tst_QVector::length4_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("z"); - QTest::addColumn("w"); - QTest::addColumn("len"); - - QTest::newRow("null") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - QTest::newRow("1x") << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("1y") << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("1z") << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)1.0f; - QTest::newRow("-1x") << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("-1z") << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)1.0f; - QTest::newRow("-1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; - QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)2.0f << (qreal)qSqrt(16.0f); -} -void tst_QVector::length4() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(qreal, w); - QFETCH(qreal, len); - - QVector4D v(x, y, z, w); - QCOMPARE((float)(v.length()), (float)len); - QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y + z * z + w * w)); -} - -// Test the unit vector conversion for 2D vectors. -void tst_QVector::normalized2_data() -{ - // Use the same test data as the length test. - length2_data(); -} -void tst_QVector::normalized2() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, len); - - QVector2D v(x, y); - QVector2D u = v.normalized(); - if (v.isNull()) - QVERIFY(u.isNull()); - else - QCOMPARE((float)(u.length()), (float)1.0f); - QCOMPARE((float)(u.x() * len), (float)(v.x())); - QCOMPARE((float)(u.y() * len), (float)(v.y())); -} - -// Test the unit vector conversion for 3D vectors. -void tst_QVector::normalized3_data() -{ - // Use the same test data as the length test. - length3_data(); -} -void tst_QVector::normalized3() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(qreal, len); - - QVector3D v(x, y, z); - QVector3D u = v.normalized(); - if (v.isNull()) - QVERIFY(u.isNull()); - else - QCOMPARE((float)(u.length()), (float)1.0f); - QCOMPARE((float)(u.x() * len), (float)(v.x())); - QCOMPARE((float)(u.y() * len), (float)(v.y())); - QCOMPARE((float)(u.z() * len), (float)(v.z())); -} - -// Test the unit vector conversion for 4D vectors. -void tst_QVector::normalized4_data() -{ - // Use the same test data as the length test. - length4_data(); -} -void tst_QVector::normalized4() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(qreal, w); - QFETCH(qreal, len); - - QVector4D v(x, y, z, w); - QVector4D u = v.normalized(); - if (v.isNull()) - QVERIFY(u.isNull()); - else - QCOMPARE((float)(u.length()), (float)1.0f); - QCOMPARE((float)(u.x() * len), (float)(v.x())); - QCOMPARE((float)(u.y() * len), (float)(v.y())); - QCOMPARE((float)(u.z() * len), (float)(v.z())); - QCOMPARE((float)(u.w() * len), (float)(v.w())); -} - -// Test the unit vector conversion for 2D vectors. -void tst_QVector::normalize2_data() -{ - // Use the same test data as the length test. - length2_data(); -} -void tst_QVector::normalize2() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - - QVector2D v(x, y); - bool isNull = v.isNull(); - v.normalize(); - if (isNull) - QVERIFY(v.isNull()); - else - QCOMPARE((float)(v.length()), (float)1.0f); -} - -// Test the unit vector conversion for 3D vectors. -void tst_QVector::normalize3_data() -{ - // Use the same test data as the length test. - length3_data(); -} -void tst_QVector::normalize3() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - - QVector3D v(x, y, z); - bool isNull = v.isNull(); - v.normalize(); - if (isNull) - QVERIFY(v.isNull()); - else - QCOMPARE((float)(v.length()), (float)1.0f); -} - -// Test the unit vector conversion for 4D vectors. -void tst_QVector::normalize4_data() -{ - // Use the same test data as the length test. - length4_data(); -} -void tst_QVector::normalize4() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(qreal, z); - QFETCH(qreal, w); - - QVector4D v(x, y, z, w); - bool isNull = v.isNull(); - v.normalize(); - if (isNull) - QVERIFY(v.isNull()); - else - QCOMPARE((float)(v.length()), (float)1.0f); -} - -// Test the comparison operators for 2D vectors. -void tst_QVector::compare2() -{ - QVector2D v1(1, 2); - QVector2D v2(1, 2); - QVector2D v3(3, 2); - QVector2D v4(1, 3); - - QVERIFY(v1 == v2); - QVERIFY(v1 != v3); - QVERIFY(v1 != v4); -} - -// Test the comparison operators for 3D vectors. -void tst_QVector::compare3() -{ - QVector3D v1(1, 2, 4); - QVector3D v2(1, 2, 4); - QVector3D v3(3, 2, 4); - QVector3D v4(1, 3, 4); - QVector3D v5(1, 2, 3); - - QVERIFY(v1 == v2); - QVERIFY(v1 != v3); - QVERIFY(v1 != v4); - QVERIFY(v1 != v5); -} - -// Test the comparison operators for 4D vectors. -void tst_QVector::compare4() -{ - QVector4D v1(1, 2, 4, 8); - QVector4D v2(1, 2, 4, 8); - QVector4D v3(3, 2, 4, 8); - QVector4D v4(1, 3, 4, 8); - QVector4D v5(1, 2, 3, 8); - QVector4D v6(1, 2, 4, 3); - - QVERIFY(v1 == v2); - QVERIFY(v1 != v3); - QVERIFY(v1 != v4); - QVERIFY(v1 != v5); - QVERIFY(v1 != v6); -} - -// Test vector addition for 2D vectors. -void tst_QVector::add2_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("x3"); - QTest::addColumn("y3"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f - << (qreal)3.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)2.0f - << (qreal)0.0f << (qreal)3.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f - << (qreal)4.0f << (qreal)5.0f - << (qreal)5.0f << (qreal)7.0f; -} -void tst_QVector::add2() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - - QVector2D v1(x1, y1); - QVector2D v2(x2, y2); - QVector2D v3(x3, y3); - - QVERIFY((v1 + v2) == v3); - - QVector2D v4(v1); - v4 += v2; - QVERIFY(v4 == v3); - - QCOMPARE(v4.x(), v1.x() + v2.x()); - QCOMPARE(v4.y(), v1.y() + v2.y()); -} - -// Test vector addition for 3D vectors. -void tst_QVector::add3_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("x3"); - QTest::addColumn("y3"); - QTest::addColumn("z3"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f; - - QTest::newRow("zonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f - << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f - << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f; -} -void tst_QVector::add3() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - QVector3D v3(x3, y3, z3); - - QVERIFY((v1 + v2) == v3); - - QVector3D v4(v1); - v4 += v2; - QVERIFY(v4 == v3); - - QCOMPARE(v4.x(), v1.x() + v2.x()); - QCOMPARE(v4.y(), v1.y() + v2.y()); - QCOMPARE(v4.z(), v1.z() + v2.z()); -} - -// Test vector addition for 4D vectors. -void tst_QVector::add4_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("w1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("w2"); - QTest::addColumn("x3"); - QTest::addColumn("y3"); - QTest::addColumn("z3"); - QTest::addColumn("w3"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("zonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f; - - QTest::newRow("wonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)8.0f - << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f - << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f << (qreal)17.0f; -} -void tst_QVector::add4() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - QFETCH(qreal, w3); - - QVector4D v1(x1, y1, z1, w1); - QVector4D v2(x2, y2, z2, w2); - QVector4D v3(x3, y3, z3, w3); - - QVERIFY((v1 + v2) == v3); - - QVector4D v4(v1); - v4 += v2; - QVERIFY(v4 == v3); - - QCOMPARE(v4.x(), v1.x() + v2.x()); - QCOMPARE(v4.y(), v1.y() + v2.y()); - QCOMPARE(v4.z(), v1.z() + v2.z()); - QCOMPARE(v4.w(), v1.w() + v2.w()); -} - -// Test vector subtraction for 2D vectors. -void tst_QVector::subtract2_data() -{ - // Use the same test data as the add test. - add2_data(); -} -void tst_QVector::subtract2() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - - QVector2D v1(x1, y1); - QVector2D v2(x2, y2); - QVector2D v3(x3, y3); - - QVERIFY((v3 - v1) == v2); - QVERIFY((v3 - v2) == v1); - - QVector2D v4(v3); - v4 -= v1; - QVERIFY(v4 == v2); - - QCOMPARE(v4.x(), v3.x() - v1.x()); - QCOMPARE(v4.y(), v3.y() - v1.y()); - - QVector2D v5(v3); - v5 -= v2; - QVERIFY(v5 == v1); - - QCOMPARE(v5.x(), v3.x() - v2.x()); - QCOMPARE(v5.y(), v3.y() - v2.y()); -} - -// Test vector subtraction for 3D vectors. -void tst_QVector::subtract3_data() -{ - // Use the same test data as the add test. - add3_data(); -} -void tst_QVector::subtract3() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - QVector3D v3(x3, y3, z3); - - QVERIFY((v3 - v1) == v2); - QVERIFY((v3 - v2) == v1); - - QVector3D v4(v3); - v4 -= v1; - QVERIFY(v4 == v2); - - QCOMPARE(v4.x(), v3.x() - v1.x()); - QCOMPARE(v4.y(), v3.y() - v1.y()); - QCOMPARE(v4.z(), v3.z() - v1.z()); - - QVector3D v5(v3); - v5 -= v2; - QVERIFY(v5 == v1); - - QCOMPARE(v5.x(), v3.x() - v2.x()); - QCOMPARE(v5.y(), v3.y() - v2.y()); - QCOMPARE(v5.z(), v3.z() - v2.z()); -} - -// Test vector subtraction for 4D vectors. -void tst_QVector::subtract4_data() -{ - // Use the same test data as the add test. - add4_data(); -} -void tst_QVector::subtract4() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - QFETCH(qreal, w3); - - QVector4D v1(x1, y1, z1, w1); - QVector4D v2(x2, y2, z2, w2); - QVector4D v3(x3, y3, z3, w3); - - QVERIFY((v3 - v1) == v2); - QVERIFY((v3 - v2) == v1); - - QVector4D v4(v3); - v4 -= v1; - QVERIFY(v4 == v2); - - QCOMPARE(v4.x(), v3.x() - v1.x()); - QCOMPARE(v4.y(), v3.y() - v1.y()); - QCOMPARE(v4.z(), v3.z() - v1.z()); - QCOMPARE(v4.w(), v3.w() - v1.w()); - - QVector4D v5(v3); - v5 -= v2; - QVERIFY(v5 == v1); - - QCOMPARE(v5.x(), v3.x() - v2.x()); - QCOMPARE(v5.y(), v3.y() - v2.y()); - QCOMPARE(v5.z(), v3.z() - v2.z()); - QCOMPARE(v5.w(), v3.w() - v2.w()); -} - -// Test component-wise vector multiplication for 2D vectors. -void tst_QVector::multiply2_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("x3"); - QTest::addColumn("y3"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)2.0f - << (qreal)0.0f << (qreal)2.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f - << (qreal)4.0f << (qreal)5.0f - << (qreal)4.0f << (qreal)10.0f; -} -void tst_QVector::multiply2() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - - QVector2D v1(x1, y1); - QVector2D v2(x2, y2); - QVector2D v3(x3, y3); - - QVERIFY((v1 * v2) == v3); - - QVector2D v4(v1); - v4 *= v2; - QVERIFY(v4 == v3); - - QCOMPARE(v4.x(), v1.x() * v2.x()); - QCOMPARE(v4.y(), v1.y() * v2.y()); -} - -// Test component-wise vector multiplication for 3D vectors. -void tst_QVector::multiply3_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("x3"); - QTest::addColumn("y3"); - QTest::addColumn("z3"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; - - QTest::newRow("zonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f - << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f - << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f; -} -void tst_QVector::multiply3() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - QVector3D v3(x3, y3, z3); - - QVERIFY((v1 * v2) == v3); - - QVector3D v4(v1); - v4 *= v2; - QVERIFY(v4 == v3); - - QCOMPARE(v4.x(), v1.x() * v2.x()); - QCOMPARE(v4.y(), v1.y() * v2.y()); - QCOMPARE(v4.z(), v1.z() * v2.z()); -} - -// Test component-wise vector multiplication for 4D vectors. -void tst_QVector::multiply4_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("w1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("w2"); - QTest::addColumn("x3"); - QTest::addColumn("y3"); - QTest::addColumn("z3"); - QTest::addColumn("w3"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("zonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; - - QTest::newRow("wonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)8.0f - << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f - << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f << (qreal)72.0f; -} -void tst_QVector::multiply4() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - QFETCH(qreal, w3); - - QVector4D v1(x1, y1, z1, w1); - QVector4D v2(x2, y2, z2, w2); - QVector4D v3(x3, y3, z3, w3); - - QVERIFY((v1 * v2) == v3); - - QVector4D v4(v1); - v4 *= v2; - QVERIFY(v4 == v3); - - QCOMPARE(v4.x(), v1.x() * v2.x()); - QCOMPARE(v4.y(), v1.y() * v2.y()); - QCOMPARE(v4.z(), v1.z() * v2.z()); - QCOMPARE(v4.w(), v1.w() * v2.w()); -} - -// Test vector multiplication by a factor for 2D vectors. -void tst_QVector::multiplyFactor2_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("factor"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f - << (qreal)100.0f - << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f - << (qreal)2.0f - << (qreal)2.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f - << (qreal)2.0f - << (qreal)0.0f << (qreal)2.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f - << (qreal)2.0f - << (qreal)2.0f << (qreal)4.0f; - - QTest::newRow("allzero") - << (qreal)1.0f << (qreal)2.0f - << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f; -} -void tst_QVector::multiplyFactor2() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, factor); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - - QVector2D v1(x1, y1); - QVector2D v2(x2, y2); - - QVERIFY((v1 * factor) == v2); - QVERIFY((factor * v1) == v2); - - QVector2D v3(v1); - v3 *= factor; - QVERIFY(v3 == v2); - - QCOMPARE(v3.x(), v1.x() * factor); - QCOMPARE(v3.y(), v1.y() * factor); -} - -// Test vector multiplication by a factor for 3D vectors. -void tst_QVector::multiplyFactor3_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("factor"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)100.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (qreal)2.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; - - QTest::newRow("zonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f - << (qreal)2.0f - << (qreal)2.0f << (qreal)4.0f << (qreal)-6.0f; - - QTest::newRow("allzero") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f - << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; -} -void tst_QVector::multiplyFactor3() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, factor); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - - QVERIFY((v1 * factor) == v2); - QVERIFY((factor * v1) == v2); - - QVector3D v3(v1); - v3 *= factor; - QVERIFY(v3 == v2); - - QCOMPARE(v3.x(), v1.x() * factor); - QCOMPARE(v3.y(), v1.y() * factor); - QCOMPARE(v3.z(), v1.z() * factor); -} - -// Test vector multiplication by a factor for 4D vectors. -void tst_QVector::multiplyFactor4_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("w1"); - QTest::addColumn("factor"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("w2"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)100.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("xonly") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f - << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("yonly") - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)2.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; - - QTest::newRow("zonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; - - QTest::newRow("wonly") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)2.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; - - QTest::newRow("all") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)4.0f - << (qreal)2.0f - << (qreal)2.0f << (qreal)4.0f << (qreal)-6.0f << (qreal)8.0f; - - QTest::newRow("allzero") - << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)4.0f - << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; -} -void tst_QVector::multiplyFactor4() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, factor); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - - QVector4D v1(x1, y1, z1, w1); - QVector4D v2(x2, y2, z2, w2); - - QVERIFY((v1 * factor) == v2); - QVERIFY((factor * v1) == v2); - - QVector4D v3(v1); - v3 *= factor; - QVERIFY(v3 == v2); - - QCOMPARE(v3.x(), v1.x() * factor); - QCOMPARE(v3.y(), v1.y() * factor); - QCOMPARE(v3.z(), v1.z() * factor); - QCOMPARE(v3.w(), v1.w() * factor); -} - -// Test vector division by a factor for 2D vectors. -void tst_QVector::divide2_data() -{ - // Use the same test data as the multiply test. - multiplyFactor2_data(); -} -void tst_QVector::divide2() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, factor); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - - QVector2D v1(x1, y1); - QVector2D v2(x2, y2); - - if (factor == (qreal)0.0f) - return; - - QVERIFY((v2 / factor) == v1); - - QVector2D v3(v2); - v3 /= factor; - QVERIFY(v3 == v1); - - QCOMPARE(v3.x(), v2.x() / factor); - QCOMPARE(v3.y(), v2.y() / factor); -} - -// Test vector division by a factor for 3D vectors. -void tst_QVector::divide3_data() -{ - // Use the same test data as the multiply test. - multiplyFactor3_data(); -} -void tst_QVector::divide3() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, factor); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - - if (factor == (qreal)0.0f) - return; - - QVERIFY((v2 / factor) == v1); - - QVector3D v3(v2); - v3 /= factor; - QVERIFY(v3 == v1); - - QCOMPARE(v3.x(), v2.x() / factor); - QCOMPARE(v3.y(), v2.y() / factor); - QCOMPARE(v3.z(), v2.z() / factor); -} - -// Test vector division by a factor for 4D vectors. -void tst_QVector::divide4_data() -{ - // Use the same test data as the multiply test. - multiplyFactor4_data(); -} -void tst_QVector::divide4() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, factor); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - - QVector4D v1(x1, y1, z1, w1); - QVector4D v2(x2, y2, z2, w2); - - if (factor == (qreal)0.0f) - return; - - QVERIFY((v2 / factor) == v1); - - QVector4D v3(v2); - v3 /= factor; - QVERIFY(v3 == v1); - - QCOMPARE(v3.x(), v2.x() / factor); - QCOMPARE(v3.y(), v2.y() / factor); - QCOMPARE(v3.z(), v2.z() / factor); - QCOMPARE(v3.w(), v2.w() / factor); -} - -// Test vector negation for 2D vectors. -void tst_QVector::negate2_data() -{ - // Use the same test data as the add test. - add2_data(); -} -void tst_QVector::negate2() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - - QVector2D v1(x1, y1); - QVector2D v2(-x1, -y1); - - QVERIFY(-v1 == v2); -} - -// Test vector negation for 3D vectors. -void tst_QVector::negate3_data() -{ - // Use the same test data as the add test. - add3_data(); -} -void tst_QVector::negate3() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - - QVector3D v1(x1, y1, z1); - QVector3D v2(-x1, -y1, -z1); - - QVERIFY(-v1 == v2); -} - -// Test vector negation for 4D vectors. -void tst_QVector::negate4_data() -{ - // Use the same test data as the add test. - add4_data(); -} -void tst_QVector::negate4() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - - QVector4D v1(x1, y1, z1, w1); - QVector4D v2(-x1, -y1, -z1, -w1); - - QVERIFY(-v1 == v2); -} - -// Test the computation of vector cross-products. -void tst_QVector::crossProduct_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("x3"); - QTest::addColumn("y3"); - QTest::addColumn("z3"); - QTest::addColumn("dot"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f; - - QTest::newRow("unitvec") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f; - - QTest::newRow("complex") - << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f - << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f - << (qreal)-3.0f << (qreal)6.0f << (qreal)-3.0f - << (qreal)32.0f; -} -void tst_QVector::crossProduct() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - QVector3D v3(x3, y3, z3); - - QVector3D v4 = QVector3D::crossProduct(v1, v2); - QVERIFY(v4 == v3); - - // Compute the cross-product long-hand and check again. - qreal xres = y1 * z2 - z1 * y2; - qreal yres = z1 * x2 - x1 * z2; - qreal zres = x1 * y2 - y1 * x2; - - QCOMPARE(v4.x(), xres); - QCOMPARE(v4.y(), yres); - QCOMPARE(v4.z(), zres); -} - -// Test the computation of normals. -void tst_QVector::normal_data() -{ - // Use the same test data as the crossProduct test. - crossProduct_data(); -} -void tst_QVector::normal() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - QVector3D v3(x3, y3, z3); - - QVERIFY(QVector3D::normal(v1, v2) == v3.normalized()); - QVERIFY(QVector3D::normal(QVector3D(), v1, v2) == v3.normalized()); - - QVector3D point(1.0f, 2.0f, 3.0f); - QVERIFY(QVector3D::normal(point, v1 + point, v2 + point) == v3.normalized()); -} - -// Test distance to plane calculations. -void tst_QVector::distanceToPlane_data() -{ - QTest::addColumn("x1"); // Point on plane - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("x2"); // Normal to plane - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("x3"); // Point to test for distance - QTest::addColumn("y3"); - QTest::addColumn("z3"); - QTest::addColumn("x4"); // Second point on plane - QTest::addColumn("y4"); - QTest::addColumn("z4"); - QTest::addColumn("x5"); // Third point on plane - QTest::addColumn("y5"); - QTest::addColumn("z5"); - QTest::addColumn("distance"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f - << (qreal)0.0f; - - QTest::newRow("above") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f - << (qreal)2.0f; - - QTest::newRow("below") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)-1.0f << (qreal)1.0f << (qreal)-2.0f - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f - << (qreal)-2.0f; -} -void tst_QVector::distanceToPlane() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - QFETCH(qreal, x4); - QFETCH(qreal, y4); - QFETCH(qreal, z4); - QFETCH(qreal, x5); - QFETCH(qreal, y5); - QFETCH(qreal, z5); - QFETCH(qreal, distance); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - QVector3D v3(x3, y3, z3); - QVector3D v4(x4, y4, z4); - QVector3D v5(x5, y5, z5); - - QCOMPARE(v3.distanceToPlane(v1, v2), distance); - QCOMPARE(v3.distanceToPlane(v1, v4, v5), distance); -} - -// Test distance to line calculations. -void tst_QVector::distanceToLine_data() -{ - QTest::addColumn("x1"); // Point on line - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("x2"); // Direction of the line - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("x3"); // Point to test for distance - QTest::addColumn("y3"); - QTest::addColumn("z3"); - QTest::addColumn("distance"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f; - - QTest::newRow("on line") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)5.0f - << (qreal)0.0f; - - QTest::newRow("off line") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)1.0f; - - QTest::newRow("off line 2") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f << (qreal)-2.0f << (qreal)0.0f - << (qreal)2.0f; - - QTest::newRow("points") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)5.0f << (qreal)0.0f - << (qreal)5.0f; -} -void tst_QVector::distanceToLine() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - QFETCH(qreal, distance); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - QVector3D v3(x3, y3, z3); - - QCOMPARE(v3.distanceToLine(v1, v2), distance); -} - -// Test the computation of dot products for 2D vectors. -void tst_QVector::dotProduct2_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("dot"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f; - - QTest::newRow("unitvec") - << (qreal)1.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)1.0f - << (qreal)0.0f; - - QTest::newRow("complex") - << (qreal)1.0f << (qreal)2.0f - << (qreal)4.0f << (qreal)5.0f - << (qreal)14.0f; -} -void tst_QVector::dotProduct2() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, dot); - - QVector2D v1(x1, y1); - QVector2D v2(x2, y2); - - QVERIFY(QVector2D::dotProduct(v1, v2) == dot); - - // Compute the dot-product long-hand and check again. - qreal d = x1 * x2 + y1 * y2; - - QCOMPARE(QVector2D::dotProduct(v1, v2), d); -} - -// Test the computation of dot products for 3D vectors. -void tst_QVector::dotProduct3_data() -{ - // Use the same test data as the crossProduct test. - crossProduct_data(); -} -void tst_QVector::dotProduct3() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, x3); - QFETCH(qreal, y3); - QFETCH(qreal, z3); - QFETCH(qreal, dot); - - Q_UNUSED(x3); - Q_UNUSED(y3); - Q_UNUSED(z3); - - QVector3D v1(x1, y1, z1); - QVector3D v2(x2, y2, z2); - - QVERIFY(QVector3D::dotProduct(v1, v2) == dot); - - // Compute the dot-product long-hand and check again. - qreal d = x1 * x2 + y1 * y2 + z1 * z2; - - QCOMPARE(QVector3D::dotProduct(v1, v2), d); -} - -// Test the computation of dot products for 4D vectors. -void tst_QVector::dotProduct4_data() -{ - QTest::addColumn("x1"); - QTest::addColumn("y1"); - QTest::addColumn("z1"); - QTest::addColumn("w1"); - QTest::addColumn("x2"); - QTest::addColumn("y2"); - QTest::addColumn("z2"); - QTest::addColumn("w2"); - QTest::addColumn("dot"); - - QTest::newRow("null") - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f; - - QTest::newRow("unitvec") - << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f - << (qreal)0.0f; - - QTest::newRow("complex") - << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)4.0f - << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f << (qreal)7.0f - << (qreal)60.0f; -} -void tst_QVector::dotProduct4() -{ - QFETCH(qreal, x1); - QFETCH(qreal, y1); - QFETCH(qreal, z1); - QFETCH(qreal, w1); - QFETCH(qreal, x2); - QFETCH(qreal, y2); - QFETCH(qreal, z2); - QFETCH(qreal, w2); - QFETCH(qreal, dot); - - QVector4D v1(x1, y1, z1, w1); - QVector4D v2(x2, y2, z2, w2); - - QVERIFY(QVector4D::dotProduct(v1, v2) == dot); - - // Compute the dot-product long-hand and check again. - qreal d = x1 * x2 + y1 * y2 + z1 * z2 + w1 * w2; - - QCOMPARE(QVector4D::dotProduct(v1, v2), d); -} - -class tst_QVectorProperties : public QObject -{ - Q_OBJECT - Q_PROPERTY(QVector2D vector2D READ vector2D WRITE setVector2D) - Q_PROPERTY(QVector3D vector3D READ vector3D WRITE setVector3D) - Q_PROPERTY(QVector4D vector4D READ vector4D WRITE setVector4D) -public: - tst_QVectorProperties(QObject *parent = 0) : QObject(parent) {} - - QVector2D vector2D() const { return v2; } - void setVector2D(const QVector2D& value) { v2 = value; } - - QVector3D vector3D() const { return v3; } - void setVector3D(const QVector3D& value) { v3 = value; } - - QVector4D vector4D() const { return v4; } - void setVector4D(const QVector4D& value) { v4 = value; } - -private: - QVector2D v2; - QVector3D v3; - QVector4D v4; -}; - -// Test getting and setting vector properties via the metaobject system. -void tst_QVector::properties() -{ - tst_QVectorProperties obj; - - obj.setVector2D(QVector2D(1.0f, 2.0f)); - obj.setVector3D(QVector3D(3.0f, 4.0f, 5.0f)); - obj.setVector4D(QVector4D(6.0f, 7.0f, 8.0f, 9.0f)); - - QVector2D v2 = qVariantValue(obj.property("vector2D")); - QCOMPARE(v2.x(), (qreal)1.0f); - QCOMPARE(v2.y(), (qreal)2.0f); - - QVector3D v3 = qVariantValue(obj.property("vector3D")); - QCOMPARE(v3.x(), (qreal)3.0f); - QCOMPARE(v3.y(), (qreal)4.0f); - QCOMPARE(v3.z(), (qreal)5.0f); - - QVector4D v4 = qVariantValue(obj.property("vector4D")); - QCOMPARE(v4.x(), (qreal)6.0f); - QCOMPARE(v4.y(), (qreal)7.0f); - QCOMPARE(v4.z(), (qreal)8.0f); - QCOMPARE(v4.w(), (qreal)9.0f); - - obj.setProperty("vector2D", - qVariantFromValue(QVector2D(-1.0f, -2.0f))); - obj.setProperty("vector3D", - qVariantFromValue(QVector3D(-3.0f, -4.0f, -5.0f))); - obj.setProperty("vector4D", - qVariantFromValue(QVector4D(-6.0f, -7.0f, -8.0f, -9.0f))); - - v2 = qVariantValue(obj.property("vector2D")); - QCOMPARE(v2.x(), (qreal)-1.0f); - QCOMPARE(v2.y(), (qreal)-2.0f); - - v3 = qVariantValue(obj.property("vector3D")); - QCOMPARE(v3.x(), (qreal)-3.0f); - QCOMPARE(v3.y(), (qreal)-4.0f); - QCOMPARE(v3.z(), (qreal)-5.0f); - - v4 = qVariantValue(obj.property("vector4D")); - QCOMPARE(v4.x(), (qreal)-6.0f); - QCOMPARE(v4.y(), (qreal)-7.0f); - QCOMPARE(v4.z(), (qreal)-8.0f); - QCOMPARE(v4.w(), (qreal)-9.0f); -} - -void tst_QVector::metaTypes() -{ - QVERIFY(QMetaType::type("QVector2D") == QMetaType::QVector2D); - QVERIFY(QMetaType::type("QVector3D") == QMetaType::QVector3D); - QVERIFY(QMetaType::type("QVector4D") == QMetaType::QVector4D); - - QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector2D)), - QByteArray("QVector2D")); - QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector3D)), - QByteArray("QVector3D")); - QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector4D)), - QByteArray("QVector4D")); - - QVERIFY(QMetaType::isRegistered(QMetaType::QVector2D)); - QVERIFY(QMetaType::isRegistered(QMetaType::QVector3D)); - QVERIFY(QMetaType::isRegistered(QMetaType::QVector4D)); - - QVERIFY(qMetaTypeId() == QMetaType::QVector2D); - QVERIFY(qMetaTypeId() == QMetaType::QVector3D); - QVERIFY(qMetaTypeId() == QMetaType::QVector4D); -} - -QTEST_APPLESS_MAIN(tst_QVector) - -#include "tst_qvectornd.moc" diff --git a/tests/auto/math3d/shared/math3dincludes.h b/tests/auto/math3d/shared/math3dincludes.h deleted file mode 100644 index 243c5a5..0000000 --- a/tests/auto/math3d/shared/math3dincludes.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MATH3DINCLUDES_H -#define MATH3DINCLUDES_H - -#include -#include -#include -#include -#include -#include - -#endif diff --git a/tests/auto/qmatrixnxn/qmatrixnxn.pro b/tests/auto/qmatrixnxn/qmatrixnxn.pro new file mode 100644 index 0000000..cf6e4a1 --- /dev/null +++ b/tests/auto/qmatrixnxn/qmatrixnxn.pro @@ -0,0 +1,2 @@ +load(qttest_p4) +SOURCES += tst_qmatrixnxn.cpp diff --git a/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp new file mode 100644 index 0000000..b8c04c0 --- /dev/null +++ b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp @@ -0,0 +1,3383 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +class tst_QMatrixNxN : public QObject +{ + Q_OBJECT +public: + tst_QMatrixNxN() {} + ~tst_QMatrixNxN() {} + +private slots: + void create2x2(); + void create3x3(); + void create4x4(); + void create4x3(); + + void isIdentity2x2(); + void isIdentity3x3(); + void isIdentity4x4(); + void isIdentity4x3(); + + void compare2x2(); + void compare3x3(); + void compare4x4(); + void compare4x3(); + + void transposed2x2(); + void transposed3x3(); + void transposed4x4(); + void transposed4x3(); + + void add2x2_data(); + void add2x2(); + void add3x3_data(); + void add3x3(); + void add4x4_data(); + void add4x4(); + void add4x3_data(); + void add4x3(); + + void subtract2x2_data(); + void subtract2x2(); + void subtract3x3_data(); + void subtract3x3(); + void subtract4x4_data(); + void subtract4x4(); + void subtract4x3_data(); + void subtract4x3(); + + void multiply2x2_data(); + void multiply2x2(); + void multiply3x3_data(); + void multiply3x3(); + void multiply4x4_data(); + void multiply4x4(); + void multiply4x3_data(); + void multiply4x3(); + + void multiplyFactor2x2_data(); + void multiplyFactor2x2(); + void multiplyFactor3x3_data(); + void multiplyFactor3x3(); + void multiplyFactor4x4_data(); + void multiplyFactor4x4(); + void multiplyFactor4x3_data(); + void multiplyFactor4x3(); + + void divideFactor2x2_data(); + void divideFactor2x2(); + void divideFactor3x3_data(); + void divideFactor3x3(); + void divideFactor4x4_data(); + void divideFactor4x4(); + void divideFactor4x3_data(); + void divideFactor4x3(); + + void negate2x2_data(); + void negate2x2(); + void negate3x3_data(); + void negate3x3(); + void negate4x4_data(); + void negate4x4(); + void negate4x3_data(); + void negate4x3(); + + void inverted4x4_data(); + void inverted4x4(); + + void orthonormalInverse4x4(); + + void scale4x4_data(); + void scale4x4(); + + void translate4x4_data(); + void translate4x4(); + + void rotate4x4_data(); + void rotate4x4(); + + void normalMatrix_data(); + void normalMatrix(); + + void optimizedTransforms(); + + void ortho(); + void frustum(); + void perspective(); + void flipCoordinates(); + + void convertGeneric(); + + void extractAxisRotation_data(); + void extractAxisRotation(); + + void extractTranslation_data(); + void extractTranslation(); + + void inferSpecialType_data(); + void inferSpecialType(); + + void columnsAndRows(); + + void convertQMatrix(); + void convertQTransform(); + + void fill(); + + void mapRect_data(); + void mapRect(); + + void properties(); + void metaTypes(); + +private: + static void setMatrix(QMatrix2x2& m, const qreal *values); + static void setMatrixDirect(QMatrix2x2& m, const qreal *values); + static bool isSame(const QMatrix2x2& m, const qreal *values); + static bool isIdentity(const QMatrix2x2& m); + + static void setMatrix(QMatrix3x3& m, const qreal *values); + static void setMatrixDirect(QMatrix3x3& m, const qreal *values); + static bool isSame(const QMatrix3x3& m, const qreal *values); + static bool isIdentity(const QMatrix3x3& m); + + static void setMatrix(QMatrix4x4& m, const qreal *values); + static void setMatrixDirect(QMatrix4x4& m, const qreal *values); + static bool isSame(const QMatrix4x4& m, const qreal *values); + static bool isIdentity(const QMatrix4x4& m); + + static void setMatrix(QMatrix4x3& m, const qreal *values); + static void setMatrixDirect(QMatrix4x3& m, const qreal *values); + static bool isSame(const QMatrix4x3& m, const qreal *values); + static bool isIdentity(const QMatrix4x3& m); +}; + +static const qreal nullValues2[] = + {0.0f, 0.0f, + 0.0f, 0.0f}; + +static qreal const identityValues2[16] = + {1.0f, 0.0f, + 0.0f, 1.0f}; + +static const qreal doubleIdentity2[] = + {2.0f, 0.0f, + 0.0f, 2.0f}; + +static qreal const uniqueValues2[16] = + {1.0f, 2.0f, + 5.0f, 6.0f}; + +static qreal const transposedValues2[16] = + {1.0f, 5.0f, + 2.0f, 6.0f}; + +static const qreal nullValues3[] = + {0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f}; + +static qreal const identityValues3[16] = + {1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f}; + +static const qreal doubleIdentity3[] = + {2.0f, 0.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 0.0f, 0.0f, 2.0f}; + +static qreal const uniqueValues3[16] = + {1.0f, 2.0f, 3.0f, + 5.0f, 6.0f, 7.0f, + 9.0f, 10.0f, 11.0f}; + +static qreal const transposedValues3[16] = + {1.0f, 5.0f, 9.0f, + 2.0f, 6.0f, 10.0f, + 3.0f, 7.0f, 11.0f}; + +static const qreal nullValues4[] = + {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f}; + +static qreal const identityValues4[16] = + {1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + +static const qreal doubleIdentity4[] = + {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 2.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 2.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 2.0f}; + +static qreal const uniqueValues4[16] = + {1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + +static qreal const transposedValues4[16] = + {1.0f, 5.0f, 9.0f, 13.0f, + 2.0f, 6.0f, 10.0f, 14.0f, + 3.0f, 7.0f, 11.0f, 15.0f, + 4.0f, 8.0f, 12.0f, 16.0f}; + +static const qreal nullValues4x3[] = + {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f}; + +static qreal const identityValues4x3[12] = + {1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f}; + +static qreal const doubleIdentity4x3[12] = + {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 2.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 2.0f, 0.0f}; + +static qreal const uniqueValues4x3[12] = + {1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f}; + +static qreal const transposedValues3x4[12] = + {1.0f, 5.0f, 9.0f, + 2.0f, 6.0f, 10.0f, + 3.0f, 7.0f, 11.0f, + 4.0f, 8.0f, 12.0f}; + +// Set a matrix to a specified array of values, which are assumed +// to be in row-major order. This sets the values using floating-point. +void tst_QMatrixNxN::setMatrix(QMatrix2x2& m, const qreal *values) +{ + for (int row = 0; row < 2; ++row) + for (int col = 0; col < 2; ++col) + m(row, col) = values[row * 2 + col]; +} +void tst_QMatrixNxN::setMatrix(QMatrix3x3& m, const qreal *values) +{ + for (int row = 0; row < 3; ++row) + for (int col = 0; col < 3; ++col) + m(row, col) = values[row * 3 + col]; +} +void tst_QMatrixNxN::setMatrix(QMatrix4x4& m, const qreal *values) +{ + for (int row = 0; row < 4; ++row) + for (int col = 0; col < 4; ++col) + m(row, col) = values[row * 4 + col]; +} +void tst_QMatrixNxN::setMatrix(QMatrix4x3& m, const qreal *values) +{ + for (int row = 0; row < 3; ++row) + for (int col = 0; col < 4; ++col) + m(row, col) = values[row * 4 + col]; +} + +// Set a matrix to a specified array of values, which are assumed +// to be in row-major order. This sets the values directly into +// the internal data() array. +void tst_QMatrixNxN::setMatrixDirect(QMatrix2x2& m, const qreal *values) +{ + float *data = m.data(); + for (int row = 0; row < 2; ++row) { + for (int col = 0; col < 2; ++col) { + data[row + col * 2] = values[row * 2 + col]; + } + } +} +void tst_QMatrixNxN::setMatrixDirect(QMatrix3x3& m, const qreal *values) +{ + float *data = m.data(); + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) { + data[row + col * 3] = values[row * 3 + col]; + } + } +} +void tst_QMatrixNxN::setMatrixDirect(QMatrix4x4& m, const qreal *values) +{ + float *data = m.data(); + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) { + data[row + col * 4] = values[row * 4 + col]; + } + } +} +void tst_QMatrixNxN::setMatrixDirect(QMatrix4x3& m, const qreal *values) +{ + float *data = m.data(); + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 4; ++col) { + data[row + col * 3] = values[row * 4 + col]; + } + } +} + +// qFuzzyCompare isn't always "fuzzy" enough to handle conversion +// between float, double, and qreal. So create "fuzzier" compares. +static bool fuzzyCompare(float x, float y, qreal epsilon = 0.001) +{ + float diff = x - y; + if (diff < 0.0f) + diff = -diff; + return (diff < epsilon); +} + +static bool fuzzyCompare(const QVector3D &v1, const QVector3D &v2, qreal epsilon = 0.001) +{ + if (!fuzzyCompare(v1.x(), v2.x(), epsilon)) + return false; + if (!fuzzyCompare(v1.y(), v2.y(), epsilon)) + return false; + if (!fuzzyCompare(v1.z(), v2.z(), epsilon)) + return false; + return true; +} + +static bool matrixFuzzyCompare(const QMatrix4x4 &m1, const QMatrix4x4 &m2) +{ + bool ret = true; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + ret = ret && fuzzyCompare(m1(i, j), m2(i, j)); + } + } + + return ret; +} + +// Determine if a matrix is the same as a specified array of values. +// The values are assumed to be specified in row-major order. +bool tst_QMatrixNxN::isSame(const QMatrix2x2& m, const qreal *values) +{ + const float *mv = m.constData(); + for (int row = 0; row < 2; ++row) { + for (int col = 0; col < 2; ++col) { + // Check the values using the operator() function. + if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 2 + col]))) { + qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 2 + col]; + return false; + } + + // Check the values using direct access, which verifies that the values + // are stored internally in column-major order. + if (!fuzzyCompare((float)(mv[col * 2 + row]), (float)(values[row * 2 + col]))) { + qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 2 + row] << "expected =" << values[row * 2 + col]; + return false; + } + } + } + return true; +} +bool tst_QMatrixNxN::isSame(const QMatrix3x3& m, const qreal *values) +{ + const float *mv = m.constData(); + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) { + // Check the values using the operator() access function. + if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 3 + col]))) { + qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 3 + col]; + return false; + } + + // Check the values using direct access, which verifies that the values + // are stored internally in column-major order. + if (!fuzzyCompare((float)(mv[col * 3 + row]), (float)(values[row * 3 + col]))) { + qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 3 + row] << "expected =" << values[row * 3 + col]; + return false; + } + } + } + return true; +} +bool tst_QMatrixNxN::isSame(const QMatrix4x4& m, const qreal *values) +{ + const float *mv = m.constData(); + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) { + // Check the values using the operator() access function. + if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 4 + col]))) { + qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 4 + col]; + return false; + } + + // Check the values using direct access, which verifies that the values + // are stored internally in column-major order. + if (!fuzzyCompare((float)(mv[col * 4 + row]), (float)(values[row * 4 + col]))) { + qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 4 + row] << "expected =" << values[row * 4 + col]; + return false; + } + } + } + return true; +} +bool tst_QMatrixNxN::isSame(const QMatrix4x3& m, const qreal *values) +{ + const float *mv = m.constData(); + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 4; ++col) { + // Check the values using the operator() access function. + if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 4 + col]))) { + qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 4 + col]; + return false; + } + + // Check the values using direct access, which verifies that the values + // are stored internally in column-major order. + if (!fuzzyCompare((float)(mv[col * 3 + row]), (float)(values[row * 4 + col]))) { + qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 3 + row] << "expected =" << values[row * 4 + col]; + return false; + } + } + } + return true; +} + +// Determine if a matrix is the identity. +bool tst_QMatrixNxN::isIdentity(const QMatrix2x2& m) +{ + return isSame(m, identityValues2); +} +bool tst_QMatrixNxN::isIdentity(const QMatrix3x3& m) +{ + return isSame(m, identityValues3); +} +bool tst_QMatrixNxN::isIdentity(const QMatrix4x4& m) +{ + return isSame(m, identityValues4); +} +bool tst_QMatrixNxN::isIdentity(const QMatrix4x3& m) +{ + return isSame(m, identityValues4x3); +} + +// Test the creation of QMatrix2x2 objects in various ways: +// construct, copy, and modify. +void tst_QMatrixNxN::create2x2() +{ + QMatrix2x2 m1; + QVERIFY(isIdentity(m1)); + QVERIFY(m1.isIdentity()); + + QMatrix2x2 m2; + setMatrix(m2, uniqueValues2); + QVERIFY(isSame(m2, uniqueValues2)); + QVERIFY(!m2.isIdentity()); + + QMatrix2x2 m3; + setMatrixDirect(m3, uniqueValues2); + QVERIFY(isSame(m3, uniqueValues2)); + + QMatrix2x2 m4(m3); + QVERIFY(isSame(m4, uniqueValues2)); + + QMatrix2x2 m5; + m5 = m3; + QVERIFY(isSame(m5, uniqueValues2)); + + m5.setIdentity(); + QVERIFY(isIdentity(m5)); + + QMatrix2x2 m6(uniqueValues2); + QVERIFY(isSame(m6, uniqueValues2)); + qreal vals[4]; + m6.toValueArray(vals); + for (int index = 0; index < 4; ++index) + QCOMPARE((float)(vals[index]), (float)(uniqueValues2[index])); +} + +// Test the creation of QMatrix3x3 objects in various ways: +// construct, copy, and modify. +void tst_QMatrixNxN::create3x3() +{ + QMatrix3x3 m1; + QVERIFY(isIdentity(m1)); + QVERIFY(m1.isIdentity()); + + QMatrix3x3 m2; + setMatrix(m2, uniqueValues3); + QVERIFY(isSame(m2, uniqueValues3)); + QVERIFY(!m2.isIdentity()); + + QMatrix3x3 m3; + setMatrixDirect(m3, uniqueValues3); + QVERIFY(isSame(m3, uniqueValues3)); + + QMatrix3x3 m4(m3); + QVERIFY(isSame(m4, uniqueValues3)); + + QMatrix3x3 m5; + m5 = m3; + QVERIFY(isSame(m5, uniqueValues3)); + + m5.setIdentity(); + QVERIFY(isIdentity(m5)); + + QMatrix3x3 m6(uniqueValues3); + QVERIFY(isSame(m6, uniqueValues3)); + qreal vals[9]; + m6.toValueArray(vals); + for (int index = 0; index < 9; ++index) + QCOMPARE((float)(vals[index]), (float)(uniqueValues3[index])); +} + +// Test the creation of QMatrix4x4 objects in various ways: +// construct, copy, and modify. +void tst_QMatrixNxN::create4x4() +{ + QMatrix4x4 m1; + QVERIFY(isIdentity(m1)); + QVERIFY(m1.isIdentity()); + + QMatrix4x4 m2; + setMatrix(m2, uniqueValues4); + QVERIFY(isSame(m2, uniqueValues4)); + QVERIFY(!m2.isIdentity()); + + QMatrix4x4 m3; + setMatrixDirect(m3, uniqueValues4); + QVERIFY(isSame(m3, uniqueValues4)); + + QMatrix4x4 m4(m3); + QVERIFY(isSame(m4, uniqueValues4)); + + QMatrix4x4 m5; + m5 = m3; + QVERIFY(isSame(m5, uniqueValues4)); + + m5.setIdentity(); + QVERIFY(isIdentity(m5)); + + QMatrix4x4 m6(uniqueValues4); + QVERIFY(isSame(m6, uniqueValues4)); + qreal vals[16]; + m6.toValueArray(vals); + for (int index = 0; index < 16; ++index) + QCOMPARE((float)(vals[index]), (float)(uniqueValues4[index])); + + QMatrix4x4 m8 + (uniqueValues4[0], uniqueValues4[1], uniqueValues4[2], uniqueValues4[3], + uniqueValues4[4], uniqueValues4[5], uniqueValues4[6], uniqueValues4[7], + uniqueValues4[8], uniqueValues4[9], uniqueValues4[10], uniqueValues4[11], + uniqueValues4[12], uniqueValues4[13], uniqueValues4[14], uniqueValues4[15]); + QVERIFY(isSame(m8, uniqueValues4)); +} + +// Test the creation of QMatrix4x3 objects in various ways: +// construct, copy, and modify. +void tst_QMatrixNxN::create4x3() +{ + QMatrix4x3 m1; + QVERIFY(isIdentity(m1)); + QVERIFY(m1.isIdentity()); + + QMatrix4x3 m2; + setMatrix(m2, uniqueValues4x3); + QVERIFY(isSame(m2, uniqueValues4x3)); + QVERIFY(!m2.isIdentity()); + + QMatrix4x3 m3; + setMatrixDirect(m3, uniqueValues4x3); + QVERIFY(isSame(m3, uniqueValues4x3)); + + QMatrix4x3 m4(m3); + QVERIFY(isSame(m4, uniqueValues4x3)); + + QMatrix4x3 m5; + m5 = m3; + QVERIFY(isSame(m5, uniqueValues4x3)); + + m5.setIdentity(); + QVERIFY(isIdentity(m5)); + + QMatrix4x3 m6(uniqueValues4x3); + QVERIFY(isSame(m6, uniqueValues4x3)); + qreal vals[12]; + m6.toValueArray(vals); + for (int index = 0; index < 12; ++index) + QCOMPARE((float)(vals[index]), (float)(uniqueValues4x3[index])); +} + +// Test isIdentity() for 2x2 matrices. +void tst_QMatrixNxN::isIdentity2x2() +{ + for (int i = 0; i < 2 * 2; ++i) { + QMatrix2x2 m; + QVERIFY(m.isIdentity()); + m.data()[i] = 42.0f; + QVERIFY(!m.isIdentity()); + } +} + +// Test isIdentity() for 3x3 matrices. +void tst_QMatrixNxN::isIdentity3x3() +{ + for (int i = 0; i < 3 * 3; ++i) { + QMatrix3x3 m; + QVERIFY(m.isIdentity()); + m.data()[i] = 42.0f; + QVERIFY(!m.isIdentity()); + } +} + +// Test isIdentity() for 4x4 matrices. +void tst_QMatrixNxN::isIdentity4x4() +{ + for (int i = 0; i < 4 * 4; ++i) { + QMatrix4x4 m; + QVERIFY(m.isIdentity()); + m.data()[i] = 42.0f; + QVERIFY(!m.isIdentity()); + } + + // Force the "Identity" flag bit to be lost and check again. + QMatrix4x4 m2; + m2.data()[0] = 1.0f; + QVERIFY(m2.isIdentity()); +} + +// Test isIdentity() for 4x3 matrices. +void tst_QMatrixNxN::isIdentity4x3() +{ + for (int i = 0; i < 4 * 3; ++i) { + QMatrix4x3 m; + QVERIFY(m.isIdentity()); + m.data()[i] = 42.0f; + QVERIFY(!m.isIdentity()); + } +} + +// Test 2x2 matrix comparisons. +void tst_QMatrixNxN::compare2x2() +{ + QMatrix2x2 m1(uniqueValues2); + QMatrix2x2 m2(uniqueValues2); + QMatrix2x2 m3(transposedValues2); + + QVERIFY(m1 == m2); + QVERIFY(!(m1 != m2)); + QVERIFY(m1 != m3); + QVERIFY(!(m1 == m3)); +} + +// Test 3x3 matrix comparisons. +void tst_QMatrixNxN::compare3x3() +{ + QMatrix3x3 m1(uniqueValues3); + QMatrix3x3 m2(uniqueValues3); + QMatrix3x3 m3(transposedValues3); + + QVERIFY(m1 == m2); + QVERIFY(!(m1 != m2)); + QVERIFY(m1 != m3); + QVERIFY(!(m1 == m3)); +} + +// Test 4x4 matrix comparisons. +void tst_QMatrixNxN::compare4x4() +{ + QMatrix4x4 m1(uniqueValues4); + QMatrix4x4 m2(uniqueValues4); + QMatrix4x4 m3(transposedValues4); + + QVERIFY(m1 == m2); + QVERIFY(!(m1 != m2)); + QVERIFY(m1 != m3); + QVERIFY(!(m1 == m3)); +} + +// Test 4x3 matrix comparisons. +void tst_QMatrixNxN::compare4x3() +{ + QMatrix4x3 m1(uniqueValues4x3); + QMatrix4x3 m2(uniqueValues4x3); + QMatrix4x3 m3(transposedValues3x4); + + QVERIFY(m1 == m2); + QVERIFY(!(m1 != m2)); + QVERIFY(m1 != m3); + QVERIFY(!(m1 == m3)); +} + +// Test matrix 2x2 transpose operations. +void tst_QMatrixNxN::transposed2x2() +{ + // Transposing the identity should result in the identity. + QMatrix2x2 m1; + QMatrix2x2 m2 = m1.transposed(); + QVERIFY(isIdentity(m2)); + + // Transpose a more interesting matrix that allows us to track + // exactly where each source element ends up. + QMatrix2x2 m3(uniqueValues2); + QMatrix2x2 m4 = m3.transposed(); + QVERIFY(isSame(m4, transposedValues2)); + + // Transpose in-place, just to check that the compiler is sane. + m3 = m3.transposed(); + QVERIFY(isSame(m3, transposedValues2)); +} + +// Test matrix 3x3 transpose operations. +void tst_QMatrixNxN::transposed3x3() +{ + // Transposing the identity should result in the identity. + QMatrix3x3 m1; + QMatrix3x3 m2 = m1.transposed(); + QVERIFY(isIdentity(m2)); + + // Transpose a more interesting matrix that allows us to track + // exactly where each source element ends up. + QMatrix3x3 m3(uniqueValues3); + QMatrix3x3 m4 = m3.transposed(); + QVERIFY(isSame(m4, transposedValues3)); + + // Transpose in-place, just to check that the compiler is sane. + m3 = m3.transposed(); + QVERIFY(isSame(m3, transposedValues3)); +} + +// Test matrix 4x4 transpose operations. +void tst_QMatrixNxN::transposed4x4() +{ + // Transposing the identity should result in the identity. + QMatrix4x4 m1; + QMatrix4x4 m2 = m1.transposed(); + QVERIFY(isIdentity(m2)); + + // Transpose a more interesting matrix that allows us to track + // exactly where each source element ends up. + QMatrix4x4 m3(uniqueValues4); + QMatrix4x4 m4 = m3.transposed(); + QVERIFY(isSame(m4, transposedValues4)); + + // Transpose in-place, just to check that the compiler is sane. + m3 = m3.transposed(); + QVERIFY(isSame(m3, transposedValues4)); +} + +// Test matrix 4x3 transpose operations. +void tst_QMatrixNxN::transposed4x3() +{ + QMatrix4x3 m3(uniqueValues4x3); + QMatrix3x4 m4 = m3.transposed(); + qreal values[12]; + m4.toValueArray(values); + for (int index = 0; index < 12; ++index) + QCOMPARE(values[index], transposedValues3x4[index]); +} + +// Test matrix addition for 2x2 matrices. +void tst_QMatrixNxN::add2x2_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("m2Values"); + QTest::addColumn("m3Values"); + + QTest::newRow("null") + << (void *)nullValues2 << (void *)nullValues2 << (void *)nullValues2; + + QTest::newRow("identity/null") + << (void *)identityValues2 << (void *)nullValues2 << (void *)identityValues2; + + QTest::newRow("identity/identity") + << (void *)identityValues2 << (void *)identityValues2 << (void *)doubleIdentity2; + + static qreal const sumValues[16] = + {2.0f, 7.0f, + 7.0f, 12.0f}; + QTest::newRow("unique") + << (void *)uniqueValues2 << (void *)transposedValues2 << (void *)sumValues; +} +void tst_QMatrixNxN::add2x2() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix2x2 m1((const qreal *)m1Values); + QMatrix2x2 m2((const qreal *)m2Values); + + QMatrix2x2 m4(m1); + m4 += m2; + QVERIFY(isSame(m4, (const qreal *)m3Values)); + + QMatrix2x2 m5; + m5 = m1 + m2; + QVERIFY(isSame(m5, (const qreal *)m3Values)); +} + +// Test matrix addition for 3x3 matrices. +void tst_QMatrixNxN::add3x3_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("m2Values"); + QTest::addColumn("m3Values"); + + QTest::newRow("null") + << (void *)nullValues3 << (void *)nullValues3 << (void *)nullValues3; + + QTest::newRow("identity/null") + << (void *)identityValues3 << (void *)nullValues3 << (void *)identityValues3; + + QTest::newRow("identity/identity") + << (void *)identityValues3 << (void *)identityValues3 << (void *)doubleIdentity3; + + static qreal const sumValues[16] = + {2.0f, 7.0f, 12.0f, + 7.0f, 12.0f, 17.0f, + 12.0f, 17.0f, 22.0f}; + QTest::newRow("unique") + << (void *)uniqueValues3 << (void *)transposedValues3 << (void *)sumValues; +} +void tst_QMatrixNxN::add3x3() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix3x3 m1((const qreal *)m1Values); + QMatrix3x3 m2((const qreal *)m2Values); + + QMatrix3x3 m4(m1); + m4 += m2; + QVERIFY(isSame(m4, (const qreal *)m3Values)); + + QMatrix3x3 m5; + m5 = m1 + m2; + QVERIFY(isSame(m5, (const qreal *)m3Values)); +} + +// Test matrix addition for 4x4 matrices. +void tst_QMatrixNxN::add4x4_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("m2Values"); + QTest::addColumn("m3Values"); + + QTest::newRow("null") + << (void *)nullValues4 << (void *)nullValues4 << (void *)nullValues4; + + QTest::newRow("identity/null") + << (void *)identityValues4 << (void *)nullValues4 << (void *)identityValues4; + + QTest::newRow("identity/identity") + << (void *)identityValues4 << (void *)identityValues4 << (void *)doubleIdentity4; + + static qreal const sumValues[16] = + {2.0f, 7.0f, 12.0f, 17.0f, + 7.0f, 12.0f, 17.0f, 22.0f, + 12.0f, 17.0f, 22.0f, 27.0f, + 17.0f, 22.0f, 27.0f, 32.0f}; + QTest::newRow("unique") + << (void *)uniqueValues4 << (void *)transposedValues4 << (void *)sumValues; +} +void tst_QMatrixNxN::add4x4() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix4x4 m1((const qreal *)m1Values); + QMatrix4x4 m2((const qreal *)m2Values); + + QMatrix4x4 m4(m1); + m4 += m2; + QVERIFY(isSame(m4, (const qreal *)m3Values)); + + QMatrix4x4 m5; + m5 = m1 + m2; + QVERIFY(isSame(m5, (const qreal *)m3Values)); +} + +// Test matrix addition for 4x3 matrices. +void tst_QMatrixNxN::add4x3_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("m2Values"); + QTest::addColumn("m3Values"); + + QTest::newRow("null") + << (void *)nullValues4x3 << (void *)nullValues4x3 << (void *)nullValues4x3; + + QTest::newRow("identity/null") + << (void *)identityValues4x3 << (void *)nullValues4x3 << (void *)identityValues4x3; + + QTest::newRow("identity/identity") + << (void *)identityValues4x3 << (void *)identityValues4x3 << (void *)doubleIdentity4x3; + + static qreal const sumValues[16] = + {2.0f, 7.0f, 12.0f, 6.0f, + 11.0f, 16.0f, 10.0f, 15.0f, + 20.0f, 14.0f, 19.0f, 24.0f}; + QTest::newRow("unique") + << (void *)uniqueValues4x3 << (void *)transposedValues3x4 << (void *)sumValues; +} +void tst_QMatrixNxN::add4x3() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix4x3 m1((const qreal *)m1Values); + QMatrix4x3 m2((const qreal *)m2Values); + + QMatrix4x3 m4(m1); + m4 += m2; + QVERIFY(isSame(m4, (const qreal *)m3Values)); + + QMatrix4x3 m5; + m5 = m1 + m2; + QVERIFY(isSame(m5, (const qreal *)m3Values)); +} + +// Test matrix subtraction for 2x2 matrices. +void tst_QMatrixNxN::subtract2x2_data() +{ + // Use the same test cases as the add test. + add2x2_data(); +} +void tst_QMatrixNxN::subtract2x2() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix2x2 m1((const qreal *)m1Values); + QMatrix2x2 m2((const qreal *)m2Values); + QMatrix2x2 m3((const qreal *)m3Values); + + QMatrix2x2 m4(m3); + m4 -= m1; + QVERIFY(isSame(m4, (const qreal *)m2Values)); + + QMatrix2x2 m5; + m5 = m3 - m1; + QVERIFY(isSame(m5, (const qreal *)m2Values)); + + QMatrix2x2 m6(m3); + m6 -= m2; + QVERIFY(isSame(m6, (const qreal *)m1Values)); + + QMatrix2x2 m7; + m7 = m3 - m2; + QVERIFY(isSame(m7, (const qreal *)m1Values)); +} + +// Test matrix subtraction for 3x3 matrices. +void tst_QMatrixNxN::subtract3x3_data() +{ + // Use the same test cases as the add test. + add3x3_data(); +} +void tst_QMatrixNxN::subtract3x3() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix3x3 m1((const qreal *)m1Values); + QMatrix3x3 m2((const qreal *)m2Values); + QMatrix3x3 m3((const qreal *)m3Values); + + QMatrix3x3 m4(m3); + m4 -= m1; + QVERIFY(isSame(m4, (const qreal *)m2Values)); + + QMatrix3x3 m5; + m5 = m3 - m1; + QVERIFY(isSame(m5, (const qreal *)m2Values)); + + QMatrix3x3 m6(m3); + m6 -= m2; + QVERIFY(isSame(m6, (const qreal *)m1Values)); + + QMatrix3x3 m7; + m7 = m3 - m2; + QVERIFY(isSame(m7, (const qreal *)m1Values)); +} + +// Test matrix subtraction for 4x4 matrices. +void tst_QMatrixNxN::subtract4x4_data() +{ + // Use the same test cases as the add test. + add4x4_data(); +} +void tst_QMatrixNxN::subtract4x4() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix4x4 m1((const qreal *)m1Values); + QMatrix4x4 m2((const qreal *)m2Values); + QMatrix4x4 m3((const qreal *)m3Values); + + QMatrix4x4 m4(m3); + m4 -= m1; + QVERIFY(isSame(m4, (const qreal *)m2Values)); + + QMatrix4x4 m5; + m5 = m3 - m1; + QVERIFY(isSame(m5, (const qreal *)m2Values)); + + QMatrix4x4 m6(m3); + m6 -= m2; + QVERIFY(isSame(m6, (const qreal *)m1Values)); + + QMatrix4x4 m7; + m7 = m3 - m2; + QVERIFY(isSame(m7, (const qreal *)m1Values)); +} + +// Test matrix subtraction for 4x3 matrices. +void tst_QMatrixNxN::subtract4x3_data() +{ + // Use the same test cases as the add test. + add4x3_data(); +} +void tst_QMatrixNxN::subtract4x3() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix4x3 m1((const qreal *)m1Values); + QMatrix4x3 m2((const qreal *)m2Values); + QMatrix4x3 m3((const qreal *)m3Values); + + QMatrix4x3 m4(m3); + m4 -= m1; + QVERIFY(isSame(m4, (const qreal *)m2Values)); + + QMatrix4x3 m5; + m5 = m3 - m1; + QVERIFY(isSame(m5, (const qreal *)m2Values)); + + QMatrix4x3 m6(m3); + m6 -= m2; + QVERIFY(isSame(m6, (const qreal *)m1Values)); + + QMatrix4x3 m7; + m7 = m3 - m2; + QVERIFY(isSame(m7, (const qreal *)m1Values)); +} + +// Test matrix multiplication for 2x2 matrices. +void tst_QMatrixNxN::multiply2x2_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("m2Values"); + QTest::addColumn("m3Values"); + + QTest::newRow("null") + << (void *)nullValues2 << (void *)nullValues2 << (void *)nullValues2; + + QTest::newRow("null/unique") + << (void *)nullValues2 << (void *)uniqueValues2 << (void *)nullValues2; + + QTest::newRow("unique/null") + << (void *)uniqueValues2 << (void *)nullValues2 << (void *)nullValues2; + + QTest::newRow("unique/identity") + << (void *)uniqueValues2 << (void *)identityValues2 << (void *)uniqueValues2; + + QTest::newRow("identity/unique") + << (void *)identityValues2 << (void *)uniqueValues2 << (void *)uniqueValues2; + + static qreal uniqueResult[4]; + for (int row = 0; row < 2; ++row) { + for (int col = 0; col < 2; ++col) { + qreal sum = 0.0f; + for (int j = 0; j < 2; ++j) + sum += uniqueValues2[row * 2 + j] * transposedValues2[j * 2 + col]; + uniqueResult[row * 2 + col] = sum; + } + } + + QTest::newRow("unique/transposed") + << (void *)uniqueValues2 << (void *)transposedValues2 << (void *)uniqueResult; +} +void tst_QMatrixNxN::multiply2x2() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix2x2 m1((const qreal *)m1Values); + QMatrix2x2 m2((const qreal *)m2Values); + + QMatrix2x2 m5; + m5 = m1 * m2; + QVERIFY(isSame(m5, (const qreal *)m3Values)); +} + +// Test matrix multiplication for 3x3 matrices. +void tst_QMatrixNxN::multiply3x3_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("m2Values"); + QTest::addColumn("m3Values"); + + QTest::newRow("null") + << (void *)nullValues3 << (void *)nullValues3 << (void *)nullValues3; + + QTest::newRow("null/unique") + << (void *)nullValues3 << (void *)uniqueValues3 << (void *)nullValues3; + + QTest::newRow("unique/null") + << (void *)uniqueValues3 << (void *)nullValues3 << (void *)nullValues3; + + QTest::newRow("unique/identity") + << (void *)uniqueValues3 << (void *)identityValues3 << (void *)uniqueValues3; + + QTest::newRow("identity/unique") + << (void *)identityValues3 << (void *)uniqueValues3 << (void *)uniqueValues3; + + static qreal uniqueResult[9]; + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) { + qreal sum = 0.0f; + for (int j = 0; j < 3; ++j) + sum += uniqueValues3[row * 3 + j] * transposedValues3[j * 3 + col]; + uniqueResult[row * 3 + col] = sum; + } + } + + QTest::newRow("unique/transposed") + << (void *)uniqueValues3 << (void *)transposedValues3 << (void *)uniqueResult; +} +void tst_QMatrixNxN::multiply3x3() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix3x3 m1((const qreal *)m1Values); + QMatrix3x3 m2((const qreal *)m2Values); + + QMatrix3x3 m5; + m5 = m1 * m2; + QVERIFY(isSame(m5, (const qreal *)m3Values)); +} + +// Test matrix multiplication for 4x4 matrices. +void tst_QMatrixNxN::multiply4x4_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("m2Values"); + QTest::addColumn("m3Values"); + + QTest::newRow("null") + << (void *)nullValues4 << (void *)nullValues4 << (void *)nullValues4; + + QTest::newRow("null/unique") + << (void *)nullValues4 << (void *)uniqueValues4 << (void *)nullValues4; + + QTest::newRow("unique/null") + << (void *)uniqueValues4 << (void *)nullValues4 << (void *)nullValues4; + + QTest::newRow("unique/identity") + << (void *)uniqueValues4 << (void *)identityValues4 << (void *)uniqueValues4; + + QTest::newRow("identity/unique") + << (void *)identityValues4 << (void *)uniqueValues4 << (void *)uniqueValues4; + + static qreal uniqueResult[16]; + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) { + qreal sum = 0.0f; + for (int j = 0; j < 4; ++j) + sum += uniqueValues4[row * 4 + j] * transposedValues4[j * 4 + col]; + uniqueResult[row * 4 + col] = sum; + } + } + + QTest::newRow("unique/transposed") + << (void *)uniqueValues4 << (void *)transposedValues4 << (void *)uniqueResult; +} +void tst_QMatrixNxN::multiply4x4() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix4x4 m1((const qreal *)m1Values); + QMatrix4x4 m2((const qreal *)m2Values); + + QMatrix4x4 m4; + m4 = m1; + m4 *= m2; + QVERIFY(isSame(m4, (const qreal *)m3Values)); + + QMatrix4x4 m5; + m5 = m1 * m2; + QVERIFY(isSame(m5, (const qreal *)m3Values)); +} + +// Test matrix multiplication for 4x3 matrices. +void tst_QMatrixNxN::multiply4x3_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("m2Values"); + QTest::addColumn("m3Values"); + + QTest::newRow("null") + << (void *)nullValues4x3 << (void *)nullValues4x3 << (void *)nullValues3; + + QTest::newRow("null/unique") + << (void *)nullValues4x3 << (void *)uniqueValues4x3 << (void *)nullValues3; + + QTest::newRow("unique/null") + << (void *)uniqueValues4x3 << (void *)nullValues4x3 << (void *)nullValues3; + + static qreal uniqueResult[9]; + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) { + qreal sum = 0.0f; + for (int j = 0; j < 4; ++j) + sum += uniqueValues4x3[row * 4 + j] * transposedValues3x4[j * 3 + col]; + uniqueResult[row * 3 + col] = sum; + } + } + + QTest::newRow("unique/transposed") + << (void *)uniqueValues4x3 << (void *)transposedValues3x4 << (void *)uniqueResult; +} +void tst_QMatrixNxN::multiply4x3() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(void *, m3Values); + + QMatrix4x3 m1((const qreal *)m1Values); + QMatrix3x4 m2((const qreal *)m2Values); + + QGenericMatrix<3, 3, qreal, float> m4; + m4 = m1 * m2; + qreal values[9]; + m4.toValueArray(values); + for (int index = 0; index < 9; ++index) + QCOMPARE(values[index], ((const qreal *)m3Values)[index]); +} + +// Test matrix multiplication by a factor for 2x2 matrices. +void tst_QMatrixNxN::multiplyFactor2x2_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("factor"); + QTest::addColumn("m2Values"); + + QTest::newRow("null") + << (void *)nullValues2 << (qreal)1.0f << (void *)nullValues2; + + QTest::newRow("double identity") + << (void *)identityValues2 << (qreal)2.0f << (void *)doubleIdentity2; + + static qreal const values[16] = + {1.0f, 2.0f, + 5.0f, 6.0f}; + static qreal const doubleValues[16] = + {2.0f, 4.0f, + 10.0f, 12.0f}; + static qreal const negDoubleValues[16] = + {-2.0f, -4.0f, + -10.0f, -12.0f}; + + QTest::newRow("unique") + << (void *)values << (qreal)2.0f << (void *)doubleValues; + + QTest::newRow("neg") + << (void *)values << (qreal)-2.0f << (void *)negDoubleValues; + + QTest::newRow("zero") + << (void *)values << (qreal)0.0f << (void *)nullValues4; +} +void tst_QMatrixNxN::multiplyFactor2x2() +{ + QFETCH(void *, m1Values); + QFETCH(qreal, factor); + QFETCH(void *, m2Values); + + QMatrix2x2 m1((const qreal *)m1Values); + + QMatrix2x2 m3; + m3 = m1; + m3 *= factor; + QVERIFY(isSame(m3, (const qreal *)m2Values)); + + QMatrix2x2 m4; + m4 = m1 * factor; + QVERIFY(isSame(m4, (const qreal *)m2Values)); + + QMatrix2x2 m5; + m5 = factor * m1; + QVERIFY(isSame(m5, (const qreal *)m2Values)); +} + +// Test matrix multiplication by a factor for 3x3 matrices. +void tst_QMatrixNxN::multiplyFactor3x3_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("factor"); + QTest::addColumn("m2Values"); + + QTest::newRow("null") + << (void *)nullValues3 << (qreal)1.0f << (void *)nullValues3; + + QTest::newRow("double identity") + << (void *)identityValues3 << (qreal)2.0f << (void *)doubleIdentity3; + + static qreal const values[16] = + {1.0f, 2.0f, 3.0f, + 5.0f, 6.0f, 7.0f, + 9.0f, 10.0f, 11.0f}; + static qreal const doubleValues[16] = + {2.0f, 4.0f, 6.0f, + 10.0f, 12.0f, 14.0f, + 18.0f, 20.0f, 22.0f}; + static qreal const negDoubleValues[16] = + {-2.0f, -4.0f, -6.0f, + -10.0f, -12.0f, -14.0f, + -18.0f, -20.0f, -22.0f}; + + QTest::newRow("unique") + << (void *)values << (qreal)2.0f << (void *)doubleValues; + + QTest::newRow("neg") + << (void *)values << (qreal)-2.0f << (void *)negDoubleValues; + + QTest::newRow("zero") + << (void *)values << (qreal)0.0f << (void *)nullValues4; +} +void tst_QMatrixNxN::multiplyFactor3x3() +{ + QFETCH(void *, m1Values); + QFETCH(qreal, factor); + QFETCH(void *, m2Values); + + QMatrix3x3 m1((const qreal *)m1Values); + + QMatrix3x3 m3; + m3 = m1; + m3 *= factor; + QVERIFY(isSame(m3, (const qreal *)m2Values)); + + QMatrix3x3 m4; + m4 = m1 * factor; + QVERIFY(isSame(m4, (const qreal *)m2Values)); + + QMatrix3x3 m5; + m5 = factor * m1; + QVERIFY(isSame(m5, (const qreal *)m2Values)); +} + +// Test matrix multiplication by a factor for 4x4 matrices. +void tst_QMatrixNxN::multiplyFactor4x4_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("factor"); + QTest::addColumn("m2Values"); + + QTest::newRow("null") + << (void *)nullValues4 << (qreal)1.0f << (void *)nullValues4; + + QTest::newRow("double identity") + << (void *)identityValues4 << (qreal)2.0f << (void *)doubleIdentity4; + + static qreal const values[16] = + {1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + static qreal const doubleValues[16] = + {2.0f, 4.0f, 6.0f, 8.0f, + 10.0f, 12.0f, 14.0f, 16.0f, + 18.0f, 20.0f, 22.0f, 24.0f, + 26.0f, 28.0f, 30.0f, 32.0f}; + static qreal const negDoubleValues[16] = + {-2.0f, -4.0f, -6.0f, -8.0f, + -10.0f, -12.0f, -14.0f, -16.0f, + -18.0f, -20.0f, -22.0f, -24.0f, + -26.0f, -28.0f, -30.0f, -32.0f}; + + QTest::newRow("unique") + << (void *)values << (qreal)2.0f << (void *)doubleValues; + + QTest::newRow("neg") + << (void *)values << (qreal)-2.0f << (void *)negDoubleValues; + + QTest::newRow("zero") + << (void *)values << (qreal)0.0f << (void *)nullValues4; +} +void tst_QMatrixNxN::multiplyFactor4x4() +{ + QFETCH(void *, m1Values); + QFETCH(qreal, factor); + QFETCH(void *, m2Values); + + QMatrix4x4 m1((const qreal *)m1Values); + + QMatrix4x4 m3; + m3 = m1; + m3 *= factor; + QVERIFY(isSame(m3, (const qreal *)m2Values)); + + QMatrix4x4 m4; + m4 = m1 * factor; + QVERIFY(isSame(m4, (const qreal *)m2Values)); + + QMatrix4x4 m5; + m5 = factor * m1; + QVERIFY(isSame(m5, (const qreal *)m2Values)); +} + +// Test matrix multiplication by a factor for 4x3 matrices. +void tst_QMatrixNxN::multiplyFactor4x3_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("factor"); + QTest::addColumn("m2Values"); + + QTest::newRow("null") + << (void *)nullValues4x3 << (qreal)1.0f << (void *)nullValues4x3; + + QTest::newRow("double identity") + << (void *)identityValues4x3 << (qreal)2.0f << (void *)doubleIdentity4x3; + + static qreal const values[12] = + {1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f}; + static qreal const doubleValues[12] = + {2.0f, 4.0f, 6.0f, 8.0f, + 10.0f, 12.0f, 14.0f, 16.0f, + 18.0f, 20.0f, 22.0f, 24.0f}; + static qreal const negDoubleValues[12] = + {-2.0f, -4.0f, -6.0f, -8.0f, + -10.0f, -12.0f, -14.0f, -16.0f, + -18.0f, -20.0f, -22.0f, -24.0f}; + + QTest::newRow("unique") + << (void *)values << (qreal)2.0f << (void *)doubleValues; + + QTest::newRow("neg") + << (void *)values << (qreal)-2.0f << (void *)negDoubleValues; + + QTest::newRow("zero") + << (void *)values << (qreal)0.0f << (void *)nullValues4x3; +} +void tst_QMatrixNxN::multiplyFactor4x3() +{ + QFETCH(void *, m1Values); + QFETCH(qreal, factor); + QFETCH(void *, m2Values); + + QMatrix4x3 m1((const qreal *)m1Values); + + QMatrix4x3 m3; + m3 = m1; + m3 *= factor; + QVERIFY(isSame(m3, (const qreal *)m2Values)); + + QMatrix4x3 m4; + m4 = m1 * factor; + QVERIFY(isSame(m4, (const qreal *)m2Values)); + + QMatrix4x3 m5; + m5 = factor * m1; + QVERIFY(isSame(m5, (const qreal *)m2Values)); +} + +// Test matrix division by a factor for 2x2 matrices. +void tst_QMatrixNxN::divideFactor2x2_data() +{ + // Use the same test cases as the multiplyFactor test. + multiplyFactor2x2_data(); +} +void tst_QMatrixNxN::divideFactor2x2() +{ + QFETCH(void *, m1Values); + QFETCH(qreal, factor); + QFETCH(void *, m2Values); + + if (factor == 0.0f) + return; + + QMatrix2x2 m2((const qreal *)m2Values); + + QMatrix2x2 m3; + m3 = m2; + m3 /= factor; + QVERIFY(isSame(m3, (const qreal *)m1Values)); + + QMatrix2x2 m4; + m4 = m2 / factor; + QVERIFY(isSame(m4, (const qreal *)m1Values)); +} + +// Test matrix division by a factor for 3x3 matrices. +void tst_QMatrixNxN::divideFactor3x3_data() +{ + // Use the same test cases as the multiplyFactor test. + multiplyFactor3x3_data(); +} +void tst_QMatrixNxN::divideFactor3x3() +{ + QFETCH(void *, m1Values); + QFETCH(qreal, factor); + QFETCH(void *, m2Values); + + if (factor == 0.0f) + return; + + QMatrix3x3 m2((const qreal *)m2Values); + + QMatrix3x3 m3; + m3 = m2; + m3 /= factor; + QVERIFY(isSame(m3, (const qreal *)m1Values)); + + QMatrix3x3 m4; + m4 = m2 / factor; + QVERIFY(isSame(m4, (const qreal *)m1Values)); +} + +// Test matrix division by a factor for 4x4 matrices. +void tst_QMatrixNxN::divideFactor4x4_data() +{ + // Use the same test cases as the multiplyFactor test. + multiplyFactor4x4_data(); +} +void tst_QMatrixNxN::divideFactor4x4() +{ + QFETCH(void *, m1Values); + QFETCH(qreal, factor); + QFETCH(void *, m2Values); + + if (factor == 0.0f) + return; + + QMatrix4x4 m2((const qreal *)m2Values); + + QMatrix4x4 m3; + m3 = m2; + m3 /= factor; + QVERIFY(isSame(m3, (const qreal *)m1Values)); + + QMatrix4x4 m4; + m4 = m2 / factor; + QVERIFY(isSame(m4, (const qreal *)m1Values)); +} + +// Test matrix division by a factor for 4x3 matrices. +void tst_QMatrixNxN::divideFactor4x3_data() +{ + // Use the same test cases as the multiplyFactor test. + multiplyFactor4x3_data(); +} +void tst_QMatrixNxN::divideFactor4x3() +{ + QFETCH(void *, m1Values); + QFETCH(qreal, factor); + QFETCH(void *, m2Values); + + if (factor == 0.0f) + return; + + QMatrix4x3 m2((const qreal *)m2Values); + + QMatrix4x3 m3; + m3 = m2; + m3 /= factor; + QVERIFY(isSame(m3, (const qreal *)m1Values)); + + QMatrix4x3 m4; + m4 = m2 / factor; + QVERIFY(isSame(m4, (const qreal *)m1Values)); +} + +// Test matrix negation for 2x2 matrices. +void tst_QMatrixNxN::negate2x2_data() +{ + // Use the same test cases as the multiplyFactor test. + multiplyFactor2x2_data(); +} +void tst_QMatrixNxN::negate2x2() +{ + QFETCH(void *, m1Values); + + const qreal *values = (const qreal *)m1Values; + + QMatrix2x2 m1(values); + + qreal negated[4]; + for (int index = 0; index < 4; ++index) + negated[index] = -values[index]; + + QMatrix2x2 m2; + m2 = -m1; + QVERIFY(isSame(m2, negated)); +} + +// Test matrix negation for 3x3 matrices. +void tst_QMatrixNxN::negate3x3_data() +{ + // Use the same test cases as the multiplyFactor test. + multiplyFactor3x3_data(); +} +void tst_QMatrixNxN::negate3x3() +{ + QFETCH(void *, m1Values); + + const qreal *values = (const qreal *)m1Values; + + QMatrix3x3 m1(values); + + qreal negated[9]; + for (int index = 0; index < 9; ++index) + negated[index] = -values[index]; + + QMatrix3x3 m2; + m2 = -m1; + QVERIFY(isSame(m2, negated)); +} + +// Test matrix negation for 4x4 matrices. +void tst_QMatrixNxN::negate4x4_data() +{ + // Use the same test cases as the multiplyFactor test. + multiplyFactor4x4_data(); +} +void tst_QMatrixNxN::negate4x4() +{ + QFETCH(void *, m1Values); + + const qreal *values = (const qreal *)m1Values; + + QMatrix4x4 m1(values); + + qreal negated[16]; + for (int index = 0; index < 16; ++index) + negated[index] = -values[index]; + + QMatrix4x4 m2; + m2 = -m1; + QVERIFY(isSame(m2, negated)); +} + +// Test matrix negation for 4x3 matrices. +void tst_QMatrixNxN::negate4x3_data() +{ + // Use the same test cases as the multiplyFactor test. + multiplyFactor4x3_data(); +} +void tst_QMatrixNxN::negate4x3() +{ + QFETCH(void *, m1Values); + + const qreal *values = (const qreal *)m1Values; + + QMatrix4x3 m1(values); + + qreal negated[12]; + for (int index = 0; index < 12; ++index) + negated[index] = -values[index]; + + QMatrix4x3 m2; + m2 = -m1; + QVERIFY(isSame(m2, negated)); +} + +// Matrix inverted. This is a more straight-forward implementation +// of the algorithm at http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q24 +// than the optimized version in the QMatrix4x4 code. Hopefully it is +// easier to verify that this version is the same as the reference. + +struct Matrix3 +{ + qreal v[9]; +}; +struct Matrix4 +{ + qreal v[16]; +}; + +static qreal m3Determinant(const Matrix3& m) +{ + return m.v[0] * (m.v[4] * m.v[8] - m.v[7] * m.v[5]) - + m.v[1] * (m.v[3] * m.v[8] - m.v[6] * m.v[5]) + + m.v[2] * (m.v[3] * m.v[7] - m.v[6] * m.v[4]); +} + +static bool m3Inverse(const Matrix3& min, Matrix3& mout) +{ + qreal det = m3Determinant(min); + if (det == 0.0f) + return false; + mout.v[0] = (min.v[4] * min.v[8] - min.v[5] * min.v[7]) / det; + mout.v[1] = -(min.v[1] * min.v[8] - min.v[2] * min.v[7]) / det; + mout.v[2] = (min.v[1] * min.v[5] - min.v[4] * min.v[2]) / det; + mout.v[3] = -(min.v[3] * min.v[8] - min.v[5] * min.v[6]) / det; + mout.v[4] = (min.v[0] * min.v[8] - min.v[6] * min.v[2]) / det; + mout.v[5] = -(min.v[0] * min.v[5] - min.v[3] * min.v[2]) / det; + mout.v[6] = (min.v[3] * min.v[7] - min.v[6] * min.v[4]) / det; + mout.v[7] = -(min.v[0] * min.v[7] - min.v[6] * min.v[1]) / det; + mout.v[8] = (min.v[0] * min.v[4] - min.v[1] * min.v[3]) / det; + return true; +} + +static void m3Transpose(Matrix3& m) +{ + qSwap(m.v[1], m.v[3]); + qSwap(m.v[2], m.v[6]); + qSwap(m.v[5], m.v[7]); +} + +static void m4Submatrix(const Matrix4& min, Matrix3& mout, int i, int j) +{ + for (int di = 0; di < 3; ++di) { + for (int dj = 0; dj < 3; ++dj) { + int si = di + ((di >= i) ? 1 : 0); + int sj = dj + ((dj >= j) ? 1 : 0); + mout.v[di * 3 + dj] = min.v[si * 4 + sj]; + } + } +} + +static qreal m4Determinant(const Matrix4& m) +{ + qreal det; + qreal result = 0.0f; + qreal i = 1.0f; + Matrix3 msub; + for (int n = 0; n < 4; ++n, i *= -1.0f) { + m4Submatrix(m, msub, 0, n); + det = m3Determinant(msub); + result += m.v[n] * det * i; + } + return result; +} + +static void m4Inverse(const Matrix4& min, Matrix4& mout) +{ + qreal det = m4Determinant(min); + Matrix3 msub; + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 4; ++j) { + qreal sign = 1.0f - ((i + j) % 2) * 2.0f; + m4Submatrix(min, msub, i, j); + mout.v[i + j * 4] = (m3Determinant(msub) * sign) / det; + } + } +} + +// Test matrix inverted for 4x4 matrices. +void tst_QMatrixNxN::inverted4x4_data() +{ + QTest::addColumn("m1Values"); + QTest::addColumn("m2Values"); + QTest::addColumn("invertible"); + + QTest::newRow("null") + << (void *)nullValues4 << (void *)identityValues4 << false; + + QTest::newRow("identity") + << (void *)identityValues4 << (void *)identityValues4 << true; + + QTest::newRow("unique") + << (void *)uniqueValues4 << (void *)identityValues4 << false; + + static Matrix4 const invertible = { + {5.0f, 0.0f, 0.0f, 2.0f, + 0.0f, 6.0f, 0.0f, 3.0f, + 0.0f, 0.0f, 7.0f, 4.0f, + 0.0f, 0.0f, 0.0f, 1.0f} + }; + static Matrix4 inverted; + m4Inverse(invertible, inverted); + + QTest::newRow("invertible") + << (void *)invertible.v << (void *)inverted.v << true; + + static Matrix4 const translate = { + {1.0f, 0.0f, 0.0f, 2.0f, + 0.0f, 1.0f, 0.0f, 3.0f, + 0.0f, 0.0f, 1.0f, 4.0f, + 0.0f, 0.0f, 0.0f, 1.0f} + }; + static Matrix4 const inverseTranslate = { + {1.0f, 0.0f, 0.0f, -2.0f, + 0.0f, 1.0f, 0.0f, -3.0f, + 0.0f, 0.0f, 1.0f, -4.0f, + 0.0f, 0.0f, 0.0f, 1.0f} + }; + + QTest::newRow("translate") + << (void *)translate.v << (void *)inverseTranslate.v << true; +} +void tst_QMatrixNxN::inverted4x4() +{ + QFETCH(void *, m1Values); + QFETCH(void *, m2Values); + QFETCH(bool, invertible); + + QMatrix4x4 m1((const qreal *)m1Values); + + if (invertible) + QVERIFY(m1.determinant() != 0.0f); + else + QVERIFY(m1.determinant() == 0.0f); + + Matrix4 m1alt; + memcpy(m1alt.v, (const qreal *)m1Values, sizeof(m1alt.v)); + + QCOMPARE((float)(m1.determinant()), (float)(m4Determinant(m1alt))); + + QMatrix4x4 m2; + bool inv; + m2 = m1.inverted(&inv); + QVERIFY(isSame(m2, (const qreal *)m2Values)); + + if (invertible) { + QVERIFY(inv); + + Matrix4 m2alt; + m4Inverse(m1alt, m2alt); + QVERIFY(isSame(m2, m2alt.v)); + + QMatrix4x4 m3; + m3 = m1 * m2; + QVERIFY(isIdentity(m3)); + + QMatrix4x4 m4; + m4 = m2 * m1; + QVERIFY(isIdentity(m4)); + } else { + QVERIFY(!inv); + } + + // Test again, after inferring the special matrix type. + m1.inferSpecialType(); + m2 = m1.inverted(&inv); + QVERIFY(isSame(m2, (const qreal *)m2Values)); + QCOMPARE(inv, invertible); +} + +void tst_QMatrixNxN::orthonormalInverse4x4() +{ + QMatrix4x4 m1; + QVERIFY(matrixFuzzyCompare(m1.inverted(), m1)); + + QMatrix4x4 m2; + m2.rotate(45.0, 1.0, 0.0, 0.0); + m2.translate(10.0, 0.0, 0.0); + + // Use inferSpecialType() to drop the internal flags that + // mark the matrix as orthonormal. This will force inverted() + // to compute m3.inverted() the long way. We can then compare + // the result to what the faster algorithm produces on m2. + QMatrix4x4 m3 = m2; + m3.inferSpecialType(); + bool invertible; + QVERIFY(matrixFuzzyCompare(m2.inverted(&invertible), m3.inverted())); + QVERIFY(invertible); + + QMatrix4x4 m4; + m4.rotate(45.0, 0.0, 1.0, 0.0); + QMatrix4x4 m5 = m4; + m5.inferSpecialType(); + QVERIFY(matrixFuzzyCompare(m4.inverted(), m5.inverted())); + + QMatrix4x4 m6; + m1.rotate(88, 0.0, 0.0, 1.0); + m1.translate(-20.0, 20.0, 15.0); + m1.rotate(25, 1.0, 0.0, 0.0); + QMatrix4x4 m7 = m6; + m7.inferSpecialType(); + QVERIFY(matrixFuzzyCompare(m6.inverted(), m7.inverted())); +} + +// Test the generation and use of 4x4 scale matrices. +void tst_QMatrixNxN::scale4x4_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("z"); + QTest::addColumn("resultValues"); + + static const qreal nullScale[] = + {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (void *)nullScale; + + QTest::newRow("identity") + << (qreal)1.0f << (qreal)1.0f << (qreal)1.0f << (void *)identityValues4; + + static const qreal doubleScale[] = + {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 2.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 2.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("double") + << (qreal)2.0f << (qreal)2.0f << (qreal)2.0f << (void *)doubleScale; + + static const qreal complexScale[] = + {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 11.0f, 0.0f, 0.0f, + 0.0f, 0.0f, -6.5f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("complex") + << (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexScale; + + static const qreal complexScale2D[] = + {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, -11.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("complex2D") + << (qreal)2.0f << (qreal)-11.0f << (qreal)1.0f << (void *)complexScale2D; +} +void tst_QMatrixNxN::scale4x4() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(void *, resultValues); + + QMatrix4x4 result((const qreal *)resultValues); + + QMatrix4x4 m1; + m1.scale(QVector3D(x, y, z)); + QVERIFY(isSame(m1, (const qreal *)resultValues)); + + QMatrix4x4 m2; + m2.scale(x, y, z); + QVERIFY(isSame(m2, (const qreal *)resultValues)); + + if (z == 1.0f) { + QMatrix4x4 m2b; + m2b.scale(x, y); + QVERIFY(m2b == m2); + } + + QVector3D v1(2.0f, 3.0f, -4.0f); + QVector3D v2 = m1 * v1; + QCOMPARE(v2.x(), (qreal)(2.0f * x)); + QCOMPARE(v2.y(), (qreal)(3.0f * y)); + QCOMPARE(v2.z(), (qreal)(-4.0f * z)); + + v2 = v1 * m1; + QCOMPARE(v2.x(), (qreal)(2.0f * x)); + QCOMPARE(v2.y(), (qreal)(3.0f * y)); + QCOMPARE(v2.z(), (qreal)(-4.0f * z)); + + QVector4D v3(2.0f, 3.0f, -4.0f, 34.0f); + QVector4D v4 = m1 * v3; + QCOMPARE(v4.x(), (qreal)(2.0f * x)); + QCOMPARE(v4.y(), (qreal)(3.0f * y)); + QCOMPARE(v4.z(), (qreal)(-4.0f * z)); + QCOMPARE(v4.w(), (qreal)34.0f); + + v4 = v3 * m1; + QCOMPARE(v4.x(), (qreal)(2.0f * x)); + QCOMPARE(v4.y(), (qreal)(3.0f * y)); + QCOMPARE(v4.z(), (qreal)(-4.0f * z)); + QCOMPARE(v4.w(), (qreal)34.0f); + + QPoint p1(2, 3); + QPoint p2 = m1 * p1; + QCOMPARE(p2.x(), (int)(2.0f * x)); + QCOMPARE(p2.y(), (int)(3.0f * y)); + + p2 = p1 * m1; + QCOMPARE(p2.x(), (int)(2.0f * x)); + QCOMPARE(p2.y(), (int)(3.0f * y)); + + QPointF p3(2.0f, 3.0f); + QPointF p4 = m1 * p3; + QCOMPARE(p4.x(), (qreal)(2.0f * x)); + QCOMPARE(p4.y(), (qreal)(3.0f * y)); + + p4 = p3 * m1; + QCOMPARE(p4.x(), (qreal)(2.0f * x)); + QCOMPARE(p4.y(), (qreal)(3.0f * y)); + + QMatrix4x4 m3(uniqueValues4); + QMatrix4x4 m4(m3); + m4.scale(x, y, z); + QVERIFY(m4 == m3 * m1); + + if (x == y && y == z) { + QMatrix4x4 m5; + m5.scale(x); + QVERIFY(isSame(m5, (const qreal *)resultValues)); + } + + if (z == 1.0f) { + QMatrix4x4 m4b(m3); + m4b.scale(x, y); + QVERIFY(m4b == m4); + } + + // Test coverage when the special matrix type is unknown. + + QMatrix4x4 m6; + m6(0, 0) = 1.0f; + m6.scale(QVector3D(x, y, z)); + QVERIFY(isSame(m6, (const qreal *)resultValues)); + + QMatrix4x4 m7; + m7(0, 0) = 1.0f; + m7.scale(x, y, z); + QVERIFY(isSame(m7, (const qreal *)resultValues)); + + if (x == y && y == z) { + QMatrix4x4 m8; + m8(0, 0) = 1.0f; + m8.scale(x); + QVERIFY(isSame(m8, (const qreal *)resultValues)); + + m8.inferSpecialType(); + m8.scale(1.0f); + QVERIFY(isSame(m8, (const qreal *)resultValues)); + + QMatrix4x4 m9; + m9.translate(0.0f, 0.0f, 0.0f); + m9.scale(x); + QVERIFY(isSame(m9, (const qreal *)resultValues)); + } +} + +// Test the generation and use of 4x4 translation matrices. +void tst_QMatrixNxN::translate4x4_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("z"); + QTest::addColumn("resultValues"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (void *)identityValues4; + + static const qreal identityTranslate[] = + {1.0f, 0.0f, 0.0f, 1.0f, + 0.0f, 1.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 1.0f, 1.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("identity") + << (qreal)1.0f << (qreal)1.0f << (qreal)1.0f << (void *)identityTranslate; + + static const qreal complexTranslate[] = + {1.0f, 0.0f, 0.0f, 2.0f, + 0.0f, 1.0f, 0.0f, 11.0f, + 0.0f, 0.0f, 1.0f, -6.5f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("complex") + << (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexTranslate; + + static const qreal complexTranslate2D[] = + {1.0f, 0.0f, 0.0f, 2.0f, + 0.0f, 1.0f, 0.0f, -11.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("complex2D") + << (qreal)2.0f << (qreal)-11.0f << (qreal)0.0f << (void *)complexTranslate2D; +} +void tst_QMatrixNxN::translate4x4() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(void *, resultValues); + + QMatrix4x4 result((const qreal *)resultValues); + + QMatrix4x4 m1; + m1.translate(QVector3D(x, y, z)); + QVERIFY(isSame(m1, (const qreal *)resultValues)); + + QMatrix4x4 m2; + m2.translate(x, y, z); + QVERIFY(isSame(m2, (const qreal *)resultValues)); + + if (z == 0.0f) { + QMatrix4x4 m2b; + m2b.translate(x, y); + QVERIFY(m2b == m2); + } + + QVector3D v1(2.0f, 3.0f, -4.0f); + QVector3D v2 = m1 * v1; + QCOMPARE(v2.x(), (qreal)(2.0f + x)); + QCOMPARE(v2.y(), (qreal)(3.0f + y)); + QCOMPARE(v2.z(), (qreal)(-4.0f + z)); + + QVector4D v3(2.0f, 3.0f, -4.0f, 1.0f); + QVector4D v4 = m1 * v3; + QCOMPARE(v4.x(), (qreal)(2.0f + x)); + QCOMPARE(v4.y(), (qreal)(3.0f + y)); + QCOMPARE(v4.z(), (qreal)(-4.0f + z)); + QCOMPARE(v4.w(), (qreal)1.0f); + + QVector4D v5(2.0f, 3.0f, -4.0f, 34.0f); + QVector4D v6 = m1 * v5; + QCOMPARE(v6.x(), (qreal)(2.0f + x * 34.0f)); + QCOMPARE(v6.y(), (qreal)(3.0f + y * 34.0f)); + QCOMPARE(v6.z(), (qreal)(-4.0f + z * 34.0f)); + QCOMPARE(v6.w(), (qreal)34.0f); + + QPoint p1(2, 3); + QPoint p2 = m1 * p1; + QCOMPARE(p2.x(), (int)(2.0f + x)); + QCOMPARE(p2.y(), (int)(3.0f + y)); + + QPointF p3(2.0f, 3.0f); + QPointF p4 = m1 * p3; + QCOMPARE(p4.x(), (qreal)(2.0f + x)); + QCOMPARE(p4.y(), (qreal)(3.0f + y)); + + QMatrix4x4 m3(uniqueValues4); + QMatrix4x4 m4(m3); + m4.translate(x, y, z); + QVERIFY(m4 == m3 * m1); + + if (z == 0.0f) { + QMatrix4x4 m4b(m3); + m4b.translate(x, y); + QVERIFY(m4b == m4); + } +} + +// Test the generation and use of 4x4 rotation matrices. +void tst_QMatrixNxN::rotate4x4_data() +{ + QTest::addColumn("angle"); + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("z"); + QTest::addColumn("resultValues"); + + static const qreal nullRotate[] = + {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("null") + << (qreal)90.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (void *)nullRotate; + + static const qreal noRotate[] = + {1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("zerodegrees") + << (qreal)0.0f + << (qreal)2.0f << (qreal)3.0f << (qreal)-4.0f + << (void *)noRotate; + + static const qreal xRotate[] = + {1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, -1.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("xrotate") + << (qreal)90.0f + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (void *)xRotate; + + static const qreal xRotateNeg[] = + {1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, -1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("-xrotate") + << (qreal)90.0f + << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f + << (void *)xRotateNeg; + + static const qreal yRotate[] = + {0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + -1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("yrotate") + << (qreal)90.0f + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (void *)yRotate; + + static const qreal yRotateNeg[] = + {0.0f, 0.0f, -1.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("-yrotate") + << (qreal)90.0f + << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f + << (void *)yRotateNeg; + + static const qreal zRotate[] = + {0.0f, -1.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("zrotate") + << (qreal)90.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (void *)zRotate; + + static const qreal zRotateNeg[] = + {0.0f, 1.0f, 0.0f, 0.0f, + -1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("-zrotate") + << (qreal)90.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f + << (void *)zRotateNeg; + + // Algorithm from http://en.wikipedia.org/wiki/Rotation_matrix. + // Deliberately different from the one in the code for cross-checking. + static qreal complexRotate[16]; + qreal x = 1.0f; + qreal y = 2.0f; + qreal z = -6.0f; + qreal angle = -45.0f; + qreal c = qCos(angle * M_PI / 180.0f); + qreal s = qSin(angle * M_PI / 180.0f); + qreal len = qSqrt(x * x + y * y + z * z); + qreal xu = x / len; + qreal yu = y / len; + qreal zu = z / len; + complexRotate[0] = (qreal)((1 - xu * xu) * c + xu * xu); + complexRotate[1] = (qreal)(-zu * s - xu * yu * c + xu * yu); + complexRotate[2] = (qreal)(yu * s - xu * zu * c + xu * zu); + complexRotate[3] = 0; + complexRotate[4] = (qreal)(zu * s - xu * yu * c + xu * yu); + complexRotate[5] = (qreal)((1 - yu * yu) * c + yu * yu); + complexRotate[6] = (qreal)(-xu * s - yu * zu * c + yu * zu); + complexRotate[7] = 0; + complexRotate[8] = (qreal)(-yu * s - xu * zu * c + xu * zu); + complexRotate[9] = (qreal)(xu * s - yu * zu * c + yu * zu); + complexRotate[10] = (qreal)((1 - zu * zu) * c + zu * zu); + complexRotate[11] = 0; + complexRotate[12] = 0; + complexRotate[13] = 0; + complexRotate[14] = 0; + complexRotate[15] = 1; + + QTest::newRow("complex") + << (qreal)angle + << (qreal)x << (qreal)y << (qreal)z + << (void *)complexRotate; +} +void tst_QMatrixNxN::rotate4x4() +{ + QFETCH(qreal, angle); + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(void *, resultValues); + + QMatrix4x4 m1; + m1.rotate(angle, QVector3D(x, y, z)); + QVERIFY(isSame(m1, (const qreal *)resultValues)); + + QMatrix4x4 m2; + m2.rotate(angle, x, y, z); + QVERIFY(isSame(m2, (const qreal *)resultValues)); + + QMatrix4x4 m3(uniqueValues4); + QMatrix4x4 m4(m3); + m4.rotate(angle, x, y, z); + QVERIFY(matrixFuzzyCompare(m4, m3 * m1)); + + // Null vectors don't make sense for quaternion rotations. + if (x != 0 || y != 0 || z != 0) { + QMatrix4x4 m5; + m5.rotate(QQuaternion::fromAxisAndAngle(QVector3D(x, y, z), angle)); + QVERIFY(isSame(m5, (const qreal *)resultValues)); + } + +#define ROTATE4(xin,yin,zin,win,xout,yout,zout,wout) \ + do { \ + xout = ((const qreal *)resultValues)[0] * xin + \ + ((const qreal *)resultValues)[1] * yin + \ + ((const qreal *)resultValues)[2] * zin + \ + ((const qreal *)resultValues)[3] * win; \ + yout = ((const qreal *)resultValues)[4] * xin + \ + ((const qreal *)resultValues)[5] * yin + \ + ((const qreal *)resultValues)[6] * zin + \ + ((const qreal *)resultValues)[7] * win; \ + zout = ((const qreal *)resultValues)[8] * xin + \ + ((const qreal *)resultValues)[9] * yin + \ + ((const qreal *)resultValues)[10] * zin + \ + ((const qreal *)resultValues)[11] * win; \ + wout = ((const qreal *)resultValues)[12] * xin + \ + ((const qreal *)resultValues)[13] * yin + \ + ((const qreal *)resultValues)[14] * zin + \ + ((const qreal *)resultValues)[15] * win; \ + } while (0) + + // Rotate various test vectors using the straight-forward approach. + qreal v1x, v1y, v1z, v1w; + ROTATE4(2.0f, 3.0f, -4.0f, 1.0f, v1x, v1y, v1z, v1w); + v1x /= v1w; + v1y /= v1w; + v1z /= v1w; + qreal v3x, v3y, v3z, v3w; + ROTATE4(2.0f, 3.0f, -4.0f, 1.0f, v3x, v3y, v3z, v3w); + qreal v5x, v5y, v5z, v5w; + ROTATE4(2.0f, 3.0f, -4.0f, 34.0f, v5x, v5y, v5z, v5w); + qreal p1x, p1y, p1z, p1w; + ROTATE4(2.0f, 3.0f, 0.0f, 1.0f, p1x, p1y, p1z, p1w); + p1x /= p1w; + p1y /= p1w; + p1z /= p1w; + + QVector3D v1(2.0f, 3.0f, -4.0f); + QVector3D v2 = m1 * v1; + QVERIFY(fuzzyCompare(v2.x(), v1x)); + QVERIFY(fuzzyCompare(v2.y(), v1y)); + QVERIFY(fuzzyCompare(v2.z(), v1z)); + + QVector4D v3(2.0f, 3.0f, -4.0f, 1.0f); + QVector4D v4 = m1 * v3; + QVERIFY(fuzzyCompare(v4.x(), v3x)); + QVERIFY(fuzzyCompare(v4.y(), v3y)); + QVERIFY(fuzzyCompare(v4.z(), v3z)); + QVERIFY(fuzzyCompare(v4.w(), v3w)); + + QVector4D v5(2.0f, 3.0f, -4.0f, 34.0f); + QVector4D v6 = m1 * v5; + QVERIFY(fuzzyCompare(v6.x(), v5x)); + QVERIFY(fuzzyCompare(v6.y(), v5y)); + QVERIFY(fuzzyCompare(v6.z(), v5z)); + QVERIFY(fuzzyCompare(v6.w(), v5w)); + + QPoint p1(2, 3); + QPoint p2 = m1 * p1; + QCOMPARE(p2.x(), qRound(p1x)); + QCOMPARE(p2.y(), qRound(p1y)); + + QPointF p3(2.0f, 3.0f); + QPointF p4 = m1 * p3; + QVERIFY(fuzzyCompare((float)(p4.x()), p1x)); + QVERIFY(fuzzyCompare((float)(p4.y()), p1y)); + + if (x != 0 || y != 0 || z != 0) { + QQuaternion q = QQuaternion::fromAxisAndAngle(QVector3D(x, y, z), angle); + QVector3D vq = q.rotateVector(v1); + QVERIFY(fuzzyCompare(vq.x(), v1x)); + QVERIFY(fuzzyCompare(vq.y(), v1y)); + QVERIFY(fuzzyCompare(vq.z(), v1z)); + } +} + +static bool isSame(const QMatrix3x3& m1, const Matrix3& m2) +{ + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) { + if (!fuzzyCompare(m1(row, col), m2.v[row * 3 + col])) + return false; + } + } + return true; +} + +// Test the computation of normal matrices from 4x4 transformation matrices. +void tst_QMatrixNxN::normalMatrix_data() +{ + QTest::addColumn("mValues"); + + QTest::newRow("identity") + << (void *)identityValues4; + QTest::newRow("unique") + << (void *)uniqueValues4; // Not invertible because determinant == 0. + + static qreal const translateValues[16] = + {1.0f, 0.0f, 0.0f, 4.0f, + 0.0f, 1.0f, 0.0f, 5.0f, + 0.0f, 0.0f, 1.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const scaleValues[16] = + {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 7.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 9.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const bothValues[16] = + {2.0f, 0.0f, 0.0f, 4.0f, + 0.0f, 7.0f, 0.0f, 5.0f, + 0.0f, 0.0f, 9.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const nullScaleValues1[16] = + {0.0f, 0.0f, 0.0f, 4.0f, + 0.0f, 7.0f, 0.0f, 5.0f, + 0.0f, 0.0f, 9.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const nullScaleValues2[16] = + {2.0f, 0.0f, 0.0f, 4.0f, + 0.0f, 0.0f, 0.0f, 5.0f, + 0.0f, 0.0f, 9.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const nullScaleValues3[16] = + {2.0f, 0.0f, 0.0f, 4.0f, + 0.0f, 7.0f, 0.0f, 5.0f, + 0.0f, 0.0f, 0.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + + QTest::newRow("translate") << (void *)translateValues; + QTest::newRow("scale") << (void *)scaleValues; + QTest::newRow("both") << (void *)bothValues; + QTest::newRow("null scale 1") << (void *)nullScaleValues1; + QTest::newRow("null scale 2") << (void *)nullScaleValues2; + QTest::newRow("null scale 3") << (void *)nullScaleValues3; +} +void tst_QMatrixNxN::normalMatrix() +{ + QFETCH(void *, mValues); + const qreal *values = (const qreal *)mValues; + + // Compute the expected answer the long way. + Matrix3 min; + Matrix3 answer; + min.v[0] = values[0]; + min.v[1] = values[1]; + min.v[2] = values[2]; + min.v[3] = values[4]; + min.v[4] = values[5]; + min.v[5] = values[6]; + min.v[6] = values[8]; + min.v[7] = values[9]; + min.v[8] = values[10]; + bool invertible = m3Inverse(min, answer); + m3Transpose(answer); + + // Perform the test. + QMatrix4x4 m1(values); + QMatrix3x3 n1 = m1.normalMatrix(); + + if (invertible) + QVERIFY(::isSame(n1, answer)); + else + QVERIFY(isIdentity(n1)); + + // Perform the test again, after inferring special matrix types. + // This tests the optimized paths in the normalMatrix() function. + m1.inferSpecialType(); + n1 = m1.normalMatrix(); + + if (invertible) + QVERIFY(::isSame(n1, answer)); + else + QVERIFY(isIdentity(n1)); +} + +// Test optimized transformations on 4x4 matrices. +void tst_QMatrixNxN::optimizedTransforms() +{ + static qreal const translateValues[16] = + {1.0f, 0.0f, 0.0f, 4.0f, + 0.0f, 1.0f, 0.0f, 5.0f, + 0.0f, 0.0f, 1.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const translateDoubleValues[16] = + {1.0f, 0.0f, 0.0f, 8.0f, + 0.0f, 1.0f, 0.0f, 10.0f, + 0.0f, 0.0f, 1.0f, -6.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const scaleValues[16] = + {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 7.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 9.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const scaleDoubleValues[16] = + {4.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 49.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 81.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const bothValues[16] = + {2.0f, 0.0f, 0.0f, 4.0f, + 0.0f, 7.0f, 0.0f, 5.0f, + 0.0f, 0.0f, 9.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const bothReverseValues[16] = + {2.0f, 0.0f, 0.0f, 4.0f * 2.0f, + 0.0f, 7.0f, 0.0f, 5.0f * 7.0f, + 0.0f, 0.0f, 9.0f, -3.0f * 9.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const bothThenTranslateValues[16] = + {2.0f, 0.0f, 0.0f, 4.0f + 2.0f * 4.0f, + 0.0f, 7.0f, 0.0f, 5.0f + 7.0f * 5.0f, + 0.0f, 0.0f, 9.0f, -3.0f + 9.0f * -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + static qreal const bothThenScaleValues[16] = + {4.0f, 0.0f, 0.0f, 4.0f, + 0.0f, 49.0f, 0.0f, 5.0f, + 0.0f, 0.0f, 81.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + + QMatrix4x4 translate(translateValues); + QMatrix4x4 scale(scaleValues); + QMatrix4x4 both(bothValues); + + QMatrix4x4 m1; + m1.translate(4.0f, 5.0f, -3.0f); + QVERIFY(isSame(m1, translateValues)); + m1.translate(4.0f, 5.0f, -3.0f); + QVERIFY(isSame(m1, translateDoubleValues)); + + QMatrix4x4 m2; + m2.translate(QVector3D(4.0f, 5.0f, -3.0f)); + QVERIFY(isSame(m2, translateValues)); + m2.translate(QVector3D(4.0f, 5.0f, -3.0f)); + QVERIFY(isSame(m2, translateDoubleValues)); + + QMatrix4x4 m3; + m3.scale(2.0f, 7.0f, 9.0f); + QVERIFY(isSame(m3, scaleValues)); + m3.scale(2.0f, 7.0f, 9.0f); + QVERIFY(isSame(m3, scaleDoubleValues)); + + QMatrix4x4 m4; + m4.scale(QVector3D(2.0f, 7.0f, 9.0f)); + QVERIFY(isSame(m4, scaleValues)); + m4.scale(QVector3D(2.0f, 7.0f, 9.0f)); + QVERIFY(isSame(m4, scaleDoubleValues)); + + QMatrix4x4 m5; + m5.translate(4.0f, 5.0f, -3.0f); + m5.scale(2.0f, 7.0f, 9.0f); + QVERIFY(isSame(m5, bothValues)); + m5.translate(4.0f, 5.0f, -3.0f); + QVERIFY(isSame(m5, bothThenTranslateValues)); + + QMatrix4x4 m6; + m6.translate(QVector3D(4.0f, 5.0f, -3.0f)); + m6.scale(QVector3D(2.0f, 7.0f, 9.0f)); + QVERIFY(isSame(m6, bothValues)); + m6.translate(QVector3D(4.0f, 5.0f, -3.0f)); + QVERIFY(isSame(m6, bothThenTranslateValues)); + + QMatrix4x4 m7; + m7.scale(2.0f, 7.0f, 9.0f); + m7.translate(4.0f, 5.0f, -3.0f); + QVERIFY(isSame(m7, bothReverseValues)); + + QMatrix4x4 m8; + m8.scale(QVector3D(2.0f, 7.0f, 9.0f)); + m8.translate(QVector3D(4.0f, 5.0f, -3.0f)); + QVERIFY(isSame(m8, bothReverseValues)); + + QMatrix4x4 m9; + m9.translate(4.0f, 5.0f, -3.0f); + m9.scale(2.0f, 7.0f, 9.0f); + QVERIFY(isSame(m9, bothValues)); + m9.scale(2.0f, 7.0f, 9.0f); + QVERIFY(isSame(m9, bothThenScaleValues)); + + QMatrix4x4 m10; + m10.translate(QVector3D(4.0f, 5.0f, -3.0f)); + m10.scale(QVector3D(2.0f, 7.0f, 9.0f)); + QVERIFY(isSame(m10, bothValues)); + m10.scale(QVector3D(2.0f, 7.0f, 9.0f)); + QVERIFY(isSame(m10, bothThenScaleValues)); +} + +// Test orthographic projections. +void tst_QMatrixNxN::ortho() +{ + QMatrix4x4 m1; + m1.ortho(QRect(0, 0, 300, 150)); + QPointF p1 = m1 * QPointF(0, 0); + QPointF p2 = m1 * QPointF(300, 0); + QPointF p3 = m1 * QPointF(0, 150); + QPointF p4 = m1 * QPointF(300, 150); + QVector3D p5 = m1 * QVector3D(300, 150, 1); + QVERIFY(fuzzyCompare(p1.x(), -1.0)); + QVERIFY(fuzzyCompare(p1.y(), 1.0)); + QVERIFY(fuzzyCompare(p2.x(), 1.0)); + QVERIFY(fuzzyCompare(p2.y(), 1.0)); + QVERIFY(fuzzyCompare(p3.x(), -1.0)); + QVERIFY(fuzzyCompare(p3.y(), -1.0)); + QVERIFY(fuzzyCompare(p4.x(), 1.0)); + QVERIFY(fuzzyCompare(p4.y(), -1.0)); + QVERIFY(fuzzyCompare(p5.x(), (qreal)1.0)); + QVERIFY(fuzzyCompare(p5.y(), (qreal)-1.0)); + QVERIFY(fuzzyCompare(p5.z(), (qreal)-1.0)); + + QMatrix4x4 m2; + m2.ortho(QRectF(0, 0, 300, 150)); + p1 = m2 * QPointF(0, 0); + p2 = m2 * QPointF(300, 0); + p3 = m2 * QPointF(0, 150); + p4 = m2 * QPointF(300, 150); + p5 = m2 * QVector3D(300, 150, 1); + QVERIFY(fuzzyCompare(p1.x(), -1.0)); + QVERIFY(fuzzyCompare(p1.y(), 1.0)); + QVERIFY(fuzzyCompare(p2.x(), 1.0)); + QVERIFY(fuzzyCompare(p2.y(), 1.0)); + QVERIFY(fuzzyCompare(p3.x(), -1.0)); + QVERIFY(fuzzyCompare(p3.y(), -1.0)); + QVERIFY(fuzzyCompare(p4.x(), 1.0)); + QVERIFY(fuzzyCompare(p4.y(), -1.0)); + QVERIFY(fuzzyCompare(p5.x(), (qreal)1.0)); + QVERIFY(fuzzyCompare(p5.y(), (qreal)-1.0)); + QVERIFY(fuzzyCompare(p5.z(), (qreal)-1.0)); + + QMatrix4x4 m3; + m3.ortho(0, 300, 150, 0, -1, 1); + p1 = m3 * QPointF(0, 0); + p2 = m3 * QPointF(300, 0); + p3 = m3 * QPointF(0, 150); + p4 = m3 * QPointF(300, 150); + p5 = m3 * QVector3D(300, 150, 1); + QVERIFY(fuzzyCompare(p1.x(), -1.0)); + QVERIFY(fuzzyCompare(p1.y(), 1.0)); + QVERIFY(fuzzyCompare(p2.x(), 1.0)); + QVERIFY(fuzzyCompare(p2.y(), 1.0)); + QVERIFY(fuzzyCompare(p3.x(), -1.0)); + QVERIFY(fuzzyCompare(p3.y(), -1.0)); + QVERIFY(fuzzyCompare(p4.x(), 1.0)); + QVERIFY(fuzzyCompare(p4.y(), -1.0)); + QVERIFY(fuzzyCompare(p5.x(), (qreal)1.0)); + QVERIFY(fuzzyCompare(p5.y(), (qreal)-1.0)); + QVERIFY(fuzzyCompare(p5.z(), (qreal)-1.0)); + + QMatrix4x4 m4; + m4.ortho(0, 300, 150, 0, -2, 3); + p1 = m4 * QPointF(0, 0); + p2 = m4 * QPointF(300, 0); + p3 = m4 * QPointF(0, 150); + p4 = m4 * QPointF(300, 150); + p5 = m4 * QVector3D(300, 150, 1); + QVERIFY(fuzzyCompare(p1.x(), -1.0)); + QVERIFY(fuzzyCompare(p1.y(), 1.0)); + QVERIFY(fuzzyCompare(p2.x(), 1.0)); + QVERIFY(fuzzyCompare(p2.y(), 1.0)); + QVERIFY(fuzzyCompare(p3.x(), -1.0)); + QVERIFY(fuzzyCompare(p3.y(), -1.0)); + QVERIFY(fuzzyCompare(p4.x(), 1.0)); + QVERIFY(fuzzyCompare(p4.y(), -1.0)); + QVERIFY(fuzzyCompare(p5.x(), (qreal)1.0)); + QVERIFY(fuzzyCompare(p5.y(), (qreal)-1.0)); + QVERIFY(fuzzyCompare(p5.z(), (qreal)-0.6)); + + // An empty view volume should leave the matrix alone. + QMatrix4x4 m5; + m5.ortho(0, 0, 150, 0, -2, 3); + QVERIFY(m5.isIdentity()); + m5.ortho(0, 300, 150, 150, -2, 3); + QVERIFY(m5.isIdentity()); + m5.ortho(0, 300, 150, 0, 2, 2); + QVERIFY(m5.isIdentity()); +} + +// Test perspective frustum projections. +void tst_QMatrixNxN::frustum() +{ + QMatrix4x4 m1; + m1.frustum(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); + QVector3D p1 = m1 * QVector3D(-1.0f, -1.0f, 1.0f); + QVector3D p2 = m1 * QVector3D(1.0f, -1.0f, 1.0f); + QVector3D p3 = m1 * QVector3D(-1.0f, 1.0f, 1.0f); + QVector3D p4 = m1 * QVector3D(1.0f, 1.0f, 1.0f); + QVector3D p5 = m1 * QVector3D(0.0f, 0.0f, 2.0f); + QVERIFY(fuzzyCompare(p1.x(), -1.0f)); + QVERIFY(fuzzyCompare(p1.y(), -1.0f)); + QVERIFY(fuzzyCompare(p1.z(), -1.0f)); + QVERIFY(fuzzyCompare(p2.x(), 1.0f)); + QVERIFY(fuzzyCompare(p2.y(), -1.0f)); + QVERIFY(fuzzyCompare(p2.z(), -1.0f)); + QVERIFY(fuzzyCompare(p3.x(), -1.0f)); + QVERIFY(fuzzyCompare(p3.y(), 1.0f)); + QVERIFY(fuzzyCompare(p3.z(), -1.0f)); + QVERIFY(fuzzyCompare(p4.x(), 1.0f)); + QVERIFY(fuzzyCompare(p4.y(), 1.0f)); + QVERIFY(fuzzyCompare(p4.z(), -1.0f)); + QVERIFY(fuzzyCompare(p5.x(), 0.0f)); + QVERIFY(fuzzyCompare(p5.y(), 0.0f)); + QVERIFY(fuzzyCompare(p5.z(), -0.5f)); + + // An empty view volume should leave the matrix alone. + QMatrix4x4 m5; + m5.frustum(0, 0, 150, 0, -2, 3); + QVERIFY(m5.isIdentity()); + m5.frustum(0, 300, 150, 150, -2, 3); + QVERIFY(m5.isIdentity()); + m5.frustum(0, 300, 150, 0, 2, 2); + QVERIFY(m5.isIdentity()); +} + +// Test perspective field-of-view projections. +void tst_QMatrixNxN::perspective() +{ + QMatrix4x4 m1; + m1.perspective(45.0f, 1.0f, -1.0f, 1.0f); + QVector3D p1 = m1 * QVector3D(-1.0f, -1.0f, 1.0f); + QVector3D p2 = m1 * QVector3D(1.0f, -1.0f, 1.0f); + QVector3D p3 = m1 * QVector3D(-1.0f, 1.0f, 1.0f); + QVector3D p4 = m1 * QVector3D(1.0f, 1.0f, 1.0f); + QVector3D p5 = m1 * QVector3D(0.0f, 0.0f, 2.0f); + QVERIFY(fuzzyCompare(p1.x(), 2.41421)); + QVERIFY(fuzzyCompare(p1.y(), 2.41421)); + QVERIFY(fuzzyCompare(p1.z(), -1)); + QVERIFY(fuzzyCompare(p2.x(), -2.41421)); + QVERIFY(fuzzyCompare(p2.y(), 2.41421)); + QVERIFY(fuzzyCompare(p2.z(), -1.0f)); + QVERIFY(fuzzyCompare(p3.x(), 2.41421)); + QVERIFY(fuzzyCompare(p3.y(), -2.41421)); + QVERIFY(fuzzyCompare(p3.z(), -1.0f)); + QVERIFY(fuzzyCompare(p4.x(), -2.41421)); + QVERIFY(fuzzyCompare(p4.y(), -2.41421)); + QVERIFY(fuzzyCompare(p4.z(), -1.0f)); + QVERIFY(fuzzyCompare(p5.x(), 0.0f)); + QVERIFY(fuzzyCompare(p5.y(), 0.0f)); + QVERIFY(fuzzyCompare(p5.z(), -0.5f)); + + // An empty view volume should leave the matrix alone. + QMatrix4x4 m5; + m5.perspective(45.0f, 1.0f, 0.0f, 0.0f); + QVERIFY(m5.isIdentity()); + m5.perspective(45.0f, 0.0f, -1.0f, 1.0f); + QVERIFY(m5.isIdentity()); + m5.perspective(0.0f, 1.0f, -1.0f, 1.0f); + QVERIFY(m5.isIdentity()); +} + +// Test left-handed vs right-handed coordinate flipping. +void tst_QMatrixNxN::flipCoordinates() +{ + QMatrix4x4 m1; + m1.flipCoordinates(); + QVector3D p1 = m1 * QVector3D(2, 3, 4); + QVERIFY(p1 == QVector3D(2, -3, -4)); + + QMatrix4x4 m2; + m2.scale(2.0f, 3.0f, 1.0f); + m2.flipCoordinates(); + QVector3D p2 = m2 * QVector3D(2, 3, 4); + QVERIFY(p2 == QVector3D(4, -9, -4)); + + QMatrix4x4 m3; + m3.translate(2.0f, 3.0f, 1.0f); + m3.flipCoordinates(); + QVector3D p3 = m3 * QVector3D(2, 3, 4); + QVERIFY(p3 == QVector3D(4, 0, -3)); + + QMatrix4x4 m4; + m4.rotate(90.0f, 0.0f, 0.0f, 1.0f); + m4.flipCoordinates(); + QVector3D p4 = m4 * QVector3D(2, 3, 4); + QVERIFY(p4 == QVector3D(3, 2, -4)); +} + +// Test conversion of generic matrices to and from the non-generic types. +void tst_QMatrixNxN::convertGeneric() +{ + QMatrix4x3 m1(uniqueValues4x3); + + static qreal const unique4x4[16] = { + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 0.0f, 0.0f, 0.0f, 1.0f + }; +#if !defined(QT_NO_MEMBER_TEMPLATES) + QMatrix4x4 m4(m1); + QVERIFY(isSame(m4, unique4x4)); +#endif + QMatrix4x4 m5 = qGenericMatrixToMatrix4x4(m1); + QVERIFY(isSame(m5, unique4x4)); + + static qreal const conv4x4[12] = { + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f + }; + QMatrix4x4 m9(uniqueValues4); +#if !defined(QT_NO_MEMBER_TEMPLATES) + QMatrix4x3 m10 = m9.toGenericMatrix<4, 3>(); + QVERIFY(isSame(m10, conv4x4)); +#endif + + QMatrix4x3 m11 = qGenericMatrixFromMatrix4x4<4, 3>(m9); + QVERIFY(isSame(m11, conv4x4)); +} + +void tst_QMatrixNxN::extractAxisRotation_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("z"); + QTest::addColumn("angle"); + + QTest::newRow("1, 0, 0, 0 deg") << 1.0f << 0.0f << 0.0f << 0.0f; + QTest::newRow("1, 0, 0, 90 deg") << 1.0f << 0.0f << 0.0f << 90.0f; + QTest::newRow("1, 0, 0, 270 deg") << 1.0f << 0.0f << 0.0f << 270.0f; + QTest::newRow("1, 0, 0, 45 deg") << 1.0f << 0.0f << 0.0f << 45.0f; + QTest::newRow("1, 0, 0, 120 deg") << 1.0f << 0.0f << 0.0f << 120.0f; + QTest::newRow("1, 0, 0, 300 deg") << 1.0f << 0.0f << 0.0f << 300.0f; + + QTest::newRow("0, 1, 0, 90 deg") << 0.0f << 1.0f << 0.0f << 90.0f; + QTest::newRow("0, 1, 0, 270 deg") << 0.0f << 1.0f << 0.0f << 270.0f; + QTest::newRow("0, 1, 0, 45 deg") << 0.0f << 1.0f << 0.0f << 45.0f; + QTest::newRow("0, 1, 0, 120 deg") << 0.0f << 1.0f << 0.0f << 120.0f; + QTest::newRow("0, 1, 0, 300 deg") << 0.0f << 1.0f << 0.0f << 300.0f; + + QTest::newRow("0, 0, 1, 90 deg") << 0.0f << 0.0f << 1.0f << 90.0f; + QTest::newRow("0, 0, 1, 270 deg") << 0.0f << 0.0f << 1.0f << 270.0f; + QTest::newRow("0, 0, 1, 45 deg") << 0.0f << 0.0f << 1.0f << 45.0f; + QTest::newRow("0, 0, 1, 120 deg") << 0.0f << 0.0f << 1.0f << 120.0f; + QTest::newRow("0, 0, 1, 300 deg") << 0.0f << 0.0f << 1.0f << 300.0f; + + QTest::newRow("1, 1, 1, 90 deg") << 1.0f << 1.0f << 1.0f << 90.0f; + QTest::newRow("1, 1, 1, 270 deg") << 1.0f << 1.0f << 1.0f << 270.0f; + QTest::newRow("1, 1, 1, 45 deg") << 1.0f << 1.0f << 1.0f << 45.0f; + QTest::newRow("1, 1, 1, 120 deg") << 1.0f << 1.0f << 1.0f << 120.0f; + QTest::newRow("1, 1, 1, 300 deg") << 1.0f << 1.0f << 1.0f << 300.0f; +} + +void tst_QMatrixNxN::extractAxisRotation() +{ + QFETCH(float, x); + QFETCH(float, y); + QFETCH(float, z); + QFETCH(float, angle); + + QMatrix4x4 m; + QVector3D origAxis(x, y, z); + + m.rotate(angle, x, y, z); + + origAxis.normalize(); + QVector3D extractedAxis; + qreal extractedAngle; + + m.extractAxisRotation(extractedAngle, extractedAxis); + + qreal epsilon = 0.001; + + if (angle > 180) { + QVERIFY(fuzzyCompare(360.0f - angle, extractedAngle, epsilon)); + QVERIFY(fuzzyCompare(extractedAxis, -origAxis, epsilon)); + } else { + QVERIFY(fuzzyCompare(angle, extractedAngle, epsilon)); + QVERIFY(fuzzyCompare(extractedAxis, origAxis, epsilon)); + } +} + +void tst_QMatrixNxN::extractTranslation_data() +{ + QTest::addColumn("rotation"); + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("z"); + + static QMatrix4x4 m1; + + QTest::newRow("identity, 100, 50, 25") + << m1 << 100.0f << 50.0f << 250.0f; + + m1.rotate(45.0, 1.0, 0.0, 0.0); + QTest::newRow("rotX 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f; + + m1.setIdentity(); + m1.rotate(45.0, 0.0, 1.0, 0.0); + QTest::newRow("rotY 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f; + + m1.setIdentity(); + m1.rotate(75, 0.0, 0.0, 1.0); + m1.rotate(25, 1.0, 0.0, 0.0); + m1.rotate(45, 0.0, 1.0, 0.0); + QTest::newRow("rotZ 75, rotX 25, rotY 45, 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f; +} + +void tst_QMatrixNxN::extractTranslation() +{ + QFETCH(QMatrix4x4, rotation); + QFETCH(float, x); + QFETCH(float, y); + QFETCH(float, z); + + rotation.translate(x, y, z); + + QVector3D vec = rotation.extractTranslation(); + + qreal epsilon = 0.001; + + QVERIFY(fuzzyCompare(vec.x(), x, epsilon)); + QVERIFY(fuzzyCompare(vec.y(), y, epsilon)); + QVERIFY(fuzzyCompare(vec.z(), z, epsilon)); + + QMatrix4x4 lookAt; + QVector3D eye(1.5f, -2.5f, 2.5f); + lookAt.lookAt(eye, + QVector3D(10.0f, 10.0f, 10.0f), + QVector3D(0.0f, 1.0f, 0.0f)); + + QVector3D extEye = lookAt.extractTranslation(); + + QVERIFY(fuzzyCompare(eye.x(), -extEye.x(), epsilon)); + QVERIFY(fuzzyCompare(eye.y(), -extEye.y(), epsilon)); + QVERIFY(fuzzyCompare(eye.z(), -extEye.z(), epsilon)); +} + +// Copy of "flagBits" in qmatrix4x4.h. +enum { + Identity = 0x0001, // Identity matrix + General = 0x0002, // General matrix, unknown contents + Translation = 0x0004, // Contains a simple translation + Scale = 0x0008, // Contains a simple scale + Rotation = 0x0010 // Contains a simple rotation +}; + +// Structure that allows direct access to "flagBits" for testing. +struct Matrix4x4 +{ + float m[4][4]; + int flagBits; +}; + +// Test the inferring of special matrix types. +void tst_QMatrixNxN::inferSpecialType_data() +{ + QTest::addColumn("mValues"); + QTest::addColumn("flagBits"); + + QTest::newRow("null") + << (void *)nullValues4 << (int)General; + QTest::newRow("identity") + << (void *)identityValues4 << (int)Identity; + QTest::newRow("unique") + << (void *)uniqueValues4 << (int)General; + + static qreal scaleValues[16] = { + 2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 3.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 4.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f + }; + QTest::newRow("scale") + << (void *)scaleValues << (int)Scale; + + static qreal translateValues[16] = { + 1.0f, 0.0f, 0.0f, 2.0f, + 0.0f, 1.0f, 0.0f, 3.0f, + 0.0f, 0.0f, 1.0f, 4.0f, + 0.0f, 0.0f, 0.0f, 1.0f + }; + QTest::newRow("scale") + << (void *)translateValues << (int)Translation; + + static qreal bothValues[16] = { + 1.0f, 0.0f, 0.0f, 2.0f, + 0.0f, 2.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 4.0f, + 0.0f, 0.0f, 0.0f, 1.0f + }; + QTest::newRow("both") + << (void *)bothValues << (int)(Scale | Translation); + + static qreal belowValues[16] = { + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 4.0f, 0.0f, 0.0f, 1.0f + }; + QTest::newRow("below") + << (void *)belowValues << (int)General; +} +void tst_QMatrixNxN::inferSpecialType() +{ + QFETCH(void *, mValues); + QFETCH(int, flagBits); + + QMatrix4x4 m((const qreal *)mValues); + m.inferSpecialType(); + + QCOMPARE(reinterpret_cast(&m)->flagBits, flagBits); +} + +void tst_QMatrixNxN::columnsAndRows() +{ + QMatrix4x4 m1(uniqueValues4); + + QVERIFY(m1.column(0) == QVector4D(1, 5, 9, 13)); + QVERIFY(m1.column(1) == QVector4D(2, 6, 10, 14)); + QVERIFY(m1.column(2) == QVector4D(3, 7, 11, 15)); + QVERIFY(m1.column(3) == QVector4D(4, 8, 12, 16)); + + QVERIFY(m1.row(0) == QVector4D(1, 2, 3, 4)); + QVERIFY(m1.row(1) == QVector4D(5, 6, 7, 8)); + QVERIFY(m1.row(2) == QVector4D(9, 10, 11, 12)); + QVERIFY(m1.row(3) == QVector4D(13, 14, 15, 16)); + + m1.setColumn(0, QVector4D(-1, -5, -9, -13)); + m1.setColumn(1, QVector4D(-2, -6, -10, -14)); + m1.setColumn(2, QVector4D(-3, -7, -11, -15)); + m1.setColumn(3, QVector4D(-4, -8, -12, -16)); + + QVERIFY(m1.column(0) == QVector4D(-1, -5, -9, -13)); + QVERIFY(m1.column(1) == QVector4D(-2, -6, -10, -14)); + QVERIFY(m1.column(2) == QVector4D(-3, -7, -11, -15)); + QVERIFY(m1.column(3) == QVector4D(-4, -8, -12, -16)); + + QVERIFY(m1.row(0) == QVector4D(-1, -2, -3, -4)); + QVERIFY(m1.row(1) == QVector4D(-5, -6, -7, -8)); + QVERIFY(m1.row(2) == QVector4D(-9, -10, -11, -12)); + QVERIFY(m1.row(3) == QVector4D(-13, -14, -15, -16)); + + m1.setRow(0, QVector4D(1, 5, 9, 13)); + m1.setRow(1, QVector4D(2, 6, 10, 14)); + m1.setRow(2, QVector4D(3, 7, 11, 15)); + m1.setRow(3, QVector4D(4, 8, 12, 16)); + + QVERIFY(m1.column(0) == QVector4D(1, 2, 3, 4)); + QVERIFY(m1.column(1) == QVector4D(5, 6, 7, 8)); + QVERIFY(m1.column(2) == QVector4D(9, 10, 11, 12)); + QVERIFY(m1.column(3) == QVector4D(13, 14, 15, 16)); + + QVERIFY(m1.row(0) == QVector4D(1, 5, 9, 13)); + QVERIFY(m1.row(1) == QVector4D(2, 6, 10, 14)); + QVERIFY(m1.row(2) == QVector4D(3, 7, 11, 15)); + QVERIFY(m1.row(3) == QVector4D(4, 8, 12, 16)); +} + +// Test converting QMatrix objects into QMatrix4x4 and then +// checking that transformations in the original perform the +// equivalent transformations in the new matrix. +void tst_QMatrixNxN::convertQMatrix() +{ + QMatrix m1; + m1.translate(-3.5, 2.0); + QPointF p1 = m1.map(QPointF(100.0, 150.0)); + QCOMPARE(p1.x(), 100.0 - 3.5); + QCOMPARE(p1.y(), 150.0 + 2.0); + + QMatrix4x4 m2(m1); + QPointF p2 = m2 * QPointF(100.0, 150.0); + QCOMPARE((double)p2.x(), 100.0 - 3.5); + QCOMPARE((double)p2.y(), 150.0 + 2.0); + QVERIFY(m1 == m2.toAffine()); + + QMatrix m3; + m3.scale(1.5, -2.0); + QPointF p3 = m3.map(QPointF(100.0, 150.0)); + QCOMPARE(p3.x(), 1.5 * 100.0); + QCOMPARE(p3.y(), -2.0 * 150.0); + + QMatrix4x4 m4(m3); + QPointF p4 = m4 * QPointF(100.0, 150.0); + QCOMPARE((double)p4.x(), 1.5 * 100.0); + QCOMPARE((double)p4.y(), -2.0 * 150.0); + QVERIFY(m3 == m4.toAffine()); + + QMatrix m5; + m5.rotate(45.0); + QPointF p5 = m5.map(QPointF(100.0, 150.0)); + + QMatrix4x4 m6(m5); + QPointF p6 = m6 * QPointF(100.0, 150.0); + QVERIFY(fuzzyCompare(p5.x(), p6.x(), 0.005)); + QVERIFY(fuzzyCompare(p5.y(), p6.y(), 0.005)); + + QMatrix m7 = m6.toAffine(); + QVERIFY(fuzzyCompare(m5.m11(), m7.m11())); + QVERIFY(fuzzyCompare(m5.m12(), m7.m12())); + QVERIFY(fuzzyCompare(m5.m21(), m7.m21())); + QVERIFY(fuzzyCompare(m5.m22(), m7.m22())); + QVERIFY(fuzzyCompare(m5.dx(), m7.dx())); + QVERIFY(fuzzyCompare(m5.dy(), m7.dy())); +} + +// Test converting QTransform objects into QMatrix4x4 and then +// checking that transformations in the original perform the +// equivalent transformations in the new matrix. +void tst_QMatrixNxN::convertQTransform() +{ + QTransform m1; + m1.translate(-3.5, 2.0); + QPointF p1 = m1.map(QPointF(100.0, 150.0)); + QCOMPARE(p1.x(), 100.0 - 3.5); + QCOMPARE(p1.y(), 150.0 + 2.0); + + QMatrix4x4 m2(m1); + QPointF p2 = m2 * QPointF(100.0, 150.0); + QCOMPARE((double)p2.x(), 100.0 - 3.5); + QCOMPARE((double)p2.y(), 150.0 + 2.0); + QVERIFY(m1 == m2.toTransform()); + + QTransform m3; + m3.scale(1.5, -2.0); + QPointF p3 = m3.map(QPointF(100.0, 150.0)); + QCOMPARE(p3.x(), 1.5 * 100.0); + QCOMPARE(p3.y(), -2.0 * 150.0); + + QMatrix4x4 m4(m3); + QPointF p4 = m4 * QPointF(100.0, 150.0); + QCOMPARE((double)p4.x(), 1.5 * 100.0); + QCOMPARE((double)p4.y(), -2.0 * 150.0); + QVERIFY(m3 == m4.toTransform()); + + QTransform m5; + m5.rotate(45.0); + QPointF p5 = m5.map(QPointF(100.0, 150.0)); + + QMatrix4x4 m6(m5); + QPointF p6 = m6 * QPointF(100.0, 150.0); + QVERIFY(fuzzyCompare(p5.x(), p6.x(), 0.005)); + QVERIFY(fuzzyCompare(p5.y(), p6.y(), 0.005)); + + QTransform m7 = m6.toTransform(); + QVERIFY(fuzzyCompare(m5.m11(), m7.m11())); + QVERIFY(fuzzyCompare(m5.m12(), m7.m12())); + QVERIFY(fuzzyCompare(m5.m21(), m7.m21())); + QVERIFY(fuzzyCompare(m5.m22(), m7.m22())); + QVERIFY(fuzzyCompare(m5.dx(), m7.dx())); + QVERIFY(fuzzyCompare(m5.dy(), m7.dy())); + QVERIFY(fuzzyCompare(m5.m13(), m7.m13())); + QVERIFY(fuzzyCompare(m5.m23(), m7.m23())); + QVERIFY(fuzzyCompare(m5.m33(), m7.m33())); +} + +// Test filling matrices with specific values. +void tst_QMatrixNxN::fill() +{ + QMatrix4x4 m1; + m1.fill(0.0f); + QVERIFY(isSame(m1, nullValues4)); + + static const qreal fillValues4[] = + {2.5f, 2.5f, 2.5f, 2.5f, + 2.5f, 2.5f, 2.5f, 2.5f, + 2.5f, 2.5f, 2.5f, 2.5f, + 2.5f, 2.5f, 2.5f, 2.5f}; + m1.fill(2.5f); + QVERIFY(isSame(m1, fillValues4)); + + QMatrix4x3 m2; + m2.fill(0.0f); + QVERIFY(isSame(m2, nullValues4x3)); + + static const qreal fillValues4x3[] = + {2.5f, 2.5f, 2.5f, 2.5f, + 2.5f, 2.5f, 2.5f, 2.5f, + 2.5f, 2.5f, 2.5f, 2.5f}; + m2.fill(2.5f); + QVERIFY(isSame(m2, fillValues4x3)); +} + +// Test the mapRect() function for QRect and QRectF. +void tst_QMatrixNxN::mapRect_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("width"); + QTest::addColumn("height"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + QTest::newRow("rect") + << (qreal)1.0f << (qreal)-20.5f << (qreal)100.0f << (qreal)63.75f; +} +void tst_QMatrixNxN::mapRect() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, width); + QFETCH(qreal, height); + + QRectF rect(x, y, width, height); + QRect recti(qRound(x), qRound(y), qRound(width), qRound(height)); + + QMatrix4x4 m1; + QVERIFY(m1.mapRect(rect) == rect); + QVERIFY(m1.mapRect(recti) == recti); + + QMatrix4x4 m2; + m2.translate(-100.5f, 64.0f); + QRectF translated = rect.translated(-100.5f, 64.0f); + QRect translatedi = QRect(qRound(recti.x() - 100.5f), recti.y() + 64, + recti.width(), recti.height()); + QVERIFY(m2.mapRect(rect) == translated); + QVERIFY(m2.mapRect(recti) == translatedi); + + QMatrix4x4 m3; + m3.scale(-100.5f, 64.0f); + qreal scalex = x * -100.5f; + qreal scaley = y * 64.0f; + qreal scalewid = width * -100.5f; + qreal scaleht = height * 64.0f; + if (scalewid < 0.0f) { + scalewid = -scalewid; + scalex -= scalewid; + } + if (scaleht < 0.0f) { + scaleht = -scaleht; + scaley -= scaleht; + } + QRectF scaled(scalex, scaley, scalewid, scaleht); + QVERIFY(m3.mapRect(rect) == scaled); + scalex = recti.x() * -100.5f; + scaley = recti.y() * 64.0f; + scalewid = recti.width() * -100.5f; + scaleht = recti.height() * 64.0f; + if (scalewid < 0.0f) { + scalewid = -scalewid; + scalex -= scalewid; + } + if (scaleht < 0.0f) { + scaleht = -scaleht; + scaley -= scaleht; + } + QRect scaledi(qRound(scalex), qRound(scaley), + qRound(scalewid), qRound(scaleht)); + QVERIFY(m3.mapRect(recti) == scaledi); + + QMatrix4x4 m4; + m4.translate(-100.5f, 64.0f); + m4.scale(-2.5f, 4.0f); + qreal transx1 = x * -2.5f - 100.5f; + qreal transy1 = y * 4.0f + 64.0f; + qreal transx2 = (x + width) * -2.5f - 100.5f; + qreal transy2 = (y + height) * 4.0f + 64.0f; + if (transx1 > transx2) + qSwap(transx1, transx2); + if (transy1 > transy2) + qSwap(transy1, transy2); + QRectF trans(transx1, transy1, transx2 - transx1, transy2 - transy1); + QVERIFY(m4.mapRect(rect) == trans); + transx1 = recti.x() * -2.5f - 100.5f; + transy1 = recti.y() * 4.0f + 64.0f; + transx2 = (recti.x() + recti.width()) * -2.5f - 100.5f; + transy2 = (recti.y() + recti.height()) * 4.0f + 64.0f; + if (transx1 > transx2) + qSwap(transx1, transx2); + if (transy1 > transy2) + qSwap(transy1, transy2); + QRect transi(qRound(transx1), qRound(transy1), + qRound(transx2) - qRound(transx1), + qRound(transy2) - qRound(transy1)); + QVERIFY(m4.mapRect(recti) == transi); + + m4.rotate(45.0f, 0.0f, 0.0f, 1.0f); + + QTransform t4; + t4.translate(-100.5f, 64.0f); + t4.scale(-2.5f, 4.0f); + t4.rotate(45.0f); + QRectF mr = m4.mapRect(rect); + QRectF tr = t4.mapRect(rect); + QVERIFY(fuzzyCompare(mr.x(), tr.x())); + QVERIFY(fuzzyCompare(mr.y(), tr.y())); + QVERIFY(fuzzyCompare(mr.width(), tr.width())); + QVERIFY(fuzzyCompare(mr.height(), tr.height())); + + QRect mri = m4.mapRect(recti); + QRect tri = t4.mapRect(recti); + QVERIFY(mri == tri); +} + +class tst_QMatrixNxN4x4Properties : public QObject +{ + Q_OBJECT + Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix) +public: + tst_QMatrixNxN4x4Properties(QObject *parent = 0) : QObject(parent) {} + + QMatrix4x4 matrix() const { return m; } + void setMatrix(const QMatrix4x4& value) { m = value; } + +private: + QMatrix4x4 m; +}; + +// Test getting and setting matrix properties via the metaobject system. +void tst_QMatrixNxN::properties() +{ + tst_QMatrixNxN4x4Properties obj; + + QMatrix4x4 m1(uniqueValues4); + obj.setMatrix(m1); + + QMatrix4x4 m2 = qVariantValue(obj.property("matrix")); + QVERIFY(isSame(m2, uniqueValues4)); + + QMatrix4x4 m3(transposedValues4); + obj.setProperty("matrix", qVariantFromValue(m3)); + + m2 = qVariantValue(obj.property("matrix")); + QVERIFY(isSame(m2, transposedValues4)); +} + +void tst_QMatrixNxN::metaTypes() +{ + QVERIFY(QMetaType::type("QMatrix4x4") == QMetaType::QMatrix4x4); + + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QMatrix4x4)), + QByteArray("QMatrix4x4")); + + QVERIFY(QMetaType::isRegistered(QMetaType::QMatrix4x4)); + + QVERIFY(qMetaTypeId() == QMetaType::QMatrix4x4); +} + +QTEST_APPLESS_MAIN(tst_QMatrixNxN) + +#include "tst_qmatrixnxn.moc" diff --git a/tests/auto/qquaternion/qquaternion.pro b/tests/auto/qquaternion/qquaternion.pro new file mode 100644 index 0000000..6f740cf --- /dev/null +++ b/tests/auto/qquaternion/qquaternion.pro @@ -0,0 +1,2 @@ +load(qttest_p4) +SOURCES += tst_qquaternion.cpp diff --git a/tests/auto/qquaternion/tst_qquaternion.cpp b/tests/auto/qquaternion/tst_qquaternion.cpp new file mode 100644 index 0000000..ba546f1 --- /dev/null +++ b/tests/auto/qquaternion/tst_qquaternion.cpp @@ -0,0 +1,882 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +class tst_QQuaternion : public QObject +{ + Q_OBJECT +public: + tst_QQuaternion() {} + ~tst_QQuaternion() {} + +private slots: + void create(); + + void length_data(); + void length(); + + void normalized_data(); + void normalized(); + + void normalize_data(); + void normalize(); + + void compare(); + + void add_data(); + void add(); + + void subtract_data(); + void subtract(); + + void multiply_data(); + void multiply(); + + void multiplyFactor_data(); + void multiplyFactor(); + + void divide_data(); + void divide(); + + void negate_data(); + void negate(); + + void conjugate_data(); + void conjugate(); + + void fromAxisAndAngle_data(); + void fromAxisAndAngle(); + + void slerp_data(); + void slerp(); + + void nlerp_data(); + void nlerp(); + + void properties(); + void metaTypes(); +}; + +// qFuzzyCompare isn't always "fuzzy" enough to handle conversion +// between float, double, and qreal. So create "fuzzier" compares. +static bool fuzzyCompare(float x, float y) +{ + float diff = x - y; + if (diff < 0.0f) + diff = -diff; + return (diff < 0.001); +} + +// Test the creation of QQuaternion objects in various ways: +// construct, copy, and modify. +void tst_QQuaternion::create() +{ + QQuaternion identity; + QCOMPARE(identity.x(), (qreal)0.0f); + QCOMPARE(identity.y(), (qreal)0.0f); + QCOMPARE(identity.z(), (qreal)0.0f); + QCOMPARE(identity.scalar(), (qreal)1.0f); + QVERIFY(identity.isIdentity()); + + QQuaternion v1(34.0f, 1.0f, 2.5f, -89.25f); + QCOMPARE(v1.x(), (qreal)1.0f); + QCOMPARE(v1.y(), (qreal)2.5f); + QCOMPARE(v1.z(), (qreal)-89.25f); + QCOMPARE(v1.scalar(), (qreal)34.0f); + QVERIFY(!v1.isNull()); + + QQuaternion v1i(34, 1, 2, -89); + QCOMPARE(v1i.x(), (qreal)1.0f); + QCOMPARE(v1i.y(), (qreal)2.0f); + QCOMPARE(v1i.z(), (qreal)-89.0f); + QCOMPARE(v1i.scalar(), (qreal)34.0f); + QVERIFY(!v1i.isNull()); + + QQuaternion v2(v1); + QCOMPARE(v2.x(), (qreal)1.0f); + QCOMPARE(v2.y(), (qreal)2.5f); + QCOMPARE(v2.z(), (qreal)-89.25f); + QCOMPARE(v2.scalar(), (qreal)34.0f); + QVERIFY(!v2.isNull()); + + QQuaternion v4; + QCOMPARE(v4.x(), (qreal)0.0f); + QCOMPARE(v4.y(), (qreal)0.0f); + QCOMPARE(v4.z(), (qreal)0.0f); + QCOMPARE(v4.scalar(), (qreal)1.0f); + QVERIFY(v4.isIdentity()); + v4 = v1; + QCOMPARE(v4.x(), (qreal)1.0f); + QCOMPARE(v4.y(), (qreal)2.5f); + QCOMPARE(v4.z(), (qreal)-89.25f); + QCOMPARE(v4.scalar(), (qreal)34.0f); + QVERIFY(!v4.isNull()); + + QQuaternion v9(34, QVector3D(1.0f, 2.5f, -89.25f)); + QCOMPARE(v9.x(), (qreal)1.0f); + QCOMPARE(v9.y(), (qreal)2.5f); + QCOMPARE(v9.z(), (qreal)-89.25f); + QCOMPARE(v9.scalar(), (qreal)34.0f); + QVERIFY(!v9.isNull()); + + v1.setX(3.0f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)2.5f); + QCOMPARE(v1.z(), (qreal)-89.25f); + QCOMPARE(v1.scalar(), (qreal)34.0f); + QVERIFY(!v1.isNull()); + + v1.setY(10.5f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)10.5f); + QCOMPARE(v1.z(), (qreal)-89.25f); + QCOMPARE(v1.scalar(), (qreal)34.0f); + QVERIFY(!v1.isNull()); + + v1.setZ(15.5f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)10.5f); + QCOMPARE(v1.z(), (qreal)15.5f); + QCOMPARE(v1.scalar(), (qreal)34.0f); + QVERIFY(!v1.isNull()); + + v1.setScalar(6.0f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)10.5f); + QCOMPARE(v1.z(), (qreal)15.5f); + QCOMPARE(v1.scalar(), (qreal)6.0f); + QVERIFY(!v1.isNull()); + + v1.setVector(2.0f, 6.5f, -1.25f); + QCOMPARE(v1.x(), (qreal)2.0f); + QCOMPARE(v1.y(), (qreal)6.5f); + QCOMPARE(v1.z(), (qreal)-1.25f); + QCOMPARE(v1.scalar(), (qreal)6.0f); + QVERIFY(!v1.isNull()); + QVERIFY(v1.vector() == QVector3D(2.0f, 6.5f, -1.25f)); + + v1.setVector(QVector3D(-2.0f, -6.5f, 1.25f)); + QCOMPARE(v1.x(), (qreal)-2.0f); + QCOMPARE(v1.y(), (qreal)-6.5f); + QCOMPARE(v1.z(), (qreal)1.25f); + QCOMPARE(v1.scalar(), (qreal)6.0f); + QVERIFY(!v1.isNull()); + QVERIFY(v1.vector() == QVector3D(-2.0f, -6.5f, 1.25f)); + + v1.setX(0.0f); + v1.setY(0.0f); + v1.setZ(0.0f); + v1.setScalar(0.0f); + QCOMPARE(v1.x(), (qreal)0.0f); + QCOMPARE(v1.y(), (qreal)0.0f); + QCOMPARE(v1.z(), (qreal)0.0f); + QCOMPARE(v1.scalar(), (qreal)0.0f); + QVERIFY(v1.isNull()); + + QVector4D v10 = v9.toVector4D(); + QCOMPARE(v10.x(), (qreal)1.0f); + QCOMPARE(v10.y(), (qreal)2.5f); + QCOMPARE(v10.z(), (qreal)-89.25f); + QCOMPARE(v10.w(), (qreal)34.0f); +} + +// Test length computation for quaternions. +void tst_QQuaternion::length_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("z"); + QTest::addColumn("w"); + QTest::addColumn("len"); + + QTest::newRow("null") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + QTest::newRow("1x") << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("1y") << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("1z") << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)1.0f; + QTest::newRow("-1x") << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("-1z") << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("-1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; + QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)2.0f << (qreal)qSqrt(16.0f); +} +void tst_QQuaternion::length() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(qreal, w); + QFETCH(qreal, len); + + QQuaternion v(w, x, y, z); + QCOMPARE((float)(v.length()), (float)len); + QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y + z * z + w * w)); +} + +// Test the unit vector conversion for quaternions. +void tst_QQuaternion::normalized_data() +{ + // Use the same test data as the length test. + length_data(); +} +void tst_QQuaternion::normalized() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(qreal, w); + QFETCH(qreal, len); + + QQuaternion v(w, x, y, z); + QQuaternion u = v.normalized(); + if (v.isNull()) + QVERIFY(u.isNull()); + else + QCOMPARE((float)(u.length()), (float)1.0f); + QCOMPARE((float)(u.x() * len), (float)(v.x())); + QCOMPARE((float)(u.y() * len), (float)(v.y())); + QCOMPARE((float)(u.z() * len), (float)(v.z())); + QCOMPARE((float)(u.scalar() * len), (float)(v.scalar())); +} + +// Test the unit vector conversion for quaternions. +void tst_QQuaternion::normalize_data() +{ + // Use the same test data as the length test. + length_data(); +} +void tst_QQuaternion::normalize() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(qreal, w); + + QQuaternion v(w, x, y, z); + bool isNull = v.isNull(); + v.normalize(); + if (isNull) + QVERIFY(v.isNull()); + else + QCOMPARE((float)(v.length()), (float)1.0f); +} + +// Test the comparison operators for quaternions. +void tst_QQuaternion::compare() +{ + QQuaternion v1(8, 1, 2, 4); + QQuaternion v2(8, 1, 2, 4); + QQuaternion v3(8, 3, 2, 4); + QQuaternion v4(8, 1, 3, 4); + QQuaternion v5(8, 1, 2, 3); + QQuaternion v6(3, 1, 2, 4); + + QVERIFY(v1 == v2); + QVERIFY(v1 != v3); + QVERIFY(v1 != v4); + QVERIFY(v1 != v5); + QVERIFY(v1 != v6); +} + +// Test addition for quaternions. +void tst_QQuaternion::add_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("w1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("w2"); + QTest::addColumn("x3"); + QTest::addColumn("y3"); + QTest::addColumn("z3"); + QTest::addColumn("w3"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("zonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f; + + QTest::newRow("wonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)8.0f + << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f + << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f << (qreal)17.0f; +} +void tst_QQuaternion::add() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + QFETCH(qreal, w3); + + QQuaternion v1(w1, x1, y1, z1); + QQuaternion v2(w2, x2, y2, z2); + QQuaternion v3(w3, x3, y3, z3); + + QVERIFY((v1 + v2) == v3); + + QQuaternion v4(v1); + v4 += v2; + QVERIFY(v4 == v3); + + QCOMPARE(v4.x(), v1.x() + v2.x()); + QCOMPARE(v4.y(), v1.y() + v2.y()); + QCOMPARE(v4.z(), v1.z() + v2.z()); + QCOMPARE(v4.scalar(), v1.scalar() + v2.scalar()); +} + +// Test subtraction for quaternions. +void tst_QQuaternion::subtract_data() +{ + // Use the same test data as the add test. + add_data(); +} +void tst_QQuaternion::subtract() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + QFETCH(qreal, w3); + + QQuaternion v1(w1, x1, y1, z1); + QQuaternion v2(w2, x2, y2, z2); + QQuaternion v3(w3, x3, y3, z3); + + QVERIFY((v3 - v1) == v2); + QVERIFY((v3 - v2) == v1); + + QQuaternion v4(v3); + v4 -= v1; + QVERIFY(v4 == v2); + + QCOMPARE(v4.x(), v3.x() - v1.x()); + QCOMPARE(v4.y(), v3.y() - v1.y()); + QCOMPARE(v4.z(), v3.z() - v1.z()); + QCOMPARE(v4.scalar(), v3.scalar() - v1.scalar()); + + QQuaternion v5(v3); + v5 -= v2; + QVERIFY(v5 == v1); + + QCOMPARE(v5.x(), v3.x() - v2.x()); + QCOMPARE(v5.y(), v3.y() - v2.y()); + QCOMPARE(v5.z(), v3.z() - v2.z()); + QCOMPARE(v5.scalar(), v3.scalar() - v2.scalar()); +} + +// Test quaternion multiplication. +void tst_QQuaternion::multiply_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("w1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("w2"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("unitvec") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; + + QTest::newRow("complex") + << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)7.0f + << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f << (qreal)8.0f; +} +void tst_QQuaternion::multiply() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + + QQuaternion q1(w1, x1, y1, z1); + QQuaternion q2(w2, x2, y2, z2); + + // Use the simple algorithm at: + // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q53 + // to calculate the answer we expect to get. + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + qreal scalar = w1 * w2 - QVector3D::dotProduct(v1, v2); + QVector3D vector = w1 * v2 + w2 * v1 + QVector3D::crossProduct(v1, v2); + QQuaternion result(scalar, vector); + + QVERIFY((q1 * q2) == result); +} + +// Test multiplication by a factor for quaternions. +void tst_QQuaternion::multiplyFactor_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("w1"); + QTest::addColumn("factor"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("w2"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)100.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("zonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; + + QTest::newRow("wonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)4.0f + << (qreal)2.0f + << (qreal)2.0f << (qreal)4.0f << (qreal)-6.0f << (qreal)8.0f; + + QTest::newRow("allzero") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)4.0f + << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; +} +void tst_QQuaternion::multiplyFactor() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, factor); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + + QQuaternion v1(w1, x1, y1, z1); + QQuaternion v2(w2, x2, y2, z2); + + QVERIFY((v1 * factor) == v2); + QVERIFY((factor * v1) == v2); + + QQuaternion v3(v1); + v3 *= factor; + QVERIFY(v3 == v2); + + QCOMPARE(v3.x(), v1.x() * factor); + QCOMPARE(v3.y(), v1.y() * factor); + QCOMPARE(v3.z(), v1.z() * factor); + QCOMPARE(v3.scalar(), v1.scalar() * factor); +} + +// Test division by a factor for quaternions. +void tst_QQuaternion::divide_data() +{ + // Use the same test data as the multiply test. + multiplyFactor_data(); +} +void tst_QQuaternion::divide() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, factor); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + + QQuaternion v1(w1, x1, y1, z1); + QQuaternion v2(w2, x2, y2, z2); + + if (factor == (qreal)0.0f) + return; + + QVERIFY((v2 / factor) == v1); + + QQuaternion v3(v2); + v3 /= factor; + QVERIFY(v3 == v1); + + QCOMPARE(v3.x(), v2.x() / factor); + QCOMPARE(v3.y(), v2.y() / factor); + QCOMPARE(v3.z(), v2.z() / factor); + QCOMPARE(v3.scalar(), v2.scalar() / factor); +} + +// Test negation for quaternions. +void tst_QQuaternion::negate_data() +{ + // Use the same test data as the add test. + add_data(); +} +void tst_QQuaternion::negate() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + + QQuaternion v1(w1, x1, y1, z1); + QQuaternion v2(-w1, -x1, -y1, -z1); + + QVERIFY(-v1 == v2); +} + +// Test quaternion conjugate calculations. +void tst_QQuaternion::conjugate_data() +{ + // Use the same test data as the add test. + add_data(); +} +void tst_QQuaternion::conjugate() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + + QQuaternion v1(w1, x1, y1, z1); + QQuaternion v2(w1, -x1, -y1, -z1); + + QVERIFY(v1.conjugate() == v2); +} + +// Test quaternion creation from an axis and an angle. +void tst_QQuaternion::fromAxisAndAngle_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("angle"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)90.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)180.0f; + + QTest::newRow("zonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)270.0f; + + QTest::newRow("complex") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)45.0f; +} +void tst_QQuaternion::fromAxisAndAngle() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, angle); + + // Use a straight-forward implementation of the algorithm at: + // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56 + // to calculate the answer we expect to get. + QVector3D vector = QVector3D(x1, y1, z1).normalized(); + qreal sin_a = qSin((angle * M_PI / 180.0) / 2.0); + qreal cos_a = qCos((angle * M_PI / 180.0) / 2.0); + QQuaternion result((qreal)cos_a, + (qreal)(vector.x() * sin_a), + (qreal)(vector.y() * sin_a), + (qreal)(vector.z() * sin_a)); + result = result.normalized(); + + QQuaternion answer = QQuaternion::fromAxisAndAngle(QVector3D(x1, y1, z1), angle); + QVERIFY(fuzzyCompare(answer.x(), result.x())); + QVERIFY(fuzzyCompare(answer.y(), result.y())); + QVERIFY(fuzzyCompare(answer.z(), result.z())); + QVERIFY(fuzzyCompare(answer.scalar(), result.scalar())); + + answer = QQuaternion::fromAxisAndAngle(x1, y1, z1, angle); + QVERIFY(fuzzyCompare(answer.x(), result.x())); + QVERIFY(fuzzyCompare(answer.y(), result.y())); + QVERIFY(fuzzyCompare(answer.z(), result.z())); + QVERIFY(fuzzyCompare(answer.scalar(), result.scalar())); +} + +// Test spherical interpolation of quaternions. +void tst_QQuaternion::slerp_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("angle1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("angle2"); + QTest::addColumn("t"); + QTest::addColumn("x3"); + QTest::addColumn("y3"); + QTest::addColumn("z3"); + QTest::addColumn("angle3"); + + QTest::newRow("first") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f + << (qreal)0.0f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f; + QTest::newRow("first2") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f + << (qreal)-0.5f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f; + QTest::newRow("second") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f + << (qreal)1.0f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f; + QTest::newRow("second2") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f + << (qreal)1.5f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f; + QTest::newRow("middle") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)90.0f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)180.0f + << (qreal)0.5f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)135.0f; + QTest::newRow("wide angle") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)0.0f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)270.0f + << (qreal)0.5f + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)-45.0f; +} +void tst_QQuaternion::slerp() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, angle1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, angle2); + QFETCH(qreal, t); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + QFETCH(qreal, angle3); + + QQuaternion q1 = QQuaternion::fromAxisAndAngle(x1, y1, z1, angle1); + QQuaternion q2 = QQuaternion::fromAxisAndAngle(x2, y2, z2, angle2); + QQuaternion q3 = QQuaternion::fromAxisAndAngle(x3, y3, z3, angle3); + + QQuaternion result = QQuaternion::slerp(q1, q2, t); + + QVERIFY(fuzzyCompare(result.x(), q3.x())); + QVERIFY(fuzzyCompare(result.y(), q3.y())); + QVERIFY(fuzzyCompare(result.z(), q3.z())); + QVERIFY(fuzzyCompare(result.scalar(), q3.scalar())); +} + +// Test normalized linear interpolation of quaternions. +void tst_QQuaternion::nlerp_data() +{ + slerp_data(); +} +void tst_QQuaternion::nlerp() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, angle1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, angle2); + QFETCH(qreal, t); + + QQuaternion q1 = QQuaternion::fromAxisAndAngle(x1, y1, z1, angle1); + QQuaternion q2 = QQuaternion::fromAxisAndAngle(x2, y2, z2, angle2); + + QQuaternion result = QQuaternion::nlerp(q1, q2, t); + + qreal resultx, resulty, resultz, resultscalar; + if (t <= 0.0f) { + resultx = q1.x(); + resulty = q1.y(); + resultz = q1.z(); + resultscalar = q1.scalar(); + } else if (t >= 1.0f) { + resultx = q2.x(); + resulty = q2.y(); + resultz = q2.z(); + resultscalar = q2.scalar(); + } else if (qAbs(angle1 - angle2) <= 180.f) { + resultx = q1.x() * (1 - t) + q2.x() * t; + resulty = q1.y() * (1 - t) + q2.y() * t; + resultz = q1.z() * (1 - t) + q2.z() * t; + resultscalar = q1.scalar() * (1 - t) + q2.scalar() * t; + } else { + // Angle greater than 180 degrees: negate q2. + resultx = q1.x() * (1 - t) - q2.x() * t; + resulty = q1.y() * (1 - t) - q2.y() * t; + resultz = q1.z() * (1 - t) - q2.z() * t; + resultscalar = q1.scalar() * (1 - t) - q2.scalar() * t; + } + + QQuaternion q3 = QQuaternion(resultscalar, resultx, resulty, resultz).normalized(); + + QVERIFY(fuzzyCompare(result.x(), q3.x())); + QVERIFY(fuzzyCompare(result.y(), q3.y())); + QVERIFY(fuzzyCompare(result.z(), q3.z())); + QVERIFY(fuzzyCompare(result.scalar(), q3.scalar())); +} + +class tst_QQuaternionProperties : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion) +public: + tst_QQuaternionProperties(QObject *parent = 0) : QObject(parent) {} + + QQuaternion quaternion() const { return q; } + void setQuaternion(const QQuaternion& value) { q = value; } + +private: + QQuaternion q; +}; + +// Test getting and setting quaternion properties via the metaobject system. +void tst_QQuaternion::properties() +{ + tst_QQuaternionProperties obj; + + obj.setQuaternion(QQuaternion(6.0f, 7.0f, 8.0f, 9.0f)); + + QQuaternion q = qVariantValue(obj.property("quaternion")); + QCOMPARE(q.scalar(), (qreal)6.0f); + QCOMPARE(q.x(), (qreal)7.0f); + QCOMPARE(q.y(), (qreal)8.0f); + QCOMPARE(q.z(), (qreal)9.0f); + + obj.setProperty("quaternion", + qVariantFromValue(QQuaternion(-6.0f, -7.0f, -8.0f, -9.0f))); + + q = qVariantValue(obj.property("quaternion")); + QCOMPARE(q.scalar(), (qreal)-6.0f); + QCOMPARE(q.x(), (qreal)-7.0f); + QCOMPARE(q.y(), (qreal)-8.0f); + QCOMPARE(q.z(), (qreal)-9.0f); +} + +void tst_QQuaternion::metaTypes() +{ + QVERIFY(QMetaType::type("QQuaternion") == QMetaType::QQuaternion); + + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QQuaternion)), + QByteArray("QQuaternion")); + + QVERIFY(QMetaType::isRegistered(QMetaType::QQuaternion)); + + QVERIFY(qMetaTypeId() == QMetaType::QQuaternion); +} + +QTEST_APPLESS_MAIN(tst_QQuaternion) + +#include "tst_qquaternion.moc" diff --git a/tests/auto/qvectornd/qvectornd.pro b/tests/auto/qvectornd/qvectornd.pro new file mode 100644 index 0000000..6346199 --- /dev/null +++ b/tests/auto/qvectornd/qvectornd.pro @@ -0,0 +1,2 @@ +load(qttest_p4) +SOURCES += tst_qvectornd.cpp diff --git a/tests/auto/qvectornd/tst_qvectornd.cpp b/tests/auto/qvectornd/tst_qvectornd.cpp new file mode 100644 index 0000000..22f0ce1 --- /dev/null +++ b/tests/auto/qvectornd/tst_qvectornd.cpp @@ -0,0 +1,2143 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +class tst_QVector : public QObject +{ + Q_OBJECT +public: + tst_QVector() {} + ~tst_QVector() {} + +private slots: + void create2(); + void create3(); + void create4(); + + void length2_data(); + void length2(); + void length3_data(); + void length3(); + void length4_data(); + void length4(); + + void normalized2_data(); + void normalized2(); + void normalized3_data(); + void normalized3(); + void normalized4_data(); + void normalized4(); + + void normalize2_data(); + void normalize2(); + void normalize3_data(); + void normalize3(); + void normalize4_data(); + void normalize4(); + + void compare2(); + void compare3(); + void compare4(); + + void add2_data(); + void add2(); + void add3_data(); + void add3(); + void add4_data(); + void add4(); + + void subtract2_data(); + void subtract2(); + void subtract3_data(); + void subtract3(); + void subtract4_data(); + void subtract4(); + + void multiply2_data(); + void multiply2(); + void multiply3_data(); + void multiply3(); + void multiply4_data(); + void multiply4(); + + void multiplyFactor2_data(); + void multiplyFactor2(); + void multiplyFactor3_data(); + void multiplyFactor3(); + void multiplyFactor4_data(); + void multiplyFactor4(); + + void divide2_data(); + void divide2(); + void divide3_data(); + void divide3(); + void divide4_data(); + void divide4(); + + void negate2_data(); + void negate2(); + void negate3_data(); + void negate3(); + void negate4_data(); + void negate4(); + + void crossProduct_data(); + void crossProduct(); + void normal_data(); + void normal(); + void distanceToPlane_data(); + void distanceToPlane(); + void distanceToLine_data(); + void distanceToLine(); + + void dotProduct2_data(); + void dotProduct2(); + void dotProduct3_data(); + void dotProduct3(); + void dotProduct4_data(); + void dotProduct4(); + + void properties(); + void metaTypes(); +}; + +// qFuzzyCompare isn't always "fuzzy" enough to handle conversion +// between float, double, and qreal. So create "fuzzier" compares. +static bool fuzzyCompare(float x, float y) +{ + float diff = x - y; + if (diff < 0.0f) + diff = -diff; + return (diff < 0.001); +} + +// Test the creation of QVector2D objects in various ways: +// construct, copy, and modify. +void tst_QVector::create2() +{ + QVector2D null; + QCOMPARE(null.x(), (qreal)0.0f); + QCOMPARE(null.y(), (qreal)0.0f); + QVERIFY(null.isNull()); + + QVector2D v1(1.0f, 2.5f); + QCOMPARE(v1.x(), (qreal)1.0f); + QCOMPARE(v1.y(), (qreal)2.5f); + QVERIFY(!v1.isNull()); + + QVector2D v1i(1, 2); + QCOMPARE(v1i.x(), (qreal)1.0f); + QCOMPARE(v1i.y(), (qreal)2.0f); + QVERIFY(!v1i.isNull()); + + QVector2D v2(v1); + QCOMPARE(v2.x(), (qreal)1.0f); + QCOMPARE(v2.y(), (qreal)2.5f); + QVERIFY(!v2.isNull()); + + QVector2D v4; + QCOMPARE(v4.x(), (qreal)0.0f); + QCOMPARE(v4.y(), (qreal)0.0f); + QVERIFY(v4.isNull()); + v4 = v1; + QCOMPARE(v4.x(), (qreal)1.0f); + QCOMPARE(v4.y(), (qreal)2.5f); + QVERIFY(!v4.isNull()); + + QVector2D v5(QPoint(1, 2)); + QCOMPARE(v5.x(), (qreal)1.0f); + QCOMPARE(v5.y(), (qreal)2.0f); + QVERIFY(!v5.isNull()); + + QVector2D v6(QPointF(1, 2.5)); + QCOMPARE(v6.x(), (qreal)1.0f); + QCOMPARE(v6.y(), (qreal)2.5f); + QVERIFY(!v6.isNull()); + + QVector2D v7(QVector3D(1.0f, 2.5f, 54.25f)); + QCOMPARE(v7.x(), (qreal)1.0f); + QCOMPARE(v7.y(), (qreal)2.5f); + QVERIFY(!v6.isNull()); + + QVector2D v8(QVector4D(1.0f, 2.5f, 54.25f, 34.0f)); + QCOMPARE(v8.x(), (qreal)1.0f); + QCOMPARE(v8.y(), (qreal)2.5f); + QVERIFY(!v6.isNull()); + + v1.setX(3.0f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)2.5f); + QVERIFY(!v1.isNull()); + + v1.setY(10.5f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)10.5f); + QVERIFY(!v1.isNull()); + + v1.setX(0.0f); + v1.setY(0.0f); + QCOMPARE(v1.x(), (qreal)0.0f); + QCOMPARE(v1.y(), (qreal)0.0f); + QVERIFY(v1.isNull()); + + QPoint p1 = v8.toPoint(); + QCOMPARE(p1.x(), 1); + QCOMPARE(p1.y(), 3); + + QPointF p2 = v8.toPointF(); + QCOMPARE((qreal)p2.x(), (qreal)1.0f); + QCOMPARE((qreal)p2.y(), (qreal)2.5f); + + QVector3D v9 = v8.toVector3D(); + QCOMPARE(v9.x(), (qreal)1.0f); + QCOMPARE(v9.y(), (qreal)2.5f); + QCOMPARE(v9.z(), (qreal)0.0f); + + QVector4D v10 = v8.toVector4D(); + QCOMPARE(v10.x(), (qreal)1.0f); + QCOMPARE(v10.y(), (qreal)2.5f); + QCOMPARE(v10.z(), (qreal)0.0f); + QCOMPARE(v10.w(), (qreal)0.0f); +} + +// Test the creation of QVector3D objects in various ways: +// construct, copy, and modify. +void tst_QVector::create3() +{ + QVector3D null; + QCOMPARE(null.x(), (qreal)0.0f); + QCOMPARE(null.y(), (qreal)0.0f); + QCOMPARE(null.z(), (qreal)0.0f); + QVERIFY(null.isNull()); + + QVector3D v1(1.0f, 2.5f, -89.25f); + QCOMPARE(v1.x(), (qreal)1.0f); + QCOMPARE(v1.y(), (qreal)2.5f); + QCOMPARE(v1.z(), (qreal)-89.25f); + QVERIFY(!v1.isNull()); + + QVector3D v1i(1, 2, -89); + QCOMPARE(v1i.x(), (qreal)1.0f); + QCOMPARE(v1i.y(), (qreal)2.0f); + QCOMPARE(v1i.z(), (qreal)-89.0f); + QVERIFY(!v1i.isNull()); + + QVector3D v2(v1); + QCOMPARE(v2.x(), (qreal)1.0f); + QCOMPARE(v2.y(), (qreal)2.5f); + QCOMPARE(v2.z(), (qreal)-89.25f); + QVERIFY(!v2.isNull()); + + QVector3D v3(1.0f, 2.5f, 0.0f); + QCOMPARE(v3.x(), (qreal)1.0f); + QCOMPARE(v3.y(), (qreal)2.5f); + QCOMPARE(v3.z(), (qreal)0.0f); + QVERIFY(!v3.isNull()); + + QVector3D v3i(1, 2, 0); + QCOMPARE(v3i.x(), (qreal)1.0f); + QCOMPARE(v3i.y(), (qreal)2.0f); + QCOMPARE(v3i.z(), (qreal)0.0f); + QVERIFY(!v3i.isNull()); + + QVector3D v4; + QCOMPARE(v4.x(), (qreal)0.0f); + QCOMPARE(v4.y(), (qreal)0.0f); + QCOMPARE(v4.z(), (qreal)0.0f); + QVERIFY(v4.isNull()); + v4 = v1; + QCOMPARE(v4.x(), (qreal)1.0f); + QCOMPARE(v4.y(), (qreal)2.5f); + QCOMPARE(v4.z(), (qreal)-89.25f); + QVERIFY(!v4.isNull()); + + QVector3D v5(QPoint(1, 2)); + QCOMPARE(v5.x(), (qreal)1.0f); + QCOMPARE(v5.y(), (qreal)2.0f); + QCOMPARE(v5.z(), (qreal)0.0f); + QVERIFY(!v5.isNull()); + + QVector3D v6(QPointF(1, 2.5)); + QCOMPARE(v6.x(), (qreal)1.0f); + QCOMPARE(v6.y(), (qreal)2.5f); + QCOMPARE(v6.z(), (qreal)0.0f); + QVERIFY(!v6.isNull()); + + QVector3D v7(QVector2D(1.0f, 2.5f)); + QCOMPARE(v7.x(), (qreal)1.0f); + QCOMPARE(v7.y(), (qreal)2.5f); + QCOMPARE(v7.z(), (qreal)0.0f); + QVERIFY(!v7.isNull()); + + QVector3D v8(QVector2D(1.0f, 2.5f), 54.25f); + QCOMPARE(v8.x(), (qreal)1.0f); + QCOMPARE(v8.y(), (qreal)2.5f); + QCOMPARE(v8.z(), (qreal)54.25f); + QVERIFY(!v8.isNull()); + + QVector3D v9(QVector4D(1.0f, 2.5f, 54.25f, 34.0f)); + QCOMPARE(v9.x(), (qreal)1.0f); + QCOMPARE(v9.y(), (qreal)2.5f); + QCOMPARE(v9.z(), (qreal)54.25f); + QVERIFY(!v9.isNull()); + + v1.setX(3.0f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)2.5f); + QCOMPARE(v1.z(), (qreal)-89.25f); + QVERIFY(!v1.isNull()); + + v1.setY(10.5f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)10.5f); + QCOMPARE(v1.z(), (qreal)-89.25f); + QVERIFY(!v1.isNull()); + + v1.setZ(15.5f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)10.5f); + QCOMPARE(v1.z(), (qreal)15.5f); + QVERIFY(!v1.isNull()); + + v1.setX(0.0f); + v1.setY(0.0f); + v1.setZ(0.0f); + QCOMPARE(v1.x(), (qreal)0.0f); + QCOMPARE(v1.y(), (qreal)0.0f); + QCOMPARE(v1.z(), (qreal)0.0f); + QVERIFY(v1.isNull()); + + QPoint p1 = v8.toPoint(); + QCOMPARE(p1.x(), 1); + QCOMPARE(p1.y(), 3); + + QPointF p2 = v8.toPointF(); + QCOMPARE((qreal)p2.x(), (qreal)1.0f); + QCOMPARE((qreal)p2.y(), (qreal)2.5f); + + QVector2D v10 = v8.toVector2D(); + QCOMPARE(v10.x(), (qreal)1.0f); + QCOMPARE(v10.y(), (qreal)2.5f); + + QVector4D v11 = v8.toVector4D(); + QCOMPARE(v11.x(), (qreal)1.0f); + QCOMPARE(v11.y(), (qreal)2.5f); + QCOMPARE(v11.z(), (qreal)54.25f); + QCOMPARE(v11.w(), (qreal)0.0f); +} + +// Test the creation of QVector4D objects in various ways: +// construct, copy, and modify. +void tst_QVector::create4() +{ + QVector4D null; + QCOMPARE(null.x(), (qreal)0.0f); + QCOMPARE(null.y(), (qreal)0.0f); + QCOMPARE(null.z(), (qreal)0.0f); + QCOMPARE(null.w(), (qreal)0.0f); + QVERIFY(null.isNull()); + + QVector4D v1(1.0f, 2.5f, -89.25f, 34.0f); + QCOMPARE(v1.x(), (qreal)1.0f); + QCOMPARE(v1.y(), (qreal)2.5f); + QCOMPARE(v1.z(), (qreal)-89.25f); + QCOMPARE(v1.w(), (qreal)34.0f); + QVERIFY(!v1.isNull()); + + QVector4D v1i(1, 2, -89, 34); + QCOMPARE(v1i.x(), (qreal)1.0f); + QCOMPARE(v1i.y(), (qreal)2.0f); + QCOMPARE(v1i.z(), (qreal)-89.0f); + QCOMPARE(v1i.w(), (qreal)34.0f); + QVERIFY(!v1i.isNull()); + + QVector4D v2(v1); + QCOMPARE(v2.x(), (qreal)1.0f); + QCOMPARE(v2.y(), (qreal)2.5f); + QCOMPARE(v2.z(), (qreal)-89.25f); + QCOMPARE(v2.w(), (qreal)34.0f); + QVERIFY(!v2.isNull()); + + QVector4D v3(1.0f, 2.5f, 0.0f, 0.0f); + QCOMPARE(v3.x(), (qreal)1.0f); + QCOMPARE(v3.y(), (qreal)2.5f); + QCOMPARE(v3.z(), (qreal)0.0f); + QCOMPARE(v3.w(), (qreal)0.0f); + QVERIFY(!v3.isNull()); + + QVector4D v3i(1, 2, 0, 0); + QCOMPARE(v3i.x(), (qreal)1.0f); + QCOMPARE(v3i.y(), (qreal)2.0f); + QCOMPARE(v3i.z(), (qreal)0.0f); + QCOMPARE(v3i.w(), (qreal)0.0f); + QVERIFY(!v3i.isNull()); + + QVector4D v3b(1.0f, 2.5f, -89.25f, 0.0f); + QCOMPARE(v3b.x(), (qreal)1.0f); + QCOMPARE(v3b.y(), (qreal)2.5f); + QCOMPARE(v3b.z(), (qreal)-89.25f); + QCOMPARE(v3b.w(), (qreal)0.0f); + QVERIFY(!v3b.isNull()); + + QVector4D v3bi(1, 2, -89, 0); + QCOMPARE(v3bi.x(), (qreal)1.0f); + QCOMPARE(v3bi.y(), (qreal)2.0f); + QCOMPARE(v3bi.z(), (qreal)-89.0f); + QCOMPARE(v3bi.w(), (qreal)0.0f); + QVERIFY(!v3bi.isNull()); + + QVector4D v4; + QCOMPARE(v4.x(), (qreal)0.0f); + QCOMPARE(v4.y(), (qreal)0.0f); + QCOMPARE(v4.z(), (qreal)0.0f); + QCOMPARE(v4.w(), (qreal)0.0f); + QVERIFY(v4.isNull()); + v4 = v1; + QCOMPARE(v4.x(), (qreal)1.0f); + QCOMPARE(v4.y(), (qreal)2.5f); + QCOMPARE(v4.z(), (qreal)-89.25f); + QCOMPARE(v4.w(), (qreal)34.0f); + QVERIFY(!v4.isNull()); + + QVector4D v5(QPoint(1, 2)); + QCOMPARE(v5.x(), (qreal)1.0f); + QCOMPARE(v5.y(), (qreal)2.0f); + QCOMPARE(v5.z(), (qreal)0.0f); + QCOMPARE(v5.w(), (qreal)0.0f); + QVERIFY(!v5.isNull()); + + QVector4D v6(QPointF(1, 2.5)); + QCOMPARE(v6.x(), (qreal)1.0f); + QCOMPARE(v6.y(), (qreal)2.5f); + QCOMPARE(v6.z(), (qreal)0.0f); + QCOMPARE(v6.w(), (qreal)0.0f); + QVERIFY(!v6.isNull()); + + QVector4D v7(QVector2D(1.0f, 2.5f)); + QCOMPARE(v7.x(), (qreal)1.0f); + QCOMPARE(v7.y(), (qreal)2.5f); + QCOMPARE(v7.z(), (qreal)0.0f); + QCOMPARE(v7.w(), (qreal)0.0f); + QVERIFY(!v7.isNull()); + + QVector4D v8(QVector3D(1.0f, 2.5f, -89.25f)); + QCOMPARE(v8.x(), (qreal)1.0f); + QCOMPARE(v8.y(), (qreal)2.5f); + QCOMPARE(v8.z(), (qreal)-89.25f); + QCOMPARE(v8.w(), (qreal)0.0f); + QVERIFY(!v8.isNull()); + + QVector4D v9(QVector3D(1.0f, 2.5f, -89.25f), 34); + QCOMPARE(v9.x(), (qreal)1.0f); + QCOMPARE(v9.y(), (qreal)2.5f); + QCOMPARE(v9.z(), (qreal)-89.25f); + QCOMPARE(v9.w(), (qreal)34.0f); + QVERIFY(!v9.isNull()); + + QVector4D v10(QVector2D(1.0f, 2.5f), 23.5f, -8); + QCOMPARE(v10.x(), (qreal)1.0f); + QCOMPARE(v10.y(), (qreal)2.5f); + QCOMPARE(v10.z(), (qreal)23.5f); + QCOMPARE(v10.w(), (qreal)-8.0f); + QVERIFY(!v10.isNull()); + + v1.setX(3.0f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)2.5f); + QCOMPARE(v1.z(), (qreal)-89.25f); + QCOMPARE(v1.w(), (qreal)34.0f); + QVERIFY(!v1.isNull()); + + v1.setY(10.5f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)10.5f); + QCOMPARE(v1.z(), (qreal)-89.25f); + QCOMPARE(v1.w(), (qreal)34.0f); + QVERIFY(!v1.isNull()); + + v1.setZ(15.5f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)10.5f); + QCOMPARE(v1.z(), (qreal)15.5f); + QCOMPARE(v1.w(), (qreal)34.0f); + QVERIFY(!v1.isNull()); + + v1.setW(6.0f); + QCOMPARE(v1.x(), (qreal)3.0f); + QCOMPARE(v1.y(), (qreal)10.5f); + QCOMPARE(v1.z(), (qreal)15.5f); + QCOMPARE(v1.w(), (qreal)6.0f); + QVERIFY(!v1.isNull()); + + v1.setX(0.0f); + v1.setY(0.0f); + v1.setZ(0.0f); + v1.setW(0.0f); + QCOMPARE(v1.x(), (qreal)0.0f); + QCOMPARE(v1.y(), (qreal)0.0f); + QCOMPARE(v1.z(), (qreal)0.0f); + QCOMPARE(v1.w(), (qreal)0.0f); + QVERIFY(v1.isNull()); + + QPoint p1 = v8.toPoint(); + QCOMPARE(p1.x(), 1); + QCOMPARE(p1.y(), 3); + + QPointF p2 = v8.toPointF(); + QCOMPARE((qreal)p2.x(), (qreal)1.0f); + QCOMPARE((qreal)p2.y(), (qreal)2.5f); + + QVector2D v11 = v8.toVector2D(); + QCOMPARE(v11.x(), (qreal)1.0f); + QCOMPARE(v11.y(), (qreal)2.5f); + + QVector3D v12 = v8.toVector3D(); + QCOMPARE(v12.x(), (qreal)1.0f); + QCOMPARE(v12.y(), (qreal)2.5f); + QCOMPARE(v12.z(), (qreal)-89.25f); + + QVector2D v13 = v9.toVector2DAffine(); + QVERIFY(fuzzyCompare(v13.x(), (qreal)(1.0f / 34.0f))); + QVERIFY(fuzzyCompare(v13.y(), (qreal)(2.5f / 34.0f))); + + QVector4D zerow(1.0f, 2.0f, 3.0f, 0.0f); + v13 = zerow.toVector2DAffine(); + QVERIFY(v13.isNull()); + + QVector3D v14 = v9.toVector3DAffine(); + QVERIFY(fuzzyCompare(v14.x(), (qreal)(1.0f / 34.0f))); + QVERIFY(fuzzyCompare(v14.y(), (qreal)(2.5f / 34.0f))); + QVERIFY(fuzzyCompare(v14.z(), (qreal)(-89.25f / 34.0f))); + + v14 = zerow.toVector3DAffine(); + QVERIFY(v14.isNull()); +} + +// Test vector length computation for 2D vectors. +void tst_QVector::length2_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("len"); + + QTest::newRow("null") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + QTest::newRow("1x") << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("1y") << (qreal)0.0f << (qreal)1.0f << (qreal)1.0f; + QTest::newRow("-1x") << (qreal)-1.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; + QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)qSqrt(8.0f); +} +void tst_QVector::length2() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, len); + + QVector2D v(x, y); + QCOMPARE((float)(v.length()), (float)len); + QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y)); +} + +// Test vector length computation for 3D vectors. +void tst_QVector::length3_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("z"); + QTest::addColumn("len"); + + QTest::newRow("null") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + QTest::newRow("1x") << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("1y") << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("1z") << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)1.0f; + QTest::newRow("-1x") << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("-1z") << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; + QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)qSqrt(12.0f); +} +void tst_QVector::length3() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(qreal, len); + + QVector3D v(x, y, z); + QCOMPARE((float)(v.length()), (float)len); + QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y + z * z)); +} + +// Test vector length computation for 4D vectors. +void tst_QVector::length4_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("z"); + QTest::addColumn("w"); + QTest::addColumn("len"); + + QTest::newRow("null") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + QTest::newRow("1x") << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("1y") << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("1z") << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)1.0f; + QTest::newRow("-1x") << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("-1z") << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)0.0f << (qreal)1.0f; + QTest::newRow("-1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; + QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)2.0f << (qreal)qSqrt(16.0f); +} +void tst_QVector::length4() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(qreal, w); + QFETCH(qreal, len); + + QVector4D v(x, y, z, w); + QCOMPARE((float)(v.length()), (float)len); + QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y + z * z + w * w)); +} + +// Test the unit vector conversion for 2D vectors. +void tst_QVector::normalized2_data() +{ + // Use the same test data as the length test. + length2_data(); +} +void tst_QVector::normalized2() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, len); + + QVector2D v(x, y); + QVector2D u = v.normalized(); + if (v.isNull()) + QVERIFY(u.isNull()); + else + QCOMPARE((float)(u.length()), (float)1.0f); + QCOMPARE((float)(u.x() * len), (float)(v.x())); + QCOMPARE((float)(u.y() * len), (float)(v.y())); +} + +// Test the unit vector conversion for 3D vectors. +void tst_QVector::normalized3_data() +{ + // Use the same test data as the length test. + length3_data(); +} +void tst_QVector::normalized3() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(qreal, len); + + QVector3D v(x, y, z); + QVector3D u = v.normalized(); + if (v.isNull()) + QVERIFY(u.isNull()); + else + QCOMPARE((float)(u.length()), (float)1.0f); + QCOMPARE((float)(u.x() * len), (float)(v.x())); + QCOMPARE((float)(u.y() * len), (float)(v.y())); + QCOMPARE((float)(u.z() * len), (float)(v.z())); +} + +// Test the unit vector conversion for 4D vectors. +void tst_QVector::normalized4_data() +{ + // Use the same test data as the length test. + length4_data(); +} +void tst_QVector::normalized4() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(qreal, w); + QFETCH(qreal, len); + + QVector4D v(x, y, z, w); + QVector4D u = v.normalized(); + if (v.isNull()) + QVERIFY(u.isNull()); + else + QCOMPARE((float)(u.length()), (float)1.0f); + QCOMPARE((float)(u.x() * len), (float)(v.x())); + QCOMPARE((float)(u.y() * len), (float)(v.y())); + QCOMPARE((float)(u.z() * len), (float)(v.z())); + QCOMPARE((float)(u.w() * len), (float)(v.w())); +} + +// Test the unit vector conversion for 2D vectors. +void tst_QVector::normalize2_data() +{ + // Use the same test data as the length test. + length2_data(); +} +void tst_QVector::normalize2() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + + QVector2D v(x, y); + bool isNull = v.isNull(); + v.normalize(); + if (isNull) + QVERIFY(v.isNull()); + else + QCOMPARE((float)(v.length()), (float)1.0f); +} + +// Test the unit vector conversion for 3D vectors. +void tst_QVector::normalize3_data() +{ + // Use the same test data as the length test. + length3_data(); +} +void tst_QVector::normalize3() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + + QVector3D v(x, y, z); + bool isNull = v.isNull(); + v.normalize(); + if (isNull) + QVERIFY(v.isNull()); + else + QCOMPARE((float)(v.length()), (float)1.0f); +} + +// Test the unit vector conversion for 4D vectors. +void tst_QVector::normalize4_data() +{ + // Use the same test data as the length test. + length4_data(); +} +void tst_QVector::normalize4() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, z); + QFETCH(qreal, w); + + QVector4D v(x, y, z, w); + bool isNull = v.isNull(); + v.normalize(); + if (isNull) + QVERIFY(v.isNull()); + else + QCOMPARE((float)(v.length()), (float)1.0f); +} + +// Test the comparison operators for 2D vectors. +void tst_QVector::compare2() +{ + QVector2D v1(1, 2); + QVector2D v2(1, 2); + QVector2D v3(3, 2); + QVector2D v4(1, 3); + + QVERIFY(v1 == v2); + QVERIFY(v1 != v3); + QVERIFY(v1 != v4); +} + +// Test the comparison operators for 3D vectors. +void tst_QVector::compare3() +{ + QVector3D v1(1, 2, 4); + QVector3D v2(1, 2, 4); + QVector3D v3(3, 2, 4); + QVector3D v4(1, 3, 4); + QVector3D v5(1, 2, 3); + + QVERIFY(v1 == v2); + QVERIFY(v1 != v3); + QVERIFY(v1 != v4); + QVERIFY(v1 != v5); +} + +// Test the comparison operators for 4D vectors. +void tst_QVector::compare4() +{ + QVector4D v1(1, 2, 4, 8); + QVector4D v2(1, 2, 4, 8); + QVector4D v3(3, 2, 4, 8); + QVector4D v4(1, 3, 4, 8); + QVector4D v5(1, 2, 3, 8); + QVector4D v6(1, 2, 4, 3); + + QVERIFY(v1 == v2); + QVERIFY(v1 != v3); + QVERIFY(v1 != v4); + QVERIFY(v1 != v5); + QVERIFY(v1 != v6); +} + +// Test vector addition for 2D vectors. +void tst_QVector::add2_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("x3"); + QTest::addColumn("y3"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f + << (qreal)3.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)2.0f + << (qreal)0.0f << (qreal)3.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f + << (qreal)4.0f << (qreal)5.0f + << (qreal)5.0f << (qreal)7.0f; +} +void tst_QVector::add2() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + + QVector2D v1(x1, y1); + QVector2D v2(x2, y2); + QVector2D v3(x3, y3); + + QVERIFY((v1 + v2) == v3); + + QVector2D v4(v1); + v4 += v2; + QVERIFY(v4 == v3); + + QCOMPARE(v4.x(), v1.x() + v2.x()); + QCOMPARE(v4.y(), v1.y() + v2.y()); +} + +// Test vector addition for 3D vectors. +void tst_QVector::add3_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("x3"); + QTest::addColumn("y3"); + QTest::addColumn("z3"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f; + + QTest::newRow("zonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f + << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f + << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f; +} +void tst_QVector::add3() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + QVector3D v3(x3, y3, z3); + + QVERIFY((v1 + v2) == v3); + + QVector3D v4(v1); + v4 += v2; + QVERIFY(v4 == v3); + + QCOMPARE(v4.x(), v1.x() + v2.x()); + QCOMPARE(v4.y(), v1.y() + v2.y()); + QCOMPARE(v4.z(), v1.z() + v2.z()); +} + +// Test vector addition for 4D vectors. +void tst_QVector::add4_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("w1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("w2"); + QTest::addColumn("x3"); + QTest::addColumn("y3"); + QTest::addColumn("z3"); + QTest::addColumn("w3"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("zonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f << (qreal)0.0f; + + QTest::newRow("wonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)3.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)8.0f + << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f + << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f << (qreal)17.0f; +} +void tst_QVector::add4() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + QFETCH(qreal, w3); + + QVector4D v1(x1, y1, z1, w1); + QVector4D v2(x2, y2, z2, w2); + QVector4D v3(x3, y3, z3, w3); + + QVERIFY((v1 + v2) == v3); + + QVector4D v4(v1); + v4 += v2; + QVERIFY(v4 == v3); + + QCOMPARE(v4.x(), v1.x() + v2.x()); + QCOMPARE(v4.y(), v1.y() + v2.y()); + QCOMPARE(v4.z(), v1.z() + v2.z()); + QCOMPARE(v4.w(), v1.w() + v2.w()); +} + +// Test vector subtraction for 2D vectors. +void tst_QVector::subtract2_data() +{ + // Use the same test data as the add test. + add2_data(); +} +void tst_QVector::subtract2() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + + QVector2D v1(x1, y1); + QVector2D v2(x2, y2); + QVector2D v3(x3, y3); + + QVERIFY((v3 - v1) == v2); + QVERIFY((v3 - v2) == v1); + + QVector2D v4(v3); + v4 -= v1; + QVERIFY(v4 == v2); + + QCOMPARE(v4.x(), v3.x() - v1.x()); + QCOMPARE(v4.y(), v3.y() - v1.y()); + + QVector2D v5(v3); + v5 -= v2; + QVERIFY(v5 == v1); + + QCOMPARE(v5.x(), v3.x() - v2.x()); + QCOMPARE(v5.y(), v3.y() - v2.y()); +} + +// Test vector subtraction for 3D vectors. +void tst_QVector::subtract3_data() +{ + // Use the same test data as the add test. + add3_data(); +} +void tst_QVector::subtract3() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + QVector3D v3(x3, y3, z3); + + QVERIFY((v3 - v1) == v2); + QVERIFY((v3 - v2) == v1); + + QVector3D v4(v3); + v4 -= v1; + QVERIFY(v4 == v2); + + QCOMPARE(v4.x(), v3.x() - v1.x()); + QCOMPARE(v4.y(), v3.y() - v1.y()); + QCOMPARE(v4.z(), v3.z() - v1.z()); + + QVector3D v5(v3); + v5 -= v2; + QVERIFY(v5 == v1); + + QCOMPARE(v5.x(), v3.x() - v2.x()); + QCOMPARE(v5.y(), v3.y() - v2.y()); + QCOMPARE(v5.z(), v3.z() - v2.z()); +} + +// Test vector subtraction for 4D vectors. +void tst_QVector::subtract4_data() +{ + // Use the same test data as the add test. + add4_data(); +} +void tst_QVector::subtract4() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + QFETCH(qreal, w3); + + QVector4D v1(x1, y1, z1, w1); + QVector4D v2(x2, y2, z2, w2); + QVector4D v3(x3, y3, z3, w3); + + QVERIFY((v3 - v1) == v2); + QVERIFY((v3 - v2) == v1); + + QVector4D v4(v3); + v4 -= v1; + QVERIFY(v4 == v2); + + QCOMPARE(v4.x(), v3.x() - v1.x()); + QCOMPARE(v4.y(), v3.y() - v1.y()); + QCOMPARE(v4.z(), v3.z() - v1.z()); + QCOMPARE(v4.w(), v3.w() - v1.w()); + + QVector4D v5(v3); + v5 -= v2; + QVERIFY(v5 == v1); + + QCOMPARE(v5.x(), v3.x() - v2.x()); + QCOMPARE(v5.y(), v3.y() - v2.y()); + QCOMPARE(v5.z(), v3.z() - v2.z()); + QCOMPARE(v5.w(), v3.w() - v2.w()); +} + +// Test component-wise vector multiplication for 2D vectors. +void tst_QVector::multiply2_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("x3"); + QTest::addColumn("y3"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)2.0f + << (qreal)0.0f << (qreal)2.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f + << (qreal)4.0f << (qreal)5.0f + << (qreal)4.0f << (qreal)10.0f; +} +void tst_QVector::multiply2() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + + QVector2D v1(x1, y1); + QVector2D v2(x2, y2); + QVector2D v3(x3, y3); + + QVERIFY((v1 * v2) == v3); + + QVector2D v4(v1); + v4 *= v2; + QVERIFY(v4 == v3); + + QCOMPARE(v4.x(), v1.x() * v2.x()); + QCOMPARE(v4.y(), v1.y() * v2.y()); +} + +// Test component-wise vector multiplication for 3D vectors. +void tst_QVector::multiply3_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("x3"); + QTest::addColumn("y3"); + QTest::addColumn("z3"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; + + QTest::newRow("zonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f + << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f + << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f; +} +void tst_QVector::multiply3() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + QVector3D v3(x3, y3, z3); + + QVERIFY((v1 * v2) == v3); + + QVector3D v4(v1); + v4 *= v2; + QVERIFY(v4 == v3); + + QCOMPARE(v4.x(), v1.x() * v2.x()); + QCOMPARE(v4.y(), v1.y() * v2.y()); + QCOMPARE(v4.z(), v1.z() * v2.z()); +} + +// Test component-wise vector multiplication for 4D vectors. +void tst_QVector::multiply4_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("w1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("w2"); + QTest::addColumn("x3"); + QTest::addColumn("y3"); + QTest::addColumn("z3"); + QTest::addColumn("w3"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("zonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; + + QTest::newRow("wonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)8.0f + << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f + << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f << (qreal)72.0f; +} +void tst_QVector::multiply4() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + QFETCH(qreal, w3); + + QVector4D v1(x1, y1, z1, w1); + QVector4D v2(x2, y2, z2, w2); + QVector4D v3(x3, y3, z3, w3); + + QVERIFY((v1 * v2) == v3); + + QVector4D v4(v1); + v4 *= v2; + QVERIFY(v4 == v3); + + QCOMPARE(v4.x(), v1.x() * v2.x()); + QCOMPARE(v4.y(), v1.y() * v2.y()); + QCOMPARE(v4.z(), v1.z() * v2.z()); + QCOMPARE(v4.w(), v1.w() * v2.w()); +} + +// Test vector multiplication by a factor for 2D vectors. +void tst_QVector::multiplyFactor2_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("factor"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f + << (qreal)100.0f + << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f + << (qreal)2.0f + << (qreal)2.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f + << (qreal)2.0f + << (qreal)0.0f << (qreal)2.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f + << (qreal)2.0f + << (qreal)2.0f << (qreal)4.0f; + + QTest::newRow("allzero") + << (qreal)1.0f << (qreal)2.0f + << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f; +} +void tst_QVector::multiplyFactor2() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, factor); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + + QVector2D v1(x1, y1); + QVector2D v2(x2, y2); + + QVERIFY((v1 * factor) == v2); + QVERIFY((factor * v1) == v2); + + QVector2D v3(v1); + v3 *= factor; + QVERIFY(v3 == v2); + + QCOMPARE(v3.x(), v1.x() * factor); + QCOMPARE(v3.y(), v1.y() * factor); +} + +// Test vector multiplication by a factor for 3D vectors. +void tst_QVector::multiplyFactor3_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("factor"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)100.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (qreal)2.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; + + QTest::newRow("zonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f + << (qreal)2.0f + << (qreal)2.0f << (qreal)4.0f << (qreal)-6.0f; + + QTest::newRow("allzero") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f + << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; +} +void tst_QVector::multiplyFactor3() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, factor); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + + QVERIFY((v1 * factor) == v2); + QVERIFY((factor * v1) == v2); + + QVector3D v3(v1); + v3 *= factor; + QVERIFY(v3 == v2); + + QCOMPARE(v3.x(), v1.x() * factor); + QCOMPARE(v3.y(), v1.y() * factor); + QCOMPARE(v3.z(), v1.z() * factor); +} + +// Test vector multiplication by a factor for 4D vectors. +void tst_QVector::multiplyFactor4_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("w1"); + QTest::addColumn("factor"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("w2"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)100.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("xonly") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f + << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("yonly") + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)2.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)0.0f; + + QTest::newRow("zonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f; + + QTest::newRow("wonly") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)2.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f; + + QTest::newRow("all") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)4.0f + << (qreal)2.0f + << (qreal)2.0f << (qreal)4.0f << (qreal)-6.0f << (qreal)8.0f; + + QTest::newRow("allzero") + << (qreal)1.0f << (qreal)2.0f << (qreal)-3.0f << (qreal)4.0f + << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; +} +void tst_QVector::multiplyFactor4() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, factor); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + + QVector4D v1(x1, y1, z1, w1); + QVector4D v2(x2, y2, z2, w2); + + QVERIFY((v1 * factor) == v2); + QVERIFY((factor * v1) == v2); + + QVector4D v3(v1); + v3 *= factor; + QVERIFY(v3 == v2); + + QCOMPARE(v3.x(), v1.x() * factor); + QCOMPARE(v3.y(), v1.y() * factor); + QCOMPARE(v3.z(), v1.z() * factor); + QCOMPARE(v3.w(), v1.w() * factor); +} + +// Test vector division by a factor for 2D vectors. +void tst_QVector::divide2_data() +{ + // Use the same test data as the multiply test. + multiplyFactor2_data(); +} +void tst_QVector::divide2() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, factor); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + + QVector2D v1(x1, y1); + QVector2D v2(x2, y2); + + if (factor == (qreal)0.0f) + return; + + QVERIFY((v2 / factor) == v1); + + QVector2D v3(v2); + v3 /= factor; + QVERIFY(v3 == v1); + + QCOMPARE(v3.x(), v2.x() / factor); + QCOMPARE(v3.y(), v2.y() / factor); +} + +// Test vector division by a factor for 3D vectors. +void tst_QVector::divide3_data() +{ + // Use the same test data as the multiply test. + multiplyFactor3_data(); +} +void tst_QVector::divide3() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, factor); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + + if (factor == (qreal)0.0f) + return; + + QVERIFY((v2 / factor) == v1); + + QVector3D v3(v2); + v3 /= factor; + QVERIFY(v3 == v1); + + QCOMPARE(v3.x(), v2.x() / factor); + QCOMPARE(v3.y(), v2.y() / factor); + QCOMPARE(v3.z(), v2.z() / factor); +} + +// Test vector division by a factor for 4D vectors. +void tst_QVector::divide4_data() +{ + // Use the same test data as the multiply test. + multiplyFactor4_data(); +} +void tst_QVector::divide4() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, factor); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + + QVector4D v1(x1, y1, z1, w1); + QVector4D v2(x2, y2, z2, w2); + + if (factor == (qreal)0.0f) + return; + + QVERIFY((v2 / factor) == v1); + + QVector4D v3(v2); + v3 /= factor; + QVERIFY(v3 == v1); + + QCOMPARE(v3.x(), v2.x() / factor); + QCOMPARE(v3.y(), v2.y() / factor); + QCOMPARE(v3.z(), v2.z() / factor); + QCOMPARE(v3.w(), v2.w() / factor); +} + +// Test vector negation for 2D vectors. +void tst_QVector::negate2_data() +{ + // Use the same test data as the add test. + add2_data(); +} +void tst_QVector::negate2() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + + QVector2D v1(x1, y1); + QVector2D v2(-x1, -y1); + + QVERIFY(-v1 == v2); +} + +// Test vector negation for 3D vectors. +void tst_QVector::negate3_data() +{ + // Use the same test data as the add test. + add3_data(); +} +void tst_QVector::negate3() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + + QVector3D v1(x1, y1, z1); + QVector3D v2(-x1, -y1, -z1); + + QVERIFY(-v1 == v2); +} + +// Test vector negation for 4D vectors. +void tst_QVector::negate4_data() +{ + // Use the same test data as the add test. + add4_data(); +} +void tst_QVector::negate4() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + + QVector4D v1(x1, y1, z1, w1); + QVector4D v2(-x1, -y1, -z1, -w1); + + QVERIFY(-v1 == v2); +} + +// Test the computation of vector cross-products. +void tst_QVector::crossProduct_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("x3"); + QTest::addColumn("y3"); + QTest::addColumn("z3"); + QTest::addColumn("dot"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f; + + QTest::newRow("unitvec") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f; + + QTest::newRow("complex") + << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f + << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f + << (qreal)-3.0f << (qreal)6.0f << (qreal)-3.0f + << (qreal)32.0f; +} +void tst_QVector::crossProduct() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + QVector3D v3(x3, y3, z3); + + QVector3D v4 = QVector3D::crossProduct(v1, v2); + QVERIFY(v4 == v3); + + // Compute the cross-product long-hand and check again. + qreal xres = y1 * z2 - z1 * y2; + qreal yres = z1 * x2 - x1 * z2; + qreal zres = x1 * y2 - y1 * x2; + + QCOMPARE(v4.x(), xres); + QCOMPARE(v4.y(), yres); + QCOMPARE(v4.z(), zres); +} + +// Test the computation of normals. +void tst_QVector::normal_data() +{ + // Use the same test data as the crossProduct test. + crossProduct_data(); +} +void tst_QVector::normal() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + QVector3D v3(x3, y3, z3); + + QVERIFY(QVector3D::normal(v1, v2) == v3.normalized()); + QVERIFY(QVector3D::normal(QVector3D(), v1, v2) == v3.normalized()); + + QVector3D point(1.0f, 2.0f, 3.0f); + QVERIFY(QVector3D::normal(point, v1 + point, v2 + point) == v3.normalized()); +} + +// Test distance to plane calculations. +void tst_QVector::distanceToPlane_data() +{ + QTest::addColumn("x1"); // Point on plane + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("x2"); // Normal to plane + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("x3"); // Point to test for distance + QTest::addColumn("y3"); + QTest::addColumn("z3"); + QTest::addColumn("x4"); // Second point on plane + QTest::addColumn("y4"); + QTest::addColumn("z4"); + QTest::addColumn("x5"); // Third point on plane + QTest::addColumn("y5"); + QTest::addColumn("z5"); + QTest::addColumn("distance"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f + << (qreal)0.0f; + + QTest::newRow("above") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)2.0f + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f + << (qreal)2.0f; + + QTest::newRow("below") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)-1.0f << (qreal)1.0f << (qreal)-2.0f + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f + << (qreal)-2.0f; +} +void tst_QVector::distanceToPlane() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + QFETCH(qreal, x4); + QFETCH(qreal, y4); + QFETCH(qreal, z4); + QFETCH(qreal, x5); + QFETCH(qreal, y5); + QFETCH(qreal, z5); + QFETCH(qreal, distance); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + QVector3D v3(x3, y3, z3); + QVector3D v4(x4, y4, z4); + QVector3D v5(x5, y5, z5); + + QCOMPARE(v3.distanceToPlane(v1, v2), distance); + QCOMPARE(v3.distanceToPlane(v1, v4, v5), distance); +} + +// Test distance to line calculations. +void tst_QVector::distanceToLine_data() +{ + QTest::addColumn("x1"); // Point on line + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("x2"); // Direction of the line + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("x3"); // Point to test for distance + QTest::addColumn("y3"); + QTest::addColumn("z3"); + QTest::addColumn("distance"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f; + + QTest::newRow("on line") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)5.0f + << (qreal)0.0f; + + QTest::newRow("off line") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)1.0f; + + QTest::newRow("off line 2") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f << (qreal)-2.0f << (qreal)0.0f + << (qreal)2.0f; + + QTest::newRow("points") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)5.0f << (qreal)0.0f + << (qreal)5.0f; +} +void tst_QVector::distanceToLine() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + QFETCH(qreal, distance); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + QVector3D v3(x3, y3, z3); + + QCOMPARE(v3.distanceToLine(v1, v2), distance); +} + +// Test the computation of dot products for 2D vectors. +void tst_QVector::dotProduct2_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("dot"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f; + + QTest::newRow("unitvec") + << (qreal)1.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)1.0f + << (qreal)0.0f; + + QTest::newRow("complex") + << (qreal)1.0f << (qreal)2.0f + << (qreal)4.0f << (qreal)5.0f + << (qreal)14.0f; +} +void tst_QVector::dotProduct2() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, dot); + + QVector2D v1(x1, y1); + QVector2D v2(x2, y2); + + QVERIFY(QVector2D::dotProduct(v1, v2) == dot); + + // Compute the dot-product long-hand and check again. + qreal d = x1 * x2 + y1 * y2; + + QCOMPARE(QVector2D::dotProduct(v1, v2), d); +} + +// Test the computation of dot products for 3D vectors. +void tst_QVector::dotProduct3_data() +{ + // Use the same test data as the crossProduct test. + crossProduct_data(); +} +void tst_QVector::dotProduct3() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, x3); + QFETCH(qreal, y3); + QFETCH(qreal, z3); + QFETCH(qreal, dot); + + Q_UNUSED(x3); + Q_UNUSED(y3); + Q_UNUSED(z3); + + QVector3D v1(x1, y1, z1); + QVector3D v2(x2, y2, z2); + + QVERIFY(QVector3D::dotProduct(v1, v2) == dot); + + // Compute the dot-product long-hand and check again. + qreal d = x1 * x2 + y1 * y2 + z1 * z2; + + QCOMPARE(QVector3D::dotProduct(v1, v2), d); +} + +// Test the computation of dot products for 4D vectors. +void tst_QVector::dotProduct4_data() +{ + QTest::addColumn("x1"); + QTest::addColumn("y1"); + QTest::addColumn("z1"); + QTest::addColumn("w1"); + QTest::addColumn("x2"); + QTest::addColumn("y2"); + QTest::addColumn("z2"); + QTest::addColumn("w2"); + QTest::addColumn("dot"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f; + + QTest::newRow("unitvec") + << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f + << (qreal)0.0f; + + QTest::newRow("complex") + << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)4.0f + << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f << (qreal)7.0f + << (qreal)60.0f; +} +void tst_QVector::dotProduct4() +{ + QFETCH(qreal, x1); + QFETCH(qreal, y1); + QFETCH(qreal, z1); + QFETCH(qreal, w1); + QFETCH(qreal, x2); + QFETCH(qreal, y2); + QFETCH(qreal, z2); + QFETCH(qreal, w2); + QFETCH(qreal, dot); + + QVector4D v1(x1, y1, z1, w1); + QVector4D v2(x2, y2, z2, w2); + + QVERIFY(QVector4D::dotProduct(v1, v2) == dot); + + // Compute the dot-product long-hand and check again. + qreal d = x1 * x2 + y1 * y2 + z1 * z2 + w1 * w2; + + QCOMPARE(QVector4D::dotProduct(v1, v2), d); +} + +class tst_QVectorProperties : public QObject +{ + Q_OBJECT + Q_PROPERTY(QVector2D vector2D READ vector2D WRITE setVector2D) + Q_PROPERTY(QVector3D vector3D READ vector3D WRITE setVector3D) + Q_PROPERTY(QVector4D vector4D READ vector4D WRITE setVector4D) +public: + tst_QVectorProperties(QObject *parent = 0) : QObject(parent) {} + + QVector2D vector2D() const { return v2; } + void setVector2D(const QVector2D& value) { v2 = value; } + + QVector3D vector3D() const { return v3; } + void setVector3D(const QVector3D& value) { v3 = value; } + + QVector4D vector4D() const { return v4; } + void setVector4D(const QVector4D& value) { v4 = value; } + +private: + QVector2D v2; + QVector3D v3; + QVector4D v4; +}; + +// Test getting and setting vector properties via the metaobject system. +void tst_QVector::properties() +{ + tst_QVectorProperties obj; + + obj.setVector2D(QVector2D(1.0f, 2.0f)); + obj.setVector3D(QVector3D(3.0f, 4.0f, 5.0f)); + obj.setVector4D(QVector4D(6.0f, 7.0f, 8.0f, 9.0f)); + + QVector2D v2 = qVariantValue(obj.property("vector2D")); + QCOMPARE(v2.x(), (qreal)1.0f); + QCOMPARE(v2.y(), (qreal)2.0f); + + QVector3D v3 = qVariantValue(obj.property("vector3D")); + QCOMPARE(v3.x(), (qreal)3.0f); + QCOMPARE(v3.y(), (qreal)4.0f); + QCOMPARE(v3.z(), (qreal)5.0f); + + QVector4D v4 = qVariantValue(obj.property("vector4D")); + QCOMPARE(v4.x(), (qreal)6.0f); + QCOMPARE(v4.y(), (qreal)7.0f); + QCOMPARE(v4.z(), (qreal)8.0f); + QCOMPARE(v4.w(), (qreal)9.0f); + + obj.setProperty("vector2D", + qVariantFromValue(QVector2D(-1.0f, -2.0f))); + obj.setProperty("vector3D", + qVariantFromValue(QVector3D(-3.0f, -4.0f, -5.0f))); + obj.setProperty("vector4D", + qVariantFromValue(QVector4D(-6.0f, -7.0f, -8.0f, -9.0f))); + + v2 = qVariantValue(obj.property("vector2D")); + QCOMPARE(v2.x(), (qreal)-1.0f); + QCOMPARE(v2.y(), (qreal)-2.0f); + + v3 = qVariantValue(obj.property("vector3D")); + QCOMPARE(v3.x(), (qreal)-3.0f); + QCOMPARE(v3.y(), (qreal)-4.0f); + QCOMPARE(v3.z(), (qreal)-5.0f); + + v4 = qVariantValue(obj.property("vector4D")); + QCOMPARE(v4.x(), (qreal)-6.0f); + QCOMPARE(v4.y(), (qreal)-7.0f); + QCOMPARE(v4.z(), (qreal)-8.0f); + QCOMPARE(v4.w(), (qreal)-9.0f); +} + +void tst_QVector::metaTypes() +{ + QVERIFY(QMetaType::type("QVector2D") == QMetaType::QVector2D); + QVERIFY(QMetaType::type("QVector3D") == QMetaType::QVector3D); + QVERIFY(QMetaType::type("QVector4D") == QMetaType::QVector4D); + + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector2D)), + QByteArray("QVector2D")); + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector3D)), + QByteArray("QVector3D")); + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector4D)), + QByteArray("QVector4D")); + + QVERIFY(QMetaType::isRegistered(QMetaType::QVector2D)); + QVERIFY(QMetaType::isRegistered(QMetaType::QVector3D)); + QVERIFY(QMetaType::isRegistered(QMetaType::QVector4D)); + + QVERIFY(qMetaTypeId() == QMetaType::QVector2D); + QVERIFY(qMetaTypeId() == QMetaType::QVector3D); + QVERIFY(qMetaTypeId() == QMetaType::QVector4D); +} + +QTEST_APPLESS_MAIN(tst_QVector) + +#include "tst_qvectornd.moc" -- cgit v0.12 From af98f27a847688e53ab1d34b4a9c04bdc63fe3e1 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 19 Aug 2009 10:09:49 +1000 Subject: Fixes compile --- examples/xml/streambookmarks/xbelreader.cpp | 9 +++++++++ examples/xml/streambookmarks/xbelreader.h | 1 + 2 files changed, 10 insertions(+) diff --git a/examples/xml/streambookmarks/xbelreader.cpp b/examples/xml/streambookmarks/xbelreader.cpp index 729fcf8..4472f8a 100644 --- a/examples/xml/streambookmarks/xbelreader.cpp +++ b/examples/xml/streambookmarks/xbelreader.cpp @@ -73,6 +73,15 @@ bool XbelReader::read(QIODevice *device) } //! [1] +//! [2] +void XbelReader::readUnknownElement() +{ + while (readNextStartElement()) { + readUnknownElement(); + } +} +//! [2] + //! [3] void XbelReader::readXBEL() { diff --git a/examples/xml/streambookmarks/xbelreader.h b/examples/xml/streambookmarks/xbelreader.h index 2debadc..80f0a28 100644 --- a/examples/xml/streambookmarks/xbelreader.h +++ b/examples/xml/streambookmarks/xbelreader.h @@ -62,6 +62,7 @@ public: private: //! [2] + void readUnknownElement(); void readXBEL(); void readTitle(QTreeWidgetItem *item); void readSeparator(QTreeWidgetItem *item); -- cgit v0.12 From 0325e1af2b53f62db6da27ae43ea62837e36c5ae Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 19 Aug 2009 17:06:33 +1000 Subject: Rectify copy'n'paste error from the QLineControl refactoring. Some of the ifdef blocks weren't, well, tested. Task-number: 259582 Reviewed-by: Trust Me --- src/gui/widgets/qlineedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index b88cd9ae..56cc828 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1388,6 +1388,7 @@ bool QLineEdit::event(QEvent * e) if (QApplication::keypadNavigationEnabled()) { if (e->type() == QEvent::EnterEditFocus) { end(false); + d->setCursorVisible(true); int cft = QApplication::cursorFlashTime(); d->control->setCursorBlinkPeriod(cft/2); } else if (e->type() == QEvent::LeaveEditFocus) { @@ -1396,7 +1397,6 @@ bool QLineEdit::event(QEvent * e) if (d->control->hasAcceptableInput() || d->control->fixup()) emit editingFinished(); } - return true; } #endif return QWidget::event(e); -- cgit v0.12 From 20d2b7312456435e5e1a98dba7c2cc96b44fe83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 19 Aug 2009 11:19:28 +0200 Subject: Fixed compile error Apparently I forgot one occurrence. --- examples/xml/streambookmarks/xbelreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xml/streambookmarks/xbelreader.cpp b/examples/xml/streambookmarks/xbelreader.cpp index 4472f8a..2682d91 100644 --- a/examples/xml/streambookmarks/xbelreader.cpp +++ b/examples/xml/streambookmarks/xbelreader.cpp @@ -95,7 +95,7 @@ void XbelReader::readXBEL() else if (name() == "separator") readSeparator(0); else - readUnknownElement(); + skipCurrentElement(); } } //! [3] -- cgit v0.12 From 03f6459939d7ef0b0d6dedb688880fa36b7d7ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 19 Aug 2009 11:23:25 +0200 Subject: Revert re-adding of readUnknownElement Now that it is really no longer used. QXmlStreamReader::skipCurrentElement replaces it. --- examples/xml/streambookmarks/xbelreader.cpp | 9 --------- examples/xml/streambookmarks/xbelreader.h | 1 - 2 files changed, 10 deletions(-) diff --git a/examples/xml/streambookmarks/xbelreader.cpp b/examples/xml/streambookmarks/xbelreader.cpp index 2682d91..99a7f34 100644 --- a/examples/xml/streambookmarks/xbelreader.cpp +++ b/examples/xml/streambookmarks/xbelreader.cpp @@ -73,15 +73,6 @@ bool XbelReader::read(QIODevice *device) } //! [1] -//! [2] -void XbelReader::readUnknownElement() -{ - while (readNextStartElement()) { - readUnknownElement(); - } -} -//! [2] - //! [3] void XbelReader::readXBEL() { diff --git a/examples/xml/streambookmarks/xbelreader.h b/examples/xml/streambookmarks/xbelreader.h index 80f0a28..2debadc 100644 --- a/examples/xml/streambookmarks/xbelreader.h +++ b/examples/xml/streambookmarks/xbelreader.h @@ -62,7 +62,6 @@ public: private: //! [2] - void readUnknownElement(); void readXBEL(); void readTitle(QTreeWidgetItem *item); void readSeparator(QTreeWidgetItem *item); -- cgit v0.12 From 215969ea20466a6a7eb78cb94723ed6c9d72a08d Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 19 Aug 2009 12:54:11 +0200 Subject: Generate proper license header. --- src/xmlpatterns/parser/createTokenLookup.sh | 47 +++++- src/xmlpatterns/parser/qtokenlookup.cpp | 246 ++++++++++++++++------------ 2 files changed, 189 insertions(+), 104 deletions(-) diff --git a/src/xmlpatterns/parser/createTokenLookup.sh b/src/xmlpatterns/parser/createTokenLookup.sh index a4e1eff..f84ee72 100755 --- a/src/xmlpatterns/parser/createTokenLookup.sh +++ b/src/xmlpatterns/parser/createTokenLookup.sh @@ -1,5 +1,50 @@ +#!/bin/sh outFile="qtokenlookup.cpp" +license=`cat < $outFile + # Watch out, the --output option is not supported in the # gperf version that apt-get pulls in on Mac OS X. -gperf TokenLookup.gperf > $outFile +gperf TokenLookup.gperf >> $outFile diff --git a/src/xmlpatterns/parser/qtokenlookup.cpp b/src/xmlpatterns/parser/qtokenlookup.cpp index 6e9c343..6bd1121 100644 --- a/src/xmlpatterns/parser/qtokenlookup.cpp +++ b/src/xmlpatterns/parser/qtokenlookup.cpp @@ -1,4 +1,44 @@ -/* C++ code produced by gperf version 3.0.2 */ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtXmlPatterns module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/* C++ code produced by gperf version 3.0.3 */ /* Command-line: gperf TokenLookup.gperf */ /* Computed positions: -k'1,3,$' */ @@ -29,7 +69,7 @@ #error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif -#line 80 "TokenLookup.gperf" +#line 107 "TokenLookup.gperf" QT_BEGIN_NAMESPACE @@ -37,7 +77,7 @@ QT_BEGIN_NAMESPACE namespace QPatternist { -#line 74 "TokenLookup.gperf" +#line 101 "TokenLookup.gperf" struct TokenMap { const char *name; @@ -120,255 +160,255 @@ TokenLookup::value (register const char *str, register unsigned int len) static const struct TokenMap wordlist[] = { {"",ERROR}, {"",ERROR}, -#line 125 "TokenLookup.gperf" +#line 152 "TokenLookup.gperf" {"eq", EQ}, {"",ERROR}, -#line 103 "TokenLookup.gperf" +#line 130 "TokenLookup.gperf" {"by", BY}, -#line 126 "TokenLookup.gperf" +#line 153 "TokenLookup.gperf" {"every", EVERY}, {"",ERROR}, -#line 96 "TokenLookup.gperf" +#line 123 "TokenLookup.gperf" {"as", AS}, {"",ERROR}, -#line 121 "TokenLookup.gperf" +#line 148 "TokenLookup.gperf" {"else", ELSE}, -#line 190 "TokenLookup.gperf" +#line 217 "TokenLookup.gperf" {"where", WHERE}, -#line 177 "TokenLookup.gperf" +#line 204 "TokenLookup.gperf" {"stable", STABLE}, -#line 99 "TokenLookup.gperf" +#line 126 "TokenLookup.gperf" {"at", AT}, {"",ERROR}, -#line 104 "TokenLookup.gperf" +#line 131 "TokenLookup.gperf" {"case", CASE}, {"",ERROR}, -#line 102 "TokenLookup.gperf" +#line 129 "TokenLookup.gperf" {"boundary-space", BOUNDARY_SPACE}, -#line 120 "TokenLookup.gperf" +#line 147 "TokenLookup.gperf" {"element", ELEMENT}, -#line 105 "TokenLookup.gperf" +#line 132 "TokenLookup.gperf" {"castable", CASTABLE}, -#line 100 "TokenLookup.gperf" +#line 127 "TokenLookup.gperf" {"attribute", ATTRIBUTE}, {"",ERROR}, -#line 127 "TokenLookup.gperf" +#line 154 "TokenLookup.gperf" {"except", EXCEPT}, -#line 134 "TokenLookup.gperf" +#line 161 "TokenLookup.gperf" {"ge", GE}, {"",ERROR}, -#line 106 "TokenLookup.gperf" +#line 133 "TokenLookup.gperf" {"cast", CAST}, -#line 183 "TokenLookup.gperf" +#line 210 "TokenLookup.gperf" {"treat", TREAT}, -#line 191 "TokenLookup.gperf" +#line 218 "TokenLookup.gperf" {"xquery", XQUERY}, -#line 154 "TokenLookup.gperf" +#line 181 "TokenLookup.gperf" {"ne", NE}, {"",ERROR}, -#line 171 "TokenLookup.gperf" +#line 198 "TokenLookup.gperf" {"satisfies", SATISFIES}, {"",ERROR}, {"",ERROR}, -#line 136 "TokenLookup.gperf" +#line 163 "TokenLookup.gperf" {"gt", GT}, -#line 124 "TokenLookup.gperf" +#line 151 "TokenLookup.gperf" {"encoding", ENCODING}, -#line 97 "TokenLookup.gperf" +#line 124 "TokenLookup.gperf" {"ascending", ASCENDING}, {"",ERROR}, -#line 98 "TokenLookup.gperf" +#line 125 "TokenLookup.gperf" {"assign", ASSIGN}, -#line 112 "TokenLookup.gperf" +#line 139 "TokenLookup.gperf" {"declare", DECLARE}, -#line 135 "TokenLookup.gperf" +#line 162 "TokenLookup.gperf" {"greatest", GREATEST}, -#line 181 "TokenLookup.gperf" +#line 208 "TokenLookup.gperf" {"then", THEN}, {"",ERROR}, -#line 94 "TokenLookup.gperf" +#line 121 "TokenLookup.gperf" {"ancestor-or-self", ANCESTOR_OR_SELF}, -#line 148 "TokenLookup.gperf" +#line 175 "TokenLookup.gperf" {"le", LE}, -#line 119 "TokenLookup.gperf" +#line 146 "TokenLookup.gperf" {"document-node", DOCUMENT_NODE}, -#line 180 "TokenLookup.gperf" +#line 207 "TokenLookup.gperf" {"text", TEXT}, {"",ERROR}, -#line 174 "TokenLookup.gperf" +#line 201 "TokenLookup.gperf" {"schema", SCHEMA}, {"",ERROR}, -#line 118 "TokenLookup.gperf" +#line 145 "TokenLookup.gperf" {"document", DOCUMENT}, {"",ERROR}, -#line 114 "TokenLookup.gperf" +#line 141 "TokenLookup.gperf" {"descendant", DESCENDANT}, {"",ERROR}, -#line 150 "TokenLookup.gperf" +#line 177 "TokenLookup.gperf" {"lt", LT}, -#line 95 "TokenLookup.gperf" +#line 122 "TokenLookup.gperf" {"and", AND}, -#line 155 "TokenLookup.gperf" +#line 182 "TokenLookup.gperf" {"node", NODE}, -#line 147 "TokenLookup.gperf" +#line 174 "TokenLookup.gperf" {"least", LEAST}, -#line 172 "TokenLookup.gperf" +#line 199 "TokenLookup.gperf" {"schema-attribute", SCHEMA_ATTRIBUTE}, {"",ERROR}, -#line 128 "TokenLookup.gperf" +#line 155 "TokenLookup.gperf" {"external", EXTERNAL}, {"",ERROR}, -#line 116 "TokenLookup.gperf" +#line 143 "TokenLookup.gperf" {"descending", DESCENDING}, -#line 157 "TokenLookup.gperf" +#line 184 "TokenLookup.gperf" {"no-preserve", NO_PRESERVE}, -#line 113 "TokenLookup.gperf" +#line 140 "TokenLookup.gperf" {"default", DEFAULT}, -#line 149 "TokenLookup.gperf" +#line 176 "TokenLookup.gperf" {"let", LET}, -#line 173 "TokenLookup.gperf" +#line 200 "TokenLookup.gperf" {"schema-element", SCHEMA_ELEMENT}, {"",ERROR}, {"",ERROR}, -#line 110 "TokenLookup.gperf" +#line 137 "TokenLookup.gperf" {"construction", CONSTRUCTION}, -#line 115 "TokenLookup.gperf" +#line 142 "TokenLookup.gperf" {"descendant-or-self", DESCENDANT_OR_SELF}, -#line 175 "TokenLookup.gperf" +#line 202 "TokenLookup.gperf" {"self", SELF}, -#line 156 "TokenLookup.gperf" +#line 183 "TokenLookup.gperf" {"no-inherit", NO_INHERIT}, {"",ERROR}, -#line 131 "TokenLookup.gperf" +#line 158 "TokenLookup.gperf" {"follows", FOLLOWS}, -#line 93 "TokenLookup.gperf" +#line 120 "TokenLookup.gperf" {"ancestor", ANCESTOR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, -#line 182 "TokenLookup.gperf" +#line 209 "TokenLookup.gperf" {"to", TO}, -#line 133 "TokenLookup.gperf" +#line 160 "TokenLookup.gperf" {"function", FUNCTION}, -#line 108 "TokenLookup.gperf" +#line 135 "TokenLookup.gperf" {"collation", COLLATION}, {"",ERROR}, -#line 178 "TokenLookup.gperf" +#line 205 "TokenLookup.gperf" {"strict", STRICT}, {"",ERROR}, -#line 146 "TokenLookup.gperf" +#line 173 "TokenLookup.gperf" {"lax", LAX}, {"",ERROR}, -#line 122 "TokenLookup.gperf" +#line 149 "TokenLookup.gperf" {"empty", EMPTY}, {"",ERROR}, -#line 158 "TokenLookup.gperf" +#line 185 "TokenLookup.gperf" {"of", OF}, -#line 168 "TokenLookup.gperf" +#line 195 "TokenLookup.gperf" {"preserve", PRESERVE}, -#line 129 "TokenLookup.gperf" +#line 156 "TokenLookup.gperf" {"following", FOLLOWING}, {"",ERROR}, {"",ERROR}, -#line 144 "TokenLookup.gperf" +#line 171 "TokenLookup.gperf" {"is", IS}, -#line 165 "TokenLookup.gperf" +#line 192 "TokenLookup.gperf" {"precedes", PRECEDES}, -#line 123 "TokenLookup.gperf" +#line 150 "TokenLookup.gperf" {"empty-sequence", EMPTY_SEQUENCE}, {"",ERROR}, {"",ERROR}, -#line 130 "TokenLookup.gperf" +#line 157 "TokenLookup.gperf" {"following-sibling", FOLLOWING_SIBLING}, -#line 142 "TokenLookup.gperf" +#line 169 "TokenLookup.gperf" {"instance", INSTANCE}, -#line 186 "TokenLookup.gperf" +#line 213 "TokenLookup.gperf" {"unordered", UNORDERED}, -#line 101 "TokenLookup.gperf" +#line 128 "TokenLookup.gperf" {"base-uri", BASEURI}, -#line 170 "TokenLookup.gperf" +#line 197 "TokenLookup.gperf" {"return", RETURN}, {"",ERROR}, -#line 187 "TokenLookup.gperf" +#line 214 "TokenLookup.gperf" {"validate", VALIDATE}, {"",ERROR}, -#line 111 "TokenLookup.gperf" +#line 138 "TokenLookup.gperf" {"copy-namespaces", COPY_NAMESPACES}, -#line 159 "TokenLookup.gperf" +#line 186 "TokenLookup.gperf" {"option", OPTION}, -#line 138 "TokenLookup.gperf" +#line 165 "TokenLookup.gperf" {"if", IF}, {"",ERROR}, -#line 166 "TokenLookup.gperf" +#line 193 "TokenLookup.gperf" {"preceding", PRECEDING}, {"",ERROR}, {"",ERROR}, -#line 141 "TokenLookup.gperf" +#line 168 "TokenLookup.gperf" {"in", IN}, {"",ERROR}, -#line 143 "TokenLookup.gperf" +#line 170 "TokenLookup.gperf" {"intersect", INTERSECT}, -#line 185 "TokenLookup.gperf" +#line 212 "TokenLookup.gperf" {"union", UNION}, {"",ERROR}, -#line 167 "TokenLookup.gperf" +#line 194 "TokenLookup.gperf" {"preceding-sibling", PRECEDING_SIBLING}, -#line 161 "TokenLookup.gperf" +#line 188 "TokenLookup.gperf" {"ordering", ORDERING}, -#line 176 "TokenLookup.gperf" +#line 203 "TokenLookup.gperf" {"some", SOME}, -#line 107 "TokenLookup.gperf" +#line 134 "TokenLookup.gperf" {"child", CHILD}, {"",ERROR}, -#line 160 "TokenLookup.gperf" +#line 187 "TokenLookup.gperf" {"ordered", ORDERED}, -#line 188 "TokenLookup.gperf" +#line 215 "TokenLookup.gperf" {"variable", VARIABLE}, {"",ERROR}, {"",ERROR}, {"",ERROR}, -#line 163 "TokenLookup.gperf" +#line 190 "TokenLookup.gperf" {"or", OR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, -#line 109 "TokenLookup.gperf" +#line 136 "TokenLookup.gperf" {"comment", COMMENT}, {"",ERROR}, {"",ERROR}, -#line 184 "TokenLookup.gperf" +#line 211 "TokenLookup.gperf" {"typeswitch", TYPESWITCH}, {"",ERROR}, -#line 140 "TokenLookup.gperf" +#line 167 "TokenLookup.gperf" {"inherit", INHERIT}, -#line 117 "TokenLookup.gperf" +#line 144 "TokenLookup.gperf" {"div", DIV}, {"",ERROR}, {"",ERROR}, -#line 152 "TokenLookup.gperf" +#line 179 "TokenLookup.gperf" {"module", MODULE}, {"",ERROR}, -#line 132 "TokenLookup.gperf" +#line 159 "TokenLookup.gperf" {"for", FOR}, -#line 153 "TokenLookup.gperf" +#line 180 "TokenLookup.gperf" {"namespace", NAMESPACE}, {"",ERROR}, {"",ERROR}, -#line 189 "TokenLookup.gperf" +#line 216 "TokenLookup.gperf" {"version", VERSION}, {"",ERROR}, {"",ERROR}, -#line 179 "TokenLookup.gperf" +#line 206 "TokenLookup.gperf" {"strip", STRIP}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, -#line 162 "TokenLookup.gperf" +#line 189 "TokenLookup.gperf" {"order", ORDER}, -#line 164 "TokenLookup.gperf" +#line 191 "TokenLookup.gperf" {"parent", PARENT}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, -#line 151 "TokenLookup.gperf" +#line 178 "TokenLookup.gperf" {"mod", MOD}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, -#line 139 "TokenLookup.gperf" +#line 166 "TokenLookup.gperf" {"import", IMPORT}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, -#line 169 "TokenLookup.gperf" +#line 196 "TokenLookup.gperf" {"processing-instruction", PROCESSING_INSTRUCTION}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, -#line 145 "TokenLookup.gperf" +#line 172 "TokenLookup.gperf" {"item", ITEM}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, @@ -378,7 +418,7 @@ TokenLookup::value (register const char *str, register unsigned int len) {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR}, -#line 137 "TokenLookup.gperf" +#line 164 "TokenLookup.gperf" {"idiv", IDIV} }; @@ -396,7 +436,7 @@ TokenLookup::value (register const char *str, register unsigned int len) } return 0; } -#line 192 "TokenLookup.gperf" +#line 219 "TokenLookup.gperf" } /* Close the QPatternist namespace. */ -- cgit v0.12 From f50439ac2bd701f88eb7843fccbbf885c3528a54 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 19 Aug 2009 13:30:18 +0200 Subject: Make the license test pass. This is partly done to address a review comment for S60. Reviewed-by: Marius SO Reviewed-by: Paul --- demos/embedded/fluidlauncher/pictureflow.cpp | 2 + examples/qws/dbscreen/dbscreen.cpp | 21 +++++----- examples/qws/dbscreen/dbscreendriverplugin.cpp | 23 +++++------ qmake/generators/unix/unixmake.cpp | 19 ++++----- src/corelib/concurrent/qtconcurrentmap.cpp | 2 +- src/gui/itemviews/qlistview.cpp | 2 +- src/gui/kernel/qt_mac.cpp | 19 ++++----- src/gui/widgets/qdatetimeedit.cpp | 2 +- tests/auto/gestures/customgesturerecognizer.cpp | 41 +++++++++++++++++++ tests/auto/headers/tst_headers.cpp | 3 ++ tests/auto/mediaobject/dummy/audiooutput.cpp | 41 +++++++++++++++++++ tests/auto/mediaobject/dummy/backend.cpp | 41 +++++++++++++++++++ tests/auto/mediaobject/dummy/mediaobject.cpp | 41 +++++++++++++++++++ tests/auto/mediaobject/dummy/videowidget.cpp | 41 +++++++++++++++++++ tests/auto/qstate/tst_qstate.cpp | 34 ++++++++++++++++ tests/auto/qstringbuilder/scenario1.cpp | 41 +++++++++++++++++++ tests/auto/qstringbuilder/scenario2.cpp | 41 +++++++++++++++++++ tests/auto/qstringbuilder/scenario3.cpp | 41 +++++++++++++++++++ tests/auto/qstringbuilder/scenario4.cpp | 41 +++++++++++++++++++ tests/auto/qxmlschema/tst_qxmlschema.cpp | 36 ++++++++++++++++- .../tst_qxmlschemavalidator.cpp | 36 ++++++++++++++++- tests/auto/windowsmobile/test/ddhelper.cpp | 40 +++++++++++++++++++ tests/auto/windowsmobile/testQMenuBar/main.cpp | 41 +++++++++++++++++++ .../xmlpatternsschema/tst_xmlpatternsschema.cpp | 42 +++++++++++++++++++- .../tst_xmlpatternsschemats.cpp | 36 ++++++++++++++++- .../tst_xmlpatternsvalidator.cpp | 34 ++++++++++++++++ tests/benchmarks/qanimation/dummyanimation.cpp | 41 +++++++++++++++++++ tests/benchmarks/qanimation/dummyobject.cpp | 43 +++++++++++++++++++- tests/benchmarks/qanimation/main.cpp | 41 +++++++++++++++++++ tests/benchmarks/qanimation/rectanimation.cpp | 41 +++++++++++++++++++ tests/benchmarks/qdir/tst_qdir.cpp | 41 +++++++++++++++++++ .../benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp | 34 ++++++++++++++++ .../qgraphicswidget/tst_qgraphicswidget.cpp | 34 ++++++++++++++++ tests/benchmarks/qstringbuilder/main.cpp | 40 +++++++++++++++++++ tests/manual/qtabletevent/main.cpp | 41 +++++++++++++++++++ tests/manual/qtabletevent/tabletwidget.cpp | 41 +++++++++++++++++++ tests/manual/qtouchevent/main.cpp | 41 +++++++++++++++++++ tests/manual/qtouchevent/touchwidget.cpp | 41 +++++++++++++++++++ tools/linguist/tests/data/main.cpp | 40 +++++++++++++++++++ tools/linguist/tests/tst_linguist.cpp | 41 +++++++++++++++++++ tools/linguist/tests/tst_lupdate.cpp | 46 ++++++++++++++++++---- tools/linguist/tests/tst_simtexth.cpp | 46 ++++++++++++++++++---- tools/xmlpatterns/main.cpp | 2 +- tools/xmlpatterns/qcoloroutput.cpp | 18 ++++----- tools/xmlpatternsvalidator/main.cpp | 2 +- util/qlalr/compress.cpp | 2 +- util/qlalr/dotgraph.cpp | 2 +- util/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp | 40 +++++++++++++++++++ util/qlalr/examples/lambda/main.cpp | 40 +++++++++++++++++++ util/qlalr/examples/qparser/qparser.cpp | 40 +++++++++++++++++++ util/qlalr/grammar.cpp | 2 +- util/qlalr/lalr.cpp | 2 +- util/qlalr/main.cpp | 2 +- util/qlalr/parsetable.cpp | 2 +- util/qlalr/recognizer.cpp | 3 +- 55 files changed, 1479 insertions(+), 91 deletions(-) diff --git a/demos/embedded/fluidlauncher/pictureflow.cpp b/demos/embedded/fluidlauncher/pictureflow.cpp index f0fedf4..2173b28 100644 --- a/demos/embedded/fluidlauncher/pictureflow.cpp +++ b/demos/embedded/fluidlauncher/pictureflow.cpp @@ -3,6 +3,8 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** +** This file is part of the QtGui module of the Qt Toolkit. +** ** This is a version of the Pictureflow animated image show widget modified by Nokia. ** ** $QT_BEGIN_LICENSE:LGPL$ diff --git a/examples/qws/dbscreen/dbscreen.cpp b/examples/qws/dbscreen/dbscreen.cpp index 86c34cd..fb6897c 100644 --- a/examples/qws/dbscreen/dbscreen.cpp +++ b/examples/qws/dbscreen/dbscreen.cpp @@ -1,11 +1,11 @@ - /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +/**************************************************************************** +** +** 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$ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -36,11 +36,8 @@ ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +****************************************************************************/ #include "dbscreen.h" #include diff --git a/examples/qws/dbscreen/dbscreendriverplugin.cpp b/examples/qws/dbscreen/dbscreendriverplugin.cpp index 6f11198..9190753 100644 --- a/examples/qws/dbscreen/dbscreendriverplugin.cpp +++ b/examples/qws/dbscreen/dbscreendriverplugin.cpp @@ -1,11 +1,11 @@ - /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +/**************************************************************************** +** +** 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$ +** +** 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 @@ -36,12 +36,9 @@ ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ - +** +****************************************************************************/ + #include #include "dbscreen.h" diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 626b955a5..dfbf8ee 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -1,11 +1,11 @@ /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the qmake application of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the qmake application 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 @@ -36,11 +36,8 @@ ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +****************************************************************************/ #include "unixmake.h" #include "option.h" diff --git a/src/corelib/concurrent/qtconcurrentmap.cpp b/src/corelib/concurrent/qtconcurrentmap.cpp index 3fd044d..243921a 100644 --- a/src/corelib/concurrent/qtconcurrentmap.cpp +++ b/src/corelib/concurrent/qtconcurrentmap.cpp @@ -1,4 +1,4 @@ - /**************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index e9e365f..cc9d643 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1,4 +1,4 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp index 642aa5c..bef3449 100644 --- a/src/gui/kernel/qt_mac.cpp +++ b/src/gui/kernel/qt_mac.cpp @@ -1,11 +1,11 @@ /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the QtGui module of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -36,11 +36,8 @@ ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +****************************************************************************/ #include #include diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp index 0fca0b7..7eb9eb5 100644 --- a/src/gui/widgets/qdatetimeedit.cpp +++ b/src/gui/widgets/qdatetimeedit.cpp @@ -1,4 +1,4 @@ -/****************************************************************************) +/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) diff --git a/tests/auto/gestures/customgesturerecognizer.cpp b/tests/auto/gestures/customgesturerecognizer.cpp index 12d07b1..6c2389c 100644 --- a/tests/auto/gestures/customgesturerecognizer.cpp +++ b/tests/auto/gestures/customgesturerecognizer.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "customgesturerecognizer.h" #include "qgesture.h" diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index f5a11f4..05cb205 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -139,6 +139,9 @@ void tst_Headers::allSourceFilesData() || sourceFile.contains("/config.tests/") || sourceFile.contains("/snippets/") || sourceFile.contains("linguist/lupdate/testdata") + || sourceFile.contains("testdata/bundle-spaces/main.cpp") + || sourceFile.contains("demos/embedded/fluidlauncher/pictureflow.cpp") + || sourceFile.contains("tools/porting/src/") || sourceFile.contains("/fulltextsearch/")) continue; diff --git a/tests/auto/mediaobject/dummy/audiooutput.cpp b/tests/auto/mediaobject/dummy/audiooutput.cpp index 41b473d..cb59eea 100644 --- a/tests/auto/mediaobject/dummy/audiooutput.cpp +++ b/tests/auto/mediaobject/dummy/audiooutput.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "audiooutput.h" #include "backend.h" #include diff --git a/tests/auto/mediaobject/dummy/backend.cpp b/tests/auto/mediaobject/dummy/backend.cpp index 53f3896..44a867d 100644 --- a/tests/auto/mediaobject/dummy/backend.cpp +++ b/tests/auto/mediaobject/dummy/backend.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "audiooutput.h" #include "mediaobject.h" #include "videowidget.h" diff --git a/tests/auto/mediaobject/dummy/mediaobject.cpp b/tests/auto/mediaobject/dummy/mediaobject.cpp index 521e3a6..d2ed7af 100644 --- a/tests/auto/mediaobject/dummy/mediaobject.cpp +++ b/tests/auto/mediaobject/dummy/mediaobject.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "mediaobject.h" #include "backend.h" diff --git a/tests/auto/mediaobject/dummy/videowidget.cpp b/tests/auto/mediaobject/dummy/videowidget.cpp index 890363f..2e26bda 100644 --- a/tests/auto/mediaobject/dummy/videowidget.cpp +++ b/tests/auto/mediaobject/dummy/videowidget.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "videowidget.h" #include #include diff --git a/tests/auto/qstate/tst_qstate.cpp b/tests/auto/qstate/tst_qstate.cpp index 43ea7fe..141e1aa 100644 --- a/tests/auto/qstate/tst_qstate.cpp +++ b/tests/auto/qstate/tst_qstate.cpp @@ -3,6 +3,40 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** ****************************************************************************/ #include diff --git a/tests/auto/qstringbuilder/scenario1.cpp b/tests/auto/qstringbuilder/scenario1.cpp index 26b4ed3..9159649 100644 --- a/tests/auto/qstringbuilder/scenario1.cpp +++ b/tests/auto/qstringbuilder/scenario1.cpp @@ -1 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "tst_qstringbuilder.cpp" diff --git a/tests/auto/qstringbuilder/scenario2.cpp b/tests/auto/qstringbuilder/scenario2.cpp index 26b4ed3..9159649 100644 --- a/tests/auto/qstringbuilder/scenario2.cpp +++ b/tests/auto/qstringbuilder/scenario2.cpp @@ -1 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "tst_qstringbuilder.cpp" diff --git a/tests/auto/qstringbuilder/scenario3.cpp b/tests/auto/qstringbuilder/scenario3.cpp index 26b4ed3..9159649 100644 --- a/tests/auto/qstringbuilder/scenario3.cpp +++ b/tests/auto/qstringbuilder/scenario3.cpp @@ -1 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "tst_qstringbuilder.cpp" diff --git a/tests/auto/qstringbuilder/scenario4.cpp b/tests/auto/qstringbuilder/scenario4.cpp index 26b4ed3..25f7932 100644 --- a/tests/auto/qstringbuilder/scenario4.cpp +++ b/tests/auto/qstringbuilder/scenario4.cpp @@ -1 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtXmlPatterns module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "tst_qstringbuilder.cpp" diff --git a/tests/auto/qxmlschema/tst_qxmlschema.cpp b/tests/auto/qxmlschema/tst_qxmlschema.cpp index b681737..95a130d 100644 --- a/tests/auto/qxmlschema/tst_qxmlschema.cpp +++ b/tests/auto/qxmlschema/tst_qxmlschema.cpp @@ -1,8 +1,42 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** ****************************************************************************/ #include diff --git a/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp b/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp index 4edb6a3..0a0248c 100644 --- a/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp +++ b/tests/auto/qxmlschemavalidator/tst_qxmlschemavalidator.cpp @@ -1,8 +1,42 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** ****************************************************************************/ #include diff --git a/tests/auto/windowsmobile/test/ddhelper.cpp b/tests/auto/windowsmobile/test/ddhelper.cpp index 5955cd3..482f8dd 100644 --- a/tests/auto/windowsmobile/test/ddhelper.cpp +++ b/tests/auto/windowsmobile/test/ddhelper.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifdef Q_OS_WINCE_WM diff --git a/tests/auto/windowsmobile/testQMenuBar/main.cpp b/tests/auto/windowsmobile/testQMenuBar/main.cpp index 4a3b3b2..4949dbb 100644 --- a/tests/auto/windowsmobile/testQMenuBar/main.cpp +++ b/tests/auto/windowsmobile/testQMenuBar/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #include #include diff --git a/tests/auto/xmlpatternsschema/tst_xmlpatternsschema.cpp b/tests/auto/xmlpatternsschema/tst_xmlpatternsschema.cpp index 030e9c0..d67db76 100644 --- a/tests/auto/xmlpatternsschema/tst_xmlpatternsschema.cpp +++ b/tests/auto/xmlpatternsschema/tst_xmlpatternsschema.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include @@ -51,7 +91,7 @@ bool tst_XMLPatternsSchema::runTest(const QVector &lis { machine.reset(); for (int i = 0; i < list.count(); ++i) { - if (!machine.proceed(list.at(i))) + if (!machine.proceed(list.at(i))) return false; } if (!machine.inEndState()) diff --git a/tests/auto/xmlpatternsschemats/tst_xmlpatternsschemats.cpp b/tests/auto/xmlpatternsschemats/tst_xmlpatternsschemats.cpp index 2747ae3..069d2b2 100644 --- a/tests/auto/xmlpatternsschemats/tst_xmlpatternsschemats.cpp +++ b/tests/auto/xmlpatternsschemats/tst_xmlpatternsschemats.cpp @@ -1,8 +1,42 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** ****************************************************************************/ #include diff --git a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp index 7d9f638..1775fea 100644 --- a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp +++ b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp @@ -3,6 +3,40 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** ****************************************************************************/ #include diff --git a/tests/benchmarks/qanimation/dummyanimation.cpp b/tests/benchmarks/qanimation/dummyanimation.cpp index 6fb1d0a..53c42b0 100644 --- a/tests/benchmarks/qanimation/dummyanimation.cpp +++ b/tests/benchmarks/qanimation/dummyanimation.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "dummyanimation.h" #include "dummyobject.h" diff --git a/tests/benchmarks/qanimation/dummyobject.cpp b/tests/benchmarks/qanimation/dummyobject.cpp index bd76388..10b24e2 100644 --- a/tests/benchmarks/qanimation/dummyobject.cpp +++ b/tests/benchmarks/qanimation/dummyobject.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "dummyobject.h" DummyObject::DummyObject() @@ -9,7 +50,7 @@ QRect DummyObject::rect() const return m_rect; } -void DummyObject::setRect(const QRect &r) +void DummyObject::setRect(const QRect &r) { m_rect = r; } diff --git a/tests/benchmarks/qanimation/main.cpp b/tests/benchmarks/qanimation/main.cpp index 7bb770f..5c9fa41 100644 --- a/tests/benchmarks/qanimation/main.cpp +++ b/tests/benchmarks/qanimation/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #include diff --git a/tests/benchmarks/qanimation/rectanimation.cpp b/tests/benchmarks/qanimation/rectanimation.cpp index d60a943..75ba476 100644 --- a/tests/benchmarks/qanimation/rectanimation.cpp +++ b/tests/benchmarks/qanimation/rectanimation.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "rectanimation.h" #include "dummyobject.h" diff --git a/tests/benchmarks/qdir/tst_qdir.cpp b/tests/benchmarks/qdir/tst_qdir.cpp index 7977e28..474848d 100644 --- a/tests/benchmarks/qdir/tst_qdir.cpp +++ b/tests/benchmarks/qdir/tst_qdir.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #ifdef Q_OS_WIN diff --git a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp index ee27ebe..923838a 100644 --- a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp @@ -3,6 +3,40 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** ****************************************************************************/ #include diff --git a/tests/benchmarks/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/benchmarks/qgraphicswidget/tst_qgraphicswidget.cpp index 6f47181..07d8312 100644 --- a/tests/benchmarks/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/benchmarks/qgraphicswidget/tst_qgraphicswidget.cpp @@ -3,6 +3,40 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** ****************************************************************************/ #include diff --git a/tests/benchmarks/qstringbuilder/main.cpp b/tests/benchmarks/qstringbuilder/main.cpp index 8b769a6..b1d4165 100644 --- a/tests/benchmarks/qstringbuilder/main.cpp +++ b/tests/benchmarks/qstringbuilder/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ // Select one of the scenarios below #define SCENARIO 1 diff --git a/tests/manual/qtabletevent/main.cpp b/tests/manual/qtabletevent/main.cpp index 4014d58..cc8003c 100644 --- a/tests/manual/qtabletevent/main.cpp +++ b/tests/manual/qtabletevent/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #include "tabletwidget.h" diff --git a/tests/manual/qtabletevent/tabletwidget.cpp b/tests/manual/qtabletevent/tabletwidget.cpp index 4d6a365..0334706 100644 --- a/tests/manual/qtabletevent/tabletwidget.cpp +++ b/tests/manual/qtabletevent/tabletwidget.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "tabletwidget.h" #include #include diff --git a/tests/manual/qtouchevent/main.cpp b/tests/manual/qtouchevent/main.cpp index 8097ab0..6449b6d 100644 --- a/tests/manual/qtouchevent/main.cpp +++ b/tests/manual/qtouchevent/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #include diff --git a/tests/manual/qtouchevent/touchwidget.cpp b/tests/manual/qtouchevent/touchwidget.cpp index a8141cc..62564a1 100644 --- a/tests/manual/qtouchevent/touchwidget.cpp +++ b/tests/manual/qtouchevent/touchwidget.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "touchwidget.h" #include diff --git a/tools/linguist/tests/data/main.cpp b/tools/linguist/tests/data/main.cpp index ebbda0a..6e09e3e 100644 --- a/tools/linguist/tests/data/main.cpp +++ b/tools/linguist/tests/data/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include #include diff --git a/tools/linguist/tests/tst_linguist.cpp b/tools/linguist/tests/tst_linguist.cpp index 199ddbb..c3f4eb6 100644 --- a/tools/linguist/tests/tst_linguist.cpp +++ b/tools/linguist/tests/tst_linguist.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "tst_linguist.h" #include "moc_tst_linguist.cpp" diff --git a/tools/linguist/tests/tst_lupdate.cpp b/tools/linguist/tests/tst_lupdate.cpp index d3b7a1c..4114bf9 100644 --- a/tools/linguist/tests/tst_lupdate.cpp +++ b/tools/linguist/tests/tst_lupdate.cpp @@ -1,13 +1,43 @@ - /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +** This file is part of the QtXmlPatterns module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include #include diff --git a/tools/linguist/tests/tst_simtexth.cpp b/tools/linguist/tests/tst_simtexth.cpp index d8315ad..b71896c 100644 --- a/tools/linguist/tests/tst_simtexth.cpp +++ b/tools/linguist/tests/tst_simtexth.cpp @@ -1,13 +1,43 @@ - /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include #include diff --git a/tools/xmlpatterns/main.cpp b/tools/xmlpatterns/main.cpp index 1bef118..31b2b6c 100644 --- a/tools/xmlpatterns/main.cpp +++ b/tools/xmlpatterns/main.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 Patternist project on Qt Labs. +** This file is part of the QtXmlPatterns module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/tools/xmlpatterns/qcoloroutput.cpp b/tools/xmlpatterns/qcoloroutput.cpp index d715e71..084a84d 100644 --- a/tools/xmlpatterns/qcoloroutput.cpp +++ b/tools/xmlpatterns/qcoloroutput.cpp @@ -1,10 +1,11 @@ /**************************************************************************** - * ** * ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - * ** - * ** This file is part of the Patternist project on Qt Labs. - * ** - * ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the QtXmlPatterns module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -35,11 +36,8 @@ ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ - * ** - * ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * ** - * ****************************************************************************/ +** +****************************************************************************/ #include #include diff --git a/tools/xmlpatternsvalidator/main.cpp b/tools/xmlpatternsvalidator/main.cpp index 5a2877f..e6793c1 100644 --- a/tools/xmlpatternsvalidator/main.cpp +++ b/tools/xmlpatternsvalidator/main.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 Patternist project on Qt Labs. +** This file is part of the QtXmlPatterns module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/compress.cpp b/util/qlalr/compress.cpp index efa4fea..3fcd6bf 100644 --- a/util/qlalr/compress.cpp +++ b/util/qlalr/compress.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 QLALR project on Qt Labs. +** This file is part of the test suite module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/dotgraph.cpp b/util/qlalr/dotgraph.cpp index 5f847a9..67359d4 100644 --- a/util/qlalr/dotgraph.cpp +++ b/util/qlalr/dotgraph.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 QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp b/util/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp index 54f5e0e..b60e7e2 100644 --- a/util/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp +++ b/util/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include #include diff --git a/util/qlalr/examples/lambda/main.cpp b/util/qlalr/examples/lambda/main.cpp index c70f9a5..bfae333 100644 --- a/util/qlalr/examples/lambda/main.cpp +++ b/util/qlalr/examples/lambda/main.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include "lambda.h" diff --git a/util/qlalr/examples/qparser/qparser.cpp b/util/qlalr/examples/qparser/qparser.cpp index 5a18ee2..4e58e14 100644 --- a/util/qlalr/examples/qparser/qparser.cpp +++ b/util/qlalr/examples/qparser/qparser.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the utils module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ #include "qparser.h" diff --git a/util/qlalr/grammar.cpp b/util/qlalr/grammar.cpp index 26f8378..e5e5618 100644 --- a/util/qlalr/grammar.cpp +++ b/util/qlalr/grammar.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 QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/lalr.cpp b/util/qlalr/lalr.cpp index 797750c..5c4eac2 100644 --- a/util/qlalr/lalr.cpp +++ b/util/qlalr/lalr.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 QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/main.cpp b/util/qlalr/main.cpp index d3a9c7f..acfb7a5 100644 --- a/util/qlalr/main.cpp +++ b/util/qlalr/main.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 QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/parsetable.cpp b/util/qlalr/parsetable.cpp index bb78d2d..e4eb684 100644 --- a/util/qlalr/parsetable.cpp +++ b/util/qlalr/parsetable.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 QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/recognizer.cpp b/util/qlalr/recognizer.cpp index 3a590ba..daf371b 100644 --- a/util/qlalr/recognizer.cpp +++ b/util/qlalr/recognizer.cpp @@ -1,10 +1,9 @@ - /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage -- cgit v0.12 From b26af959573407b3bb4cb657f08b76023554607f Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 18 Aug 2009 15:57:17 +0200 Subject: Don't use pointers to temporary vars that go out of scope. Moved the dummy variable to the same scope as the 'motion' variable. This fixes Coverity defect CID 1528. Reviewed-by: Olivier Goffart Reviewed-by: Gabriel de Dietrich --- src/gui/kernel/qapplication_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index d942519..0d07a02 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -4572,6 +4572,7 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet int deviceType = QTabletEvent::NoDevice; int pointerType = QTabletEvent::UnknownPointer; XEvent mouseMotionEvent; + XEvent dummy; const XDeviceMotionEvent *motion = 0; XDeviceButtonEvent *button = 0; const XProximityNotifyEvent *proximity = 0; @@ -4589,7 +4590,6 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet // Do event compression. Skip over tablet+mouse move events if there are newer ones. qt_tablet_motion_data tabletMotionData; tabletMotionData.tabletMotionType = tablet->xinput_motion; - XEvent dummy; while (true) { // Find first mouse event since we expect them in pairs inside Qt tabletMotionData.error =false; -- cgit v0.12 From 774543a3336841df4a13d3e283af83cf4b53b966 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 19 Aug 2009 11:35:24 +0200 Subject: Improved the documentation of saving and restoring window geometry. Mentioned in the doc that the preferred way to save/restore a geometry of a QMainWindow is to use both saveGeometry() and saveState(). Reviewed-by: Kavindra Devi Palaraja --- doc/src/howtos/restoring-geometry.qdoc | 39 ++++++++++------------ .../snippets/code/src_gui_widgets_qmainwindow.cpp | 19 +++++++++++ src/gui/widgets/qmainwindow.cpp | 15 ++++++++- 3 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp diff --git a/doc/src/howtos/restoring-geometry.qdoc b/doc/src/howtos/restoring-geometry.qdoc index c9e6f4f..cc6f3e1 100644 --- a/doc/src/howtos/restoring-geometry.qdoc +++ b/doc/src/howtos/restoring-geometry.qdoc @@ -45,25 +45,28 @@ \ingroup best-practices - This document describes how to save and restore a window's - geometry using the geometry properties. On Windows, this is - basically storing the result of QWidget::geometry() and calling - QWidget::setGeometry() in the next session before calling - \l{QWidget::show()}{show()}. + This document describes how to save and restore a \l{Window + Geometry}{window's geometry} using the geometry properties. On + Windows, this is basically storing the result of + QWidget::geometry() and calling QWidget::setGeometry() in the next + session before calling \l{QWidget::show()}{show()}. - On X11, this won't work because an invisible window doesn't have - a frame yet. The window manager will decorate the window later. - When this happens, the window shifts towards the bottom/right - corner of the screen depending on the size of the decoration frame. - Although X provides a way to avoid this shift, most window managers - fail to implement this feature. + On X11, this might not work because an invisible window does not + have a frame yet. The window manager will decorate the window + later. When this happens, the window shifts towards the + bottom/right corner of the screen depending on the size of the + decoration frame. Although X provides a way to avoid this shift, + some window managers fail to implement this feature. Since version 4.2, Qt provides functions that saves and restores a window's geometry and state for you. QWidget::saveGeometry() saves the window geometry and maximized/fullscreen state, while QWidget::restoreGeometry() restores it. The restore function also checks if the restored geometry is outside the available screen - geometry, and modifies it as appropriate if it is. + geometry, and modifies it as appropriate if it is: + + \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 0 + \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 1 If those functions are not available or cannot be used, then a workaround is to call \l{QWidget::setGeometry()}{setGeometry()} @@ -74,14 +77,6 @@ \l{QWidget::pos()}{pos()} and \l{QWidget::size()}{size()} and to restore the geometry using \l{QWidget::resize()} and \l{QWidget::move()}{move()} before calling - \l{QWidget::show()}{show()}, as demonstrated in the following - code snippets (from the \l{mainwindows/application}{Application} - example): - - \snippet examples/mainwindows/application/mainwindow.cpp 35 - \codeline - \snippet examples/mainwindows/application/mainwindow.cpp 38 - - This method works on Windows, Mac OS X, and most X11 window - managers. + \l{QWidget::show()}{show()}, as demonstrated in the + \l{mainwindows/application}{Application} example. */ diff --git a/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp new file mode 100644 index 0000000..0e4040a --- /dev/null +++ b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp @@ -0,0 +1,19 @@ +//! [0] +void MyMainWindow::closeEvent(QCloseEvent *event) +{ + QSettings settings("MyCompany", "MyApp"); + settings.setValue("geometry", saveGeometry()); + settings.setValue("windowState", saveState()); + QMainWindow::closeEvent(event); +} +//! [0] + + +//! [1] +void MainWindow::readSettings() +{ + QSettings settings("MyCompany", "MyApp"); + restoreGeometry(settings.value("myWidget/geometry").toByteArray()); + restoreState(settings.value("myWidget/windowState").toByteArray()); +} +//! [1] diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index e19961f..ebf01d4 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -1027,6 +1027,8 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget Restores the state of \a dockwidget if it is created after the call to restoreState(). Returns true if the state was restored; otherwise returns false. + + \sa restoreState(), saveState() */ bool QMainWindow::restoreDockWidget(QDockWidget *dockwidget) @@ -1158,6 +1160,11 @@ Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const To restore the saved state, pass the return value and \a version number to restoreState(). + To save the geometry when the window closes, you can + implement a close event like this: + + \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 0 + \sa restoreState(), QWidget::saveGeometry(), QWidget::restoreGeometry() */ QByteArray QMainWindow::saveState(int version) const @@ -1177,7 +1184,13 @@ QByteArray QMainWindow::saveState(int version) const unchanged, and this function returns \c false; otherwise, the state is restored, and this function returns \c true. - \sa saveState(), QWidget::saveGeometry(), QWidget::restoreGeometry() + To restore geometry saved using QSettings, you can use code like + this: + + \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 1 + + \sa saveState(), QWidget::saveGeometry(), + QWidget::restoreGeometry(), restoreDockWidget() */ bool QMainWindow::restoreState(const QByteArray &state, int version) { -- cgit v0.12 From 8db1aedc017bf0f9a96728bf6e354dc37d8d13e4 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 19 Aug 2009 13:32:23 +0200 Subject: Carbon and Cocoa: Adding support for standard gestures. --- src/gui/kernel/qstandardgestures.cpp | 18 +++++++++++++++--- src/gui/kernel/qwidget_mac.mm | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 47f3146..10689ba 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -172,8 +172,6 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event) bool QPanGesture::filterEvent(QEvent *event) { Q_D(QPanGesture); - if (!event->spontaneous()) - return false; const QTouchEvent *ev = static_cast(event); if (event->type() == QEvent::TouchBegin) { QTouchEvent::TouchPoint p = ev->touchPoints().at(0); @@ -329,10 +327,11 @@ bool QPinchGesture::event(QEvent *event) bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event) { -#ifdef Q_WS_WIN +#if defined(Q_WS_WIN) || defined(Q_WS_MAC) Q_D(QPinchGesture); if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) { QNativeGestureEvent *ev = static_cast(event); +#if defined(Q_WS_WIN) QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); QApplicationPrivate::WidgetStandardGesturesMap::iterator it; it = qAppPriv->widgetGestures.find(static_cast(receiver)); @@ -340,7 +339,9 @@ bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event) return false; if (this != it.value().pinch) return false; +#endif Qt::GestureState nextState = Qt::NoGesture; + switch(ev->gestureType) { case QNativeGestureEvent::GestureBegin: // next we might receive the first gesture update event, so we @@ -349,15 +350,22 @@ bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event) d->scaleFactor = d->lastScaleFactor = 1; d->rotationAngle = d->lastRotationAngle = 0; d->startCenterPoint = d->centerPoint = d->lastCenterPoint = QPoint(); +#if defined(Q_WS_WIN) d->initialDistance = 0; +#endif return false; case QNativeGestureEvent::Rotate: d->lastRotationAngle = d->rotationAngle; +#if defined(Q_WS_WIN) d->rotationAngle = -1 * GID_ROTATE_ANGLE_FROM_ARGUMENT(ev->argument); +#elif defined(Q_WS_MAC) + d->rotationAngle = ev->percentage; +#endif nextState = Qt::GestureUpdated; event->accept(); break; case QNativeGestureEvent::Zoom: +#if defined(Q_WS_WIN) if (d->initialDistance != 0) { d->lastScaleFactor = d->scaleFactor; int distance = int(qint64(ev->argument)); @@ -365,6 +373,10 @@ bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event) } else { d->initialDistance = int(qint64(ev->argument)); } +#elif defined(Q_WS_MAC) + d->lastScaleFactor = d->scaleFactor; + d->scaleFactor = ev->percentage; +#endif nextState = Qt::GestureUpdated; event->accept(); break; diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 999faeb..71571e4 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -1055,7 +1055,7 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event, handled_event = false; break; } - qNGEvent.gestureType = QNativeGestureEvent::Zoom; + qNGEvent.gestureType = QNativeGestureEvent::Rotate; qNGEvent.percentage = float(amount); break; } case kEventGestureSwipe: { -- cgit v0.12 From 9281ec0a69a1426d764f0f3a044ee6e89ae6f639 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Wed, 19 Aug 2009 15:46:29 +0200 Subject: Doc - Cleanups on QAbstractTableModel, QAbstractItemModel, etc. Reviewed-By: TrustMe --- src/corelib/kernel/qabstractitemmodel.cpp | 821 ++++++++++++++++-------------- 1 file changed, 433 insertions(+), 388 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index d6d1bcf..fd2611b 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -251,8 +251,9 @@ QPersistentModelIndex::operator const QModelIndex&() const Returns true if this persistent model index refers to the same location as the \a other model index; otherwise returns false. - Note that all values in the persistent model index are used when comparing - with another model index. + + All values in the persistent model index are used when comparing with + another model index. */ bool QPersistentModelIndex::operator==(const QModelIndex &other) const @@ -335,10 +336,10 @@ qint64 QPersistentModelIndex::internalId() const } /*! - Returns the parent QModelIndex for this persistent index, or - QModelIndex() if it has no parent. + Returns the parent QModelIndex for this persistent index, or an invalid + QModelIndex if it has no parent. - \sa child() sibling() model() + \sa child() sibling() model() */ QModelIndex QPersistentModelIndex::parent() const { @@ -348,10 +349,10 @@ QModelIndex QPersistentModelIndex::parent() const } /*! - Returns the sibling at \a row and \a column or an invalid - QModelIndex if there is no sibling at this position. + Returns the sibling at \a row and \a column or an invalid QModelIndex if + there is no sibling at this position. - \sa parent() child() + \sa parent() child() */ QModelIndex QPersistentModelIndex::sibling(int row, int column) const @@ -362,10 +363,10 @@ QModelIndex QPersistentModelIndex::sibling(int row, int column) const } /*! - Returns the child of the model index that is stored in the given - \a row and \a column. + Returns the child of the model index that is stored in the given \a row + and \a column. - \sa parent() sibling() + \sa parent() sibling() */ QModelIndex QPersistentModelIndex::child(int row, int column) const @@ -376,9 +377,10 @@ QModelIndex QPersistentModelIndex::child(int row, int column) const } /*! - Returns the data for the given \a role for the item referred to by the index. + Returns the data for the given \a role for the item referred to by the + index. - \sa Qt::ItemDataRole, QAbstractItemModel::setData() + \sa Qt::ItemDataRole, QAbstractItemModel::setData() */ QVariant QPersistentModelIndex::data(int role) const { @@ -388,9 +390,9 @@ QVariant QPersistentModelIndex::data(int role) const } /*! - \since 4.2 + \since 4.2 - Returns the flags for the item referred to by the index. + Returns the flags for the item referred to by the index. */ Qt::ItemFlags QPersistentModelIndex::flags() const { @@ -400,7 +402,7 @@ Qt::ItemFlags QPersistentModelIndex::flags() const } /*! - Returns the model that the index belongs to. + Returns the model that the index belongs to. */ const QAbstractItemModel *QPersistentModelIndex::model() const { @@ -414,7 +416,9 @@ const QAbstractItemModel *QPersistentModelIndex::model() const Returns true if this persistent model index is valid; otherwise returns false. - A valid index belongs to a model, and has non-negative row and column numbers. + + A valid index belongs to a model, and has non-negative row and column + numbers. \sa model(), row(), column() */ @@ -760,44 +764,42 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, selection models to locate an item in the model. New QModelIndex objects are created by the model using the - QAbstractItemModel::createIndex() function. An \e invalid model index - can be constructed with the QModelIndex constructor. Invalid indexes are - often used as parent indexes when referring to top-level items in a model. + QAbstractItemModel::createIndex() function. An \e invalid model index can + be constructed with the QModelIndex constructor. Invalid indexes are often + used as parent indexes when referring to top-level items in a model. Model indexes refer to items in models, and contain all the information required to specify their locations in those models. Each index is located - in a given row and column, and may have a parent index; use row(), column(), - and parent() to obtain this information. Each top-level item in a model is - represented by a model index that does not have a parent index - in this - case, parent() will return an invalid model index, equivalent to an index - constructed with the zero argument form of the QModelIndex() constructor. + in a given row and column, and may have a parent index; use row(), + column(), and parent() to obtain this information. Each top-level item in a + model is represented by a model index that does not have a parent index - + in this case, parent() will return an invalid model index, equivalent to an + index constructed with the zero argument form of the QModelIndex() + constructor. To obtain a model index that refers to an existing item in a model, call - QAbstractItemModel::index() with the required row and column - values, and the model index of the parent. When referring to - top-level items in a model, supply QModelIndex() as the parent index. + QAbstractItemModel::index() with the required row and column values, and + the model index of the parent. When referring to top-level items in a + model, supply QModelIndex() as the parent index. The model() function returns the model that the index references as a - QAbstractItemModel. - The child() function is used to examine the items held beneath the index - in the model. - The sibling() function allows you to traverse items in the model on the - same level as the index. + QAbstractItemModel. The child() function is used to examine items held + under the index in the model. The sibling() function allows you to traverse + items in the model on the same level as the index. \note Model indexes should be used immediately and then discarded. You should not rely on indexes to remain valid after calling model functions that change the structure of the model or delete items. If you need to keep a model index over time use a QPersistentModelIndex. - \sa \link model-view-programming.html Model/View Programming\endlink QPersistentModelIndex QAbstractItemModel + \sa {Model/View Programming}, QPersistentModelIndex, QAbstractItemModel */ /*! \fn QModelIndex::QModelIndex() - Creates a new empty model index. - This type of model index is used to indicate - that the position in the model is invalid. + Creates a new empty model index. This type of model index is used to + indicate that the position in the model is invalid. \sa isValid() QAbstractItemModel */ @@ -860,7 +862,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \fn bool QModelIndex::isValid() const Returns true if this model index is valid; otherwise returns false. - A valid index belongs to a model, and has non-negative row and column numbers. + + A valid index belongs to a model, and has non-negative row and column + numbers. \sa model(), row(), column() */ @@ -871,33 +875,34 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, Returns a pointer to the model containing the item that this index refers to. - You receive a const pointer to the model because calls to - non-const functions of the model might invalidate the model index - - and possibly crash your application. + A const pointer to the model is returned because calls to non-const + functions of the model might invalidate the model index and possibly + crash your application. */ /*! \fn QModelIndex QModelIndex::sibling(int row, int column) const - Returns the sibling at \a row and \a column or an invalid - QModelIndex if there is no sibling at this position. + Returns the sibling at \a row and \a column. If there is no sibling at this + position, an invalid QModelIndex is returned. - \sa parent() child() + \sa parent(), child() */ /*! \fn QModelIndex QModelIndex::child(int row, int column) const - Returns the child of the model index that is stored in the given - \a row and \a column. + Returns the child of the model index that is stored in the given \a row and + \a column. - \sa parent() sibling() + \sa parent(), sibling() */ /*! \fn QVariant QModelIndex::data(int role) const - Returns the data for the given \a role for the item referred to by the index. + Returns the data for the given \a role for the item referred to by the + index. */ /*! @@ -910,28 +915,29 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, /*! \fn bool QModelIndex::operator==(const QModelIndex &other) const - Returns true if this model index refers to the same location as - the \a other model index; otherwise returns false. - Note that all values in the model index are used when comparing - with another model index. + Returns true if this model index refers to the same location as the + \a other model index; otherwise returns false. + + All values in the model index are used when comparing with another model + index. */ /*! \fn bool QModelIndex::operator!=(const QModelIndex &other) const - Returns true if this model index does not refer to the same - location as the \a other model index; otherwise returns false. + Returns true if this model index does not refer to the same location as + the \a other model index; otherwise returns false. */ /*! - \fn QModelIndex QModelIndex::parent() const + \fn QModelIndex QModelIndex::parent() const - Returns the parent of the model index, or QModelIndex() if it has no - parent. + Returns the parent of the model index, or QModelIndex() if it has no + parent. - \sa child() sibling() model() + \sa child(), sibling(), model() */ /*! @@ -960,7 +966,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, simple table of rows and columns. Each item has a unique index specified by a QModelIndex. - \img modelindex-no-parent.png + \image modelindex-no-parent.png Every item of data that can be accessed via a model has an associated model index. You can obtain this model index using the index() function. Each @@ -1078,9 +1084,8 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \sa {Model Classes}, {Model Subclassing Reference}, QModelIndex, QAbstractItemView, {Using Drag and Drop with Item Views}, - {Simple DOM Model Example}, - {Simple Tree Model Example}, {Editable Tree Model Example}, - {Fetch More Example} + {Simple DOM Model Example}, {Simple Tree Model Example}, + {Editable Tree Model Example}, {Fetch More Example} */ /*! @@ -1089,8 +1094,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, Returns the index of the item in the model specified by the given \a row, \a column and \a parent index. - When reimplementing this function in a subclass, call createIndex() to generate - model indexes that other components can use to refer to items in your model. + When reimplementing this function in a subclass, call createIndex() to + generate model indexes that other components can use to refer to items in + your model. \sa createIndex() */ @@ -1099,8 +1105,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \fn bool QAbstractItemModel::insertColumn(int column, const QModelIndex &parent) Inserts a single column before the given \a column in the child items of - the \a parent specified. Returns true if the column is inserted; otherwise - returns false. + the \a parent specified. + + Returns true if the column is inserted; otherwise returns false. \sa insertColumns() insertRow() removeColumn() */ @@ -1109,8 +1116,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \fn bool QAbstractItemModel::insertRow(int row, const QModelIndex &parent) Inserts a single row before the given \a row in the child items of the - \a parent specified. Returns true if the row is inserted; otherwise - returns false. + \a parent specified. + + Returns true if the row is inserted; otherwise returns false. \sa insertRows() insertColumn() removeRow() */ @@ -1123,17 +1131,18 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, /*! \fn QModelIndex QAbstractItemModel::parent(const QModelIndex &index) const = 0 - Returns the parent of the model item with the given \a index, or QModelIndex() - if it has no parent. + Returns the parent of the model item with the given \a index. If the model + has no parent, an invalid QModelIndex is returned. A common convention used in models that expose tree data structures is that - only items in the first column have children. For that case, when reimplementing - this function in a subclass the column of the returned QModelIndex would be 0. + only items in the first column have children. For that case, when + reimplementing this function in a subclass the column of the returned + QModelIndex would be 0. - \note When reimplementing this function in a subclass, be careful to avoid + When reimplementing this function in a subclass, be careful to avoid calling QModelIndex member functions, such as QModelIndex::parent(), since - indexes belonging to your model will simply call your implementation, leading - to infinite recursion. + indexes belonging to your model will simply call your implementation, + leading to infinite recursion. \sa createIndex() */ @@ -1141,7 +1150,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, /*! \fn bool QAbstractItemModel::removeColumn(int column, const QModelIndex &parent) - Removes the given \a column from the child items of the \a parent specified. + Removes the given \a column from the child items of the \a parent + specified. + Returns true if the column is removed; otherwise returns false. \sa removeColumns(), removeRow(), insertColumn() @@ -1151,10 +1162,11 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \fn bool QAbstractItemModel::removeRow(int row, const QModelIndex &parent) Removes the given \a row from the child items of the \a parent specified. + Returns true if the row is removed; otherwise returns false. - The removeRow() is a convenience function that calls removeRows(). - The QAbstractItemModel implementation of removeRows does nothing. + This is a convenience function that calls removeRows(). The + QAbstractItemModel implementation of removeRows() does nothing. \sa removeRows(), removeColumn(), insertRow() */ @@ -1166,13 +1178,12 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, indicates whether the horizontal or vertical header has changed. The sections in the header from the \a first to the \a last need to be updated. - Note that this signal must be emitted explicitly when - reimplementing the setHeaderData() function. + When reimplementing the setHeaderData() function, this signal must be + emitted explicitly. - If you are changing the number of columns or rows you don't need - to emit this signal, but use the begin/end functions (see the - section on subclassing in the QAbstractItemModel class description - for details). + If you are changing the number of columns or rows you do not need to emit + this signal, but use the begin/end functions (refer to the section on + subclassing in the QAbstractItemModel class description for details). \sa headerData(), setHeaderData(), dataChanged() */ @@ -1182,8 +1193,8 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \since 4.2 This signal is emitted just before the layout of a model is changed. - Components connected to this signal use it to adapt to changes - in the model's layout. + Components connected to this signal use it to adapt to changes in the + model's layout. Subclasses should update any persistent model indexes after emitting layoutAboutToBeChanged(). @@ -1195,19 +1206,20 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \fn void QAbstractItemModel::layoutChanged() This signal is emitted whenever the layout of items exposed by the model - has changed; for example, when the model has been sorted. When this signal is - received by a view, it should update the layout of items to reflect this + has changed; for example, when the model has been sorted. When this signal + is received by a view, it should update the layout of items to reflect this change. - When subclassing QAbstractItemModel or QAbstractProxyModel, ensure that - you emit layoutAboutToBeChanged() before changing the order of items or + When subclassing QAbstractItemModel or QAbstractProxyModel, ensure that you + emit layoutAboutToBeChanged() before changing the order of items or altering the structure of the data you expose to views, and emit layoutChanged() after changing the layout. - Subclasses should update any persistent model indexes before - emitting layoutChanged(). + Subclasses should update any persistent model indexes before emitting + layoutChanged(). - \sa layoutAboutToBeChanged(), dataChanged(), headerDataChanged(), reset(), changePersistentIndex() + \sa layoutAboutToBeChanged(), dataChanged(), headerDataChanged(), reset(), + changePersistentIndex() */ /*! @@ -1237,12 +1249,12 @@ QAbstractItemModel::~QAbstractItemModel() /*! \fn QModelIndex QAbstractItemModel::sibling(int row, int column, const QModelIndex &index) const - Returns the sibling at \a row and \a column for the item at \a index, or - an invalid QModelIndex if there is no sibling at that location. + Returns the sibling at \a row and \a column for the item at \a index, or an + invalid QModelIndex if there is no sibling at that location. sibling() is just a convenience function that finds the item's parent, and - uses it to retrieve the index of the child item in the specified \a row - and \a column. + uses it to retrieve the index of the child item in the specified \a row and + \a column. \sa index(), QModelIndex::row(), QModelIndex::column() */ @@ -1251,11 +1263,11 @@ QAbstractItemModel::~QAbstractItemModel() /*! \fn int QAbstractItemModel::rowCount(const QModelIndex &parent) const - Returns the number of rows under the given \a parent. When the parent - is valid it means that rowCount is returning the number of children of parent. + Returns the number of rows under the given \a parent. When the parent is + valid it means that rowCount is returning the number of children of parent. - \bold{Tip:} When implementing a table based model, rowCount() should return 0 when - the parent is valid. + \note When implementing a table based model, rowCount() should return 0 + when the parent is valid. \sa columnCount() */ @@ -1265,13 +1277,14 @@ QAbstractItemModel::~QAbstractItemModel() Returns the number of columns for the children of the given \a parent. - In most subclasses, the number of columns is independent of the - \a parent. For example: + In most subclasses, the number of columns is independent of the \a parent. + + For example: \snippet examples/itemviews/simpledommodel/dommodel.cpp 2 - \bold{Tip:} When implementing a table based model, columnCount() should return 0 when - the parent is valid. + \note When implementing a table based model, columnCount() should return 0 + when the parent is valid. \sa rowCount() */ @@ -1298,8 +1311,8 @@ QAbstractItemModel::~QAbstractItemModel() model. The new items are those between \a start and \a end inclusive, under the given \a parent item. - \bold{Note:} Components connected to this signal use it to adapt to changes - in the model's dimensions. It can only be emitted by the QAbstractItemModel + \note Components connected to this signal use it to adapt to changes in the + model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. \sa insertRows(), beginInsertRows() @@ -1308,11 +1321,11 @@ QAbstractItemModel::~QAbstractItemModel() /*! \fn void QAbstractItemModel::rowsAboutToBeInserted(const QModelIndex &parent, int start, int end) - This signal is emitted just before rows are inserted into the - model. The new items will be positioned between \a start and \a end - inclusive, under the given \a parent item. + This signal is emitted just before rows are inserted into the model. The + new items will be positioned between \a start and \a end inclusive, under + the given \a parent item. - \bold{Note:} Components connected to this signal use it to adapt to changes + \note Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. @@ -1322,11 +1335,11 @@ QAbstractItemModel::~QAbstractItemModel() /*! \fn void QAbstractItemModel::rowsRemoved(const QModelIndex &parent, int start, int end) - This signal is emitted after rows have been removed from the - model. The removed items are those between \a start and \a end - inclusive, under the given \a parent item. + This signal is emitted after rows have been removed from the model. The + removed items are those between \a start and \a end inclusive, under the + given \a parent item. - \bold{Note:} Components connected to this signal use it to adapt to changes + \note Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. @@ -1336,11 +1349,11 @@ QAbstractItemModel::~QAbstractItemModel() /*! \fn void QAbstractItemModel::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) - This signal is emitted just before rows are removed from the - model. The items that will be removed are those between \a start and \a end - inclusive, under the given \a parent item. + This signal is emitted just before rows are removed from the model. The + items that will be removed are those between \a start and \a end inclusive, + under the given \a parent item. - \bold{Note:} Components connected to this signal use it to adapt to changes + \note Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. @@ -1350,12 +1363,12 @@ QAbstractItemModel::~QAbstractItemModel() /*! \fn void QAbstractItemModel::columnsInserted(const QModelIndex &parent, int start, int end) - This signal is emitted after columns have been inserted into the - model. The new items are those between \a start and \a end - inclusive, under the given \a parent item. + This signal is emitted after columns have been inserted into the model. The + new items are those between \a start and \a end inclusive, under the given + \a parent item. - \bold{Note:} Components connected to this signal use it to adapt to changes - in the model's dimensions. It can only be emitted by the QAbstractItemModel + \note Components connected to this signal use it to adapt to changes in the + model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. \sa insertColumns(), beginInsertColumns() @@ -1364,12 +1377,12 @@ QAbstractItemModel::~QAbstractItemModel() /*! \fn void QAbstractItemModel::columnsAboutToBeInserted(const QModelIndex &parent, int start, int end) - This signal is emitted just before columns are inserted into the - model. The new items will be positioned between \a start and \a end - inclusive, under the given \a parent item. + This signal is emitted just before columns are inserted into the model. The + new items will be positioned between \a start and \a end inclusive, under + the given \a parent item. - \bold{Note:} Components connected to this signal use it to adapt to changes - in the model's dimensions. It can only be emitted by the QAbstractItemModel + \note Components connected to this signal use it to adapt to changes in the + model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. \sa insertColumns(), beginInsertColumns() @@ -1378,12 +1391,12 @@ QAbstractItemModel::~QAbstractItemModel() /*! \fn void QAbstractItemModel::columnsRemoved(const QModelIndex &parent, int start, int end) - This signal is emitted after columns have been removed from the - model. The removed items are those between \a start and \a end - inclusive, under the given \a parent item. + This signal is emitted after columns have been removed from the model. + The removed items are those between \a start and \a end inclusive, + under the given \a parent item. - \bold{Note:} Components connected to this signal use it to adapt to changes - in the model's dimensions. It can only be emitted by the QAbstractItemModel + \note Components connected to this signal use it to adapt to changes in + the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. \sa removeColumns(), beginRemoveColumns() @@ -1392,20 +1405,20 @@ QAbstractItemModel::~QAbstractItemModel() /*! \fn void QAbstractItemModel::columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end) - This signal is emitted just before columns are removed - from the model. The items to be removed are those between \a start and - \a end inclusive, under the given \a parent item. + This signal is emitted just before columns are removed from the model. The + items to be removed are those between \a start and \a end inclusive, under + the given \a parent item. - \bold{Note:} Components connected to this signal use it to adapt to changes - in the model's dimensions. It can only be emitted by the QAbstractItemModel + \note Components connected to this signal use it to adapt to changes in the + model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. \sa removeColumns(), beginRemoveColumns() */ /*! - Returns true if the model returns a valid QModelIndex for \a row and - \a column with \a parent, otherwise returns false. + Returns true if the model returns a valid QModelIndex for \a row and + \a column with \a parent, otherwise returns false. */ bool QAbstractItemModel::hasIndex(int row, int column, const QModelIndex &parent) const { @@ -1416,10 +1429,11 @@ bool QAbstractItemModel::hasIndex(int row, int column, const QModelIndex &parent /*! - Returns true if \a parent has any children; otherwise returns false. - Use rowCount() on the parent to find out the number of children. + Returns true if \a parent has any children; otherwise returns false. + + Use rowCount() on the parent to find out the number of children. - \sa parent() index() + \sa parent() index() */ bool QAbstractItemModel::hasChildren(const QModelIndex &parent) const { @@ -1428,11 +1442,11 @@ bool QAbstractItemModel::hasChildren(const QModelIndex &parent) const /*! - Returns a map with values for all predefined roles in the model - for the item at the given \a index. + Returns a map with values for all predefined roles in the model for the + item at the given \a index. - Reimplemented this function if you want to extend the default behavior - of this function to include custom roles in the map. + Reimplement this function if you want to extend the default behavior of + this function to include custom roles in the map. \sa Qt::ItemDataRole, data() */ @@ -1449,14 +1463,14 @@ QMap QAbstractItemModel::itemData(const QModelIndex &index) const /*! Sets the \a role data for the item at \a index to \a value. + Returns true if successful; otherwise returns false. - The dataChanged() signal should be emitted if the data was successfully set. + The dataChanged() signal should be emitted if the data was successfully + set. - The base class implementation returns false. This function and - data() must be reimplemented for editable models. Note that the - dataChanged() signal must be emitted explicitly when - reimplementing this function. + The base class implementation returns false. This function and data() must + be reimplemented for editable models. \sa Qt::ItemDataRole, data(), itemData() */ @@ -1475,15 +1489,16 @@ bool QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value by the \a index. \note If you do not have a value to return, return an \bold invalid - QVariant() instead of returning 0. + QVariant instead of returning 0. \sa Qt::ItemDataRole, setData(), headerData() */ /*! Sets the role data for the item at \a index to the associated value in - \a roles, for every Qt::ItemDataRole. Returns true if successful; otherwise - returns false. + \a roles, for every Qt::ItemDataRole. + + Returns true if successful; otherwise returns false. Roles that are not in \a roles will not be modified. @@ -1498,8 +1513,8 @@ bool QAbstractItemModel::setItemData(const QModelIndex &index, const QMap &roleNames) { @@ -1915,11 +1944,11 @@ void QAbstractItemModel::setRoleNames(const QHash &roleNames) } /*! - \since 4.6 + \since 4.6 - Returns the model's role names. + Returns the model's role names. - \sa setRoleNames() + \sa setRoleNames() */ const QHash &QAbstractItemModel::roleNames() const { @@ -1928,10 +1957,12 @@ const QHash &QAbstractItemModel::roleNames() const } /*! - Called to let the model know that it should submit whatever it has cached - to the permanent storage. Typically used for row editing. + Lets the model know that it should submit cached information to permanent + storage. This function is typically used for row editing. + + Returns true if there is no error; otherwise returns false. - Returns false on error, otherwise true. + \sa revert() */ bool QAbstractItemModel::submit() @@ -1940,8 +1971,10 @@ bool QAbstractItemModel::submit() } /*! - Called to let the model know that it should discard whatever it has cached. - Typically used for row editing. + Lets the model know that it should discard cached information. This + function is typically used for row editing. + + \sa submit() */ void QAbstractItemModel::revert() @@ -1950,14 +1983,14 @@ void QAbstractItemModel::revert() } /*! - Returns the data for the given \a role and \a section in the header - with the specified \a orientation. + Returns the data for the given \a role and \a section in the header with + the specified \a orientation. - For horizontal headers, the section number corresponds to the column - number of items shown beneath it. For vertical headers, the section - number typically to the row number of items shown alongside it. + For horizontal headers, the section number corresponds to the column + number. Similarly, for vertical headers, the section number corresponds to + the row number. - \sa Qt::ItemDataRole, setHeaderData(), QHeaderView + \sa Qt::ItemDataRole, setHeaderData(), QHeaderView */ QVariant QAbstractItemModel::headerData(int section, Qt::Orientation orientation, int role) const @@ -1969,14 +2002,15 @@ QVariant QAbstractItemModel::headerData(int section, Qt::Orientation orientation } /*! - Sets the data for the given \a role and \a section in the header with - the specified \a orientation to the \a value supplied. - Returns true if the header's data was updated; otherwise returns false. + Sets the data for the given \a role and \a section in the header with the + specified \a orientation to the \a value supplied. - Note that the headerDataChanged() signal must be emitted explicitly - when reimplementing this function. + Returns true if the header's data was updated; otherwise returns false. - \sa Qt::ItemDataRole, headerData() + When reimplementing this function, the headerDataChanged() signal must be + emitted explicitly. + + \sa Qt::ItemDataRole, headerData() */ bool QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation, @@ -1992,11 +2026,12 @@ bool QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation, /*! \fn QModelIndex QAbstractItemModel::createIndex(int row, int column, void *ptr) const - Creates a model index for the given \a row and \a column with the internal pointer \a ptr. + Creates a model index for the given \a row and \a column with the internal + pointer \a ptr. - Note that when you are using a QSortFilterProxyModel its indexes have their own - internal pointer. It is not advisable to access the internal pointer in the index - outside of the model. Use the data() function instead. + When using a QSortFilterProxyModel, its indexes have their own internal + pointer. It is not advisable to access this internal pointer outside of the + model. Use the data() function instead. This function provides a consistent interface that model subclasses must use to create model indexes. @@ -2006,7 +2041,8 @@ bool QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation, \fn QModelIndex QAbstractItemModel::createIndex(int row, int column, int id) const \obsolete - Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead. + Use QModelIndex + QAbstractItemModel::createIndex(int row, int column, quint32 id) instead. */ /*! @@ -2017,6 +2053,7 @@ bool QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation, This function provides a consistent interface that model subclasses must use to create model indexes. + \sa QModelIndex::internalId() */ @@ -2120,32 +2157,36 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare /*! Begins a row insertion operation. - When reimplementing insertRows() in a subclass, you must call this - function \e before inserting data into the model's underlying data - store. + When reimplementing insertRows() in a subclass, you must call this function + \e before inserting data into the model's underlying data store. - The \a parent index corresponds to the parent into which the new - rows are inserted; \a first and \a last are the row numbers that the - new rows will have after they have been inserted. + The \a parent index corresponds to the parent into which the new rows are + inserted; \a first and \a last are the row numbers that the new rows will + have after they have been inserted. \table 80% - \row \o \inlineimage modelview-begin-insert-rows.png Inserting rows - \o Specify the first and last row numbers for the span of rows - you want to insert into an item in a model. - - For example, as shown in the diagram, we insert three rows before - row 2, so \a first is 2 and \a last is 4: - \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 0 - This inserts the three new rows as rows 2, 3, and 4. \row - \o \inlineimage modelview-begin-append-rows.png Appending rows - \o To append rows, insert them after the last row. - - For example, as shown in the diagram, we append two rows to a - collection of 4 existing rows (ending in row 3), so \a first is 4 - and \a last is 5: - \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 1 - This appends the two new rows as rows 4 and 5. + \o \inlineimage modelview-begin-insert-rows.png Inserting rows + \o Specify the first and last row numbers for the span of rows you + want to insert into an item in a model. + + For example, as shown in the diagram, we insert three rows before + row 2, so \a first is 2 and \a last is 4: + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 0 + + This inserts the three new rows as rows 2, 3, and 4. + \row + \o \inlineimage modelview-begin-append-rows.png Appending rows + \o To append rows, insert them after the last row. + + For example, as shown in the diagram, we append two rows to a + collection of 4 existing rows (ending in row 3), so \a first is 4 + and \a last is 5: + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 1 + + This appends the two new rows as rows 4 and 5. \endtable \sa endInsertRows() @@ -2163,9 +2204,8 @@ void QAbstractItemModel::beginInsertRows(const QModelIndex &parent, int first, i /*! Ends a row insertion operation. - When reimplementing insertRows() in a subclass, you must call this - function \e after inserting data into the model's underlying data - store. + When reimplementing insertRows() in a subclass, you must call this function + \e after inserting data into the model's underlying data store. \sa beginInsertRows() */ @@ -2181,21 +2221,22 @@ void QAbstractItemModel::endInsertRows() Begins a row removal operation. When reimplementing removeRows() in a subclass, you must call this - function \e before removing data from the model's underlying data - store. + function \e before removing data from the model's underlying data store. - The \a parent index corresponds to the parent from which the new - rows are removed; \a first and \a last are the row numbers of the - rows to be removed. + The \a parent index corresponds to the parent from which the new rows are + removed; \a first and \a last are the row numbers of the rows to be + removed. \table 80% - \row \o \inlineimage modelview-begin-remove-rows.png Removing rows - \o Specify the first and last row numbers for the span of rows - you want to remove from an item in a model. - - For example, as shown in the diagram, we remove the two rows from - row 2 to row 3, so \a first is 2 and \a last is 3: - \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 2 + \row + \o \inlineimage modelview-begin-remove-rows.png Removing rows + \o Specify the first and last row numbers for the span of rows you + want to remove from an item in a model. + + For example, as shown in the diagram, we remove the two rows from + row 2 to row 3, so \a first is 2 and \a last is 3: + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 2 \endtable \sa endRemoveRows() @@ -2213,9 +2254,8 @@ void QAbstractItemModel::beginRemoveRows(const QModelIndex &parent, int first, i /*! Ends a row removal operation. - When reimplementing removeRows() in a subclass, you must call this - function \e after removing data from the model's underlying data - store. + When reimplementing removeRows() in a subclass, you must call this function + \e after removing data from the model's underlying data store. \sa beginRemoveRows() */ @@ -2231,31 +2271,35 @@ void QAbstractItemModel::endRemoveRows() Begins a column insertion operation. When reimplementing insertColumns() in a subclass, you must call this - function \e before inserting data into the model's underlying data - store. + function \e before inserting data into the model's underlying data store. - The \a parent index corresponds to the parent into which the new - columns are inserted; \a first and \a last are the column numbers of - the new columns will have after they have been inserted. + The \a parent index corresponds to the parent into which the new columns + are inserted; \a first and \a last are the column numbers of the new + columns will have after they have been inserted. \table 80% - \row \o \inlineimage modelview-begin-insert-columns.png Inserting columns - \o Specify the first and last column numbers for the span of columns - you want to insert into an item in a model. - - For example, as shown in the diagram, we insert three columns before - column 4, so \a first is 4 and \a last is 6: - \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 3 - This inserts the three new columns as columns 4, 5, and 6. \row - \o \inlineimage modelview-begin-append-columns.png Appending columns - \o To append columns, insert them after the last column. - - For example, as shown in the diagram, we append three columns to a - collection of six existing columns (ending in column 5), so \a first - is 6 and \a last is 8: - \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 4 - This appends the two new columns as columns 6, 7, and 8. + \o \inlineimage modelview-begin-insert-columns.png Inserting columns + \o Specify the first and last column numbers for the span of columns + you want to insert into an item in a model. + + For example, as shown in the diagram, we insert three columns + before column 4, so \a first is 4 and \a last is 6: + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 3 + + This inserts the three new columns as columns 4, 5, and 6. + \row + \o \inlineimage modelview-begin-append-columns.png Appending columns + \o To append columns, insert them after the last column. + + For example, as shown in the diagram, we append three columns to a + collection of six existing columns (ending in column 5), so + \a first is 6 and \a last is 8: + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 4 + + This appends the two new columns as columns 6, 7, and 8. \endtable \sa endInsertColumns() @@ -2291,21 +2335,22 @@ void QAbstractItemModel::endInsertColumns() Begins a column removal operation. When reimplementing removeColumns() in a subclass, you must call this - function \e before removing data from the model's underlying data - store. + function \e before removing data from the model's underlying data store. - The \a parent index corresponds to the parent from which the new - columns are removed; \a first and \a last are the column numbers of - the first and last columns to be removed. + The \a parent index corresponds to the parent from which the new columns + are removed; \a first and \a last are the column numbers of the first and + last columns to be removed. \table 80% - \row \o \inlineimage modelview-begin-remove-columns.png Removing columns - \o Specify the first and last column numbers for the span of columns - you want to remove from an item in a model. - - For example, as shown in the diagram, we remove the three columns - from column 4 to column 6, so \a first is 4 and \a last is 6: - \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 5 + \row + \o \inlineimage modelview-begin-remove-columns.png Removing columns + \o Specify the first and last column numbers for the span of columns + you want to remove from an item in a model. + + For example, as shown in the diagram, we remove the three columns + from column 4 to column 6, so \a first is 4 and \a last is 6: + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 5 \endtable \sa endRemoveColumns() @@ -2324,8 +2369,7 @@ void QAbstractItemModel::beginRemoveColumns(const QModelIndex &parent, int first Ends a column removal operation. When reimplementing removeColumns() in a subclass, you must call this - function \e after removing data from the model's underlying data - store. + function \e after removing data from the model's underlying data store. \sa beginRemoveColumns() */ @@ -2340,11 +2384,11 @@ void QAbstractItemModel::endRemoveColumns() /*! Resets the model to its original state in any attached views. - \note The view to which the model is attached to will be reset as well. + The view to which the model is attached to will be reset as well. When a model is reset it means that any previous data reported from the - model is now invalid and has to be queried for again. This also means - that the current item and any selected items will become invalid. + model is now invalid and has to be queried for again. This also means that + the current item and any selected items will become invalid. When a model radically changes its data it can sometimes be easier to just call this function rather than emit dataChanged() to inform other @@ -2361,13 +2405,13 @@ void QAbstractItemModel::reset() } /*! - Changes the QPersistentModelIndex that is equal to the given \a from - model index to the given \a to model index. + Changes the QPersistentModelIndex that is equal to the given \a from model + index to the given \a to model index. - If no persistent model index equal to the given \a from model index was - found, nothing is changed. + If no persistent model index equal to the given \a from model index was + found, nothing is changed. - \sa persistentIndexList(), changePersistentIndexList() + \sa persistentIndexList(), changePersistentIndexList() */ void QAbstractItemModel::changePersistentIndex(const QModelIndex &from, const QModelIndex &to) { @@ -2388,15 +2432,15 @@ void QAbstractItemModel::changePersistentIndex(const QModelIndex &from, const QM } /*! - \since 4.1 + \since 4.1 - Changes the QPersistentModelIndexes that is equal to the indexes in the given \a from - model index list to the given \a to model index list. + Changes the QPersistentModelIndexes that is equal to the indexes in the + given \a from model index list to the given \a to model index list. - If no persistent model indexes equal to the indexes in the given \a from model index list - was found, nothing is changed. + If no persistent model indexes equal to the indexes in the given \a from + model index list was found, nothing is changed. - \sa persistentIndexList(), changePersistentIndex() + \sa persistentIndexList(), changePersistentIndex() */ void QAbstractItemModel::changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to) @@ -2429,9 +2473,9 @@ void QAbstractItemModel::changePersistentIndexList(const QModelIndexList &from, } /*! - \since 4.2 + \since 4.2 - Returns the list of indexes stored as persistent indexes in the model. + Returns the list of indexes stored as persistent indexes in the model. */ QModelIndexList QAbstractItemModel::persistentIndexList() const { @@ -2458,10 +2502,10 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const but must be subclassed. Since the model provides a more specialized interface than - QAbstractItemModel, it is not suitable for use with tree views, although - it can be used to provide data to a QListView. If you need to represent - a simple list of items, and only need a model to contain a single column - of data, subclassing the QAbstractListModel may be more appropriate. + QAbstractItemModel, it is not suitable for use with tree views, although it + can be used to provide data to a QListView. If you need to represent a + simple list of items, and only need a model to contain a single column of + data, subclassing the QAbstractListModel may be more appropriate. The rowCount() and columnCount() functions return the dimensions of the table. To retrieve a model index corresponding to an item in the model, use @@ -2469,9 +2513,6 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const \section1 Subclassing - \bold{Note:} Some general guidelines for subclassing models are - available in the \l{Model Subclassing Reference}. - When subclassing QAbstractTableModel, you must implement rowCount(), columnCount(), and data(). Default implementations of the index() and parent() functions are provided by QAbstractTableModel. @@ -2502,9 +2543,13 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const call endRemoveColumns() \e{immediately afterwards}. \endlist - \sa {Model Classes}, {Model Subclassing Reference}, QAbstractItemModel, - QAbstractListModel, - {Pixelator Example} + \note Some general guidelines for subclassing models are available in the + \l{Model Subclassing Reference}. + + \note + + \sa {Model Classes}, QAbstractItemModel, QAbstractListModel, + {Pixelator Example} */ /*! @@ -2602,9 +2647,6 @@ bool QAbstractTableModel::hasChildren(const QModelIndex &parent) const \section1 Subclassing - \bold{Note:} Some general guidelines for subclassing models are - available in the \l{Model Subclassing Reference}. - When subclassing QAbstractListModel, you must provide implementations of the rowCount() and data() functions. Well behaved models also provide a headerData() implementation. @@ -2631,6 +2673,9 @@ bool QAbstractTableModel::hasChildren(const QModelIndex &parent) const call endRemoveRows() \e{immediately afterwards}. \endlist + \note Some general guidelines for subclassing models are available in the + \l{Model Subclassing Reference}. + \sa {Model Classes}, {Model Subclassing Reference}, QAbstractItemView, QAbstractTableModel, {Item Views Puzzle Example} */ -- cgit v0.12 From 332ca73378043970087f843036d02192e3fef50d Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Wed, 19 Aug 2009 15:48:55 +0200 Subject: Doc - Fixed whitespace issues Reviewed-By: TrustMe --- src/corelib/kernel/qabstractitemmodel.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index fd2611b..8761ec1 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -862,7 +862,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \fn bool QModelIndex::isValid() const Returns true if this model index is valid; otherwise returns false. - + A valid index belongs to a model, and has non-negative row and column numbers. @@ -1767,7 +1767,7 @@ void QAbstractItemModel::fetchMore(const QModelIndex &) /*! Returns true if there is more data available for \a parent; otherwise returns false. - + The default implementation always returns false. If canFetchMore() returns true, QAbstractItemView will call fetchMore(). @@ -1840,7 +1840,7 @@ QModelIndex QAbstractItemModel::buddy(const QModelIndex &index) const By default, this function will perform a wrapping, string-based comparison on all items, searching for items that begin with the search term specified by \a value. - + \note The default implementation of this function only searches columns. Reimplement this function to include a different search behavior. */ @@ -1931,7 +1931,7 @@ QSize QAbstractItemModel::span(const QModelIndex &) const Sets the model's role names to \a roleNames. This function allows mapping of role identifiers to role property names in - Declarative UI. This function must be called before the model is used. + Declarative UI. This function must be called before the model is used. Modifying the role names after the model has been set may result in undefined behaviour. @@ -2172,20 +2172,20 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare For example, as shown in the diagram, we insert three rows before row 2, so \a first is 2 and \a last is 4: - + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 0 - + This inserts the three new rows as rows 2, 3, and 4. \row \o \inlineimage modelview-begin-append-rows.png Appending rows \o To append rows, insert them after the last row. - + For example, as shown in the diagram, we append two rows to a collection of 4 existing rows (ending in row 3), so \a first is 4 and \a last is 5: \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 1 - + This appends the two new rows as rows 4 and 5. \endtable @@ -2235,7 +2235,7 @@ void QAbstractItemModel::endInsertRows() For example, as shown in the diagram, we remove the two rows from row 2 to row 3, so \a first is 2 and \a last is 3: - + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 2 \endtable @@ -2287,7 +2287,7 @@ void QAbstractItemModel::endRemoveRows() before column 4, so \a first is 4 and \a last is 6: \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 3 - + This inserts the three new columns as columns 4, 5, and 6. \row \o \inlineimage modelview-begin-append-columns.png Appending columns @@ -2296,9 +2296,9 @@ void QAbstractItemModel::endRemoveRows() For example, as shown in the diagram, we append three columns to a collection of six existing columns (ending in column 5), so \a first is 6 and \a last is 8: - + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 4 - + This appends the two new columns as columns 6, 7, and 8. \endtable @@ -2346,10 +2346,10 @@ void QAbstractItemModel::endInsertColumns() \o \inlineimage modelview-begin-remove-columns.png Removing columns \o Specify the first and last column numbers for the span of columns you want to remove from an item in a model. - + For example, as shown in the diagram, we remove the three columns from column 4 to column 6, so \a first is 4 and \a last is 6: - + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 5 \endtable @@ -2546,7 +2546,7 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const \note Some general guidelines for subclassing models are available in the \l{Model Subclassing Reference}. - \note + \note \sa {Model Classes}, QAbstractItemModel, QAbstractListModel, {Pixelator Example} -- cgit v0.12 From 0d9cc367b72d74d709b9a03748db6dd48e126472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 19 Aug 2009 15:06:15 +0200 Subject: Changed the streambookmarks example to use aggregation QXmlStreamReader and QXmlStreamWriter can be used conveniently without subclassing, which the example now demonstrates. Reviewed-by: mae Reviewed-by: David Boddie --- doc/src/examples/qxmlstreambookmarks.qdoc | 42 ++++++++++-------- examples/xml/streambookmarks/mainwindow.cpp | 4 +- examples/xml/streambookmarks/xbelreader.cpp | 68 +++++++++++++++++------------ examples/xml/streambookmarks/xbelreader.h | 5 ++- examples/xml/streambookmarks/xbelwriter.cpp | 32 +++++++------- examples/xml/streambookmarks/xbelwriter.h | 3 +- src/corelib/xml/qxmlstream.cpp | 6 +-- 7 files changed, 89 insertions(+), 71 deletions(-) diff --git a/doc/src/examples/qxmlstreambookmarks.qdoc b/doc/src/examples/qxmlstreambookmarks.qdoc index 26964c4..904cd6d 100644 --- a/doc/src/examples/qxmlstreambookmarks.qdoc +++ b/doc/src/examples/qxmlstreambookmarks.qdoc @@ -51,10 +51,10 @@ \section1 XbelWriter Class Definition - The \c XbelWriter class is a subclass of QXmlStreamReader, which provides - an XML parser with a streaming API. \c XbelWriter also contains a private - instance of QTreeWidget in order to display the bookmarks according to - hierarchies. + The \c XbelWriter class contains a private instance of QXmlStreamWriter, + which provides an XML writer with a streaming API. \c XbelWriter also + has a reference to the QTreeWidget instance where the bookmark hierarchy + is stored. \snippet examples/xml/streambookmarks/xbelwriter.h 0 @@ -75,7 +75,7 @@ \snippet examples/xml/streambookmarks/xbelwriter.cpp 1 - The \c writeItem() function accepts a QTreeWidget object and writes it + The \c writeItem() function accepts a QTreeWidgetItem object and writes it to the stream, depending on its \c tagName, which can either be a "folder", "bookmark", or "separator". @@ -83,9 +83,10 @@ \section1 XbelReader Class Definition - The \c XbelReader class is a subclass of QXmlStreamReader, the pendent - class for QXmlStreamWriter. \c XbelReader contains a private instance - of QTreeWidget to group bookmarks according to their hierarchies. + The \c XbelReader contains a private instance of QXmlStreamReader, the + companion class to QXmlStreamWriter. \c XbelReader also contains a + reference to the QTreeWidget that is used to group the bookmarks according + to their hierarchy. \snippet examples/xml/streambookmarks/xbelreader.h 0 @@ -102,21 +103,26 @@ \snippet examples/xml/streambookmarks/xbelreader.cpp 0 The \c read() function accepts a QIODevice and sets it using - \l{QXmlStreamReader::setDevice()}{setDevice()}. The actual process - of reading only takes place if the file is a valid XBEL 1.0 file. - Note that the XML input needs to be well-formed to be accepted by - QXmlStreamReader. Otherwise, the \l{QXmlStreamReader::raiseError()} - {raiseError()} function is used to display an error message. Since the - XBEL reader is only concerned with reading XML elements, it makes - extensive use of the \l{QXmlStreamReader::readNextStartElement()} + \l{QXmlStreamReader::}{setDevice()}. The actual process of reading only + takes place if the file is a valid XBEL 1.0 file. Note that the XML input + needs to be well-formed to be accepted by QXmlStreamReader. Otherwise, the + \l{QXmlStreamReader::}{raiseError()} function is used to display an error + message. Since the XBEL reader is only concerned with reading XML elements, + it makes extensive use of the \l{QXmlStreamReader::}{readNextStartElement()} convenience function. \snippet examples/xml/streambookmarks/xbelreader.cpp 1 + The \c errorString() function is used if an error occurred, in order to + obtain a description of the error complete with line and column number + information. + + \snippet examples/xml/streambookmarks/xbelreader.cpp 2 + The \c readXBEL() function reads the name of a startElement and calls the appropriate function to read it, depending on whether if its a "folder", "bookmark" or "separator". Otherwise, it calls - \l{QXmlStreamReader::skipCurrentElement()}. The Q_ASSERT() macro is used + \l{QXmlStreamReader::}{skipCurrentElement()}. The Q_ASSERT() macro is used to provide a pre-condition for the function. \snippet examples/xml/streambookmarks/xbelreader.cpp 3 @@ -126,8 +132,8 @@ \snippet examples/xml/streambookmarks/xbelreader.cpp 4 The \c readSeparator() function creates a separator and sets its flags. - The text is set to 30 "0xB7", the HEX equivalent for period, and then - read using \c readElementText(). + The text is set to 30 "0xB7", the HEX equivalent for period. The element + is then skipped using \l{QXmlStreamReader::}{skipCurrentElement()}. \snippet examples/xml/streambookmarks/xbelreader.cpp 5 diff --git a/examples/xml/streambookmarks/mainwindow.cpp b/examples/xml/streambookmarks/mainwindow.cpp index 183143d..5aef327 100644 --- a/examples/xml/streambookmarks/mainwindow.cpp +++ b/examples/xml/streambookmarks/mainwindow.cpp @@ -91,10 +91,8 @@ void MainWindow::open() XbelReader reader(treeWidget); if (!reader.read(&file)) { QMessageBox::warning(this, tr("QXmlStream Bookmarks"), - tr("Parse error in file %1 at line %2, column %3:\n%4") + tr("Parse error in file %1:\n\n%2") .arg(fileName) - .arg(reader.lineNumber()) - .arg(reader.columnNumber()) .arg(reader.errorString())); } else { statusBar()->showMessage(tr("File loaded"), 2000); diff --git a/examples/xml/streambookmarks/xbelreader.cpp b/examples/xml/streambookmarks/xbelreader.cpp index 99a7f34..0770643 100644 --- a/examples/xml/streambookmarks/xbelreader.cpp +++ b/examples/xml/streambookmarks/xbelreader.cpp @@ -60,33 +60,43 @@ XbelReader::XbelReader(QTreeWidget *treeWidget) //! [1] bool XbelReader::read(QIODevice *device) { - setDevice(device); + xml.setDevice(device); - if (readNextStartElement()) { - if (name() == "xbel" && attributes().value("version") == "1.0") + if (xml.readNextStartElement()) { + if (xml.name() == "xbel" && xml.attributes().value("version") == "1.0") readXBEL(); else - raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); + xml.raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); } - return !error(); + return !xml.error(); } //! [1] +//! [2] +QString XbelReader::errorString() const +{ + return QObject::tr("%1\nLine %2, column %3") + .arg(xml.errorString()) + .arg(xml.lineNumber()) + .arg(xml.columnNumber()); +} +//! [2] + //! [3] void XbelReader::readXBEL() { - Q_ASSERT(isStartElement() && name() == "xbel"); + Q_ASSERT(xml.isStartElement() && xml.name() == "xbel"); - while (readNextStartElement()) { - if (name() == "folder") + while (xml.readNextStartElement()) { + if (xml.name() == "folder") readFolder(0); - else if (name() == "bookmark") + else if (xml.name() == "bookmark") readBookmark(0); - else if (name() == "separator") + else if (xml.name() == "separator") readSeparator(0); else - skipCurrentElement(); + xml.skipCurrentElement(); } } //! [3] @@ -94,9 +104,9 @@ void XbelReader::readXBEL() //! [4] void XbelReader::readTitle(QTreeWidgetItem *item) { - Q_ASSERT(isStartElement() && name() == "title"); + Q_ASSERT(xml.isStartElement() && xml.name() == "title"); - QString title = readElementText(); + QString title = xml.readElementText(); item->setText(0, title); } //! [4] @@ -104,52 +114,52 @@ void XbelReader::readTitle(QTreeWidgetItem *item) //! [5] void XbelReader::readSeparator(QTreeWidgetItem *item) { - Q_ASSERT(isStartElement() && name() == "separator"); + Q_ASSERT(xml.isStartElement() && xml.name() == "separator"); QTreeWidgetItem *separator = createChildItem(item); separator->setFlags(item->flags() & ~Qt::ItemIsSelectable); separator->setText(0, QString(30, 0xB7)); - skipCurrentElement(); + xml.skipCurrentElement(); } //! [5] void XbelReader::readFolder(QTreeWidgetItem *item) { - Q_ASSERT(isStartElement() && name() == "folder"); + Q_ASSERT(xml.isStartElement() && xml.name() == "folder"); QTreeWidgetItem *folder = createChildItem(item); - bool folded = (attributes().value("folded") != "no"); + bool folded = (xml.attributes().value("folded") != "no"); treeWidget->setItemExpanded(folder, !folded); - while (readNextStartElement()) { - if (name() == "title") + while (xml.readNextStartElement()) { + if (xml.name() == "title") readTitle(folder); - else if (name() == "folder") + else if (xml.name() == "folder") readFolder(folder); - else if (name() == "bookmark") + else if (xml.name() == "bookmark") readBookmark(folder); - else if (name() == "separator") + else if (xml.name() == "separator") readSeparator(folder); else - skipCurrentElement(); + xml.skipCurrentElement(); } } void XbelReader::readBookmark(QTreeWidgetItem *item) { - Q_ASSERT(isStartElement() && name() == "bookmark"); + Q_ASSERT(xml.isStartElement() && xml.name() == "bookmark"); QTreeWidgetItem *bookmark = createChildItem(item); bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable); bookmark->setIcon(0, bookmarkIcon); bookmark->setText(0, QObject::tr("Unknown title")); - bookmark->setText(1, attributes().value("href").toString()); + bookmark->setText(1, xml.attributes().value("href").toString()); - while (readNextStartElement()) { - if (name() == "title") + while (xml.readNextStartElement()) { + if (xml.name() == "title") readTitle(bookmark); else - skipCurrentElement(); + xml.skipCurrentElement(); } } @@ -161,6 +171,6 @@ QTreeWidgetItem *XbelReader::createChildItem(QTreeWidgetItem *item) } else { childItem = new QTreeWidgetItem(treeWidget); } - childItem->setData(0, Qt::UserRole, name().toString()); + childItem->setData(0, Qt::UserRole, xml.name().toString()); return childItem; } diff --git a/examples/xml/streambookmarks/xbelreader.h b/examples/xml/streambookmarks/xbelreader.h index 2debadc..00d5850 100644 --- a/examples/xml/streambookmarks/xbelreader.h +++ b/examples/xml/streambookmarks/xbelreader.h @@ -51,7 +51,7 @@ class QTreeWidgetItem; QT_END_NAMESPACE //! [0] -class XbelReader : public QXmlStreamReader +class XbelReader { public: //! [1] @@ -60,6 +60,8 @@ public: bool read(QIODevice *device); + QString errorString() const; + private: //! [2] void readXBEL(); @@ -70,6 +72,7 @@ private: QTreeWidgetItem *createChildItem(QTreeWidgetItem *item); + QXmlStreamReader xml; QTreeWidget *treeWidget; //! [2] diff --git a/examples/xml/streambookmarks/xbelwriter.cpp b/examples/xml/streambookmarks/xbelwriter.cpp index 3a2862a..58757f5 100644 --- a/examples/xml/streambookmarks/xbelwriter.cpp +++ b/examples/xml/streambookmarks/xbelwriter.cpp @@ -47,23 +47,23 @@ XbelWriter::XbelWriter(QTreeWidget *treeWidget) : treeWidget(treeWidget) { - setAutoFormatting(true); + xml.setAutoFormatting(true); } //! [0] //! [1] bool XbelWriter::writeFile(QIODevice *device) { - setDevice(device); + xml.setDevice(device); - writeStartDocument(); - writeDTD(""); - writeStartElement("xbel"); - writeAttribute("version", "1.0"); + xml.writeStartDocument(); + xml.writeDTD(""); + xml.writeStartElement("xbel"); + xml.writeAttribute("version", "1.0"); for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) writeItem(treeWidget->topLevelItem(i)); - writeEndDocument(); + xml.writeEndDocument(); return true; } //! [1] @@ -74,20 +74,20 @@ void XbelWriter::writeItem(QTreeWidgetItem *item) QString tagName = item->data(0, Qt::UserRole).toString(); if (tagName == "folder") { bool folded = !treeWidget->isItemExpanded(item); - writeStartElement(tagName); - writeAttribute("folded", folded ? "yes" : "no"); - writeTextElement("title", item->text(0)); + xml.writeStartElement(tagName); + xml.writeAttribute("folded", folded ? "yes" : "no"); + xml.writeTextElement("title", item->text(0)); for (int i = 0; i < item->childCount(); ++i) writeItem(item->child(i)); - writeEndElement(); + xml.writeEndElement(); } else if (tagName == "bookmark") { - writeStartElement(tagName); + xml.writeStartElement(tagName); if (!item->text(1).isEmpty()) - writeAttribute("href", item->text(1)); - writeTextElement("title", item->text(0)); - writeEndElement(); + xml.writeAttribute("href", item->text(1)); + xml.writeTextElement("title", item->text(0)); + xml.writeEndElement(); } else if (tagName == "separator") { - writeEmptyElement(tagName); + xml.writeEmptyElement(tagName); } } //! [2] diff --git a/examples/xml/streambookmarks/xbelwriter.h b/examples/xml/streambookmarks/xbelwriter.h index 29a8b04..b74d015 100644 --- a/examples/xml/streambookmarks/xbelwriter.h +++ b/examples/xml/streambookmarks/xbelwriter.h @@ -50,7 +50,7 @@ class QTreeWidgetItem; QT_END_NAMESPACE //! [0] -class XbelWriter : public QXmlStreamWriter +class XbelWriter { public: XbelWriter(QTreeWidget *treeWidget); @@ -58,6 +58,7 @@ public: private: void writeItem(QTreeWidgetItem *item); + QXmlStreamWriter xml; QTreeWidget *treeWidget; }; //! [0] diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index a311b99..4cd8965 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -313,8 +313,8 @@ QXmlStreamEntityResolver *QXmlStreamReader::entityResolver() const error handling described. The \l{QXmlStream Bookmarks Example} illustrates how to use the - recursive descent technique with a subclassed stream reader to read - an XML bookmark file (XBEL). + recursive descent technique to read an XML bookmark file (XBEL) with + a stream reader. \section1 Namespaces @@ -2943,7 +2943,7 @@ QStringRef QXmlStreamReader::documentEncoding() const encodings can be enforced using setCodec(). The \l{QXmlStream Bookmarks Example} illustrates how to use a - subclassed stream writer to write an XML bookmark file (XBEL) that + stream writer to write an XML bookmark file (XBEL) that was previously read in by a QXmlStreamReader. */ -- cgit v0.12 From d0bf6b569eefef47891d851161f610bf34d28bfb Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 19 Aug 2009 16:14:27 +0200 Subject: Document more of the behavior of QTouchEvent This includes docs on the default QWidget::event() behavior, how to use touch with QAbstractScrollArea subclasses, how the propagation and grouping works, as well as some caveats. Reviewed-by: David Boddie --- src/gui/kernel/qevent.cpp | 158 +++++++++++++++++++++++++++++++++------------- 1 file changed, 115 insertions(+), 43 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 7365820..3e1d12d 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3538,38 +3538,108 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar) \since 4.6 \ingroup events - Touch events occur when pressing, releasing, or moving one or more - touch points on a touch device (such as a touch-screen or - track-pad). To receive touch events, widgets have to have the - Qt::WA_AcceptTouchEvents attribute set and graphics items need to have - the \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} - attribute set to true. - - All touch events are of type QEvent::TouchBegin, - QEvent::TouchUpdate, or QEvent::TouchEnd. The touchPoints() - function returns a list of all touch points contained in the event. - Information about each touch point can be retrieved using the - QTouchEvent::TouchPoint class. The Qt::TouchPointState enum - describes the different states that a touch point may have. - - Similar to QMouseEvent, Qt automatically grabs each touch point on - the first press inside a widget; the widget will receive all - updates for the touch point until it is released. Note that it is - possible for a widget to receive events for multiple touch points, - and that multiple widgets may be receiving touch events at the same - time. - - A touch event contains a special accept flag that indicates - whether the receiver wants the event. By default, the event is - accepted. You should call ignore() if the touch event is not handled by - your widget. A QEvent::TouchBegin event is propagated up the parent widget - chain until a widget accepts it with accept(), or an event filter - consumes it. If the QEvent::TouchBegin event is neither accepted nor consumed, - then mouse events are simulated from the state of the first touch - point. - - Reimplement QWidget::event() for widgets and QGraphicsItem::sceneEvent() - for items in a graphics view to receive touch events. + \section1 Enabling Touch Events + + Touch events occur when pressing, releasing, or moving one or more touch points on a touch + device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the + Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the + \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true. + + Note: when using QAbstractScrollArea based widgets, you should enabled the + Qt::WA_AcceptTouchEvents attribute on the scroll area's + \l{QAbstractScrollArea::viewport()}{viewport}. + + \section1 Event Delivery and Propagation + + All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, or QEvent::TouchEnd. + Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for widgets and + QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events. By default, + QWidget::event() translates the first non-primary touch point in a QTouchEvent into a + QMouseEvent. This makes it possible to enable touch events on existing widgets that do not + normally handle QTouchEvent. See below for information on some special considerations needed + when doing this. + + QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event + contains a special accept flag that indicates whether the receiver wants the event. By default, + the event is accepted. You should call ignore() if the touch event is not handled by your + widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget + accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the + QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event + propagation for QGraphicsItems). + + The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that + accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not + filtered by an event filter, then no further touch events are sent until the next + QEvent::TouchBegin. + + The touchPoints() function returns a list of all touch points contained in the event. + Information about each touch point can be retrieved using the QTouchEvent::TouchPoint class. + The Qt::TouchPointState enum describes the different states that a touch point may have. + + Similar to QMouseEvent, Qt automatically grabs each touch point on the first press inside a + widget; the widget will receive all updates for the touch point until it is released. Note that + it is possible for a widget to receive events for multiple touch points, and that multiple + widgets may be receiving touch events at the same time. + + \section1 Touch Point Grouping + + As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the + same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same + widget, which could theoretically happen during propagation if, for example, the user touched 2 + separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event. + + To avoid this, Qt will group new touch points together using the following rules: + + \list + + \i When the first touch point is detected, the destination widget is determined firstly by the + location on screen first and secondly by the propagation rules. + + \i When additional touch points are detected, Qt first looks to see if there are any active + touch points on any ancestor or descendent of the widget under the new touch point. If there + are, the new touch point is grouped with the first, and the new touch point will be sent in a + single QTouchEvent to the widget that handled the first touch point. (The widget under the new + touch point will not receive an event). + + \endlist + + This makes it possible for sibling widgets to handle touch events independently while making + sure that the sequence of QTouchEvents is always correct. + + \section1 Mouse Events and the Primary Touch Point + + QTouchEvent delivery is independent from that of QMouseEvent. On some windowing systems, mouse + events are also sent for the \l{QTouchEvent::TouchPoint::isPrimary()}{primary touch point}. + This means it is possible for your widget to receive both QTouchEvent and QMouseEvent for the + same user interaction point. You can use the QTouchEvent::TouchPoint::isPrimary() function to + identify the primary touch point. + + Note that on some systems, it is possible to receive touch events without a primary touch + point. All this means is that there will be no mouse event generated for the touch points in + the QTouchEvent. + + \section1 Caveats + + \list + + \i As mentioned above, enabling touch events means multiple widgets can be receiving touch + events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents, + this gives you great flexibility in designing multi-touch user interfaces. Be aware of the + implications. For example, is is possible that the user is moving a QSlider with one finger and + pressing a QPushButton with another. The signals are emitted from these widgets will be + interleaved. + + \i Recursion into the event loop using one of the exec() methods (e.g. QDialog::exec() or + QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event + recipients, unexpected recursion may cause problems, including but not limited to lost events + and unexpected infinite recursion. + + \i QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an + \l{QApplication::activePopupWidget()}{active popup widget}. The behavior of QTouchEvents is + undefined when opening a popup or grabbing the mouse while there are multiple active touch + points. + + \endlist \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents, QGraphicsItem::acceptTouchEvents() @@ -3648,6 +3718,11 @@ QTouchEvent::~QTouchEvent() Returns the list of touch points contained in the touch event. */ +/*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const + + Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}. +*/ + /*! \fn void QTouchEvent::setWidget(QWidget *widget) \internal @@ -3669,6 +3744,14 @@ QTouchEvent::~QTouchEvent() Sets the list of touch points for this event. */ +/*! \fn void QTouchEvent::setDeviceType(DeviceType deviceType) + + \internal + + Sets the device type to \a deviceType, which is of type \l {QTouchEvent::DeviceType} + {DeviceType}. +*/ + /*! \class QTouchEvent::TouchPoint \brief The QTouchEvent::TouchPoint class provides information about a touch point in a QTouchEvent. \since 4.6 @@ -4080,15 +4163,4 @@ QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::T return *this; } -/*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const - Returns the touch device Type, which is of type - \l {QTouchEvent::DeviceType} {DeviceType}. - */ - -/*! \fn void QTouchEvent::setDeviceType(DeviceType deviceType) - Sets the device type to \a deviceType, which is of type - \l {QTouchEvent::DeviceType} {DeviceType}. - */ - - QT_END_NAMESPACE -- cgit v0.12 From 555fafe46e26b352e9d8ab5586910591761ab5ad Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Wed, 19 Aug 2009 16:20:45 +0200 Subject: Doc - mentioning that the begin...() functions emit a signal that must be handled by connected views/proxies. Otherwise, the views/proxies may end up in an invalid state. Task: 227718 Reviewed-By: Olivier Goffart --- src/corelib/kernel/qabstractitemmodel.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 8761ec1..17af60d 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -2189,6 +2189,9 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare This appends the two new rows as rows 4 and 5. \endtable + \note This function emits the rowsAboutToBeInserted() signal which + connected views (or proxies) must handle before the data is inserted. + Otherwise, the views may end up in an invalid state. \sa endInsertRows() */ void QAbstractItemModel::beginInsertRows(const QModelIndex &parent, int first, int last) @@ -2239,6 +2242,10 @@ void QAbstractItemModel::endInsertRows() \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 2 \endtable + \note This function emits the rowsAboutToBeRemoved() signal which connected + views (or proxies) must handle before the data is removed. Otherwise, the + views may end up in an invalid state. + \sa endRemoveRows() */ void QAbstractItemModel::beginRemoveRows(const QModelIndex &parent, int first, int last) @@ -2302,6 +2309,10 @@ void QAbstractItemModel::endRemoveRows() This appends the two new columns as columns 6, 7, and 8. \endtable + \note This function emits the columnsAboutToBeInserted() signal which + connected views (or proxies) must handle before the data is inserted. + Otherwise, the views may end up in an invalid state. + \sa endInsertColumns() */ void QAbstractItemModel::beginInsertColumns(const QModelIndex &parent, int first, int last) @@ -2353,6 +2364,10 @@ void QAbstractItemModel::endInsertColumns() \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 5 \endtable + \note This function emits the columnsAboutToBeRemoved() signal which + connected views (or proxies) must handle before the data is removed. + Otherwise, the views may end up in an invalid state. + \sa endRemoveColumns() */ void QAbstractItemModel::beginRemoveColumns(const QModelIndex &parent, int first, int last) -- cgit v0.12