fix for #73416. show the proper icons in the thread pane.

sr=bienvenu
This commit is contained in:
sspitzer%netscape.com 2001-03-26 23:17:33 +00:00
Родитель 72ed9a2969
Коммит 6e03315ffb
3 изменённых файлов: 160 добавлений и 88 удалений

Просмотреть файл

@ -46,12 +46,18 @@ static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
nsrefcnt nsMsgDBView::gInstanceCount = 0;
nsIAtom * nsMsgDBView::kUnreadMsgAtom = nsnull;
nsIAtom * nsMsgDBView::kHighestPriorityAtom = nsnull;
nsIAtom * nsMsgDBView::kHighPriorityAtom = nsnull;
nsIAtom * nsMsgDBView::kLowestPriorityAtom = nsnull;
nsIAtom * nsMsgDBView::kLowPriorityAtom = nsnull;
nsIAtom * nsMsgDBView::kUnreadMsgAtom = nsnull;
nsIAtom * nsMsgDBView::kOfflineMsgAtom = nsnull;
nsIAtom * nsMsgDBView::kFlaggedMsgAtom = nsnull;
nsIAtom * nsMsgDBView::kNewsMsgAtom = nsnull;
nsIAtom * nsMsgDBView::kImapDeletedMsgAtom = nsnull;
nsIAtom * nsMsgDBView::kAttachMsgAtom = nsnull;
PRUnichar * nsMsgDBView::kHighestPriorityString = nsnull;
PRUnichar * nsMsgDBView::kHighPriorityString = nsnull;
@ -84,7 +90,8 @@ nsMsgDBView::nsMsgDBView()
m_currentlyDisplayedMsgKey = nsMsgKey_None;
mNumSelectedRows = 0;
mSupressMsgDisplay = PR_FALSE;
mSpecialFolder = PR_FALSE;
mIsSpecialFolder = PR_FALSE;
mIsNews = PR_FALSE;
// initialize any static atoms or unicode strings
if (gInstanceCount == 0)
@ -99,6 +106,10 @@ void nsMsgDBView::InitializeAtomsAndLiterals()
{
kUnreadMsgAtom = NS_NewAtom("unread");
kOfflineMsgAtom = NS_NewAtom("offline");
kFlaggedMsgAtom = NS_NewAtom("flagged");
kNewsMsgAtom = NS_NewAtom("news");
kImapDeletedMsgAtom = NS_NewAtom("imapdeleted");
kAttachMsgAtom = NS_NewAtom("attach");
kHighestPriorityAtom = NS_NewAtom("priority-highest");
kHighPriorityAtom = NS_NewAtom("priority-high");
@ -128,6 +139,11 @@ nsMsgDBView::~nsMsgDBView()
{
NS_IF_RELEASE(kUnreadMsgAtom);
NS_IF_RELEASE(kOfflineMsgAtom);
NS_IF_RELEASE(kFlaggedMsgAtom);
NS_IF_RELEASE(kNewsMsgAtom);
NS_IF_RELEASE(kImapDeletedMsgAtom);
NS_IF_RELEASE(kAttachMsgAtom);
NS_IF_RELEASE(kHighestPriorityAtom);
NS_IF_RELEASE(kHighPriorityAtom);
NS_IF_RELEASE(kLowestPriorityAtom);
@ -180,7 +196,7 @@ nsresult nsMsgDBView::FetchAuthor(nsIMsgHdr * aHdr, PRUnichar ** aSenderString)
mHeaderParser = do_CreateInstance(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID);
nsresult rv = NS_OK;
if (mSpecialFolder)
if (mIsSpecialFolder)
rv = aHdr->GetMime2DecodedRecipients(getter_Copies(unparsedAuthor));
else
rv = aHdr->GetMime2DecodedAuthor(getter_Copies(unparsedAuthor));
@ -306,6 +322,14 @@ nsresult nsMsgDBView::FetchSize(nsIMsgHdr * aHdr, PRUnichar ** aSizeString)
{
nsAutoString formattedSizeString;
PRUint32 msgSize = 0;
// for news, show the line count not the size
if (mIsNews) {
aHdr->GetLineCount(&msgSize);
formattedSizeString.AppendInt(msgSize);
return NS_OK;
}
aHdr->GetMessageSize(&msgSize);
if(msgSize < 1024)
@ -314,6 +338,7 @@ nsresult nsMsgDBView::FetchSize(nsIMsgHdr * aHdr, PRUnichar ** aSizeString)
PRUint32 sizeInKB = msgSize/1024;
formattedSizeString.AppendInt(sizeInKB);
// XXX todo, fix this hard coded string?
formattedSizeString.Append(NS_LITERAL_STRING("KB"));
*aSizeString = formattedSizeString.ToNewUnicode();
@ -633,7 +658,6 @@ NS_IMETHODIMP nsMsgDBView::GetColumnProperties(const PRUnichar *colID, nsIDOMEle
return NS_OK;
}
NS_IMETHODIMP nsMsgDBView::GetCellProperties(PRInt32 aRow, const PRUnichar *colID, nsISupportsArray *properties)
{
// this is where we tell the outliner to apply styles to a particular row
@ -665,7 +689,16 @@ NS_IMETHODIMP nsMsgDBView::GetCellProperties(PRInt32 aRow, const PRUnichar *colI
if (flags & MSG_FLAG_OFFLINE)
properties->AppendElement(kOfflineMsgAtom);
if (flags & MSG_FLAG_ATTACHMENT)
properties->AppendElement(kAttachMsgAtom);
if (flags & MSG_FLAG_IMAP_DELETED)
properties->AppendElement(kImapDeletedMsgAtom);
if (mIsNews)
properties->AppendElement(kNewsMsgAtom);
if (colID[0] == 'p') // for the priority column, add special styles....
{
nsMsgPriorityValue priority;
@ -688,6 +721,13 @@ NS_IMETHODIMP nsMsgDBView::GetCellProperties(PRInt32 aRow, const PRUnichar *colI
break;
}
}
else if (colID[0] == 'f')
{
if (m_flags[aRow] & MSG_FLAG_MARKED)
{
properties->AppendElement(kFlaggedMsgAtom);
}
}
return NS_OK;
}
@ -854,21 +894,9 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, P
case 'p': // priority
rv = FetchPriority(msgHdr, aValue);
break;
case 't': // threaded mode (this is temporary...it's how we are faking twisties
if (aColID[1] == 'h')
{
if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay)
{
// if it's an open container, print a '-' sign. If it's a closed container,
// print a "+" sign. o.t. do nothing.
if (m_flags[aRow] & MSG_FLAG_ELIDED)
*aValue = nsCRT::strdup(NS_LITERAL_STRING("+").get());
else if (m_flags[aRow] & MSG_VIEW_FLAG_HASCHILDREN)
*aValue = nsCRT::strdup(NS_LITERAL_STRING("-").get());
}
}
case 't':
// total msgs in thread column
else if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay)
if (aColID[1] == 'o' && (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay))
{
if (m_flags[aRow] & MSG_VIEW_FLAG_ISTHREAD)
{
@ -884,22 +912,9 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, P
}
}
break;
case 'f':
if (m_flags[aRow] & MSG_FLAG_MARKED)
*aValue = nsCRT::strdup(NS_LITERAL_STRING("*").get());
else
*aValue = nsCRT::strdup(NS_LITERAL_STRING("'").get());
break;
case 'u': // unread button column
if (aColID[6] == 'B')
{
if (m_flags[aRow] & MSG_FLAG_READ)
*aValue = nsCRT::strdup(NS_LITERAL_STRING("'").get());
else
*aValue = nsCRT::strdup(NS_LITERAL_STRING("*").get());
}
case 'u':
// unread msgs in thread col
else if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay)
if (aColID[6] == 'C' && (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay))
{
if (m_flags[aRow] & MSG_VIEW_FLAG_ISTHREAD)
{
@ -933,9 +948,14 @@ NS_IMETHODIMP nsMsgDBView::SetOutliner(nsIOutlinerBoxObject *outliner)
NS_IMETHODIMP nsMsgDBView::ToggleOpenState(PRInt32 index)
{
PRUint32 numChanged;
PRUint32 numChanged = 0;
PRInt32 multiplier = -1;
if (m_flags[index] & MSG_FLAG_ELIDED)
multiplier = 1;
nsresult rv = ToggleExpansion(index, &numChanged);
return rv;
NS_ENSURE_SUCCESS(rv,rv);
mOutliner->RowCountChanged(index, numChanged * multiplier);
return NS_OK;
}
NS_IMETHODIMP nsMsgDBView::CycleHeader(const PRUnichar * aColID, nsIDOMElement * aElement)
@ -965,7 +985,7 @@ NS_IMETHODIMP nsMsgDBView::CycleHeader(const PRUnichar * aColID, nsIDOMElement *
}
else if (aColID[1] == 'e') // sort by sender
{
if (mSpecialFolder)
if (mIsSpecialFolder)
sortType = nsMsgViewSortType::byRecipient;
else
sortType = nsMsgViewSortType::byAuthor;
@ -1059,13 +1079,7 @@ NS_IMETHODIMP nsMsgDBView::CycleCell(PRInt32 row, const PRUnichar *colID)
case 't': // threaded cell or total cell
if ((colID[1] == 'h') && ((m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) && (m_flags [row] & MSG_VIEW_FLAG_HASCHILDREN))) // 'th' for threaded, 'to' for total
{
PRUint32 numChanged = 0;
PRInt32 multiplier = -1;
if (m_flags [row] & MSG_FLAG_ELIDED)
multiplier = 1;
ToggleExpansion(row, &numChanged);
mOutliner->RowCountChanged(row, numChanged * multiplier);
ExpandAndSelectThreadByIndex(row);
}
break;
case 'f': // flagged column
@ -1133,13 +1147,23 @@ NS_IMETHODIMP nsMsgDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTypeValue sor
m_db->AddListener(this);
m_folder = folder;
// for sent, unsent and draft folders, be sure to set mSpecialFolder so we'll show the recipient field
// determine if we are in a news folder or not.
// if yes, we'll show lines instead of size, and special icons in the thread pane
nsCOMPtr <nsIMsgIncomingServer> server;
rv = folder->GetServer(getter_AddRefs(server));
NS_ENSURE_SUCCESS(rv,rv);
nsXPIDLCString type;
rv = server->GetType(getter_Copies(type));
NS_ENSURE_SUCCESS(rv,rv);
mIsNews = !nsCRT::strcmp("nntp",type.get());
// for sent, unsent and draft folders, be sure to set mIsSpecialFolder so we'll show the recipient field
// in place of the author.
PRUint32 folderFlags = 0;
m_folder->GetFlags(&folderFlags);
if ( (folderFlags & MSG_FOLDER_FLAG_DRAFTS) || (folderFlags & MSG_FOLDER_FLAG_SENTMAIL)
|| (folderFlags & MSG_FOLDER_FLAG_QUEUE))
mSpecialFolder = PR_TRUE;
mIsSpecialFolder = PR_TRUE;
}
#ifdef HAVE_PORT
CacheAdd ();
@ -1478,7 +1502,7 @@ nsMsgDBView::ApplyCommandToIndices(nsMsgViewCommandTypeValue command, nsMsgViewI
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(m_folder);
PRBool thisIsImapFolder = (imapFolder != nsnull);
if (command == nsMsgViewCommandType::deleteMsg)
rv = DeleteMessages (mMsgWindow, indices, numIndices, PR_FALSE);
rv = DeleteMessages(mMsgWindow, indices, numIndices, PR_FALSE);
else if (command == nsMsgViewCommandType::deleteNoTrash)
rv = DeleteMessages(mMsgWindow, indices, numIndices, PR_TRUE);
else
@ -2611,41 +2635,56 @@ nsresult nsMsgDBView::ExpandAndSelectThread()
rv = mOutlinerSelection->GetCurrentIndex(&index);
NS_ENSURE_SUCCESS(rv,rv);
nsMsgViewIndex threadIndex = ThreadIndexOfMsg(GetAt(index), index);
if (threadIndex == nsMsgViewIndex_None) {
NS_ASSERTION(PR_FALSE, "couldn't find thread");
return NS_MSG_MESSAGE_NOT_FOUND;
}
PRInt32 flags = m_flags[threadIndex];
PRInt32 count = 0;
if ((flags & MSG_VIEW_FLAG_ISTHREAD) && (flags && MSG_VIEW_FLAG_HASCHILDREN)) {
// if closed, expand this thread.
if (flags & MSG_FLAG_ELIDED) {
PRUint32 numExpanded;
rv = ExpandByIndex(threadIndex, &numExpanded);
NS_ENSURE_SUCCESS(rv,rv);
}
// get the number of messages in the expanded thread
// so we know how many to select
count = CountExpandedThread(threadIndex);
}
NS_ASSERTION(count > 0, "bad count");
// clear the existing selection.
mOutlinerSelection->ClearSelection();
// is this correct?
mOutlinerSelection->SetCurrentIndex(threadIndex);
// the count should be 1 or greater. if there was only one message in the thread, we just select it.
// if more, we select all of them.
mOutlinerSelection->RangedSelect(threadIndex, threadIndex + count - 1, PR_TRUE /* augment */);
rv = ExpandAndSelectThreadByIndex(index);
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
}
nsresult nsMsgDBView::ExpandAndSelectThreadByIndex(nsMsgViewIndex index)
{
nsresult rv;
nsMsgViewIndex threadIndex = ThreadIndexOfMsg(GetAt(index), index);
if (threadIndex == nsMsgViewIndex_None) {
NS_ASSERTION(PR_FALSE, "couldn't find thread");
return NS_MSG_MESSAGE_NOT_FOUND;
}
PRInt32 flags = m_flags[threadIndex];
PRInt32 count = 0;
if ((flags & MSG_VIEW_FLAG_ISTHREAD) && (flags && MSG_VIEW_FLAG_HASCHILDREN)) {
// if closed, expand this thread.
if (flags & MSG_FLAG_ELIDED) {
PRUint32 numExpanded;
rv = ExpandByIndex(threadIndex, &numExpanded);
NS_ENSURE_SUCCESS(rv,rv);
}
// get the number of messages in the expanded thread
// so we know how many to select
count = CountExpandedThread(threadIndex);
}
NS_ASSERTION(count > 0, "bad count");
NS_ASSERTION(mOutlinerSelection, "no outliner selection");
if (!mOutlinerSelection) return NS_ERROR_UNEXPECTED;
// clear the existing selection.
mOutlinerSelection->ClearSelection();
// is this correct?
mOutlinerSelection->SetCurrentIndex(threadIndex);
// the count should be 1 or greater. if there was only one message in the thread, we just select it.
// if more, we select all of them.
mOutlinerSelection->RangedSelect(threadIndex, threadIndex + count - 1, PR_TRUE /* augment */);
//do we want to do something like this to clear the message pane
//when the user selects a thread?
//NoteChange(?, ?, nsMsgViewNotificationCode::clearMessagePane);
return NS_OK;
}
nsresult nsMsgDBView::ExpandAll()
{
for (PRInt32 i = GetSize() - 1; i >= 0; i--)

Просмотреть файл

@ -77,6 +77,11 @@ protected:
// these so i'm going to make them static.
static nsIAtom* kUnreadMsgAtom;
static nsIAtom* kOfflineMsgAtom;
static nsIAtom* kFlaggedMsgAtom;
static nsIAtom* kNewsMsgAtom;
static nsIAtom* kImapDeletedMsgAtom;
static nsIAtom* kAttachMsgAtom;
static nsIAtom* kHighestPriorityAtom;
static nsIAtom* kHighPriorityAtom;
static nsIAtom* kLowestPriorityAtom;
@ -140,6 +145,7 @@ protected:
nsresult CollapseByIndex(nsMsgViewIndex index, PRUint32 *pNumCollapsed);
nsresult ExpandAll();
nsresult CollapseAll();
nsresult ExpandAndSelectThreadByIndex(nsMsgViewIndex index);
nsresult ExpandAndSelectThread();
// helper routines for thread expanding and collapsing.
@ -247,7 +253,8 @@ protected:
nsMsgKey m_currentlyDisplayedMsgKey;
nsCOMPtr <nsIMsgFolder> m_folder;
PRBool mSpecialFolder; // for special folders, the Sender column really shows recipients.
PRBool mIsSpecialFolder; // for special folders, the Sender column really shows recipients.
PRBool mIsNews; // we have special icons for news, and for news, we show lines instead of size
nsCOMPtr <nsIMsgDatabase> m_db;
PRBool m_sortValid;
nsMsgViewSortTypeValue m_sortType;

Просмотреть файл

@ -91,9 +91,6 @@ outlinercol.threadColumnHeader[sortDirection="descending"] {
list-style-image: url("chrome://messenger/skin/icons/threadcol-threaded.gif");
}
/* message row icons */
outlinerbody:-moz-outliner-image(threadCol, container) {
list-style-image: url("chrome://messenger/skin/icons/thread-closed.gif");
}
@ -102,15 +99,20 @@ outlinerbody:-moz-outliner-image(threadCol, container, open) {
list-style-image: url("chrome://messenger/skin/icons/thread-open.gif");
}
outlinerbody:-moz-outliner-image(threadCol, container, unread) {
list-style-image: url("chrome://messenger/skin/icons/thread-new-closed.gif");
}
outlinerbody:-moz-outliner-image(threadCol, container, unread, open) {
list-style-image: url("chrome://messenger/skin/icons/thread-new-open.gif");
}
/* ..... read column ..... */
outlinercol.readColumnHeader {
list-style-image: url("chrome://messenger/skin/icons/readcol-unread.gif");
}
/* message row icons */
outlinerbody:-moz-outliner-image(unreadButtonColHeader) {
list-style-image: url("chrome://messenger/skin/icons/readcol-read.gif");
}
@ -125,12 +127,36 @@ outlinercol.flagColumnHeader {
list-style-image: url("chrome://messenger/skin/icons/flagcol-flagged.gif");
}
/* message row icons */
outlinerbody:-moz-outliner-image(flaggedCol) {
list-style-image: url("chrome://messenger/skin/icons/readcol-read.gif");
}
outlinerbody:-moz-outliner-image(flaggedCol, flagged) {
list-style-image: url("chrome://messenger/skin/icons/flagcol-flagged.gif");
}
}
/* ..... subject column ..... */
outlinerbody:-moz-outliner-image(subjectCol) {
list-style-image: url("chrome://messenger/skin/icons/message-mail.gif");
}
outlinerbody:-moz-outliner-image(subjectCol, unread) {
list-style-image: url("chrome://messenger/skin/icons/message-mail-new.gif");
}
outlinerbody:-moz-outliner-image(subjectCol, mail, imapdeleted) {
list-style-image: url("chrome://messenger/skin/icons/message-mail-imapdelete.gif");
}
outlinerbody:-moz-outliner-image(subjectCol, mail, attach) {
list-style-image: url("chrome://messenger/skin/icons/message-mail-attach.gif");
}
outlinerbody:-moz-outliner-image(subjectCol, news) {
list-style-image: url("chrome://messenger/skin/icons/message-news.gif");
}
outlinerbody:-moz-outliner-image(subjectCol, news, unread) {
list-style-image: url("chrome://messenger/skin/icons/message-news-new.gif");
}