HaikuDepot: Minor optimization.
- PackageAction now stores/returns a type code indicating the embodied action. Adjust PackageActionView accordingly in its comparison of the old/new package action list.
This commit is contained in:
@@ -16,9 +16,10 @@ using namespace BPackageKit;
|
|||||||
// #pragma mark - PackageAction
|
// #pragma mark - PackageAction
|
||||||
|
|
||||||
|
|
||||||
PackageAction::PackageAction(PackageInfoRef package)
|
PackageAction::PackageAction(int32 type, PackageInfoRef package)
|
||||||
:
|
:
|
||||||
fPackage(package)
|
fPackage(package),
|
||||||
|
fType(type)
|
||||||
{
|
{
|
||||||
// TODO: allow configuring the installation location
|
// TODO: allow configuring the installation location
|
||||||
fPackageManager = new(std::nothrow) PackageManager(
|
fPackageManager = new(std::nothrow) PackageManager(
|
||||||
|
|||||||
@@ -14,12 +14,22 @@
|
|||||||
|
|
||||||
class PackageManager;
|
class PackageManager;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PACKAGE_ACTION_INSTALL = 0,
|
||||||
|
PACKAGE_ACTION_UNINSTALL,
|
||||||
|
PACKAGE_ACTION_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class PackageAction : public BReferenceable {
|
class PackageAction : public BReferenceable {
|
||||||
public:
|
public:
|
||||||
PackageAction(PackageInfoRef package);
|
PackageAction(int32 type,
|
||||||
|
PackageInfoRef package);
|
||||||
virtual ~PackageAction();
|
virtual ~PackageAction();
|
||||||
|
|
||||||
|
int32 Type() const
|
||||||
|
{ return fType; }
|
||||||
|
|
||||||
virtual const char* Label() const = 0;
|
virtual const char* Label() const = 0;
|
||||||
|
|
||||||
virtual status_t Perform() = 0;
|
virtual status_t Perform() = 0;
|
||||||
@@ -32,6 +42,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
PackageInfoRef fPackage;
|
PackageInfoRef fPackage;
|
||||||
|
int32 fType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -547,8 +547,8 @@ public:
|
|||||||
clearNeeded = true;
|
clearNeeded = true;
|
||||||
else {
|
else {
|
||||||
for (int32 i = 0; i < actions.CountItems(); i++) {
|
for (int32 i = 0; i < actions.CountItems(); i++) {
|
||||||
if (strcasecmp(actions.ItemAtFast(i)->Label(),
|
if (actions.ItemAtFast(i)->Type()
|
||||||
fPackageActions.ItemAtFast(i)->Label()) != 0) {
|
!= fPackageActions.ItemAtFast(i)->Type()) {
|
||||||
clearNeeded = true;
|
clearNeeded = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class InstallPackageAction : public PackageAction {
|
|||||||
public:
|
public:
|
||||||
InstallPackageAction(PackageInfoRef package)
|
InstallPackageAction(PackageInfoRef package)
|
||||||
:
|
:
|
||||||
PackageAction(package)
|
PackageAction(PACKAGE_ACTION_INSTALL, package)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class UninstallPackageAction : public PackageAction {
|
|||||||
public:
|
public:
|
||||||
UninstallPackageAction(PackageInfoRef package)
|
UninstallPackageAction(PackageInfoRef package)
|
||||||
:
|
:
|
||||||
PackageAction(package)
|
PackageAction(PACKAGE_ACTION_UNINSTALL, package)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user