Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 68535eab authored by camilo higuita's avatar camilo higuita

more fixes along the way and now sources work flawlessly

parent ab7a2405
...@@ -916,22 +916,29 @@ QSqlQuery CollectionDB::getQuery(const QString &queryTxt) ...@@ -916,22 +916,29 @@ QSqlQuery CollectionDB::getQuery(const QString &queryTxt)
bool CollectionDB::removeSource(const QString &url) bool CollectionDB::removeSource(const QString &url)
{ {
auto path = url.endsWith("/") ? url.chopped(1) : url; const auto path = url.endsWith("/") ? url.chopped(1) : url;
auto queryTxt = QString("DELETE FROM %1 WHERE %2 LIKE \"%3%\"").arg(TABLEMAP[TABLE::TRACKS_PLAYLISTS],
auto queryTxt = QString("DELETE FROM %1 WHERE %2 LIKE \"%3%\"").arg(TABLEMAP[TABLE::TRACKS], FMH::MODEL_NAME[FMH::MODEL_KEY::URL], path);
FMH::MODEL_NAME[FMH::MODEL_KEY::SOURCE], path);
qDebug() << queryTxt; qDebug() << queryTxt;
auto query = this->getQuery(queryTxt); auto query = this->getQuery(queryTxt);
if(query.exec()) if(query.exec())
{ {
queryTxt = QString("DELETE FROM %1 WHERE %2 LIKE \"%3%\"").arg(TABLEMAP[TABLE::SOURCES], queryTxt = QString("DELETE FROM %1 WHERE %2 LIKE \"%3%\"").arg(TABLEMAP[TABLE::TRACKS],
FMH::MODEL_NAME[FMH::MODEL_KEY::URL],path); FMH::MODEL_NAME[FMH::MODEL_KEY::SOURCE], path);
query.prepare(queryTxt); query.prepare(queryTxt);
if(query.exec()) if(query.exec())
{ {
this->removeFolder(path); queryTxt = QString("DELETE FROM %1 WHERE %2 LIKE \"%3%\"").arg(TABLEMAP[TABLE::SOURCES],
if(cleanAlbums()) cleanArtists(); FMH::MODEL_NAME[FMH::MODEL_KEY::URL],path);
return true; query.prepare(queryTxt);
if(query.exec())
{
this->removeFolder(path);
if(cleanAlbums())
cleanArtists();
return true;
}
} }
} }
......
...@@ -125,7 +125,6 @@ void AlbumsModel::setList() ...@@ -125,7 +125,6 @@ void AlbumsModel::setList()
void AlbumsModel::fetchInformation() void AlbumsModel::fetchInformation()
{ {
qDebug() << "RNUNGING BRAIN EFFORRTS"; qDebug() << "RNUNGING BRAIN EFFORRTS";
QFutureWatcher<void> *watcher = new QFutureWatcher<void>; QFutureWatcher<void> *watcher = new QFutureWatcher<void>;
...@@ -200,8 +199,8 @@ void AlbumsModel::fetchInformation() ...@@ -200,8 +199,8 @@ void AlbumsModel::fetchInformation()
// }); // });
QObject::connect(this, &AlbumsModel::destroyed, [&]() QObject::connect(this, &AlbumsModel::destroyed, [&]()
{ {
// loop.quit();
stop = true; stop = true;
loop.quit();
}); });
for(auto i = 0; i < requests.size(); i++) for(auto i = 0; i < requests.size(); i++)
......
...@@ -104,7 +104,7 @@ FMH::MODEL_LIST PlaylistsModel::defaultPlaylists() ...@@ -104,7 +104,7 @@ FMH::MODEL_LIST PlaylistsModel::defaultPlaylists()
}, },
{ {
{FMH::MODEL_KEY::PLAYLIST, "Favorites"}, {FMH::MODEL_KEY::PLAYLIST, "Rating"},
{FMH::MODEL_KEY::ICON, "view-media-favorite"}, {FMH::MODEL_KEY::ICON, "view-media-favorite"},
{FMH::MODEL_KEY::ADDDATE,QDateTime::currentDateTime().toString(Qt::DateFormat::TextDate)} {FMH::MODEL_KEY::ADDDATE,QDateTime::currentDateTime().toString(Qt::DateFormat::TextDate)}
}, },
......
...@@ -93,6 +93,14 @@ QVariantList vvave::sourceFolders() ...@@ -93,6 +93,14 @@ QVariantList vvave::sourceFolders()
return res; return res;
} }
bool vvave::removeSource(const QString &source)
{
if(!this->getSourceFolders().contains(source))
return false;
return this->db->removeSource(source);
}
QString vvave::moodColor(const int &index) QString vvave::moodColor(const int &index)
{ {
if(index < BAE::MoodColors.size() && index > -1) if(index < BAE::MoodColors.size() && index > -1)
......
...@@ -30,6 +30,7 @@ public slots: ...@@ -30,6 +30,7 @@ public slots:
///DB Interfaces ///DB Interfaces
/// useful functions for non modeled views and actions with not direct access to a tracksmodel or its own model /// useful functions for non modeled views and actions with not direct access to a tracksmodel or its own model
QVariantList sourceFolders(); QVariantList sourceFolders();
bool removeSource(const QString &source);
static QString moodColor(const int &index); static QString moodColor(const int &index);
void scanDir(const QStringList &paths = BAE::defaultSources); void scanDir(const QStringList &paths = BAE::defaultSources);
......
...@@ -4,69 +4,79 @@ import org.kde.mauikit 1.0 as Maui ...@@ -4,69 +4,79 @@ import org.kde.mauikit 1.0 as Maui
import "../view_models/BabeTable" import "../view_models/BabeTable"
import "../db/Queries.js" as Q import "../db/Queries.js" as Q
StackView Item
{ {
id: stack Maui.GridBrowser
property alias list : filterList
property var tracks : []
property string currentFolder : ""
initialItem: Maui.Page
{ {
id: browser
property alias list : _filterList
property var tracks : []
property string currentFolder : ""
// headBarTitle: qsTr("Source folders") // headBarTitle: qsTr("Source folders")
headBar.visible: false anchors.margins: space.big
headBarExit: false anchors.fill: parent
margins: space.large showEmblem: false
Maui.GridBrowser onItemClicked:
{
var item = browser.model.get(index)
_filterList.headBarTitle= item.label
currentFolder = item.path
filter()
_listDialog.open()
}
Maui.Holder
{ {
anchors.fill: parent anchors.fill: parent
id: browser visible: !browser.count
showEmblem: false emoji: "qrc:/assets/MusicCloud.png"
onItemClicked: isMask: false
title : "No Folders!"
body: "Add new music to your sources to browse by folders"
emojiSize: iconSizes.huge
}
Maui.Dialog
{
id: _listDialog
parent: parent
maxHeight: maxWidth
maxWidth: unit * 600
defaultButtons: false
page.margins: 0
BabeTable
{ {
stack.push(filterList) id: _filterList
var item = browser.model.get(index) anchors.fill: parent
filterList.headBarTitle= item.label coverArtVisible: true
currentFolder = item.path headBarExit: false
filter() holder.emoji: "qrc:/assets/MusicCloud.png"
holder.isMask: false
holder.title : "No Tracks!"
holder.body: "This source folder seems to be empty!"
holder.emojiSize: iconSizes.huge
} }
} }
}
BabeTable Component.onCompleted: populate()
{
id: filterList
coverArtVisible: true
headBarExitIcon: "go-previous"
holder.emoji: "qrc:/assets/MusicCloud.png"
holder.isMask: false
holder.title : "No Tracks!"
holder.body: "This source folder seems to be empty!"
holder.emojiSize: iconSizes.huge
onExit: function populate()
{ {
stack.pop() browser.model.clear()
var folders = vvave.sourceFolders();
if(folders.length > 0)
for(var i in folders)
browser.model.append(folders[i])
} }
}
Component.onCompleted: populate()
function populate() function filter()
{ {
browser.model.clear() var where = "source = \""+currentFolder+"\""
var folders = vvave.sourceFolders(); _filterList.list.query = (Q.GET.tracksWhere_.arg(where))
if(folders.length > 0)
for(var i in folders)
browser.model.append(folders[i])
}
function filter()
{
var where = "source = \""+currentFolder+"\""
filterList.list.query = (Q.GET.tracksWhere_.arg(where))
}
} }
} }
...@@ -11,9 +11,13 @@ import "../../db/Queries.js" as Q ...@@ -11,9 +11,13 @@ import "../../db/Queries.js" as Q
import "../../utils/Help.js" as H import "../../utils/Help.js" as H
Kirigami.PageRow
ColumnLayout
{ {
id: playlistViewRoot id: control
clip: true
spacing: 0
property string playlistQuery property string playlistQuery
property alias playlistModel : playlistViewModel.model property alias playlistModel : playlistViewModel.model
...@@ -26,172 +30,162 @@ Kirigami.PageRow ...@@ -26,172 +30,162 @@ Kirigami.PageRow
signal playSync(var playlist) signal playSync(var playlist)
signal appendAll() signal appendAll()
clip: true SwipeView
separatorVisible: wideMode
initialPage: [playlistLayout, filterList]
defaultColumnWidth: Kirigami.Units.gridUnit * 15
ColumnLayout
{ {
id: playlistLayout id: playlistSwipe
Layout.fillHeight: true
Layout.fillWidth: true
interactive: false
clip: true clip: true
spacing: 0
Layout.margins: 0
SwipeView PlaylistsViewModel
{ {
id: playlistSwipe id: playlistViewModel
onPlaySync: syncAndPlay(index)
}
Layout.fillHeight: true BabeList
Layout.fillWidth: true {
id: playlistViewModelFilter
interactive: false headBarExitIcon: "go-previous"
clip: true
PlaylistsViewModel model : ListModel {}
delegate: Maui.LabelDelegate
{ {
id: playlistViewModel id: delegate
onPlaySync: syncAndPlay(index) label : tag
} Connections
BabeList
{
id: playlistViewModelFilter
headBarExitIcon: "go-previous"
model : ListModel {}
delegate: Maui.LabelDelegate
{ {
id: delegate target: delegate
label : tag
Connections
{
target: delegate
onClicked: {}
}
}
onExit: playlistSwipe.currentIndex = 0 onClicked: {}
}
} }
onExit: playlistSwipe.currentIndex = 0
} }
ColorTagsBar
{
Layout.fillWidth: true
height: rowHeightAlt
recSize: isMobile ? iconSize : 16
onColorClicked:
{
populate(Q.GET.colorTracks_.arg(color))
if(!playlistViewRoot.wideMode)
playlistViewRoot.currentIndex = 1
}
}
} }
BabeTable ColorTagsBar
{ {
id: filterList Layout.fillWidth: true
clip: true height: rowHeightAlt
quickPlayVisible: true recSize: isMobile ? iconSize : 16
coverArtVisible: true
trackRating: true onColorClicked: populate(Q.GET.colorTracks_.arg(color))
trackDuration: false
headBar.visible: !holder.visible
headBarExitIcon: "go-previous"
headBarExit: !playlistViewRoot.wideMode
headBarTitle: playlistViewModel.list.get(playlistViewModel.currentIndex).playlist
onExit: if(!playlistViewRoot.wideMode)
playlistViewRoot.currentIndex = 0
holder.emoji: "qrc:/assets/Electricity.png"
holder.isMask: false
holder.title : playlistViewModel.model.get(playlistViewModel.currentIndex).playlist
holder.body: "Your playlist is empty,<br>start adding new music to it"
holder.emojiSize: iconSizes.huge
contextMenuItems:
Maui.MenuItem
{
text: qsTr("Remove from playlist")
}
}
// headerMenu.menuItem: [ Maui.Dialog
// Maui.MenuItem {
// { id: _filterDialog
// enabled: !playlistViewModel.model.get(playlistViewModel.currentIndex).playlistIcon parent: parent
// text: "Sync tags" maxHeight: maxWidth
// onTriggered: {} maxWidth: unit * 600
// }, defaultButtons: false
// Maui.MenuItem page.margins: 0
// {
// enabled: !playlistViewModel.model.get(playlistViewModel.currentIndex).playlistIcon BabeTable
// text: "Play-n-Sync"
// onTriggered:
// {
// filterList.headerMenu.close()
// syncAndPlay(playlistViewModel.currentIndex)
// }
// },
// Maui.MenuItem
// {
// enabled: !playlistViewModel.model.get(playlistViewModel.currentIndex).playlistIcon
// text: "Remove playlist"
// onTriggered: removePlaylist()
// }
// ]
// contextMenu.menuItem: [
// MenuItem
// {
// text: qsTr("Remove from playlist")
// onTriggered:
// {
// bae.removePlaylistTrack(filterList.model.get(filterList.currentIndex).url, playlistViewModel.model.get(playlistViewModel.currentIndex).playlist)
// populate(playlistQuery)
// }
// }
// ]
section.criteria: ViewSection.FullString
section.delegate: Maui.LabelDelegate
{ {
label: filterList.section.property === qsTr("stars") ? H.setStars(section) : section id: filterList
isSection: true anchors.fill: parent
boldLabel: true clip: true
labelTxt.font.family: "Material Design Icons" quickPlayVisible: true
coverArtVisible: true
trackRating: true
trackDuration: false
headBar.visible: !holder.visible
headBarExit: false
headBarTitle: playlistViewModel.list.get(playlistViewModel.currentIndex).playlist
holder.emoji: "qrc:/assets/Electricity.png"
holder.isMask: false
holder.title : playlistViewModel.model.get(playlistViewModel.currentIndex).playlist
holder.body: "Your playlist is empty,<br>start adding new music to it"
holder.emojiSize: iconSizes.huge
contextMenuItems:
Maui.MenuItem
{
text: qsTr("Remove from playlist")
}
}
Connections // headerMenu.menuItem: [
{ // Maui.MenuItem
target: filterList // {
onRowClicked: playlistViewRoot.rowClicked(filterList.model.get(index)) // enabled: !playlistViewModel.model.get(playlistViewModel.currentIndex).playlistIcon
onQuickPlayTrack: // text: "Sync tags"
// onTriggered: {}
// },
// Maui.MenuItem
// {
// enabled: !playlistViewModel.model.get(playlistViewModel.currentIndex).playlistIcon
// text: "Play-n-Sync"
// onTriggered:
// {
// filterList.headerMenu.close()
// syncAndPlay(playlistViewModel.currentIndex)
// }
// },
// Maui.MenuItem
// {
// enabled: !playlistViewModel.model.get(playlistViewModel.currentIndex).playlistIcon
// text: "Remove playlist"
// onTriggered: removePlaylist()
// }
// ]
// contextMenu.menuItem: [
// MenuItem
// {
// text: qsTr("Remove from playlist")
// onTriggered:
// {
// bae.removePlaylistTrack(filterList.model.get(filterList.currentIndex).url, playlistViewModel.model.get(playlistViewModel.currentIndex).playlist)
// populate(playlistQuery)
// }
// }
// ]
section.criteria: ViewSection.FullString
section.delegate: Maui.LabelDelegate
{ {
playlistViewRoot.quickPlayTrack(filterList.model.get(filterList.currentIndex)) label: filterList.section.property === qsTr("stars") ? H.setStars(section) : section
isSection: true
boldLabel: true
labelTxt.font.family: "Material Design Icons"
} }
onPlayAll: playAll()
onAppendAll: appendAll()
onPulled: populate(playlistQuery)
}
Connections Connections
{ {
target: filterList.contextMenu target: filterList
onRowClicked: control.rowClicked(filterList.model.get(index))
onQuickPlayTrack: control.quickPlayTrack(filterList.model.get(filterList.currentIndex))
onRemoveClicked: onPlayAll: playAll()
onAppendAll: appendAll()
onPulled: populate(playlistQuery)
}
Connections
{ {
playlistList.removeTrack(playlistViewList.currentIndex, filterList.list.get(filterList.currentIndex).url) target: filterList.contextMenu
populate(playlistQuery)
onRemoveClicked:
{
playlistList.removeTrack(playlistViewList.currentIndex, filterList.list.get(filterList.currentIndex).url)
populate(playlistQuery)
}
} }
} }
} }
...@@ -216,21 +210,15 @@ Kirigami.PageRow ...@@ -216,21 +210,15 @@ Kirigami.PageRow
function populate(query) function populate(query)
{ {
if(!playlistViewRoot.wideMode)
playlistViewRoot.currentIndex = 1
playlistViewRoot.playlistQuery = query playlistQuery = query
filterList.list.query = playlistViewRoot.playlistQuery filterList.list.query = playlistQuery
}
function refresh()
{
} }
function syncAndPlay(index) function syncAndPlay(index)
{ {
if(!playlistList.get(index).playlistIcon) if(!playlistList.get(index).playlistIcon)
playlistViewRoot.playSync(playlistList.get(index).playlist) playSync(playlistList.get(index).playlist)
} }
function removePlaylist() function removePlaylist()
......
...@@ -82,29 +82,29 @@ BabeList ...@@ -82,29 +82,29 @@ BabeList
{ {
case "Most Played": case "Most Played":
playlistViewRoot.populate(Q.GET.mostPlayedTracks); populate(Q.GET.mostPlayedTracks);
filterList.list.sortBy = Tracks.COUNT filterList.list.sortBy = Tracks.COUNT
break; break;
case "Favorites": case "Rating":
filterList.list.sortBy = Tracks.RATE filterList.list.sortBy = Tracks.RATE
filterList.group = true filterList.group = true
playlistViewRoot.populate(Q.GET.favoriteTracks); populate(Q.GET.favoriteTracks);
break; break;
case "Recent": case "Recent":
playlistViewRoot.populate(Q.GET.recentTracks); populate(Q.GET.recentTracks);
filterList.list.sortBy = Tracks.ADDDATE filterList.list.sortBy = Tracks.ADDDATE
filterList.group = true filterList.group = true
break; break;
case "Favs": case "Favs":
playlistViewRoot.populate(Q.GET.babedTracks); populate(Q.GET.babedTracks);
break; break;
case "Online": case "Online":
playlistViewRoot.populate(Q.GET.favoriteTracks);