forked from lubuwest/Friendiqa
Version 0.002 with working Permissions
This commit is contained in:
parent
571c9046d0
commit
15e2e8f60a
62 changed files with 924 additions and 1277 deletions
192
v0.002/Develop/source-linux/qml/newsqml/MessageSend.qml
Normal file
192
v0.002/Develop/source-linux/qml/newsqml/MessageSend.qml
Normal file
|
@ -0,0 +1,192 @@
|
|||
// message.qml
|
||||
// message with buttons
|
||||
import QtQuick 2.0
|
||||
import QtQml 2.2
|
||||
import QtQuick.Controls 1.3
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.LocalStorage 2.0
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/js/service.js" as Servicejs
|
||||
|
||||
Item{
|
||||
id:messageSend
|
||||
property var login
|
||||
property string parentId: ""
|
||||
property string reply_to_user:""
|
||||
property string attachImageURL: "";
|
||||
property int directmessage: 0;
|
||||
property var contacts: []
|
||||
property var groups: []
|
||||
property var contact_allow:[]
|
||||
property var contact_deny:[]
|
||||
property var group_allow:[]
|
||||
property var group_deny:[]
|
||||
|
||||
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
||||
xhr.url= login.server + "/api/statuses/update.xml";
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
xhr.clearParams();
|
||||
xhr.setParam("source", "Friendiqa");
|
||||
xhr.setParam("status", status);
|
||||
if (parentId!="") {xhr.setParam("in_reply_to_status_id", parentId)};
|
||||
if (title!=="") {xhr.setParam("title", title)};
|
||||
if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))};
|
||||
if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))};
|
||||
if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))};
|
||||
if (contact_deny.length>0) {xhr.setParam("contact_deny", Helperjs.cleanArray(contact_deny))};
|
||||
if (attachImageURL!=="") {xhr.setImageFileParam("media", attachImageURL )};
|
||||
xhr.post();
|
||||
}
|
||||
|
||||
function dmUpdate(title,text,replyto,screen_name,attachImageURL) {
|
||||
xhr.url= login.server + "/api/direct_messages/new.xml";
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
xhr.clearParams();
|
||||
xhr.setParam("text", text);
|
||||
xhr.setParam("screen_name", screen_name);
|
||||
if (parentId!="") {xhr.setParam("replyto", replyto)};
|
||||
if (title!=="") {xhr.setParam("title", title)};
|
||||
if (attachImageURL!=="") {xhr.setImageFileParam("media", attachImageURL )};
|
||||
xhr.post();
|
||||
}
|
||||
|
||||
Column {
|
||||
id:messageColumn
|
||||
spacing: 2
|
||||
width: parent.width
|
||||
TextField {
|
||||
id: titleField
|
||||
width: parent.width
|
||||
placeholderText: qsTr("Title (optional)")
|
||||
visible: messageSend.parentId === ""
|
||||
}
|
||||
|
||||
TextArea {
|
||||
id: bodyField
|
||||
width: parent.width
|
||||
height: 30*mm
|
||||
wrapMode: TextEdit.Wrap
|
||||
textFormat: TextEdit.PlainText
|
||||
}
|
||||
|
||||
Row{
|
||||
|
||||
spacing: 2
|
||||
CheckBox{
|
||||
id:dmCheckbox
|
||||
text:"DM"
|
||||
enabled: false
|
||||
checked: (directmessage==1)?true:false
|
||||
onClicked:{
|
||||
if(dmCheckbox.checkedState==Qt.Checked){directmessage=1}
|
||||
else if(dmCheckbox.checkedState==Qt.Unchecked){directmessage=0}
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
text:qsTr("Url")
|
||||
onClicked: {
|
||||
if(bodyField.selectedText==""){Helperjs.showMessage("Error","No text selected",messageSend)}
|
||||
else{urlTextEdit.text="";
|
||||
urlRectangle.visible=true}}
|
||||
}
|
||||
Rectangle{
|
||||
id:urlRectangle
|
||||
height:parent.height
|
||||
width:37*mm
|
||||
visible:false
|
||||
TextField{
|
||||
id:urlTextEdit
|
||||
width:30*mm
|
||||
height:parent.height
|
||||
}
|
||||
Button{
|
||||
anchors.left:urlTextEdit.right
|
||||
anchors.leftMargin:mm
|
||||
text:qsTr("\u2713")
|
||||
onClicked: {
|
||||
var start = bodyField.selectionStart;
|
||||
var end = bodyField.selectionEnd;
|
||||
var text = bodyField.getText(start,end);
|
||||
text = "<a href='"+urlTextEdit.text+"'>" + text + "</a>";
|
||||
bodyField.remove(start,end);
|
||||
bodyField.insert(start,text);
|
||||
urlRectangle.visible=false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Row{
|
||||
spacing:2
|
||||
Button{
|
||||
visible: (directmessage==1)?false:true
|
||||
text:qsTr("Permissions")
|
||||
onClicked: {
|
||||
var component = Qt.createComponent("qrc:/qml/newsqml/PermissionDialog.qml");
|
||||
var permissions = component.createObject(messageColumn);
|
||||
}}
|
||||
Button {
|
||||
id: attachButton
|
||||
text: qsTr("Attach")
|
||||
onClicked: {
|
||||
try{imageAttachment.visible=false;
|
||||
imageAttachment.opacity=0;imageAttachment.destroy()}catch(e){}
|
||||
imageAttachmentDialog.open()}
|
||||
}
|
||||
Button{
|
||||
id:contactButton
|
||||
text:qsTr("cc")
|
||||
visible:(directmessage==0)
|
||||
onClicked:{
|
||||
var contactitems="";
|
||||
for (var i=0;i<contacts.length;i++){
|
||||
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"'; onTriggered: bodyField.append(' @"+contacts[i].screen_name+"')}"
|
||||
}
|
||||
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
|
||||
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput")
|
||||
contactlistObject.popup() }
|
||||
}
|
||||
}
|
||||
Row{
|
||||
spacing:2
|
||||
Button {
|
||||
id: cancelButton
|
||||
text: qsTr("Cancel")
|
||||
onClicked: {newsStack.pop()}
|
||||
}
|
||||
Button {
|
||||
id: sendButton
|
||||
text: qsTr("Send")
|
||||
onClicked: {
|
||||
//print("login: "+login.server+login.username);
|
||||
var title=titleField.text.replace("\"","\'");
|
||||
var body=bodyField.getText(0,bodyField.length);
|
||||
if (directmessage==0){
|
||||
statusUpdate(title,body,messageSend.parentId,attachImageURL.toString())}
|
||||
else {dmUpdate( title,body,"",messageSend.reply_to_user) }
|
||||
newsStack.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
||||
stackView.pop(); event.accepted = true;
|
||||
}}
|
||||
FileDialog {
|
||||
id: imageAttachmentDialog
|
||||
title: "Please choose a picture"
|
||||
folder: shortcuts.pictures
|
||||
selectFolder: false
|
||||
onAccepted: {
|
||||
attachImageURL=imageAttachmentDialog.fileUrl;
|
||||
var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment;source:"'+attachImageURL.toString()+'"; width: 15*mm; height: 15*mm;fillMode: Image.PreserveAspectFit}',messageColumn,"attachedImage");
|
||||
//console.log("You chose: " + attachImageURL)
|
||||
|
||||
}
|
||||
onRejected: {
|
||||
//console.log("Canceled")
|
||||
}
|
||||
}
|
||||
}
|
192
v0.002/Develop/source-linux/qml/newsqml/NewsTab.qml
Normal file
192
v0.002/Develop/source-linux/qml/newsqml/NewsTab.qml
Normal file
|
@ -0,0 +1,192 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.LocalStorage 2.0 as Sql
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
|
||||
Item {
|
||||
property string newstabStatus:"news"
|
||||
|
||||
function showNews(newsToShow){
|
||||
newsBusy.running=false;
|
||||
var currentTime= new Date();
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsToShow};
|
||||
newsWorker.sendMessage(msg);
|
||||
}
|
||||
|
||||
function onFriendsMessages(friend){print(" Friend "+friend);
|
||||
newstabStatus="friendmessage";
|
||||
Newsjs.newsfromdb(db,root.login.username, function(dbnews){showNews(dbnews)},friend)
|
||||
}
|
||||
|
||||
function onDirectMessage(friend){
|
||||
print(root.login.server);
|
||||
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
|
||||
}
|
||||
|
||||
function cleanNews(database){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var maxnewsrs = tx.executeSql("SELECT DISTINCT maxnews FROM config");
|
||||
var maxnews=maxnewsrs.rows.item(0);
|
||||
var newscountrs = tx.executeSql('SELECT COUNT(*) from news');
|
||||
var newscount = newscountrs.rows.item(0);
|
||||
if (newscount>maxnews){var lastvalidtimers= tx.executeSql('select created_at from news ORDER BY created_at DESC LIMIT ' +(newscount-maxnews));
|
||||
var lastvalidtime=lastvalidtimers.rows.item(-1);
|
||||
var deleters = tx.executeSql('DELETE from news WHERE created_at<'+lastvalidtime)}
|
||||
});
|
||||
Qt.quit()
|
||||
}
|
||||
|
||||
StackView{
|
||||
id: newsStack
|
||||
anchors.fill:parent
|
||||
focus: true
|
||||
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
||||
stackView.pop(); event.accepted = true;
|
||||
}
|
||||
else if(event.key === Qt.Key_Back &&newstabStatus=="conversation"){
|
||||
newstabStatus="news"
|
||||
newsModel.clear();
|
||||
Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
||||
showNews(dbnews)
|
||||
})}
|
||||
}
|
||||
initialItem:Rectangle {
|
||||
y:1
|
||||
color: "white"
|
||||
width:root.width-2*mm
|
||||
height:root.height-8*mm
|
||||
|
||||
ComboBox{
|
||||
y:mm
|
||||
width: 8*mm
|
||||
model: ListModel{
|
||||
id: cbModel
|
||||
ListElement{text: qsTr("News")}
|
||||
ListElement{text: qsTr("Favorites")}
|
||||
}
|
||||
onCurrentIndexChanged:{
|
||||
if (currentIndex==0){newsModel.clear();
|
||||
Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
||||
showNews(dbnews)
|
||||
})}
|
||||
else if (currentIndex==1){
|
||||
newsBusy.running=true;
|
||||
Newsjs.requestFavorites(root.login,db,root,function(news){
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
Newsjs.favoritesfromdb(db,root.login.username,function(newsarray){
|
||||
showNews(newsarray)
|
||||
|
||||
});
|
||||
}
|
||||
)})
|
||||
}
|
||||
}}
|
||||
|
||||
Button {
|
||||
id: newMessageButton
|
||||
text: qsTr("+")
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
var groups=[];
|
||||
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
|
||||
groups=groupobject});
|
||||
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
|
||||
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
|
||||
},"isFriend",1);
|
||||
}
|
||||
}
|
||||
Button {
|
||||
id: quitButton
|
||||
text: qsTr("Quit")
|
||||
anchors.top: parent.top
|
||||
anchors.right: newMessageButton.left
|
||||
onClicked: {cleanNews(root.db)}
|
||||
}
|
||||
|
||||
Component { id:footerComponent
|
||||
Rectangle{
|
||||
border.color: "#EEEEEE"
|
||||
border.width: 1
|
||||
width:parent.width
|
||||
height:6*mm
|
||||
Text{
|
||||
font.pixelSize: 1.5*mm
|
||||
anchors.centerIn: parent
|
||||
text:qsTr("More")
|
||||
}
|
||||
MouseArea{anchors.fill:parent
|
||||
onClicked:{
|
||||
var currentTime= new Date();
|
||||
if(newstabStatus=="news"){
|
||||
var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;
|
||||
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)}
|
||||
else if(newstabStatus=="friendmessage"){
|
||||
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)}
|
||||
}}
|
||||
}
|
||||
}
|
||||
ListView {
|
||||
id: newsView
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 8*root.mm
|
||||
anchors.leftMargin: 3*root.mm; anchors.rightMargin: root.mm
|
||||
anchors.bottomMargin: 1*root.mm
|
||||
clip: true
|
||||
spacing: 0
|
||||
footer: footerComponent
|
||||
model: newsModel
|
||||
delegate: Newsitem{}
|
||||
}
|
||||
|
||||
ListModel{id: newsModel}
|
||||
|
||||
WorkerScript {
|
||||
id: newsWorker
|
||||
source: "qrc:/js/newsworker.js"
|
||||
}
|
||||
|
||||
Button {
|
||||
id: update
|
||||
anchors.top: parent.top
|
||||
anchors.right: quitButton.left
|
||||
text: "Update"
|
||||
onClicked: { //try{newsModel.clear()} catch(e){}
|
||||
newsBusy.running=true;
|
||||
root.contactLoadType="news";
|
||||
Newsjs.getFriendsTimeline(login,db,contactlist,newstab,function(ns,nc){
|
||||
root.news=ns;root.newContacts=nc;root.currentContact=0;
|
||||
if (ns.length==0){
|
||||
Newsjs.getDirectMessage(root.login,root.db,root,function(dbnews){showNews(dbnews)});
|
||||
newsBusy.running=false}
|
||||
})}
|
||||
}
|
||||
BusyIndicator{
|
||||
id: newsBusy
|
||||
anchors.horizontalCenter: newsView.horizontalCenter
|
||||
anchors.top:parent.top
|
||||
anchors.topMargin: 2*mm
|
||||
width:7*mm
|
||||
height: 7*mm
|
||||
}
|
||||
Component.onCompleted: {
|
||||
root.messageSignal.connect(onFriendsMessages);
|
||||
root.directmessageSignal.connect(onDirectMessage);
|
||||
root.newsSignal.connect(showNews);
|
||||
try{newsModel.clear()} catch(e){}
|
||||
Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
||||
showNews(dbnews)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
336
v0.002/Develop/source-linux/qml/newsqml/Newsitem.qml
Normal file
336
v0.002/Develop/source-linux/qml/newsqml/Newsitem.qml
Normal file
|
@ -0,0 +1,336 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.LocalStorage 2.0
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
|
||||
|
||||
Item {
|
||||
id: newsitem
|
||||
width: newsView.width
|
||||
height:Math.max((itemMessage.height+topFlow.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
|
||||
|
||||
property string conversation_id: ""
|
||||
property string attending: ""
|
||||
onAttendingChanged: {attendLabel.visible=true;
|
||||
attendLabel.text= qsTr("attending: ")+ qsTr(attending)}
|
||||
signal replyto(string parent_id)
|
||||
|
||||
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"
|
||||
|
||||
Column {
|
||||
id: authorcolumn
|
||||
width: 8*mm
|
||||
|
||||
Image {
|
||||
id:profileImage
|
||||
source: (newsitemobject.user.profile_image!="")? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
|
||||
x:1
|
||||
width: 7*mm
|
||||
height: 7*mm
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onPressAndHold: { newsmenu.popup()}
|
||||
}
|
||||
onStatusChanged: if (profileImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
|
||||
}
|
||||
Label {
|
||||
id:user_name
|
||||
color: "grey"
|
||||
//height:3.5*mm
|
||||
width:parent.width
|
||||
font.pixelSize: 1.5*mm
|
||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||
text: Qt.atob(newsitemobject.user.name)
|
||||
}
|
||||
}
|
||||
Column {
|
||||
id:newscolumn
|
||||
width: newsitem.width-8*mm
|
||||
anchors.left: authorcolumn.right
|
||||
|
||||
Flow{
|
||||
id:topFlow
|
||||
spacing: 2*mm
|
||||
width:parent.width
|
||||
Label {
|
||||
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"
|
||||
height:3.5*mm
|
||||
font.pixelSize: 1.5*mm
|
||||
horizontalAlignment: Label.AlignRight
|
||||
text: dateDiff
|
||||
}
|
||||
CheckBox {
|
||||
id:favoritedCheckbox
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
implicitWidth: 6*mm
|
||||
implicitHeight:2*mm
|
||||
color:"white"
|
||||
}
|
||||
indicator:
|
||||
Rectangle{x:3*mm
|
||||
width: 3*mm
|
||||
implicitHeight:2*mm
|
||||
Text{
|
||||
anchors.centerIn: parent
|
||||
color:control.checked?"black":"grey"
|
||||
text:"\u2605"
|
||||
}}
|
||||
}
|
||||
checked:(newsitemobject.favorited>0)
|
||||
onClicked:{
|
||||
if(favoritedCheckbox.checkedState==Qt.Checked)
|
||||
{Newsjs.favorite(login,true,newsitemobject.status_id,root)}
|
||||
else
|
||||
if(favoritedCheckbox.checkedState==Qt.Unchecked)
|
||||
{Newsjs.favorite(login,false,newsitemobject.status_id,root)}
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
width: 4*mm
|
||||
height: 3*mm
|
||||
Text{
|
||||
id:newsmenusymbol
|
||||
color: "grey"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: 2*mm
|
||||
font.bold: true
|
||||
text: "\u22EE"
|
||||
}
|
||||
MouseArea{
|
||||
anchors.fill:parent
|
||||
onClicked: {newsmenu.popup()}}
|
||||
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
width: 4*mm
|
||||
height: 3*mm
|
||||
visible:(newsitemobject.in_reply_to_status_id!="")?true:false
|
||||
Text{
|
||||
id:conversationsymbol
|
||||
color: "grey"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: 2*mm
|
||||
text: "\u21C4"
|
||||
}
|
||||
MouseArea{
|
||||
anchors.fill:parent
|
||||
onClicked: {
|
||||
newsBusy.running=true;
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||
for (var i=0;i<newContacts.length;i++){
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
newstab.newstabStatus="conversation";
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
newsBusy.running=false
|
||||
})
|
||||
}
|
||||
)})
|
||||
}}
|
||||
}}
|
||||
|
||||
Text {
|
||||
color: "#404040"
|
||||
linkColor: "light green"
|
||||
id: itemMessage
|
||||
textFormat: Text.RichText
|
||||
text: Qt.atob(newsitemobject.statusnet_html)
|
||||
width: newsitem.width-8*mm-2
|
||||
height: implicitHeight
|
||||
wrapMode: Text.Wrap
|
||||
onLinkActivated:{
|
||||
Qt.openUrlExternally(link)}
|
||||
}
|
||||
Row{id:friendicaActivities
|
||||
spacing:mm
|
||||
Label{color: "grey"
|
||||
font.pixelSize: 1.5*mm
|
||||
text: friendica_activities.likeText
|
||||
}
|
||||
Label{color: "grey"
|
||||
font.pixelSize: 1.5*mm
|
||||
text: friendica_activities.dislikeText
|
||||
}
|
||||
Label{color: "grey"
|
||||
font.pixelSize: 1.5*mm
|
||||
text: friendica_activities.attendyesText
|
||||
}
|
||||
Label{color: "grey"
|
||||
font.pixelSize: 1.5*mm
|
||||
text: friendica_activities.attendnoText
|
||||
}
|
||||
Label{color: "grey"
|
||||
font.pixelSize: 1.5*mm
|
||||
text: friendica_activities.attendmaybeText
|
||||
}
|
||||
}
|
||||
Row {
|
||||
CheckBox{id:likeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
visible: (newsitemobject.messagetype==0)? true:false
|
||||
checked:(friendica_activities.self.liked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
implicitWidth: 7*mm
|
||||
implicitHeight: 3*mm
|
||||
color:"white"
|
||||
}
|
||||
indicator:
|
||||
Rectangle{
|
||||
implicitWidth: 3*mm
|
||||
implicitHeight:3*mm
|
||||
color:control.checked?"yellow":"white"
|
||||
x: 5*mm
|
||||
Text{
|
||||
font.pixelSize: 1.5*mm
|
||||
color:"grey"
|
||||
text:":-)"
|
||||
}}
|
||||
}
|
||||
onClicked: {
|
||||
if(likeCheckbox.checked==true){Newsjs.like(root.login,root.db,1,"like",newsitemobject.status_id,root);dislikeCheckbox.checked=false}
|
||||
else{Newsjs.like(root.login,root.db,0,"like",newsitemobject.status_id,root)}}
|
||||
}
|
||||
CheckBox{id: dislikeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
visible: (newsitemobject.messagetype==0)? true:false
|
||||
checked: (friendica_activities.self.disliked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
implicitWidth: 7*mm
|
||||
implicitHeight:3*mm
|
||||
color:"white"
|
||||
}
|
||||
indicator:
|
||||
Rectangle{
|
||||
implicitWidth: 3*mm
|
||||
implicitHeight:3*mm
|
||||
color:control.checked?"yellow":"white"
|
||||
x:5*mm
|
||||
Text{
|
||||
font.pixelSize: 1.5*mm
|
||||
color:"grey"
|
||||
text:":-("
|
||||
}}
|
||||
}
|
||||
onClicked: {
|
||||
if (dislikeCheckbox.checked==true){Newsjs.like(root.login,root.db,1,"dislike",newsitemobject.status_id);likeCheckbox.checked=false}
|
||||
else {Newsjs.like(root.login,root.db,0,"dislike",newsitemobject.status_id,root)}}
|
||||
}
|
||||
Label {
|
||||
id:replytoLabel
|
||||
color: "grey"
|
||||
height:3.5*mm
|
||||
font.pixelSize: 1.5*mm
|
||||
horizontalAlignment: Label.AlignRight
|
||||
text: try {qsTr("In reply to ")+newsitemobject.reply_user.screen_name
|
||||
}catch(e){" "}
|
||||
}
|
||||
Label {
|
||||
id:attendLabel
|
||||
visible: false
|
||||
color: "grey"
|
||||
height:3.5*mm
|
||||
font.pixelSize: 1.5*mm
|
||||
horizontalAlignment: Label.AlignRight
|
||||
text: (friendica_activities.self.attending)?qsTr("attending: ")+ qsTr(attending):""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
id:newsmenu
|
||||
MenuItem {
|
||||
text: qsTr("Reply")
|
||||
onTriggered: {
|
||||
var directmessage=0;
|
||||
if (newsitemobject.messagetype==1){ directmessage=1}
|
||||
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_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.status_id,root,function(reply){
|
||||
print(reply);
|
||||
})
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Conversation")
|
||||
onTriggered: {
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||
for (var i=0;i<newContacts.length;i++){
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
});
|
||||
}
|
||||
)})
|
||||
}}
|
||||
|
||||
Menu{
|
||||
title: qsTr("Attending")
|
||||
|
||||
MenuItem{text:qsTr("yes")
|
||||
onTriggered: {Newsjs.attend(root.login,db,"yes",newsitemobject.status_id,root,function(){
|
||||
newsitem.attending="yes";
|
||||
attendLabel.visible=true})}
|
||||
}
|
||||
|
||||
MenuItem{text:qsTr("maybe")
|
||||
onTriggered: {Newsjs.attend(root.login,db,"maybe",newsitemobject.status_id,root,function(){
|
||||
newsitem.attending="maybe"})}
|
||||
}
|
||||
|
||||
MenuItem{text:qsTr("no")
|
||||
onTriggered: {Newsjs.attend(root.login,db,"no",newsitemobject.status_id,root,function(){
|
||||
newsitem.attending="no"})}
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Delete")
|
||||
onTriggered: {
|
||||
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,newsitemobject.messagetype,root,function(reply){
|
||||
print("Deleted "+reply);
|
||||
newsModel.remove(index);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
156
v0.002/Develop/source-linux/qml/newsqml/PermissionDialog.qml
Normal file
156
v0.002/Develop/source-linux/qml/newsqml/PermissionDialog.qml
Normal file
|
@ -0,0 +1,156 @@
|
|||
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
|
||||
x: mm
|
||||
width: messageColumn.width-5*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: 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
|
||||
property string contactstatus:"neutral"
|
||||
onContactstatusChanged:
|
||||
{if(contactstatus=="positive"){contactitemRect.color="light green"}
|
||||
else if (contactstatus=="negative"){contactitemRect.color= "light red"}
|
||||
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";
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
Text{
|
||||
x:contactView.width+2*mm
|
||||
y:0.5*mm
|
||||
text: "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
|
||||
height: 5*mm
|
||||
property string groupstatus:"neutral"
|
||||
onGroupstatusChanged:
|
||||
{if(groupstatus=="positive"){groupitemRect.color="light green"}
|
||||
else if (groupstatus=="negative"){groupitemRect.color= "light red"}
|
||||
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"}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin:1
|
||||
text:qsTr("Done")
|
||||
onClicked:{//var group_allow=[];var group_deny=[];
|
||||
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++)
|
||||
{//print("contact: "+JSON.stringify(contactModel.get(j).contact));
|
||||
if (contactModel.get(j).contactstatus=="positive"){
|
||||
print(JSON.stringify(contact_allow));
|
||||
contact_allow.push(contactModel.get(j).contact.cid)
|
||||
}
|
||||
if (contactModel.get(j).contactstatus=="negative"){
|
||||
contact_deny.push(contactModel.get(j).contact.cid)
|
||||
}
|
||||
}
|
||||
//print("contacts: "+Helperjs.cleanArray(contact_allow))
|
||||
permissionDialog.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted:{
|
||||
Helperjs.readData(db,"contacts",login.username,function(contacts){
|
||||
for (var name in contacts){
|
||||
contactModel.append({"contact":contacts[name],"contactstatus":"neutral"})
|
||||
}},"isFriend",1);
|
||||
|
||||
Helperjs.readData(db,"groups",login.username,function(owngroups){
|
||||
for (var number in owngroups){
|
||||
groupModel.append({"group":owngroups[number],"groupstatus":"neutral"})
|
||||
}});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue