HaikuDepot: add repository column in package list view

* As requested in #12538

* Hidden by default to not clutter up the view with information that
  isn't important in the default setup. Like the state of other
  columns, the visibility is remembered.
This commit is contained in:
Julian Harnath 2017-11-20 20:45:17 +01:00
parent 546065592d
commit d90412cb8f
3 changed files with 29 additions and 2 deletions

View File

@ -935,7 +935,10 @@ PackageInfo::SetSize(int64 size)
void
PackageInfo::SetDepotName(const BString& depotName)
{
fDepotName = depotName;
if (fDepotName != depotName) {
fDepotName = depotName;
_NotifyListeners(PKG_CHANGED_DEPOT);
}
}

View File

@ -20,7 +20,8 @@ enum {
PKG_CHANGED_CHANGELOG = 1 << 7,
PKG_CHANGED_CATEGORIES = 1 << 8,
PKG_CHANGED_PROMINENCE = 1 << 9,
PKG_CHANGED_SIZE = 1 << 10
PKG_CHANGED_SIZE = 1 << 10,
PKG_CHANGED_DEPOT = 1 << 11
// ...
};

View File

@ -1,4 +1,5 @@
/*
* Copyright 2017, Julian Harnath, <julian.harnath@rwth-aachen.de>.
* Copyright 2015, Axel Dörfler, <axeld@pinc-software.de>.
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2013, Rene Gollent, <rene@gollent.com>.
@ -149,6 +150,7 @@ public:
void UpdateState();
void UpdateRating();
void UpdateSize();
void UpdateRepository();
private:
PackageInfoRef fPackage;
@ -523,6 +525,7 @@ enum {
kDescriptionColumn,
kSizeColumn,
kStatusColumn,
kRepositoryColumn
};
@ -554,6 +557,9 @@ PackageRow::PackageRow(const PackageInfoRef& packageRef,
// Status
UpdateState();
// Repository
UpdateRepository();
package.AddListener(fPackageListener);
}
@ -618,6 +624,16 @@ PackageRow::UpdateSize()
}
void
PackageRow::UpdateRepository()
{
if (fPackage.Get() == NULL)
return;
SetField(new BStringField(fPackage->DepotName()), kRepositoryColumn);
}
// #pragma mark - ItemCountView
@ -728,6 +744,11 @@ PackageListView::PackageListView(BLocker* modelLock)
spacing + StringWidth(B_TRANSLATE("Available")), 60 * scale,
140 * scale, B_TRUNCATE_END), kStatusColumn);
AddColumn(new PackageColumn(B_TRANSLATE("Repository"), 120 * scale,
50 * scale, 200 * scale, B_TRUNCATE_MIDDLE), kRepositoryColumn);
SetColumnVisible(kRepositoryColumn, false);
// invisible by default
fItemCountView = new ItemCountView();
AddStatusView(fItemCountView);
}
@ -787,6 +808,8 @@ PackageListView::MessageReceived(BMessage* message)
row->UpdateSize();
if ((changes & PKG_CHANGED_ICON) != 0)
row->UpdateTitle();
if ((changes & PKG_CHANGED_DEPOT) != 0)
row->UpdateRepository();
}
break;
}