summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSami Merilä <sami.merila@nokia.com>2009-09-28 13:29:13 (GMT)
committerSami Merilä <sami.merila@nokia.com>2009-09-28 13:29:13 (GMT)
commit124b4a1a5832d21d63722ee5ac68007083a4f8ae (patch)
treeff987348820e659fa69fb242017951673fdcd151 /src
parent3a52aeb622da3f7d4171ea64df7896fa5d2d7d4a (diff)
parente131a4653ec13e9a680a4b41094e78f2cc929f4d (diff)
downloadQt-124b4a1a5832d21d63722ee5ac68007083a4f8ae.zip
Qt-124b4a1a5832d21d63722ee5ac68007083a4f8ae.tar.gz
Qt-124b4a1a5832d21d63722ee5ac68007083a4f8ae.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qcalendarwidget.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp
index 71588c4..08ed7f6 100644
--- a/src/gui/widgets/qcalendarwidget.cpp
+++ b/src/gui/widgets/qcalendarwidget.cpp
@@ -3022,11 +3022,21 @@ bool QCalendarWidget::event(QEvent *event)
bool QCalendarWidget::eventFilter(QObject *watched, QEvent *event)
{
Q_D(QCalendarWidget);
- if (event->type() == QEvent::MouseButtonPress && d->yearEdit->hasFocus() && !QRect(d->yearEdit->mapToGlobal(QPoint(0, 0)), d->yearEdit->size()).contains(static_cast<QMouseEvent *>(event)->globalPos())) {
- event->accept();
- d->_q_yearEditingFinished();
- setFocus();
- return true;
+ if (event->type() == QEvent::MouseButtonPress && d->yearEdit->hasFocus()) {
+ QWidget *tlw = window();
+ QWidget *widget = static_cast<QWidget*>(watched);
+ //as we have a event filter on the whole application we first make sure that the top level widget
+ //of both this and the watched widget are the same to decide if we should finish the year edition.
+ if (widget->window() == tlw) {
+ QPoint mousePos = widget->mapTo(tlw, static_cast<QMouseEvent *>(event)->pos());
+ QRect geom = QRect(d->yearEdit->mapTo(tlw, QPoint(0, 0)), d->yearEdit->size());
+ if (!geom.contains(mousePos)) {
+ event->accept();
+ d->_q_yearEditingFinished();
+ setFocus();
+ return true;
+ }
+ }
}
return QWidget::eventFilter(watched, event);
}