From 46bcb34d051b580c4a8e6e22f1b7726e4ddbf15f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 29 Sep 2014 22:01:30 +0200 Subject: [PATCH] HaikuDepot: Store BPackageVersion in PackageInfo... ...instead of the string representation. This makes it easier to get the major, minor, micro, prerelease and revision parts later on. --- src/apps/haikudepot/model/PackageInfo.cpp | 3 ++- src/apps/haikudepot/model/PackageInfo.h | 11 +++++++---- src/apps/haikudepot/ui/MainWindow.cpp | 2 +- src/apps/haikudepot/ui/PackageInfoView.cpp | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/apps/haikudepot/model/PackageInfo.cpp b/src/apps/haikudepot/model/PackageInfo.cpp index 9bb7cca367..8167f85bbb 100644 --- a/src/apps/haikudepot/model/PackageInfo.cpp +++ b/src/apps/haikudepot/model/PackageInfo.cpp @@ -11,6 +11,7 @@ #include + // #pragma mark - UserInfo @@ -466,7 +467,7 @@ PackageInfo::PackageInfo() PackageInfo::PackageInfo(const BString& title, - const BString& version, const PublisherInfo& publisher, + const BPackageVersion& version, const PublisherInfo& publisher, const BString& shortDescription, const BString& fullDescription, int32 flags, const char* architecture) : diff --git a/src/apps/haikudepot/model/PackageInfo.h b/src/apps/haikudepot/model/PackageInfo.h index aa9ece0e9b..b9e6f47a6e 100644 --- a/src/apps/haikudepot/model/PackageInfo.h +++ b/src/apps/haikudepot/model/PackageInfo.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include "List.h" #include "PackageInfoListener.h" @@ -229,12 +229,15 @@ enum PackageState { }; +using BPackageKit::BPackageVersion; + + class PackageInfo : public BReferenceable { public: PackageInfo(); PackageInfo( const BString& title, - const BString& version, + const BPackageVersion& version, const PublisherInfo& publisher, const BString& shortDescription, const BString& fullDescription, @@ -248,7 +251,7 @@ public: const BString& Title() const { return fTitle; } - const BString& Version() const + const BPackageVersion& Version() const { return fVersion; } void SetShortDescription(const BString& description); const BString& ShortDescription() const @@ -323,7 +326,7 @@ private: private: BitmapRef fIcon; BString fTitle; - BString fVersion; + BPackageVersion fVersion; PublisherInfo fPublisher; BString fShortDescription; BString fFullDescription; diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index bf28e4d744..4c3084a3b0 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -641,7 +641,7 @@ MainWindow::_RefreshPackageList() modelInfo.SetTo(new(std::nothrow) PackageInfo( repoPackageInfo.Name(), - repoPackageInfo.Version().ToString(), + repoPackageInfo.Version(), PublisherInfo(BitmapRef(), publisherName, "", publisherURL), repoPackageInfo.Summary(), repoPackageInfo.Description(), diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp b/src/apps/haikudepot/ui/PackageInfoView.cpp index c13887a6a5..8c492c543e 100644 --- a/src/apps/haikudepot/ui/PackageInfoView.cpp +++ b/src/apps/haikudepot/ui/PackageInfoView.cpp @@ -514,7 +514,7 @@ public: fPublisherView->SetText(publisher); BString version = B_TRANSLATE("%Version%"); - version.ReplaceAll("%Version%", package.Version()); + version.ReplaceAll("%Version%", package.Version().ToString()); fVersionInfo->SetText(version); RatingSummary ratingSummary = package.CalculateRatingSummary();