HaikuDepot: Fixed selecting the right package when the list is sorted.

This commit is contained in:
Stephan Aßmus
2013-09-16 22:18:22 +02:00
parent b0fbddbd03
commit bb4c532b77
2 changed files with 15 additions and 11 deletions
+13 -4
View File
@@ -8,6 +8,7 @@
#include <stdio.h> #include <stdio.h>
#include <Alert.h> #include <Alert.h>
#include <Autolock.h>
#include <Application.h> #include <Application.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h> #include <Catalog.h>
@@ -87,14 +88,22 @@ MainWindow::MessageReceived(BMessage* message)
switch (message->what) { switch (message->what) {
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
case B_REFS_RECEIVED: case B_REFS_RECEIVED:
// TODO: ?
break; break;
case MSG_PACKAGE_SELECTED: case MSG_PACKAGE_SELECTED:
{ {
int32 index; BString title;
if (message->FindInt32("index", &index) == B_OK if (message->FindString("title", &title) == B_OK) {
&& index >= 0 && index < fVisiblePackages.CountItems()) { int count = fVisiblePackages.CountItems();
_AdoptPackage(fVisiblePackages.ItemAtFast(index)); for (int i = 0; i < count; i++) {
const PackageInfoRef& package
= fVisiblePackages.ItemAtFast(i);
if (package.Get() != NULL && package->Title() == title) {
_AdoptPackage(package);
break;
}
}
} else { } else {
_ClearPackage(); _ClearPackage();
} }
+2 -7
View File
@@ -544,14 +544,9 @@ PackageListView::SelectionChanged()
BMessage message(MSG_PACKAGE_SELECTED); BMessage message(MSG_PACKAGE_SELECTED);
BRow* selected = CurrentSelection(); PackageRow* selected = dynamic_cast<PackageRow*>(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;
if (selected != NULL) if (selected != NULL)
index = IndexOf(selected); message.AddString("title", selected->Package()->Title());
message.AddInt32("index", index);
Window()->PostMessage(&message); Window()->PostMessage(&message);
} }