Track: Hide the track number from the public
I provide an accessor function to keep this value from ever getting changed. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
91f6f54b4e
commit
468a4e79d5
|
@ -39,7 +39,7 @@ void Track :: read(File &f)
|
|||
unsigned int library_id, artist_id, album_id, genre_id;
|
||||
|
||||
f >> library_id >> artist_id >> album_id >> genre_id;
|
||||
f >> track >> last_year >> last_month >> last_day;
|
||||
f >> _track >> last_year >> last_month >> last_day;
|
||||
f >> play_count >> length;
|
||||
|
||||
title = f.getline();
|
||||
|
@ -60,7 +60,7 @@ void Track :: read(File &f)
|
|||
void Track :: write(File &f)
|
||||
{
|
||||
f << _library->index() << " " << _artist->index() << " ";
|
||||
f << _album->index() << " " << _genre->index() << " " << track << " ";
|
||||
f << _album->index() << " " << _genre->index() << " " << _track << " ";
|
||||
f << last_year << " " << last_month << " " << last_day << " ";
|
||||
f << play_count << " " << length << " " << title << std::endl;
|
||||
f << filepath << std::endl;
|
||||
|
@ -111,7 +111,7 @@ bool Track :: tag()
|
|||
_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();
|
||||
_track = tag->track();
|
||||
length = audio->length();
|
||||
title = format_tag(tag->title());
|
||||
|
||||
|
@ -193,7 +193,7 @@ int Track :: less_than(Track *rhs, sort_t field)
|
|||
case SORT_TITLE:
|
||||
return compare_string(title_lower, rhs->title_lower);
|
||||
case SORT_TRACK:
|
||||
return compare_uint(track, rhs->track);
|
||||
return compare_uint(_track, rhs->_track);
|
||||
case SORT_YEAR:
|
||||
return compare_uint(_album->year(), rhs->album()->year());
|
||||
}
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
Track :: Track()
|
||||
: GenericTag(),
|
||||
_album(NULL), _artist(NULL), _genre(NULL), _library(NULL),
|
||||
track(0), length(0), play_count(0), last_year(0), last_month(0), last_day(0)
|
||||
_track(0), length(0), play_count(0), last_year(0), last_month(0), last_day(0)
|
||||
{}
|
||||
|
||||
Track :: Track(Album *album, Artist *artist, Genre *genre, Library *library)
|
||||
: _album(album), _artist(artist), _genre(genre), _library(library)
|
||||
Track :: Track(Album *album, Artist *artist, Genre *genre, Library *library,
|
||||
unsigned int track)
|
||||
: _album(album), _artist(artist), _genre(genre), _library(library),
|
||||
_track(track)
|
||||
{
|
||||
_library->inc_size();
|
||||
}
|
||||
|
@ -27,3 +29,5 @@ Album *Track :: album() { return _album; }
|
|||
Artist *Track :: artist() { return _artist; }
|
||||
Genre *Track :: genre() { return _genre; }
|
||||
Library *Track :: library() { return _library; }
|
||||
|
||||
unsigned int Track :: track() { return _track; }
|
||||
|
|
|
@ -44,11 +44,11 @@ private:
|
|||
Genre *_genre; /**< Pointer to the Genre describing this track. */
|
||||
Library *_library; /**< Pointer to the Library containing this track. */
|
||||
|
||||
unsigned int _track; /**< Track number of this track. */
|
||||
|
||||
void set_length_str();
|
||||
|
||||
public:
|
||||
/** Track number of this track */
|
||||
unsigned int track;
|
||||
/** Length of this track (in seconds) */
|
||||
unsigned int length;
|
||||
/** The number of times this track has been played */
|
||||
|
@ -79,8 +79,9 @@ public:
|
|||
* @param artist The artist performing this track.
|
||||
* @param genre The genre describing this track.
|
||||
* @param library The library containing this track.
|
||||
* @param track The track number of this track.
|
||||
*/
|
||||
Track(Album *, Artist *, Genre *, Library *);
|
||||
Track(Album *, Artist *, Genre *, Library *, unsigned int);
|
||||
|
||||
/**
|
||||
* Track constructor
|
||||
|
@ -98,6 +99,7 @@ public:
|
|||
Genre *genre(); /**< @return Track::_genre. */
|
||||
Library *library(); /**< @return Track::_library. */
|
||||
|
||||
unsigned int track(); /**< @return Track::_track. */
|
||||
|
||||
/**
|
||||
* Called to access a track's primary key
|
||||
|
|
|
@ -118,7 +118,7 @@ void QueueModel::get_value_uint(Track *track, int column,
|
|||
|
||||
switch (column) {
|
||||
case 0:
|
||||
specific.set(track->track);
|
||||
specific.set(track->track());
|
||||
break;
|
||||
case 5:
|
||||
specific.set(track->album()->year());
|
||||
|
|
|
@ -22,7 +22,7 @@ static void test_track_tag_default()
|
|||
test_equal(track.filepath, (std::string)"");
|
||||
test_equal(track.length_str, (std::string)"");
|
||||
|
||||
test_equal(track.track, (unsigned)0);
|
||||
test_equal(track.track(), (unsigned)0);
|
||||
test_equal(track.length, (unsigned)0);
|
||||
test_equal(track.play_count, (unsigned)0);
|
||||
test_equal(track.last_year, (unsigned)0);
|
||||
|
@ -36,13 +36,15 @@ static void test_track_tag_constructor()
|
|||
Artist *artist = tags :: get_artist("Koji Kondo");
|
||||
Genre *genre = tags :: get_genre("Video Game Music");
|
||||
Library *library = tags :: get_library("/home/Zelda/Music");
|
||||
Track track(album, artist, genre, library);
|
||||
Track track(album, artist, genre, library, 13);
|
||||
|
||||
test_equal(track.album(), album);
|
||||
test_equal(track.artist(), artist);
|
||||
test_equal(track.genre(), genre);
|
||||
test_equal(track.library(), library);
|
||||
test_equal(library->size(), (unsigned)1);
|
||||
|
||||
test_equal(track.track(), (unsigned)13);
|
||||
}
|
||||
|
||||
static void test_track_tag_destructor()
|
||||
|
|
Loading…
Reference in New Issue