Navigation Menu

Skip to content

Commit

Permalink
[BUG #7199] Improved lookup table creation. The lookup table is build…
Browse files Browse the repository at this point in the history
… when the model change effects the visible part of the tree.
  • Loading branch information
Christian Hagendorn committed Feb 5, 2013
1 parent 8cb9289 commit a337932
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
12 changes: 12 additions & 0 deletions framework/source/class/qx/test/ui/tree/virtual/Tree.js
Expand Up @@ -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);
Expand Down
26 changes: 23 additions & 3 deletions framework/source/class/qx/ui/tree/VirtualTree.js
Expand Up @@ -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();
}
}
},

Expand Down

0 comments on commit a337932

Please sign in to comment.