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

@ -1,74 +0,0 @@
import QtQuick 2.0
import Qt.labs.folderlistmodel 2.1
import "qrc:/js/service.js" as Service
import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml/genericqml"
Rectangle{
id:attachmentDialog
z:2
border.color: "grey"
width: parent.width-4*mm
height:parent.height-12*mm
x:2*mm
y:10*mm
property var parsedAttachments: JSON.parse(attachedobjects)
Text{
x:0.5*mm
y:0.5*mm
width: imageDialog-8*mm
elide:Text.ElideRight
text: "Attachments:"
}
BlueButton{
id:closeButton
anchors.top: parent.top
anchors.topMargin: 1*mm
anchors.right: parent.right
anchors.rightMargin: 1*mm
text: "\uf057"
onClicked:{attachmentDialog.destroy()}
}
ListView {
id: attachmentView
x:0.5*mm
y:5.5*mm
width: attachmentDialog.width-2*mm
height: attachmentDialog.height-14*mm
clip: true
spacing:0
model: attachmentModel
delegate: attachmentItem
}
ListModel{id: attachmentModel}
Component { id:attachmentItem
Rectangle{
border.color: "#EEEEEE"
border.width: 1
width:parent.width
height:6*mm
Text{
font.pixelSize: 3*mm
x: mm
text:attachment.name
}
MouseArea{
anchors.fill: parent
onClicked:{
Qt.openUrlExternally(attachment.url)
}
}
}}
}
Component.onCompleted: {
for (var a in parsedAttachments){
attachmentModel.append({"attachment":parsedAttachments[a]})
}
}
}

View file

