diff --git a/src/apps/haiku-depot/Jamfile b/src/apps/haiku-depot/Jamfile index cb532f33dc..d9e290775b 100644 --- a/src/apps/haiku-depot/Jamfile +++ b/src/apps/haiku-depot/Jamfile @@ -8,6 +8,7 @@ Application HaikuDepot : main.cpp MainWindow.cpp PackageActionsView.cpp + PackageInfo.cpp PackageInfoView.cpp PackageListView.cpp support.cpp diff --git a/src/apps/haiku-depot/PackageInfo.cpp b/src/apps/haiku-depot/PackageInfo.cpp new file mode 100644 index 0000000000..78a617d243 --- /dev/null +++ b/src/apps/haiku-depot/PackageInfo.cpp @@ -0,0 +1,191 @@ +/* + * Copyright 2013, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "PackageInfo.h" + +#include + + +// #pragma mark - UserInfo + + +UserInfo::UserInfo() + : + fNickName() +{ +} + + +UserInfo::UserInfo(const BString& fNickName) + : + fNickName(fNickName) +{ +} + + +UserInfo::UserInfo(const UserInfo& other) + : + fNickName(other.fNickName) +{ +} + + +UserInfo& +UserInfo::operator=(const UserInfo& other) +{ + fNickName = other.fNickName; + return *this; +} + + +bool +UserInfo::operator==(const UserInfo& other) const +{ + return fNickName == other.fNickName; +} + + +bool +UserInfo::operator!=(const UserInfo& other) const +{ + return !(*this == other); +} + + +// #pragma mark - UserRating + + +UserRating::UserRating() + : + fUserInfo(), + fComment(), + fRating(0.0f), + fPackageVersion() +{ +} + + +UserRating::UserRating(const UserInfo& userInfo, const BString& comment, + float rating, const BString& packageVersion) + : + fUserInfo(userInfo), + fComment(comment), + fRating(rating), + fPackageVersion(packageVersion) + +{ +} + + +UserRating::UserRating(const UserRating& other) + : + fUserInfo(other.fUserInfo), + fComment(other.fComment), + fRating(other.fRating), + fPackageVersion(other.fPackageVersion) +{ +} + + +UserRating& +UserRating::operator=(const UserRating& other) +{ + fUserInfo = other.fUserInfo; + fComment = other.fComment; + fRating = other.fRating; + fPackageVersion = other.fPackageVersion; + return *this; +} + + +bool +UserRating::operator==(const UserRating& other) const +{ + return fUserInfo == other.fUserInfo + && fComment == other.fComment + && fRating == other.fRating + && fPackageVersion == other.fPackageVersion; +} + + +bool +UserRating::operator!=(const UserRating& other) const +{ + return !(*this == other); +} + + +// #pragma mark - PackageInfo + + +PackageInfo::PackageInfo() + : + fTitle(), + fVersion(), + fDescription(), + fChangelog(), + fUserRatings() +{ +} + + +PackageInfo::PackageInfo(const BString& title, const BString& version, + const BString& description, const BString& changelog) + : + fTitle(title), + fVersion(version), + fDescription(description), + fChangelog(changelog), + fUserRatings() +{ +} + + +PackageInfo::PackageInfo(const PackageInfo& other) + : + fTitle(other.fTitle), + fVersion(other.fVersion), + fDescription(other.fDescription), + fChangelog(other.fChangelog), + fUserRatings(other.fUserRatings) +{ +} + + +PackageInfo& +PackageInfo::operator=(const PackageInfo& other) +{ + fTitle = other.fTitle; + fVersion = other.fVersion; + fDescription = other.fDescription; + fChangelog = other.fChangelog; + fUserRatings = other.fUserRatings; + return *this; +} + + +bool +PackageInfo::operator==(const PackageInfo& other) const +{ + return fTitle == other.fTitle + && fVersion == other.fVersion + && fDescription == other.fDescription + && fChangelog == other.fChangelog + && fUserRatings == other.fUserRatings; +} + + +bool +PackageInfo::operator!=(const PackageInfo& other) const +{ + return !(*this == other); +} + + +bool +PackageInfo::AddUserRating(const UserRating& rating) +{ + return fUserRatings.Add(rating); +} diff --git a/src/apps/haiku-depot/PackageInfo.h b/src/apps/haiku-depot/PackageInfo.h new file mode 100644 index 0000000000..24d4c8e7a1 --- /dev/null +++ b/src/apps/haiku-depot/PackageInfo.h @@ -0,0 +1,99 @@ +/* + * Copyright 2013, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef PACKAGE_INFO_H +#define PACKAGE_INFO_H + + +#include + +#include "List.h" + + +class UserInfo { +public: + UserInfo(); + UserInfo(const BString& nickName); + UserInfo(const UserInfo& other); + + UserInfo& operator=(const UserInfo& other); + bool operator==(const UserInfo& other) const; + bool operator!=(const UserInfo& other) const; + + const BString& NickName() const; + +private: + BString fNickName; +}; + + +class UserRating { +public: + UserRating(); + UserRating(const UserInfo& userInfo, + const BString& comment, float rating, + const BString& packageVersion); + UserRating(const UserRating& other); + + UserRating& operator=(const UserRating& other); + bool operator==(const UserRating& other) const; + bool operator!=(const UserRating& other) const; + + const UserInfo& User() const + { return fUserInfo; } + const BString& Comment() const + { return fComment; } + const float Rating() const + { return fRating; } + const BString& PackageVersion() const + { return fPackageVersion; } + +private: + UserInfo fUserInfo; + BString fComment; + float fRating; + BString fPackageVersion; +}; + + +typedef List UserRatingList; + + +class PackageInfo { +public: + PackageInfo(); + PackageInfo(const BString& title, + const BString& version, + const BString& description, + const BString& changelog); + PackageInfo(const PackageInfo& other); + + PackageInfo& operator=(const PackageInfo& other); + bool operator==(const PackageInfo& other) const; + bool operator!=(const PackageInfo& other) const; + + const BString& Title() const + { return fTitle; } + const BString& Version() const + { return fVersion; } + const BString& Description() const + { return fDescription; } + const BString& Changelog() const + { return fChangelog; } + + bool AddUserRating(const UserRating& rating); + +private: + BString fTitle; + BString fVersion; + BString fDescription; + BString fChangelog; + UserRatingList fUserRatings; +}; + + +typedef List PackageInfoList; + + +#endif // PACKAGE_INFO_H