fix for bug #389782: history sidebar doesn't show the same results as fx 2, dup
licate uris when grouped by site, last visited, or most visited r=dietrich git-svn-id: svn://10.0.0.236/trunk@231395 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
8ef59c881a
commit
67c25bf8ac
@ -40,7 +40,6 @@
|
||||
const NHRVO = Ci.nsINavHistoryResultViewObserver;
|
||||
|
||||
// XXXmano: we should move most/all of these constants to PlacesUtils
|
||||
const ORGANIZER_ROOT_HISTORY_UNSORTED = "place:type=1";
|
||||
const ORGANIZER_ROOT_BOOKMARKS = "place:folder=2&group=3&excludeItems=1&queryType=1";
|
||||
const ORGANIZER_SUBSCRIPTIONS_QUERY = "place:annotation=livemark%2FfeedURI";
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ function HistorySidebarInit()
|
||||
|
||||
initContextMenu();
|
||||
|
||||
initPlace();
|
||||
searchHistory("");
|
||||
|
||||
gSearchBox.focus();
|
||||
}
|
||||
@ -109,63 +109,55 @@ function historyAddBookmarks()
|
||||
PlacesUtils.showMinimalAddBookmarkUI(PlacesUtils._uri(node.uri), node.title);
|
||||
}
|
||||
|
||||
function SetSortingAndGrouping(aOptions)
|
||||
function searchHistory(aInput)
|
||||
{
|
||||
var query = PlacesUtils.history.getNewQuery();
|
||||
var options = PlacesUtils.history.getNewQueryOptions();
|
||||
|
||||
const NHQO = Ci.nsINavHistoryQueryOptions;
|
||||
var sortingMode;
|
||||
var groups = [];
|
||||
switch (gHistoryGrouping) {
|
||||
case "site":
|
||||
sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
|
||||
break;
|
||||
case "visited":
|
||||
sortingMode = NHQO.SORT_BY_VISITCOUNT_DESCENDING;
|
||||
break;
|
||||
case "lastvisited":
|
||||
sortingMode = NHQO.SORT_BY_DATE_DESCENDING;
|
||||
break;
|
||||
case "dayandsite":
|
||||
groups.push(NHQO.GROUP_BY_DAY);
|
||||
groups.push(NHQO.GROUP_BY_HOST);
|
||||
sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
|
||||
break;
|
||||
default:
|
||||
groups.push(NHQO.GROUP_BY_DAY);
|
||||
sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
|
||||
break;
|
||||
}
|
||||
aOptions.setGroupingMode(groups, groups.length);
|
||||
aOptions.sortingMode = sortingMode;
|
||||
}
|
||||
var groups = [];
|
||||
var resultType;
|
||||
|
||||
if (aInput) {
|
||||
query.searchTerms = aInput;
|
||||
sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
|
||||
resultType = NHQO.RESULTS_AS_URI;
|
||||
}
|
||||
else {
|
||||
switch (gHistoryGrouping) {
|
||||
case "site":
|
||||
resultType = NHQO.RESULTS_AS_URI;
|
||||
sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
|
||||
break;
|
||||
case "visited":
|
||||
resultType = NHQO.RESULTS_AS_URI;
|
||||
sortingMode = NHQO.SORT_BY_VISITCOUNT_DESCENDING;
|
||||
break;
|
||||
case "lastvisited":
|
||||
resultType = NHQO.RESULTS_AS_URI;
|
||||
sortingMode = NHQO.SORT_BY_DATE_DESCENDING;
|
||||
break;
|
||||
case "dayandsite":
|
||||
resultType = NHQO.RESULTS_AS_VISIT;
|
||||
groups.push(NHQO.GROUP_BY_DAY);
|
||||
groups.push(NHQO.GROUP_BY_HOST);
|
||||
sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
|
||||
break;
|
||||
default:
|
||||
resultType = NHQO.RESULTS_AS_VISIT;
|
||||
groups.push(NHQO.GROUP_BY_DAY);
|
||||
sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
options.setGroupingMode(groups, groups.length);
|
||||
options.sortingMode = sortingMode;
|
||||
options.resultType = resultType;
|
||||
|
||||
function initPlace()
|
||||
{
|
||||
// call load() on the tree manually
|
||||
// instead of setting the place attribute in history-panel.xul
|
||||
// otherwise, we will end up calling load() twice
|
||||
var optionsRef = {};
|
||||
var queriesRef = {};
|
||||
PlacesUtils.history.queryStringToQueries(ORGANIZER_ROOT_HISTORY_UNSORTED, queriesRef, {}, optionsRef);
|
||||
SetSortingAndGrouping(optionsRef.value);
|
||||
gHistoryTree.load(queriesRef.value, optionsRef.value);
|
||||
}
|
||||
|
||||
function searchHistory(aInput)
|
||||
{
|
||||
if (aInput) {
|
||||
if (!gSearching) {
|
||||
// Unset grouping when searching;
|
||||
var options = asQuery(gHistoryTree.getResult().root).queryOptions;
|
||||
options.setGroupingMode([], 0);
|
||||
gSearching = true;
|
||||
}
|
||||
|
||||
// applyFilter will update the view by calling load()
|
||||
gHistoryTree.applyFilter(aInput, false /* onlyBookmarks */,
|
||||
null /* folderRestrict */, null);
|
||||
}
|
||||
else {
|
||||
initPlace();
|
||||
gSearching = false;
|
||||
}
|
||||
gHistoryTree.load([query], options);
|
||||
}
|
||||
|
||||
@ -1265,8 +1265,18 @@ nsNavHistoryContainerResultNode::MergeResults(
|
||||
PRUint32 oldIndex;
|
||||
nsNavHistoryResultNode* oldNode =
|
||||
FindChildURI(curAddition->mURI, &oldIndex);
|
||||
if (oldNode)
|
||||
ReplaceChildURIAt(oldIndex, curAddition);
|
||||
if (oldNode) {
|
||||
// if we don't have a parent (for example, the history
|
||||
// sidebar, when sorted by last visited or most visited)
|
||||
// we have to manually Remove/Insert instead of Replace
|
||||
// see bug #389782 for details
|
||||
if (mParent)
|
||||
ReplaceChildURIAt(oldIndex, curAddition);
|
||||
else {
|
||||
RemoveChildAt(oldIndex, PR_TRUE);
|
||||
InsertSortedChild(curAddition, PR_TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
InsertSortedChild(curAddition);
|
||||
}
|
||||
@ -2446,8 +2456,9 @@ nsNavHistoryQueryResultNode::OnDeleteURI(nsIURI *aURI)
|
||||
for (PRInt32 i = 0; i < matches.Count(); i ++) {
|
||||
nsNavHistoryResultNode* node = matches[i];
|
||||
nsNavHistoryContainerResultNode* parent = node->mParent;
|
||||
NS_ASSERTION(parent, "URI nodes should always have parents");
|
||||
|
||||
// URI nodes should always have parents
|
||||
NS_ENSURE_TRUE(parent, NS_ERROR_UNEXPECTED);
|
||||
|
||||
PRInt32 childIndex = parent->FindChild(node);
|
||||
NS_ASSERTION(childIndex >= 0, "Child not found in parent");
|
||||
parent->RemoveChildAt(childIndex);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user