diff --git a/mail/base/content/commandglue.js b/mail/base/content/commandglue.js index ebf93a37d4f3..1b4f9b0884fc 100644 --- a/mail/base/content/commandglue.js +++ b/mail/base/content/commandglue.js @@ -297,8 +297,6 @@ 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', ""); - // show "Lines" for news, "Size" for mail - SetNewsFolderColumns(isNewsURI(uri)); // null this out, so we don't try sort. if (gDBView) { @@ -432,11 +430,11 @@ function SetSentFolderColumns(isSentFolder) } } -function SetNewsFolderColumns(isNewsFolder) +function SetNewsFolderColumns() { var sizeColumn = document.getElementById("sizeCol"); - if (isNewsFolder) { + if (gDBView.usingLines) { sizeColumn.setAttribute("label",gMessengerBundle.getString("linesColumnHeader")); } else { diff --git a/mailnews/base/public/nsIMsgDBView.idl b/mailnews/base/public/nsIMsgDBView.idl index 7aa6bf6a4aca..aee9e1ed1f55 100644 --- a/mailnews/base/public/nsIMsgDBView.idl +++ b/mailnews/base/public/nsIMsgDBView.idl @@ -320,6 +320,9 @@ interface nsIMsgDBView : nsISupports nsMsgViewIndex findIndexFromKey(in nsMsgKey aMsgKey, in boolean aExpand); void ExpandAndSelectThreadByIndex(in nsMsgViewIndex aIndex, in boolean aAugment); + + // use lines or kB for size? + readonly attribute boolean usingLines; }; /* this interface is rapidly morphing from a command updater interface into a more generic diff --git a/mailnews/base/resources/content/commandglue.js b/mailnews/base/resources/content/commandglue.js index a24fa7da31af..b1531d0eac89 100644 --- a/mailnews/base/resources/content/commandglue.js +++ b/mailnews/base/resources/content/commandglue.js @@ -305,8 +305,6 @@ 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', ""); - // show "Lines" for news, "Size" for mail - SetNewsFolderColumns(isNewsURI(uri)); // null this out, so we don't try sort. if (gDBView) { @@ -438,11 +436,11 @@ function SetSentFolderColumns(isSentFolder) } } -function SetNewsFolderColumns(isNewsFolder) +function SetNewsFolderColumns() { var sizeColumn = document.getElementById("sizeCol"); - if (isNewsFolder) { + if (gDBView.usingLines) { sizeColumn.setAttribute("tooltiptext",gMessengerBundle.getString("linesColumnTooltip")); sizeColumn.setAttribute("label",gMessengerBundle.getString("linesColumnHeader")); } diff --git a/mailnews/base/resources/content/threadPane.js b/mailnews/base/resources/content/threadPane.js index 12d980dcc8c0..68a496764aa0 100644 --- a/mailnews/base/resources/content/threadPane.js +++ b/mailnews/base/resources/content/threadPane.js @@ -410,6 +410,8 @@ function EnsureRowInThreadTreeIsVisible(index) function RerootThreadPane() { + SetNewsFolderColumns(); + var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView); if (treeView) { diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index 53081dd41317..cf529a8eefdd 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -144,7 +144,8 @@ nsMsgDBView::nsMsgDBView() m_deletingRows = PR_FALSE; mJunkIndices = nsnull; mNumJunkIndices = 0; - + mShowSizeInLines = PR_FALSE; + /* mCommandsNeedDisablingBecauseOffline - A boolean that tell us if we needed to disable commands because we're offline w/o a downloaded msg select */ mCommandsNeedDisablingBecauseOffline = PR_FALSE; @@ -679,8 +680,8 @@ nsresult nsMsgDBView::FetchSize(nsIMsgHdr * aHdr, PRUnichar ** aSizeString) nsAutoString formattedSizeString; PRUint32 msgSize = 0; - // for news, show the line count not the size - if (mIsNews) + // for news, show the line count, not the size if the user wants so + if (mShowSizeInLines) { aHdr->GetLineCount(&msgSize); formattedSizeString.AppendInt(msgSize); @@ -1766,6 +1767,18 @@ NS_IMETHODIMP nsMsgDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTypeValue sor mIsNews = !strcmp("nntp",type.get()); GetImapDeleteModel(nsnull); + + if (mIsNews) + { + nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (prefs) + { + PRBool temp; + rv = prefs->GetBoolPref("news.show_size_in_lines", &temp); + if (NS_SUCCEEDED(rv)) + mShowSizeInLines = temp; + } + } } return NS_OK; } @@ -1846,6 +1859,12 @@ NS_IMETHODIMP nsMsgDBView::GetSuppressMsgDisplay(PRBool * aSuppressDisplay) return NS_OK; } +NS_IMETHODIMP nsMsgDBView::GetUsingLines(PRBool * aUsingLines) +{ + *aUsingLines = mShowSizeInLines; + return NS_OK; +} + int PR_CALLBACK CompareViewIndices (const void *v1, const void *v2, void *) { nsMsgViewIndex i1 = *(nsMsgViewIndex*) v1; @@ -3250,7 +3269,7 @@ nsresult nsMsgDBView::GetLongField(nsIMsgDBHdr *msgHdr, nsMsgViewSortTypeValue s switch (sortType) { case nsMsgViewSortType::bySize: - rv = (mIsNews) ? msgHdr->GetLineCount(result) : msgHdr->GetMessageSize(result); + rv = (mShowSizeInLines) ? msgHdr->GetLineCount(result) : msgHdr->GetMessageSize(result); break; case nsMsgViewSortType::byPriority: nsMsgPriorityValue priority; @@ -5751,6 +5770,7 @@ nsresult nsMsgDBView::CopyDBView(nsMsgDBView *aNewMsgDBView, nsIMessenger *aMess if (m_db) aNewMsgDBView->m_db->AddListener(aNewMsgDBView); aNewMsgDBView->mIsNews = mIsNews; + aNewMsgDBView->mShowSizeInLines = mShowSizeInLines; aNewMsgDBView->mHeaderParser = mHeaderParser; aNewMsgDBView->mDeleteModel = mDeleteModel; aNewMsgDBView->m_flags.CopyArray(m_flags); diff --git a/mailnews/base/src/nsMsgDBView.h b/mailnews/base/src/nsMsgDBView.h index 9bbaeb814519..64d1b300a347 100644 --- a/mailnews/base/src/nsMsgDBView.h +++ b/mailnews/base/src/nsMsgDBView.h @@ -331,7 +331,8 @@ protected: // and decendents of those folders // (like the "Sent" folder, "Sent/Old Sent") // the Sender column really shows recipients. - PRPackedBool mIsNews; // we have special icons for news, and for news, we show lines instead of size + PRPackedBool mIsNews; // we have special icons for news + PRPackedBool mShowSizeInLines; // for news we show lines instead of size when true PRPackedBool m_sortValid; PRUint8 m_saveRestoreSelectionDepth; diff --git a/mailnews/mailnews.js b/mailnews/mailnews.js index ab0fcebc0dcc..e0dea17d06cc 100644 --- a/mailnews/mailnews.js +++ b/mailnews/mailnews.js @@ -170,6 +170,7 @@ pref("news.fcc_folder", ""); pref("news.notify.on", true); pref("news.max_articles", 500); pref("news.mark_old_read", false); +pref("news.show_size_in_lines", true); pref("mailnews.wraplength", 72); pref("mail.compose.wrap_to_window_width", false);