Give streams key 0

This commit is contained in:
craig
2012-04-08 11:20:37 +00:00
committed by craig
parent cf2fa440b5
commit 677bb33361
4 changed files with 15 additions and 3 deletions

View File

@@ -1576,7 +1576,7 @@ void MainWindow::updateCurrentSong(const Song &song)
current=song;
if (current.file.startsWith("http") && HttpServer::self()->isOurs(current.file)) {
if (current.isCantataStream()) {
Song mod=HttpServer::self()->decodeUrl(current.file);
if (!mod.title.isEmpty()) {
current=mod;

View File

@@ -261,7 +261,7 @@ QList<Song> MPDParseUtils::parseSongs(const QByteArray &data)
if (i == lines.size() - 1 || lines.at(i + 1).startsWith("file:")) {
Song song=parseSong(line);
if (song.file.startsWith("http") && HttpServer::self()->isOurs(song.file)) {
if (song.isCantataStream()) {
Song mod=HttpServer::self()->decodeUrl(song.file);
if (!mod.title.isEmpty()) {
mod.id=song.id;

View File

@@ -28,6 +28,7 @@
#include "song.h"
#include "mpdparseutils.h"
#include "musiclibraryitemalbum.h"
#include "httpserver.h"
#ifdef ENABLE_KDE_SUPPORT
#include <KDE/KLocale>
#else
@@ -139,12 +140,17 @@ void Song::setKey()
static quint16 currentKey=0;
static QMap<QString, quint16> keys;
if (isStream() && !isCantataStream()) {
key=0;
return;
}
QString albumAndArtist=albumArtist()+QLatin1String("::")+album;
QMap<QString, quint16>::ConstIterator it=keys.find(albumAndArtist);
if (it!=keys.end()) {
key=it.value();
} else {
currentKey++;
currentKey++; // Key 0 is for streams, so we need to increment before setting...
keys.insert(albumAndArtist, currentKey);
key=currentKey;
}
@@ -314,3 +320,8 @@ bool Song::capitalise()
return artist!=origArtist || albumartist!=origAlbumArtist || album!=origAlbum || title!=origTitle;
}
bool Song::isCantataStream() const
{
return !file.isEmpty() && file.startsWith("http") && HttpServer::self()->isOurs(file);
}

View File

@@ -87,6 +87,7 @@ struct Song
static QString capitalize(const QString &s);
bool capitalise();
bool isStream() const { return file.isEmpty() || file.contains("://"); }
bool isCantataStream() const;
};
Q_DECLARE_METATYPE(Song)