Example #1
0
PodcastService::PodcastService(Application* app, InternetModel* parent)
    : InternetService(kServiceName, app, parent, parent),
      use_pretty_covers_(true),
      icon_loader_(new StandardItemIconLoader(app->album_cover_loader(), this)),
      backend_(app->podcast_backend()),
      model_(new PodcastServiceModel(this)),
      proxy_(new PodcastSortProxyModel(this)),
      context_menu_(nullptr),
      root_(nullptr),
      organise_dialog_(new OrganiseDialog(app_->task_manager())) {
  icon_loader_->SetModel(model_);
  proxy_->setSourceModel(model_);
  proxy_->setDynamicSortFilter(true);
  proxy_->sort(0);

  connect(backend_, SIGNAL(SubscriptionAdded(Podcast)),
          SLOT(SubscriptionAdded(Podcast)));
  connect(backend_, SIGNAL(SubscriptionRemoved(Podcast)),
          SLOT(SubscriptionRemoved(Podcast)));
  connect(backend_, SIGNAL(EpisodesAdded(PodcastEpisodeList)),
          SLOT(EpisodesAdded(PodcastEpisodeList)));
  connect(backend_, SIGNAL(EpisodesUpdated(PodcastEpisodeList)),
          SLOT(EpisodesUpdated(PodcastEpisodeList)));

  connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)),
          SLOT(CurrentSongChanged(Song)));
}
Example #2
0
void PodcastBackend::UpdateEpisodes(const PodcastEpisodeList& episodes) {
  QMutexLocker l(db_->Mutex());
  QSqlDatabase db(db_->Connect());
  ScopedTransaction t(&db);

  QSqlQuery q(
      "UPDATE podcast_episodes"
      " SET listened = :listened,"
      "     listened_date = :listened_date,"
      "     downloaded = :downloaded,"
      "     local_url = :local_url"
      " WHERE ROWID = :id",
      db);

  for (const PodcastEpisode& episode : episodes) {
    q.bindValue(":listened", episode.listened());
    q.bindValue(":listened_date", episode.listened_date().toTime_t());
    q.bindValue(":downloaded", episode.downloaded());
    q.bindValue(":local_url", episode.local_url().toEncoded());
    q.bindValue(":id", episode.database_id());
    q.exec();
    db_->CheckErrors(q);
  }

  t.Commit();

  emit EpisodesUpdated(episodes);
}