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.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013, Stephan Aßmus <[email protected]>.
|
* Copyright 2013-2014, Stephan Aßmus <[email protected]>.
|
||||||
* Copyright 2013, Rene Gollent, <[email protected]>.
|
* Copyright 2013, Rene Gollent, <[email protected]>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -123,6 +123,7 @@ public:
|
|||||||
const PackageInfoRef& Package() const
|
const PackageInfoRef& Package() const
|
||||||
{ return fPackage; }
|
{ return fPackage; }
|
||||||
|
|
||||||
|
void UpdateTitle();
|
||||||
void UpdateState();
|
void UpdateState();
|
||||||
void UpdateRating();
|
void UpdateRating();
|
||||||
|
|
||||||
@@ -466,10 +467,7 @@ PackageRow::PackageRow(const PackageInfoRef& packageRef,
|
|||||||
|
|
||||||
// Package icon and title
|
// Package icon and title
|
||||||
// NOTE: The icon BBitmap is referenced by the fPackage member.
|
// NOTE: The icon BBitmap is referenced by the fPackage member.
|
||||||
const BBitmap* icon = NULL;
|
UpdateTitle();
|
||||||
if (package.Icon().Get() != NULL)
|
|
||||||
icon = package.Icon()->Bitmap(SharedBitmap::SIZE_16);
|
|
||||||
SetField(new BBitmapStringField(icon, package.Title()), kTitleColumn);
|
|
||||||
|
|
||||||
// Rating
|
// Rating
|
||||||
UpdateRating();
|
UpdateRating();
|
||||||
@@ -482,7 +480,6 @@ PackageRow::PackageRow(const PackageInfoRef& packageRef,
|
|||||||
SetField(new BStringField("0 KiB"), kSizeColumn);
|
SetField(new BStringField("0 KiB"), kSizeColumn);
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
// TODO: Fetch info about installed/deactivated/uninstalled/...
|
|
||||||
SetField(new BStringField(package_state_to_string(fPackage)),
|
SetField(new BStringField(package_state_to_string(fPackage)),
|
||||||
kStatusColumn);
|
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
|
void
|
||||||
PackageRow::UpdateState()
|
PackageRow::UpdateState()
|
||||||
{
|
{
|
||||||
@@ -670,6 +680,8 @@ PackageListView::MessageReceived(BMessage* message)
|
|||||||
row->UpdateRating();
|
row->UpdateRating();
|
||||||
if ((changes & PKG_CHANGED_STATE) != 0)
|
if ((changes & PKG_CHANGED_STATE) != 0)
|
||||||
row->UpdateState();
|
row->UpdateState();
|
||||||
|
if ((changes & PKG_CHANGED_ICON) != 0)
|
||||||
|
row->UpdateTitle();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user