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