diff --git a/src/libdanbooru/danbooruservice.cpp b/src/libdanbooru/danbooruservice.cpp index ccc9bc1..eb4bb7e 100644 --- a/src/libdanbooru/danbooruservice.cpp +++ b/src/libdanbooru/danbooruservice.cpp @@ -329,6 +329,16 @@ int DanbooruService::maxPosts() const return m_maxPosts; } +int DanbooruService::minimumWidth() const +{ + return m_minimumWidth > 0 ? m_minimumWidth: -1; +} + +int DanbooruService::minimumHeight() const +{ + return m_minimumHeight > 0 ? m_minimumHeight: -1; +} + void DanbooruService::nextPostPage() { m_currentPage++; @@ -449,6 +459,18 @@ void DanbooruService::processPostList(KJob *job) continue; } + if (post->width() < minimumWidth()) { + m_postsToFetch--; + delete post; + continue; + } + + if (post->height() < minimumHeight()) { + m_postsToFetch--; + delete post; + continue; + } + QPixmap pix; // qCDebug(LIBDANBOORU) << "About to donwload images"; @@ -618,4 +640,16 @@ void DanbooruService::setCurrentPage(int page) m_currentPage = page; } +void Danbooru::DanbooruService::setResolution(unsigned int width, unsigned int height) +{ + if (width > 0) { + m_minimumWidth = width; + } + + if (height > 0) { + m_minimumHeight = height; + } +} + + } // namespace Danbooru diff --git a/src/libdanbooru/danbooruservice.h b/src/libdanbooru/danbooruservice.h index 5a617b8..a6d1beb 100644 --- a/src/libdanbooru/danbooruservice.h +++ b/src/libdanbooru/danbooruservice.h @@ -93,6 +93,8 @@ private: DanbooruPost::Ratings m_maxRating; int m_maxPosts; int m_currentPage; + unsigned int m_minimumHeight = 0; + unsigned int m_minimumWidth = 0; QStringList m_tags; unsigned int m_postsToFetch; // To tell when to quit @@ -207,6 +209,10 @@ public: **/ QStringList postTags() const; + int minimumWidth() const; + + int minimumHeight() const; + /** * @brief Resets the service to the default state, clearing the page counters. **/ @@ -282,6 +288,11 @@ public: void setPostTags(const QStringList &tags); + void setResolution(unsigned int width = 0, unsigned int height = 0); + + void setMinimumWidth(unsigned int width) { m_minimumWidth = width; }; + void setMinimumHeight(unsigned int height) { m_minimumHeight = height; }; + private Q_SLOTS: void processPostList(KJob *job); void processTagList(KJob *job);