Updates
This commit is contained in:
parent
c8dda3d020
commit
3ef9d0f281
1 changed files with 33 additions and 20 deletions
|
@ -17,62 +17,75 @@
|
||||||
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
|
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "test_konachan.h"
|
#include "test_service.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <KImageCache>
|
||||||
|
|
||||||
namespace Danbooru {
|
namespace Danbooru {
|
||||||
|
|
||||||
KonachanServiceTest::KonachanServiceTest(QUrl boardUrl):
|
DanbooruServiceTest::DanbooruServiceTest(QUrl boardUrl, Danbooru::ApiType type):
|
||||||
m_service(0),
|
m_service(0),
|
||||||
m_label(new QLabel())
|
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->setParent(this);
|
||||||
m_service->setMaximumAllowedRating(DanbooruPost::Explicit);
|
m_service->setMaximumAllowedRating(Danbooru::Questionable);
|
||||||
m_service->setMaxPosts(1);
|
m_service->setMaxPosts(2);
|
||||||
connect(m_service, &DanbooruServiceBase::postDownloaded, this, &KonachanServiceTest::showPostData);
|
m_service->setImageCache(cache);
|
||||||
connect(m_service, &DanbooruServiceBase::poolDownloaded, this, &KonachanServiceTest::showPoolData);
|
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_service;
|
||||||
delete m_label;
|
delete m_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KonachanServiceTest::testPostService() {
|
void DanbooruServiceTest::testPostService() {
|
||||||
m_service->getPostList();
|
m_service->getPostList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KonachanServiceTest::testPoolService() {
|
void DanbooruServiceTest::testPoolService() {
|
||||||
m_service->getPoolList(1 /*limit */);
|
m_service->getPoolList(1 /*limit */);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KonachanServiceTest::testPoolRetrieval(int postid) {
|
void DanbooruServiceTest::testPoolRetrieval(int postid) {
|
||||||
|
qDebug() << "getting ID" << postid;
|
||||||
m_service->getPool(postid);
|
m_service->getPool(postid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KonachanServiceTest::showPostData(DanbooruPost* post) {
|
void DanbooruServiceTest::showPostData(DanbooruPost* post) {
|
||||||
qDebug() << "Post File URL" << post->fileUrl().toString();
|
qDebug() << post->toString();
|
||||||
qDebug() << "Post ID" << post->id();
|
|
||||||
qDebug() << "Post tags" << post->tags();
|
|
||||||
qDebug() << "Post rating" << post->rating();
|
|
||||||
m_label->setPixmap(post->pixmap());
|
m_label->setPixmap(post->pixmap());
|
||||||
m_label->show();
|
m_label->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KonachanServiceTest::showPoolData(DanbooruPool* pool) {
|
void DanbooruServiceTest::showPoolData(DanbooruPool* pool) {
|
||||||
qDebug() << "----";
|
qDebug() << "----";
|
||||||
qDebug() << "Pool ID" << pool->id();
|
qDebug() << "Pool ID" << pool->id();
|
||||||
qDebug() << "Pool name" << pool->name();
|
qDebug() << "Pool name" << pool->name();
|
||||||
qDebug() << "Pool description" << pool->description();
|
qDebug() << "Pool description" << pool->description();
|
||||||
qDebug() << "Pool post count" << pool->postCount();
|
qDebug() << "Pool post count" << pool->postCount();
|
||||||
// qDebug() << "Post IDs" << pool->posts();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DanbooruServiceBase* KonachanServiceTest::service() const {
|
DanbooruServiceBase* DanbooruServiceTest::service() const {
|
||||||
return m_service;
|
return m_service;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Danbooru
|
} // namespace Danbooru
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue