diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 46 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitemanimation.cpp | 2 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicslayoutitem.cpp | 2 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 31 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.h | 1 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene_p.h | 3 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsview.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 213 | ||||
-rw-r--r-- | src/gui/kernel/qcursor.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qgesture.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 46 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager_p.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qt_s60_p.h | 15 | ||||
-rw-r--r-- | src/gui/painting/qcolor.cpp | 6 | ||||
-rw-r--r-- | src/gui/painting/qmatrix.cpp | 8 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 43 | ||||
-rw-r--r-- | src/gui/painting/qpainterpath.cpp | 4 | ||||
-rw-r--r-- | src/gui/painting/qpolygon.cpp | 8 | ||||
-rw-r--r-- | src/gui/text/qtextcontrol.cpp | 8 |
19 files changed, 268 insertions, 182 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index fd128b8..dfd58b3 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -50,7 +50,7 @@ It provides a light-weight foundation for writing your own custom items. This includes defining the item's geometry, collision detection, its painting implementation and item interaction through its event handlers. - QGraphicsItem is part of \l{The Graphics View Framework} + QGraphicsItem is part of the \l{Graphics View Framework} \image graphicsview-items.png @@ -264,7 +264,7 @@ functionality is completely untouched by Qt itself; it is provided for the user's convenience. - \sa QGraphicsScene, QGraphicsView, {The Graphics View Framework} + \sa QGraphicsScene, QGraphicsView, {Graphics View Framework} */ /*! @@ -7652,9 +7652,10 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent */ void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) { - QGraphicsItemPrivate * const d = QGraphicsItem::d_func(); - d->gestureContext.insert(gesture, flags); - (void)QGestureManager::instance(); // create a gesture manager + bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture); + QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags); + if (!contains && QGraphicsItem::d_ptr->scene) + QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture); } /*! @@ -7664,11 +7665,8 @@ void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flag */ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) { - QGraphicsItemPrivate * const d = QGraphicsItem::d_func(); - if (d->gestureContext.remove(gesture)) { - QGestureManager *manager = QGestureManager::instance(); - manager->cleanupCachedGestures(this, gesture); - } + if (QGraphicsItem::d_ptr->gestureContext.remove(gesture) && QGraphicsItem::d_ptr->scene) + QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture); } /*! Updates the item's micro focus. This is slot for convenience. @@ -8007,7 +8005,7 @@ void QGraphicsItemPrivate::resetHeight() \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPathItem, QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem, - QGraphicsPixmapItem, {The Graphics View Framework} + QGraphicsPixmapItem, {Graphics View Framework} */ class QAbstractGraphicsShapeItemPrivate : public QGraphicsItemPrivate @@ -8146,7 +8144,7 @@ QPainterPath QAbstractGraphicsShapeItem::opaqueArea() const setBrush() functions. \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem, - QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {The Graphics + QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics View Framework} */ @@ -8355,7 +8353,7 @@ QVariant QGraphicsPathItem::extension(const QVariant &variant) const those instead. \sa QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem, - QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {The Graphics + QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics View Framework} */ @@ -8599,7 +8597,7 @@ QVariant QGraphicsRectItem::extension(const QVariant &variant) const brush, which you can set by calling setPen() and setBrush(). \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsPolygonItem, - QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {The Graphics + QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics View Framework} */ @@ -8908,7 +8906,7 @@ QVariant QGraphicsEllipseItem::extension(const QVariant &variant) const setPen() and setBrush() functions. \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, - QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {The Graphics + QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics View Framework} */ @@ -9140,8 +9138,8 @@ QVariant QGraphicsPolygonItem::extension(const QVariant &variant) const function draws the line using the item's associated pen. \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, - QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, {The - Graphics View Framework} + QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, + {Graphics View Framework} */ class QGraphicsLineItemPrivate : public QGraphicsItemPrivate @@ -9410,8 +9408,8 @@ QVariant QGraphicsLineItem::extension(const QVariant &variant) const transformation mode for the item. \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, - QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, {The - Graphics View Framework} + QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, + {Graphics View Framework} */ /*! @@ -9781,7 +9779,7 @@ QVariant QGraphicsPixmapItem::extension(const QVariant &variant) const \sa QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, - QGraphicsLineItem, {The Graphics View Framework} + QGraphicsLineItem, {Graphics View Framework} */ class QGraphicsTextItemPrivate @@ -10697,9 +10695,9 @@ void QGraphicsSimpleTextItemPrivate::updateBoundingRect() \img graphicsview-simpletextitem.png - \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, - QGraphicsPixmapItem, QGraphicsPolygonItem, QGraphicsLineItem, {The - Graphics View Framework} + \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem, + QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, + QGraphicsLineItem, {Graphics View Framework} */ /*! @@ -10960,7 +10958,7 @@ QVariant QGraphicsSimpleTextItem::extension(const QVariant &variant) const item group. As with addToGroup(), the item's scene-relative position and transformation remain intact. - \sa QGraphicsItem, {The Graphics View Framework} + \sa QGraphicsItem, {Graphics View Framework} */ class QGraphicsItemGroupPrivate : public QGraphicsItemPrivate diff --git a/src/gui/graphicsview/qgraphicsitemanimation.cpp b/src/gui/graphicsview/qgraphicsitemanimation.cpp index 839c4ee..9cb9a8d 100644 --- a/src/gui/graphicsview/qgraphicsitemanimation.cpp +++ b/src/gui/graphicsview/qgraphicsitemanimation.cpp @@ -77,7 +77,7 @@ so scheduling several transformations of the same kind (e.g., rotations) at the same step is not recommended. - \sa QTimeLine, {The Graphics View Framework} + \sa QTimeLine, {Graphics View Framework} */ #include "qgraphicsitemanimation.h" diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index 9f9a39d..5a7f1af 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -322,7 +322,7 @@ void QGraphicsLayoutItemPrivate::setSizeComponent( layout, or false otherwise. Qt uses QGraphicsLayoutItem to provide layout functionality in the - \l{The Graphics View Framework}, but in the future its use may spread + \l{Graphics View Framework}, but in the future its use may spread throughout Qt itself. \sa QGraphicsWidget, QGraphicsLayout, QGraphicsLinearLayout, diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 9b7cf12..4b09a7e 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -50,7 +50,7 @@ The class serves as a container for QGraphicsItems. It is used together with QGraphicsView for visualizing graphical items, such as lines, rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is - part of \l{The Graphics View Framework}. + part of the \l{Graphics View Framework}. QGraphicsScene also provides functionality that lets you efficiently determine both the location of items, and for determining what items are @@ -710,6 +710,9 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) cachedTargetItems.removeOne(dummy); cachedItemGestures.remove(dummy); cachedAlreadyDeliveredGestures.remove(dummy); + + foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys()) + ungrabGesture(item, gesture); } /*! @@ -2595,6 +2598,9 @@ void QGraphicsScene::addItem(QGraphicsItem *item) d->enableTouchEventsOnViews(); } + foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys()) + d->grabGesture(item, gesture); + // Update selection lists if (item->isSelected()) d->selectedItems << item; @@ -5609,6 +5615,8 @@ bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event) void QGraphicsScenePrivate::addView(QGraphicsView *view) { views << view; + foreach (Qt::GestureType gesture, grabbedGestures.keys()) + view->viewport()->grabGesture(gesture); } void QGraphicsScenePrivate::removeView(QGraphicsView *view) @@ -6306,6 +6314,27 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original) } } +void QGraphicsScenePrivate::grabGesture(QGraphicsItem *, Qt::GestureType gesture) +{ + (void)QGestureManager::instance(); // create a gesture manager + if (!grabbedGestures[gesture]++) { + foreach (QGraphicsView *view, views) + view->viewport()->grabGesture(gesture); + } +} + +void QGraphicsScenePrivate::ungrabGesture(QGraphicsItem *item, Qt::GestureType gesture) +{ + // we know this can only be an object + Q_ASSERT(item->d_ptr->isObject); + QGraphicsObject *obj = static_cast<QGraphicsObject *>(item); + QGestureManager::instance()->cleanupCachedGestures(obj, gesture); + if (!--grabbedGestures[gesture]) { + foreach (QGraphicsView *view, views) + view->viewport()->ungrabGesture(gesture); + } +} + QT_END_NAMESPACE #include "moc_qgraphicsscene.cpp" diff --git a/src/gui/graphicsview/qgraphicsscene.h b/src/gui/graphicsview/qgraphicsscene.h index e5b15ef..c34a303 100644 --- a/src/gui/graphicsview/qgraphicsscene.h +++ b/src/gui/graphicsview/qgraphicsscene.h @@ -302,6 +302,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_updateScenePosDescendants()) friend class QGraphicsItem; friend class QGraphicsItemPrivate; + friend class QGraphicsObject; friend class QGraphicsView; friend class QGraphicsViewPrivate; friend class QGraphicsWidget; diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 77bf450..8ad2a0a 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -302,6 +302,7 @@ public: QHash<QGraphicsObject *, QSet<QGesture *> > cachedItemGestures; QHash<QGraphicsObject *, QSet<QGesture *> > cachedAlreadyDeliveredGestures; QHash<QGesture *, QGraphicsObject *> gestureTargets; + QHash<Qt::GestureType, int> grabbedGestures; void gestureEventHandler(QGestureEvent *event); void gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures, Qt::GestureFlag flag, @@ -310,6 +311,8 @@ public: QSet<QGesture *> *normal = 0, QSet<QGesture *> *conflicts = 0); void cancelGesturesForChildren(QGesture *original); + void grabGesture(QGraphicsItem *, Qt::GestureType gesture); + void ungrabGesture(QGraphicsItem *, Qt::GestureType gesture); void updateInputMethodSensitivityInViews(); diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index d2964ca..9dfcd2c 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -2688,6 +2688,11 @@ void QGraphicsView::setupViewport(QWidget *widget) if (d->scene && !d->scene->d_func()->allItemsIgnoreTouchEvents) widget->setAttribute(Qt::WA_AcceptTouchEvents); + if (d->scene) { + foreach (Qt::GestureType gesture, d->scene->d_func()->grabbedGestures.keys()) + widget->grabGesture(gesture); + } + widget->setAcceptDrops(acceptDrops()); } diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 3213f66..fa07b1a 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -364,6 +364,7 @@ void QSymbianControl::ConstructL(bool isWindowOwning, bool desktop) SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); + m_doubleClickTimer.invalidate(); DrawableWindow()->SetPointerGrab(ETrue); } @@ -589,109 +590,113 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod case EEventKeyUp: case EEventKey: { - // S60 has a confusing way of delivering key events. There are three types of - // events: EKeyEvent, EKeyEventDown and EKeyEventUp. When a key is pressed, the - // two first events are generated. When releasing the key, the last one is - // generated. - // Because S60 does not generate keysyms for EKeyEventDown and EKeyEventUp events, - // we need to do some special tricks to map it to the Qt way. First, we completely - // discard EKeyEventDown events, since they are redundant. Second, since - // EKeyEventUp does not give us a keysym, we need to cache the keysyms from - // the EKeyEvent events. This is what resolveS60ScanCode does. - - - // ### hackish way to send Qt application to background when pressing right softkey - /* - if( keyEvent.iScanCode == EStdKeyDevice1 ) { - S60->window_group->SetOrdinalPosition(-1); - qApp->setActiveWindow(0); - return EKeyWasNotConsumed; - } - */ - - TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode, - keyEvent.iCode); - int keyCode; - if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used - keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode); - } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) { - // Normal characters keys. - keyCode = s60Keysym; - } else { - // Special S60 keys. - keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); - } - #ifndef QT_NO_CURSOR if (S60->mouseInteractionEnabled && S60->virtualMouseRequired) { //translate keys to pointer - if (keyCode >= Qt::Key_Left && keyCode <= Qt::Key_Down || keyCode == Qt::Key_Select) { - /*Explanation about virtualMouseAccel: - Tapping an arrow key allows precise pixel positioning - Holding an arrow key down, acceleration is applied to allow cursor - to be quickly moved to another part of the screen by key repeats. - */ - if (S60->virtualMouseLastKey == keyCode) { - S60->virtualMouseAccel *= 2; - if (S60->virtualMouseAccel > S60->virtualMouseMaxAccel) - S60->virtualMouseAccel = S60->virtualMouseMaxAccel; - } - else - S60->virtualMouseAccel = 1; - S60->virtualMouseLastKey = keyCode; - + if ((keyEvent.iScanCode >= EStdKeyLeftArrow && keyEvent.iScanCode <= EStdKeyDownArrow) || + (keyEvent.iScanCode >= EStdKeyDevice10 && keyEvent.iScanCode <= EStdKeyDevice13) || + keyEvent.iScanCode == EStdKeyDevice3) { QPoint pos = QCursor::pos(); TPointerEvent fakeEvent; fakeEvent.iType = (TPointerEvent::TType)(-1); + fakeEvent.iModifiers = keyEvent.iModifiers; TInt x = pos.x(); TInt y = pos.y(); if (type == EEventKeyUp) { - if (keyCode == Qt::Key_Select && - (S60->virtualMousePressedKeys & QS60Data::Select)) - fakeEvent.iType = TPointerEvent::EButton1Up; - S60->virtualMouseAccel = 1; - S60->virtualMouseLastKey = 0; - switch (keyCode) { - case Qt::Key_Left: + S60->virtualMouseAccelTimeout.start(); + switch (keyEvent.iScanCode) { + case EStdKeyLeftArrow: S60->virtualMousePressedKeys &= ~QS60Data::Left; break; - case Qt::Key_Right: + case EStdKeyRightArrow: S60->virtualMousePressedKeys &= ~QS60Data::Right; break; - case Qt::Key_Up: + case EStdKeyUpArrow: S60->virtualMousePressedKeys &= ~QS60Data::Up; break; - case Qt::Key_Down: + case EStdKeyDownArrow: S60->virtualMousePressedKeys &= ~QS60Data::Down; break; - case Qt::Key_Select: + // diagonal keys (named aliases don't exist in 3.1 SDK) + case EStdKeyDevice10: + S60->virtualMousePressedKeys &= ~QS60Data::LeftUp; + break; + case EStdKeyDevice11: + S60->virtualMousePressedKeys &= ~QS60Data::RightUp; + break; + case EStdKeyDevice12: + S60->virtualMousePressedKeys &= ~QS60Data::RightDown; + break; + case EStdKeyDevice13: + S60->virtualMousePressedKeys &= ~QS60Data::LeftDown; + break; + case EStdKeyDevice3: //select + if (S60->virtualMousePressedKeys & QS60Data::Select) + fakeEvent.iType = TPointerEvent::EButton1Up; S60->virtualMousePressedKeys &= ~QS60Data::Select; break; } } else if (type == EEventKey) { - switch (keyCode) { - case Qt::Key_Left: + int dx = 0; + int dy = 0; + if (keyEvent.iScanCode != EStdKeyDevice3) { + m_doubleClickTimer.invalidate(); + //reset mouse accelleration after a short time with no moves + const int maxTimeBetweenKeyEventsMs = 500; + if (S60->virtualMouseAccelTimeout.isValid() && + S60->virtualMouseAccelTimeout.hasExpired(maxTimeBetweenKeyEventsMs)) { + S60->virtualMouseAccelDX = 0; + S60->virtualMouseAccelDY = 0; + } + S60->virtualMouseAccelTimeout.invalidate(); + } + switch (keyEvent.iScanCode) { + case EStdKeyLeftArrow: S60->virtualMousePressedKeys |= QS60Data::Left; - x -= S60->virtualMouseAccel; + dx = -1; fakeEvent.iType = TPointerEvent::EMove; break; - case Qt::Key_Right: + case EStdKeyRightArrow: S60->virtualMousePressedKeys |= QS60Data::Right; - x += S60->virtualMouseAccel; + dx = 1; fakeEvent.iType = TPointerEvent::EMove; break; - case Qt::Key_Up: + case EStdKeyUpArrow: S60->virtualMousePressedKeys |= QS60Data::Up; - y -= S60->virtualMouseAccel; + dy = -1; fakeEvent.iType = TPointerEvent::EMove; break; - case Qt::Key_Down: + case EStdKeyDownArrow: S60->virtualMousePressedKeys |= QS60Data::Down; - y += S60->virtualMouseAccel; + dy = 1; + fakeEvent.iType = TPointerEvent::EMove; + break; + case EStdKeyDevice10: + S60->virtualMousePressedKeys |= QS60Data::LeftUp; + dx = -1; + dy = -1; fakeEvent.iType = TPointerEvent::EMove; break; - case Qt::Key_Select: + case EStdKeyDevice11: + S60->virtualMousePressedKeys |= QS60Data::RightUp; + dx = 1; + dy = -1; + fakeEvent.iType = TPointerEvent::EMove; + break; + case EStdKeyDevice12: + S60->virtualMousePressedKeys |= QS60Data::RightDown; + dx = 1; + dy = 1; + fakeEvent.iType = TPointerEvent::EMove; + break; + case EStdKeyDevice13: + S60->virtualMousePressedKeys |= QS60Data::LeftDown; + dx = -1; + dy = 1; + fakeEvent.iType = TPointerEvent::EMove; + break; + case EStdKeyDevice3: // Platform bug. If you start pressing several keys simultaneously (for // example for drag'n'drop), Symbian starts producing spurious up and // down messages for some keys. Therefore, make sure we have a clean slate @@ -701,9 +706,42 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod } else { S60->virtualMousePressedKeys |= QS60Data::Select; fakeEvent.iType = TPointerEvent::EButton1Down; + if (m_doubleClickTimer.isValid() + && !m_doubleClickTimer.hasExpired(QApplication::doubleClickInterval())) { + fakeEvent.iModifiers |= EModifierDoubleClick; + m_doubleClickTimer.invalidate(); + } else { + m_doubleClickTimer.start(); + } } break; } + if (dx) { + int cdx = S60->virtualMouseAccelDX; + //reset accel on change of sign, else double accel + if (dx * cdx <= 0) + cdx = dx; + else + cdx *= 4; + //cap accelleration + if (dx * cdx > S60->virtualMouseMaxAccel) + cdx = dx * S60->virtualMouseMaxAccel; + //move mouse position + x += cdx; + S60->virtualMouseAccelDX = cdx; + } + + if (dy) { + int cdy = S60->virtualMouseAccelDY; + if (dy * cdy <= 0) + cdy = dy; + else + cdy *= 4; + if (dy * cdy > S60->virtualMouseMaxAccel) + cdy = dy * S60->virtualMouseMaxAccel; + y += cdy; + S60->virtualMouseAccelDY = cdy; + } } //clip to screen size (window server allows a sprite hotspot to be outside the screen) if (x < 0) @@ -716,19 +754,46 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod y = S60->screenHeightInPixels - 1; TPoint epos(x, y); TPoint cpos = epos - PositionRelativeToScreen(); - fakeEvent.iModifiers = keyEvent.iModifiers; fakeEvent.iPosition = cpos; fakeEvent.iParentPosition = epos; if(fakeEvent.iType != -1) HandlePointerEvent(fakeEvent); return EKeyWasConsumed; } - else { - S60->virtualMouseLastKey = keyCode; - S60->virtualMouseAccel = 1; - } } #endif + // S60 has a confusing way of delivering key events. There are three types of + // events: EKeyEvent, EKeyEventDown and EKeyEventUp. When a key is pressed, the + // two first events are generated. When releasing the key, the last one is + // generated. + // Because S60 does not generate keysyms for EKeyEventDown and EKeyEventUp events, + // we need to do some special tricks to map it to the Qt way. First, we completely + // discard EKeyEventDown events, since they are redundant. Second, since + // EKeyEventUp does not give us a keysym, we need to cache the keysyms from + // the EKeyEvent events. This is what resolveS60ScanCode does. + + + // ### hackish way to send Qt application to background when pressing right softkey + /* + if( keyEvent.iScanCode == EStdKeyDevice1 ) { + S60->window_group->SetOrdinalPosition(-1); + qApp->setActiveWindow(0); + return EKeyWasNotConsumed; + } + */ + + TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode, + keyEvent.iCode); + int keyCode; + if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used + keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode); + } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) { + // Normal characters keys. + keyCode = s60Keysym; + } else { + // Special S60 keys. + keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); + } Qt::KeyboardModifiers mods = mapToQtModifiers(keyEvent.iModifiers); QKeyEventEx qKeyEvent(type == EEventKeyUp ? QEvent::KeyRelease : QEvent::KeyPress, keyCode, diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index ae1f60d..5b58984 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -229,7 +229,7 @@ QT_BEGIN_NAMESPACE Writes the \a cursor to the \a stream. - \sa {Format of the QDataStream operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &s, const QCursor &c) @@ -256,7 +256,7 @@ QDataStream &operator<<(QDataStream &s, const QCursor &c) Reads the \a cursor from the \a stream. - \sa {Format of the QDataStream operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &s, QCursor &c) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index 956499b..49bdea7 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -612,7 +612,7 @@ void QPinchGesture::setRotationAngle(qreal value) If the gesture has either a horizontal or vertical component, the swipe angle describes the angle between the direction of motion and the x-axis as defined using the standard widget - \l{The Coordinate System}{coordinate system}. + \l{Coordinate System}{coordinate system}. \sa horizontalDirection, verticalDirection */ diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 9495f40..43facef 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -161,8 +161,10 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ it = m_obsoleteGestures.begin(), e = m_obsoleteGestures.end(); it != e; ++it) { it.value() -= gestures; } - foreach (QGesture *g, gestures) + foreach (QGesture *g, gestures) { m_deletedRecognizers.remove(g); + m_gestureToRecognizer.remove(g); + } qDeleteAll(gestures); iter = m_objectGestures.erase(iter); } else { @@ -286,24 +288,14 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *, // i.e. were canceled QSet<QGesture *> canceledGestures = m_activeGestures & notGestures; - // start timers for new gestures in maybe state - foreach (QGesture *state, newMaybeGestures) { - QBasicTimer &timer = m_maybeGestures[state]; - if (!timer.isActive()) - timer.start(3000, this); - } - // kill timers for gestures that were in maybe state + // new gestures in maybe state + m_maybeGestures += newMaybeGestures; + + // gestures that were in maybe state QSet<QGesture *> notMaybeGestures = (startedGestures | triggeredGestures | finishedGestures | canceledGestures | notGestures); - foreach(QGesture *gesture, notMaybeGestures) { - QHash<QGesture *, QBasicTimer>::iterator it = - m_maybeGestures.find(gesture); - if (it != m_maybeGestures.end()) { - it.value().stop(); - m_maybeGestures.erase(it); - } - } + m_maybeGestures -= notMaybeGestures; Q_ASSERT((startedGestures & finishedGestures).isEmpty()); Q_ASSERT((startedGestures & newMaybeGestures).isEmpty()); @@ -347,7 +339,7 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *, !finishedGestures.isEmpty() || !canceledGestures.isEmpty()) { DEBUG() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures - << "\n\tmaybeGestures:" << m_maybeGestures.keys() + << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures @@ -686,26 +678,6 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures, } } -void QGestureManager::timerEvent(QTimerEvent *event) -{ - QHash<QGesture *, QBasicTimer>::iterator it = m_maybeGestures.begin(), - e = m_maybeGestures.end(); - for (; it != e; ) { - QBasicTimer &timer = it.value(); - Q_ASSERT(timer.isActive()); - if (timer.timerId() == event->timerId()) { - timer.stop(); - QGesture *gesture = it.key(); - it = m_maybeGestures.erase(it); - DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:" - << gesture; - recycle(gesture); - } else { - ++it; - } - } -} - void QGestureManager::recycle(QGesture *gesture) { QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index c105c9b..c452f49 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -85,7 +85,6 @@ public: void recycle(QGesture *gesture); protected: - void timerEvent(QTimerEvent *event); bool filterEventThroughContexts(const QMultiMap<QObject *, Qt::GestureType> &contexts, QEvent *event); @@ -93,7 +92,7 @@ private: QMultiMap<Qt::GestureType, QGestureRecognizer *> m_recognizers; QSet<QGesture *> m_activeGestures; - QHash<QGesture *, QBasicTimer> m_maybeGestures; + QSet<QGesture *> m_maybeGestures; enum State { Gesture, diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 58da302..f560458 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -62,6 +62,7 @@ #include "QtGui/qevent.h" #include "qpointer.h" #include "qapplication.h" +#include "qelapsedtimer.h" #include <w32std.h> #include <coecntrl.h> #include <eikenv.h> @@ -102,16 +103,21 @@ public: int defaultDpiX; int defaultDpiY; WId curWin; - int virtualMouseLastKey; enum PressedKeys { Select = 0x1, Right = 0x2, Down = 0x4, Left = 0x8, - Up = 0x10 + Up = 0x10, + LeftUp = 0x20, + RightUp = 0x40, + RightDown = 0x80, + LeftDown = 0x100 }; int virtualMousePressedKeys; // of the above type, but avoids casting problems - int virtualMouseAccel; + int virtualMouseAccelDX; + int virtualMouseAccelDY; + QElapsedTimer virtualMouseAccelTimeout; int virtualMouseMaxAccel; #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS int brokenPointerCursors : 1; @@ -222,6 +228,7 @@ private: private: QWidget *qwidget; QLongTapTimer* m_longTapDetector; + QElapsedTimer m_doubleClickTimer; bool m_ignoreFocusChanged : 1; bool m_symbianPopupIsOpen : 1; @@ -246,7 +253,7 @@ inline void QS60Data::updateScreenSize() S60->screenWidthInTwips = params.iTwipsSize.iWidth; S60->screenHeightInTwips = params.iTwipsSize.iHeight; - S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 20; + S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 10; TReal inches = S60->screenHeightInTwips / (TReal)KTwipsPerInch; S60->defaultDpiY = S60->screenHeightInPixels / inches; diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 08d5572..37d7fa3 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -133,7 +133,7 @@ QT_BEGIN_NAMESPACE QColor is platform and device independent. The QColormap class maps the color to the hardware. - For more information about painting in general, see \l{The Paint + For more information about painting in general, see the \l{Paint System} documentation. \tableofcontents @@ -2523,7 +2523,7 @@ QDebug operator<<(QDebug dbg, const QColor &c) Writes the \a color to the \a stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &stream, const QColor &color) { @@ -2559,7 +2559,7 @@ QDataStream &operator<<(QDataStream &stream, const QColor &color) Reads the \a color from the \a stream. - \sa { Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &stream, QColor &color) { diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp index 00f32f7..7746316 100644 --- a/src/gui/painting/qmatrix.cpp +++ b/src/gui/painting/qmatrix.cpp @@ -103,7 +103,7 @@ QT_BEGIN_NAMESPACE coordinate system. The standard coordinate system of a QPaintDevice has its origin located at the top-left position. The \e x values increase to the right; \e y values increase - downward. For a complete description, see the \l {The Coordinate + downward. For a complete description, see the \l {Coordinate System}{coordinate system} documentation. QPainter has functions to translate, scale, shear and rotate the @@ -176,7 +176,7 @@ QT_BEGIN_NAMESPACE \snippet doc/src/snippets/matrix/matrix.cpp 2 \endtable - \sa QPainter, QTransform, {The Coordinate System}, + \sa QPainter, QTransform, {Coordinate System}, {demos/affine}{Affine Transformations Demo}, {Transformations Example} */ @@ -1135,7 +1135,7 @@ Q_GUI_EXPORT QPainterPath operator *(const QPainterPath &p, const QMatrix &m) Writes the given \a matrix to the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &s, const QMatrix &m) @@ -1161,7 +1161,7 @@ QDataStream &operator<<(QDataStream &s, const QMatrix &m) Reads the given \a matrix from the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &s, QMatrix &m) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 596649e..657229a 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -970,7 +970,7 @@ void QPainterPrivate::updateState(QPainterState *newState) devices. If the painter is active, device() returns the paint device on which the painter paints, and paintEngine() returns the paint engine that the painter is currently operating on. For more - information, see \l {The Paint System} documentation. + information, see the \l {Paint System}. Sometimes it is desirable to make someone else paint on an unusual QPaintDevice. QPainter supports a static function to do this, @@ -1015,7 +1015,7 @@ void QPainterPrivate::updateState(QPainterState *newState) \o viewport(), window(), worldTransform() make up the painter's coordinate transformation system. For more information, see the \l - {Coordinate Transformations} section and the \l {The Coordinate + {Coordinate Transformations} section and the \l {Coordinate System} documentation. \o hasClipping() tells whether the painter clips at all. (The paint @@ -1222,7 +1222,7 @@ void QPainterPrivate::updateState(QPainterState *newState) All the tranformation operations operate on the transformation worldTransform(). A matrix transforms a point in the plane to another point. For more information about the transformation matrix, see - the \l {The Coordinate System} and QTransform documentation. + the \l {Coordinate System} and QTransform documentation. The setWorldTransform() function can replace or add to the currently set worldTransform(). The resetTransform() function resets any @@ -1244,7 +1244,7 @@ void QPainterPrivate::updateState(QPainterState *newState) logical coordinates, and the worldTransform() is identical with the transformation matrix. - See also \l {The Coordinate System} documentation. + See also \l {Coordinate System} \section1 Clipping @@ -2880,8 +2880,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) functions is safe. For more information about the coordinate system, transformations - and window-viewport conversion, see \l {The Coordinate System} - documentation. + and window-viewport conversion, see \l {Coordinate System}. \sa setWorldTransform(), QTransform */ @@ -2901,7 +2900,7 @@ void QPainter::setWorldMatrix(const QMatrix &matrix, bool combine) preserve the properties of perspective transformations. \sa {QPainter#Coordinate Transformations}{Coordinate Transformations}, - {The Coordinate System} + {Coordinate System} */ const QMatrix &QPainter::worldMatrix() const @@ -3044,7 +3043,7 @@ void QPainter::setWorldMatrixEnabled(bool enable) Returns true if world transformation is enabled; otherwise returns false. - \sa setWorldMatrixEnabled(), worldTransform(), {The Coordinate System} + \sa setWorldMatrixEnabled(), worldTransform(), {Coordinate System} */ bool QPainter::worldMatrixEnabled() const @@ -3386,7 +3385,7 @@ void QPainter::drawPath(const QPainterPath &path) \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 6 \endtable - \sa drawLines(), drawPolyline(), {The Coordinate System} + \sa drawLines(), drawPolyline(), {Coordinate System} */ /*! @@ -3433,7 +3432,7 @@ void QPainter::drawPath(const QPainterPath &path) \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 7 \endtable - \sa drawRects(), drawPolygon(), {The Coordinate System} + \sa drawRects(), drawPolygon(), {Coordinate System} */ /*! @@ -3597,7 +3596,7 @@ void QPainter::drawRects(const QRect *rects, int rectCount) Draws a single point at the given \a position using the current pen's color. - \sa {The Coordinate System} + \sa {Coordinate System} */ /*! @@ -3619,7 +3618,7 @@ void QPainter::drawRects(const QRect *rects, int rectCount) Draws the first \a pointCount points in the array \a points using the current pen's color. - \sa {The Coordinate System} + \sa {Coordinate System} */ void QPainter::drawPoints(const QPointF *points, int pointCount) { @@ -4225,7 +4224,7 @@ void QPainter::drawRoundRect(const QRectF &r, int xRnd, int yRnd) \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 9 \endtable - \sa drawPie(), {The Coordinate System} + \sa drawPie(), {Coordinate System} */ void QPainter::drawEllipse(const QRectF &r) { @@ -4355,7 +4354,7 @@ void QPainter::drawEllipse(const QRect &r) \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 10 \endtable - \sa drawPie(), drawChord(), {The Coordinate System} + \sa drawPie(), drawChord(), {Coordinate System} */ void QPainter::drawArc(const QRectF &r, int a, int alen) @@ -4419,7 +4418,7 @@ void QPainter::drawArc(const QRectF &r, int a, int alen) \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 11 \endtable - \sa drawEllipse(), drawChord(), {The Coordinate System} + \sa drawEllipse(), drawChord(), {Coordinate System} */ void QPainter::drawPie(const QRectF &r, int a, int alen) { @@ -4488,7 +4487,7 @@ void QPainter::drawPie(const QRectF &r, int a, int alen) \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 12 \endtable - \sa drawArc(), drawPie(), {The Coordinate System} + \sa drawArc(), drawPie(), {Coordinate System} */ void QPainter::drawChord(const QRectF &r, int a, int alen) { @@ -4779,7 +4778,7 @@ void QPainter::drawLines(const QPoint *pointPairs, int lineCount) \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 13 \endtable - \sa drawLines(), drawPolygon(), {The Coordinate System} + \sa drawLines(), drawPolygon(), {Coordinate System} */ void QPainter::drawPolyline(const QPointF *points, int pointCount) { @@ -4918,7 +4917,7 @@ void QPainter::drawPolyline(const QPoint *points, int pointCount) \l{Qt::FillRule} for a more detailed description of these fill rules. - \sa drawConvexPolygon(), drawPolyline(), {The Coordinate System} + \sa drawConvexPolygon(), drawPolyline(), {Coordinate System} */ void QPainter::drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule) { @@ -5069,7 +5068,7 @@ void QPainter::drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fi On some platforms (e.g. X11), the drawConvexPolygon() function can be faster than the drawPolygon() function. - \sa drawPolygon(), drawPolyline(), {The Coordinate System} + \sa drawPolygon(), drawPolyline(), {Coordinate System} */ /*! @@ -7112,7 +7111,7 @@ bool QPainter::viewTransformEnabled() const The default window rectangle is the same as the device's rectangle. - \sa window(), viewTransformEnabled(), {The Coordinate + \sa window(), viewTransformEnabled(), {Coordinate System#Window-Viewport Conversion}{Window-Viewport Conversion} */ @@ -7176,7 +7175,7 @@ QRect QPainter::window() const The default viewport rectangle is the same as the device's rectangle. - \sa viewport(), viewTransformEnabled() {The Coordinate + \sa viewport(), viewTransformEnabled() {Coordinate System#Window-Viewport Conversion}{Window-Viewport Conversion} */ @@ -7260,7 +7259,7 @@ QRect QPainter::viewport() const Enables view transformations if \a enable is true, or disables view transformations if \a enable is false. - \sa viewTransformEnabled(), {The Coordinate System#Window-Viewport + \sa viewTransformEnabled(), {Coordinate System#Window-Viewport Conversion}{Window-Viewport Conversion} */ diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index f5a698e..ffd0d5c 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -2307,7 +2307,7 @@ QPainterPath &QPainterPath::operator-=(const QPainterPath &other) Writes the given painter \a path to the given \a stream, and returns a reference to the \a stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &s, const QPainterPath &p) { @@ -2334,7 +2334,7 @@ QDataStream &operator<<(QDataStream &s, const QPainterPath &p) Reads a painter path from the given \a stream into the specified \a path, and returns a reference to the \a stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &s, QPainterPath &p) { diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp index b68314f..2fb52b5 100644 --- a/src/gui/painting/qpolygon.cpp +++ b/src/gui/painting/qpolygon.cpp @@ -719,7 +719,7 @@ QPolygon::operator QVariant() const Writes the given \a polygon to the given \a stream, and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &s, const QPolygon &a) { @@ -735,7 +735,7 @@ QDataStream &operator<<(QDataStream &s, const QPolygon &a) Reads a polygon from the given \a stream into the given \a polygon, and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &s, QPolygon &a) { @@ -755,7 +755,7 @@ QDataStream &operator>>(QDataStream &s, QPolygon &a) Writes the given \a polygon to the given \a stream, and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &s, const QPolygonF &a) @@ -776,7 +776,7 @@ QDataStream &operator<<(QDataStream &s, const QPolygonF &a) Reads a polygon from the given \a stream into the given \a polygon, and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &s, QPolygonF &a) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index a2ee659..3d34687 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -747,7 +747,11 @@ void QTextControl::undo() { Q_D(QTextControl); d->repaintSelection(); + const int oldCursorPos = d->cursor.position(); d->doc->undo(&d->cursor); + if (d->cursor.position() != oldCursorPos) + emit cursorPositionChanged(); + emit microFocusChanged(); ensureCursorVisible(); } @@ -755,7 +759,11 @@ void QTextControl::redo() { Q_D(QTextControl); d->repaintSelection(); + const int oldCursorPos = d->cursor.position(); d->doc->redo(&d->cursor); + if (d->cursor.position() != oldCursorPos) + emit cursorPositionChanged(); + emit microFocusChanged(); ensureCursorVisible(); } |