Add setters for board url, cache, username, and password to DanbooruService
Remove also a useless constructor
This commit is contained in:
parent
d20cc5d3f5
commit
d94084bc25
2 changed files with 56 additions and 16 deletions
|
@ -58,17 +58,7 @@ const QString DanbooruService::ARTIST_URL = "artist/index.json";
|
||||||
const QString DanbooruService::POOL_DATA_URL = "pool/show.xml";
|
const QString DanbooruService::POOL_DATA_URL = "pool/show.xml";
|
||||||
const QString DanbooruService::RELATED_TAG_URL = "tag/related.json";
|
const QString DanbooruService::RELATED_TAG_URL = "tag/related.json";
|
||||||
|
|
||||||
DanbooruService::DanbooruService(QObject *parent):
|
DanbooruService::DanbooruService(QUrl boardUrl, QString username,
|
||||||
QObject(parent),
|
|
||||||
m_url(QUrl()),
|
|
||||||
m_username(QString()),
|
|
||||||
m_password(QString()),
|
|
||||||
m_maxRating(DanbooruPost::Safe),
|
|
||||||
m_postsToFetch(0),
|
|
||||||
m_cache(0){
|
|
||||||
}
|
|
||||||
|
|
||||||
DanbooruService::DanbooruService(QUrl &boardUrl, QString username,
|
|
||||||
QString password, KImageCache *cache,
|
QString password, KImageCache *cache,
|
||||||
QObject *parent):
|
QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
|
@ -92,6 +82,8 @@ void DanbooruService::getPostList(int page, QStringList tags, int limit)
|
||||||
|
|
||||||
// We can't fetch more than 100 items, API limitation
|
// We can't fetch more than 100 items, API limitation
|
||||||
|
|
||||||
|
qDebug() << "Fetching with URL" << m_url;
|
||||||
|
|
||||||
limit = limit > 100 ? 100 : limit;
|
limit = limit > 100 ? 100 : limit;
|
||||||
|
|
||||||
QMap<QString, QString> parameters;
|
QMap<QString, QString> parameters;
|
||||||
|
@ -102,7 +94,7 @@ void DanbooruService::getPostList(int page, QStringList tags, int limit)
|
||||||
QUrl danbooruUrl = requestUrl(m_url, POST_URL, m_username,
|
QUrl danbooruUrl = requestUrl(m_url, POST_URL, m_username,
|
||||||
m_password, parameters, tags);
|
m_password, parameters, tags);
|
||||||
|
|
||||||
// qDebug() << "Final constructed post URL" << danbooruUrl.url();
|
qDebug() << "Final constructed post URL" << danbooruUrl;
|
||||||
|
|
||||||
KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
|
KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
|
||||||
KIO::HideProgressInfo);
|
KIO::HideProgressInfo);
|
||||||
|
@ -455,7 +447,9 @@ void DanbooruService::processPostList(KJob *job)
|
||||||
|
|
||||||
QPixmap pix;
|
QPixmap pix;
|
||||||
|
|
||||||
if (m_cache->findPixmap(post->thumbnailUrl().url(), &pix)) {
|
qDebug() << "About to donwload images";
|
||||||
|
|
||||||
|
if (m_cache && m_cache->findPixmap(post->thumbnailUrl().url(), &pix)) {
|
||||||
|
|
||||||
post->setPixmap(pix);
|
post->setPixmap(pix);
|
||||||
Q_EMIT(postDownloaded(post));
|
Q_EMIT(postDownloaded(post));
|
||||||
|
@ -531,5 +525,24 @@ void DanbooruService::downloadAllTags(KJob *job)
|
||||||
Q_UNUSED(job)
|
Q_UNUSED(job)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DanbooruService::setBoardUrl(const QUrl& url)
|
||||||
|
{
|
||||||
|
m_url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DanbooruService::setUserName(const QString& username)
|
||||||
|
{
|
||||||
|
m_username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DanbooruService::setPassword(const QString& password)
|
||||||
|
{
|
||||||
|
m_password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DanbooruService::setImageCache(KImageCache* cache)
|
||||||
|
{
|
||||||
|
m_cache = cache;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Danbooru
|
} // namespace Danbooru
|
||||||
|
|
|
@ -104,8 +104,6 @@ private:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
DanbooruService(QObject *parent = 0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Construct a default instance of the service.
|
* @brief Construct a default instance of the service.
|
||||||
*
|
*
|
||||||
|
@ -117,7 +115,7 @@ public:
|
||||||
* @param parent The parent QObject
|
* @param parent The parent QObject
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
DanbooruService(QUrl &boardUrl, QString username = QString(),
|
DanbooruService(QUrl boardUrl=QUrl(), QString username = QString(),
|
||||||
QString password = QString(), KImageCache *cache = 0,
|
QString password = QString(), KImageCache *cache = 0,
|
||||||
QObject *parent = 0);
|
QObject *parent = 0);
|
||||||
|
|
||||||
|
@ -212,6 +210,35 @@ public:
|
||||||
**/
|
**/
|
||||||
void setBlackList(QStringList blacklist);
|
void setBlackList(QStringList blacklist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the board URL to connect to.
|
||||||
|
*
|
||||||
|
* @param url The URL to connect to.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void setBoardUrl(const QUrl& url);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set an image cache to use.
|
||||||
|
*
|
||||||
|
* @param cache A pointer to an intsnaec of KImageCache.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void setImageCache(KImageCache *cache);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set username for login.
|
||||||
|
*
|
||||||
|
* @param username The username to use.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void setUserName(const QString& username);
|
||||||
|
|
||||||
|
void setPassword(const QString& password);
|
||||||
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void processPostList(KJob *job);
|
void processPostList(KJob *job);
|
||||||
void downloadAllTags(KJob *job);
|
void downloadAllTags(KJob *job);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue