[UI/MOBILE] WIP on internal path support

This commit is contained in:
emeric
2016-03-06 00:44:24 +01:00
parent a07704c218
commit f8c808433f
34 changed files with 696 additions and 454 deletions
+2 -2
View File
@@ -77,7 +77,7 @@ AudioPlayer::loadTrack(Database::Track::id_type trackId)
bindString("track", Wt::WString::fromUTF8(track->getName()));
bindString("artist", Wt::WString::fromUTF8(track->getArtist()->getName()));
_cover->setImageLink(SessionCoverResource()->getTrackUrl(trackId, 64));
_cover->setImageLink(SessionImageResource()->getTrackUrl(trackId, 64));
std::string durationFormat = track->getDuration().total_seconds() < 3600 ? "%M:%S" : "%H:%M:%S";
@@ -140,7 +140,7 @@ AudioPlayer::AudioPlayer(Wt::WContainerWidget *parent)
_cover = new Wt::WImage();
bindWidget("cover", _cover);
_cover->setImageLink(SessionCoverResource()->getUnknownTrackUrl(64));
_cover->setImageLink(SessionImageResource()->getUnknownTrackUrl(64));
InputRange *seekbar = new InputRange();
seekbar->addStyleClass("mediaplayer-seekbar");
+1 -1
View File
@@ -387,7 +387,7 @@ PlayQueue::addTracks(const std::vector<Database::Track::id_type>& trackIds)
_model->setData(dataRow, COLUMN_ID_TRACK_ID, track.id(), Wt::UserRole);
std::string coverUrl;
coverUrl = LmsApplication::instance()->getCoverResource()->getTrackUrl(track.id(), 64);
coverUrl = SessionImageResource()->getTrackUrl(track.id(), 64);
_model->setData(dataRow, COLUMN_ID_COVER, coverUrl, Wt::DecorationRole);
_model->setData(dataRow, COLUMN_ID_COVER, std::string("playqueue-cover"), Wt::StyleClassRole);
-2
View File
@@ -25,8 +25,6 @@
#include "database/Types.hpp"
#include "resource/CoverResource.hpp"
namespace UserInterface {
namespace Desktop {
+11 -33
View File
@@ -29,23 +29,19 @@
namespace UserInterface {
namespace Mobile {
using namespace Database;
ArtistSearch::ArtistSearch(Wt::WString title, Wt::WContainerWidget *parent)
: Wt::WContainerWidget(parent),
_count(0)
: Wt::WContainerWidget(parent)
{
Wt::WTemplate* artistSearch = new Wt::WTemplate(this);
artistSearch->setTemplateText(Wt::WString::tr("wa-artist-search"));
Wt::WTemplate* t = new Wt::WTemplate(this);
t->setTemplateText(Wt::WString::tr("wa-artist-search"));
Wt::WTemplate *titleTemplate = new Wt::WTemplate(this);
titleTemplate->setTemplateText(Wt::WString::tr("mobile-search-title"));
titleTemplate->bindString("text", title);
artistSearch->bindWidget("title", titleTemplate);
t->bindWidget("title", titleTemplate);
_contents = new Wt::WContainerWidget();
artistSearch->bindWidget("release-container", _contents );
t->bindWidget("contents", _contents );
_showMore = new Wt::WTemplate();
_showMore->setTemplateText(Wt::WString::tr("mobile-search-more"));
@@ -54,15 +50,13 @@ _count(0)
_showMore->clicked().connect(std::bind([=] {
_sigShowMore.emit();
}));
artistSearch->bindWidget("show-more", _showMore);
t->bindWidget("show-more", _showMore);
}
void
ArtistSearch::clear()
{
_contents->clear();
_count = 0;
_showMore->hide();
}
@@ -75,38 +69,24 @@ ArtistSearch::search(Database::SearchFilter filter, size_t nb)
addResults(nb);
}
static
std::vector<Artist::pointer>
getArtists(SearchFilter filter, size_t offset, size_t nb, bool &moreResults)
{
std::vector<Artist::pointer> artists = Artist::getByFilter(DboSession(), filter, offset, nb + 1);
if (artists.size() == nb + 1)
{
moreResults = true;
artists.pop_back();
}
else
moreResults = false;
return artists;
}
void
ArtistSearch::addResults(std::size_t nb)
{
using namespace Database;
Wt::Dbo::Transaction transaction(DboSession());
bool moreResults;
std::vector<Artist::pointer> artists = getArtists(_filter, _count, nb, moreResults);
std::vector<Artist::pointer> artists = Artist::getByFilter(DboSession(), _filter, _contents->count(), nb, moreResults);
for (Artist::pointer artist : artists)
{
Wt::WTemplate* res = new Wt::WTemplate(_contents);
res->setTemplateText(Wt::WString::tr("wa-artist-res"));
res->setTemplateText(Wt::WString::tr("wa-artist-search-res"));
Wt::WAnchor *coverAnchor = new Wt::WAnchor(Wt::WLink(Wt:: WLink::InternalPath, "/audio/artist/" + std::to_string(artist.id())));
Wt::WImage *artistImg = new Wt::WImage(coverAnchor);
artistImg->setImageLink( SessionImageResource()->getArtistUrl(artist.id(), 512));
artistImg->setStyleClass("center-block"); // TODO move in css?
artistImg->setStyleClass("release_res_shadow release_img-responsive"); // TODO move in css?
@@ -114,8 +94,6 @@ ArtistSearch::addResults(std::size_t nb)
res->bindString("name", Wt::WString::fromUTF8(artist->getName(), Wt::PlainText));
}
_count += artists.size();
if (moreResults)
_showMore->show();
else
+13 -2
View File
@@ -17,7 +17,7 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wt/WApplication>
#include "LmsApplication.hpp"
#include "utils/Utils.hpp"
@@ -45,11 +45,22 @@ ArtistView::ArtistView(Wt::WContainerWidget *parent)
Artist::id_type id;
if (readAs(strId, id))
releases->search(SearchFilter::ById(SearchFilter::Field::Artist, id), 20);
{
Wt::Dbo::Transaction transaction(DboSession());
auto artist = Artist::getById(DboSession(), id);
releases->search(SearchFilter::ById(SearchFilter::Field::Artist, id), 20, artist ? Wt::WString::fromUTF8(artist->getName()) : "Unknown artist");
}
}, std::placeholders::_1));
}
Wt::WLink
ArtistView::getLink(Database::Artist::id_type id)
{
return Wt::WLink(Wt::WLink::InternalPath, "/audio/artist/" + std::to_string(id));
}
} //namespace Mobile
} //namespace UserInterface
+6
View File
@@ -20,6 +20,9 @@
#pragma once
#include <Wt/WContainerWidget>
#include <Wt/WLink>
#include "database/Types.hpp"
namespace UserInterface {
namespace Mobile {
@@ -27,6 +30,9 @@ namespace Mobile {
class ArtistView : public Wt::WContainerWidget
{
public:
static Wt::WLink getLink(Database::Artist::id_type id);
ArtistView(Wt::WContainerWidget *parent = 0);
};
+6 -5
View File
@@ -29,10 +29,11 @@
#include "audio/AudioPlayer.hpp"
#include "LmsApplication.hpp"
#include "ArtistSearchView.hpp"
#include "PreviewSearchView.hpp"
#include "ReleaseSearch.hpp"
#include "TrackSearch.hpp"
#include "ArtistSearchView.hpp"
#include "ReleaseSearchView.hpp"
#include "TrackSearchView.hpp"
#include "ArtistView.hpp"
#include "ReleaseView.hpp"
@@ -84,8 +85,8 @@ Audio::Audio(Wt::WContainerWidget *parent)
// Same order as WidgetIdxXXX
stack->addWidget(new PreviewSearchView());
stack->addWidget(new ArtistSearchView());
stack->addWidget(new ReleaseSearch());
stack->addWidget(new TrackSearch());
stack->addWidget(new ReleaseSearchView());
stack->addWidget(new TrackSearchView());
stack->addWidget(new ArtistView());
stack->addWidget(new ReleaseView());
+9 -1
View File
@@ -60,6 +60,14 @@ PreviewSearchView::PreviewSearchView(Wt::WContainerWidget* parent)
wApp->setInternalPath(path, true);
}));
trackSearch->showMore().connect(std::bind([=]
{
std::string path = wApp->internalPath();
path.replace(0, pathPrefix.length(), "/audio/search/track");
wApp->setInternalPath(path, true);
}));
wApp->internalPathChanged().connect(std::bind([=] (std::string path)
{
if (!wApp->internalPathMatches(pathPrefix))
@@ -68,7 +76,7 @@ PreviewSearchView::PreviewSearchView(Wt::WContainerWidget* parent)
std::vector<std::string> keywords = searchPathToSearchKeywords(path.substr(pathPrefix.length()));
artistSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Artist, keywords), SEARCH_NB_ITEMS);
releaseSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Release, keywords), SEARCH_NB_ITEMS);
releaseSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Release, keywords), SEARCH_NB_ITEMS, "Releases");
trackSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Track, keywords), SEARCH_NB_ITEMS);
}, std::placeholders::_1));
+47 -63
View File
@@ -26,6 +26,8 @@
#include "LmsApplication.hpp"
#include "ReleaseSearch.hpp"
#include "ReleaseView.hpp"
#include "ArtistView.hpp"
namespace UserInterface {
namespace Mobile {
@@ -33,112 +35,94 @@ namespace Mobile {
using namespace Database;
ReleaseSearch::ReleaseSearch(Wt::WContainerWidget *parent)
: Wt::WContainerWidget(parent),
_resCount(0)
: Wt::WContainerWidget(parent)
{
Wt::WTemplate* title = new Wt::WTemplate(this);
title->setTemplateText(Wt::WString::tr("mobile-search-title"));
Wt::WTemplate* t = new Wt::WTemplate(this);
t->setTemplateText(Wt::WString::tr("wa-release-search"));
title->bindWidget("text", new Wt::WText("Releases", Wt::PlainText));
Wt::WTemplate *titleTemplate = new Wt::WTemplate(this);
titleTemplate->setTemplateText(Wt::WString::tr("mobile-search-title"));
_title = new Wt::WText();
titleTemplate->bindWidget("text", _title);
t->bindWidget("title", titleTemplate);
Wt::WTemplate* releaseWrapper = new Wt::WTemplate(this);
releaseWrapper->setTemplateText(Wt::WString::tr("wa-release-wrapper"));
_contents = new Wt::WContainerWidget();
releaseWrapper->bindWidget("contents", _contents );
t->bindWidget("contents", _contents );
_showMore = new Wt::WTemplate();
_showMore->setTemplateText(Wt::WString::tr("mobile-search-more"));
_showMore->bindString("text", "Tap to show more results...");
_showMore->hide();
_showMore->clicked().connect(std::bind([=] {
_sigShowMore.emit();
}));
t->bindWidget("show-more", _showMore);
}
void
ReleaseSearch::clear()
{
while (count() > 1)
removeWidget(this->widget(1));
_resCount = 0;
_contents->clear();
_showMore->hide();
}
void
ReleaseSearch::search(Database::SearchFilter filter, size_t max)
ReleaseSearch::search(Database::SearchFilter filter, size_t max, Wt::WString title)
{
_filter = filter;
_title->setText(title);
clear();
addResults(filter, max);
}
static Wt::WString
getArtistFromRelease(Release::pointer release)
{
auto artists = Artist::getByFilter(DboSession(),
SearchFilter::ById(SearchFilter::Field::Release, release.id()), -1, 2);
if (artists.size() > 1)
return Wt::WString::fromUTF8("Various artists", Wt::PlainText);
else
return Wt::WString::fromUTF8(artists.front()->getName(), Wt::PlainText);
addResults(max);
}
void
ReleaseSearch::addResults(Database::SearchFilter filter, size_t nb)
ReleaseSearch::addResults(size_t nb)
{
using namespace Database;
Wt::Dbo::Transaction transaction(DboSession());
std::vector<Release::pointer> releases = Release::getByFilter(DboSession(), filter, _resCount, nb + 1);
bool expectMoreResults;
if (releases.size() == nb + 1)
{
expectMoreResults = true;
releases.pop_back();
}
else
expectMoreResults = false;
bool moreResults;
std::vector<Release::pointer> releases = Release::getByFilter(DboSession(), _filter, _contents->count(), nb, moreResults);
for (Release::pointer release : releases)
{
Wt::WTemplate* releaseWidget = new Wt::WTemplate(this);
releaseWidget->setTemplateText(Wt::WString::tr("wa-release-res"));
Wt::WTemplate* res = new Wt::WTemplate(_contents);
res->setTemplateText(Wt::WString::tr("wa-release-search-res"));
Wt::WAnchor *coverAnchor = new Wt::WAnchor(Wt::WLink(Wt:: WLink::InternalPath, "/audio/release/" + std::to_string(release.id())));
Wt::WAnchor *coverAnchor = new Wt::WAnchor(ReleaseView::getLink(release.id()));
Wt::WImage *cover = new Wt::WImage(coverAnchor);
cover->setStyleClass("center-block");
cover->setImageLink( Wt::WLink( LmsApplication::instance()->getCoverResource()->getReleaseUrl(release.id(), 512)));
cover->setImageLink( SessionImageResource()->getReleaseUrl(release.id(), 512));
cover->setStyleClass("release_res_shadow release_img-responsive"); // TODO move?
releaseWidget->bindWidget("cover", coverAnchor);
releaseWidget->bindWidget("name", new Wt::WText(Wt::WString::fromUTF8(release->getName()), Wt::PlainText));
releaseWidget->bindString("release_name", Wt::WString::fromUTF8(release->getName()), Wt::PlainText);
res->bindWidget("cover", coverAnchor);
res->bindWidget("name", new Wt::WText(Wt::WString::fromUTF8(release->getName()), Wt::PlainText));
res->bindString("release_name", Wt::WString::fromUTF8(release->getName()), Wt::PlainText);
auto artists = Artist::getByFilter(DboSession(),
SearchFilter::ById(SearchFilter::Field::Release, release.id()), -1, 2);
if (artists.size() == 1)
{
Wt::WAnchor *artistAnchor = new Wt::WAnchor(Wt::WLink(Wt:: WLink::InternalPath, "/audio/artist/" + std::to_string(artists.front().id())));
Wt::WAnchor *artistAnchor = new Wt::WAnchor(ArtistView::getLink(artists.front().id()));
Wt::WText *artist = new Wt::WText(artistAnchor);
artist->setText(Wt::WString::fromUTF8(artists.front()->getName(), Wt::PlainText));
releaseWidget->bindWidget("artist", artistAnchor);
res->bindWidget("artist", artistAnchor);
}
else
releaseWidget->bindWidget("artist", new Wt::WText(Wt::WString::fromUTF8("Various Artists", Wt::PlainText)));
res->bindWidget("artist", new Wt::WText(Wt::WString::fromUTF8("Various Artists", Wt::PlainText)));
}
_resCount += releases.size();;
if (moreResults)
_showMore->show();
else
_showMore->hide();
if (expectMoreResults)
{
Wt::WTemplate* moreRes = new Wt::WTemplate(this);
moreRes->setTemplateText(Wt::WString::tr("mobile-search-more"));
moreRes->bindWidget("text", new Wt::WText("Tap to show more results..."));
moreRes->clicked().connect(std::bind([=] {
_sigMoreReleasesSelected();
removeWidget(moreRes);
addResults(filter, 20);
}));
}
}
} // namespace Mobile
+10 -8
View File
@@ -21,6 +21,7 @@
#include <Wt/WContainerWidget>
#include <Wt/WSignal>
#include <Wt/WText>
#include "database/SearchFilter.hpp"
#include "database/Types.hpp"
@@ -34,22 +35,23 @@ class ReleaseSearch : public Wt::WContainerWidget
ReleaseSearch(Wt::WContainerWidget *parent = 0);
void search(Database::SearchFilter filter, size_t nb);
void search(Database::SearchFilter filter, std::size_t nb, Wt::WString title);
void addResults(std::size_t nb);
// Slots
Wt::Signal<Database::Release::id_type>& releaseSelected() { return _sigReleaseSelected;}
Wt::Signal<void>& moreReleasesSelected() { return _sigMoreReleasesSelected;}
Wt::Signal<void>& showMore() { return _sigShowMore;}
private:
Wt::Signal<Database::Release::id_type> _sigReleaseSelected;
Wt::Signal<void> _sigMoreReleasesSelected;
Wt::Signal<void> _sigShowMore;
void clear(void);
void addResults(Database::SearchFilter filter, size_t nb);
Wt::WContainerWidget* _contents;
std::size_t _resCount;
Wt::WTemplate* _showMore;
Database::SearchFilter _filter;
Wt::WContainerWidget* _contents;
Wt::WText* _title;
std::size_t _count;
};
} // namespace Mobile
+58
View File
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2015 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wt/WApplication>
#include "SearchUtils.hpp"
#include "ReleaseSearch.hpp"
#include "ReleaseSearchView.hpp"
namespace UserInterface {
namespace Mobile {
#define SEARCH_NB_ITEMS 20
using namespace Database;
ReleaseSearchView::ReleaseSearchView(Wt::WContainerWidget* parent)
{
ReleaseSearch* artistSearch = new ReleaseSearch(this);
artistSearch->showMore().connect(std::bind([=] {
artistSearch->addResults(SEARCH_NB_ITEMS);
}));
wApp->internalPathChanged().connect(std::bind([=] (std::string path)
{
const std::string pathPrefix = "/audio/search/release";
if (!wApp->internalPathMatches(pathPrefix))
return;
std::vector<std::string> keywords = searchPathToSearchKeywords(path.substr(pathPrefix.length()));
artistSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Release, keywords), SEARCH_NB_ITEMS, "Releases");
}, std::placeholders::_1));
}
} // namespace Mobile
} // namespace UserInterface
+37
View File
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2016 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Wt/WContainerWidget>
namespace UserInterface {
namespace Mobile {
class ReleaseSearchView : public Wt::WContainerWidget
{
public:
ReleaseSearchView(Wt::WContainerWidget* parent = 0);
};
} // namespace Mobile
} // namespace UserInterface
+7 -1
View File
@@ -150,7 +150,7 @@ ReleaseView::addResults(size_t nb)
Wt::WImage *cover = new Wt::WImage();
cover->setStyleClass ("center-block img-responsive"); // TODO move to CSS?
cover->setImageLink(Wt::WLink (LmsApplication::instance()->getCoverResource()->getReleaseUrl(release.id(), 512)));
cover->setImageLink(Wt::WLink (LmsApp->getImageResource()->getReleaseUrl(release.id(), 512)));
releaseContainer->bindWidget("cover", cover);
releaseContainer->bindString("artist-name", getArtistNameFromRelease(release), Wt::PlainText);
@@ -210,5 +210,11 @@ ReleaseView::addResults(size_t nb)
_showMore->hide();
}
Wt::WLink
ReleaseView::getLink(Database::Release::id_type id)
{
return Wt::WLink(Wt::WLink::InternalPath, "/audio/release/" + std::to_string(id));
}
} // namespace Mobile
} // namespace UserInterface
+2 -2
View File
@@ -22,8 +22,6 @@
#include <Wt/WContainerWidget>
#include <Wt/WSignal>
#include "resource/CoverResource.hpp"
namespace UserInterface {
namespace Mobile {
@@ -31,6 +29,8 @@ class ReleaseView : public Wt::WContainerWidget
{
public:
static Wt::WLink getLink(Database::Release::id_type id);
ReleaseView(Wt::WContainerWidget *parent = 0);
void search(Database::SearchFilter filter, size_t nb);
+16 -40
View File
@@ -36,37 +36,32 @@ using namespace Database;
TrackSearch::TrackSearch(Wt::WContainerWidget *parent)
: Wt::WContainerWidget(parent)
{
Wt::WTemplate* wrapper = new Wt::WTemplate(this);
wrapper->setTemplateText(Wt::WString::tr("wa-track-wrapper"));
Wt::WTemplate* t = new Wt::WTemplate(this);
t->setTemplateText(Wt::WString::tr("wa-track-search"));
Wt::WTemplate* title = new Wt::WTemplate(this);
wrapper->bindWidget("title", title);
title->setTemplateText(Wt::WString::tr("mobile-search-title"));
title->bindString("text", "Tracks", Wt::PlainText);
t->bindWidget("title", title);
_container = new Wt::WContainerWidget();
wrapper->bindWidget("track-container", _container);
_contents = new Wt::WContainerWidget();
t->bindWidget("contents", _contents);
_showMore = new Wt::WTemplate();
wrapper->bindWidget("show-more", _showMore);
_showMore->setTemplateText(Wt::WString::tr("mobile-search-more"));
_showMore->bindString("text", "Tap to show more results...");
_showMore->hide();
_showMore->clicked().connect(std::bind([=] {
_sigMoreSelected();
_sigShowMore.emit();
addResults(20);
}));
t->bindWidget("show-more", _showMore);
}
void
TrackSearch::clear()
{
// Flush the release container
_container->clear();
_nbTracks = 0;
_contents->clear();
_showMore->hide();
}
@@ -79,43 +74,25 @@ TrackSearch::search(SearchFilter filter, size_t nb)
addResults(nb);
}
static
std::vector<Track::pointer >
getTracks(SearchFilter filter, size_t offset, size_t nb, bool &moreResults)
{
std::vector<Track::pointer > tracks = Track::getByFilter(DboSession(), filter, offset, nb + 1);
if (tracks.size() == nb + 1)
{
moreResults = true;
tracks.pop_back();
}
else
moreResults = false;
return tracks;
}
void
TrackSearch::addResults(size_t nb)
{
Wt::Dbo::Transaction transaction(DboSession());
bool moreResults;
std::vector<Track::pointer > tracks = getTracks(_filter, _nbTracks, nb, moreResults);
std::vector<Track::pointer > tracks = Track::getByFilter(DboSession(), _filter, _contents->count(), nb, moreResults);
for (Track::pointer track : tracks)
{
Wt::WTemplate* trackRes = new Wt::WTemplate(_container);
trackRes->setTemplateText(Wt::WString::tr("wa-track"));
Wt::WTemplate* res = new Wt::WTemplate(_contents);
res->setTemplateText(Wt::WString::tr("wa-track-search-res"));
Wt::WImage *cover = new Wt::WImage();
cover->setStyleClass ("center-block img-responsive");
cover->setImageLink(Wt::WLink(LmsApplication::instance()->getCoverResource()->getTrackUrl(track.id(), 128)));
trackRes->bindWidget("cover", cover);
trackRes->bindString("track-name", Wt::WString::fromUTF8(track->getName()), Wt::PlainText);
trackRes->bindString("artist-name", Wt::WString::fromUTF8(track->getArtist()->getName()), Wt::PlainText);
cover->setImageLink(SessionImageResource()->getTrackUrl(track.id(), 64));
res->bindWidget("cover", cover);
res->bindString("track-name", Wt::WString::fromUTF8(track->getName()), Wt::PlainText);
res->bindString("artist-name", Wt::WString::fromUTF8(track->getArtist()->getName()), Wt::PlainText);
Wt::WText *playBtn = new Wt::WText("Play", Wt::PlainText);
playBtn->setStyleClass("center-block"); // TODO move to CSS?
@@ -123,8 +100,7 @@ TrackSearch::addResults(size_t nb)
_sigTrackPlay.emit(track.id());
}));
trackRes->bindWidget("btn", playBtn);
_nbTracks++;
res->bindWidget("btn", playBtn);
}
if (moreResults)
+6 -8
View File
@@ -22,8 +22,8 @@
#include <Wt/WContainerWidget>
#include <Wt/WSignal>
#include "database/Types.hpp"
#include "database/SearchFilter.hpp"
#include "database/Types.hpp"
namespace UserInterface {
namespace Mobile {
@@ -34,25 +34,23 @@ class TrackSearch : public Wt::WContainerWidget
TrackSearch(Wt::WContainerWidget *parent = 0);
void addResults(size_t nb);
void search(Database::SearchFilter filter, size_t nb);
// Slots
Wt::Signal<void>& showMore() { return _sigShowMore;}
Wt::Signal<Database::Track::id_type>& trackPlay() { return _sigTrackPlay;}
Wt::Signal<void>& moreSelected() { return _sigMoreSelected;}
private:
Wt::Signal<void> _sigShowMore;
Wt::Signal<Database::Track::id_type> _sigTrackPlay;
Wt::Signal<void> _sigMoreSelected;
void clear(void);
void addResults(size_t nb);
Wt::WTemplate* _showMore;
Wt::WTemplate* _showMore;
Database::SearchFilter _filter;
std::size_t _nbTracks;
Wt::WContainerWidget* _container;
Wt::WContainerWidget* _contents;
};
} // namespace Mobile
+60
View File
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2016 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wt/WApplication>
#include <Wt/WText>
#include "logger/Logger.hpp"
#include "SearchUtils.hpp"
#include "TrackSearch.hpp"
#include "TrackSearchView.hpp"
namespace UserInterface {
namespace Mobile {
#define SEARCH_NB_ITEMS 20
using namespace Database;
TrackSearchView::TrackSearchView(Wt::WContainerWidget* parent)
{
TrackSearch* trackSearch = new TrackSearch(this);
trackSearch->showMore().connect(std::bind([=] {
trackSearch->addResults(SEARCH_NB_ITEMS);
}));
wApp->internalPathChanged().connect(std::bind([=] (std::string path)
{
const std::string pathPrefix = "/audio/search/track";
if (!wApp->internalPathMatches(pathPrefix))
return;
std::vector<std::string> keywords = searchPathToSearchKeywords(path.substr(pathPrefix.length()));
trackSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Track, keywords), SEARCH_NB_ITEMS);
}, std::placeholders::_1));
}
} // namespace Mobile
} // namespace UserInterface
+37
View File
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2016 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Wt/WContainerWidget>
namespace UserInterface {
namespace Mobile {
class TrackSearchView : public Wt::WContainerWidget
{
public:
TrackSearchView(Wt::WContainerWidget* parent = 0);
};
} // namespace Mobile
} // namespace UserInterface