Clementine-audio-player-Mac.../src/song.h

100 lines
2.3 KiB
C
Raw Normal View History

2009-12-24 20:16:07 +01:00
#ifndef SONG_H
#define SONG_H
#include <QString>
#include <QList>
#include <QSqlQuery>
2009-12-26 23:15:57 +01:00
namespace lastfm {
class Track;
}
2009-12-29 20:22:02 +01:00
// TODO: QSharedData
2009-12-24 20:16:07 +01:00
class Song {
public:
Song();
static const char* kColumnSpec;
static const char* kBindSpec;
static const char* kUpdateSpec;
// Constructors
void InitFromFile(const QString& filename, int directory_id);
void InitFromQuery(const QSqlQuery& query);
2009-12-26 23:15:57 +01:00
void InitFromLastFM(const lastfm::Track& track);
2009-12-24 20:16:07 +01:00
// Save
void BindToQuery(QSqlQuery* query) const;
2009-12-29 20:22:02 +01:00
void ToLastFM(lastfm::Track* track) const;
2009-12-24 20:16:07 +01:00
// Simple accessors
bool is_valid() const { return valid_; }
int id() const { return id_; }
QString title() const { return title_; }
QString album() const { return album_; }
QString artist() const { return artist_; }
QString albumartist() const { return albumartist_; }
QString composer() const { return composer_; }
int track() const { return track_; }
int disc() const { return disc_; }
float bpm() const { return bpm_; }
int year() const { return year_; }
QString genre() const { return genre_; }
QString comment() const { return comment_; }
bool is_compilation() const { return compilation_; }
int length() const { return length_; }
int bitrate() const { return bitrate_; }
int samplerate() const { return samplerate_; }
int directory_id() const { return directory_id_; }
QString filename() const { return filename_; }
uint mtime() const { return mtime_; }
uint ctime() const { return ctime_; }
int filesize() const { return filesize_; }
// Pretty accessors
QString PrettyTitle() const;
QString PrettyTitleWithArtist() const;
QString PrettyLength() const;
// Setters
void set_id(int id) { id_ = id; }
2009-12-29 20:22:02 +01:00
void set_title(const QString& title) { title_ = title; }
2009-12-24 20:16:07 +01:00
// Comparison functions
bool IsMetadataEqual(const Song& other) const;
private:
bool valid_;
int id_;
QString title_;
QString album_;
QString artist_;
QString albumartist_;
QString composer_;
int track_;
int disc_;
float bpm_;
int year_;
QString genre_;
QString comment_;
bool compilation_;
int length_;
int bitrate_;
int samplerate_;
int directory_id_;
QString filename_;
int mtime_;
int ctime_;
int filesize_;
};
typedef QList<Song> SongList;
#endif // SONG_H