// This file is part of Friendiqa // https://git.friendi.ca/lubuwest/Friendiqa // Copyright (C) 2017 Marco R. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // In addition, as a special exception, the copyright holders give // permission to link the code of portions of this program with the // OpenSSL library under certain conditions as described in each // individual source file, and distribute linked combinations including // the two. // // You must obey the GNU General Public License in all respects for all // of the code used other than OpenSSL. If you modify file(s) with this // exception, you may extend this exception to your version of the // file(s), but you are not obligated to do so. If you do not wish to do // so, delete this exception statement from your version. If you delete // this exception statement from all source files in the program, then // also delete it here. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . import QtQuick 2.0 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import "qrc:/js/news.js" as Newsjs import "qrc:/js/helper.js" as Helperjs import "qrc:/qml/genericqml" Item { id: newsitem 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) property int itemindex: index property string attending: "" onAttendingChanged: {attendLabel.visible=true; attendLabel.text= qsTr("attending: ")+ qsTr(attending)} signal replyto(string parent_id) function showActivityContacts(contacts){ var component = Qt.createComponent("qrc:/qml/newsqml/FriendicaActivities.qml"); var imagedialog = component.createObject(friendicaActivities,{"activitymembers": contacts}); } function findTags(fulltext){ return fulltext.match(/\s+[#]+[A-Za-z0-9-_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]+/g) } Rectangle{width:newsitem.width; height: 1; anchors.bottom: newsitem.bottom; color:"light grey"} Rectangle{ width:newsitem.width height:newsitem.height-1 color: (newsitemobject.messagetype==1)?"#ffe6e6" : "white" Row{id:toprow Column { id: authorcolumn width: 8*mm Image { id:profileImage source: ((newsitemobject.user.profile_image!="") && (typeof(newsitemobject.user.profile_image)=="string"))? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url x:1 width: 7*mm height: 7*mm MouseArea{ anchors.fill: parent onClicked:{ showContact(newsitemobject.user)} } onStatusChanged: if (profileImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"} } Label { id:user_name color: "grey" width:parent.width font.pixelSize: 1.5*mm wrapMode: Text.WrapAtWordBoundaryOrAnywhere text: newsitemobject.user.name+forumname } } Column { id:newscolumn width: newsitem.width-8*mm Flow{ id:topFlow spacing: mm width:parent.width Label { id:messageTypeLabel color: "grey" text: if (newsitemobject.messagetype==0){qsTr("Source: ")+newsitemobject.source } else if (newsitemobject.messagetype==1){ qsTr("Direct Message")} else {" Notification"} font.pixelSize: 1.5*mm } Label { id:createdAtLabel color: "grey" font.pixelSize: 1.5*mm horizontalAlignment: Label.AlignRight text: dateDiff } Label { id:replytoLabel color: "grey" font.pixelSize: 1.5*mm horizontalAlignment: Label.AlignRight text: try {qsTr("In reply to ")+newsitemobject.reply_user.screen_name }catch(e){" "} } Label { id:newscountLabel visible:((newstabstatus=="Conversations")&&(newsitemobject.newscount>1))?true:false color: "grey" height:3.5*mm font.pixelSize: 1.5*mm font.bold: true horizontalAlignment: Label.AlignRight text: try {(newsitemobject.newscount-1)+qsTr(" comments") }catch(e){" "} MouseArea{ anchors.fill:parent onClicked: { newsStack.push("qrc:/qml/newsqml/Conversation.qml"); showConversation(index,newsitemobject) } } } } Column{ id: messageColumn //anchors.top:topFlow.bottom width:parent.width spacing:mm clip:true height: Math.min(implicitHeight,3/4*root.height) MouseArea{ width: newsitem.width-8*mm-2 height: itemMessage.height onPressAndHold: { newsStack.push("qrc:/qml/newsqml/Conversation.qml"); showConversation(index,newsitemobject) } Text { color: "#404040" linkColor: "light green" id: itemMessage textFormat: Text.RichText text: newsitemobject.statusnet_html//newsitemobject.attachmentList.length>0?newsitemobject.text : newsitemobject.statusnet_html width: newsitem.width-8*mm-2 height: implicitHeight wrapMode: Text.Wrap clip:true //MouseArea{anchors.fill:parent;onClicked: print("Test")} onLinkActivated:{ Qt.openUrlExternally(link)} Component.onCompleted:{ if (newsitemobject.messagetype==0){ var hashtags=[]; hashtags=findTags(newsitemobject.text); var component = Qt.createComponent("qrc:/qml/newsqml/Hashtag.qml"); for (var tags in hashtags){ var hashtagQml = component.createObject(friendicaActivities,{"text":hashtags[tags].trim()}); }} if (newsitemobject.attachmentList.length>0){ for(var attachments in newsitemobject.attachmentList){// (newsitemobject.attachmentList[attachments].url); if(newsitemobject.attachmentList[attachments].mimetype.substring(0,5)=="image"){ var component = Qt.createComponent("qrc:/qml/newsqml/NewsImage.qml"); var imageQml = component.createObject(messageColumn,{"source":newsitemobject.attachmentList[attachments].url,"mimetype":newsitemobject.attachmentList[attachments].mimetype}); } else if(newsitemobject.attachmentList[attachments].mimetype=="text/html"){ var component = Qt.createComponent("qrc:/qml/newsqml/NewsLink.qml"); var linkQml = component.createObject(messageColumn,{"url":newsitemobject.attachmentList[attachments].url}); } else {//print(newsitemobject.attachmentList[attachments].url+" Type: "+newsitemobject.attachmentList[attachments].mimetype) var component = Qt.createComponent("qrc:/qml/newsqml/NewsVideo.qml"); var videoQml = component.createObject(messageColumn,{"source":newsitemobject.attachmentList[attachments].url,"mimetype":newsitemobject.attachmentList[attachments].mimetype}); } } } } }} } BlueButton{ width: newsitem.width-8*mm-2 height:5*mm //anchors.bottom: messageColumn.bottom//itemMessage.bottom visible: messageColumn.implicitHeight>3/4*root.height//itemMessage.implicitHeight>3/4*root.height text:"\uf078" fontColor:"grey" border.color: "transparent" color:"white" // gradient: Gradient { // GradientStop { position: 0.0; color: "transparent" } // GradientStop { position: 0.5; color: "white" } // } radius:0 onClicked: { if (text=="\uf078"){ messageColumn.height=messageColumn.implicitHeight+10*mm;text="\uf077" } else { messageColumn.height=Math.min(messageColumn.implicitHeight,3/4*root.height); text="\uf078"; newsView.positionViewAtIndex(index,ListView.Beginning); } } } } } Flow{ id:friendicaActivities anchors.top:toprow.bottom width:parent.width spacing:mm Label{color: "grey" height:3.5*mm font.pixelSize: 1.5*mm text: friendica_activities.likeText MouseArea{ anchors.fill: parent onClicked: { showActivityContacts(newsitemobject.friendica_activities.like)} } } Label{color: "grey" height:3.5*mm font.pixelSize: 1.5*mm text: friendica_activities.dislikeText MouseArea{ anchors.fill: parent onClicked: { showActivityContacts(newsitemobject.friendica_activities.dislike)} } } Label{color: "grey" height:3.5*mm font.pixelSize: 1.5*mm text: friendica_activities.attendyesText MouseArea{ anchors.fill: parent onClicked: { showActivityContacts(newsitemobject.friendica_activities.attendyes)} }} Label{color: "grey" height:3.5*mm font.pixelSize: 1.5*mm text: friendica_activities.attendnoText MouseArea{ anchors.fill: parent onClicked: { showActivityContacts(newsitemobject.friendica_activities.attendno)} } } Label{color: "grey" height:3.5*mm font.pixelSize: 1.5*mm text: friendica_activities.attendmaybeText MouseArea{ anchors.fill: parent onClicked: { showActivityContacts(newsitemobject.friendica_activities.attendmaybe)} } } Label{ id:attendLabel color: "grey" height:3.5*mm font.pixelSize: 1.5*mm horizontalAlignment: Label.AlignRight text: (friendica_activities.self.attending)?(qsTr("Attending: ")+ qsTr(friendica_activities.self.attending)):"" } } Row{id:controlrow anchors.top:friendicaActivities.bottom CheckBox{ id:likeCheckbox width:10*mm visible: (newsitemobject.messagetype==0)? true:false checked:(friendica_activities.self.liked==1)?true:false style: CheckBoxStyle { 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:control.checked?"\uf118"+"!":"\uf118" } } } onClicked: { if(likeCheckbox.checked==true){Newsjs.like(root.login,root.db,1,"like",newsitemobject.id,root);dislikeCheckbox.checked=false; model.friendica_activities.self.liked=0 } else{Newsjs.like(root.login,root.db,0,"like",newsitemobject.id,root); model.friendica_activities.self.liked=1}} } CheckBox{ id: dislikeCheckbox width:10*mm visible: (newsitemobject.messagetype==0)? true:false checked: (friendica_activities.self.disliked==1)?true:false style: CheckBoxStyle { 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: control.checked?"\uf119"+"!":"\uf119" } } } onClicked: { if (dislikeCheckbox.checked==true){Newsjs.like(root.login,root.db,1,"dislike",newsitemobject.id,root);likeCheckbox.checked=false; model.friendica_activities.self.disliked=0} else {Newsjs.like(root.login,root.db,0,"dislike",newsitemobject.id,root); model.friendica_activities.self.disliked=1}} } CheckBox { id:favoritedCheckbox visible:(newsitemobject.messagetype==0) width: 10*mm style: CheckBoxStyle { indicator:Rectangle{ x:4*mm width: 3*mm implicitHeight:4*mm Text{ color: control.checked?"black":"grey" font.pixelSize: 2.5*mm text:"\uf005" } } } checked:(newsitemobject.favorited>0) onClicked:{ if(favoritedCheckbox.checkedState==Qt.Checked){ Newsjs.favorite(login,true,newsitemobject.id,root); model.newsitemobject.favorited=1} else if(favoritedCheckbox.checkedState==Qt.Unchecked){ Newsjs.favorite(login,false,newsitemobject.id,root);model.newsitemobject.favorited=0} } } Rectangle{ width: 10*mm height: 4*mm visible:(newsitemobject.messagetype!==2) color:"transparent" Text{ id:newsmenusymbol color: "grey" anchors.centerIn: parent font.pixelSize: 2.5*mm font.family:fontAwesome.name text: "\uf142" } MouseArea{ anchors.fill:parent onClicked: {newsmenu.popup()}} } Rectangle{ width: 10*mm height: 4*mm visible:(newsitemobject.messagetype!==2)&&(newstab.newstabstatus!="Conversation") color:"transparent" Text{ id:conversationsymbol color: "grey" anchors.centerIn: parent font.pixelSize: 2.5*mm font.family: fontAwesome.name text: "\uf086" } MouseArea{ anchors.fill:parent onClicked:{ //conversationsymbol.color="black"; // var component = Qt.createComponent("qrc:/qml/newsqml/Conversation.qml"); // var conversationItem = component.createObject(friendicaActivities); newsStack.push("qrc:/qml/newsqml/Conversation.qml") showConversation(index,newsitemobject) } } } } Menu { id:newsmenu MenuItem { text: qsTr("Reply") onTriggered: { var directmessage=0; if (newsitemobject.messagetype==1){ directmessage=1} newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.id,"login":root.login,"directmessage":directmessage}); } } MenuItem { text: qsTr("DM") onTriggered: { root.directmessageSignal(newsitemobject.user.screen_name); } } MenuItem { text: qsTr("Repost") onTriggered: { Newsjs.retweetNews(root.login,db,newsitemobject.id,root,function(reply){ Helperjs.showMessage("Repost",qsTr("Success!"),root) }) } } MenuItem { text: qsTr("Conversation") onTriggered: { conversationsymbol.color="black"; var component = Qt.createComponent("qrc:/qml/newsqml/Conversation.qml"); var conversationItem = component.createObject(friendicaActivities,{"news":newsitemobject.chatArray}); showConversation(index,newsitemobject) } } Menu{ title: qsTr("Attending") MenuItem{ text:qsTr("yes") onTriggered: {Newsjs.attend(root.login,db,"yes",newsitemobject.id,root,function(){ model.friendica_activities.self.attending="yes";attending="yes"}) } } MenuItem{text:qsTr("maybe") onTriggered: {Newsjs.attend(root.login,db,"maybe",newsitemobject.id,root,function(){ model.friendica_activities.self.attending="maybe";attending="maybe"}) } } MenuItem{text:qsTr("no") onTriggered: {Newsjs.attend(root.login,db,"no",newsitemobject.id,root,function(){ model.friendica_activities.self.attending="no";attending="no"})} } } MenuItem { text: qsTr("Delete") onTriggered: { Newsjs.deleteNews(root.login,root.db,newsitemobject.id,newsitemobject.messagetype,root,function(reply){ var msg = {'deleteId': index, 'model': newsModel}; newsWorker.sendMessage(msg); }) } } //MenuItem{ // text:qsTr("Show on website") // onTriggered:Qt.openUrlExternally(login.server+"/display/"+newsitemobject //} } }}