@ -1,11 +1,12 @@
// ConversationView with button
import QtQuick 2.0
import QtQuick.Controls 1.2
import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml/genericqml"
Rectangle {
id:conversationList
property var news
//property var news
y:1
z:2
color: "white"
@ -15,10 +16,7 @@ Rectangle {
Connections{
target:newstab
onConversationChanged:{
if(newstab.conversation.length==0){
newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
conversationList.destroy(); conversationsymbol.color="grey"
}
}
}
@ -34,6 +32,32 @@ Rectangle {
model: conversationModel
delegate: Newsitem{}
}
BusyIndicator{
id: conversationBusy
anchors.horizontalCenter: conversationView.horizontalCenter
anchors.top:conversationView.top
anchors.topMargin: 2*mm
width:10*mm
height: 10*mm
running: true
}
Connections{
target:newstab
onConversationChanged:{
if(newsitem.itemindex==newsStack.conversationIndex){
if(newstab.conversation.length==0){
newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
conversationList.destroy(); conversationsymbol.color="grey"
} else { conversationBusy.running=false;
conversationModel.clear();
var currentTime= new Date();
var msg = {'currentTime': currentTime, 'model': conversationModel,'news':newstab.conversation};
conversationWorker.sendMessage(msg)
conversationsymbol.color="grey"}
}
}
}
Component { id:footerReply
Rectangle{
@ -117,9 +141,9 @@ Rectangle {
}
}
Component.onCompleted: {
var currentTime= new Date();
var msg = {'currentTime': currentTime, 'model': conversationModel,'news':news};
conversationWorker.sendMessage(msg)
}
// Component.onCompleted: {
// if (news){var currentTime= new Date();
// var msg = {'currentTime': currentTime, 'model': conversationModel,'news':news};
// conversationWorker.sendMessage(msg)}
// }
}

View file

@ -1,4 +1,4 @@
// List if people from Friendica Activities
// List of people from Friendica Activities
import QtQuick 2.0
import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml/genericqml"
@ -51,11 +51,7 @@ Rectangle {
MouseArea{
anchors.fill: parent
onClicked:{
try {root.currentIndex=1;
friendstab.active=true;
root.contactdetailsSignal(contact)
} catch(e) {Helperjs.showMessage("Error",e,root)}}
onClicked:{showContact(contact)}
}
}}

View file

@ -1,121 +0,0 @@
import QtQuick 2.0
import QtQuick.Controls 1.2
import Qt.labs.folderlistmodel 2.1
import "qrc:/js/service.js" as Service
import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml/genericqml"
Rectangle{
id:imageDialog
z:2
border.color: "grey"
width: parent.width-4*mm
height:parent.height-12*mm
x:2*mm
y:10*mm
property string directory: ""
Text{
id:directoryText
x:0.5*mm
y:0.5*mm
width: imageDialog.width-15*mm
height:contentHeight
wrapMode: Text.Wrap
text: directory
}
BlueButton{
id:closeButton
anchors.top: parent.top
anchors.topMargin: 1*mm
anchors.right: parent.right
anchors.rightMargin: 1*mm
text: "\uf057"
onClicked:{imageDialog.destroy()}
}
ListView {
id: imageView
x:0.5*mm
y:directoryText.height+mm
width: imageDialog.width-2*mm
height: imageDialog.height-directoryText.height-4*mm
clip: true
model: imageModel
delegate: imageItem
}
FolderListModel{
id: imageModel
nameFilters: ["*.png", "*.jpg",".jpeg","*.JPG","*.gif"]
sortField: FolderListModel.Time
sortReversed:false
showDotAndDotDot: true
showDirs: true
showDirsFirst: true
folder:directory
}
BusyIndicator{
id: imageBusy
anchors.horizontalCenter: imageView.horizontalCenter
anchors.top:imageView.top
anchors.topMargin: 2*mm
width:10*mm
height: 10*mm
running:false
}
Component{
id:imageItem
Item{
width:imageView.width
height:folderImage.height+2*mm
Rectangle{
id:imagetextRectangle
color:"black"
x:mm
z:3
opacity: fileIsDir?0:0.5
width:imagetext.contentWidth
height: imagetext.contentHeight
anchors.bottom: folderImage.bottom
}
Text {
id:imagetext
x:fileIsDir?11*mm:mm
z:4
text: fileName
width: fileIsDir?parent.width - 12*mm :imageView.width-mm
anchors.bottom: folderImage.bottom
color: fileIsDir?"black":"white"
font.pixelSize: 3*mm
wrapMode:Text.Wrap
}
Image{id:folderImage
width: fileIsDir?10*mm: imageView.width-mm
fillMode:Image.PreserveAspectFit
source:fileIsDir?"qrc:/images/folder-blue.png":fileURL
}
MouseArea{
anchors.fill: parent
onClicked:{
if (fileName==".."){
imageModel.folder=imageModel.parentFolder;
directory=imageModel.parentFolder
}
else if (fileIsDir){
imageModel.folder=fileURL;
directory=fileURL
}
else{
attachImageURLs.push(fileURL);
attachImage(fileURL);
imageDialog.destroy()
}
}
}
}
}
}

View file

@ -130,7 +130,7 @@ Flickable{
visible: (directmessage==1)?false:true
text: ((contact_allow.length==0)&&(contact_deny.length==0)&&(group_allow.length==0)&&(group_deny.length==0))?"\uf09c":"\uf023"
onClicked: {
var component = Qt.createComponent("qrc:/qml/newsqml/PermissionDialog.qml");
var component = Qt.createComponent("qrc:/qml/genericqml/PermissionDialog.qml");
var permissions = component.createObject(messageColumn);
}}
BlueButton {
@ -143,7 +143,7 @@ Flickable{
}
else{
var defaultDirectory="file://"+osSettings.attachImageDir;
var component = Qt.createComponent("qrc:/qml/newsqml/ImageDialog.qml");
var component = Qt.createComponent("qrc:/qml/genericqml/ImageDialog.qml");
var imagedialog = component.createObject(messageSend,{"directory": defaultDirectory});
}
}
@ -159,7 +159,7 @@ Flickable{
if(Helperjs.getCount(db,login,"contacts","screen_name",contacts[i].screen_name)>1){
contacts[i].screen_name=contacts[i].screen_name+"+"+contacts[i].cid
}
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"';iconSource:'"+contacts[i].profile_image+"'; onTriggered: bodyField.insert(0,' @"+contacts[i].screen_name+"+"+contacts[i].cid+" ')}"
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"';iconSource:'"+contacts[i].profile_image+"'; onTriggered: bodyField.insert(0,' @"+contacts[i].screen_name+" ')}"
}}
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput")

View file

@ -53,7 +53,7 @@ Item {
}
function showConversation(conversationIndex,newsitemobject){
newsBusy.running=true;
//newsBusy.running=true;
root.contactLoadType="conversation";
newsStack.conversationIndex= conversationIndex;
if(newsitemobject.messagetype==0){
@ -65,6 +65,13 @@ Item {
})}
}
function showContact(contact){
var component = Qt.createComponent("qrc:/qml/contactqml/ContactDetailsComponent.qml");
if (component.status== Component.Ready){
var contactDetails = component.createObject(newstab,{"contact": contact})
}
}
function onFriendsMessages(friend){
newstab.newstabstatus="Contact"
Newsjs.newsfromdb(db,root.login.username, function(dbnews){showNews(dbnews)},friend)
@ -75,6 +82,8 @@ Item {
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
}
StackView{
id: newsStack
anchors.fill:parent
@ -100,7 +109,6 @@ Item {
BlueButton {
id: newMessageButton
width:10*mm
text: "\uf040"
onClicked: {
var groups=[];
@ -115,7 +123,6 @@ Item {
}
BlueButton {
id: quitButton
width:10*mm
text: "\uf08b"
onClicked: {Service.cleanNews(root.db,function(){Qt.quit() })}
}
@ -153,29 +160,29 @@ Item {
}
MouseArea{anchors.fill:parent
onClicked:{
var currentTime= new Date();
if(newstab.newstabstatus=="Timeline"){
var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;
var currentTime= new Date();
var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;
print("Lastnews ID "+lastnews_id+Qt.atob(newsModel.get(newsModel.count-1).newsitemobject.statusnet_html))
if(newstab.newstabstatus=="Timeline"){
Newsjs.newsfromdb(root.db,root.login.username, function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
newsWorker.sendMessage(msg);
},false,lastnews_id)}
if(newstab.newstabstatus=="Conversations"){
var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
newsWorker.sendMessage(msg);
},false,lastnews_id)}
if(newstab.newstabstatus=="Conversations"){
Newsjs.chatsfromdb(root.db,root.login.username, function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
newsWorker.sendMessage(msg);
},lastnews_id)}
else if(newstab.newstabstatus=="Contact"){
Newsjs.newsfromdb(root.db,root.login.username, function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
newsWorker.sendMessage(msg);
},newsModel.get(newsModel.count-1).newsitemobject.uid,newsModel.get(newsModel.count-1).newsitemobject.created_at)}
}}
}
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
newsWorker.sendMessage(msg);
},lastnews_id)}
else if(newstab.newstabstatus=="Contact"){
Newsjs.newsfromdb(root.db,root.login.username, function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
newsWorker.sendMessage(msg);
},newsModel.get(newsModel.count-1).newsitemobject.uid,lastnews_id)}
}
}
}
}
ListView {
id: newsView
anchors.fill: parent
@ -187,8 +194,8 @@ Item {
footer: footerComponent
model: newsModel
delegate: Newsitem{}
//onContentYChanged:{if(contentY<-15*mm&&contentY>(-15*mm-1)){print("refreshing");
onDragEnded:{if(contentY<-8*mm){//print("refreshing");
//onContentYChanged:{if(contentY<-8*mm&&contentY>(-8*mm-1)){print("refreshing");
onDragEnded:{if(contentY<-5*mm){//print("refreshing");
newsBusy.running=true;
newstab.newstabstatus=login.newsViewType;
root.contactLoadType="news";

View file

@ -10,21 +10,8 @@ Item {
width: parent.width
height:toprow.height+friendicaActivities.height+controlrow.height+1//Math.max((itemMessage.height+topFlow.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
Connections{
target:newstab
onConversationChanged:{
newsBusy.running=false;
if(index==newsStack.conversationIndex){
if(newstab.conversation.length>0){
var component = Qt.createComponent("qrc:/qml/newsqml/Conversation.qml");
var conversation = component.createObject(friendicaActivities,{"news":newstab.conversation});
}
else{conversationsymbol.color="grey"}
}
}
}
property string attending: ""
property int itemindex: index
onAttendingChanged: {attendLabel.visible=true;
attendLabel.text= qsTr("attending: ")+ qsTr(attending)}
@ -54,13 +41,9 @@ Item {
height: 7*mm
MouseArea{
anchors.fill: parent
onClicked:{
try{root.currentIndex=1;
friendstab.active=true;
root.contactdetailsSignal(newsitemobject.user)} catch (e){Helperjs.showMessage("Error",e,root)}
}
onClicked:{showContact(newsitemobject.user)}
}
onStatusChanged: if (profileImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
onStatusChanged: if (profileImage.status == Image.Error) {print("Image Failed "+"file://"+newsitemobject.user.profile_image);source="qrc:/images/defaultcontact.jpg"}
}
Label {
id:user_name
@ -68,13 +51,12 @@ Item {
width:parent.width
font.pixelSize: 1.5*mm
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
text: Qt.atob(newsitemobject.user.name)//+forumname
text: Qt.atob(newsitemobject.user.name)+forumname
}
}
Column {
id:newscolumn
width: newsitem.width-8*mm
//anchors.left: authorcolumn.right
Flow{
id:topFlow
@ -114,7 +96,13 @@ Item {
text: try {(newsitemobject.newscount-1)+qsTr(" comments") }catch(e){" "}
MouseArea{
anchors.fill:parent
onClicked: {conversationsymbol.color="black";showConversation(index,newsitemobject)}
onClicked: {
conversationsymbol.color="black";
newsView.contentY+=newsitem.height;
var component = Qt.createComponent("qrc:/qml/newsqml/Conversation.qml");
var conversationItem = component.createObject(friendicaActivities,{"news":newsitemobject.chatArray});
showConversation(index,newsitemobject);
}
}
}
}
@ -150,6 +138,7 @@ Item {
spacing:mm
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
text: friendica_activities.likeText
MouseArea{
@ -158,6 +147,7 @@ Item {
}
}
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
text: friendica_activities.dislikeText
MouseArea{
@ -166,6 +156,7 @@ Item {
}
}
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
text: friendica_activities.attendyesText
MouseArea{
@ -173,6 +164,7 @@ Item {
onClicked: { showActivityContacts(newsitemobject.attendyes)}
}}
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
text: friendica_activities.attendnoText
MouseArea{
@ -181,6 +173,7 @@ Item {
}
}
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
text: friendica_activities.attendmaybeText
MouseArea{
@ -190,7 +183,6 @@ Item {
}
Label{
id:attendLabel
//visible: false
color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
@ -203,28 +195,21 @@ Item {
CheckBox{
id:likeCheckbox
//height:3*mm
width:8*mm
width:10*mm
visible: (newsitemobject.messagetype==0)? true:false
checked:(friendica_activities.self.liked==1)?true:false
style: CheckBoxStyle {
background: Rectangle {
implicitWidth: 6*mm
implicitHeight: 3*mm
color:"white"
}
indicator: Rectangle{
implicitWidth: 3*mm
implicitHeight:3*mm
color:control.checked?"yellow":"white"
x: 4*mm
Text{
anchors.centerIn: parent
font.pixelSize: 2.5*mm
font.family:fontAwesome.name
color:control.checked?"black": "grey"
text:"\uf118"
}}
indicator: Rectangle{
implicitWidth: 10*mm
implicitHeight:3*mm
Text{
anchors.centerIn: parent
font.pixelSize: 2.5*mm
font.family:fontAwesome.name
color:control.checked?"black": "grey"
text:"\uf118"
}
}
}
onClicked: {
if(likeCheckbox.checked==true){Newsjs.like(root.login,root.db,1,"like",newsitemobject.status_id,root);dislikeCheckbox.checked=false; model.friendica_activities.self.liked=0 }
@ -232,73 +217,43 @@ Item {
}
CheckBox{
id: dislikeCheckbox
//height:3*mm
width:8*mm
width:10*mm
visible: (newsitemobject.messagetype==0)? true:false
checked: (friendica_activities.self.disliked==1)?true:false
style: CheckBoxStyle {
background: Rectangle {
implicitWidth: 6*mm
implicitHeight:3*mm
color:"white"
}
indicator: Rectangle{
implicitWidth: 3*mm
implicitWidth: 10*mm
implicitHeight:3*mm
color:control.checked?"yellow":"white"
x:4*mm
Text{
anchors.centerIn: parent
font.pixelSize: 2.5*mm
font.family:fontAwesome.name
color:control.checked?"black": "grey"
text: "\uf119"
}}
}
}
}
onClicked: {
if (dislikeCheckbox.checked==true){Newsjs.like(root.login,root.db,1,"dislike",newsitemobject.status_id,root);likeCheckbox.checked=false; model.friendica_activities.self.disliked=0}
else {Newsjs.like(root.login,root.db,0,"dislike",newsitemobject.status_id,root); model.friendica_activities.self.disliked=1}}
}
// Rectangle{
// width: 8*mm
// height: 3*mm
// color:"transparent"
// Text{
// id:trashsymbol
// color: "grey"
// anchors.centerIn: parent
// font.pixelSize: 2*mm
// font.bold: true
// text: "\uf1f8"
// }
// MouseArea{
// anchors.fill:parent
// onClicked: {
// Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,newsitemobject.messagetype,root,function(reply){
// newsModel.remove(index)})
// }}
// }
CheckBox {
id:favoritedCheckbox
visible:(newsitemobject.messagetype==0)
width: 8*mm
width: 10*mm
style: CheckBoxStyle {
background: Rectangle {
implicitWidth: 6*mm
implicitHeight:3*mm
color:"transparent"
indicator:Rectangle{
x:4*mm
width: 3*mm
implicitHeight:4*mm
Text{
color: control.checked?"black":"grey"
font.pixelSize: 2.5*mm
text:"\uf005"
}
}
indicator:Rectangle{
x:3*mm
width: 3*mm
implicitHeight:3*mm
Text{
color: control.checked?"black":"grey"
font.pixelSize: 2.5*mm
text:"\uf005"
}}
}
}
checked:(newsitemobject.favorited>0)
onClicked:{
if(favoritedCheckbox.checkedState==Qt.Checked){
@ -308,8 +263,8 @@ Item {
}
}
Rectangle{
width: 8*mm
height: 3*mm
width: 10*mm
height: 4*mm
color:"transparent"
Text{
id:newsmenusymbol
@ -324,8 +279,8 @@ Item {
onClicked: {newsmenu.popup()}}
}
Rectangle{
width: 8*mm
height: 3*mm
width: 10*mm
height: 4*mm
visible:newstab.newstabstatus!="Conversation"
color:"transparent"
Text{
@ -340,7 +295,11 @@ Item {
anchors.fill:parent
onClicked:{
conversationsymbol.color="black";
showConversation(index,newsitemobject)
//Newsjs.conversationfromdb(db,login.username,newsitemobject.conversation_id,function(conversation){
var component = Qt.createComponent("qrc:/qml/newsqml/Conversation.qml");
// var conversationItem = component.createObject(friendicaActivities,{"news":newsitemobject.chatArray});
var conversationItem = component.createObject(friendicaActivities); showConversation(index,newsitemobject)
}
}
}
@ -372,7 +331,13 @@ Item {
}
MenuItem {
text: qsTr("Conversation")
onTriggered: showConversation(index,newsitemobject)
onTriggered: {
conversationsymbol.color="black";
//Newsjs.conversationfromdb(db,login.username,newsitemobject.conversation_id,function(conversation){
var component = Qt.createComponent("qrc:/qml/newsqml/Conversation.qml");
var conversationItem = component.createObject(friendicaActivities,{"news":newsitemobject.chatArray});
showConversation(index,newsitemobject)
}
}
Menu{
@ -398,8 +363,15 @@ Item {
text: qsTr("Delete")
onTriggered: {
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,newsitemobject.messagetype,root,function(reply){
newsModel.remove(index)})
// newsModel.remove(index)
var msg = {'deleteId': index, 'model': newsModel};
newsWorker.sendMessage(msg);
})
}
}
//MenuItem{
// text:qsTr("Show on website")
// onTriggered:Qt.openUrlExternally(login.server+"/display/"+newsitemobject
//}
}
}}

View file

@ -1,189 +0,0 @@
import QtQuick 2.0
import "qrc:/js/service.js" as Service
import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml/genericqml"
Rectangle{
id:permissionDialog
x: mm
width: messageColumn.width-5*mm
height:root.height/3
function updatePerms(){
for (var i=0;i<groupModel.count;i++)
{if (groupModel.get(i).groupstatus=="positive"){
group_allow.push(groupModel.get(i).group.gid)
}
if (groupModel.get(i).groupstatus=="negative"){
group_deny.push(groupModel.get(i).group.gid)
}
}
for (var j=0;j<contactModel.count;j++){
if (contactModel.get(j).contactstatus=="positive"){
contact_allow.push(contactModel.get(j).contact.cid)
}
if (contactModel.get(j).contactstatus=="negative"){
contact_deny.push(contactModel.get(j).contact.cid)
}
if ((contact_allow.length==0)&&(contact_deny.length==0)&&(group_allow.length==0)&&(group_deny.length==0))
{permButton.text="\uf09c"}
else{permButton.text="\uf023"}
}}
Text{
x:0.5*mm
y:0.5*mm
text: qsTr("Friends")
}
ListView {
id: contactView
x:0.5*mm
y:5.5*mm
width: permissionDialog.width/2-2*mm
height: permissionDialog.height-14*mm
clip: true
spacing: 1
model: contactModel
delegate: contactItem
}
ListModel{id: contactModel}
Component{
id:contactItem
Rectangle{
id:contactitemRect
width:contactView.width
height: 5*mm
radius: 0.5*mm
property string contactstatus
onContactstatusChanged:{
if(contactstatus=="positive"){contactitemRect.color="light green"}
else if (contactstatus=="negative"){contactitemRect.color= "ffe6e6"}
else{contactitemRect.color= "white"}}
color: "white"
border.color:"grey"
Text{
color:"grey"
text:contact.screen_name
}
MouseArea{
anchors.fill: parent
onClicked:{
if(contactModel.get(index).contactstatus=="neutral"){
contactModel.set(index,{"contactstatus":"positive"});
contactstatus="positive"
}
else if (contactModel.get(index).contactstatus=="positive"){
contactModel.set(index,{"contactstatus":"negative"})
contactstatus="negative"
}
else{contactModel.set(index,{"contactstatus":"neutral"});
contactstatus="neutral";
}
}}
Component.onCompleted:{
if (contactModel.get(index).contactstatus=="positive"){
contactstatus="positive"
}
else if (contactModel.get(index).contactstatus=="negative"){
contactstatus="negative"
}
else {contactstatus="neutral"} }
}
}
Text{
x:contactView.width+2*mm
y:0.5*mm
text: qsTr("Groups")
}
ListView {
id: groupView
x:contactView.width+2*mm
y:5.5*mm
width: permissionDialog.width/2-2*mm
height: permissionDialog.height-14*mm
clip: true
spacing: 1
model: groupModel
delegate: groupItem
}
ListModel{id: groupModel}
Component{
id:groupItem
Rectangle{
id:groupitemRect
width:groupView.width
radius: 0.5*mm
height: 5*mm
property string groupstatus:"neutral"
onGroupstatusChanged:
{if(groupstatus=="positive"){groupitemRect.color="light green"}
else if (groupstatus=="negative"){groupitemRect.color= "#ffe6e6"}
else{groupitemRect.color= "white"}}
color: "white"
border.color:"grey"
Text{
color:"grey"
text:group.groupname
}
MouseArea{
anchors.fill: parent
onClicked:{
if(groupModel.get(index).groupstatus=="neutral"){
groupModel.set(index,{"groupstatus":"positive"});
groupstatus="positive"}
else if (groupModel.get(index).groupstatus=="positive"){
groupModel.set(index,{"groupstatus":"negative"});
groupstatus="negative"}
else{groupModel.set(index,{"groupstatus":"neutral"})
groupstatus="neutral"}
}}
Component.onCompleted:{ if (groupModel.get(index).groupstatus=="positive"){
groupstatus="positive"
}
else if (groupModel.get(index).groupstatus=="negative"){
groupstatus="negative"
}
else {groupstatus="neutral"} }
}
}
BlueButton{
x:0.5*mm
anchors.bottom: parent.bottom
anchors.bottomMargin:1
text:"\uf0c7"
onClicked:{
updatePerms();
var perms=[];
perms.push(contact_allow,contact_deny,group_allow,group_deny);
Service.savePermissions(db,perms)
}
}
BlueButton{
x:contactView.width+2*mm
anchors.bottom: parent.bottom
anchors.bottomMargin:1
text:"\u2713"
onClicked:{updatePerms();
permissionDialog.destroy();
}
}
Component.onCompleted:{
Helperjs.readData(db,"contacts",login.username,function(contacts){
for (var name in contacts){
var contactstatus="neutral";
if (contact_allow.indexOf(contacts[name].cid)>-1){contactstatus="positive";print(contacts[name].cid+" pos")}
else if (contact_deny.indexOf(contacts[name].cid)>-1){contactstatus="negative"}
contactModel.append({"contact":contacts[name],"contactstatus":contactstatus})
}},"isFriend",1);
Helperjs.readData(db,"groups",login.username,function(owngroups){
for (var number in owngroups){
var groupstatus= "neutral";
if (group_allow.indexOf(owngroups[number].gid)>-1){groupstatus="positive"}
else if (group_deny.indexOf(owngroups[number].gid)>-1){groupstatus="negative"}
groupModel.append({"group":owngroups[number],"groupstatus":groupstatus})
}});
}
}