Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsAbView Class Reference

#include <nsAbView.h>

Inheritance diagram for nsAbView:
Inheritance graph
[legend]
Collaboration diagram for nsAbView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsAbView ()
virtual ~nsAbView ()
NS_DECL_ISUPPORTS
NS_DECL_NSIABVIEW
NS_DECL_NSITREEVIEW
NS_DECL_NSIABLISTENER
NS_DECL_NSIOBSERVER PRInt32 
CompareCollationKeys (PRUint8 *key1, PRUint32 len1, PRUint8 *key2, PRUint32 len2)
wstring init (in string URI, in boolean aSearchView, in nsIAbViewListener abViewListener, in wstring sortColumn, in wstring sortDirection)
 returns the actual sortColumn.
void close ()
void sortBy (in wstring sortColumn, in wstring sortDirection)
 sortBy does not optimize for the case when sortColumn and sortDirection is identical since the last call, the caller is responsible optimizing for that case
nsIAbCard getCardFromRow (in long row)
void selectAll ()
void deleteSelectedCards ()
void swapFirstNameLastName ()
void getRowProperties (in long index, in nsISupportsArray properties)
 An atomized list of properties for a given row.
void getCellProperties (in long row, in nsITreeColumn col, in nsISupportsArray properties)
 An atomized list of properties for a given cell.
void getColumnProperties (in nsITreeColumn col, in nsISupportsArray properties)
 Called to get properties to paint a column background.
boolean isContainer (in long index)
 Methods that can be used to test whether or not a twisty should be drawn, and if so, whether an open or closed twisty should be used.
boolean isContainerOpen (in long index)
boolean isContainerEmpty (in long index)
boolean isSeparator (in long index)
 isSeparator is used to determine if the row at index is a separator.
boolean isSorted ()
 Specifies if there is currently a sort on any column.
boolean canDrop (in long index, in long orientation)
 Methods used by the drag feedback code to determine if a drag is allowable at the current location.
void drop (in long row, in long orientation)
 Called when the user drops something on this view.
long getParentIndex (in long rowIndex)
 Methods used by the tree to draw thread lines in the tree.
boolean hasNextSibling (in long rowIndex, in long afterIndex)
 hasNextSibling is used to determine if the row at rowIndex has a nextSibling that occurs after the index specified by afterIndex.
long getLevel (in long index)
 The level is an integer value that represents the level of indentation.
AString getImageSrc (in long row, in nsITreeColumn col)
 The image path for a given cell.
long getProgressMode (in long row, in nsITreeColumn col)
AString getCellValue (in long row, in nsITreeColumn col)
 The value for a given cell.
AString getCellText (in long row, in nsITreeColumn col)
 The text for a given cell.
void setTree (in nsITreeBoxObject tree)
 Called during initialization to link the view to the front end box object.
void toggleOpenState (in long index)
 Called on the view when an item is opened or closed.
void cycleHeader (in nsITreeColumn col)
 Called on the view when a header is clicked.
void selectionChanged ()
 Should be called from a XUL onselect handler whenever the selection changes.
void cycleCell (in long row, in nsITreeColumn col)
 Called on the view when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.
boolean isEditable (in long row, in nsITreeColumn col)
 isEditable is called to ask the view if the cell contents are editable.
void setCellValue (in long row, in nsITreeColumn col, in AString value)
 setCellValue is called when the value of the cell has been set by the user.
void setCellText (in long row, in nsITreeColumn col, in AString value)
 setCellText is called when the contents of the cell have been edited by the user.
void performAction (in wstring action)
 A command API that can be used to invoke commands on the selection.
void performActionOnRow (in wstring action, in long row)
 A command API that can be used to invoke commands on a specific row.
void performActionOnCell (in wstring action, in long row, in nsITreeColumn col)
 A command API that can be used to invoke commands on a specific cell.
void onItemAdded (in nsISupports parentDir, in nsISupports item)
 Called when an address book item (book, card or list) is added.
void onItemRemoved (in nsISupports parentDir, in nsISupports item)
 Called when an address book, mailing list or card is removed.
void onItemPropertyChanged (in nsISupports item, in string property, in wstring oldValue, in wstring newValue)
 Called when an address book item is changed.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

readonly attribute string URI
readonly attribute AString sortColumn
readonly attribute AString sortDirection
readonly attribute nsIAbDirectory directory
readonly attribute nsISupportsArray selectedAddresses
readonly attribute long rowCount
 The total number of rows in the tree (including the offscreen rows).
attribute nsITreeSelection selection
 The selection for this view.
const short DROP_BEFORE = -1
const short DROP_ON = 0
const short DROP_AFTER = 1
const short PROGRESS_NORMAL = 1
 The progress mode for a given cell.
const short PROGRESS_UNDETERMINED = 2
const short PROGRESS_NONE = 3

Private Member Functions

PRInt32 FindIndexForInsert (AbCard *abcard)
PRInt32 FindIndexForCard (nsIAbCard *card)
nsresult GenerateCollationKeysForCard (const PRUnichar *colID, AbCard *abcard)
nsresult InvalidateTree (PRInt32 row)
nsresult RemoveCardAt (PRInt32 row)
nsresult AddCard (AbCard *abcard, PRBool selectCardAfterAdding, PRInt32 *index)
nsresult RemoveCardAndSelectNextCard (nsISupports *item)
nsresult EnumerateCards ()
nsresult AddPrefObservers ()
nsresult RemovePrefObservers ()
nsresult SetGeneratedNameFormatFromPrefs ()
nsresult GetSelectedCards (nsISupportsArray **cards)
nsresult ReselectCards (nsISupportsArray *cards, nsIAbCard *indexCard)
nsresult GetCardValue (nsIAbCard *card, const PRUnichar *colID, PRUnichar **_retval)
nsresult RefreshTree ()

Private Attributes

nsCOMPtr< nsITreeBoxObjectmTree
nsCOMPtr< nsITreeSelectionmTreeSelection
nsCString mURI
nsCOMPtr< nsIAbDirectorymDirectory
nsVoidArray mCards
nsCOMPtr< nsIAtommMailListAtom
nsString mSortColumn
nsString mSortDirection
nsCOMPtr< nsICollationmCollationKeyGenerator
nsCOMPtr< nsIAbViewListenermAbViewListener
PRPackedBool mSearchView
PRPackedBool mSuppressSelectionChange
PRPackedBool mSuppressCountChange
PRInt32 mGeneratedNameFormat

Detailed Description

Definition at line 66 of file nsAbView.h.


Constructor & Destructor Documentation

Definition at line 78 of file nsAbView.cpp.

Here is the call graph for this function:

nsAbView::~nsAbView ( ) [virtual]

Definition at line 87 of file nsAbView.cpp.

{
  if (mDirectory) {
    nsresult rv;
    rv = Close();
    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to close view");
  }
}

Member Function Documentation

nsresult nsAbView::AddCard ( AbCard abcard,
PRBool  selectCardAfterAdding,
PRInt32 index 
) [private]

Definition at line 851 of file nsAbView.cpp.

