This commit is contained in:
pankraz 2017-11-07 21:57:40 +01:00
commit 7e37546ae9
108 changed files with 6063 additions and 1450 deletions

View file

@ -20,7 +20,7 @@ Rectangle {
width: 10*mm
height:10*mm
source:(contact.profile_image!="")? "file://"+contact.profile_image : contact.profile_image_url
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
onStatusChanged: {if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}}
}
Label {

View file

@ -13,8 +13,8 @@ property string connectUrl: (contact.network!=="dfrn")||(contact.isFriend==1)?""
Rectangle {
id: wrapper
width:friendsTabView.width;
height:friendsTabView.height-15*mm
width:root.width-2*mm //friendsTabView.width;
height:root.height-20*mm// friendsTabView.height-15*mm
border.color: "grey"
color:"white"
Image {
@ -30,7 +30,7 @@ Rectangle {
Label {
id: namelabel
x: mm
width:friendsTabView.width-4*mm
width: root.width-6*mm //friendsTabView.width-4*mm
height: 3*mm
text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"
elide:Text.ElideRight
@ -50,7 +50,7 @@ Rectangle{
frameVisible: true
id:namelabelflickable
width: root.width-10*mm
height:friendsTabView.height-45*mm
height:root.height-50*mm//friendsTabView.height-45*mm
x: mm
clip:true
Text{
@ -83,6 +83,7 @@ Rectangle{
root.currentIndex=2;
fotostab.active=true;
root.fotoSignal(contact) ;
contactLargeComponent.destroy();
}
}
@ -93,6 +94,7 @@ Rectangle{
root.currentIndex=0;
newstab.active=true;
root.messageSignal(contact.id) ;
contactLargeComponent.destroy();
}
}
@ -104,6 +106,7 @@ Rectangle{
root.currentIndex=0;
newstab.active=true;
root.directmessageSignal(contact.screen_name);
contactLargeComponent.destroy();
}
}
@ -117,6 +120,7 @@ Rectangle{
calendartab.active=true;
calendartab.calendartabstatus="Friend"
root.eventSignal(contact.url);
contactLargeComponent.destroy();
}
}
@ -124,8 +128,7 @@ Rectangle{
id: closeButton
text: "\uf057" //"close"
onClicked:{contactLargeComponent.destroy();
//contactComponent.state="";
friendsTabView.contactSignal}
}
}
}
}

View file

@ -0,0 +1,101 @@
// List of people
import QtQuick 2.0
import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml/genericqml"
Rectangle {
id:contactlistRectangle
property var contacts:[]
property var possibleUsers: []
//y:8*mm
color: "white"
border.color: "light grey"
radius:0.5*mm
width:groupListView.width
height:groupListView.height
ListView {
id: contactView
x:mm
y:6*mm
width: contactlistRectangle.width-2*mm
height: contactlistRectangle.height-10*mm
clip: true
spacing: 0
model: contactModel
delegate: listContact
}
ListModel{id: contactModel}
Component { id:listContact
Rectangle{
border.color: "#EEEEEE"
border.width: 1
radius:0.5*mm
width:contactView.width
height:6*mm
Image {
id: contactImage
x:1
y:1
width: 5*mm
height:5*mm
source:(contact.profile_image!="")? "file://"+contact.profile_image : contact.profile_image_url
onStatusChanged: if (contactImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
}
Text{
font.pixelSize: 3*mm
anchors.left: contactImage.right
anchors.margins: 1*mm
text:Qt.atob(contact.name)
}
Text {
id:selected
anchors.right:parent.right
visible: contactlist.indexOf(contact)>-1
z:4
text: "\u2713"
width: 5*mm
anchors.top: parent.top
color: "green"
font.pixelSize: 3*mm
}
MouseArea{
anchors.fill: parent
onClicked:{
if(selected.visible==true){
contacts.splice(Helperjs.inArray(contacts,"id",contact.id),1);
selected.visible=false
}
else{
contacts.push(contact);
selected.visible=true;
}
}
}
}
}
BlueButton {
id: closeButton
anchors.top: parent.top
anchors.topMargin: 1*mm
anchors.right: parent.right
anchors.rightMargin: 1*mm
color:"white"
text: "\uf057"
onClicked: {
groupModelAppend(contacts,function(){
contactlistRectangle.destroy()
});
}
}
Component.onCompleted: {
for (var user in possibleUsers){
contactModel.append({"contact":possibleUsers[user]})
}
}
}

View file

@ -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);
}

