Commit c24335b7 authored by camilo higuita's avatar camilo higuita

initial work on sycing playlist and start refactoring playlist model

parent 20283e69
......@@ -136,7 +136,7 @@ Maui.ApplicationWindow
headBar.middleContent : Maui.ActionGroup
{
id: _actionGroup
Layout.fillWidth: true
// Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumWidth: implicitWidth
currentIndex : swipeView.currentIndex
......@@ -685,7 +685,7 @@ Maui.ApplicationWindow
Loader
{
active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem || item
sourceComponent:PlaylistsView
sourceComponent: PlaylistsView
{
id: playlistsView
......
......@@ -233,8 +233,13 @@ void PlaylistsModel::addTrack(const int &index, const QStringList &urls)
if(index >= this->list.size() || index < 0)
return;
for(auto url : urls)
this->db->trackPlaylist(url, this->list[index][FMH::MODEL_KEY::PLAYLIST]);
this->addTrack(this->list[index][FMH::MODEL_KEY::PLAYLIST], urls);
}
void PlaylistsModel::addTrack(const QString &playlist, const QStringList &urls)
{
for(const auto &url : urls)
this->db->trackPlaylist(url, playlist);
}
void PlaylistsModel::removeTrack(const int &index, const QString &url)
......
......@@ -50,7 +50,9 @@ public slots:
void append(const QVariantMap &item, const int &at);
void insert(const QString &playlist);
void insertAt(const QString &playlist, const int &at);
void addTrack(const int &index, const QStringList &urls);
void addTrack(const QString &playlist, const QStringList &urls);
void removeTrack(const int &index, const QString &url);
void removePlaylist(const int &index);
};
......
......@@ -138,8 +138,7 @@ function appendTrack(track)
mainPlaylist.list.append(track)
if(sync === true)
{
infoMsgAnim()
// addToPlaylist([track.url], syncPlaylist)
playlistsList.addTrack(syncPlaylist, [track.url])
}
}
}
......@@ -205,7 +204,6 @@ function playAll(tracks)
{
sync = false
syncPlaylist = ""
infoMsg = ""
mainPlaylist.list.clear()
appendAll(tracks)
......
......@@ -28,7 +28,8 @@ Item
Maui.Badge
{
anchors.centerIn: parent
anchors.fill: parent
anchors.margins: Maui.Style.space.tiny
visible: anim.running
text: mainPlaylist.table.count
}
......
......@@ -63,12 +63,6 @@ Maui.ToolBar
}
}
rightContent: ToolButton
{
icon.name: "document-save"
onClicked: mainPlaylist.table.saveList()
}
middleContent: ListView
{
id: _listView
......
......@@ -61,6 +61,34 @@ Maui.Page
onRowClicked: play(index)
showQuickActions: false
listView.footer: Maui.ToolBar
{
Kirigami.Theme.inherit: false
z: table.z + 999
width: table.width
leftContent: Label
{
text: root.syncPlaylist
}
rightContent: [
ToolButton
{
icon.name: "edit-clear"
onClicked: mainPlaylist.table.list.clear()
},
ToolButton
{
icon.name: "document-save"
onClicked: mainPlaylist.table.saveList()
}
]
}
onArtworkDoubleClicked: contextMenu.babeIt(index)
property int startContentY
......
......@@ -18,9 +18,11 @@ ColumnLayout
property alias playlistModel : playlistViewModel.model
property alias playlistViewList : playlistViewModel
property alias listModel : filterList.listModel
signal rowClicked(var track)
signal quickPlayTrack(var track)
signal playAll()
signal playAll(string playlist)
signal playSync(var playlist)
signal appendAll()
......@@ -36,7 +38,7 @@ ColumnLayout
PlaylistsViewModel
{
id: playlistViewModel
onPlaySync: syncAndPlay(index)
// onPlaySync: syncAndPlay(index)
}
BabeList
......@@ -156,7 +158,7 @@ ColumnLayout
onRowClicked: control.rowClicked(filterList.listModel.get(index))
onQuickPlayTrack: control.quickPlayTrack(filterList.listModel.get(filterList.currentIndex))
onPlayAll: playAll()
onPlayAll: control.syncAndPlay(playlistViewModel.currentIndex)
onAppendAll: appendAll()
onPulled: populate(playlistQuery)
}
......@@ -202,7 +204,9 @@ ColumnLayout
function syncAndPlay(index)
{
if(!playlistsList.get(index).playlistIcon)
playSync(playlistsList.get(index).playlist)
control.playAll(playlistsList.get(index).playlist)
_filterDialog.close()
}
function removePlaylist()
......
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