summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-06-05 09:12:04 (GMT)
committerAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-06-05 09:14:04 (GMT)
commit800b7e087f90e6253e4c496e816721c63b366e02 (patch)
treedf86eaa60ccb70ac0a9dddcdc7bab03d3c8cccfc /src
parentde03e80fa733da21ff294e72bc91435dc68e4071 (diff)
downloadQt-800b7e087f90e6253e4c496e816721c63b366e02.zip
Qt-800b7e087f90e6253e4c496e816721c63b366e02.tar.gz
Qt-800b7e087f90e6253e4c496e816721c63b366e02.tar.bz2
Enabling QGraphicsTextItem to handle input method events.
On S60 one should get virtual keyboard.
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp129
1 files changed, 128 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index e8ace65..ed1891c 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -515,6 +515,7 @@
#include <QtGui/qpixmapcache.h>
#include <QtGui/qstyleoption.h>
#include <QtGui/qevent.h>
+#include <QInputContext>
#include <private/qgraphicsitem_p.h>
#include <private/qgraphicswidget_p.h>
@@ -7609,7 +7610,7 @@ class QGraphicsTextItemPrivate
{
public:
QGraphicsTextItemPrivate()
- : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false)
+ : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)
{ }
mutable QTextControl *control;
@@ -7630,6 +7631,8 @@ public:
bool useDefaultImpl;
bool tabChangesFocus;
+ uint clickCausedFocus : 1;
+
QGraphicsTextItem *qq;
};
@@ -7956,7 +7959,13 @@ void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
dd->useDefaultImpl = false;
return;
}
+
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -7968,7 +7977,13 @@ void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QGraphicsItem::mouseMoveEvent(event);
return;
}
+
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -7988,7 +8003,23 @@ void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
return;
}
+
+ if (event->button() == Qt::LeftButton && qApp->autoSipEnabled()
+ && (!dd->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
+ QEvent _event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(event->widget(), &_event);
+ } else {
+ QGraphicsItem::mouseReleaseEvent(event);
+ }
+ dd->clickCausedFocus = 0;
+
dd->sendControlEvent(event);
+
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8007,6 +8038,11 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
}
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8015,6 +8051,11 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8023,6 +8064,18 @@ void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)
{
dd->sendControlEvent(event);
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->update();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8031,6 +8084,18 @@ void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)
void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)
{
dd->sendControlEvent(event);
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->update();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8039,7 +8104,22 @@ void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)
void QGraphicsTextItem::focusInEvent(QFocusEvent *event)
{
dd->sendControlEvent(event);
+ if (event->reason() == Qt::MouseFocusReason) {
+ dd->clickCausedFocus = 1;
+ }
update();
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->reset();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8049,6 +8129,18 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)
{
dd->sendControlEvent(event);
update();
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->reset();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8057,6 +8149,11 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)
void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8065,6 +8162,11 @@ void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8073,6 +8175,11 @@ void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8081,6 +8188,11 @@ void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8097,6 +8209,11 @@ void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event)
void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8105,6 +8222,11 @@ void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8113,6 +8235,11 @@ void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!