Ejemplo n.º 1
0
void PodcastService::CopyToDevice(const QModelIndexList& episode_indexes,
                                  const QModelIndexList& podcast_indexes) {
  PodcastEpisode episode_tmp;
  SongList songs;
  PodcastEpisodeList episodes;
  Podcast podcast;
  for (const QModelIndex& index : episode_indexes) {
    episode_tmp = index.data(Role_Episode).value<PodcastEpisode>();
    if (episode_tmp.downloaded()) episodes << episode_tmp;
  }

  for (const QModelIndex& podcast : podcast_indexes) {
    for (int i = 0; i < podcast.model()->rowCount(podcast); ++i) {
      const QModelIndex& index = podcast.child(i, 0);
      episode_tmp = index.data(Role_Episode).value<PodcastEpisode>();
      if (episode_tmp.downloaded() && !episode_tmp.listened())
        episodes << episode_tmp;
    }
  }
  for (const PodcastEpisode& episode : episodes) {
    podcast = backend_->GetSubscriptionById(episode.podcast_database_id());
    songs.append(episode.ToSong(podcast));
  }

  organise_dialog_->SetDestinationModel(
      app_->device_manager()->connected_devices_model(), true);
  organise_dialog_->SetCopy(true);
  if (organise_dialog_->SetSongs(songs)) organise_dialog_->show();
}
Ejemplo n.º 2
0
void PodcastService::CancelDownload(const QModelIndexList& episode_indexes,
                                    const QModelIndexList& podcast_indexes) {
  PodcastEpisode episode_tmp;
  SongList songs;
  PodcastEpisodeList episodes;
  Podcast podcast;
  for (const QModelIndex& index : episode_indexes) {
    episode_tmp = index.data(Role_Episode).value<PodcastEpisode>();
    episodes << episode_tmp;
  }

  for (const QModelIndex& podcast : podcast_indexes) {
    for (int i = 0; i < podcast.model()->rowCount(podcast); ++i) {
      const QModelIndex& index = podcast.child(i, 0);
      episode_tmp = index.data(Role_Episode).value<PodcastEpisode>();
      episodes << episode_tmp;
    }
  }
  episodes = app_->podcast_downloader()->EpisodesDownloading(episodes);
  app_->podcast_downloader()->cancelDownload(episodes);
}