Version 0.002 with working Favorite Combobox

This commit is contained in:
LubuWest 2016-11-14 13:28:23 +01:00
commit 571c9046d0
42 changed files with 1948 additions and 814 deletions

View file

@ -187,7 +187,8 @@ onCurrentIndexChanged:{
if (errormessage=="") {
filesystem.Directory=userconfig.imagestore;
filesystem.makeDir("contacts");
Service.storeConfig(db,userconfig);
filesystem.makeDir("albums");
Service.storeConfig(db,userconfig);
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
var serverString=obj;
var serverconfigObject=Qt.createQmlObject(serverString,configBackground,"serverconfigOutput");
@ -236,13 +237,14 @@ onCurrentIndexChanged:{
}
Component.onCompleted: {
try{Helperjs.readData(db,"config",root.login.username,function(users){
try{print("get users");
Helperjs.readData(db,"config","",function(users){
users.sort(function(obj1, obj2) {
return obj1.isActive - obj2.isActive;
});
for (var i=0; i<users.length;i++){
if (users[i]) {usermodel.append({text:users[i].username});};
};})}
}})}
catch (e){print(e)}
}
}

View file

@ -0,0 +1,137 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
Item {
id: contactComponent
property var createdAtDate: new Date(contact.created_at)
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
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:(contact.isFriend==1)? "file://"+contact.profile_image :contact.profile_image_url
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
}
Label {
id: namelabel
x: 1
width: wrapper.width-4
height: 3*mm
text: contact.screen_name
elide:Text.ElideRight
anchors.topMargin: 0
anchors.left: photoImage.left
color: "#303030"
font.pixelSize: 3*mm
anchors.top: photoImage.bottom
}
Button{
id:infobutton
width: 5*mm
height: 5*mm
text:"?"
anchors.left: photoImage.right
anchors.leftMargin: 3
anchors.topMargin: 3
anchors.top: parent.top
onClicked:{
//print("State: "+ friendComponent.state);
contactComponent.state="large"}
}
Rectangle{
id: detailsrectangle
anchors.top: namelabel.bottom
anchors.topMargin: 2*mm
opacity: 0
Flickable{
id:namelabelflickable
width: root.width-10*mm
height:friendsTabView.height-55*mm
boundsBehavior:Flickable.StopAtBounds
flickableDirection:Flickable.VerticalFlick
contentWidth:width
contentHeight: namelabeltext.height
clip:true
Text{
id:namelabeltext
//anchors.top: parent.top
width: namelabelflickable.width
height: implicitHeight
font.pixelSize: 3*mm
textFormat:Text.RichText
wrapMode: Text.Wrap
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
onLinkActivated: {
Qt.openUrlExternally(link)}
}
}
Row{
anchors.top: namelabelflickable.bottom
anchors.topMargin: 2*mm
spacing:4
Button{
id:photobutton
text:"Photos"
visible:contact.location=="Friendica"? 1:0
onClicked:{contactComponent.state="";
root.currentIndex=2;
fotostab.active=true;
root.fotoSignal(contact) ;
}
}
Button{
id:messagebutton
text:"Messages"
onClicked:{contactComponent.state="";
root.currentIndex=0;
newstab.active=true;
root.messageSignal(contact.id) ;
}
}
Button{
id:dmbutton
visible: contact.following=="true"?true:false
text: "DM"
onClicked:{contactComponent.state="";
root.currentIndex=0;
newstab.active=true;
root.directmessageSignal(contact.screen_name);
}
}
Button{
id: closeButton
text: "close"
onClicked:{contactComponent.state=""}
}
}
}
}
states: [
State {
name: "large"
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
PropertyChanges { target: contactComponent; z: 2 }
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
PropertyChanges { target: detailsrectangle; opacity:1 }
}
]
}

View file

