browser: add support for sorting by mtime in local browser
This commit is contained in:
@@ -498,7 +498,10 @@ void Browser::GetLocalDirectory(MPD::ItemList &v, const std::string &directory,
|
||||
item.song = std::shared_ptr<MPD::Song>(s);
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (!recursively)
|
||||
{
|
||||
s->setMTime(fs::last_write_time(e.path()));
|
||||
Tags::read(*s);
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
v.push_back(item);
|
||||
}
|
||||
|
||||
@@ -160,12 +160,24 @@ unsigned MutableSong::getDuration() const
|
||||
return Song::getDuration();
|
||||
}
|
||||
|
||||
time_t MutableSong::getMTime() const
|
||||
{
|
||||
if (m_mtime > 0)
|
||||
return m_mtime;
|
||||
else
|
||||
return Song::getMTime();
|
||||
}
|
||||
|
||||
void MutableSong::setDuration(unsigned int duration)
|
||||
{
|
||||
m_duration = duration;
|
||||
}
|
||||
|
||||
void MutableSong::setMTime(time_t mtime)
|
||||
{
|
||||
m_mtime = mtime;
|
||||
}
|
||||
|
||||
void MutableSong::setTags(SetFunction set, const std::string &value, const std::string &delimiter)
|
||||
{
|
||||
std::vector<std::string> tags;
|
||||
|
||||
@@ -30,8 +30,8 @@ struct MutableSong : public Song
|
||||
{
|
||||
typedef void (MutableSong::*SetFunction)(const std::string &, unsigned);
|
||||
|
||||
MutableSong() : m_duration(0) { }
|
||||
MutableSong(Song s) : Song(s), m_duration(0) { }
|
||||
MutableSong() : m_mtime(0), m_duration(0) { }
|
||||
MutableSong(Song s) : Song(s), m_mtime(0), m_duration(0) { }
|
||||
|
||||
virtual std::string getArtist(unsigned idx = 0) const;
|
||||
virtual std::string getTitle(unsigned idx = 0) const;
|
||||
@@ -61,7 +61,9 @@ struct MutableSong : public Song
|
||||
void setNewURI(const std::string &value);
|
||||
|
||||
virtual unsigned getDuration() const;
|
||||
virtual time_t getMTime() const;
|
||||
void setDuration(unsigned duration);
|
||||
void setMTime(time_t mtime);
|
||||
|
||||
void setTags(SetFunction set, const std::string &value, const std::string &delimiter);
|
||||
|
||||
@@ -103,6 +105,7 @@ private:
|
||||
}
|
||||
|
||||
std::string m_uri;
|
||||
time_t m_mtime;
|
||||
unsigned m_duration;
|
||||
std::map<Tag, std::string> m_tags;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user