diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 05e502aea..8111f3615 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1510,19 +1510,19 @@ void MainWindow::updateCurrentSong(const Song &song) if (!mod.title.isEmpty()) { current=mod; current.id=song.id; - current.file="XXX"; +// current.file="XXX"; } } - positionSlider->setEnabled(!currentIsStream()); + positionSlider->setEnabled(!current.isStream()); // Determine if album cover should be updated const QString &albumArtist=song.albumArtist(); if (coverWidget->property("artist").toString() != albumArtist || coverWidget->property("album").toString() != song.album) { if (!albumArtist.isEmpty() && !song.album.isEmpty()) { Covers::self()->get(song, MPDParseUtils::groupSingle() && MusicLibraryModel::self()->isFromSingleTracks(song)); - } else if (!currentIsStream()) { - coverWidget->setPixmap(noCover); + } else { + coverWidget->setPixmap(current.isStream() ? noStreamCover : noCover); } coverWidget->setProperty("artist", albumArtist); coverWidget->setProperty("album", song.album); @@ -1690,7 +1690,7 @@ void MainWindow::updateStatus() QString timeElapsedFormattedString; - if (!currentIsStream()) { + if (!current.isStream() || (status->timeTotal()>0 && status->timeElapsed()<=status->timeTotal())) { if (status->state() == MPDStatus::State_Stopped || status->state() == MPDStatus::State_Inactive) { timeElapsedFormattedString = "0:00 / 0:00"; } else { @@ -2189,17 +2189,12 @@ void MainWindow::tabToggled(int index) } } -bool MainWindow::currentIsStream() -{ - return !current.title.isEmpty() && (current.file.isEmpty() || current.file.contains("://")); -} - void MainWindow::cover(const QString &artist, const QString &album, const QImage &img, const QString &file) { if (artist==current.albumArtist() && album==current.album) { if (img.isNull()) { coverSong=Song(); - coverWidget->setPixmap(currentIsStream() ? noStreamCover : noCover); + coverWidget->setPixmap(current.isStream() ? noStreamCover : noCover); coverFileName=QString(); emit coverFile(QString()); } else { diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 4751aac52..ff2544df7 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -298,7 +298,6 @@ private: void startVolumeFade(/*bool stop*/); void stopVolumeFade(); // void callK3b(const QString &type); - bool currentIsStream(); void showTab(int page); private: diff --git a/models/playqueuemodel.cpp b/models/playqueuemodel.cpp index fd6bed243..9cd26f6b7 100644 --- a/models/playqueuemodel.cpp +++ b/models/playqueuemodel.cpp @@ -192,26 +192,6 @@ QVariant PlayQueueModel::data(const QModelIndex &index, int role) const var.setValue(songs.at(index.row())); return var; } -// case PlayQueueView::Role_Artist: -// return songs.at(index.row()).artist; -// case PlayQueueView::Role_AlbumArtist: -// return songs.at(index.row()).albumArtist(); -// case PlayQueueView::Role_Album: { -// const Song &song = songs.at(index.row()); -// return song.album.isEmpty() && !song.name.isEmpty() && (song.file.isEmpty() || song.file.contains("://")) -// ? song.name : song.album; -// } -// case PlayQueueView::Role_Title: { -// const Song &song = songs.at(index.row()); -// if (!song.albumartist.isEmpty() && song.albumartist != song.artist) { -// return song.title + " - " + song.artist; -// } -// return song.title; -// } -// case PlayQueueView::Role_Track: -// return songs.at(index.row()).track; -// case PlayQueueView::Role_Duration: -// return songs.at(index.row()).time; case PlayQueueView::Role_AlbumDuration: { const Song &first = songs.at(index.row()); quint32 d=first.time; @@ -270,7 +250,7 @@ QVariant PlayQueueModel::data(const QModelIndex &index, int role) const case Qt::FontRole: { Song s=songs.at(index.row()); - if (s.file.isEmpty() || s.file.contains("://")) { + if (s.isStream()) { QFont font; if (songs.at(index.row()).id == currentSongId) { font.setBold(true); @@ -300,8 +280,7 @@ QVariant PlayQueueModel::data(const QModelIndex &index, int role) const case COL_ARTIST: return song.artist; case COL_ALBUM: - return song.album.isEmpty() && !song.name.isEmpty() && (song.file.isEmpty() || song.file.contains("://")) - ? song.name : song.album; + return song.album.isEmpty() && !song.name.isEmpty() && song.isStream() ? song.name : song.album; case COL_TRACK: if (song.track <= 0) return QVariant(); diff --git a/mpd/song.h b/mpd/song.h index a1153a7cb..9c7685c15 100644 --- a/mpd/song.h +++ b/mpd/song.h @@ -78,6 +78,7 @@ struct Song bool revertVariousArtists(); static QString capitalize(const QString &s); bool capitalise(); + bool isStream() const { return file.isEmpty() || file.contains("://"); } }; Q_DECLARE_METATYPE(Song) diff --git a/widgets/playqueueview.cpp b/widgets/playqueueview.cpp index 0dbc24d3a..9faeaaa5b 100644 --- a/widgets/playqueueview.cpp +++ b/widgets/playqueueview.cpp @@ -183,7 +183,7 @@ public: QString title; QString track; QString duration=Song::formattedTime(song.time); - bool stream=song.file.isEmpty() || song.file.contains("://"); + bool stream=song.isStream(); int state=index.data(PlayQueueView::Role_Status).toInt(); QString trackTitle=!song.albumartist.isEmpty() && song.albumartist != song.artist ? song.title + " - " + song.artist