summaryrefslogtreecommitdiff
path: root/qml/ForumPage.qml
blob: 6c2174202d6a2bd21fee0af099c321c8c2c416b6 (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
107
108
109
110
111
import QtQuick 1.1
import com.nokia.meego 1.1
import com.nokia.extras 1.1
import com.javispedro.tapasboard 1.0

Page {
	id: forumPage

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

	property Board board: null;
	property int forumId;

	tools: ToolBarLayout {
		ToolIcon {
			platformIconId: "toolbar-back"
			onClicked: pageStack.pop()
		}
		ToolIcon {
			platformIconId: "toolbar-add"
			onClicked: {
				var component = Qt.createComponent("NewTopicSheet.qml");
				if (component.status === Component.Ready) {
					var sheet = component.createObject(forumPage, {
														   "board": board,
														   "forumId": forumId
													   });
					sheet.open();
				}
			}
		}
		ToolIcon {
			platformIconId: board.busy ? "toolbar-cancle" : "toolbar-refresh"
			onClicked: {
				if (board.busy) {
					board.cancelAllActions();
				} else {
					forumModel.refresh();
				}
			}
		}
		ToolIcon {
			platformIconId: "toolbar-view-menu"
		}
	}

	ListView {
		id: topicsView
		anchors.fill: parent
		model: ForumModel {
			id: forumModel
			board: forumPage.board
			forumId: forumPage.forumId
		}
		delegate: EmptyListDelegate {
			id: topicItem

			height: Math.max(topicItemColumn.height + UiConstants.ButtonSpacing * 2, UiConstants.ListItemHeightDefault)

			unread: model.unread

			Column {
				id: topicItemColumn
				anchors.left: parent.left
				anchors.right: topicRepliesCount.left
				anchors.verticalCenter: parent.verticalCenter

				Text {
					text: model.title
					width: parent.width
					font: UiConstants.TitleFont
					wrapMode: Text.Wrap
				}
			}

			CountBubble {
				id: topicRepliesCount
				anchors.right: topicItemImage.left
				anchors.verticalCenter: parent.verticalCenter
				value: model.numReplies
				visible: value > 0
			}

			Image {
				id: topicItemImage
				source: "image://theme/icon-m-common-drilldown-arrow" + (theme.inverted ? "-inverse" : "")
				anchors.right: parent.right
				anchors.verticalCenter: parent.verticalCenter
			}

			onClicked: {
				pageStack.push(Qt.resolvedUrl("TopicPage.qml"), {
				                      board: forumPage.board,
				                      topicId: model.topicId
								  });
			}
		}
	}

	ScrollDecorator {
		flickableItem: topicsView
	}

	BusyIndicator {
		anchors.centerIn: parent
		platformStyle: BusyIndicatorStyle { size: "large" }
		visible: topicsView.count == 0 && board.busy
		running: visible
	}
}