Version 0.002 with working Favorite Combobox

This commit is contained in:
LubuWest 2016-11-14 13:28:23 +01:00
commit 571c9046d0
42 changed files with 1948 additions and 814 deletions

View file

@ -24,13 +24,13 @@ function requestList(login,database,rootwindow,callback) {
function dataRequest(login,photoID,database,rootwindow) {
// check if image exist and call download function
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photoID, rootwindow, function (obj){
try{ if(obj==""){currentImageNo=currentImageNo+1}else{
var image = JSON.parse(obj);
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photoID, rootwindow, function (image){
try{ if(image==""){currentImageNo=currentImageNo+1}else{
var obj = JSON.parse(image);
print('storeData() for ' + JSON.stringify(obj));
try{sprite.destroy();}catch(e){}
if (obj["link"]["0"]){var source=obj["link"]["0"]} else {var source=obj["link"]["4"]}//source for profile picture or original size
print("Source"+obj["link"]["0"]+source)
// try{sprite.destroy();}catch(e){}
// if (obj["link"]["0"]){var source=obj["link"]["0"]} else {var source=obj["link"]["4"]}//source for profile picture or original size
// print("Source"+source);
obj["source"]=source;
var filename=obj.filename;
if (filename==""){// check if file as any filename
@ -45,7 +45,7 @@ function dataRequest(login,photoID,database,rootwindow) {
}
print("obj.Filename: "+obj["filename"]+" filename: "+filename)
}
saveImage(obj,login.imagestore,function(obj,sprite){
saveImage(obj,login.imagestore+'albums/'+obj.album,function(obj,sprite){
//sprite.destroy(500);
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) {
@ -53,9 +53,9 @@ function dataRequest(login,photoID,database,rootwindow) {
var result = tx.executeSql('SELECT * from imageData where id = "'+obj["id"]+'"');
if(result.rows.length === 1) {// use update
print(obj["id"] +' exists, update it')
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+obj.id+'", created="'+obj.created+'", edited="'+obj.edited+'", profile="'+obj.profile+'", link="'+obj.source+'", filename="'+obj.filename+'",title="'+obj.title+'", desc="'+obj.desc+'", type="'+obj.type+'", width="'+obj.width+'", height="'+obj.height+'", album="'+obj.album+'", location="file://'+login.imagestore+'" where id="'+obj["id"]+'"');
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+obj.id+'", created="'+obj.created+'", edited="'+obj.edited+'", profile="'+obj.profile+'", link="'+obj["link"]["4"]+'", filename="'+obj.filename+'",title="'+obj.title+'", desc="'+obj.desc+'", type="'+obj.type+'", width="'+obj.width+'", height="'+obj.height+'", album="'+obj.album+'", location="file://'+login.imagestore+'albums/'+obj.album+'/" where id="'+obj["id"]+'"');
} else {// use insert print('... does not exists, create it')
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,obj.id,obj.created,obj.edited, obj.title, obj.desc, obj.album, obj.filename, obj.type, obj.height, obj.width,obj. profile,obj.source,'file://'+login.imagestore]);
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,obj.id,obj.created,obj.edited, obj.title, obj.desc, obj.album, obj.filename, obj.type, obj.height, obj.width,obj. profile,obj["link"]["4"],'file://'+login.imagestore+'albums/'+obj.album+"/"]);
print("Inserted");}
})})}}
catch (e){print("Data retrieval failure! "+ e+obj);}
@ -63,18 +63,17 @@ function dataRequest(login,photoID,database,rootwindow) {
function saveImage(obj,storagedirectory,callback) {
// create image component from base64 code and save it
print("Storing "+storagedirectory+obj.filename+obj.width+"x"+obj.height);
print("Storing "+storagedirectory+"/"+obj.filename+obj.width+"x"+obj.height);
var maxSize=Math.max(fotostab.width,fotostab.height);
var helpwidth=(obj.width<maxSize)?obj.width:maxSize;
var helpheight=(obj.height<maxSize)?obj.height:maxSize;
if (obj.width>obj.height){ //landscape
helpheight=helpwidth*obj.height/obj.width
} else { //portrait
helpwidth=helpheight*obj.width/obj.height
}
var component=Qt.createComponent("qrc:/qml/PhotoPlaceholder.qml");
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj.source,"downloadtype":"picture"});
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+"/"+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj["link"]["4"],"downloadtype":"picture"});
callback(obj,sprite)
}
@ -141,8 +140,8 @@ function initDatabase(database) { // initialize the database object
print('... create table')
tx.executeSql('CREATE TABLE IF NOT EXISTS imageData(username TEXT,id INT, created TEXT,edited TEXT, title TEXT, desc TEXT, album TEXT,filename TEXT, type TEXT, height INT, width INT, profile INT, link TEXT,location TEXT)');
tx.executeSql('CREATE TABLE IF NOT EXISTS config(server TEXT, username TEXT, password TEXT, imagestore TEXT, maxnews INT, timerInterval INT, newsViewType TEXT,isActive INT)');
tx.executeSql('CREATE TABLE IF NOT EXISTS news(username TEXT, messagetype INT, text TEXT, created_at INT, in_reply_to_status_id INT, source TEXT, status_id INT, in_reply_to_user_id INT, geo TEXT,favorited TEXT, uid INT, statusnet_html TEXT, statusnet_conversation_id TEXT,like TEXT, dislike TEXT, attendyes TEXT,attendno TEXT, attendmaybe TEXT)');
tx.executeSql('CREATE TABLE IF NOT EXISTS contacts(username TEXT, id INT, name TEXT, screen_name TEXT, location TEXT,description TEXT, profile_image BLOB, url TEXT, protected TEXT, followers_count INT, friends_count INT, created_at TEXT, favourites_count TEXT, utc_offset TEXT, time_zone TEXT, statuses_count INT, following TEXT, verified TEXT, statusnet_blocking TEXT, notifications TEXT, statusnet_profile_url TEXT, cid INT, network TEXT, isFriend INT)');
tx.executeSql('CREATE TABLE IF NOT EXISTS news(username TEXT, messagetype INT, text TEXT, created_at INT, in_reply_to_status_id INT, source TEXT, status_id INT, in_reply_to_user_id INT, geo TEXT,favorited TEXT, uid INT, statusnet_html TEXT, statusnet_conversation_id TEXT,friendica_activities TEXT, friendica_activities_self TEXT)');
tx.executeSql('CREATE TABLE IF NOT EXISTS contacts(username TEXT, id INT, name TEXT, screen_name TEXT, location TEXT,profile_image_url TEXT, description TEXT, profile_image BLOB, url TEXT, protected TEXT, followers_count INT, friends_count INT, created_at INT, favourites_count TEXT, utc_offset TEXT, time_zone TEXT, statuses_count INT, following TEXT, verified TEXT, statusnet_blocking TEXT, notifications TEXT, statusnet_profile_url TEXT, cid INT, network TEXT, isFriend INT)');
tx.executeSql('CREATE TABLE IF NOT EXISTS groups(username TEXT, groupname TEXT, gid INT, members TEXT)');
})}