/*!
\internal
- This helper function helped us add input method query support in
- Qt 4.4.1 without having to reimplement the inputMethodQuery()
- function in QGraphicsProxyWidget. ### Qt 5: Remove. We cannot
- remove it in 4.5+ even if we do reimplement the function properly,
- because apps compiled with 4.4 will not be able to call the
- reimplementation.
-*/
-QVariant QGraphicsItemPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
-{
- Q_UNUSED(query);
- return QVariant();
-}
-
-/*!
- \internal
-
Make sure not to trigger any pure virtual function calls (e.g.,
prepareGeometryChange) if the item is in its destructor, i.e.
inDestructor is 1.
*/
QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const
{
- if (isWidget()) {
- // ### Qt 5: Remove. The reimplementation in
- // QGraphicsProxyWidget solves this problem (but requires a
- // recompile to take effect).
- return d_ptr->inputMethodQueryHelper(query);
- }
-
Q_UNUSED(query);
return QVariant();
}
/*!
\internal
-
- Reimplemented from QGraphicsItemPrivate. ### Qt 5: Move impl to
- reimplementation QGraphicsProxyWidget::inputMethodQuery().
-*/
-QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
-{
- Q_Q(const QGraphicsProxyWidget);
- if (!widget || !q->hasFocus())
- return QVariant();
-
- QWidget *focusWidget = widget->focusWidget();
- if (!focusWidget)
- focusWidget = widget;
- QVariant v = focusWidget->inputMethodQuery(query);
- QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
- switch (v.type()) {
- case QVariant::RectF:
- v = v.toRectF().translated(focusWidgetPos);
- break;
- case QVariant::PointF:
- v = v.toPointF() + focusWidgetPos;
- break;
- case QVariant::Rect:
- v = v.toRect().translated(focusWidgetPos.toPoint());
- break;
- case QVariant::Point:
- v = v.toPoint() + focusWidgetPos.toPoint();
- break;
- default:
- break;
- }
- return v;
-}
-
-/*!
- \internal
Some of the logic is shared with QApplicationPrivate::focusNextPrevChild_helper
*/
QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const
break;
}
case QEvent::InputMethod: {
- // Forward input method events if the focus widget enables
- // input methods.
- // ### Qt 4.5: this code must also go into a reimplementation
- // of inputMethodEvent().
- QWidget *focusWidget = d->widget->focusWidget();
- if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
- QApplication::sendEvent(focusWidget, event);
+ inputMethodEvent(static_cast<QInputMethodEvent *>(event));
break;
}
case QEvent::ShortcutOverride: {
/*!
\reimp
*/
+QVariant QGraphicsProxyWidget::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ Q_D(const QGraphicsProxyWidget);
+
+ if (!d->widget || !hasFocus())
+ return QVariant();
+
+ QWidget *focusWidget = widget()->focusWidget();
+ if (!focusWidget)
+ focusWidget = d->widget;
+ QVariant v = focusWidget->inputMethodQuery(query);
+ QPointF focusWidgetPos = subWidgetRect(focusWidget).topLeft();
+ switch (v.type()) {
+ case QVariant::RectF:
+ v = v.toRectF().translated(focusWidgetPos);
+ break;
+ case QVariant::PointF:
+ v = v.toPointF() + focusWidgetPos;
+ break;
+ case QVariant::Rect:
+ v = v.toRect().translated(focusWidgetPos.toPoint());
+ break;
+ case QVariant::Point:
+ v = v.toPoint() + focusWidgetPos.toPoint();
+ break;
+ default:
+ break;
+ }
+ return v;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::inputMethodEvent(QInputMethodEvent *event)
+{
+ // Forward input method events if the focus widget enables input methods.
+ Q_D(const QGraphicsProxyWidget);
+ QWidget *focusWidget = d->widget->focusWidget();
+ if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
+ QApplication::sendEvent(focusWidget, event);
+}
+
+/*!
+ \reimp
+*/
QSizeF QGraphicsProxyWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
Q_D(const QGraphicsProxyWidget);
void focusInEvent(QFocusEvent *event);
void focusOutEvent(QFocusEvent *event);
bool focusNextPrevChild(bool next);
- // ### Qt 4.5:
- // QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
- // void inputMethodEvent(QInputMethodEvent *event);
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+ void inputMethodEvent(QInputMethodEvent *event);
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
void resizeEvent(QGraphicsSceneResizeEvent *event);