This commit is contained in:
Luca Beltrame 2018-08-24 18:27:47 +02:00
parent c8dda3d020
commit 3ef9d0f281
Signed by: einar
GPG key ID: 8DF631FD021DB0C5

View file

@ -17,62 +17,75 @@
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
*/
#include "test_konachan.h"
#include "test_service.h"
#include <QLabel>
#include <KImageCache>
namespace Danbooru {
KonachanServiceTest::KonachanServiceTest(QUrl boardUrl):
DanbooruServiceTest::DanbooruServiceTest(QUrl boardUrl, Danbooru::ApiType type):
m_service(0),
m_label(new QLabel())
{
m_service = new KonachanDanbooruService(boardUrl);
auto cache = new KImageCache("test-data", 48000000);
cache->clear();
cache->setPixmapCaching(true);
switch(type) {
case Danbooru::MoeBooru:
m_service = new MoebooruService(boardUrl);
break;
case Danbooru::Danbooru:
m_service = new DanbooruService(boardUrl);
break;
};
qDebug() << m_service->apiType() << "type";
m_service->setParent(this);
m_service->setMaximumAllowedRating(DanbooruPost::Explicit);
m_service->setMaxPosts(1);
connect(m_service, &DanbooruServiceBase::postDownloaded, this, &KonachanServiceTest::showPostData);
connect(m_service, &DanbooruServiceBase::poolDownloaded, this, &KonachanServiceTest::showPoolData);
m_service->setMaximumAllowedRating(Danbooru::Questionable);
m_service->setMaxPosts(2);
m_service->setImageCache(cache);
connect(m_service, &DanbooruServiceBase::postDownloaded, this, &DanbooruServiceTest::showPostData);
connect(m_service, &DanbooruServiceBase::poolDownloaded, this, &DanbooruServiceTest::showPoolData);
}
KonachanServiceTest::~KonachanServiceTest() {
DanbooruServiceTest::~DanbooruServiceTest() {
delete m_service;
delete m_label;
}
void KonachanServiceTest::testPostService() {
void DanbooruServiceTest::testPostService() {
m_service->getPostList();
}
void KonachanServiceTest::testPoolService() {
void DanbooruServiceTest::testPoolService() {
m_service->getPoolList(1 /*limit */);
}
void KonachanServiceTest::testPoolRetrieval(int postid) {
void DanbooruServiceTest::testPoolRetrieval(int postid) {
qDebug() << "getting ID" << postid;
m_service->getPool(postid);
}
void KonachanServiceTest::showPostData(DanbooruPost* post) {
qDebug() << "Post File URL" << post->fileUrl().toString();
qDebug() << "Post ID" << post->id();
qDebug() << "Post tags" << post->tags();
qDebug() << "Post rating" << post->rating();
void DanbooruServiceTest::showPostData(DanbooruPost* post) {
qDebug() << post->toString();
m_label->setPixmap(post->pixmap());
m_label->show();
}
void KonachanServiceTest::showPoolData(DanbooruPool* pool) {
void DanbooruServiceTest::showPoolData(DanbooruPool* pool) {
qDebug() << "----";
qDebug() << "Pool ID" << pool->id();
qDebug() << "Pool name" << pool->name();
qDebug() << "Pool description" << pool->description();
qDebug() << "Pool post count" << pool->postCount();
// qDebug() << "Post IDs" << pool->posts();
}
DanbooruServiceBase* KonachanServiceTest::service() const {
DanbooruServiceBase* DanbooruServiceTest::service() const {
return m_service;
}
} // namespace Danbooru
} // namespace Danbooru