From 0fc4b54f4ea4c8032ac31f8ebbecb82ce2c1d859 Mon Sep 17 00:00:00 2001 From: "ere%atp.fi" Date: Wed, 17 Sep 2003 19:52:23 +0000 Subject: [PATCH] Bug 36492: Implementation of separate recipient and sender columns in thread pane r=Neil sr=Bienvenu --- mailnews/base/public/nsIMsgDBView.idl | 2 +- .../base/resources/content/commandglue.js | 51 +++++++++++-------- .../resources/content/mailContextMenus.js | 6 +-- .../resources/content/mailWindowOverlay.js | 18 ++----- .../resources/content/mailWindowOverlay.xul | 12 ++--- mailnews/base/resources/content/threadPane.js | 16 +++--- .../base/resources/content/threadPane.xul | 6 ++- .../base/resources/locale/en-US/messenger.dtd | 7 ++- .../locale/en-US/messenger.properties | 8 --- .../resources/locale/en-US/threadpane.dtd | 2 + .../search/resources/content/SearchDialog.js | 2 +- mailnews/base/src/nsMsgDBView.cpp | 41 +++++++++++---- mailnews/base/src/nsMsgDBView.h | 2 +- mailnews/base/src/nsMsgSearchDBView.cpp | 4 +- mailnews/base/src/nsMsgSearchDBView.h | 2 +- mailnews/base/src/nsMsgSpecialViews.cpp | 5 -- mailnews/base/src/nsMsgSpecialViews.h | 1 - mailnews/base/src/nsMsgThreadedDBView.cpp | 4 +- mailnews/base/src/nsMsgThreadedDBView.h | 2 +- 19 files changed, 101 insertions(+), 90 deletions(-) diff --git a/mailnews/base/public/nsIMsgDBView.idl b/mailnews/base/public/nsIMsgDBView.idl index 1f704e523798..a04ef9c56ca3 100644 --- a/mailnews/base/public/nsIMsgDBView.idl +++ b/mailnews/base/public/nsIMsgDBView.idl @@ -247,7 +247,7 @@ interface nsMsgNavigationType [scriptable, uuid(704c7d28-fd1a-11d4-a5be-0060b0fc04b7)] interface nsIMsgDBView : nsISupports { - void open(in nsIMsgFolder folder, in nsMsgViewSortTypeValue sortType, in nsMsgViewSortOrderValue sortOrder, in nsMsgViewFlagsTypeValue viewFlags, in boolean aTreatRecipientAsAuthor, out long count); + void open(in nsIMsgFolder folder, in nsMsgViewSortTypeValue sortType, in nsMsgViewSortOrderValue sortOrder, in nsMsgViewFlagsTypeValue viewFlags, out long count); void close(); void init(in nsIMessenger aMessengerInstance, in nsIMsgWindow aMsgWindow, in nsIMsgDBViewCommandUpdater aCommandUpdater); diff --git a/mailnews/base/resources/content/commandglue.js b/mailnews/base/resources/content/commandglue.js index 6718d26afa08..0f65c08605fc 100644 --- a/mailnews/base/resources/content/commandglue.js +++ b/mailnews/base/resources/content/commandglue.js @@ -389,18 +389,32 @@ function SwitchView(command) function SetSentFolderColumns(isSentFolder) { - var senderOrRecipientColumn = document.getElementById("senderOrRecipientCol"); + var tree = GetThreadTree(); var searchCriteria = document.getElementById("searchCriteria"); + + var lastFolderSent = tree.getAttribute("lastfoldersent") == "true"; + if (isSentFolder != lastFolderSent) + { + var senderColumn = document.getElementById("senderCol"); + var recipientColumn = document.getElementById("recipientCol"); + + var saveHidden = senderColumn.getAttribute("hidden"); + senderColumn.setAttribute("hidden", senderColumn.getAttribute("swappedhidden")); + senderColumn.setAttribute("swappedhidden", saveHidden); + + saveHidden = recipientColumn.getAttribute("hidden"); + recipientColumn.setAttribute("hidden", recipientColumn.getAttribute("swappedhidden")); + recipientColumn.setAttribute("swappedhidden", saveHidden); + } + if(isSentFolder) { - senderOrRecipientColumn.setAttribute("tooltiptext", gMessengerBundle.getString("recipientColumnTooltip")); - senderOrRecipientColumn.setAttribute("label", gMessengerBundle.getString("recipientColumnHeader")); + tree.setAttribute("lastfoldersent", "true"); searchCriteria.setAttribute("value", gMessengerBundle.getString("recipientSearchCriteria")); } else { - senderOrRecipientColumn.setAttribute("tooltiptext", gMessengerBundle.getString("senderColumnTooltip")); - senderOrRecipientColumn.setAttribute("label", gMessengerBundle.getString("senderColumnHeader")); + tree.setAttribute("lastfoldersent", "false"); searchCriteria.setAttribute("value", gMessengerBundle.getString("senderSearchCriteria")); } } @@ -447,13 +461,11 @@ function ConvertColumnIDToSortType(columnID) case "dateCol": sortKey = nsMsgViewSortType.byDate; break; - case "senderOrRecipientCol": - if (IsSpecialFolderSelected(MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE)) { - sortKey = nsMsgViewSortType.byRecipient; - } - else { - sortKey = nsMsgViewSortType.byAuthor; - } + case "senderCol": + sortKey = nsMsgViewSortType.byAuthor; + break; + case "recipientCol": + sortKey = nsMsgViewSortType.byRecipient; break; case "subjectCol": sortKey = nsMsgViewSortType.bySubject; @@ -509,8 +521,10 @@ function ConvertSortTypeToColumnID(sortKey) columnID = "dateCol"; break; case nsMsgViewSortType.byAuthor: + columnID = "senderCol"; + break; case nsMsgViewSortType.byRecipient: - columnID = "senderOrRecipientCol"; + columnID = "recipientCol"; break; case nsMsgViewSortType.bySubject: columnID = "subjectCol"; @@ -598,18 +612,11 @@ function CreateBareDBView(originalView, msgFolder, viewType, viewFlags, sortType if (!gThreadPaneCommandUpdater) gThreadPaneCommandUpdater = new nsMsgDBViewCommandUpdater(); - if ((sortType == nsMsgViewSortType.byAuthor) && IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE)) { - gCurSortType = nsMsgViewSortType.byRecipient; - } - else { - gCurSortType = sortType; - } + gCurSortType = sortType; if (!originalView) { gDBView.init(messenger, msgWindow, gThreadPaneCommandUpdater); - - var treatRecipientAsAuthor = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE); - gDBView.open(msgFolder, gCurSortType, sortOrder, viewFlags, treatRecipientAsAuthor, count); + gDBView.open(msgFolder, gCurSortType, sortOrder, viewFlags, count); } else { gDBView = originalView.cloneDBView(messenger, msgWindow, gThreadPaneCommandUpdater); diff --git a/mailnews/base/resources/content/mailContextMenus.js b/mailnews/base/resources/content/mailContextMenus.js index f50877c807a9..390baa3c9a58 100644 --- a/mailnews/base/resources/content/mailContextMenus.js +++ b/mailnews/base/resources/content/mailContextMenus.js @@ -311,9 +311,9 @@ function fillFolderPaneContextMenu() EnableMenuItem("folderPaneContext-markNewsgroupAllRead", true); // End of News folder context menu ======================================= - - ShowMenuItem("folderPaneContext-markMailFolderAllRead", (numSelected <= 1) && ! isNewsgroup); - EnableMenuItem("folderPaneContext-markMailFolderAllRead", true); + + ShowMenuItem("folderPaneContext-markMailFolderAllRead", (numSelected <= 1) && ! isNewsgroup); + EnableMenuItem("folderPaneContext-markMailFolderAllRead", true); ShowMenuItem("folderPaneContext-searchMessages", (numSelected<=1)); EnableMenuItem("folderPaneContext-searchMessages", IsCanSearchMessagesEnabled()); diff --git a/mailnews/base/resources/content/mailWindowOverlay.js b/mailnews/base/resources/content/mailWindowOverlay.js index cb09f6b7af42..27d1a9e3230c 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.js +++ b/mailnews/base/resources/content/mailWindowOverlay.js @@ -218,21 +218,9 @@ function InitViewSortByMenu() setSortByMenuItemCheckState("sortByUnreadMenuitem", (sortType == nsMsgViewSortType.byUnread)); setSortByMenuItemCheckState("sortByLabelMenuitem", (sortType == nsMsgViewSortType.byLabel)); setSortByMenuItemCheckState("sortByJunkStatusMenuitem", (sortType == nsMsgViewSortType.byJunkStatus)); - - // the Sender / Recipient menu is dynamic - setSortByMenuItemCheckState("sortBySenderOrRecipientMenuitem", (sortType == nsMsgViewSortType.byAuthor) || (sortType == nsMsgViewSortType.byRecipient)); - var senderOrRecipientMenuitem = document.getElementById("sortBySenderOrRecipientMenuitem"); - if (senderOrRecipientMenuitem) { - var currentFolder = gDBView.msgFolder; - if (IsSpecialFolder(currentFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE)) { - senderOrRecipientMenuitem.setAttribute('label',gMessengerBundle.getString('recipientColumnHeader')); - senderOrRecipientMenuitem.setAttribute('accesskey',gMessengerBundle.getString('recipientAccessKey')); - } - else { - senderOrRecipientMenuitem.setAttribute('label',gMessengerBundle.getString('senderColumnHeader')); - senderOrRecipientMenuitem.setAttribute('accesskey',gMessengerBundle.getString('senderAccessKey')); - } - } + setSortByMenuItemCheckState("sortBySenderMenuitem", (sortType == nsMsgViewSortType.byAuthor)); + setSortByMenuItemCheckState("sortByRecipientMenuitem", (sortType == nsMsgViewSortType.byRecipient)); + var sortOrder = gDBView.sortOrder; setSortByMenuItemCheckState("sortAscending", (sortOrder == nsMsgViewSortOrder.ascending)); diff --git a/mailnews/base/resources/content/mailWindowOverlay.xul b/mailnews/base/resources/content/mailWindowOverlay.xul index 8900233eed27..5d6f0cc48b2c 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.xul +++ b/mailnews/base/resources/content/mailWindowOverlay.xul @@ -648,10 +648,10 @@ Rights Reserved. - + - - + + diff --git a/mailnews/base/resources/content/threadPane.js b/mailnews/base/resources/content/threadPane.js index a3e3b1eb408a..10b56ac6fd39 100644 --- a/mailnews/base/resources/content/threadPane.js +++ b/mailnews/base/resources/content/threadPane.js @@ -170,14 +170,14 @@ function MsgSortByDate() MsgSortThreadPane(nsMsgViewSortType.byDate); } -function MsgSortBySenderOrRecipient() +function MsgSortBySender() { - if (IsSpecialFolderSelected(MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE)) { - MsgSortThreadPane(nsMsgViewSortType.byRecipient); - } - else { - MsgSortThreadPane(nsMsgViewSortType.byAuthor); - } + MsgSortThreadPane(nsMsgViewSortType.byAuthor); +} + +function MsgSortByRecipient() +{ + MsgSortThreadPane(nsMsgViewSortType.byRecipient); } function MsgSortByStatus() @@ -373,7 +373,7 @@ function ThreadPaneOnLoad() var tree = GetThreadTree(); tree.addEventListener("click",ThreadPaneOnClick,true); - + // The mousedown event listener below should only be added in the thread // pane of the mailnews 3pane window, not in the advanced search window. if(tree.parentNode.id == "searchResultListBox") diff --git a/mailnews/base/resources/content/threadPane.xul b/mailnews/base/resources/content/threadPane.xul index 639339b89ff7..4ab062f79594 100644 --- a/mailnews/base/resources/content/threadPane.xul +++ b/mailnews/base/resources/content/threadPane.xul @@ -35,7 +35,7 @@ Contributors: