| 37 | } |
| 38 | |
| 39 | void AnimeModel::init() |
| 40 | { |
| 41 | if(inited) return; |
| 42 | inited = true; |
| 43 | Notifier::getNotifier()->showMessage(Notifier::LIBRARY_NOTIFY, tr("Fetching..."), NM_PROCESS | NM_DARKNESS_BACK); |
| 44 | ThreadTask task(GlobalObjects::workThread); |
| 45 | task.RunOnce([this](){ |
| 46 | totalCount += AnimeWorker::instance()->animeCount(); |
| 47 | QSharedPointer<QVector<Anime *>> animes = QSharedPointer<QVector<Anime *>>::create(); |
| 48 | animes->reserve(limitCount); |
| 49 | AnimeWorker::instance()->fetchAnimes(animes.get(), 0, limitCount); |
| 50 | ThreadTask task(this->thread()); |
| 51 | task.RunOnce([animes, this](){ |
| 52 | if (!animes->empty()) |
| 53 | { |
| 54 | beginInsertRows(QModelIndex(), 0, animes->count() - 1); |
| 55 | this->animes.append(*animes); |
| 56 | endInsertRows(); |
| 57 | } |
| 58 | currentOffset+=animes->count(); |
| 59 | hasMoreAnimes = animes->count() >= limitCount; |
| 60 | showStatisMessage(); |
| 61 | Notifier::getNotifier()->showMessage(Notifier::LIBRARY_NOTIFY, tr("Down"), NM_HIDE); |
| 62 | }); |
| 63 | }); |
| 64 | } |
| 65 | |
| 66 | void AnimeModel::setActive(bool isActive) |
| 67 | { |
nothing calls this directly
no test coverage detected