Version 0.004

This commit is contained in:
LubuWest 2017-05-11 22:15:34 +02:00
commit 438f8a4e4d
64 changed files with 2736 additions and 636 deletions

View file

@ -13,23 +13,13 @@ Item {
}
}
Connections{
target:newstab
onConversationChanged:{
newsBusy.running=false;
newstab.newstabstatus="Conversation";
//newsStack.push({item:"qrc:/qml/newsqml/Conversation.qml",properties:{"news": conversation}})
showNews(conversation);
}
}
Connections{
target:root
onCurrentContactChanged:{
if (root.newContacts.length>0){
if(root.currentContact<root.newContacts.length){
downloadNotice.text= qsTr("Download profile image for ")+ root.newContacts[root.currentContact].name;
print(root.newContacts[root.currentContact].name)
//print(root.newContacts[root.currentContact].name)
}
}else{downloadNotice.text=""}
}
@ -62,23 +52,19 @@ Item {
newsWorker.sendMessage(msg);
}
function showConversation(timelineIndex,newsitemobject){
function showConversation(conversationIndex,newsitemobject){
newsBusy.running=true;
root.contactLoadType="conversation";
newsStack.timelineIndex= timelineIndex;
if(newsitemobject.messagetype==0){
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(ns,nc){
newsStack.conversationIndex= conversationIndex;
if(newsitemobject.messagetype==0){
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(ns,nc){
root.news=ns;root.newContacts=nc;root.currentContact=0;
})}
else{Newsjs.conversationfromdb(root.db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
root.news=newsarray;root.newContacts=[];root.currentContact=1;
})}
else{Newsjs.conversationfromdb(root.db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
root.news=newsarray;root.newContacts=[];root.currentContact=1;
})}
}
function onFriendsMessages(friend){
newstab.newstabstatus="Contact"
Newsjs.newsfromdb(db,root.login.username, function(dbnews){showNews(dbnews)},friend)
@ -92,14 +78,11 @@ Item {
StackView{
id: newsStack
anchors.fill:parent
property int timelineIndex: 0
onTimelineIndexChanged:print("timelineindex:"+ timelineIndex)
property int conversationIndex: 0
initialItem:Rectangle {
initialItem:Rectangle {
y:1
color: "white"
width:root.width-2*mm
height:root.height-8*mm
BlueButton{
id:newstabstatusButton
@ -116,26 +99,27 @@ Item {
anchors.right: parent.right
BlueButton {
id: newMessageButton
width:10*mm
text: "\uf040"
onClicked: {
var groups=[];
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
groups=groupobject});
newstab.newstabstatus="SendMessage";
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);
}
}
BlueButton {
id: quitButton
width:10*mm
text: "\uf08b"
onClicked: {Service.cleanNews(root.db,function(){Qt.quit() })}
}
BlueButton {
id: newMessageButton
width:10*mm
text: "\uf040"
onClicked: {
var groups=[];
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
groups=groupobject
});
newstab.newstabstatus="SendMessage";
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);
}
}
BlueButton {
id: quitButton
width:10*mm
text: "\uf08b"
onClicked: {Service.cleanNews(root.db,function(){Qt.quit() })}
}
BlueButton {
id: update
text: "\uf021"
onClicked: {
@ -176,7 +160,7 @@ Item {
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
newsWorker.sendMessage(msg);
},false,lastnews_id)}
if(newstab.newstabstatus=="Tree"){
if(newstab.newstabstatus=="Conversations"){
var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;
Newsjs.chatsfromdb(root.db,root.login.username, function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
@ -191,83 +175,35 @@ Item {
}
}
Component { id:footerReply
Rectangle{
border.color: "#EEEEEE"
border.width: 1
color:"lightgrey"
width:newsView.width
height:Math.max(replyText.contentHeight+2*mm,6*mm)
Rectangle{
color: "white"
radius:0.5*mm
anchors.left: parent.left
anchors.leftMargin:mm
anchors.top:parent.top
anchors.topMargin: 0.5*mm
width:parent.width-12*mm
height:Math.max( replyText.contentHeight,5*mm)
TextInput {
id: replyText
font.pixelSize: 3*mm
wrapMode: Text.Wrap
//width: parent.width
anchors.fill: parent
selectByMouse: true
}
}
BlueButton {
id: sendButton
text: "\uf1d9"
anchors.right: parent.right
anchors.rightMargin:mm
anchors.top:parent.top
anchors.topMargin: 0.5*mm
color:"white"
onClicked: { try{
var body=replyText.getText(0,replyText.length);
newsBusy.running=true;
replyText.text=""
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
if (newsModel.get(0).newsitemobject.messagetype==0){
xhr.setParam("source", "Friendiqa");
xhr.url= login.server + "/api/statuses/update.json";
xhr.setParam("status", body);
xhr.setParam("in_reply_to_status_id", newsModel.get(newsModel.count-1).newsitemobject.status_id)}
else {xhr.url= login.server + "/api/direct_messages/new.json";
xhr.setParam("text", body);
xhr.setParam("screen_name",newsModel.get(newsModel.count-1).newsitemobject.screen_name);
xhr.setParam("replyto", newsModel.get(newsModel.count-1).newsitemobject.status_id)
}
xhr.post();
//replyText.text=""
} catch(e){Helperjs.showMessage("Error",e.toString(),root)}
}
}
}
}
ListView {
id: newsView
anchors.fill: parent
anchors.topMargin: 8*root.mm
anchors.topMargin: 7*root.mm
anchors.leftMargin: 3*root.mm; anchors.rightMargin: root.mm
anchors.bottomMargin: 1*root.mm
clip: true
spacing: 0
footer: (newstab.newstabstatus=="Conversation")?footerReply:footerComponent
footer: footerComponent
model: newsModel
delegate: Newsitem{}
Component.onCompleted: {//print(newstab.newstabstatus);
if(newstab.newstabstatus!="Conversation"){
positionViewAtIndex(newsStack.timelineIndex-1, ListView.Beginning)}
else {positionViewAtBeginning();
newsStack.timelineIndex=0
}}
}
//onContentYChanged:{if(contentY<-15*mm&&contentY>(-15*mm-1)){print("refreshing");
onDragEnded:{if(contentY<-8*mm){//print("refreshing");
newsBusy.running=true;
newstab.newstabstatus=login.newsViewType;
root.contactLoadType="news";
var onlynew=true;
Newsjs.getFriendsTimeline(login,db,contactlist,onlynew,newstab,function(ns,nc){
root.news=ns;root.newContacts=nc;root.currentContact=0;
if (ns.length==0){// update last 20 existing news for changes and likes
onlynew=false;
Newsjs.getFriendsTimeline(login,db,contactlist,onlynew,newstab,function(rns,rnc){
root.contactLoadType="news";
root.news=rns;root.newContacts=rnc;root.currentContact=0})
}
})
}}
}
ListModel{id: newsModel}
@ -331,10 +267,10 @@ Item {
}
MenuItem {
text: qsTr("Tree")
text: qsTr("Conversations")
onTriggered:{
newsModel.clear();
newstab.newstabstatus="Tree";
newstab.newstabstatus="Conversations";
Newsjs.chatsfromdb(db,root.login.username,function(news){showNews(news)})
}
}