From b34f1a8b118d0f595a1dadaec05431d8ba8bce96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 28 Mar 2014 23:44:44 +0100 Subject: [PATCH] HaikuDepot: Refactored setting title and icon in listview... ... so that it is also done when a package state change notification is received that has the icon bit set. --- src/apps/haikudepot/PackageListView.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/apps/haikudepot/PackageListView.cpp b/src/apps/haikudepot/PackageListView.cpp index 9be0d83357..725bac23fc 100644 --- a/src/apps/haikudepot/PackageListView.cpp +++ b/src/apps/haikudepot/PackageListView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013, Stephan Aßmus . + * Copyright 2013-2014, Stephan Aßmus . * Copyright 2013, Rene Gollent, . * All rights reserved. Distributed under the terms of the MIT License. */ @@ -123,6 +123,7 @@ public: const PackageInfoRef& Package() const { return fPackage; } + void UpdateTitle(); void UpdateState(); void UpdateRating(); @@ -466,10 +467,7 @@ PackageRow::PackageRow(const PackageInfoRef& packageRef, // Package icon and title // NOTE: The icon BBitmap is referenced by the fPackage member. - const BBitmap* icon = NULL; - if (package.Icon().Get() != NULL) - icon = package.Icon()->Bitmap(SharedBitmap::SIZE_16); - SetField(new BBitmapStringField(icon, package.Title()), kTitleColumn); + UpdateTitle(); // Rating UpdateRating(); @@ -482,7 +480,6 @@ PackageRow::PackageRow(const PackageInfoRef& packageRef, SetField(new BStringField("0 KiB"), kSizeColumn); // Status - // TODO: Fetch info about installed/deactivated/uninstalled/... SetField(new BStringField(package_state_to_string(fPackage)), kStatusColumn); @@ -497,6 +494,19 @@ PackageRow::~PackageRow() } +void +PackageRow::UpdateTitle() +{ + if (fPackage.Get() == NULL) + return; + + const BBitmap* icon = NULL; + if (fPackage->Icon().Get() != NULL) + icon = fPackage->Icon()->Bitmap(SharedBitmap::SIZE_16); + SetField(new BBitmapStringField(icon, fPackage->Title()), kTitleColumn); +} + + void PackageRow::UpdateState() { @@ -670,6 +680,8 @@ PackageListView::MessageReceived(BMessage* message) row->UpdateRating(); if ((changes & PKG_CHANGED_STATE) != 0) row->UpdateState(); + if ((changes & PKG_CHANGED_ICON) != 0) + row->UpdateTitle(); } break; }