{
  nsresult rv = NS_OK;
  NS_ENSURE_ARG_POINTER(abcard);
  
  *index = FindIndexForInsert(abcard);
  rv = mCards.InsertElementAt((void *)abcard, *index);
  NS_ENSURE_SUCCESS(rv,rv);
    
  // this needs to happen after we insert the card, as RowCountChanged() will call GetRowCount()
  if (mTree)
    rv = mTree->RowCountChanged(*index, 1);

  if (selectCardAfterAdding && mTreeSelection) {
    mTreeSelection->SetCurrentIndex(*index);
    mTreeSelection->RangedSelect(*index, *index, PR_FALSE /* augment */);
  }

  if (mAbViewListener && !mSuppressCountChange) {
    rv = mAbViewListener->OnCountChanged(mCards.Count());
    NS_ENSURE_SUCCESS(rv,rv);
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 167 of file nsAbView.cpp.

Here is the call graph for this function:

boolean nsITreeView::canDrop ( in long  index,
in long  orientation 
) [inherited]

Methods used by the drag feedback code to determine if a drag is allowable at the current location.

To get the behavior where drops are only allowed on items, such as the mailNews folder pane, always return false when the orientation is not DROP_ON.

void nsIAbView::close ( ) [inherited]
PRInt32 nsAbView::CompareCollationKeys ( PRUint8 key1,
PRUint32  len1,
PRUint8 key2,
PRUint32  len2 
)

Definition at line 747 of file nsAbView.cpp.

{
  NS_ASSERTION(mCollationKeyGenerator, "no key generator");
  if (!mCollationKeyGenerator)
    return 0;

  PRInt32 result;

  nsresult rv = mCollationKeyGenerator->CompareRawSortKey(key1,len1,key2,len2,&result);
  NS_ASSERTION(NS_SUCCEEDED(rv), "key compare failed");
  if (NS_FAILED(rv))
    result = 0;
  return result;
}

Here is the caller graph for this function:

void nsITreeView::cycleCell ( in long  row,
in nsITreeColumn  col 
) [inherited]

Called on the view when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.

Called on the view when a header is clicked.

void nsITreeView::drop ( in long  row,
in long  orientation 
) [inherited]

Called when the user drops something on this view.

The |orientation| param specifies before/on/after the given |row|.

Definition at line 283 of file nsAbView.cpp.

{
  nsresult rv;    
  nsCOMPtr<nsIEnumerator> cardsEnumerator;
  nsCOMPtr<nsIAbCard> card;

  if (!mDirectory)
    return NS_ERROR_UNEXPECTED;

  rv = mDirectory->GetChildCards(getter_AddRefs(cardsEnumerator));
  if (NS_SUCCEEDED(rv) && cardsEnumerator)
  {
    nsCOMPtr<nsISupports> item;
    for (rv = cardsEnumerator->First(); NS_SUCCEEDED(rv); rv = cardsEnumerator->Next())
    {
      rv = cardsEnumerator->CurrentItem(getter_AddRefs(item));
      if (NS_SUCCEEDED(rv))
      {
        nsCOMPtr <nsIAbCard> card = do_QueryInterface(item);
        // malloc these from an arena
        AbCard *abcard = (AbCard *) PR_Calloc(1, sizeof(struct AbCard));
        if (!abcard) 
          return NS_ERROR_OUT_OF_MEMORY;

        abcard->card = card;
        NS_IF_ADDREF(abcard->card);

        // XXX todo
        // would it be better to do an insertion sort, than append and sort?
        // XXX todo
        // if we knew how many cards there was going to be
        // we could allocate an array of the size, 
        // instead of growing and copying as we append
        rv = mCards.AppendElement((void *)abcard);
        NS_ASSERTION(NS_SUCCEEDED(rv), "failed to append card");
      }
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 949 of file nsAbView.cpp.

{
  PRInt32 count = mCards.Count();
  PRInt32 i;
 
  // you can't implement the binary search here, as all you have is the nsIAbCard
  // you might be here because one of the card properties has changed, and that property
  // could be the collation key.
  for (i=0; i < count; i++) {
    AbCard *abcard = (AbCard*) (mCards.ElementAt(i));
    PRBool equals;
    nsresult rv = card->Equals(abcard->card, &equals);
    if (NS_SUCCEEDED(rv) && equals) {
      return i;
    }
  }
  return CARD_NOT_FOUND;
}

Here is the caller graph for this function:

PRInt32 nsAbView::FindIndexForInsert ( AbCard abcard) [private]

Definition at line 877 of file nsAbView.cpp.

{
  PRInt32 count = mCards.Count();
  PRInt32 i;

  void *item = (void *)abcard;
  
  SortClosure closure;
  SetSortClosure(mSortColumn.get(), mSortDirection.get(), this, &closure);
  
  // XXX todo
  // make this a binary search
  for (i=0; i < count; i++) {
    void *current = mCards.ElementAt(i);
    PRInt32 value = inplaceSortCallback(item, current, (void *)(&closure));
    // XXX fix me, this is not right for both ascending and descending
    if (value <= 0) 
      break;
  }
  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsAbView::GenerateCollationKeysForCard ( const PRUnichar colID,
AbCard abcard 
) [private]

Definition at line 762 of file nsAbView.cpp.

{
  nsresult rv;
  nsXPIDLString value;

  if (!mCollationKeyGenerator)
  {
    nsCOMPtr<nsILocaleService> localeSvc = do_GetService(NS_LOCALESERVICE_CONTRACTID,&rv); 
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsILocale> locale; 
    rv = localeSvc->GetApplicationLocale(getter_AddRefs(locale));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr <nsICollationFactory> factory = do_CreateInstance(kCollationFactoryCID, &rv); 
    NS_ENSURE_SUCCESS(rv, rv);

    rv = factory->CreateCollation(locale, getter_AddRefs(mCollationKeyGenerator));
    NS_ENSURE_SUCCESS(rv, rv);
  }

  rv = GetCardValue(abcard->card, colID, getter_Copies(value));
  NS_ENSURE_SUCCESS(rv,rv);
  
  PR_FREEIF(abcard->primaryCollationKey);
  rv = mCollationKeyGenerator->AllocateRawSortKey(nsICollation::kCollationCaseInSensitive,
    value, &(abcard->primaryCollationKey), &(abcard->primaryCollationKeyLen));
  NS_ENSURE_SUCCESS(rv,rv);
  
  // XXX todo
  // fix me, do this with a const getter, to avoid the strcpy

  // hardcode email to be our secondary key
  rv = GetCardValue(abcard->card, NS_LITERAL_STRING(kPriEmailColumn).get(), getter_Copies(value));
  NS_ENSURE_SUCCESS(rv,rv);
  
  PR_FREEIF(abcard->secondaryCollationKey);
  rv = mCollationKeyGenerator->AllocateRawSortKey(nsICollation::kCollationCaseInSensitive,
    value, &(abcard->secondaryCollationKey), &(abcard->secondaryCollationKeyLen));
  NS_ENSURE_SUCCESS(rv,rv);
  return rv;
}

Here is the call graph for this function:

nsresult nsAbView::GetCardValue ( nsIAbCard card,
const PRUnichar colID,
PRUnichar **  _retval 
) [private]

Definition at line 449 of file nsAbView.cpp.

{
  nsresult rv;

  // "G" == "GeneratedName", "_P" == "_PhoneticName"
  // else, standard column (like PrimaryEmail and _AimScreenName)
  if ((colID[0] == PRUnichar('G')) ||
      (colID[0] == PRUnichar('_') && colID[1] == PRUnichar('P'))) {
    // XXX todo 
    // cache the ab session?
    nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv,rv);
    
    if (colID[0] == PRUnichar('G'))
      rv = abSession->GenerateNameFromCard(card, mGeneratedNameFormat, _retval);
    else
      // use LN/FN order for the phonetic name
      rv = abSession->GeneratePhoneticNameFromCard(card, PR_TRUE, _retval);
    NS_ENSURE_SUCCESS(rv,rv);
  }
  else {
      rv = card->GetCardValue(NS_LossyConvertUCS2toASCII(colID).get(), _retval);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsITreeView::getCellProperties ( in long  row,
in nsITreeColumn  col,
in nsISupportsArray  properties 
) [inherited]

An atomized list of properties for a given cell.

Each property, x, that the view gives back will cause the pseudoclass :moz-tree-cell-x to be matched on the ::moz-tree-cell pseudoelement.

AString nsITreeView::getCellText ( in long  row,
in nsITreeColumn  col 
) [inherited]

The text for a given cell.

If a column consists only of an image, then the empty string is returned.

AString nsITreeView::getCellValue ( in long  row,
in nsITreeColumn  col 
) [inherited]

The value for a given cell.

This method is only called for columns of type other than |text|.

Called to get properties to paint a column background.

For shading the sort column, etc.

AString nsITreeView::getImageSrc ( in long  row,
in nsITreeColumn  col 
) [inherited]

The image path for a given cell.

For defining an icon for a cell. If the empty string is returned, the :moz-tree-image pseudoelement will be used.

long nsITreeView::getLevel ( in long  index) [inherited]

The level is an integer value that represents the level of indentation.

It is multiplied by the width specified in the :moz-tree-indentation pseudoelement to compute the exact indendation.

long nsITreeView::getParentIndex ( in long  rowIndex) [inherited]

Methods used by the tree to draw thread lines in the tree.

getParentIndex is used to obtain the index of a parent row. If there is no parent row, getParentIndex returns -1.

long nsITreeView::getProgressMode ( in long  row,
in nsITreeColumn  col 
) [inherited]
void nsITreeView::getRowProperties ( in long  index,
in nsISupportsArray  properties 
) [inherited]

An atomized list of properties for a given row.

Each property, x, that the view gives back will cause the pseudoclass :moz-tree-row-x to be matched on the pseudoelement ::moz-tree-row.

Definition at line 1114 of file nsAbView.cpp.

{
  *selectedCards = nsnull;
  if (!mTreeSelection)
    return NS_OK;
  
  PRInt32 selectionCount; 
  nsresult rv = mTreeSelection->GetRangeCount(&selectionCount);
  NS_ENSURE_SUCCESS(rv,rv);
  
  if (!selectionCount)
    return NS_OK;
  
  rv = NS_NewISupportsArray(selectedCards);
  NS_ENSURE_SUCCESS(rv,rv);
  
  for (PRInt32 i = 0; i < selectionCount; i++)
  {
    PRInt32 startRange;
    PRInt32 endRange;
    rv = mTreeSelection->GetRangeAt(i, &startRange, &endRange);
    NS_ENSURE_SUCCESS(rv, NS_OK); 
    PRInt32 totalCards = mCards.Count();
    if (startRange >= 0 && startRange < totalCards)
    {
      for (PRInt32 rangeIndex = startRange; rangeIndex <= endRange && rangeIndex < totalCards; rangeIndex++) {
        nsCOMPtr<nsIAbCard> abCard;
        rv = GetCardFromRow(rangeIndex, getter_AddRefs(abCard));
        NS_ENSURE_SUCCESS(rv,rv);
        
        nsCOMPtr<nsISupports> supports = do_QueryInterface(abCard, &rv);
        NS_ENSURE_SUCCESS(rv,rv);
        
        rv = (*selectedCards)->AppendElement(supports);
        NS_ENSURE_SUCCESS(rv,rv);
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

boolean nsITreeView::hasNextSibling ( in long  rowIndex,
in long  afterIndex 
) [inherited]

hasNextSibling is used to determine if the row at rowIndex has a nextSibling that occurs after the index specified by afterIndex.

Code that is forced to march down the view looking at levels can optimize the march by starting at afterIndex+1.

wstring nsIAbView::init ( in string  URI,
in boolean  aSearchView,
in nsIAbViewListener  abViewListener,
in wstring  sortColumn,
in wstring  sortDirection 
) [inherited]

returns the actual sortColumn.

migration, switching from mozilla to netscape 6.x, etc, could cause the "persisted" sortColumn to be bogus.

Definition at line 537 of file nsAbView.cpp.

{
  if (!mTree)
    return NS_OK;
  
  if (row == ALL_ROWS)
    return mTree->Invalidate();
  else
    return mTree->InvalidateRow(row);
}

Here is the caller graph for this function:

boolean nsITreeView::isContainer ( in long  index) [inherited]

Methods that can be used to test whether or not a twisty should be drawn, and if so, whether an open or closed twisty should be used.

Here is the caller graph for this function:

boolean nsITreeView::isContainerEmpty ( in long  index) [inherited]
boolean nsITreeView::isContainerOpen ( in long  index) [inherited]
boolean nsITreeView::isEditable ( in long  row,
in nsITreeColumn  col 
) [inherited]

isEditable is called to ask the view if the cell contents are editable.

A value of true will result in the tree popping up a text field when the user tries to inline edit the cell.

boolean nsITreeView::isSeparator ( in long  index) [inherited]

isSeparator is used to determine if the row at index is a separator.

A value of true will result in the tree drawing a horizontal separator. The tree uses the ::moz-tree-separator pseudoclass to draw the separator.

boolean nsITreeView::isSorted ( ) [inherited]

Specifies if there is currently a sort on any column.

Used mostly by dragdrop to affect drop feedback.

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
void nsIAbListener::onItemAdded ( in nsISupports  parentDir,
in nsISupports  item 
) [inherited]

Called when an address book item (book, card or list) is added.

Parameters:
parentDirThe parent of the item being added.
itemThe item being added to the database (a directory or card).
void nsIAbListener::onItemPropertyChanged ( in nsISupports  item,
in string  property,
in wstring  oldValue,
in wstring  newValue 
) [inherited]

Called when an address book item is changed.

Note the current implementation means that property is either the literal string "DirName" or null, with oldValue and newValue being specified if the property is "DirName" otherwise they are null.

Parameters:
itemThe item being updated (a directory or a card).
propertyThe property of the item being changed.
oldValueThe old value of the item property being changed if it is known, null otherwise.
newValueThe new value of the item property being changed.
void nsIAbListener::onItemRemoved ( in nsISupports  parentDir,
in nsISupports  item 
) [inherited]

Called when an address book, mailing list or card is removed.

This is partially configurable when setting up the listener via nsIAddrBookSession

Parameters:
parentDirThe parent of the item being removed, this may be an empty directory in the case of a top level address book.
itemThe item being removed from the database.
void nsITreeView::performAction ( in wstring  action) [inherited]

A command API that can be used to invoke commands on the selection.

The tree will automatically invoke this method when certain keys are pressed. For example, when the DEL key is pressed, performAction will be called with the "delete" string.

void nsITreeView::performActionOnCell ( in wstring  action,
in long  row,
in nsITreeColumn  col 
) [inherited]

A command API that can be used to invoke commands on a specific cell.

void nsITreeView::performActionOnRow ( in wstring  action,
in long  row 
) [inherited]

A command API that can be used to invoke commands on a specific row.

Definition at line 475 of file nsAbView.cpp.

{
  nsresult 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.
  // the same applies for kPhoneticNameColumn 
  //
  // XXX optimize me
  // PrimaryEmail is always the secondary sort, unless it is currently the
  // primary sort.  So, if PrimaryEmail is the primary sort, 
  // GeneratedName might be the secondary sort.
  //
  // one day, we can get fancy and remember what the secondary sort is.
  // 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 GeneratedName (or kPhoneticNameColumn), 
  // all we have to do is invalidate (to show the new GeneratedNames), 
  // but the sort will not change.
  if (mSortColumn.EqualsLiteral(GENERATED_NAME_COLUMN_ID) ||
      mSortColumn.EqualsLiteral(kPriEmailColumn) ||
      mSortColumn.EqualsLiteral(kPhoneticNameColumn)) {
    rv = SortBy(mSortColumn.get(), mSortDirection.get());
  }
  else {
    rv = InvalidateTree(ALL_ROWS);
  }

  return rv;
}

Here is the call graph for this function:

nsresult nsAbView::RemoveCardAndSelectNextCard ( nsISupports *  item) [private]

Definition at line 913 of file nsAbView.cpp.

{
  nsresult rv = NS_OK;
  nsCOMPtr <nsIAbCard> card = do_QueryInterface(item);
  if (card) {
    PRInt32 index = FindIndexForCard(card);
    if (index != CARD_NOT_FOUND) {
      PRBool selectNextCard = PR_FALSE;
      if (mTreeSelection) {
        PRInt32 selectedIndex;
        // XXX todo
        // make sure it works if nothing selected
        mTreeSelection->GetCurrentIndex(&selectedIndex);
        if (index == selectedIndex)
          selectNextCard = PR_TRUE;
      }

      rv = RemoveCardAt(index);
      NS_ENSURE_SUCCESS(rv,rv);

      if (selectNextCard) {
      PRInt32 count = mCards.Count();
      if (count && mTreeSelection) {
        // if we deleted the last card, adjust so we select the new "last" card
        if (index >= (count - 1)) {
          index = count -1;
        }
        mTreeSelection->SetCurrentIndex(index);
        mTreeSelection->RangedSelect(index, index, PR_FALSE /* augment */);
      }
    }
  }
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 125 of file nsAbView.cpp.

{
  nsresult rv;

  AbCard *abcard = (AbCard*) (mCards.ElementAt(row));
  NS_IF_RELEASE(abcard->card);
  mCards.RemoveElementAt(row);
  PR_FREEIF(abcard->primaryCollationKey);
  PR_FREEIF(abcard->secondaryCollationKey);
  PR_FREEIF(abcard);

  
  // this needs to happen after we remove the card, as RowCountChanged() will call GetRowCount()
  if (mTree) {
    rv = mTree->RowCountChanged(row, -1);
    NS_ENSURE_SUCCESS(rv,rv);
  }

  if (mAbViewListener && !mSuppressCountChange) {
    rv = mAbViewListener->OnCountChanged(mCards.Count());
    NS_ENSURE_SUCCESS(rv,rv);
  }
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 178 of file nsAbView.cpp.

Here is the call graph for this function:

nsresult nsAbView::ReselectCards ( nsISupportsArray cards,
nsIAbCard indexCard 
) [private]

Definition at line 1059 of file nsAbView.cpp.

{
  PRUint32 count;
  PRUint32 i;

  if (!mTreeSelection || !cards)
    return NS_OK;

  nsresult rv = mTreeSelection->ClearSelection();
  NS_ENSURE_SUCCESS(rv,rv);

  rv = cards->Count(&count);
  NS_ENSURE_SUCCESS(rv, rv);

  for (i = 0; i < count; i++) {
    nsCOMPtr <nsIAbCard> card = do_QueryElementAt(cards, i);
    if (card) {
      PRInt32 index = FindIndexForCard(card);
      if (index != CARD_NOT_FOUND) {
        mTreeSelection->RangedSelect(index, index, PR_TRUE /* augment */);
      }
    }
  }

  // reset the index card, and ensure it is visible
  if (indexCard) {
    PRInt32 currentIndex = FindIndexForCard(indexCard);
    rv = mTreeSelection->SetCurrentIndex(currentIndex);
    NS_ENSURE_SUCCESS(rv, rv);
  
    if (mTree) {
      rv = mTree->EnsureRowIsVisible(currentIndex);
      NS_ENSURE_SUCCESS(rv, rv);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

void nsIAbView::selectAll ( ) [inherited]

Should be called from a XUL onselect handler whenever the selection changes.

void nsITreeView::setCellText ( in long  row,
in nsITreeColumn  col,
in AString  value 
) [inherited]

setCellText is called when the contents of the cell have been edited by the user.

void nsITreeView::setCellValue ( in long  row,
in nsITreeColumn  col,
in AString  value 
) [inherited]

setCellValue is called when the value of the cell has been set by the user.

This method is only called for columns of type other than |text|.

Definition at line 156 of file nsAbView.cpp.

Here is the call graph for this function:

Called during initialization to link the view to the front end box object.

void nsIAbView::sortBy ( in wstring  sortColumn,
in wstring  sortDirection 
) [inherited]

sortBy does not optimize for the case when sortColumn and sortDirection is identical since the last call, the caller is responsible optimizing for that case

void nsITreeView::toggleOpenState ( in long  index) [inherited]

Called on the view when an item is opened or closed.


Member Data Documentation

Definition at line 71 of file nsIAbView.idl.

const short nsITreeView::DROP_AFTER = 1 [inherited]

Definition at line 103 of file nsITreeView.idl.

const short nsITreeView::DROP_BEFORE = -1 [inherited]

Definition at line 101 of file nsITreeView.idl.

const short nsITreeView::DROP_ON = 0 [inherited]

Definition at line 102 of file nsITreeView.idl.

Definition at line 106 of file nsAbView.h.

Definition at line 101 of file nsAbView.h.

Definition at line 105 of file nsAbView.h.

Definition at line 100 of file nsAbView.h.

Definition at line 111 of file nsAbView.h.

Definition at line 102 of file nsAbView.h.

Definition at line 108 of file nsAbView.h.

Definition at line 103 of file nsAbView.h.

Definition at line 104 of file nsAbView.h.

Definition at line 110 of file nsAbView.h.

Definition at line 109 of file nsAbView.h.

Definition at line 81 of file nsAbView.h.

Definition at line 82 of file nsAbView.h.

Definition at line 99 of file nsAbView.h.

const short nsITreeView::PROGRESS_NONE = 3 [inherited]

Definition at line 153 of file nsITreeView.idl.

const short nsITreeView::PROGRESS_NORMAL = 1 [inherited]

The progress mode for a given cell.

This method is only called for columns of type |progressmeter|.

Definition at line 151 of file nsITreeView.idl.

Definition at line 152 of file nsITreeView.idl.

readonly attribute long nsITreeView::rowCount [inherited]

The total number of rows in the tree (including the offscreen rows).

Definition at line 53 of file nsITreeView.idl.

Definition at line 77 of file nsIAbView.idl.

The selection for this view.

Definition at line 58 of file nsITreeView.idl.

readonly attribute AString nsIAbView::sortColumn [inherited]

Definition at line 69 of file nsIAbView.idl.

readonly attribute AString nsIAbView::sortDirection [inherited]

Definition at line 70 of file nsIAbView.idl.

readonly attribute string nsIAbView::URI [inherited]

Definition at line 68 of file nsIAbView.idl.


The documentation for this class was generated from the following files: