summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-19 01:15:14 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-19 01:15:14 (GMT)
commit1226fa946170caa7e30ffd1bf64e806a34139978 (patch)
tree4b515f0a2e8090ba951383e951f1763933a7fc9c /src/gui
parent6d6b7b318a842ef5037065554f30ebfb4ae34d74 (diff)
parentdf9ab6c300eca3a5c75dcee93ae848957cb9a617 (diff)
downloadQt-1226fa946170caa7e30ffd1bf64e806a34139978.zip
Qt-1226fa946170caa7e30ffd1bf64e806a34139978.tar.gz
Qt-1226fa946170caa7e30ffd1bf64e806a34139978.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Only setup ICD test data when ICD is enabled. Doc: Fixed two diagrams and finally committed images for them. Make sure cursorPositionChanged is emitted when doing undo/redo Some more 4.7.0 changes Fix cosmetic issue in designer filter edits Doc: Adding support for IE 6, 7 and 8 doc: Updated the widgets tutorial to work without page links. My 4.7.0 changes Added support for es_419 locale. Added Korean and Nynorsk locales support on Symbian. Gestures in GraphicsView do not require a viewport to subscribe to gestures. Upgraded QLocale to Unicode CLDR 1.8.1 Removed the "maybe" timer from gesturemanager. Fixes a crash and a memory leak in gesturemanager. Embedded changes for 4.7 Added a default value for optimization settings. Update Polish translations
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp14
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp29
-rw-r--r--src/gui/graphicsview/qgraphicsscene.h1
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h3
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp5
-rw-r--r--src/gui/kernel/qgesturemanager.cpp46
-rw-r--r--src/gui/kernel/qgesturemanager_p.h3
-rw-r--r--src/gui/text/qtextcontrol.cpp8
8 files changed, 62 insertions, 47 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 5e0d46f..04d9075 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -7650,9 +7650,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);
}
/*!
@@ -7662,11 +7663,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.
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 9b7cf12..b7e2fda 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -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/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/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();
}