ItemTreeView now has support for receiving change events. (needs support on the data layer, and probably bug fixes).
(+ some cosmetic changes)
This commit is contained in:
parent
c1241b608a
commit
d65bf82e0e
3 changed files with 59 additions and 15 deletions
|
@ -4,6 +4,9 @@ Scholar.ItemTreeView = function(itemGroup)
|
|||
this._dataItems = new Array();
|
||||
this.rowCount = 0;
|
||||
this._itemGroup = itemGroup;
|
||||
this.refresh();
|
||||
|
||||
// Scholar.registerItemTree(this);
|
||||
}
|
||||
|
||||
Scholar.ItemTreeView.prototype.setTree = function(treebox)
|
||||
|
@ -11,12 +14,6 @@ Scholar.ItemTreeView.prototype.setTree = function(treebox)
|
|||
if(this._treebox)
|
||||
return;
|
||||
this._treebox = treebox;
|
||||
|
||||
var newRows = this._itemGroup.getChildItems();
|
||||
for(var i = 0; i < newRows.length; i++)
|
||||
this._showItem(newRows[i], i+1); //item ref, before row
|
||||
|
||||
this._refreshHashMap();
|
||||
}
|
||||
|
||||
Scholar.ItemTreeView.prototype.getCellText = function(row, column)
|
||||
|
@ -132,4 +129,55 @@ Scholar.ItemTreeView.prototype._refreshHashMap = function()
|
|||
//Scholar.debug(Scholar.varDump(this.folderRowMap));
|
||||
//Scholar.debug(Scholar.varDump(this.objectRowMap));
|
||||
|
||||
}
|
||||
|
||||
Scholar.ItemTreeView.prototype.getCollectionID = function()
|
||||
{
|
||||
if(this._itemGroup.isCollection())
|
||||
return this._itemGroup.ref.getID();
|
||||
|
||||
}
|
||||
|
||||
//CALLED BY DATA LAYER ON CHANGE:
|
||||
Scholar.ItemTreeView.prototype.notify = function(action, type, id)
|
||||
{
|
||||
var row = this._itemRowMap[id];
|
||||
if(action == 'remove' && row)
|
||||
{
|
||||
this._hideItem(row);
|
||||
this._treebox.rowCountChanged(row,-1);
|
||||
}
|
||||
else if(action == 'modify' && row)
|
||||
{
|
||||
this._treebox.invalidateRow(row)
|
||||
}
|
||||
else if(action == 'add' && !row)
|
||||
{
|
||||
var item = Scholar.Items.get(id);
|
||||
|
||||
if(this._itemGroup.isLibrary() || item.hasParent(this.getCollectionID()))
|
||||
{
|
||||
this._showItem(item,this.rowCount);
|
||||
this._treebox.rowCountChanged(this.rowCount,1);
|
||||
}
|
||||
//TODO: sorted? figure it out later
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._refreshHashMap();
|
||||
}
|
||||
|
||||
Scholar.ItemTreeView.prototype.refresh = function()
|
||||
{
|
||||
this._dataItems = new Array();
|
||||
this.rowCount = 0;
|
||||
|
||||
var newRows = this._itemGroup.getChildItems();
|
||||
for(var i = 0; i < newRows.length; i++)
|
||||
this._showItem(newRows[i], i+1); //item ref, before row
|
||||
|
||||
this._refreshHashMap();
|
||||
}
|
|
@ -21,10 +21,6 @@
|
|||
|
||||
<window id="main-window">
|
||||
<vbox id="scholar-floater" hidden="true">
|
||||
<toolbar id="scholar-floater-handle">
|
||||
<label value="Scholar Quick Info"/>
|
||||
<spacer flex="1"/>
|
||||
</toolbar>
|
||||
<vbox id="scholar-metadata"/>
|
||||
<vbox id="scholar-notes">
|
||||
<textbox value="Notes.... lorem ispum delorum..." multiline="true" flex="1"/>
|
||||
|
|
|
@ -59,21 +59,21 @@ tree #items-tree
|
|||
right: 0px;
|
||||
margin-bottom: 30px;
|
||||
margin-right: 30px;
|
||||
border: 1px solid #a5a5a5;
|
||||
padding: 5px;
|
||||
background: #f5f5f5;
|
||||
|
||||
font-size: 12px;
|
||||
width: 400px;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
#scholar-floater vbox, #scholar-floater toolbar
|
||||
#scholar-floater vbox
|
||||
{
|
||||
|
||||
border: 1px solid #a5a5a5;
|
||||
background: #f5f5f5;
|
||||
|
||||
width: 400px;
|
||||
max-width: 400px;
|
||||
margin-top: 5px;
|
||||
padding: none;
|
||||
}
|
||||
|
||||
#scholar-metadata
|
||||
|
|
Loading…
Reference in a new issue