mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-31 19:10:36 +00:00
more work for converting AB results pane to outliner.
bug #73868. not part of the build
This commit is contained in:
parent
21ea678b01
commit
f8e88066a6
@ -38,8 +38,11 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIAbCard;
|
||||
|
||||
[scriptable, uuid(e35c015c-1dd1-11b2-9494-f88326252aae)]
|
||||
interface nsIAbView : nsISupports
|
||||
{
|
||||
void init(in string uri);
|
||||
void init(in string aURI);
|
||||
nsIAbCard getCardFromRow(in long row);
|
||||
};
|
||||
|
@ -23,7 +23,51 @@
|
||||
|
||||
function AbResultsPaneOnClick(event)
|
||||
{
|
||||
dump("XXX onclick\n");
|
||||
// we only care about button 0 (left click) events
|
||||
if (event.button != 0) return;
|
||||
|
||||
// all we need to worry about here is double clicks
|
||||
// and column header.
|
||||
//
|
||||
// we get in here for clicks on the "outlinercol" (headers)
|
||||
// and the "scrollbarbutton" (scrollbar buttons)
|
||||
// we don't want those events to cause a "double click"
|
||||
|
||||
var t = event.originalTarget;
|
||||
|
||||
if (t.localName == "outlinercol") {
|
||||
AbResultsPaneColumnClick(t.id);
|
||||
}
|
||||
else if (t.localName == "outlinerbody") {
|
||||
var row = new Object;
|
||||
var colID = new Object;
|
||||
var childElt = new Object;
|
||||
|
||||
var outliner = GetAbResultsOutliner();
|
||||
// figure out what cell the click was in
|
||||
outliner.boxObject.QueryInterface(Components.interfaces.nsIOutlinerBoxObject).getCellAt(event.clientX, event.clientY, row, colID, childElt);
|
||||
|
||||
if (event.detail == 2) {
|
||||
AbResultsPaneDoubleClick(row.value);
|
||||
}
|
||||
else {
|
||||
var card = gAbView.getCardFromRow(row.value);
|
||||
DisplayCardViewPane(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AbResultsPaneColumnClick(col)
|
||||
{
|
||||
dump("XXX click on col " + col + "\n");
|
||||
}
|
||||
|
||||
function AbResultsPaneDoubleClick(row)
|
||||
{
|
||||
dump("XXX double click on row " + row + "\n");
|
||||
var card = gAbView.getCardFromRow(row);
|
||||
|
||||
AbEditCard(card);
|
||||
}
|
||||
|
||||
function AbResultsPaneKeyPress(event)
|
||||
|
@ -22,12 +22,11 @@ Original Author:
|
||||
Seth Spitzer <sspitzer@netscape.com>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<?xml-stylesheet href="chrome://messenger/skin/addressbook/abResultPane.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/addressbook/abResultsPane.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/abResultsPaneOverlay.dtd">
|
||||
|
||||
-->
|
||||
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
|
||||
|
||||
<overlay
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
@ -37,15 +36,43 @@ Original Author:
|
||||
<outliner id="abResultsOutliner" flex="1" enableColumnDrag="true"
|
||||
onkeypress="AbResultsPaneKeyPress(event);">
|
||||
|
||||
<outlinercol id="nameCol" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator" persist="hidden ordinal width" flex="1" label="nameXXX" primary="true"/>
|
||||
<!-- 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"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="workPhoneCol" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator" persist="hidden ordinal width" flex="1" label="emailXXX"/>
|
||||
<outlinercol id="WorkPhone" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&WorkPhone.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="emailCol" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator" persist="hidden ordinal width" flex="1" label="workXXX"/>
|
||||
<outlinercol id="PrimaryEmail" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&PrimaryEmail.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="organizationCol" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator" persist="hidden ordinal width" flex="1" label="orgXXX"/>
|
||||
<outlinercol id="Company" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&Company.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
|
||||
<outlinercol id="NickName" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&NickName.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="HomePhone" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&HomePhone.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="FaxNumber" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&FaxNumber.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="PagerNumber" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&PagerNumber.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="CellularNumber" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&CellularNumber.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="SecondEmail" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&SecondEmail.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="JobTitle" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&JobTitle.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<outlinercol id="Department" class="outlinercol-header outlinercol-inset-header sortDirectionIndicator"
|
||||
persist="hidden ordinal width" flex="1" label="&Department.label;"/>
|
||||
|
||||
<outlinerbody flex="1"
|
||||
onselect="this.parentNode.outlinerBoxObject.view.selectionChanged();"
|
||||
ondraggesture="return BeginDragAbResultsPane(event);"/>
|
||||
|
@ -1,4 +1,12 @@
|
||||
<!ENTITY nameCol.label "Name">
|
||||
<!ENTITY emailCol.label "Email">
|
||||
<!ENTITY workPhoneCol.label "Phone">
|
||||
<!ENTITY organizationCol.label "Company">
|
||||
<!ENTITY DisplayName.label "Name">
|
||||
<!ENTITY PrimaryEmail.label "Email">
|
||||
<!ENTITY Company.label "Organization">
|
||||
<!ENTITY NickName.label "Nick Name">
|
||||
<!ENTITY SecondEmail.label "Additional Email">
|
||||
<!ENTITY Department.label "Department">
|
||||
<!ENTITY JobTitle.label "Title">
|
||||
<!ENTITY CellularNumber.label "Cellular">
|
||||
<!ENTITY PagerNumber.label "Pager">
|
||||
<!ENTITY FaxNumber.label "Fax">
|
||||
<!ENTITY HomePhone.label "Work Phone">
|
||||
<!ENTITY WorkPhone.label "Home Phone">
|
||||
|
@ -55,6 +55,8 @@ NS_INTERFACE_MAP_END
|
||||
nsAbView::nsAbView()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
mMailListAtom = getter_AddRefs(NS_NewAtom("MailList"));
|
||||
}
|
||||
|
||||
|
||||
@ -62,17 +64,17 @@ nsAbView::~nsAbView()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbView::Init(const char *uri)
|
||||
NS_IMETHODIMP nsAbView::Init(const char *aURI)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
mURI = uri;
|
||||
mURI = aURI;
|
||||
|
||||
nsCOMPtr <nsIRDFService> rdfService = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr <nsIRDFResource> resource;
|
||||
rv = rdfService->GetResource(uri, getter_AddRefs(resource));
|
||||
rv = rdfService->GetResource(aURI, getter_AddRefs(resource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(resource, &rv);
|
||||
@ -137,7 +139,22 @@ NS_IMETHODIMP nsAbView::GetRowProperties(PRInt32 index, nsISupportsArray *proper
|
||||
|
||||
NS_IMETHODIMP nsAbView::GetCellProperties(PRInt32 row, const PRUnichar *colID, nsISupportsArray *properties)
|
||||
{
|
||||
// this is only for the DisplayName column (ignore Department)
|
||||
if (colID[0] != 'D' || colID[1] != 'i')
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIAbCard> card = do_QueryInterface(cards->ElementAt(row), &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRBool isMailList = PR_FALSE;
|
||||
rv = card->GetIsMailList(&isMailList);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (isMailList)
|
||||
properties->AppendElement(mMailListAtom);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbView::GetColumnProperties(const PRUnichar *colID, nsIDOMElement *colElt, nsISupportsArray *properties)
|
||||
@ -211,23 +228,8 @@ NS_IMETHODIMP nsAbView::GetCellText(PRInt32 row, const PRUnichar *colID, PRUnich
|
||||
nsCOMPtr <nsIAbCard> card = do_QueryInterface(cards->ElementAt(row), &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
switch (colID[0]) {
|
||||
case 'e':
|
||||
rv = card->GetPrimaryEmail(_retval);
|
||||
break;
|
||||
case 'n':
|
||||
rv = card->GetDisplayName(_retval);
|
||||
break;
|
||||
case 'w':
|
||||
rv = card->GetWorkPhone(_retval);
|
||||
break;
|
||||
case 'o':
|
||||
rv = card->GetCompany(_retval);
|
||||
break;
|
||||
default:
|
||||
*_retval = nsnull;
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
rv = card->GetCardUnicharValue(colID, _retval);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -282,3 +284,15 @@ NS_IMETHODIMP nsAbView::PerformActionOnCell(const PRUnichar *action, PRInt32 row
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbView::GetCardFromRow(PRInt32 row, nsIAbCard **aCard)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr <nsIAbCard> card = do_QueryInterface(cards->ElementAt(row), &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
*aCard = card;
|
||||
NS_IF_ADDREF(*aCard);
|
||||
return NS_OK;
|
||||
}
|
@ -47,6 +47,7 @@
|
||||
#include "nsString.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIAbDirectory.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
class nsAbView : public nsIAbView, public nsIOutlinerView
|
||||
{
|
||||
@ -65,6 +66,7 @@ private:
|
||||
nsresult EnumerateCards(nsIAbDirectory* directory);
|
||||
nsCString mURI;
|
||||
nsCOMPtr<nsISupportsArray> cards;
|
||||
nsCOMPtr<nsIAtom> mMailListAtom;
|
||||
};
|
||||
|
||||
#endif /* _nsAbView_H_ */
|
||||
|
@ -23,12 +23,12 @@
|
||||
|
||||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
|
||||
outlinerbody:-moz-outliner-image(nameCol) {
|
||||
outlinerbody:-moz-outliner-image(DisplayName) {
|
||||
padding-right: 2px;
|
||||
list-style-image: url("chrome://messenger/skin/addressbook/icons/person.gif");
|
||||
}
|
||||
|
||||
outlinerbody:-moz-outliner-image(nameCol, mailList) {
|
||||
outlinerbody:-moz-outliner-image(DisplayName, MailList) {
|
||||
padding-right: 2px;
|
||||
list-style-image: url("chrome://messenger/skin/addressbook/icons/list.gif");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user