зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 134824. Column Sorting in the Download Manager has no effect.
r=neil, sr=jag, a=asa
This commit is contained in:
Родитель
eda4a735f0
Коммит
806c8a51d3
|
@ -62,7 +62,7 @@ interface nsIXULSortService : nsISupports
|
|||
* <code>aSortDirection</code> as the direction.
|
||||
*
|
||||
* @param aNode A node in the XUL widget whose children are to be
|
||||
* sorted. <code>Sort</code> will traverse upwards to find the
|
||||
* sorted. <code>sort</code> will traverse upwards to find the
|
||||
* root node at which to begin the actualy sorting. For optimal
|
||||
* results, pass in the root of the widget.
|
||||
*
|
||||
|
@ -74,14 +74,14 @@ interface nsIXULSortService : nsISupports
|
|||
* <b>ascending</b> to sort the contents in ascending order, or
|
||||
* <b>descending</b> to sort the contents in descending order.
|
||||
*/
|
||||
void Sort(in nsIDOMNode aNode,
|
||||
in string aSortResource,
|
||||
in string aSortDirection);
|
||||
void sort(in nsIDOMNode aNode,
|
||||
in AString aSortResource,
|
||||
in AString aSortDirection);
|
||||
|
||||
/**
|
||||
* Used internally for insertion sorting.
|
||||
*/
|
||||
[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db,
|
||||
[noscript] void insertContainerNode(in nsIRDFCompositeDataSource db,
|
||||
in nsRDFSortState sortStatePtr,
|
||||
in nsIContent root,
|
||||
in nsIContent trueParent,
|
||||
|
|
|
@ -170,13 +170,12 @@ private:
|
|||
|
||||
nsresult FindDatabaseElement(nsIContent* aElement, nsIContent** aDatabaseElement);
|
||||
nsresult FindSortableContainer(nsIContent *tree, nsIContent **treeBody);
|
||||
nsresult SetSortHints(nsIContent *tree, const nsString &sortResource, const nsString &sortDirection, const nsString &sortResource2, PRBool inbetweenSeparatorSort, PRBool found);
|
||||
nsresult SetSortColumnHints(nsIContent *content, const nsString &sortResource, const nsString &sortDirection);
|
||||
nsresult GetSortColumnInfo(nsIContent *tree, nsString &sortResource, nsString &sortDirection, nsString &sortResource2, PRBool &inbetweenSeparatorSort);
|
||||
nsresult SetSortHints(nsIContent *tree, const nsAString &sortResource, const nsAString &sortDirection, const nsAString &sortResource2, PRBool inbetweenSeparatorSort, PRBool found);
|
||||
nsresult SetSortColumnHints(nsIContent *content, const nsAString &sortResource, const nsAString &sortDirection);
|
||||
nsresult GetSortColumnInfo(nsIContent *tree, nsAString &sortResource, nsAString &sortDirection, nsAString &sortResource2, PRBool &inbetweenSeparatorSort);
|
||||
|
||||
nsresult SortContainer(nsIContent *container, sortPtr sortInfo, PRBool merelyInvertFlag);
|
||||
nsresult InvertSortInfo(contentSortInfo **data, PRInt32 numItems);
|
||||
nsresult DoSort(nsIDOMNode* node, const nsString& sortResource, const nsString& sortDirection);
|
||||
|
||||
static nsresult GetCachedTarget(sortPtr sortInfo, PRBool useCache, nsIRDFResource* aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsIRDFNode **aResult);
|
||||
static nsresult GetTarget(contentSortInfo *contentSortInfo, sortPtr sortInfo, PRBool first, PRBool onlyCollationHint, PRBool truthValue,nsIRDFNode **target, PRBool &isCollationKey);
|
||||
|
@ -383,8 +382,8 @@ XULSortServiceImpl::FindSortableContainer(nsIContent *aRoot, nsIContent **aConta
|
|||
}
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::SetSortHints(nsIContent *tree, const nsString &sortResource,
|
||||
const nsString &sortDirection, const nsString &sortResource2,
|
||||
XULSortServiceImpl::SetSortHints(nsIContent *tree, const nsAString &sortResource,
|
||||
const nsAString &sortDirection, const nsAString &sortResource2,
|
||||
PRBool inbetweenSeparatorSort, PRBool found)
|
||||
{
|
||||
if (found) {
|
||||
|
@ -416,7 +415,7 @@ XULSortServiceImpl::SetSortHints(nsIContent *tree, const nsString &sortResource,
|
|||
}
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::SetSortColumnHints(nsIContent *content, const nsString &sortResource, const nsString &sortDirection)
|
||||
XULSortServiceImpl::SetSortColumnHints(nsIContent *content, const nsAString &sortResource, const nsAString &sortDirection)
|
||||
{
|
||||
PRInt32 numChildren, childIndex, nameSpaceID;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
|
@ -458,8 +457,8 @@ XULSortServiceImpl::SetSortColumnHints(nsIContent *content, const nsString &sort
|
|||
}
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::GetSortColumnInfo(nsIContent *tree, nsString &sortResource,
|
||||
nsString &sortDirection, nsString &sortResource2,
|
||||
XULSortServiceImpl::GetSortColumnInfo(nsIContent *tree, nsAString &sortResource,
|
||||
nsAString &sortDirection, nsAString &sortResource2,
|
||||
PRBool &inbetweenSeparatorSort)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
@ -1584,13 +1583,7 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSortServiceImpl::Sort(nsIDOMNode* node, const char *sortResource, const char *sortDirection)
|
||||
{
|
||||
return DoSort(node, NS_ConvertASCIItoUCS2(sortResource), NS_ConvertASCIItoUCS2(sortDirection));
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, const nsString& sortDirection)
|
||||
XULSortServiceImpl::Sort(nsIDOMNode* node, const nsAString& sortResource, const nsAString& sortDirection)
|
||||
{
|
||||
nsresult rv;
|
||||
_sortStruct sortInfo;
|
||||
|
@ -1663,7 +1656,7 @@ XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, const
|
|||
GetSortColumnInfo(contentNode, unused, unused, sortResource2, sortInfo.inbetweenSeparatorSort);
|
||||
|
||||
// build resource url for first sort resource
|
||||
rv = gRDFService->GetUnicodeResource(sortResource.get(), getter_AddRefs(sortInfo.sortProperty));
|
||||
rv = gRDFService->GetUnicodeResource(PromiseFlatString(sortResource).get(), getter_AddRefs(sortInfo.sortProperty));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString resourceUrl;
|
||||
|
|
|
@ -628,11 +628,11 @@ function onSortCol(sortColName)
|
|||
return false;
|
||||
try
|
||||
{
|
||||
xulSortService.Sort(node, sortResource, sortDirection);
|
||||
xulSortService.sort(node, sortResource, sortDirection);
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
//dd("Exception calling xulSortService.Sort()");
|
||||
//dd("Exception calling xulSortService.sort()");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -133,7 +133,7 @@ function onLoad() {
|
|||
function sortAccountList(accounttree)
|
||||
{
|
||||
var xulSortService = Components.classes["@mozilla.org/xul/xul-sort-service;1"].getService(Components.interfaces.nsIXULSortService);
|
||||
xulSortService.Sort(accounttree, 'http://home.netscape.com/NC-rdf#FolderTreeName?sort=true', 'ascending');
|
||||
xulSortService.sort(accounttree, 'http://home.netscape.com/NC-rdf#FolderTreeName?sort=true', 'ascending');
|
||||
}
|
||||
|
||||
function selectServer(server, selectPage)
|
||||
|
|
|
@ -233,7 +233,7 @@ function doSort(aTarget)
|
|||
|
||||
try {
|
||||
var sortService = Components.classes[XULSORTSERVICE_CONTRACTID].getService(nsIXULSortService);
|
||||
sortService.Sort(aTarget, sortResource, sortDirection);
|
||||
sortService.sort(aTarget, sortResource, sortDirection);
|
||||
} catch(ex) { }
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ function Startup()
|
|||
gNC_File = gRDFService.GetResource(NC_NS + "File");
|
||||
|
||||
gDownloadView = document.getElementById("downloadView");
|
||||
setSortVariables(gDownloadView);
|
||||
|
||||
const dlmgrContractID = "@mozilla.org/download-manager;1";
|
||||
const dlmgrIID = Components.interfaces.nsIDownloadManager;
|
||||
|
@ -90,7 +91,7 @@ function Startup()
|
|||
gDownloadView.database.AddDataSource(ds);
|
||||
gDownloadView.builder.rebuild();
|
||||
window.setTimeout(onRebuild, 0);
|
||||
|
||||
|
||||
var key;
|
||||
if (navigator.platform.indexOf("Win") != -1)
|
||||
key = "Win";
|
||||
|
@ -330,3 +331,40 @@ function Shutdown()
|
|||
catch (ex) {
|
||||
}
|
||||
}
|
||||
|
||||
function setSortVariables(tree)
|
||||
{
|
||||
var node;
|
||||
for (node = document.getElementById("Name"); node; node = node.nextSibling) {
|
||||
if (node.getAttribute("sortActive") == "true")
|
||||
break;
|
||||
}
|
||||
if (!node) {
|
||||
node = document.getElementById("Progress");
|
||||
node.setAttribute("sortActive", "true");
|
||||
node.setAttribute("sortDirection", "descending");
|
||||
}
|
||||
|
||||
tree.setAttribute("sortActive", "true");
|
||||
tree.setAttribute("sortDirection", node.getAttribute("sortDirection"));
|
||||
tree.setAttribute("sortResource", node.getAttribute("resource"));
|
||||
}
|
||||
|
||||
function doSort(node)
|
||||
{
|
||||
if (node.localName != "treecol")
|
||||
return;
|
||||
|
||||
var sortResource = node.getAttribute("resource");
|
||||
|
||||
var sortDirection = node.getAttribute("sortDirection");
|
||||
sortDirection = sortDirection == "ascending" ? "descending" : "ascending";
|
||||
|
||||
try {
|
||||
var sortService = Components.classes["@mozilla.org/xul/xul-sort-service;1"]
|
||||
.getService(Components.interfaces.nsIXULSortService);
|
||||
sortService.sort(node, sortResource, sortDirection);
|
||||
}
|
||||
catch(ex) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,54 +132,53 @@
|
|||
datasources="rdf:null" ref="NC:DownloadsRoot" flags="dont-test-empty"
|
||||
ondblclick="return goDoCommand('cmd_properties');" enableColumnDrag="true"
|
||||
onselect="onSelect(event);">
|
||||
<treecols>
|
||||
<treecols onclick="doSort(event.target)">
|
||||
<treecol id="Name" primary="true"
|
||||
label="&view.header.name.label;"
|
||||
class="sortDirectionIndicator" width="3*" flex="3"
|
||||
sort="http://home.netscape.com/NC-rdf#Name"
|
||||
resource="http://home.netscape.com/NC-rdf#Name"
|
||||
persist="width sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="Progress" type="progressmeter"
|
||||
label="&view.header.progress.label;"
|
||||
class="sortDirectionIndicator" width="3*" flex="3"
|
||||
sort="http://home.netscape.com/NC-rdf#ProgressPercent"
|
||||
persist="width hidden sortActive sortDirection"
|
||||
sortActive="true" sortDirection="descending"/>
|
||||
resource="http://home.netscape.com/NC-rdf#ProgressPercent"
|
||||
persist="width hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="ProgressPercent" hidden="true"
|
||||
label="&view.header.progresstext.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
sort="http://home.netscape.com/NC-rdf#ProgressPercent"
|
||||
resource="http://home.netscape.com/NC-rdf#ProgressPercent"
|
||||
persist="width hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="TimeRemaining"
|
||||
label="&view.header.timeremaining.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
sort="http://home.netscape.com/NC-rdf#TimeRemaining"
|
||||
resource="http://home.netscape.com/NC-rdf#TimeRemaining"
|
||||
persist="width hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="Transferred"
|
||||
label="&view.header.transferred.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
sort="http://home.netscape.com/NC-rdf#Transferred"
|
||||
resource="http://home.netscape.com/NC-rdf#Transferred"
|
||||
persist="width hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="TransferRate"
|
||||
label="&view.header.transferrate.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
sort="http://home.netscape.com/NC-rdf#TransferRate"
|
||||
resource="http://home.netscape.com/NC-rdf#TransferRate"
|
||||
persist="width hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="TimeElapsed" hidden="true"
|
||||
label="&view.header.timeelapsed.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
sort="http://home.netscape.com/NC-rdf#TimeElapsed"
|
||||
resource="http://home.netscape.com/NC-rdf#TimeElapsed"
|
||||
persist="width hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="Source" hidden="true"
|
||||
label="&view.header.source.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
sort="http://home.netscape.com/NC-rdf#URL"
|
||||
resource="http://home.netscape.com/NC-rdf#URL"
|
||||
persist="width hidden sortActive sortDirection"/>
|
||||
</treecols>
|
||||
<template>
|
||||
|
|
|
@ -425,18 +425,8 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
|
|||
nsCOMPtr<nsIRDFResource> downloadRes;
|
||||
gRDFService->GetResource(path.get(), getter_AddRefs(downloadRes));
|
||||
|
||||
// if the resource is in the container already (the user has already
|
||||
// downloaded this file), remove it
|
||||
PRInt32 itemIndex;
|
||||
nsCOMPtr<nsIRDFNode> node;
|
||||
downloads->IndexOf(downloadRes, &itemIndex);
|
||||
if (itemIndex > 0) {
|
||||
rv = downloads->RemoveElementAt(itemIndex, PR_TRUE, getter_AddRefs(node));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = downloads->AppendElement(downloadRes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
// Assert source url information
|
||||
nsCAutoString spec;
|
||||
aSource->GetSpec(spec);
|
||||
|
@ -448,11 +438,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
|
|||
rv = mDataSource->Change(downloadRes, gNC_URL, node, urlResource);
|
||||
else
|
||||
rv = mDataSource->Assert(downloadRes, gNC_URL, urlResource, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
downloads->IndexOf(downloadRes, &itemIndex);
|
||||
downloads->RemoveElementAt(itemIndex, PR_TRUE, getter_AddRefs(node));
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Set and assert the "pretty" (display) name of the download
|
||||
nsAutoString displayName; displayName.Assign(aDisplayName);
|
||||
|
@ -468,11 +454,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
|
|||
rv = mDataSource->Change(downloadRes, gNC_Name, node, nameLiteral);
|
||||
else
|
||||
rv = mDataSource->Assert(downloadRes, gNC_Name, nameLiteral, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
downloads->IndexOf(downloadRes, &itemIndex);
|
||||
downloads->RemoveElementAt(itemIndex, PR_TRUE, getter_AddRefs(node));
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
internalDownload->SetMIMEInfo(aMIMEInfo);
|
||||
internalDownload->SetStartTime(aStartTime);
|
||||
|
@ -481,11 +463,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
|
|||
nsCOMPtr<nsIRDFResource> fileResource;
|
||||
gRDFService->GetResource(path.get(), getter_AddRefs(fileResource));
|
||||
rv = mDataSource->Assert(downloadRes, gNC_File, fileResource, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
downloads->IndexOf(downloadRes, &itemIndex);
|
||||
downloads->RemoveElementAt(itemIndex, PR_TRUE, getter_AddRefs(node));
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Assert download state information (NOTSTARTED, since it's just now being added)
|
||||
nsCOMPtr<nsIRDFInt> intLiteral;
|
||||
|
@ -495,20 +473,19 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
|
|||
rv = mDataSource->Change(downloadRes, gNC_DownloadState, node, intLiteral);
|
||||
else
|
||||
rv = mDataSource->Assert(downloadRes, gNC_DownloadState, intLiteral, PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
downloads->IndexOf(downloadRes, &itemIndex);
|
||||
downloads->RemoveElementAt(itemIndex, PR_TRUE, getter_AddRefs(node));
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 itemIndex;
|
||||
downloads->IndexOf(downloadRes, &itemIndex);
|
||||
if (itemIndex == -1) {
|
||||
rv = downloads->AppendElement(downloadRes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Now flush all this to disk
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remote(do_QueryInterface(mDataSource));
|
||||
rv = remote->Flush();
|
||||
if (NS_FAILED(rv)) {
|
||||
downloads->IndexOf(downloadRes, &itemIndex);
|
||||
downloads->RemoveElementAt(itemIndex, PR_TRUE, getter_AddRefs(node));
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// if a persist object was specified, set the download item as the progress listener
|
||||
// this will create a cycle that will be broken in nsDownload::OnStateChange
|
||||
|
|
|
@ -240,11 +240,11 @@ function doSort(sortColName, naturalOrderResource)
|
|||
if (!xulSortService) return(false);
|
||||
try
|
||||
{
|
||||
xulSortService.Sort(node, sortResource, sortDirection);
|
||||
xulSortService.sort(node, sortResource, sortDirection);
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
debug("Exception calling xulSortService.Sort()");
|
||||
debug("Exception calling xulSortService.sort()");
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
|
|
@ -337,11 +337,11 @@ function doSort(sortColName, naturalOrderResource)
|
|||
if (!xulSortService) return(false);
|
||||
try
|
||||
{
|
||||
xulSortService.Sort(node, sortResource, sortDirection);
|
||||
xulSortService.sort(node, sortResource, sortDirection);
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
debug("Exception calling xulSortService.Sort()");
|
||||
debug("Exception calling xulSortService.sort()");
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ function setInitialSort(node, sortDirection)
|
|||
if (!isupports) return(false);
|
||||
var xulSortService = isupports.QueryInterface(Components.interfaces.nsIXULSortService);
|
||||
if (!xulSortService) return(false);
|
||||
xulSortService.Sort(node, sortResource, sortDirection);
|
||||
xulSortService.sort(node, sortResource, sortDirection);
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче