* BOutlineListView::SortItemsUnder() and FullListSortItems() does not behave

as described in the BeBook when oneLevelOnly is false - only
  BListView::SortItems() does ignore the hierarchy. So the work-arounds for
  this are completely unnecessary. Removed now unused compare_list_items().
* The BOutlineListView sorting methods have a different comparison signature
  as the other comparison functions: they point to the items directly. The
  compare_typed_list_items() function did not take this into account, and
  dereferenced them anyway, leading to #5883.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36587 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2010-05-02 18:00:20 +00:00
parent 533d9a5f85
commit 7b63fd1c11

View File

@ -35,20 +35,12 @@
#define TR_CONTEXT "Locale Preflet Window"
static int
compare_list_items(const void* _a, const void* _b)
{
LanguageListItem* a = *(LanguageListItem**)_a;
LanguageListItem* b = *(LanguageListItem**)_b;
return strcasecmp(a->Text(), b->Text());
}
static int
compare_typed_list_items(const BListItem* _a, const BListItem* _b)
{
LanguageListItem* a = *(LanguageListItem**)_a;
LanguageListItem* b = *(LanguageListItem**)_b;
// TODO: sort them using collators.
LanguageListItem* a = (LanguageListItem*)_a;
LanguageListItem* b = (LanguageListItem*)_b;
return strcasecmp(a->Text(), b->Text());
}
@ -87,16 +79,14 @@ LocaleWindow::LocaleWindow()
// Fill the language list from the LocaleRoster data
BMessage installedLanguages;
if (be_locale_roster->GetInstalledLanguages(&installedLanguages)
== B_OK) {
if (be_locale_roster->GetInstalledLanguages(&installedLanguages) == B_OK) {
BString currentLanguageCode;
BString currentLanguageName;
LanguageListItem* lastAddedItem = NULL;
LanguageListItem* lastAddedCountryItem = NULL;
for (int i = 0; installedLanguages.FindString("langs",
i, &currentLanguageCode) == B_OK; i++) {
// Now get an human-readable, localized name for each language
// TODO: sort them using collators.
BLanguage* currentLanguage;
be_locale_roster->GetLanguage(&currentLanguage,
currentLanguageCode.String());
@ -107,26 +97,18 @@ LocaleWindow::LocaleWindow()
LanguageListItem* item = new LanguageListItem(currentLanguageName,
currentLanguageCode.String());
if (currentLanguage->IsCountry()) {
fLanguageListView->AddUnder(item, lastAddedItem);
fLanguageListView->AddUnder(item, lastAddedCountryItem);
} else {
// This is a language without country, add it at top-level
fLanguageListView->AddItem(item);
item->SetExpanded(false);
if (lastAddedItem != NULL) {
fLanguageListView->SortItemsUnder(lastAddedItem, true,
compare_typed_list_items);
}
lastAddedItem = item;
lastAddedCountryItem = item;
}
delete currentLanguage;
}
fLanguageListView->SortItemsUnder(lastAddedItem, true,
compare_typed_list_items);
fLanguageListView->SortItems(compare_list_items);
// see previous comment on sort using collators
fLanguageListView->FullListSortItems(compare_typed_list_items);
} else {
BAlert* myAlert = new BAlert("Error",
TR("Unable to find the available languages! You can't use this "
@ -271,7 +253,7 @@ LocaleWindow::MessageReceived(BMessage* message)
}
index++;
}
fLanguageListView->SortItems(compare_list_items);
fLanguageListView->FullListSortItems(compare_typed_list_items);
be_app_messenger.SendMessage(&update);
break;
}
@ -320,8 +302,7 @@ LocaleWindow::MessageReceived(BMessage* message)
LanguageListItem* listItem = static_cast<LanguageListItem*>
(fPreferredListView->RemoveItem(index));
fLanguageListView->AddItem(listItem);
fLanguageListView->SortItems(compare_list_items);
// see previous comment on sort using collators
fLanguageListView->FullListSortItems(compare_typed_list_items);
fPreferredListView->Invoke(fMsgPrefLanguagesChanged);
}
break;