Add a basic pool widget
More work is needed to make it workable: - Download pools - Clearing the thumbnail area when things are fetched - Find a way to get more posts from the same pool
This commit is contained in:
parent
8ed916ef20
commit
1af084647f
2 changed files with 35 additions and 4 deletions
|
@ -27,6 +27,7 @@
|
|||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include <kactioncollection.h>
|
||||
#include <KStandardAction>
|
||||
|
@ -36,7 +37,9 @@
|
|||
|
||||
#include "libdanbooru/danbooruservice.h"
|
||||
#include "libdanbooru/danboorupost.h"
|
||||
#include "libdanbooru/danboorupool.h"
|
||||
#include "model/danboorupostmodel.h"
|
||||
#include "model/danboorupoolmodel.h"
|
||||
#include "mainwindow.h"
|
||||
#include "danbooruconnectwidget.h"
|
||||
#include "danboorusettings.h"
|
||||
|
@ -55,7 +58,9 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
: KXmlGuiWindow(parent),
|
||||
m_view(new QQuickWidget(this)),
|
||||
m_model(new DanbooruPostModel(this)),
|
||||
m_poolModel(new DanbooruPoolModel(this)),
|
||||
m_service(new DanbooruService()),
|
||||
m_tableView(new QTableView(this)),
|
||||
m_cache(0)
|
||||
{
|
||||
|
||||
|
@ -95,6 +100,18 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
statusBar()->addPermanentWidget(m_connectWidget);
|
||||
m_connectWidget->hide();
|
||||
|
||||
// Set up PoolWidget
|
||||
m_tableView->setModel(m_poolModel);
|
||||
QDockWidget* dockWidget = new QDockWidget(i18n("Pools"), this);
|
||||
dockWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
|
||||
dockWidget->setWidget(m_tableView);
|
||||
dockWidget->setObjectName("PoolView");
|
||||
// Prevent the use of winId() when detached, leads to QQuickWidget bugs
|
||||
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
|
||||
dockWidget->show();
|
||||
m_tableView->show();
|
||||
|
||||
// then, setup our actions
|
||||
setupActions();
|
||||
|
||||
|
@ -125,7 +142,14 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
m_connectWidget->hide();
|
||||
});
|
||||
|
||||
connect(m_service, &Danbooru::DanbooruService::postDownloaded, m_model, &Danbooru::DanbooruPostModel::addPost);
|
||||
connect(m_service, &Danbooru::DanbooruService::postDownloaded, m_model,
|
||||
&Danbooru::DanbooruPostModel::addPost);
|
||||
connect(m_service, &Danbooru::DanbooruService::poolDownloaded, m_poolModel,
|
||||
&DanbooruPoolModel::addPool);
|
||||
connect(m_service, &Danbooru::DanbooruService::poolDownloadFinished, [this]() {
|
||||
m_tableView->resizeColumnsToContents();
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
@ -178,6 +202,7 @@ void DanbooruMainWindow::connectToBoard()
|
|||
}
|
||||
|
||||
m_model->clear();
|
||||
m_poolModel->clear();
|
||||
m_service->reset();
|
||||
m_connectWidget->show();
|
||||
|
||||
|
@ -189,8 +214,7 @@ void DanbooruMainWindow::downloadPosts()
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO Pick from configuration
|
||||
m_service->getPostList();
|
||||
m_service->getPoolList();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,15 @@
|
|||
#ifndef DANBOORU_CLIENT_H
|
||||
#define DANBOORU_CLIENT_H
|
||||
|
||||
#include "libdanbooru/danboorupost.h"
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
#include <kxmlguiwindow.h>
|
||||
#include <KSharedDataCache>
|
||||
#include <KImageCache>
|
||||
|
||||
#include "libdanbooru/danboorupost.h"
|
||||
|
||||
|
||||
class QQuickWidget;
|
||||
|
||||
|
@ -37,6 +41,7 @@ namespace Danbooru
|
|||
class DanbooruClientView;
|
||||
class DanbooruService;
|
||||
class DanbooruPostModel;
|
||||
class DanbooruPoolModel;
|
||||
class DanbooruConnectWidget;
|
||||
|
||||
/**
|
||||
|
@ -54,8 +59,10 @@ class DanbooruMainWindow : public KXmlGuiWindow
|
|||
private:
|
||||
QQuickWidget *m_view;
|
||||
DanbooruPostModel *m_model;
|
||||
DanbooruPoolModel *m_poolModel;
|
||||
DanbooruService *m_service;
|
||||
DanbooruConnectWidget *m_connectWidget;
|
||||
QTableView *m_tableView;
|
||||
KImageCache *m_cache;
|
||||
static QHash<int, DanbooruPost::Rating> ratingMap;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue