Retrieve a post's URL from the model

This commit is contained in:
Christian Muehlhaeuser 2019-05-01 17:17:09 +02:00
parent b865bd8c57
commit d393ebae94
No known key found for this signature in database
GPG key ID: 3CF9FA45CA1EBB7E
4 changed files with 14 additions and 6 deletions

View file

@ -41,6 +41,7 @@ func handleEvents(eventsIn chan interface{}, messages *MessageModel, notificatio
p.Avatar = event.Post.Avatar
p.Body = strings.TrimSpace(event.Post.Body)
p.CreatedAt = event.Post.CreatedAt
p.PostURL = event.Post.URL
p.Reply = event.Reply
p.ReplyToID = event.Post.ReplyToID
p.ReplyToAuthor = event.Post.ReplyToAuthor

View file

@ -1,7 +1,6 @@
package main
import (
"strconv"
"time"
humanize "github.com/dustin/go-humanize"
@ -21,6 +20,7 @@ const (
Avatar
Body
CreatedAt
PostURL
Actor
ActorName
Reply
@ -56,7 +56,7 @@ type Message struct {
Avatar string
Body string
CreatedAt time.Time
URL string
PostURL string
Actor string
ActorName string
Reply bool
@ -77,6 +77,7 @@ func (m *MessageModel) init() {
Avatar: core.NewQByteArray2("avatar", -1),
Body: core.NewQByteArray2("body", -1),
CreatedAt: core.NewQByteArray2("createdat", -1),
PostURL: core.NewQByteArray2("posturl", -1),
Actor: core.NewQByteArray2("actor", -1),
ActorName: core.NewQByteArray2("actorname", -1),
Reply: core.NewQByteArray2("reply", -1),
@ -154,6 +155,10 @@ func (m *MessageModel) data(index *core.QModelIndex, role int) *core.QVariant {
{
return core.NewQVariant14(humanize.Time(p.CreatedAt))
}
case PostURL:
{
return core.NewQVariant14(p.PostURL)
}
case Actor:
{
return core.NewQVariant14(p.Actor)

View file

@ -11,6 +11,7 @@ RowLayout {
property string avatar: model.avatar
property string body: model.body
property string createdat: model.createdat
property string posturl: model.posturl
property string actor: model.actor
property string actorname: model.actorname
property bool reply: model.reply
@ -74,8 +75,7 @@ RowLayout {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
Qt.openUrlExternally(
"https://twitter.com/statuses/" + messageid)
Qt.openUrlExternally(posturl)
}
}
}
@ -114,8 +114,7 @@ RowLayout {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
Qt.openUrlExternally(
"https://twitter.com/statuses/" + replytoid)
Qt.openUrlExternally(posturl)
}
}
}
@ -162,6 +161,7 @@ RowLayout {
tweetPopup.avatar = avatar
tweetPopup.body = body
tweetPopup.createdat = createdat
tweetPopup.posturl = posturl
tweetPopup.actor = actor
tweetPopup.actorname = actorname
tweetPopup.reply = reply

View file

@ -11,6 +11,7 @@ Popup {
property string avatar
property string body
property string createdat
property string posturl
property string actor
property string actorname
property bool reply
@ -36,6 +37,7 @@ Popup {
avatar: popup.avatar
body: popup.body
createdat: popup.createdat
posturl: popup.posturl
actor: popup.actor
actorname: popup.actorname
reply: popup.reply