Commit 48e89c36 authored by camilo higuita's avatar camilo higuita

more fixes towards stable release

parent 0ec84e4a
......@@ -255,8 +255,8 @@ void Babe::linkDecoder(QString json)
}
case LINK::CODE::SEARCHFOR :
{
auto res = this->searchFor(msg.split(","));
link.sendToClient(link.packResponse(static_cast<LINK::CODE>(code), res));
// auto res = this->searchFor(msg.split(","));
// link.sendToClient(link.packResponse(static_cast<LINK::CODE>(code), res));
break;
}
case LINK::CODE::PLAY :
......@@ -310,6 +310,11 @@ QVariantList Babe::getFolders()
return res;
}
QStringList Babe::getSourceFolders()
{
return this->db->getSourcesFolders();
}
void Babe::notify(const QString &title, const QString &body)
{
......@@ -495,68 +500,6 @@ QString Babe::loadCover(const QString &url)
return this->fetchCoverArt(track);
}
QVariantList Babe::searchFor(const QStringList &queries)
{
QVariantList mapList;
bool hasKey = false;
for(auto searchQuery : queries)
{
if(searchQuery.contains(BAE::SearchTMap[BAE::SearchT::LIKE]+":") || searchQuery.startsWith("#"))
{
if(searchQuery.startsWith("#"))
searchQuery=searchQuery.replace("#","").trimmed();
else
searchQuery=searchQuery.replace(BAE::SearchTMap[BAE::SearchT::LIKE]+":","").trimmed();
searchQuery = searchQuery.trimmed();
if(!searchQuery.isEmpty())
{
mapList += this->db->getSearchedTracks(FMH::MODEL_KEY::WIKI, searchQuery);
mapList += this->db->getSearchedTracks(FMH::MODEL_KEY::TAG, searchQuery);
mapList += this->db->getSearchedTracks(FMH::MODEL_KEY::LYRICS, searchQuery);
}
}else if(searchQuery.contains((BAE::SearchTMap[BAE::SearchT::SIMILAR]+":")))
{
searchQuery=searchQuery.replace(BAE::SearchTMap[BAE::SearchT::SIMILAR]+":","").trimmed();
searchQuery=searchQuery.trimmed();
if(!searchQuery.isEmpty())
mapList += this->db->getSearchedTracks(FMH::MODEL_KEY::TAG, searchQuery);
}else
{
FMH::MODEL_KEY key;
QHashIterator<FMH::MODEL_KEY, QString> k(FMH::MODEL_NAME);
while (k.hasNext())
{
k.next();
if(searchQuery.contains(QString(k.value()+":")))
{
hasKey=true;
key=k.key();
searchQuery = searchQuery.replace(k.value()+":","").trimmed();
}
}
searchQuery = searchQuery.trimmed();
if(!searchQuery.isEmpty())
{
if(hasKey)
mapList += this->db->getSearchedTracks(key, searchQuery);
else
{
auto queryTxt = QString("SELECT t.*, al.artwork FROM tracks t INNER JOIN albums al ON t.album = al.album AND t.artist = al.artist WHERE t.title LIKE \"%"+searchQuery+"%\" OR t.artist LIKE \"%"+searchQuery+"%\" OR t.album LIKE \"%"+searchQuery+"%\"OR t.genre LIKE \"%"+searchQuery+"%\"OR t.url LIKE \"%"+searchQuery+"%\" ORDER BY strftime(\"%s\", t.addDate) desc LIMIT 1000");
mapList += this->db->getDBDataQML(queryTxt);
}
}
}
}
return mapList;
}
QString Babe::fetchCoverArt(FMH::MODEL &song)
{
......
......@@ -49,6 +49,7 @@ public:
Q_INVOKABLE QString albumWiki(const QString &album, const QString &artist);
Q_INVOKABLE QVariantList getFolders();
Q_INVOKABLE QStringList getSourceFolders();
/* SETTINGS */
Q_INVOKABLE void scanDir(const QString &url);
......@@ -85,7 +86,6 @@ public:
/*USEFUL*/
Q_INVOKABLE QString loadCover(const QString &url);
Q_INVOKABLE QVariantList searchFor(const QStringList &queries);
/*KDE*/
Q_INVOKABLE void notify(const QString &title, const QString &body);
......
......@@ -665,7 +665,7 @@ FMH::MODEL_LIST CollectionDB::getBabedTracks(const FMH::MODEL_KEY &orderBy, cons
return this->getDBData(queryTxt);
}
QVariantList CollectionDB::getSearchedTracks(const FMH::MODEL_KEY &where, const QString &search)
FMH::MODEL_LIST CollectionDB::getSearchedTracks(const FMH::MODEL_KEY &where, const QString &search)
{
QString queryTxt;
......@@ -719,9 +719,7 @@ QVariantList CollectionDB::getSearchedTracks(const FMH::MODEL_KEY &where, const
FMH::MODEL_NAME[where],
search);
bDebug::Instance()->msg("SEARCH QUERY: " + queryTxt);
return this->getDBDataQML(queryTxt);
return this->getDBData(queryTxt);
}
......
......@@ -78,7 +78,7 @@ class CollectionDB : public QObject
FMH::MODEL_LIST getAlbumTracks(const QString &album, const QString &artist, const FMH::MODEL_KEY &orderBy = FMH::MODEL_KEY::TRACK, const BAE::W &order = BAE::W::ASC);
FMH::MODEL_LIST getArtistTracks(const QString &artist, const FMH::MODEL_KEY &orderBy = FMH::MODEL_KEY::ALBUM, const BAE::W &order = BAE::W::ASC);
FMH::MODEL_LIST getBabedTracks(const FMH::MODEL_KEY &orderBy = FMH::MODEL_KEY::COUNT, const BAE::W &order = BAE::W::DESC);
QVariantList getSearchedTracks(const FMH::MODEL_KEY &where, const QString &search);
FMH::MODEL_LIST getSearchedTracks(const FMH::MODEL_KEY &where, const QString &search);
FMH::MODEL_LIST getPlaylistTracks(const QString &playlist, const FMH::MODEL_KEY &orderBy = FMH::MODEL_KEY::ADDDATE, const BAE::W &order = BAE::W::DESC);
FMH::MODEL_LIST getMostPlayedTracks(const int &greaterThan = 1, const int &limit = 50, const FMH::MODEL_KEY &orderBy = FMH::MODEL_KEY::COUNT, const BAE::W &order = BAE::W::DESC);
FMH::MODEL_LIST getFavTracks(const int &stars = 1, const int &limit = 50, const FMH::MODEL_KEY &orderBy = FMH::MODEL_KEY::RATE, const BAE::W &order = BAE::W::DESC);
......
......@@ -335,6 +335,7 @@ Maui.ApplicationWindow
Maui.MenuItem
{
text: "Vvave Stream"
icon.name: "headphones"
onTriggered:
{
pageStack.currentIndex = 1
......@@ -345,6 +346,7 @@ Maui.ApplicationWindow
Maui.MenuItem
{
text: qsTr("Folders")
icon.name: "folder-open"
onTriggered:
{
pageStack.currentIndex = 1
......@@ -355,6 +357,7 @@ Maui.ApplicationWindow
Maui.MenuItem
{
text: qsTr("Linking")
icon.name: "view-links"
onTriggered:
{
pageStack.currentIndex = 1
......@@ -366,6 +369,7 @@ Maui.ApplicationWindow
Maui.MenuItem
{
text: qsTr("YouTube")
icon.name: "internet-services"
onTriggered:
{
pageStack.currentIndex = 1
......@@ -376,6 +380,7 @@ Maui.ApplicationWindow
Maui.MenuItem
{
text: qsTr("Spotify")
icon.name: "internet-services"
onTriggered:
{
pageStack.currentIndex = 1
......@@ -388,14 +393,14 @@ Maui.ApplicationWindow
Maui.MenuItem
{
text: qsTr("Sources...")
icon.name: "folder-add"
onTriggered: sourcesDialog.open()
},
Maui.Menu
{
title: qsTr("Collection")
// icon.name: "settings-configure"
Maui.MenuItem
{
......@@ -667,9 +672,7 @@ Maui.ApplicationWindow
{
var query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
query = query.arg(data.artist)
var tracks = bae.get(query)
mainPlaylist.list.clear()
mainPlaylist.list.query = query
......@@ -717,11 +720,13 @@ Maui.ApplicationWindow
onPlayAll:
{
var query = Q.GET.artistTracks_.arg(artist)
query = query.arg(data.artist)
var tracks = bae.get(query)
Player.playAll(tracks)
mainPlaylist.list.clear()
mainPlaylist.list.sortBy = Tracks.NONE
mainPlaylist.list.query = query
Player.playAll()
}
onAppendAll:
......
......@@ -188,6 +188,71 @@ void TracksModel::appendQuery(const QString &query)
emit this->postListChanged();
}
void TracksModel::searchQueries(const QStringList &queries)
{
emit this->preListChanged();
this->list.clear();
bool hasKey = false;
for(auto searchQuery : queries)
{
if(searchQuery.contains(BAE::SearchTMap[BAE::SearchT::LIKE]+":") || searchQuery.startsWith("#"))
{
if(searchQuery.startsWith("#"))
searchQuery = searchQuery.replace("#","").trimmed();
else
searchQuery = searchQuery.replace(BAE::SearchTMap[BAE::SearchT::LIKE]+":","").trimmed();
searchQuery = searchQuery.trimmed();
if(!searchQuery.isEmpty())
{
this->list << this->db->getSearchedTracks(FMH::MODEL_KEY::WIKI, searchQuery);
this->list << this->db->getSearchedTracks(FMH::MODEL_KEY::TAG, searchQuery);
this->list << this->db->getSearchedTracks(FMH::MODEL_KEY::LYRICS, searchQuery);
}
}else if(searchQuery.contains((BAE::SearchTMap[BAE::SearchT::SIMILAR]+":")))
{
searchQuery=searchQuery.replace(BAE::SearchTMap[BAE::SearchT::SIMILAR]+":","").trimmed();
searchQuery=searchQuery.trimmed();
if(!searchQuery.isEmpty())
this->list << this->db->getSearchedTracks(FMH::MODEL_KEY::TAG, searchQuery);
}else
{
FMH::MODEL_KEY key;
QHashIterator<FMH::MODEL_KEY, QString> k(FMH::MODEL_NAME);
while (k.hasNext())
{
k.next();
if(searchQuery.contains(QString(k.value()+":")))
{
hasKey=true;
key=k.key();
searchQuery = searchQuery.replace(k.value()+":","").trimmed();
}
}
searchQuery = searchQuery.trimmed();
if(!searchQuery.isEmpty())
{
if(hasKey)
this->list << this->db->getSearchedTracks(key, searchQuery);
else
{
auto queryTxt = QString("SELECT t.*, al.artwork FROM tracks t INNER JOIN albums al ON t.album = al.album AND t.artist = al.artist WHERE t.title LIKE \"%"+searchQuery+"%\" OR t.artist LIKE \"%"+searchQuery+"%\" OR t.album LIKE \"%"+searchQuery+"%\"OR t.genre LIKE \"%"+searchQuery+"%\"OR t.url LIKE \"%"+searchQuery+"%\" ORDER BY strftime(\"%s\", t.addDate) desc LIMIT 1000");
this->list << this->db->getDBData(queryTxt);
}
}
}
}
emit this->postListChanged();
}
void TracksModel::clear()
{
emit this->preListChanged();
......
......@@ -24,6 +24,7 @@ public:
RATE = FMH::MODEL_KEY::RATE,
FAV = FMH::MODEL_KEY::FAV,
TRACK = FMH::MODEL_KEY::TRACK,
COUNT = FMH::MODEL_KEY::COUNT,
NONE
}; Q_ENUM(SORTBY)
......@@ -56,6 +57,7 @@ public slots:
void append(const QVariantMap &item);
void append(const QVariantMap &item, const int &at);
void appendQuery(const QString &query);
void searchQueries(const QStringList &queries);
void clear();
bool color(const int &index, const QString &color);
bool fav(const int &index, const bool &value);
......
......@@ -21,6 +21,8 @@ BabeList
property alias list : _tracksList
property alias listModel : _tracksModel
property alias listView : babeTableRoot.listView
property bool trackNumberVisible
property bool quickPlayVisible : true
property bool coverArtVisible : false
......@@ -246,6 +248,7 @@ BabeList
section.criteria: ViewSection.FullString
section.delegate: Maui.LabelDelegate
{
id: _sectionDelegate
label: section
isSection: true
boldLabel: true
......@@ -256,7 +259,6 @@ BabeList
{
color: colorScheme.backgroundColor
}
}
......
......@@ -29,7 +29,7 @@ Maui.Menu
signal rateClicked(var paths, int rate)
signal colorClicked(var paths, string color)
property alias menuItem : customItems.children
property alias menuItem : control.content
Maui.MenuItem
{
......@@ -105,12 +105,6 @@ Maui.Menu
}
}
Column
{
id: customItems
width: parent.implicitWidth
}
Maui.MenuItem
{
id: starsRow
......
......@@ -50,6 +50,8 @@ StackView
}
}
Component.onCompleted: populate()
function populate()
{
browser.model.clear()
......@@ -61,16 +63,8 @@ StackView
function filter()
{
filterList.model.clear()
tracks = getTracks()
for(var i in tracks)
filterList.model.append(tracks[i])
}
var where = "source = \""+currentFolder+"\""
filterList.list.query = (Q.GET.tracksWhere_.arg(where))
function getTracks()
{
var where = "sources_url = \""+currentFolder+"\""
return bae.get(Q.GET.tracksWhere_.arg(where))
}
}
......@@ -18,9 +18,9 @@ Kirigami.PageRow
property string playlistQuery
property alias playlistViewModel : playlistViewModel
// property alias list : _playlistsList
// property alias listModel: _playlistsModel
// property alias listView : playlistViewModel.listView
// property alias list : _playlistsList
// property alias listModel: _playlistsModel
// property alias listView : playlistViewModel.listView
signal rowClicked(var track)
signal quickPlayTrack(var track)
......@@ -121,13 +121,13 @@ Kirigami.PageRow
holder.emojiSize: iconSizes.huge
headerMenu.menuItem: [
MenuItem
Maui.MenuItem
{
enabled: !playlistViewModel.model.get(playlistViewModel.currentIndex).playlistIcon
text: "Sync tags"
onTriggered: {}
},
MenuItem
Maui.MenuItem
{
enabled: !playlistViewModel.model.get(playlistViewModel.currentIndex).playlistIcon
text: "Play-n-Sync"
......@@ -137,7 +137,7 @@ Kirigami.PageRow
syncAndPlay(playlistViewModel.currentIndex)
}
},
MenuItem
Maui.MenuItem
{
enabled: !playlistViewModel.model.get(playlistViewModel.currentIndex).playlistIcon
text: "Remove playlist"
......@@ -215,19 +215,11 @@ Kirigami.PageRow
function populate(query)
{
if(!playlistViewRoot.wideMode)
playlistViewRoot.currentIndex = 1
playlistQuery = query
filterList.clearTable()
var tracks = bae.get(query)
if(tracks.length>0)
for(var i in tracks)
filterList.model.append(tracks[i])
playlistViewRoot.playlistQuery = query
filterList.list.query = playlistViewRoot.playlistQuery
}
function refresh()
......
......@@ -6,6 +6,8 @@ import org.kde.mauikit 1.0 as Maui
import PlaylistsList 1.0
import BaseModel 1.0
import TracksList 1.0
import "../../utils"
import "../../view_models"
......@@ -71,26 +73,31 @@ BabeList
onClicked :
{
currentIndex = index
var playlist = list.get(index).playlist
filterList.section.property = ""
var playlist = _playlistsList.get(index).playlist
filterList.group = false
switch(playlist)
{
case "Most Played":
playlistViewRoot.populate(Q.GET.mostPlayedTracks);
filterList.list.sortBy = Tracks.COUNT
break;
case "Favorites":
filterList.section.property = "stars"
playlistViewRoot.populate(Q.GET.favoriteTracks);
filterList.list.sortBy = Tracks.RATE
filterList.group = true
playlistViewRoot.populate(Q.GET.favoriteTracks);
break;
case "Recent":
playlistViewRoot.populate(Q.GET.recentTracks);
filterList.list.sortBy = Tracks.ADDDATE
filterList.group = true
break;
case "Babes":
case "Favs":
playlistViewRoot.populate(Q.GET.babedTracks);
break;
......
......@@ -100,8 +100,7 @@ BabeTable
searchTable.headBarTitle = searchTxt
var queries = searchTxt.split(",")
searchRes = bae.searchFor(queries)
populate(searchView.searchRes)
searchTable.list.searchQueries(queries)
searchTable.forceActiveFocus()
suggestionsPopup.close()
}
......
......@@ -4,13 +4,14 @@ import QtQuick.Controls 2.2
import org.kde.mauikit 1.0 as Maui
import "../../view_models"
Maui.Popup
Maui.Dialog
{
property string pathToRemove : ""
maxWidth: unit * 600
maxHeight: unit * 500
page.margins: 0
defaultButtons: false
function scanDir(folderUrl)
{
bae.scanDir(folderUrl)
......@@ -33,7 +34,7 @@ Maui.Popup
id: sources
anchors.fill: parent
headBar.visible: true
headBarExit: true
headBarExit: false
headBarTitle: qsTr("Sources")
Layout.fillWidth: true
Layout.fillHeight: true
......@@ -111,8 +112,8 @@ Maui.Popup
function getSources()
{
sources.clearTable()
var folders = bae.getSourcesFolders()
sources.model.clear()
var folders = bae.getSourceFolders()
for(var i in folders)
sources.model.append({url : folders[i]})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment