diff --git a/src/cover/CoverArtGrabber.cpp b/src/cover/CoverArtGrabber.cpp index f720e7c2..7a09bf72 100644 --- a/src/cover/CoverArtGrabber.cpp +++ b/src/cover/CoverArtGrabber.cpp @@ -17,8 +17,13 @@ * along with LMS. If not, see . */ +#include + #include "av/AvInfo.hpp" +#include "database/Release.hpp" +#include "database/Track.hpp" + #include "utils/Logger.hpp" #include "CoverArtGrabber.hpp" @@ -145,7 +150,7 @@ Grabber::getFromTrack(const boost::filesystem::path& p, std::size_t nbMaxCovers) } std::vector -Grabber::getFromTrack(Wt::Dbo::Session& session, Database::Track::id_type trackId, std::size_t nbMaxCovers) const +Grabber::getFromTrack(Wt::Dbo::Session& session, Database::IdType trackId, std::size_t nbMaxCovers) const { using namespace Database; @@ -173,7 +178,7 @@ Grabber::getFromTrack(Wt::Dbo::Session& session, Database::Track::id_type trackI std::vector -Grabber::getFromRelease(Wt::Dbo::Session& session, Database::Release::id_type releaseId, std::size_t nbMaxCovers) const +Grabber::getFromRelease(Wt::Dbo::Session& session, Database::IdType releaseId, std::size_t nbMaxCovers) const { using namespace Database; diff --git a/src/cover/CoverArtGrabber.hpp b/src/cover/CoverArtGrabber.hpp index 18d53a5d..43753c4f 100644 --- a/src/cover/CoverArtGrabber.hpp +++ b/src/cover/CoverArtGrabber.hpp @@ -38,8 +38,8 @@ class Grabber std::vector getCoverPaths(const boost::filesystem::path& directoryPath, std::size_t nbMaxCovers = 1) const; std::vector getFromDirectory(const boost::filesystem::path& path, std::size_t nbMaxCovers = 1) const; std::vector getFromTrack(const boost::filesystem::path& path, std::size_t nbMaxCovers = 1) const; - std::vector getFromTrack(Wt::Dbo::Session& session, Database::Track::id_type trackId, std::size_t nbMaxCovers = 1) const; - std::vector getFromRelease(Wt::Dbo::Session& session, Database::Release::id_type releaseId, std::size_t nbMaxCovers = 1) const; + std::vector getFromTrack(Wt::Dbo::Session& session, Database::IdType trackId, std::size_t nbMaxCovers = 1) const; + std::vector getFromRelease(Wt::Dbo::Session& session, Database::IdType releaseId, std::size_t nbMaxCovers = 1) const; private: Grabber(); diff --git a/src/database/DatabaseHandler.cpp b/src/database/DatabaseHandler.cpp index ff6b5136..dc915eb7 100644 --- a/src/database/DatabaseHandler.cpp +++ b/src/database/DatabaseHandler.cpp @@ -33,6 +33,12 @@ #include "utils/Logger.hpp" +#include "DbArtist.hpp" +#include "MediaDirectory.hpp" +#include "Playlist.hpp" +#include "Release.hpp" +#include "Track.hpp" + #include "DatabaseHandler.hpp" namespace Database { diff --git a/src/database/DatabaseHandler.hpp b/src/database/DatabaseHandler.hpp index 1a1a8006..f57a096d 100644 --- a/src/database/DatabaseHandler.hpp +++ b/src/database/DatabaseHandler.hpp @@ -17,8 +17,7 @@ * along with LMS. If not, see . */ -#ifndef DATABASE_HANDLER_HPP -#define DATABASE_HANDLER_HPP +#pragma once #include #include @@ -30,12 +29,11 @@ #include #include -#include "Types.hpp" +#include "User.hpp" namespace Database { -typedef Wt::Dbo::dbo_default_traits::IdType id_type; -typedef Wt::Auth::Dbo::UserDatabase UserDatabase; +using UserDatabase = Wt::Auth::Dbo::UserDatabase; // Session living class handling the database and the login class Handler @@ -72,5 +70,4 @@ class Handler } // namespace Database -#endif diff --git a/src/database/DbArtist.cpp b/src/database/DbArtist.cpp index 823cf35c..416bdc26 100644 --- a/src/database/DbArtist.cpp +++ b/src/database/DbArtist.cpp @@ -17,11 +17,14 @@ * along with LMS. If not, see . */ -#include "Types.hpp" #include "SqlQuery.hpp" #include "utils/Logger.hpp" +#include "Release.hpp" +#include "DbArtist.hpp" +#include "Track.hpp" + namespace Database { @@ -46,7 +49,7 @@ Artist::getByMBID(Wt::Dbo::Session& session, const std::string& mbid) } Artist::pointer -Artist::getById(Wt::Dbo::Session& session, Artist::id_type id) +Artist::getById(Wt::Dbo::Session& session, IdType id) { return session.find().where("id = ?").bind(id); } @@ -75,7 +78,7 @@ Artist::getAllOrphans(Wt::Dbo::Session& session) static Wt::Dbo::Query getQuery(Wt::Dbo::Session& session, - const std::set& clusterIds, + const std::set& clusterIds, const std::vector& keywords) { WhereClause where; @@ -116,7 +119,7 @@ getQuery(Wt::Dbo::Session& session, std::vector Artist::getByFilter(Wt::Dbo::Session& session, - const std::set& clusters, + const std::set& clusters, const std::vector keywords, int offset, int size, bool& moreResults) { @@ -138,7 +141,7 @@ Artist::getByFilter(Wt::Dbo::Session& session, } std::vector> -Artist::getReleases(const std::set& clusterIds) const +Artist::getReleases(const std::set& clusterIds) const { assert(self()); assert(self()->id() != Wt::Dbo::dbo_traits::invalidId() ); @@ -212,7 +215,7 @@ Artist::getClusterGroups(std::vector clusterTypes, std::si Wt::Dbo::collection queryRes = query; - std::map> clusters; + std::map> clusters; for (auto cluster : queryRes) { if (clusters[cluster->getType().id()].size() < size) diff --git a/src/database/DbArtist.hpp b/src/database/DbArtist.hpp index 1b5f6629..9ff9c673 100644 --- a/src/database/DbArtist.hpp +++ b/src/database/DbArtist.hpp @@ -17,8 +17,7 @@ * along with LMS. If not, see . */ -#ifndef _DB_ARTIST_HPP_ -#define _DB_ARTIST_HPP_ +#pragma once #include #include @@ -26,6 +25,8 @@ #include #include +#include "Types.hpp" + namespace Database { @@ -39,17 +40,16 @@ class Artist : public Wt::Dbo::Dbo public: typedef Wt::Dbo::ptr pointer; - typedef Wt::Dbo::dbo_traits::IdType id_type; Artist() {} Artist(const std::string& name, const std::string& MBID = ""); // Accessors static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID); - static pointer getById(Wt::Dbo::Session& session, id_type id); + static pointer getById(Wt::Dbo::Session& session, IdType id); static std::vector getByName(Wt::Dbo::Session& session, const std::string& name); static std::vector getByFilter(Wt::Dbo::Session& session, - const std::set& clusters, // at least one track that belongs to these clusters + const std::set& clusters, // at least one track that belongs to these clusters const std::vector keywords, // name must match all of these keywords int offset, int size, @@ -63,7 +63,7 @@ class Artist : public Wt::Dbo::Dbo std::string getMBID(void) const { return _MBID; } // Get the releases that have at least one track for this artist that belongs to optional cluster filters - std::vector> getReleases(const std::set& clusterIds = std::set()) const; + std::vector> getReleases(const std::set& clusterIds = std::set()) const; // Get the cluster of the tracks made by this artist // Each clusters are grouped by cluster type, sorted by the number of occurence @@ -97,4 +97,3 @@ class Artist : public Wt::Dbo::Dbo } // namespace Database -#endif diff --git a/src/database/MediaDirectory.cpp b/src/database/MediaDirectory.cpp index d9801689..edc4d7ef 100644 --- a/src/database/MediaDirectory.cpp +++ b/src/database/MediaDirectory.cpp @@ -19,7 +19,7 @@ #include "utils/Utils.hpp" -#include "Types.hpp" +#include "MediaDirectory.hpp" namespace Database { diff --git a/src/database/MediaDirectory.hpp b/src/database/MediaDirectory.hpp index 434e78a3..7b640967 100644 --- a/src/database/MediaDirectory.hpp +++ b/src/database/MediaDirectory.hpp @@ -17,8 +17,7 @@ * along with LMS. If not, see . */ -#ifndef DATABASE_MEDIA_DIRECTORY_HPP -#define DATABASE_MEDIA_DIRECTORY_HPP +#pragma once #include @@ -59,5 +58,3 @@ class MediaDirectory } // namespace Database -#endif - diff --git a/src/database/Playlist.cpp b/src/database/Playlist.cpp index 8676ffda..d1b5842b 100644 --- a/src/database/Playlist.cpp +++ b/src/database/Playlist.cpp @@ -16,8 +16,12 @@ * You should have received a copy of the GNU General Public License * along with LMS. If not, see . */ +#include -#include "Types.hpp" +#include "User.hpp" +#include "Track.hpp" + +#include "Playlist.hpp" namespace Database { diff --git a/src/database/Playlist.hpp b/src/database/Playlist.hpp index beddbfa7..b9840fc9 100644 --- a/src/database/Playlist.hpp +++ b/src/database/Playlist.hpp @@ -17,8 +17,7 @@ * along with LMS. If not, see . */ -#ifndef DATABASE_PLAYLIST_HPP -#define DATABASE_PLAYLIST_HPP +#pragma once #include @@ -108,4 +107,3 @@ class PlaylistEntry } // namespace Database -#endif diff --git a/src/database/Release.cpp b/src/database/Release.cpp index 0fe6ba65..cde23718 100644 --- a/src/database/Release.cpp +++ b/src/database/Release.cpp @@ -17,9 +17,13 @@ * along with LMS. If not, see . */ -#include "Types.hpp" #include "SqlQuery.hpp" +#include "DbArtist.hpp" +#include "Track.hpp" + +#include "Release.hpp" + namespace Database { @@ -44,7 +48,7 @@ Release::getByMBID(Wt::Dbo::Session& session, const std::string& mbid) } Release::pointer -Release::getById(Wt::Dbo::Session& session, Release::id_type id) +Release::getById(Wt::Dbo::Session& session, IdType id) { return session.find().where("id = ?").bind(id); } @@ -73,7 +77,7 @@ Release::getAllOrphans(Wt::Dbo::Session& session) static Wt::Dbo::Query getQuery(Wt::Dbo::Session& session, - const std::set& clusterIds, + const std::set& clusterIds, const std::vector keywords) { WhereClause where; @@ -113,7 +117,7 @@ getQuery(Wt::Dbo::Session& session, std::vector Release::getByFilter(Wt::Dbo::Session& session, - const std::set& clusterIds, + const std::set& clusterIds, const std::vector keywords, int offset, int size, bool& moreResults) { @@ -182,7 +186,7 @@ Release::hasVariousArtists() const } std::vector> -Release::getTracks(const std::set& clusterIds) const +Release::getTracks(const std::set& clusterIds) const { assert(self()); assert(self()->id() != Wt::Dbo::dbo_traits::invalidId() ); @@ -256,7 +260,7 @@ Release::getClusterGroups(std::vector clusterTypes, std::s Wt::Dbo::collection queryRes = query; - std::map> clusters; + std::map> clusters; for (auto cluster : queryRes) { if (clusters[cluster->getType().id()].size() < size) diff --git a/src/database/Release.hpp b/src/database/Release.hpp index c7020556..32cd1f10 100644 --- a/src/database/Release.hpp +++ b/src/database/Release.hpp @@ -23,19 +23,22 @@ #include +#include "Types.hpp" + namespace Database { class Track; class Release; class Artist; +class Cluster; +class ClusterType; class Release : public Wt::Dbo::Dbo { public: typedef Wt::Dbo::ptr pointer; - typedef Wt::Dbo::dbo_traits::IdType id_type; Release() {} Release(const std::string& name, const std::string& MBID = ""); @@ -43,18 +46,18 @@ class Release : public Wt::Dbo::Dbo // Accessors static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID); static std::vector getByName(Wt::Dbo::Session& session, const std::string& name); - static pointer getById(Wt::Dbo::Session& session, id_type id); + static pointer getById(Wt::Dbo::Session& session, IdType id); static std::vector getAllOrphans(Wt::Dbo::Session& session); // no track related static std::vector getAll(Wt::Dbo::Session& session, int offset, int size); static std::vector getByFilter(Wt::Dbo::Session& session, - const std::set& clusters, // at least one track that belongs to these clusters + const std::set& clusters, // at least one track that belongs to these clusters const std::vector keywords, // name must match all of these keywords int offset, int size, bool& moreExpected); - std::vector> getTracks(const std::set& clusters = std::set()) const; + std::vector> getTracks(const std::set& clusters = std::set()) const; // Get the cluster of the tracks that belong to this release // Each clusters are grouped by cluster type, sorted by the number of occurence // size is the max number of cluster per cluster type diff --git a/src/database/SqlQuery.hpp b/src/database/SqlQuery.hpp index 98ce0b4f..76e6487e 100644 --- a/src/database/SqlQuery.hpp +++ b/src/database/SqlQuery.hpp @@ -17,8 +17,7 @@ * along with LMS. If not, see . */ -#ifndef SQL_QUERY_HPP___ -#define SQL_QUERY_HPP___ +#pragma once #include #include @@ -134,5 +133,3 @@ class SqlQuery GroupByStatement _groupByStatement; // GROUP BY statement }; -#endif - diff --git a/src/database/Track.cpp b/src/database/Track.cpp index 6bad83fb..9283eef7 100644 --- a/src/database/Track.cpp +++ b/src/database/Track.cpp @@ -21,7 +21,10 @@ #include "SqlQuery.hpp" -#include "Types.hpp" +#include "DbArtist.hpp" +#include "Release.hpp" + +#include "Track.hpp" namespace Database { @@ -37,12 +40,12 @@ Track::getAll(Wt::Dbo::Session& session) return session.find(); } -std::vector +std::vector Track::getAllIds(Wt::Dbo::Session& session) { Wt::Dbo::Transaction transaction(session); - Wt::Dbo::collection res = session.query("SELECT id from track"); - return std::vector(res.begin(), res.end()); + Wt::Dbo::collection res = session.query("SELECT id from track"); + return std::vector(res.begin(), res.end()); } Track::pointer @@ -52,7 +55,7 @@ Track::getByPath(Wt::Dbo::Session& session, const boost::filesystem::path& p) } Track::pointer -Track::getById(Wt::Dbo::Session& session, id_type id) +Track::getById(Wt::Dbo::Session& session, IdType id) { return session.find().where("id = ?").bind(id); } @@ -102,7 +105,7 @@ Track::getClusters(void) const static Wt::Dbo::Query< Track::pointer > getQuery(Wt::Dbo::Session& session, - const std::set& clusterIds, + const std::set& clusterIds, const std::vector keywords) { WhereClause where; @@ -142,7 +145,7 @@ getQuery(Wt::Dbo::Session& session, std::vector Track::getByFilter(Wt::Dbo::Session& session, - const std::set& clusterIds, + const std::set& clusterIds, const std::vector keywords, int offset, int size, bool& moreResults) { @@ -165,7 +168,7 @@ Track::getByFilter(Wt::Dbo::Session& session, std::vector Track::getByFilter(Wt::Dbo::Session& session, - const std::set& clusters) + const std::set& clusters) { bool moreResults; @@ -233,7 +236,7 @@ Cluster::getAll(Wt::Dbo::Session& session) } Cluster::pointer -Cluster::getById(Wt::Dbo::Session& session, id_type id) +Cluster::getById(Wt::Dbo::Session& session, IdType id) { return session.find().where("id = ?").bind(id); } @@ -288,7 +291,7 @@ std::vector ClusterType::getClusters() const { assert(self()); - assert(self()->id() != Wt::Dbo::dbo_traits::invalidId() ); + assert(self()->id() != Wt::Dbo::dbo_traits::invalidId() ); assert(session()); Wt::Dbo::collection res = session()->find() @@ -298,5 +301,11 @@ ClusterType::getClusters() const return std::vector(res.begin(), res.end()); } +void +Cluster::addTrack(Wt::Dbo::ptr track) +{ + _tracks.insert(track); +} + } // namespace Database diff --git a/src/database/Track.hpp b/src/database/Track.hpp index 88ae32b7..d0c90081 100644 --- a/src/database/Track.hpp +++ b/src/database/Track.hpp @@ -31,6 +31,8 @@ #include +#include "Types.hpp" + namespace Database { @@ -44,14 +46,13 @@ class Cluster : public Wt::Dbo::Dbo { public: typedef Wt::Dbo::ptr pointer; - typedef Wt::Dbo::dbo_traits::IdType id_type; Cluster(); Cluster(Wt::Dbo::ptr type, std::string name); // Find utility static std::vector getAll(Wt::Dbo::Session& session); - static pointer getById(Wt::Dbo::Session& session, id_type id); + static pointer getById(Wt::Dbo::Session& session, IdType id); // Create utility static pointer create(Wt::Dbo::Session& session, Wt::Dbo::ptr type, std::string name); @@ -61,7 +62,7 @@ class Cluster : public Wt::Dbo::Dbo Wt::Dbo::ptr getType() const { return _clusterType; } const Wt::Dbo::collection>& getTracks() const { return _tracks; } - void addTrack(Wt::Dbo::ptr track) { _tracks.insert(track); } + void addTrack(Wt::Dbo::ptr track); template void persist(Action& a) @@ -88,7 +89,6 @@ class ClusterType : public Wt::Dbo::Dbo public: using pointer = Wt::Dbo::ptr; - using id_type = Wt::Dbo::dbo_traits::IdType; ClusterType() {} ClusterType(std::string name); @@ -126,7 +126,6 @@ class Track public: typedef Wt::Dbo::ptr pointer; - typedef Wt::Dbo::dbo_traits::IdType id_type; Track() {} Track(const boost::filesystem::path& p); @@ -139,19 +138,19 @@ class Track // Find utility functions static pointer getByPath(Wt::Dbo::Session& session, const boost::filesystem::path& p); - static pointer getById(Wt::Dbo::Session& session, id_type id); + static pointer getById(Wt::Dbo::Session& session, IdType id); static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID); static std::vector getByFilter(Wt::Dbo::Session& session, - const std::set& clusters); // tracks that belong to these clusters + const std::set& clusters); // tracks that belong to these clusters static std::vector getByFilter(Wt::Dbo::Session& session, - const std::set& clusters, // tracks that belong to these clusters + const std::set& clusters, // tracks that belong to these clusters const std::vector keywords, // name must match all of these keywords int offset, int size, bool& moreExpected); static Wt::Dbo::collection< pointer > getAll(Wt::Dbo::Session& session); - static std::vector getAllIds(Wt::Dbo::Session& session); // nested transaction + static std::vector getAllIds(Wt::Dbo::Session& session); // nested transaction static std::vector getAllPaths(Wt::Dbo::Session& session); // nested transaction static std::vector getMBIDDuplicates(Wt::Dbo::Session& session); static std::vector getChecksumDuplicates(Wt::Dbo::Session& session); diff --git a/src/database/Types.hpp b/src/database/Types.hpp index 0518cbe5..5aa1644f 100644 --- a/src/database/Types.hpp +++ b/src/database/Types.hpp @@ -17,12 +17,11 @@ * along with LMS. If not, see . */ -// header file aimed to ease database class declarations +#pragma once -#include "DbArtist.hpp" -#include "Track.hpp" -#include "Playlist.hpp" -#include "Release.hpp" -#include "MediaDirectory.hpp" -#include "User.hpp" +#include + +namespace Database { + using IdType = Wt::Dbo::dbo_default_traits::IdType; +} diff --git a/src/database/User.cpp b/src/database/User.cpp index 9cc52dfd..dd8ed1dd 100644 --- a/src/database/User.cpp +++ b/src/database/User.cpp @@ -17,7 +17,7 @@ * along with LMS. If not, see . */ -#include "Types.hpp" +#include "User.hpp" namespace Database { diff --git a/src/database/User.hpp b/src/database/User.hpp index 28127150..325b11a9 100644 --- a/src/database/User.hpp +++ b/src/database/User.hpp @@ -17,8 +17,7 @@ * along with LMS. If not, see . */ -#ifndef DATABASE_USER_HPP -#define DATABASE_USER_HPP +#pragma once #include @@ -28,7 +27,7 @@ namespace Database { class User; -typedef Wt::Auth::Dbo::AuthInfo AuthInfo; +using AuthInfo = Wt::Auth::Dbo::AuthInfo; class Playlist; @@ -109,4 +108,3 @@ class User : public Wt::Dbo::Dbo } // namespace Databas' -#endif diff --git a/src/scanner/MediaScanner.cpp b/src/scanner/MediaScanner.cpp index 2a66913a..6ea38650 100644 --- a/src/scanner/MediaScanner.cpp +++ b/src/scanner/MediaScanner.cpp @@ -26,8 +26,11 @@ #include "cover/CoverArtGrabber.hpp" +#include "database/DbArtist.hpp" +#include "database/Release.hpp" +#include "database/MediaDirectory.hpp" +#include "database/Track.hpp" #include "database/Setting.hpp" -#include "database/Types.hpp" #include "utils/Logger.hpp" #include "utils/Path.hpp" diff --git a/src/scanner/MediaScanner.hpp b/src/scanner/MediaScanner.hpp index c3d052e5..cedf2922 100644 --- a/src/scanner/MediaScanner.hpp +++ b/src/scanner/MediaScanner.hpp @@ -29,6 +29,9 @@ #include "metadata/TagLibParser.hpp" #include "database/DatabaseHandler.hpp" +#include "database/Track.hpp" +#include "database/DbArtist.hpp" +#include "database/Release.hpp" namespace Scanner { diff --git a/src/ui/MediaPlayer.cpp b/src/ui/MediaPlayer.cpp index f2fbe015..8fb21a14 100644 --- a/src/ui/MediaPlayer.cpp +++ b/src/ui/MediaPlayer.cpp @@ -45,7 +45,7 @@ static std::string escape(const std::string& str) } void -MediaPlayer::playTrack(Database::Track::id_type trackId) +MediaPlayer::playTrack(Database::IdType trackId) { LMS_LOG(UI, DEBUG) << "Playing track ID = " << trackId; diff --git a/src/ui/MediaPlayer.hpp b/src/ui/MediaPlayer.hpp index 55da4f42..eec209b7 100644 --- a/src/ui/MediaPlayer.hpp +++ b/src/ui/MediaPlayer.hpp @@ -32,7 +32,7 @@ class MediaPlayer : public Wt::WTemplate MediaPlayer(); void stop(); - void playTrack(Database::Track::id_type); + void playTrack(Database::IdType trackId); // Signals Wt::JSignal<> playbackEnded; diff --git a/src/ui/PlayQueueView.cpp b/src/ui/PlayQueueView.cpp index b30b48f1..321d9f63 100644 --- a/src/ui/PlayQueueView.cpp +++ b/src/ui/PlayQueueView.cpp @@ -23,6 +23,8 @@ #include "utils/Logger.hpp" +#include "database/Playlist.hpp" + #include "LmsApplication.hpp" #include "PlayQueueView.hpp" @@ -91,7 +93,7 @@ PlayQueue::play(std::size_t pos) { updateCurrentTrack(false); - Database::Track::id_type trackId; + Database::IdType trackId; { Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); diff --git a/src/ui/PlayQueueView.hpp b/src/ui/PlayQueueView.hpp index 0d65d2a0..9249073d 100644 --- a/src/ui/PlayQueueView.hpp +++ b/src/ui/PlayQueueView.hpp @@ -26,7 +26,7 @@ #include -#include "database/Types.hpp" +#include "database/Track.hpp" namespace UserInterface { @@ -45,7 +45,7 @@ class PlayQueue : public Wt::WTemplate void playPrevious(); // Signal emitted when a track is to be played - Wt::Signal playTrack; + Wt::Signal playTrack; // Signal emitted when play has to be stopped Wt::Signal<> playbackStop; diff --git a/src/ui/admin/UsersView.cpp b/src/ui/admin/UsersView.cpp index 97709a1f..776d61f0 100644 --- a/src/ui/admin/UsersView.cpp +++ b/src/ui/admin/UsersView.cpp @@ -20,7 +20,7 @@ #include #include -#include "database/Types.hpp" +#include "database/User.hpp" #include "utils/Logger.hpp" #include "LmsApplication.hpp" diff --git a/src/ui/explore/ArtistView.cpp b/src/ui/explore/ArtistView.cpp index 025bc6f7..f883a7b4 100644 --- a/src/ui/explore/ArtistView.cpp +++ b/src/ui/explore/ArtistView.cpp @@ -22,8 +22,8 @@ #include #include +#include "database/DbArtist.hpp" #include "database/Setting.hpp" -#include "database/Types.hpp" #include "utils/Logger.hpp" #include "utils/Utils.hpp" @@ -92,7 +92,7 @@ Artist::refresh() clear(); - auto artistId = readAs(wApp->internalPathNextPart("/artist/")); + auto artistId = readAs(wApp->internalPathNextPart("/artist/")); if (!artistId) return; diff --git a/src/ui/explore/ArtistView.hpp b/src/ui/explore/ArtistView.hpp index b4bb329f..8c3aed93 100644 --- a/src/ui/explore/ArtistView.hpp +++ b/src/ui/explore/ArtistView.hpp @@ -22,6 +22,8 @@ #include #include +#include "database/Types.hpp" + namespace UserInterface { class Filters; @@ -31,11 +33,11 @@ class Artist : public Wt::WContainerWidget public: Artist(Filters* filters); - Wt::Signal artistAdd; - Wt::Signal artistPlay; + Wt::Signal artistAdd; + Wt::Signal artistPlay; - Wt::Signal releaseAdd; - Wt::Signal releasePlay; + Wt::Signal releaseAdd; + Wt::Signal releasePlay; private: void refresh(); diff --git a/src/ui/explore/ArtistsView.cpp b/src/ui/explore/ArtistsView.cpp index 8cd3ec77..aba01ab5 100644 --- a/src/ui/explore/ArtistsView.cpp +++ b/src/ui/explore/ArtistsView.cpp @@ -21,8 +21,8 @@ #include #include +#include "database/DbArtist.hpp" #include "database/Setting.hpp" -#include "database/Types.hpp" #include "utils/Logger.hpp" #include "utils/Utils.hpp" diff --git a/src/ui/explore/ArtistsView.hpp b/src/ui/explore/ArtistsView.hpp index bfb643f6..7aa9bb0c 100644 --- a/src/ui/explore/ArtistsView.hpp +++ b/src/ui/explore/ArtistsView.hpp @@ -24,6 +24,8 @@ #include #include +#include "database/Types.hpp" + namespace UserInterface { class Filters; @@ -33,8 +35,8 @@ class Artists : public Wt::WTemplate public: Artists(Filters* filters); - Wt::Signal artistAdd; - Wt::Signal artistPlay; + Wt::Signal artistAdd; + Wt::Signal artistPlay; private: void refresh(); diff --git a/src/ui/explore/Explore.cpp b/src/ui/explore/Explore.cpp index 99da8f63..d9596ace 100644 --- a/src/ui/explore/Explore.cpp +++ b/src/ui/explore/Explore.cpp @@ -118,7 +118,7 @@ Explore::Explore() } // TODO SQL this? -static std::vector getArtistTracks(Wt::Dbo::Session& session, Database::id_type artistId, std::set clusters) +static std::vector getArtistTracks(Wt::Dbo::Session& session, Database::IdType artistId, std::set clusters) { std::vector res; @@ -140,7 +140,7 @@ static std::vector getArtistTracks(Wt::Dbo::Session& s return res; } -static std::vector getReleaseTracks(Wt::Dbo::Session& session, Database::id_type releaseId, std::set clusters) +static std::vector getReleaseTracks(Wt::Dbo::Session& session, Database::IdType releaseId, std::set clusters) { std::vector res; @@ -151,7 +151,7 @@ static std::vector getReleaseTracks(Wt::Dbo::Session& return release->getTracks(clusters); } -static std::vector getTrack(Wt::Dbo::Session& session, Database::id_type trackId) +static std::vector getTrack(Wt::Dbo::Session& session, Database::IdType trackId) { std::vector res; @@ -163,7 +163,7 @@ static std::vector getTrack(Wt::Dbo::Session& session, } void -Explore::handleArtistAdd(Database::id_type id) +Explore::handleArtistAdd(Database::IdType id) { Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); @@ -171,7 +171,7 @@ Explore::handleArtistAdd(Database::id_type id) } void -Explore::handleArtistPlay(Database::id_type id) +Explore::handleArtistPlay(Database::IdType id) { Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); @@ -179,7 +179,7 @@ Explore::handleArtistPlay(Database::id_type id) } void -Explore::handleReleaseAdd(Database::id_type id) +Explore::handleReleaseAdd(Database::IdType id) { Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); @@ -187,7 +187,7 @@ Explore::handleReleaseAdd(Database::id_type id) } void -Explore::handleReleasePlay(Database::id_type id) +Explore::handleReleasePlay(Database::IdType id) { Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); @@ -195,7 +195,7 @@ Explore::handleReleasePlay(Database::id_type id) } void -Explore::handleTrackAdd(Database::id_type id) +Explore::handleTrackAdd(Database::IdType id) { Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); @@ -203,7 +203,7 @@ Explore::handleTrackAdd(Database::id_type id) } void -Explore::handleTrackPlay(Database::id_type id) +Explore::handleTrackPlay(Database::IdType id) { Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); diff --git a/src/ui/explore/Explore.hpp b/src/ui/explore/Explore.hpp index 75302f6e..ea538876 100644 --- a/src/ui/explore/Explore.hpp +++ b/src/ui/explore/Explore.hpp @@ -21,6 +21,7 @@ #include +#include "database/Track.hpp" #include "database/Types.hpp" namespace UserInterface { @@ -37,12 +38,12 @@ class Explore : public Wt::WTemplate private: - void handleArtistAdd(Database::Artist::id_type id); - void handleArtistPlay(Database::Artist::id_type id); - void handleReleaseAdd(Database::Release::id_type id); - void handleReleasePlay(Database::Release::id_type id); - void handleTrackAdd(Database::Track::id_type id); - void handleTrackPlay(Database::Track::id_type id); + void handleArtistAdd(Database::IdType id); + void handleArtistPlay(Database::IdType id); + void handleReleaseAdd(Database::IdType id); + void handleReleasePlay(Database::IdType id); + void handleTrackAdd(Database::IdType id); + void handleTrackPlay(Database::IdType id); void handleTracksAdd(std::vector tracks); void handleTracksPlay(std::vector tracks); diff --git a/src/ui/explore/Filters.cpp b/src/ui/explore/Filters.cpp index 02d51e46..6c63eed3 100644 --- a/src/ui/explore/Filters.cpp +++ b/src/ui/explore/Filters.cpp @@ -116,7 +116,7 @@ Filters::showDialog() } void -Filters::add(Database::Cluster::id_type clusterId) +Filters::add(Database::IdType clusterId) { Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); diff --git a/src/ui/explore/Filters.hpp b/src/ui/explore/Filters.hpp index 85b5606e..845f0305 100644 --- a/src/ui/explore/Filters.hpp +++ b/src/ui/explore/Filters.hpp @@ -34,9 +34,9 @@ class Filters : public Wt::WTemplate public: Filters(); - void add(Database::Cluster::id_type clusterId); + void add(Database::IdType clusterId); - std::set getClusterIds() const { return _filterIds; } + std::set getClusterIds() const { return _filterIds; } Wt::Signal<>& updated() { return _sigUpdated; } @@ -46,7 +46,7 @@ class Filters : public Wt::WTemplate Wt::WContainerWidget *_filters; Wt::Signal<> _sigUpdated; - std::set _filterIds; + std::set _filterIds; }; } // namespace UserInterface diff --git a/src/ui/explore/ReleaseView.cpp b/src/ui/explore/ReleaseView.cpp index fe8744e4..9be21dfa 100644 --- a/src/ui/explore/ReleaseView.cpp +++ b/src/ui/explore/ReleaseView.cpp @@ -23,7 +23,7 @@ #include #include -#include "database/Types.hpp" +#include "database/Release.hpp" #include "database/Setting.hpp" #include "utils/Logger.hpp" @@ -92,7 +92,7 @@ Release::refresh() clear(); - auto releaseId = readAs(wApp->internalPathNextPart("/release/")); + auto releaseId = readAs(wApp->internalPathNextPart("/release/")); if (!releaseId) return; diff --git a/src/ui/explore/ReleaseView.hpp b/src/ui/explore/ReleaseView.hpp index 12bde073..c0e628ca 100644 --- a/src/ui/explore/ReleaseView.hpp +++ b/src/ui/explore/ReleaseView.hpp @@ -21,6 +21,8 @@ #include +#include "database/Types.hpp" + namespace UserInterface { class Filters; @@ -29,11 +31,11 @@ class Release : public Wt::WContainerWidget public: Release(Filters* filters); - Wt::Signal releaseAdd; - Wt::Signal releasePlay; + Wt::Signal releaseAdd; + Wt::Signal releasePlay; - Wt::Signal trackAdd; - Wt::Signal trackPlay; + Wt::Signal trackAdd; + Wt::Signal trackPlay; private: void refresh(); diff --git a/src/ui/explore/ReleasesView.cpp b/src/ui/explore/ReleasesView.cpp index 7151f6d3..f634cd29 100644 --- a/src/ui/explore/ReleasesView.cpp +++ b/src/ui/explore/ReleasesView.cpp @@ -23,7 +23,7 @@ #include #include -#include "database/Types.hpp" +#include "database/Release.hpp" #include "utils/Logger.hpp" #include "utils/Utils.hpp" diff --git a/src/ui/explore/ReleasesView.hpp b/src/ui/explore/ReleasesView.hpp index 9797da51..eec4ec62 100644 --- a/src/ui/explore/ReleasesView.hpp +++ b/src/ui/explore/ReleasesView.hpp @@ -24,6 +24,8 @@ #include #include +#include "database/Types.hpp" + namespace UserInterface { class Filters; @@ -33,8 +35,8 @@ class Releases : public Wt::WTemplate public: Releases(Filters* filters); - Wt::Signal releaseAdd; - Wt::Signal releasePlay; + Wt::Signal releaseAdd; + Wt::Signal releasePlay; private: void refresh(); diff --git a/src/ui/explore/TracksView.cpp b/src/ui/explore/TracksView.cpp index 19544136..77962644 100644 --- a/src/ui/explore/TracksView.cpp +++ b/src/ui/explore/TracksView.cpp @@ -22,7 +22,9 @@ #include #include -#include "database/Types.hpp" +#include "database/DbArtist.hpp" +#include "database/Track.hpp" +#include "database/Release.hpp" #include "utils/Logger.hpp" #include "utils/Utils.hpp" diff --git a/src/ui/explore/TracksView.hpp b/src/ui/explore/TracksView.hpp index 2b46be07..f5b13d8c 100644 --- a/src/ui/explore/TracksView.hpp +++ b/src/ui/explore/TracksView.hpp @@ -23,6 +23,9 @@ #include #include +#include "database/Types.hpp" +#include "database/Track.hpp" + namespace UserInterface { class Filters; @@ -31,8 +34,8 @@ class Tracks : public Wt::WTemplate public: Tracks(Filters* filters); - Wt::Signal trackAdd; - Wt::Signal trackPlay; + Wt::Signal trackAdd; + Wt::Signal trackPlay; Wt::Signal> tracksAdd; Wt::Signal> tracksPlay; diff --git a/src/ui/resource/ImageResource.cpp b/src/ui/resource/ImageResource.cpp index b64b0529..af342972 100644 --- a/src/ui/resource/ImageResource.cpp +++ b/src/ui/resource/ImageResource.cpp @@ -90,19 +90,19 @@ ImageResource::getDefaultArtistImage(std::size_t size) } std::string -ImageResource::getReleaseUrl(Database::Release::id_type releaseId, std::size_t size) const +ImageResource::getReleaseUrl(Database::IdType releaseId, std::size_t size) const { return url() + "&releaseid=" + std::to_string(releaseId) + "&size=" + std::to_string(size); } std::string -ImageResource::getTrackUrl(Database::Track::id_type trackId, std::size_t size) const +ImageResource::getTrackUrl(Database::IdType trackId, std::size_t size) const { return url() + "&trackid=" + std::to_string(trackId) + "&size=" + std::to_string(size); } std::string -ImageResource::getArtistUrl(Database::Artist::id_type artistId, std::size_t size) const +ImageResource::getArtistUrl(Database::IdType artistId, std::size_t size) const { return url() + "&artistid=" + std::to_string(artistId) + "&size=" + std::to_string(size); } @@ -159,7 +159,7 @@ ImageResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Respons if (trackIdStr) { - auto trackId = readAs(*trackIdStr); + auto trackId = readAs(*trackIdStr); if (!trackId) return; @@ -202,7 +202,7 @@ ImageResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Respons } else if (releaseIdStr) { - auto releaseId = readAs(*releaseIdStr); + auto releaseId = readAs(*releaseIdStr); if (!releaseId) return; diff --git a/src/ui/resource/ImageResource.hpp b/src/ui/resource/ImageResource.hpp index 3629b468..aa01ce2c 100644 --- a/src/ui/resource/ImageResource.hpp +++ b/src/ui/resource/ImageResource.hpp @@ -25,6 +25,8 @@ #include #include "database/DatabaseHandler.hpp" +#include "database/Types.hpp" + #include "image/Image.hpp" namespace UserInterface { @@ -38,9 +40,9 @@ class ImageResource : public Wt::WResource ImageResource(Database::Handler& db); ~ImageResource(); - std::string getReleaseUrl(Database::Release::id_type releaseId, size_t size) const; - std::string getTrackUrl(Database::Track::id_type trackId, size_t size) const; - std::string getArtistUrl(Database::Artist::id_type artistId, size_t size) const; + std::string getReleaseUrl(Database::IdType releaseId, size_t size) const; + std::string getTrackUrl(Database::IdType trackId, size_t size) const; + std::string getArtistUrl(Database::IdType artistId, size_t size) const; std::string getUnknownTrackUrl(size_t size) const; void handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response); diff --git a/src/ui/resource/TranscodeResource.cpp b/src/ui/resource/TranscodeResource.cpp index 5665ea2e..f6aa03f9 100644 --- a/src/ui/resource/TranscodeResource.cpp +++ b/src/ui/resource/TranscodeResource.cpp @@ -40,7 +40,7 @@ TranscodeResource:: ~TranscodeResource() } std::string -TranscodeResource::getUrl(Database::Track::id_type trackId, Av::Encoding encoding) const +TranscodeResource::getUrl(Database::IdType trackId, Av::Encoding encoding) const { std::string res = url()+ "&trackid=" + std::to_string(trackId) + "&encoding=" + std::to_string(Av::encodingToInt(encoding)); @@ -64,7 +64,7 @@ TranscodeResource::handleRequest(const Wt::Http::Request& request, } else { - Database::Track::id_type trackId; + Database::IdType trackId; Av::TranscodeParameters parameters; LMS_LOG(UI, DEBUG) << "No continuation yet"; diff --git a/src/ui/resource/TranscodeResource.hpp b/src/ui/resource/TranscodeResource.hpp index b3842541..ead39acc 100644 --- a/src/ui/resource/TranscodeResource.hpp +++ b/src/ui/resource/TranscodeResource.hpp @@ -26,6 +26,8 @@ #include "av/AvTranscoder.hpp" #include "database/DatabaseHandler.hpp" +#include "database/Types.hpp" + namespace UserInterface { @@ -35,7 +37,7 @@ class TranscodeResource : public Wt::WResource TranscodeResource(Database::Handler& db); ~TranscodeResource(); - std::string getUrl(Database::Track::id_type trackId, Av::Encoding encoding) const; + std::string getUrl(Database::IdType trackId, Av::Encoding encoding) const; void handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response);