mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-13 18:27:35 +00:00
more work on #73868. converting ab from tree to outliner.
restore selection after sorting. NOT PART OF THE BUILD.
This commit is contained in:
parent
7c514e0bd3
commit
a5c16ce813
@ -609,7 +609,29 @@ NS_IMETHODIMP nsAbView::SortBy(const PRUnichar *colID, const PRUnichar *sortDir)
|
||||
SortClosure closure;
|
||||
SetSortClosure(sortColumn.get(), sortDirection.get(), this, &closure);
|
||||
|
||||
nsCOMPtr <nsISupportsArray> selectedCards;
|
||||
rv = GetSelectedCards(getter_AddRefs(selectedCards));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIAbCard> indexCard;
|
||||
|
||||
if (mOutlinerSelection) {
|
||||
PRInt32 currentIndex = -1;
|
||||
|
||||
rv = mOutlinerSelection->GetCurrentIndex(¤tIndex);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (currentIndex != -1) {
|
||||
rv = GetCardFromRow(currentIndex, getter_AddRefs(indexCard));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
}
|
||||
|
||||
mCards.Sort(inplaceSortCallback, (void *)(&closure));
|
||||
|
||||
rv = ReselectCards(selectedCards, indexCard);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
mSortColumn = sortColumn.get();
|
||||
mSortDirection = sortDirection.get();
|
||||
}
|
||||
@ -966,19 +988,76 @@ NS_IMETHODIMP nsAbView::GetSortColumn(PRUnichar **column)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbView::ReselectCards(nsISupportsArray *cards, nsIAbCard *indexCard)
|
||||
{
|
||||
PRUint32 count;
|
||||
PRUint32 i;
|
||||
|
||||
if (!mOutlinerSelection)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = mOutlinerSelection->ClearSelection();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = cards->Count(&count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsISupports> cardSupports;
|
||||
cardSupports = getter_AddRefs(cards->ElementAt(i));
|
||||
nsCOMPtr <nsIAbCard> card = do_QueryInterface(cardSupports);
|
||||
if (card) {
|
||||
PRInt32 index = FindIndexForCard(card);
|
||||
if (index != CARD_NOT_FOUND) {
|
||||
mOutlinerSelection->RangedSelect(index, index, PR_TRUE /* augment */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reset the index card, and ensure it is visible
|
||||
if (indexCard) {
|
||||
PRInt32 currentIndex = FindIndexForCard(indexCard);
|
||||
rv = mOutlinerSelection->SetCurrentIndex(currentIndex);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mOutliner) {
|
||||
rv = mOutliner->EnsureRowIsVisible(currentIndex);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbView::DeleteSelectedCards()
|
||||
{
|
||||
if (mOutlinerSelection)
|
||||
{
|
||||
nsCOMPtr <nsISupportsArray> cardsToDelete;
|
||||
|
||||
nsresult rv = GetSelectedCards(getter_AddRefs(cardsToDelete));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = mDirectory->DeleteCards(cardsToDelete);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbView::GetSelectedCards(nsISupportsArray **selectedCards)
|
||||
{
|
||||
*selectedCards = nsnull;
|
||||
if (!mOutlinerSelection)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = NS_NewISupportsArray(selectedCards);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRInt32 selectionCount;
|
||||
nsresult rv = mOutlinerSelection->GetRangeCount(&selectionCount);
|
||||
rv = mOutlinerSelection->GetRangeCount(&selectionCount);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (!selectionCount)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr <nsISupportsArray> cardsToDelete;
|
||||
NS_NewISupportsArray(getter_AddRefs(cardsToDelete));
|
||||
NS_NewISupportsArray(selectedCards);
|
||||
|
||||
for (PRInt32 i = 0; i < selectionCount; i++)
|
||||
{
|
||||
@ -997,14 +1076,10 @@ NS_IMETHODIMP nsAbView::DeleteSelectedCards()
|
||||
nsCOMPtr<nsISupports> supports = do_QueryInterface(abCard, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = cardsToDelete->AppendElement(supports);
|
||||
rv = (*selectedCards)->AppendElement(supports);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rv = mDirectory->DeleteCards(cardsToDelete);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
@ -91,6 +91,8 @@ private:
|
||||
nsresult AddPrefObservers();
|
||||
nsresult RemovePrefObservers();
|
||||
nsresult SetGeneratedNameFormatFromPrefs();
|
||||
nsresult GetSelectedCards(nsISupportsArray **cards);
|
||||
nsresult ReselectCards(nsISupportsArray *cards, nsIAbCard *indexCard);
|
||||
|
||||
nsCString mURI;
|
||||
nsCOMPtr <nsIAbDirectory> mDirectory;
|
||||
|
Loading…
Reference in New Issue
Block a user