forked from mirror/nheko
parent
4f41c0df4d
commit
73dbd3c8dd
@ -1,25 +0,0 @@ |
||||
#pragma once |
||||
|
||||
#include <QJsonObject> |
||||
#include <QString> |
||||
#include <QUrl> |
||||
#include <vector> |
||||
|
||||
struct Community |
||||
{ |
||||
void parseProfile(const QJsonObject &profile); |
||||
void parseRooms(const QJsonObject &rooms); |
||||
|
||||
QUrl getAvatar() const { return avatar_; } |
||||
QString getName() const { return name_; } |
||||
QString getShortDescription() const { return short_description_; } |
||||
QString getLongDescription() const { return long_description_; } |
||||
std::vector<QString> getRoomList() const { return rooms_; } |
||||
|
||||
QUrl avatar_; |
||||
QString name_; |
||||
QString short_description_; |
||||
QString long_description_; |
||||
|
||||
std::vector<QString> rooms_; |
||||
}; |
@ -1,33 +0,0 @@ |
||||
#include "include/Community.h" |
||||
|
||||
#include <QJsonArray> |
||||
#include <QJsonValue> |
||||
|
||||
void |
||||
Community::parseProfile(const QJsonObject &profile) |
||||
{ |
||||
if (profile["name"].type() == QJsonValue::Type::String) |
||||
name_ = profile["name"].toString(); |
||||
else |
||||
name_ = "Unnamed Community"; // TODO: what is correct here?
|
||||
|
||||
if (profile["avatar_url"].type() == QJsonValue::Type::String) |
||||
avatar_ = QUrl(profile["avatar_url"].toString()); |
||||
|
||||
if (profile["short_description"].type() == QJsonValue::Type::String) |
||||
short_description_ = profile["short_description"].toString(); |
||||
|
||||
if (profile["long_description"].type() == QJsonValue::Type::String) |
||||
long_description_ = profile["long_description"].toString(); |
||||
} |
||||
|
||||
void |
||||
Community::parseRooms(const QJsonObject &rooms) |
||||
{ |
||||
rooms_.clear(); |
||||
|
||||
for (auto const &room : rooms["chunk"].toArray()) { |
||||
if (room.toObject().contains("room_id")) |
||||
rooms_.emplace_back(room.toObject()["room_id"].toString()); |
||||
} |
||||
} |
Loading…
Reference in new issue