From 6b89bb98c0516e3e1c7abf8d50642a134a50de54 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Fri, 29 Jun 2001 00:48:14 +0000 Subject: [PATCH] fix for bug #86326. make it so news is threaded by default. r=bienvenu, sr=mscott. --- .../base/resources/content/commandglue.js | 28 ++----------------- mailnews/db/msgdb/public/nsIMsgDatabase.idl | 7 +++++ mailnews/db/msgdb/public/nsNewsDatabase.h | 3 ++ mailnews/db/msgdb/src/nsDBFolderInfo.cpp | 12 ++++++-- mailnews/db/msgdb/src/nsMsgDatabase.cpp | 13 +++++++++ mailnews/db/msgdb/src/nsNewsDatabase.cpp | 15 ++++++++++ 6 files changed, 50 insertions(+), 28 deletions(-) diff --git a/mailnews/base/resources/content/commandglue.js b/mailnews/base/resources/content/commandglue.js index b35d1e557d6..538bb69b8c3 100644 --- a/mailnews/base/resources/content/commandglue.js +++ b/mailnews/base/resources/content/commandglue.js @@ -298,10 +298,8 @@ function RerootFolder(uri, newFolder, viewType, viewFlags, sortType, sortOrder) //Clear out the thread pane so that we can sort it with the new sort id without taking any time. // folder.setAttribute('ref', ""); - if (isNewsURI(uri)) - SetNewsFolderColumns(true); - else - SetNewsFolderColumns(false); + // show "Lines" for news, "Size" for mail + SetNewsFolderColumns(isNewsURI(uri)); // null this out, so we don't try sort. if (gDBView) { @@ -563,28 +561,6 @@ function CreateBareDBView(msgFolder, viewType, viewFlags, sortType, sortOrder) gDBView = Components.classes[dbviewContractId].createInstance(Components.interfaces.nsIMsgDBView); - var isNews = isNewsURI(msgFolder.URI); - if (!viewFlags) { - if (isNews) { - // news defaults to threaded mode - viewFlags = nsMsgViewFlagsType.kThreadedDisplay; - } - } - - if (!sortType) { - if (isNews) { - // news defaults to threaded mode - sortType = nsMsgViewSortType.byThread; - } - else { - sortType = nsMsgViewSortType.byDate; - } - } - - if (!sortOrder) { - sortOrder = nsMsgViewSortOrder.ascending; - } - gCurViewFlags = viewFlags; var count = new Object; if (!gThreadPaneCommandUpdater) diff --git a/mailnews/db/msgdb/public/nsIMsgDatabase.idl b/mailnews/db/msgdb/public/nsIMsgDatabase.idl index 7ba802a7657..28fdbd57975 100644 --- a/mailnews/db/msgdb/public/nsIMsgDatabase.idl +++ b/mailnews/db/msgdb/public/nsIMsgDatabase.idl @@ -24,6 +24,7 @@ #include "MailNewsTypes2.idl" #include "nsIFileSpec.idl" #include "nsIDBChangeAnnouncer.idl" +#include "nsIMsgDBView.idl" %{C++ #include "nsMsgKeyArray.h" @@ -240,5 +241,11 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer { // for sorting [noscript] void createCollationKey(in wstring sourceString, out octetPtr key, out unsigned long len); [noscript] long compareCollationKeys(out octet key1, in unsigned long len1, out octet key2, in unsigned long len2); + + // when creating a view, the default sort order and view flags + // use these for the default. (this allows news to override, so that + // news can be threaded by default) + readonly attribute nsMsgViewFlagsTypeValue defaultViewFlags; + readonly attribute nsMsgViewSortTypeValue defaultSortType; }; diff --git a/mailnews/db/msgdb/public/nsNewsDatabase.h b/mailnews/db/msgdb/public/nsNewsDatabase.h index 6c4fadec151..7f12bbb80d7 100644 --- a/mailnews/db/msgdb/public/nsNewsDatabase.h +++ b/mailnews/db/msgdb/public/nsNewsDatabase.h @@ -85,6 +85,9 @@ public: // caller needs to free static char *GetGroupNameFromURL(const char *url); + NS_IMETHOD GetDefaultViewFlags(nsMsgViewFlagsTypeValue *aDefaultViewFlags); + NS_IMETHOD GetDefaultSortType(nsMsgViewSortTypeValue *aDefaultSortType); + protected: virtual PRBool ThreadBySubjectWithoutRe() ; diff --git a/mailnews/db/msgdb/src/nsDBFolderInfo.cpp b/mailnews/db/msgdb/src/nsDBFolderInfo.cpp index 05957df2f4f..b54d2bee7ad 100644 --- a/mailnews/db/msgdb/src/nsDBFolderInfo.cpp +++ b/mailnews/db/msgdb/src/nsDBFolderInfo.cpp @@ -770,8 +770,12 @@ NS_IMETHODIMP nsDBFolderInfo::SetViewType(nsMsgViewTypeValue aViewType) /* attribute nsMsgViewFlagsTypeValue viewFlags; */ NS_IMETHODIMP nsDBFolderInfo::GetViewFlags(nsMsgViewFlagsTypeValue *aViewFlags) { + nsMsgViewFlagsTypeValue defaultViewFlags; + nsresult rv = m_mdb->GetDefaultViewFlags(&defaultViewFlags); + NS_ENSURE_SUCCESS(rv,rv); + PRUint32 viewFlagsValue; - nsresult rv = GetUint32Property("viewFlags", &viewFlagsValue, nsMsgViewFlagsType::kNone); + rv = GetUint32Property("viewFlags", &viewFlagsValue, defaultViewFlags); *aViewFlags = viewFlagsValue; return rv; } @@ -783,8 +787,12 @@ NS_IMETHODIMP nsDBFolderInfo::SetViewFlags(nsMsgViewFlagsTypeValue aViewFlags) /* attribute nsMsgViewSortTypeValue sortType; */ NS_IMETHODIMP nsDBFolderInfo::GetSortType(nsMsgViewSortTypeValue *aSortType) { + nsMsgViewSortTypeValue defaultSortType; + nsresult rv = m_mdb->GetDefaultSortType(&defaultSortType); + NS_ENSURE_SUCCESS(rv,rv); + PRUint32 sortTypeValue; - nsresult rv = GetUint32Property("sortType", &sortTypeValue, nsMsgViewSortType::byDate); + rv = GetUint32Property("sortType", &sortTypeValue, defaultSortType); *aSortType = sortTypeValue; return rv; } diff --git a/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mailnews/db/msgdb/src/nsMsgDatabase.cpp index 2bd51094276..982f010d35c 100644 --- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -4148,3 +4148,16 @@ NS_IMETHODIMP nsMsgDownloadSettings::SetAgeLimitOfMsgsToDownload(PRUint32 ageLim return NS_OK; } +NS_IMETHODIMP nsMsgDatabase::GetDefaultViewFlags(nsMsgViewFlagsTypeValue *aDefaultViewFlags) +{ + NS_ENSURE_ARG_POINTER(aDefaultViewFlags); + *aDefaultViewFlags = nsMsgViewFlagsType::kNone; + return NS_OK; +} + +NS_IMETHODIMP nsMsgDatabase::GetDefaultSortType(nsMsgViewSortTypeValue *aDefaultSortType) +{ + NS_ENSURE_ARG_POINTER(aDefaultSortType); + *aDefaultSortType = nsMsgViewSortType::byDate; + return NS_OK; +} diff --git a/mailnews/db/msgdb/src/nsNewsDatabase.cpp b/mailnews/db/msgdb/src/nsNewsDatabase.cpp index fe2a385e098..58dc2e65fc0 100644 --- a/mailnews/db/msgdb/src/nsNewsDatabase.cpp +++ b/mailnews/db/msgdb/src/nsNewsDatabase.cpp @@ -447,3 +447,18 @@ NS_IMETHODIMP nsNewsDatabase::MarkAllRead(nsMsgKeyArray *thoseMarked) return err; } +NS_IMETHODIMP +nsNewsDatabase::GetDefaultViewFlags(nsMsgViewFlagsTypeValue *aDefaultViewFlags) +{ + NS_ENSURE_ARG_POINTER(aDefaultViewFlags); + *aDefaultViewFlags = nsMsgViewFlagsType::kThreadedDisplay; + return NS_OK; +} + +NS_IMETHODIMP +nsNewsDatabase::GetDefaultSortType(nsMsgViewSortTypeValue *aDefaultSortType) +{ + NS_ENSURE_ARG_POINTER(aDefaultSortType); + *aDefaultSortType = nsMsgViewSortType::byThread; + return NS_OK; +}