-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewsDelegate.qml
170 lines (160 loc) · 5.89 KB
/
NewsDelegate.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import QtQuick 2.0
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
Item {
// anchors.left: parent.left
// anchors.leftMargin: 10
width: listview.width
height: 100
ColumnLayout {
width: parent.width
height: parent.height
Rectangle {
Layout.leftMargin: 10
id: viewcontent
Layout.fillWidth: true
Layout.preferredHeight: 94
Label {
id: indexnumber
// Layout.alignment: Qt.AlignVCenter
// Layout.preferredWidth: 10
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
text: index + 1
font.bold: Font.Bold
font.pixelSize: 15
color: "#212121"
}
Label {
id: voteicon
property bool voted: false
// Layout.alignment: Qt.AlignVCenter
// Layout.preferredWidth: 30
anchors.left: indexnumber.right
anchors.leftMargin: 15
anchors.verticalCenter: parent.verticalCenter
font.family: "fontello"
font.pixelSize: 26
color: "#FFAB00"
text: "\ue807"
state: voted ? "voted" : "not-voted"
states: [
State {
name: "voted"
PropertyChanges {
target: voteicon
rotation: 360
text: "\ue808"
}
},
State {
name: "not-voted"
PropertyChanges {
target: voteicon
rotation: 0
text: "\ue807"
}
}
]
transitions: [
Transition {
RotationAnimation {
duration: 400
}
}
]
MouseArea {
anchors.fill: parent
onClicked: {
voteicon.voted = !voteicon.voted
if (voteicon.voted) {
points.text = (model.point + 1) + " pts"
} else {
points.text = model.point + " pts"
}
}
cursorShape: Qt.PointingHandCursor
}
}
ColumnLayout {
anchors.verticalCenter: parent.verticalCenter
anchors.left: voteicon.right
anchors.leftMargin: 15
// width: 100
// Layout.alignment: Qt.AlignVCenter
// Layout.leftMargin: -20
spacing: 0
RowLayout {
// Layout.fillWidth: true
// width: 100
Label {
text: model.title
font.pixelSize: 20
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: Qt.openUrlExternally(model.url);
}
}
Label {
text: "(" + model.url + ")"
font.pixelSize: 12
}
}
RowLayout {
spacing: 2
Label {
id: points
font.pixelSize: 11
text: model.point + " pts"
}
Label {
font.pixelSize: 11
text: "by " + model.author + " |"
}
// Label {
// font.pixelSize: 11
// text: model.date + " |"
// }
ClickableText {
font.pixelSize: 11
text: model.comment + " comments"
color: "#f56565"
onClicked: {
if (!loginhandler.login) {
stackView.tabBarNeeded = false
stackView.push(loginpage)
return;
}
toolbar.tbar.currentIndex = -1
stackView.tabBarNeeded = false
stackView.index = index
commentmodel.postid = model.id
commentmodel.getPostComments()
stackView.push(commentpage)
}
}
ClickableText {
visible: model.author == loginhandler.username
text: "| delete"
color: "#FF3D00"
onClicked: stackView.mainModel.remove(index)
}
}
}
Label {
anchors.right: parent.right
anchors.rightMargin: 10
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
font.pixelSize: 11
text: model.date
}
}
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
color: "#E0E0E0"
}
}
}