Implement most missing functions
This commit is contained in:
parent
816b370302
commit
869620d6f6
2 changed files with 217 additions and 93 deletions
|
@ -31,42 +31,32 @@
|
|||
*
|
||||
**/
|
||||
|
||||
// Qt
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QSet>
|
||||
|
||||
// KDE
|
||||
|
||||
#include <KUrl>
|
||||
#include <KIO/JobClasses>
|
||||
|
||||
// Own
|
||||
|
||||
#include "danbooru.h"
|
||||
|
||||
class QPixmap;
|
||||
class KUrl;
|
||||
class KJob;
|
||||
|
||||
/**
|
||||
* @brief The Danbooru namespace.
|
||||
*
|
||||
**/
|
||||
namespace Danbooru {
|
||||
|
||||
/**
|
||||
* @brief Types of tags
|
||||
*
|
||||
* A Danbooru tag is not simply a string, but carries some (limited)
|
||||
* semantic information. In particular, tags are organized in what they
|
||||
* refer to, either something related to the image itself, or to the
|
||||
* artist that drew it, or the copyrights associated to the image, or even
|
||||
* the characters that are represented in it.
|
||||
*
|
||||
**/
|
||||
enum TagType {
|
||||
General, /**< Generic tags **/
|
||||
Artist, /**< Tags related to artists **/
|
||||
Copyright, /**<Tags related to copyrights **/
|
||||
Character /**<Tags related to characters **/
|
||||
};
|
||||
namespace Danbooru {
|
||||
|
||||
class DanbooruPost;
|
||||
class DanbooruPool;
|
||||
class DanbooruTag;
|
||||
|
||||
using KIO::StoredTransferJob;
|
||||
|
||||
|
@ -96,29 +86,16 @@ namespace Danbooru {
|
|||
static const QString POOL_DATA_URL;
|
||||
static const QString RELATED_TAG_URL;
|
||||
|
||||
// Ratings
|
||||
|
||||
static const QMap<QString, QStringList> RATINGS;
|
||||
|
||||
// member variables
|
||||
|
||||
KUrl m_url;
|
||||
QString m_username;
|
||||
QString m_password;
|
||||
QStringList m_blacklist;
|
||||
QString m_maxRating;
|
||||
QSet<QString> m_blacklist;
|
||||
Ratings m_maxRating;
|
||||
|
||||
unsigned int m_currentPosts; // To tell when to quit
|
||||
|
||||
// private functions
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
**/
|
||||
static const QMap< QString, QStringList > initRatings();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -169,10 +146,15 @@ namespace Danbooru {
|
|||
/**
|
||||
* @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="");
|
||||
|
@ -184,7 +166,7 @@ namespace Danbooru {
|
|||
* @param tagType The type of tag to query for
|
||||
**/
|
||||
void getRelatedTags(QStringList tags=QStringList(),
|
||||
TagType tagType=General);
|
||||
Danbooru::TagType tagType=General);
|
||||
|
||||
/**
|
||||
* @return The currently allowed ratings when downloading posts.
|
||||
|
@ -194,12 +176,14 @@ namespace Danbooru {
|
|||
/**
|
||||
* @return The maximum allowed rating for a post.
|
||||
**/
|
||||
const QString maximumAllowedRating() const;
|
||||
const Ratings maximumAllowedRating() const;
|
||||
|
||||
/**
|
||||
* @return The currently blacklisted tags.
|
||||
**/
|
||||
QStringList blacklist() const;
|
||||
const QSet<QString> blacklist() const;
|
||||
|
||||
void setBlacklist(const QSet<QString>& blacklist);
|
||||
|
||||
/**
|
||||
* @brief Set the maximum allowed rating for the board.
|
||||
|
@ -208,7 +192,7 @@ namespace Danbooru {
|
|||
* downloaded.
|
||||
*
|
||||
**/
|
||||
void setMaximumAllowedRating(QString rating);
|
||||
void setMaximumAllowedRating(const Ratings& rating);
|
||||
|
||||
/**
|
||||
* @brief Set the tag blacklist.
|
||||
|
@ -221,6 +205,7 @@ namespace Danbooru {
|
|||
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);
|
||||
|
@ -258,6 +243,8 @@ namespace Danbooru {
|
|||
void postDownloaded(Danbooru::DanbooruPost* post);
|
||||
|
||||
void poolDownloaded(Danbooru::DanbooruPool* pool);
|
||||
|
||||
void tagDownloaded(Danbooru::DanbooruTag* tag);
|
||||
// TODO: Tags and similar
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue