Run astyle-kdelibs on the source
This commit is contained in:
parent
4b85d63d68
commit
39aac8c95b
22 changed files with 1227 additions and 1264 deletions
|
@ -24,7 +24,6 @@
|
|||
#ifndef DANBOORUSERVICE_H
|
||||
#define DANBOORUSERVICE_H
|
||||
|
||||
|
||||
/**
|
||||
* @brief Classes to interact with Danbooru boards
|
||||
* @file danbooruservice.h
|
||||
|
@ -56,214 +55,214 @@ class KJob;
|
|||
|
||||
using Danbooru::DanbooruTag;
|
||||
|
||||
namespace Danbooru {
|
||||
namespace Danbooru
|
||||
{
|
||||
|
||||
class DanbooruPool;
|
||||
class DanbooruPool;
|
||||
|
||||
using KIO::StoredTransferJob;
|
||||
using KIO::StoredTransferJob;
|
||||
|
||||
/**
|
||||
* @brief A class which provides a wrapper around Danbooru's RESTful API.
|
||||
*
|
||||
* This class provides access to Danbooru-based image boards
|
||||
* by making the appropriate RESTful calls to the service and then
|
||||
* retrieving and parsing the reuslts.
|
||||
*
|
||||
* @author Luca Beltrame (lbeltrame@kde.org)
|
||||
*
|
||||
*
|
||||
**/
|
||||
class DanbooruService : public QObject
|
||||
{
|
||||
/**
|
||||
* @brief A class which provides a wrapper around Danbooru's RESTful API.
|
||||
*
|
||||
* This class provides access to Danbooru-based image boards
|
||||
* by making the appropriate RESTful calls to the service and then
|
||||
* retrieving and parsing the reuslts.
|
||||
*
|
||||
* @author Luca Beltrame (lbeltrame@kde.org)
|
||||
*
|
||||
*
|
||||
**/
|
||||
class DanbooruService : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
// URL fragments
|
||||
// URL fragments
|
||||
|
||||
static const QString POST_URL;
|
||||
static const QString TAG_URL;
|
||||
static const QString POOL_URL;
|
||||
static const QString ARTIST_URL;
|
||||
static const QString POOL_DATA_URL;
|
||||
static const QString RELATED_TAG_URL;
|
||||
static const QString POST_URL;
|
||||
static const QString TAG_URL;
|
||||
static const QString POOL_URL;
|
||||
static const QString ARTIST_URL;
|
||||
static const QString POOL_DATA_URL;
|
||||
static const QString RELATED_TAG_URL;
|
||||
|
||||
// member variables
|
||||
// member variables
|
||||
|
||||
QUrl m_url;
|
||||
QString m_username;
|
||||
QString m_password;
|
||||
QSet<QString> m_blacklist;
|
||||
DanbooruPost::Ratings m_maxRating;
|
||||
QUrl m_url;
|
||||
QString m_username;
|
||||
QString m_password;
|
||||
QSet<QString> m_blacklist;
|
||||
DanbooruPost::Ratings m_maxRating;
|
||||
|
||||
unsigned int m_postsToFetch; // To tell when to quit
|
||||
unsigned int m_postsToFetch; // To tell when to quit
|
||||
|
||||
KImageCache* m_cache; // Pixmap cache
|
||||
KImageCache *m_cache; // Pixmap cache
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Construct a default instance of the service.
|
||||
*
|
||||
* @param boardUrl The URL to connect to.
|
||||
* @param username Username to use (optional)
|
||||
* @param password Password to use (optional)
|
||||
* @param cache A pointer to a KImageCache instance to enable caching
|
||||
* of downloaded pixmaps.
|
||||
* @param parent The parent QObject
|
||||
*
|
||||
**/
|
||||
DanbooruService(QUrl& boardUrl, QString username = QString(),
|
||||
QString password = QString(), KImageCache* cache = 0,
|
||||
QObject* parent = 0);
|
||||
/**
|
||||
* @brief Construct a default instance of the service.
|
||||
*
|
||||
* @param boardUrl The URL to connect to.
|
||||
* @param username Username to use (optional)
|
||||
* @param password Password to use (optional)
|
||||
* @param cache A pointer to a KImageCache instance to enable caching
|
||||
* of downloaded pixmaps.
|
||||
* @param parent The parent QObject
|
||||
*
|
||||
**/
|
||||
DanbooruService(QUrl &boardUrl, QString username = QString(),
|
||||
QString password = QString(), KImageCache *cache = 0,
|
||||
QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* Default destructor.
|
||||
**/
|
||||
~DanbooruService();
|
||||
/**
|
||||
* Default destructor.
|
||||
**/
|
||||
~DanbooruService();
|
||||
|
||||
/**
|
||||
*@brief Get posts from a the board.
|
||||
*
|
||||
* @param page The page containing posts (default: 1)
|
||||
* @param tags The specific tags to query for (default: all tags)
|
||||
* @param limit The number of posts to fetch (maximum 100)
|
||||
*
|
||||
**/
|
||||
void getPostList(int page=1, QStringList tags=QStringList(),
|
||||
int limit=100);
|
||||
/**
|
||||
*@brief Get posts from a the board.
|
||||
*
|
||||
* @param page The page containing posts (default: 1)
|
||||
* @param tags The specific tags to query for (default: all tags)
|
||||
* @param limit The number of posts to fetch (maximum 100)
|
||||
*
|
||||
**/
|
||||
void getPostList(int page = 1, QStringList tags = QStringList(),
|
||||
int limit = 100);
|
||||
|
||||
/**
|
||||
* @brief Get a list of pools from the board.
|
||||
*
|
||||
* @param page The page to get pools from (default: 1)
|
||||
*
|
||||
**/
|
||||
void getPoolList(int page = 1);
|
||||
/**
|
||||
* @brief Get a list of pools from the board.
|
||||
*
|
||||
* @param page The page to get pools from (default: 1)
|
||||
*
|
||||
**/
|
||||
void getPoolList(int page = 1);
|
||||
|
||||
/**
|
||||
* @brief Get the posts associated with a specific pool ID.
|
||||
*
|
||||
* @param poolId The ID of the pool to fetch posts from.
|
||||
* @param page The page of the pool posts (if > 100)
|
||||
*
|
||||
**/
|
||||
void getPool(int poolId, int page=1);
|
||||
/**
|
||||
* @brief Get the posts associated with a specific pool ID.
|
||||
*
|
||||
* @param poolId The ID of the pool to fetch posts from.
|
||||
* @param page The page of the pool posts (if > 100)
|
||||
*
|
||||
**/
|
||||
void getPool(int poolId, int page = 1);
|
||||
|
||||
/**
|
||||
* @brief Get a list of tags from the board
|
||||
*
|
||||
* If name is supplied, a list of tags including the exact name of the
|
||||
* tag is fetched from Danbooru, otherwise the most recent tags are
|
||||
* retrieved.
|
||||
*
|
||||
* The tagDownloaded signal is emitted every time a tag has been
|
||||
* retrieved.
|
||||
*
|
||||
* @param limit The number of tags to get.
|
||||
* @param name The name of the tag to retrieve, or an empty string
|
||||
*
|
||||
**/
|
||||
void getTagList(int limit=10, QString name="");
|
||||
/**
|
||||
* @brief Get a list of tags from the board
|
||||
*
|
||||
* If name is supplied, a list of tags including the exact name of the
|
||||
* tag is fetched from Danbooru, otherwise the most recent tags are
|
||||
* retrieved.
|
||||
*
|
||||
* The tagDownloaded signal is emitted every time a tag has been
|
||||
* retrieved.
|
||||
*
|
||||
* @param limit The number of tags to get.
|
||||
* @param name The name of the tag to retrieve, or an empty string
|
||||
*
|
||||
**/
|
||||
void getTagList(int limit = 10, QString name = "");
|
||||
|
||||
/**
|
||||
* @brief Get tags related to a specific, user supplied list.
|
||||
*
|
||||
* @param tags The tags to query for related terms
|
||||
* @param tagType The type of tag to query for
|
||||
**/
|
||||
void getRelatedTags(const QStringList& tags, DanbooruTag::TagType tagType = DanbooruTag::General);
|
||||
/**
|
||||
* @brief Get tags related to a specific, user supplied list.
|
||||
*
|
||||
* @param tags The tags to query for related terms
|
||||
* @param tagType The type of tag to query for
|
||||
**/
|
||||
void getRelatedTags(const QStringList &tags, DanbooruTag::TagType tagType = DanbooruTag::General);
|
||||
|
||||
/**
|
||||
* @return The currently allowed ratings when downloading posts.
|
||||
**/
|
||||
const QStringList allowedRatings() const;
|
||||
/**
|
||||
* @return The currently allowed ratings when downloading posts.
|
||||
**/
|
||||
const QStringList allowedRatings() const;
|
||||
|
||||
/**
|
||||
* @return The maximum allowed rating for a post.
|
||||
**/
|
||||
const DanbooruPost::Ratings maximumAllowedRating() const;
|
||||
/**
|
||||
* @return The maximum allowed rating for a post.
|
||||
**/
|
||||
const DanbooruPost::Ratings maximumAllowedRating() const;
|
||||
|
||||
/**
|
||||
* @return The currently blacklisted tags.
|
||||
**/
|
||||
const QSet<QString> blacklist() const;
|
||||
/**
|
||||
* @return The currently blacklisted tags.
|
||||
**/
|
||||
const QSet<QString> blacklist() const;
|
||||
|
||||
void setBlacklist(const QSet<QString>& blacklist);
|
||||
void setBlacklist(const QSet<QString> &blacklist);
|
||||
|
||||
/**
|
||||
* @brief Set the maximum allowed rating for the board.
|
||||
*
|
||||
* Posts whose rating is higher than the maximuk allowed will not be
|
||||
* downloaded.
|
||||
*
|
||||
**/
|
||||
void setMaximumAllowedRating(DanbooruPost::Rating rating);
|
||||
/**
|
||||
* @brief Set the maximum allowed rating for the board.
|
||||
*
|
||||
* Posts whose rating is higher than the maximuk allowed will not be
|
||||
* downloaded.
|
||||
*
|
||||
**/
|
||||
void setMaximumAllowedRating(DanbooruPost::Rating rating);
|
||||
|
||||
/**
|
||||
* @brief Set the tag blacklist.
|
||||
*
|
||||
* If a tag is in the blacklist, posts tagged with it will not be downloaded.
|
||||
*
|
||||
**/
|
||||
void setBlackList(QStringList blacklist);
|
||||
/**
|
||||
* @brief Set the tag blacklist.
|
||||
*
|
||||
* If a tag is in the blacklist, posts tagged with it will not be downloaded.
|
||||
*
|
||||
**/
|
||||
void setBlackList(QStringList blacklist);
|
||||
|
||||
private Q_SLOTS:
|
||||
void processPostList(KJob* job);
|
||||
void processPoolList(KJob* job);
|
||||
void processTagList(KJob* job);
|
||||
void processRelatedTagList(KJob* job);
|
||||
void downloadThumbnail(KJob* job);
|
||||
void downloadAllTags(KJob* job);
|
||||
private Q_SLOTS:
|
||||
void processPostList(KJob *job);
|
||||
void processPoolList(KJob *job);
|
||||
void processTagList(KJob *job);
|
||||
void processRelatedTagList(KJob *job);
|
||||
void downloadThumbnail(KJob *job);
|
||||
void downloadAllTags(KJob *job);
|
||||
|
||||
Q_SIGNALS:
|
||||
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 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 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 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 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 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);
|
||||
|
||||
/**
|
||||
* 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 // DANBOORUSERVICE_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue