1 // -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 deleteAll(aTree, aView, aItems, aDeletedItems) {
9 for (var i = 0; i < aItems.length; ++i) {
10 aDeletedItems.push(aItems[i]);
12 aItems.splice(0, aItems.length);
13 var oldCount = aView.rowCount;
15 aTree.rowCountChanged(0, -oldCount);
18 deleteSelectedItems(aTree, aView, aItems, aDeletedItems) {
19 var selection = aTree.view.selection;
20 selection.selectEventsSuppressed = true;
22 var rc = selection.getRangeCount();
23 for (var i = 0; i < rc; ++i) {
26 selection.getRangeAt(i, min, max);
27 for (let j = min.value; j <= max.value; ++j) {
28 aDeletedItems.push(aItems[j]);
33 var nextSelection = 0;
34 for (i = 0; i < aItems.length; ++i) {
37 while (j < aItems.length && !aItems[j]) {
40 aItems.splice(i, j - i);
41 nextSelection = j < aView.rowCount ? j - 1 : j - 2;
42 aView._rowCount -= j - i;
43 aTree.rowCountChanged(i, i - j);
48 selection.select(nextSelection);
49 aTree.ensureRowIsVisible(nextSelection);
52 selection.selectEventsSuppressed = false;
64 var ascending = aColumn == aLastSortColumn ? !aLastSortAscending : true;
65 if (!aDataSet.length) {
69 var sortFunction = null;
71 sortFunction = function(a, b) {
72 return aComparator(a[aColumn], b[aColumn]);
75 aDataSet.sort(sortFunction);
80 aTree.view.selection.clearSelection();
81 aTree.view.selection.select(0);
83 aTree.ensureRowIsVisible(0);