~ubuntu-branches/ubuntu/vivid/muon/vivid-proposed

« back to all changes in this revision

Viewing changes to installer/ReviewsBackend/Review.cpp

Tags: upstream-1.3.65
Import upstream version 1.3.65

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright © 2011 Jonathan Thomas <echidnaman@kubuntu.org>             *
3
 
 *                                                                         *
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.                    *
11
 
 *                                                                         *
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.                          *
16
 
 *                                                                         *
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
 
 ***************************************************************************/
20
 
 
21
 
#include "Review.h"
22
 
 
23
 
#include <LibQApt/Package>
24
 
 
25
 
Review::Review(const QVariantMap &data)
26
 
{
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();
33
 
 
34
 
    QString reviewUsername = data.value("reviewer_username").toString();
35
 
    QString reviewDisplayName = data.value("reviewer_displayname").toString();
36
 
    if (!reviewDisplayName.isEmpty()) {
37
 
        m_reviewer = reviewDisplayName;
38
 
    } else {
39
 
        m_reviewer = reviewUsername;
40
 
    }
41
 
 
42
 
    QString creationDate = data.value("date_created").toString();
43
 
    m_creationDate = QDateTime::fromString(creationDate, "yyyy-MM-dd HH:mm:ss");
44
 
 
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();
50
 
}
51
 
 
52
 
Review::~Review()
53
 
{
54
 
}
55
 
 
56
 
bool Review::operator<(const Review &other) const
57
 
{
58
 
    return m_creationDate < other.m_creationDate;
59
 
}
60
 
 
61
 
bool Review::operator>(const Review &other) const
62
 
{
63
 
    return m_creationDate > other.m_creationDate;
64
 
}
65
 
 
66
 
QString Review::applicationName() const
67
 
{
68
 
    return m_appName;
69
 
}
70
 
 
71
 
QString Review::packageName() const
72
 
{
73
 
    return m_packageName;
74
 
}
75
 
 
76
 
QString Review::packageVersion() const
77
 
{
78
 
    return m_packageVersion;
79
 
}
80
 
 
81
 
QString Review::language() const
82
 
{
83
 
    return m_language;
84
 
}
85
 
 
86
 
QString Review::summary() const
87
 
{
88
 
    return m_summary;
89
 
}
90
 
 
91
 
QString Review::reviewText() const
92
 
{
93
 
    return m_reviewText;
94
 
}
95
 
 
96
 
QString Review::reviewer() const
97
 
{
98
 
    return m_reviewer;
99
 
}
100
 
 
101
 
QDateTime Review::creationDate() const
102
 
{
103
 
    return m_creationDate;
104
 
}
105
 
 
106
 
bool Review::shouldShow() const
107
 
{
108
 
    return m_shouldShow;
109
 
}
110
 
 
111
 
quint64 Review::id() const
112
 
{
113
 
    return m_id;
114
 
}
115
 
 
116
 
int Review::rating() const
117
 
{
118
 
    return m_rating;
119
 
}
120
 
 
121
 
int Review::usefulnessTotal() const
122
 
{
123
 
    return m_usefulnessTotal;
124
 
}
125
 
 
126
 
int Review::usefulnessFavorable() const
127
 
{
128
 
    return m_usefulnessFavorable;
129
 
}
130
 
 
131
 
QApt::Package *Review::package() const
132
 
{
133
 
    return m_package;
134
 
}
135
 
 
136
 
void Review::setPackage(QApt::Package *package)
137
 
{
138
 
    m_package = package;
139
 
}