Visit Mozilla.org

nsINavHistoryResultTreeViewer

From MDC

nsINavHistoryResultTreeViewer provides a predefined view adaptor for interfacing places query results with an nsITree.

This object removes itself from the associated result when the tree is detached; this prevents circular references. It's important to be aware of this -- if you wan to reuse the same viewer, you need to keep your own reference to it, then reinitialize it when the tree changes.

If you use a nsINavHistoryResultTreeViewer and attach it to a result without attaching it to a tree, then forget about it, it will leak.

Contents

nsINavHistoryResultTreeViewer is defined in toolkit/components/places/public/nsINavHistoryResultTreeViewer.idl. It is scriptable and unfrozen (hasn't changed since Mozilla 1.9).

Inherits from: nsINavHistoryResultViewer

[edit] Method overview

nsINavHistoryResultNode nodeForTreeIndex(in unsigned long aIndex);
unsigned long treeIndexForNode(in nsINavHistoryResultNode aNode);

[edit] Attributes

Attribute Type Description
collapseDuplicates boolean Controls whether or not duplicate adjacent elements are collapsed into a single item in the tree. This prevents displaying multiple entries for results when the display is showing visits. When sorted by date, however, all entries are shown because they are separated (unless the user clicks reload a number of times in a row).

If you know you only need one entry per site, you should ask for URIs instead of visits for efficiency.

By default, this value is true.

flatItemCount unsigned long The number of items in the flattened result list (in other words, the number of rows currently in the tree).

The tree adaptor also performs a QueryInterface() to nsITreeView, and this value will be the same as nsITreeView.rowCount. This attribute is only valid when a tree is attached; otherwise it is zero.

[edit] Constants

Constant Value Description
INDEX_INVISIBLE 0xffffffff Returned by treeIndexForNode() when the requested node isn't visible (such as when its parent is collapsed). Also returned if there is no tree attached.

[edit] Methods

[edit] nodeForTreeIndex()

Returns the node for a given row index. Only valid when a tree is attached.

 nsINavHistoryResultNode nodeForTreeIndex(
   in unsigned long aIndex
 );
[edit] Parameters
aIndex
The row index of the note to return.
[edit] Returns

The node located at the specified index in the tree.

[edit] treeIndexForNode()

Returns the row index corresponding to the specified node within the tree, or INDEX_INVISIBLE if the tree is unattached or the node wasn't found in the tree.

 unsigned long treeIndexForNode(
   in nsINavHistoryResultNode aNode
 );
[edit] Parameters
aNode
The node whose index is to be returned. This must be a node retrieved from the same result the viewer is for.
[edit] Return value

The row index of the node specified by aNode, or INDEX_INVISIBLE for nodes that are hidden (by their parents being collapsed, for example) or if there is no attached tree.

[edit] See also

nsINavHistoryResult, nsITree