Bug 504954 - "Add Outbox to smart folders" [r+sr=bienvenu ui-review=clarkbw]
authorBlake Winton <bwinton@latte.ca>
Thu, 03 Sep 2009 07:38:21 +0100
changeset 3493 9a323dde5ffa7cde3da34dae18242af3386c5bab
parent 3492 9ba3c9960761a272d8cbbee98c12a2919a32b385
child 3494 08625567a7c72f1593b165ca4e98d069c9f6ebc0
push idunknown
push userunknown
push dateunknown
bugs504954
Bug 504954 - "Add Outbox to smart folders" [r+sr=bienvenu ui-review=clarkbw]
mail/base/content/folderPane.js
mailnews/base/util/nsMsgDBFolder.cpp
--- a/mail/base/content/folderPane.js
+++ b/mail/base/content/folderPane.js
@@ -802,16 +802,18 @@ let gFolderTreeView = {
     gFolderTreeView._addSmartFoldersForFlag(smartChildren, accounts, smartRoot,
                                             nsMsgFolderFlags.Trash, "Trash");
     gFolderTreeView._addSmartFoldersForFlag(smartChildren, accounts, smartRoot,
                                             nsMsgFolderFlags.Templates, "Templates");
     gFolderTreeView._addSmartFoldersForFlag(smartChildren, accounts, smartRoot,
                                             nsMsgFolderFlags.Archive, "Archives");
     gFolderTreeView._addSmartFoldersForFlag(smartChildren, accounts, smartRoot,
                                             nsMsgFolderFlags.Junk, "Junk");
+    gFolderTreeView._addSmartFoldersForFlag(smartChildren, accounts, smartRoot,
+                                            nsMsgFolderFlags.Queue, "Outbox");
 
     sortFolderItems(smartChildren);
     for each (smartChild in smartChildren)
       map.push(smartChild);
 
     for each (acct in accounts) {
       // Bug 466311 Sometimes this can throw file not found, we're unsure
       // why, but catch it and log the fact.
@@ -828,16 +830,25 @@ let gFolderTreeView = {
       map.push(new ftv_SmartItem(acct.incomingServer.rootFolder));
 
     return map;
   },
 
   _addSmartFoldersForFlag: function ftv_addSmartFoldersForFlag(map, accounts, smartRootFolder,
                                                                flag, folderName)
   {
+    // If there's only one subFolder, just put it at the root.
+    let subFolders = gFolderTreeView._allFoldersWithFlag(accounts, flag, false);
+    if (subFolders.length == 1) {
+      let folderItem = new ftvItem(subFolders[0]);
+      folderItem._level = 0;
+      map.push(folderItem);
+      return;
+    }
+
     let smartFolder;
     try {
       let folderUri = smartRootFolder.URI + "/" + folderName;
       smartFolder = smartRootFolder.getChildWithURI(folderUri, false, true);
     } catch (ex) {
         smartFolder = null;
     };
     if (!smartFolder) {
@@ -852,17 +863,16 @@ let gFolderTreeView = {
         return;
       smartFolder = gFolderTreeView._createVFFolder(folderName, smartRootFolder,
                                                     searchFolderURIs, flag);
     }
 
     let smartFolderItem = new ftvItem(smartFolder);
     smartFolderItem._level = 0;
     map.push(smartFolderItem);
-    let subFolders = gFolderTreeView._allFoldersWithFlag(accounts, flag, false);
     // now add the actual inboxes as sub-folders of the saved search.
     // By setting _children directly, we bypass the normal calculation
     // of subfolders.
     smartFolderItem._children = [new ftvItem(f) for each (f in subFolders)];
 
     // sortFolderItems(this._children);
     // Each child is a level one below the smartFolder
     for each (let child in smartFolderItem._children) {
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -5133,31 +5133,31 @@ NS_IMETHODIMP nsMsgDBFolder::GetSortOrde
   NS_ENSURE_ARG_POINTER(order);
 
   PRUint32 flags;
   nsresult rv = GetFlags(&flags);
   NS_ENSURE_SUCCESS(rv,rv);
 
   if (flags & nsMsgFolderFlags::Inbox)
     *order = 0;
-  else if (flags & nsMsgFolderFlags::Queue)
+  else if (flags & nsMsgFolderFlags::Drafts)
     *order = 1;
-  else if (flags & nsMsgFolderFlags::Drafts)
+  else if (flags & nsMsgFolderFlags::Templates)
     *order = 2;
-  else if (flags & nsMsgFolderFlags::Templates)
+  else if (flags & nsMsgFolderFlags::SentMail)
     *order = 3;
-  else if (flags & nsMsgFolderFlags::SentMail)
+  else if (flags & nsMsgFolderFlags::Archive)
     *order = 4;
-  else if (flags & nsMsgFolderFlags::Archive)
+  else if (flags & nsMsgFolderFlags::Junk)
     *order = 5;
-  else if (flags & nsMsgFolderFlags::Junk)
+  else if (flags & nsMsgFolderFlags::Trash)
     *order = 6;
-  else if (flags & nsMsgFolderFlags::Trash)
+  else if (flags & nsMsgFolderFlags::Virtual)
     *order = 7;
-  else if (flags & nsMsgFolderFlags::Virtual)
+  else if (flags & nsMsgFolderFlags::Queue)
     *order = 8;
   else
     *order = 9;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgDBFolder::GetSortKey(PRUint32 *aLength, PRUint8 **aKey)