From d8fcff1a2d6eb61c97c44790dbdb920ba9f52980 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Thu, 4 Apr 2013 15:49:31 +0200 Subject: add showing unread posts --- qml/BoardPage.qml | 108 +++++++++++++++++++++++++++++++ qml/EmptyListDelegate.qml | 35 ++++++++++ qml/ForumPage.qml | 95 +++++++++++++++++++++++++++ qml/GroupHeader.qml | 26 ++++++++ qml/MainPage.qml | 39 +++++++++++ qml/TopicPage.qml | 122 +++++++++++++++++++++++++++++++++++ qml/main.qml | 12 ++++ qml/tapasboard/BoardPage.qml | 106 ------------------------------ qml/tapasboard/EmptyListDelegate.qml | 29 --------- qml/tapasboard/ForumPage.qml | 93 -------------------------- qml/tapasboard/GroupHeader.qml | 26 -------- qml/tapasboard/MainPage.qml | 39 ----------- qml/tapasboard/TopicPage.qml | 122 ----------------------------------- qml/tapasboard/main.qml | 12 ---- 14 files changed, 437 insertions(+), 427 deletions(-) create mode 100644 qml/BoardPage.qml create mode 100644 qml/EmptyListDelegate.qml create mode 100644 qml/ForumPage.qml create mode 100644 qml/GroupHeader.qml create mode 100644 qml/MainPage.qml create mode 100644 qml/TopicPage.qml create mode 100644 qml/main.qml delete mode 100644 qml/tapasboard/BoardPage.qml delete mode 100644 qml/tapasboard/EmptyListDelegate.qml delete mode 100644 qml/tapasboard/ForumPage.qml delete mode 100644 qml/tapasboard/GroupHeader.qml delete mode 100644 qml/tapasboard/MainPage.qml delete mode 100644 qml/tapasboard/TopicPage.qml delete mode 100644 qml/tapasboard/main.qml (limited to 'qml') diff --git a/qml/BoardPage.qml b/qml/BoardPage.qml new file mode 100644 index 0000000..ca988f3 --- /dev/null +++ b/qml/BoardPage.qml @@ -0,0 +1,108 @@ +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(); + } + } + } + } + + 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 + } +} diff --git a/qml/EmptyListDelegate.qml b/qml/EmptyListDelegate.qml new file mode 100644 index 0000000..71fa3dc --- /dev/null +++ b/qml/EmptyListDelegate.qml @@ -0,0 +1,35 @@ +import QtQuick 1.1 +import com.nokia.meego 1.1 + +Item { + id: listItem + + signal clicked + property alias pressed: mouseArea.pressed + property bool unread: false + + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: UiConstants.ButtonSpacing + height: UiConstants.ListItemHeightDefault + + BorderImage { + id: background + anchors.fill: parent + anchors.leftMargin: -(UiConstants.DefaultMargin+parent.anchors.leftMargin) + anchors.rightMargin: -UiConstants.DefaultMargin + border { left: 22; right: 22; top: 22; bottom: 22; } + visible: pressed || unread + source: "image://theme/meegotouch" + (unread|(!unread&&!pressed)?"-unread-inbox":"") + + "-panel" + (theme.inverted?"-inverted":"") + + "-background" + (pressed?"-pressed":"") + } + + MouseArea { + id: mouseArea; + anchors.fill: parent + onClicked: { + listItem.clicked(); + } + } +} diff --git a/qml/ForumPage.qml b/qml/ForumPage.qml new file mode 100644 index 0000000..ee04e43 --- /dev/null +++ b/qml/ForumPage.qml @@ -0,0 +1,95 @@ +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: board.busy ? "toolbar-cancle" : "toolbar-refresh" + onClicked: { + if (board.busy) { + board.cancelAllActions(); + } else { + forumModel.refresh(); + } + } + } + } + + 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 + } +} diff --git a/qml/GroupHeader.qml b/qml/GroupHeader.qml new file mode 100644 index 0000000..0350ee0 --- /dev/null +++ b/qml/GroupHeader.qml @@ -0,0 +1,26 @@ +import QtQuick 1.1 +import com.nokia.meego 1.1 + +Item { + id: header + height: 40 + + property alias text: headerLabel.text + + Text { + id: headerLabel + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.rightMargin: 8 + anchors.bottomMargin: 2 + font: UiConstants.GroupHeaderFont + color: theme.inverted ? "#4D4D4D" : "#3C3C3C"; + } + Image { + anchors.right: headerLabel.left + anchors.left: parent.left + anchors.verticalCenter: headerLabel.verticalCenter + anchors.rightMargin: 24 + source: "image://theme/meegotouch-groupheader" + (theme.inverted ? "-inverted" : "") + "-background" + } +} diff --git a/qml/MainPage.qml b/qml/MainPage.qml new file mode 100644 index 0000000..e0e8fb8 --- /dev/null +++ b/qml/MainPage.qml @@ -0,0 +1,39 @@ +import QtQuick 1.1 +import com.nokia.meego 1.1 +import com.nokia.extras 1.1 +import com.javispedro.tapasboard 1.0 + +Page { + id: mainPage + + anchors.leftMargin: UiConstants.DefaultMargin + anchors.rightMargin: UiConstants.DefaultMargin + + ListView { + id: favoritesView + anchors.fill: parent + model: FavoritesModel { + + } + delegate: ListDelegate { + id: favoriteItem + + Image { + id: topicItemImage + source: "image://theme/icon-m-common-drilldown-arrow" + (theme.inverted ? "-inverse" : "") + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + } + + onClicked: { + var board = boardManager.getBoard(model.boardUrl, + model.loginUsername, + model.loginPassword); + pageStack.push(Qt.resolvedUrl("BoardPage.qml"), { + board: board, + forumId: board.rootForumId + }); + } + } + } +} diff --git a/qml/TopicPage.qml b/qml/TopicPage.qml new file mode 100644 index 0000000..689dce7 --- /dev/null +++ b/qml/TopicPage.qml @@ -0,0 +1,122 @@ +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 Board board; + property int topicId; + + tools: ToolBarLayout { + ToolIcon { + platformIconId: "toolbar-back" + onClicked: pageStack.pop() + } + ToolIcon { + platformIconId: board.busy ? "toolbar-cancle" : "toolbar-refresh" + onClicked: { + if (board.busy) { + board.cancelAllActions(); + } else { + topicModel.refresh(); + } + } + } + } + + ListView { + id: postsView + anchors.fill: parent + model: TopicModel { + id: topicModel + board: topicPage.board + 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 + } + + BusyIndicator { + anchors.centerIn: parent + platformStyle: BusyIndicatorStyle { size: "large" } + visible: postsView.count == 0 && board.busy + running: visible + } +} diff --git a/qml/main.qml b/qml/main.qml new file mode 100644 index 0000000..11a7e44 --- /dev/null +++ b/qml/main.qml @@ -0,0 +1,12 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 + +PageStackWindow { + id: appWindow + + initialPage: mainPage + + MainPage { + id: mainPage + } +} diff --git a/qml/tapasboard/BoardPage.qml b/qml/tapasboard/BoardPage.qml deleted file mode 100644 index 7efc6db..0000000 --- a/qml/tapasboard/BoardPage.qml +++ /dev/null @@ -1,106 +0,0 @@ -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(); - } - } - } - } - - 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) - - 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 - } -} diff --git a/qml/tapasboard/EmptyListDelegate.qml b/qml/tapasboard/EmptyListDelegate.qml deleted file mode 100644 index 9a9d63d..0000000 --- a/qml/tapasboard/EmptyListDelegate.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.1 -import com.nokia.meego 1.1 - -Item { - id: listItem - - signal clicked - property alias pressed: mouseArea.pressed - - height: UiConstants.ListItemHeightDefault - width: parent.width - - BorderImage { - id: background - anchors.fill: parent - anchors.leftMargin: -UiConstants.DefaultMargin - anchors.rightMargin: -UiConstants.DefaultMargin - visible: pressed - source: theme.inverted ? "image://theme/meegotouch-panel-inverted-background-pressed" : "image://theme/meegotouch-panel-background-pressed" - } - - MouseArea { - id: mouseArea; - anchors.fill: parent - onClicked: { - listItem.clicked(); - } - } -} diff --git a/qml/tapasboard/ForumPage.qml b/qml/tapasboard/ForumPage.qml deleted file mode 100644 index 96b8082..0000000 --- a/qml/tapasboard/ForumPage.qml +++ /dev/null @@ -1,93 +0,0 @@ -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: board.busy ? "toolbar-cancle" : "toolbar-refresh" - onClicked: { - if (board.busy) { - board.cancelAllActions(); - } else { - forumModel.refresh(); - } - } - } - } - - 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) - - 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 - } -} diff --git a/qml/tapasboard/GroupHeader.qml b/qml/tapasboard/GroupHeader.qml deleted file mode 100644 index 0350ee0..0000000 --- a/qml/tapasboard/GroupHeader.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.1 -import com.nokia.meego 1.1 - -Item { - id: header - height: 40 - - property alias text: headerLabel.text - - Text { - id: headerLabel - anchors.right: parent.right - anchors.bottom: parent.bottom - anchors.rightMargin: 8 - anchors.bottomMargin: 2 - font: UiConstants.GroupHeaderFont - color: theme.inverted ? "#4D4D4D" : "#3C3C3C"; - } - Image { - anchors.right: headerLabel.left - anchors.left: parent.left - anchors.verticalCenter: headerLabel.verticalCenter - anchors.rightMargin: 24 - source: "image://theme/meegotouch-groupheader" + (theme.inverted ? "-inverted" : "") + "-background" - } -} diff --git a/qml/tapasboard/MainPage.qml b/qml/tapasboard/MainPage.qml deleted file mode 100644 index e0e8fb8..0000000 --- a/qml/tapasboard/MainPage.qml +++ /dev/null @@ -1,39 +0,0 @@ -import QtQuick 1.1 -import com.nokia.meego 1.1 -import com.nokia.extras 1.1 -import com.javispedro.tapasboard 1.0 - -Page { - id: mainPage - - anchors.leftMargin: UiConstants.DefaultMargin - anchors.rightMargin: UiConstants.DefaultMargin - - ListView { - id: favoritesView - anchors.fill: parent - model: FavoritesModel { - - } - delegate: ListDelegate { - id: favoriteItem - - Image { - id: topicItemImage - source: "image://theme/icon-m-common-drilldown-arrow" + (theme.inverted ? "-inverse" : "") - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - } - - onClicked: { - var board = boardManager.getBoard(model.boardUrl, - model.loginUsername, - model.loginPassword); - pageStack.push(Qt.resolvedUrl("BoardPage.qml"), { - board: board, - forumId: board.rootForumId - }); - } - } - } -} diff --git a/qml/tapasboard/TopicPage.qml b/qml/tapasboard/TopicPage.qml deleted file mode 100644 index 689dce7..0000000 --- a/qml/tapasboard/TopicPage.qml +++ /dev/null @@ -1,122 +0,0 @@ -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 Board board; - property int topicId; - - tools: ToolBarLayout { - ToolIcon { - platformIconId: "toolbar-back" - onClicked: pageStack.pop() - } - ToolIcon { - platformIconId: board.busy ? "toolbar-cancle" : "toolbar-refresh" - onClicked: { - if (board.busy) { - board.cancelAllActions(); - } else { - topicModel.refresh(); - } - } - } - } - - ListView { - id: postsView - anchors.fill: parent - model: TopicModel { - id: topicModel - board: topicPage.board - 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 - } - - BusyIndicator { - anchors.centerIn: parent - platformStyle: BusyIndicatorStyle { size: "large" } - visible: postsView.count == 0 && board.busy - running: visible - } -} diff --git a/qml/tapasboard/main.qml b/qml/tapasboard/main.qml deleted file mode 100644 index 11a7e44..0000000 --- a/qml/tapasboard/main.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.1 -import com.nokia.meego 1.0 - -PageStackWindow { - id: appWindow - - initialPage: mainPage - - MainPage { - id: mainPage - } -} -- cgit v1.2.3