more work on #73868. converting ab from tree to outliner. NOT PART OF THE BUILD.

This commit is contained in:
sspitzer%netscape.com 2001-11-15 00:28:12 +00:00
Родитель cca3f3c832
Коммит 620ecc1d4f
7 изменённых файлов: 58 добавлений и 98 удалений

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

@ -36,9 +36,9 @@ Original Author:
<outliner id="abResultsOutliner" flex="1" enableColumnDrag="true"
onkeypress="AbResultsPaneKeyPress(event);">
<!-- these column ids must match up to the mork column names, see nsIAddrDatabase.idl -->
<outlinercol id="DisplayName" class="outlinercol-header outlinercell-inset-header sortDirectionIndicator"
persist="hidden ordinal width" flex="1" label="&DisplayName.label;" primary="true"/>
<!-- these column ids must match up to the mork column names, except for GeneratedName, see nsIAddrDatabase.idl -->
<outlinercol id="GeneratedName" class="outlinercol-header outlinercell-inset-header sortDirectionIndicator"
persist="hidden ordinal width" flex="1" label="&GeneratedName.label;" primary="true"/>
<splitter class="tree-splitter"/>
<outlinercol id="WorkPhone" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
persist="hidden ordinal width" flex="1" label="&WorkPhone.label;"/>

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

@ -21,8 +21,8 @@ Original Author:
Seth Spitzer <sspitzer@netscape.com>
-->
<!ENTITY DisplayName.label "Name">
<!ENTITY DisplayName.accesskey "N">
<!ENTITY GeneratedName.label "Name">
<!ENTITY GeneratedName.accesskey "N">
<!ENTITY PrimaryEmail.label "Email">
<!ENTITY PrimaryEmail.accesskey "E">
<!ENTITY Company.label "Organization">

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

@ -53,14 +53,13 @@
#include "nsIPrefBranch.h"
#include "nsIPrefBranchInternal.h"
#define CARD_NOT_FOUND -1
#define ALL_ROWS -1
#define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST "mail.addr_book.lastnamefirst"
// also, our default primary sort
#define DISPLAY_NAME_COLUMN_ID "DisplayName"
#define GENERATED_NAME_COLUMN_ID "GeneratedName"
// also, our default secondary sort
#define PRIMARY_EMAIL_COLUMN_ID "PrimaryEmail"
@ -84,6 +83,7 @@ nsAbView::nsAbView()
mMailListAtom = getter_AddRefs(NS_NewAtom("MailList"));
mSuppressSelectionChange = PR_FALSE;
mSuppressCountChange = PR_FALSE;
mGeneratedNameFormat = 0;
}
nsAbView::~nsAbView()
@ -142,6 +142,21 @@ NS_IMETHODIMP nsAbView::GetURI(char **aURI)
return NS_OK;
}
nsresult nsAbView::SetGeneratedNameFormatFromPrefs()
{
nsresult rv;
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
NS_ENSURE_SUCCESS(rv,rv);
rv = prefBranch->GetIntPref(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST, &mGeneratedNameFormat);
NS_ENSURE_SUCCESS(rv, rv);
return rv;
}
nsresult nsAbView::AddPrefObservers()
{
nsresult rv;
@ -158,8 +173,7 @@ nsresult nsAbView::AddPrefObservers()
rv = pbi->AddObserver(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST, this, PR_FALSE);
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
return rv;
}
nsresult nsAbView::RemovePrefObservers()
@ -178,8 +192,7 @@ nsresult nsAbView::RemovePrefObservers()
rv = pbi->RemoveObserver(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST, this);
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
return rv;
}
NS_IMETHODIMP nsAbView::Init(const char *aURI, nsIAbViewListener *abViewListener,
@ -193,6 +206,9 @@ NS_IMETHODIMP nsAbView::Init(const char *aURI, nsIAbViewListener *abViewListener
rv = AddPrefObservers();
NS_ENSURE_SUCCESS(rv,rv);
rv = SetGeneratedNameFormatFromPrefs();
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIRDFService> rdfService = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -214,7 +230,7 @@ NS_IMETHODIMP nsAbView::Init(const char *aURI, nsIAbViewListener *abViewListener
rv = abSession->AddAddressBookListener(this);
NS_ENSURE_SUCCESS(rv,rv);
if (mAbViewListener && !mSuppressCountChange) {
rv = mAbViewListener->OnCountChanged(mCards.Count());
NS_ENSURE_SUCCESS(rv,rv);
@ -297,8 +313,8 @@ NS_IMETHODIMP nsAbView::GetCellProperties(PRInt32 row, const PRUnichar *colID, n
if (mCards.Count() <= row)
return NS_OK;
// "Di" to distinguish "DisplayName" from "Department"
if (colID[0] != 'D' || colID[1] != 'i')
// "G" == "GeneratedName"
if (colID[0] != 'G')
return NS_OK;
nsIAbCard *card = ((AbCard *)(mCards.ElementAt(row)))->card;
@ -381,9 +397,15 @@ NS_IMETHODIMP nsAbView::GetCellText(PRInt32 row, const PRUnichar *colID, PRUnich
{
nsIAbCard *card = ((AbCard *)(mCards.ElementAt(row)))->card;
nsresult rv = card->GetCardUnicharValue(colID, _retval);
NS_ENSURE_SUCCESS(rv,rv);
nsresult rv;
// "G" == "GeneratedName"
if (colID[0] == 'G')
rv = card->GetGeneratedName(mGeneratedNameFormat, _retval);
else
rv = card->GetCardUnicharValue(colID, _retval);
NS_ENSURE_SUCCESS(rv,rv);
return rv;
}
@ -515,7 +537,7 @@ NS_IMETHODIMP nsAbView::SortBy(const PRUnichar *colID, const PRUnichar *sortDir)
nsAutoString sortColumn;
if (!colID)
sortColumn = NS_LITERAL_STRING(DISPLAY_NAME_COLUMN_ID); // default sort
sortColumn = NS_LITERAL_STRING(GENERATED_NAME_COLUMN_ID); // default sort
else
sortColumn = colID;
@ -578,10 +600,13 @@ nsresult nsAbView::GenerateCollationKeysForCard(const PRUnichar *colID, AbCard *
nsresult rv;
nsXPIDLString value;
// XXX fix me, do this with const to avoid the strcpy
rv = abcard->card->GetCardUnicharValue(colID, getter_Copies(value));
if (colID[0] == 'G') // "G" == "GeneratedName"
rv = abcard->card->GetGeneratedName(mGeneratedNameFormat, getter_Copies(value));
else
rv = abcard->card->GetCardUnicharValue(colID, getter_Copies(value));
NS_ENSURE_SUCCESS(rv,rv);
// XXX be smarter about the key, from an arena
// XXX be smarter about the allocation
PR_FREEIF(abcard->primaryCollationKey);
rv = CreateCollationKey(value, &(abcard->primaryCollationKey));
NS_ENSURE_SUCCESS(rv,rv);
@ -590,7 +615,7 @@ nsresult nsAbView::GenerateCollationKeysForCard(const PRUnichar *colID, AbCard *
rv = abcard->card->GetCardUnicharValue(NS_LITERAL_STRING(PRIMARY_EMAIL_COLUMN_ID).get(), getter_Copies(value));
NS_ENSURE_SUCCESS(rv,rv);
// XXX be smarter about the key, from an arena
// XXX be smarter about the allocation
PR_FREEIF(abcard->secondaryCollationKey);
rv = CreateCollationKey(value, &(abcard->secondaryCollationKey));
NS_ENSURE_SUCCESS(rv,rv);
@ -679,21 +704,24 @@ NS_IMETHODIMP nsAbView::Observe(nsISupports *aSubject, const char *aTopic, const
nsDependentString prefName(someData);
if (prefName.Equals(NS_LITERAL_STRING(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST))) {
// the PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST pref affects how the DisplayName column looks.
// so if the DisplayName is our primary or secondary sort,
rv = SetGeneratedNameFormatFromPrefs();
NS_ENSURE_SUCCESS(rv,rv);
// the PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST pref affects how the GeneratedName column looks.
// so if the GeneratedName is our primary or secondary sort,
// we need to resort.
//
// XXX optimize me
// PrimaryEmail is always the secondary sort, unless it is currently the
// primary sort. So, if PrimaryEmail is the primary sort,
// DisplayName might be the secondary sort.
// GeneratedName might be the secondary sort.
//
// one day, we can get fancy and remember what the secondary sort is.
// we we do that, we can fix this code. at best, it will turn a sort into a invalidate.
//
// if neither the primary nor the secondary sorts are DisplayName, all we have to do is
// invalidate (to show the new DisplayNames), but the sort will not change.
if (!nsCRT::strcmp(mSortColumn.get(), NS_LITERAL_STRING(DISPLAY_NAME_COLUMN_ID).get()) ||
// if neither the primary nor the secondary sorts are GeneratedName, all we have to do is
// invalidate (to show the new GeneratedNames), but the sort will not change.
if (!nsCRT::strcmp(mSortColumn.get(), NS_LITERAL_STRING(GENERATED_NAME_COLUMN_ID).get()) ||
!nsCRT::strcmp(mSortColumn.get(), NS_LITERAL_STRING(PRIMARY_EMAIL_COLUMN_ID).get())) {
rv = SortBy(mSortColumn.get(), mSortDirection.get());
}

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

@ -86,6 +86,7 @@ private:
nsresult EnumerateCards();
nsresult AddPrefObservers();
nsresult RemovePrefObservers();
nsresult SetGeneratedNameFormatFromPrefs();
nsCString mURI;
nsCOMPtr <nsIAbDirectory> mDirectory;
@ -98,6 +99,7 @@ private:
PRPackedBool mSuppressSelectionChange;
PRPackedBool mSuppressCountChange;
PRInt32 mGeneratedNameFormat;
};
#endif /* _nsAbView_H_ */

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

@ -1,35 +0,0 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author:
* Seth Spitzer <sspitzer@netscape.com>
*/
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
outlinerbody:-moz-outliner-image(DisplayName) {
padding-right: 2px;
list-style-image: url("chrome://messenger/skin/abcard.gif");
}
outlinerbody:-moz-outliner-image(DisplayName, MailList) {
padding-right: 2px;
list-style-image: url("chrome://messenger/skin/addressbook/list.gif");
}

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

@ -1,35 +0,0 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author:
* Seth Spitzer <sspitzer@netscape.com>
*/
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
outlinerbody:-moz-outliner-image(DisplayName) {
padding-right: 2px;
list-style-image: url("chrome://messenger/skin/abcard.gif");
}
outlinerbody:-moz-outliner-image(DisplayName, MailList) {
padding-right: 2px;
list-style-image: url("chrome://messenger/skin/addressbook/list.gif");
}

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

@ -23,12 +23,12 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
outlinerbody:-moz-outliner-image(DisplayName) {
outlinerbody:-moz-outliner-image(GeneratedName) {
padding-right: 2px;
list-style-image: url("chrome://messenger/skin/addressbook/icons/person.gif");
}
outlinerbody:-moz-outliner-image(DisplayName, MailList) {
outlinerbody:-moz-outliner-image(GeneratedName, MailList) {
padding-right: 2px;
list-style-image: url("chrome://messenger/skin/addressbook/icons/list.gif");
}