diff --git a/src/libdanbooru/danboorutag.cpp b/src/libdanbooru/danboorutag.cpp new file mode 100644 index 0000000..5b032bf --- /dev/null +++ b/src/libdanbooru/danboorutag.cpp @@ -0,0 +1,88 @@ +/* + * + * Copyright 2013 Luca Beltrame + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "danboorutag.h" + +namespace Danbooru { + + DanbooruTag::DanbooruTag(const QVariantMap& postData, QObject* parent): + QObject(parent) + { + m_id = postData.value("id").toInt(); + m_name = postData.value("name").toString(); + m_count = postData.value("count").toInt(); + m_ambiguous = postData.value("ambiguous").toBool(); + + int type = postData.value("type").toInt(); + + switch (type) { + case 0: + m_tagType = General; + break; + case 1: + m_tagType = Artist; + break; + case 2: + m_tagType = Copyright; + break; + case 3: + m_tagType = Character; + break; + case 4: + m_tagType = Unknown; + break; + default: + m_tagType = Unknown; + break; + } + } + + int DanbooruTag::id() const + { + return m_id; + } + + int DanbooruTag::count() const + { + return m_count; + } + + const QString DanbooruTag::name() const + { + return m_name; + } + + bool DanbooruTag::ambiguous() const + { + return m_ambiguous; + } + + TagType DanbooruTag::type() const + { + return m_tagType; + } + + + + + +}; // namespace Danbooru diff --git a/src/libdanbooru/danboorutag.h b/src/libdanbooru/danboorutag.h new file mode 100644 index 0000000..b8e70c9 --- /dev/null +++ b/src/libdanbooru/danboorutag.h @@ -0,0 +1,59 @@ +/* + * + * Copyright 2013 Luca Beltrame + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + + +#ifndef DANBOORUTAG_H +#define DANBOORUTAG_H + +#include +#include + +#include "danbooru.h" + +namespace Danbooru { + + class DanbooruTag : public QObject + { + Q_OBJECT + + private: + int m_id; + int m_count; + QString m_name; + bool m_ambiguous; + TagType m_tagType; + + public: + DanbooruTag(const QVariantMap& postData, QObject* parent=0); + int id() const; + int count() const; + const QString name() const; + bool ambiguous() const; + TagType type() const; + + }; + +}; // namespace Danbooru + +Q_DECLARE_METATYPE(Danbooru::DanbooruTag*) + +#endif // DANBOORUTAG_H