[UI/Mobile] Search keywords are now ANDed

This commit is contained in:
emeric
2015-12-10 19:52:51 +01:00
parent 6db3606a4b
commit 3b9745bd54
5 changed files with 33 additions and 11 deletions
+2
View File
@@ -17,6 +17,8 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "logger/Logger.hpp"
#include "SearchFilter.hpp"
namespace Database
+13 -2
View File
@@ -64,12 +64,23 @@ class SearchFilter
return SearchFilter({{field, {id} }});
}
// Single Field Name match
static SearchFilter ByName(Field field, std::vector<std::string> keywords)
// Single Field Name match OR
static SearchFilter ByNameOr(Field field, std::vector<std::string> keywords)
{
return NameLikeMatch({{{field, keywords}}});
}
// Single Field Name match AND
static SearchFilter ByNameAnd(Field field, std::vector<std::string> keywords)
{
NameLikeMatchType nameLikeMatch;
for (auto keyword : keywords)
nameLikeMatch.push_back({{{field, {keyword}}}});
return NameLikeMatch(nameLikeMatch);
}
// The filter is a AND of the following conditions:
// ((Field1.name LIKE STR1-1 OR Field1.name LIKE STR1-2 ...) OR (Field2.name LIKE STR2-1 OR Field2.name LIKE STR2-2 ...) ...
+3 -3
View File
@@ -95,9 +95,9 @@ Audio::Audio(Wt::WContainerWidget *parent)
// Song
auto keywords = splitString(edit->text().toUTF8(), " ");;
releaseSearch->search(SearchFilter::ByName(SearchFilter::Field::Release, keywords), SEARCH_NB_ITEMS);
artistSearch->search(SearchFilter::ByName(SearchFilter::Field::Artist, keywords), SEARCH_NB_ITEMS);
trackSearch->search(SearchFilter::ByName(SearchFilter::Field::Track, keywords), SEARCH_NB_ITEMS);
releaseSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Release, keywords), SEARCH_NB_ITEMS);
artistSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Artist, keywords), SEARCH_NB_ITEMS);
trackSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Track, keywords), SEARCH_NB_ITEMS);
artistSearch->show();
releaseSearch->show();
-2
View File
@@ -20,8 +20,6 @@
#ifndef UI_MOBILE_TRACK_SEARCH_HPP
#define UI_MOBILE_TRACK_SEARCH_HPP
#include <boost/algorithm/string/split.hpp>
#include <Wt/WContainerWidget>
#include <Wt/WSignal>
+15 -4
View File
@@ -33,7 +33,7 @@ class InputRange : public Wt::WWebWidget
};
Wt::WString MyPlayerTemplate = "${prev} ${play-pause} ${next} ${cover} ${artist} ${track} ${release} ${curtime} ${seekbar} ${duration} ${volume}";
Wt::WString MyPlayerTemplate = "${shuffle} ${repeat} ${playlist} ${prev} ${play-pause} ${next} ${cover} ${artist} ${track} ${release} ${curtime} ${seekbar} ${duration} ${volume}";
class MyPlayer : public Wt::WContainerWidget
{
@@ -124,13 +124,22 @@ class MyPlayer : public Wt::WContainerWidget
InputRange *volumeSlider = new InputRange();
t->bindWidget("volume", volumeSlider);
Wt::WPushButton *prevBtn = new Wt::WPushButton("<<");
Wt::WPushButton *playlistBtn = new Wt::WPushButton("<i class=\"fa fa-list fa-lg\"></i>", Wt::XHTMLText);
t->bindWidget("playlist", playlistBtn);
Wt::WPushButton *repeatBtn = new Wt::WPushButton("<i class=\"fa fa-repeat fa-lg\"></i>", Wt::XHTMLText);
t->bindWidget("repeat", repeatBtn);
Wt::WPushButton *shuffleBtn = new Wt::WPushButton("<i class=\"fa fa-random fa-lg\"></i>", Wt::XHTMLText);
t->bindWidget("shuffle", shuffleBtn);
Wt::WPushButton *prevBtn = new Wt::WPushButton("<i class=\"fa fa-step-backward fa-lg\"></i>", Wt::XHTMLText);
t->bindWidget("prev", prevBtn);
Wt::WPushButton *nextBtn = new Wt::WPushButton(">>");
Wt::WPushButton *nextBtn = new Wt::WPushButton("<i class=\"fa fa-step-forward fa-lg\"></i>", Wt::XHTMLText);
t->bindWidget("next", nextBtn);
Wt::WPushButton *playPauseBtn = new Wt::WPushButton("play/pause");
Wt::WPushButton *playPauseBtn = new Wt::WPushButton("<i class=\"fa fa-play fa-lg\"></i>", Wt::XHTMLText);
t->bindWidget("play-pause", playPauseBtn);
Wt::WText *trackCurrentTime = new Wt::WText("00:00");
@@ -254,6 +263,8 @@ class TestApplication : public Wt::WApplication
bootstrapTheme->setResponsive(true);
setTheme(bootstrapTheme);
useStyleSheet("resources/font-awesome/css/font-awesome.min.css");
Wt::WLineEdit* trackSelector = new Wt::WLineEdit();
MyPlayer* player = new MyPlayer(_db);