Hi,
I'm new in qml programming.
I read a Storage.js file code, its code wants to create a table name "playlist" and you can setPlaylist (to set data table) or getPlaylist (to get data table).
As I understand, pl is an item (playlist) which have many small items (song), each song have 4 property: source, title, arstist and time.
It's ok when I make a song item, but I don't know how to make a playlist item which don't have fixed number of songs.
Thanks.
//Storage.js
function setPlaylist(pl){
var db = openDatabase()
var res = ""
db.transaction(
function(tx){
var rs = tx.executeSql("DELETE FROM playlist;")
var count = 0
for(var i=0;i<pl.count;i++){
rs = tx.executeSql("INSERT INTO playlist VALUES (?,?,?,?);"[pl.item(i).source, pl.item(i).title, pl.item(i).artist, pl.item(i).time])
count += rs.rowsAffected
}
if(count>0)
res = "OK"
else res = "Error"
}
)
return res
}
function getPlaylist(pl){
var db = openDatabase()
var res = ""
db.transaction(
function(tx){
var rs = tx.executeSql("SELECT * FROM playlist;")
if(rs.rows.length>0){
for(var i = 0;i<rs.rows.length;i++){
pl.append(
{"source":rs.rows.item(i).source,"title":rs.rows.item(i).title,"artist":rs.rows.item(i).artist,"time":rs.rows.item(i).time,"selected":false}
)
}
}
}
)
return res
}



