From 2c9bf5d611cbc293851c80d4df5a46c36eac41f7 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 29 Jul 2009 11:53:50 +1000 Subject: Fixes various db2 autotest issues. --- src/qt3support/sql/q3sqlcursor.cpp | 2 +- src/sql/drivers/db2/qsql_db2.cpp | 4 +++- tests/auto/qsqldatabase/tst_databases.h | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qt3support/sql/q3sqlcursor.cpp b/src/qt3support/sql/q3sqlcursor.cpp index 6b0c69f..aa6aae2 100644 --- a/src/qt3support/sql/q3sqlcursor.cpp +++ b/src/qt3support/sql/q3sqlcursor.cpp @@ -879,7 +879,7 @@ QString Q3SqlCursor::toString(const QString& prefix, QSqlField* field, const QSt { QString f; if (field && driver()) { - f = (prefix.length() > 0 ? prefix + QLatin1Char('.') : QString()) + field->name(); + f = (prefix.length() > 0 ? prefix + QLatin1Char('.') : QString()) + driver()->escapeIdentifier(field->name(), QSqlDriver::FieldName); f += QLatin1Char(' ') + fieldSep + QLatin1Char(' '); if (field->isNull()) { f += QLatin1String("NULL"); diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/sql/drivers/db2/qsql_db2.cpp index 474c53d..a32b3aa 100644 --- a/src/sql/drivers/db2/qsql_db2.cpp +++ b/src/sql/drivers/db2/qsql_db2.cpp @@ -868,11 +868,13 @@ bool QDB2Result::fetch(int i) SQL_FETCH_ABSOLUTE, actualIdx); } - if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) { + if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r != SQL_NO_DATA) { setLastError(qMakeError(QCoreApplication::translate("QDB2Result", "Unable to fetch record %1").arg(i), QSqlError::StatementError, d)); return false; } + else if (r == SQL_NO_DATA) + return false; setAt(i); return true; } diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h index 9c8c313..8253541 100644 --- a/tests/auto/qsqldatabase/tst_databases.h +++ b/tests/auto/qsqldatabase/tst_databases.h @@ -335,7 +335,7 @@ public: if(table2.compare(table.section('.', -1, -1), Qt::CaseInsensitive) == 0) { table=db.driver()->escapeIdentifier(table2, QSqlDriver::TableName); wasDropped = q.exec( "drop table " + table); - dbtables.removeAll(table); + dbtables.removeAll(table2); } } } @@ -430,8 +430,8 @@ public: return "IDENTITY"; /* if ( db.driverName().startsWith( "QPSQL" ) ) return "SERIAL";*/ - if ( db.driverName().startsWith( "QDB2" ) ) - return "GENERATED BY DEFAULT AS IDENTITY"; +// if ( db.driverName().startsWith( "QDB2" ) ) +// return "GENERATED BY DEFAULT AS IDENTITY"; return QString(); } @@ -483,6 +483,10 @@ public: { return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL") ); } + static bool isDB2( QSqlDatabase db ) + { + return db.driverName().startsWith("QDB2") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("db2") ); + } // -1 on fail, else Oracle version static int getOraVersion( QSqlDatabase db ) -- cgit v0.12 From 509a04338bc2b556c15f494a73947e82e3cdcc62 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 29 Jul 2009 02:32:48 +0200 Subject: Disambiguate QGraphicsObject::children(). Add using to prefer QObject::children() over the obsolete QGraphicsItem::children() function. Reviewed-by: Henrik Hartz --- src/gui/graphicsview/qgraphicsitem.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 945163f..b94fb97 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -514,6 +514,13 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem public: QGraphicsObject(QGraphicsItem *parent = 0); + // ### Qt 5: Disambiguate +#ifdef Q_NO_USING_KEYWORD + const QObjectList &children() const { return QObject::children(); } +#else + using QObject::children; +#endif + Q_SIGNALS: void parentChanged(); void opacityChanged(); -- cgit v0.12 From e841cc37bf7fde58e7b0ffc024d31f6a46a83745 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 29 Jul 2009 03:21:09 +0200 Subject: Fix remaining autotest failures in tst_QGraphicsWidget Change f68fed3 introduced a few regressions in the QGraphicsWidget autotests. It turned out those autotests relied on behavior that this fix "fixed". The exact bugs were 1) that setting focus on a window or a child of a window that isn't active will automatically give that item focus, despite that its window is inactive (in contrast it should just set up subfocus and give the item focus when the window is activated), and 2) that adding a window to a scene that is active did not immediately activate that window. So one fix in the test and one in QGraphicsScene. The autotests were modified so that the respective tests operate on an active scene (by assigning the scene to an active view). The change in QGraphicsScene ensures that the first window that gets added to an active scene that does not have any active windows already, automatically gets activated. Reviewed-by: Michael Brasser --- src/gui/graphicsview/qgraphicsscene.cpp | 4 ++++ tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index f223cbe..e54efe0 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2356,6 +2356,10 @@ void QGraphicsScene::addItem(QGraphicsItem *item) // Deliver post-change notification item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant); + // Auto-activate the first inactive window if the scene is active. + if (d->activationRefCount > 0 && !d->activeWindow && item->isWindow()) + setActiveWindow(static_cast(item)); + // Ensure that newly added items that have subfocus set, gain // focus automatically if there isn't a focus item already. if (!d->focusItem && item->focusItem()) diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 78d13d3..2cfedb1 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -1315,6 +1315,12 @@ void tst_QGraphicsWidget::focusNextPrevChild() void tst_QGraphicsWidget::verifyFocusChain() { QGraphicsScene scene; + QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); { // parent/child focus SubQGraphicsWidget *w = new SubQGraphicsWidget(0, Qt::Window); @@ -1448,6 +1454,11 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); + // delete item in focus chain with no focus and verify chain SubQGraphicsWidget *parent = new SubQGraphicsWidget(0, Qt::Window); SubQGraphicsWidget *w = new SubQGraphicsWidget(0, Qt::Window); -- cgit v0.12 From b51f10492b40b94c25661ec42ccf951268f3a969 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 29 Jul 2009 04:51:50 +0200 Subject: Ensure hover enter events are dispatched on mouse press. This change ensures that mouse presses received by the scene when there are no current mouse grabbers trigger hover event delivery. This is useful when the scene only receives presses, and no mouse moves (e.g., disabling mouse tracking on the viewport, or on systems where the mouse press is the first received event). Reviewed-by: Michael Brasser --- src/gui/graphicsview/qgraphicsscene.cpp | 7 +++ tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 69 ++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index e54efe0..a846cf6 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -3682,6 +3682,13 @@ void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent) void QGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { Q_D(QGraphicsScene); + if (d->mouseGrabberItems.isEmpty()) { + // Dispatch hover events + QGraphicsSceneHoverEvent hover; + _q_hoverFromMouseEvent(&hover, mouseEvent); + d->dispatchHoverEvent(&hover); + } + d->mousePressEventHandler(mouseEvent); } diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index f7ea4ce..4ef1cdd 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -255,6 +255,7 @@ private slots: void sendEvent(); void inputMethod_data(); void inputMethod(); + void dispatchHoverOnPress(); // task specific tests below me void task139710_bspTreeCrash(); @@ -3719,5 +3720,73 @@ void tst_QGraphicsScene::inputMethod() QCOMPARE(item->queryCalls, 0); } +void tst_QGraphicsScene::dispatchHoverOnPress() +{ + QGraphicsScene scene; + EventTester *tester1 = new EventTester; + tester1->setAcceptHoverEvents(true); + EventTester *tester2 = new EventTester; + tester2->setAcceptHoverEvents(true); + tester2->setPos(30, 30); + scene.addItem(tester1); + scene.addItem(tester2); + + tester1->eventTypes.clear(); + tester2->eventTypes.clear(); + + { + QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress); + me.setButton(Qt::LeftButton); + me.setButtons(Qt::LeftButton); + QGraphicsSceneMouseEvent me2(QEvent::GraphicsSceneMouseRelease); + me2.setButton(Qt::LeftButton); + qApp->sendEvent(&scene, &me); + qApp->sendEvent(&scene, &me2); + QCOMPARE(tester1->eventTypes, QList() + << QEvent::GraphicsSceneHoverEnter + << QEvent::GraphicsSceneHoverMove + << QEvent::GrabMouse + << QEvent::GraphicsSceneMousePress + << QEvent::UngrabMouse); + tester1->eventTypes.clear(); + qApp->sendEvent(&scene, &me); + qApp->sendEvent(&scene, &me2); + QCOMPARE(tester1->eventTypes, QList() + << QEvent::GraphicsSceneHoverMove + << QEvent::GrabMouse + << QEvent::GraphicsSceneMousePress + << QEvent::UngrabMouse); + } + { + QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress); + me.setScenePos(QPointF(30, 30)); + me.setButton(Qt::LeftButton); + me.setButtons(Qt::LeftButton); + QGraphicsSceneMouseEvent me2(QEvent::GraphicsSceneMouseRelease); + me2.setScenePos(QPointF(30, 30)); + me2.setButton(Qt::LeftButton); + tester1->eventTypes.clear(); + qApp->sendEvent(&scene, &me); + qApp->sendEvent(&scene, &me2); + qDebug() << tester1->eventTypes; + QCOMPARE(tester1->eventTypes, QList() + << QEvent::GraphicsSceneHoverLeave); + QCOMPARE(tester2->eventTypes, QList() + << QEvent::GraphicsSceneHoverEnter + << QEvent::GraphicsSceneHoverMove + << QEvent::GrabMouse + << QEvent::GraphicsSceneMousePress + << QEvent::UngrabMouse); + tester2->eventTypes.clear(); + qApp->sendEvent(&scene, &me); + qApp->sendEvent(&scene, &me2); + QCOMPARE(tester2->eventTypes, QList() + << QEvent::GraphicsSceneHoverMove + << QEvent::GrabMouse + << QEvent::GraphicsSceneMousePress + << QEvent::UngrabMouse); + } +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" -- cgit v0.12 From 188ac02e2fb6cc6437b776f8c5b69a508728fbdb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 29 Jul 2009 05:20:31 +0200 Subject: fix compilation without 3d support --- src/gui/graphicsview/qgraphicstransform.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index f18752a..b55d78e 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -63,7 +63,7 @@ void QGraphicsTransformPrivate::setItem(QGraphicsItem *i) item->prepareGeometryChange(); Q_ASSERT(d_ptr->transformData); - d_ptr->transformData->graphicsTransforms.remove(q); + d_ptr->transformData->graphicsTransforms.removeAll(q); d_ptr->dirtySceneTransform = 1; item = 0; } -- cgit v0.12 From e570225ee8332602c85506ff87e2596173b68ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Wed, 29 Jul 2009 07:14:47 +0200 Subject: Compile on 10.4 Don't use the "for ... in" syntax. This is Objective-C 2, which is only supported on 10.5 and up. --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 1c4177e..ff4cb71 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1211,7 +1211,10 @@ void qt_mac_menu_collapseSeparators(void */*NSMenu **/ theMenu, bool collapse) if (collapse) { bool previousIsSeparator = true; // setting to true kills all the separators placed at the top. NSMenuItem *previousItem = nil; - for (NSMenuItem *item in [menu itemArray]) { + + NSArray *itemArray = [menu itemArray]; + for (unsigned int i = 0; i < [itemArray count]; ++i) { + NSMenuItem *item = reinterpret_cast([itemArray objectAtIndex:i]); if ([item isSeparatorItem]) { [item setHidden:previousIsSeparator]; } -- cgit v0.12 From a45fe18569be1fc91e26f6e58d2f16bc8c6958de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Wed, 29 Jul 2009 07:42:30 +0200 Subject: Compile. Remobe another instance of for ... in use. --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index ff4cb71..3104083 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1229,7 +1229,9 @@ void qt_mac_menu_collapseSeparators(void */*NSMenu **/ theMenu, bool collapse) if (previousItem && previousIsSeparator) [previousItem setHidden:YES]; } else { - for (NSMenuItem *item in [menu itemArray]) { + NSArray *itemArray = [menu itemArray]; + for (unsigned int i = 0; i < [itemArray count]; ++i) { + NSMenuItem *item = reinterpret_cast([itemArray objectAtIndex:i]); if (QAction *action = reinterpret_cast([item tag])) [item setHidden:!action->isVisible()]; } -- cgit v0.12