add ability to persist view info r=naving, sr=sspitzer part of work for 12896

This commit is contained in:
bienvenu%netscape.com 2001-05-18 00:53:21 +00:00
Родитель 0dd9b26baa
Коммит a624232f79
14 изменённых файлов: 128 добавлений и 69 удалений

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

@ -29,13 +29,9 @@ interface nsIMessenger;
interface nsIMsgDBHdr;
interface nsIMsgDBViewCommandUpdater;
typedef long nsMsgViewSortOrderValue;
typedef long nsMsgViewSortTypeValue;
typedef long nsMsgViewTypeValue;
typedef long nsMsgViewNotificationCodeValue;
typedef long nsMsgViewCommandCheckStateValue;
typedef long nsMsgViewCommandTypeValue;
typedef long nsMsgViewFlagsTypeValue;
typedef long nsMsgNavigationTypeValue;
[scriptable, uuid(682a18be-fd18-11d4-a5be-0060b0fc04b7)]

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

@ -107,11 +107,24 @@ function ChangeFolderByDOMNode(folderNode)
dump(uri + "\n");
if (!uri) return;
var sortType = folderNode.getAttribute('sortType');
var sortOrder = folderNode.getAttribute('sortOrder');
var viewFlags = folderNode.getAttribute('viewFlags');
var viewType = folderNode.getAttribute('viewType');
var sortType = 0;
var sortOrder = 0;
var viewFlags = 0;
var viewType = 0;
var resource = RDF.GetResource(uri);
var msgfolder = resource.QueryInterface(Components.interfaces.nsIMsgFolder);
if (msgfolder)
{
var msgdb = msgfolder.getMsgDatabase(msgWindow);
if (msgdb)
{
var dbFolderInfo = msgdb.dBFolderInfo;
sortType = dbFolderInfo.sortType;
sortOrder = dbFolderInfo.sortOrder;
viewFlags = dbFolderInfo.viewFlags;
viewType = dbFolderInfo.viewType;
}
}
ChangeFolderByURI(uri, viewType, viewFlags, sortType, sortOrder);
}
@ -600,7 +613,6 @@ function CreateDBView(msgFolder, viewType, viewFlags, sortType, sortOrder)
gDBView.supressMsgDisplay = IsThreadAndMessagePaneSplitterCollapsed();
UpdateSortIndicators(gCurSortType, sortOrder);
PersistViewAttributesOnFolder();
}
function SetViewFlags(viewFlags)

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

@ -59,7 +59,7 @@
CanSubscribe="rdf:http://home.netscape.com/NC-rdf#CanSubscribe"
CanFileMessages="rdf:http://home.netscape.com/NC-rdf#CanFileMessages"
NoSelect="rdf:http://home.netscape.com/NC-rdf#NoSelect"
persist="open viewType viewFlags sortOrder sortType">
persist="open">
<treerow class="tree-folder-row"
IsServer="rdf:http://home.netscape.com/NC-rdf#IsServer"
HasUnreadMessages="rdf:http://home.netscape.com/NC-rdf#HasUnreadMessages"

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

@ -65,8 +65,7 @@ Contributors:
SpecialFolder="rdf:http://home.netscape.com/NC-rdf#SpecialFolder"
IsServer="rdf:http://home.netscape.com/NC-rdf#IsServer"
ServerType="rdf:http://home.netscape.com/NC-rdf#ServerType"
Synchronize="rdf:http://home.netscape.com/NC-rdf#Synchronize"
persist="viewType viewFlags sortOrder sortType">
Synchronize="rdf:http://home.netscape.com/NC-rdf#Synchronize">
<treerow class="tree-folder-row"
IsServer="rdf:http://home.netscape.com/NC-rdf#IsServer">

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

@ -102,18 +102,6 @@ function HandleColumnClick(columnID)
}
}
function PersistViewAttributesOnFolder()
{
var folder = GetSelectedFolder();
if (folder) {
folder.setAttribute("viewType", gDBView.viewType);
folder.setAttribute("viewFlags", gDBView.viewFlags);
folder.setAttribute("sortType", gDBView.sortType);
folder.setAttribute("sortOrder", gDBView.sortOrder);
}
}
function MsgComposeDraftMessage()
{
var loadedFolder = GetLoadedMsgFolder();
@ -215,7 +203,6 @@ function MsgSortThreadPane(sortType)
var dbview = GetDBView();
dbview.sort(sortType, nsMsgViewSortOrder.ascending);
UpdateSortIndicators(sortType, nsMsgViewSortOrder.ascending);
PersistViewAttributesOnFolder();
}
function MsgReverseSortThreadPane()
@ -234,7 +221,6 @@ function MsgSortAscending()
var dbview = GetDBView();
dbview.sort(dbview.sortType, nsMsgViewSortOrder.ascending);
UpdateSortIndicators(dbview.sortType, nsMsgViewSortOrder.ascending);
PersistViewAttributesOnFolder();
}
function MsgSortDescending()
@ -242,7 +228,6 @@ function MsgSortDescending()
var dbview = GetDBView();
dbview.sort(dbview.sortType, nsMsgViewSortOrder.descending);
UpdateSortIndicators(dbview.sortType, nsMsgViewSortOrder.descending);
PersistViewAttributesOnFolder();
}
function UpdateSortIndicators(sortType, sortOrder)

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

