From fdd8245eec7e5fee4d663b3645e267e276461652 Mon Sep 17 00:00:00 2001 From: David Norton Date: Fri, 2 Jun 2006 12:59:58 +0000 Subject: [PATCH] Some experimentation with drag and drop (doesn't work yet) Made some fixes on itemTreeView to allow for notify() on multiple deletes (shifts the row identifier up 1 for each previous delete, etc.) One more thing -- this might not happen because the tree calls each Item.erase() or Collection.removeItem() individually. Bug fix on notifier.js so that register*Tree() actually returns the hash. :-) Unfortunately, unregister*Tree() does not seem to actually work, there is still an object at _observers['itemTree'][hash] (temporary): When you select an item Scholar no longer loads a page into the browser. The javascript bugs on those HTML pages were frustrating the debugger. --- .../content/scholar/folderTreeView.js | 29 ++++++- .../content/scholar/itemTreeView.js | 82 +++++++++++++------ chrome/chromeFiles/content/scholar/overlay.js | 32 +++++++- .../chromeFiles/content/scholar/overlay.xul | 2 + .../content/scholar/xpcom/notifier.js | 4 +- 5 files changed, 116 insertions(+), 33 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/folderTreeView.js b/chrome/chromeFiles/content/scholar/folderTreeView.js index ff534f214..960344fdf 100644 --- a/chrome/chromeFiles/content/scholar/folderTreeView.js +++ b/chrome/chromeFiles/content/scholar/folderTreeView.js @@ -29,8 +29,16 @@ Scholar.FolderTreeView.prototype.getCellText = function(row, column) return ""; } -Scholar.FolderTreeView.prototype.isContainer = function(row) { return this._getItemAtRow(row).isCollection(); } -Scholar.FolderTreeView.prototype.isContainerOpen = function(row) { return this._dataItems[row][1]; } +Scholar.FolderTreeView.prototype.isContainer = function(row) +{ + return this._getItemAtRow(row).isCollection(); +} + +Scholar.FolderTreeView.prototype.isContainerOpen = function(row) +{ + return this._dataItems[row][1]; +} + Scholar.FolderTreeView.prototype.isContainerEmpty = function(row) { var itemGroup = this._getItemAtRow(row); @@ -164,6 +172,23 @@ Scholar.FolderTreeView.prototype._refreshHashMap = function() //Scholar.debug(Scholar.varDump(this.objectRowMap)); } +Scholar.FolderTreeView.prototype.canDrop = function(row, orient) +{ + if(orient == this.DROP_ON && this._getItemAtRow(row).isCollection()) + return true; + else + return false; + +} + +Scholar.FolderTreeView.prototype.drop = function(row, orient) +{ + //you can't really do anything here, look to overlay.js - ScholarCollectionsDragObserver +} + +// +// SCHOLAR ITEMGROUP +// Scholar.ItemGroup = function(type, ref) { this.type = type; diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js index e84216528..78d50711b 100644 --- a/chrome/chromeFiles/content/scholar/itemTreeView.js +++ b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -119,10 +119,10 @@ Scholar.ItemTreeView.prototype.deleteSelection = function() else if(this._itemGroup.isCollection()) this._itemGroup.ref.removeItem(this._getItemAtRow(rows[i]-i).getID()); - + /* Don't do this, the notifier tells us? //remove row from tree: this._hideItem(rows[i]-i); - this._treebox.rowCountChanged(rows[i]-i, -1); + this._treebox.rowCountChanged(rows[i]-i, -1); */ } this._treebox.endUpdateBatch(); @@ -159,36 +159,66 @@ Scholar.ItemTreeView.prototype.getCollectionID = function() Scholar.ItemTreeView.prototype.notify = function(action, type, ids) { ids = Scholar.flattenArguments(ids); + var madeChanges = false; - for (var i=0, len=ids.length; i 0) { - 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(ids[i]); + rows.sort(function(a,b) { return a-b }); - if(this._itemGroup.isLibrary() || item.inCollection(this.getCollectionID())) + for(var i=0, len=rows.length; i