forked from lubuwest/Friendiqa
v0.1
This commit is contained in:
parent
8d99b55818
commit
7e37546ae9
108 changed files with 6063 additions and 1450 deletions
|
@ -3,6 +3,7 @@ import QtQuick.Controls 1.2
|
|||
import QtQuick.Controls.Styles 1.4
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
import "qrc:/js/service.js" as Service
|
||||
import "qrc:/qml/contactqml"
|
||||
import "qrc:/qml/genericqml"
|
||||
|
||||
|
@ -20,6 +21,9 @@ Rectangle {
|
|||
var contactDetails = component.createObject(friendstab,{"contact": contact})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
TabView{
|
||||
id:friendsTabView
|
||||
tabPosition: Qt.TopEdge
|
||||
|
@ -63,7 +67,7 @@ Rectangle {
|
|||
id: friendsGridTab
|
||||
function showFriends(contact){
|
||||
try {friendsModel.clear()} catch(e){print(e)};
|
||||
Helperjs.readData(db,"contacts",root.login.username,function(friendsobject){
|
||||
Helperjs.readData(db,"contacts",login.username,function(friendsobject){
|
||||
for (var i=0;i<friendsobject.length;i++){
|
||||
if(Helperjs.getCount(db,login,"contacts","screen_name",friendsobject[i].screen_name)>1){
|
||||
friendsobject[i].screen_name=friendsobject[i].screen_name+"+"+friendsobject[i].cid
|
||||
|
@ -140,13 +144,30 @@ Rectangle {
|
|||
}
|
||||
},"isFriend",0,"screen_name ASC");
|
||||
}
|
||||
BlueButton {
|
||||
id: cleanButton
|
||||
text: "\uf021"
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: mm
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
Service.cleanContacts(root.login,root.db,function(){
|
||||
try {contactsModel.clear()} catch(e){print(e)};
|
||||
Helperjs.readData(db, "contacts",root.login.username,function(contactsobject){
|
||||
for (var j=0;j<contactsobject.length;j++){
|
||||
contactsModel.append({"contact":contactsobject[j]});
|
||||
}
|
||||
},"isFriend",0,"screen_name ASC");
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
GridView {
|
||||
id: contactsView
|
||||
x:mm
|
||||
y:2*mm
|
||||
y:cleanButton.height+2*mm
|
||||
width:contactsGridTab.width-2*mm
|
||||
height:contactsGridTab.height-2*mm
|
||||
height:contactsGridTab.height-cleanButton.height-2*mm
|
||||
clip: true
|
||||
cellHeight: 16*mm
|
||||
cellWidth: 17*mm
|
||||
|
@ -173,16 +194,65 @@ Rectangle {
|
|||
for (var j=0;j<groupsobject.length;j++){
|
||||
groupsModel.append({"group":groupsobject[j]});
|
||||
}})}
|
||||
|
||||
function updateGroup(login,database,group){
|
||||
// update groups
|
||||
//var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
//var groupdata={"gid":group.id,"name":group.name,"user":group.user};
|
||||
//print("Groupdata "+JSON.stringify(group));
|
||||
var api="";
|
||||
if (group.new){api="/api/friendica/group_create.json?name="+group.name}else{api="/api/friendica/group_update.json?gid="+group.id}
|
||||
xhr.url= login.server + api;
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
xhr.clearParams();
|
||||
xhr.setParam("gid",group.id);
|
||||
xhr.setParam("name",group.name);
|
||||
xhr.setParam("user", group.user);
|
||||
xhr.setParam("json",group);
|
||||
xhr.post();
|
||||
// Helperjs.friendicaPostRequest(login,api,groupdata,"POST",rootwindow, function (obj){print("groupcreate "+obj);
|
||||
// var groups=JSON.parse(obj);
|
||||
// db.transaction( function(tx) {
|
||||
// var result = tx.executeSql('DELETE from groups where username="'+login.username+'"'); // clean old groups
|
||||
// for (var i=0;i<groups.length;i++){
|
||||
// var memberarray=[]; for (var user in groups[i].user){memberarray.push(parseInt(groups[i].user[user].cid))}
|
||||
// //print("Members: "+groups[i].user)
|
||||
// var result2 = tx.executeSql('INSERT INTO groups VALUES (?,?,?,?)', [login.username,groups[i].name,groups[i].gid,JSON.stringify(memberarray)])}
|
||||
// callback()
|
||||
// });
|
||||
// })
|
||||
}
|
||||
|
||||
Connections{
|
||||
target:xhr
|
||||
onError:{print(data)}//if (data=="image"){Helperjs.showMessage()}}
|
||||
onSuccess:{print("gruppe "+data);
|
||||
Newsjs.requestGroups(root.login,root.db,root,function(){
|
||||
showGroups(root.login.username)});
|
||||
}
|
||||
}
|
||||
BlueButton {
|
||||
id: updateGroupsButton
|
||||
text: "\uf021"
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: mm
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: mm
|
||||
onClicked: {
|
||||
Newsjs.requestGroups(root.login,root.db,root,function(){
|
||||
showGroups(root.login.username)})}
|
||||
}
|
||||
// BlueButton {
|
||||
// id: newGroupButton
|
||||
// text: "\uf234"
|
||||
// anchors.top: parent.top
|
||||
// anchors.topMargin: mm
|
||||
// anchors.right: updateGroupsButton.left
|
||||
// anchors.rightMargin: mm
|
||||
// onClicked: {
|
||||
// groupsModel.append({"group": {"new":true}});
|
||||
// }
|
||||
// }
|
||||
GridView {
|
||||
id: groupsView
|
||||
x:mm
|
||||
|
@ -196,11 +266,29 @@ Rectangle {
|
|||
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
|
||||
}
|
||||
model: groupsModel
|
||||
delegate: GroupComponent { }
|
||||
delegate: GroupComponent {}
|
||||
//footer:groupFooter
|
||||
}
|
||||
ListModel{
|
||||
id: groupsModel
|
||||
}
|
||||
// Component{
|
||||
// id: groupFooter
|
||||
// Image{
|
||||
// id: footerImage
|
||||
// width: 15*mm
|
||||
// height: 15*mm
|
||||
// fillMode: Image.PreserveAspectFit
|
||||
// source:"qrc:/images/addImage.png"
|
||||
// MouseArea{
|
||||
// anchors.fill: parent
|
||||
// onClicked:{
|
||||
// print("new group")
|
||||
// var component = Qt.createComponent("qrc:/qml/contactqml/GroupComponent.qml");
|
||||
// var imagedialog = component.createObject(groupsView,{"group": []});}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Component.onCompleted: {
|
||||
friendsTabView.groupsSignal.connect(showGroups);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue