HaikuDepot: Fixed selecting the right package when the list is sorted.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Autolock.h>
|
||||
#include <Application.h>
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
@@ -87,14 +88,22 @@ MainWindow::MessageReceived(BMessage* message)
|
||||
switch (message->what) {
|
||||
case B_SIMPLE_DATA:
|
||||
case B_REFS_RECEIVED:
|
||||
// TODO: ?
|
||||
break;
|
||||
|
||||
case MSG_PACKAGE_SELECTED:
|
||||
{
|
||||
int32 index;
|
||||
if (message->FindInt32("index", &index) == B_OK
|
||||
&& index >= 0 && index < fVisiblePackages.CountItems()) {
|
||||
_AdoptPackage(fVisiblePackages.ItemAtFast(index));
|
||||
BString title;
|
||||
if (message->FindString("title", &title) == B_OK) {
|
||||
int count = fVisiblePackages.CountItems();
|
||||
for (int i = 0; i < count; i++) {
|
||||
const PackageInfoRef& package
|
||||
= fVisiblePackages.ItemAtFast(i);
|
||||
if (package.Get() != NULL && package->Title() == title) {
|
||||
_AdoptPackage(package);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_ClearPackage();
|
||||
}
|
||||
|
||||
@@ -544,14 +544,9 @@ PackageListView::SelectionChanged()
|
||||
|
||||
BMessage message(MSG_PACKAGE_SELECTED);
|
||||
|
||||
BRow* selected = CurrentSelection();
|
||||
|
||||
// TODO: Wrong index, its the visible one (i.e. sorted)!
|
||||
// Solve by putting an ID for the package in the message instead.
|
||||
int32 index = -1;
|
||||
PackageRow* selected = dynamic_cast<PackageRow*>(CurrentSelection());
|
||||
if (selected != NULL)
|
||||
index = IndexOf(selected);
|
||||
message.AddInt32("index", index);
|
||||
message.AddString("title", selected->Package()->Title());
|
||||
|
||||
Window()->PostMessage(&message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user