void SongLoaderInserter::AsyncLoad() { // First, quick load raw songs. int async_progress = 0; int async_load_id = task_manager_->StartTask(tr("Loading tracks")); task_manager_->SetTaskProgress(async_load_id, async_progress, pending_.count()); for (SongLoader* loader : pending_) { loader->LoadFilenamesBlocking(); task_manager_->SetTaskProgress(async_load_id, ++async_progress); songs_ << loader->songs(); } task_manager_->SetTaskFinished(async_load_id); emit PreloadFinished(); // Songs are inserted in playlist, now load them completely. async_progress = 0; async_load_id = task_manager_->StartTask(tr("Loading tracks info")); task_manager_->SetTaskProgress(async_load_id, async_progress, songs_.count()); SongList songs; for (SongLoader* loader : pending_) { loader->LoadMetadataBlocking(); songs << loader->songs(); task_manager_->SetTaskProgress(async_load_id, songs.count()); } task_manager_->SetTaskFinished(async_load_id); // Replace the partially-loaded items by the new ones, fully loaded. emit EffectiveLoadFinished(songs); deleteLater(); }
void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now, bool enqueue, const QList<QUrl>& urls) { destination_ = destination; row_ = row; play_now_ = play_now; enqueue_ = enqueue; connect(destination, SIGNAL(destroyed()), SLOT(DestinationDestroyed())); connect(this, SIGNAL(PreloadFinished()), SLOT(InsertSongs())); connect(this, SIGNAL(EffectiveLoadFinished(const SongList&)), destination, SLOT(UpdateItems(const SongList&))); for (const QUrl& url : urls) { SongLoader* loader = new SongLoader(library_, player_, this); SongLoader::Result ret = loader->Load(url); if (ret == SongLoader::BlockingLoadRequired) { pending_.append(loader); continue; } if (ret == SongLoader::Success) songs_ << loader->songs(); else emit Error(tr("Error loading %1").arg(url.toString())); delete loader; } if (pending_.isEmpty()) { InsertSongs(); deleteLater(); } else { QtConcurrent::run(this, &SongLoaderInserter::AsyncLoad); } }
void SplashScreenViewController::OnPreloadScreen(CYIBundle bundle, const CYIPersistentStore &stateData) { TabbedScreenViewController::OnPreloadScreen(bundle, stateData); PreloadFinished(this); }
void ScreenViewController2::OnPreloadScreen(CYIBundle bundle, const CYIPersistentStore &StateData) { YI_UNUSED(bundle); YI_UNUSED(StateData); PreloadFinished(this); }