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