-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFeedDelegate.qml
142 lines (115 loc) · 2.93 KB
/
FeedDelegate.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import QtQuick 2.2
Column {
id: delegate
width: delegate.ListView.view.width
spacing: 8
// Gets image URL from str
function getImageUrl(str){
var matches = str.match(/<img src="(.*?)"/g);
var result = "";
if (matches === null) {
result = "qrc:/Img/cropped-logo.png"
}
else {
result = matches[0];
result = result.slice(result.indexOf("\"") + 1, result.length - 1);
result = "https:" + result;
}
return result;
}
// Deletes all HTML tags from str
function getCleanText(str){
var clean = str.replace(/<\/?[^>]+(>|$)/g, "");
return clean;
}
Item { height: 8; width: delegate.width }
Row {
width: parent.width
spacing: 8
Column {
Item {
width: 4
height: titleText.font.pixelSize / 4
}
Image {
id: titleImage
width: 100
height: 100
source: getImageUrl(description)
}
}
Text {
id: titleText
text: title
width: delegate.width - titleImage.width
wrapMode: Text.WordWrap
font.pixelSize: 26
font.bold: true
}
}
Text {
width: delegate.width
font.pixelSize: 12
font.italic: true
text: "(<a href=\"" + link + "\">Link</a>)"
onLinkActivated: {
Qt.openUrlExternally(link)
}
}
Text {
id: pubDateText
text: "pubDate: " + pubDate
width: parent.width
wrapMode: Text.WordWrap
font.pixelSize: 14
}
Text {
id: guidText
text: "<guid isPermaLink=\"" + isPermaLink + "\">" + guid + "</guid>"
width: parent.width
wrapMode: Text.WordWrap
font.pixelSize: 14
}
Text {
id: descriptionText
text: getCleanText(description)
width: parent.width
wrapMode: Text.WordWrap
font.pixelSize: 14
}
Text {
id: dcCreatorText
text: "dc:creator: " + dcCreator
width: parent.width
wrapMode: Text.WordWrap
font.pixelSize: 14
}
Text {
id: dcSubjectText
text: "dc:subject: " + dcSubject
width: parent.width
wrapMode: Text.WordWrap
font.pixelSize: 14
}
Text {
id: categoryText
text: "category: " + category
width: parent.width
wrapMode: Text.WordWrap
font.pixelSize: 14
}
Text {
id: annotateReferenceText
text: "annotate:reference: " + annotateReference
width: parent.width
wrapMode: Text.WordWrap
font.pixelSize: 14
}
Text {
id: commentsText
text: "comments: " + comments
width: parent.width
wrapMode: Text.WordWrap
font.pixelSize: 14
}
}