Track: Hide the artist tag from the public
Also set it using our new constructor. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
6149c928d2
commit
0a6ace3c14
|
@ -22,7 +22,7 @@ Database<Track> track_db("track.db", false);
|
|||
*/
|
||||
|
||||
Track :: Track(const std::string &f, Library *library)
|
||||
: _library(library), artist(NULL), album(NULL), genre(NULL),
|
||||
: _artist(NULL), _library(library), album(NULL), genre(NULL),
|
||||
play_count(0), last_year(0), last_month(0), last_day(0),
|
||||
filepath(f.substr(library->primary_key().size() + 1))
|
||||
{
|
||||
|
@ -52,12 +52,12 @@ void Track :: read(File &f)
|
|||
filepath = f.getline();
|
||||
|
||||
_library = tags :: get_library(library_id);
|
||||
artist = tags :: get_artist(artist_id);
|
||||
_artist = tags :: get_artist(artist_id);
|
||||
album = tags :: get_album(album_id);
|
||||
genre = tags :: get_genre(genre_id);
|
||||
|
||||
title_lower = filter :: add(title, index());
|
||||
filter :: add(artist->name(), index());
|
||||
filter :: add(_artist->name(), index());
|
||||
filter :: add(album->name(), index());
|
||||
_library->inc_size();
|
||||
set_length_str();
|
||||
|
@ -65,7 +65,7 @@ void Track :: read(File &f)
|
|||
|
||||
void Track :: write(File &f)
|
||||
{
|
||||
f << _library->index() << " " << artist->index() << " ";
|
||||
f << _library->index() << " " << _artist->index() << " ";
|
||||
f << album->index() << " " << genre->index() << " " << track << " ";
|
||||
f << last_year << " " << last_month << " " << last_day << " ";
|
||||
f << play_count << " " << length << " " << title << std::endl;
|
||||
|
@ -114,7 +114,7 @@ bool Track :: tag()
|
|||
tag = ref.tag();
|
||||
audio = ref.audioProperties();
|
||||
|
||||
artist = tags :: get_artist(format_tag(tag->artist()));
|
||||
_artist = tags :: get_artist(format_tag(tag->artist()));
|
||||
album = tags :: get_album(format_tag(tag->album()), tag->year());
|
||||
genre = tags :: get_genre(format_tag(tag->genre()));
|
||||
track = tag->track();
|
||||
|
@ -124,7 +124,7 @@ bool Track :: tag()
|
|||
title_lower = filter :: add(title, index());
|
||||
set_length_str();
|
||||
|
||||
filter :: add(artist->name(), index());
|
||||
filter :: add(_artist->name(), index());
|
||||
filter :: add(album->name(), index());
|
||||
|
||||
return true;
|
||||
|
@ -179,7 +179,7 @@ int Track :: less_than(Track *rhs, sort_t field)
|
|||
int ret;
|
||||
switch (field) {
|
||||
case SORT_ARTIST:
|
||||
return artist->compare(rhs->artist);
|
||||
return _artist->compare(rhs->artist());
|
||||
case SORT_ALBUM:
|
||||
return album->compare(rhs->album);
|
||||
case SORT_COUNT:
|
||||
|
|
|
@ -7,14 +7,15 @@
|
|||
|
||||
Track :: Track()
|
||||
: GenericTag(),
|
||||
_library(NULL), artist(NULL), album(NULL), genre(NULL),
|
||||
_artist(NULL), _library(NULL), album(NULL), genre(NULL),
|
||||
track(0), length(0), play_count(0), last_year(0), last_month(0), last_day(0)
|
||||
{}
|
||||
|
||||
Track :: Track(Library *library)
|
||||
: _library(library)
|
||||
Track :: Track(Artist *artist, Library *library)
|
||||
: _artist(artist), _library(library)
|
||||
{
|
||||
_library->inc_size();
|
||||
}
|
||||
|
||||
Artist *Track :: artist() { return _artist; }
|
||||
Library *Track :: library() { return _library; }
|
||||
|
|
|
@ -47,7 +47,7 @@ static void on_track_loaded(Track *track)
|
|||
Gtk::Label *duration = lib :: get_widget<Gtk::Label>("o_total_time");
|
||||
|
||||
set_label_text(title, "xx-large", track->title);
|
||||
set_label_text(artist, "x-large", "By: " + track->artist->name());
|
||||
set_label_text(artist, "x-large", "By: " + track->artist()->name());
|
||||
set_label_text(album, "x-large", "From: " + track->album->name());
|
||||
duration->set_text(track->length_str);
|
||||
|
||||
|
|
|
@ -39,13 +39,12 @@ enum sort_t {
|
|||
|
||||
class Track : public GenericTag {
|
||||
private:
|
||||
Artist *_artist; /**< Pointer to the Artist performing this track. */
|
||||
Library *_library; /**< Pointer to the Library containing this track. */
|
||||
|
||||
void set_length_str();
|
||||
|
||||
public:
|
||||
/** Pointer to this track's artist information */
|
||||
Artist *artist;
|
||||
/** Pointer to this track's album information */
|
||||
Album *album;
|
||||
/** Pointer to this track's genre information */
|
||||
|
@ -79,9 +78,10 @@ public:
|
|||
/**
|
||||
* Track constructor
|
||||
*
|
||||
* @param artist The artist performing this track.
|
||||
* @param library The library containing this track.
|
||||
*/
|
||||
Track(Library *);
|
||||
Track(Artist *, Library *);
|
||||
|
||||
/**
|
||||
* Track constructor
|
||||
|
@ -94,6 +94,7 @@ public:
|
|||
~Track();
|
||||
|
||||
|
||||
Artist *artist(); /**< @return Track::_artist. */
|
||||
Library *library(); /**< @return Track::_library. */
|
||||
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ void QueueModel::get_value_str(Track *track, int column,
|
|||
specific.set(track->length_str);
|
||||
break;
|
||||
case 3:
|
||||
specific.set(track->artist->name());
|
||||
specific.set(track->artist()->name());
|
||||
break;
|
||||
case 4:
|
||||
specific.set(track->album->name());
|
||||
|
|
|
@ -9,8 +9,8 @@ static void test_track_tag_default()
|
|||
{
|
||||
Track track;
|
||||
|
||||
test_equal(track.artist(), (Artist *)NULL);
|
||||
test_equal(track.library(), (Library *)NULL);
|
||||
test_equal(track.artist, (Artist *)NULL);
|
||||
test_equal(track.album, (Album *)NULL);
|
||||
test_equal(track.genre, (Genre *)NULL);
|
||||
|
||||
|
@ -32,9 +32,11 @@ static void test_track_tag_default()
|
|||
|
||||
static void test_track_tag_constructor()
|
||||
{
|
||||
Artist *artist = tags :: get_artist("Koji Kondo");
|
||||
Library *library = tags :: get_library("/home/Zelda/Music");
|
||||
Track track(library);
|
||||
Track track(artist, library);
|
||||
|
||||
test_equal(track.artist(), artist);
|
||||
test_equal(track.library(), library);
|
||||
test_equal(track.library()->size(), (unsigned)1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue