Commit 7e87b82b authored by Camilo Higuita's avatar Camilo Higuita

retrieve data from collectionDB

parent ea57aeaf
......@@ -537,6 +537,21 @@ DB_LIST CollectionDB::getDBData(const QStringList &urls)
return mapList;
}
QVariantList CollectionDB::get(const QString &queryTxt)
{
QVariantList res;
for(auto data : this->getDBData(queryTxt))
{
QVariantMap map;
for(auto key : data.keys())
map[BAE::KEYMAP[key]] = data[key];
res<<map;
}
return res;
}
DB_LIST CollectionDB::getDBData(const QString &queryTxt)
{
DB_LIST mapList;
......
......@@ -64,7 +64,8 @@ public:
bool trackPlaylist(const QString &url, const QString &playlist);
BAE::DB_LIST getDBData(const QStringList &urls);
BAE::DB_LIST getDBData(const QString &queryTxt);
Q_INVOKABLE QVariantList get(const QString &queryTxt);
Q_INVOKABLE BAE::DB_LIST getDBData(const QString &queryTxt);
BAE::DB_LIST getAlbumTracks(const QString &album, const QString &artist, const BAE::KEY &orderBy = BAE::KEY::TRACK, const BAE::W &order = BAE::W::ASC);
BAE::DB_LIST getArtistTracks(const QString &artist, const BAE::KEY &orderBy = BAE::KEY::ALBUM, const BAE::W &order = BAE::W::ASC);
......@@ -84,10 +85,10 @@ public:
int getTrackBabe(const QString &path);
QString getArtistArt(const QString &artist);
QString getArtistWiki(const QString &artist);
// QStringList getArtistTags(const QString &artist);
// QStringList getArtistTags(const QString &artist);
QString getAlbumArt(const QString &album, const QString &artist);
QString getAlbumWiki(const QString &album, const QString &artist);
// QStringList getAlbumTags(const QString &album, const QString &artist);
// QStringList getAlbumTags(const QString &album, const QString &artist);
QStringList getArtistAlbums(const QString &artist);
QStringList getPlaylists();
......
......@@ -22,10 +22,6 @@ int main(int argc, char *argv[])
context->setContextProperty("con", &con);
context->setContextProperty("set", &settings);
qmlRegisterUncreatableMetaObject(BAE::staticMetaObject,
"com.babe.bae", 1, 0, "BAE",
"Cannot create namespace WarningLevel in QML");
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
......
This diff is collapsed.
......@@ -35,7 +35,7 @@ Item
fillMode: Image.PreserveAspectFit
source: icon
source: artwork || "qrc:/assets/cover.png"
layer.enabled: true
layer.effect: OpacityMask
{
......
......@@ -6,7 +6,7 @@ Pane
property int albumSize : 150
property int albumSpacing: 20
property int borderRadius : 4
property alias gridModel: gridModel
signal albumCoverClicked(string album, string artist)
width: 500
......@@ -14,14 +14,7 @@ Pane
ListModel
{
id: appModel
ListElement { album: "Continium"; artist:"John Mayer"; icon: "qrc:/assets/cover.png" }
ListElement { album: "Channel Orange"; artist: "Frank Ocean"; icon: "qrc:/assets/cover.png" }
ListElement { album: "Coloring Book"; artist: "Chance the Rapper"; icon: "qrc:/assets/cover.png" }
ListElement { album: "The Lonely Hour"; artist: "Sam Smith"; icon: "qrc:/assets/cover.png" }
ListElement { artist: "Sam Smith"; icon: "qrc:/assets/cover.png" }
ListElement { album: "Lil Empire"; artist: "Petite Meller"; icon: "qrc:/assets/cover.png" }
ListElement { album: "Lost Generation"; artist: "Unkown";icon: "qrc:/assets/cover.png" }
id: gridModel
}
GridView
......@@ -38,7 +31,7 @@ Pane
cellWidth: albumSize+albumSpacing
cellHeight: parseInt(albumSize+(albumSize*0.6))
focus: true
model: appModel
model: gridModel
highlight: Rectangle
{
id: highlight
......@@ -80,5 +73,6 @@ Pane
}
}
}
}
......@@ -66,89 +66,7 @@ ListView
}
}
ListModel
{
id: listModel
ListElement
{
trackNumber: "2"
title: "Slow Dancing In A Burning Room"
artist: "Jhon Mayer"
album: "Continium"
date: "555 3264"
genre: "555 3264"
rate: "555 3264"
babe: "555 3264"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "3"
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "4"
title: "America"
artist: "Petite Miller"
}
}
ListModel { id: listModel }
model: listModel
......@@ -168,7 +86,6 @@ ListView
}
onClicked:
{
console.log(list.model.get(index).title)
list.rowClicked(index)
}
}
......
......@@ -13,6 +13,9 @@ BabeGrid
albumSize: 150
borderRadius: 20
property string drawerAlbum
property string drawerArtist
Drawer
{
id: drawer
......@@ -41,6 +44,7 @@ BabeGrid
id: albumTitle
width: parent.width - closeBtn.width
height: parent.height
text: drawerAlbum
elide: Text.ElideRight
font.pointSize: 12
font.bold: true
......@@ -76,17 +80,37 @@ BabeGrid
id: drawerList
width: parent.width
height: parent.height - titleBar.height
}
}
}
onAlbumCoverClicked:
{
albumTitle.text = album
drawerAlbum = album
drawerArtist = artist
drawer.open()
console.log("haha: ", album, artist)
var query = "select * from tracks where album = \""+albumsView.drawerAlbum+"\" and artist = \""+albumsView.drawerArtist+"\""
console.log(query)
var map = con.get(query)
for(var i in map)
{
drawerList.model.append(map[i])
console.log(map[i].title)
}
}
Component.onCompleted:
{
var map = con.get("select * from albums")
for(var i in map)
{
gridModel.append(map[i])
}
}
}
......@@ -21,7 +21,7 @@ Pane
folder: StandardPaths.standardLocations(StandardPaths.MusicLocation)[0]
onAccepted:
{
listModel.append({source: folder.toString()})
listModel.append({url: folder.toString()})
set.collectionPathChanged(folder.toString())
}
}
......@@ -69,7 +69,7 @@ Pane
{
id: sourceUrl
width: parent.width
text: source
text: url
elide: Text.ElideRight
Layout.fillWidth: true
font.pointSize: 10
......@@ -78,6 +78,14 @@ Pane
}
Component.onCompleted:
{
var map = con.get("select url from sources")
for(var i in map)
{
model.append(map[i])
}
}
}
Row
......
......@@ -5,6 +5,14 @@ import "../view_models"
BabeTable
{
id: tracksView
Component.onCompleted:
{
var map = con.get("select * from tracks")
for(var i in map)
{
tracksView.model.append(map[i])
}
}
}
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