commit d65bf82e0ea50059fb5bdb3e314b947ba7fdce4d
parent c1241b608a0eba10ba1ffb06e5c085fb213a178f
Author: David Norton <david@nortoncrew.com>
Date: Thu, 1 Jun 2006 17:54:41 +0000
ItemTreeView now has support for receiving change events. (needs support on the data layer, and probably bug fixes).
(+ some cosmetic changes)
Diffstat:
3 files changed, 59 insertions(+), 15 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js
@@ -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();
}
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul
@@ -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"/>
diff --git a/chrome/chromeFiles/skin/default/scholar/overlay.css b/chrome/chromeFiles/skin/default/scholar/overlay.css
@@ -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