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:
@@ -323,6 +323,8 @@ Model::SetPackageState(const PackageInfoRef& package, PackageState state)
|
|||||||
fUninstalledPackages.Add(package);
|
fUninstalledPackages.Add(package);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package->SetState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -445,7 +445,8 @@ PackageInfo::PackageInfo()
|
|||||||
fFullDescription(),
|
fFullDescription(),
|
||||||
fChangelog(),
|
fChangelog(),
|
||||||
fUserRatings(),
|
fUserRatings(),
|
||||||
fScreenshots()
|
fScreenshots(),
|
||||||
|
fState(NONE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,7 +465,8 @@ PackageInfo::PackageInfo(const BitmapRef& icon, const BString& title,
|
|||||||
fChangelog(changelog),
|
fChangelog(changelog),
|
||||||
fCategories(),
|
fCategories(),
|
||||||
fUserRatings(),
|
fUserRatings(),
|
||||||
fScreenshots()
|
fScreenshots(),
|
||||||
|
fState(NONE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,7 +482,8 @@ PackageInfo::PackageInfo(const PackageInfo& other)
|
|||||||
fChangelog(other.fChangelog),
|
fChangelog(other.fChangelog),
|
||||||
fCategories(other.fCategories),
|
fCategories(other.fCategories),
|
||||||
fUserRatings(other.fUserRatings),
|
fUserRatings(other.fUserRatings),
|
||||||
fScreenshots(other.fScreenshots)
|
fScreenshots(other.fScreenshots),
|
||||||
|
fState(other.fState)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,6 +501,7 @@ PackageInfo::operator=(const PackageInfo& other)
|
|||||||
fCategories = other.fCategories;
|
fCategories = other.fCategories;
|
||||||
fUserRatings = other.fUserRatings;
|
fUserRatings = other.fUserRatings;
|
||||||
fScreenshots = other.fScreenshots;
|
fScreenshots = other.fScreenshots;
|
||||||
|
fState = other.fState;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,6 +536,14 @@ PackageInfo::AddCategory(const CategoryRef& category)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageInfo::SetState(PackageState state)
|
||||||
|
{
|
||||||
|
fState = state;
|
||||||
|
_NotifyListeners(PKG_CHANGED_STATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PackageInfo::AddUserRating(const UserRating& rating)
|
PackageInfo::AddUserRating(const UserRating& rating)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -185,6 +185,14 @@ typedef List<CategoryRef, false> CategoryList;
|
|||||||
typedef List<PackageInfoListenerRef, false, 2> PackageListenerList;
|
typedef List<PackageInfoListenerRef, false, 2> PackageListenerList;
|
||||||
|
|
||||||
|
|
||||||
|
enum PackageState {
|
||||||
|
NONE = 0,
|
||||||
|
INSTALLED = 1,
|
||||||
|
ACTIVATED = 2,
|
||||||
|
UNINSTALLED = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class PackageInfo : public BReferenceable {
|
class PackageInfo : public BReferenceable {
|
||||||
public:
|
public:
|
||||||
PackageInfo();
|
PackageInfo();
|
||||||
@@ -216,6 +224,10 @@ public:
|
|||||||
const BString& Changelog() const
|
const BString& Changelog() const
|
||||||
{ return fChangelog; }
|
{ return fChangelog; }
|
||||||
|
|
||||||
|
PackageState State() const
|
||||||
|
{ return fState; }
|
||||||
|
void SetState(PackageState state);
|
||||||
|
|
||||||
bool AddCategory(const CategoryRef& category);
|
bool AddCategory(const CategoryRef& category);
|
||||||
const CategoryList& Categories() const
|
const CategoryList& Categories() const
|
||||||
{ return fCategories; }
|
{ return fCategories; }
|
||||||
@@ -248,6 +260,7 @@ private:
|
|||||||
CategoryList fCategories;
|
CategoryList fCategories;
|
||||||
UserRatingList fUserRatings;
|
UserRatingList fUserRatings;
|
||||||
BitmapList fScreenshots;
|
BitmapList fScreenshots;
|
||||||
|
PackageState fState;
|
||||||
PackageListenerList fListeners;
|
PackageListenerList fListeners;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -258,14 +271,6 @@ typedef BReference<PackageInfo> PackageInfoRef;
|
|||||||
typedef List<PackageInfoRef, false> PackageList;
|
typedef List<PackageInfoRef, false> PackageList;
|
||||||
|
|
||||||
|
|
||||||
enum PackageState {
|
|
||||||
NONE = 0,
|
|
||||||
INSTALLED = 1,
|
|
||||||
ACTIVATED = 2,
|
|
||||||
UNINSTALLED = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class DepotInfo {
|
class DepotInfo {
|
||||||
public:
|
public:
|
||||||
DepotInfo();
|
DepotInfo();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ enum {
|
|||||||
PKG_CHANGED_DESCRIPTION = 1 << 0,
|
PKG_CHANGED_DESCRIPTION = 1 << 0,
|
||||||
PKG_CHANGED_RATINGS = 1 << 1,
|
PKG_CHANGED_RATINGS = 1 << 1,
|
||||||
PKG_CHANGED_SCREENSHOTS = 1 << 2,
|
PKG_CHANGED_SCREENSHOTS = 1 << 2,
|
||||||
|
PKG_CHANGED_STATE = 1 << 3
|
||||||
// ...
|
// ...
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,29 @@
|
|||||||
#define B_TRANSLATION_CONTEXT "PackageListView"
|
#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
|
// A field type displaying both a bitmap and a string so that the
|
||||||
// tree display looks nicer (both text and bitmap are indented)
|
// tree display looks nicer (both text and bitmap are indented)
|
||||||
// TODO: Code-duplication with DriveSetup PartitionList.h
|
// TODO: Code-duplication with DriveSetup PartitionList.h
|
||||||
@@ -450,8 +473,9 @@ 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/unintalled/...
|
// TODO: Fetch info about installed/deactivated/uninstalled/...
|
||||||
SetField(new BStringField("n/a"), kStatusColumn);
|
SetField(new BStringField(PackageStateToString(package.State())),
|
||||||
|
kStatusColumn);
|
||||||
|
|
||||||
package.AddListener(fPackageListener);
|
package.AddListener(fPackageListener);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user