Add support for parsing Danbooru (donmai.us) type posts
Also added unit test, passing.
This commit is contained in:
parent
7ec33e8e57
commit
4c662ed7c1
3 changed files with 83 additions and 8 deletions
|
|
@ -35,6 +35,20 @@ namespace Danbooru
|
|||
|
||||
const QMap<QString, DanbooruPost::Rating> DanbooruPost::RATING_MAP = initRatingMap();
|
||||
|
||||
void DanbooruPost::parseDanbooruDonmai(const QVariantMap &postData) {
|
||||
|
||||
m_tags = QSet<QString>::fromList(postData.value("tag_string").toString().split(' '));
|
||||
m_id = postData.value("id").toString().toInt();
|
||||
m_height = postData.value("image_height").toString().toInt();
|
||||
m_width = postData.value("image_width").toString().toInt();
|
||||
m_url = postData.value("file_url").toUrl();
|
||||
m_thumbnailUrl = postData.value("preview_file_url").toUrl();
|
||||
m_size = postData.value("file_size").toInt();
|
||||
m_rating = RATING_MAP.value(postData.value("rating").toString());
|
||||
m_sampleUrl = postData.value("large_file_url").toUrl();
|
||||
|
||||
}
|
||||
|
||||
void DanbooruPost::parseDanbooruKonachan(const QVariantMap &postData) {
|
||||
|
||||
m_tags = QSet<QString>::fromList(postData.value("tags").toString().split(' '));
|
||||
|
|
@ -49,9 +63,6 @@ void DanbooruPost::parseDanbooruKonachan(const QVariantMap &postData) {
|
|||
m_sampleUrl = postData.value("sample_url").toUrl();
|
||||
}
|
||||
|
||||
void DanbooruPost::parseDanbooruDonmai(const QVariantMap &postData) {
|
||||
}
|
||||
|
||||
DanbooruPost::DanbooruPost(QObject *parent): QObject(parent)
|
||||
{
|
||||
m_pixmap = QPixmap();
|
||||
|
|
@ -148,6 +159,24 @@ void DanbooruPost::setPixmap(const QPixmap &pixmap)
|
|||
m_pixmap = pixmap;
|
||||
}
|
||||
|
||||
void DanbooruPost::setFileUrl(const QUrl &url) {
|
||||
if (url.isValid()) {
|
||||
m_url = url;
|
||||
}
|
||||
}
|
||||
|
||||
void DanbooruPost::setSampleUrl(const QUrl &url) {
|
||||
if (url.isValid()) {
|
||||
m_sampleUrl = url;
|
||||
}
|
||||
}
|
||||
|
||||
void DanbooruPost::setThumbnailUrl(const QUrl &url) {
|
||||
if (url.isValid()) {
|
||||
m_thumbnailUrl = url;
|
||||
}
|
||||
}
|
||||
|
||||
const QString DanbooruPost::toString()
|
||||
{
|
||||
QString display = QString("Danbooru Post with ID %1 and URL %2, width %3 height %4 ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue