more d&d polish NPOB

This commit is contained in:
beng%bengoodger.com 2005-12-01 02:22:14 +00:00
parent d05d68190c
commit ef2f143ba1
2 changed files with 45 additions and 10 deletions

View File

@ -62,9 +62,15 @@ const TYPE_HTML = "text/html";
// Place entries as raw URL text
const TYPE_UNICODE = "text/unicode";
// No change to the view, preserve current selection
const RELOAD_ACTION_NOTHING = 0;
// Inserting items new to the view, select the inserted rows
const RELOAD_ACTION_INSERT = 1;
// Removing items from the view, select the first item after the last selected
const RELOAD_ACTION_REMOVE = 2;
// Moving items within a view, don't treat the dropped items as additional
// rows.
const RELOAD_ACTION_MOVE = 3;
function STACK(args) {
var temp = arguments.callee.caller;
@ -1015,7 +1021,8 @@ var PlacesControllerDragHelper = {
var copy = session.dragAction & Ci.nsIDragService.DRAGDROP_ACTION_COPY;
var transactions = [];
var xferable = this._initTransferable(targetView, orientation);
for (var i = 0; i < session.numDropItems; ++i) {
var dropCount = session.numDropItems;
for (var i = 0; i < dropCount; ++i) {
session.getData(xferable, i);
var data = { }, flavor = { };
@ -1030,14 +1037,23 @@ var PlacesControllerDragHelper = {
insertionPoint.index, copy));
}
if (sourceView)
sourceView.willReloadView(RELOAD_ACTION_REMOVE, sourceView, null,
session.numDropItems);
PlacesController.willReloadView(RELOAD_ACTION_INSERT, targetView,
insertionPoint, session.numDropItems);
if (sourceView == targetView) {
// When we're rearranging the contents of the current view, we
// invoke separate handling that takes care not to count the
// dropCount as added rows - they just changed index.
PlacesController.willReloadView(RELOAD_ACTION_MOVE, targetView,
insertionPoint, dropCount);
}
else {
if (sourceView)
sourceView.willReloadView(RELOAD_ACTION_REMOVE, sourceView, null,
dropCount);
PlacesController.willReloadView(RELOAD_ACTION_INSERT, targetView,
insertionPoint, dropCount);
}
var txn = new PlacesAggregateTransaction("DropItems", transactions);
PlacesController._hist.transactionManager.doTransaction(txn);
if (sourceView)
if (sourceView && sourceView != targetView)
sourceView.didReloadView(sourceView);
PlacesController.didReloadView(targetView);
}

View File

@ -478,6 +478,25 @@
this._selection.push({ min: min.value, max: max.value });
}
break;
case RELOAD_ACTION_MOVE:
// Insert index of insertion and number of rows to insert
var query = this._places.getNewQuery();
query.setFolders([insertionPoint.folderId], 1);
query.itemTypes = this.filterOptions;
var options = this._places.getNewQueryOptions();
options.setGroupingMode([Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER], 1);
var result = this._places.executeQuery(query, options);
if (insertionPoint.index > -1) {
var node = result.getChild(insertionPoint.index - 1);
var index = this.getResult().treeIndexForNode(node);
if (insertionPoint.index == result.childCount)
++index;
}
else
index = this.getResult().childCount;
var max = index + count - 1;
this._selection = [{ min: index, max: max }];
break;
case RELOAD_ACTION_INSERT:
// Insert index of insertion and number of rows to insert
var query = this._places.getNewQuery();
@ -505,8 +524,8 @@
this._selection = [{ min: min.value, max: min.value }];
break;
}
if (this._selection.length)
LOG("SET UP RANGE: " + this._selection[0].toSource() + " for " + this.id + " action = " + action);
//if (this._selection.length)
// LOG("SET UP RANGE: " + this._selection[0].toSource() + " for " + this.id + " action = " + action);
]]></body>
</method>
@ -519,7 +538,7 @@
selection.clearSelection();
for (var i = 0; i < this._selection.length; ++i) {
var range = this._selection[i];
LOG("RESELECTING RANGE: " + range.min + "," + range.max + " in: " + this.id);
//LOG("RESELECTING RANGE: " + range.min + "," + range.max + " in: " + this.id);
selection.rangedSelect(range.min, range.max, true);
}
if (view != this.view)