diff options
Diffstat (limited to 'src/declarative/graphicsitems')
10 files changed, 105 insertions, 12 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index c4b2c2ebe0..aee91e1135 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -818,7 +818,9 @@ void QDeclarativeGridViewPrivate::createHighlight() if (highlight) { if (trackedItem == highlight) trackedItem = 0; - delete highlight->item; + if (highlight->item->scene()) + highlight->item->scene()->removeItem(highlight->item); + highlight->item->deleteLater(); delete highlight; highlight = 0; delete highlightXAnimator; diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index fed3587db8..15cd728561 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -449,6 +449,12 @@ void QDeclarativeItemKeyFilter::componentComplete() a chain of items with the same KeyNavigation handler. If multiple items in a row are not enabled or visible, they will also be skipped. + KeyNavigation will implicitly set the other direction to return focus to this item. So if you set + \l left to another item, \l right will be set on that item's KeyNavigation to set focus back to this + item. However, if that item's KeyNavigation has had right explicitly set then no change will occur. + This means that the above example could have been written, with the same behaviour, without specifing + KeyNavigation.right or KeyNavigation.down for any of the items. + \sa {Keys}{Keys attached property} */ @@ -498,6 +504,13 @@ void QDeclarativeKeyNavigationAttached::setLeft(QDeclarativeItem *i) if (d->left == i) return; d->left = i; + d->leftSet = true; + QDeclarativeKeyNavigationAttached* other = + qobject_cast<QDeclarativeKeyNavigationAttached*>(qmlAttachedPropertiesObject<QDeclarativeKeyNavigationAttached>(i)); + if(other && !other->d_func()->rightSet){ + other->d_func()->right = qobject_cast<QDeclarativeItem*>(parent()); + emit other->rightChanged(); + } emit leftChanged(); } @@ -513,6 +526,13 @@ void QDeclarativeKeyNavigationAttached::setRight(QDeclarativeItem *i) if (d->right == i) return; d->right = i; + d->rightSet = true; + QDeclarativeKeyNavigationAttached* other = + qobject_cast<QDeclarativeKeyNavigationAttached*>(qmlAttachedPropertiesObject<QDeclarativeKeyNavigationAttached>(i)); + if(other && !other->d_func()->leftSet){ + other->d_func()->left = qobject_cast<QDeclarativeItem*>(parent()); + emit other->leftChanged(); + } emit rightChanged(); } @@ -528,6 +548,13 @@ void QDeclarativeKeyNavigationAttached::setUp(QDeclarativeItem *i) if (d->up == i) return; d->up = i; + d->upSet = true; + QDeclarativeKeyNavigationAttached* other = + qobject_cast<QDeclarativeKeyNavigationAttached*>(qmlAttachedPropertiesObject<QDeclarativeKeyNavigationAttached>(i)); + if(other && !other->d_func()->downSet){ + other->d_func()->down = qobject_cast<QDeclarativeItem*>(parent()); + emit other->downChanged(); + } emit upChanged(); } @@ -543,6 +570,13 @@ void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i) if (d->down == i) return; d->down = i; + d->downSet = true; + QDeclarativeKeyNavigationAttached* other = + qobject_cast<QDeclarativeKeyNavigationAttached*>(qmlAttachedPropertiesObject<QDeclarativeKeyNavigationAttached>(i)); + if(other && !other->d_func()->upSet){ + other->d_func()->up = qobject_cast<QDeclarativeItem*>(parent()); + emit other->upChanged(); + } emit downChanged(); } @@ -558,6 +592,13 @@ void QDeclarativeKeyNavigationAttached::setTab(QDeclarativeItem *i) if (d->tab == i) return; d->tab = i; + d->tabSet = true; + QDeclarativeKeyNavigationAttached* other = + qobject_cast<QDeclarativeKeyNavigationAttached*>(qmlAttachedPropertiesObject<QDeclarativeKeyNavigationAttached>(i)); + if(other && !other->d_func()->backtabSet){ + other->d_func()->backtab = qobject_cast<QDeclarativeItem*>(parent()); + emit other->backtabChanged(); + } emit tabChanged(); } @@ -573,6 +614,13 @@ void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i) if (d->backtab == i) return; d->backtab = i; + d->backtabSet = true; + QDeclarativeKeyNavigationAttached* other = + qobject_cast<QDeclarativeKeyNavigationAttached*>(qmlAttachedPropertiesObject<QDeclarativeKeyNavigationAttached>(i)); + if(other && !other->d_func()->tabSet){ + other->d_func()->tab = qobject_cast<QDeclarativeItem*>(parent()); + emit other->tabChanged(); + } emit backtabChanged(); } diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 517259c9cc..80131d137a 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -382,7 +382,10 @@ class QDeclarativeKeyNavigationAttachedPrivate : public QObjectPrivate { public: QDeclarativeKeyNavigationAttachedPrivate() - : QObjectPrivate(), left(0), right(0), up(0), down(0), tab(0), backtab(0) {} + : QObjectPrivate(), + left(0), right(0), up(0), down(0), tab(0), backtab(0), + leftSet(false), rightSet(false), upSet(false), downSet(false), + tabSet(false), backtabSet(false) {} QDeclarativeItem *left; QDeclarativeItem *right; @@ -390,6 +393,12 @@ public: QDeclarativeItem *down; QDeclarativeItem *tab; QDeclarativeItem *backtab; + bool leftSet : 1; + bool rightSet : 1; + bool upSet : 1; + bool downSet : 1; + bool tabSet : 1; + bool backtabSet : 1; }; class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeItemKeyFilter diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 8d2fd93e2b..225b031530 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -733,6 +733,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) if (doBuffer && (bufferMode & BufferBefore)) fillFrom = bufferFrom; + bool haveValidItems = false; int modelIndex = visibleIndex; qreal itemEnd = visiblePos-1; if (!visibleItems.isEmpty()) { @@ -741,11 +742,13 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) int i = visibleItems.count() - 1; while (i > 0 && visibleItems.at(i)->index == -1) --i; - if (visibleItems.at(i)->index != -1) + if (visibleItems.at(i)->index != -1) { + haveValidItems = true; modelIndex = visibleItems.at(i)->index + 1; + } } - if (visibleItems.count() && (fillFrom > itemEnd+averageSize+spacing + if (haveValidItems && (fillFrom > itemEnd+averageSize+spacing || fillTo < visiblePos - averageSize - spacing)) { // We've jumped more than a page. Estimate which items are now // visible and fill from there. @@ -940,7 +943,9 @@ void QDeclarativeListViewPrivate::createHighlight() if (highlight) { if (trackedItem == highlight) trackedItem = 0; - delete highlight->item; + if (highlight->item->scene()) + highlight->item->scene()->removeItem(highlight->item); + highlight->item->deleteLater(); delete highlight; highlight = 0; delete highlightPosAnimator; @@ -3406,9 +3411,9 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count) } } - if (removedVisible && !haveVisibleIndex) { + if (!haveVisibleIndex) { d->timeline.clear(); - if (d->itemCount == 0) { + if (removedVisible && d->itemCount == 0) { d->visibleIndex = 0; d->visiblePos = d->header ? d->header->size() : 0; d->setPosition(0); diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index 271a70498e..20ca0f689a 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -660,6 +660,32 @@ void QDeclarativeMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) setHovered(false); } +#ifndef QT_NO_CONTEXTMENU +void QDeclarativeMouseArea::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + bool acceptsContextMenuButton; +#if defined(Q_OS_SYMBIAN) + // In Symbian a Long Tap on the screen will trigger. See QSymbianControl::HandleLongTapEventL(). + acceptsContextMenuButton = acceptedButtons() & Qt::LeftButton; +#elif defined(Q_WS_WINCE) + // ### WinCE can trigger context menu event with a gesture in the left button or a + // click with the right button. Since we have no way here to differentiate them when + // event happens, accepting either of the them will block the event. + acceptsContextMenuButton = acceptedButtons() & (Qt::LeftButton | Qt::RightButton); +#else + acceptsContextMenuButton = acceptedButtons() & Qt::RightButton; +#endif + + if (isEnabled() && event->reason() == QGraphicsSceneContextMenuEvent::Mouse + && acceptsContextMenuButton) { + // Do not let the context menu event propagate to items behind. + return; + } + + QDeclarativeItem::contextMenuEvent(event); +} +#endif // QT_NO_CONTEXTMENU + bool QDeclarativeMouseArea::sceneEvent(QEvent *event) { bool rv = QDeclarativeItem::sceneEvent(event); diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h index c3e5d3d704..8fd453f5de 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h @@ -190,6 +190,9 @@ protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverMoveEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); +#ifndef QT_NO_CONTEXTMENU + void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); +#endif // QT_NO_CONTEXTMENU bool sceneEvent(QEvent *); bool sendMouseEvent(QGraphicsSceneMouseEvent *event); bool sceneEventFilter(QGraphicsItem *i, QEvent *e); diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 79e52cd244..94f128dca8 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -203,7 +203,9 @@ void QDeclarativePathViewPrivate::createHighlight() bool changed = false; if (highlightItem) { - delete highlightItem; + if (highlightItem->scene()) + highlightItem->scene()->removeItem(highlightItem); + highlightItem->deleteLater(); highlightItem = 0; changed = true; } diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index fbeabcdc16..b32e02dcae 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -273,7 +273,6 @@ void QDeclarativeTextEdit::setText(const QString &text) \o TextEdit.AutoText \o TextEdit.PlainText \o TextEdit.RichText - \o TextEdit.StyledText \endlist The default is TextEdit.AutoText. If the text format is TextEdit.AutoText the text edit @@ -1110,7 +1109,7 @@ void QDeclarativeTextEdit::setMouseSelectionMode(SelectionMode mode) /*! \qmlproperty bool TextEdit::readOnly - Whether the user an interact with the TextEdit item. If this + Whether the user can interact with the TextEdit item. If this property is set to true the text cannot be edited by user interaction. By default this property is false. diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index dd5a58ebdc..98ec2050e9 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1876,7 +1876,7 @@ bool QDeclarativeTextInput::isInputMethodComposing() const void QDeclarativeTextInputPrivate::init() { Q_Q(QDeclarativeTextInput); - control->setParent(q); + control->setParent(q);//Now mandatory due to accessibility changes control->setCursorWidth(1); control->setPasswordCharacter(QLatin1Char('*')); q->setSmooth(smooth); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h index 4712c65ff0..947ddc7bfa 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h @@ -84,7 +84,6 @@ public: showInputPanelOnFocus = false; } #endif - } ~QDeclarativeTextInputPrivate() |