2018-02-19 22:36:00 +01:00
|
|
|
// This file is part of Friendiqa
|
2018-11-09 22:06:13 +01:00
|
|
|
// https://git.friendi.ca/lubuwest/Friendiqa
|
2018-02-19 22:36:00 +01:00
|
|
|
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
|
|
|
//
|
|
|
|
// 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-08-25 16:17:09 +02:00
|
|
|
import QtQuick 2.7
|
|
|
|
import QtQuick.Controls 1.4
|
|
|
|
import QtQuick.Controls 2.3 as QC2
|
2018-07-20 21:15:54 +02:00
|
|
|
//import QtQuick.Controls.Styles 2.3
|
2018-07-01 15:09:21 +02:00
|
|
|
import QtQuick.Dialogs 1.3
|
2017-01-26 21:55:31 +01:00
|
|
|
import "qrc:/qml/genericqml"
|
|
|
|
import "qrc:/js/news.js" as Newsjs
|
|
|
|
import "qrc:/js/helper.js" as Helperjs
|
|
|
|
import "qrc:/js/service.js" as Service
|
|
|
|
|
2018-04-11 21:50:43 +02:00
|
|
|
|
2019-01-09 22:03:16 +01:00
|
|
|
import AndroidNative 1.0
|
|
|
|
|
2017-01-26 21:55:31 +01:00
|
|
|
Item {
|
|
|
|
Connections{
|
|
|
|
target:newstab
|
|
|
|
onNewstabstatusChanged:{
|
|
|
|
newstabstatusButton.text= qsTr(newstab.newstabstatus)
|
|
|
|
}
|
|
|
|
}
|
2017-01-29 17:26:09 +01:00
|
|
|
|
|
|
|
Connections{
|
|
|
|
target:xhr
|
2018-07-01 15:09:21 +02:00
|
|
|
onError:{
|
2018-08-25 16:17:09 +02:00
|
|
|
Helperjs.showMessage(qsTr("Network Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root);
|
2018-07-01 15:09:21 +02:00
|
|
|
}
|
|
|
|
onSuccess:{
|
|
|
|
// downloadNotice.text=downloadNotice.text+ "\n xhr finished "+Date.now();
|
|
|
|
Service.processNews(api,data);
|
2017-03-25 23:36:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-09 22:03:16 +01:00
|
|
|
// Connections{
|
|
|
|
// target:xhr
|
|
|
|
// onError:{
|
|
|
|
// Helperjs.showMessage(qsTr("Network Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root);
|
|
|
|
// }
|
|
|
|
// onSuccess:{
|
|
|
|
// if (api=="/api/statuses/friends_timeline"){
|
|
|
|
// // downloadNotice.text=downloadNotice.text+ "\n xhr finished "+Date.now();
|
|
|
|
// //Service.processNews(api,data);
|
|
|
|
// if(login.newsViewType=="Timeline"){
|
|
|
|
// Newsjs.newsfromdb(db,login.username,function(dbnews){showNews(dbnews)})}
|
|
|
|
// else{Newsjs.chatsfromdb(db,login.username,function(dbnews){
|
|
|
|
// showNews(dbnews);
|
|
|
|
// })}
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
2017-03-25 23:36:14 +01:00
|
|
|
Timer {id:replytimer; interval: 1000; running: false; repeat: false
|
2018-02-19 22:36:00 +01:00
|
|
|
onTriggered: {
|
|
|
|
if(newstab.newstabstatus=="Conversation"){
|
|
|
|
showConversation(newsStack.timelineIndex-1,newsModel.get(0).newsitemobject)}
|
|
|
|
else{
|
2018-07-01 15:09:21 +02:00
|
|
|
Service.updateView(newstab.newstabstatus)
|
2018-02-19 22:36:00 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-29 17:26:09 +01:00
|
|
|
}
|
|
|
|
|
2018-07-01 15:09:21 +02:00
|
|
|
Timer {id:contacttimer; interval: 50; running: false; repeat: false
|
|
|
|
onTriggered: {
|
|
|
|
// downloadNotice.text=downloadNotice.text + "\n contactTimer start "+ Date.now()
|
|
|
|
root.newContacts=Newsjs.findNewContacts(root.news,root.contactlist);
|
|
|
|
Newsjs.storeNews(login,db,root.news,root)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-25 23:36:14 +01:00
|
|
|
|
2017-01-26 21:55:31 +01:00
|
|
|
function showNews(newsToShow){
|
2018-10-01 21:17:54 +02:00
|
|
|
try{
|
|
|
|
if (newsStack.depth>1){newsStack.pop()}
|
|
|
|
}catch(e){}
|
2018-04-22 21:12:40 +02:00
|
|
|
newsBusy.running=false;
|
2017-01-26 21:55:31 +01:00
|
|
|
var currentTime= new Date();
|
2018-07-01 15:09:21 +02:00
|
|
|
// downloadNotice.text=downloadNotice.text + "\n shownews start "+ Date.now();
|
|
|
|
//print("appendnews "+newsStack.appendNews +JSON.stringify(newsToShow))
|
2018-11-09 22:06:13 +01:00
|
|
|
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsToShow,'method':newsStack.updateMethodNews, 'options':globaloptions};
|
2017-01-26 21:55:31 +01:00
|
|
|
newsWorker.sendMessage(msg);
|
2018-08-25 16:17:09 +02:00
|
|
|
//newsStack.appendNews=false
|
2017-01-26 21:55:31 +01:00
|
|
|
}
|
|
|
|
|
2018-07-01 15:09:21 +02:00
|
|
|
|
|
|
|
|
2017-05-11 22:15:34 +02:00
|
|
|
function showConversation(conversationIndex,newsitemobject){
|
|
|
|
if(newsitemobject.messagetype==0){
|
2018-07-01 15:09:21 +02:00
|
|
|
xhr.clearParams();
|
|
|
|
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
|
|
|
xhr.setUrl(login.server);
|
|
|
|
xhr.setApi("/api/conversation/show");
|
|
|
|
xhr.setParam("id",newsitemobject.id)
|
|
|
|
xhr.get();
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
xhr.clearParams();
|
|
|
|
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
|
|
|
xhr.setUrl(login.server);
|
|
|
|
xhr.setApi("/api/direct_messages/conversation");
|
|
|
|
xhr.setParam("uri",newsitemobject.statusnet_conversation_id)
|
|
|
|
xhr.get();
|
|
|
|
}
|
2017-03-25 23:36:14 +01:00
|
|
|
}
|
|
|
|
|
2017-11-07 21:57:40 +01:00
|
|
|
function showContact(contact){
|
2018-10-01 21:17:54 +02:00
|
|
|
newstab.newstabstatus="Contact";
|
|
|
|
newsStack.push({item:"qrc:/qml/newsqml/ContactPage.qml",properties:{"contact": contact}});
|
2017-11-07 21:57:40 +01:00
|
|
|
}
|
|
|
|
|
2018-07-01 15:09:21 +02:00
|
|
|
function search(term){//print("Search "+term)
|
|
|
|
if (term!=""){
|
|
|
|
newstab.newstabstatus="Search";
|
|
|
|
newsBusy.running=true;
|
2018-08-25 16:17:09 +02:00
|
|
|
newsStack.updateMethodNews="refresh";
|
2018-07-01 15:09:21 +02:00
|
|
|
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
|
|
|
xhr.setUrl(login.server);
|
|
|
|
xhr.setApi("/api/search");
|
|
|
|
xhr.clearParams();
|
|
|
|
xhr.setParam("q",term)
|
|
|
|
xhr.get();}
|
|
|
|
newsView.anchors.topMargin=7*mm
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-26 21:55:31 +01:00
|
|
|
function onFriendsMessages(friend){
|
2017-01-29 17:26:09 +01:00
|
|
|
newstab.newstabstatus="Contact"
|
2018-02-19 22:36:00 +01:00
|
|
|
Newsjs.newsfromdb(db,root.login.username, function(dbnews){
|
|
|
|
if (dbnews.length==0){
|
|
|
|
Newsjs.newsfromdb(db,login.username,function(forumnews){
|
|
|
|
showNews(forumnews)
|
|
|
|
},friend.url)
|
|
|
|
}
|
|
|
|
else showNews(dbnews)
|
|
|
|
},friend.id)
|
2017-01-26 21:55:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onDirectMessage(friend){
|
2018-11-09 22:06:13 +01:00
|
|
|
//newstab.newstabstatus="SendMessage" ,"login":login ,
|
|
|
|
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1, "login":root.login}});
|
2017-01-26 21:55:31 +01:00
|
|
|
}
|
|
|
|
|
2018-08-25 16:17:09 +02:00
|
|
|
function sendUrls(urls){print(root.currentIndex==0);
|
2018-04-11 21:50:43 +02:00
|
|
|
if((urls.length==1)&&(newsStack.depth<2)){
|
2018-08-25 16:17:09 +02:00
|
|
|
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"attachImageURLs":urls}})
|
2018-04-22 21:12:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendtext(text){
|
|
|
|
if(text&&(newsStack.depth<2)){
|
|
|
|
if (text.subject=="undefined"){text.subject=""}
|
2018-08-25 16:17:09 +02:00
|
|
|
if(text.plaintext.lastIndexOf(".jpg")>-1 || text.plaintext.lastIndexOf(".jpeg")>-1 || text.plaintext.lastIndexOf(".png")>-1 || text.plaintext.lastIndexOf(".gif")>-1){
|
2018-07-20 21:15:54 +02:00
|
|
|
text.plaintext="<a href="+text.plaintext+"><img src="+text.plaintext+"></a>"}
|
2018-08-25 16:17:09 +02:00
|
|
|
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"bodyMessage":text.subject+"\n"+text.plaintext}})
|
2018-04-11 21:50:43 +02:00
|
|
|
}
|
|
|
|
}
|
2017-11-07 21:57:40 +01:00
|
|
|
|
2017-01-26 21:55:31 +01:00
|
|
|
StackView{
|
|
|
|
id: newsStack
|
|
|
|
anchors.fill:parent
|
2018-08-25 16:17:09 +02:00
|
|
|
property string updateMethodNews: "refresh"
|
2018-07-01 15:09:21 +02:00
|
|
|
property var allchats: ({})
|
2017-05-11 22:15:34 +02:00
|
|
|
initialItem:Rectangle {
|
2018-04-11 21:50:43 +02:00
|
|
|
id:newslistRectangle
|
2017-01-26 21:55:31 +01:00
|
|
|
y:1
|
|
|
|
color: "white"
|
|
|
|
|
|
|
|
BlueButton{
|
|
|
|
id:newstabstatusButton
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 0.5*mm
|
|
|
|
text: qsTr(newstab.newstabstatus)
|
2018-07-20 21:15:54 +02:00
|
|
|
onClicked: {newstabmenu.popup(2*mm,6*mm)}
|
2018-07-01 15:09:21 +02:00
|
|
|
|
2018-08-25 16:17:09 +02:00
|
|
|
QC2.Menu{id:newstabmenu
|
2018-07-20 21:15:54 +02:00
|
|
|
width: 40*mm
|
|
|
|
|
2018-08-25 16:17:09 +02:00
|
|
|
delegate:QC2.MenuItem{
|
2018-07-20 21:15:54 +02:00
|
|
|
contentItem: Text{
|
|
|
|
font.pixelSize: 3.5*mm
|
|
|
|
text:parent.text
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
|
|
|
implicitWidth: 40*mm; implicitHeight: 5*mm
|
|
|
|
color: "#ffffff"
|
|
|
|
border.color: "grey"
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 16:17:09 +02:00
|
|
|
QC2.Action {
|
2018-07-01 15:09:21 +02:00
|
|
|
text: qsTr("Timeline")
|
|
|
|
onTriggered: {
|
|
|
|
newstab.newstabstatus="Timeline";
|
2018-08-25 16:17:09 +02:00
|
|
|
//newsModel.clear();
|
2018-07-01 15:09:21 +02:00
|
|
|
try{ Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
|
|
|
showNews(dbnews)
|
|
|
|
})}catch(e){Helperjs.showMessage("Error",e,root)}}
|
|
|
|
}
|
2018-08-25 16:17:09 +02:00
|
|
|
QC2.Action {
|
2018-07-01 15:09:21 +02:00
|
|
|
text: qsTr("Conversations")
|
|
|
|
onTriggered:{
|
2018-08-25 16:17:09 +02:00
|
|
|
//newsModel.clear();
|
2018-07-01 15:09:21 +02:00
|
|
|
newstab.newstabstatus="Conversations";
|
|
|
|
Newsjs.chatsfromdb(db,root.login.username,function(news){showNews(news)})
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 16:17:09 +02:00
|
|
|
QC2.Action {
|
2018-07-01 15:09:21 +02:00
|
|
|
text: qsTr("Favorites")
|
|
|
|
onTriggered:{
|
2018-08-25 16:17:09 +02:00
|
|
|
newsStack.updateMethodNews="refresh";
|
2018-07-01 15:09:21 +02:00
|
|
|
newstab.newstabstatus="Favorites";
|
|
|
|
Service.updateView("Favorites")
|
|
|
|
}
|
|
|
|
}
|
2019-01-09 22:03:16 +01:00
|
|
|
QC2.Action {
|
|
|
|
text: qsTr("Replies")
|
|
|
|
onTriggered:{
|
|
|
|
newsStack.updateMethodNews="refresh";
|
|
|
|
newstab.newstabstatus="Replies";
|
|
|
|
Service.updateView("Replies")
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 16:17:09 +02:00
|
|
|
QC2.Action {
|
2018-07-01 15:09:21 +02:00
|
|
|
text: qsTr("Public timeline")
|
|
|
|
onTriggered:{
|
2018-08-25 16:17:09 +02:00
|
|
|
newsStack.updateMethodNews="refresh";
|
2018-07-01 15:09:21 +02:00
|
|
|
newstab.newstabstatus="Public Timeline";
|
|
|
|
Service.updateView("Public Timeline")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-25 16:17:09 +02:00
|
|
|
QC2.Action {
|
2018-07-01 15:09:21 +02:00
|
|
|
text: qsTr("Direct Messages")
|
|
|
|
onTriggered:{
|
2018-08-25 16:17:09 +02:00
|
|
|
newsStack.updateMethodNews="refresh";
|
2018-07-01 15:09:21 +02:00
|
|
|
newstab.newstabstatus="Direct Messages";
|
|
|
|
Service.updateView("Direct Messages")
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 16:17:09 +02:00
|
|
|
QC2.Action {
|
2018-07-01 15:09:21 +02:00
|
|
|
text: qsTr("Notifications")
|
|
|
|
onTriggered:{
|
2018-08-25 16:17:09 +02:00
|
|
|
newsStack.updateMethodNews="refresh";
|
2018-07-01 15:09:21 +02:00
|
|
|
newstab.newstabstatus="Notifications";
|
|
|
|
Service.updateView("Notifications")
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 16:17:09 +02:00
|
|
|
QC2.Action {
|
|
|
|
|
2018-07-01 15:09:21 +02:00
|
|
|
text: qsTr("Group news")
|
2018-08-25 16:17:09 +02:00
|
|
|
onTriggered:
|
|
|
|
{
|
|
|
|
newsStack.updateMethodNews="refresh";
|
|
|
|
Service.showGroups();
|
|
|
|
}
|
2018-07-01 15:09:21 +02:00
|
|
|
}
|
2018-08-25 16:17:09 +02:00
|
|
|
QC2.Action {
|
2018-07-01 15:09:21 +02:00
|
|
|
text: qsTr("Quit")
|
|
|
|
onTriggered:{
|
|
|
|
Service.cleanNews(root.db,function(){
|
|
|
|
Service.cleanContacts(root.login,root.db,function(){
|
|
|
|
Qt.quit()})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-26 21:55:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Row{
|
|
|
|
spacing: mm
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 0.5*mm
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
2018-07-01 15:09:21 +02:00
|
|
|
BlueButton {
|
|
|
|
id: searchButton
|
|
|
|
text: "\uf002"
|
|
|
|
onClicked: {
|
2018-10-01 21:17:54 +02:00
|
|
|
newsView.anchors.topMargin=18*mm;
|
2018-08-25 16:17:09 +02:00
|
|
|
var component = Qt.createComponent("qrc:/qml/genericqml/Search.qml");
|
2018-10-01 21:17:54 +02:00
|
|
|
var searchItem = component.createObject(newsStack,{y:8*mm,width:root.width,height: 8*mm});
|
2018-07-01 15:09:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 21:55:31 +01:00
|
|
|
BlueButton {
|
2017-05-11 22:15:34 +02:00
|
|
|
id: newMessageButton
|
|
|
|
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){
|
2018-07-20 21:15:54 +02:00
|
|
|
newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"contacts": friends,"login":root.login})
|
2017-05-11 22:15:34 +02:00
|
|
|
},"isFriend",1);
|
|
|
|
}
|
|
|
|
}
|
2018-07-01 15:09:21 +02:00
|
|
|
// BlueButton {
|
|
|
|
// id: quitButton
|
|
|
|
// text: "\uf08b"
|
|
|
|
// onClicked: {Service.cleanNews(root.db,function(){
|
|
|
|
// Service.cleanContacts(root.login,root.db,function(){
|
|
|
|
// Qt.quit() })
|
|
|
|
// })}
|
|
|
|
// }
|
2017-05-11 22:15:34 +02:00
|
|
|
BlueButton {
|
2017-01-26 21:55:31 +01:00
|
|
|
id: update
|
2017-03-25 23:36:14 +01:00
|
|
|
text: "\uf021"
|
2017-01-26 21:55:31 +01:00
|
|
|
onClicked: {
|
2018-08-25 16:17:09 +02:00
|
|
|
if (newstab.newstabstatus=="Timeline"){
|
|
|
|
newsStack.updateMethodNews="append"
|
|
|
|
} else {newsStack.updateMethodNews="refresh"}
|
2018-10-01 21:17:54 +02:00
|
|
|
//root.contactLoadType="news";
|
2018-07-01 15:09:21 +02:00
|
|
|
Service.updateView(newstab.newstabstatus)
|
2017-03-25 23:36:14 +01:00
|
|
|
}
|
2017-01-26 21:55:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Component { id:footerComponent
|
|
|
|
Rectangle{
|
|
|
|
border.color: "#EEEEEE"
|
|
|
|
border.width: 1
|
2017-03-25 23:36:14 +01:00
|
|
|
width:newsView.width
|
2017-01-26 21:55:31 +01:00
|
|
|
height:6*mm
|
|
|
|
Text{
|
|
|
|
font.pixelSize: 1.5*mm
|
|
|
|
anchors.centerIn: parent
|
|
|
|
text:qsTr("More")
|
|
|
|
}
|
|
|
|
MouseArea{anchors.fill:parent
|
|
|
|
onClicked:{
|
2017-11-07 21:57:40 +01:00
|
|
|
var currentTime= new Date();
|
|
|
|
var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;
|
|
|
|
if(newstab.newstabstatus=="Timeline"){
|
2017-01-26 21:55:31 +01:00
|
|
|
Newsjs.newsfromdb(root.db,root.login.username, function(news){
|
2018-11-09 22:06:13 +01:00
|
|
|
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true, 'options':globaloptions};
|
2017-11-07 21:57:40 +01:00
|
|
|
newsWorker.sendMessage(msg);
|
|
|
|
},false,lastnews_id)}
|
|
|
|
if(newstab.newstabstatus=="Conversations"){
|
2017-01-26 21:55:31 +01:00
|
|
|
Newsjs.chatsfromdb(root.db,root.login.username, function(news){
|
2018-11-09 22:06:13 +01:00
|
|
|
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true, 'options':globaloptions};
|
2017-11-07 21:57:40 +01:00
|
|
|
newsWorker.sendMessage(msg);
|
|
|
|
},lastnews_id)}
|
2018-10-01 21:17:54 +02:00
|
|
|
// 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)}
|
2018-07-01 15:09:21 +02:00
|
|
|
else if (newstab.newstabstatus=="Notifications"){}
|
|
|
|
else{
|
2018-10-01 21:17:54 +02:00
|
|
|
//newsStack.appendNews=true;
|
2018-07-01 15:09:21 +02:00
|
|
|
xhr.setParam("max_id",newsModel.get(newsModel.count-1).newsitemobject.id-1);
|
|
|
|
xhr.get()
|
|
|
|
}}
|
2017-11-07 21:57:40 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-26 21:55:31 +01:00
|
|
|
}
|
2018-10-01 21:17:54 +02:00
|
|
|
|
2018-08-25 16:17:09 +02:00
|
|
|
|
2017-01-26 21:55:31 +01:00
|
|
|
ListView {
|
|
|
|
id: newsView
|
|
|
|
anchors.fill: parent
|
2017-05-11 22:15:34 +02:00
|
|
|
anchors.topMargin: 7*root.mm
|
2017-01-26 21:55:31 +01:00
|
|
|
anchors.leftMargin: 3*root.mm; anchors.rightMargin: root.mm
|
|
|
|
anchors.bottomMargin: 1*root.mm
|
|
|
|
clip: true
|
|
|
|
spacing: 0
|
2017-05-11 22:15:34 +02:00
|
|
|
footer: footerComponent
|
2017-01-26 21:55:31 +01:00
|
|
|
model: newsModel
|
|
|
|
delegate: Newsitem{}
|
2017-11-07 21:57:40 +01:00
|
|
|
//onContentYChanged:{if(contentY<-8*mm&&contentY>(-8*mm-1)){print("refreshing");
|
2018-08-25 16:17:09 +02:00
|
|
|
onDragEnded:{if(contentY<-5*mm){
|
2018-10-01 21:17:54 +02:00
|
|
|
var onlynew=true;
|
2018-07-01 15:09:21 +02:00
|
|
|
Service.updateView(newstab.newstabstatus)
|
2017-05-11 22:15:34 +02:00
|
|
|
}}
|
|
|
|
}
|
2017-01-26 21:55:31 +01:00
|
|
|
|
|
|
|
ListModel{id: newsModel}
|
|
|
|
|
|
|
|
WorkerScript {
|
|
|
|
id: newsWorker
|
|
|
|
source: "qrc:/js/newsworker.js"
|
|
|
|
}
|
|
|
|
|
|
|
|
BusyIndicator{
|
|
|
|
id: newsBusy
|
|
|
|
anchors.horizontalCenter: newsView.horizontalCenter
|
|
|
|
anchors.top:newsView.top
|
|
|
|
anchors.topMargin: 2*mm
|
|
|
|
width:10*mm
|
|
|
|
height: 10*mm
|
|
|
|
}
|
2017-01-29 17:26:09 +01:00
|
|
|
Rectangle{
|
|
|
|
id:downloadNotice
|
|
|
|
property alias text: noticeText.text
|
|
|
|
color:"white"
|
|
|
|
border.color:"grey"
|
|
|
|
z:1
|
|
|
|
anchors.horizontalCenter: newsView.horizontalCenter
|
|
|
|
anchors.bottom:newsView.bottom
|
|
|
|
anchors.bottomMargin: 2*mm
|
|
|
|
width: noticeText.width+2*mm
|
|
|
|
height: noticeText.height+2*mm
|
|
|
|
visible: (downloadNotice.text!="")
|
|
|
|
|
|
|
|
Text{
|
|
|
|
id:noticeText
|
|
|
|
color: "grey"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: contentWidth
|
|
|
|
height: contentHeight
|
|
|
|
font.pixelSize: 2*mm
|
|
|
|
text:""
|
|
|
|
}
|
|
|
|
}
|
2017-01-26 21:55:31 +01:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
root.messageSignal.connect(onFriendsMessages);
|
|
|
|
root.directmessageSignal.connect(onDirectMessage);
|
2018-10-01 21:17:54 +02:00
|
|
|
root.contactdetailsSignal.connect(showContact);
|
2017-01-26 21:55:31 +01:00
|
|
|
root.newsSignal.connect(showNews);
|
2018-04-11 21:50:43 +02:00
|
|
|
root.uploadSignal.connect(sendUrls);
|
2018-04-22 21:12:40 +02:00
|
|
|
root.sendtextSignal.connect(sendtext);
|
2017-01-26 21:55:31 +01:00
|
|
|
try{newsModel.clear()} catch(e){}
|
2018-11-09 22:06:13 +01:00
|
|
|
// xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
|
|
|
// xhr.setUrl(login.server);
|
2018-04-11 21:50:43 +02:00
|
|
|
if(root.news.length>0){showNews(root.news)}
|
2018-07-01 15:09:21 +02:00
|
|
|
else{ newstab.newstabstatus=login.newsViewType;
|
2018-04-11 21:50:43 +02:00
|
|
|
if(login.newsViewType=="Timeline"){Newsjs.newsfromdb(db,login.username,function(dbnews){showNews(dbnews)})}
|
2018-08-25 16:17:09 +02:00
|
|
|
else{Newsjs.chatsfromdb(db,login.username,function(dbnews){
|
|
|
|
showNews(dbnews);
|
|
|
|
})}
|
2018-04-11 21:50:43 +02:00
|
|
|
}
|
2017-01-26 21:55:31 +01:00
|
|
|
}
|
2018-04-11 21:50:43 +02:00
|
|
|
}
|
2017-01-26 21:55:31 +01:00
|
|
|
}
|
|
|
|
}
|