Support for minimum height and width in libdanbooru
This will allow to filter posts with less than required minimum height and width. Currently this is done client-side, I don't plan on doing checks on the API until/if the multiple API branch is merged.
This commit is contained in:
parent
e98d99a5e1
commit
76330d4416
2 changed files with 45 additions and 0 deletions
|
@ -329,6 +329,16 @@ int DanbooruService::maxPosts() const
|
||||||
return m_maxPosts;
|
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()
|
void DanbooruService::nextPostPage()
|
||||||
{
|
{
|
||||||
m_currentPage++;
|
m_currentPage++;
|
||||||
|
@ -449,6 +459,18 @@ void DanbooruService::processPostList(KJob *job)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (post->width() < minimumWidth()) {
|
||||||
|
m_postsToFetch--;
|
||||||
|
delete post;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (post->height() < minimumHeight()) {
|
||||||
|
m_postsToFetch--;
|
||||||
|
delete post;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap pix;
|
QPixmap pix;
|
||||||
|
|
||||||
// qCDebug(LIBDANBOORU) << "About to donwload images";
|
// qCDebug(LIBDANBOORU) << "About to donwload images";
|
||||||
|
@ -618,4 +640,16 @@ void DanbooruService::setCurrentPage(int page)
|
||||||
m_currentPage = 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
|
} // namespace Danbooru
|
||||||
|
|
|
@ -93,6 +93,8 @@ private:
|
||||||
DanbooruPost::Ratings m_maxRating;
|
DanbooruPost::Ratings m_maxRating;
|
||||||
int m_maxPosts;
|
int m_maxPosts;
|
||||||
int m_currentPage;
|
int m_currentPage;
|
||||||
|
unsigned int m_minimumHeight = 0;
|
||||||
|
unsigned int m_minimumWidth = 0;
|
||||||
QStringList m_tags;
|
QStringList m_tags;
|
||||||
|
|
||||||
unsigned int m_postsToFetch; // To tell when to quit
|
unsigned int m_postsToFetch; // To tell when to quit
|
||||||
|
@ -207,6 +209,10 @@ public:
|
||||||
**/
|
**/
|
||||||
QStringList postTags() const;
|
QStringList postTags() const;
|
||||||
|
|
||||||
|
int minimumWidth() const;
|
||||||
|
|
||||||
|
int minimumHeight() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Resets the service to the default state, clearing the page counters.
|
* @brief Resets the service to the default state, clearing the page counters.
|
||||||
**/
|
**/
|
||||||
|
@ -282,6 +288,11 @@ public:
|
||||||
|
|
||||||
void setPostTags(const QStringList &tags);
|
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:
|
private Q_SLOTS:
|
||||||
void processPostList(KJob *job);
|
void processPostList(KJob *job);
|
||||||
void processTagList(KJob *job);
|
void processTagList(KJob *job);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue