1
/***************************************************************************
2
* Copyright © 2011 Jonathan Thomas <echidnaman@kubuntu.org> *
4
* This program is free software; you can redistribute it and/or *
5
* modify it under the terms of the GNU General Public License as *
6
* published by the Free Software Foundation; either version 2 of *
7
* the License or (at your option) version 3 or any later version *
8
* accepted by the membership of KDE e.V. (or its successor approved *
9
* by the membership of KDE e.V.), which shall act as a proxy *
10
* defined in Section 14 of version 3 of the license. *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
19
***************************************************************************/
23
#include <LibQApt/Package>
25
Review::Review(const QVariantMap &data)
27
m_appName = data.value("app_name").toString();
28
m_packageName = data.value("package_name").toString();
29
m_packageVersion = data.value("version").toString();
30
m_language = data.value("language").toString();
31
m_summary = data.value("summary").toString();
32
m_reviewText = data.value("review_text").toString();
34
QString reviewUsername = data.value("reviewer_username").toString();
35
QString reviewDisplayName = data.value("reviewer_displayname").toString();
36
if (!reviewDisplayName.isEmpty()) {
37
m_reviewer = reviewDisplayName;
39
m_reviewer = reviewUsername;
42
QString creationDate = data.value("date_created").toString();
43
m_creationDate = QDateTime::fromString(creationDate, "yyyy-MM-dd HH:mm:ss");
45
m_shouldShow = !data.value("hide").toBool();
46
m_id = data.value("id").toULongLong();
47
m_rating = data.value("rating").toInt() * 2;
48
m_usefulnessTotal = data.value("usefulness_total").toInt();
49
m_usefulnessFavorable = data.value("usefulness_favorable").toInt();
56
bool Review::operator<(const Review &other) const
58
return m_creationDate < other.m_creationDate;
61
bool Review::operator>(const Review &other) const
63
return m_creationDate > other.m_creationDate;
66
QString Review::applicationName() const
71
QString Review::packageName() const
76
QString Review::packageVersion() const
78
return m_packageVersion;
81
QString Review::language() const
86
QString Review::summary() const
91
QString Review::reviewText() const
96
QString Review::reviewer() const
101
QDateTime Review::creationDate() const
103
return m_creationDate;
106
bool Review::shouldShow() const
111
quint64 Review::id() const
116
int Review::rating() const
121
int Review::usefulnessTotal() const
123
return m_usefulnessTotal;
126
int Review::usefulnessFavorable() const
128
return m_usefulnessFavorable;
131
QApt::Package *Review::package() const
136
void Review::setPackage(QApt::Package *package)