// #define TOUCH_DEBUG
// #define DIRTY_DEBUG
+#ifdef FOCUS_DEBUG
+void printFocusTree(QQuickItem *item, QQuickItem *scope = 0, int depth = 1);
+#endif
+
QQuickItem::UpdatePaintNodeData::UpdatePaintNodeData()
: transformNode(0)
{
QT_BEGIN_NAMESPACE
#ifdef FOCUS_DEBUG
+void printFocusTree(QQuickItem *item, QQuickItem *scope = 0, int depth = 1);
void printFocusTree(QQuickItem *item, QQuickItem *scope, int depth)
{
qWarning()
if (d->canvas) {
QQuickCanvasPrivate::get(d->canvas)->clearFocusInScope(scopeItem, scopeFocusedItem,
QQuickCanvasPrivate::DontChangeFocusProperty);
+ if (scopeFocusedItem != this)
+ QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, true);
} else {
QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(scopeItem, false);
}
for (int ii = 0; ii < childItems.count(); ++ii) {
QQuickItemPrivate::get(childItems.at(ii))->setEffectiveEnableRecur(
- flags & QQuickItem::ItemIsFocusScope ? q : scope, newEffectiveEnable);
+ (flags & QQuickItem::ItemIsFocusScope) && scope ? q : scope, newEffectiveEnable);
}
if (canvas && scope && effectiveEnable && focus) {
QVarLengthArray<QQuickItem *, 20> changed;
QQuickItem *oldSubFocusItem = QQuickItemPrivate::get(scope)->subFocusItem;
if (oldSubFocusItem) {
+ QQuickItemPrivate::get(oldSubFocusItem)->updateSubFocusItem(scope, false);
QQuickItemPrivate::get(oldSubFocusItem)->focus = false;
changed << oldSubFocusItem;
}
void multipleFocusClears();
void focusSubItemInNonFocusScope();
void parentItemWithFocus();
+ void reparentFocusedItem();
void constructor();
void setParentItem();
}
}
+void tst_qquickitem::reparentFocusedItem()
+{
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem parent(canvas.rootItem());
+ QQuickItem child(&parent);
+ QQuickItem sibling(&parent);
+ QQuickItem grandchild(&child);
+
+ FocusState focusState;
+ focusState << &parent << &child << &sibling << &grandchild;
+ FVERIFY();
+
+ grandchild.setFocus(true);
+ focusState[&parent].set(false, false);
+ focusState[&child].set(false, false);
+ focusState[&sibling].set(false, false);
+ focusState[&grandchild].set(true, true);
+ focusState.active(&grandchild);
+ FVERIFY();
+
+ // Parenting the item to another item within the same focus scope shouldn't change it's focus.
+ child.setParentItem(&sibling);
+ FVERIFY();
+}
+
void tst_qquickitem::constructor()
{
QQuickItem *root = new QQuickItem;