From 615e594e39d11f90d6796e1c6e38e1a54f79465f Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Sun, 22 Mar 2015 00:32:48 +0100 Subject: [PATCH] Initial experimental work for multiple Danbooru APIs --- src/libdanbooru/servicebase.cpp | 1 + src/libdanbooru/servicebase.h | 133 ++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/libdanbooru/servicebase.cpp create mode 100644 src/libdanbooru/servicebase.h diff --git a/src/libdanbooru/servicebase.cpp b/src/libdanbooru/servicebase.cpp new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/libdanbooru/servicebase.cpp @@ -0,0 +1 @@ + diff --git a/src/libdanbooru/servicebase.h b/src/libdanbooru/servicebase.h new file mode 100644 index 0000000..45a00db --- /dev/null +++ b/src/libdanbooru/servicebase.h @@ -0,0 +1,133 @@ +/* + * Copyright 2015 Luca Beltrame + * + * This file is part of Danbooru Client. + * + * Danbooru Client 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 3 of the License, or + * (at your option) any later version. + * + * Danbooru Client 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 Danbooru Client. If not, see . + */ + +#ifndef DANBOORU_SERVICEBASE_H +#define DANBOORU_SERVICEBASE_H + +// Qt + +#include +#include +#include +#include + +// KF5 + +#include + +// Own + +#include "danbooru.h" +#include "danboorupost.h" +#include "danboorutag.h" + + +namespace Danbooru +{ + +class DanbooruServiceBase: public QObject +{ + +Q_OBJECT + +public: + + explicit DanbooruServiceBase(); + ~DanbooruServiceBase(); + + const QStringList allowedRatings() const; + const int apiVersion() const; + const QSet blacklist() const; + int currentPage() const; + + virtual void getPostList() = 0; + virtual void getPoolList() = 0; + virtual void getPool(int poolId, int page = 1) = 0; + virtual void getTagList(int limit = 10, QString name = "") = 0; + virtual void getRelatedTags(const QStringList &tags, + DanbooruTag::TagType tagType = DanbooruTag::General) = 0; + + const DanbooruPost::Ratings maximumAllowedRating() const; + Q_INVOKABLE void nextPostPage(); + Q_INVOKABLE void nextPoolPage(); + QStringList postTags() const; + void reset(); + + void setBlacklist(const QStringList &blacklist); + void setBoardUrl(const QUrl &url); + void setCurrentPage(int page); + void setImageCache(KImageCache *cache); + void setMaximumAllowedRating(DanbooruPost::Rating rating); + void setMaxPosts(int number); + void setPassword(const QString &password); + void setPostTags(const QStringList &tags); + void setUserName(const QString &username); + +Q_SIGNALS: + + /** + * Emitted when there are no more posts to download. + * + * Connect to this signal to know when downloading is complete. + * + **/ + void postDownloadFinished(); + + /** + * Emitted when there are no more pools to download. + **/ + void poolDownloadFinished(); + + /** + * Emitted when a download error occurred. + * + * The parameter contains the error string. + * + **/ + void downloadError(QString error); + + /** + * Emitted when a post has been downloaded. + * + * The parameter contains a pointer to the post that has been + * downloaded. + **/ + void postDownloaded(Danbooru::DanbooruPost *post); + + /** + * Emitted when a pool has been downloaded. + * + * The parameter contains a pointer to the pool that has been + * downloaded. + **/ + void poolDownloaded(Danbooru::DanbooruPool *pool); + + /** + * Emitted when a tag has been downloaded. + * + * The parameter contains a pointer to the tag that has been + * downloaded. + **/ + void tagDownloaded(Danbooru::DanbooruTag *tag); + +}; + +} + +#endif \ No newline at end of file