45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
function showFriends(db) {
|
|
Service.readActiveConfig(db,function(login){
|
|
Service.requestFriends(login.url,login.user,login.password,displayFriends);
|
|
});
|
|
}
|
|
function displayFriends(obj){
|
|
for (var i=0; i<obj.length; i++){
|
|
print(obj[i]);
|
|
if (obj[i]) {friendsModel.append({"friendName": obj[i]});
|
|
};
|
|
|
|
}}
|
|
|
|
function ensureVisibility(c,f)
|
|
{
|
|
if (f.contentX >= c.x)
|
|
f.contentX = c.x;
|
|
else if (f.contentX+f.width <= c.x+c.width)
|
|
f.contentX = c.x+c.width-f.width;
|
|
if (f.contentY >= c.y)
|
|
f.contentY = c.y;
|
|
else if (f.contentY+f.height <= c.y+c.height)
|
|
f.contentY = c.y+c.height-f.height;
|
|
}
|
|
|
|
function createObject(objectQml,qmlParameters,parentitem,callback) {
|
|
var component = Qt.createComponent(objectQml);
|
|
if (component.status === Component.Ready || component.status === Component.Error)
|
|
finishCreation(component,qmlParameters,parentitem,callback);
|
|
else
|
|
component.statusChanged.connect(finishCreation(qmlParameters));
|
|
}
|
|
|
|
function finishCreation(component,qmlParameters,parentitem,callback) {
|
|
if (component.status === Component.Ready) {
|
|
var createdObject = component.createObject(parentitem, qmlParameters);
|
|
if (createdObject === null)
|
|
print("Error creating image"); }
|
|
else if (component.status === Component.Error)
|
|
print("Error loading component:"+component.errorString());
|
|
else {print("created")}
|
|
//callback(createdObject);
|
|
}
|
|
|