From f22c0b6d94ca32115ea778986bd0669f3965e7ad Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Sat, 4 Oct 2014 00:03:01 +0200 Subject: [PATCH] Move to the new rating structure --- src/libdanbooru/danboorupost.cpp | 14 ++++++-------- src/libdanbooru/danboorupost.h | 17 ++++++++--------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/libdanbooru/danboorupost.cpp b/src/libdanbooru/danboorupost.cpp index 215facf..95a9003 100644 --- a/src/libdanbooru/danboorupost.cpp +++ b/src/libdanbooru/danboorupost.cpp @@ -37,7 +37,7 @@ namespace Danbooru { -const QMap DanbooruPost::RATING_MAP = initRatingMap(); +const QMap DanbooruPost::RATING_MAP = initRatingMap(); DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap, QObject* parent): @@ -76,15 +76,13 @@ DanbooruPost::DanbooruPost(QXmlStreamAttributes& postData, QPixmap pixmap, QObje DanbooruPost::~DanbooruPost() { - delete m_pixmap; - m_pixmap = 0; } -const QMap< QString, Rating > DanbooruPost::initRatingMap() +const QMap< QString, DanbooruPost::Rating > DanbooruPost::initRatingMap() { - QMap map; + QMap map; map.insert("s", Safe); map.insert("q", Questionable); map.insert("e", Explicit); @@ -100,7 +98,7 @@ bool DanbooruPost::operator==(const Danbooru::DanbooruPost& other) } -void DanbooruPost::setPixmap(const QPixmap pixmap) +void DanbooruPost::setPixmap(const QPixmap &pixmap) { m_pixmap = pixmap; } @@ -137,7 +135,7 @@ const QUrl DanbooruPost::thumbnailUrl() const return m_thumbnailUrl; } -const QPixmap DanbooruPost::pixmap() const +QPixmap DanbooruPost::pixmap() const { return m_pixmap; } @@ -152,7 +150,7 @@ const QUrl DanbooruPost::fileUrl() const return m_url; } -const Ratings DanbooruPost::rating() const +const Danbooru::DanbooruPost::Rating DanbooruPost::rating() const { return m_rating; } diff --git a/src/libdanbooru/danboorupost.h b/src/libdanbooru/danboorupost.h index 72fd545..05c5017 100644 --- a/src/libdanbooru/danboorupost.h +++ b/src/libdanbooru/danboorupost.h @@ -45,7 +45,6 @@ #include "danbooru.h" -class QPixmap; namespace Danbooru { @@ -78,7 +77,7 @@ namespace Danbooru { Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl) public: - + /** * @brief Ratings for a Danbooru item * @@ -91,10 +90,10 @@ namespace Danbooru { Explicit = 4 /**< Explicit material **/ }; - + private: - const QPixmap m_pixmap; + QPixmap m_pixmap; // basic features of a post @@ -106,7 +105,7 @@ namespace Danbooru { QUrl m_url; QUrl m_thumbnailUrl; QSet m_tags; - Ratings m_rating; + DanbooruPost::Rating m_rating; static const QMap RATING_MAP; @@ -193,18 +192,18 @@ namespace Danbooru { /** * @return A pointer to the thumbnail's pixmap. **/ - const QPixmap pixmap() const; + QPixmap pixmap() const; /** * @return The current post's rating. **/ - const Ratings rating() const; + const Rating rating() const; /** * Set the post's pixmap to a specific QPixmap instance's pointer. * **/ - void setPixmap(const QPixmap pixmap); + void setPixmap(const QPixmap& pixmap); /** * @return A string representation of the post. @@ -213,7 +212,7 @@ namespace Danbooru { const QString toString(); }; - + Q_DECLARE_FLAGS(Ratings, DanbooruPost::Rating) Q_DECLARE_OPERATORS_FOR_FLAGS(Ratings)