mirror of
https://github.com/QuasarApp/SoundBand.git
synced 2025-05-11 22:49:33 +00:00
create song storage class
This commit is contained in:
parent
b6cbfade5c
commit
ba25504274
@ -45,14 +45,6 @@ bool SongHeader::isValid() const{
|
||||
|
||||
SongHeader::~SongHeader(){}
|
||||
|
||||
|
||||
|
||||
Song::Song():
|
||||
SongHeader()
|
||||
{
|
||||
source.clear();
|
||||
}
|
||||
|
||||
QDataStream& operator << (QDataStream& stream, const SongHeader& song){
|
||||
stream << song.id;
|
||||
stream << song.name;
|
||||
@ -66,6 +58,57 @@ QDataStream& operator >> (QDataStream& stream, SongHeader& song){
|
||||
return stream;
|
||||
}
|
||||
|
||||
SongStorage::SongStorage():
|
||||
SongHeader()
|
||||
{
|
||||
url.clear();
|
||||
}
|
||||
|
||||
SongStorage::SongStorage(const SongHeader& from)
|
||||
:SongStorage::SongStorage()
|
||||
{
|
||||
this->id = from.id;
|
||||
this->name = from.name;
|
||||
this->size = from.size;
|
||||
}
|
||||
|
||||
unsigned int SongStorage::getSize() const{
|
||||
return SongHeader::getSize();
|
||||
}
|
||||
|
||||
const QUrl& SongStorage::getSource()const{
|
||||
return url;
|
||||
}
|
||||
|
||||
QMediaContent SongStorage::toMedia()const{
|
||||
return QMediaContent(url);
|
||||
}
|
||||
|
||||
bool SongStorage::isValid() const{
|
||||
|
||||
return SongHeader::isValid() && url.isValid();
|
||||
}
|
||||
|
||||
SongStorage::~SongStorage(){}
|
||||
|
||||
QDataStream& operator << (QDataStream& stream,const SongStorage& song){
|
||||
stream << static_cast<const SongHeader&>(song);
|
||||
stream << song.url;
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream& operator >> (QDataStream& stream, SongStorage& song){
|
||||
stream >> static_cast<SongHeader&>(song);
|
||||
stream >> song.url;
|
||||
return stream;
|
||||
}
|
||||
|
||||
Song::Song():
|
||||
SongHeader()
|
||||
{
|
||||
source.clear();
|
||||
}
|
||||
|
||||
Song::Song(const SongHeader& from)
|
||||
:Song::Song()
|
||||
{
|
||||
|
23
sync/song.h
23
sync/song.h
@ -4,6 +4,7 @@
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
#include "chronotime.h"
|
||||
#include <QMediaContent>
|
||||
|
||||
namespace syncLib {
|
||||
|
||||
@ -49,11 +50,31 @@ public:
|
||||
friend QDataStream& operator >> (QDataStream& stream, SongHeader& song);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The SongStorage class
|
||||
* header with url to song source
|
||||
*/
|
||||
class SongStorage : public SongHeader {
|
||||
private:
|
||||
QUrl url;
|
||||
public:
|
||||
SongStorage();
|
||||
SongStorage(const SongHeader& from);
|
||||
const QUrl& getSource()const;
|
||||
QMediaContent toMedia()const;
|
||||
unsigned int getSize() const;
|
||||
bool isValid() const;
|
||||
~SongStorage();
|
||||
friend QDataStream& operator << (QDataStream& stream, const SongStorage& song);
|
||||
friend QDataStream& operator >> (QDataStream& stream, SongStorage& song);
|
||||
friend class MySql;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The Song class
|
||||
* into this calss added mediadata of playable media file.
|
||||
*/
|
||||
class Song : public SongHeader{
|
||||
class Song : public SongHeader {
|
||||
private:
|
||||
QByteArray source;
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user