Bug 381281 - Cannot reorder bookmarks. r=sspitzer.

This commit is contained in:
mozilla.mano@sent.com 2007-05-20 15:27:04 -07:00
parent 0123739ccf
commit ce228c8079
2 changed files with 19 additions and 18 deletions

View File

@ -610,7 +610,7 @@
this._self._selection = event.target.node; this._self._selection = event.target.node;
if (event.ctrlKey) if (event.ctrlKey)
dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY; dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY;
xferData.data = this._controller.getTransferData(dragAction.action); xferData.data = this._self._controller.getTransferData(dragAction.action);
}, },
canDrop: function TBV_DO_canDrop(event, session) { canDrop: function TBV_DO_canDrop(event, session) {

View File

@ -57,10 +57,14 @@
setTimeout(function() { self.place = self.place; }, 0); setTimeout(function() { self.place = self.place; }, 0);
]]></constructor> ]]></constructor>
<destructor><![CDATA[ <destructor><![CDATA[
this._result.viewer = null; // Break the treeviewer->result->treeviewer cycle.
// Note: unsetting the result's viewer also unsets
// the viewer's reference to our treeBoxObject.
var result = this.getResult();
if (result)
result.viewer = null;
this.view = null; this.view = null;
this._result = null;
]]></destructor> ]]></destructor>
<property name="controller" <property name="controller"
@ -84,7 +88,7 @@
} }
]]></setter> ]]></setter>
</property> </property>
<method name="getBestOptions"> <method name="getBestOptions">
<body><![CDATA[ <body><![CDATA[
// Get the best set of grouping options to use, either reuse the // Get the best set of grouping options to use, either reuse the
@ -95,7 +99,7 @@
return options; return options;
]]></body> ]]></body>
</method> </method>
<method name="applyFilter"> <method name="applyFilter">
<parameter name="filterString"/> <parameter name="filterString"/>
<parameter name="onlyBookmarks"/> <parameter name="onlyBookmarks"/>
@ -639,21 +643,21 @@
// Drag and Drop does not work while a tree view is sorted. // Drag and Drop does not work while a tree view is sorted.
if (this.getAttribute("sortActive") == "true") if (this.getAttribute("sortActive") == "true")
throw Cr.NS_OK; throw Cr.NS_OK;
// Items that are "static" - i.e. above the user-configurable area
// of the view - can not be moved.
var nodes = this.getSelectionNodes(); var nodes = this.getSelectionNodes();
for (var i = 0; i < nodes.length; ++i) { for (var i = 0; i < nodes.length; ++i) {
var node = nodes[i]; var node = nodes[i];
// If this node is part of a readonly container (e.g. a livemark) it // If this node is part of a readonly container (e.g. a livemark) it
// cannot be moved, only copied, so we must change the action used // cannot be moved, only copied, so we must change the action used
// by the drag session. // by the drag session.
var parent = node.parent; var parent = node.parent;
if (PlacesUtils.nodeIsReadOnly(parent)) if (PlacesUtils.nodeIsReadOnly(parent)) {
dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY; dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY;
break;
}
} }
// XXXben - the drag wrapper should do this automatically. // XXXben - the drag wrapper should do this automatically.
if (event.ctrlKey) if (event.ctrlKey)
dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY; dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY;
@ -728,7 +732,7 @@
for (var i = 0; i < cc; ++i) { for (var i = 0; i < cc; ++i) {
var node = aContainer.getChild(i); var node = aContainer.getChild(i);
if (PlacesUtils.nodeIsFolder(node)) { if (PlacesUtils.nodeIsFolder(node)) {
if (folder.itemId == aItemId) { if (node.itemId == aItemId) {
foundNode = node; foundNode = node;
break; break;
} }
@ -795,9 +799,6 @@
var result = this._self.getResult(); var result = this._self.getResult();
var resultview = this._self.getResultView(); var resultview = this._self.getResultView();
var node = index != -1 ? resultview.nodeForTreeIndex(index) : result.root; var node = index != -1 ? resultview.nodeForTreeIndex(index) : result.root;
// Cannot drop before fixed items in the list.
if (node.parent == result.root && orientation != NHRVO.DROP_ON)
return false;
if (orientation == NHRVO.DROP_ON) { if (orientation == NHRVO.DROP_ON) {
// The user cannot drop an item into itself or a read-only container // The user cannot drop an item into itself or a read-only container
@ -809,10 +810,10 @@
} }
else if (node.parent && PlacesUtils.nodeIsReadOnly(node.parent)) else if (node.parent && PlacesUtils.nodeIsReadOnly(node.parent))
return false; return false;
return PlacesControllerDragHelper.canDrop(this._self, orientation); return PlacesControllerDragHelper.canDrop(this._self, orientation);
}, },
/** /**
* Adjusts an InsertionPoint's insertion index using these rules: * Adjusts an InsertionPoint's insertion index using these rules:
* XXXben define rules * XXXben define rules