summaryrefslogtreecommitdiff
path: root/qml/tapasboard/TopicPage.qml
blob: 805154f7d941ad12a038a3e0aeca93d40f3024bc (plain)
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
import QtQuick 1.1
import com.nokia.meego 1.1
import com.nokia.extras 1.1
import com.javispedro.tapasboard 1.0

Page {
	id: topicPage

	anchors.leftMargin: UiConstants.DefaultMargin
	anchors.rightMargin: UiConstants.DefaultMargin

	property string boardUrl;
	property int topicId;

	tools: ToolBarLayout {
		ToolIcon {
			id: backToolIcon
			platformIconId: "toolbar-back"
			anchors.left: parent.left
			onClicked: pageStack.pop()
		}
	}

	ListView {
		id: postsView
		anchors.fill: parent
		model: TopicModel {
			boardUrl: topicPage.boardUrl
			topicId: topicPage.topicId
		}
		section.property: "humanDate"
		section.criteria: ViewSection.FullString
		section.delegate: GroupHeader {
			width: parent.width
			text: section
		}

		delegate: Item {
			id: postItem

			height: postItemRectangle.height + UiConstants.ButtonSpacing * 2
			width: parent.width

			Rectangle {
				id: postItemRectangle
				width: parent.width
				height: postItemColumn.height + UiConstants.DefaultMargin
				anchors.centerIn: parent

				color: "white"
				radius: 20

				Column {
					id: postItemColumn
					anchors.left: parent.left
					anchors.right: parent.right
					anchors.margins: UiConstants.DefaultMargin
					anchors.verticalCenter: parent.verticalCenter
					spacing: 2

					Item {
						width: parent.width
						height: childrenRect.height

						Text {
							anchors.top: parent.top
							anchors.left: parent.left
							text: model.userName
							font: UiConstants.SmallTitleFont
							textFormat: Text.PlainText
						}
						Text {
							anchors.top: parent.top
							anchors.right: parent.right
							text: model.humanTime
							font: UiConstants.SubtitleFont
							textFormat: Text.PlainText
						}
					}

					Text {
						text: model.title
						width: parent.width
						font: UiConstants.TitleFont
						visible: text != ""
						textFormat: Text.PlainText
						wrapMode: Text.Wrap
					}

					Text {
						text: model.content
						width: parent.width
						font: UiConstants.SubtitleFont
						textFormat: Text.RichText
						wrapMode: Text.Wrap
						onLinkActivated: Qt.openUrlExternally(link)
					}
				}
			}
		}
	}

	ScrollDecorator {
		flickableItem: postsView
	}
}