Added helpers to simplify session data accesses. Made the CoverResource global to the session
This commit is contained in:
@@ -47,6 +47,21 @@ AudioMediaPlayer::AudioMediaPlayer( Wt::WMediaPlayer::Encoding encoding, Wt::WCo
|
||||
Wt::WVBoxLayout* mainLayout = new Wt::WVBoxLayout();
|
||||
this->setLayout(mainLayout);
|
||||
|
||||
/* TODO add media info here
|
||||
// Current Media info
|
||||
Wt::WHBoxLayout *currentMediaLayout = new Wt::WHBoxLayout();
|
||||
mainLayout->addLayout(currentMediaLayout);
|
||||
|
||||
currentMediaLayout->addWidget( _mediaCover = new Wt::WImage());
|
||||
_mediaCover->setImageLink( Wt::WLink("images/unknown-cover.jpg") );
|
||||
|
||||
Wt::WVBoxLayout* mediaInfoLayout = new Wt::WVBoxLayout();
|
||||
currentMediaLayout->addLayout(mediaInfoLayout, 1);
|
||||
|
||||
mediaInfoLayout->addWidget( _mediaTitle = new Wt::WText());
|
||||
mediaInfoLayout->addWidget( _mediaArtistRelease = new Wt::WText());
|
||||
*/
|
||||
// Time control
|
||||
Wt::WHBoxLayout *sliderLayout = new Wt::WHBoxLayout();
|
||||
mainLayout->addLayout(sliderLayout);
|
||||
|
||||
@@ -56,6 +71,7 @@ AudioMediaPlayer::AudioMediaPlayer( Wt::WMediaPlayer::Encoding encoding, Wt::WCo
|
||||
sliderLayout->addWidget(_duration = new Wt::WText("00:00:00"));
|
||||
_duration->setLineHeight(30);
|
||||
|
||||
// Controls
|
||||
Wt::WHBoxLayout *controlsLayout = new Wt::WHBoxLayout();
|
||||
|
||||
mainLayout->addLayout(controlsLayout);
|
||||
@@ -63,7 +79,6 @@ AudioMediaPlayer::AudioMediaPlayer( Wt::WMediaPlayer::Encoding encoding, Wt::WCo
|
||||
Wt::WContainerWidget *btnContainer = new Wt::WContainerWidget();
|
||||
// Do not allow button to wrap
|
||||
btnContainer->setMinimumSize(155, Wt::WLength::Auto);
|
||||
|
||||
Wt::WTemplate *t = new Wt::WTemplate(Wt::WString::tr("mediaplayer-controls"), btnContainer);
|
||||
|
||||
Wt::WPushButton *prevBtn = new Wt::WPushButton("<<");
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WMediaPlayer>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WImage>
|
||||
|
||||
#include "transcode/Parameters.hpp"
|
||||
#include "resource/AvConvTranscodeStreamResource.hpp"
|
||||
#include "resource/CoverResource.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Desktop {
|
||||
@@ -79,6 +81,11 @@ class AudioMediaPlayer : public Wt::WContainerWidget
|
||||
AvConvTranscodeStreamResource* _mediaResource;
|
||||
Wt::WMediaPlayer::Encoding _encoding;
|
||||
|
||||
// Media info
|
||||
Wt::WImage* _mediaCover;
|
||||
Wt::WText* _mediaTitle;
|
||||
Wt::WText* _mediaArtistRelease;
|
||||
|
||||
// Controls
|
||||
std::shared_ptr<Transcode::Parameters> _currentParameters;
|
||||
Wt::WPushButton* _playBtn;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <Wt/WLabel>
|
||||
|
||||
#include "logger/Logger.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
#include "TableFilter.hpp"
|
||||
#include "KeywordSearchFilter.hpp"
|
||||
@@ -55,9 +56,8 @@ namespace Desktop {
|
||||
// Restored at the beginning of the session
|
||||
static const std::string CurrentQueuePlaylistName = "__current__";
|
||||
|
||||
Audio::Audio(SessionData& sessionData, Wt::WContainerWidget* parent)
|
||||
Audio::Audio(Wt::WContainerWidget* parent)
|
||||
: UserInterface::Audio(parent),
|
||||
_db(sessionData.getDatabaseHandler()),
|
||||
_mediaPlayer(nullptr),
|
||||
_trackView(nullptr),
|
||||
_playQueue(nullptr)
|
||||
@@ -69,15 +69,15 @@ _playQueue(nullptr)
|
||||
// Filters
|
||||
Wt::WHBoxLayout *filterLayout = new Wt::WHBoxLayout();
|
||||
|
||||
TableFilterGenre *filterGenre = new TableFilterGenre(_db);
|
||||
TableFilterGenre *filterGenre = new TableFilterGenre();
|
||||
filterLayout->addWidget(filterGenre);
|
||||
_filterChain.addFilter(filterGenre);
|
||||
|
||||
TableFilterArtist *filterArtist = new TableFilterArtist(_db);
|
||||
TableFilterArtist *filterArtist = new TableFilterArtist();
|
||||
filterLayout->addWidget(filterArtist);
|
||||
_filterChain.addFilter(filterArtist);
|
||||
|
||||
TableFilterRelease *filterRelease = new TableFilterRelease(_db);
|
||||
TableFilterRelease *filterRelease = new TableFilterRelease();
|
||||
filterLayout->addWidget(filterRelease);
|
||||
_filterChain.addFilter(filterRelease);
|
||||
|
||||
@@ -88,7 +88,7 @@ _playQueue(nullptr)
|
||||
|
||||
Wt::WVBoxLayout* trackLayout = new Wt::WVBoxLayout();
|
||||
|
||||
_trackView = new TrackView(_db);
|
||||
_trackView = new TrackView();
|
||||
trackLayout->addWidget(_trackView, 1);
|
||||
|
||||
Wt::WHBoxLayout* trackControls = new Wt::WHBoxLayout();
|
||||
@@ -109,12 +109,11 @@ _playQueue(nullptr)
|
||||
|
||||
_filterChain.addFilter(_trackView);
|
||||
|
||||
_playQueue = new PlayQueue(_db);
|
||||
_playQueue = new PlayQueue();
|
||||
|
||||
// Playlist/PlayQueue
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Database::User::pointer user = _db.getCurrentUser();
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
Wt::WContainerWidget* playQueueContainer = new Wt::WContainerWidget();
|
||||
playQueueContainer->setStyleClass("playqueue");
|
||||
@@ -123,7 +122,7 @@ _playQueue(nullptr)
|
||||
|
||||
// Determine the encoding to be used
|
||||
Wt::WMediaPlayer::Encoding encoding;
|
||||
switch (user->getAudioEncoding())
|
||||
switch (CurrentUser()->getAudioEncoding())
|
||||
{
|
||||
case Database::AudioEncoding::MP3: encoding = Wt::WMediaPlayer::MP3; break;
|
||||
case Database::AudioEncoding::WEBMA: encoding = Wt::WMediaPlayer::WEBMA; break;
|
||||
@@ -188,7 +187,7 @@ _playQueue(nullptr)
|
||||
// Load the last known queue
|
||||
playlistLoadToPlayqueue(CurrentQueuePlaylistName);
|
||||
// Select the last known playing track
|
||||
_playQueue->select(user->getCurPlayingTrackPos());
|
||||
_playQueue->select(CurrentUser()->getCurPlayingTrackPos());
|
||||
}
|
||||
|
||||
mainLayout->setRowStretch(1, 1);
|
||||
@@ -281,14 +280,10 @@ Audio::playlistShowSaveNewDialog()
|
||||
void
|
||||
Audio::playlistShowSaveDialog(std::string playlistName)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
|
||||
Database::User::pointer user = _db.getCurrentUser();
|
||||
if (!user)
|
||||
return;
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
// Actually create the dialog only if the given list already exists
|
||||
if (Database::Playlist::get(_db.getSession(), playlistName, user))
|
||||
if (Database::Playlist::get(DboSession(), playlistName, CurrentUser()))
|
||||
{
|
||||
Wt::WMessageBox *messageBox = new Wt::WMessageBox
|
||||
("Overwrite playlist",
|
||||
@@ -318,20 +313,16 @@ Audio::playlistSaveFromPlayqueue(std::string playlistName)
|
||||
{
|
||||
LMS_LOG(MOD_UI, SEV_INFO) << "Saving playqueue to playlist '" << playlistName << "'";
|
||||
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
Database::User::pointer user = _db.getCurrentUser();
|
||||
if (!user)
|
||||
return;
|
||||
|
||||
Database::Playlist::pointer playlist = Database::Playlist::get(_db.getSession(), playlistName, user);
|
||||
Database::Playlist::pointer playlist = Database::Playlist::get(DboSession(), playlistName, CurrentUser());
|
||||
if (playlist)
|
||||
{
|
||||
LMS_LOG(MOD_UI, SEV_INFO) << "Erasing playlist '" << playlistName << "'";
|
||||
playlist.remove();
|
||||
}
|
||||
|
||||
playlist = Database::Playlist::create(_db.getSession(), playlistName, false, user);
|
||||
playlist = Database::Playlist::create(DboSession(), playlistName, false, CurrentUser());
|
||||
|
||||
std::vector<Database::Track::id_type> trackIds;
|
||||
_playQueue->getTracks(trackIds);
|
||||
@@ -339,10 +330,10 @@ Audio::playlistSaveFromPlayqueue(std::string playlistName)
|
||||
int pos = 0;
|
||||
BOOST_FOREACH(Database::Track::id_type trackId, trackIds)
|
||||
{
|
||||
Database::Track::pointer track = Database::Track::getById(_db.getSession(), trackId);
|
||||
Database::Track::pointer track = Database::Track::getById(DboSession(), trackId);
|
||||
|
||||
if (track)
|
||||
Database::PlaylistEntry::create(_db.getSession(), track, playlist, pos++);
|
||||
Database::PlaylistEntry::create(DboSession(), track, playlist, pos++);
|
||||
}
|
||||
|
||||
LMS_LOG(MOD_UI, SEV_INFO) << "Saving playqueue to playlist '" << playlistName << "' done. Contains " << pos << " entries";
|
||||
@@ -356,17 +347,13 @@ Audio::playlistLoadToPlayqueue(std::string playlistName)
|
||||
std::vector<Database::Track::id_type> entries;
|
||||
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
Database::User::pointer user = _db.getCurrentUser();
|
||||
if (!user)
|
||||
return;
|
||||
|
||||
Database::Playlist::pointer playlist = Database::Playlist::get(_db.getSession(), playlistName, user);
|
||||
Database::Playlist::pointer playlist = Database::Playlist::get(DboSession(), playlistName, CurrentUser());
|
||||
if (!playlist)
|
||||
return;
|
||||
|
||||
entries = Database::PlaylistEntry::getEntries(_db.getSession(), playlist);
|
||||
entries = Database::PlaylistEntry::getEntries(DboSession(), playlist);
|
||||
}
|
||||
|
||||
_playQueue->clear();
|
||||
@@ -390,12 +377,9 @@ Audio::playlistShowDeleteDialog(std::string name)
|
||||
messageBox->buttonClicked().connect(std::bind([=] () {
|
||||
if (messageBox->buttonResult() == Wt::Yes)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Database::User::pointer user = _db.getCurrentUser();
|
||||
if (!user)
|
||||
return;
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
Database::Playlist::pointer playlist = Database::Playlist::get(_db.getSession(), name, user);
|
||||
Database::Playlist::pointer playlist = Database::Playlist::get(DboSession(), name, CurrentUser());
|
||||
if (playlist)
|
||||
playlist.remove();
|
||||
|
||||
@@ -411,11 +395,7 @@ Audio::playlistShowDeleteDialog(std::string name)
|
||||
void
|
||||
Audio::playlistRefreshMenus()
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
|
||||
Database::User::pointer user = _db.getCurrentUser();
|
||||
if (!user)
|
||||
return;
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
// Clear playlists in each menu
|
||||
LMS_LOG(MOD_UI, SEV_DEBUG) << "Save item count: " << _popupMenuSave->count();
|
||||
@@ -430,7 +410,7 @@ Audio::playlistRefreshMenus()
|
||||
}));
|
||||
_popupMenuSave->addSeparator();
|
||||
|
||||
std::vector<Database::Playlist::pointer> playlists = Database::Playlist::get(_db.getSession(), user);
|
||||
std::vector<Database::Playlist::pointer> playlists = Database::Playlist::get(DboSession(), CurrentUser());
|
||||
|
||||
BOOST_FOREACH(Database::Playlist::pointer playlist, playlists)
|
||||
{
|
||||
@@ -528,18 +508,10 @@ Audio::playTrack(boost::filesystem::path p, int pos)
|
||||
|
||||
// Get user preferences
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Database::User::pointer user = _db.getCurrentUser();
|
||||
if (user)
|
||||
{
|
||||
bitrate = user->getAudioBitrate();
|
||||
user.modify()->setCurPlayingTrackPos(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
LMS_LOG(MOD_UI, SEV_ERROR) << "Can't play: user does not exists!";
|
||||
return; // TODO logout?
|
||||
}
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
bitrate = CurrentUser()->getAudioBitrate();
|
||||
CurrentUser().modify()->setCurPlayingTrackPos(pos);
|
||||
}
|
||||
|
||||
Transcode::InputMediaFile inputFile(p);
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
#include <Wt/WPopupMenu>
|
||||
|
||||
#include "common/SessionData.hpp"
|
||||
|
||||
#include "AudioMediaPlayer.hpp"
|
||||
#include "TrackView.hpp"
|
||||
#include "PlayQueue.hpp"
|
||||
@@ -42,7 +40,7 @@ class Audio : public UserInterface::Audio
|
||||
|
||||
public:
|
||||
|
||||
Audio(SessionData& sessionData, Wt::WContainerWidget* parent = 0);
|
||||
Audio(Wt::WContainerWidget* parent = 0);
|
||||
|
||||
void search(std::string searchText);
|
||||
|
||||
@@ -68,8 +66,6 @@ class Audio : public UserInterface::Audio
|
||||
|
||||
void handlePlaylistSelected(Wt::WString name);
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
AudioMediaPlayer* _mediaPlayer;
|
||||
TrackView* _trackView;
|
||||
PlayQueue* _playQueue;
|
||||
|
||||
@@ -27,10 +27,9 @@
|
||||
#include <Wt/WFileResource>
|
||||
#include <Wt/WTheme>
|
||||
|
||||
#include "resource/CoverResource.hpp"
|
||||
|
||||
#include "logger/Logger.hpp"
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
#include "PlayQueue.hpp"
|
||||
|
||||
static const int TrackInfoRole = Wt::UserRole;
|
||||
@@ -271,9 +270,8 @@ class PlayQueueItemDelegate : public Wt::WItemDelegate
|
||||
};
|
||||
|
||||
|
||||
PlayQueue::PlayQueue(Database::Handler& db, Wt::WContainerWidget* parent)
|
||||
PlayQueue::PlayQueue(Wt::WContainerWidget* parent)
|
||||
: Wt::WTableView(parent),
|
||||
_db(db),
|
||||
_curPlayedTrackPos(trackPosInvalid),
|
||||
_trackSelector(new TrackSelector())
|
||||
{
|
||||
@@ -315,7 +313,6 @@ _trackSelector(new TrackSelector())
|
||||
|
||||
}, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
_coverResource = new CoverResource(db, 64);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -375,8 +372,8 @@ PlayQueue::addTracks(const std::vector<Database::Track::id_type>& trackIds)
|
||||
//
|
||||
BOOST_FOREACH(Database::Track::id_type trackId, trackIds)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Database::Track::pointer track (Database::Track::getById(_db.getSession(), trackId));
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Database::Track::pointer track (Database::Track::getById(DboSession(), trackId));
|
||||
|
||||
if (track)
|
||||
{
|
||||
@@ -388,9 +385,9 @@ PlayQueue::addTracks(const std::vector<Database::Track::id_type>& trackIds)
|
||||
|
||||
std::string coverUrl;
|
||||
if (track->hasCover())
|
||||
coverUrl = _coverResource->getTrackUrl(track.id());
|
||||
coverUrl = LmsApplication::instance()->getCoverResource()->getTrackUrl(track.id(), 64);
|
||||
else
|
||||
coverUrl = "images/unknown-cover.jpg";
|
||||
coverUrl = LmsApplication::instance()->getCoverResource()->getUnkownTrackUrl(64);
|
||||
_model->setData(dataRow, COLUMN_ID_COVER, coverUrl, Wt::DecorationRole);
|
||||
|
||||
TrackInfo trackInfo;
|
||||
@@ -463,12 +460,12 @@ PlayQueue::playPrevious(void)
|
||||
bool
|
||||
PlayQueue::readTrack(int rowPos)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
LMS_LOG(MOD_UI, SEV_DEBUG) << "Reading track at pos " << rowPos;
|
||||
Database::Track::id_type trackId = boost::any_cast<Database::Track::id_type>(_model->data(rowPos, COLUMN_ID_TRACK_ID, Wt::UserRole));
|
||||
|
||||
Database::Track::pointer track = Database::Track::getById(_db.getSession(), trackId);
|
||||
Database::Track::pointer track = Database::Track::getById(DboSession(), trackId);
|
||||
if (track)
|
||||
{
|
||||
setPlayingTrackPos(rowPos);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <Wt/WTableView>
|
||||
#include <Wt/WStandardItemModel>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
#include "resource/CoverResource.hpp"
|
||||
|
||||
@@ -36,7 +36,7 @@ class TrackSelector;
|
||||
class PlayQueue : public Wt::WTableView
|
||||
{
|
||||
public:
|
||||
PlayQueue(Database::Handler& db, Wt::WContainerWidget* parent = 0);
|
||||
PlayQueue(Wt::WContainerWidget* parent = 0);
|
||||
|
||||
void addTracks(const std::vector<Database::Track::id_type>& trackIds);
|
||||
void getTracks(std::vector<Database::Track::id_type>& trackIds) const;
|
||||
@@ -79,14 +79,10 @@ class PlayQueue : public Wt::WTableView
|
||||
Wt::Signal< boost::filesystem::path, int > _sigTrackPlay;
|
||||
Wt::Signal< void > _sigTracksUpdated;
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
Wt::WStandardItemModel* _model;
|
||||
|
||||
PlayQueueItemDelegate* _itemDelegate;
|
||||
|
||||
CoverResource* _coverResource;
|
||||
|
||||
int _curPlayedTrackPos;
|
||||
std::unique_ptr<TrackSelector> _trackSelector;
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
#include <Wt/WItemDelegate>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
#include "logger/Logger.hpp"
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
#include "TableFilter.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
@@ -32,15 +32,14 @@ namespace Desktop {
|
||||
|
||||
using namespace Database;
|
||||
|
||||
TableFilterGenre::TableFilterGenre(Database::Handler& db, Wt::WContainerWidget* parent)
|
||||
: Wt::WTableView( parent ), Filter(),
|
||||
_db(db)
|
||||
TableFilterGenre::TableFilterGenre(Wt::WContainerWidget* parent)
|
||||
: Wt::WTableView( parent ), Filter()
|
||||
{
|
||||
const std::vector<Wt::WString> columnNames = {"Genre", "Tracks"};
|
||||
|
||||
SearchFilter filter;
|
||||
|
||||
Genre::updateGenreQueryModel(_db.getSession(), _queryModel, filter, columnNames);
|
||||
Genre::updateGenreQueryModel(DboSession(), _queryModel, filter, columnNames);
|
||||
|
||||
this->setSelectionMode(Wt::ExtendedSelection);
|
||||
this->setSortingEnabled(true);
|
||||
@@ -83,7 +82,7 @@ TableFilterGenre::layoutSizeChanged (int width, int height)
|
||||
void
|
||||
TableFilterGenre::refresh(SearchFilter& filter)
|
||||
{
|
||||
Genre::updateGenreQueryModel(_db.getSession(), _queryModel, filter);
|
||||
Genre::updateGenreQueryModel(DboSession(), _queryModel, filter);
|
||||
}
|
||||
|
||||
// Get constraint created by this filter
|
||||
@@ -103,15 +102,14 @@ TableFilterGenre::getConstraint(SearchFilter& filter)
|
||||
}
|
||||
}
|
||||
|
||||
TableFilterArtist::TableFilterArtist(Database::Handler& db, Wt::WContainerWidget* parent)
|
||||
: Wt::WTableView( parent ), Filter(),
|
||||
_db(db)
|
||||
TableFilterArtist::TableFilterArtist(Wt::WContainerWidget* parent)
|
||||
: Wt::WTableView( parent ), Filter()
|
||||
{
|
||||
const std::vector<Wt::WString> columnNames = {"Artist", "Releases", "Tracks"};
|
||||
|
||||
SearchFilter filter;
|
||||
|
||||
Track::updateArtistQueryModel(_db.getSession(), _queryModel, filter, columnNames);
|
||||
Track::updateArtistQueryModel(DboSession(), _queryModel, filter, columnNames);
|
||||
|
||||
this->setSelectionMode(Wt::ExtendedSelection);
|
||||
this->setSortingEnabled(true);
|
||||
@@ -155,7 +153,7 @@ TableFilterArtist::layoutSizeChanged (int width, int height)
|
||||
void
|
||||
TableFilterArtist::refresh(SearchFilter& filter)
|
||||
{
|
||||
Track::updateArtistQueryModel(_db.getSession(), _queryModel, filter);
|
||||
Track::updateArtistQueryModel(DboSession(), _queryModel, filter);
|
||||
}
|
||||
|
||||
// Get constraint created by this filter
|
||||
@@ -175,15 +173,14 @@ TableFilterArtist::getConstraint(SearchFilter& filter)
|
||||
}
|
||||
}
|
||||
|
||||
TableFilterRelease::TableFilterRelease(Database::Handler& db, Wt::WContainerWidget* parent)
|
||||
: Wt::WTableView( parent ), Filter(),
|
||||
_db(db)
|
||||
TableFilterRelease::TableFilterRelease(Wt::WContainerWidget* parent)
|
||||
: Wt::WTableView( parent ), Filter()
|
||||
{
|
||||
const std::vector<Wt::WString> columnNames = {"Release", "Date", "Tracks"};
|
||||
|
||||
SearchFilter filter;
|
||||
|
||||
Track::updateReleaseQueryModel(_db.getSession(), _queryModel, filter, columnNames);
|
||||
Track::updateReleaseQueryModel(DboSession(), _queryModel, filter, columnNames);
|
||||
|
||||
this->setSelectionMode(Wt::ExtendedSelection);
|
||||
this->setSortingEnabled(true);
|
||||
@@ -234,7 +231,7 @@ TableFilterRelease::layoutSizeChanged (int width, int height)
|
||||
void
|
||||
TableFilterRelease::refresh(SearchFilter& filter)
|
||||
{
|
||||
Track::updateReleaseQueryModel(_db.getSession(), _queryModel, filter);
|
||||
Track::updateReleaseQueryModel(DboSession(), _queryModel, filter);
|
||||
}
|
||||
|
||||
// Get constraint created by this filter
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <Wt/WTableView>
|
||||
|
||||
#include "Filter.hpp"
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Desktop {
|
||||
@@ -33,7 +33,7 @@ namespace Desktop {
|
||||
class TableFilterGenre : public Wt::WTableView, public Filter
|
||||
{
|
||||
public:
|
||||
TableFilterGenre(Database::Handler& db, Wt::WContainerWidget* parent = 0);
|
||||
TableFilterGenre(Wt::WContainerWidget* parent = 0);
|
||||
|
||||
// Set constraints on this filter
|
||||
void refresh(Database::SearchFilter& filter);
|
||||
@@ -51,8 +51,6 @@ class TableFilterGenre : public Wt::WTableView, public Filter
|
||||
|
||||
SigDoubleClicked _sigDoubleClicked;
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
// Name, track count
|
||||
Wt::Dbo::QueryModel<Database::Genre::GenreResult> _queryModel;
|
||||
};
|
||||
@@ -60,7 +58,7 @@ class TableFilterGenre : public Wt::WTableView, public Filter
|
||||
class TableFilterArtist : public Wt::WTableView, public Filter
|
||||
{
|
||||
public:
|
||||
TableFilterArtist(Database::Handler& db, Wt::WContainerWidget* parent = 0);
|
||||
TableFilterArtist(Wt::WContainerWidget* parent = 0);
|
||||
|
||||
// Set constraints on this filter
|
||||
void refresh(Database::SearchFilter& filter);
|
||||
@@ -78,8 +76,6 @@ class TableFilterArtist : public Wt::WTableView, public Filter
|
||||
|
||||
SigDoubleClicked _sigDoubleClicked;
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
// Name, track count
|
||||
Wt::Dbo::QueryModel<Database::Track::ArtistResult> _queryModel;
|
||||
};
|
||||
@@ -87,7 +83,7 @@ class TableFilterArtist : public Wt::WTableView, public Filter
|
||||
class TableFilterRelease : public Wt::WTableView, public Filter
|
||||
{
|
||||
public:
|
||||
TableFilterRelease(Database::Handler& db, Wt::WContainerWidget* parent = 0);
|
||||
TableFilterRelease(Wt::WContainerWidget* parent = 0);
|
||||
|
||||
// Set constraints on this filter
|
||||
void refresh(Database::SearchFilter& filter);
|
||||
@@ -105,8 +101,6 @@ class TableFilterRelease : public Wt::WTableView, public Filter
|
||||
|
||||
SigDoubleClicked _sigDoubleClicked;
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
// Name, track count
|
||||
Wt::Dbo::QueryModel<Database::Track::ReleaseResult> _queryModel;
|
||||
};
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
#include "logger/Logger.hpp"
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
#include "TrackView.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Desktop {
|
||||
|
||||
TrackView::TrackView( Database::Handler& db, Wt::WContainerWidget* parent)
|
||||
: Wt::WTableView( parent ),
|
||||
_db(db)
|
||||
TrackView::TrackView(Wt::WContainerWidget* parent)
|
||||
: Wt::WTableView( parent )
|
||||
{
|
||||
|
||||
static const std::vector<Wt::WString> columnNames =
|
||||
@@ -50,7 +50,7 @@ _db(db)
|
||||
|
||||
Database::SearchFilter filter;
|
||||
|
||||
Database::Track::updateTracksQueryModel(_db.getSession(), _queryModel, filter, columnNames);
|
||||
Database::Track::updateTracksQueryModel(DboSession(), _queryModel, filter, columnNames);
|
||||
|
||||
_queryModel.setBatchSize(300);
|
||||
|
||||
@@ -111,7 +111,7 @@ _db(db)
|
||||
void
|
||||
TrackView::refresh(Database::SearchFilter& filter)
|
||||
{
|
||||
Database::Track::updateTracksQueryModel(_db.getSession(), _queryModel, filter);
|
||||
Database::Track::updateTracksQueryModel(DboSession(), _queryModel, filter);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -34,7 +34,7 @@ class TrackView : public Wt::WTableView, public Filter
|
||||
{
|
||||
public:
|
||||
|
||||
TrackView( Database::Handler& db, Wt::WContainerWidget* parent = 0);
|
||||
TrackView(Wt::WContainerWidget* parent = 0);
|
||||
|
||||
// Filter interface
|
||||
// Set constraints created by parent filters
|
||||
@@ -62,8 +62,6 @@ class TrackView : public Wt::WTableView, public Filter
|
||||
|
||||
SigTrackDoubleClicked _sigTrackDoubleClicked;
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
typedef Database::Track::pointer ResultType;
|
||||
Wt::Dbo::QueryModel< ResultType > _queryModel;
|
||||
Wt::WTableView* _tableView;
|
||||
|
||||
@@ -21,14 +21,15 @@
|
||||
#include <Wt/WTemplate>
|
||||
#include <Wt/WPushButton>
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
#include "ArtistSearch.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
ArtistSearch::ArtistSearch(Database::Handler& db, Wt::WContainerWidget *parent)
|
||||
ArtistSearch::ArtistSearch(Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_db(db),
|
||||
_resCount(0)
|
||||
{
|
||||
Wt::WTemplate *title = new Wt::WTemplate(this);
|
||||
@@ -60,10 +61,10 @@ ArtistSearch::addResults(Database::SearchFilter filter, std::size_t nb)
|
||||
std::vector<std::string> artists;
|
||||
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
// Request one more to see if more results are to be expected
|
||||
artists = Database::Track::getArtists(_db.getSession(), filter, _resCount, nb + 1);
|
||||
artists = Database::Track::getArtists(DboSession(), filter, _resCount, nb + 1);
|
||||
}
|
||||
|
||||
bool expectMoreResults;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <Wt/WContainerWidget>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
@@ -32,7 +32,7 @@ class ArtistSearch : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
|
||||
ArtistSearch(Database::Handler& db, Wt::WContainerWidget *parent = 0);
|
||||
ArtistSearch(Wt::WContainerWidget *parent = 0);
|
||||
|
||||
void search(Database::SearchFilter filter, std::size_t nb);
|
||||
|
||||
@@ -48,7 +48,6 @@ class ArtistSearch : public Wt::WContainerWidget
|
||||
void clear(void);
|
||||
void addResults(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
Database::Handler& _db;
|
||||
std::size_t _resCount;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WTable>
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
#include "MobileAudio.hpp"
|
||||
|
||||
#include "ArtistSearch.hpp"
|
||||
@@ -40,9 +42,8 @@
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
Audio::Audio(Database::Handler& db, Wt::WContainerWidget *parent)
|
||||
: UserInterface::Audio(parent),
|
||||
_db(db)
|
||||
Audio::Audio(Wt::WContainerWidget *parent)
|
||||
: UserInterface::Audio(parent)
|
||||
{
|
||||
// Root div has to be a "container"
|
||||
this->setStyleClass("container");
|
||||
@@ -56,27 +57,29 @@ _db(db)
|
||||
search->bindWidget("search", edit);
|
||||
search->setMargin(10);
|
||||
|
||||
ArtistSearch* artistSearch = new ArtistSearch(_db, this);
|
||||
ReleaseSearch* releaseSearch = new ReleaseSearch(_db, this);
|
||||
TrackSearch* trackSearch = new TrackSearch(_db, this);
|
||||
ArtistSearch* artistSearch = new ArtistSearch(this);
|
||||
ReleaseSearch* releaseSearch = new ReleaseSearch(this);
|
||||
TrackSearch* trackSearch = new TrackSearch(this);
|
||||
|
||||
Wt::WTemplate* playerTemplate = new Wt::WTemplate(this);
|
||||
playerTemplate->setTemplateText(Wt::WString::tr("mobile-audio-player"));
|
||||
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Database::User::pointer user = _db.getCurrentUser();
|
||||
|
||||
// Determine the encoding to be used
|
||||
Wt::WMediaPlayer::Encoding encoding;
|
||||
switch (user->getAudioEncoding())
|
||||
|
||||
{
|
||||
case Database::AudioEncoding::MP3: encoding = Wt::WMediaPlayer::MP3; break;
|
||||
case Database::AudioEncoding::WEBMA: encoding = Wt::WMediaPlayer::WEBMA; break;
|
||||
case Database::AudioEncoding::OGA: encoding = Wt::WMediaPlayer::OGA; break;
|
||||
case Database::AudioEncoding::FLA: encoding = Wt::WMediaPlayer::FLA; break;
|
||||
case Database::AudioEncoding::AUTO:
|
||||
default:
|
||||
encoding = AudioMediaPlayer::getBestEncoding();
|
||||
Wt::Dbo::Transaction transaction (DboSession());
|
||||
|
||||
switch (CurrentUser()->getAudioEncoding())
|
||||
{
|
||||
case Database::AudioEncoding::MP3: encoding = Wt::WMediaPlayer::MP3; break;
|
||||
case Database::AudioEncoding::WEBMA: encoding = Wt::WMediaPlayer::WEBMA; break;
|
||||
case Database::AudioEncoding::OGA: encoding = Wt::WMediaPlayer::OGA; break;
|
||||
case Database::AudioEncoding::FLA: encoding = Wt::WMediaPlayer::FLA; break;
|
||||
case Database::AudioEncoding::AUTO:
|
||||
default:
|
||||
encoding = AudioMediaPlayer::getBestEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
AudioMediaPlayer* mediaPlayer = new AudioMediaPlayer(encoding);
|
||||
@@ -185,9 +188,10 @@ _db(db)
|
||||
trackSearch->trackPlay().connect(std::bind([=] (Database::Track::id_type id)
|
||||
{
|
||||
LMS_LOG(MOD_UI, SEV_DEBUG) << "Playing track id " << id;
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
// TODO reduce transaction scope here
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
Database::Track::pointer track = Database::Track::getById(_db.getSession(), id);
|
||||
Database::Track::pointer track = Database::Track::getById(DboSession(), id);
|
||||
|
||||
if (track)
|
||||
{
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
|
||||
#include "audio/Audio.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
@@ -32,13 +30,12 @@ namespace Mobile {
|
||||
class Audio : public UserInterface::Audio
|
||||
{
|
||||
public:
|
||||
Audio(Database::Handler& db, Wt::WContainerWidget *parent = 0);
|
||||
Audio(Wt::WContainerWidget *parent = 0);
|
||||
|
||||
void search(std::string text) {}
|
||||
|
||||
private:
|
||||
|
||||
Database::Handler& _db;
|
||||
};
|
||||
|
||||
} // namespace Mobile
|
||||
|
||||
@@ -23,23 +23,21 @@
|
||||
#include <Wt/WTemplate>
|
||||
|
||||
#include "logger/Logger.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
#include "ReleaseSearch.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
ReleaseSearch::ReleaseSearch(Database::Handler& db, Wt::WContainerWidget *parent)
|
||||
ReleaseSearch::ReleaseSearch(Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_db(db),
|
||||
_resCount(0)
|
||||
{
|
||||
Wt::WTemplate* title = new Wt::WTemplate(this);
|
||||
title->setTemplateText(Wt::WString::tr("mobile-search-title"));
|
||||
|
||||
title->bindWidget("text", new Wt::WText("Releases", Wt::PlainText));
|
||||
|
||||
_coverResource = new CoverResource(db, 56);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -65,10 +63,10 @@ ReleaseSearch::addResults(Database::SearchFilter filter, size_t nb)
|
||||
std::vector<std::string> releases;
|
||||
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
// Request one more to see if more results are to be expected
|
||||
releases = Database::Track::getReleases(_db.getSession(), filter, _resCount, nb + 1);
|
||||
releases = Database::Track::getReleases(DboSession(), filter, _resCount, nb + 1);
|
||||
}
|
||||
|
||||
bool expectMoreResults;
|
||||
@@ -87,7 +85,7 @@ ReleaseSearch::addResults(Database::SearchFilter filter, size_t nb)
|
||||
|
||||
Wt::WImage *cover = new Wt::WImage();
|
||||
cover->setStyleClass("center-block");
|
||||
cover->setImageLink( Wt::WLink( _coverResource->getReleaseUrl(release)));
|
||||
cover->setImageLink( Wt::WLink( LmsApplication::instance()->getCoverResource()->getReleaseUrl(release, 56)));
|
||||
releaseWidget->bindWidget("cover", cover);
|
||||
|
||||
releaseWidget->bindWidget("name", new Wt::WText(Wt::WString::fromUTF8(release), Wt::PlainText));
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WSignal>
|
||||
|
||||
#include "resource/CoverResource.hpp"
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
@@ -36,7 +32,7 @@ class ReleaseSearch : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
|
||||
ReleaseSearch(Database::Handler& db, Wt::WContainerWidget *parent = 0);
|
||||
ReleaseSearch(Wt::WContainerWidget *parent = 0);
|
||||
|
||||
void search(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
@@ -52,10 +48,6 @@ class ReleaseSearch : public Wt::WContainerWidget
|
||||
void clear(void);
|
||||
void addResults(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
CoverResource* _coverResource;
|
||||
|
||||
std::size_t _resCount;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
#include <Wt/WTemplate>
|
||||
|
||||
#include "logger/Logger.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
#include "TrackSearch.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
TrackSearch::TrackSearch(Database::Handler& db, Wt::WContainerWidget *parent)
|
||||
TrackSearch::TrackSearch(Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_db(db),
|
||||
_resCount(0)
|
||||
{
|
||||
Wt::WTemplate* title = new Wt::WTemplate(this);
|
||||
@@ -39,7 +39,6 @@ _resCount(0)
|
||||
|
||||
title->bindWidget("text", new Wt::WText("Tracks", Wt::PlainText));
|
||||
|
||||
_coverResource = new CoverResource(db, 56);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -61,9 +60,9 @@ TrackSearch::search(Database::SearchFilter filter, size_t max)
|
||||
void
|
||||
TrackSearch::addResults(Database::SearchFilter filter, size_t nb)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
std::vector< Database::Track::pointer > tracks = Database::Track::getTracks(_db.getSession(), filter, _resCount, nb + 1);
|
||||
std::vector< Database::Track::pointer > tracks = Database::Track::getTracks(DboSession(), filter, _resCount, nb + 1);
|
||||
|
||||
bool expectMoreResults;
|
||||
if (tracks.size() == nb + 1)
|
||||
@@ -81,7 +80,7 @@ TrackSearch::addResults(Database::SearchFilter filter, size_t nb)
|
||||
|
||||
Wt::WImage *cover = new Wt::WImage();
|
||||
cover->setStyleClass("center-block");
|
||||
cover->setImageLink( Wt::WLink (_coverResource->getTrackUrl(track.id())) );
|
||||
cover->setImageLink( Wt::WLink (LmsApplication::instance()->getCoverResource()->getTrackUrl(track.id(), 56)) );
|
||||
trackWidget->bindWidget("cover", cover);
|
||||
|
||||
// Track Name (bold)
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
#include "resource/CoverResource.hpp"
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
@@ -36,7 +34,7 @@ class TrackSearch : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
|
||||
TrackSearch(Database::Handler& db, Wt::WContainerWidget *parent = 0);
|
||||
TrackSearch(Wt::WContainerWidget *parent = 0);
|
||||
|
||||
void search(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
@@ -52,10 +50,6 @@ class TrackSearch : public Wt::WContainerWidget
|
||||
void clear(void);
|
||||
void addResults(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
CoverResource* _coverResource;
|
||||
|
||||
std::size_t _resCount;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user