Add tag sorting (based on counts) to the tag view
This commit is contained in:
parent
ebd9e559ef
commit
db03bdbce2
2 changed files with 24 additions and 12 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <QDockWidget>
|
||||
#include <QQuickItem>
|
||||
#include <QFileDialog>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include <kactioncollection.h>
|
||||
#include <KStandardAction>
|
||||
|
@ -74,6 +75,7 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
m_connectWidget(Q_NULLPTR),
|
||||
m_searchWidget(new DanbooruSearchWidget(this)),
|
||||
m_tagWidget(new DanbooruTagWidget(this)),
|
||||
m_proxyModel(new QSortFilterProxyModel(this)),
|
||||
m_tableView(new QTableView(this)),
|
||||
m_cache(Q_NULLPTR)
|
||||
{
|
||||
|
@ -89,8 +91,14 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
|
||||
m_cache = new KImageCache(qApp->applicationName(), DanbooruSettings::self()->cacheSize());
|
||||
m_service->setImageCache(m_cache);
|
||||
|
||||
m_proxyModel->setSortRole(DanbooruTagModel::TagCountRole);
|
||||
m_proxyModel->setSourceModel(m_tagModel);
|
||||
m_proxyModel->setDynamicSortFilter(true);
|
||||
|
||||
m_tableView->setModel(m_poolModel);
|
||||
m_tagWidget->setModel(m_tagModel);
|
||||
m_tagWidget->setModel(m_proxyModel);
|
||||
|
||||
|
||||
// Set up declarative bindings for the QQuickWidget
|
||||
|
||||
|
@ -183,6 +191,18 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
searchDockWidget->hide();
|
||||
});
|
||||
|
||||
connect(m_service, &DanbooruService::postDownloadFinished, [this]() {
|
||||
|
||||
if (m_tagModel->rowCount() == 0) {
|
||||
// Only get tags if we don't have any already
|
||||
for (auto tag: m_model->postTags()) {
|
||||
m_service->getTagList(1, tag);
|
||||
}
|
||||
}
|
||||
m_proxyModel->sort(0, Qt::DescendingOrder);
|
||||
|
||||
});
|
||||
|
||||
connect(m_view->rootObject(), SIGNAL(downloadRequested(const QUrl&)), this,
|
||||
SLOT(slotHandleDownload(const QUrl&)));
|
||||
|
||||
|
@ -375,17 +395,6 @@ void DanbooruMainWindow::setupDockWidgets() {
|
|||
qobject_cast<KDualAction*>(actionCollection()->action(QLatin1String("tags")))->setActive(visible);
|
||||
});
|
||||
|
||||
connect(m_service, &DanbooruService::postDownloadFinished, [this]() {
|
||||
|
||||
if (m_tagModel->rowCount() == 0) {
|
||||
// Only get tags if we don't have any already
|
||||
for (auto tag: m_model->postTags()) {
|
||||
m_service->getTagList(1, tag);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void DanbooruMainWindow::connectToBoard()
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
|
||||
class QQuickWidget;
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
|
||||
namespace Danbooru
|
||||
|
@ -70,6 +71,8 @@ private:
|
|||
DanbooruConnectWidget *m_connectWidget;
|
||||
DanbooruSearchWidget *m_searchWidget;
|
||||
DanbooruTagWidget *m_tagWidget;
|
||||
QSortFilterProxyModel *m_proxyModel;
|
||||
|
||||
QTableView *m_tableView;
|
||||
KImageCache *m_cache;
|
||||
static QHash<int, DanbooruPost::Rating> ratingMap;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue