From fb4a884eb76a67919112f2a389283b1bd6d4848e Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 18 Aug 2009 09:11:12 +0200 Subject: Avoid divide by zero on buggy Xlib/Xserver implementations Some X servers seem to report zero physical size, so our DPI calculations would crash with divide-by-zero. Avoid this and just use 72 DPI instead. Task-number: 258319 --- src/gui/kernel/qapplication_x11.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index db349f0..d942519 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -1851,10 +1851,20 @@ void qt_init(QApplicationPrivate *priv, int, QX11InfoData *screen = X11->screens + s; screen->ref = 1; // ensures it doesn't get deleted screen->screen = s; - screen->dpiX = (DisplayWidth(X11->display, s) * 254 + DisplayWidthMM(X11->display, s)*5) - / (DisplayWidthMM(X11->display, s)*10); - screen->dpiY = (DisplayHeight(X11->display, s) * 254 + DisplayHeightMM(X11->display, s)*5) - / (DisplayHeightMM(X11->display, s)*10); + + int widthMM = DisplayWidthMM(X11->display, s); + if (widthMM != 0) { + screen->dpiX = (DisplayWidth(X11->display, s) * 254 + widthMM * 5) / (widthMM * 10); + } else { + screen->dpiX = 72; + } + + int heightMM = DisplayHeightMM(X11->display, s); + if (heightMM != 0) { + screen->dpiY = (DisplayHeight(X11->display, s) * 254 + heightMM * 5) / (heightMM * 10); + } else { + screen->dpiY = 72; + } X11->argbVisuals[s] = 0; X11->argbColormaps[s] = 0; -- cgit v0.12 From 0e29b6085233bbd14471c7df466575750841f4d7 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 10:01:01 +0200 Subject: Fixed a possible crash in QTextCursor --- src/gui/text/qtextcursor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 88ab9d0..5a938e3 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -84,7 +84,8 @@ QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs) QTextCursorPrivate::~QTextCursorPrivate() { - priv->removeCursor(this); + if (priv) + priv->removeCursor(this); } QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op) -- cgit v0.12 From 9b7a6b231014135d7df0f3675d121c2d76d89e76 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 18 Aug 2009 10:07:11 +0200 Subject: As of Qt 4.6, the minimum OS X version is 10.4. --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 92fe649..40b65fd 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -297,7 +297,7 @@ namespace QT_NAMESPACE {} # ifdef MAC_OS_X_VERSION_MIN_REQUIRED # undef MAC_OS_X_VERSION_MIN_REQUIRED # endif -# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_3 +# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 # include # if !defined(MAC_OS_X_VERSION_10_3) # define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1 -- cgit v0.12 From b120ff4f1a479c35b3e5bbcbc3c72cc18ee4879c Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 18 Aug 2009 10:31:31 +0200 Subject: tst_QTableView::task259308_scrollVerticalHeaderSwappedSections fails. The QTableView scrolled down after the sections swap. Setting the current index to the topmost visual element fixes the issue. Reviewed-by: Thierry --- tests/auto/qtableview/tst_qtableview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 2f41d77..e650dc8 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -3270,6 +3270,7 @@ void tst_QTableView::task259308_scrollVerticalHeaderSwappedSections() tv.setModel(&model); tv.show(); tv.verticalHeader()->swapSections(0, model.rowCount() - 1); + tv.setCurrentIndex(model.index(model.rowCount() - 1, 0)); QTest::qWait(60); QTest::keyClick(&tv, Qt::Key_PageUp); // PageUp won't scroll when at top -- cgit v0.12 From 7b58efd28ec66725acf0e42d871859f1a046439a Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 18 Aug 2009 08:44:16 +0200 Subject: Speed up midpoint lines starting far outside the device bounds. Reviewed-By: Samuel --- src/gui/painting/qpaintengine_raster.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 8b83f02..547818c 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -5198,6 +5198,13 @@ static void drawLine_midpoint_i(int x1, int y1, int x2, int y2, ProcessSpans spa dy = -dy; } + int x_lower_limit = - 128; + if (x1 < x_lower_limit) { + int cy = dy * (x_lower_limit - x1) / dx + y1; + drawLine_midpoint_i(x_lower_limit, cy, x2, y2, span_func, data, style, devRect); + return; + } + if (style == LineDrawNormal) --x2; @@ -5335,6 +5342,13 @@ static void drawLine_midpoint_i(int x1, int y1, int x2, int y2, ProcessSpans spa dx = -dx; } + int y_lower_limit = - 128; + if (y1 < y_lower_limit) { + int cx = dx * (y_lower_limit - y1) / dy + x1; + drawLine_midpoint_i(cx, y_lower_limit, x2, y2, span_func, data, style, devRect); + return; + } + if (style == LineDrawNormal) --y2; -- cgit v0.12 From a160bbbed21cea0487410013eea95937be65b3d4 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 17 Aug 2009 09:56:21 +0200 Subject: Added support for gestures on Mac OS X Carbon --- src/gui/kernel/qcocoaview_mac.mm | 10 ++--- src/gui/kernel/qeventdispatcher_mac.mm | 2 +- src/gui/kernel/qwidget_mac.mm | 71 +++++++++++++++++++++++++++++++++- 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 45b0ada..7ac0d89 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -872,7 +872,7 @@ extern "C" { NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); qNGEvent.percentage = [event magnification]; - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } - (void)rotateWithEvent:(NSEvent *)event; @@ -885,7 +885,7 @@ extern "C" { NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); qNGEvent.percentage = [event rotation]; - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } - (void)swipeWithEvent:(NSEvent *)event; @@ -898,7 +898,7 @@ extern "C" { NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); qNGEvent.direction = QSize(-[event deltaX], -[event deltaY]); - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } - (void)beginGestureWithEvent:(NSEvent *)event; @@ -910,7 +910,7 @@ extern "C" { qNGEvent.gestureType = QNativeGestureEvent::GestureBegin; NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } - (void)endGestureWithEvent:(NSEvent *)event; @@ -922,7 +922,7 @@ extern "C" { qNGEvent.gestureType = QNativeGestureEvent::GestureEnd; NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; qNGEvent.position = flipPoint(p).toPoint(); - qApp->sendEvent(qwidget, &qNGEvent); + qt_sendSpontaneousEvent(qwidget, &qNGEvent); } #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index efe6375..113362a 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -500,7 +500,7 @@ static bool IsMouseOrKeyEvent( NSEvent* event ) static inline void qt_mac_waitForMoreEvents() { #ifndef QT_MAC_USE_COCOA - while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, true) == kCFRunLoopRunTimedOut); + while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, true) == kCFRunLoopRunTimedOut) ; #else // If no event exist in the cocoa event que, wait // (and free up cpu time) until at least one event occur. diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5bf140c..b13c9eb 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -107,6 +107,7 @@ #include #include "qwidget_p.h" +#include "qevent_p.h" #include "qdnd_p.h" #include @@ -729,7 +730,12 @@ static EventTypeSpec window_events[] = { { kEventClassWindow, kEventWindowGetRegion }, { kEventClassWindow, kEventWindowGetClickModality }, { kEventClassWindow, kEventWindowTransitionCompleted }, - { kEventClassMouse, kEventMouseDown } + { kEventClassMouse, kEventMouseDown }, + { kEventClassGesture, kEventGestureStarted }, + { kEventClassGesture, kEventGestureEnded }, + { kEventClassGesture, kEventGestureMagnify }, + { kEventClassGesture, kEventGestureSwipe }, + { kEventClassGesture, kEventGestureRotate } }; static EventHandlerUPP mac_win_eventUPP = 0; static void cleanup_win_eventUPP() @@ -1013,6 +1019,69 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event, return SendEventToApplication(event); handled_event = false; break; } + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + case kEventClassGesture: { + // First, find the widget that was under + // the mouse when the gesture happened: + HIPoint screenLocation; + if (GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, 0, + sizeof(screenLocation), 0, &screenLocation) != noErr) { + handled_event = false; + break; + } + QWidget *widget = QApplication::widgetAt(screenLocation.x, screenLocation.y); + if (!widget) { + handled_event = false; + break; + } + + QNativeGestureEvent qNGEvent; + qNGEvent.position = QPoint(screenLocation.x, screenLocation.y); + + switch (ekind) { + case kEventGestureStarted: + qNGEvent.gestureType = QNativeGestureEvent::GestureBegin; + break; + case kEventGestureEnded: + qNGEvent.gestureType = QNativeGestureEvent::GestureEnd; + break; + case kEventGestureRotate: { + CGFloat amount; + if (GetEventParameter(event, kEventParamRotationAmount, typeCGFloat, 0, + sizeof(amount), 0, &amount) != noErr) { + handled_event = false; + break; + } + qNGEvent.gestureType = QNativeGestureEvent::Zoom; + qNGEvent.percentage = float(amount); + break; } + case kEventGestureSwipe: { + HIPoint swipeDirection; + if (GetEventParameter(event, kEventParamSwipeDirection, typeHIPoint, 0, + sizeof(swipeDirection), 0, &swipeDirection) != noErr) { + handled_event = false; + break; + } + qNGEvent.gestureType = QNativeGestureEvent::Swipe; + qNGEvent.direction = QSize(-swipeDirection.x, -swipeDirection.y); + break; } + case kEventGestureMagnify: { + CGFloat amount; + if (GetEventParameter(event, kEventParamMagnificationAmount, typeCGFloat, 0, + sizeof(amount), 0, &amount) != noErr) { + handled_event = false; + break; + } + qNGEvent.gestureType = QNativeGestureEvent::Zoom; + qNGEvent.percentage = float(amount); + break; } + } + + QApplication::sendSpontaneousEvent(widget, &qNGEvent); + break; } +#endif // gestures + default: handled_event = false; } -- cgit v0.12 From 0f8a326341bd3aab1675acb6b15e011247f7c6f8 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 18 Aug 2009 11:19:15 +0200 Subject: Fix build failure on Mac OS 10.5 Gestures only awailable on 10.6 --- src/gui/kernel/qwidget_mac.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index b13c9eb..999faeb 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -730,12 +730,14 @@ static EventTypeSpec window_events[] = { { kEventClassWindow, kEventWindowGetRegion }, { kEventClassWindow, kEventWindowGetClickModality }, { kEventClassWindow, kEventWindowTransitionCompleted }, - { kEventClassMouse, kEventMouseDown }, +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 { kEventClassGesture, kEventGestureStarted }, { kEventClassGesture, kEventGestureEnded }, { kEventClassGesture, kEventGestureMagnify }, { kEventClassGesture, kEventGestureSwipe }, - { kEventClassGesture, kEventGestureRotate } + { kEventClassGesture, kEventGestureRotate }, +#endif + { kEventClassMouse, kEventMouseDown } }; static EventHandlerUPP mac_win_eventUPP = 0; static void cleanup_win_eventUPP() -- cgit v0.12 From 610af2bf4d6d57f86ca71c9764b5b03b01aafad8 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 11:55:07 +0200 Subject: QHeaderView: assertion when modifying the root iem of a treewidget dataChanged is emitted with invalid model index. We needed to handle that. Reviewed-by: ogoffart --- src/gui/itemviews/qheaderview.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index f7b5b6f..4ab81f5 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1195,7 +1195,8 @@ QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const { Q_D(const QHeaderView); int visual = visualIndex(logicalIndex); - Q_ASSERT(visual != -1); + if (visual == -1) + return Fixed; //the default value return d->headerSectionResizeMode(visual); } -- cgit v0.12 From 7a64a3f67d53a99e6e2200f6481c98013004b4e4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 11:56:46 +0200 Subject: QItemSelectionModel: hasSelection can return true when no selection we needed to finalize the selection when rows are removed Reviewed-by: ogoffart --- src/gui/itemviews/qitemselectionmodel.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index 98810a0..8414460 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -573,6 +573,7 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare int start, int end) { Q_Q(QItemSelectionModel); + finalize(); // update current index if (currentIndex.isValid() && parent == currentIndex.parent() @@ -591,8 +592,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare } QItemSelection deselected; - QItemSelection::iterator it = currentSelection.begin(); - while (it != currentSelection.end()) { + QItemSelection::iterator it = ranges.begin(); + while (it != ranges.end()) { if (it->topLeft().parent() != parent) { // Check parents until reaching root or contained in range QModelIndex itParent = it->topLeft().parent(); while (itParent.isValid() && itParent.parent() != parent) @@ -600,24 +601,22 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare if (parent.isValid() && start <= itParent.row() && itParent.row() <= end) { deselected.append(*it); - it = currentSelection.erase(it); + it = ranges.erase(it); } else { ++it; } } else if (start <= it->bottom() && it->bottom() <= end // Full inclusion && start <= it->top() && it->top() <= end) { deselected.append(*it); - it = currentSelection.erase(it); + it = ranges.erase(it); } else if (start <= it->top() && it->top() <= end) { // Top intersection deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->left(), it->parent()))); - it = currentSelection.insert(it, QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), - it->bottomRight())); - it = currentSelection.erase(++it); + *it = QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), it->bottomRight()); + ++it; } else if (start <= it->bottom() && it->bottom() <= end) { // Bottom intersection deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight())); - it = currentSelection.insert(it, QItemSelectionRange(it->topLeft(), - model->index(start - 1, it->right(), it->parent()))); - it = currentSelection.erase(++it); + *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent())); + ++it; } else { if (it->top() < start && end < it->bottom()) // Middle intersection (do nothing) deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), @@ -626,7 +625,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare } } - emit q->selectionChanged(QItemSelection(), deselected); + if (!deselected.isEmpty()) + emit q->selectionChanged(QItemSelection(), deselected); } /*! -- cgit v0.12 From 089689914fd7b223c10f5408a6db255ce540e718 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 12:36:40 +0200 Subject: Fix autotest: removed useless debug traces --- tests/auto/qmenu/tst_qmenu.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index b06b247..90b9a2a 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -710,7 +710,6 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition() uint i = 2; while (main.columnCount() < 2) { main.addAction(QString("Item %1").arg(i)); - qDebug() << "adding action" << i; ++i; Q_ASSERT(i<1000); } -- cgit v0.12 From 7d2fb4f6dfbfe843ec2d101c06b891230a49d20a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 12:42:23 +0200 Subject: Autotest: Be very pedant about the tests. There's at least one compiler where it breaks, so let's find out where. --- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 37 +++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index ab75c91..c9b2325 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -761,17 +761,46 @@ void tst_QSharedPointer::differentPointers() { DiffPtrDerivedData *aData = new DiffPtrDerivedData; Data *aBase = aData; - Q_ASSERT(aData == aBase); - Q_ASSERT(*reinterpret_cast(&aData) != *reinterpret_cast(&aBase)); + + // ensure that this compiler isn't broken + if (*reinterpret_cast(&aData) == *reinterpret_cast(&aBase)) + qFatal("Something went very wrong -- we couldn't create two different pointers to the same object"); + if (aData != aBase) + QSKIP("Broken compiler", SkipAll); + if (aBase != aData) + QSKIP("Broken compiler", SkipAll); QSharedPointer ptr = QSharedPointer(aData); QSharedPointer baseptr = qSharedPointerCast(ptr); - QVERIFY(ptr == baseptr); + qDebug("naked: orig: %p; base: %p (%s) -- QSharedPointer: orig: %p; base %p (%s) -- result: %s", + aData, aBase, aData == aBase ? "equal" : "not equal", + ptr.data(), baseptr.data(), ptr.data() == baseptr.data() ? "equal" : "not equal", + baseptr.data() == aData ? "equal" : "not equal"); + QVERIFY(ptr.data() == baseptr.data()); + QVERIFY(baseptr.data() == ptr.data()); + QVERIFY(ptr == baseptr); + QVERIFY(baseptr == ptr); + + QVERIFY(ptr.data() == aBase); + QVERIFY(aBase == ptr.data()); + QVERIFY(ptr.data() == aData); + QVERIFY(aData == ptr.data()); + QVERIFY(ptr == aBase); + QVERIFY(aBase == ptr); QVERIFY(ptr == aData); - QVERIFY(baseptr == aData); + QVERIFY(aData == ptr); + + QVERIFY(baseptr.data() == aBase); + QVERIFY(aBase == baseptr.data()); QVERIFY(baseptr == aBase); + QVERIFY(aBase == baseptr); + + QVERIFY(baseptr.data() == aData); + QVERIFY(aData == baseptr.data()); + QVERIFY(baseptr == aData); + QVERIFY(aData == baseptr); } check(); -- cgit v0.12 From e1c9136214532cc41074449e3a894fdea020a41e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 13:20:35 +0200 Subject: Fix autotest: on windows, timers are not accurate enough --- tests/auto/qtoolbutton/tst_qtoolbutton.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/qtoolbutton/tst_qtoolbutton.cpp index 6376c5d..aca9a20 100644 --- a/tests/auto/qtoolbutton/tst_qtoolbutton.cpp +++ b/tests/auto/qtoolbutton/tst_qtoolbutton.cpp @@ -222,8 +222,10 @@ void tst_QToolButton::task176137_autoRepeatOfAction() tb.setAutoRepeat (true); QSignalSpy repeatSpy(&action,SIGNAL(triggered())); // new spy QTest::mousePress ( &tb, Qt::LeftButton); - QTest::mouseRelease ( &tb, Qt::LeftButton, 0, QPoint (), 2000); - QCOMPARE (repeatSpy.count(), (2000 - tb.autoRepeatDelay()) / tb.autoRepeatInterval() + 1); + QTest::mouseRelease ( &tb, Qt::LeftButton, 0, QPoint (), 3000); + qreal expected = (3000 - tb.autoRepeatDelay()) / tb.autoRepeatInterval() + 1; + //we check that the difference is less than 10% (on some systems timers are not super accurate) + QVERIFY ( qAbs( (expected - repeatSpy.count()) / expected) < 0.1); } -- cgit v0.12 From 5f2f444a9d8d80d778053c2af66534d582145055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 18 Aug 2009 13:35:30 +0200 Subject: Fixed bug when rendering long lines of text without XRender. XRectangle coordinates need to be clipped to the short integer range. Task-number: 250137 Reviewed-by: Trond --- src/gui/painting/qpaintengine_x11.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 6816aac..a4d34b5 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -2459,15 +2459,23 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti) XRectangle rects[rectcount]; int num_rects = 0; + QPoint delta(qRound(d->matrix.dx()), qRound(d->matrix.dy())); + QRect clip(d->polygonClipper.boundingRect()); for (int i=0; i < path.elementCount(); i+=5) { int x = qRound(path.elementAt(i).x); int y = qRound(path.elementAt(i).y); int w = qRound(path.elementAt(i+1).x) - x; int h = qRound(path.elementAt(i+2).y) - y; - rects[num_rects].x = x + qRound(d->matrix.dx()); - rects[num_rects].y = y + qRound(d->matrix.dy()); - rects[num_rects].width = w; - rects[num_rects].height = h; + + QRect rect = QRect(x + delta.x(), y + delta.y(), w, h); + rect = rect.intersected(clip); + if (rect.isEmpty()) + continue; + + rects[num_rects].x = short(rect.x()); + rects[num_rects].y = short(rect.y()); + rects[num_rects].width = ushort(rect.width()); + rects[num_rects].height = ushort(rect.height()); ++num_rects; if (num_rects == rectcount) { XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects); -- cgit v0.12 From a250ca3a3c0b777f274388b9e57a985d7438f8ff Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 14:54:15 +0200 Subject: Make TestLib compatible with mingw when gui is not used The problem is that headers in QTestLib define functions for mouse and key events. Those are causing link errors on all autotests that do "QT -= gui" with mingw (only debug seems to be affected). Reviewed-by: jasplin --- src/testlib/qtestevent.h | 5 +++++ src/testlib/qtestkeyboard.h | 2 +- src/testlib/qtestmouse.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/testlib/qtestevent.h b/src/testlib/qtestevent.h index a8376ee..dfbba33 100644 --- a/src/testlib/qtestevent.h +++ b/src/testlib/qtestevent.h @@ -71,6 +71,7 @@ public: virtual ~QTestEvent() {} }; +#ifdef QT_GUI_LIB class QTestKeyEvent: public QTestEvent { public: @@ -135,6 +136,8 @@ private: QPoint _pos; int _delay; }; +#endif //QT_GUI_LIB + class QTestDelayEvent: public QTestEvent { @@ -159,6 +162,7 @@ public: inline void clear() { qDeleteAll(*this); QList::clear(); } +#ifdef QT_GUI_LIB inline void addKeyClick(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) { addKeyEvent(QTest::Click, qtKey, modifiers, msecs); } inline void addKeyPress(Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) @@ -194,6 +198,7 @@ public: { append(new QTestMouseEvent(QTest::MouseDClick, button, stateKey, pos, delay)); } inline void addMouseMove(QPoint pos = QPoint(), int delay=-1) { append(new QTestMouseEvent(QTest::MouseMove, Qt::NoButton, 0, pos, delay)); } +#endif //QT_GUI_LIB inline void addDelay(int msecs) { append(new QTestDelayEvent(msecs)); } diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h index 2e475b2..af81075 100644 --- a/src/testlib/qtestkeyboard.h +++ b/src/testlib/qtestkeyboard.h @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#ifndef QTESTKEYBOARD_H +#if !defined(QTESTKEYBOARD_H) && defined(QT_GUI_LIB) #define QTESTKEYBOARD_H #if 0 diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 2825c58..7ea927c 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#ifndef QTESTMOUSE_H +#if !defined(QTESTMOUSE_H) && defined(QT_GUI_LIB) #define QTESTMOUSE_H #if 0 -- cgit v0.12 From aaf10f42467aba28717b587adb85f31b4ada08ab Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 14:43:14 +0200 Subject: Animations: update the documentation Removed the reference to the QAnimationState that doesn't exist anymore --- src/corelib/animation/qanimationgroup.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp index ab47b5a..78777f1 100644 --- a/src/corelib/animation/qanimationgroup.cpp +++ b/src/corelib/animation/qanimationgroup.cpp @@ -79,13 +79,6 @@ QAnimationGroup takes ownership of the animations it manages, and ensures that they are deleted when the animation group is deleted. - You can also use a \l{The State Machine Framework}{state machine} - to create complex animations. The framework provides a special - state, QAnimationState, that plays an animation upon entry and - transitions to a new state when the animation has finished - playing. This technique can also be combined with using animation - groups. - \sa QAbstractAnimation, QVariantAnimation, {The Animation Framework} */ -- cgit v0.12 From 413efbbc942262a636c521b898e0086258daa61a Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 18 Aug 2009 15:39:24 +0200 Subject: Compile fix with namespaces --- src/gui/painting/qpaintdevice.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index 6477952..6a2a4c4 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -64,3 +64,5 @@ int QPaintDevice::metric(PaintDeviceMetric) const qWarning("QPaintDevice::metrics: Device has no metric information"); return 0; } + +QT_END_NAMESPACE -- cgit v0.12 From d59b92565e3632e2b36ea7de881bd08418760bbc Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 15:41:34 +0200 Subject: add QGraphicsObject Q_INTERFACES macro --- src/gui/graphicsview/qgraphicsitem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index b5e6ed5..52b862e 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -516,6 +516,7 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint) + Q_INTERFACES(QGraphicsItem) public: QGraphicsObject(QGraphicsItem *parent = 0); -- cgit v0.12 From 37b375092b6db1c3302f93676b6329742f5c9fef Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 15:53:21 +0200 Subject: mingw: make it possible to build without rtti support --- mkspecs/features/win32/rtti_off.prf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/features/win32/rtti_off.prf b/mkspecs/features/win32/rtti_off.prf index 8f175de..b520bfa 100644 --- a/mkspecs/features/win32/rtti_off.prf +++ b/mkspecs/features/win32/rtti_off.prf @@ -1,3 +1,4 @@ CONFIG -= rtti QMAKE_CFLAGS += $$QMAKE_CFLAGS_RTTI_OFF QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_RTTI_OFF +DEFINES += QT_NO_DYNAMIC_CAST \ No newline at end of file -- cgit v0.12 From 68b7514840fe29f84af8d418538084ed337bd171 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 18 Aug 2009 07:05:08 -0700 Subject: Make sure to update pos QDFBCursor::move We don't need to chain to the base class since the QDirectFBScreenCursor always is rendered by hardware but we should update the pos variable in case people ask where the cursor is. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 774162c..2541677 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -578,6 +578,7 @@ QDirectFBScreenCursor::QDirectFBScreenCursor() void QDirectFBScreenCursor::move(int x, int y) { + pos = QPoint(x, y); layer->WarpCursor(layer, x, y); } -- cgit v0.12 From e1869593a4c2a074cc916c770e258d6f2349db01 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 18 Aug 2009 16:25:31 +0200 Subject: Doc: Added missing images. Reviewed-by: Trust Me --- doc/src/diagrams/dbus-examples.png | Bin 0 -> 19642 bytes doc/src/images/dbus-examples.png | Bin 0 -> 6181 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 doc/src/diagrams/dbus-examples.png create mode 100644 doc/src/images/dbus-examples.png diff --git a/doc/src/diagrams/dbus-examples.png b/doc/src/diagrams/dbus-examples.png new file mode 100644 index 0000000..816a9ab Binary files /dev/null and b/doc/src/diagrams/dbus-examples.png differ diff --git a/doc/src/images/dbus-examples.png b/doc/src/images/dbus-examples.png new file mode 100644 index 0000000..6768935 Binary files /dev/null and b/doc/src/images/dbus-examples.png differ -- cgit v0.12 From 89cc6c1b49e3e33fc7787f1dd9cfaadb43ad4bac Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 18 Aug 2009 15:46:00 +0200 Subject: Fixed QRasterPaintEngine::drawImage() for 1x1 source rectangles. QRasterPaintEngine::drawImage() used an optimized code path when the source rectangle was 1x1. It would sample the source image at the source rectangle's top-left corner and use the sampled color to fill the entire target rectangle. There were two bugs, however: 1) The sampled color was assumed to be non-premultiplied, so you could end up with premultiplying the color twice. This was fixed by avoiding premultiplying a second time if the source image has a premultiplied format. 2) Since the source rectangle is a QRectF, it could easily cross pixel boundaries even if it's 1x1. In this case, it is not correct to fill the target rectangle with a single color. This was fixed by checking if the entire source rectangle is contained in a single pixel before taking the optimized code path. Task-number: 256950 Reviewed-by: Trond --- src/gui/painting/qpaintengine_raster.cpp | 36 ++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 547818c..63c4e32 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2544,12 +2544,44 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); const bool aa = s->flags.antialiased || s->flags.bilinear; - if (!aa && sr.size() == QSize(1, 1)) { + int sr_l = qFloor(sr.left()); + int sr_r = qCeil(sr.right()) - 1; + int sr_t = qFloor(sr.top()); + int sr_b = qCeil(sr.bottom()) - 1; + + if (!aa && sr_l == sr_r && sr_t == sr_b) { // as fillRect will apply the aliased coordinate delta we need to // subtract it here as we don't use it for image drawing QTransform old = s->matrix; s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); - fillRect(r, QColor::fromRgba(img.pixel(sr.x(), sr.y()))); + + // Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied. + QRgb color = img.pixel(sr_l, sr_t); + switch (img.format()) { + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_ARGB6666_Premultiplied: + case QImage::Format_ARGB8555_Premultiplied: + case QImage::Format_ARGB4444_Premultiplied: + // Combine premultiplied color with the opacity set on the painter. + d->solid_color_filler.solid.color = + ((((color & 0x00ff00ff) * s->intOpacity) >> 8) & 0x00ff00ff) + | ((((color & 0xff00ff00) >> 8) * s->intOpacity) & 0xff00ff00); + break; + default: + d->solid_color_filler.solid.color = PREMUL(ARGB_COMBINE_ALPHA(color, s->intOpacity)); + break; + } + + if ((d->solid_color_filler.solid.color & 0xff000000) == 0 + && s->composition_mode == QPainter::CompositionMode_SourceOver) { + return; + } + + d->solid_color_filler.clip = d->clip(); + d->solid_color_filler.adjustSpanMethods(); + fillRect(r, &d->solid_color_filler); + s->matrix = old; return; } -- cgit v0.12 From c38e1a53cee2178f9270b515826bf907654b1964 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 14:28:26 +0200 Subject: Add support for LIBS_PRIVATE to the VCProject generator too. Reviewed-by: Marius Storm-Olsen --- qmake/generators/win32/msvc_vcproj.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 2b0ce28..7c4c70f 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -623,7 +623,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) } // Add all unknown libs to the deps - QStringList where("QMAKE_LIBS"); + QStringList where = QStringList() << "QMAKE_LIBS" << "QMAKE_LIBS_PRIVATE"; if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; for(QStringList::iterator wit = where.begin(); @@ -1556,6 +1556,7 @@ void VcprojGenerator::initOld() } project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); + project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); // Get filename w/o extension ----------------------------------- QString msvcproj_project = ""; @@ -1599,6 +1600,7 @@ void VcprojGenerator::initOld() // $$QMAKE.. -> $$MSVCPROJ.. ------------------------------------- project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS"); + project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS_PRIVATE"); project->values("MSVCPROJ_LFLAGS") += project->values("QMAKE_LFLAGS"); if(!project->values("QMAKE_LIBDIR").isEmpty()) { QStringList strl = project->values("QMAKE_LIBDIR"); -- cgit v0.12 From 3f83ef0a8abc5d1365c67337357564a8d478b1c1 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 18 Aug 2009 17:27:02 +0200 Subject: Fixed a crash when setting twice the same viewmode on a QListView autotest will detect the problem --- src/gui/itemviews/qlistview.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index ea38f5f..e9e365f 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -458,6 +458,8 @@ QSize QListView::gridSize() const void QListView::setViewMode(ViewMode mode) { Q_D(QListView); + if (d->viewMode == mode) + return; d->viewMode = mode; if (mode == ListMode) { @@ -1963,7 +1965,7 @@ QListViewPrivate::QListViewPrivate() movement(QListView::Static), resizeMode(QListView::Fixed), layoutMode(QListView::SinglePass), - viewMode(QListView::ListMode), + viewMode(QListView::IconMode), //this will ensure the first initialization to ListView modeProperties(0), column(0), uniformItemSizes(false), -- cgit v0.12 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 c2dd348e4145ae53d25eb6595a03d5140e12e10e Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 19 Aug 2009 09:38:37 +0300 Subject: Trivial whitespace removal from src/xml/sax/qxml.cpp. Reviewed-by: TrustMe --- src/xml/sax/qxml.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index d7ac5c5..8d331b1 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -2767,7 +2767,7 @@ QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate() void QXmlSimpleReaderPrivate::initIncrementalParsing() { - if( parseStack ) + if(parseStack) parseStack->clear(); else parseStack = new QStack; -- cgit v0.12 From f0a8feed9e9b4de10df76faa350201edaef98f1d Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Wed, 19 Aug 2009 08:33:56 +0200 Subject: Removing local function (*accept*, *connect*, *bind* ...) and replacing them with the "safe" subtitutes. --- src/network/socket/qnativesocketengine_unix.cpp | 170 +++--------------------- 1 file changed, 20 insertions(+), 150 deletions(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index efcaefd..8a826cc 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -59,10 +59,6 @@ #include #endif -#ifdef Q_OS_SYMBIAN -#include -#endif - #if defined QNATIVESOCKETENGINE_DEBUG #include #include @@ -77,132 +73,6 @@ QT_BEGIN_NAMESPACE -static inline int qt_socket_connect(int s, const struct sockaddr * addrptr, socklen_t namelen) -{ - return ::connect(s, addrptr, namelen); -} -#if defined(connect) -# undef connect -#endif - -static inline int qt_socket_bind(int s, const struct sockaddr * addrptr, socklen_t namelen) -{ - return ::bind(s, addrptr, namelen); -} -#if defined(bind) -# undef bind -#endif - -static inline int qt_socket_write(int socket, const char *data, qint64 len) -{ - return ::write(socket, data, len); -} -#if defined(write) -# undef write -#endif - -static inline int qt_socket_read(int socket, char *data, qint64 len) -{ - return ::read(socket, data, len); -} -#if defined(read) -# undef read -#endif - -static inline int qt_socket_recv(int socket, void *data, size_t length, int flags) -{ - return ::recv(socket, data, length, flags); -} -#if defined(recv) -# undef recv -#endif - -static inline int qt_socket_recvfrom(int socket, void *data, size_t length, - int flags, struct sockaddr *address, - socklen_t *address_length) -{ - return ::recvfrom(socket, data, length, flags, address, address_length); -} -#if defined(recvfrom) -# undef recvfrom -#endif - -static inline int qt_socket_sendto(int socket, const void *data, size_t length, - int flags, const struct sockaddr *dest_addr, - socklen_t dest_length) -{ - return ::sendto(socket, data, length, flags, dest_addr, dest_length); -} -#if defined(sendto) -# undef sendto -#endif -static inline int qt_socket_close(int socket) -{ - return ::close(socket); -} -#if defined(close) -# undef close -#endif - -static inline int qt_socket_fcntl(int socket, int command, int option) -{ - return ::fcntl(socket, command, option); -} -#if defined(fcntl) -# undef fcntl -#endif - -static inline int qt_socket_ioctl(int socket, int command, char *option) -{ - return ::ioctl(socket, command, option); -} -#if defined(ioctl) -# undef ioctl -#endif - -static inline int qt_socket_getsockname(int socket, struct sockaddr *address, socklen_t *address_len) -{ - return ::getsockname(socket, address, address_len); -} -#if defined(getsockname) -# undef getsockname -#endif - -static inline int qt_socket_getpeername(int socket, struct sockaddr *address, socklen_t *address_len) -{ - return ::getpeername(socket, address, address_len); -} -#if defined(getpeername) -# undef getpeername -#endif - -static inline int qt_socket_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) -{ - return ::select(nfds, readfds, writefds, exceptfds, timeout); -} - -#if defined(select) -# undef select -#endif - -static inline int qt_socket_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlen) -{ - return ::getsockopt(socket, level, optname, optval, optlen); -} - -#if defined(getsockopt) -# undef getsockopt -#endif - -static inline int qt_socket_setsockopt(int socket, int level, int optname, void *optval, socklen_t optlen) -{ - return ::setsockopt(socket, level, optname, optval, optlen); -} - -#if defined(setsockopt) -# undef setsockopt -#endif - #if defined QNATIVESOCKETENGINE_DEBUG /* @@ -329,7 +199,7 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc } // Ensure that the socket is closed on exec*(). - qt_socket_fcntl(socket, F_SETFD, FD_CLOEXEC); + ::fcntl(socket, F_SETFD, FD_CLOEXEC); socketDescriptor = socket; return true; @@ -377,7 +247,7 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co int v = -1; QT_SOCKOPTLEN_T len = sizeof(v); - if (qt_socket_getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1) + if (::getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1) return v; return -1; @@ -409,14 +279,14 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt case QNativeSocketEngine::NonBlockingSocketOption: { // Make the socket nonblocking. #if !defined(Q_OS_VXWORKS) - int flags = qt_socket_fcntl(socketDescriptor, F_GETFL, 0); + int flags = ::fcntl(socketDescriptor, F_GETFL, 0); if (flags == -1) { #ifdef QNATIVESOCKETENGINE_DEBUG perror("QNativeSocketEnginePrivate::setOption(): fcntl(F_GETFL) failed"); #endif return false; } - if (qt_socket_fcntl(socketDescriptor, F_SETFL, flags | O_NONBLOCK) == -1) { + if (::fcntl(socketDescriptor, F_SETFL, flags | O_NONBLOCK) == -1) { #ifdef QNATIVESOCKETENGINE_DEBUG perror("QNativeSocketEnginePrivate::setOption(): fcntl(F_SETFL) failed"); #endif @@ -456,7 +326,7 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt break; } - return qt_socket_setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0; + return ::setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0; } bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16 port) @@ -503,7 +373,7 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16 // unreachable } - int connectResult = qt_socket_connect(socketDescriptor, sockAddrPtr, sockAddrSize); + int connectResult = qt_safe_connect(socketDescriptor, sockAddrPtr, sockAddrSize); if (connectResult == -1) { switch (errno) { @@ -607,7 +477,7 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16 // unreachable } - int bindResult = qt_socket_bind(socketDescriptor, sockAddrPtr, sockAddrSize); + int bindResult = QT_SOCKET_BIND(socketDescriptor, sockAddrPtr, sockAddrSize); if (bindResult < 0) { switch(errno) { @@ -677,7 +547,7 @@ int QNativeSocketEnginePrivate::nativeAccept() //check if we have vaild descriptor at all if(acceptedDescriptor > 0) { // Ensure that the socket is closed on exec*() - qt_socket_fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC); + ::fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC); } else { qWarning("QNativeSocketEnginePrivate::nativeAccept() - acceptedDescriptor <= 0"); } @@ -711,7 +581,7 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const ssize_t readBytes; do { char c; - readBytes = qt_socket_recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize); + readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize); } while (readBytes == -1 && errno == EINTR); // If there's no error, or if our buffer was too small, there must be a @@ -729,7 +599,7 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const { size_t nbytes = 0; - qt_socket_ioctl(socketDescriptor, E32IONREAD, (char *) &nbytes); + ::ioctl(socketDescriptor, E32IONREAD, (char *) &nbytes); return qint64(nbytes-28); } #else @@ -771,7 +641,7 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS ssize_t recvFromResult = 0; do { char c; - recvFromResult = qt_socket_recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1, + recvFromResult = ::recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1, 0, &aa.a, &sz); } while (recvFromResult == -1 && errno == EINTR); @@ -859,7 +729,7 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters() // Determine local address memset(&sa, 0, sizeof(sa)); - if (qt_socket_getsockname(socketDescriptor, &sa.a, &sockAddrSize) == 0) { + if (::getsockname(socketDescriptor, &sa.a, &sockAddrSize) == 0) { qt_socket_getPortAndAddress(&sa, &localPort, &localAddress); // Determine protocol family @@ -883,13 +753,13 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters() } // Determine the remote address - if (!qt_socket_getpeername(socketDescriptor, &sa.a, &sockAddrSize)) + if (!::getpeername(socketDescriptor, &sa.a, &sockAddrSize)) qt_socket_getPortAndAddress(&sa, &peerPort, &peerAddress); // Determine the socket type (UDP/TCP) int value = 0; QT_SOCKOPTLEN_T valueSize = sizeof(int); - if (qt_socket_getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, &value, &valueSize) == 0) { + if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, &value, &valueSize) == 0) { if (value == SOCK_STREAM) socketType = QAbstractSocket::TcpSocket; else if (value == SOCK_DGRAM) @@ -920,7 +790,7 @@ void QNativeSocketEnginePrivate::nativeClose() #if defined (QNATIVESOCKETENGINE_DEBUG) qDebug("QNativeSocketEngine::nativeClose()"); #endif - qt_socket_close(socketDescriptor); + qt_safe_close(socketDescriptor); } qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len) @@ -934,7 +804,7 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len) // of an interrupting signal. ssize_t writtenBytes; do { - writtenBytes = qt_socket_write(socketDescriptor, data, len); + writtenBytes = qt_safe_write(socketDescriptor, data, len); // writtenBytes = QT_WRITE(socketDescriptor, data, len); ### TODO S60: Should this line be removed or the one above it? } while (writtenBytes < 0 && errno == EINTR); @@ -977,7 +847,7 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize) ssize_t r = 0; do { - r = qt_socket_read(socketDescriptor, data, maxSize); + r = qt_safe_read(socketDescriptor, data, maxSize); } while (r == -1 && errno == EINTR); if (r < 0) { @@ -1039,13 +909,13 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co #ifndef Q_OS_SYMBIAN retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv); #else - retval = qt_socket_select(socketDescriptor + 1, &fds, 0, &fdexec, timeout < 0 ? 0 : &tv); + retval = qt_safe_select(socketDescriptor + 1, &fds, 0, &fdexec, timeout < 0 ? 0 : &tv); #endif else #ifndef Q_OS_SYMBIAN retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv); #else - retval = qt_socket_select(socketDescriptor + 1, 0, &fds, &fdexec, timeout < 0 ? 0 : &tv); + retval = qt_safe_select(socketDescriptor + 1, 0, &fds, &fdexec, timeout < 0 ? 0 : &tv); #endif @@ -1097,7 +967,7 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c timer.start(); do { - ret = qt_socket_select(socketDescriptor + 1, &fdread, &fdwrite, &fdexec, timeout < 0 ? 0 : &tv); + ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, &fdexec, timeout < 0 ? 0 : &tv); bool selectForExec = false; if(ret != 0) { if(ret < 0) { -- 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 2de1adfb8eee36728ac4075593e078577698c92a Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Wed, 19 Aug 2009 09:27:38 +0200 Subject: As far as we know the bug int the Open C, regarding SO_REUSEPORT behaviour should be fixed at the moment (1.5.5 Beta). --- src/network/socket/qnativesocketengine_unix.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 8a826cc..df9b7b4 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -304,9 +304,7 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt return true; } case QNativeSocketEngine::AddressReusable: -#ifdef Q_OS_SYMBIAN - n = SO_REUSEADDR; -#elif SO_REUSEPORT +#ifdef SO_REUSEPORT n = SO_REUSEPORT; #else n = SO_REUSEADDR; -- cgit v0.12 From 7f43e476169bdc5b4b29dae4b49642f5e542c0aa Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 19 Aug 2009 10:30:16 +0300 Subject: Fixed xmlpatterns review comments. In comments it was stated that RVCT version is just fine for all platforms and ifdef are not needed. Also the compilers will really optimize extra temp variables for the other compilers. Reviewed-by: Janne Koskinen --- src/xmlpatterns/data/qabstractfloatcasters.cpp | 7 ------- src/xmlpatterns/functions/qcomparingaggregator.cpp | 4 ---- src/xmlpatterns/functions/qsequencefns_p.h | 8 -------- 3 files changed, 19 deletions(-) diff --git a/src/xmlpatterns/data/qabstractfloatcasters.cpp b/src/xmlpatterns/data/qabstractfloatcasters.cpp index cdbeb67..f41bb4a 100644 --- a/src/xmlpatterns/data/qabstractfloatcasters.cpp +++ b/src/xmlpatterns/data/qabstractfloatcasters.cpp @@ -63,7 +63,6 @@ template Item BooleanToAbstractFloatCaster::castFrom(const Item &from, const QExplicitlySharedDataPointer &context) const { -#if defined(Q_CC_RVCT) // RVCT doesn't like using template parameter in trinary operator when the trinary operator result is // passed directly into another constructor. bool tempDouble = isDouble; @@ -71,11 +70,5 @@ Item BooleanToAbstractFloatCaster::castFrom(const Item &from, return tempDouble ? toItem(CommonValues::DoubleOne) : toItem(CommonValues::FloatOne); else return tempDouble ? toItem(CommonValues::DoubleZero) : toItem(CommonValues::FloatZero); -#else - if(from.template as()->evaluateEBV(context)) - return isDouble ? toItem(CommonValues::DoubleOne) : toItem(CommonValues::FloatOne); - else - return isDouble ? toItem(CommonValues::DoubleZero) : toItem(CommonValues::FloatZero); -#endif } diff --git a/src/xmlpatterns/functions/qcomparingaggregator.cpp b/src/xmlpatterns/functions/qcomparingaggregator.cpp index 559b944..4fbb070 100644 --- a/src/xmlpatterns/functions/qcomparingaggregator.cpp +++ b/src/xmlpatterns/functions/qcomparingaggregator.cpp @@ -204,12 +204,8 @@ ComparingAggregator::typeCheck(const StaticContext::Ptr &context, if(!m_operands.first()->staticType()->cardinality().allowsMany()) return m_operands.first(); -#if defined(Q_CC_RVCT) // explicit scope needed in RVCT ComparingAggregator::prepareComparison(fetchComparator(t1, t1, context)); -#else - prepareComparison(fetchComparator(t1, t1, context)); -#endif return me; } diff --git a/src/xmlpatterns/functions/qsequencefns_p.h b/src/xmlpatterns/functions/qsequencefns_p.h index 18d2806..f16462f 100644 --- a/src/xmlpatterns/functions/qsequencefns_p.h +++ b/src/xmlpatterns/functions/qsequencefns_p.h @@ -146,28 +146,20 @@ namespace QPatternist */ virtual Expression::Ptr compress(const StaticContext::Ptr &context) { -#if defined(Q_CC_RVCT) && !defined(QT_NO_DEBUG) // RVCT doesn't like using template parameter in trinary operator when the trinary operator result is // passed directly into another constructor. bool tempAssert = (Id == IDExistsFN || Id == IDEmptyFN); Q_ASSERT(tempAssert); -#else - Q_ASSERT(Id == IDExistsFN || Id == IDEmptyFN); -#endif const Expression::Ptr me(FunctionCall::compress(context)); if(me != this) return me; -#if defined(Q_CC_RVCT) // RVCT doesn't like using template parameter in trinary operator when the trinary operator result is // passed directly into another constructor. Expression::ID tempId = Id; const Cardinality myCard((tempId == IDExistsFN) ? Cardinality::oneOrMore() : Cardinality::empty()); -#else - const Cardinality myCard((Id == IDExistsFN) ? Cardinality::oneOrMore() : Cardinality::empty()); -#endif const Cardinality card(m_operands.first()->staticType()->cardinality()); if(myCard.isMatch(card)) -- cgit v0.12 From 4b8d6db43ba41597beb348a56239c30413ac4be3 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Wed, 19 Aug 2009 09:53:39 +0200 Subject: Being more precise in the code comments. --- src/network/socket/qudpsocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp index 5483ece..aeb525c 100644 --- a/src/network/socket/qudpsocket.cpp +++ b/src/network/socket/qudpsocket.cpp @@ -97,7 +97,7 @@ \note On Symbian OS bind flags behaviour depends on process capabilties. If process has NetworkControl capability, the bind attempt with - ReuseAddressHint will always succeed even the address and port is already + ReuseAddressHint will always succeed even if the address and port is already bound by another socket with any flags. If process does not have NetworkControl capability, the bind attempt to address and port already bound by another socket will always fail. -- cgit v0.12 From e0d00380975ffc5b0441927d88f6e966695b644c Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 19 Aug 2009 09:59:57 +0200 Subject: Changed names and URLs to reflect name change. RevBy: Trust me --- demos/demobase.pri | 4 ++-- demos/embedded/anomaly/src/AddressBar.cpp | 2 +- demos/embedded/anomaly/src/AddressBar.h | 2 +- demos/embedded/anomaly/src/BookmarksView.cpp | 6 +++--- demos/embedded/anomaly/src/BookmarksView.h | 2 +- demos/embedded/anomaly/src/BrowserView.cpp | 2 +- demos/embedded/anomaly/src/BrowserView.h | 2 +- demos/embedded/anomaly/src/BrowserWindow.cpp | 2 +- demos/embedded/anomaly/src/BrowserWindow.h | 2 +- demos/embedded/anomaly/src/ControlStrip.cpp | 2 +- demos/embedded/anomaly/src/ControlStrip.h | 2 +- demos/embedded/anomaly/src/HomeView.cpp | 2 +- demos/embedded/anomaly/src/HomeView.h | 2 +- demos/embedded/anomaly/src/Main.cpp | 2 +- demos/embedded/anomaly/src/TitleBar.cpp | 2 +- demos/embedded/anomaly/src/TitleBar.h | 2 +- demos/embedded/anomaly/src/ZoomStrip.cpp | 2 +- demos/embedded/anomaly/src/ZoomStrip.h | 2 +- demos/embedded/anomaly/src/flickcharm.cpp | 2 +- demos/embedded/anomaly/src/flickcharm.h | 2 +- demos/embedded/desktopservices/contenttab.cpp | 2 +- demos/embedded/desktopservices/contenttab.h | 2 +- demos/embedded/desktopservices/desktopwidget.cpp | 2 +- demos/embedded/desktopservices/desktopwidget.h | 2 +- demos/embedded/desktopservices/linktab.cpp | 4 ++-- demos/embedded/desktopservices/linktab.h | 2 +- demos/embedded/desktopservices/main.cpp | 2 +- dist/changes-4.5.0-garden | 4 ++-- dist/changes-4.5.2-tower | 8 ++++---- doc/src/examples/htmlinfo.qdoc | 2 +- doc/src/exceptionsafety.qdoc | 2 +- doc/src/s60-introduction.qdoc | 2 +- doc/src/symbian-exceptionsafety.qdoc | 2 +- examples/examplebase.pri | 4 ++-- examples/network/ftp/sym_iap_util.h | 2 +- examples/widgets/softkeys/main.cpp | 2 +- examples/widgets/softkeys/softkeys.cpp | 2 +- examples/widgets/softkeys/softkeys.h | 2 +- examples/xml/htmlinfo/main.cpp | 2 +- examples/xml/htmlinfo/simpleexample.html | 4 ++-- mkspecs/common/symbian/fixed_stdlib.h | 2 +- mkspecs/common/symbian/qplatformdefs.h | 2 +- mkspecs/win32-mwc/qplatformdefs.h | 2 +- qmake/generators/symbian/initprojectdeploy_symbian.cpp | 2 +- qmake/generators/symbian/initprojectdeploy_symbian.h | 2 +- qmake/generators/symbian/symmake.cpp | 2 +- qmake/generators/symbian/symmake.h | 2 +- qmake/generators/symbian/symmake_abld.cpp | 2 +- qmake/generators/symbian/symmake_abld.h | 2 +- qmake/generators/symbian/symmake_sbsv2.cpp | 2 +- qmake/generators/symbian/symmake_sbsv2.h | 2 +- src/3rdparty/phonon/gstreamer/backend.cpp | 2 +- src/3rdparty/phonon/qt7/backend.mm | 2 +- src/3rdparty/webkit/WebCore/ChangeLog-2009-06-16 | 4 ++-- src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp | 4 ++-- src/3rdparty/webkit/WebKit/qt/ChangeLog | 6 +++--- src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp | 2 +- .../webkit/WebKit/qt/docs/webkitsnippets/webpage/main.cpp | 2 +- src/corelib/arch/qatomic_symbian.h | 2 +- src/corelib/arch/symbian/qatomic_symbian.cpp | 2 +- src/corelib/io/qfilesystemwatcher_symbian.cpp | 2 +- src/corelib/io/qfilesystemwatcher_symbian_p.h | 2 +- src/corelib/io/qprocess_symbian.cpp | 2 +- src/corelib/kernel/qcore_symbian_p.cpp | 2 +- src/corelib/kernel/qcore_symbian_p.h | 2 +- src/corelib/kernel/qeventdispatcher_symbian.cpp | 2 +- src/corelib/kernel/qeventdispatcher_symbian_p.h | 2 +- src/corelib/kernel/qsharedmemory_symbian.cpp | 2 +- src/corelib/kernel/qsystemsemaphore_symbian.cpp | 2 +- src/corelib/tools/qlocale_symbian.cpp | 2 +- src/corelib/tools/qscopedpointer.cpp | 2 +- src/corelib/tools/qscopedpointer.h | 2 +- src/gui/dialogs/qfscompleter_p.h | 2 +- src/gui/image/qpixmap_s60.cpp | 2 +- src/gui/inputmethod/qcoefepinputcontext_p.h | 2 +- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 2 +- src/gui/kernel/qapplication_s60.cpp | 2 +- src/gui/kernel/qclipboard_s60.cpp | 2 +- src/gui/kernel/qcursor_s60.cpp | 2 +- src/gui/kernel/qdesktopwidget_s60.cpp | 2 +- src/gui/kernel/qdnd_s60.cpp | 2 +- src/gui/kernel/qeventdispatcher_s60.cpp | 2 +- src/gui/kernel/qeventdispatcher_s60_p.h | 2 +- src/gui/kernel/qkeymapper_s60.cpp | 2 +- src/gui/kernel/qsound_s60.cpp | 2 +- src/gui/kernel/qt_s60_p.h | 2 +- src/gui/kernel/qwidget_s60.cpp | 2 +- src/gui/painting/qblendfunctions_armv6_rvct.s | 2 +- src/gui/painting/qcolormap_s60.cpp | 2 +- src/gui/painting/qdrawhelper_armv6_p.h | 2 +- src/gui/painting/qdrawhelper_armv6_rvct.inc | 2 +- src/gui/painting/qdrawhelper_armv6_rvct.s | 2 +- src/gui/painting/qregion_s60.cpp | 2 +- src/gui/painting/qwindowsurface_s60.cpp | 2 +- src/gui/painting/qwindowsurface_s60_p.h | 2 +- src/gui/styles/qs60style.cpp | 2 +- src/gui/styles/qs60style.h | 2 +- src/gui/styles/qs60style_p.h | 2 +- src/gui/styles/qs60style_s60.cpp | 2 +- src/gui/styles/qs60style_simulated.cpp | 2 +- src/gui/text/qfont_s60.cpp | 2 +- src/gui/text/qfontdatabase_s60.cpp | 2 +- src/gui/text/qfontengine_s60.cpp | 2 +- src/gui/text/qfontengine_s60_p.h | 2 +- src/gui/util/qdesktopservices_s60.cpp | 2 +- src/gui/widgets/qactiontokeyeventmapper.cpp | 2 +- src/gui/widgets/qactiontokeyeventmapper_p.h | 2 +- src/gui/widgets/qmenu_symbian.cpp | 2 +- src/network/kernel/qnetworkinterface_symbian.cpp | 2 +- src/plugins/s60/src/qdesktopservices_3_1.cpp | 2 +- src/plugins/s60/src/qdesktopservices_3_2.cpp | 2 +- src/plugins/s60/src/qlocale_3_1.cpp | 2 +- src/plugins/s60/src/qlocale_3_2.cpp | 2 +- src/s60installs/qt_libs.pro | 4 ++-- src/s60main/qts60main.cpp | 2 +- src/s60main/qts60main_mcrt0.cpp | 2 +- src/s60main/qts60mainapplication.cpp | 2 +- src/s60main/qts60mainapplication_p.h | 2 +- src/s60main/qts60mainappui.cpp | 2 +- src/s60main/qts60mainappui_p.h | 2 +- src/s60main/qts60maindocument.cpp | 2 +- src/s60main/qts60maindocument_p.h | 2 +- src/s60main/s60main.rss | 2 +- tests/auto/exceptionsafety_objects/oomsimulator.h | 2 +- .../auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp | 2 +- tests/auto/qinputcontext/tst_qinputcontext.cpp | 2 +- tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 2 +- tests/auto/symbian/orientationchange/tst_orientationchange.cpp | 2 +- tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp | 2 +- util/s60pixelmetrics/bld.inf | 2 +- util/s60pixelmetrics/pixel_metrics.cpp | 2 +- util/s60pixelmetrics/pixel_metrics.h | 2 +- util/s60pixelmetrics/pm_mapper.hrh | 2 +- util/s60pixelmetrics/pm_mapper.mmp | 2 +- util/s60pixelmetrics/pm_mapper.rss | 2 +- util/s60pixelmetrics/pm_mapper_reg.rss | 2 +- util/s60pixelmetrics/pm_mapperapp.cpp | 2 +- util/s60pixelmetrics/pm_mapperapp.h | 2 +- util/s60pixelmetrics/pm_mapperview.cpp | 2 +- util/s60pixelmetrics/pm_mapperview.h | 2 +- util/s60theme/main.cpp | 2 +- util/s60theme/s60themeconvert.cpp | 2 +- util/s60theme/s60themeconvert.h | 2 +- 143 files changed, 158 insertions(+), 158 deletions(-) diff --git a/demos/demobase.pri b/demos/demobase.pri index ec26f3a..e6763d5 100644 --- a/demos/demobase.pri +++ b/demos/demobase.pri @@ -3,10 +3,10 @@ symbian { vendorinfo = \ "; Localised Vendor name" \ - "%{\"Nokia, Qt Software\"}" \ + "%{\"Nokia, Qt\"}" \ " " \ "; Unique Vendor name" \ - ":\"Nokia, Qt Software\"" \ + ":\"Nokia, Qt\"" \ " " default_deployment.pkg_prerules += vendorinfo } diff --git a/demos/embedded/anomaly/src/AddressBar.cpp b/demos/embedded/anomaly/src/AddressBar.cpp index 0fd3d35..57ea6be 100644 --- a/demos/embedded/anomaly/src/AddressBar.cpp +++ b/demos/embedded/anomaly/src/AddressBar.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/AddressBar.h b/demos/embedded/anomaly/src/AddressBar.h index a1e58d2..2e9d1b5 100644 --- a/demos/embedded/anomaly/src/AddressBar.h +++ b/demos/embedded/anomaly/src/AddressBar.h @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/BookmarksView.cpp b/demos/embedded/anomaly/src/BookmarksView.cpp index 62e483c..aa2233da 100644 --- a/demos/embedded/anomaly/src/BookmarksView.cpp +++ b/demos/embedded/anomaly/src/BookmarksView.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. @@ -36,10 +36,10 @@ BookmarksView::BookmarksView(QWidget *parent) layout->addWidget(m_iconView); m_iconView->addItem("www.google.com"); - m_iconView->addItem("doc.trolltech.com/4.5"); + m_iconView->addItem("qt.nokia.com/doc/4.5"); m_iconView->addItem("news.bbc.co.uk/text_only.stm"); m_iconView->addItem("mobile.wikipedia.org"); - m_iconView->addItem("www.qtsoftware.com"); + m_iconView->addItem("qt.nokia.com"); m_iconView->addItem("en.wikipedia.org"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); diff --git a/demos/embedded/anomaly/src/BookmarksView.h b/demos/embedded/anomaly/src/BookmarksView.h index 3c9a054..b918192 100644 --- a/demos/embedded/anomaly/src/BookmarksView.h +++ b/demos/embedded/anomaly/src/BookmarksView.h @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/BrowserView.cpp b/demos/embedded/anomaly/src/BrowserView.cpp index b882a2e..9eea7b2 100644 --- a/demos/embedded/anomaly/src/BrowserView.cpp +++ b/demos/embedded/anomaly/src/BrowserView.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/BrowserView.h b/demos/embedded/anomaly/src/BrowserView.h index a9cf8d2..e80166a 100644 --- a/demos/embedded/anomaly/src/BrowserView.h +++ b/demos/embedded/anomaly/src/BrowserView.h @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/BrowserWindow.cpp b/demos/embedded/anomaly/src/BrowserWindow.cpp index 61dcb61..9f81fe3 100644 --- a/demos/embedded/anomaly/src/BrowserWindow.cpp +++ b/demos/embedded/anomaly/src/BrowserWindow.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/BrowserWindow.h b/demos/embedded/anomaly/src/BrowserWindow.h index b65d421..2b9757f 100644 --- a/demos/embedded/anomaly/src/BrowserWindow.h +++ b/demos/embedded/anomaly/src/BrowserWindow.h @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/ControlStrip.cpp b/demos/embedded/anomaly/src/ControlStrip.cpp index 4801870..190db30 100644 --- a/demos/embedded/anomaly/src/ControlStrip.cpp +++ b/demos/embedded/anomaly/src/ControlStrip.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/ControlStrip.h b/demos/embedded/anomaly/src/ControlStrip.h index d3fb253..bf8d7e8 100644 --- a/demos/embedded/anomaly/src/ControlStrip.h +++ b/demos/embedded/anomaly/src/ControlStrip.h @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/HomeView.cpp b/demos/embedded/anomaly/src/HomeView.cpp index f4e19f5..def677d 100644 --- a/demos/embedded/anomaly/src/HomeView.cpp +++ b/demos/embedded/anomaly/src/HomeView.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/HomeView.h b/demos/embedded/anomaly/src/HomeView.h index a33881a..2a56295 100644 --- a/demos/embedded/anomaly/src/HomeView.h +++ b/demos/embedded/anomaly/src/HomeView.h @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/Main.cpp b/demos/embedded/anomaly/src/Main.cpp index f3e2298..d73e58a 100644 --- a/demos/embedded/anomaly/src/Main.cpp +++ b/demos/embedded/anomaly/src/Main.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/TitleBar.cpp b/demos/embedded/anomaly/src/TitleBar.cpp index 2e4eda5..f33ccab 100644 --- a/demos/embedded/anomaly/src/TitleBar.cpp +++ b/demos/embedded/anomaly/src/TitleBar.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/TitleBar.h b/demos/embedded/anomaly/src/TitleBar.h index 7f56860..5e982ff 100644 --- a/demos/embedded/anomaly/src/TitleBar.h +++ b/demos/embedded/anomaly/src/TitleBar.h @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/ZoomStrip.cpp b/demos/embedded/anomaly/src/ZoomStrip.cpp index 8848347..167a4f7 100644 --- a/demos/embedded/anomaly/src/ZoomStrip.cpp +++ b/demos/embedded/anomaly/src/ZoomStrip.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/ZoomStrip.h b/demos/embedded/anomaly/src/ZoomStrip.h index f613249..88ce264 100644 --- a/demos/embedded/anomaly/src/ZoomStrip.h +++ b/demos/embedded/anomaly/src/ZoomStrip.h @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/flickcharm.cpp b/demos/embedded/anomaly/src/flickcharm.cpp index 851cadf..ec257b3 100644 --- a/demos/embedded/anomaly/src/flickcharm.cpp +++ b/demos/embedded/anomaly/src/flickcharm.cpp @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/anomaly/src/flickcharm.h b/demos/embedded/anomaly/src/flickcharm.h index 74de9c5..9e36296 100644 --- a/demos/embedded/anomaly/src/flickcharm.h +++ b/demos/embedded/anomaly/src/flickcharm.h @@ -14,7 +14,7 @@ ** http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/demos/embedded/desktopservices/contenttab.cpp b/demos/embedded/desktopservices/contenttab.cpp index 8b70c1d..d1b7a02 100644 --- a/demos/embedded/desktopservices/contenttab.cpp +++ b/demos/embedded/desktopservices/contenttab.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/demos/embedded/desktopservices/contenttab.h b/demos/embedded/desktopservices/contenttab.h index e703754..1840827 100644 --- a/demos/embedded/desktopservices/contenttab.h +++ b/demos/embedded/desktopservices/contenttab.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/demos/embedded/desktopservices/desktopwidget.cpp b/demos/embedded/desktopservices/desktopwidget.cpp index fbcc078..015e8f3 100644 --- a/demos/embedded/desktopservices/desktopwidget.cpp +++ b/demos/embedded/desktopservices/desktopwidget.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/demos/embedded/desktopservices/desktopwidget.h b/demos/embedded/desktopservices/desktopwidget.h index c550715..960127a 100644 --- a/demos/embedded/desktopservices/desktopwidget.h +++ b/demos/embedded/desktopservices/desktopwidget.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/demos/embedded/desktopservices/linktab.cpp b/demos/embedded/desktopservices/linktab.cpp index 95024da..4ae43f0 100644 --- a/demos/embedded/desktopservices/linktab.cpp +++ b/demos/embedded/desktopservices/linktab.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -67,7 +67,7 @@ void LinkTab::populateListWidget() QUrl LinkTab::itemUrl(QListWidgetItem *item) { if (m_WebItem == item) { - return QUrl(tr("http://www.qtsoftware.com")); + return QUrl(tr("http://qt.nokia.com")); } else if (m_MailToItem == item) { return QUrl(tr("mailto:qts60-feedback@trolltech.com?subject=QtS60 feedback&body=Hello")); } else { diff --git a/demos/embedded/desktopservices/linktab.h b/demos/embedded/desktopservices/linktab.h index 3f8cc5d..1ddd354 100644 --- a/demos/embedded/desktopservices/linktab.h +++ b/demos/embedded/desktopservices/linktab.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/demos/embedded/desktopservices/main.cpp b/demos/embedded/desktopservices/main.cpp index 89c31d8..c200f4b 100644 --- a/demos/embedded/desktopservices/main.cpp +++ b/demos/embedded/desktopservices/main.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/dist/changes-4.5.0-garden b/dist/changes-4.5.0-garden index 1fae42e..ce258e7 100644 --- a/dist/changes-4.5.0-garden +++ b/dist/changes-4.5.0-garden @@ -9,12 +9,12 @@ Up to and including change: b7621555cb1d1c97967dd40d63dd7e85a418407c Lists just S60 fixes, for general 4.5.0 changes go to: - http://www.qtsoftware.com/developer/changes/changes-4.5.0 + http://qt.nokia.com/developer/changes/changes-4.5.0 Some of the changes listed in this file include issue tracking numbers corresponding to tasks in the Task Tracker: - http://qtsoftware.com/developer/task-tracker + http://qt.nokia.com/developer/task-tracker Each of these identifiers can be entered in the task tracker to obtain more information about a particular change. Sometimes the task is internal diff --git a/dist/changes-4.5.2-tower b/dist/changes-4.5.2-tower index eaf493d..8252c29 100644 --- a/dist/changes-4.5.2-tower +++ b/dist/changes-4.5.2-tower @@ -7,14 +7,14 @@ S60 porting project. "Tower" is based on the Qt 4.5 codebase (mostly Qt 4.5.2). This list of changes lists S60 specific fixes only, for general 4.5.x changes go to: - http://www.qtsoftware.com/developer/changes/changes-4.5.0 - http://www.qtsoftware.com/developer/changes/changes-4.5.1 - http://www.qtsoftware.com/developer/changes/changes-4.5.2 (partially in Tower) + http://qt.nokia.com/developer/changes/changes-4.5.0 + http://qt.nokia.com/developer/changes/changes-4.5.1 + http://qt.nokia.com/developer/changes/changes-4.5.2 (partially in Tower) Some of the changes listed in this file include issue tracking numbers corresponding to tasks in the Task Tracker: - http://qtsoftware.com/developer/task-tracker + http://qt.nokia.com/developer/task-tracker Each of these identifiers can be entered in the task tracker to obtain more information about a particular change. Sometimes the task is internal diff --git a/doc/src/examples/htmlinfo.qdoc b/doc/src/examples/htmlinfo.qdoc index e2be964..68e8320 100644 --- a/doc/src/examples/htmlinfo.qdoc +++ b/doc/src/examples/htmlinfo.qdoc @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/doc/src/exceptionsafety.qdoc b/doc/src/exceptionsafety.qdoc index 1378f24..284159f 100644 --- a/doc/src/exceptionsafety.qdoc +++ b/doc/src/exceptionsafety.qdoc @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/doc/src/s60-introduction.qdoc b/doc/src/s60-introduction.qdoc index 16919cb..24f7817 100644 --- a/doc/src/s60-introduction.qdoc +++ b/doc/src/s60-introduction.qdoc @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/doc/src/symbian-exceptionsafety.qdoc b/doc/src/symbian-exceptionsafety.qdoc index cb6d5ff..9183ba7 100644 --- a/doc/src/symbian-exceptionsafety.qdoc +++ b/doc/src/symbian-exceptionsafety.qdoc @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/examplebase.pri b/examples/examplebase.pri index caaf819..9f24232 100644 --- a/examples/examplebase.pri +++ b/examples/examplebase.pri @@ -3,10 +3,10 @@ symbian { vendorinfo = \ "; Localised Vendor name" \ - "%{\"Nokia, Qt Software\"}" \ + "%{\"Nokia, Qt\"}" \ " " \ "; Unique Vendor name" \ - ":\"Nokia, Qt Software\"" \ + ":\"Nokia, Qt\"" \ " " default_deployment.pkg_prerules += vendorinfo } diff --git a/examples/network/ftp/sym_iap_util.h b/examples/network/ftp/sym_iap_util.h index 1eb66a3..6c43738 100644 --- a/examples/network/ftp/sym_iap_util.h +++ b/examples/network/ftp/sym_iap_util.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/widgets/softkeys/main.cpp b/examples/widgets/softkeys/main.cpp index 3025e36..a0f6052 100644 --- a/examples/widgets/softkeys/main.cpp +++ b/examples/widgets/softkeys/main.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp index 7419aec..98ffd69 100644 --- a/examples/widgets/softkeys/softkeys.cpp +++ b/examples/widgets/softkeys/softkeys.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h index 6f46563..e0ee89a 100644 --- a/examples/widgets/softkeys/softkeys.h +++ b/examples/widgets/softkeys/softkeys.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/xml/htmlinfo/main.cpp b/examples/xml/htmlinfo/main.cpp index fa85f55..9831d36 100644 --- a/examples/xml/htmlinfo/main.cpp +++ b/examples/xml/htmlinfo/main.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/xml/htmlinfo/simpleexample.html b/examples/xml/htmlinfo/simpleexample.html index 87ccf36..83a55cf 100644 --- a/examples/xml/htmlinfo/simpleexample.html +++ b/examples/xml/htmlinfo/simpleexample.html @@ -5,7 +5,7 @@

A paragraph.

-

A second paragraph. Check out our developer blogs

-

And the last paragraph. Or our online documentation.

+

A second paragraph. Check out our developer blogs

+

And the last paragraph. Or our online documentation.

diff --git a/mkspecs/common/symbian/fixed_stdlib.h b/mkspecs/common/symbian/fixed_stdlib.h index 82ad45d..a6dcbc7 100644 --- a/mkspecs/common/symbian/fixed_stdlib.h +++ b/mkspecs/common/symbian/fixed_stdlib.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/mkspecs/common/symbian/qplatformdefs.h b/mkspecs/common/symbian/qplatformdefs.h index db5f461..b459cef 100644 --- a/mkspecs/common/symbian/qplatformdefs.h +++ b/mkspecs/common/symbian/qplatformdefs.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/mkspecs/win32-mwc/qplatformdefs.h b/mkspecs/win32-mwc/qplatformdefs.h index 5c31394..a96b4db 100644 --- a/mkspecs/win32-mwc/qplatformdefs.h +++ b/mkspecs/win32-mwc/qplatformdefs.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.cpp b/qmake/generators/symbian/initprojectdeploy_symbian.cpp index 392eca2..d95a0d6 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp +++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.h b/qmake/generators/symbian/initprojectdeploy_symbian.h index a104985..6c643a0 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.h +++ b/qmake/generators/symbian/initprojectdeploy_symbian.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index b3fa0f2..a0f1cf2 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/qmake/generators/symbian/symmake.h b/qmake/generators/symbian/symmake.h index e4b23e2..22dc4c9 100644 --- a/qmake/generators/symbian/symmake.h +++ b/qmake/generators/symbian/symmake.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index d88b34b..271d210 100644 --- a/qmake/generators/symbian/symmake_abld.cpp +++ b/qmake/generators/symbian/symmake_abld.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/qmake/generators/symbian/symmake_abld.h b/qmake/generators/symbian/symmake_abld.h index 0b2989f..7709d5d 100644 --- a/qmake/generators/symbian/symmake_abld.h +++ b/qmake/generators/symbian/symmake_abld.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index bf96b73..1cbd9f4 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/qmake/generators/symbian/symmake_sbsv2.h b/qmake/generators/symbian/symmake_sbsv2.h index 7806d53..7f78834 100644 --- a/qmake/generators/symbian/symmake_sbsv2.h +++ b/qmake/generators/symbian/symmake_sbsv2.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/3rdparty/phonon/gstreamer/backend.cpp b/src/3rdparty/phonon/gstreamer/backend.cpp index d05f6a6..cd49454 100644 --- a/src/3rdparty/phonon/gstreamer/backend.cpp +++ b/src/3rdparty/phonon/gstreamer/backend.cpp @@ -60,7 +60,7 @@ Backend::Backend(QObject *parent, const QVariantList &) setProperty("backendName", QLatin1String("Gstreamer")); setProperty("backendComment", QLatin1String("Gstreamer plugin for Phonon")); setProperty("backendVersion", QLatin1String("0.2")); - setProperty("backendWebsite", QLatin1String("http://qtsoftware.com/")); + setProperty("backendWebsite", QLatin1String("http://qt.nokia.com/")); //check if we should enable debug output QString debugLevelString = qgetenv("PHONON_GST_DEBUG"); diff --git a/src/3rdparty/phonon/qt7/backend.mm b/src/3rdparty/phonon/qt7/backend.mm index 327ddd7..b3ca106 100644 --- a/src/3rdparty/phonon/qt7/backend.mm +++ b/src/3rdparty/phonon/qt7/backend.mm @@ -59,7 +59,7 @@ Backend::Backend(QObject *parent, const QStringList &) : QObject(parent) setProperty("backendComment", QLatin1String("Developed by Trolltech")); setProperty("backendVersion", QLatin1String("0.1")); setProperty("backendIcon", QLatin1String("")); - setProperty("backendWebsite", QLatin1String("http://qtsoftware.com/")); + setProperty("backendWebsite", QLatin1String("http://qt.nokia.com/")); } Backend::~Backend() diff --git a/src/3rdparty/webkit/WebCore/ChangeLog-2009-06-16 b/src/3rdparty/webkit/WebCore/ChangeLog-2009-06-16 index 1041c90..1f283d2 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog-2009-06-16 +++ b/src/3rdparty/webkit/WebCore/ChangeLog-2009-06-16 @@ -47996,7 +47996,7 @@ Rubber-stamped by Simon Hausmann. - http://www.qtsoftware.com/developer/task-tracker/index_html?id=238662&method=entry + http://qt.nokia.com/developer/task-tracker/index_html?id=238662&method=entry [Qt] Map function keys F1 to F24. @@ -52735,7 +52735,7 @@ Reviewed by Simon Hausmann. - http://www.qtsoftware.com/developer/task-tracker/index_html?id=211228&method=entry + http://qt.nokia.com/developer/task-tracker/index_html?id=211228&method=entry [Qt] Show focus rect when a button gets the focus for the first time. This is important at least for Windows style. diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp index e3b7efe..8506099 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp @@ -142,7 +142,7 @@ void QWebPluginFactory::refreshPlugins() For example: \code - + @@ -155,7 +155,7 @@ void QWebPluginFactory::refreshPlugins() \row \o mimeType \o "application/x-pdf" \row \o url - \o "http://qtsoftware.com/document.pdf" + \o "http://qt.nokia.com/document.pdf" \row \o argumentNames \o "showTableOfContents" "hideThumbnails" \row \o argumentVaues diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 83808d2..e8f5ad0 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -2663,7 +2663,7 @@ Reviewed by Simon Hausmann. - http://www.qtsoftware.com/developer/task-tracker/index_html?id=238391&method=entry + http://qt.nokia.com/developer/task-tracker/index_html?id=238391&method=entry [Qt] If QPainter fails to start on a QPrinter instance, do not continue printing. @@ -2856,7 +2856,7 @@ Rubber-stamped by Simon Hausmann. - http://www.qtsoftware.com/developer/task-tracker/index_html?id=219344&method=entry + http://qt.nokia.com/developer/task-tracker/index_html?id=219344&method=entry [Qt] API documentation for QWebPage::WebAction enum. @@ -2911,7 +2911,7 @@ Reviewed by Simon Hausmann. - http://www.qtsoftware.com/developer/task-tracker/index_html?id=241144&method=entry + http://qt.nokia.com/developer/task-tracker/index_html?id=241144&method=entry [Qt] Create actions for text selection and editing for QWebPage. Also properly disable and enable them when contentEditable is toggled. diff --git a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp index 82f5b6c..408630e 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp +++ b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) QWidget *parent = 0; //! [Using QWebView] QWebView *view = new QWebView(parent); - view->load(QUrl("http://qtsoftware.com/")); + view->load(QUrl("http://qt.nokia.com/")); view->show(); //! [Using QWebView] return app.exec(); diff --git a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webpage/main.cpp b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webpage/main.cpp index b91bc30..393b16a 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webpage/main.cpp +++ b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webpage/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - Thumbnailer thumbnail(QUrl("http://qtsoftware.com")); + Thumbnailer thumbnail(QUrl("http://qt.nokia.com")); QObject::connect(&thumbnail, SIGNAL(finished()), &app, SLOT(quit())); diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h index 74a0ca8..211c5f5 100644 --- a/src/corelib/arch/qatomic_symbian.h +++ b/src/corelib/arch/qatomic_symbian.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/arch/symbian/qatomic_symbian.cpp b/src/corelib/arch/symbian/qatomic_symbian.cpp index b08a468..910a03d 100644 --- a/src/corelib/arch/symbian/qatomic_symbian.cpp +++ b/src/corelib/arch/symbian/qatomic_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp index 412372a..72b8b83 100644 --- a/src/corelib/io/qfilesystemwatcher_symbian.cpp +++ b/src/corelib/io/qfilesystemwatcher_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/io/qfilesystemwatcher_symbian_p.h b/src/corelib/io/qfilesystemwatcher_symbian_p.h index 846541b..a1bd607 100644 --- a/src/corelib/io/qfilesystemwatcher_symbian_p.h +++ b/src/corelib/io/qfilesystemwatcher_symbian_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp index 64519f6..a8c72d3 100644 --- a/src/corelib/io/qprocess_symbian.cpp +++ b/src/corelib/io/qprocess_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp index c7264cf..a7d2694 100644 --- a/src/corelib/kernel/qcore_symbian_p.cpp +++ b/src/corelib/kernel/qcore_symbian_p.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h index 391774f..2a81b99 100644 --- a/src/corelib/kernel/qcore_symbian_p.h +++ b/src/corelib/kernel/qcore_symbian_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index ed55ef6..d7b9d92 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 28fee9e..69912d0 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qsharedmemory_symbian.cpp b/src/corelib/kernel/qsharedmemory_symbian.cpp index d35c21f..fee6293 100644 --- a/src/corelib/kernel/qsharedmemory_symbian.cpp +++ b/src/corelib/kernel/qsharedmemory_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/kernel/qsystemsemaphore_symbian.cpp b/src/corelib/kernel/qsystemsemaphore_symbian.cpp index a14db7e..3af441a 100644 --- a/src/corelib/kernel/qsystemsemaphore_symbian.cpp +++ b/src/corelib/kernel/qsystemsemaphore_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index dc9692b..a534560 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index 5b8991e..ef6cc39 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 344964b..7a3ee14 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/dialogs/qfscompleter_p.h b/src/gui/dialogs/qfscompleter_p.h index f0fcdec..2e5a674 100644 --- a/src/gui/dialogs/qfscompleter_p.h +++ b/src/gui/dialogs/qfscompleter_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index ab19924..a796066 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h index 5e6450c..c9a9423 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_p.h +++ b/src/gui/inputmethod/qcoefepinputcontext_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 833e000..7c7bce3 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 44ac380..bbebb64 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/gui/kernel/qclipboard_s60.cpp index 3c14b93..f409b12 100644 --- a/src/gui/kernel/qclipboard_s60.cpp +++ b/src/gui/kernel/qclipboard_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qcursor_s60.cpp b/src/gui/kernel/qcursor_s60.cpp index bc4fdd1..1f89430 100644 --- a/src/gui/kernel/qcursor_s60.cpp +++ b/src/gui/kernel/qcursor_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp index 5734ddd..4127302 100644 --- a/src/gui/kernel/qdesktopwidget_s60.cpp +++ b/src/gui/kernel/qdesktopwidget_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qdnd_s60.cpp b/src/gui/kernel/qdnd_s60.cpp index 8db2e93..e014940 100644 --- a/src/gui/kernel/qdnd_s60.cpp +++ b/src/gui/kernel/qdnd_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qeventdispatcher_s60.cpp b/src/gui/kernel/qeventdispatcher_s60.cpp index a176ede..8dc063e 100644 --- a/src/gui/kernel/qeventdispatcher_s60.cpp +++ b/src/gui/kernel/qeventdispatcher_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qeventdispatcher_s60_p.h b/src/gui/kernel/qeventdispatcher_s60_p.h index 6a63875..ed1cb36 100644 --- a/src/gui/kernel/qeventdispatcher_s60_p.h +++ b/src/gui/kernel/qeventdispatcher_s60_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qkeymapper_s60.cpp b/src/gui/kernel/qkeymapper_s60.cpp index b68c244..6063ee4 100644 --- a/src/gui/kernel/qkeymapper_s60.cpp +++ b/src/gui/kernel/qkeymapper_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qsound_s60.cpp b/src/gui/kernel/qsound_s60.cpp index 5eae4de..b654567 100644 --- a/src/gui/kernel/qsound_s60.cpp +++ b/src/gui/kernel/qsound_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 1ac6a8e..832ba8f 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index f8a5be5..d28e2c0 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/painting/qblendfunctions_armv6_rvct.s b/src/gui/painting/qblendfunctions_armv6_rvct.s index 1027548..0d413cb 100644 --- a/src/gui/painting/qblendfunctions_armv6_rvct.s +++ b/src/gui/painting/qblendfunctions_armv6_rvct.s @@ -34,7 +34,7 @@ ;** met: http://www.gnu.org/copyleft/gpl.html. ;** ;** If you are unsure which license is appropriate for your use, please -;** contact the sales department at http://www.qtsoftware.com/contact. +;** contact the sales department at http://qt.nokia.com/contact. ;** $QT_END_LICENSE$ ;** ;****************************************************************************/ diff --git a/src/gui/painting/qcolormap_s60.cpp b/src/gui/painting/qcolormap_s60.cpp index 01d12d1..7a27c94 100644 --- a/src/gui/painting/qcolormap_s60.cpp +++ b/src/gui/painting/qcolormap_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/painting/qdrawhelper_armv6_p.h b/src/gui/painting/qdrawhelper_armv6_p.h index 2ab63eb..9f3e062 100644 --- a/src/gui/painting/qdrawhelper_armv6_p.h +++ b/src/gui/painting/qdrawhelper_armv6_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/painting/qdrawhelper_armv6_rvct.inc b/src/gui/painting/qdrawhelper_armv6_rvct.inc index f6c23d0..1aabbf5 100644 --- a/src/gui/painting/qdrawhelper_armv6_rvct.inc +++ b/src/gui/painting/qdrawhelper_armv6_rvct.inc @@ -34,7 +34,7 @@ ;** met: http://www.gnu.org/copyleft/gpl.html. ;** ;** If you are unsure which license is appropriate for your use, please -;** contact the sales department at http://www.qtsoftware.com/contact. +;** contact the sales department at http://qt.nokia.com/contact. ;** $QT_END_LICENSE$ ;** ;****************************************************************************/ diff --git a/src/gui/painting/qdrawhelper_armv6_rvct.s b/src/gui/painting/qdrawhelper_armv6_rvct.s index 215bdaf..51b67a4 100644 --- a/src/gui/painting/qdrawhelper_armv6_rvct.s +++ b/src/gui/painting/qdrawhelper_armv6_rvct.s @@ -34,7 +34,7 @@ ;** met: http://www.gnu.org/copyleft/gpl.html. ;** ;** If you are unsure which license is appropriate for your use, please -;** contact the sales department at http://www.qtsoftware.com/contact. +;** contact the sales department at http://qt.nokia.com/contact. ;** $QT_END_LICENSE$ ;** ;****************************************************************************/ diff --git a/src/gui/painting/qregion_s60.cpp b/src/gui/painting/qregion_s60.cpp index 2d85f10..5600ece 100644 --- a/src/gui/painting/qregion_s60.cpp +++ b/src/gui/painting/qregion_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 714c9e8..622b8de 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/painting/qwindowsurface_s60_p.h b/src/gui/painting/qwindowsurface_s60_p.h index 54b2035..87dfd5e 100644 --- a/src/gui/painting/qwindowsurface_s60_p.h +++ b/src/gui/painting/qwindowsurface_s60_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 0efc5b4..2a88c9a 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index 7711b19..a03803b 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 680d787..2e661c0 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 45be2eb..85f0ae4 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 5ceb875..350ef51 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp index 4bc81f8..9541fe8 100644 --- a/src/gui/text/qfont_s60.cpp +++ b/src/gui/text/qfont_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 3fc3744..058041b 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index ebff9c8..eba21e8 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index a5bd0c8..0c1be8c 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp index 09411e1..f171390 100644 --- a/src/gui/util/qdesktopservices_s60.cpp +++ b/src/gui/util/qdesktopservices_s60.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/widgets/qactiontokeyeventmapper.cpp b/src/gui/widgets/qactiontokeyeventmapper.cpp index 0e1e1bb..cf4ffd2 100644 --- a/src/gui/widgets/qactiontokeyeventmapper.cpp +++ b/src/gui/widgets/qactiontokeyeventmapper.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/widgets/qactiontokeyeventmapper_p.h b/src/gui/widgets/qactiontokeyeventmapper_p.h index 57b81af..2cc1698 100644 --- a/src/gui/widgets/qactiontokeyeventmapper_p.h +++ b/src/gui/widgets/qactiontokeyeventmapper_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index b0cd7c8..e4079c5 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -33,7 +33,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/network/kernel/qnetworkinterface_symbian.cpp b/src/network/kernel/qnetworkinterface_symbian.cpp index 2ba5350..32b51b1 100644 --- a/src/network/kernel/qnetworkinterface_symbian.cpp +++ b/src/network/kernel/qnetworkinterface_symbian.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/s60/src/qdesktopservices_3_1.cpp b/src/plugins/s60/src/qdesktopservices_3_1.cpp index 508009c..a651c03 100644 --- a/src/plugins/s60/src/qdesktopservices_3_1.cpp +++ b/src/plugins/s60/src/qdesktopservices_3_1.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/s60/src/qdesktopservices_3_2.cpp b/src/plugins/s60/src/qdesktopservices_3_2.cpp index a2e8cce..fab1237 100644 --- a/src/plugins/s60/src/qdesktopservices_3_2.cpp +++ b/src/plugins/s60/src/qdesktopservices_3_2.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/s60/src/qlocale_3_1.cpp b/src/plugins/s60/src/qlocale_3_1.cpp index fb148ab..ed3c8ce 100644 --- a/src/plugins/s60/src/qlocale_3_1.cpp +++ b/src/plugins/s60/src/qlocale_3_1.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/s60/src/qlocale_3_2.cpp b/src/plugins/s60/src/qlocale_3_2.cpp index 087d29d..835f46b 100644 --- a/src/plugins/s60/src/qlocale_3_2.cpp +++ b/src/plugins/s60/src/qlocale_3_2.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/qt_libs.pro index cb03a05..7ce9597 100644 --- a/src/s60installs/qt_libs.pro +++ b/src/s60installs/qt_libs.pro @@ -40,10 +40,10 @@ symbian: { vendorinfo = \ "; Localised Vendor name" \ - "%{\"Nokia, Qt Software\"}" \ + "%{\"Nokia, Qt\"}" \ " " \ "; Unique Vendor name" \ - ":\"Nokia, Qt Software\"" \ + ":\"Nokia, Qt\"" \ " " diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp index e3ab46d..4112424 100644 --- a/src/s60main/qts60main.cpp +++ b/src/s60main/qts60main.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp index ae29260..c250b61 100644 --- a/src/s60main/qts60main_mcrt0.cpp +++ b/src/s60main/qts60main_mcrt0.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60main/qts60mainapplication.cpp b/src/s60main/qts60mainapplication.cpp index 52b15d6..11ade1b 100644 --- a/src/s60main/qts60mainapplication.cpp +++ b/src/s60main/qts60mainapplication.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60main/qts60mainapplication_p.h b/src/s60main/qts60mainapplication_p.h index b35b38e..0d662ff 100644 --- a/src/s60main/qts60mainapplication_p.h +++ b/src/s60main/qts60mainapplication_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60main/qts60mainappui.cpp b/src/s60main/qts60mainappui.cpp index 4567350..2f3d925 100644 --- a/src/s60main/qts60mainappui.cpp +++ b/src/s60main/qts60mainappui.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60main/qts60mainappui_p.h b/src/s60main/qts60mainappui_p.h index 943d61d..737dcda 100644 --- a/src/s60main/qts60mainappui_p.h +++ b/src/s60main/qts60mainappui_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60main/qts60maindocument.cpp b/src/s60main/qts60maindocument.cpp index 1fd3e3e..a42fe59 100644 --- a/src/s60main/qts60maindocument.cpp +++ b/src/s60main/qts60maindocument.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60main/qts60maindocument_p.h b/src/s60main/qts60maindocument_p.h index a7e1fd2..dfdac5f 100644 --- a/src/s60main/qts60maindocument_p.h +++ b/src/s60main/qts60maindocument_p.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/s60main/s60main.rss b/src/s60main/s60main.rss index b2998ac..e8b9abc 100644 --- a/src/s60main/s60main.rss +++ b/src/s60main/s60main.rss @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/exceptionsafety_objects/oomsimulator.h b/tests/auto/exceptionsafety_objects/oomsimulator.h index d765e5b..88d8039 100644 --- a/tests/auto/exceptionsafety_objects/oomsimulator.h +++ b/tests/auto/exceptionsafety_objects/oomsimulator.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 15c9cfb..8e40873 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp index 05f79e5..47675e0 100644 --- a/tests/auto/qinputcontext/tst_qinputcontext.cpp +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index 7f571a9..f206ad1 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/symbian/orientationchange/tst_orientationchange.cpp b/tests/auto/symbian/orientationchange/tst_orientationchange.cpp index 0f04118..480b748 100644 --- a/tests/auto/symbian/orientationchange/tst_orientationchange.cpp +++ b/tests/auto/symbian/orientationchange/tst_orientationchange.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp b/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp index 05e3054..ae70ce3 100644 --- a/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp +++ b/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/bld.inf b/util/s60pixelmetrics/bld.inf index fbb6475..0740cb3 100644 --- a/util/s60pixelmetrics/bld.inf +++ b/util/s60pixelmetrics/bld.inf @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pixel_metrics.cpp b/util/s60pixelmetrics/pixel_metrics.cpp index 1f01312..9d51ed9 100644 --- a/util/s60pixelmetrics/pixel_metrics.cpp +++ b/util/s60pixelmetrics/pixel_metrics.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pixel_metrics.h b/util/s60pixelmetrics/pixel_metrics.h index 1d3328b..d632860 100644 --- a/util/s60pixelmetrics/pixel_metrics.h +++ b/util/s60pixelmetrics/pixel_metrics.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pm_mapper.hrh b/util/s60pixelmetrics/pm_mapper.hrh index aa19e50..ab0cfb1 100644 --- a/util/s60pixelmetrics/pm_mapper.hrh +++ b/util/s60pixelmetrics/pm_mapper.hrh @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pm_mapper.mmp b/util/s60pixelmetrics/pm_mapper.mmp index f1c16ee..f2fc85a 100644 --- a/util/s60pixelmetrics/pm_mapper.mmp +++ b/util/s60pixelmetrics/pm_mapper.mmp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pm_mapper.rss b/util/s60pixelmetrics/pm_mapper.rss index fc85cbb..64a8352 100644 --- a/util/s60pixelmetrics/pm_mapper.rss +++ b/util/s60pixelmetrics/pm_mapper.rss @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pm_mapper_reg.rss b/util/s60pixelmetrics/pm_mapper_reg.rss index 93e88fa..fffd001 100644 --- a/util/s60pixelmetrics/pm_mapper_reg.rss +++ b/util/s60pixelmetrics/pm_mapper_reg.rss @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pm_mapperapp.cpp b/util/s60pixelmetrics/pm_mapperapp.cpp index 7db1297..790c568 100644 --- a/util/s60pixelmetrics/pm_mapperapp.cpp +++ b/util/s60pixelmetrics/pm_mapperapp.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pm_mapperapp.h b/util/s60pixelmetrics/pm_mapperapp.h index 022a999..5b71925 100644 --- a/util/s60pixelmetrics/pm_mapperapp.h +++ b/util/s60pixelmetrics/pm_mapperapp.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pm_mapperview.cpp b/util/s60pixelmetrics/pm_mapperview.cpp index dad22ec..b6c2d5c 100644 --- a/util/s60pixelmetrics/pm_mapperview.cpp +++ b/util/s60pixelmetrics/pm_mapperview.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60pixelmetrics/pm_mapperview.h b/util/s60pixelmetrics/pm_mapperview.h index 1d964c2..d986a43 100644 --- a/util/s60pixelmetrics/pm_mapperview.h +++ b/util/s60pixelmetrics/pm_mapperview.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60theme/main.cpp b/util/s60theme/main.cpp index cbb8c6f..72ac331 100644 --- a/util/s60theme/main.cpp +++ b/util/s60theme/main.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60theme/s60themeconvert.cpp b/util/s60theme/s60themeconvert.cpp index 7fcb43c..7d8452c 100644 --- a/util/s60theme/s60themeconvert.cpp +++ b/util/s60theme/s60themeconvert.cpp @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/util/s60theme/s60themeconvert.h b/util/s60theme/s60themeconvert.h index 667a10e..b31fffa 100644 --- a/util/s60theme/s60themeconvert.h +++ b/util/s60theme/s60themeconvert.h @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. +** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From 3ae4ebe921a318ba4474a6b0b9d76b1795d0719d Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Wed, 19 Aug 2009 10:27:54 +0200 Subject: Changig variable name from misleading fdexec to proper fdexception. --- src/network/socket/qnativesocketengine_unix.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index df9b7b4..1c77a37 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -897,9 +897,9 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co tv.tv_usec = (timeout % 1000) * 1000; #ifdef Q_OS_SYMBIAN - fd_set fdexec; - FD_ZERO(&fdexec); - FD_SET(socketDescriptor, &fdexec); + fd_set fdexception; + FD_ZERO(&fdexception); + FD_SET(socketDescriptor, &fdexception); #endif int retval; @@ -907,13 +907,13 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co #ifndef Q_OS_SYMBIAN retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv); #else - retval = qt_safe_select(socketDescriptor + 1, &fds, 0, &fdexec, timeout < 0 ? 0 : &tv); + retval = qt_safe_select(socketDescriptor + 1, &fds, 0, &fdexception, timeout < 0 ? 0 : &tv); #endif else #ifndef Q_OS_SYMBIAN retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv); #else - retval = qt_safe_select(socketDescriptor + 1, 0, &fds, &fdexec, timeout < 0 ? 0 : &tv); + retval = qt_safe_select(socketDescriptor + 1, 0, &fds, &fdexception, timeout < 0 ? 0 : &tv); #endif @@ -923,10 +923,10 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co if(retval < 0) { qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor); } - selectForExec = FD_ISSET(socketDescriptor, &fdexec); + selectForExec = FD_ISSET(socketDescriptor, &fdexception); } if(selectForExec) { - qWarning("nativeSelect (selectForRead %d, retVal %d, errno %d) Unexpected expectfds ready in fd %d", + qWarning("nativeSelect (selectForRead %d, retVal %d, errno %d) Unexpected exception for fd %d", selectForRead, retval, errno, socketDescriptor); } #endif @@ -948,9 +948,9 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c FD_SET(socketDescriptor, &fdwrite); #ifdef Q_OS_SYMBIAN - fd_set fdexec; - FD_ZERO(&fdexec); - FD_SET(socketDescriptor, &fdexec); + fd_set fdexception; + FD_ZERO(&fdexception); + FD_SET(socketDescriptor, &fdexception); #endif struct timeval tv; @@ -965,13 +965,13 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c timer.start(); do { - ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, &fdexec, timeout < 0 ? 0 : &tv); + ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, &fdexception, timeout < 0 ? 0 : &tv); bool selectForExec = false; if(ret != 0) { if(ret < 0) { qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor); } - selectForExec = FD_ISSET(socketDescriptor, &fdexec); + selectForExec = FD_ISSET(socketDescriptor, &fdexception); } if(selectForExec) { qWarning("nativeSelect (checkRead %d, checkWrite %d, ret %d, errno %d): Unexpected expectfds ready in fd %d", -- cgit v0.12 From e7b85ede7327c7ca928f07a211ed98bd3706567f Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 19 Aug 2009 10:44:18 +0200 Subject: Did some cleanups after review of the S60 branch. RevBy: Trust me It's all comments and build fixes. --- src/corelib/global/qglobal.cpp | 9 +++++---- src/corelib/global/qglobal.h | 17 ++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 73431e0..c4fbc49 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1169,9 +1169,9 @@ bool qSharedBuild() QSysInfo::symbianVersion() function gives the version of the system on which the application is run. - \value SV_9_2 Symbian OS 9.2 - \value SV_9_3 Symbian OS 9.3 - \value SV_9_4 Symbian OS 9.4 + \value SV_9_2 Symbian OS v9.2 + \value SV_9_3 Symbian OS v9.3 + \value SV_9_4 Symbian OS v9.4 \value SV_Unknown An unknown and currently unsupported platform \sa S60Version, WinVersion, MacVersion @@ -2189,7 +2189,8 @@ void qt_message_output(QtMsgType msgType, const char *buf) TPtrC8 ptr(reinterpret_cast(buf)); TInt len = Min(tmp.MaxLength(), ptr.Length()); tmp.Copy(ptr.Left(len)); - User::Panic(tmp, 0); // Panic the current thread + // Panic the current thread. We don't use real panic codes, so 0 has no special meaning. + User::Panic(tmp, 0); #elif (defined(Q_OS_UNIX) || defined(Q_CC_MINGW)) abort(); // trap; generates core dump #else diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 36dd863..244161d 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -186,7 +186,6 @@ namespace QT_NAMESPACE {} #elif defined(__SYMBIAN32__) || defined(SYMBIAN) # define Q_OS_SYMBIAN # define Q_NO_POSIX_SIGNALS -// TODO: should this be in qconfig.h # define QT_NO_GETIFADDRS #elif defined(__CYGWIN__) # define Q_OS_CYGWIN @@ -726,7 +725,6 @@ namespace QT_NAMESPACE {} #elif defined(__WINSCW__) && !defined(Q_CC_NOKIAX86) # define Q_CC_NOKIAX86 -// # define Q_CC_MWERKS // May be required #else @@ -1156,9 +1154,7 @@ class QDataStream; #define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE)) #ifndef Q_DECL_EXPORT -# ifdef Q_OS_WIN -# define Q_DECL_EXPORT __declspec(dllexport) -# elif defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) +# if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) # define Q_DECL_EXPORT __declspec(dllexport) # elif defined(QT_VISIBILITY_AVAILABLE) # define Q_DECL_EXPORT __attribute__((visibility("default"))) @@ -1168,9 +1164,7 @@ class QDataStream; # endif #endif #ifndef Q_DECL_IMPORT -# if defined(Q_OS_WIN) -# define Q_DECL_IMPORT __declspec(dllimport) -# elif defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) +# if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) # define Q_DECL_IMPORT __declspec(dllimport) # else # define Q_DECL_IMPORT @@ -1178,7 +1172,7 @@ class QDataStream; #endif /* - Create Qt DLL if QT_DLL is defined (Windows only) + Create Qt DLL if QT_DLL is defined (Windows and Symbian only) */ #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) @@ -1546,6 +1540,11 @@ inline void qUnused(T &x) { (void)x; } Debugging and error handling */ +/* + On Symbian we do not know beforehand whether we are compiling in + release or debug mode, so check the Symbian build define here, + and set the QT_NO_DEBUG define appropriately. +*/ #if defined(Q_OS_SYMBIAN) && defined(NDEBUG) && !defined(QT_NO_DEBUG) # define QT_NO_DEBUG #endif -- cgit v0.12 From 9addeea6f35a7f1b1c20d818dd022ed64086a6a2 Mon Sep 17 00:00:00 2001 From: mread Date: Wed, 19 Aug 2009 09:49:19 +0100 Subject: renamed and restyled exit info printer --- src/corelib/arch/symbian/qatomic_symbian.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/corelib/arch/symbian/qatomic_symbian.cpp b/src/corelib/arch/symbian/qatomic_symbian.cpp index b08a468..e418c09 100644 --- a/src/corelib/arch/symbian/qatomic_symbian.cpp +++ b/src/corelib/arch/symbian/qatomic_symbian.cpp @@ -44,33 +44,40 @@ #include -// Heap and handle info printer. This code is placed here as it happens to make it the very last static to be destroyed in a Qt app. +QT_BEGIN_NAMESPACE + +// Heap and handle info printer. // This way we can report on heap cells and handles that are really not owned by anything which still exists. // This information can be used to detect whether memory leaks are happening, particularly if these numbers grow as the app is used more. -struct SPrintExitInfo +// This code is placed here as it happens to make it the very last static to be destroyed in a Qt app. The +// reason assumed is that this file appears before any other file declaring static data in the generated +// Symbian MMP file. This particular file was chosen as it is the earliest symbian specific file. +struct QSymbianPrintExitInfo { - SPrintExitInfo() + QSymbianPrintExitInfo() { - RThread().HandleCount(initProcessHandleCount,initThreadHandleCount); + RThread().HandleCount(initProcessHandleCount, initThreadHandleCount); initCells = User::CountAllocCells(); } - ~SPrintExitInfo() + ~QSymbianPrintExitInfo() { RProcess myProc; TFullName fullName = myProc.FileName(); TInt cells = User::CountAllocCells(); TInt processHandleCount=0; TInt threadHandleCount=0; - RThread().HandleCount(processHandleCount,threadHandleCount); + RThread().HandleCount(processHandleCount, threadHandleCount); RDebug::Print(_L("%S exiting with %d allocated cells, %d handles"), - &fullName, - cells - initCells, - (processHandleCount + threadHandleCount) - (initProcessHandleCount + initThreadHandleCount)); + &fullName, + cells - initCells, + (processHandleCount + threadHandleCount) - (initProcessHandleCount + initThreadHandleCount)); } TInt initCells; TInt initProcessHandleCount; TInt initThreadHandleCount; -} printExitInfo; +} symbian_printExitInfo; + +QT_END_NAMESPACE #if defined(Q_CC_RVCT) -- cgit v0.12 From ac5bcbd221416ec28c9bcf82c6689f35b3a14f00 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Wed, 19 Aug 2009 10:59:30 +0200 Subject: This was bug as EINPROGRESS and EAGAIN are not the same thing. --- src/network/socket/qlocalsocket_unix.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 2cf8ef6..9211d63 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -306,7 +306,6 @@ void QLocalSocketPrivate::_q_connectToSocket() case ETIMEDOUT: errorOccurred(QLocalSocket::SocketTimeoutError, function); break; - case EINPROGRESS: case EAGAIN: // Try again later, all of the sockets listening are full if (!delayConnect) { -- 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 b3a3652abbf1cb4ebba6c6257ecf47f8dc022d93 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Wed, 19 Aug 2009 11:20:15 +0200 Subject: Fixing the build break. --- src/network/socket/qnativesocketengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 1c77a37..4388382 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -610,7 +610,7 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const // the data written to udpMessagePeekBuffer is discarded, so // this function is still reentrant although it might not look // so. - recvResult = qt_socket_recv(socketDescriptor, udpMessagePeekBuffer.data(), + recvResult = ::recv(socketDescriptor, udpMessagePeekBuffer.data(), udpMessagePeekBuffer.size(), MSG_PEEK); if (recvResult == -1 && errno == EINTR) continue; -- cgit v0.12 From a6a2daf14c3ab6d2ab6cb68e4a3a7809df33ea66 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 19 Aug 2009 12:27:01 +0300 Subject: Trivial fixes for src/plugins/imageformats after review. Reviewed-by: TrustMe --- src/plugins/imageformats/jpeg/jpeg.pro | 5 +++-- src/plugins/imageformats/mng/mng.pro | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro index f8893a0..ebc79cc 100644 --- a/src/plugins/imageformats/jpeg/jpeg.pro +++ b/src/plugins/imageformats/jpeg/jpeg.pro @@ -14,7 +14,9 @@ wince*: { } symbian: { - QMAKE_CXXFLAGS.CW += -W nounusedarg + #Disable warnings in 3rdparty code due to unused arguments + QMAKE_CXXFLAGS.CW += -W nounusedarg + TARGET.UID3=0x2001E61B } contains(QT_CONFIG, system-jpeg) { @@ -76,4 +78,3 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target -symbian:TARGET.UID3=0x2001E61B diff --git a/src/plugins/imageformats/mng/mng.pro b/src/plugins/imageformats/mng/mng.pro index e391ebc..de7dfa7 100644 --- a/src/plugins/imageformats/mng/mng.pro +++ b/src/plugins/imageformats/mng/mng.pro @@ -8,7 +8,9 @@ SOURCES += main.cpp \ qmnghandler.cpp symbian: { - QMAKE_CXXFLAGS.CW += -W nounused + #Disable warnings in 3rdparty code due to unused variables and arguments + QMAKE_CXXFLAGS.CW += -W nounused + TARGET.UID3=0x2001E619 } contains(QT_CONFIG, system-mng) { @@ -52,4 +54,3 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/imageformats target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target -symbian:TARGET.UID3=0x2001E619 -- cgit v0.12 From 783ab1980c9085308aa1defb1cfc2939a2c5f387 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 19 Aug 2009 11:07:54 +0200 Subject: Import the raycasting demo. Originally it was published in Qt Labs: http://labs.trolltech.com/blogs/2009/08/09/ray-casting-on-qts60/ Reviewed-by: Jason Barron --- demos/embedded/fluidlauncher/config_s60/config.xml | 1 + .../fluidlauncher/screenshots/raycasting.png | Bin 0 -> 43006 bytes demos/embedded/raycasting/raycasting.cpp | 310 +++++++++++++++++++++ demos/embedded/raycasting/raycasting.pro | 3 + demos/embedded/raycasting/raycasting.qrc | 5 + demos/embedded/raycasting/textures.png | Bin 0 -> 42319 bytes 6 files changed, 319 insertions(+) create mode 100644 demos/embedded/fluidlauncher/screenshots/raycasting.png create mode 100644 demos/embedded/raycasting/raycasting.cpp create mode 100644 demos/embedded/raycasting/raycasting.pro create mode 100644 demos/embedded/raycasting/raycasting.qrc create mode 100644 demos/embedded/raycasting/textures.png diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index 95e96bd..92cbebd 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -14,6 +14,7 @@ + diff --git a/demos/embedded/fluidlauncher/screenshots/raycasting.png b/demos/embedded/fluidlauncher/screenshots/raycasting.png new file mode 100644 index 0000000..d3c86e9 Binary files /dev/null and b/demos/embedded/fluidlauncher/screenshots/raycasting.png differ diff --git a/demos/embedded/raycasting/raycasting.cpp b/demos/embedded/raycasting/raycasting.cpp new file mode 100644 index 0000000..7d61c4f --- /dev/null +++ b/demos/embedded/raycasting/raycasting.cpp @@ -0,0 +1,310 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define WORLD_SIZE 8 +int world_map[WORLD_SIZE][WORLD_SIZE] = { + { 1, 1, 1, 1, 6, 1, 1, 1 }, + { 1, 0, 0, 1, 0, 0, 0, 7 }, + { 1, 1, 0, 1, 0, 1, 1, 1 }, + { 6, 0, 0, 0, 0, 0, 0, 3 }, + { 1, 8, 8, 0, 8, 0, 8, 1 }, + { 2, 2, 0, 0, 8, 8, 7, 1 }, + { 3, 0, 0, 0, 0, 0, 0, 5 }, + { 2, 2, 2, 2, 7, 4, 4, 4 }, +}; + +#define TEXTURE_SIZE 64 +#define TEXTURE_BLOCK (TEXTURE_SIZE * TEXTURE_SIZE) + +class Raycasting: public QWidget +{ +public: + Raycasting(QWidget *parent = 0) + : QWidget(parent) + , angle(0.5) + , playerPos(1.5, 1.5) + , angleDelta(0) + , moveDelta(0) { + + // http://www.areyep.com/RIPandMCS-TextureLibrary.html + textureImg.load(":/textures.png"); + textureImg = textureImg.convertToFormat(QImage::Format_ARGB32); + Q_ASSERT(textureImg.width() == TEXTURE_SIZE * 2); + Q_ASSERT(textureImg.bytesPerLine() == 4 * TEXTURE_SIZE * 2); + textureCount = textureImg.height() / TEXTURE_SIZE; + + watch.start(); + ticker.start(25, this); + setAttribute(Qt::WA_OpaquePaintEvent, true); + } + + void updatePlayer() { + int interval = qBound(20, watch.elapsed(), 250); + watch.start(); + angle += angleDelta * interval / 1000; + qreal step = moveDelta * interval / 1000; + qreal dx = cos(angle) * step; + qreal dy = sin(angle) * step; + QPointF pos = playerPos + 3 * QPointF(dx, dy); + int xi = static_cast(pos.x()); + int yi = static_cast(pos.y()); + if (world_map[yi][xi] == 0) + playerPos = playerPos + QPointF(dx, dy); + } + + void showFps() { + static QTime frameTick; + static int totalFrame = 0; + if (!(totalFrame & 31)) { + int elapsed = frameTick.elapsed(); + frameTick.start(); + int fps = 32 * 1000 / (1 + elapsed); + setWindowTitle(QString("Raycasting (%1 FPS)").arg(fps)); + } + totalFrame++; + } + + void render() { + + // setup the screen surface + if (buffer.size() != size()) + buffer = QImage(size(), QImage::Format_ARGB32); + int bufw = buffer.width(); + int bufh = buffer.height(); + + // we intentionally cheat here, to avoid detach + const uchar *ptr = buffer.bits(); + QRgb *start = (QRgb*)(ptr); + QRgb stride = buffer.bytesPerLine() / 4; + QRgb *finish = start + stride * bufh; + + // prepare the texture pointer + const uchar *src = textureImg.bits(); + const QRgb *texsrc = reinterpret_cast(src); + + // cast all rays here + qreal sina = sin(angle); + qreal cosa = cos(angle); + qreal u = cosa - sina; + qreal v = sina + cosa; + qreal du = 2 * sina / bufw; + qreal dv = -2 * cosa / bufw; + + for (int ray = 0; ray < bufw; ++ray, u += du, v += dv) { + // everytime this ray advances 'u' units in x direction, + // it also advanced 'v' units in y direction + qreal uu = (u < 0) ? -u : u; + qreal vv = (v < 0) ? -v : v; + qreal duu = 1 / uu; + qreal dvv = 1 / vv; + int stepx = (u < 0) ? -1 : 1; + int stepy = (v < 0) ? -1 : 1; + + // the cell in the map that we need to check + qreal px = playerPos.x(); + qreal py = playerPos.y(); + int mapx = static_cast(px); + int mapy = static_cast(py); + + // the position and texture for the hit + int texture = 0; + qreal hitdist = 0.1; + qreal texofs = 0; + bool dark = false; + + // first hit at constant x and constant y lines + qreal distx = (u > 0) ? (mapx + 1 - px) * duu : (px - mapx) * duu; + qreal disty = (v > 0) ? (mapy + 1 - py) * dvv : (py - mapy) * dvv; + + // loop until we hit something + while (texture <= 0) { + if (distx > disty) { + // shorter distance to a hit in constant y line + hitdist = disty; + disty += dvv; + mapy += stepy; + texture = world_map[mapy][mapx]; + if (texture > 0) { + dark = true; + if (stepy > 0) { + qreal ofs = px + u * (mapy - py) / v; + texofs = ofs - floor(ofs); + } else { + qreal ofs = px + u * (mapy + 1 - py) / v; + texofs = ofs - floor(ofs); + } + } + } else { + // shorter distance to a hit in constant x line + hitdist = distx; + distx += duu; + mapx += stepx; + texture = world_map[mapy][mapx]; + if (texture > 0) { + if (stepx > 0) { + qreal ofs = py + v * (mapx - px) / u; + texofs = ofs - floor(ofs); + } else { + qreal ofs = py + v * (mapx + 1 - px) / u; + texofs = ceil(ofs) - ofs; + } + } + } + } + + // get the texture, note that the texture image + // has two textures horizontally, "normal" vs "dark" + int col = static_cast(texofs * TEXTURE_SIZE); + col = qBound(0, col, TEXTURE_SIZE - 1); + texture = (texture - 1) % textureCount; + const QRgb *tex = texsrc + TEXTURE_BLOCK * texture * 2 + + (TEXTURE_SIZE * 2 * col); + if (dark) + tex += TEXTURE_SIZE; + + // start from the texture center (horizontally) + int h = static_cast(bufw / hitdist / 2); + int dy = (TEXTURE_SIZE << 12) / h; + int p1 = ((TEXTURE_SIZE / 2) << 12) - dy; + int p2 = p1 + dy; + + // start from the screen center (vertically) + // y1 will go up (decrease), y2 will go down (increase) + int y1 = bufh / 2; + int y2 = y1 + 1; + QRgb *pixel1 = start + y1 * stride + ray; + QRgb *pixel2 = pixel1 + stride; + + // map the texture to the sliver + while (y1 >= 0 && y2 < bufh && p1 >= 0) { + *pixel1 = tex[p1 >> 12]; + *pixel2 = tex[p2 >> 12]; + p1 -= dy; + p2 += dy; + --y1; + ++y2; + pixel1 -= stride; + pixel2 += stride; + } + + // ceiling and floor + for (; pixel1 > start; pixel1 -= stride) + *pixel1 = qRgb(0, 0, 0); + for (; pixel2 < finish; pixel2 += stride) + *pixel2 = qRgb(96, 96, 96); + } + + update(); + } + +protected: + + void timerEvent(QTimerEvent*) { + updatePlayer(); + render(); + showFps(); + } + + void paintEvent(QPaintEvent *event) { + QPainter p(this); + p.drawImage(event->rect(), buffer, event->rect()); + } + + void keyPressEvent(QKeyEvent *event) { + event->accept(); + if (event->key() == Qt::Key_Left) + angleDelta = 1.3 * M_PI; + if (event->key() == Qt::Key_Right) + angleDelta = -1.3 * M_PI; + if (event->key() == Qt::Key_Up) + moveDelta = 2.5; + if (event->key() == Qt::Key_Down) + moveDelta = -2.5; + } + + void keyReleaseEvent(QKeyEvent *event) { + event->accept(); + if (event->key() == Qt::Key_Left) + angleDelta = (angleDelta > 0) ? 0 : angleDelta; + if (event->key() == Qt::Key_Right) + angleDelta = (angleDelta < 0) ? 0 : angleDelta; + if (event->key() == Qt::Key_Up) + moveDelta = (moveDelta > 0) ? 0 : moveDelta; + if (event->key() == Qt::Key_Down) + moveDelta = (moveDelta < 0) ? 0 : moveDelta; + } + +private: + QTime watch; + QBasicTimer ticker; + QImage buffer; + qreal angle; + QPointF playerPos; + qreal angleDelta; + qreal moveDelta; + QImage textureImg; + int textureCount; +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + Raycasting w; + w.setWindowTitle("Raycasting"); +#if defined(Q_OS_SYMBIAN) + w.showMaximized(); +#else + w.resize(640, 480); + w.show(); +#endif + + return app.exec(); +} diff --git a/demos/embedded/raycasting/raycasting.pro b/demos/embedded/raycasting/raycasting.pro new file mode 100644 index 0000000..dae9412 --- /dev/null +++ b/demos/embedded/raycasting/raycasting.pro @@ -0,0 +1,3 @@ +TEMPLATE = app +SOURCES = raycasting.cpp +RESOURCES += raycasting.qrc diff --git a/demos/embedded/raycasting/raycasting.qrc b/demos/embedded/raycasting/raycasting.qrc new file mode 100644 index 0000000..974a060 --- /dev/null +++ b/demos/embedded/raycasting/raycasting.qrc @@ -0,0 +1,5 @@ + + + textures.png + + diff --git a/demos/embedded/raycasting/textures.png b/demos/embedded/raycasting/textures.png new file mode 100644 index 0000000..839488b Binary files /dev/null and b/demos/embedded/raycasting/textures.png differ -- cgit v0.12 From 9ba33f657acaa766a312a0f655ff722fe8c04469 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 19 Aug 2009 12:06:00 +0200 Subject: Let's build the ray casting demo. Reviewed-by: TrustMe --- demos/embedded/embedded.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index f876dc1..f5315f2 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS = styledemo +SUBDIRS = styledemo raycasting contains(QT_CONFIG, svg) { SUBDIRS += embeddedsvgviewer \ -- cgit v0.12 From 7e7fda589b86113e07953ed3a9a9a610b85f7987 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 19 Aug 2009 11:50:13 +0200 Subject: Import OpenStreetMap example. Originally it was published in Qt Labs: http://labs.trolltech.com/blogs/2009/08/04/openstreetmap-and-qt-and-s60/ Reviewed-by: Jason Barron --- demos/embedded/embedded.pro | 4 + demos/embedded/fluidlauncher/config_s60/config.xml | 1 + .../fluidlauncher/screenshots/lightmaps.png | Bin 0 -> 114178 bytes demos/embedded/lightmaps/lightmaps.cpp | 575 +++++++++++++++++++++ demos/embedded/lightmaps/lightmaps.pro | 10 + 5 files changed, 590 insertions(+) create mode 100644 demos/embedded/fluidlauncher/screenshots/lightmaps.png create mode 100644 demos/embedded/lightmaps/lightmaps.cpp create mode 100644 demos/embedded/lightmaps/lightmaps.pro diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index f5315f2..2af64c7 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -7,6 +7,10 @@ contains(QT_CONFIG, svg) { !vxworks:!qnx:SUBDIRS += fluidlauncher } +contains(QT_CONFIG, network) { + SUBDIRS += lightmaps +} + contains(QT_CONFIG, webkit) { SUBDIRS += anomaly } diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index 92cbebd..be4f016 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -15,6 +15,7 @@ + diff --git a/demos/embedded/fluidlauncher/screenshots/lightmaps.png b/demos/embedded/fluidlauncher/screenshots/lightmaps.png new file mode 100644 index 0000000..7cbe2e4 Binary files /dev/null and b/demos/embedded/fluidlauncher/screenshots/lightmaps.png differ diff --git a/demos/embedded/lightmaps/lightmaps.cpp b/demos/embedded/lightmaps/lightmaps.cpp new file mode 100644 index 0000000..fdb86fd --- /dev/null +++ b/demos/embedded/lightmaps/lightmaps.cpp @@ -0,0 +1,575 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#if defined (Q_OS_SYMBIAN) +#include "sym_iap_util.h" +#endif + +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +// how long (milliseconds) the user need to hold (after a tap on the screen) +// before triggering the magnifying glass feature +// 701, a prime number, is the sum of 229, 233, 239 +// (all three are also prime numbers, consecutive!) +#define HOLD_TIME 701 + +// maximum size of the magnifier +// Hint: see above to find why I picked this one :) +#define MAX_MAGNIFIER 229 + +uint qHash(const QPoint& p) +{ + return p.x() * 17 ^ p.y(); +} + +// tile size in pixels +const int tdim = 256; + +QPointF tileForCoordinate(qreal lat, qreal lng, int zoom) +{ + qreal zn = static_cast(1 << zoom); + qreal tx = (lng + 180.0) / 360.0; + qreal ty = (1.0 - log(tan(lat * M_PI / 180.0) + + 1.0 / cos(lat * M_PI / 180.0)) / M_PI) / 2.0; + return QPointF(tx * zn, ty * zn); +} + +qreal longitudeFromTile(qreal tx, int zoom) +{ + qreal zn = static_cast(1 << zoom); + qreal lat = tx / zn * 360.0 - 180.0; + return lat; +} + +qreal latitudeFromTile(qreal ty, int zoom) +{ + qreal zn = static_cast(1 << zoom); + qreal n = M_PI - 2 * M_PI * ty / zn; + qreal lng = 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n))); + return lng; +} + +class SlippyMap: public QObject +{ + Q_OBJECT + +public: + int width; + int height; + int zoom; + qreal latitude; + qreal longitude; + + SlippyMap(QObject *parent = 0) + : QObject(parent) + , width(400) + , height(300) + , zoom(15) + , latitude(59.9138204) + , longitude(10.7387413) { + m_emptyTile = QPixmap(tdim, tdim); + m_emptyTile.fill(Qt::lightGray); + + QNetworkDiskCache *cache = new QNetworkDiskCache; + cache->setCacheDirectory(QDesktopServices::storageLocation + (QDesktopServices::CacheLocation)); + m_manager.setCache(cache); + connect(&m_manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleNetworkData(QNetworkReply*))); + } + + void invalidate() { + if (width <= 0 || height <= 0) + return; + + QPointF ct = tileForCoordinate(latitude, longitude, zoom); + qreal tx = ct.x(); + qreal ty = ct.y(); + + // top-left corner of the center tile + int xp = width / 2 - (tx - floor(tx)) * tdim; + int yp = height / 2 - (ty - floor(ty)) * tdim; + + // first tile vertical and horizontal + int xa = (xp + tdim - 1) / tdim; + int ya = (yp + tdim - 1) / tdim; + int xs = static_cast(tx) - xa; + int ys = static_cast(ty) - ya; + + // offset for top-left tile + m_offset = QPoint(xp - xa * tdim, yp - ya * tdim); + + // last tile vertical and horizontal + int xe = static_cast(tx) + (width - xp - 1) / tdim; + int ye = static_cast(ty) + (height - yp - 1) / tdim; + + // build a rect + m_tilesRect = QRect(xs, ys, xe - xs + 1, ye - ys + 1); + + if (m_url.isEmpty()) + download(); + + emit updated(QRect(0, 0, width, height)); + } + + void render(QPainter *p, const QRect &rect) { + for (int x = 0; x <= m_tilesRect.width(); ++x) + for (int y = 0; y <= m_tilesRect.height(); ++y) { + QPoint tp(x + m_tilesRect.left(), y + m_tilesRect.top()); + QRect box = tileRect(tp); + if (rect.intersects(box)) { + if (m_tilePixmaps.contains(tp)) + p->drawPixmap(box, m_tilePixmaps.value(tp)); + else + p->drawPixmap(box, m_emptyTile); + } + } + } + + void pan(const QPoint &delta) { + QPointF dx = QPointF(delta) / qreal(tdim); + QPointF center = tileForCoordinate(latitude, longitude, zoom) - dx; + latitude = latitudeFromTile(center.y(), zoom); + longitude = longitudeFromTile(center.x(), zoom); + invalidate(); + } + +private slots: + + void handleNetworkData(QNetworkReply *reply) { + QImage img; + QPoint tp = reply->request().attribute(QNetworkRequest::User).toPoint(); + QUrl url = reply->url(); + if (!reply->error()) + if (!img.load(reply, 0)) + img = QImage(); + reply->deleteLater(); + m_tilePixmaps[tp] = QPixmap::fromImage(img); + if (img.isNull()) + m_tilePixmaps[tp] = m_emptyTile; + emit updated(tileRect(tp)); + + // purge unused spaces + QRect bound = m_tilesRect.adjusted(-2, -2, 2, 2); + foreach(QPoint tp, m_tilePixmaps.keys()) + if (!bound.contains(tp)) + m_tilePixmaps.remove(tp); + + download(); + } + + void download() { + QPoint grab(0, 0); + for (int x = 0; x <= m_tilesRect.width(); ++x) + for (int y = 0; y <= m_tilesRect.height(); ++y) { + QPoint tp = m_tilesRect.topLeft() + QPoint(x, y); + if (!m_tilePixmaps.contains(tp)) { + grab = tp; + break; + } + } + if (grab == QPoint(0, 0)) { + m_url = QUrl(); + return; + } + + QString path = "http://tile.openstreetmap.org/%1/%2/%3.png"; + m_url = QUrl(path.arg(zoom).arg(grab.x()).arg(grab.y())); + QNetworkRequest request; + request.setUrl(m_url); + request.setRawHeader("User-Agent", "Nokia (Qt) Graphics Dojo 1.0"); + request.setAttribute(QNetworkRequest::User, QVariant(grab)); + m_manager.get(request); + } + +signals: + void updated(const QRect &rect); + +protected: + QRect tileRect(const QPoint &tp) { + QPoint t = tp - m_tilesRect.topLeft(); + int x = t.x() * tdim + m_offset.x(); + int y = t.y() * tdim + m_offset.y(); + return QRect(x, y, tdim, tdim); + } + +private: + QPoint m_offset; + QRect m_tilesRect; + QPixmap m_emptyTile; + QHash m_tilePixmaps; + QNetworkAccessManager m_manager; + QUrl m_url; +}; + +class LightMaps: public QWidget +{ + Q_OBJECT + +public: + LightMaps(QWidget *parent = 0) + : QWidget(parent) + , pressed(false) + , snapped(false) + , zoomed(false) + , invert(false) { + m_normalMap = new SlippyMap(this); + m_largeMap = new SlippyMap(this); + connect(m_normalMap, SIGNAL(updated(QRect)), SLOT(updateMap(QRect))); + connect(m_largeMap, SIGNAL(updated(QRect)), SLOT(update())); + } + + void setCenter(qreal lat, qreal lng) { + m_normalMap->latitude = lat; + m_normalMap->longitude = lng; + m_normalMap->invalidate(); + } + +public slots: + void toggleNightMode() { + invert = !invert; + update(); + } + +private slots: + void updateMap(const QRect &r) { + update(r); + } + +protected: + + void activateZoom() { + zoomed = true; + tapTimer.stop(); + m_largeMap->zoom = m_normalMap->zoom + 1; + m_largeMap->width = m_normalMap->width * 2; + m_largeMap->height = m_normalMap->height * 2; + m_largeMap->latitude = m_normalMap->latitude; + m_largeMap->longitude = m_normalMap->longitude; + m_largeMap->invalidate(); + update(); + } + + void resizeEvent(QResizeEvent *) { + m_normalMap->width = width(); + m_normalMap->height = height(); + m_normalMap->invalidate(); + } + + void paintEvent(QPaintEvent *event) { + QPainter p; + p.begin(this); + m_normalMap->render(&p, event->rect()); + p.setPen(Qt::black); +#if defined(Q_OS_SYMBIAN) + QFont font = p.font(); + font.setPixelSize(13); + p.setFont(font); +#endif + p.drawText(rect(), Qt::AlignBottom | Qt::TextWordWrap, + "Map data CCBYSA 2009 OpenStreetMap.org contributors"); + p.end(); + + if (zoomed) { + int dim = qMin(width(), height()); + int magnifierSize = qMin(MAX_MAGNIFIER, dim * 2 / 3); + int radius = magnifierSize / 2; + int ring = radius - 15; + QSize box = QSize(magnifierSize, magnifierSize); + + // reupdate our mask + if (maskPixmap.size() != box) { + maskPixmap = QPixmap(box); + maskPixmap.fill(Qt::transparent); + + QRadialGradient g; + g.setCenter(radius, radius); + g.setFocalPoint(radius, radius); + g.setRadius(radius); + g.setColorAt(1.0, QColor(255, 255, 255, 0)); + g.setColorAt(0.5, QColor(128, 128, 128, 255)); + + QPainter mask(&maskPixmap); + mask.setRenderHint(QPainter::Antialiasing); + mask.setCompositionMode(QPainter::CompositionMode_Source); + mask.setBrush(g); + mask.setPen(Qt::NoPen); + mask.drawRect(maskPixmap.rect()); + mask.setBrush(QColor(Qt::transparent)); + mask.drawEllipse(g.center(), ring, ring); + mask.end(); + } + + QPoint center = dragPos - QPoint(0, radius); + center = center + QPoint(0, radius / 2); + QPoint corner = center - QPoint(radius, radius); + + QPoint xy = center * 2 - QPoint(radius, radius); + + // only set the dimension to the magnified portion + if (zoomPixmap.size() != box) { + zoomPixmap = QPixmap(box); + zoomPixmap.fill(Qt::lightGray); + } + if (true) { + QPainter p(&zoomPixmap); + p.translate(-xy); + m_largeMap->render(&p, QRect(xy, box)); + p.end(); + } + + QPainterPath clipPath; + clipPath.addEllipse(center, ring, ring); + + QPainter p(this); + p.setRenderHint(QPainter::Antialiasing); + p.setClipPath(clipPath); + p.drawPixmap(corner, zoomPixmap); + p.setClipping(false); + p.drawPixmap(corner, maskPixmap); + p.setPen(Qt::gray); + p.drawPath(clipPath); + } + if (invert) { + QPainter p(this); + p.setCompositionMode(QPainter::CompositionMode_Difference); + p.fillRect(event->rect(), Qt::white); + p.end(); + } + } + + void timerEvent(QTimerEvent *) { + if (!zoomed) + activateZoom(); + update(); + } + + void mousePressEvent(QMouseEvent *event) { + if (event->buttons() != Qt::LeftButton) + return; + pressed = snapped = true; + pressPos = dragPos = event->pos(); + tapTimer.stop(); + tapTimer.start(HOLD_TIME, this); + } + + void mouseMoveEvent(QMouseEvent *event) { + if (!event->buttons()) + return; + if (!zoomed) { + if (!pressed || !snapped) { + QPoint delta = event->pos() - pressPos; + pressPos = event->pos(); + m_normalMap->pan(delta); + return; + } else { + const int threshold = 10; + QPoint delta = event->pos() - pressPos; + if (snapped) { + snapped &= delta.x() < threshold; + snapped &= delta.y() < threshold; + snapped &= delta.x() > -threshold; + snapped &= delta.y() > -threshold; + } + if (!snapped) + tapTimer.stop(); + } + } else { + dragPos = event->pos(); + update(); + } + } + + void mouseReleaseEvent(QMouseEvent *) { + zoomed = false; + update(); + } + + void keyPressEvent(QKeyEvent *event) { + if (!zoomed) { + if (event->key() == Qt::Key_Left) + m_normalMap->pan(QPoint(20, 0)); + if (event->key() == Qt::Key_Right) + m_normalMap->pan(QPoint(-20, 0)); + if (event->key() == Qt::Key_Up) + m_normalMap->pan(QPoint(0, 20)); + if (event->key() == Qt::Key_Down) + m_normalMap->pan(QPoint(0, -20)); + if (event->key() == Qt::Key_Z || event->key() == Qt::Key_Select) { + dragPos = QPoint(width() / 2, height() / 2); + activateZoom(); + } + } else { + if (event->key() == Qt::Key_Z || event->key() == Qt::Key_Select) { + zoomed = false; + update(); + } + QPoint delta(0, 0); + if (event->key() == Qt::Key_Left) + delta = QPoint(-15, 0); + if (event->key() == Qt::Key_Right) + delta = QPoint(15, 0); + if (event->key() == Qt::Key_Up) + delta = QPoint(0, -15); + if (event->key() == Qt::Key_Down) + delta = QPoint(0, 15); + if (delta != QPoint(0, 0)) { + dragPos += delta; + update(); + } + } + } + +private: + SlippyMap *m_normalMap; + SlippyMap *m_largeMap; + bool pressed; + bool snapped; + QPoint pressPos; + QPoint dragPos; + QBasicTimer tapTimer; + bool zoomed; + QPixmap zoomPixmap; + QPixmap maskPixmap; + bool invert; +}; + +class MapZoom : public QMainWindow +{ + Q_OBJECT + +private: + LightMaps *map; + +public: + MapZoom(): QMainWindow(0) { + map = new LightMaps(this); + setCentralWidget(map); + map->setFocus(); + + QAction *osloAction = new QAction("&Oslo", this); + QAction *berlinAction = new QAction("&Berlin", this); + QAction *jakartaAction = new QAction("&Jakarta", this); + QAction *nightModeAction = new QAction("Night Mode", this); + nightModeAction->setCheckable(true); + nightModeAction->setChecked(false); + QAction *osmAction = new QAction("About OpenStreetMap", this); + connect(osloAction, SIGNAL(triggered()), SLOT(chooseOslo())); + connect(berlinAction, SIGNAL(triggered()), SLOT(chooseBerlin())); + connect(jakartaAction, SIGNAL(triggered()), SLOT(chooseJakarta())); + connect(nightModeAction, SIGNAL(triggered()), map, SLOT(toggleNightMode())); + connect(osmAction, SIGNAL(triggered()), SLOT(aboutOsm())); + +#if defined(Q_OS_SYMBIAN) + menuBar()->addAction(osloAction); + menuBar()->addAction(berlinAction); + menuBar()->addAction(jakartaAction); + menuBar()->addAction(nightModeAction); + menuBar()->addAction(osmAction); +#else + QMenu *menu = menuBar()->addMenu("&Options"); + menu->addAction(osloAction); + menu->addAction(berlinAction); + menu->addAction(jakartaAction); + menu->addSeparator(); + menu->addAction(nightModeAction); + menu->addAction(osmAction); +#endif + + QTimer::singleShot(0, this, SLOT(delayedInit())); + } + +private slots: + + void delayedInit() { +#if defined(Q_OS_SYMBIAN) + qt_SetDefaultIap(); +#endif + } + + void chooseOslo() { + map->setCenter(59.9138204, 10.7387413); + } + + void chooseBerlin() { + map->setCenter(52.52958999943302, 13.383053541183472); + } + + void chooseJakarta() { + map->setCenter(-6.211544, 106.845172); + } + + void aboutOsm() { + QDesktopServices::openUrl(QUrl("http://www.openstreetmap.org")); + } +}; + + +#include "lightmaps.moc" + +int main(int argc, char **argv) +{ +#if defined(Q_WS_X11) + QApplication::setGraphicsSystem("raster"); +#endif + + QApplication app(argc, argv); + app.setApplicationName("LightMaps"); + + MapZoom w; + w.setWindowTitle("OpenStreetMap"); +#if defined(Q_OS_SYMBIAN) + w.showMaximized(); +#else + w.resize(600, 450); + w.show(); +#endif + + return app.exec(); +} diff --git a/demos/embedded/lightmaps/lightmaps.pro b/demos/embedded/lightmaps/lightmaps.pro new file mode 100644 index 0000000..e57d15d --- /dev/null +++ b/demos/embedded/lightmaps/lightmaps.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +SOURCES = lightmaps.cpp +QT += network + +symbian { + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock -lconnmon + TARGET.CAPABILITY = NetworkServices + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} -- cgit v0.12 From 35dcea3f7813c7aa5bdb6e85f6fa827fac741cb7 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 19 Aug 2009 13:14:02 +0300 Subject: Enabled contextmenu event for Symbian. In Symbian the context menu event is triggered after long press event is detected. This is equivalent to right mouse click on desktop environments. --- src/gui/kernel/qapplication_s60.cpp | 12 +++++++++--- src/gui/kernel/qt_s60_p.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 44ac380..00e16af 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -347,7 +347,13 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons | Qt::RightButton; QMouseEvent mEvent(QEvent::MouseButtonPress, alienWidget->mapFrom(qwidget, widgetPos), globalPos, Qt::RightButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier); - sendMouseEvent(alienWidget, &mEvent); + + bool res = sendMouseEvent(alienWidget, &mEvent); + +#if !defined(QT_NO_CONTEXTMENU) + QContextMenuEvent e2(QContextMenuEvent::Mouse, widgetPos, globalPos, mEvent.modifiers()); +#endif + m_previousEventLongTap = true; } @@ -444,9 +450,9 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) } } -void QSymbianControl::sendMouseEvent(QWidget *widget, QMouseEvent *mEvent) +bool QSymbianControl::sendMouseEvent(QWidget *widget, QMouseEvent *mEvent) { - qt_sendSpontaneousEvent(widget, mEvent); + return qt_sendSpontaneousEvent(widget, mEvent); } TKeyResponse QSymbianControl::OfferKeyEventL(const TKeyEvent& keyEvent, TEventCode type) diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 1ac6a8e..4d05f11 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -153,7 +153,7 @@ private: void HandlePointerEvent(const TPointerEvent& aPointerEvent); TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType); TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent); - void sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); + bool sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); private: -- cgit v0.12 From f8710c79adc55708a6484a0dcd3ce3d0ddd57284 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 19 Aug 2009 13:33:32 +0200 Subject: Cosmetic fix: Unify the Q_DISABLE_COPY macro Q_DISABLE_COPY must make the copy constructor and assignment operator private in all cases, otherwise the compiler will create implicit versions when exception support is on. --- src/corelib/global/qglobal.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index f38d7cc..6722418 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2337,16 +2337,9 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1); classes contains a private copy constructor and assignment operator to disable copying (the compiler gives an error message). */ - -#if !defined(Q_NO_DECLARED_NOT_DEFINED) || !defined(QT_MAKEDLL) -# define Q_DISABLE_COPY(Class) \ - Class(const Class &); \ - Class &operator=(const Class &); -#else -# define Q_DISABLE_COPY(Class) \ - Class(const Class &); \ - Class &operator=(const Class &); -#endif +#define Q_DISABLE_COPY(Class) \ + Class(const Class &); \ + Class &operator=(const Class &); class QByteArray; Q_CORE_EXPORT QByteArray qgetenv(const char *varName); -- cgit v0.12 From 38466376233e7bcbc208602dde704baf20ef0952 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 19 Aug 2009 13:38:05 +0200 Subject: Revert "The Metrowerks compiler was crashing when processing the following line in" This reverts commit e2e4f600970a3577db4bcb099c10e8241754bd56. Not needed anymore after the MWC compiler became unsupported. RevBy: Jason Barron --- src/tools/moc/preprocessor.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 6650a1b..b4cf578 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -515,12 +515,7 @@ void Preprocessor::substituteMacro(const MacroName ¯o, Symbols &substituted, Symbols saveSymbols = symbols; int saveIndex = index; - // This is a workaround for a compiler bug that did not like the QHash::value function that - // simply did: "return T();" This code should essentially do the same thing but declares the - // default instance outside and calls the other QHash::value() implementation that returns - // 'dummy' as the default value now. - Macro dummy; - symbols = macros.value(macro, dummy).symbols; + symbols = macros.value(macro).symbols; index = 0; safeset += macro; -- cgit v0.12 From a238c86219a2a16d1e417a4c75273c6d9c7faecc Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 19 Aug 2009 13:39:46 +0200 Subject: Revert "We don't need this library for the Metrowerks toolchain." This reverts commit 9a6eb12c26697330a5adf4450beb98098ad7da40. Not needed anymore after the MWC compiler became unsupported. RevBy: Jason Barron --- src/tools/bootstrap/bootstrap.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/bootstrap/bootstrap.pri b/src/tools/bootstrap/bootstrap.pri index 6261b30..b4f9b2f 100644 --- a/src/tools/bootstrap/bootstrap.pri +++ b/src/tools/bootstrap/bootstrap.pri @@ -55,7 +55,7 @@ hpux-acc*|hpuxi-acc* { unix:LIBS += -lz # win32:LIBS += libz.lib } -win32:!win32-mwc:LIBS += -luser32 +win32:LIBS += -luser32 mac { CONFIG -= incremental -- cgit v0.12 From fa246f93508147b4b2e582c61fbb60a0d7f881c3 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 19 Aug 2009 13:24:05 +0200 Subject: Import the flight info example. Originally it was published in Qt Labs: http://labs.trolltech.com/blogs/2009/07/26/track-your-flight-with-qts60/ Reviewed-by: Jason Barron --- demos/embedded/embedded.pro | 1 + demos/embedded/flightinfo/aircraft.png | Bin 0 -> 28713 bytes demos/embedded/flightinfo/flightinfo.cpp | 415 +++++++++++++++++++++ demos/embedded/flightinfo/flightinfo.pro | 12 + demos/embedded/flightinfo/flightinfo.qrc | 5 + demos/embedded/flightinfo/form.ui | 226 +++++++++++ demos/embedded/fluidlauncher/config_s60/config.xml | 1 + .../fluidlauncher/screenshots/flightinfo_s60.png | Bin 0 -> 24473 bytes 8 files changed, 660 insertions(+) create mode 100644 demos/embedded/flightinfo/aircraft.png create mode 100644 demos/embedded/flightinfo/flightinfo.cpp create mode 100644 demos/embedded/flightinfo/flightinfo.pro create mode 100644 demos/embedded/flightinfo/flightinfo.qrc create mode 100644 demos/embedded/flightinfo/form.ui create mode 100644 demos/embedded/fluidlauncher/screenshots/flightinfo_s60.png diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index 2af64c7..3fa0e13 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -9,6 +9,7 @@ contains(QT_CONFIG, svg) { contains(QT_CONFIG, network) { SUBDIRS += lightmaps + SUBDIRS += flightinfo } contains(QT_CONFIG, webkit) { diff --git a/demos/embedded/flightinfo/aircraft.png b/demos/embedded/flightinfo/aircraft.png new file mode 100644 index 0000000..0845cb4 Binary files /dev/null and b/demos/embedded/flightinfo/aircraft.png differ diff --git a/demos/embedded/flightinfo/flightinfo.cpp b/demos/embedded/flightinfo/flightinfo.cpp new file mode 100644 index 0000000..de3a9e9 --- /dev/null +++ b/demos/embedded/flightinfo/flightinfo.cpp @@ -0,0 +1,415 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#if defined (Q_OS_SYMBIAN) +#include "sym_iap_util.h" +#endif + +#include "ui_form.h" + +#define FLIGHTVIEW_URL "http://mobile.flightview.com/TrackByFlight.aspx" +#define FLIGHTVIEW_RANDOM "http://mobile.flightview.com/TrackSampleFlight.aspx" + +// strips all invalid constructs that might trip QXmlStreamReader +static QString sanitized(const QString &xml) +{ + QString data = xml; + + // anything up to the html tag + int i = data.indexOf(" 0) + data.remove(0, i - 1); + + // everything inside the head tag + i = data.indexOf(" 0) + data.remove(i, data.indexOf("") - i + 7); + + // invalid link for JavaScript code + while (true) { + i = data.indexOf("onclick=\"gotoUrl("); + if (i < 0) + break; + data.remove(i, data.indexOf('\"', i + 9) - i + 1); + } + + // all inline frames + while (true) { + i = data.indexOf("") - i + 8); + } + + // entities + data.remove(" "); + data.remove("©"); + + return data; +} + +class FlightInfo : public QMainWindow +{ + Q_OBJECT + +private: + + Ui_Form ui; + QUrl m_url; + QDate m_searchDate; + QPixmap m_map; + +public: + + FlightInfo(QMainWindow *parent = 0): QMainWindow(parent) { + + QWidget *w = new QWidget(this); + ui.setupUi(w); + setCentralWidget(w); + + ui.searchBar->hide(); + ui.infoBox->hide(); + connect(ui.searchButton, SIGNAL(clicked()), SLOT(startSearch())); + connect(ui.flightEdit, SIGNAL(returnPressed()), SLOT(startSearch())); + + setWindowTitle("Flight Info"); + QTimer::singleShot(0, this, SLOT(delayedInit())); + + // Rendered from the public-domain vectorized aircraft + // http://openclipart.org/media/people/Jarno + m_map = QPixmap(":/aircraft.png"); + + QAction *searchTodayAction = new QAction("Today's Flight", this); + QAction *searchYesterdayAction = new QAction("Yesterday's Flight", this); + QAction *randomAction = new QAction("Random Flight", this); + connect(searchTodayAction, SIGNAL(triggered()), SLOT(today())); + connect(searchYesterdayAction, SIGNAL(triggered()), SLOT(yesterday())); + connect(randomAction, SIGNAL(triggered()), SLOT(randomFlight())); +#if defined(Q_OS_SYMBIAN) + menuBar()->addAction(searchTodayAction); + menuBar()->addAction(searchYesterdayAction); + menuBar()->addAction(randomAction); +#else + addAction(searchTodayAction); + addAction(searchYesterdayAction); + addAction(randomAction); + setContextMenuPolicy(Qt::ActionsContextMenu); +#endif + } + +private slots: + void delayedInit() { +#if defined(Q_OS_SYMBIAN) + qt_SetDefaultIap(); +#endif + } + + + void handleNetworkData(QNetworkReply *networkReply) { + if (!networkReply->error()) { + // Assume UTF-8 encoded + QByteArray data = networkReply->readAll(); + QString xml = QString::fromUtf8(data); + digest(xml); + } + networkReply->deleteLater(); + networkReply->manager()->deleteLater(); + } + + void handleMapData(QNetworkReply *networkReply) { + if (!networkReply->error()) { + m_map.loadFromData(networkReply->readAll()); + update(); + } + networkReply->deleteLater(); + networkReply->manager()->deleteLater(); + } + + void today() { + QDateTime timestamp = QDateTime::currentDateTime(); + m_searchDate = timestamp.date(); + searchFlight(); + } + + void yesterday() { + QDateTime timestamp = QDateTime::currentDateTime(); + timestamp = timestamp.addDays(-1); + m_searchDate = timestamp.date(); + searchFlight(); + } + + void searchFlight() { + ui.searchBar->show(); + ui.infoBox->hide(); + ui.flightStatus->hide(); + ui.flightName->setText("Enter flight number"); + m_map = QPixmap(); + update(); + } + + void startSearch() { + ui.searchBar->hide(); + QString flight = ui.flightEdit->text().simplified(); + if (!flight.isEmpty()) + request(flight, m_searchDate); + } + + void randomFlight() { + request(QString(), QDate::currentDate()); + } + +public slots: + + void request(const QString &flightCode, const QDate &date) { + + setWindowTitle("Loading..."); + + QString code = flightCode.simplified(); + QString airlineCode = code.left(2).toUpper(); + QString flightNumber = code.mid(2, code.length()); + + ui.flightName->setText("Searching for " + code); + + m_url = QUrl(FLIGHTVIEW_URL); + m_url.addEncodedQueryItem("view", "detail"); + m_url.addEncodedQueryItem("al", QUrl::toPercentEncoding(airlineCode)); + m_url.addEncodedQueryItem("fn", QUrl::toPercentEncoding(flightNumber)); + m_url.addEncodedQueryItem("dpdat", QUrl::toPercentEncoding(date.toString("yyyyMMdd"))); + + if (code.isEmpty()) { + // random flight as sample + m_url = QUrl(FLIGHTVIEW_RANDOM); + ui.flightName->setText("Getting a random flight..."); + } + + QNetworkAccessManager *manager = new QNetworkAccessManager(this); + connect(manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleNetworkData(QNetworkReply*))); + manager->get(QNetworkRequest(m_url)); + } + + +private: + + void digest(const QString &content) { + + setWindowTitle("Flight Info"); + QString data = sanitized(content); + + // do we only get the flight list? + // we grab the first leg in the flight list + // then fetch another URL for the real flight info + int i = data.indexOf("a href=\"?view=detail"); + if (i > 0) { + QString href = data.mid(i, data.indexOf('\"', i + 8) - i + 1); + QRegExp regex("dpap=([A-Za-z0-9]+)"); + regex.indexIn(href); + QString airport = regex.cap(1); + m_url.addEncodedQueryItem("dpap", QUrl::toPercentEncoding(airport)); + QNetworkAccessManager *manager = new QNetworkAccessManager(this); + connect(manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleNetworkData(QNetworkReply*))); + manager->get(QNetworkRequest(m_url)); + return; + } + + QXmlStreamReader xml(data); + bool inFlightName = false; + bool inFlightStatus = false; + bool inFlightMap = false; + bool inFieldName = false; + bool inFieldValue = false; + + QString flightName; + QString flightStatus; + QStringList fieldNames; + QStringList fieldValues; + + while (!xml.atEnd()) { + xml.readNext(); + + if (xml.tokenType() == QXmlStreamReader::StartElement) { + QStringRef className = xml.attributes().value("class"); + inFlightName |= xml.name() == "h1"; + inFlightStatus |= className == "FlightDetailHeaderStatus"; + inFlightMap |= className == "flightMap"; + if (xml.name() == "td" && !className.isEmpty()) { + QString cn = className.toString(); + if (cn.contains("fieldTitle")) { + inFieldName = true; + fieldNames += QString(); + fieldValues += QString(); + } + if (cn.contains("fieldValue")) + inFieldValue = true; + } + if (xml.name() == "img" && inFlightMap) { + QString src = xml.attributes().value("src").toString(); + src.prepend("http://mobile.flightview.com"); + QUrl url = QUrl::fromPercentEncoding(src.toAscii()); + QNetworkAccessManager *manager = new QNetworkAccessManager(this); + connect(manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleMapData(QNetworkReply*))); + manager->get(QNetworkRequest(url)); + } + } + + if (xml.tokenType() == QXmlStreamReader::EndElement) { + inFlightName &= xml.name() != "h1"; + inFlightStatus &= xml.name() != "div"; + inFlightMap &= xml.name() != "div"; + inFieldName &= xml.name() != "td"; + inFieldValue &= xml.name() != "td"; + } + + if (xml.tokenType() == QXmlStreamReader::Characters) { + if (inFlightName) + flightName += xml.text(); + if (inFlightStatus) + flightStatus += xml.text(); + if (inFieldName) + fieldNames.last() += xml.text(); + if (inFieldValue) + fieldValues.last() += xml.text(); + } + } + + if (fieldNames.isEmpty()) { + QString code = ui.flightEdit->text().simplified().left(10); + QString msg = QString("Flight %1 is not found").arg(code); + ui.flightName->setText(msg); + return; + } + + ui.flightName->setText(flightName); + flightStatus.remove("Status: "); + ui.flightStatus->setText(flightStatus); + ui.flightStatus->show(); + + QStringList whiteList; + whiteList << "Departure"; + whiteList << "Arrival"; + whiteList << "Scheduled"; + whiteList << "Takeoff"; + whiteList << "Estimated"; + whiteList << "Term-Gate"; + + QString text; + text = QString("").arg(width() - 25); + for (int i = 0; i < fieldNames.count(); i++) { + QString fn = fieldNames[i].simplified(); + if (fn.endsWith(':')) + fn = fn.left(fn.length() - 1); + if (!whiteList.contains(fn)) + continue; + + QString fv = fieldValues[i].simplified(); + bool special = false; + special |= fn.startsWith("Departure"); + special |= fn.startsWith("Arrival"); + text += ""; + if (special) { + text += ""; + } else { + text += ""; + text += ""; + } + text += ""; + } + text += "
"; + text += "" + fv + ""; + text += ""; + text += fn; + text += " : "; + text += " "; + text += ""; + text += fv; + text += "
"; + ui.detailedInfo->setText(text); + ui.infoBox->show(); + } + + void resizeEvent(QResizeEvent *event) { + Q_UNUSED(event); + ui.detailedInfo->setMaximumWidth(width() - 25); + } + + void paintEvent(QPaintEvent *event) { + QMainWindow::paintEvent(event); + QPainter p(this); + p.fillRect(rect(), QColor(131, 171, 210)); + if (!m_map.isNull()) { + int x = (width() - m_map.width()) / 2; + int space = ui.infoBox->pos().y(); + if (!ui.infoBox->isVisible()) + space = height(); + int top = ui.titleBox->height(); + int y = qMax(top, (space - m_map.height()) / 2); + p.drawPixmap(x, y, m_map); + } + p.end(); + } + +}; + + +#include "flightinfo.moc" + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(flightinfo); + + QApplication app(argc, argv); + + FlightInfo w; +#if defined(Q_OS_SYMBIAN) + w.showMaximized(); +#else + w.resize(360, 504); + w.show(); +#endif + + return app.exec(); +} diff --git a/demos/embedded/flightinfo/flightinfo.pro b/demos/embedded/flightinfo/flightinfo.pro new file mode 100644 index 0000000..5edb175 --- /dev/null +++ b/demos/embedded/flightinfo/flightinfo.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +TARGET = flightinfo +SOURCES = flightinfo.cpp +FORMS += form.ui +RESOURCES = flightinfo.qrc +QT += network + +symbian { + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock -lconnmon + TARGET.CAPABILITY = NetworkServices +} diff --git a/demos/embedded/flightinfo/flightinfo.qrc b/demos/embedded/flightinfo/flightinfo.qrc new file mode 100644 index 0000000..babea7e --- /dev/null +++ b/demos/embedded/flightinfo/flightinfo.qrc @@ -0,0 +1,5 @@ + + + aircraft.png + + diff --git a/demos/embedded/flightinfo/form.ui b/demos/embedded/flightinfo/form.ui new file mode 100644 index 0000000..3a24c75 --- /dev/null +++ b/demos/embedded/flightinfo/form.ui @@ -0,0 +1,226 @@ + + + Form + + + + 0 + 0 + 220 + 171 + + + + Form + + + + 0 + + + 0 + + + + + QFrame { +background-color: #45629a; +} + +QLabel { +color: white; +} + + + QFrame::NoFrame + + + QFrame::Raised + + + 0 + + + + 0 + + + 4 + + + + + + 0 + 0 + + + + Powered by FlightView + + + + + + + + 0 + 0 + + + + + 75 + true + + + + background-color: white; +color: #45629a; + + + 0 + + + Ready + + + Qt::AlignCenter + + + 4 + + + + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 5 + + + + + color: black; +border: 1px solid black; +background: white; +selection-background-color: lightgray; + + + + + + + color: rgb(255, 255, 255); +background-color: rgb(85, 85, 255); +padding: 2px; +border: 2px solid rgb(0, 0, 127); + + + Search + + + Qt::ToolButtonTextBesideIcon + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 58 + + + + + + + + + 0 + 0 + + + + QFrame { border: 2px solid white; +border-radius: 10px; +margin: 5px; +background-color: rgba(69, 98, 154, 192); } + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 5 + + + + + + 0 + 0 + + + + color: white; +border: none; +background-color: none; + + + + + + Qt::RichText + + + true + + + Qt::NoTextInteraction + + + + + + + + + + + diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index be4f016..5957404 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -16,6 +16,7 @@ + diff --git a/demos/embedded/fluidlauncher/screenshots/flightinfo_s60.png b/demos/embedded/fluidlauncher/screenshots/flightinfo_s60.png new file mode 100644 index 0000000..8a304eb Binary files /dev/null and b/demos/embedded/fluidlauncher/screenshots/flightinfo_s60.png differ -- cgit v0.12 From 5ac4ae83bbb074ae792abd7f5738a63512d6a68c Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 19 Aug 2009 13:44:16 +0200 Subject: Import the weather info example. Originally it was published in Qt Labs: http://labs.trolltech.com/blogs/2009/07/22/weather-info-for-qts60/ Reviewed-by: Jason Barron --- demos/embedded/embedded.pro | 3 + demos/embedded/fluidlauncher/config_s60/config.xml | 1 + .../fluidlauncher/screenshots/weatherinfo.png | Bin 0 -> 38521 bytes demos/embedded/weatherinfo/icons/README.txt | 5 + .../weatherinfo/icons/weather-few-clouds.svg | 738 +++ demos/embedded/weatherinfo/icons/weather-fog.svg | 1585 ++++++ demos/embedded/weatherinfo/icons/weather-haze.svg | 1121 +++++ demos/embedded/weatherinfo/icons/weather-icy.svg | 255 + .../weatherinfo/icons/weather-overcast.svg | 3036 ++++++++++++ .../embedded/weatherinfo/icons/weather-showers.svg | 4753 ++++++++++++++++++ demos/embedded/weatherinfo/icons/weather-sleet.svg | 5196 ++++++++++++++++++++ demos/embedded/weatherinfo/icons/weather-snow.svg | 1974 ++++++++ demos/embedded/weatherinfo/icons/weather-storm.svg | 4308 ++++++++++++++++ .../icons/weather-sunny-very-few-clouds.svg | 593 +++ demos/embedded/weatherinfo/icons/weather-sunny.svg | 1330 +++++ .../weatherinfo/icons/weather-thundershower.svg | 4587 +++++++++++++++++ demos/embedded/weatherinfo/weatherinfo.cpp | 511 ++ demos/embedded/weatherinfo/weatherinfo.pro | 11 + demos/embedded/weatherinfo/weatherinfo.qrc | 16 + 19 files changed, 30023 insertions(+) create mode 100644 demos/embedded/fluidlauncher/screenshots/weatherinfo.png create mode 100644 demos/embedded/weatherinfo/icons/README.txt create mode 100644 demos/embedded/weatherinfo/icons/weather-few-clouds.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-fog.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-haze.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-icy.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-overcast.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-showers.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-sleet.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-snow.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-storm.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-sunny.svg create mode 100644 demos/embedded/weatherinfo/icons/weather-thundershower.svg create mode 100644 demos/embedded/weatherinfo/weatherinfo.cpp create mode 100644 demos/embedded/weatherinfo/weatherinfo.pro create mode 100644 demos/embedded/weatherinfo/weatherinfo.qrc diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index 3fa0e13..e425eb5 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -10,6 +10,9 @@ contains(QT_CONFIG, svg) { contains(QT_CONFIG, network) { SUBDIRS += lightmaps SUBDIRS += flightinfo + contains(QT_CONFIG, svg) { + SUBDIRS += weatherinfo + } } contains(QT_CONFIG, webkit) { diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index 5957404..08cdb90 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -17,6 +17,7 @@ + diff --git a/demos/embedded/fluidlauncher/screenshots/weatherinfo.png b/demos/embedded/fluidlauncher/screenshots/weatherinfo.png new file mode 100644 index 0000000..b18608d Binary files /dev/null and b/demos/embedded/fluidlauncher/screenshots/weatherinfo.png differ diff --git a/demos/embedded/weatherinfo/icons/README.txt b/demos/embedded/weatherinfo/icons/README.txt new file mode 100644 index 0000000..d384153 --- /dev/null +++ b/demos/embedded/weatherinfo/icons/README.txt @@ -0,0 +1,5 @@ +The scalable icons are from: + +http://tango.freedesktop.org/Tango_Icon_Library +http://darkobra.deviantart.com/art/Tango-Weather-Icon-Pack-98024429 + diff --git a/demos/embedded/weatherinfo/icons/weather-few-clouds.svg b/demos/embedded/weatherinfo/icons/weather-few-clouds.svg new file mode 100644 index 0000000..57d45e9 --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-few-clouds.svg @@ -0,0 +1,738 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-clear + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-fog.svg b/demos/embedded/weatherinfo/icons/weather-fog.svg new file mode 100644 index 0000000..a9a4ca8 --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-fog.svg @@ -0,0 +1,1585 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-haze.svg b/demos/embedded/weatherinfo/icons/weather-haze.svg new file mode 100644 index 0000000..f2d6671 --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-haze.svg @@ -0,0 +1,1121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-icy.svg b/demos/embedded/weatherinfo/icons/weather-icy.svg new file mode 100644 index 0000000..fe42860 --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-icy.svg @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-overcast.svg b/demos/embedded/weatherinfo/icons/weather-overcast.svg new file mode 100644 index 0000000..35fb4a4 --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-overcast.svg @@ -0,0 +1,3036 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-overcast + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-showers.svg b/demos/embedded/weatherinfo/icons/weather-showers.svg new file mode 100644 index 0000000..c814571 --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-showers.svg @@ -0,0 +1,4753 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-showers + January 2006 + + + Ryan collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + appplet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-sleet.svg b/demos/embedded/weatherinfo/icons/weather-sleet.svg new file mode 100644 index 0000000..f1cb9eb --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-sleet.svg @@ -0,0 +1,5196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-showers + January 2006 + + + Ryan collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + appplet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-snow.svg b/demos/embedded/weatherinfo/icons/weather-snow.svg new file mode 100644 index 0000000..6c7b4ad --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-snow.svg @@ -0,0 +1,1974 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-snow + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-storm.svg b/demos/embedded/weatherinfo/icons/weather-storm.svg new file mode 100644 index 0000000..4d8bfec --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-storm.svg @@ -0,0 +1,4308 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-storm + January 2006 + + + Ryan Collier + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg b/demos/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg new file mode 100644 index 0000000..93b0009 --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg @@ -0,0 +1,593 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-clear + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-sunny.svg b/demos/embedded/weatherinfo/icons/weather-sunny.svg new file mode 100644 index 0000000..0360ac7 --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-sunny.svg @@ -0,0 +1,1330 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-clear + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/icons/weather-thundershower.svg b/demos/embedded/weatherinfo/icons/weather-thundershower.svg new file mode 100644 index 0000000..406abfa --- /dev/null +++ b/demos/embedded/weatherinfo/icons/weather-thundershower.svg @@ -0,0 +1,4587 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-storm + January 2006 + + + Ryan Collier + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/embedded/weatherinfo/weatherinfo.cpp b/demos/embedded/weatherinfo/weatherinfo.cpp new file mode 100644 index 0000000..0762644 --- /dev/null +++ b/demos/embedded/weatherinfo/weatherinfo.cpp @@ -0,0 +1,511 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#if defined (Q_OS_SYMBIAN) +#include "sym_iap_util.h" +#endif + +class WeatherInfo: public QMainWindow +{ + Q_OBJECT + +private: + + QGraphicsView *m_view; + QGraphicsScene m_scene; + QString city; + QGraphicsRectItem *m_statusItem; + QGraphicsTextItem *m_temperatureItem; + QGraphicsTextItem *m_conditionItem; + QGraphicsSvgItem *m_iconItem; + QList m_forecastItems; + QList m_dayItems; + QList m_conditionItems; + QList m_rangeItems; + QTimeLine m_timeLine; + QHash m_icons; + +public: + WeatherInfo(QWidget *parent = 0): QMainWindow(parent) { + + m_view = new QGraphicsView(this); + setCentralWidget(m_view); + + setupScene(); + m_view->setScene(&m_scene); + m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + m_view->setFrameShape(QFrame::NoFrame); + setWindowTitle("Weather Info"); + + QStringList cities; + cities << "Oslo"; + cities << "Berlin"; + cities << "Brisbane"; + cities << "Helsinki"; + cities << "San Diego"; + for (int i = 0; i < cities.count(); ++i) { + QAction *action = new QAction(cities[i], this); + connect(action, SIGNAL(triggered()), SLOT(chooseCity())); + addAction(action); +#if defined(Q_OS_SYMBIAN) + menuBar()->addAction(action); +#endif + } + setContextMenuPolicy(Qt::ActionsContextMenu); + + QTimer::singleShot(0, this, SLOT(delayedInit())); + } + +private slots: + void delayedInit() { +#if defined(Q_OS_SYMBIAN) + qt_SetDefaultIap(); +#else + request("Oslo"); +#endif + } + +private slots: + + void chooseCity() { + QAction *action = qobject_cast(sender()); + if (action) + request(action->text()); + } + + void handleNetworkData(QNetworkReply *networkReply) { + QUrl url = networkReply->url(); + if (!networkReply->error()) + digest(QString::fromUtf8(networkReply->readAll())); + networkReply->deleteLater(); + networkReply->manager()->deleteLater(); + } + + void animate(int frame) { + qreal progress = static_cast(frame) / 100; +#if QT_VERSION >= 0x040500 + m_iconItem->setOpacity(progress); +#endif + qreal hw = width() / 2.0; + m_statusItem->setPos(-hw + hw * progress, 0); + for (int i = 0; i < m_forecastItems.count(); ++i) { + qreal ofs = i * 0.5 / m_forecastItems.count(); + qreal alpha = qBound(qreal(0), 2 * (progress - ofs), qreal(1)); +#if QT_VERSION >= 0x040500 + m_conditionItems[i]->setOpacity(alpha); +#endif + QPointF pos = m_forecastItems[i]->pos(); + if (width() > height()) { + qreal fx = width() - width() * 0.4 * alpha; + m_forecastItems[i]->setPos(fx, pos.y()); + } else { + qreal fx = height() - height() * 0.5 * alpha; + m_forecastItems[i]->setPos(pos.x(), fx); + } + } + } + +private: + + void setupScene() { + + QColor textColor = palette().color(QPalette::WindowText); + QFont textFont = font(); + textFont.setBold(true); + textFont.setPointSize(textFont.pointSize() * 2); + + m_temperatureItem = m_scene.addText(QString(), textFont); + m_temperatureItem->setDefaultTextColor(textColor); + + m_conditionItem = m_scene.addText(QString(), textFont); + m_conditionItem->setDefaultTextColor(textColor); + + m_iconItem = new QGraphicsSvgItem; + m_scene.addItem(m_iconItem); + + m_statusItem = m_scene.addRect(0, 0, 10, 10); + m_statusItem->setPen(Qt::NoPen); + m_statusItem->setBrush(Qt::NoBrush); + m_temperatureItem->setParentItem(m_statusItem); + m_conditionItem->setParentItem(m_statusItem); + m_iconItem->setParentItem(m_statusItem); + + connect(&m_timeLine, SIGNAL(frameChanged(int)), SLOT(animate(int))); + m_timeLine.setDuration(1100); + m_timeLine.setFrameRange(0, 100); + m_timeLine.setCurveShape(QTimeLine::EaseInCurve); + } + + void request(const QString &location) { + QUrl url("http://www.google.com/ig/api"); + url.addEncodedQueryItem("hl", "en"); + url.addEncodedQueryItem("weather", QUrl::toPercentEncoding(location)); + + QNetworkAccessManager *manager = new QNetworkAccessManager(this); + connect(manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleNetworkData(QNetworkReply*))); + manager->get(QNetworkRequest(url)); + + city = QString(); + setWindowTitle("Loading..."); + } + + QString extractIcon(const QString &data) { + if (m_icons.isEmpty()) { + m_icons["mostly_cloudy"] = "weather-few-clouds"; + m_icons["cloudy"] = "weather-overcast"; + m_icons["mostly_sunny"] = "weather-sunny-very-few-clouds"; + m_icons["partly_cloudy"] = "weather-sunny-very-few-clouds"; + m_icons["sunny"] = "weather-sunny"; + m_icons["flurries"] = "weather-snow"; + m_icons["fog"] = "weather-fog"; + m_icons["haze"] = "weather-haze"; + m_icons["icy"] = "weather-icy"; + m_icons["sleet"] = "weather-sleet"; + m_icons["chance_of_sleet"] = "weather-sleet"; + m_icons["snow"] = "weather-snow"; + m_icons["chance_of_snow"] = "weather-snow"; + m_icons["mist"] = "weather-showers"; + m_icons["rain"] = "weather-showers"; + m_icons["chance_of_rain"] = "weather-showers"; + m_icons["storm"] = "weather-storm"; + m_icons["chance_of_storm"] = "weather-storm"; + m_icons["thunderstorm"] = "weather-thundershower"; + m_icons["chance_of_tstorm"] = "weather-thundershower"; + } + QRegExp regex("([\\w]+).gif$"); + if (regex.indexIn(data) != -1) { + QString i = regex.cap(); + i = i.left(i.length() - 4); + QString name = m_icons.value(i); + if (!name.isEmpty()) { + name.prepend(":/icons/"); + name.append(".svg"); + return name; + } + } + return QString(); + } + + static QString toCelcius(QString t, QString unit) { + bool ok = false; + int degree = t.toInt(&ok); + if (!ok) + return QString(); + if (unit != "SI") + degree = ((degree - 32) * 5 + 8)/ 9; + return QString::number(degree) + QChar(176); + } + + +#define GET_DATA_ATTR xml.attributes().value("data").toString() + + void digest(const QString &data) { + + QColor textColor = palette().color(QPalette::WindowText); + QString unitSystem; + + delete m_iconItem; + m_iconItem = new QGraphicsSvgItem(); + m_scene.addItem(m_iconItem); + m_iconItem->setParentItem(m_statusItem); + qDeleteAll(m_dayItems); + qDeleteAll(m_conditionItems); + qDeleteAll(m_rangeItems); + qDeleteAll(m_forecastItems); + m_dayItems.clear(); + m_conditionItems.clear(); + m_rangeItems.clear(); + m_forecastItems.clear(); + + QXmlStreamReader xml(data); + while (!xml.atEnd()) { + xml.readNext(); + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == "city") { + city = GET_DATA_ATTR; + setWindowTitle(city); + } + if (xml.name() == "unit_system") + unitSystem = xml.attributes().value("data").toString(); + // Parse current weather conditions + if (xml.name() == "current_conditions") { + while (!xml.atEnd()) { + xml.readNext(); + if (xml.name() == "current_conditions") + break; + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == "condition") { + m_conditionItem->setPlainText(GET_DATA_ATTR); + } + if (xml.name() == "icon") { + QString name = extractIcon(GET_DATA_ATTR); + if (!name.isEmpty()) { + delete m_iconItem; + m_iconItem = new QGraphicsSvgItem(name); + m_scene.addItem(m_iconItem); + m_iconItem->setParentItem(m_statusItem); + } + } + if (xml.name() == "temp_c") { + QString s = GET_DATA_ATTR + QChar(176); + m_temperatureItem->setPlainText(s); + } + } + } + } + // Parse and collect the forecast conditions + if (xml.name() == "forecast_conditions") { + QGraphicsTextItem *dayItem = 0; + QGraphicsSvgItem *statusItem = 0; + QString lowT, highT; + while (!xml.atEnd()) { + xml.readNext(); + if (xml.name() == "forecast_conditions") { + if (dayItem && statusItem && + !lowT.isEmpty() && !highT.isEmpty()) { + m_dayItems << dayItem; + m_conditionItems << statusItem; + QString txt = highT + '/' + lowT; + QGraphicsTextItem* rangeItem; + rangeItem = m_scene.addText(txt); + rangeItem->setDefaultTextColor(textColor); + m_rangeItems << rangeItem; + QGraphicsRectItem *box; + box = m_scene.addRect(0, 0, 10, 10); + box->setPen(Qt::NoPen); + box->setBrush(Qt::NoBrush); + m_forecastItems << box; + dayItem->setParentItem(box); + statusItem->setParentItem(box); + rangeItem->setParentItem(box); + } else { + delete dayItem; + delete statusItem; + } + break; + } + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == "day_of_week") { + QString s = GET_DATA_ATTR; + dayItem = m_scene.addText(s.left(3)); + dayItem->setDefaultTextColor(textColor); + } + if (xml.name() == "icon") { + QString name = extractIcon(GET_DATA_ATTR); + if (!name.isEmpty()) { + statusItem = new QGraphicsSvgItem(name); + m_scene.addItem(statusItem); + } + } + if (xml.name() == "low") + lowT = toCelcius(GET_DATA_ATTR, unitSystem); + if (xml.name() == "high") + highT = toCelcius(GET_DATA_ATTR, unitSystem); + } + } + } + + } + } + + m_timeLine.stop(); + layoutItems(); + animate(0); + m_timeLine.start(); + } + + void layoutItems() { + m_scene.setSceneRect(0, 0, width() - 1, height() - 1); + m_view->centerOn(width() / 2, height() / 2); + if (width() > height()) + layoutItemsLandscape(); + else + layoutItemsPortrait(); + } + + void layoutItemsLandscape() { + m_statusItem->setRect(0, 0, width() / 2 - 1, height() - 1); + + if (!m_iconItem->boundingRect().isEmpty()) { + qreal dim = qMin(width() * 0.6, height() * 0.8); + qreal pad = (height() - dim) / 2; + qreal sw = dim / m_iconItem->boundingRect().width(); + qreal sh = dim / m_iconItem->boundingRect().height(); + m_iconItem->setTransform(QTransform().scale(sw, sh)); + m_iconItem->setPos(1, pad); + } + + m_temperatureItem->setPos(2, 2); + qreal h = m_conditionItem->boundingRect().height(); + m_conditionItem->setPos(10, height() - h); + + if (m_dayItems.count()) { + qreal left = width() * 0.6; + qreal h = height() / m_dayItems.count(); + QFont textFont = font(); + textFont.setPixelSize(static_cast(h * 0.3)); + qreal statusWidth = 0; + qreal rangeWidth = 0; + for (int i = 0; i < m_dayItems.count(); ++i) { + m_dayItems[i]->setFont(textFont); + QRectF brect = m_dayItems[i]->boundingRect(); + statusWidth = qMax(statusWidth, brect.width()); + brect = m_rangeItems[i]->boundingRect(); + rangeWidth = qMax(rangeWidth, brect.width()); + } + qreal space = width() - left - statusWidth - rangeWidth; + qreal dim = qMin(h, space); + qreal pad = statusWidth + (space - dim) / 2; + for (int i = 0; i < m_dayItems.count(); ++i) { + qreal base = h * i; + m_forecastItems[i]->setPos(left, base); + m_forecastItems[i]->setRect(0, 0, width() - left, h); + QRectF brect = m_dayItems[i]->boundingRect(); + qreal ofs = (h - brect.height()) / 2; + m_dayItems[i]->setPos(0, ofs); + brect = m_rangeItems[i]->boundingRect(); + ofs = (h - brect.height()) / 2; + m_rangeItems[i]->setPos(width() - rangeWidth - left, ofs); + brect = m_conditionItems[i]->boundingRect(); + ofs = (h - dim) / 2; + m_conditionItems[i]->setPos(pad, ofs); + if (brect.isEmpty()) + continue; + qreal sw = dim / brect.width(); + qreal sh = dim / brect.height(); + m_conditionItems[i]->setTransform(QTransform().scale(sw, sh)); + } + } + } + + void layoutItemsPortrait() { + + m_statusItem->setRect(0, 0, width() - 1, height() / 2 - 1); + + if (!m_iconItem->boundingRect().isEmpty()) { + qreal dim = qMin(width() * 0.8, height() * 0.4); + qreal ofsy = (height() / 2 - dim) / 2; + qreal ofsx = (width() - dim) / 3; + qreal sw = dim / m_iconItem->boundingRect().width(); + qreal sh = dim / m_iconItem->boundingRect().height(); + m_iconItem->setTransform(QTransform().scale(sw, sh)); + m_iconItem->setPos(ofsx, ofsy); + } + + m_temperatureItem->setPos(2, 2); + qreal ch = m_conditionItem->boundingRect().height(); + qreal cw = m_conditionItem->boundingRect().width(); + m_conditionItem->setPos(width() - cw , height() / 2 - ch - 20); + + if (m_dayItems.count()) { + qreal top = height() * 0.5; + qreal w = width() / m_dayItems.count(); + qreal statusHeight = 0; + qreal rangeHeight = 0; + for (int i = 0; i < m_dayItems.count(); ++i) { + m_dayItems[i]->setFont(font()); + QRectF brect = m_dayItems[i]->boundingRect(); + statusHeight = qMax(statusHeight, brect.height()); + brect = m_rangeItems[i]->boundingRect(); + rangeHeight = qMax(rangeHeight, brect.height()); + } + qreal space = height() - top - statusHeight - rangeHeight; + qreal dim = qMin(w, space); + + qreal boxh = statusHeight + rangeHeight + dim; + qreal pad = (height() - top - boxh) / 2; + + for (int i = 0; i < m_dayItems.count(); ++i) { + qreal base = w * i; + m_forecastItems[i]->setPos(base, top); + m_forecastItems[i]->setRect(0, 0, w, boxh); + QRectF brect = m_dayItems[i]->boundingRect(); + qreal ofs = (w - brect.width()) / 2; + m_dayItems[i]->setPos(ofs, pad); + + brect = m_rangeItems[i]->boundingRect(); + ofs = (w - brect.width()) / 2; + m_rangeItems[i]->setPos(ofs, pad + statusHeight + dim); + + brect = m_conditionItems[i]->boundingRect(); + ofs = (w - dim) / 2; + m_conditionItems[i]->setPos(ofs, pad + statusHeight); + if (brect.isEmpty()) + continue; + qreal sw = dim / brect.width(); + qreal sh = dim / brect.height(); + m_conditionItems[i]->setTransform(QTransform().scale(sw, sh)); + } + } + } + + + void resizeEvent(QResizeEvent *event) { + Q_UNUSED(event); + layoutItems(); + } + +}; + +#include "weatherinfo.moc" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + WeatherInfo w; +#if defined(Q_OS_SYMBIAN) + w.showMaximized(); +#else + w.resize(520, 288); + w.show(); +#endif + + return app.exec(); +} diff --git a/demos/embedded/weatherinfo/weatherinfo.pro b/demos/embedded/weatherinfo/weatherinfo.pro new file mode 100644 index 0000000..a89acba --- /dev/null +++ b/demos/embedded/weatherinfo/weatherinfo.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = weatherinfo +SOURCES = weatherinfo.cpp +RESOURCES = weatherinfo.qrc +QT += network svg + +symbian { + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock -lconnmon + TARGET.CAPABILITY = NetworkServices +} diff --git a/demos/embedded/weatherinfo/weatherinfo.qrc b/demos/embedded/weatherinfo/weatherinfo.qrc new file mode 100644 index 0000000..6e9d224 --- /dev/null +++ b/demos/embedded/weatherinfo/weatherinfo.qrc @@ -0,0 +1,16 @@ + + + icons/weather-few-clouds.svg + icons/weather-fog.svg + icons/weather-haze.svg + icons/weather-icy.svg + icons/weather-overcast.svg + icons/weather-showers.svg + icons/weather-sleet.svg + icons/weather-snow.svg + icons/weather-storm.svg + icons/weather-sunny.svg + icons/weather-sunny-very-few-clouds.svg + icons/weather-thundershower.svg + + -- cgit v0.12 From 25ba469ae5a2df8fbe75beb8b66fb12c3fe1dcb2 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 19 Aug 2009 14:05:40 +0200 Subject: Import the flick list (kinetic scrolling) example. Originally it was published in Qt Labs: http://labs.trolltech.com/blogs/2009/07/19/kinetic-scrolling-on-any-widgets/ Reviewed-by: Jason Barron --- demos/embedded/embedded.pro | 2 +- demos/embedded/flickable/flickable.cpp | 284 +++++++++++++++++++++ demos/embedded/flickable/flickable.h | 80 ++++++ demos/embedded/flickable/flickable.pro | 2 + demos/embedded/flickable/main.cpp | 233 +++++++++++++++++ demos/embedded/fluidlauncher/config_s60/config.xml | 1 + .../fluidlauncher/screenshots/flickable.png | Bin 0 -> 21107 bytes 7 files changed, 601 insertions(+), 1 deletion(-) create mode 100644 demos/embedded/flickable/flickable.cpp create mode 100644 demos/embedded/flickable/flickable.h create mode 100644 demos/embedded/flickable/flickable.pro create mode 100644 demos/embedded/flickable/main.cpp create mode 100644 demos/embedded/fluidlauncher/screenshots/flickable.png diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index e425eb5..7fcae45 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS = styledemo raycasting +SUBDIRS = styledemo raycasting flickable contains(QT_CONFIG, svg) { SUBDIRS += embeddedsvgviewer \ diff --git a/demos/embedded/flickable/flickable.cpp b/demos/embedded/flickable/flickable.cpp new file mode 100644 index 0000000..8fbefe6 --- /dev/null +++ b/demos/embedded/flickable/flickable.cpp @@ -0,0 +1,284 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "flickable.h" + +#include +#include + +class FlickableTicker: QObject +{ +public: + FlickableTicker(Flickable *scroller) { + m_scroller = scroller; + } + + void start(int interval) { + if (!m_timer.isActive()) + m_timer.start(interval, this); + } + + void stop() { + m_timer.stop(); + } + +protected: + void timerEvent(QTimerEvent *event) { + Q_UNUSED(event); + m_scroller->tick(); + } + +private: + Flickable *m_scroller; + QBasicTimer m_timer; +}; + +class FlickablePrivate +{ +public: + typedef enum { + Steady, + Pressed, + ManualScroll, + AutoScroll, + Stop + } State; + + State state; + int threshold; + QPoint pressPos; + QPoint offset; + QPoint delta; + QPoint speed; + FlickableTicker *ticker; + QTime timeStamp; + QWidget *target; + QList ignoreList; +}; + +Flickable::Flickable() +{ + d = new FlickablePrivate; + d->state = FlickablePrivate::Steady; + d->threshold = 10; + d->ticker = new FlickableTicker(this); + d->timeStamp = QTime::currentTime(); + d->target = 0; +} + +Flickable::~Flickable() +{ + delete d; +} + +void Flickable::setThreshold(int th) +{ + if (th >= 0) + d->threshold = th; +} + +int Flickable::threshold() const +{ + return d->threshold; +} + +void Flickable::setAcceptMouseClick(QWidget *target) +{ + d->target = target; +} + +static QPoint deaccelerate(const QPoint &speed, int a = 1, int max = 64) +{ + int x = qBound(-max, speed.x(), max); + int y = qBound(-max, speed.y(), max); + x = (x == 0) ? x : (x > 0) ? qMax(0, x - a) : qMin(0, x + a); + y = (y == 0) ? y : (y > 0) ? qMax(0, y - a) : qMin(0, y + a); + return QPoint(x, y); +} + +void Flickable::handleMousePress(QMouseEvent *event) +{ + event->ignore(); + + if (event->button() != Qt::LeftButton) + return; + + if (d->ignoreList.removeAll(event)) + return; + + switch (d->state) { + + case FlickablePrivate::Steady: + event->accept(); + d->state = FlickablePrivate::Pressed; + d->pressPos = event->pos(); + break; + + case FlickablePrivate::AutoScroll: + event->accept(); + d->state = FlickablePrivate::Stop; + d->speed = QPoint(0, 0); + d->pressPos = event->pos(); + d->offset = scrollOffset(); + d->ticker->stop(); + break; + + default: + break; + } +} + +void Flickable::handleMouseRelease(QMouseEvent *event) +{ + event->ignore(); + + if (event->button() != Qt::LeftButton) + return; + + if (d->ignoreList.removeAll(event)) + return; + + QPoint delta; + + switch (d->state) { + + case FlickablePrivate::Pressed: + event->accept(); + d->state = FlickablePrivate::Steady; + if (d->target) { + QMouseEvent *event1 = new QMouseEvent(QEvent::MouseButtonPress, + d->pressPos, Qt::LeftButton, + Qt::LeftButton, Qt::NoModifier); + QMouseEvent *event2 = new QMouseEvent(*event); + d->ignoreList << event1; + d->ignoreList << event2; + QApplication::postEvent(d->target, event1); + QApplication::postEvent(d->target, event2); + } + break; + + case FlickablePrivate::ManualScroll: + event->accept(); + delta = event->pos() - d->pressPos; + if (d->timeStamp.elapsed() > 100) { + d->timeStamp = QTime::currentTime(); + d->speed = delta - d->delta; + d->delta = delta; + } + d->offset = scrollOffset(); + d->pressPos = event->pos(); + if (d->speed == QPoint(0, 0)) { + d->state = FlickablePrivate::Steady; + } else { + d->speed /= 4; + d->state = FlickablePrivate::AutoScroll; + d->ticker->start(20); + } + break; + + case FlickablePrivate::Stop: + event->accept(); + d->state = FlickablePrivate::Steady; + d->offset = scrollOffset(); + break; + + default: + break; + } +} + +void Flickable::handleMouseMove(QMouseEvent *event) +{ + event->ignore(); + + if (!(event->buttons() & Qt::LeftButton)) + return; + + if (d->ignoreList.removeAll(event)) + return; + + QPoint delta; + + switch (d->state) { + + case FlickablePrivate::Pressed: + case FlickablePrivate::Stop: + delta = event->pos() - d->pressPos; + if (delta.x() > d->threshold || delta.x() < -d->threshold || + delta.y() > d->threshold || delta.y() < -d->threshold) { + d->timeStamp = QTime::currentTime(); + d->state = FlickablePrivate::ManualScroll; + d->delta = QPoint(0, 0); + d->pressPos = event->pos(); + event->accept(); + } + break; + + case FlickablePrivate::ManualScroll: + event->accept(); + delta = event->pos() - d->pressPos; + setScrollOffset(d->offset - delta); + if (d->timeStamp.elapsed() > 100) { + d->timeStamp = QTime::currentTime(); + d->speed = delta - d->delta; + d->delta = delta; + } + break; + + default: + break; + } +} + +void Flickable::tick() +{ + if (d->state == FlickablePrivate:: AutoScroll) { + d->speed = deaccelerate(d->speed); + setScrollOffset(d->offset - d->speed); + d->offset = scrollOffset(); + if (d->speed == QPoint(0, 0)) { + d->state = FlickablePrivate::Steady; + d->ticker->stop(); + } + } else { + d->ticker->stop(); + } +} diff --git a/demos/embedded/flickable/flickable.h b/demos/embedded/flickable/flickable.h new file mode 100644 index 0000000..26497db --- /dev/null +++ b/demos/embedded/flickable/flickable.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FLICKABLE_H +#define FLICKABLE_H + +class QMouseEvent; +class QPoint; +class QWidget; + +class FlickableTicker; +class FlickablePrivate; + +class Flickable +{ +public: + + Flickable(); + virtual ~Flickable(); + + void setThreshold(int threshold); + int threshold() const; + + void setAcceptMouseClick(QWidget *target); + + void handleMousePress(QMouseEvent *event); + void handleMouseMove(QMouseEvent *event); + void handleMouseRelease(QMouseEvent *event); + +protected: + virtual QPoint scrollOffset() const = 0; + virtual void setScrollOffset(const QPoint &offset) = 0; + +private: + void tick(); + +private: + FlickablePrivate *d; + friend class FlickableTicker; +}; + +#endif // FLICKABLE_H diff --git a/demos/embedded/flickable/flickable.pro b/demos/embedded/flickable/flickable.pro new file mode 100644 index 0000000..3c021dd --- /dev/null +++ b/demos/embedded/flickable/flickable.pro @@ -0,0 +1,2 @@ +SOURCES = flickable.cpp main.cpp +HEADERS = flickable.h diff --git a/demos/embedded/flickable/main.cpp b/demos/embedded/flickable/main.cpp new file mode 100644 index 0000000..cc024d9 --- /dev/null +++ b/demos/embedded/flickable/main.cpp @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "flickable.h" + +// Returns a list of two-word color names +static QStringList colorPairs(int max) +{ + // capitalize the first letter + QStringList colors = QColor::colorNames(); + colors.removeAll("transparent"); + int num = colors.count(); + for (int c = 0; c < num; ++c) + colors[c] = colors[c][0].toUpper() + colors[c].mid(1); + + // combine two colors, e.g. "lime skyblue" + QStringList combinedColors; + for (int i = 0; i < num; ++i) + for (int j = 0; j < num; ++j) + combinedColors << QString("%1 %2").arg(colors[i]).arg(colors[j]); + + // randomize it + colors.clear(); + while (combinedColors.count()) { + int i = qrand() % combinedColors.count(); + colors << combinedColors[i]; + combinedColors.removeAt(i); + if (colors.count() == max) + break; + } + + return colors; +} + +class ColorList : public QWidget, public Flickable +{ + Q_OBJECT + +public: + ColorList(QWidget *parent = 0) + : QWidget(parent) { + m_offset = 0; + m_height = QFontMetrics(font()).height() + 5; + m_highlight = -1; + m_selected = -1; + + QStringList colors = colorPairs(999); + for (int i = 0; i < colors.count(); ++i) { + QString c = colors[i]; + QString str; + str.sprintf("%4d", i + 1); + m_colorNames << (str + " " + c); + + QStringList duet = c.split(' '); + m_firstColor << duet[0]; + m_secondColor << duet[1]; + } + + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + + setMouseTracking(true); + Flickable::setAcceptMouseClick(this); + } + +protected: + // reimplement from Flickable + virtual QPoint scrollOffset() const { + return QPoint(0, m_offset); + } + + // reimplement from Flickable + virtual void setScrollOffset(const QPoint &offset) { + int yy = offset.y(); + if (yy != m_offset) { + m_offset = qBound(0, yy, m_height * m_colorNames.count() - height()); + update(); + } + } + +protected: + void paintEvent(QPaintEvent *event) { + QPainter p(this); + p.fillRect(event->rect(), Qt::white); + int start = m_offset / m_height; + int y = start * m_height - m_offset; + if (m_offset <= 0) { + start = 0; + y = -m_offset; + } + int end = start + height() / m_height + 1; + if (end > m_colorNames.count() - 1) + end = m_colorNames.count() - 1; + for (int i = start; i <= end; ++i, y += m_height) { + + p.setBrush(Qt::NoBrush); + p.setPen(Qt::black); + if (i == m_highlight) { + p.fillRect(0, y, width(), m_height, QColor(0, 64, 128)); + p.setPen(Qt::white); + } + if (i == m_selected) { + p.fillRect(0, y, width(), m_height, QColor(0, 128, 240)); + p.setPen(Qt::white); + } + + p.drawText(m_height + 2, y, width(), m_height, Qt::AlignVCenter, m_colorNames[i]); + + p.setPen(Qt::NoPen); + p.setBrush(m_firstColor[i]); + p.drawRect(1, y + 1, m_height - 2, m_height - 2); + p.setBrush(m_secondColor[i]); + p.drawRect(5, y + 5, m_height - 11, m_height - 11); + } + p.end(); + } + + void keyReleaseEvent(QKeyEvent *event) { + if (event->key() == Qt::Key_Down) { + m_offset += 20; + event->accept(); + update(); + return; + } + if (event->key() == Qt::Key_Up) { + m_offset -= 20; + event->accept(); + update(); + return; + } + } + + void mousePressEvent(QMouseEvent *event) { + Flickable::handleMousePress(event); + if (event->isAccepted()) + return; + + if (event->button() == Qt::LeftButton) { + int y = event->pos().y() + m_offset; + int i = y / m_height; + if (i != m_highlight) { + m_highlight = i; + m_selected = -1; + update(); + } + event->accept(); + } + } + + void mouseMoveEvent(QMouseEvent *event) { + Flickable::handleMouseMove(event); + } + + void mouseReleaseEvent(QMouseEvent *event) { + Flickable::handleMouseRelease(event); + if (event->isAccepted()) + return; + + if (event->button() == Qt::LeftButton) { + m_selected = m_highlight; + event->accept(); + update(); + } + } + +private: + int m_offset; + int m_height; + int m_highlight; + int m_selected; + QStringList m_colorNames; + QList m_firstColor; + QList m_secondColor; +}; + +#include "main.moc" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + ColorList list; + list.setWindowTitle("Kinetic Scrolling"); +#ifdef Q_OS_SYMBIAN + list.showMaximized(); +#else + list.resize(320, 320); + list.show(); +#endif + + return app.exec(); +} diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index 08cdb90..dfa8da7 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -18,6 +18,7 @@ + diff --git a/demos/embedded/fluidlauncher/screenshots/flickable.png b/demos/embedded/fluidlauncher/screenshots/flickable.png new file mode 100644 index 0000000..7080fc1 Binary files /dev/null and b/demos/embedded/fluidlauncher/screenshots/flickable.png differ -- cgit v0.12 From e843ec2585017978996beb40f0cf84c7b54a20b0 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 19 Aug 2009 14:12:13 +0200 Subject: Import flipping (digital) clock demo. Originally it was published in Qt Labs: http://labs.trolltech.com/blogs/2009/07/15/digital-clock-in-a-phone/ Reviewed-by: Jason Barron --- demos/embedded/digiflip/digiflip.cpp | 425 +++++++++++++++++++++ demos/embedded/digiflip/digiflip.pro | 1 + demos/embedded/embedded.pro | 2 +- demos/embedded/fluidlauncher/config_s60/config.xml | 1 + .../fluidlauncher/screenshots/digiflip.png | Bin 0 -> 3508 bytes 5 files changed, 428 insertions(+), 1 deletion(-) create mode 100644 demos/embedded/digiflip/digiflip.cpp create mode 100644 demos/embedded/digiflip/digiflip.pro create mode 100644 demos/embedded/fluidlauncher/screenshots/digiflip.png diff --git a/demos/embedded/digiflip/digiflip.cpp b/demos/embedded/digiflip/digiflip.cpp new file mode 100644 index 0000000..b822659 --- /dev/null +++ b/demos/embedded/digiflip/digiflip.cpp @@ -0,0 +1,425 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class Digits: public QWidget +{ + Q_OBJECT + +public: + + enum { + Slide, + Flip, + Rotate + }; + + Digits(QWidget *parent) + : QWidget(parent) + , m_number(0) + , m_transition(Slide) + { + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + connect(&m_animator, SIGNAL(frameChanged(int)), SLOT(update())); + m_animator.setFrameRange(0, 100); + m_animator.setDuration(600); + m_animator.setCurveShape(QTimeLine::EaseInOutCurve); + } + + void setTransition(int tr) { + m_transition = tr; + } + + int transition() const { + return m_transition; + } + + void setNumber(int n) { + if (m_number != n) { + m_number = qBound(0, n, 99); + preparePixmap(); + update(); + } + } + + void flipTo(int n) { + if (m_number != n) { + m_number = qBound(0, n, 99); + m_lastPixmap = m_pixmap; + preparePixmap(); + m_animator.stop(); + m_animator.start(); + } + } + +protected: + + void drawFrame(QPainter *p, const QRect &rect) { + p->setPen(Qt::NoPen); + QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); + gradient.setColorAt(0.00, QColor(245, 245, 245)); + gradient.setColorAt(0.49, QColor(192, 192, 192)); + gradient.setColorAt(0.51, QColor(245, 245, 245)); + gradient.setColorAt(1.00, QColor(192, 192, 192)); + p->setBrush(gradient); + QRect r = rect; + p->drawRoundedRect(r, 15, 15, Qt::RelativeSize); + r.adjust(1, 4, -1, -4); + p->setPen(QColor(181, 181, 181)); + p->setBrush(Qt::NoBrush); + p->drawRoundedRect(r, 15, 15, Qt::RelativeSize); + p->setPen(QColor(159, 159, 159)); + int y = rect.top() + rect.height() / 2 - 1; + p->drawLine(rect.left(), y, rect.right(), y); + } + + QPixmap drawDigits(int n, const QRect &rect) { + + int scaleFactor = 2; +#if defined(Q_OS_SYMBIAN) + if (rect.height() > 240) + scaleFactor = 1; +#endif + + QString str = QString::number(n); + if (str.length() == 1) + str.prepend("0"); + + QFont font; + font.setFamily("Helvetica"); + int fontHeight = scaleFactor * 0.55 * rect.height(); + font.setPixelSize(fontHeight); + font.setBold(true); + + QPixmap pixmap(rect.size() * scaleFactor); + pixmap.fill(Qt::transparent); + + QLinearGradient gradient(QPoint(0, 0), QPoint(0, pixmap.height())); + gradient.setColorAt(0.00, QColor(128, 128, 128)); + gradient.setColorAt(0.49, QColor(64, 64, 64)); + gradient.setColorAt(0.51, QColor(128, 128, 128)); + gradient.setColorAt(1.00, QColor(16, 16, 16)); + + QPainter p; + p.begin(&pixmap); + p.setFont(font); + QPen pen; + pen.setBrush(QBrush(gradient)); + p.setPen(pen); + p.drawText(pixmap.rect(), Qt::AlignCenter, str); + p.end(); + + return pixmap.scaledToWidth(width(), Qt::SmoothTransformation); + } + + void preparePixmap() { + m_pixmap = QPixmap(size()); + m_pixmap.fill(Qt::transparent); + QPainter p; + p.begin(&m_pixmap); + p.drawPixmap(0, 0, drawDigits(m_number, rect())); + p.end(); + } + + void resizeEvent(QResizeEvent*) { + preparePixmap(); + update(); + } + + void paintStatic() { + QPainter p(this); + p.fillRect(rect(), Qt::black); + + int pad = width() / 10; + drawFrame(&p, rect().adjusted(pad, pad, -pad, -pad)); + p.drawPixmap(0, 0, m_pixmap); + } + + void paintSlide() { + QPainter p(this); + p.fillRect(rect(), Qt::black); + + int pad = width() / 10; + QRect fr = rect().adjusted(pad, pad, -pad, -pad); + drawFrame(&p, fr); + p.setClipRect(fr); + + int y = height() * m_animator.currentFrame() / 100; + p.drawPixmap(0, y, m_lastPixmap); + p.drawPixmap(0, y - height(), m_pixmap); + } + + void paintFlip() { + QPainter p(this); +#if !defined(Q_OS_SYMBIAN) + p.setRenderHint(QPainter::SmoothPixmapTransform, true); + p.setRenderHint(QPainter::Antialiasing, true); +#endif + p.fillRect(rect(), Qt::black); + + int hw = width() / 2; + int hh = height() / 2; + + // behind is the new pixmap + int pad = width() / 10; + QRect fr = rect().adjusted(pad, pad, -pad, -pad); + drawFrame(&p, fr); + p.drawPixmap(0, 0, m_pixmap); + + int index = m_animator.currentFrame(); + + if (index <= 50) { + + // the top part of the old pixmap is flipping + int angle = -180 * index / 100; + QTransform transform; + transform.translate(hw, hh); + transform.rotate(angle, Qt::XAxis); + p.setTransform(transform); + drawFrame(&p, fr.adjusted(-hw, -hh, -hw, -hh)); + p.drawPixmap(-hw, -hh, m_lastPixmap); + + // the bottom part is still the old pixmap + p.resetTransform(); + p.setClipRect(0, hh, width(), hh); + drawFrame(&p, fr); + p.drawPixmap(0, 0, m_lastPixmap); + } else { + + p.setClipRect(0, hh, width(), hh); + + // the bottom part is still the old pixmap + drawFrame(&p, fr); + p.drawPixmap(0, 0, m_lastPixmap); + + // the bottom part of the new pixmap is flipping + int angle = 180 - 180 * m_animator.currentFrame() / 100; + QTransform transform; + transform.translate(hw, hh); + transform.rotate(angle, Qt::XAxis); + p.setTransform(transform); + drawFrame(&p, fr.adjusted(-hw, -hh, -hw, -hh)); + p.drawPixmap(-hw, -hh, m_pixmap); + + } + + } + + void paintRotate() { + QPainter p(this); + + int pad = width() / 10; + QRect fr = rect().adjusted(pad, pad, -pad, -pad); + drawFrame(&p, fr); + p.setClipRect(fr); + + int angle1 = -180 * m_animator.currentFrame() / 100; + int angle2 = 180 - 180 * m_animator.currentFrame() / 100; + int angle = (m_animator.currentFrame() <= 50) ? angle1 : angle2; + QPixmap pix = (m_animator.currentFrame() <= 50) ? m_lastPixmap : m_pixmap; + + QTransform transform; + transform.translate(width() / 2, height() / 2); + transform.rotate(angle, Qt::XAxis); + + p.setTransform(transform); + p.setRenderHint(QPainter::SmoothPixmapTransform, true); + p.drawPixmap(-width() / 2, -height() / 2, pix); + } + + void paintEvent(QPaintEvent *event) { + Q_UNUSED(event); + if (m_animator.state() == QTimeLine::Running) { + if (m_transition == Slide) + paintSlide(); + if (m_transition == Flip) + paintFlip(); + if (m_transition == Rotate) + paintRotate(); + } else { + paintStatic(); + } + } + +private: + int m_number; + int m_transition; + QPixmap m_pixmap; + QPixmap m_lastPixmap; + QTimeLine m_animator; +}; + +class DigiFlip : public QMainWindow +{ + Q_OBJECT + +public: + DigiFlip(QWidget *parent = 0) + : QMainWindow(parent) + { + m_hour = new Digits(this); + m_hour->show(); + m_minute = new Digits(this); + m_minute->show(); + + QPalette pal = palette(); + pal.setColor(QPalette::Window, Qt::black); + setPalette(pal); + + m_ticker.start(1000, this); + QTime t = QTime::currentTime(); + m_hour->setNumber(t.hour()); + m_minute->setNumber(t.minute()); + updateTime(); + + QAction *slideAction = new QAction("&Slide", this); + QAction *flipAction = new QAction("&Flip", this); + QAction *rotateAction = new QAction("&Rotate", this); + connect(slideAction, SIGNAL(triggered()), SLOT(chooseSlide())); + connect(flipAction, SIGNAL(triggered()), SLOT(chooseFlip())); + connect(rotateAction, SIGNAL(triggered()), SLOT(chooseRotate())); +#if defined(Q_OS_SYMBIAN) + menuBar()->addAction(slideAction); + menuBar()->addAction(flipAction); + menuBar()->addAction(rotateAction); +#else + addAction(slideAction); + addAction(flipAction); + addAction(rotateAction); + setContextMenuPolicy(Qt::ActionsContextMenu); +#endif + } + + void updateTime() { + QTime t = QTime::currentTime(); + m_hour->flipTo(t.hour()); + m_minute->flipTo(t.minute()); + QString str = t.toString("hh:mm:ss"); + str.prepend(": "); + if (m_hour->transition() == Digits::Slide) + str.prepend("Slide"); + if (m_hour->transition() == Digits::Flip) + str.prepend("Flip"); + if (m_hour->transition() == Digits::Rotate) + str.prepend("Rotate"); + setWindowTitle(str); + } + + void switchTransition(int delta) { + int i = (m_hour->transition() + delta + 3) % 3; + m_hour->setTransition(i); + m_minute->setTransition(i); + updateTime(); + } + +protected: + void resizeEvent(QResizeEvent*) { + int digitsWidth = width() / 2; + int digitsHeight = digitsWidth * 1.2; + + int y = (height() - digitsHeight) / 3; + + m_hour->resize(digitsWidth, digitsHeight); + m_hour->move(0, y); + + m_minute->resize(digitsWidth, digitsHeight); + m_minute->move(width() / 2, y); + } + + void timerEvent(QTimerEvent*) { + updateTime(); + } + + void keyPressEvent(QKeyEvent *event) { + if (event->key() == Qt::Key_Right) { + switchTransition(1); + event->accept(); + } + if (event->key() == Qt::Key_Left) { + switchTransition(-1); + event->accept(); + } + } + +private slots: + void chooseSlide() { + m_hour->setTransition(0); + m_minute->setTransition(0); + updateTime(); + } + + void chooseFlip() { + m_hour->setTransition(1); + m_minute->setTransition(1); + updateTime(); + } + + void chooseRotate() { + m_hour->setTransition(2); + m_minute->setTransition(2); + updateTime(); + } + +private: + QBasicTimer m_ticker; + Digits *m_hour; + Digits *m_minute; +}; + +#include "digiflip.moc" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + DigiFlip time; +#if defined(Q_OS_SYMBIAN) + time.showMaximized(); +#else + time.resize(320, 240); + time.show(); +#endif + + return app.exec(); +} diff --git a/demos/embedded/digiflip/digiflip.pro b/demos/embedded/digiflip/digiflip.pro new file mode 100644 index 0000000..6654088 --- /dev/null +++ b/demos/embedded/digiflip/digiflip.pro @@ -0,0 +1 @@ +SOURCES = digiflip.cpp diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro index 7fcae45..d0fb40a 100644 --- a/demos/embedded/embedded.pro +++ b/demos/embedded/embedded.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS = styledemo raycasting flickable +SUBDIRS = styledemo raycasting flickable digiflip contains(QT_CONFIG, svg) { SUBDIRS += embeddedsvgviewer \ diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index dfa8da7..192a2e3 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -19,6 +19,7 @@ + diff --git a/demos/embedded/fluidlauncher/screenshots/digiflip.png b/demos/embedded/fluidlauncher/screenshots/digiflip.png new file mode 100644 index 0000000..117b61b Binary files /dev/null and b/demos/embedded/fluidlauncher/screenshots/digiflip.png differ -- cgit v0.12 From e7d36a55746e6e3a2a66c47ee85cbfbfbe079c4e Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 19 Aug 2009 15:34:28 +0300 Subject: Review fixes for qmake (project.cpp cleanup) Removed symbian specific functionality from project.cpp: - generate_test_uid qmake function removed - Uids are now generated automatically for projects that don't have one. - Usage of ICON (in application_icon.prf) now requires explicit UID3 definition. - Autotests that require UID3 in .pro now define it explicitly - Move most symbian specific function implementations away from project.cpp to files under generators/symbian Reviewed-by: Janne Anttila --- mkspecs/features/qttest_p4.prf | 1 - mkspecs/features/symbian/application_icon.prf | 4 +- qmake/generators/symbian/epocroot.h | 51 +++++++ .../symbian/initprojectdeploy_symbian.cpp | 133 ++++++++++++++++ .../generators/symbian/initprojectdeploy_symbian.h | 5 + qmake/generators/symbian/symmake.cpp | 5 +- qmake/project.cpp | 169 +-------------------- qmake/project.h | 5 +- qmake/qmake.pri | 1 + tests/auto/qdatastream/qdatastream.pro | 1 + tests/auto/qdir/qdir.pro | 1 + tests/auto/qdirmodel/qdirmodel.pro | 1 + tests/auto/qicoimageformat/qicoimageformat.pro | 1 + tests/auto/qlocalsocket/test/test.pro | 1 + tests/auto/qscriptengine/qscriptengine.pro | 1 + 15 files changed, 205 insertions(+), 175 deletions(-) create mode 100644 qmake/generators/symbian/epocroot.h diff --git a/mkspecs/features/qttest_p4.prf b/mkspecs/features/qttest_p4.prf index ae58c5d..4ab5ac2 100644 --- a/mkspecs/features/qttest_p4.prf +++ b/mkspecs/features/qttest_p4.prf @@ -6,7 +6,6 @@ qtAddLibrary(QtTest) symbian:{ # qt.prf sets TARGET.EPOCSTACKSIZE and TARGET.EPOCHEAPSIZE # DEFINES += QTEST_NO_SPECIALIZATIONS - TARGET.UID3 = $$generate_test_uid($$TARGET) TARGET.CAPABILITY="ALL -TCB" RSS_RULES ="group_name=\"QtTests\";" } diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index df4bb1c..97b99a5 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -13,8 +13,8 @@ contains( CONFIG, no_icon ) { message("ICON keyword must have one or the same amout of items as in TRANSLATIONS keyword") } - # MIF files will have UID in their names, if TARGET.UID3 is not set we need to generate it - isEmpty(TARGET.UID3):TARGET.UID3 = $$generate_test_uid($$TARGET) + # MIF files will have UID in their names, if TARGET.UID3 is not set, remind the user + isEmpty(TARGET.UID3):error("TARGET.UID3 must be explicitly defined for ICON generation") # Note: symbian-sbsv2 builds can't utilize extra compiler for mifconv, so ICON handling is done in code symbian-abld { diff --git a/qmake/generators/symbian/epocroot.h b/qmake/generators/symbian/epocroot.h new file mode 100644 index 0000000..02884b1 --- /dev/null +++ b/qmake/generators/symbian/epocroot.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef EPOCROOT_H +#define EPOCROOT_H + +#include + +// Implementation of epocRoot method is in initprojectdeploy_symbian.cpp +// Defined in separate header for inclusion clarity +extern QString epocRoot(); + +#endif // EPOCROOT_H diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.cpp b/qmake/generators/symbian/initprojectdeploy_symbian.cpp index 392eca2..7b58adc 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp +++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp @@ -42,6 +42,8 @@ #include "initprojectdeploy_symbian.h" #include #include +#include +#include #include #define PLUGIN_STUB_DIR "qmakepluginstubs" @@ -51,6 +53,99 @@ #define SUFFIX_EXE "exe" #define SUFFIX_QTPLUGIN "qtplugin" +static void fixEpocRootStr(QString& path) +{ + path.replace("\\", "/"); + + if (path.size() > 1 && path[1] == QChar(':')) { + path = path.mid(2); + } + + if (!path.size() || path[path.size()-1] != QChar('/')) { + path += QChar('/'); + } +} + +#define SYMBIAN_SDKS_KEY "HKEY_LOCAL_MACHINE\\Software\\Symbian\\EPOC SDKs" + +static QString epocRootStr; + +QString epocRoot() +{ + if (!epocRootStr.isEmpty()) { + return epocRootStr; + } + + // First, check the env variable + epocRootStr = qgetenv("EPOCROOT"); + + if (epocRootStr.isEmpty()) { + // No EPOCROOT set, check the default device + // First check EPOCDEVICE env variable + QString defaultDevice = qgetenv("EPOCDEVICE"); + + // Check the windows registry via QSettings for devices.xml path + QSettings settings(SYMBIAN_SDKS_KEY, QSettings::NativeFormat); + QString devicesXmlPath = settings.value("CommonPath").toString(); + + if (!devicesXmlPath.isEmpty()) { + // Parse xml for correct device + devicesXmlPath += "/devices.xml"; + QFile devicesFile(devicesXmlPath); + if (devicesFile.open(QIODevice::ReadOnly)) { + QXmlStreamReader xml(&devicesFile); + while (!xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "devices") { + if (xml.attributes().value("version") == "1.0") { + // Look for correct device + while (!(xml.isEndElement() && xml.name() == "devices") && !xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "device") { + if ((defaultDevice.isEmpty() && xml.attributes().value("default") == "yes") || + (!defaultDevice.isEmpty() && (xml.attributes().value("id").toString() + QString(":") + xml.attributes().value("name").toString()) == defaultDevice)) { + // Found the correct device + while (!(xml.isEndElement() && xml.name() == "device") && !xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "epocroot") { + epocRootStr = xml.readElementText(); + fixEpocRootStr(epocRootStr); + return epocRootStr; + } + } + xml.raiseError("No epocroot element found"); + } + } + } + } else { + xml.raiseError("Invalid 'devices' element version"); + } + } + } + if (xml.hasError()) { + fprintf(stderr, "ERROR: \"%s\" when parsing devices.xml\n", qPrintable(xml.errorString())); + } + } else { + fprintf(stderr, "Could not open devices.xml (%s)\n", qPrintable(devicesXmlPath)); + } + } else { + fprintf(stderr, "Could not retrieve " SYMBIAN_SDKS_KEY " setting\n"); + } + + fprintf(stderr, "Failed to determine epoc root.\n"); + if (!defaultDevice.isEmpty()) + fprintf(stderr, "The device indicated by EPOCDEVICE environment variable (%s) could not be found.\n", qPrintable(defaultDevice)); + fprintf(stderr, "Either set EPOCROOT or EPOCDEVICE environment variable to a valid value, or provide a default Symbian device.\n"); + + // No valid device found; set epocroot to "/" + epocRootStr = QLatin1String("/"); + } + + fixEpocRootStr(epocRootStr); + return epocRootStr; +} + + static bool isPlugin(const QFileInfo& info, const QString& devicePath) { // Libraries are plugins if deployment path is something else than @@ -103,6 +198,44 @@ static void createPluginStub(const QFileInfo& info, Option::fixPathToLocalOS(devicePath + "\\" + stubInfo.fileName()))); } +QString generate_uid(const QString& target) +{ + static QMap targetToUid; + + QString tmp = targetToUid[target]; + + if (!tmp.isEmpty()) { + return tmp; + } + + unsigned long hash = 5381; + int c; + + for (int i = 0; i < target.size(); ++i) { + c = target.at(i).toAscii(); + hash ^= c + ((c - i) << i % 20) + ((c + i) << (i + 5) % 20) + ((c - 2 * i) << (i + 10) % 20) + ((c + 2 * i) << (i + 15) % 20); + } + + tmp.setNum(hash, 16); + for (int i = tmp.size(); i < 8; ++i) + tmp.prepend("0"); + + targetToUid[target] = tmp; + + return tmp; +} + +// UIDs starting with 0xE are test UIDs in symbian +QString generate_test_uid(const QString& target) +{ + QString tmp = generate_uid(target); + tmp.replace(0, 1, "E"); + tmp.prepend("0x"); + + return tmp; +} + + void initProjectDeploySymbian(QMakeProject* project, DeploymentList &deploymentList, const QString &testPath, diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.h b/qmake/generators/symbian/initprojectdeploy_symbian.h index a104985..867a910 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.h +++ b/qmake/generators/symbian/initprojectdeploy_symbian.h @@ -50,6 +50,8 @@ #include #include +#include "epocroot.h" + struct CopyItem { CopyItem(const QString& f, const QString& t) : from(f) , to(t) { } @@ -58,6 +60,9 @@ struct CopyItem }; typedef QList DeploymentList; +extern QString generate_uid(const QString& target); +extern QString generate_test_uid(const QString& target); + extern void initProjectDeploySymbian(QMakeProject* project, DeploymentList &deploymentList, const QString &testPath, diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index b3fa0f2..f4886d5 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -486,7 +486,7 @@ void SymbianMakefileGenerator::init() // .mmp initMmpVariables(); - // Check TARGET.UID2 and TARGET.UID3 presence + // Check TARGET.UID3 presence if (0 != project->values("TARGET.UID3").size()) { uid3 = project->first("TARGET.UID3"); } else { @@ -1686,4 +1686,5 @@ void SymbianMakefileGenerator::generateDistcleanTargets(QTextStream& t) t << "distclean: clean dodistclean" << endl; t << endl; -} \ No newline at end of file +} + diff --git a/qmake/project.cpp b/qmake/project.cpp index 8455c6d..7239ee9 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -44,6 +44,8 @@ #include "option.h" #include "cachekeys.h" +#include "epocroot.h" + #include #include #include @@ -52,8 +54,6 @@ #include #include #include -#include -#include #include #ifdef Q_OS_UNIX #include @@ -79,7 +79,7 @@ enum ExpandFunc { E_MEMBER=1, E_FIRST, E_LAST, E_CAT, E_FROMFILE, E_EVAL, E_LIST E_SPRINTF, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION, E_FIND, E_SYSTEM, E_UNIQUE, E_QUOTE, E_ESCAPE_EXPAND, E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_REPLACE, - E_GENERATE_TEST_UID, E_SIZE }; + E_SIZE }; QMap qmake_expandFunctions() { static QMap *qmake_expand_functions = 0; @@ -110,7 +110,6 @@ QMap qmake_expandFunctions() qmake_expand_functions->insert("files", E_FILES); qmake_expand_functions->insert("prompt", E_PROMPT); qmake_expand_functions->insert("replace", E_REPLACE); - qmake_expand_functions->insert("generate_test_uid", E_GENERATE_TEST_UID); qmake_expand_functions->insert("size", E_SIZE); } return *qmake_expand_functions; @@ -2395,22 +2394,6 @@ QMakeProject::doProjectExpand(QString func, QList args_list, ret += it->replace(before, after); } break; } - case E_GENERATE_TEST_UID: { - if(args.count() != 1) { - fprintf(stderr, "%s:%d: generate_test_uid(targetname) requires one argument.\n", - parser.file.toLatin1().constData(), parser.line_no); - } else { - QString target = args[0]; - - QString currPath = qmake_getpwd(); - target.prepend("/").prepend(currPath); - - - QString tmp = generate_test_uid(target); - - ret += tmp; - } - break; } case E_SIZE: { if(args.count() != 1) { fprintf(stderr, "%s:%d: size(var) requires one argument.\n", @@ -3308,150 +3291,4 @@ QStringList &QMakeProject::values(const QString &_var, QMap targetToUid; - - QString tmp = targetToUid[target]; - - if (!tmp.isEmpty()) { - return tmp; - } - - unsigned long hash = 5381; - int c; - - for (int i = 0; i < target.size(); ++i) { - c = target.at(i).toAscii(); - hash ^= c + ((c - i) << i % 20) + ((c + i) << (i + 5) % 20) + ((c - 2 * i) << (i + 10) % 20) + ((c + 2 * i) << (i + 15) % 20); - } - - tmp.setNum(hash, 16); - for (int i = tmp.size(); i < 8; ++i) - tmp.prepend("0"); - -#if 0 - static QMap uidConflictCheckList; - QString testStr = tmp; - testStr.replace(0, 1, "E"); // Simulate actual UID generation - if (uidConflictCheckList.contains(testStr)) { - printf("\n\n!!!! generated duplicate uid for %s is %s <-> %s !!!!\n\n\n", - qPrintable(target), - qPrintable(testStr), - qPrintable(uidConflictCheckList.value(testStr))); - } - uidConflictCheckList.insert(testStr, target); - printf("generate_uid for %s is %s \n", qPrintable(target), qPrintable(tmp)); -#endif - - targetToUid[target] = tmp; - - return tmp; -} - -static void fixEpocRootStr(QString& path) -{ - path.replace("\\", "/"); - - if (path.size() > 1 && path[1] == QChar(':')) { - path = path.mid(2); - } - - if (!path.size() || path[path.size()-1] != QChar('/')) { - path += QChar('/'); - } -} - -#define SYMBIAN_SDKS_KEY "HKEY_LOCAL_MACHINE\\Software\\Symbian\\EPOC SDKs" - -static QString epocRootStr; - -QString epocRoot() -{ - if (!epocRootStr.isEmpty()) { - return epocRootStr; - } - - // First, check the env variable - epocRootStr = qgetenv("EPOCROOT"); - - if (epocRootStr.isEmpty()) { - // No EPOCROOT set, check the default device - // First check EPOCDEVICE env variable - QString defaultDevice = qgetenv("EPOCDEVICE"); - - // Check the windows registry via QSettings for devices.xml path - QSettings settings(SYMBIAN_SDKS_KEY, QSettings::NativeFormat); - QString devicesXmlPath = settings.value("CommonPath").toString(); - - if (!devicesXmlPath.isEmpty()) { - // Parse xml for correct device - devicesXmlPath += "/devices.xml"; - QFile devicesFile(devicesXmlPath); - if (devicesFile.open(QIODevice::ReadOnly)) { - QXmlStreamReader xml(&devicesFile); - while (!xml.atEnd()) { - xml.readNext(); - if (xml.isStartElement() && xml.name() == "devices") { - if (xml.attributes().value("version") == "1.0") { - // Look for correct device - while (!(xml.isEndElement() && xml.name() == "devices") && !xml.atEnd()) { - xml.readNext(); - if (xml.isStartElement() && xml.name() == "device") { - if ((defaultDevice.isEmpty() && xml.attributes().value("default") == "yes") || - (!defaultDevice.isEmpty() && (xml.attributes().value("id").toString() + QString(":") + xml.attributes().value("name").toString()) == defaultDevice)) { - // Found the correct device - while (!(xml.isEndElement() && xml.name() == "device") && !xml.atEnd()) { - xml.readNext(); - if (xml.isStartElement() && xml.name() == "epocroot") { - epocRootStr = xml.readElementText(); - fixEpocRootStr(epocRootStr); - return epocRootStr; - } - } - xml.raiseError("No epocroot element found"); - } - } - } - } else { - xml.raiseError("Invalid 'devices' element version"); - } - } - } - if (xml.hasError()) { - fprintf(stderr, "ERROR: \"%s\" when parsing devices.xml\n", qPrintable(xml.errorString())); - } - } else { - fprintf(stderr, "Could not open devices.xml (%s)\n", qPrintable(devicesXmlPath)); - } - } else { - fprintf(stderr, "Could not retrieve " SYMBIAN_SDKS_KEY " setting\n"); - } - - fprintf(stderr, "Failed to determine epoc root.\n"); - if (!defaultDevice.isEmpty()) - fprintf(stderr, "The device indicated by EPOCDEVICE environment variable (%s) could not be found.\n", qPrintable(defaultDevice)); - fprintf(stderr, "Either set EPOCROOT or EPOCDEVICE environment variable to a valid value, or provide a default Symbian device.\n"); - - // No valid device found; set epocroot to "/" - epocRootStr = QLatin1String("/"); - } - - fixEpocRootStr(epocRootStr); - return epocRootStr; -} - QT_END_NAMESPACE diff --git a/qmake/project.h b/qmake/project.h index 8d15724..7273c2b 100644 --- a/qmake/project.h +++ b/qmake/project.h @@ -203,10 +203,7 @@ inline QString QMakeProject::first(const QString &v) inline QMap &QMakeProject::variables() { return vars; } -// Helper functions needed for Symbian .mmp files and deployment -QString generate_test_uid(const QString& target); -QString generate_uid(const QString& target); -QString epocRoot(); +// Helper functions needed for Symbian bool isForSymbian(); bool isForSymbianSbsv2(); diff --git a/qmake/qmake.pri b/qmake/qmake.pri index fe15d71..206c1c2 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -29,6 +29,7 @@ HEADERS += project.h property.h generators/makefile.h \ generators/symbian/symmake.h \ generators/symbian/symmake_abld.h \ generators/symbian/symmake_sbsv2.h \ + generators/symbian/epocroot.h \ generators/symbian/initprojectdeploy_symbian.h contains(QT_EDITION, OpenSource) { diff --git a/tests/auto/qdatastream/qdatastream.pro b/tests/auto/qdatastream/qdatastream.pro index 317c3bf..5b90357 100644 --- a/tests/auto/qdatastream/qdatastream.pro +++ b/tests/auto/qdatastream/qdatastream.pro @@ -22,6 +22,7 @@ wince*: { addFiles.path = . DEPLOYMENT += addFiles TARGET.EPOCHEAPSIZE = 1000000 10000000 + TARGET.UID3 = 0xE0340001 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) }else { DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/qdir/qdir.pro b/tests/auto/qdir/qdir.pro index 8fe5d83..0111672 100644 --- a/tests/auto/qdir/qdir.pro +++ b/tests/auto/qdir/qdir.pro @@ -16,6 +16,7 @@ wince*:{ QT = core TARGET.CAPABILITY += AllFiles + TARGET.UID3 = 0xE0340002 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } else { QT = core diff --git a/tests/auto/qdirmodel/qdirmodel.pro b/tests/auto/qdirmodel/qdirmodel.pro index 6b3a707..19ec231 100644 --- a/tests/auto/qdirmodel/qdirmodel.pro +++ b/tests/auto/qdirmodel/qdirmodel.pro @@ -14,6 +14,7 @@ wince*|symbian: { wince*: { DEFINES += SRCDIR=\\\"./\\\" } symbian: { + TARGET.UID3 = 0xE0340003 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/qicoimageformat/qicoimageformat.pro b/tests/auto/qicoimageformat/qicoimageformat.pro index 45f616a..c0aa4b5 100644 --- a/tests/auto/qicoimageformat/qicoimageformat.pro +++ b/tests/auto/qicoimageformat/qicoimageformat.pro @@ -18,6 +18,7 @@ wince*: { addPlugins.sources = qico.dll addPlugins.path = imageformats DEPLOYMENT += addFiles addPlugins + TARGET.UID3 = 0xE0340004 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } else { DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/qlocalsocket/test/test.pro b/tests/auto/qlocalsocket/test/test.pro index da741b9..503f769 100644 --- a/tests/auto/qlocalsocket/test/test.pro +++ b/tests/auto/qlocalsocket/test/test.pro @@ -35,6 +35,7 @@ wince* { symbian { additionalFiles.sources = lackey.exe additionalFiles.path = \sys\bin + TARGET.UID3 = 0xE0340005 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } diff --git a/tests/auto/qscriptengine/qscriptengine.pro b/tests/auto/qscriptengine/qscriptengine.pro index 4d1828f..f72c070 100644 --- a/tests/auto/qscriptengine/qscriptengine.pro +++ b/tests/auto/qscriptengine/qscriptengine.pro @@ -10,6 +10,7 @@ wince*|symbian*: { } symbian: { + TARGET.UID3 = 0xE0340006 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" } -- cgit v0.12 From 0b658e2bc30e4dc0a8cc90f13b2e63a8175081b0 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 19 Aug 2009 14:54:25 +0200 Subject: Preload the tiles for the zoomed out version of the map. This eats more network, but helps to avoid the impression that the magnifying glass does not work. (This is cherry-picked from Graphics Dojo fix). Reviewed-by: TrustMe --- demos/embedded/lightmaps/lightmaps.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/demos/embedded/lightmaps/lightmaps.cpp b/demos/embedded/lightmaps/lightmaps.cpp index fdb86fd..6ad2020 100644 --- a/demos/embedded/lightmaps/lightmaps.cpp +++ b/demos/embedded/lightmaps/lightmaps.cpp @@ -269,6 +269,7 @@ public: m_normalMap->latitude = lat; m_normalMap->longitude = lng; m_normalMap->invalidate(); + m_largeMap->invalidate(); } public slots: @@ -300,6 +301,9 @@ protected: m_normalMap->width = width(); m_normalMap->height = height(); m_normalMap->invalidate(); + m_largeMap->width = m_normalMap->width * 2; + m_largeMap->height = m_normalMap->height * 2; + m_largeMap->invalidate(); } void paintEvent(QPaintEvent *event) { -- cgit v0.12 From 05b30326aa7c862cb8dd25e202267eb1e3c378a6 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Wed, 19 Aug 2009 15:15:19 +0200 Subject: Tidy up the PRELOAD macro definitions in qdrawhelper.cpp. Remove a little bit of duplicated code here after code reviews. Reviewed-by: Miikka Heikkinen --- src/gui/painting/qdrawhelper.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 9ca5572..ddb47ce 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1231,17 +1231,14 @@ static const uint L2CacheLineLengthInInts = L2CacheLineLength/sizeof(uint); // Two consecutive preloads stall, so space them out a bit by using different modulus. # define PRELOAD_COND2(x,y) if (((uint)&x[i])%L2CacheLineLength == 0) preload(&x[i] + L2CacheLineLengthInInts); \ if (((uint)&y[i])%L2CacheLineLength == 16) preload(&y[i] + L2CacheLineLengthInInts); -# else +# endif // QT_HAVE_ARMV6 +#endif // Q_CC_RVCT + +#if !defined(Q_CC_RVCT) || !defined(QT_HAVE_ARMV6) # define PRELOAD_INIT(x) # define PRELOAD_INIT2(x,y) # define PRELOAD_COND(x) # define PRELOAD_COND2(x,y) -# endif -#else -# define PRELOAD_INIT(x) -# define PRELOAD_INIT2(x,y) -# define PRELOAD_COND(x) -# define PRELOAD_COND2(x,y) #endif /* The constant alpha factor describes an alpha factor that gets applied -- cgit v0.12 From dc6c7b7b2fa5a1df1aa26cb170679a5f008fd20a Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 19 Aug 2009 15:33:30 +0200 Subject: Remove win32-mwc support, as per suggested in review comment by Espen. Reviewed-by: axis --- tools/configure/configure.pro | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index c87fd11..06e9fe0 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -6,10 +6,7 @@ CONFIG -= moc qt DEFINES = UNICODE QT_NODLL QT_NO_CODECS QT_NO_TEXTCODEC QT_NO_UNICODETABLES QT_LITE_COMPONENT QT_NO_STL QT_NO_COMPRESS QT_BUILD_QMAKE QT_NO_THREAD QT_NO_QOBJECT _CRT_SECURE_NO_DEPRECATE -win32 : !win32-mwc : LIBS += -lole32 -ladvapi32 -win32-mwc { - LIBS += -ladvapi32.lib -luuid.lib -} +win32 : LIBS += -lole32 -ladvapi32 win32-msvc.net | win32-msvc2* : QMAKE_CXXFLAGS += /EHsc win32-g++ : LIBS += -luuid -- cgit v0.12 From e9c2263b0be0696dca42a9f0f93c47674826b719 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 19 Aug 2009 15:39:55 +0200 Subject: Added some comments after code review. RevBy: Trust me --- src/corelib/thread/qthread_unix.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index b0b285e..5401cfd 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -208,6 +208,7 @@ void QThreadPrivate::createEventDispatcher(QThreadData *data) void *QThreadPrivate::start(void *arg) { + // Symbian Open C supports neither thread cancellation nor cleanup_push. #ifndef Q_OS_SYMBIAN pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); pthread_cleanup_push(QThreadPrivate::finish, arg); @@ -584,6 +585,11 @@ void QThread::terminate() } d->terminated = true; + // "false, false" meaning: + // 1. lockAnyway = false. Don't lock the mutex because it's already locked + // (see above). + // 2. closeNativeSymbianHandle = false. We don't want to close the thread handle, + // because we need it here to terminate the thread. QThreadPrivate::finish(this, false, false); d->data->symbian_thread_handle.Terminate(KErrNone); d->data->symbian_thread_handle.Close(); @@ -627,6 +633,9 @@ void QThread::setTerminationEnabled(bool enabled) d->terminationEnabled = enabled; if (enabled && d->terminatePending) { d->terminated = true; + // "false" meaning: + // - lockAnyway = false. Don't lock the mutex because it's already locked + // (see above). QThreadPrivate::finish(thr, false); locker.unlock(); // don't leave the mutex locked! pthread_exit(NULL); -- cgit v0.12 From af6d0ac59424e75ee840b668f193a1d5973efe07 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 19 Aug 2009 15:40:40 +0200 Subject: Reverse the ifdefs to make it clearer, as per code review. RevBy: Trust me --- src/corelib/thread/qthread_unix.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 5401cfd..30914f4 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -243,10 +243,10 @@ void *QThreadPrivate::start(void *arg) #endif thr->run(); -#ifndef Q_OS_SYMBIAN - pthread_cleanup_pop(1); -#else +#ifdef Q_OS_SYMBIAN QThreadPrivate::finish(arg); +#else + pthread_cleanup_pop(1); #endif return 0; -- cgit v0.12 From bf8de28190bb0ac5cbcde550fdfb86f42c504f00 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 19 Aug 2009 16:55:47 +0200 Subject: Ifdef compiler workaround. Addresses review comment. --- tests/auto/qcombobox/tst_qcombobox.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index c364129..9700839 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2260,7 +2260,11 @@ void tst_QComboBox::setItemDelegate() QComboBox comboBox; QStyledItemDelegate *itemDelegate = new QStyledItemDelegate; comboBox.setItemDelegate(itemDelegate); - QCOMPARE(static_cast(comboBox.itemDelegate()), itemDelegate); + QCOMPARE( +#ifdef Q_CC_MWERKS + static_cast +#endif + (comboBox.itemDelegate()), itemDelegate); } void tst_QComboBox::task253944_itemDelegateIsReset() @@ -2270,10 +2274,18 @@ void tst_QComboBox::task253944_itemDelegateIsReset() comboBox.setItemDelegate(itemDelegate); comboBox.setEditable(true); - QCOMPARE(static_cast(comboBox.itemDelegate()), itemDelegate); + QCOMPARE( +#ifdef Q_CC_MWERKS + static_cast +#endif + (comboBox.itemDelegate()), itemDelegate); comboBox.setStyleSheet("QComboBox { border: 1px solid gray; }"); - QCOMPARE(static_cast(comboBox.itemDelegate()), itemDelegate); + QCOMPARE( +#ifdef Q_CC_MWERKS + static_cast +#endif + (comboBox.itemDelegate()), itemDelegate); } -- cgit v0.12 From af0d032ddeb09250a3b22302bec8e8996dddd687 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 19 Aug 2009 17:14:45 +0200 Subject: Remove commented line. --- tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 8e40873..c18b5c8 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -160,7 +160,6 @@ void tst_ExceptionSafetyObjects::objects_data() NEWROW(QFile); NEWROW(QProcess); NEWROW(QSettings); - // NEWROW(QSocketNotifier); NEWROW(QThread); NEWROW(QThreadPool); NEWROW(QTranslator); -- cgit v0.12 From e15bb13513e1157094c42d014db906063d057230 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 19 Aug 2009 17:25:54 +0200 Subject: Remove dead commment. Addresses review. Reviewed-by: TrustMe --- tests/auto/qsslsocket/tst_qsslsocket.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index a02c21e..9c5086a 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -538,7 +538,6 @@ void tst_QSslSocket::sslErrors() SslErrorList output; foreach (QSslError error, socket->sslErrors()) { - //printf("error = %s\n", error.errorString().toAscii().data()); output << error.error(); } -- cgit v0.12 From dbdeae0da8702379c1dabb11bfe8440438c1fd98 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 20 Aug 2009 08:53:10 +0200 Subject: Removing unnecessary comments and enabling additional test rows that were forgotten. --- tests/auto/qsslsocket/tst_qsslsocket.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 9c5086a..ba5ef70 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -249,13 +249,13 @@ void tst_QSslSocket::initTestCase_data() QTest::addColumn("setProxy"); QTest::addColumn("proxyType"); - //QTest::newRow("WithoutProxy") << false << 0; + QTest::newRow("WithoutProxy") << false << 0; #ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy); - //QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic); + QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic); - //QTest::newRow("WithHttpProxy") << true << int(HttpProxy); - //QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic); + QTest::newRow("WithHttpProxy") << true << int(HttpProxy); + QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic); // uncomment the line below when NTLM works // QTest::newRow("WithHttpProxyNtlmAuth") << true << int(HttpProxy | AuthNtlm); #endif -- cgit v0.12 From 5ce1ce19cc34c389ac4705d85582ee1c57519175 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 20 Aug 2009 09:08:31 +0200 Subject: No need to use more time in QTimer::singleShot() than on other platforms. --- tests/auto/qhttp/tst_qhttp.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/auto/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp index b0835ac..fcc80ab 100644 --- a/tests/auto/qhttp/tst_qhttp.cpp +++ b/tests/auto/qhttp/tst_qhttp.cpp @@ -1242,11 +1242,7 @@ void tst_QHttp::unexpectedRemoteClose() QCoreApplication::instance()->processEvents(); QEventLoop loop; -#ifndef Q_OS_SYMBIAN QTimer::singleShot(3000, &loop, SLOT(quit())); -#else - QTimer::singleShot(30000, &loop, SLOT(quit())); -#endif QHttp http; QObject::connect(&http, SIGNAL(done(bool)), &loop, SLOT(quit())); -- cgit v0.12 From b0743dd4e6f72108ac1fd989a418969fd241335d Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 20 Aug 2009 09:26:22 +0200 Subject: Removing commented lines. --- tests/auto/qftp/tst_qftp.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index c60a5cd..34b42a9 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -1556,16 +1556,10 @@ void tst_QFtp::binaryAscii() ResMapIt it2 = resultMap.find(QFtp::Get); QVERIFY(it2 != resultMap.end()); QVERIFY(it2.value().success); -/* -#ifdef Q_OS_SYMBIAN - QVERIFY(getData.size() == putData.size()); -#else -*/ // most modern ftp servers leave the file as it is by default // (and do not remove the windows line ending), the -1 below could be // deleted in the future QVERIFY(getData.size() == putData.size()-1); -//#endi ////////////////////////////////////////////////////////////////// // cleanup (i.e. remove the file) -- this also tests the remove command init(); -- cgit v0.12 From 78c4473499a9269615e0001fd6afa245d4674277 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 20 Aug 2009 09:31:52 +0200 Subject: Make qprintdialog_unix.cpp compile on some Unices. As part of the exception changes, the include of qfiledialog_p.h was removed and this then removed the inclusion of qevent.h which is needed by the showEvent() function in order to call accept(). Reviewed-by: Miikka Heikkinen --- src/gui/dialogs/qprintdialog_unix.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp index a491532..eb66ecb 100644 --- a/src/gui/dialogs/qprintdialog_unix.cpp +++ b/src/gui/dialogs/qprintdialog_unix.cpp @@ -48,6 +48,7 @@ #include "qprintdialog.h" #include "qfiledialog.h" #include +#include #include #include #include -- cgit v0.12 From d2551a711786b3c43ac6fef6cabd8555142f1924 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 20 Aug 2009 09:41:21 +0200 Subject: We can use runs = 100 in the test case. On Symbian platform it will take longer time. --- tests/auto/qhostinfo/tst_qhostinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index e129f87..6dbada1 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -391,7 +391,7 @@ protected: void tst_QHostInfo::threadSafety() { const int nattempts = 5; -#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) +#if defined(Q_OS_WINCE) const int runs = 10; #else const int runs = 100; -- cgit v0.12 From 1e496321d0fe7e1f1b40f1f94a18c17f7e38f9cd Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 20 Aug 2009 10:46:11 +0200 Subject: Removuing lines that were commented. --- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 3 +-- tests/auto/qudpsocket/tst_qudpsocket.cpp | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 5ee615b..9bbb344 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -81,7 +81,7 @@ #include #include #ifndef TEST_QNETWORK_PROXY -//#define TEST_QNETWORK_PROXY +#define TEST_QNETWORK_PROXY #endif // RVCT compiles also unused inline methods # include @@ -2231,7 +2231,6 @@ void tst_QTcpSocket::invalidProxy_data() << "this-host-will-never-exist.troll.no" << 3128 << false << int(QAbstractSocket::ProxyNotFoundError); #if !defined(Q_OS_SYMBIAN) - //QSKIP("On Symbian Emulator not clear what to expect + server settings", SkipAll); QTest::newRow("http-on-socks5") << int(QNetworkProxy::HttpProxy) << fluke << 1080 << false << int(QAbstractSocket::ProxyConnectionClosedError); QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << fluke << 3128 << false diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp index 0ae2521..8d09924 100644 --- a/tests/auto/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp @@ -552,8 +552,6 @@ void tst_QUdpSocket::bindMode() QUdpSocket socket2; QVERIFY(!socket2.bind(socket.localPort())); #if defined(Q_OS_SYMBIAN) - - //RPRocess me; if(RProcess().HasCapability(ECapabilityNetworkControl)) { qDebug("Test executed *with* NetworkControl capability"); // In Symbian OS ReuseAddressHint together with NetworkControl capability -- cgit v0.12 From d3d7969329f42d52ed7140cb2fd684171a484eb5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 20 Aug 2009 11:58:19 +0300 Subject: Comment clarifications based on mkspecs review. Reviewed-by: TrustMe --- mkspecs/common/symbian/stl-off/new | 2 +- mkspecs/features/symbian/qt.prf | 3 +++ mkspecs/features/symbian/stl.prf | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mkspecs/common/symbian/stl-off/new b/mkspecs/common/symbian/stl-off/new index 3939e11..8584ba3 100644 --- a/mkspecs/common/symbian/stl-off/new +++ b/mkspecs/common/symbian/stl-off/new @@ -1,4 +1,4 @@ -// new implemented in symbian libs, do nothing here, just keep Qt happpy +// 'new' implemented in symbian libs, so do nothing here; just keep Qt happy #ifndef __NEW_SYMB_ADDON #define __NEW_SYMB_ADDON #include diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf index db2ea14..dd4a4d5 100644 --- a/mkspecs/features/symbian/qt.prf +++ b/mkspecs/features/symbian/qt.prf @@ -6,6 +6,9 @@ CONFIG += qtmain load(qt) +# Add dependency to QtLibs package to all other projects besides QtLibs. +# Note: QtLibs with full capabilities has UID3 of 0x2001E61C, +# while self-signed version typically has temporary UID3 of 0xE001E61C. contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C) { default_deployment.pkg_prerules += \ "; Default dependency to Qt libraries" \ diff --git a/mkspecs/features/symbian/stl.prf b/mkspecs/features/symbian/stl.prf index 9eb6b86..c885bb7 100644 --- a/mkspecs/features/symbian/stl.prf +++ b/mkspecs/features/symbian/stl.prf @@ -1,14 +1,15 @@ CONFIG -= stl_off -# STL usage in S60 requires the following mmp variables to be uses +# STL usage in S60 requires the following mmp variables to be used. +# These are added via $$STLLIB_USAGE_CW_FLAGS and $$STLLIB_USAGE_DEFINES +# variables below. # OPTION CW -wchar_t on # MACRO _WCHAR_T_DECLARED QMAKE_CXXFLAGS.CW *= $$STLLIB_USAGE_CW_FLAGS DEFINES *= $$STLLIB_USAGE_DEFINES -# Legacy support requires some hardcoded stdapis paths. -# Note: Also the new header is used from STL when it is enabled +# Path to stlport headers INCLUDEPATH += $$OS_LAYER_STDCPP_SYSTEMINCLUDE # Remove mkspecs/common/symbian/stl-off from beginning of includepath -- cgit v0.12 From ca1c3a91d9a8e276585b3970582fb338302ba4a5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 20 Aug 2009 12:11:50 +0300 Subject: Fixed compile warning in qmake Wrapped QString passed to fprintf into qPrintable to get rid of compiler warning. Task-number: 259463 Reviewed-by: TrustMe --- qmake/generators/symbian/symmake_sbsv2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index 1cbd9f4..2471a2b 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -365,7 +365,7 @@ void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t if (icons.size()) { QString icon = icons.first(); if (icons.size() > 1) - fprintf(stderr, "Warning: Only first icon specified in ICON variable is used: '%s'.", icon); + fprintf(stderr, "Warning: Only first icon specified in ICON variable is used: '%s'.", qPrintable(icon)); t << "START EXTENSION s60/mifconv" << endl; -- cgit v0.12 From 7a9a09fea2926e003e15d1220ca7de089a108a8c Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 20 Aug 2009 12:16:58 +0300 Subject: Changed a define to comply to Qt naming conventions. Prepended QT_ to a define we use internally in fixed_stdlib.h Reviewed-by: Janne Anttila --- mkspecs/common/symbian/fixed_stdlib.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mkspecs/common/symbian/fixed_stdlib.h b/mkspecs/common/symbian/fixed_stdlib.h index a6dcbc7..f8dc138 100644 --- a/mkspecs/common/symbian/fixed_stdlib.h +++ b/mkspecs/common/symbian/fixed_stdlib.h @@ -49,16 +49,16 @@ // If _WCHAR_T_DECLARED is defined, undef it and store information that we // need to revert the _WCHAR_T_DECLARED define after include # ifdef _WCHAR_T_DECLARED -# define REVERT_WCHAR_T_DECLARED +# define QT_REVERT_WCHAR_T_DECLARED # undef _WCHAR_T_DECLARED # endif //_WCHAR_T_DECLARED #include // Revert _WCHAR_T_DECLARED if necessary -# ifdef REVERT_WCHAR_T_DECLARED +# ifdef QT_REVERT_WCHAR_T_DECLARED # define _WCHAR_T_DECLARED -# undef REVERT_WCHAR_T_DECLARED -# endif //REVERT_WCHAR_T_DECLARED +# undef QT_REVERT_WCHAR_T_DECLARED +# endif //QT_REVERT_WCHAR_T_DECLARED #endif -- cgit v0.12 From 821619ea1a4962b87e509c9aeedb35cd6a4b0434 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Thu, 20 Aug 2009 11:33:10 +0200 Subject: Move the declarative ui destroyed handling Otherwise, the qWarning will be bogus. --- src/corelib/kernel/qobject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 55c8e12..5247290 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -836,8 +836,6 @@ QObject::~QObject() QT_TRY { emit destroyed(this); - if (d->declarativeData) - d->declarativeData->destroyed(this); // ### TODO: Can this throw? } QT_CATCH(...) { // all the signal/slots connections are still in place - if we don't // quit now, we will crash pretty soon. @@ -854,6 +852,8 @@ QObject::~QObject() #endif } + if (d->declarativeData) + d->declarativeData->destroyed(this); { QMutex *signalSlotMutex = 0; -- cgit v0.12 From 7b962163d416f62f862c736738dddd58c1a617bc Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 20 Aug 2009 11:56:16 +0200 Subject: Add support for LIBS_PRIVATE to the Symbian generators. Qt added a new internal variable called LIBS_PRIVATE that should be added to the libraries section of the generated build file. Add this to bring us up to parity with the other platforms. Reviewed-by: Miikka Heikkinen --- qmake/generators/symbian/symmake.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index 4665912..c20ecf3 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -479,6 +479,7 @@ void SymbianMakefileGenerator::init() project->values("QMAKESPEC").append(qgetenv("QMAKESPEC")); project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); + project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); // bld.inf project->values("MAKEFILE") += BLD_INF_FILENAME; @@ -878,7 +879,7 @@ void SymbianMakefileGenerator::writeMmpFileIncludePart(QTextStream& t) void SymbianMakefileGenerator::writeMmpFileLibraryPart(QTextStream& t) { QStringList &libs = project->values("LIBS"); - libs << project->values("QMAKE_LIBS"); + libs << project->values("QMAKE_LIBS") << project->values("QMAKE_LIBS_PRIVATE"); removeDuplicatedStrings(libs); -- cgit v0.12 From 641ad254a43572a534a3db86120e7bbe5d2df147 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Thu, 20 Aug 2009 12:04:49 +0200 Subject: Trivial: fix include --- src/gui/dialogs/qprintdialog_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp index eb66ecb..d4d8f02 100644 --- a/src/gui/dialogs/qprintdialog_unix.cpp +++ b/src/gui/dialogs/qprintdialog_unix.cpp @@ -48,7 +48,7 @@ #include "qprintdialog.h" #include "qfiledialog.h" #include -#include +#include #include #include #include -- cgit v0.12 From 1e5ad7ed3f1e6f66a8367318c32df6e5dd68250a Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 20 Aug 2009 13:21:48 +0300 Subject: Clarified comment on ordinal use in QLibraryPrivate::loadPlugin() Reviewed-by: TrustMe --- src/corelib/plugin/qlibrary.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 4cd3386..3a5bb55 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -499,9 +499,12 @@ bool QLibraryPrivate::loadPlugin() if (load()) { instance = (QtPluginInstanceFunction)resolve("qt_plugin_instance"); #if defined(Q_OS_SYMBIAN) - // If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal - if (!instance) + if (!instance) { + // If resolving with function name failed (i.e. not STDDLL), + // try resolving using known ordinal, which for + // qt_plugin_instance function is always "2". instance = (QtPluginInstanceFunction)resolve("2"); + } #endif return instance; } -- cgit v0.12 From 3f76d68d9573b81fa85c5286e2826bdadd0c9e77 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Thu, 20 Aug 2009 14:11:35 +0300 Subject: Symbian clipboard to use UID3 of QtGui. clipboard stream to use unique id instead of bogus one. Reviewed-by: Shane Kearns --- src/gui/kernel/qclipboard_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/gui/kernel/qclipboard_s60.cpp index 3c14b93..7cf4280 100644 --- a/src/gui/kernel/qclipboard_s60.cpp +++ b/src/gui/kernel/qclipboard_s60.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE //### Mime Type mapping to UIDs -const TUid KQtCbDataStream = {0x666777}; +const TUid KQtCbDataStream = {0x2001B2DD}; class QClipboardData -- cgit v0.12 From 8fe90a6651f2370d1a669fc2d543ad0d64c5ba7e Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 20 Aug 2009 14:17:29 +0300 Subject: Fixed incorrect SRCDIR usage in qsslcertificate autotest for Symbian. Reviewed-by: TrustMe --- tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index 7179a2b..c046e38 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -48,7 +48,7 @@ #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir // Current path (C:\private\) contains only ascii chars -#define SRCDIR QDir::currentPath().toAscii() +#define SRCDIR "./" #endif class tst_QSslCertificate : public QObject -- cgit v0.12 From adc732da98be7c2c13ffafaf6535e3cc47ebc0c3 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 20 Aug 2009 13:46:52 +0200 Subject: Fix compilation of qpaintengine_vg.cpp.. again. After the latest round of changes to Q_DECLARE_PRIVATE to use templates, we no longer need to call data() because Q_D() will expand to d_func() which will always return a pointer to the actual object instead of the scoped pointer. --- src/openvg/qpaintengine_vg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 2e6caf2..b0e190f 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1323,7 +1323,7 @@ QPainterState *QVGPaintEngine::createState(QPainterState *orig) const return new QVGPainterState(); } else { Q_D(const QVGPaintEngine); - QVGPaintEnginePrivate *d2 = const_cast(d.data()); + QVGPaintEnginePrivate *d2 = const_cast(d); QVGPainterState *origState = static_cast(orig); origState->savedDirty = d2->dirty; d2->dirty = 0; -- cgit v0.12