@ -1062,6 +1062,7 @@ NS_IMETHODIMP nsMsgDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTypeValue sor
m_viewFlags = viewFlags;
m_sortOrder = sortOrder;
m_sortType = sortType;
nsMsgViewTypeValue viewType;
if (folder) // search view will have a null folder
{
@ -1070,6 +1071,12 @@ NS_IMETHODIMP nsMsgDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTypeValue sor
NS_ENSURE_SUCCESS(rv,rv);
m_db->AddListener(this);
m_folder = folder;
// save off sort type and order, view type and flags
folderInfo->SetSortType(sortType);
folderInfo->SetSortOrder(sortOrder);
folderInfo->SetViewFlags(viewFlags);
GetViewType(&viewType);
folderInfo->SetViewType(viewType);
// 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
@ -2124,16 +2131,36 @@ nsMsgDBView::GetLocationCollationKey(nsIMsgHdr *msgHdr, PRUint8 **result, PRUint
return NS_OK;
}
nsresult nsMsgDBView::SaveSortInfo(nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder)
{
if (m_folder)
{
nsCOMPtr <nsIDBFolderInfo> folderInfo;
nsresult rv = m_folder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(m_db));
if (NS_SUCCEEDED(rv) && folderInfo)
{
// save off sort type and order, view type and flags
folderInfo->SetSortType(sortType);
folderInfo->SetSortOrder(sortOrder);
}
}
return NS_OK;
}
NS_IMETHODIMP nsMsgDBView::Sort(nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder)
{
nsresult rv;
if (m_sortType == sortType && m_sortValid) {
if (m_sortOrder == sortOrder) {
if (m_sortType == sortType && m_sortValid)
{
if (m_sortOrder == sortOrder)
{
// same as it ever was. do nothing
return NS_OK;
}
else {
else
{
SaveSortInfo(sortType, sortOrder);
if (m_sortType != nsMsgViewSortType::byThread) {
rv = ReverseSort();
NS_ENSURE_SUCCESS(rv,rv);

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

@ -168,6 +168,7 @@ protected:
nsresult ExpansionDelta(nsMsgViewIndex index, PRInt32 *expansionDelta);
nsresult ReverseSort();
nsresult ReverseThreads();
nsresult SaveSortInfo(nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder);
nsMsgKey GetAt(nsMsgViewIndex index) ;
nsMsgViewIndex FindViewIndex(nsMsgKey key)

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

@ -139,6 +139,7 @@ NS_IMETHODIMP nsMsgThreadedDBView::Sort(nsMsgViewSortTypeValue sortType, nsMsgVi
{
if (sortType == nsMsgViewSortType::byThread)
{
SaveSortInfo(sortType, sortOrder);
m_sortType = sortType;
m_viewFlags |= nsMsgViewFlagsType::kThreadedDisplay;
if ( m_havePrevView)
@ -150,7 +151,6 @@ NS_IMETHODIMP nsMsgThreadedDBView::Sort(nsMsgViewSortTypeValue sortType, nsMsgVi
m_flags.InsertAt(0, &m_prevFlags);
m_levels.RemoveAll();
m_levels.InsertAt(0, &m_prevLevels);
// m_messageDB->SetSortInfo(sortType, sortOrder);
m_sortValid = PR_TRUE;
// the sort may have changed the number of rows

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

@ -44,7 +44,7 @@ class nsMsgDatabase;
class nsDBFolderInfo : public nsIDBFolderInfo
{
public:
// friend class nsMsgDatabase;
friend class nsMsgDatabase;
nsDBFolderInfo(nsMsgDatabase *mdb);
virtual ~nsDBFolderInfo();
@ -61,11 +61,6 @@ public:
nsMsgKey GetLateredAt(PRInt32 laterIndex, PRTime pUntil);
void RemoveLateredAt(PRInt32 laterIndex);
void SetViewType(PRInt32 viewType);
PRInt32 GetViewType();
// we would like to just store the property name we're sorted by
void SetSortInfo(nsMsgSortType, nsMsgSortOrder);
void GetSortInfo(nsMsgSortType *, nsMsgSortOrder *);
PRBool TestFlag(PRInt32 flags);
PRInt16 GetIMAPHierarchySeparator() ;
void SetIMAPHierarchySeparator(PRInt16 hierarchySeparator) ;
@ -103,10 +98,9 @@ protected:
nsMsgKey m_lastMessageLoaded; // set by the FE's to remember the last loaded message
PRUint16 m_version; // for upgrading...
PRInt32 m_sortType; // the last sort type open on this db.
PRInt16 m_csid; // default csid for these messages
PRInt16 m_IMAPHierarchySeparator; // imap path separator
PRInt8 m_sortOrder; // the last sort order (up or down
// mail only (for now)
// IMAP only
@ -116,7 +110,6 @@ protected:
// news only (for now)
nsMsgKey m_expiredMark; // Highest invalid article number in group - for expiring
PRInt32 m_viewType; // for news, the last view type open on this db.
// the db folder info will have to know what db and row it belongs to, since it is really
// just a wrapper around the singleton folder info row in the mdb.
nsMsgDatabase *m_mdb;

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

@ -53,6 +53,12 @@ interface nsIDBFolderInfo : nsISupports {
attribute long ImapTotalPendingMessages;
attribute long ImapUnreadPendingMessages;
attribute wchar IMAPHierarchySeparator;
attribute nsMsgViewTypeValue viewType;
attribute nsMsgViewFlagsTypeValue viewFlags;
attribute nsMsgViewSortTypeValue sortType;
attribute nsMsgViewSortOrderValue sortOrder;
void ChangeExpungedBytes(in long delta);
void GetCharPtrProperty(in string propertyName, out string resultProperty);

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

@ -100,7 +100,7 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
// In 4.x, it was mainly used to remove corrupted databases.
void ForceClosed();
readonly attribute nsIDBFolderInfo DBFolderInfo;
readonly attribute nsIDBFolderInfo dBFolderInfo;
// get a message header for the given key. Caller must release()!

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

@ -28,6 +28,8 @@
#include "nsIPref.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsIMsgDBView.h"
static const char *kDBFolderInfoScope = "ns:msg:db:row:scope:dbfolderinfo:all";
static const char *kDBFolderInfoTableKind = "ns:msg:db:table:kind:dbfolderinfo";
@ -138,7 +140,6 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
: m_flags(0),
m_lastMessageLoaded(0),
m_expiredMark(0),
m_viewType(0),
m_numVisibleMessagesColumnToken(0),
m_expiredMarkColumnToken(0)
{
@ -146,10 +147,8 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
m_mdbTable = NULL;
m_mdbRow = NULL;
m_version = 1; // for upgrading...
m_sortType = 0; // the last sort type open on this db.
m_csid = 0; // default csid for these messages
m_IMAPHierarchySeparator = 0; // imap path separator
m_sortOrder = 0; // the last sort order (up or down
// mail only (for now)
m_folderSize = 0;
m_folderDate = 0;
@ -340,7 +339,6 @@ nsresult nsDBFolderInfo::InitMDBInfo()
store->StringToToken(env, kUnreadPendingMessagesColumnName, &m_unreadPendingMessagesColumnToken);
store->StringToToken(env, kExpiredMarkColumnName, &m_expiredMarkColumnToken);
store->StringToToken(env, kVersionColumnName, &m_versionColumnToken);
store->StringToToken(env, kNumVisibleMessagesColumnName, &m_numVisibleMessagesColumnToken);
m_mdbTokensInitialized = PR_TRUE;
}
return ret;
@ -484,24 +482,6 @@ NS_IMETHODIMP nsDBFolderInfo::GetMailboxName(nsString *boxName)
return GetPropertyWithToken(m_mailboxNameColumnToken, boxName);
}
void nsDBFolderInfo::SetViewType(PRInt32 viewType)
{
m_viewType = viewType;
}
PRInt32 nsDBFolderInfo::GetViewType()
{
return m_viewType;
}
void nsDBFolderInfo::SetSortInfo(nsMsgSortType type, nsMsgSortOrder order)
{
}
void nsDBFolderInfo::GetSortInfo(nsMsgSortType *type, nsMsgSortOrder *orde)
{
}
NS_IMETHODIMP nsDBFolderInfo::ChangeNumNewMessages(PRInt32 delta)
{
m_numNewMessages += delta;
@ -774,6 +754,59 @@ void nsDBFolderInfo::ChangeImapUnreadPendingMessages(PRInt32 delta)
SetInt32PropertyWithToken(m_unreadPendingMessagesColumnToken, m_unreadPendingMessages);
}
/* attribute nsMsgViewTypeValue viewType; */
NS_IMETHODIMP nsDBFolderInfo::GetViewType(nsMsgViewTypeValue *aViewType)
{
PRUint32 viewTypeValue;
nsresult rv = GetUint32Property("viewType", &viewTypeValue, nsMsgViewType::eShowAllThreads);
*aViewType = viewTypeValue;
return rv;
}
NS_IMETHODIMP nsDBFolderInfo::SetViewType(nsMsgViewTypeValue aViewType)
{
return SetUint32Property("viewType", aViewType);
}
/* attribute nsMsgViewFlagsTypeValue viewFlags; */
NS_IMETHODIMP nsDBFolderInfo::GetViewFlags(nsMsgViewFlagsTypeValue *aViewFlags)
{
PRUint32 viewFlagsValue;
nsresult rv = GetUint32Property("viewFlags", &viewFlagsValue, nsMsgViewFlagsType::kNone);
*aViewFlags = viewFlagsValue;
return rv;
}
NS_IMETHODIMP nsDBFolderInfo::SetViewFlags(nsMsgViewFlagsTypeValue aViewFlags)
{
return SetUint32Property("viewFlags", aViewFlags);
}
/* attribute nsMsgViewSortTypeValue sortType; */
NS_IMETHODIMP nsDBFolderInfo::GetSortType(nsMsgViewSortTypeValue *aSortType)
{
PRUint32 sortTypeValue;
nsresult rv = GetUint32Property("sortType", &sortTypeValue, nsMsgViewSortType::byDate);
*aSortType = sortTypeValue;
return rv;
}
NS_IMETHODIMP nsDBFolderInfo::SetSortType(nsMsgViewSortTypeValue aSortType)
{
return SetUint32Property("sortType", aSortType);
}
/* attribute nsMsgViewSortOrderValue sortOrder; */
NS_IMETHODIMP nsDBFolderInfo::GetSortOrder(nsMsgViewSortOrderValue *aSortOrder)
{
PRUint32 sortOrderValue;
nsresult rv = GetUint32Property("sortOrder", &sortOrderValue, nsMsgViewSortOrder::none);
*aSortOrder = sortOrderValue;
return rv;
}
NS_IMETHODIMP nsDBFolderInfo::SetSortOrder(nsMsgViewSortOrderValue aSortOrder)
{
return SetUint32Property("sortOrder", aSortOrder);
}
NS_IMETHODIMP nsDBFolderInfo::SetKnownArtsSet(nsString *newsArtSet)
{

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

@ -965,7 +965,9 @@ NS_IMETHODIMP nsMsgDatabase::ForceClosed()
NotifyAnnouncerGoingAway();
// OK, remove from cache first and close the store.
// RemoveFromCache(this);
// clear out db ptr in folder info; it's about to be invalid
if (m_dbFolderInfo)
m_dbFolderInfo->m_mdb = nsnull;
NS_IF_RELEASE(m_dbFolderInfo);
m_dbFolderInfo = nsnull;
@ -982,6 +984,7 @@ NS_IMETHODIMP nsMsgDatabase::ForceClosed()
if (m_mdbStore)
{
m_mdbStore->CloseMdbObject(m_mdbEnv);
m_mdbEnv = nsnull;
m_mdbStore = nsnull;
}
Release();
@ -991,11 +994,11 @@ NS_IMETHODIMP nsMsgDatabase::ForceClosed()
// caller must Release result.
NS_IMETHODIMP nsMsgDatabase::GetDBFolderInfo(nsIDBFolderInfo **result)
{
*result = m_dbFolderInfo;
if (m_dbFolderInfo)
*result = m_dbFolderInfo;
if (m_dbFolderInfo)
{
m_dbFolderInfo->AddRef();
return NS_OK;
m_dbFolderInfo->AddRef();
return NS_OK;
}
else
{

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

@ -37,3 +37,7 @@ interface nsMsgPriority {
const nsMsgPriorityValue highest = 6;
};
typedef long nsMsgViewSortOrderValue;
typedef long nsMsgViewSortTypeValue;
typedef long nsMsgViewTypeValue;
typedef long nsMsgViewFlagsTypeValue;