Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import a copy of qdaapd, for now at least
- Loading branch information
Showing
23 changed files
with
6,622 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include "collection.h" | ||
using namespace QDaap; | ||
|
||
Collection::Collection(QString name, QObject *parent) : | ||
QObject(parent), m_tracksloaded(false), m_name(name) | ||
{ | ||
} | ||
|
||
int Collection::numTracks() | ||
{ | ||
return tracks().size(); | ||
} | ||
|
||
QMap<quint32,Track> & Collection::tracks() | ||
{ | ||
return m_tracks; | ||
} | ||
|
||
void Collection::loadTracks() | ||
{ | ||
qDebug() << "LoadTracks()"; | ||
|
||
QDaap::Track t; | ||
t.id = t.perid = 1; | ||
t.artist = "Test artist name 1"; | ||
t.album = "Test album name 1"; | ||
t.track = "Test track title 1"; | ||
t.duration = 300000; | ||
t.filesize = 1024*1024*5; | ||
t.albumposition = 1; | ||
t.genre = "Rock"; | ||
t.comment = "no comment"; | ||
t.year = 1982; | ||
t.albumdiscnumber = 1; | ||
t.bitrate = 128; | ||
|
||
|
||
m_tracks[t.id] = t; | ||
|
||
QDaap::Track t2; | ||
t2.id = t2.perid = 2; | ||
t2.artist = "Test artist name 2"; | ||
t2.album = "Test album name 2"; | ||
t2.track = "Test track title 2"; | ||
t2.duration = 200000; | ||
t2.filesize = 1024*1024*3; | ||
t2.albumposition = 7; | ||
t2.genre = "Rock"; | ||
t2.comment = "no comment"; | ||
t2.year = 1982; | ||
t2.albumdiscnumber = 1; | ||
t2.bitrate = 128; | ||
|
||
m_tracks[t2.id] = t2; | ||
|
||
m_tracksloaded = true; | ||
emit finishedLoading(); | ||
} | ||
|
||
QIODevice * Collection::getTrack(quint32 id) | ||
{ | ||
if(!m_tracks.contains(id)) | ||
{ | ||
qDebug() << "no track id in collection : " << id; | ||
return 0; | ||
//Q_ASSERT(false); | ||
} | ||
QDaap::Track t = m_tracks[id]; | ||
QFile * f = new QFile("/tmp/angels.mp3"); | ||
f->open(QIODevice::ReadOnly); | ||
return f; | ||
} | ||
|
||
int Collection::numPlaylists() const | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#ifndef COLLECTION_H | ||
#define COLLECTION_H | ||
|
||
#include <QObject> | ||
#include <QList> | ||
#include <QMap> | ||
#include <QFile> | ||
#include <QMutex> | ||
#include <QWaitCondition> | ||
#include <QDebug> | ||
|
||
namespace QDaap | ||
{ | ||
|
||
|
||
class Track | ||
{ | ||
public: | ||
Track() : extension("mp3"), disabled(false), trackcount(1), albumdiscnumber(1) | ||
{}; | ||
|
||
quint32 id; | ||
quint64 perid; | ||
QString genre; | ||
QString artist; | ||
QString album; | ||
QString track; | ||
QString comment; | ||
QString extension; | ||
bool disabled; | ||
quint16 bitrate; | ||
quint32 duration; // ms | ||
quint32 filesize; | ||
quint16 trackcount; | ||
quint16 albumposition; | ||
quint16 year; | ||
quint16 albumdiscnumber; | ||
}; | ||
|
||
|
||
|
||
/* | ||
class Playlist | ||
{ | ||
public: | ||
quint32 id; | ||
quint64 perid; | ||
QString title; | ||
quint32 length; // num tracks in playlist | ||
virtual QList<Track> getTracks() | ||
{ | ||
return QList<Track>(); | ||
}; | ||
}; | ||
*/ | ||
|
||
class Collection : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit Collection(QString name, QObject *parent = 0); | ||
|
||
QString name() const { return m_name; }; | ||
|
||
int numTracks(); | ||
QMap<quint32,Track> & tracks(); | ||
|
||
int numPlaylists() const; | ||
|
||
// this should hit DB/peer get full current list of all tracks: | ||
virtual void loadTracks(); | ||
|
||
virtual QIODevice * getTrack(quint32 id); | ||
|
||
//QList<Playlist> playlists() const = 0; | ||
|
||
bool isLoaded() const { return m_tracksloaded; }; | ||
|
||
|
||
signals: | ||
void finishedLoading(); | ||
|
||
public slots: | ||
|
||
protected: | ||
|
||
QString m_name; | ||
|
||
QMap<quint32,Track> m_tracks; | ||
bool m_tracksloaded; | ||
}; | ||
|
||
} // ns | ||
|
||
#endif // COLLECTION_H |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.