Mercurial > minori
comparison src/gui/pages/anime_list.cc @ 320:1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
there are some things the API just... doesn't provide. therefore
we have to request the genres separately any time a new anime info
box is opened...
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 12 Jun 2024 19:49:19 -0400 |
parents | 34347fd2a2de |
children | 5d3c9b31aa6e |
comparison
equal
deleted
inserted
replaced
319:d928ec7b6a0d | 320:1b5c04268d6a |
---|---|
31 #include <QRunnable> | 31 #include <QRunnable> |
32 #include <QTreeView> | 32 #include <QTreeView> |
33 | 33 |
34 #include <set> | 34 #include <set> |
35 | 35 |
36 AnimeListPageUpdateEntryThread::AnimeListPageUpdateEntryThread(AnimeListPage* parent) : QThread(parent) { | 36 AnimeListPageUpdateEntryThread::AnimeListPageUpdateEntryThread(QObject* parent) : QThread(parent) {} |
37 page_ = parent; | |
38 } | |
39 | 37 |
40 void AnimeListPageUpdateEntryThread::AddToQueue(int id) { | 38 void AnimeListPageUpdateEntryThread::AddToQueue(int id) { |
41 const std::lock_guard<std::mutex> guard(_queue_mutex); | 39 const std::lock_guard<std::mutex> guard(queue_mutex_); |
42 queue_.push(id); | 40 queue_.push(id); |
43 } | 41 } |
44 | 42 |
45 /* processes the queue... */ | 43 /* processes the queue... */ |
46 void AnimeListPageUpdateEntryThread::run() { | 44 void AnimeListPageUpdateEntryThread::run() { |
47 { | 45 queue_mutex_.lock(); |
48 const std::lock_guard<std::mutex> guard(_queue_mutex); | 46 while (!queue_.empty() && !isInterruptionRequested()) { |
49 while (!queue_.empty() && !isInterruptionRequested()) { | 47 int id = queue_.front(); |
50 Services::UpdateAnimeEntry(queue_.front()); | 48 |
51 queue_.pop(); | 49 /* unlock the mutex for a long blocking operation, so items |
52 } | 50 * can be added without worry */ |
53 } | 51 queue_mutex_.unlock(); |
52 Services::UpdateAnimeEntry(id); | |
53 queue_mutex_.lock(); | |
54 | |
55 queue_.pop(); | |
56 } | |
57 queue_mutex_.unlock(); | |
58 | |
54 emit NeedRefresh(); | 59 emit NeedRefresh(); |
55 } | 60 } |
56 | 61 |
57 AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { | 62 AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { |
58 } | 63 } |
445 Refresh(); | 450 Refresh(); |
446 } | 451 } |
447 | 452 |
448 /* --------- QTabWidget replication end ---------- */ | 453 /* --------- QTabWidget replication end ---------- */ |
449 | 454 |
450 AnimeListPage::AnimeListPage(QWidget* parent) : QWidget(parent), update_entry_thread_(this) { | 455 AnimeListPage::AnimeListPage(QWidget* parent) : QWidget(parent) { |
451 /* Tab bar */ | 456 /* Tab bar */ |
452 tab_bar = new QTabBar(this); | 457 tab_bar = new QTabBar(this); |
453 tab_bar->setExpanding(false); | 458 tab_bar->setExpanding(false); |
454 tab_bar->setDrawBase(false); | 459 tab_bar->setDrawBase(false); |
455 | 460 |