new version with hashtags

This commit is contained in:
LubuWest 2020-11-25 21:40:17 +01:00
commit 56bdb80ea0
47 changed files with 1424 additions and 825 deletions

View file

@ -37,7 +37,7 @@ import "qrc:/qml/genericqml"
Item {
id: newsitem
width: parent.width
width: newsView.width //parent.width
height:toprow.height+friendicaActivities.height+controlrow.height+conversationColumn.height+1//Math.max((itemMessage.height+topFlow.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
property int itemindex: index
property var newsitemobject:model.newsitemobject
@ -54,9 +54,7 @@ Item {
var imagedialog = component.createObject(friendicaActivities,{"activitymembers": contacts});
}
function findTags(fulltext){
return fulltext.match(/\s+[#]+[A-Za-z0-9-_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]+/g)
}
function pushConversation(){
if (model.newsitemobject.hasOwnProperty("currentconversation")){
@ -73,17 +71,10 @@ Item {
height:newsitem.height-1
color: "white"//(newsitemobject.messagetype==1)?"#ffe6e6" : "white"
// Row{id:toprow
// Column {
// id: authorcolumn
// width: 8*mm
// }
Column {
id:toprow //newscolumn
width: newsitemobject.hasOwnProperty("indent")?newsitem.width-(newsitem.width/20 *newsitemobject.indent):newsitem.width//-8*mm
x:newsitemobject.hasOwnProperty("indent")?newsitem.width/20*newsitemobject.indent:0
width: newsitemobject.hasOwnProperty("indent")?newsitem.width-(newsitem.width/20 *(newsitemobject.indent+1)):newsitem.width//-8*mm
x:newsitemobject.hasOwnProperty("indent")?newsitem.width/20*(newsitemobject.indent):0
Item{
height: Math.max(profileImage.height+mm,topFlow.implicitHeight+mm)
width: parent.width
@ -100,7 +91,6 @@ Item {
width: 7*mm
height: 7*mm
//radius:mm
onStatusChanged: if (profileImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
}
Flow{
@ -140,140 +130,117 @@ Item {
horizontalAlignment: Label.AlignRight
text: try {qsTr("In reply to ")+newsitemobject.reply_user.screen_name
}catch(e){" "}
}
// Label {
// id:newscountLabel
// visible:((newstabstatus=="Conversations")&&(newsitemobject.newscount>1))?true:false
// color: "grey"
// height:3.5*mm
// font.pixelSize: 1.5*mm
// font.bold: true
// horizontalAlignment: Label.AlignRight
// text: try {(newsitemobject.newscount-1)+qsTr(" comments") }catch(e){" "}
// MouseArea{
// anchors.fill:parent
// onClicked: {
// pushConversation();
// }
// }
// }
}
}
}
// Column{ id: messageColumn
// //anchors.top:topFlow.bottom
// width:parent.width
// spacing:mm
// clip:true
// height: newsitemobject.nsfw?5*mm:Math.min(implicitHeight,3/4*root.height)
MouseArea{
width: toprow.width-2
height: itemMessage.height
onPressAndHold: {
pushConversation();
}
Text {
color: "#404040"
linkColor: "light green"
id: itemMessage
textFormat: Text.RichText
font.family: "Noto Sans"
text: newsitemobject.statusnet_html//newsitemobject.attachmentList.length>0?newsitemobject.text : newsitemobject.statusnet_html
MouseArea{
width: toprow.width-2
height:newsitemobject.nsfw?5*mm:Math.min(implicitHeight,3/4*root.height)
//height: implicitHeight
wrapMode: Text.Wrap
clip:true
onLinkActivated:{
Qt.openUrlExternally(link)}
Component.onCompleted:{
if (newsitemobject.messagetype==0){
var hashtags=[];
hashtags=findTags(newsitemobject.text);
var component = Qt.createComponent("qrc:/qml/newsqml/Hashtag.qml");
for (var tags in hashtags){
var hashtagQml = component.createObject(friendicaActivities,{"text":hashtags[tags].trim()});
}}
height: itemMessage.height
onPressAndHold: {
pushConversation();
}
Text {
color: "#404040"
linkColor: "light green"
id: itemMessage
textFormat: Text.RichText
font.family: "Noto Sans"
text: newsitemobject.statusnet_html//newsitemobject.attachmentList.length>0?newsitemobject.text : newsitemobject.statusnet_html
width: toprow.width-2
height:newsitemobject.nsfw?5*mm:Math.min(implicitHeight,3/4*root.height)
//height: implicitHeight
wrapMode: Text.Wrap
clip:true
onLinkActivated:{
Qt.openUrlExternally(link)}
Component.onCompleted:{
if (newsitemobject.messagetype==0){
var hashtags=[];
hashtags=Newsjs.findTags(newsitemobject.text);
var component = Qt.createComponent("qrc:/qml/newsqml/Hashtag.qml");
for (var tags in hashtags){
var hashtagQml = component.createObject(friendicaActivities,{"text":hashtags[tags].trim()});
}}
if (newsitemobject.attachmentList.length>0){
for(var attachments in newsitemobject.attachmentList){// (newsitemobject.attachmentList[attachments].url);
if(newsitemobject.attachmentList[attachments].mimetype.substring(0,5)=="image"){
var component = Qt.createComponent("qrc:/qml/newsqml/NewsImage.qml");
var imageQml = component.createObject(toprow,{"source":newsitemobject.attachmentList[attachments].url,"mimetype":newsitemobject.attachmentList[attachments].mimetype});
}
else if(newsitemobject.attachmentList[attachments].mimetype=="text/html"){
var component = Qt.createComponent("qrc:/qml/newsqml/NewsLink.qml");
var linkQml = component.createObject(toprow,{"url":newsitemobject.attachmentList[attachments].url});
}
else {
var component = Qt.createComponent("qrc:/qml/newsqml/NewsVideo.qml");
//var videoQml = component.createObject(messageColumn,{"source":newsitemobject.attachmentList[attachments].url,"mimetype":newsitemobject.attachmentList[attachments].mimetype});
var videoQml = component.createObject(toprow,{"attachment":newsitemobject.attachmentList[attachments]});
if (newsitemobject.attachmentList.length>0){
for(var attachments in newsitemobject.attachmentList){// (newsitemobject.attachmentList[attachments].url);
if(newsitemobject.attachmentList[attachments].mimetype.substring(0,5)=="image"){
var component = Qt.createComponent("qrc:/qml/newsqml/NewsImage.qml");
var imageQml = component.createObject(toprow,{"source":newsitemobject.attachmentList[attachments].url,"mimetype":newsitemobject.attachmentList[attachments].mimetype});
}
else if(newsitemobject.attachmentList[attachments].mimetype=="text/html"){
var component = Qt.createComponent("qrc:/qml/newsqml/NewsLink.qml");
var linkQml = component.createObject(toprow,{"url":newsitemobject.attachmentList[attachments].url});
}
else {
var component = Qt.createComponent("qrc:/qml/newsqml/NewsVideo.qml");
//var videoQml = component.createObject(messageColumn,{"source":newsitemobject.attachmentList[attachments].url,"mimetype":newsitemobject.attachmentList[attachments].mimetype});
var videoQml = component.createObject(toprow,{"attachment":newsitemobject.attachmentList[attachments]});
}
}
}
}
if (newsitemobject.hasOwnProperty("lastcomment")){
var moreComponent = Qt.createComponent("qrc:/qml/newsqml/MoreComments.qml");
var conversationQml = moreComponent.createObject(conversationColumn,{"comments":newsitemobject.newscount-1});
if (newsitemobject.hasOwnProperty("lastcomment")){
var moreComponent = Qt.createComponent("qrc:/qml/newsqml/MoreComments.qml");
var conversationQml = moreComponent.createObject(conversationColumn,{"comments":newsitemobject.newscount-1});
var commentComponent = Qt.createComponent("qrc:/qml/newsqml/Newsitem.qml");
var conversationQml = commentComponent.createObject(conversationColumn,{"newsitemobject":newsitemobject.lastcomment});
var commentComponent = Qt.createComponent("qrc:/qml/newsqml/Newsitem.qml");
var conversationQml = commentComponent.createObject(conversationColumn,{"newsitemobject":newsitemobject.lastcomment});
}
}
}
}}
//}
BlueButton{
width: newsitem.width-8*mm-2
height:5*mm
//anchors.bottom: messageColumn.bottom//itemMessage.bottom
visible: itemMessage.implicitHeight>3/4*root.height || newsitemobject.nsfw//messageColumn.implicitHeight>3/4*root.height || newsitemobject.nsfw//itemMessage.implicitHeight>3/4*root.height
text:"\uf078"
fontColor:"grey"
border.color: "transparent"
color:"white"
BlueButton{
width: newsitem.width-8*mm-2
height:5*mm
//anchors.bottom: messageColumn.bottom//itemMessage.bottom
visible: itemMessage.implicitHeight>3/4*root.height || newsitemobject.nsfw//messageColumn.implicitHeight>3/4*root.height || newsitemobject.nsfw//itemMessage.implicitHeight>3/4*root.height
text:"\uf078"
fontColor:"grey"
border.color: "transparent"
color:"white"
// gradient: Gradient {
// GradientStop { position: 0.0; color: "transparent" }
// GradientStop { position: 0.5; color: "white" }
// }
radius:0
onClicked: {
if (text=="\uf078"){
itemMessage.height=itemMessage.implicitHeight+10*mm;text="\uf077"
} else {
itemMessage.height=Math.min(itemMessage.implicitHeight,3/4*root.height);
text="\uf078";
newsView.positionViewAtIndex(index,ListView.Beginning);
}
}
}
//}
radius:0
onClicked: {
if (text=="\uf078"){
itemMessage.height=itemMessage.implicitHeight+10*mm;text="\uf077"
} else {
itemMessage.height=Math.min(itemMessage.implicitHeight,3/4*root.height);
text="\uf078";
newsView.positionViewAtIndex(index,ListView.Beginning);
}
}
}
}
Flow{
id:friendicaActivities
anchors.top:toprow.bottom
width:parent.width
spacing:mm
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
text: friendica_activities_view.likeText
MouseArea{
anchors.fill: parent
onClicked: { showActivityContacts(newsitemobject.friendica_activities.like)}
}
}
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
text: friendica_activities_view.dislikeText
MouseArea{
anchors.fill: parent
onClicked: { showActivityContacts(newsitemobject.friendica_activities.dislike)}
}
}
// Bottom row for activities
Flow{
id:friendicaActivities
anchors.top:toprow.bottom
width:parent.width
spacing:mm
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
text: friendica_activities_view.likeText
MouseArea{
anchors.fill: parent
onClicked: { showActivityContacts(newsitemobject.friendica_activities.like)}
}
}
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
text: friendica_activities_view.dislikeText
MouseArea{
anchors.fill: parent
onClicked: { showActivityContacts(newsitemobject.friendica_activities.dislike)}
}
}
Label{color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
@ -309,6 +276,8 @@ Item {
text: (newsitemobject.friendica_activities_view.self.attending)?(qsTr("Attending: ")+ qsTr(newsitemobject.friendica_activities_view.self.attending)):""
}
}
//Bottom row for buttons
Row{id:controlrow
anchors.top:friendicaActivities.bottom
height: 4*mm
@ -385,9 +354,9 @@ Item {
}
checked:(newsitemobject.favorited>0)
onClicked:{
if(favoritedCheckbox.checkedState==Qt.Checked){
if(favoritedCheckbox.checkState==Qt.Checked){
Newsjs.favorite(login,true,newsitemobject.id,root); model.newsitemobject.favorited=1}
else if(favoritedCheckbox.checkedState==Qt.Unchecked){
else if(favoritedCheckbox.checkState==Qt.Unchecked){
Newsjs.favorite(login,false,newsitemobject.id,root);model.newsitemobject.favorited=0}
}
}
@ -408,29 +377,6 @@ Item {
anchors.fill:parent
onClicked: {newsmenu.popup()}}
}
// Rectangle{
// width: 10*mm
// height: 4*mm
// visible:(newsitemobject.messagetype!==2)&&(newstab.newstabstatus!="Conversation")
// color:"transparent"
// Text{
// id:conversationsymbol
// color: "grey"
// anchors.centerIn: parent
// font.pixelSize: 2.5*mm
// font.family: fontAwesome.name
// text: "\uf086"
// }
// MouseArea{
// anchors.fill:parent
// onClicked:{
// if (newsitemobject.hasOwnProperty("currentconversation")){newsStack.push("qrc:/qml/newsqml/Conversation.qml",{"news": newsitemobject.currentconversation})}
// else{newsStack.push("qrc:/qml/newsqml/Conversation.qml")};
// showConversation(index,newsitemobject)
// }
// }
// }
}
Menu {
@ -450,8 +396,6 @@ Item {
var replycomp=Qt.createComponent("qrc:/qml/newsqml/MessageSend.qml");
var conversation;newsitem.ListView.view.viewtype=="conversation"?true:false;
var reply=replycomp.createObject(friendicaActivities,{parentId:newsitemobject.id,reply_to_user:newsitemobject.user.screen_name, state:"reply",conversation:conversation,textfocus:true})
//replySignal(newsitemobject)
//newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.id,"login":root.login,"directmessage":directmessage});
}
}
Action {
@ -511,6 +455,14 @@ Item {
}
}
Action {
text: qsTr("Show height")
onTriggered: {
Helperjs.showMessage("Height",itemMessage.height + "toprow: "+ toprow.height,root)
}
}
//MenuItem{
// text:qsTr("Show on website")
// onTriggered:Qt.openUrlExternally(login.server+"/display/"+newsitemobject
@ -519,8 +471,8 @@ Item {
Column{
id:conversationColumn
anchors.top:controlrow.bottom
anchors.right: parent.right
width: newsitem.width-5*mm
//anchors.right: parent.right
width: newsitem.width
}
}
}