-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.cpp
53 lines (48 loc) · 1.73 KB
/
profile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "profile.h"
#include <QJsonDocument>
#include <QDebug>
#include <QDateTime>
using namespace Plurq;
QUrl Profile::avatarUrl(Avatar size) const
{
bool hasProfileImage = (intValue(QLatin1String("has_profile_image")) == 1);
auto avatar = (*this)[QLatin1String("avatar")];
if (!hasProfileImage) {
switch (size) {
case Avatar::Small:
return QUrl(QStringLiteral("https://www.plurk.com/static/default_small.gif"));
case Avatar::Medium:
return QUrl(QStringLiteral("https://www.plurk.com/static/default_medium.gif"));
case Avatar::Large:
return QUrl(QStringLiteral("https://www.plurk.com/static/default_big.gif"));
}
} else {
QString version = avatar.isNull() ? "" : QString::number(avatar.toInt());
switch (size) {
case Avatar::Small:
return QUrl(QStringLiteral("https://avatars.plurk.com/%1-small%2.gif").arg(id()).arg(version));
case Avatar::Medium:
return QUrl(QStringLiteral("https://avatars.plurk.com/%1-medium%2.gif").arg(id()).arg(version));
case Avatar::Large:
return QUrl(QStringLiteral("https://avatars.plurk.com/%1-large%2.jpg").arg(id()).arg(version));
}
}
}
bool Profile::birthday() const
{
if (intValue(QLatin1String("bday_privacy")) != 0) {
QDate date = dateValue(QLatin1String("date_of_birth")).date();
QDate today = QDate::currentDate();
return (date.month() == today.month()) && (date.day() == today.day());
} else {
return false;
}
}
QString Profile::name() const
{
QString result;
if ((result = displayName()).isEmpty())
if ((result = fullName()).isEmpty())
return nickName();
return result;
}