From a3379326116205157b4cbd4ec2817ebc1490ba65 Mon Sep 17 00:00:00 2001 From: Christian Hagendorn Date: Tue, 5 Feb 2013 19:07:33 +0100 Subject: [PATCH] [BUG #7199] Improved lookup table creation. The lookup table is build when the model change effects the visible part of the tree. --- .../class/qx/test/ui/tree/virtual/Tree.js | 12 +++++++++ .../source/class/qx/ui/tree/VirtualTree.js | 26 ++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/framework/source/class/qx/test/ui/tree/virtual/Tree.js b/framework/source/class/qx/test/ui/tree/virtual/Tree.js index d4ef837dd00..cf4929967ea 100644 --- a/framework/source/class/qx/test/ui/tree/virtual/Tree.js +++ b/framework/source/class/qx/test/ui/tree/virtual/Tree.js @@ -305,6 +305,18 @@ qx.Class.define("qx.test.ui.tree.virtual.Tree", }, + testNoChangeBubblesAddChild : function() + { + var root = this.createModelAndSetModel(3); + + var spy = this.spy(this.tree, "buildLookupTable"); + + var newItem = new qx.test.ui.tree.virtual.Node("test"); + root.getChildren().getItem(2).getChildren().getItem(0).getChildren().push(newItem); + this.assertNotCalled(spy); + }, + + testGetOpenNodes : function() { var root = this.createModelAndSetModel(1); diff --git a/framework/source/class/qx/ui/tree/VirtualTree.js b/framework/source/class/qx/ui/tree/VirtualTree.js index a0d1d4549b9..d65025758fe 100644 --- a/framework/source/class/qx/ui/tree/VirtualTree.js +++ b/framework/source/class/qx/ui/tree/VirtualTree.js @@ -677,15 +677,35 @@ qx.Class.define("qx.ui.tree.VirtualTree", */ _onChangeBubble : function(event) { - var propertyName = event.getData().name; + var data = event.getData(); + var propertyName = data.name; var index = propertyName.lastIndexOf("."); if (index != -1) { propertyName = propertyName.substr(index + 1, propertyName.length); } - if (qx.lang.String.startsWith(propertyName, this.getChildProperty())) { - this.__applyModelChanges(); + // only continue when the effected property is the child property + if (qx.lang.String.startsWith(propertyName, this.getChildProperty())) + { + var item = data.item; + + if (qx.Class.isSubClassOf(item.constructor, qx.data.Array)) + { + if (index === -1) + { + item = this.getModel(); + } + else + { + var propertyChain = data.name.substr(0, index); + item = qx.data.SingleValueBinding.resolvePropertyChain(this.getModel(), propertyChain); + } + } + + if (this.__lookupTable.indexOf(item) != -1) { + this.__applyModelChanges(); + } } },