summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-15 15:35:00 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-15 15:35:00 (GMT)
commitde1c505ddb5acedf96168df00172b9e3a694a32d (patch)
treeab8c69b1a1dec5a65986afe86853904f5aea49e7
parent9ecd481a859977660b68a57d3b2203f75377ccc4 (diff)
parent0caad7dc081812fcc056d917288757b2e475ea05 (diff)
downloadQt-de1c505ddb5acedf96168df00172b9e3a694a32d.zip
Qt-de1c505ddb5acedf96168df00172b9e3a694a32d.tar.gz
Qt-de1c505ddb5acedf96168df00172b9e3a694a32d.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fixes auto-test failure for 9da13ea53aec6d841ba7f416531d6c52d4368df4. Fixes tooltips for QGraphicsProxyWidget.
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp31
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp6
-rw-r--r--src/gui/kernel/qtooltip.cpp4
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp82
5 files changed, 100 insertions, 25 deletions
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
index 2132526..bdd41cd 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp
@@ -897,6 +897,29 @@ bool QGraphicsProxyWidget::event(QEvent *event)
}
break;
}
+#ifndef QT_NO_TOOLTIP
+ case QEvent::GraphicsSceneHelp: {
+ // Propagate the help event (for tooltip) to the widget under mouse
+ if (d->lastWidgetUnderMouse) {
+ QGraphicsSceneHelpEvent *he = static_cast<QGraphicsSceneHelpEvent *>(event);
+ QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint();
+ QHelpEvent e(QEvent::ToolTip, pos, he->screenPos());
+ QApplication::sendEvent(d->lastWidgetUnderMouse, &e);
+ event->setAccepted(e.isAccepted());
+ return e.isAccepted();
+ }
+ break;
+ }
+ case QEvent::ToolTipChange: {
+ // Propagate tooltip change to the widget
+ if (!d->tooltipChangeMode) {
+ d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
+ d->widget->setToolTip(toolTip());
+ d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ }
+ break;
+ }
+#endif
default:
break;
}
@@ -952,6 +975,14 @@ bool QGraphicsProxyWidget::eventFilter(QObject *object, QEvent *event)
d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
}
break;
+ case QEvent::ToolTipChange:
+ // Propagate tooltip change to the proxy.
+ if (!d->tooltipChangeMode) {
+ d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ setToolTip(d->widget->toolTip());
+ d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ }
+ break;
default:
break;
}
diff --git a/src/gui/graphicsview/qgraphicsproxywidget_p.h b/src/gui/graphicsview/qgraphicsproxywidget_p.h
index 8aed363..0e29a7e 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget_p.h
+++ b/src/gui/graphicsview/qgraphicsproxywidget_p.h
@@ -72,6 +72,7 @@ public:
enabledChangeMode(NoMode),
styleChangeMode(NoMode),
paletteChangeMode(NoMode),
+ tooltipChangeMode(NoMode),
focusFromWidgetToProxy(0)
{ }
void init();
@@ -117,6 +118,7 @@ public:
quint32 enabledChangeMode : 2;
quint32 styleChangeMode : 2;
quint32 paletteChangeMode : 2;
+ quint32 tooltipChangeMode : 2;
quint32 focusFromWidgetToProxy : 1;
quint32 proxyIsGivingFocus : 1;
};
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 6581727..b368a82 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -3772,6 +3772,12 @@ void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)
QGraphicsItem *toolTipItem = 0;
for (int i = 0; i < itemsAtPos.size(); ++i) {
QGraphicsItem *tmp = itemsAtPos.at(i);
+ if (tmp->d_func()->isProxyWidget()) {
+ // if the item is a proxy widget, the event is forwarded to it
+ sendEvent(tmp, helpEvent);
+ if (helpEvent->isAccepted())
+ return;
+ }
if (!tmp->toolTip().isEmpty()) {
toolTipItem = tmp;
break;
diff --git a/src/gui/kernel/qtooltip.cpp b/src/gui/kernel/qtooltip.cpp
index 1343959..c8fcf45 100644
--- a/src/gui/kernel/qtooltip.cpp
+++ b/src/gui/kernel/qtooltip.cpp
@@ -168,9 +168,9 @@ QTipLabel *QTipLabel::instance = 0;
QTipLabel::QTipLabel(const QString &text, QWidget *w)
#ifndef QT_NO_STYLE_STYLESHEET
- : QLabel(w, Qt::ToolTip), styleSheetParent(0), widget(0)
+ : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), styleSheetParent(0), widget(0)
#else
- : QLabel(w, Qt::ToolTip), widget(0)
+ : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), widget(0)
#endif
{
delete instance;
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index e46709b..d5f63d3 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -43,6 +43,7 @@
#include <QtTest/QtTest>
#include <QtGui>
#include "../../shared/util.h"
+#include <private/qgraphicsproxywidget_p.h>
#include <private/qlayoutengine_p.h> // qSmartMin functions...
#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
#include <QMacStyle>
@@ -2582,33 +2583,68 @@ void tst_QGraphicsProxyWidget::changingCursor_basic()
void tst_QGraphicsProxyWidget::tooltip_basic()
{
- // Confirm that mouse events are working properly by checking that
- // when moving the mouse over a label with a tooptip the tooltip appears
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- view.show();
+ QString toolTip = "Qt rocks!";
+ QString toolTip2 = "Qt rocks even more!";
+
+ QPushButton *button = new QPushButton("button");
+ QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget;
+ QGraphicsProxyWidgetPrivate *proxyd = static_cast<QGraphicsProxyWidgetPrivate *>(QGraphicsItemPrivate::get(proxy));
+ proxy->setWidget(button);
+ proxyd->lastWidgetUnderMouse = button; // force widget under mouse
+
+ QVERIFY(button->toolTip().isEmpty());
+ QVERIFY(proxy->toolTip().isEmpty());
+ // Check that setting the tooltip on the proxy also set it on the widget
+ proxy->setToolTip(toolTip);
+ QCOMPARE(proxy->toolTip(), toolTip);
+ QCOMPARE(button->toolTip(), toolTip);
+ // Check that setting the tooltip on the widget also set it on the proxy
+ button->setToolTip(toolTip2);
+ QCOMPARE(proxy->toolTip(), toolTip2);
+ QCOMPARE(button->toolTip(), toolTip2);
- QSKIP("Tooltips don't work yet", SkipAll);
-
- SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
- QLabel *widget = new QLabel;
- widget->setText("If it ain't tested it's broken");
- widget->setToolTip("When in doubt, test");
- proxy->setWidget(widget);
- widget->show();
+ QGraphicsScene scene;
scene.addItem(proxy);
- QTest::qWait(125);
- // in
- QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())));
+ QGraphicsView view(&scene);
+ view.setFixedSize(200, 200);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ {
+ QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(),
+ view.viewport()->mapToGlobal(view.viewport()->rect().topLeft()));
+ QApplication::sendEvent(view.viewport(), &helpEvent);
+ QTest::qWait(350);
+
+ bool foundView = false;
+ bool foundTipLabel = false;
+ foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ if (widget == &view)
+ foundView = true;
+ if (widget->inherits("QTipLabel"))
+ foundTipLabel = true;
+ }
+ QVERIFY(foundView);
+ QVERIFY(!foundTipLabel);
+ }
- QTRY_COMPARE(proxy->childItems().count(), 1);
- QGraphicsProxyWidget *child = (QGraphicsProxyWidget*)(proxy->childItems())[0];
- QVERIFY(child->isWidget());
- QVERIFY(child->widget());
- QCOMPARE(child->widget()->parent(), static_cast<QObject*>(widget));
- QCOMPARE(child->widget()->x(), widget->x()); // ### ???
- QCOMPARE(child->widget()->y(), widget->y() + widget->height()); // ### ???
+ {
+ QHelpEvent helpEvent(QEvent::ToolTip, view.mapFromScene(proxy->boundingRect().center()),
+ view.viewport()->mapToGlobal(view.mapFromScene(proxy->boundingRect().center())));
+ QApplication::sendEvent(view.viewport(), &helpEvent);
+ QTest::qWait(350);
+
+ bool foundView = false;
+ bool foundTipLabel = false;
+ foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ if (widget == &view)
+ foundView = true;
+ if (widget->inherits("QTipLabel"))
+ foundTipLabel = true;
+ }
+ QVERIFY(foundView);
+ QVERIFY(foundTipLabel);
+ }
}
void tst_QGraphicsProxyWidget::childPos_data()