View file

@ -1,128 +1,215 @@
import QtQuick 2.0
import "qrc:/js/helper.js" as Helperjs
import "qrc:/js/news.js" as Newsjs
import "qrc:/qml/genericqml"
Item {
id: groupComponent
Rectangle {
id: wrapper
width: 16*mm
height: 15*mm
border.color: "grey"
color:"white"
Item {
id: groupComponent
property var groupmembers:[]
//property bool newGroup: false
function groupModelAppend(groupcontacts,callback){
for (var n in groupcontacts){
groupModel.append({"groupmember":groupcontacts[n]});}
callback()
}
Image {
id: photoImage
x:1
y:1
width: 10*mm
height:10*mm
source:"qrc:/images/defaultcontact.jpg"
}
Text {
id: namelabel
x: 1
width: wrapper.width-2
height: 3*mm
text: group.groupname
color: "#303030"
font.pixelSize: 3*mm
anchors.top: photoImage.bottom
}
BlueButton{
id:infobutton
width: 5*mm
height: 5*mm
color:"transparent"
text:"?"
anchors.left: photoImage.right
anchors.leftMargin: 3
anchors.topMargin: 3
anchors.top: parent.top
onClicked:{
Helperjs.readField("members",root.db,"groups",root.login.username,function(groups){
try {groupModel.clear()}catch (e){print(e)}
var groupmembers=JSON.parse(groups);
for (var user in groupmembers){
Helperjs.readData(root.db,"contacts",root.login.username,function(userdata){
if (userdata[0]){groupModel.append({"groupmember":userdata[0]})}
},"id",groupmembers[user])}
},"groupname",group.groupname);
groupComponent.state="large"}
}
Rectangle {
id: wrapper
width: 16*mm
height: 15*mm
border.color: "grey"
color:"white"
Image {
id: photoImage
x:1
y:1
width: 10*mm
height:10*mm
source:"qrc:/images/defaultcontact.jpg"
}
Rectangle{
id:namelabelRect
x: 1
width: wrapper.width-2
height: 3.5*mm
anchors.top: photoImage.bottom
border.color: "light grey"
TextInput {
id: namelabel
anchors.fill: parent
readOnly: true
text: group.new?"":group.groupname
color: "#303030"
font.pixelSize: 3*mm
Rectangle{
}
}
BlueButton{
id:infobutton
width: 5*mm
height: 5*mm
color:"transparent"
text:"?"
anchors.left: photoImage.right
anchors.leftMargin: 3
anchors.topMargin: 3
anchors.top: parent.top
onClicked:{
//if(group.new){
Helperjs.readField("members",root.db,"groups",root.login.username,function(groups){
try {groupModel.clear()}catch (e){print(e)}
groupmembers=JSON.parse(groups);
for (var user in groupmembers){
Helperjs.readData(root.db,"contacts",root.login.username,function(userdata){
if (userdata[0]){groupModel.append({"groupmember":userdata[0]})}
},"id",groupmembers[user])
} //catch(e){}
},"groupname",group.groupname);
//}
groupComponent.state="large"
}
}
Rectangle{
id: detailsrectangle
anchors.top: namelabel.bottom
anchors.top: namelabelRect.bottom
anchors.topMargin: 2*mm
opacity: 0
Component { id:groupMember
Rectangle{
border.color: "#EEEEEE"
border.width: 1
width:parent.width
height:6*mm
Image {
id: memberImage
x:1
y:1
width: 5*mm
height:5*mm
source:(groupmember.isFriend==1)? "file://"+groupmember.profile_image :groupmember.profile_image_url
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
}
Text{
font.pixelSize: 3*mm
anchors.left: memberImage.right
anchors.margins: 1*mm
text:Qt.atob(groupmember.name)
}
MouseArea{
anchors.fill: parent
onClicked:{
root.currentIndex=1;
friendstab.active=true;
root.contactdetailsSignal(groupmember)
Component {
id:groupMember
Rectangle{
width:parent.width
height:6*mm
Rectangle{id:memberrectangle
border.color: "#EEEEEE"
border.width: 1
width:parent.width-12*mm
height:6*mm
Image {
id: memberImage
x:1
y:1
width: 5*mm
height:5*mm
source:(groupmember.isFriend==1)? "file://"+groupmember.profile_image :groupmember.profile_image_url
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
}
Text{
font.pixelSize: 3*mm
anchors.left: memberImage.right
anchors.margins: 1*mm
width:parent.width-1
text:Qt.atob(groupmember.name)
}
MouseArea{
anchors.fill: parent
onClicked:{
root.currentIndex=1;
friendstab.active=true;
root.contactdetailsSignal(groupmember)
}
}
// BlueButton{
// anchors.left: memberrectangle.right
// anchors.margins: 1*mm
// text: "\uf056"
// onClicked:{
// groupModel.remove(index)
// }
// }
}
}
}
}}
ListView{
id: groupListView
x:1
//anchors.top: parent.top
width: root.width-10*mm
height:groupsView.height -29*mm
clip: true
spacing: 2
model: groupModel
delegate: groupMember
}
ListView{
id: groupListView
x:1
//anchors.top: parent.top
width: root.width-10*mm
height:groupsView.height -31*mm
clip: true
spacing: 2
model: groupModel
delegate: groupMember
}
ListModel{id: groupModel}
ListModel{id: groupModel}
BlueButton{
id: closeButton
anchors.top: groupListView.bottom
anchors.topMargin: mm
text: "\uf057"
onClicked:{groupComponent.state=""}
Row{
anchors.top: groupListView.bottom
anchors.topMargin: mm
spacing: mm
BlueButton{
id: closeButton
text: "\uf057"
onClicked:{groupComponent.state="";
if (group.new){groupsModel.remove(index)}
}
}
// BlueButton{
// id: addMembers
// text:"\uf234"
// onClicked: {
// Newsjs.listFriends(root.login,root.db,function(userdata){
// var newlistcontacts=[];
// for (var n in userdata){
// if (groupmembers.indexOf(userdata[n].id)==-1){
// newlistcontacts.push(userdata[n])
// }
// }
// var component = Qt.createComponent("qrc:/qml/contactqml/Contactlist.qml");
// var contactlistobject = component.createObject(groupListView,{"possibleUsers":newlistcontacts});
// })
// }
// }
// BlueButton{
// id: updateButton
// text: "\uf0ee"
// onClicked:{
// var groupobject={};
// var groupmembers=[];
// for (var i=0;i<groupModel.count;i++){groupmembers.push(groupModel.get(i).groupmember)}
// try{ groupobject.id=group.gid} catch(e){};
// try{ groupobject.new=group.new} catch(e){};
// if (namelabel.text==""){
// Helperjs.showMessage(qsTr("Error"),qsTr("No name given"),root)}
// else {
// groupobject.name=namelabel.text;
// groupobject.user=groupmembers;
// updateGroup(login,db,groupobject)
// groupComponent.state="";
// }
// }
// }
// BlueButton{
// id: deleteButton
// text: "\uf056"
// onClicked:{
// Newsjs.deleteGroup(root.login,root.db,root,group,function(){
// groupComponent.state="";
// groupsModel.remove(index)})
// }
// }
}
}
Component.onCompleted:{if(group.new){groupComponent.state="large"}}
}
}
states: [
State {
states: [
State {
name: "large"
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:groupsView.width}
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:groupsView.width; readOnly:false}
PropertyChanges { target: namelabelRect; height: 4.5*mm}
PropertyChanges { target: groupComponent; z: 2 }
PropertyChanges { target: wrapper; width:groupsView.width;height:groupsView.height -2*mm-1}
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
PropertyChanges { target:groupComponent.GridView.view ;contentY:groupComponent.y;contentX:groupComponent.x;interactive:false}
PropertyChanges { target: detailsrectangle; opacity:1 }
}
]
]
}