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,13 +916,18 @@ QSqlQuery CollectionDB::getQuery(const QString &queryTxt) ...@@ -916,13 +916,18 @@ 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::TRACKS],
FMH::MODEL_NAME[FMH::MODEL_KEY::SOURCE], path);
query.prepare(queryTxt);
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::SOURCES],
FMH::MODEL_NAME[FMH::MODEL_KEY::URL],path); FMH::MODEL_NAME[FMH::MODEL_KEY::URL],path);
...@@ -930,10 +935,12 @@ bool CollectionDB::removeSource(const QString &url) ...@@ -930,10 +935,12 @@ bool CollectionDB::removeSource(const QString &url)
if(query.exec()) if(query.exec())
{ {
this->removeFolder(path); this->removeFolder(path);
if(cleanAlbums()) cleanArtists(); if(cleanAlbums())
cleanArtists();
return true; return true;
} }
} }
}
return false; return false;
} }
......
...@@ -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,51 +4,60 @@ import org.kde.mauikit 1.0 as Maui ...@@ -4,51 +4,60 @@ 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
margins: space.large
Maui.GridBrowser
{
anchors.fill: parent anchors.fill: parent
id: browser
showEmblem: false showEmblem: false
onItemClicked: onItemClicked:
{ {
stack.push(filterList)
var item = browser.model.get(index) var item = browser.model.get(index)
filterList.headBarTitle= item.label _filterList.headBarTitle= item.label
currentFolder = item.path currentFolder = item.path
filter() filter()
_listDialog.open()
} }
Maui.Holder
{
anchors.fill: parent
visible: !browser.count
emoji: "qrc:/assets/MusicCloud.png"
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 BabeTable
{ {
id: filterList id: _filterList
anchors.fill: parent
coverArtVisible: true coverArtVisible: true
headBarExitIcon: "go-previous" headBarExit: false
holder.emoji: "qrc:/assets/MusicCloud.png" holder.emoji: "qrc:/assets/MusicCloud.png"
holder.isMask: false holder.isMask: false
holder.title : "No Tracks!" holder.title : "No Tracks!"
holder.body: "This source folder seems to be empty!" holder.body: "This source folder seems to be empty!"
holder.emojiSize: iconSizes.huge holder.emojiSize: iconSizes.huge
onExit:
{
stack.pop()
} }
} }
...@@ -66,7 +75,8 @@ StackView ...@@ -66,7 +75,8 @@ StackView
function filter() function filter()
{ {
var where = "source = \""+currentFolder+"\"" var where = "source = \""+currentFolder+"\""
filterList.list.query = (Q.GET.tracksWhere_.arg(where)) _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,18 +30,6 @@ Kirigami.PageRow ...@@ -26,18 +30,6 @@ Kirigami.PageRow
signal playSync(var playlist) signal playSync(var playlist)
signal appendAll() signal appendAll()
clip: true
separatorVisible: wideMode
initialPage: [playlistLayout, filterList]
defaultColumnWidth: Kirigami.Units.gridUnit * 15
ColumnLayout
{
id: playlistLayout
clip: true
spacing: 0
Layout.margins: 0
SwipeView SwipeView
{ {
id: playlistSwipe id: playlistSwipe
...@@ -84,29 +76,32 @@ Kirigami.PageRow ...@@ -84,29 +76,32 @@ Kirigami.PageRow
height: rowHeightAlt height: rowHeightAlt
recSize: isMobile ? iconSize : 16 recSize: isMobile ? iconSize : 16
onColorClicked: onColorClicked: populate(Q.GET.colorTracks_.arg(color))
{
populate(Q.GET.colorTracks_.arg(color))
if(!playlistViewRoot.wideMode)
playlistViewRoot.currentIndex = 1
}
}
} }
Maui.Dialog
{
id: _filterDialog
parent: parent
maxHeight: maxWidth
maxWidth: unit * 600
defaultButtons: false
page.margins: 0
BabeTable BabeTable
{ {
id: filterList id: filterList
anchors.fill: parent
clip: true clip: true
quickPlayVisible: true quickPlayVisible: true
coverArtVisible: true coverArtVisible: true
trackRating: true trackRating: true
trackDuration: false trackDuration: false
headBar.visible: !holder.visible headBar.visible: !holder.visible
headBarExitIcon: "go-previous" headBarExit: false
headBarExit: !playlistViewRoot.wideMode
headBarTitle: playlistViewModel.list.get(playlistViewModel.currentIndex).playlist headBarTitle: playlistViewModel.list.get(playlistViewModel.currentIndex).playlist
onExit: if(!playlistViewRoot.wideMode)
playlistViewRoot.currentIndex = 0
holder.emoji: "qrc:/assets/Electricity.png" holder.emoji: "qrc:/assets/Electricity.png"
holder.isMask: false holder.isMask: false
...@@ -174,11 +169,9 @@ Kirigami.PageRow ...@@ -174,11 +169,9 @@ Kirigami.PageRow
Connections Connections
{ {
target: filterList target: filterList
onRowClicked: playlistViewRoot.rowClicked(filterList.model.get(index)) onRowClicked: control.rowClicked(filterList.model.get(index))
onQuickPlayTrack: onQuickPlayTrack: control.quickPlayTrack(filterList.model.get(filterList.currentIndex))
{
playlistViewRoot.quickPlayTrack(filterList.model.get(filterList.currentIndex))
}
onPlayAll: playAll() onPlayAll: playAll()
onAppendAll: appendAll() onAppendAll: appendAll()
onPulled: populate(playlistQuery) onPulled: populate(playlistQuery)
...@@ -195,6 +188,7 @@ Kirigami.PageRow ...@@ -195,6 +188,7 @@ Kirigami.PageRow
} }
} }
} }
}
function populateExtra(query, title) function populateExtra(query, title)
...@@ -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); populate(Q.GET.favoriteTracks);
break; break;
case "Tags": case "Tags":
...@@ -112,11 +112,11 @@ BabeList ...@@ -112,11 +112,11 @@ BabeList
break; break;
case "Relationships": case "Relationships":
playlistViewRoot.populate(Q.GET.favoriteTracks); populate(Q.GET.favoriteTracks);
break; break;
case "Popular": case "Popular":
playlistViewRoot.populate(Q.GET.favoriteTracks); populate(Q.GET.favoriteTracks);
break; break;
case "Genres": case "Genres":
...@@ -124,10 +124,12 @@ BabeList ...@@ -124,10 +124,12 @@ BabeList
break; break;
default: default:
playlistViewRoot.populate(Q.GET.playlistTracks_.arg(playlist)); populate(Q.GET.playlistTracks_.arg(playlist));
break; break;
} }
_filterDialog.open()
} }
} }
} }
......
...@@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3 ...@@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import org.kde.mauikit 1.0 as Maui import org.kde.mauikit 1.0 as Maui
import "../../view_models" import "../../view_models"
import "../../utils/Help.js" as H
Maui.Dialog Maui.Dialog
{ {
...@@ -11,7 +12,34 @@ Maui.Dialog ...@@ -11,7 +12,34 @@ Maui.Dialog
maxWidth: unit * 600 maxWidth: unit * 600
maxHeight: unit * 500 maxHeight: unit * 500
page.margins: 0 page.margins: 0
defaultButtons: false defaultButtons: true
acceptButton.text: qsTr("Add")
rejectButton.text: qsTr("Remove")
onRejected:
{
var index = sources.currentIndex
var url = sources.model.get(index).url
pathToRemove = url
confirmationDialog.title = "Remove source"
confirmationDialog.message = "Are you sure you want to remove the source: \n "+url
confirmationDialog.open()
}
onAccepted:
{
fmDialog.onlyDirs = true
fmDialog.show(function(paths)
{
console.log("SCAN DIR <<", paths)
for(var i in paths)
listModel.append({url: paths[i]})
vvave.scanDir([paths])
})
getSources()
}
Maui.Dialog Maui.Dialog
{ {
...@@ -19,17 +47,30 @@ Maui.Dialog ...@@ -19,17 +47,30 @@ Maui.Dialog
onAccepted: onAccepted:
{ {
if(pathToRemove.length>0) if(pathToRemove.length>0)
if(bae.removeSource(pathToRemove)) if(vvave.removeSource(pathToRemove))
bae.refreshCollection() H.refreshCollection()
getSources()
confirmationDialog.close()
} }
onRejected: confirmationDialog.close()
}
Maui.Holder
{
anchors.fill: parent
visible: !sources.count
emoji: "qrc:/assets/MusicCloud.png"
isMask: false
title : "No Sources!"
body: "Add new sources to organize and play your music collection"
emojiSize: iconSizes.huge
} }
BabeList BabeList
{ {
id: sources id: sources
anchors.fill: parent anchors.fill: parent
headBar.visible: true headBar.visible: false
headBarExit: false headBarExit: false
headBarTitle: qsTr("Sources") headBarTitle: qsTr("Sources")
Layout.fillWidth: true Layout.fillWidth: true
...@@ -53,55 +94,6 @@ Maui.Dialog ...@@ -53,55 +94,6 @@ Maui.Dialog
onClicked: sources.currentIndex = index onClicked: sources.currentIndex = index
} }
} }
headBar.rightContent: [
Maui.ToolButton
{
iconName: "list-remove"
onClicked:
{
close()
var index = sources.currentIndex
var url = sources.list.model.get(index).url
confirmationDialog.title = "Remove source"
if(bae.defaultSources().indexOf(url)<0)
{
pathToRemove = url
confirmationDialog.message = "Are you sure you want to remove the source: \n "+url
}
else
{
pathToRemove = ""
confirmationDialog.message = url+"\nis a default source and cannot be removed"
}
confirmationDialog.open()
}
},
Maui.ToolButton
{
iconName: "list-add"
onClicked:
{
close()
fmDialog.onlyDirs = true
fmDialog.show(function(paths)
{
console.log("SCAN DIR <<", paths)
for(var i in paths)
listModel.append({url: paths[i]})
vvave.scanDir([paths])
close()
})
}
}
]
} }
onOpened: getSources() onOpened: getSources()
......
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