diff --git a/core/tags.cpp b/core/tags.cpp index b97320ce..8dcfe441 100644 --- a/core/tags.cpp +++ b/core/tags.cpp @@ -23,7 +23,7 @@ Database track_db("track.db", false); Track :: Track(const std::string &f, Library *library) : _album(NULL), _artist(NULL), _genre(NULL), _library(library), - play_count(0), last_year(0), last_month(0), last_day(0), + _count(0), last_year(0), last_month(0), last_day(0), filepath(f.substr(library->primary_key().size() + 1)) { library->inc_size(); @@ -40,7 +40,7 @@ void Track :: read(File &f) f >> library_id >> artist_id >> album_id >> genre_id; f >> _track >> last_year >> last_month >> last_day; - f >> play_count >> length; + f >> _count >> length; title = f.getline(); filepath = f.getline(); @@ -62,7 +62,7 @@ void Track :: write(File &f) 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; + f << _count << " " << length << " " << title << std::endl; f << filepath << std::endl; } @@ -136,7 +136,7 @@ void Track :: played() time_t the_time = time(NULL); struct tm *now = localtime(&the_time); - play_count++; + _count++; last_day = now->tm_mday; last_month = now->tm_mon + 1; last_year = now->tm_year + 1900; @@ -177,7 +177,7 @@ int Track :: less_than(Track *rhs, sort_t field) case SORT_ALBUM: return _album->compare(rhs->album()); case SORT_COUNT: - return compare_uint(play_count, rhs->play_count); + return compare_uint(_count, rhs->_count); case SORT_GENRE: return _genre->compare(rhs->genre()); case SORT_LENGTH: diff --git a/core/tags/track.cpp b/core/tags/track.cpp index a3b195f8..1140ca16 100644 --- a/core/tags/track.cpp +++ b/core/tags/track.cpp @@ -8,13 +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) + _count(0), _track(0), length(0), last_year(0), last_month(0), last_day(0) {} Track :: Track(Album *album, Artist *artist, Genre *genre, Library *library, unsigned int track) : _album(album), _artist(artist), _genre(genre), _library(library), - _track(track) + _count(0), _track(track) { _library->inc_size(); } @@ -30,4 +30,5 @@ Artist *Track :: artist() { return _artist; } Genre *Track :: genre() { return _genre; } Library *Track :: library() { return _library; } +unsigned int Track :: count() { return _count; } unsigned int Track :: track() { return _track; } diff --git a/include/core/tags/track.h b/include/core/tags/track.h index f3ed94dd..ed9a9ed2 100644 --- a/include/core/tags/track.h +++ b/include/core/tags/track.h @@ -44,15 +44,14 @@ 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. */ + unsigned int _count; /**< Number of times this track has been played. */ + unsigned int _track; /**< Track number of this track. */ void set_length_str(); public: /** Length of this track (in seconds) */ unsigned int length; - /** The number of times this track has been played */ - unsigned int play_count; /** The year this track was last played */ unsigned int last_year; /** The month this track was last played */ @@ -99,6 +98,7 @@ public: Genre *genre(); /**< @return Track::_genre. */ Library *library(); /**< @return Track::_library. */ + unsigned int count(); /**< @return Track::_count. */ unsigned int track(); /**< @return Track::_track. */ /** diff --git a/lib/model.cpp b/lib/model.cpp index 3028bd18..09efe46d 100644 --- a/lib/model.cpp +++ b/lib/model.cpp @@ -124,7 +124,7 @@ void QueueModel::get_value_uint(Track *track, int column, specific.set(track->album()->year()); break; case 7: - specific.set(track->play_count); + specific.set(track->count()); } value.init(Glib::Value::value_type()); @@ -155,7 +155,7 @@ void QueueModel::get_value_str(Track *track, int column, specific.set(track->genre()->name()); break; case 8: - if (track->play_count == 0) + if (track->count() == 0) specific.set("Never"); else { ss << track->last_month << " / "; diff --git a/tests/core/tags/track.cpp b/tests/core/tags/track.cpp index bdf4fbe6..455ba5d0 100644 --- a/tests/core/tags/track.cpp +++ b/tests/core/tags/track.cpp @@ -24,7 +24,7 @@ static void test_track_tag_default() test_equal(track.track(), (unsigned)0); test_equal(track.length, (unsigned)0); - test_equal(track.play_count, (unsigned)0); + test_equal(track.count(), (unsigned)0); test_equal(track.last_year, (unsigned)0); test_equal(track.last_month, (unsigned)0); test_equal(track.last_day, (unsigned)0); @@ -45,6 +45,7 @@ static void test_track_tag_constructor() test_equal(library->size(), (unsigned)1); test_equal(track.track(), (unsigned)13); + test_equal(track.count(), (unsigned)0); } static void test_track_tag_destructor()