Added a play/add all on tracks view

This commit is contained in:
emeric
2018-02-25 08:57:05 +01:00
parent fe53103445
commit aa54b5b599
12 changed files with 84 additions and 18 deletions
+3 -1
View File
@@ -120,7 +120,9 @@ Artist::getByFilter(Wt::Dbo::Session& session,
const std::vector<std::string> keywords,
int offset, int size, bool& moreResults)
{
Wt::Dbo::collection<Artist::pointer> collection = getQuery(session, clusters, keywords).limit(size + 1).offset(offset);
Wt::Dbo::collection<Artist::pointer> collection = getQuery(session, clusters, keywords)
.limit(size != -1 ? size + 1 : -1)
.offset(offset);
auto res = std::vector<pointer>(collection.begin(), collection.end());
+6 -6
View File
@@ -61,12 +61,6 @@ Playlist::getAll(Wt::Dbo::Session& session, Wt::Dbo::ptr<User> user)
return std::vector<Playlist::pointer>(res.begin(), res.end());
}
void
Playlist::addTrack(Wt::Dbo::ptr<Track> track)
{
_entries.insert( PlaylistEntry::create(*session(), track, self(), _entries.size()) );
}
PlaylistEntry::PlaylistEntry(Wt::Dbo::ptr<Track> track, Wt::Dbo::ptr<Playlist> playlist, int pos)
: _pos(pos),
_track(track),
@@ -107,4 +101,10 @@ Playlist::getTracks(int offset, int size, bool& moreResults) const
return res;
}
std::size_t
Playlist::getCount() const
{
return _entries.size();
}
} // namespace Database
+1 -1
View File
@@ -50,10 +50,10 @@ class Playlist : public Wt::Dbo::Dbo<Playlist>
bool isPublic() const { return _isPublic; }
// Modifiers
void addTrack(Wt::Dbo::ptr<Track> track);
void clear() { _entries.clear(); }
// Get tracks, ordered by position
std::size_t getCount() const;
std::vector<Wt::Dbo::ptr<Track>> getTracks(int offset, int size, bool& moreResults) const;
template<class Action>
+3 -1
View File
@@ -118,7 +118,9 @@ Release::getByFilter(Wt::Dbo::Session& session,
const std::vector<std::string> keywords,
int offset, int size, bool& moreResults)
{
Wt::Dbo::collection<pointer> collection = getQuery(session, clusterIds, keywords).limit(size + 1).offset(offset);
Wt::Dbo::collection<pointer> collection = getQuery(session, clusterIds, keywords)
.limit(size != -1 ? size + 1 : -1)
.offset(offset);
auto res = std::vector<pointer>(collection.begin(), collection.end());
+12 -1
View File
@@ -169,7 +169,9 @@ Track::getByFilter(Wt::Dbo::Session& session,
const std::vector<std::string> keywords,
int offset, int size, bool& moreResults)
{
Wt::Dbo::collection<pointer> collection = getQuery(session, clusterIds, keywords).limit(size + 1).offset(offset);
Wt::Dbo::collection<pointer> collection = getQuery(session, clusterIds, keywords)
.limit(size != -1 ? size + 1 : -1)
.offset(offset);
auto res = std::vector<pointer>(collection.begin(), collection.end());
@@ -184,6 +186,15 @@ Track::getByFilter(Wt::Dbo::Session& session,
return res;
}
std::vector<Track::pointer>
Track::getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusters)
{
bool moreResults;
return getByFilter(session, clusters, std::vector<std::string>(), -1, -1, moreResults);
}
boost::optional<std::size_t>
Track::getTrackNumber(void) const
{
+2
View File
@@ -118,6 +118,8 @@ class Track
static pointer getByPath(Wt::Dbo::Session& session, const boost::filesystem::path& p);
static pointer getById(Wt::Dbo::Session& session, id_type id);
static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID);
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusters); // tracks that belong to these clusters
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusters, // tracks that belong to these clusters
const std::vector<std::string> keywords, // name must match all of these keywords