File indexing completed on 2024-05-05 17:33:22

0001 /*
0002  *   SPDX-FileCopyrightText: 2011 Jonathan Thomas <echidnaman@kubuntu.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #include "Review.h"
0008 #include <resources/ResourcesModel.h>
0009 
0010 Review::Review(QString name,
0011                QString pkgName,
0012                QString language,
0013                QString summary,
0014                QString reviewText,
0015                QString userName,
0016                const QDateTime &date,
0017                bool show,
0018                quint64 id,
0019                int rating,
0020                int usefulTotal,
0021                int usefulFavorable,
0022                QString packageVersion)
0023     : m_appName(std::move(name))
0024     , m_creationDate(date)
0025     , m_shouldShow(show)
0026     , m_id(id)
0027     , m_language(std::move(language))
0028     , m_packageName(std::move(pkgName))
0029     , m_rating(rating)
0030     , m_reviewText(std::move(reviewText))
0031     , m_reviewer(std::move(userName))
0032     , m_usefulnessTotal(usefulTotal)
0033     , m_usefulnessFavorable(usefulFavorable)
0034     , m_usefulChoice(ReviewsModel::None)
0035     , m_summary(std::move(summary))
0036     , m_packageVersion(std::move(packageVersion))
0037 {
0038 }
0039 
0040 Review::~Review() = default;
0041 
0042 bool Review::operator<(const Review &other) const
0043 {
0044     return m_creationDate < other.m_creationDate;
0045 }
0046 
0047 bool Review::operator>(const Review &other) const
0048 {
0049     return m_creationDate > other.m_creationDate;
0050 }
0051 
0052 QString Review::applicationName() const
0053 {
0054     return m_appName;
0055 }
0056 
0057 QString Review::packageName() const
0058 {
0059     return m_packageName;
0060 }
0061 
0062 QString Review::packageVersion() const
0063 {
0064     return m_packageVersion;
0065 }
0066 
0067 QString Review::language() const
0068 {
0069     return m_language;
0070 }
0071 
0072 QString Review::summary() const
0073 {
0074     return m_summary;
0075 }
0076 
0077 QString Review::reviewText() const
0078 {
0079     return m_reviewText;
0080 }
0081 
0082 QString Review::reviewer() const
0083 {
0084     return m_reviewer;
0085 }
0086 
0087 QDateTime Review::creationDate() const
0088 {
0089     return m_creationDate;
0090 }
0091 
0092 bool Review::shouldShow() const
0093 {
0094     return m_shouldShow;
0095 }
0096 
0097 quint64 Review::id() const
0098 {
0099     return m_id;
0100 }
0101 
0102 int Review::rating() const
0103 {
0104     return m_rating;
0105 }
0106 
0107 int Review::usefulnessTotal() const
0108 {
0109     return m_usefulnessTotal;
0110 }
0111 
0112 int Review::usefulnessFavorable() const
0113 {
0114     return m_usefulnessFavorable;
0115 }
0116 
0117 ReviewsModel::UserChoice Review::usefulChoice() const
0118 {
0119     return m_usefulChoice;
0120 }
0121 
0122 void Review::setUsefulChoice(ReviewsModel::UserChoice useful)
0123 {
0124     m_usefulChoice = useful;
0125 }
0126 
0127 void Review::addMetadata(const QString &key, const QVariant &value)
0128 {
0129     m_metadata.insert(key, value);
0130 }
0131 
0132 QVariant Review::getMetadata(const QString &key)
0133 {
0134     return m_metadata.value(key);
0135 }