Commit e86852c9 authored by Camilo Higuita's avatar Camilo Higuita

better template for all lists

parent 19f13ca2
......@@ -31,6 +31,7 @@ CollectionDB::CollectionDB(QObject *parent) : QObject(parent)
this->openDB(this->name);
qDebug()<<"Collection doesn't exists, trying to create it" << BAE::CollectionDBPath + BAE::DBName;
this->prepareCollectionDB();
}else this->openDB(this->name);
}
......
......@@ -46,9 +46,9 @@ bool ConThread::isRunning()
return this->go;
}
void ConThread::setInterval()
void ConThread::setInterval(const uint &interval)
{
this->interval = interval;
}
void ConThread::get(QString query)
......@@ -65,13 +65,11 @@ void ConThread::set(QString tableName, QVariantList wheres)
this->t.msleep(this->interval);
}
qDebug()<<"FINISHED SET ON QUEUE CONTHREAD"<< this->queue.first()["TABLE"].toString();
this->queue.removeFirst();
qDebug()<<"QUERYS ON QUEUE THREAD"<<this->queue.size();
emit this->finished();
if(!this->queue.isEmpty())
this->set(this->queue.first()["TABLE"].toString(), this->queue.first()["WHERES"].toList());
else qDebug()<<"FINISHED SET ON CONTHREAD TOTALLY";
}
......
......@@ -15,7 +15,7 @@ public:
void stop();
void pause();
bool isRunning();
void setInterval();
void setInterval(const uint &interval);
void get(QString query);
......
......@@ -209,9 +209,9 @@ Kirigami.ApplicationWindow
target: bae
onRefreshTables:
{
tracksView.clearTable()
albumsView.clearGrid()
artistsView.clearGrid()
tracksView.list.clearTable()
albumsView.list.clearGrid()
artistsView.list.clearGrid()
tracksView.populate()
albumsView.populate()
......@@ -768,7 +768,6 @@ Kirigami.ApplicationWindow
onQuickPlayTrack: Player.quickPlay(searchView.searchTable.model.get(index))
onPlayAll: Player.playAll(searchView.searchRes)
onAppendAll: Player.appendAll(searchView.searchRes)
// onHeaderClosed: clearSearch()
onArtworkDoubleClicked:
{
var query = Q.GET.albumTracks_.arg(searchView.searchTable.model.get(index).album)
......
......@@ -1693,7 +1693,7 @@ var Babe = {
"media-playlist-repeat": "\uf49E",
"babe" : Icon.heart,
"arrow-left":"\uf04D",
"arrow-left": Icon.arrowLeft,
"overflow-menu": Icon.dotsVertical,
"player-time": "\uf40C",
......
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.2 as Kirigami
ListView
Item
{
id: babeList
property alias list : babeList
property alias model : babeList.model
property alias delegate : babeList.delegate
property alias count : babeList.count
property alias currentIndex : babeList.currentIndex
property alias holder : holder
signal pulled()
property bool wasPulled : false
clip: true
highlight: Rectangle
{
width: babeList.width
height: babeList.currentItem.height
color: babeHighlightColor
// y: babeList.currentItem.y
// Behavior on y
// {
// SpringAnimation
// {
// spring: 3
// damping: 0.2
// }
// }
}
property alias headerBarRight : headerBarActionsRight.children
property alias headerBarLeft : headerBarActionsLeft.children
focus: true
interactive: true
highlightFollowsCurrentItem: true
highlightMoveDuration: 0
keyNavigationWraps: !isMobile
keyNavigationEnabled : !isMobile
property bool headerBarVisible: true
property string headerBarTitle
property bool headerBarExit : true
property string headerBarExitIcon : "window-close"
property color headerBarColor : "transparent"
Keys.onUpPressed: decrementCurrentIndex()
Keys.onDownPressed: incrementCurrentIndex()
Keys.onReturnPressed: rowClicked(currentIndex)
Keys.onEnterPressed: quickPlayTrack(currentIndex)
boundsBehavior: !isMobile? Flickable.StopAtBounds : Flickable.DragAndOvershootBounds
flickableDirection: Flickable.AutoFlickDirection
snapMode: ListView.SnapToItem
addDisplaced: Transition
{
NumberAnimation { properties: "x,y"; duration: 100 }
}
property bool wasPulled : false
function clearTable()
{
listModel.clear()
}
signal pulled()
signal exit()
BabeHolder
{
id: holder
visible: count === 0
}
Rectangle
ColumnLayout
{
anchors.fill: parent
color: "transparent"
z: -999
spacing: 0
Item
{
id: headerRoot
width: parent.width
height: visible ? toolBarHeight : 0
Layout.fillWidth: true
visible: headerBarVisible
Rectangle
{
anchors.fill: parent
color: headerBarColor
Kirigami.Separator
{
Rectangle
{
anchors.fill: parent
color: Kirigami.Theme.viewFocusColor
}
anchors
{
left: parent.left
right: parent.right
bottom: parent.bottom
}
}
}
RowLayout
{
id: headerBar
anchors.fill: parent
BabeButton
{
Layout.alignment : Qt.AlignLeft
Layout.leftMargin: contentMargins-6
width: rowHeight
visible: headerBarExit
anim : true
iconName : headerBarExitIcon //"dialog-close"
onClicked : exit()
}
Row
{
id: headerBarActionsLeft
Layout.alignment : Qt.AlignLeft
Layout.leftMargin: headerBarExit ? 0 : contentMargins-6
}
Label
{
text : headerBarTitle || babeList.count +" tracks"
Layout.fillHeight : true
Layout.fillWidth : true
Layout.alignment : Qt.AlignCenter
elide : Text.ElideRight
font.bold : false
color : foregroundColor
horizontalAlignment : Text.AlignHCenter
verticalAlignment : Text.AlignVCenter
}
Row
{
id: headerBarActionsRight
Layout.alignment : Qt.AlignRight
Layout.rightMargin: contentMargins-6
}
}
}
ListView
{
id: babeList
Layout.fillHeight: true
Layout.fillWidth: true
clip: true
highlight: Rectangle
{
width: babeList.width
height: babeList.currentItem.height
color: babeHighlightColor
// y: babeList.currentItem.y
// Behavior on y
// {
// SpringAnimation
// {
// spring: 3
// damping: 0.2
// }
// }
}
focus: true
interactive: true
highlightFollowsCurrentItem: true
highlightMoveDuration: 0
keyNavigationWraps: !isMobile
keyNavigationEnabled : !isMobile
Keys.onUpPressed: decrementCurrentIndex()
Keys.onDownPressed: incrementCurrentIndex()
Keys.onReturnPressed: rowClicked(currentIndex)
Keys.onEnterPressed: quickPlayTrack(currentIndex)
boundsBehavior: !isMobile? Flickable.StopAtBounds : Flickable.DragAndOvershootBounds
flickableDirection: Flickable.AutoFlickDirection
snapMode: ListView.SnapToItem
addDisplaced: Transition
{
NumberAnimation { properties: "x,y"; duration: 100 }
}
function clearTable()
{
listModel.clear()
}
BabeHolder
{
id: holder
visible: babeList.count === 0
}
Rectangle
{
anchors.fill: parent
color: "transparent"
z: -999
}
ScrollBar.vertical:BabeScrollBar { }
onContentYChanged:
{
if(contentY < -120)
wasPulled = true
if(contentY == toolBarHeight*-1 && wasPulled)
{ pulled(); wasPulled = false}
}
}
}
ScrollBar.vertical:BabeScrollBar { }
onContentYChanged:
{
if(contentY < -120)
wasPulled = true
if(contentY == toolBarHeight*-1 && wasPulled)
{ pulled(); wasPulled = false}
}
}
......@@ -7,11 +7,11 @@ import ".."
BabeList
{
id: list
// id: list
holder.message: "<h2>This list is empty</h2><p>You can sdd new music sources from the settings</p>"
// cacheBuffer : 300
headerBarColor: midLightColor
property bool headerBar: false
property bool trackNumberVisible
property bool quickPlayVisible : true
property bool coverArtVisible : false
......@@ -20,10 +20,6 @@ BabeList
property bool trackDuration
property bool trackRating
property string headerTitle
property bool headerClose : false
property alias holder : list.holder
property alias headerMenu: headerMenu
property alias contextMenu : contextMenu
......@@ -31,96 +27,38 @@ BabeList
signal rowPressed(int index)
signal quickPlayTrack(int index)
signal queueTrack(int index)
signal headerClosed()
signal artworkDoubleClicked(int index)
signal playAll()
signal appendAll()
headerPositioning: ListView.OverlayHeader
header: Rectangle
headerBarLeft: BabeButton
{
id: tableHeader
width: parent.width
height: visible ? toolBarHeight : 0
color: midLightColor
visible: headerBar
z: 999
Kirigami.Separator
{
Rectangle
{
anchors.fill: parent
color: Kirigami.Theme.viewFocusColor
}
anchors
{
left: parent.left
right: parent.right
bottom: parent.bottom
}
}
id : playAllBtn
visible : headerBarVisible && count > 0
anim : true
iconName : /*"amarok_clock"*/ "media-playback-start"
onClicked : playAll()
}
RowLayout
headerBarRight: [
BabeButton
{
anchors.fill: parent
anchors.centerIn: parent
BabeButton
{
id: closeBtn
width: rowHeight
visible: headerClose
anim : true
iconName : "window-close" //"dialog-close"
onClicked : headerClosed()
}
BabeButton
{
id : playAllBtn
visible : headerBar && count > 0
anim : true
iconName : /*"amarok_clock"*/ "media-playback-start"
onClicked : playAll()
}
Label
{
text : headerTitle || count +" tracks"
Layout.fillHeight : true
Layout.fillWidth : true
Layout.alignment : Qt.AlignCenter
elide : Text.ElideRight
// font.pointSize: 8
font.bold : false
color : foregroundColor
horizontalAlignment : Text.AlignHCenter
verticalAlignment : Text.AlignVCenter
}
BabeButton
{
id: appendBtn
visible: headerBar && count > 0
anim : true
iconName : "archive-insert"//"media-repeat-track-amarok"
onClicked: appendAll()
}
BabeButton
{
id: menuBtn
iconName: /*"application-menu"*/ "overflow-menu"
onClicked: headerMenu.popup()
}
id: appendBtn
visible: headerBarVisible && count > 0
anim : true
iconName : "archive-insert"//"media-repeat-track-amarok"
onClicked: appendAll()
},
BabeButton
{
id: menuBtn
iconName: /*"application-menu"*/ "overflow-menu"
onClicked: headerMenu.popup()
}
}
]
PlaylistDialog
{
......@@ -151,8 +89,8 @@ BabeList
number : trackNumberVisible ? true : false
quickPlay: quickPlayVisible
coverArt : coverArtVisible
trackDurationVisible : list.trackDuration
trackRatingVisible : list.trackRating
trackDurationVisible : trackDuration
trackRatingVisible : trackRating
menuItem: menuItemVisible
......@@ -167,19 +105,19 @@ BabeList
{
currentIndex = index
if(root.isMobile)
list.rowClicked(index)
rowClicked(index)
}
onDoubleClicked:
{
if(!root.isMobile)
list.rowClicked(index)
rowClicked(index)
}
onPlay: list.quickPlayTrack(index)
onPlay: quickPlayTrack(index)
onArtworkCoverDoubleClicked: list.artworkDoubleClicked(index)
onArtworkCoverDoubleClicked: artworkDoubleClicked(index)
}
}
......@@ -187,19 +125,19 @@ BabeList
function openItemMenu(index)
{
currentIndex = index
contextMenu.rate = bae.getTrackStars(list.model.get(list.currentIndex).url)
contextMenu.babe = list.model.get(list.currentIndex).babe == "1" ? true : false
contextMenu.rate = bae.getTrackStars(model.get(currentIndex).url)
contextMenu.babe = model.get(currentIndex).babe == "1" ? true : false
if(root.isMobile) contextMenu.open()
else
contextMenu.popup()
list.rowPressed(index)
rowPressed(index)
}
function saveList()
{
var trackList = []
for(var i = 0; i < list.model.count; ++i)
trackList.push(list.model.get(i).url)
for(var i = 0; i < model.count; ++i)
trackList.push(model.get(i).url)
playlistDialog.tracks = trackList
playlistDialog.open()
......
......@@ -88,6 +88,8 @@ BabeDialog
if(playlists.length > 0)
for(var i in playlists)
playlistsList.model.append(playlists[i])
newPlaylistField.forceActiveFocus()
}
onAccepted:
......
......@@ -11,6 +11,9 @@ BabePopup
signal accepted(var path)
signal goBack(var path)
property string currentUrl
property string currentName
background: Rectangle
{
anchors.fill: parent
......@@ -19,36 +22,31 @@ BabePopup
radius: 3
}
ColumnLayout
BabeList
{
id: dirList
anchors.fill: parent
property int currentRow : -1
property string currentUrl
property string currentName
RowLayout
{
Layout.margins: contentMargins
width:parent.width
height: toolBarHeight
signal rowClicked(int index)
signal rowPressed(int index)
BabeButton
{
Layout.alignment: Qt.AlignLeft
id: closeBtn
iconName: "window-close"
onClicked: close()
}
onExit: close()
Item
{
Layout.fillWidth: true
headerBarExit: true
headerBarVisible: true
headerBarTitle: ""
}
headerBarLeft: [
BabeButton
{
id: homeBtn
iconName: "gohome"
onClicked: load(bae.homeDir())
}
},
BabeButton
{
......@@ -56,47 +54,51 @@ BabePopup
iconName: "sd"
onClicked: load(bae.sdDir())
}
]
Button
{
Layout.alignment: Qt.AlignRight
onClicked: {accepted(dirList.currentUrl); close()}
text: "Accept"
Material.accent: babeColor
Material.background: backgroundColor
Material.primary: backgroundColor
Material.foreground: foregroundColor
headerBarRight: Button
{
Layout.alignment: Qt.AlignRight
onClicked: {accepted(dirList.currentUrl); close()}
text: "Accept"
}
Material.accent: babeColor
Material.background: backgroundColor
Material.primary: backgroundColor
Material.foreground: foregroundColor
}
FolderPickerList
ListModel { id: listModel }
model: listModel
delegate: BabeDelegate
{
id: dirList
Layout.fillWidth:true
Layout.fillHeight: true
width: parent.width
id: delegate
label : name
Connections
{
target: dirList
onRowClicked:
target: delegate
onClicked:
{
dirList.currentUrl = dirList.model.get(index).url
dirList.currentName = dirList.model.get(index).name
pathClicked(dirList.currentUrl)
currentIndex = index
currentUrl = dirList.model.get(index).url
currentName = dirList.model.get(index).name
pathClicked(currentUrl)
}
}
}
}
function load(folderUrl)
{
dirList.clearTable()
dirList.list.clearTable()
var dirs = bae.getDirs(folderUrl)
for(var path in dirs)
dirList.model.append(dirs[path])
}
}
......@@ -13,6 +13,8 @@ BabeGrid
id: albumsViewGrid
visible: true
property alias list : drawerList.list
signal rowClicked(var track)
signal playAlbum(var tracks)
signal playTrack(var track)
......@@ -81,8 +83,8 @@ BabeGrid
id: drawerList
anchors.fill: parent
trackNumberVisible: true
headerBar: true
headerClose: true
headerBarVisible: true
headerBarExit: true
coverArtVisible: true
quickPlayVisible: true
......@@ -126,16 +128,16 @@ BabeGrid
drawer.close()
}
onHeaderClosed: drawer.close()
onExit: drawer.close()
}
}
onAlbumCoverClicked:
{
drawerList.headerTitle = album
drawerList.headerBarTitle = album
drawer.open()
drawerList.clearTable()
list.clearTable()
var query = Q.GET.albumTracks_.arg(album)
query = query.arg(artist)
......
......@@ -14,6 +14,7 @@ BabeGrid
visible: true
// albumCardVisible: false
// albumCoverRadius: Math.min(albumCoverSize, albumCoverSize)
property alias list : drawerList.list
signal rowClicked(var track)
signal playAlbum(var tracks)
......@@ -83,8 +84,8 @@ BabeGrid
id: drawerList
anchors.fill: parent
trackNumberVisible: true
headerBar: true
headerClose: true
headerBarVisible: true
headerBarExit: true
coverArtVisible: true