@ -1,6 +1,7 @@
import QtQuick 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import "qrc:/js/service.js" as Service
import "qrc:/js/helper.js" as Helperjs
import "qrc:/js/news.js" as Newsjs
@ -17,17 +18,35 @@ Rectangle {
tabPosition: Qt.TopEdge
x:mm
y:mm
width: root.width-5*mm
width: root.width-2*mm
height: root.height-10*mm
currentIndex: 0
signal friendsSignal(var username)
signal contactsSignal(var username)
signal groupsSignal(var username)
onCurrentIndexChanged:{
if (currentIndex==0){friendsSignal(root.login.username)}
if (currentIndex==0){root.friendsSignal(root.login.username)}
else if (currentIndex==1){contactsSignal(root.login.username)}
else if (currentIndex==2){groupsSignal(root.login.username)}
}
style: TabViewStyle {
frameOverlap: 1
tab: Rectangle {
color: "white"
//border.color: "light grey"
implicitWidth: root.width/3-2*mm
implicitHeight: 4*mm
Text { id: text
anchors.centerIn: parent
text: styleData.title
color: "dark grey"
font.pixelSize:2.5*mm
font.bold: styleData.selected
}
}
frame: Rectangle { color: "light grey" }
tabsAlignment:Qt.AlignHCenter
}
Tab{
title: qsTr("Friends")
@ -35,15 +54,16 @@ Rectangle {
id: friendsGridTab
function showFriends(username){
try {friendsModel.clear()} catch(e){print(e)};
Helperjs.readData(db,"contacts",username,function(friends){
for (var i=0;i<friends.length;i++){
friendsModel.append({"friend":friends[i]});
Helperjs.readData(db,"contacts",username,function(friendsobject){
for (var i=0;i<friendsobject.length;i++){
friendsModel.append({"contact":friendsobject[i]});
}},"isFriend",1)
}
Button {
id: updateFriendsButton
text: qsTr("Update")
anchors.top: parent.top
anchors.topMargin: mm
anchors.right: parent.right
onClicked: {
try {friendsModel.clear()} catch(e){print(e)};
@ -67,7 +87,7 @@ Rectangle {
GridView {
id: friendsView
x:mm
y:updateFriendsButton.height+mm
y:updateFriendsButton.height+2*mm
width:friendsGridTab.width-2*mm
height:friendsGridTab.height-updateFriendsButton.height-2*mm
clip: true
@ -77,7 +97,7 @@ Rectangle {
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
}
model: friendsModel
delegate: FriendComponent { }
delegate: ContactComponent { }
}
ListModel{id:friendsModel}
@ -85,7 +105,7 @@ Rectangle {
Component.onCompleted: {
friendsTabView.friendsSignal.connect(showFriends);
root.friendsSignal.connect(showFriends);
showFriends(root.login.username)
}
}
@ -98,16 +118,16 @@ Rectangle {
id: contactsGridTab
function showContacts(username){
try {contactsModel.clear()} catch(e){print(e)};
Helperjs.readData(db, "contacts",root.login.username,function(friendsobject){
for (var j=0;j<friendsobject.length;j++){
contactsModel.append({"friend":friendsobject[j]});
Helperjs.readData(db, "contacts",root.login.username,function(contactsobject){
for (var j=0;j<contactsobject.length;j++){
contactsModel.append({"contact":contactsobject[j]});
}
},"isFriend",0)}
GridView {
id: contactsView
x:mm
y:mm
y:2*mm
width:contactsGridTab.width-2*mm
height:contactsGridTab.height-2*mm
clip: true
@ -117,7 +137,7 @@ Rectangle {
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
}
model: contactsModel
delegate: FriendComponent { }
delegate: ContactComponent { }
}
ListModel{id: contactsModel}
@ -132,7 +152,6 @@ Rectangle {
id: groupsGridTab
function showGroups(username){
try {groupsModel.clear()} catch(e){print(e)};
print("showGroups"+username);
Helperjs.readData(db, "groups",root.login.username,function(groupsobject){
for (var j=0;j<groupsobject.length;j++){
groupsModel.append({"group":groupsobject[j]});
@ -141,6 +160,7 @@ Rectangle {
id: updateGroupsButton
text: qsTr("Update")
anchors.top: parent.top
anchors.topMargin: mm
anchors.right: parent.right
onClicked: {
print("Update groups");
@ -150,7 +170,7 @@ Rectangle {
GridView {
id: groupsView
x:mm
y:updateGroupsButton.height+mm
y:updateGroupsButton.height+2*mm
width:groupsGridTab.width-2*mm
height:groupsGridTab.height-updateGroupsButton.height-2*mm
clip: true

View file

@ -1,11 +1,8 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
import "qrc:/js/service.js" as Service
import "qrc:/js/layout.js" as Layoutjs
import "qrc:/js/helper.js" as Helperjs
Item {
id: groupComponent
Rectangle {
id: wrapper
width: 16*mm
@ -13,6 +10,14 @@ import "qrc:/js/layout.js" as Layoutjs
border.color: "grey"
color:"white"
Image {
id: photoImage
x:1
y:1
width: 10*mm
height:10*mm
source:"qrc:/images/defaultcontact.jpg"
}
Label {
id: namelabel
x: 1
@ -22,127 +27,92 @@ import "qrc:/js/layout.js" as Layoutjs
color: "#303030"
font.pixelSize: 3*mm
anchors.centerIn:parent
anchors.top: photoImage.bottom
}
Button{
id:infobutton
width: 5*mm
height: 5*mm
text:"?"
anchors.top: namelabel.bottom;anchors.topMargin: 3
anchors.left: photoImage.right
anchors.leftMargin: 3
anchors.topMargin: 3
anchors.top: parent.top
onClicked:{
print("State: "+ groupComponent.state+groupView.contentY);
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){
groupModel.append({"groupmember":userdata[0]});
},"id",groupmembers[user])}
},"groupname",group.groupname);
groupComponent.state="large"}
}
Rectangle{
id: detailsrectangle
anchors.top: infobutton.bottom
anchors.top: namelabel.bottom
anchors.topMargin: 2*mm
opacity: 0
Component { id:footerComponent
Rectangle{
border.color: "#EEEEEE"
border.width: 1
width:parent.width
height:6*mm
Text{
font.pixelSize: 3*mm
anchors.centerIn: parent
text:qsTr("+")
}
MouseArea{anchors.fill:parent
onClicked:{var contactitems="";
readData(db,"contacts",root.login.username, function(contacts){for (var i=0;i<contacts.length;i++){
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"'; onTriggered: groupModel.append(' @"+contacts[i]+"')}"
}},"isFriend",0)
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
print("menustring: "+menuString);
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput");
contactlistObject.popup();
Newsjs.addToGroup
}}}}
Component { id:groupMember
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: parent.left
text:groupmember.screen_name
anchors.left: memberImage.right
anchors.margins: 1*mm
text:Qt.atob(groupmember.name)
}
}}
ListView{
id:namelabeltext
anchors.top: parent.top
ListView{
id: groupListView
x:1
//anchors.top: parent.top
width: root.width-10*mm
height:wrapper.height-20*mm
height:groupsView.height -28*mm
clip: true
spacing: 0
footer: footerComponent
spacing: 2
model: groupModel
delegate: groupMember
}
ListModel{id: groupModel}
}
Row{
anchors.top: namelabeltext.bottom
anchors.topMargin: 2*mm
spacing:4
Button{
id:photobutton
text:"Photos"
visible:friend.location=="Friendica"? 1:0
onClicked:{root.currentIndex=2;
fotostab.active=true;
root.fotoSignal(friend) ;
}
}
Button{
id:messagebutton
text:"Messages"
onClicked:{root.currentIndex=0;
newstab.active=true;
root.messageSignal(friend.id) ;
}
}
Button{id:dmbutton
visible: friend.following=="true"?true:false
text: "DM"
onClicked:{root.currentIndex=0;
newstab.active=true;
root.directmessageSignal(friend.screen_name);
}
}
Button{
id: closeButton
text: "close"
onClicked:{friendComponent.state=""}
}
}
Button{
id: closeButton
anchors.top: groupListView.bottom
x:1
text: "close"
onClicked:{groupComponent.state=""}
}
}
}
states: [
State {
name: "large"
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsView.width; text:Qt.atob(friend.name)+" (@"+friend.screen_name+")"}
PropertyChanges { target: friendComponent; z: 2 }
PropertyChanges { target: wrapper; width:friendsView.width;height:friendsView.height -2*mm-1}
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
PropertyChanges { target:friendComponent.GridView.view ;contentY:friendComponent.y;contentX:friendComponent.x;interactive:false}
PropertyChanges { target: detailsrectangle; opacity:1 }
}
name: "large"
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:groupsView.width}
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 }
}
]
}

View file

@ -7,7 +7,7 @@ Rectangle{
Text{id:infoBoxText
textFormat: Text.RichText
wrapMode: Text.Wrap
text: "<b>Friendiqa v0.001 </b><br>Licensed under GPL 3<br> "+
text: "<b>Friendiqa v0.002 </b><br>Licensed under GPL 3<br> "+
"Sourcecode: <a href='https://github.com/LubuWest/Friendiqa'>https://github.com/LubuWest/Friendica</a><br>"+
"C++ code by <a href='https://kirgroup.com/profile/fabrixxm'>Fabio</a><br>"+
"QML and Javascript code by <a href='https://freunde.ma-nic.de/profile/marco'>Marco</a>"

View file

@ -5,18 +5,22 @@ import QtQml 2.2
import QtQuick.Controls 1.3
import QtQuick.Dialogs 1.2
import QtQuick.LocalStorage 2.0
//import "../qml"
import "qrc:/js/service.js" as Service
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: []
// title: parentId !== "" ? qsTr("Reply to "+reply_to_user) : qsTr("New post")
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 string contact_allow:""
property string contact_deny:""
property string group_allow:""
property string group_deny:""
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
xhr.url= login.server + "/api/statuses/update.xml";
@ -46,7 +50,7 @@ Item{
Column {
id:messageColumn
spacing: 2
width: parent.width
TextField {
id: titleField
width: parent.width
@ -59,8 +63,13 @@ Item{
width: parent.width
height: 30*mm
wrapMode: TextEdit.Wrap
textFormat: TextEdit.RichText
}
CheckBox{
Row{
spacing: 2
CheckBox{
id:dmCheckbox
text:"DM"
enabled: false
@ -70,18 +79,59 @@ CheckBox{
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 {
id: cancelButton
text: qsTr("Cancel")
onClicked: {newsStack.pop()}
}
Button{
text:qsTr("Permissions")
onClicked: {
var component = Qt.createComponent("qrc:/qml/PermissionDialog.qml");
var sprite = component.createObject(messageColumn);
if (sprite == null) { // Error Handling
console.log("Error creating object"); }
}}
Button {
id: attachButton
text: qsTr("Attach")
onClicked: {imageAttachmentDialog.open()}
onClicked: {
try{imageAttachment.visible=false;
imageAttachment.opacity=0;imageAttachment.destroy()}catch(e){}
imageAttachmentDialog.open()}
}
Button{
id:contactButton
@ -90,43 +140,49 @@ CheckBox{
onClicked:{
var contactitems="";
for (var i=0;i<contacts.length;i++){
contactitems=contactitems+"MenuItem{text:'"+contacts[i]+"'; onTriggered: bodyField.append(' @"+contacts[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+"}";
// print(menuString);
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput")
contactlistObject.popup() }
}
Button {
id: sendButton
text: qsTr("Send")
onClicked: {
print("login: "+login.server+login.username);
if (directmessage==0){
statusUpdate(titleField.text,bodyField.text,messageSend.parentId,attachImageURL.toString());}
else {dmUpdate( titleField.text,bodyField.text,"",messageSend.reply_to_user) }
newsStack.pop()
}
}
}
}
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()
}
}
}
}
FileDialog {
id: imageAttachmentDialog
title: "Please choose a picture"
folder: shortcuts.pictures
selectFolder: false
onAccepted: {
attachImageURL=imageAttachmentDialog.fileUrl;
var imageAttachementObject=Qt.createQmlObject('import QtQuick 2.0; Image {source:"'+attachImageURL.toString()+'"; width: 30*mm; height: 30*mm;fillMode: Image.PreserveAspectFit}',messageColumn,"attachedImage");
console.log("You chose: " + attachImageURL)
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")
//console.log("Canceled")
}
}
}

View file

@ -21,6 +21,7 @@ Item {
}
function onDirectMessage(friend){
print(root.login.server);
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
}
@ -51,13 +52,43 @@ Item {
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){
JSON.stringify("Favorites: "+news);
Newsjs.storeNews(root.login,root.db,news,root,function(){
Newsjs.favoritesfromdb(db,root.login.username,function(newsarray){
JSON.stringify("FavoritesArray: "+newsarray);showNews(newsarray)
});
}
)})
}
}}
Button {
id: newMessageButton
text: qsTr("+")
anchors.top: parent.top
anchors.right: parent.right
onClicked: {
Helperjs.readField("screen_name",root.db,"contacts",root.login.username,function(friends){
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/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
},"isFriend",1);
}
@ -150,6 +181,6 @@ Item {
showNews(dbnews)
})
}
}
}
}
}

View file

@ -3,15 +3,13 @@ import QtQuick.LocalStorage 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import "qrc:/js/news.js" as Newsjs
import "qrc:/js/layout.js" as Layoutjs
Item {
id: newsitem
width: newsView.width
height:Math.max((itemMessage.height+createdAtLabel.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
height:Math.max((itemMessage.height+topFlow.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
// property var friendica_activities
property string conversation_id: ""
property string attending: ""
onAttendingChanged: {attendLabel.visible=true;
@ -23,7 +21,7 @@ Item {
Rectangle{
width:newsitem.width
height:newsitem.height-1
color: (newsitemobject.directmessage)?"#ffe6e6" : "white"
color: (newsitemobject.messagetype==1)?"#ffe6e6" : "white"
Column {
id: authorcolumn
@ -31,7 +29,7 @@ Item {
Image {
id:profileImage
source: "file://"+newsitemobject.user.profile_image
source:(newsitemobject.user.isFriend==1)? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
x:1
width: 7*mm
height: 7*mm
@ -53,10 +51,13 @@ Item {
}
Column {
id:newscolumn
width: newsitem.width-8*mm
anchors.left: authorcolumn.right
Row{
spacing: 5*mm
Flow{
id:topFlow
spacing: 2*mm
width:parent.width
Label {
color: "grey"
text: if (newsitemobject.messagetype==0){qsTr("Source: ")+newsitemobject.source
@ -66,9 +67,9 @@ Item {
Label {
id:createdAtLabel
color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
horizontalAlignment: Label.AlignRight
height:3.5*mm
font.pixelSize: 1.5*mm
horizontalAlignment: Label.AlignRight
text: dateDiff
}
CheckBox {
@ -104,8 +105,53 @@ Item {
{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
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();
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
newsWorker.sendMessage(msg);
newsBusy.running=false
});
}
)})
}}
}}
Text {
color: "#404040"
@ -116,10 +162,10 @@ Item {
width: newsitem.width-8*mm-2
height: implicitHeight
wrapMode: Text.Wrap
onLinkActivated:{ print("link "+link);
Qt.openUrlExternally(link)}
onLinkActivated:{
Qt.openUrlExternally(link)}
}
Row{id: friendicaActivities
Row{id:friendicaActivities
spacing:mm
Label{color: "grey"
font.pixelSize: 1.5*mm
@ -141,13 +187,13 @@ Item {
font.pixelSize: 1.5*mm
text: friendica_activities.attendmaybeText
}
}
Row {
}
Row {
CheckBox{id:likeCheckbox
height:3*mm
width:8*mm
checked:(newsitemobject.liked==1)?true:false
style: CheckBoxStyle {
checked:(friendica_activities.self.liked)?true:false
style: CheckBoxStyle {
background: Rectangle {
implicitWidth: 7*mm
implicitHeight: 3*mm
@ -170,11 +216,11 @@ Row {
else{Newsjs.like(root.login,root.db,0,"like",newsitemobject.status_id,root)}}
}
CheckBox{id: dislikeCheckbox
height:3*mm
width:8*mm
checked: (newsitemobject.disliked==1)?true:false
style: CheckBoxStyle {
background: Rectangle {
height:3*mm
width:8*mm
checked: (friendica_activities.self.disliked)?true:false
style: CheckBoxStyle {
background: Rectangle {
implicitWidth: 7*mm
implicitHeight:3*mm
color:"white"
@ -211,7 +257,7 @@ Row {
height:3.5*mm
font.pixelSize: 1.5*mm
horizontalAlignment: Label.AlignRight
text: qsTr("attending: ")+ qsTr(attending)
text: (friendica_activities.self.attending)?qsTr("attending: ")+ qsTr(attending):""
}
}
}
@ -221,10 +267,10 @@ Row {
MenuItem {
text: qsTr("Reply")
onTriggered: {
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id}});
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id,"login":root.login}});
}
}
MenuItem {
MenuItem {
text: qsTr("DM")
onTriggered: {
root.directmessageSignal(newsitemobject.user.screen_name);
@ -241,16 +287,20 @@ MenuItem {
MenuItem {
text: qsTr("Conversation")
onTriggered: {
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root,function(){
var currentTime= new Date();
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
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")
@ -275,8 +325,8 @@ Menu{
MenuItem {
text: qsTr("Delete")
onTriggered: {
Newsjs.deleteNews(root.login,db,newsitemobject.status_id,root,function(reply){
print(JSON.stringify(reply));
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,root,function(reply){
print("Deleted "+reply);
newsModel.remove(index);
})
}

View file

@ -0,0 +1,126 @@
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]})
}});
}
}

View file

@ -18,17 +18,42 @@ Rectangle {
// photoWorker.sendMessage(msg);
//}
onNewImagesChanged:{
Helperjs.readField("album",root.db,"imageData",root.login.username,function(albums){
//print("albums"+JSON.stringify(albums)+JSON.stringify(newImages[currentImageNo]));
if(albums.indexOf(newImages[currentImageNo].album)==-1){
filesystem.Directory=root.login.imagestore+"/albums";
filesystem.makeDir(newImages[currentImageNo].album);}
});
if(newImages.length>0){
print("Current image number"+currentImageNo)
Service.dataRequest(root.login,newImages[currentImageNo].id,root.db,fotorectangle);
newImagesProgress.visible=true //download first image
}}
onCurrentImageNoChanged:{
if(currentImageNo<newImages.length){Service.dataRequest(root.login,newImages[currentImageNo].id,root.db,fotorectangle)};
if(currentImageNo==newImages.length){newImagesProgress.visible=false;showOwnFotos();
newImages=[];currentImageNo=0}
// download next image if photoplaceholder is finished saving
// download next image if photoplaceholder is finished saving
}
function showOwnFotos(){
try {photogroupModel.clear()}catch (e){print(e)}
Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
if (albums[0]) {
var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false};
photoWorker.sendMessage(msg);
};
})
}
function onFriendsFotos(friend){print("Friend "+friend.url);
try {photogroupModel.clear()}catch (e){print(e)}
Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true};
photoWorker.sendMessage(msg);
})
}
ProgressBar{
id: newImagesProgress
@ -118,23 +143,5 @@ Button {
ListView {anchors.fill: parent; model: visualphotoModel.parts.fullscreen; interactive: false }
WorkerScript{id: photoWorker;source: "qrc:/js/photoworker.js"}
function showOwnFotos(){
try {photogroupModel.clear()}catch (e){print(e)}
Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
if (albums[0]) {
var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false};
photoWorker.sendMessage(msg);
};
})
}
function onFriendsFotos(friend){print("Friend "+friend.url);
try {photogroupModel.clear()}catch (e){print(e)}
Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true};
photoWorker.sendMessage(msg);
})
}
Component.onCompleted: { root.fotoSignal.connect(onFriendsFotos);}
Component.onCompleted: { root.fotoSignal.connect(onFriendsFotos);}
}

View file

@ -3,6 +3,7 @@ import QtQuick.LocalStorage 2.0
import QtQuick.Window 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQml.Models 2.1
import "qrc:/js/news.js" as Newsjs
@ -16,7 +17,7 @@ TabView{
id:root
tabPosition: Qt.BottomEdge
width: Screen.desktopAvailableWidth
height: Screen.desktopAvailableHeight
height: Screen.desktopAvailableHeight
property var db: ["Photos", "1.0", "Stores Friendica data", 100000000]
property var login: Service.readActiveConfig(db)
@ -26,7 +27,7 @@ TabView{
signal fotoSignal(var friend)
signal directmessageSignal(var friend)
signal newsSignal(var news)
signal friendsSignal(var username)
currentIndex: (login=="")? 3:0
@ -39,11 +40,11 @@ TabView{
newsSignal(dbnews)
})}
onNewContactsChanged:{if(newContacts.length>0){// download first contact image and update db
print("newcontact"+JSON.stringify(newContacts[0]));
// print("newcontact"+JSON.stringify(newContacts));
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
}
onCurrentContactChanged:{// download next contact image after photoplaceholder is finished saving and update db
print("Current contact"+JSON.stringify(newContacts[currentContact]));
//print("Current contact"+JSON.stringify(newContacts[currentContact]));
if(currentContact<newContacts.length){
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
@ -66,25 +67,56 @@ TabView{
}
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
try{var imagename=login.imagestore+"contacts/"+contact.screen_name+".jpg";
var component=Qt.createComponent("qrc:/qml/PhotoPlaceholder.qml");
print("imageName "+imagename+" source "+ contact.profile_image_url)
var sprite = component.createObject(root, {"fillMode": "Image.PreserveAspectFit","x":root.width,"y":50,"imageName":imagename,"source": contact.profile_image_url,"downloadtype":"contact"});} catch(e){print("Fehler beim Profilbild"+e)}
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+".jpg";
if (isFriend==1){
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
xhr.setFilename(imagename);
xhr.download();
}
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
var result;
db.transaction( function(tx) {
result = tx.executeSql('SELECT * from contacts where id = '+contact.id); // check for news id
if(result.rows.length === 1) {// use update
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'",description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Newsjs.cleanDate(contact.created_at)+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
} else {// use insert
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Newsjs.cleanDate(contact.created_at),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,contact.profile_image_url, Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Date.parse(Newsjs.cleanDate(contact.created_at)),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
});
if (isFriend!=1){root.currentContact=root.currentContact+1}
}
Connections{
target:xhr
onDownloaded:{root.currentContact=root.currentContact+1}
}
Connections{
target:xhr
onError:{print("Error"+data)}
}
Component.onCompleted: {
if (login==""){Service.initDatabase(db)}
Helperjs.readField("id",db,"contacts",login.username,function(contacts){contactlist=contacts},"isFriend",1)
}
style: TabViewStyle {
frameOverlap: 1
tab: Rectangle {
color: styleData.selected?"white":"light blue"
border.color: "light grey"
implicitWidth: root.width/4-2*mm
implicitHeight: 4*mm
Text { id: text
anchors.centerIn: parent
text: styleData.title
color: "black"
font.pixelSize:3*mm
font.bold: styleData.selected
}
}
frame: Rectangle { color: "light grey" }
tabsAlignment:Qt.AlignHCenter
}
Tab{
title: qsTr("News")
id: newstab