summaryrefslogtreecommitdiff
path: root/qml/BoardPage.qml
blob: 63df29e7df34dc026bd33dae3af468d6ac05af87 (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
112
113
114
115
116
117
118
119
120
121
122
123
import QtQuick 1.1
import com.nokia.meego 1.1
import com.nokia.extras 1.1
import com.javispedro.tapasboard 1.0

Page {
	id: boardPage

	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: board.busy ? "toolbar-cancle" : "toolbar-refresh"
			onClicked: {
				if (board.busy) {
					board.cancelAllActions();
				} else {
					boardModel.refresh();
				}
			}
		}
		ToolIcon {
			platformIconId: "toolbar-view-menu"
			onClicked: (boardMenu.status === DialogStatus.Closed) ? boardMenu.open() : boardMenu.close()
		}
	}

	Menu {
		id: boardMenu
		MenuLayout {
			MenuItem {
				text: boardPage.forumId == 0 ? qsTr("Mark all forums read") : qsTr("Mark subforums read");
				onClicked: boardModel.markSubforumsRead();
			}
		}

	}

	ListView {
		id: forumsView
		anchors.fill: parent
		model: BoardModel {
			id: boardModel
			board: boardPage.board
			forumId: boardPage.forumId
		}
		section.criteria: ViewSection.FullString
		section.property: "category"
		section.delegate: GroupHeader {
			width: parent.width
			text: section
		}

		delegate: EmptyListDelegate {
			id: forumItem

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

			unread: model.unread

			Column {
				id: forumItemColumn
				anchors.left: parent.left
				anchors.right: forumItemImage.left
				anchors.verticalCenter: parent.verticalCenter

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

				Text {
					text: model.description
					width: parent.width
					font: UiConstants.SubtitleFont
					wrapMode: Text.Wrap
					visible: text != ""
				}
			}

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

			onClicked: {
				if (model.subOnly) {
					pageStack.push(Qt.resolvedUrl("BoardPage.qml"), {
										  board: boardPage.board,
										  forumId: model.forumId
										});
				} else {
					pageStack.push(Qt.resolvedUrl("ForumPage.qml"), {
										  board: boardPage.board,
										  forumId: model.forumId
										});
				}
			}
		}
	}

	ScrollDecorator {
		flickableItem: forumsView
	}

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