summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-05-17 13:40:50 +1000
committerWarwick Allison <warwick.allison@nokia.com>2010-05-17 13:40:50 +1000
commite86732a38bc601c51a41400c1000b857b71f2e75 (patch)
tree26b96a620f088bd2361255bce017704e4277c6d2 /src
parentfd0b25da6997553bb95ea91bbdd509fa35711b9d (diff)
parent414edec537821711e22a3bb2729e189aa501bfbb (diff)
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp7
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp200
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h37
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp7
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp60
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp9
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp5
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp5
10 files changed, 264 insertions, 75 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index fe78c84a79..e1874b8c19 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -1651,6 +1651,9 @@ qreal QDeclarativeGridView::maxXExtent() const
void QDeclarativeGridView::keyPressEvent(QKeyEvent *event)
{
Q_D(QDeclarativeGridView);
+ keyPressPreHandler(event);
+ if (event->isAccepted())
+ return;
if (d->model && d->model->count() && d->interactive) {
d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
int oldCurrent = currentIndex();
@@ -1676,10 +1679,8 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event)
}
}
d->moveReason = QDeclarativeGridViewPrivate::Other;
- QDeclarativeFlickable::keyPressEvent(event);
- if (event->isAccepted())
- return;
event->ignore();
+ QDeclarativeFlickable::keyPressEvent(event);
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index f251ba1a45..95478844bd 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -375,7 +375,7 @@ void QDeclarativeContents::childAdded(QDeclarativeItem *item)
}
QDeclarativeItemKeyFilter::QDeclarativeItemKeyFilter(QDeclarativeItem *item)
-: m_next(0)
+: m_processPost(false), m_next(0)
{
QDeclarativeItemPrivate *p =
item?static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(item)):0;
@@ -389,19 +389,19 @@ QDeclarativeItemKeyFilter::~QDeclarativeItemKeyFilter()
{
}
-void QDeclarativeItemKeyFilter::keyPressed(QKeyEvent *event)
+void QDeclarativeItemKeyFilter::keyPressed(QKeyEvent *event, bool post)
{
- if (m_next) m_next->keyPressed(event);
+ if (m_next) m_next->keyPressed(event, post);
}
-void QDeclarativeItemKeyFilter::keyReleased(QKeyEvent *event)
+void QDeclarativeItemKeyFilter::keyReleased(QKeyEvent *event, bool post)
{
- if (m_next) m_next->keyReleased(event);
+ if (m_next) m_next->keyReleased(event, post);
}
-void QDeclarativeItemKeyFilter::inputMethodEvent(QInputMethodEvent *event)
+void QDeclarativeItemKeyFilter::inputMethodEvent(QInputMethodEvent *event, bool post)
{
- if (m_next) m_next->inputMethodEvent(event);
+ if (m_next) m_next->inputMethodEvent(event, post);
}
QVariant QDeclarativeItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const
@@ -463,9 +463,11 @@ void QDeclarativeItemKeyFilter::componentComplete()
}
\endcode
- KeyNavigation receives key events after the item it is attached to.
+ By default KeyNavigation receives key events after the item it is attached to.
If the item accepts an arrow key event, the KeyNavigation
- attached property will not receive an event for that key.
+ attached property will not receive an event for that key. Setting the
+ \l priority property to KeyNavigation.BeforeItem allows handling
+ of the key events before normal item processing.
If an item has been set for a direction and the KeyNavigation
attached property receives the corresponding
@@ -490,6 +492,7 @@ QDeclarativeKeyNavigationAttached::QDeclarativeKeyNavigationAttached(QObject *pa
: QObject(*(new QDeclarativeKeyNavigationAttachedPrivate), parent),
QDeclarativeItemKeyFilter(qobject_cast<QDeclarativeItem*>(parent))
{
+ m_processPost = true;
}
QDeclarativeKeyNavigationAttached *
@@ -576,12 +579,45 @@ void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i)
emit changed();
}
-void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event)
+/*!
+ \qmlproperty enumeration KeyNavigation::priority
+
+ This property determines whether the keys are processed before
+ or after the attached item's own key handling.
+
+ \list
+ \o KeyNavigation.BeforeItem - process the key events before normal
+ item key processing. If the event is accepted it will not
+ be passed on to the item.
+ \o KeyNavigation.AfterItem (default) - process the key events after normal item key
+ handling. If the item accepts the key event it will not be
+ handled by the KeyNavigation attached property handler.
+ \endlist
+*/
+QDeclarativeKeyNavigationAttached::Priority QDeclarativeKeyNavigationAttached::priority() const
{
- Q_D(QDeclarativeKeyNavigationAttached);
+ return m_processPost ? AfterItem : BeforeItem;
+}
+
+void QDeclarativeKeyNavigationAttached::setPriority(Priority order)
+{
+ bool processPost = order == AfterItem;
+ if (processPost != m_processPost) {
+ m_processPost = processPost;
+ emit priorityChanged();
+ }
+}
+void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event, bool post)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
event->ignore();
+ if (post != m_processPost) {
+ QDeclarativeItemKeyFilter::keyPressed(event, post);
+ return;
+ }
+
switch(event->key()) {
case Qt::Key_Left:
if (d->left) {
@@ -623,15 +659,19 @@ void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event)
break;
}
- if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event);
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post);
}
-void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event)
+void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post)
{
Q_D(QDeclarativeKeyNavigationAttached);
-
event->ignore();
+ if (post != m_processPost) {
+ QDeclarativeItemKeyFilter::keyReleased(event, post);
+ return;
+ }
+
switch(event->key()) {
case Qt::Key_Left:
if (d->left) {
@@ -667,7 +707,7 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event)
break;
}
- if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event);
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post);
}
/*!
@@ -709,6 +749,28 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event)
See \l {Qt::Key}{Qt.Key} for the list of keyboard codes.
+ If priority is Keys.BeforeItem (default) the order of key event processing is:
+
+ \list 1
+ \o Items specified in \c forwardTo
+ \o specific key handlers, e.g. onReturnPressed
+ \o onKeyPress, onKeyRelease handlers
+ \o Item specific key handling, e.g. TextInput key handling
+ \o parent item
+ \endlist
+
+ If priority is Keys.AfterItem the order of key event processing is:
+ \list 1
+ \o Item specific key handling, e.g. TextInput key handling
+ \o Items specified in \c forwardTo
+ \o specific key handlers, e.g. onReturnPressed
+ \o onKeyPress, onKeyRelease handlers
+ \o parent item
+ \endlist
+
+ If the event is accepted during any of the above steps, key
+ propagation stops.
+
\sa KeyEvent, {KeyNavigation}{KeyNavigation attached property}
*/
@@ -720,6 +782,22 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event)
*/
/*!
+ \qmlproperty enumeration Keys::priority
+
+ This property determines whether the keys are processed before
+ or after the attached item's own key handling.
+
+ \list
+ \o Keys.BeforeItem (default) - process the key events before normal
+ item key processing. If the event is accepted it will not
+ be passed on to the item.
+ \o Keys.AfterItem - process the key events after normal item key
+ handling. If the item accepts the key event it will not be
+ handled by the Keys attached property handler.
+ \endlist
+*/
+
+/*!
\qmlproperty list<Object> Keys::forwardTo
This property provides a way to forward key presses, key releases, and keyboard input
@@ -1039,6 +1117,7 @@ QDeclarativeKeysAttached::QDeclarativeKeysAttached(QObject *parent)
QDeclarativeItemKeyFilter(qobject_cast<QDeclarativeItem*>(parent))
{
Q_D(QDeclarativeKeysAttached);
+ m_processPost = false;
d->item = qobject_cast<QDeclarativeItem*>(parent);
}
@@ -1046,6 +1125,20 @@ QDeclarativeKeysAttached::~QDeclarativeKeysAttached()
{
}
+QDeclarativeKeysAttached::Priority QDeclarativeKeysAttached::priority() const
+{
+ return m_processPost ? AfterItem : BeforeItem;
+}
+
+void QDeclarativeKeysAttached::setPriority(Priority order)
+{
+ bool processPost = order == AfterItem;
+ if (processPost != m_processPost) {
+ m_processPost = processPost;
+ emit priorityChanged();
+ }
+}
+
void QDeclarativeKeysAttached::componentComplete()
{
Q_D(QDeclarativeKeysAttached);
@@ -1060,11 +1153,12 @@ void QDeclarativeKeysAttached::componentComplete()
}
}
-void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event)
+void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event, bool post)
{
Q_D(QDeclarativeKeysAttached);
- if (!d->enabled || d->inPress) {
+ if (post != m_processPost || !d->enabled || d->inPress) {
event->ignore();
+ QDeclarativeItemKeyFilter::keyPressed(event, post);
return;
}
@@ -1099,14 +1193,15 @@ void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event)
emit pressed(&ke);
event->setAccepted(ke.isAccepted());
- if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event);
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post);
}
-void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event)
+void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event, bool post)
{
Q_D(QDeclarativeKeysAttached);
- if (!d->enabled || d->inRelease) {
+ if (post != m_processPost || !d->enabled || d->inRelease) {
event->ignore();
+ QDeclarativeItemKeyFilter::keyReleased(event, post);
return;
}
@@ -1129,13 +1224,13 @@ void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event)
emit released(&ke);
event->setAccepted(ke.isAccepted());
- if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event);
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post);
}
-void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event)
+void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post)
{
Q_D(QDeclarativeKeysAttached);
- if (d->item && !d->inIM && d->item->scene()) {
+ if (post == m_processPost && d->item && !d->inIM && d->item->scene()) {
d->inIM = true;
for (int ii = 0; ii < d->targets.count(); ++ii) {
QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii));
@@ -1150,7 +1245,7 @@ void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event)
}
d->inIM = false;
}
- if (!event->isAccepted()) QDeclarativeItemKeyFilter::inputMethodEvent(event);
+ if (!event->isAccepted()) QDeclarativeItemKeyFilter::inputMethodEvent(event, post);
}
class QDeclarativeItemAccessor : public QGraphicsItem
@@ -1822,8 +1917,11 @@ void QDeclarativeItemPrivate::removeItemChangeListener(QDeclarativeItemChangeLis
void QDeclarativeItem::keyPressEvent(QKeyEvent *event)
{
Q_D(QDeclarativeItem);
+ keyPressPreHandler(event);
+ if (event->isAccepted())
+ return;
if (d->keyHandler)
- d->keyHandler->keyPressed(event);
+ d->keyHandler->keyPressed(event, true);
else
event->ignore();
}
@@ -1832,8 +1930,11 @@ void QDeclarativeItem::keyPressEvent(QKeyEvent *event)
void QDeclarativeItem::keyReleaseEvent(QKeyEvent *event)
{
Q_D(QDeclarativeItem);
+ keyReleasePreHandler(event);
+ if (event->isAccepted())
+ return;
if (d->keyHandler)
- d->keyHandler->keyReleased(event);
+ d->keyHandler->keyReleased(event, true);
else
event->ignore();
}
@@ -1842,8 +1943,11 @@ void QDeclarativeItem::keyReleaseEvent(QKeyEvent *event)
void QDeclarativeItem::inputMethodEvent(QInputMethodEvent *event)
{
Q_D(QDeclarativeItem);
+ inputMethodPreHandler(event);
+ if (event->isAccepted())
+ return;
if (d->keyHandler)
- d->keyHandler->inputMethodEvent(event);
+ d->keyHandler->inputMethodEvent(event, true);
else
event->ignore();
}
@@ -1862,6 +1966,37 @@ QVariant QDeclarativeItem::inputMethodQuery(Qt::InputMethodQuery query) const
return v;
}
+void QDeclarativeItem::keyPressPreHandler(QKeyEvent *event)
+{
+ Q_D(QDeclarativeItem);
+ if (d->keyHandler && !d->doneEventPreHandler)
+ d->keyHandler->keyPressed(event, false);
+ else
+ event->ignore();
+ d->doneEventPreHandler = true;
+}
+
+void QDeclarativeItem::keyReleasePreHandler(QKeyEvent *event)
+{
+ Q_D(QDeclarativeItem);
+ if (d->keyHandler && !d->doneEventPreHandler)
+ d->keyHandler->keyReleased(event, false);
+ else
+ event->ignore();
+ d->doneEventPreHandler = true;
+}
+
+void QDeclarativeItem::inputMethodPreHandler(QInputMethodEvent *event)
+{
+ Q_D(QDeclarativeItem);
+ if (d->keyHandler && !d->doneEventPreHandler)
+ d->keyHandler->inputMethodEvent(event, false);
+ else
+ event->ignore();
+ d->doneEventPreHandler = true;
+}
+
+
/*!
\internal
*/
@@ -2976,6 +3111,17 @@ void QDeclarativeItem::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidg
*/
bool QDeclarativeItem::event(QEvent *ev)
{
+ Q_D(QDeclarativeItem);
+ switch (ev->type()) {
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::InputMethod:
+ d->doneEventPreHandler = false;
+ break;
+ default:
+ break;
+ }
+
return QGraphicsObject::event(ev);
}
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index 3b05b09a62..29fd241c3d 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -178,6 +178,10 @@ protected:
virtual void keyReleaseEvent(QKeyEvent *event);
virtual void inputMethodEvent(QInputMethodEvent *);
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+ void keyPressPreHandler(QKeyEvent *);
+ void keyReleasePreHandler(QKeyEvent *);
+ void inputMethodPreHandler(QInputMethodEvent *);
+
virtual void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry);
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 516d6d08e5..15b34f0470 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -124,7 +124,7 @@ public:
_stateGroup(0), origin(QDeclarativeItem::Center),
widthValid(false), heightValid(false),
_componentComplete(true), _keepMouse(false),
- smooth(false), transformOriginDirty(true), keyHandler(0),
+ smooth(false), transformOriginDirty(true), doneEventPreHandler(false), keyHandler(0),
mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0)
{
QGraphicsItemPrivate::acceptedMouseButtons = 0;
@@ -263,6 +263,7 @@ public:
bool _keepMouse:1;
bool smooth:1;
bool transformOriginDirty : 1;
+ bool doneEventPreHandler : 1;
QDeclarativeItemKeyFilter *keyHandler;
@@ -324,12 +325,14 @@ public:
QDeclarativeItemKeyFilter(QDeclarativeItem * = 0);
virtual ~QDeclarativeItemKeyFilter();
- virtual void keyPressed(QKeyEvent *event);
- virtual void keyReleased(QKeyEvent *event);
- virtual void inputMethodEvent(QInputMethodEvent *event);
+ virtual void keyPressed(QKeyEvent *event, bool post);
+ virtual void keyReleased(QKeyEvent *event, bool post);
+ virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
virtual void componentComplete();
+ bool m_processPost;
+
private:
QDeclarativeItemKeyFilter *m_next;
};
@@ -359,6 +362,9 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte
Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY changed)
Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY changed)
Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY changed)
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
+
+ Q_ENUMS(Priority)
public:
QDeclarativeKeyNavigationAttached(QObject * = 0);
@@ -376,14 +382,19 @@ public:
QDeclarativeItem *backtab() const;
void setBacktab(QDeclarativeItem *);
+ enum Priority { BeforeItem, AfterItem };
+ Priority priority() const;
+ void setPriority(Priority);
+
static QDeclarativeKeyNavigationAttached *qmlAttachedProperties(QObject *);
Q_SIGNALS:
void changed();
+ void priorityChanged();
private:
- virtual void keyPressed(QKeyEvent *event);
- virtual void keyReleased(QKeyEvent *event);
+ virtual void keyPressed(QKeyEvent *event, bool post);
+ virtual void keyReleased(QKeyEvent *event, bool post);
};
class QDeclarativeKeysAttachedPrivate : public QObjectPrivate
@@ -423,6 +434,9 @@ class QDeclarativeKeysAttached : public QObject, public QDeclarativeItemKeyFilte
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> forwardTo READ forwardTo)
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
+
+ Q_ENUMS(Priority)
public:
QDeclarativeKeysAttached(QObject *parent=0);
@@ -437,6 +451,10 @@ public:
}
}
+ enum Priority { BeforeItem, AfterItem};
+ Priority priority() const;
+ void setPriority(Priority);
+
QDeclarativeListProperty<QDeclarativeItem> forwardTo() {
Q_D(QDeclarativeKeysAttached);
return QDeclarativeListProperty<QDeclarativeItem>(this, d->targets);
@@ -448,6 +466,7 @@ public:
Q_SIGNALS:
void enabledChanged();
+ void priorityChanged();
void pressed(QDeclarativeKeyEvent *event);
void released(QDeclarativeKeyEvent *event);
void digit0Pressed(QDeclarativeKeyEvent *event);
@@ -492,9 +511,9 @@ Q_SIGNALS:
void volumeDownPressed(QDeclarativeKeyEvent *event);
private:
- virtual void keyPressed(QKeyEvent *event);
- virtual void keyReleased(QKeyEvent *event);
- virtual void inputMethodEvent(QInputMethodEvent *);
+ virtual void keyPressed(QKeyEvent *event, bool post);
+ virtual void keyReleased(QKeyEvent *event, bool post);
+ virtual void inputMethodEvent(QInputMethodEvent *, bool post);
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
const QByteArray keyToSignal(int key) {
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index b71bb7ee9f..936f9b0262 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -2263,6 +2263,9 @@ qreal QDeclarativeListView::maxXExtent() const
void QDeclarativeListView::keyPressEvent(QKeyEvent *event)
{
Q_D(QDeclarativeListView);
+ keyPressPreHandler(event);
+ if (event->isAccepted())
+ return;
if (d->model && d->model->count() && d->interactive) {
if ((d->orient == QDeclarativeListView::Horizontal && event->key() == Qt::Key_Left)
@@ -2287,10 +2290,8 @@ void QDeclarativeListView::keyPressEvent(QKeyEvent *event)
}
}
}
- QDeclarativeFlickable::keyPressEvent(event);
- if (event->isAccepted())
- return;
event->ignore();
+ QDeclarativeFlickable::keyPressEvent(event);
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 93bff3ef9f..8796e63819 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -204,7 +204,11 @@ void QDeclarativeBasePositioner::prePositioning()
if (!isComponentComplete())
return;
+ if (d->doingPositioning)
+ return;
+
d->queuedPositioning = false;
+ d->doingPositioning = true;
//Need to order children by creation order modified by stacking order
QList<QGraphicsItem *> children = d->QGraphicsItemPrivate::children;
qSort(children.begin(), children.end(), d->insertionOrder);
@@ -242,6 +246,7 @@ void QDeclarativeBasePositioner::prePositioning()
doPositioning(&contentSize);
if(d->addTransition || d->moveTransition)
finishApplyTransitions();
+ d->doingPositioning = false;
//Set implicit size to the size of its children
setImplicitHeight(contentSize.height());
setImplicitWidth(contentSize.width());
@@ -339,7 +344,8 @@ Column {
Note that the positioner assumes that the x and y positions of its children
will not change. If you manually change the x or y properties in script, bind
- the x or y properties, or use anchors on a child of a positioner, then the
+ the x or y properties, use anchors on a child of a positioner, or have the
+ height of a child depend on the position of a child, then the
positioner may exhibit strange behaviour.
*/
@@ -437,7 +443,7 @@ void QDeclarativeColumn::doPositioning(QSizeF *contentSize)
void QDeclarativeColumn::reportConflictingAnchors()
{
- bool childsWithConflictingAnchors(false);
+ QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this));
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
if (child.item) {
@@ -446,15 +452,16 @@ void QDeclarativeColumn::reportConflictingAnchors()
QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors();
if (usedAnchors & QDeclarativeAnchors::TopAnchor ||
usedAnchors & QDeclarativeAnchors::BottomAnchor ||
- usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
- childsWithConflictingAnchors = true;
+ usedAnchors & QDeclarativeAnchors::VCenterAnchor ||
+ anchors->fill() || anchors->centerIn()) {
+ d->anchorConflict = true;
break;
}
}
}
}
- if (childsWithConflictingAnchors) {
- qmlInfo(this) << "Cannot specify top, bottom or verticalCenter anchors for items inside Column";
+ if (d->anchorConflict) {
+ qmlInfo(this) << "Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column";
}
}
@@ -486,7 +493,8 @@ Row {
Note that the positioner assumes that the x and y positions of its children
will not change. If you manually change the x or y properties in script, bind
- the x or y properties, or use anchors on a child of a positioner, then the
+ the x or y properties, use anchors on a child of a positioner, or have the
+ width of a child depend on the position of a child, then the
positioner may exhibit strange behaviour.
*/
@@ -574,7 +582,7 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize)
void QDeclarativeRow::reportConflictingAnchors()
{
- bool childsWithConflictingAnchors(false);
+ QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this));
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
if (child.item) {
@@ -583,16 +591,16 @@ void QDeclarativeRow::reportConflictingAnchors()
QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors();
if (usedAnchors & QDeclarativeAnchors::LeftAnchor ||
usedAnchors & QDeclarativeAnchors::RightAnchor ||
- usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
- childsWithConflictingAnchors = true;
+ usedAnchors & QDeclarativeAnchors::HCenterAnchor ||
+ anchors->fill() || anchors->centerIn()) {
+ d->anchorConflict = true;
break;
}
}
}
}
- if (childsWithConflictingAnchors) {
- qmlInfo(this) << "Cannot specify left, right or horizontalCenter anchors for items inside Row";
- }
+ if (d->anchorConflict)
+ qmlInfo(this) << "Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row";
}
/*!
@@ -638,7 +646,8 @@ Grid {
Note that the positioner assumes that the x and y positions of its children
will not change. If you manually change the x or y properties in script, bind
- the x or y properties, or use anchors on a child of a positioner, then the
+ the x or y properties, use anchors on a child of a positioner, or have the
+ width or height of a child depend on the position of a child, then the
positioner may exhibit strange behaviour.
*/
/*!
@@ -866,20 +875,19 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
void QDeclarativeGrid::reportConflictingAnchors()
{
- bool childsWithConflictingAnchors(false);
+ QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this));
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
if (child.item) {
QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors;
- if (anchors && anchors->usedAnchors()) {
- childsWithConflictingAnchors = true;
+ if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) {
+ d->anchorConflict = true;
break;
}
}
}
- if (childsWithConflictingAnchors) {
+ if (d->anchorConflict)
qmlInfo(this) << "Cannot specify anchors for items inside Grid";
- }
}
/*!
@@ -888,6 +896,11 @@ void QDeclarativeGrid::reportConflictingAnchors()
\brief The Flow item lines up its children side by side, wrapping as necessary.
\inherits Item
+ Note that the positioner assumes that the x and y positions of its children
+ will not change. If you manually change the x or y properties in script, bind
+ the x or y properties, use anchors on a child of a positioner, or have the
+ width or height of a child depend on the position of a child, then the
+ positioner may exhibit strange behaviour.
*/
/*!
@@ -1026,20 +1039,19 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
void QDeclarativeFlow::reportConflictingAnchors()
{
- bool childsWithConflictingAnchors(false);
+ Q_D(QDeclarativeFlow);
for (int ii = 0; ii < positionedItems.count(); ++ii) {
const PositionedItem &child = positionedItems.at(ii);
if (child.item) {
QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors;
- if (anchors && anchors->usedAnchors()) {
- childsWithConflictingAnchors = true;
+ if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) {
+ d->anchorConflict = true;
break;
}
}
}
- if (childsWithConflictingAnchors) {
+ if (d->anchorConflict)
qmlInfo(this) << "Cannot specify anchors for items inside Flow";
- }
}
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
index 576f35b19a..04f0181edb 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h
@@ -75,6 +75,7 @@ public:
QDeclarativeBasePositionerPrivate()
: spacing(0), type(QDeclarativeBasePositioner::None)
, moveTransition(0), addTransition(0), queuedPositioning(false)
+ , doingPositioning(false), anchorConflict(false)
{
}
@@ -95,7 +96,9 @@ public:
void watchChanges(QDeclarativeItem *other);
void unwatchChanges(QDeclarativeItem* other);
- bool queuedPositioning;
+ bool queuedPositioning : 1;
+ bool doingPositioning : 1;
+ bool anchorConflict : 1;
virtual void itemSiblingOrderChanged(QDeclarativeItem* other)
{
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index db20da8323..7f71dd2d91 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -858,8 +858,9 @@ Handles the given key \a event.
void QDeclarativeTextEdit::keyPressEvent(QKeyEvent *event)
{
Q_D(QDeclarativeTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
-
+ keyPressPreHandler(event);
+ if (!event->isAccepted())
+ d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QDeclarativePaintedItem::keyPressEvent(event);
}
@@ -871,7 +872,9 @@ Handles the given key \a event.
void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event)
{
Q_D(QDeclarativeTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
+ keyReleasePreHandler(event);
+ if (!event->isAccepted())
+ d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QDeclarativePaintedItem::keyReleaseEvent(event);
}
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index afbaaac571..db480b15d9 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass TextInput QDeclarativeTextInput
\since 4.7
- The TextInput item allows you to add an editable line of text to a scene.
+ \brief The TextInput item allows you to add an editable line of text to a scene.
TextInput can only display a single line of text, and can only display
plain text. However it can provide addition input constraints on the text.
@@ -863,6 +863,9 @@ void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus)
void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev)
{
Q_D(QDeclarativeTextInput);
+ keyPressPreHandler(ev);
+ if (ev->isAccepted())
+ return;
if (((ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down) && ev->modifiers() == Qt::NoModifier) // Don't allow MacOSX up/down support, and we don't allow a completer.
|| (((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
|| (d->control->cursor() == d->control->text().length()
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 622354894e..9a5c9dea33 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -537,10 +537,7 @@ void QDeclarativeListModel::append(const QScriptValue& valuemap)
*/
QScriptValue QDeclarativeListModel::get(int index) const
{
- // the internal flat/nested class takes care of return value for bad index
- if (index >= count() || index < 0)
- qmlInfo(this) << tr("get: index %1 out of range").arg(index);
-
+ // the internal flat/nested class checks for bad index
return m_flat ? m_flat->get(index) : m_nested->get(index);
}