Bug 346819: fix the drop/canDrop implementations so that search engine list drag and drop behaves correctly in all cases, r=mconnor

This commit is contained in:
gavin%gavinsharp.com 2006-08-03 18:57:59 +00:00
Родитель 1e9d8f5eed
Коммит 468e598194
1 изменённых файлов: 18 добавлений и 14 удалений

Просмотреть файл

@ -358,25 +358,29 @@ EngineView.prototype = {
canDrop: function(targetIndex, orientation) {
var sourceIndex = this.getSourceIndexFromDrag();
return sourceIndex != -1 &&
sourceIndex != targetIndex &&
(orientation == Ci.nsITreeView.DROP_BEFORE ||
orientation == Ci.nsITreeView.DROP_AFTER);
return (sourceIndex != -1 &&
sourceIndex != targetIndex &&
sourceIndex != (targetIndex + orientation));
},
drop: function(newIndex, orientation) {
drop: function(dropIndex, orientation) {
var sourceIndex = this.getSourceIndexFromDrag();
if (sourceIndex != -1) {
var sourceEngine = this._engineStore.engines[sourceIndex];
var sourceEngine = this._engineStore.engines[sourceIndex];
this._engineStore.moveEngine(sourceEngine, newIndex);
// Redraw, and adjust selection
this.invalidate();
this.selection.clearSelection();
this.selection.select(newIndex);
if (dropIndex > sourceIndex) {
if (orientation == Ci.nsITreeView.DROP_BEFORE)
dropIndex--;
} else {
if (orientation == Ci.nsITreeView.DROP_AFTER)
dropIndex++;
}
this._engineStore.moveEngine(sourceEngine, dropIndex);
// Redraw, and adjust selection
this.invalidate();
this.selection.clearSelection();
this.selection.select(dropIndex);
},
selection: null,