127 lines
3.7 KiB
QML
127 lines
3.7 KiB
QML
import QtQuick 2.0
|
|
import QtQuick.Dialogs 1.2
|
|
import QtQuick.Controls 1.4
|
|
import QtQml.Models 2.1
|
|
import "qrc:/js/service.js" as Service
|
|
import "qrc:/js/helper.js" as Helperjs
|
|
|
|
Rectangle{
|
|
id:permissionDialog
|
|
width: 80*mm
|
|
height:root.height/3
|
|
|
|
Text{
|
|
x:0.5*mm
|
|
y:0.5*mm
|
|
text: "Contacts"
|
|
}
|
|
ListView {
|
|
id: contactView
|
|
x:0.5*mm
|
|
y:5.5*mm
|
|
width: 39*mm
|
|
height:permissionDialog.height-14*mm
|
|
clip: true
|
|
spacing: 0
|
|
model: contactModel
|
|
delegate: contactItem
|
|
}
|
|
|
|
ListModel{id: contactModel}
|
|
Component{
|
|
id:contactItem
|
|
|
|
Rectangle{
|
|
id:contactitemRect
|
|
width:contactView.width
|
|
height: 5*mm
|
|
property string contactstatus:""
|
|
color: "light blue"
|
|
border.color:"grey"
|
|
Text{
|
|
color:"grey"
|
|
text:contact.screen_name
|
|
}
|
|
onContactstatusChanged:
|
|
{ if(contactstatus=="positive"){contactsitemRect.color="green"} else if (contactstatus=="negative"){contactsitemRect.color= "red"} else{contactsitemRect.color= "white"}}
|
|
MouseArea{
|
|
anchors.fill: parent}
|
|
}
|
|
}
|
|
Text{
|
|
x:20*mm
|
|
y:0.5*mm
|
|
text: "Groups"
|
|
}
|
|
ListView {
|
|
id: groupView
|
|
x:20*mm
|
|
y:5.5*mm
|
|
width: 19*mm
|
|
height:permissionDialog-8*mm
|
|
clip: true
|
|
spacing: 0
|
|
model: groupModel
|
|
delegate: groupItem
|
|
}
|
|
|
|
ListModel{id: groupModel}
|
|
Component{
|
|
id:groupItem
|
|
|
|
Rectangle{
|
|
id:groupitemRect
|
|
width:groupView.width
|
|
height: 5*mm
|
|
property string groupstatus:""
|
|
color: "white"
|
|
border.color:"grey"
|
|
Text{
|
|
color:"grey"
|
|
text:group.groupname
|
|
}
|
|
onGroupstatusChanged:
|
|
{ if(groupstatus=="positive"){groupitemRect.color="green"} else if (groupstatus=="negative"){groupitemRect.color= "red"} else{groupitemRect.color= "white"}}
|
|
MouseArea{
|
|
anchors.fill: parent
|
|
onClicked:{
|
|
if(groupModel.get(index).groupstatus=="neutral"){
|
|
groupModel.setProperty(index,"groupstatus","positive")}
|
|
else if (groupModel.get(index).groupstatus=="positive"){
|
|
groupModel.setProperty(index,"groupstatus","negative")}
|
|
else{groupModel.setProperty(index,"groupstatus","neutral")}
|
|
}}
|
|
}
|
|
}
|
|
|
|
Button{
|
|
anchors.horizontalCenter: parent.hoizontalCenter
|
|
anchors.bottom: parent.bottom
|
|
anchors.bottomMargin:1
|
|
text:qsTr("Done")
|
|
onClicked:{var group_allow=[];
|
|
for (var i=0;i<groupModel.count;i++)
|
|
{if (groupModel.get(i).groupstatus=="positive"){
|
|
group_allow.append(groupModel.get(i).groupname)
|
|
}
|
|
}
|
|
print("groups"+JSON.stringify(group_allow))
|
|
permissionDialog.destroy();
|
|
}
|
|
}
|
|
|
|
Component.onCompleted:{
|
|
print("permissiondialog completed");
|
|
Helperjs.readData(db,"contacts",login.username,function(contacts){
|
|
for (var name in contacts){
|
|
print("contact: "+JSON.stringify(contacts[name]));
|
|
contactModel.append({"contact":contacts[name]})
|
|
}},"isFriend",1);
|
|
|
|
Helperjs.readData(db,"groups",login.username,function(owngroups){
|
|
for (var number in owngroups){
|
|
groupModel.append({"group":owngroup[number]})
|
|
}});
|
|
}
|
|
}
|