HaikuDepot: Show installation state in list view.
- Add package installation state to PackageInfo and update accordingly in Model. - Add package listener event for installation state change (not yet used). - PackageListView now fetches installation state from package and displays accordingly.
This commit is contained in:
parent
50792d1199
commit
b4c8d2ff49
@ -323,6 +323,8 @@ Model::SetPackageState(const PackageInfoRef& package, PackageState state)
|
||||
fUninstalledPackages.Add(package);
|
||||
break;
|
||||
}
|
||||
|
||||
package->SetState(state);
|
||||
}
|
||||
|
||||
|
||||
|
@ -445,7 +445,8 @@ PackageInfo::PackageInfo()
|
||||
fFullDescription(),
|
||||
fChangelog(),
|
||||
fUserRatings(),
|
||||
fScreenshots()
|
||||
fScreenshots(),
|
||||
fState(NONE)
|
||||
{
|
||||
}
|
||||
|
||||
@ -464,7 +465,8 @@ PackageInfo::PackageInfo(const BitmapRef& icon, const BString& title,
|
||||
fChangelog(changelog),
|
||||
fCategories(),
|
||||
fUserRatings(),
|
||||
fScreenshots()
|
||||
fScreenshots(),
|
||||
fState(NONE)
|
||||
{
|
||||
}
|
||||
|
||||
@ -480,7 +482,8 @@ PackageInfo::PackageInfo(const PackageInfo& other)
|
||||
fChangelog(other.fChangelog),
|
||||
fCategories(other.fCategories),
|
||||
fUserRatings(other.fUserRatings),
|
||||
fScreenshots(other.fScreenshots)
|
||||
fScreenshots(other.fScreenshots),
|
||||
fState(other.fState)
|
||||
{
|
||||
}
|
||||
|
||||
@ -498,6 +501,7 @@ PackageInfo::operator=(const PackageInfo& other)
|
||||
fCategories = other.fCategories;
|
||||
fUserRatings = other.fUserRatings;
|
||||
fScreenshots = other.fScreenshots;
|
||||
fState = other.fState;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -532,6 +536,14 @@ PackageInfo::AddCategory(const CategoryRef& category)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageInfo::SetState(PackageState state)
|
||||
{
|
||||
fState = state;
|
||||
_NotifyListeners(PKG_CHANGED_STATE);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageInfo::AddUserRating(const UserRating& rating)
|
||||
{
|
||||
|
@ -185,6 +185,14 @@ typedef List<CategoryRef, false> CategoryList;
|
||||
typedef List<PackageInfoListenerRef, false, 2> PackageListenerList;
|
||||
|
||||
|
||||
enum PackageState {
|
||||
NONE = 0,
|
||||
INSTALLED = 1,
|
||||
ACTIVATED = 2,
|
||||
UNINSTALLED = 3,
|
||||
};
|
||||
|
||||
|
||||
class PackageInfo : public BReferenceable {
|
||||
public:
|
||||
PackageInfo();
|
||||
@ -216,6 +224,10 @@ public:
|
||||
const BString& Changelog() const
|
||||
{ return fChangelog; }
|
||||
|
||||
PackageState State() const
|
||||
{ return fState; }
|
||||
void SetState(PackageState state);
|
||||
|
||||
bool AddCategory(const CategoryRef& category);
|
||||
const CategoryList& Categories() const
|
||||
{ return fCategories; }
|
||||
@ -248,6 +260,7 @@ private:
|
||||
CategoryList fCategories;
|
||||
UserRatingList fUserRatings;
|
||||
BitmapList fScreenshots;
|
||||
PackageState fState;
|
||||
PackageListenerList fListeners;
|
||||
};
|
||||
|
||||
@ -258,14 +271,6 @@ typedef BReference<PackageInfo> PackageInfoRef;
|
||||
typedef List<PackageInfoRef, false> PackageList;
|
||||
|
||||
|
||||
enum PackageState {
|
||||
NONE = 0,
|
||||
INSTALLED = 1,
|
||||
ACTIVATED = 2,
|
||||
UNINSTALLED = 3,
|
||||
};
|
||||
|
||||
|
||||
class DepotInfo {
|
||||
public:
|
||||
DepotInfo();
|
||||
|
@ -13,6 +13,7 @@ enum {
|
||||
PKG_CHANGED_DESCRIPTION = 1 << 0,
|
||||
PKG_CHANGED_RATINGS = 1 << 1,
|
||||
PKG_CHANGED_SCREENSHOTS = 1 << 2,
|
||||
PKG_CHANGED_STATE = 1 << 3
|
||||
// ...
|
||||
};
|
||||
|
||||
|
@ -18,6 +18,29 @@
|
||||
#define B_TRANSLATION_CONTEXT "PackageListView"
|
||||
|
||||
|
||||
static const char* skPackageStateAvailable = B_TRANSLATE_MARK("Available");
|
||||
static const char* skPackageStateUninstalled = B_TRANSLATE_MARK("Uninstalled");
|
||||
static const char* skPackageStateActive = B_TRANSLATE_MARK("Active");
|
||||
static const char* skPackageStateInactive = B_TRANSLATE_MARK("Inactive");
|
||||
|
||||
|
||||
inline BString PackageStateToString(PackageState state)
|
||||
{
|
||||
switch (state) {
|
||||
case NONE:
|
||||
return B_TRANSLATE(skPackageStateAvailable);
|
||||
case INSTALLED:
|
||||
return B_TRANSLATE(skPackageStateInactive);
|
||||
case ACTIVATED:
|
||||
return B_TRANSLATE(skPackageStateActive);
|
||||
case UNINSTALLED:
|
||||
return B_TRANSLATE(skPackageStateUninstalled);
|
||||
}
|
||||
|
||||
return B_TRANSLATE("Unknown");
|
||||
}
|
||||
|
||||
|
||||
// A field type displaying both a bitmap and a string so that the
|
||||
// tree display looks nicer (both text and bitmap are indented)
|
||||
// TODO: Code-duplication with DriveSetup PartitionList.h
|
||||
@ -450,8 +473,9 @@ PackageRow::PackageRow(const PackageInfoRef& packageRef,
|
||||
SetField(new BStringField("0 KiB"), kSizeColumn);
|
||||
|
||||
// Status
|
||||
// TODO: Fetch info about installed/deactivated/unintalled/...
|
||||
SetField(new BStringField("n/a"), kStatusColumn);
|
||||
// TODO: Fetch info about installed/deactivated/uninstalled/...
|
||||
SetField(new BStringField(PackageStateToString(package.State())),
|
||||
kStatusColumn);
|
||||
|
||||
package.AddListener(fPackageListener);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user