41 _makeAtom:
function PTV__makeAtom(aString) {
42 return Cc[
"@mozilla.org/atom-service;1"].
48 _getAtomFor:
function PTV__getAtomFor(
aName) {
49 if (!this._atoms[
aName])
50 this._atoms[
aName] = this._makeAtom(aName);
52 return this._atoms[
aName];
55 _ensureValidRow:
function PTV__ensureValidRow(aRow) {
56 if (aRow < 0 || aRow >= this._visibleElements.length)
57 throw Cr.NS_ERROR_INVALID_ARG;
62 if (!this.__dateService) {
63 this.__dateService =
Cc[
"@mozilla.org/intl/scriptabledateformat;1"].
66 return this.__dateService;
70 if (aIID.equals(
Ci.nsITreeView) ||
71 aIID.equals(
Ci.nsINavHistoryResultViewer) ||
72 aIID.equals(
Ci.nsINavHistoryResultTreeViewer) ||
73 aIID.equals(
Ci.nsISupports))
76 throw Cr.NS_ERROR_NO_INTERFACE;
82 _finishInit:
function PTV__finishInit() {
83 var selection = this.selection;
85 selection.selectEventsSuppressed =
true;
87 this._rootNode._viewIndex = -1;
88 if (!this._rootNode.containerOpen) {
90 this._rootNode.containerOpen =
true;
93 this.invalidateContainer(this._rootNode);
96 this.sortingChanged(this._result.sortingMode);
99 selection.selectEventsSuppressed =
false;
116 _buildVisibleSection:
117 function PTV__buildVisibleSection(aContainer, aVisible, aToOpen, aVisibleStartIndex)
119 if (!aContainer.containerOpen)
122 const openLiteral =
PlacesUIUtils.RDF.GetResource(
"http://home.netscape.com/NC-rdf#open");
125 var cc = aContainer.childCount;
126 var sortingMode = this._result.sortingMode;
127 for (var
i=0;
i < cc;
i++) {
128 var curChild = aContainer.getChild(
i);
129 var curChildType = curChild.type;
132 if (curChildType ==
Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR) {
133 if (sortingMode !=
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) {
134 curChild._viewIndex = -1;
140 curChild._viewIndex = aVisibleStartIndex + aVisible.length;
141 aVisible.push(curChild);
144 if (!this._flatList &&
145 curChild instanceof
Ci.nsINavHistoryContainerResultNode) {
146 var resource = this._getResourceForNode(curChild);
147 var isopen = resource !=
null &&
150 if (isopen != curChild.containerOpen)
151 aToOpen.push(curChild);
152 else if (curChild.containerOpen && curChild.childCount > 0)
153 this._buildVisibleSection(curChild, aVisible, aToOpen, aVisibleStartIndex);
162 _countVisibleRowsForNode:
function PTV__countVisibleRowsForNode(aNode) {
163 if (aNode == this._rootNode)
164 return this._visibleElements.length;
166 var viewIndex = aNode._viewIndex;
167 NS_ASSERT(viewIndex >= 0,
"Node is not visible, no rows to count");
168 var outerLevel = aNode.indentLevel;
169 for (var
i = viewIndex + 1;
i < this._visibleElements.length;
i++) {
170 if (this._visibleElements[
i].indentLevel <= outerLevel)
171 return i - viewIndex;
174 return this._visibleElements.length - viewIndex;
185 _refreshVisibleSection:
function PTV__refreshVisibleSection(aContainer) {
186 NS_ASSERT(this._result,
"Need to have a result to update");
191 if (aContainer != this._rootNode) {
192 if (aContainer._viewIndex < 0 ||
193 aContainer._viewIndex >
this._visibleElements.length)
194 throw "Trying to expand a node that is not visible";
196 NS_ASSERT(this._visibleElements[aContainer._viewIndex] == aContainer,
197 "Visible index is out of sync!");
200 var startReplacement = aContainer._viewIndex + 1;
201 var replaceCount = this._countVisibleRowsForNode(aContainer);
206 if (aContainer != this._rootNode)
210 var previouslySelectedNodes = [];
211 var selection = this.selection;
212 var rc = selection.getRangeCount();
213 for (var rangeIndex = 0; rangeIndex < rc; rangeIndex++) {
214 var
min = { }, max = { };
215 selection.getRangeAt(rangeIndex, min, max);
216 var lastIndex = Math.min(max.value, startReplacement + replaceCount -1);
219 if (max.value < startReplacement || min.value > lastIndex)
224 var firstIndex = Math.max(min.value, startReplacement);
225 for (var nodeIndex = firstIndex; nodeIndex <= lastIndex; nodeIndex++) {
228 var
node = this._visibleElements[nodeIndex];
229 if (nodeIndex >= startReplacement &&
230 nodeIndex < startReplacement + replaceCount)
231 node._viewIndex = -1;
233 previouslySelectedNodes.push(
234 { node:
node, oldIndex: nodeIndex });
239 var newElements = [];
240 var toOpenElements = [];
241 this._buildVisibleSection(aContainer,
242 newElements, toOpenElements, startReplacement);
247 this._visibleElements =
248 this._visibleElements.slice(0, startReplacement).concat(newElements)
249 .concat(this._visibleElements.slice(startReplacement + replaceCount,
250 this._visibleElements.length));
254 if (replaceCount != newElements.length) {
255 for (var
i = startReplacement + newElements.length;
256 i <
this._visibleElements.length;
i++) {
257 this._visibleElements[
i]._viewIndex =
i;
262 selection.selectEventsSuppressed =
true;
263 this._tree.beginUpdateBatch();
266 this._tree.rowCountChanged(startReplacement, -replaceCount);
267 if (newElements.length)
268 this._tree.rowCountChanged(startReplacement, newElements.length);
270 if (!this._flatList) {
272 for (var
i = 0;
i < toOpenElements.length;
i++) {
273 var item = toOpenElements[
i];
274 var parent = item.parent;
277 if (parent.uri == item.uri)
279 parent = parent.parent;
283 if (!parent && !item.containerOpen)
284 item.containerOpen =
true;
288 this._tree.endUpdateBatch();
291 if (previouslySelectedNodes.length > 0) {
292 for (var
i = 0;
i < previouslySelectedNodes.length;
i++) {
293 var nodeInfo = previouslySelectedNodes[
i];
294 var index = nodeInfo.node._viewIndex;
300 var itemId = PlacesUtils.getConcreteItemId(nodeInfo.node);
303 for (var j = 0; j < newElements.length && index == -1; j++) {
304 if (PlacesUtils.getConcreteItemId(newElements[j]) == itemId)
305 index = newElements[j]._viewIndex;
310 var
uri = nodeInfo.node.uri;
312 for (var j = 0; j < newElements.length && index == -1; j++) {
313 if (newElements[j].uri == uri)
314 index = newElements[j]._viewIndex;
322 selection.rangedSelect(index, index,
true);
327 if (previouslySelectedNodes.length == 1 &&
328 selection.getRangeCount() == 0 &&
329 this._visibleElements.length > previouslySelectedNodes[0].oldIndex) {
330 selection.rangedSelect(previouslySelectedNodes[0].oldIndex,
331 previouslySelectedNodes[0].oldIndex,
true);
334 selection.selectEventsSuppressed =
false;
337 _convertPRTimeToString:
function PTV__convertPRTimeToString(aTime) {
338 var timeInMilliseconds = aTime / 1000;
345 var dateObj =
new Date();
346 var timeZoneOffsetInMs = dateObj.getTimezoneOffset() * 60000;
347 var
now = dateObj.getTime() - timeZoneOffsetInMs;
348 var midnight = now - (now % (86400000));
350 var dateFormat = timeInMilliseconds - timeZoneOffsetInMs >= midnight ?
351 Ci.nsIScriptableDateFormat.dateFormatNone :
352 Ci.nsIScriptableDateFormat.dateFormatShort;
354 var timeObj =
new Date(timeInMilliseconds);
355 return (this._dateService.FormatDateTime(
"", dateFormat,
356 Ci.nsIScriptableDateFormat.timeFormatNoSeconds,
357 timeObj.getFullYear(), timeObj.getMonth() + 1,
358 timeObj.getDate(), timeObj.getHours(),
359 timeObj.getMinutes(), timeObj.getSeconds()));
362 COLUMN_TYPE_UNKNOWN: 0,
363 COLUMN_TYPE_TITLE: 1,
366 COLUMN_TYPE_VISITCOUNT: 4,
367 COLUMN_TYPE_KEYWORD: 5,
368 COLUMN_TYPE_DESCRIPTION: 6,
369 COLUMN_TYPE_DATEADDED: 7,
370 COLUMN_TYPE_LASTMODIFIED: 8,
373 _getColumnType:
function PTV__getColumnType(aColumn) {
374 var columnType = aColumn.element.getAttribute(
"anonid") || aColumn.id;
376 switch (columnType) {
378 return this.COLUMN_TYPE_TITLE;
380 return this.COLUMN_TYPE_URI;
382 return this.COLUMN_TYPE_DATE;
384 return this.COLUMN_TYPE_VISITCOUNT;
386 return this.COLUMN_TYPE_KEYWORD;
388 return this.COLUMN_TYPE_DESCRIPTION;
390 return this.COLUMN_TYPE_DATEADDED;
392 return this.COLUMN_TYPE_LASTMODIFIED;
394 return this.COLUMN_TYPE_TAGS;
396 return this.COLUMN_TYPE_UNKNOWN;
399 _sortTypeToColumnType:
function PTV__sortTypeToColumnType(aSortType) {
401 case Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_ASCENDING:
402 return [this.COLUMN_TYPE_TITLE,
false];
403 case Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_DESCENDING:
404 return [this.COLUMN_TYPE_TITLE,
true];
405 case Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_ASCENDING:
406 return [this.COLUMN_TYPE_DATE,
false];
407 case Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING:
408 return [this.COLUMN_TYPE_DATE,
true];
409 case Ci.nsINavHistoryQueryOptions.SORT_BY_URI_ASCENDING:
410 return [this.COLUMN_TYPE_URI,
false];
411 case Ci.nsINavHistoryQueryOptions.SORT_BY_URI_DESCENDING:
412 return [this.COLUMN_TYPE_URI,
true];
413 case Ci.nsINavHistoryQueryOptions.SORT_BY_VISITCOUNT_ASCENDING:
414 return [this.COLUMN_TYPE_VISITCOUNT,
false];
415 case Ci.nsINavHistoryQueryOptions.SORT_BY_VISITCOUNT_DESCENDING:
416 return [this.COLUMN_TYPE_VISITCOUNT,
true];
417 case Ci.nsINavHistoryQueryOptions.SORT_BY_KEYWORD_ASCENDING:
418 return [this.COLUMN_TYPE_KEYWORD,
false];
419 case Ci.nsINavHistoryQueryOptions.SORT_BY_KEYWORD_DESCENDING:
420 return [this.COLUMN_TYPE_KEYWORD,
true];
421 case Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING:
423 return [this.COLUMN_TYPE_DESCRIPTION,
false];
425 case Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING:
427 return [this.COLUMN_TYPE_DESCRIPTION,
true];
428 case Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_ASCENDING:
429 return [this.COLUMN_TYPE_DATEADDED,
false];
430 case Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_DESCENDING:
431 return [this.COLUMN_TYPE_DATEADDED,
true];
432 case Ci.nsINavHistoryQueryOptions.SORT_BY_LASTMODIFIED_ASCENDING:
433 return [this.COLUMN_TYPE_LASTMODIFIED,
false];
434 case Ci.nsINavHistoryQueryOptions.SORT_BY_LASTMODIFIED_DESCENDING:
435 return [this.COLUMN_TYPE_LASTMODIFIED,
true];
436 case Ci.nsINavHistoryQueryOptions.SORT_BY_TAGS_ASCENDING:
437 return [this.COLUMN_TYPE_TAGS,
false];
438 case Ci.nsINavHistoryQueryOptions.SORT_BY_TAGS_DESCENDING:
439 return [this.COLUMN_TYPE_TAGS,
true];
441 return [this.COLUMN_TYPE_UNKNOWN,
false];
445 nodeInserted:
function PTV_nodeInserted(aParentNode, aNode, aNewIndex) {
449 throw Cr.NS_ERROR_UNEXPECTED;
451 if (PlacesUtils.nodeIsSeparator(aNode) &&
452 this._result.sortingMode !=
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) {
453 aNode._viewIndex = -1;
459 if (aParentNode.childCount == 1)
460 this._tree.invalidateRow(aParentNode._viewIndex);
463 var newViewIndex = -1;
464 if (aNewIndex == 0) {
468 newViewIndex = aParentNode._viewIndex + 1;
475 for (var
i = aNewIndex + 1;
i < aParentNode.childCount;
i++) {
476 var viewIndex = aParentNode.getChild(
i)._viewIndex;
477 if (viewIndex >= 0) {
480 newViewIndex = viewIndex;
484 if (newViewIndex < 0) {
488 var prevChild = aParentNode.getChild(aNewIndex - 1);
489 newViewIndex = prevChild._viewIndex + this._countVisibleRowsForNode(prevChild);
493 aNode._viewIndex = newViewIndex;
494 this._visibleElements.splice(newViewIndex, 0, aNode);
495 for (var
i = newViewIndex + 1;
496 i < this._visibleElements.length;
i++) {
497 this._visibleElements[
i]._viewIndex =
i;
499 this._tree.rowCountChanged(newViewIndex, 1);
501 if (PlacesUtils.nodeIsContainer(aNode) &&
asContainer(aNode).containerOpen)
502 this._refreshVisibleSection(aNode);
507 _fixViewIndexOnRemove:
function PTV_fixViewIndexOnRemove(aNode,
509 var oldViewIndex = aNode._viewIndex;
511 var
count = this._countVisibleRowsForNode(aNode);
513 if (oldViewIndex > this._visibleElements.length)
514 throw(
"Trying to remove a node with an invalid viewIndex");
516 this._visibleElements.splice(oldViewIndex, count);
517 for (var
i = oldViewIndex;
i < this._visibleElements.length;
i++)
518 this._visibleElements[
i]._viewIndex =
i;
520 this._tree.rowCountChanged(oldViewIndex, -count);
523 if (!aParentNode.hasChildren)
524 this._tree.invalidateRow(aParentNode._viewIndex);
536 nodeRemoved:
function PTV_nodeRemoved(aParentNode, aNode, aOldIndex) {
537 NS_ASSERT(this._result,
"Got a notification but have no result!");
541 var oldViewIndex = aNode._viewIndex;
542 if (oldViewIndex < 0) {
549 var selectNext =
false;
550 var selection = this.selection;
551 if (selection.getRangeCount() == 1) {
552 var
min = { }, max = { };
553 selection.getRangeAt(0, min, max);
554 if (min.value == max.value &&
555 this.nodeForTreeIndex(min.value) == aNode)
560 this._fixViewIndexOnRemove(aNode, aParentNode);
567 if (this._visibleElements.length > oldViewIndex)
568 selection.rangedSelect(oldViewIndex, oldViewIndex,
true);
569 else if (this._visibleElements.length > 0) {
571 selection.rangedSelect(this._visibleElements.length - 1,
572 this._visibleElements.length - 1,
true);
581 function PTV_nodeMoved(aNode, aOldParent, aOldIndex, aNewParent, aNewIndex) {
582 NS_ASSERT(this._result,
"Got a notification but have no result!");
586 var oldViewIndex = aNode._viewIndex;
587 if (oldViewIndex < 0) {
593 var
count = this._countVisibleRowsForNode(aNode);
596 var nodesToSelect = [];
597 var selection = this.selection;
598 var rc = selection.getRangeCount();
599 for (var rangeIndex = 0; rangeIndex < rc; rangeIndex++) {
600 var
min = { }, max = { };
601 selection.getRangeAt(rangeIndex, min, max);
602 var lastIndex = Math.min(max.value, oldViewIndex + count -1);
603 if (min.value < oldViewIndex || min.value > lastIndex)
606 for (var nodeIndex = min.value; nodeIndex <= lastIndex; nodeIndex++)
607 nodesToSelect.push(this._visibleElements[nodeIndex]);
609 if (nodesToSelect.length > 0)
610 selection.selectEventsSuppressed =
true;
613 this._fixViewIndexOnRemove(aNode, aOldParent);
619 if (nodesToSelect.length > 0) {
620 for (var
i = 0;
i < nodesToSelect.length;
i++) {
621 var
node = nodesToSelect[
i];
622 var index = node._viewIndex;
623 selection.rangedSelect(index, index,
true);
625 selection.selectEventsSuppressed =
false;
634 function PTV_nodeReplaced(aParentNode, aOldNode, aNewNode, aIndexDoNotUse) {
638 var viewIndex = aOldNode._viewIndex;
639 aNewNode._viewIndex = viewIndex;
640 if (viewIndex >= 0 &&
641 viewIndex < this._visibleElements.length) {
642 this._visibleElements[viewIndex] = aNewNode;
644 aOldNode._viewIndex = -1;
645 this._tree.invalidateRow(viewIndex);
648 _invalidateCellValue:
function PTV__invalidateCellValue(aNode,
650 NS_ASSERT(this._result,
"Got a notification but have no result!");
651 let viewIndex = aNode._viewIndex;
656 let column = this._findColumnByType(aColumnType);
657 if (column && !column.element.hidden)
658 this._tree.invalidateCell(viewIndex, column);
661 if (aColumnType != this.COLUMN_TYPE_LASTMODIFIED) {
662 let lastModifiedColumn =
663 this._findColumnByType(this.COLUMN_TYPE_LASTMODIFIED);
664 if (lastModifiedColumn && !lastModifiedColumn.hidden)
665 this._tree.invalidateCell(viewIndex, lastModifiedColumn);
670 nodeTitleChanged:
function PTV_nodeTitleChanged(aNode, aNewTitle) {
671 this._invalidateCellValue(aNode, this.COLUMN_TYPE_TITLE);
674 nodeURIChanged:
function PTV_nodeURIChanged(aNode, aNewURI) {
675 this._invalidateCellValue(aNode, this.COLUMN_TYPE_URI);
678 nodeIconChanged:
function PTV_nodeIconChanged(aNode) {
679 this._invalidateCellValue(aNode, this.COLUMN_TYPE_TITLE);
682 nodeHistoryDetailsChanged:
683 function PTV_nodeHistoryDetailsChanged(aNode, aUpdatedVisitDate,
684 aUpdatedVisitCount) {
685 this._invalidateCellValue(aNode, this.COLUMN_TYPE_DATE);
686 this._invalidateCellValue(aNode, this.COLUMN_TYPE_VISITCOUNT);
689 nodeTagsChanged:
function PTV_nodeTagsChanged(aNode) {
690 this._invalidateCellValue(aNode, this.COLUMN_TYPE_TAGS);
693 nodeKeywordChanged:
function PTV_nodeKeywordChanged(aNode, aNewKeyword) {
694 this._invalidateCellValue(aNode, this.COLUMN_TYPE_KEYWORD);
697 nodeAnnotationChanged:
function PTV_nodeAnnotationChanged(aNode, aAnno) {
699 this._invalidateCellValue(aNode, this.COLUMN_TYPE_DESCRIPTION);
702 nodeDateAddedChanged:
function PTV_nodeDateAddedChanged(aNode, aNewValue) {
703 this._invalidateCellValue(aNode, this.COLUMN_TYPE_DATEADDED);
706 nodeLastModifiedChanged:
707 function PTV_nodeLastModifiedChanged(aNode, aNewValue) {
708 this._invalidateCellValue(aNode, this.COLUMN_TYPE_LASTMODIFIED);
711 containerOpened:
function PTV_containerOpened(aNode) {
712 this.invalidateContainer(aNode);
715 containerClosed:
function PTV_containerClosed(aNode) {
716 this.invalidateContainer(aNode);
719 invalidateContainer:
function PTV_invalidateContainer(aNode) {
720 NS_ASSERT(this._result,
"Got a notification but have no result!");
724 if (aNode._viewIndex >=
this._visibleElements.length) {
726 throw Cr.NS_ERROR_UNEXPECTED;
728 this._refreshVisibleSection(aNode);
732 _findColumnByType:
function PTV__findColumnByType(aColumnType) {
736 var
columns = this._tree.columns;
737 var colCount = columns.count;
738 for (var
i = 0;
i < colCount;
i++) {
739 let column = columns.getColumnAt(
i);
740 let columnType = this._getColumnType(column);
742 if (columnType == aColumnType)
751 sortingChanged:
function PTV__sortingChanged(aSortingMode) {
752 if (!this._tree || !this._result)
756 window.updateCommands(
"sort");
758 var
columns = this._tree.columns;
761 var sortedColumn = columns.getSortedColumn();
763 sortedColumn.element.removeAttribute(
"sortDirection");
766 if (aSortingMode ==
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE)
769 var [desiredColumn, desiredIsDescending] =
770 this._sortTypeToColumnType(aSortingMode);
771 var colCount = columns.count;
772 var column = this._findColumnByType(desiredColumn);
774 let sortDir = desiredIsDescending ?
"descending" :
"ascending";
775 column.element.setAttribute(
"sortDirection", sortDir);
789 if (this._result !=
val) {
791 this._rootNode.containerOpen =
false;
797 if (this._tree &&
val)
803 nodeForTreeIndex:
function PTV_nodeForTreeIndex(aIndex) {
804 if (aIndex > this._visibleElements.length)
805 throw Cr.NS_ERROR_INVALID_ARG;
807 return this._visibleElements[aIndex];
810 treeIndexForNode:
function PTV_treeNodeForIndex(aNode) {
811 var viewIndex = aNode._viewIndex;
813 return Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE;
815 NS_ASSERT(this._visibleElements[viewIndex] == aNode,
816 "Node's visible index and array out of sync");
820 _getResourceForNode:
function PTV_getResourceForNode(aNode)
823 NS_ASSERT(uri,
"if there is no uri, we can't persist the open state");
829 return this._visibleElements.length;
833 return this._selection;
837 return this._selection =
val;
840 getRowProperties:
function PTV_getRowProperties(aRow, aProperties) { },
843 this._ensureValidRow(aRow);
846 var columnType = aColumn.element.getAttribute(
"anonid");
848 aProperties.AppendElement(this._getAtomFor(columnType));
850 var columnType = aColumn.id;
853 if (columnType ==
"url")
854 aProperties.AppendElement(this._getAtomFor(
"ltr"));
856 if (columnType !=
"title")
859 var
node = this._visibleElements[aRow];
860 if (!node._cellProperties) {
861 let properties =
new Array();
862 var itemId = node.itemId;
863 var nodeType = node.type;
864 if (PlacesUtils.containerTypes.indexOf(nodeType) != -1) {
865 if (nodeType ==
Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY) {
866 properties.push(this._getAtomFor(
"query"));
867 if (PlacesUtils.nodeIsTagQuery(node))
868 properties.push(
this._getAtomFor(
"tagContainer"));
869 else if (PlacesUtils.nodeIsDay(node))
870 properties.push(
this._getAtomFor(
"dayContainer"));
871 else if (PlacesUtils.nodeIsHost(node))
872 properties.push(
this._getAtomFor(
"hostContainer"));
874 else if (nodeType ==
Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER ||
875 nodeType ==
Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT) {
876 if (PlacesUtils.nodeIsLivemarkContainer(node))
877 properties.push(
this._getAtomFor(
"livemark"));
881 var queryName =
PlacesUIUtils.getLeftPaneQueryNameFromId(itemId);
883 properties.push(this._getAtomFor(
"OrganizerQuery_" + queryName));
886 else if (nodeType ==
Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR)
887 properties.push(this._getAtomFor(
"separator"));
888 else if (PlacesUtils.nodeIsURI(node)) {
889 properties.push(this._getAtomFor(
PlacesUIUtils.guessUrlSchemeForUI(node.uri)));
891 if (PlacesUtils.nodeIsLivemarkContainer(node.parent))
892 properties.push(
this._getAtomFor(
"livemarkItem"));
896 node._cellProperties = properties;
898 for (var
i = 0;
i < node._cellProperties.length;
i++)
899 aProperties.AppendElement(node._cellProperties[
i]);
902 getColumnProperties:
function(aColumn, aProperties) { },
904 isContainer:
function PTV_isContainer(aRow) {
905 this._ensureValidRow(aRow);
907 var
node = this._visibleElements[aRow];
908 if (PlacesUtils.nodeIsContainer(node)) {
915 if (PlacesUtils.nodeIsQuery(node)) {
916 var parent = node.parent;
917 if ((PlacesUtils.nodeIsQuery(parent) ||
918 PlacesUtils.nodeIsFolder(parent)) &&
920 return asQuery(parent).queryOptions.expandQueries;
927 isContainerOpen:
function PTV_isContainerOpen(aRow) {
931 this._ensureValidRow(aRow);
932 return this._visibleElements[aRow].containerOpen;
935 isContainerEmpty:
function PTV_isContainerEmpty(aRow) {
939 this._ensureValidRow(aRow);
940 return !this._visibleElements[aRow].hasChildren;
943 isSeparator:
function PTV_isSeparator(aRow) {
944 this._ensureValidRow(aRow);
945 return PlacesUtils.nodeIsSeparator(this._visibleElements[aRow]);
948 isSorted:
function PTV_isSorted() {
949 return this._result.sortingMode !=
950 Ci.nsINavHistoryQueryOptions.SORT_BY_NONE;
953 canDrop:
function PTV_canDrop(aRow, aOrientation) {
955 throw Cr.NS_ERROR_UNEXPECTED;
961 var ip = this._getInsertionPoint(aRow, aOrientation);
965 _getInsertionPoint:
function PTV__getInsertionPoint(index, orientation) {
966 var container = this._result.root;
967 var dropNearItemId = -1;
971 var lastSelected = this.nodeForTreeIndex(index);
972 if (this.isContainer(index) && orientation ==
Ci.nsITreeView.DROP_ON) {
975 container = lastSelected;
978 else if (lastSelected.containerOpen &&
979 orientation ==
Ci.nsITreeView.DROP_AFTER &&
980 lastSelected.hasChildren) {
983 container = lastSelected;
984 orientation =
Ci.nsITreeView.DROP_ON;
991 container = lastSelected.parent || container;
998 var queryOptions =
asQuery(this._result.root).queryOptions;
999 if (queryOptions.sortingMode !=
1000 Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) {
1004 else if (queryOptions.excludeItems ||
1005 queryOptions.excludeQueries ||
1006 queryOptions.excludeReadOnlyFolders) {
1011 dropNearItemId = lastSelected.itemId;
1014 var lsi = PlacesUtils.getIndexOfNode(lastSelected);
1015 index = orientation ==
Ci.nsITreeView.DROP_BEFORE ? lsi : lsi + 1;
1023 return new InsertionPoint(PlacesUtils.getConcreteItemId(container),
1025 PlacesUtils.nodeIsTagQuery(container),
1029 drop:
function PTV_drop(aRow, aOrientation) {
1033 var ip = this._getInsertionPoint(aRow, aOrientation);
1039 getParentIndex:
function PTV_getParentIndex(aRow) {
1040 this._ensureValidRow(aRow);
1041 var parent = this._visibleElements[aRow].parent;
1042 if (!parent || parent._viewIndex < 0)
1045 return parent._viewIndex;
1048 hasNextSibling:
function PTV_hasNextSibling(aRow, aAfterIndex) {
1049 this._ensureValidRow(aRow);
1050 if (aRow == this._visibleElements.length -1) {
1055 var thisLevel = this._visibleElements[aRow].indentLevel;
1056 for (var
i = aAfterIndex + 1;
i < this._visibleElements.length; ++
i) {
1057 var nextLevel = this._visibleElements[
i].indentLevel;
1058 if (nextLevel == thisLevel)
1060 if (nextLevel < thisLevel)
1066 getLevel:
function PTV_getLevel(aRow) {
1067 this._ensureValidRow(aRow);
1070 return this._visibleElements[aRow].indentLevel;
1073 getImageSrc:
function PTV_getImageSrc(aRow, aColumn) {
1074 this._ensureValidRow(aRow);
1077 if (this._getColumnType(aColumn) != this.COLUMN_TYPE_TITLE)
1080 return this._visibleElements[aRow].icon;
1083 getProgressMode:
function(aRow, aColumn) { },
1084 getCellValue:
function(aRow, aColumn) { },
1086 getCellText:
function PTV_getCellText(aRow, aColumn) {
1087 this._ensureValidRow(aRow);
1089 var
node = this._visibleElements[aRow];
1090 var columnType = this._getColumnType(aColumn);
1091 switch (columnType) {
1092 case this.COLUMN_TYPE_TITLE:
1097 if (PlacesUtils.nodeIsSeparator(node))
1100 case this.COLUMN_TYPE_TAGS:
1102 case this.COLUMN_TYPE_URI:
1103 if (PlacesUtils.nodeIsURI(node))
1106 case this.COLUMN_TYPE_DATE:
1107 let nodeTime = node.time;
1108 if (nodeTime == 0 || !PlacesUtils.nodeIsURI(node)) {
1117 return this._convertPRTimeToString(nodeTime);
1118 case this.COLUMN_TYPE_VISITCOUNT:
1119 return node.accessCount;
1120 case this.COLUMN_TYPE_KEYWORD:
1121 if (PlacesUtils.nodeIsBookmark(node))
1122 return PlacesUtils.bookmarks.getKeywordForBookmark(node.itemId);
1124 case this.COLUMN_TYPE_DESCRIPTION:
1125 if (node.itemId != -1) {
1127 return PlacesUtils.annotations.
1133 case this.COLUMN_TYPE_DATEADDED:
1135 return this._convertPRTimeToString(node.dateAdded);
1137 case this.COLUMN_TYPE_LASTMODIFIED:
1138 if (node.lastModified)
1139 return this._convertPRTimeToString(node.lastModified);
1145 setTree:
function PTV_setTree(aTree) {
1146 var hasOldTree = this._tree !=
null;
1154 this._result.viewer =
null;
1161 toggleOpenState:
function PTV_toggleOpenState(aRow) {
1163 throw Cr.NS_ERROR_UNEXPECTED;
1164 this._ensureValidRow(aRow);
1166 var
node = this._visibleElements[aRow];
1167 if (this._flatList && this._openContainerCallback) {
1168 this._openContainerCallback(node);
1172 var resource = this._getResourceForNode(node);
1174 const openLiteral =
PlacesUIUtils.RDF.GetResource(
"http://home.netscape.com/NC-rdf#open");
1177 if (node.containerOpen)
1178 PlacesUIUtils.localStore.Unassert(resource, openLiteral, trueLiteral);
1180 PlacesUIUtils.localStore.Assert(resource, openLiteral, trueLiteral,
true);
1183 node.containerOpen = !node.containerOpen;
1186 cycleHeader:
function PTV_cycleHeader(aColumn) {
1188 throw Cr.NS_ERROR_UNEXPECTED;
1201 var allowTriState = PlacesUtils.nodeIsFolder(this._result.root);
1203 var oldSort = this._result.sortingMode;
1204 var oldSortingAnnotation = this._result.sortingAnnotation;
1206 var newSortingAnnotation =
"";
1207 const NHQO =
Ci.nsINavHistoryQueryOptions;
1208 var columnType = this._getColumnType(aColumn);
1209 switch (columnType) {
1210 case this.COLUMN_TYPE_TITLE:
1211 if (oldSort == NHQO.SORT_BY_TITLE_ASCENDING)
1212 newSort = NHQO.SORT_BY_TITLE_DESCENDING;
1213 else if (allowTriState && oldSort == NHQO.SORT_BY_TITLE_DESCENDING)
1214 newSort = NHQO.SORT_BY_NONE;
1216 newSort = NHQO.SORT_BY_TITLE_ASCENDING;
1219 case this.COLUMN_TYPE_URI:
1220 if (oldSort == NHQO.SORT_BY_URI_ASCENDING)
1221 newSort = NHQO.SORT_BY_URI_DESCENDING;
1222 else if (allowTriState && oldSort == NHQO.SORT_BY_URI_DESCENDING)
1223 newSort = NHQO.SORT_BY_NONE;
1225 newSort = NHQO.SORT_BY_URI_ASCENDING;
1228 case this.COLUMN_TYPE_DATE:
1229 if (oldSort == NHQO.SORT_BY_DATE_ASCENDING)
1230 newSort = NHQO.SORT_BY_DATE_DESCENDING;
1231 else if (allowTriState &&
1232 oldSort == NHQO.SORT_BY_DATE_DESCENDING)
1233 newSort = NHQO.SORT_BY_NONE;
1235 newSort = NHQO.SORT_BY_DATE_ASCENDING;
1238 case this.COLUMN_TYPE_VISITCOUNT:
1242 if (oldSort == NHQO.SORT_BY_VISITCOUNT_DESCENDING)
1243 newSort = NHQO.SORT_BY_VISITCOUNT_ASCENDING;
1244 else if (allowTriState && oldSort == NHQO.SORT_BY_VISITCOUNT_ASCENDING)
1245 newSort = NHQO.SORT_BY_NONE;
1247 newSort = NHQO.SORT_BY_VISITCOUNT_DESCENDING;
1250 case this.COLUMN_TYPE_KEYWORD:
1251 if (oldSort == NHQO.SORT_BY_KEYWORD_ASCENDING)
1252 newSort = NHQO.SORT_BY_KEYWORD_DESCENDING;
1253 else if (allowTriState && oldSort == NHQO.SORT_BY_KEYWORD_DESCENDING)
1254 newSort = NHQO.SORT_BY_NONE;
1256 newSort = NHQO.SORT_BY_KEYWORD_ASCENDING;
1259 case this.COLUMN_TYPE_DESCRIPTION:
1260 if (oldSort == NHQO.SORT_BY_ANNOTATION_ASCENDING &&
1262 newSort = NHQO.SORT_BY_ANNOTATION_DESCENDING;
1265 else if (allowTriState &&
1266 oldSort == NHQO.SORT_BY_ANNOTATION_DESCENDING &&
1268 newSort = NHQO.SORT_BY_NONE;
1270 newSort = NHQO.SORT_BY_ANNOTATION_ASCENDING;
1275 case this.COLUMN_TYPE_DATEADDED:
1276 if (oldSort == NHQO.SORT_BY_DATEADDED_ASCENDING)
1277 newSort = NHQO.SORT_BY_DATEADDED_DESCENDING;
1278 else if (allowTriState &&
1279 oldSort == NHQO.SORT_BY_DATEADDED_DESCENDING)
1280 newSort = NHQO.SORT_BY_NONE;
1282 newSort = NHQO.SORT_BY_DATEADDED_ASCENDING;
1285 case this.COLUMN_TYPE_LASTMODIFIED:
1286 if (oldSort == NHQO.SORT_BY_LASTMODIFIED_ASCENDING)
1287 newSort = NHQO.SORT_BY_LASTMODIFIED_DESCENDING;
1288 else if (allowTriState &&
1289 oldSort == NHQO.SORT_BY_LASTMODIFIED_DESCENDING)
1290 newSort = NHQO.SORT_BY_NONE;
1292 newSort = NHQO.SORT_BY_LASTMODIFIED_ASCENDING;
1295 case this.COLUMN_TYPE_TAGS:
1296 if (oldSort == NHQO.SORT_BY_TAGS_ASCENDING)
1297 newSort = NHQO.SORT_BY_TAGS_DESCENDING;
1298 else if (allowTriState && oldSort == NHQO.SORT_BY_TAGS_DESCENDING)
1299 newSort = NHQO.SORT_BY_NONE;
1301 newSort = NHQO.SORT_BY_TAGS_ASCENDING;
1305 throw Cr.NS_ERROR_INVALID_ARG;
1307 this._result.sortingAnnotation = newSortingAnnotation;
1308 this._result.sortingMode = newSort;
1311 isEditable:
function PTV_isEditable(aRow, aColumn) {
1313 if (aColumn.index != 0)
1316 var
node = this.nodeForTreeIndex(aRow);
1317 if (!PlacesUtils.nodeIsReadOnly(node) &&
1318 (PlacesUtils.nodeIsFolder(node) ||
1319 (PlacesUtils.nodeIsBookmark(node) &&
1320 !PlacesUtils.nodeIsLivemarkItem(node))))
1326 setCellText:
function PTV_setCellText(aRow, aColumn, aText) {
1328 var
node = this.nodeForTreeIndex(aRow);
1329 if (node.title != aText) {
1330 var txn =
PlacesUIUtils.ptm.editItemTitle(node.itemId, aText);
1335 selectionChanged:
function() { },
1336 cycleCell:
function PTV_cycleCell(aRow, aColumn) { },
1337 isSelectable:
function(aRow, aColumn) {
return false; },
1338 performAction:
function(aAction) { },
1339 performActionOnRow:
function(aAction, aRow) { },
1340 performActionOnCell:
function(aAction, aRow, aColumn) { }
1345 this._result =
null;
1346 this._selection =
null;
1347 this._visibleElements = [];
1348 this._flatList = aFlatList;
1349 this._openContainerCallback = aOnOpenFlatContainer;
sbOSDControlService prototype QueryInterface
getService(Ci.sbIFaceplateManager)
gImageView getCellProperties
this _dialogInput val(dateText)
function NS_ASSERT(cond, msg)
var PlacesControllerDragHelper
sbDeviceServicePane prototype nodeInserted
function InsertionPoint(aItemId, aIndex, aOrientation, aIsTag, aDropNearItemId)
function PlacesTreeView(aFlatList, aOnOpenFlatContainer)
_getSelectedPageStyle s i
function asContainer(aNode)
sbDeviceServicePane prototype nodeRemoved