Displaying Places information using views

  • Revision slug: Displaying_Places_information_using_views
  • Revision title: Displaying Places information using views
  • Revision id: 96298
  • Created:
  • Creator: BrettWilson
  • Is current revision? No
  • Comment /* The built-in tree view */

Revision Content

Views are how you display nsINavHistoryResult objects to the user.

Introduction

Views implement the interface nsINavHistoryResultViewer defined in {{wiki.template('Named-source', [ "browser/components/places/public/nsINavHistoryService.idl", "nsINavHistoryService.idl" ])}}.


Creating and registering a view

The built-in tree view

The most common type of view is in a tree control, but it is also relatively difficult to implement. Therefore, Places provides a built-in view object for when you want to display a result in a tree view. It is implemented in {{template.Source("browser/components/places/src/nsNavHistoryResult.cpp")}}.

This object's contract ID is "@mozilla.org/browser/nav-history/result-tree-viewer;1". This object implements both nsINavHistoryResultViewer and {{wiki.template('Named-source', [ "/layout/xul/base/src/tree/public/nsITreeView.idl", "nsITreeView" ])}}. You can therefore use this object to bridge between a result and a tree:


If you require a more customized tree view, it may be easiest to wrap the nsINavHistoryResultTreeViewer in your own class. For example, if you wanted a "special" first row, your object would provide nsITreeView responses for the first row, and pass all other messages through to the built-in tree view with indices shifted by one.</pre>

Revision Source

<p>
</p><p>Views are how you display nsINavHistoryResult objects to the user.
</p>
<h3 name="Introduction"> Introduction </h3>
<p>Views implement the interface nsINavHistoryResultViewer defined in {{wiki.template('Named-source', [ "browser/components/places/public/nsINavHistoryService.idl", "nsINavHistoryService.idl" ])}}.
</p><p><br>
</p>
<h3 name="Creating_and_registering_a_view"> Creating and registering a view </h3>
<h5 name="The_built-in_tree_view"> The built-in tree view </h5>
<p>The most common type of view is in a tree control, but it is also relatively difficult to implement. Therefore, Places provides a built-in view object for when you want to display a result in a tree view. It is implemented in {{template.Source("browser/components/places/src/nsNavHistoryResult.cpp")}}.
</p><p>This object's contract ID is <code>"@mozilla.org/browser/nav-history/result-tree-viewer;1"</code>. This object implements both nsINavHistoryResultViewer and {{wiki.template('Named-source', [ "/layout/xul/base/src/tree/public/nsITreeView.idl", "nsITreeView" ])}}. You can therefore use this object to bridge between a result and a tree:
</p>
<pre></pre>
<p>If you require a more customized tree view, it may be easiest to wrap the nsINavHistoryResultTreeViewer in your own class. For example, if you wanted a "special" first row, your object would provide nsITreeView responses for the first row, and pass all other messages through to the built-in tree view with indices shifted by one.&lt;/pre&gt;
</p>
Revert to this revision