diff --git a/src/apps/haiku-depot/Model.cpp b/src/apps/haiku-depot/Model.cpp index c2c76e5bd0..1ea70a21bc 100644 --- a/src/apps/haiku-depot/Model.cpp +++ b/src/apps/haiku-depot/Model.cpp @@ -323,6 +323,8 @@ Model::SetPackageState(const PackageInfoRef& package, PackageState state) fUninstalledPackages.Add(package); break; } + + package->SetState(state); } diff --git a/src/apps/haiku-depot/PackageInfo.cpp b/src/apps/haiku-depot/PackageInfo.cpp index a202cc26dd..c200f12632 100644 --- a/src/apps/haiku-depot/PackageInfo.cpp +++ b/src/apps/haiku-depot/PackageInfo.cpp @@ -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) { diff --git a/src/apps/haiku-depot/PackageInfo.h b/src/apps/haiku-depot/PackageInfo.h index f4f74fa13f..485b139096 100644 --- a/src/apps/haiku-depot/PackageInfo.h +++ b/src/apps/haiku-depot/PackageInfo.h @@ -185,6 +185,14 @@ typedef List CategoryList; typedef List 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 PackageInfoRef; typedef List PackageList; -enum PackageState { - NONE = 0, - INSTALLED = 1, - ACTIVATED = 2, - UNINSTALLED = 3, -}; - - class DepotInfo { public: DepotInfo(); diff --git a/src/apps/haiku-depot/PackageInfoListener.h b/src/apps/haiku-depot/PackageInfoListener.h index 323733ab3a..88154d2c62 100644 --- a/src/apps/haiku-depot/PackageInfoListener.h +++ b/src/apps/haiku-depot/PackageInfoListener.h @@ -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 // ... }; diff --git a/src/apps/haiku-depot/PackageListView.cpp b/src/apps/haiku-depot/PackageListView.cpp index 3e3b163484..1d693a18e7 100644 --- a/src/apps/haiku-depot/PackageListView.cpp +++ b/src/apps/haiku-depot/PackageListView.cpp @@ -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); }