Fixed podcast copy to device
This commit is contained in:
parent
f60327b1d1
commit
01635397d4
@ -313,3 +313,26 @@ PodcastEpisodeList PodcastBackend::GetOldDownloadedEpisodes(const QDateTime& max
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PodcastEpisodeList PodcastBackend::GetNewDownloadedEpisodes() {
|
||||
PodcastEpisodeList ret;
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
QSqlQuery q("SELECT ROWID, " + PodcastEpisode::kColumnSpec +
|
||||
" FROM podcast_episodes"
|
||||
" WHERE downloaded = 'true'"
|
||||
" AND listened = 'false'", db);
|
||||
q.exec();
|
||||
if (db_->CheckErrors(q))
|
||||
return ret;
|
||||
|
||||
while (q.next()) {
|
||||
PodcastEpisode episode;
|
||||
episode.InitFromQuery(q);
|
||||
ret << episode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
// last listened to before the given QDateTime. This query is NOT indexed so
|
||||
// it involves a full search of the table.
|
||||
PodcastEpisodeList GetOldDownloadedEpisodes(const QDateTime& max_listened_date);
|
||||
|
||||
PodcastEpisodeList GetNewDownloadedEpisodes();
|
||||
// Adds episodes to the database. Every episode must have a valid
|
||||
// podcast_database_id set already.
|
||||
void AddEpisodes(PodcastEpisodeList* episodes);
|
||||
|
@ -174,7 +174,9 @@ Song PodcastEpisode::ToSong(const Podcast& podcast) const {
|
||||
if (podcast.is_valid()) {
|
||||
ret.set_album(podcast.title().simplified());
|
||||
ret.set_art_automatic(podcast.ImageUrlLarge().toString());
|
||||
|
||||
if (author().isNull() || author().isEmpty())
|
||||
ret.set_artist(podcast.title().simplified());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -119,27 +119,35 @@ QStandardItem* PodcastService::CreateRootItem() {
|
||||
}
|
||||
|
||||
void PodcastService::CopyToDeviceSlot() {
|
||||
QList<QUrl> url_list;
|
||||
QList<PodcastEpisode> episodes;
|
||||
|
||||
QList<Song> songs;
|
||||
PodcastEpisode episode_tmp;
|
||||
Podcast podcast;
|
||||
foreach (const QModelIndex& index, selected_episodes_) {
|
||||
episodes << index.data(Role_Episode).value<PodcastEpisode>();
|
||||
episode_tmp = index.data(Role_Episode).value<PodcastEpisode>();
|
||||
if (episode_tmp.downloaded())
|
||||
episodes << episode_tmp;
|
||||
}
|
||||
|
||||
foreach (const QModelIndex& podcast, explicitly_selected_podcasts_) {
|
||||
for (int i=0 ; i<podcast.model()->rowCount(podcast) ; ++i) {
|
||||
const QModelIndex& index = podcast.child(i, 0);
|
||||
episodes << index.data(Role_Episode).value<PodcastEpisode>();
|
||||
episode_tmp = index.data(Role_Episode).value<PodcastEpisode>();
|
||||
if (episode_tmp.downloaded())
|
||||
episodes << episode_tmp;
|
||||
}
|
||||
}
|
||||
if(selected_episodes_.isEmpty() && explicitly_selected_podcasts_.isEmpty()) {
|
||||
episodes << backend_->GetNewDownloadedEpisodes();
|
||||
}
|
||||
|
||||
foreach (const PodcastEpisode& episode, episodes) {
|
||||
if(!episode.local_url().isEmpty())
|
||||
url_list.append(episode.local_url());
|
||||
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_->SetUrls(url_list))
|
||||
if (organise_dialog_->SetSongs(songs))
|
||||
organise_dialog_->show();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user