fixing a bug where streams were removed from playlist during Clementine's startup
This commit is contained in:
parent
bfb068a6d1
commit
e619d7a280
|
@ -154,7 +154,7 @@ void Player::TrackEnded() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_item_ && current_item_->IsLocalLibraryItem() &&
|
if (current_item_ && current_item_->IsLocalLibraryItem() &&
|
||||||
!playlists_->active()->has_scrobbled()) {
|
current_item_->Metadata().id() != -1 && !playlists_->active()->has_scrobbled()) {
|
||||||
// The track finished before its scrobble point (30 seconds), so increment
|
// The track finished before its scrobble point (30 seconds), so increment
|
||||||
// the play count now.
|
// the play count now.
|
||||||
playlists_->library_backend()->IncrementPlayCountAsync(
|
playlists_->library_backend()->IncrementPlayCountAsync(
|
||||||
|
|
|
@ -34,7 +34,7 @@ class LibraryPlaylistItem : public PlaylistItem {
|
||||||
|
|
||||||
QUrl Url() const;
|
QUrl Url() const;
|
||||||
|
|
||||||
bool IsLocalLibraryItem() const { return song_.id() != -1; }
|
bool IsLocalLibraryItem() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant DatabaseValue(DatabaseColumn column) const;
|
QVariant DatabaseValue(DatabaseColumn column) const;
|
||||||
|
|
|
@ -235,7 +235,8 @@ QVariant Playlist::data(const QModelIndex& index, int role) const {
|
||||||
|
|
||||||
case Role_CanSetRating:
|
case Role_CanSetRating:
|
||||||
return index.column() == Column_Rating &&
|
return index.column() == Column_Rating &&
|
||||||
items_[index.row()]->IsLocalLibraryItem();
|
items_[index.row()]->IsLocalLibraryItem() &&
|
||||||
|
items_[index.row()]->Metadata().id() != -1;
|
||||||
|
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
|
@ -1130,11 +1131,13 @@ void Playlist::ItemsLoaded() {
|
||||||
|
|
||||||
PlaylistItemList items = watcher->future().results();
|
PlaylistItemList items = watcher->future().results();
|
||||||
|
|
||||||
// backend returns empty elements for items which it couldn't
|
// backend returns empty elements for library items which it couldn't
|
||||||
// match (because they got deleted); we don't need those
|
// match (because they got deleted); we don't need those
|
||||||
QMutableListIterator<PlaylistItemPtr> it(items);
|
QMutableListIterator<PlaylistItemPtr> it(items);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
if (it.next()->Metadata().filename().isEmpty()) {
|
PlaylistItemPtr item = it.next();
|
||||||
|
|
||||||
|
if (item->IsLocalLibraryItem() && item->Metadata().filename().isEmpty()) {
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1402,7 +1405,7 @@ void Playlist::RateSong(const QModelIndex& index, double rating) {
|
||||||
|
|
||||||
if(has_item_at(row)) {
|
if(has_item_at(row)) {
|
||||||
PlaylistItemPtr item = item_at(row);
|
PlaylistItemPtr item = item_at(row);
|
||||||
if (item && item->IsLocalLibraryItem()) {
|
if (item && item->IsLocalLibraryItem() && item->Metadata().id() != -1) {
|
||||||
library_->UpdateSongRatingAsync(item->Metadata().id(), rating);
|
library_->UpdateSongRatingAsync(item->Metadata().id(), rating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,9 @@ class PlaylistItem : public boost::enable_shared_from_this<PlaylistItem> {
|
||||||
|
|
||||||
// Convenience function to find out whether this item is from the local
|
// Convenience function to find out whether this item is from the local
|
||||||
// library, as opposed to a device, a file on disk, or a stream.
|
// library, as opposed to a device, a file on disk, or a stream.
|
||||||
|
// Remember that even if this returns true, the library item might be
|
||||||
|
// invalid so you might want to check that it's id is not equal to -1
|
||||||
|
// before actually using it.
|
||||||
virtual bool IsLocalLibraryItem() const { return false; }
|
virtual bool IsLocalLibraryItem() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -177,8 +177,11 @@ Returns true if L{SetTemporaryMetadata()} has been called.
|
||||||
bool IsLocalLibraryItem() const;
|
bool IsLocalLibraryItem() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
IsLocalLibraryItem() -> bool
|
IsLocalLibraryItem() -> bool
|
||||||
Convenience function to check whether this item is from the local library (the
|
Convenience function to check whether this item is from the local
|
||||||
list of songs appearing in the Library tab).
|
library, as opposed to a device, a file on disk or a stream.
|
||||||
|
Remember that even if this returns true, the library item might be
|
||||||
|
invalid so you might want to check that it's id is not equal to -1
|
||||||
|
before actually using it.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void SetBackgroundColor(short priority, const QColor& color);
|
void SetBackgroundColor(short priority, const QColor& color);
|
||||||
|
|
|
@ -847,7 +847,8 @@ void MainWindow::SongChanged(const Song& song) {
|
||||||
void MainWindow::TrackSkipped(PlaylistItemPtr item) {
|
void MainWindow::TrackSkipped(PlaylistItemPtr item) {
|
||||||
// If it was a library item then we have to increment its skipped count in
|
// If it was a library item then we have to increment its skipped count in
|
||||||
// the database.
|
// the database.
|
||||||
if (item && item->IsLocalLibraryItem() && !playlists_->active()->has_scrobbled()) {
|
if (item && item->IsLocalLibraryItem() &&
|
||||||
|
item->Metadata().id() != -1 && !playlists_->active()->has_scrobbled()) {
|
||||||
Song song = item->Metadata();
|
Song song = item->Metadata();
|
||||||
const qint64 position = player_->engine()->position_nanosec();
|
const qint64 position = player_->engine()->position_nanosec();
|
||||||
const qint64 length = player_->engine()->length_nanosec();
|
const qint64 length = player_->engine()->length_nanosec();
|
||||||
|
@ -989,7 +990,7 @@ void MainWindow::UpdateTrackPosition() {
|
||||||
playlists_->active()->set_scrobbled(true);
|
playlists_->active()->set_scrobbled(true);
|
||||||
|
|
||||||
// Update the play count for the song if it's from the library
|
// Update the play count for the song if it's from the library
|
||||||
if (item->IsLocalLibraryItem()) {
|
if (item->IsLocalLibraryItem() && item->Metadata().id() != -1) {
|
||||||
library_->backend()->IncrementPlayCountAsync(item->Metadata().id());
|
library_->backend()->IncrementPlayCountAsync(item->Metadata().id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1191,7 +1192,8 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
|
||||||
ui_->action_edit_value->setText(tr("Edit tag \"%1\"...").arg(column_name));
|
ui_->action_edit_value->setText(tr("Edit tag \"%1\"...").arg(column_name));
|
||||||
|
|
||||||
// Is it a library item?
|
// Is it a library item?
|
||||||
if (playlists_->current()->item_at(source_index.row())->IsLocalLibraryItem()) {
|
PlaylistItemPtr item = playlists_->current()->item_at(source_index.row());
|
||||||
|
if (item->IsLocalLibraryItem() && item->Metadata().id() != -1) {
|
||||||
playlist_organise_->setVisible(editable);
|
playlist_organise_->setVisible(editable);
|
||||||
} else {
|
} else {
|
||||||
playlist_copy_to_library_->setVisible(editable);
|
playlist_copy_to_library_->setVisible(editable);
|
||||||
|
|
Loading…
Reference in New Issue