From 215f828b2a47fe01e1c6f05a12e632a8f117ef12 Mon Sep 17 00:00:00 2001 From: Yves Marcoz Date: Wed, 11 Jan 2012 20:48:46 -0800 Subject: [PATCH] psa: scrolling only right --- psa_harmattan/feedingit/qml/ArticleDisplay.qml | 2 +- psa_harmattan/feedingit/qml/ArticleViewer.qml | 101 +++++++++-------- psa_harmattan/feedingit/qml/Articles.qml | 143 ++++++++++++++---------- psa_harmattan/feedingit/qml/main.qml | 105 +++++++++++------ 4 files changed, 213 insertions(+), 138 deletions(-) diff --git a/psa_harmattan/feedingit/qml/ArticleDisplay.qml b/psa_harmattan/feedingit/qml/ArticleDisplay.qml index 9bbc659..638fefb 100644 --- a/psa_harmattan/feedingit/qml/ArticleDisplay.qml +++ b/psa_harmattan/feedingit/qml/ArticleDisplay.qml @@ -17,7 +17,7 @@ Rectangle { height: parent.height; width: webView.width; contentWidth: webView.width*webView.scale; //Math.max(screen.width,webView.width*webView.scale) - contentHeight: Math.max(articleViewer.height,webView.height*webView.scale) + contentHeight: Math.max(articleView.height,webView.height*webView.scale) //contentWidth: childrenRect.width; contentHeight: childrenRect.height interactive: parent.vertPanningEnabled; diff --git a/psa_harmattan/feedingit/qml/ArticleViewer.qml b/psa_harmattan/feedingit/qml/ArticleViewer.qml index 7cf092f..82ad870 100644 --- a/psa_harmattan/feedingit/qml/ArticleViewer.qml +++ b/psa_harmattan/feedingit/qml/ArticleViewer.qml @@ -8,10 +8,12 @@ Item { property string feedid: parent.feedid //property string feedid: "61ac1458d761423344998dc76770e36e" //articlesItem.feedid; //property string hideReadArticles: ""; - property alias articleShown: articleView.visible; + //property alias articleShown: articleView.visible; property bool zoomEnabled: false; property bool vertPanningEnabled: true + signal openArticle(string articleid); + function modulo(x,y) { // Fixes modulo for negative numbers return ((x%y)+y)%y; @@ -61,23 +63,23 @@ Item { clip: true } - ListView { - id: articleView; - property int webviewFontSize: settings.webviewFontSize - model: articles; - delegate: viewer - orientation: ListView.Horizontal - width: parent.width; - height: updateBarArticles.visible? parent.height-updateBarArticles.height : parent.height; - visible: false; z:8 - onCurrentIndexChanged: articleView.positionViewAtIndex(currentIndex, ListView.Contain) - highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem - //cacheBuffer: 5; - onMovementStarted: articleViewer.vertPanningEnabled=false; - onMovementEnded: articleViewer.vertPanningEnabled=true; - highlightMoveDuration: 300; - clip: true - } +// ListView { +// id: articleView; +// property int webviewFontSize: settings.webviewFontSize +// model: articles; +// delegate: viewer +// orientation: ListView.Horizontal +// width: parent.width; +// height: updateBarArticles.visible? parent.height-updateBarArticles.height : parent.height; +// visible: false; z:8 +// onCurrentIndexChanged: articleView.positionViewAtIndex(currentIndex, ListView.Contain) +// highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem +// //cacheBuffer: 5; +// onMovementStarted: articleViewer.vertPanningEnabled=false; +// onMovementEnded: articleViewer.vertPanningEnabled=true; +// highlightMoveDuration: 300; +// clip: true +// } ProgressBar { id: updateBarArticles @@ -166,41 +168,44 @@ Item { font.pointSize: settings.articleListingTextSize } MouseArea { anchors.fill: listItem; - onClicked: { articleView.currentIndex = index; articleView.visible = true; } + onClicked: { + articleViewer.openArticle(articleid) + //articleView.currentIndex = index; articleView.visible = true; + } } } } - Component { - id: viewer - Item { - id: flipItem; - width: articleDisplay.width; - height: articleView.height; - - //property string url: (articleView.visible && Math.abs(articleView.currentIndex-index)<2) ? path: ""; - property string html: controller.getArticle(articleViewer.feedid, articleid) - ArticleDisplay { - id: articleDisplay - zoomEnabled: articleViewer.zoomEnabled; - property bool vertPanningEnabled: articleViewer.vertPanningEnabled; - - states: [ State { - name: 'articleIsRead'; - when: articleView.visible && articleView.currentIndex == index; - StateChangeScript { - name: "myScript" - script: { - //flipItem.url=path; - controller.setEntryRead(articleViewer.feedid, articleid) - } - } - } - ] - } - } - } +// Component { +// id: viewer +// Item { +// id: flipItem; +// width: articleDisplay.width; +// height: articleView.height; + +// //property string url: (articleView.visible && Math.abs(articleView.currentIndex-index)<2) ? path: ""; +// property string html: controller.getArticle(articleViewer.feedid, articleid) +// ArticleDisplay { +// id: articleDisplay +// zoomEnabled: articleViewer.zoomEnabled; +// property bool vertPanningEnabled: articleViewer.vertPanningEnabled; + +// states: [ State { +// name: 'articleIsRead'; +// when: articleView.visible && articleView.currentIndex == index; +// StateChangeScript { +// name: "myScript" +// script: { +// //flipItem.url=path; +// controller.setEntryRead(articleViewer.feedid, articleid) +// } +// } +// } +// ] +// } +// } +// } XmlListModel { id: articles diff --git a/psa_harmattan/feedingit/qml/Articles.qml b/psa_harmattan/feedingit/qml/Articles.qml index f3bffe3..1451c28 100644 --- a/psa_harmattan/feedingit/qml/Articles.qml +++ b/psa_harmattan/feedingit/qml/Articles.qml @@ -1,79 +1,108 @@ import Qt 4.7 +import com.nokia.meego 1.0 Item { - //anchors.fill: parent; - width: parent.width; - property string feedid : "" - property alias count: articles.count - property alias url: articles.source + id: articlePage + property string mainArticleId: parent.mainArticleId; + property string feedid: parent.feedid + property bool zoomEnabled: false + property bool vertPanningEnabled: true + width: parent.width; height: parent.height; - x: parent.width; height: parent.height; - anchors.top: parent.top; anchors.bottom: parent.bottom + ListView { + id: articleView; + model: articlesModel; + delegate: viewer; + property int webviewFontSize: settings.webviewFontSize + orientation: ListView.Horizontal + width: parent.width; + height: updateBarArticles.visible? parent.height-updateBarArticles.height : parent.height; + //onCurrentIndexChanged: articleView.positionViewAtIndex(currentIndex, ListView.Contain) + highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem + cacheBuffer: width; + onMovementStarted: articlePage.vertPanningEnabled=false; + onMovementEnded: articlePage.vertPanningEnabled=true; + highlightMoveDuration: 300; + clip: true + boundsBehavior: Flickable.DragOverBounds - function getArticleid(index) { - return articles.get(index).articleid - } + onCurrentIndexChanged: { + if (currentIndex >= count-1) { + articlesModel.append({articleid: controller.getNextId(feedid, articlesModel.get(currentIndex).articleid)}) + } + } - function reload() { - //articlesModel.reload() +// onCountChanged: { +// if (count == 3) { +// articleView.currentIndex = 1 +// } +// } } - ListView { - id: articleList; model: articlesModel; delegate: articleDelegate; z: 6 - width: parent.width; height: parent.height; /*x: 0;*/ - cacheBuffer: 100; - flickDeceleration: 1500 + ProgressBar { + id: updateBarArticles + minimumValue: 0 + maximumValue: 100 + value: window.updateProgressValue + visible: window.isUpdateInProgress + width: parent.width + anchors.bottom: parent.bottom } - XmlListModel { - id: articles + ListModel { + id: articlesModel + - source: feedid == "" ? "" : "http://localhost:8000/articles/" + feedid + "?onlyUnread=" + hideReadArticles - query: "/xml/article" - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "articleid"; query: "articleid/string()"; isKey: true } - XmlRole { name: "path"; query: "path/string()" } - XmlRole { name: "unread"; query: "unread/string()"; isKey: true} } Component { - id: articleDelegate - + id: viewer Item { - id: wrapper; width: wrapper.ListView.view.width; height: 86 - Item { - id: moveMe - Rectangle { id: backRect; color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 } - Text { - anchors.fill: backRect - anchors.margins: 5 - verticalAlignment: Text.AlignVCenter; text: title; color: (model.article.unread=="True") ? "white" : "#7b97fd"; - width: wrapper.width; wrapMode: Text.WordWrap; font.bold: false; - } -// Rectangle { -// x: 3; y: 4; width: 77; height: 77; color: "#ff0000"; smooth: true - -// } - -// Column { -// x: 3; - -// width: wrapper.width - 3; y: 5; spacing: 2 -// height: parent.height; -// Text { Rectangle {anchors.fill: parent; color: "white"; opacity: 0.5;} -// verticalAlignment: Text.AlignVCenter; text: model.article.title; color: (model.article.unread=="True") ? "white" : "#7b97fd"; width: parent.width; wrapMode: Text.WordWrap; font.bold: false; /*elide: Text.ElideRight;*/ /*style: Text.Raised;*/ styleColor: "black"; } -// //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" } -// } - } - MouseArea { - anchors.fill: wrapper; - onClicked: { - container.articleClicked(model.article.articleid, index) - } + id: flipItem; + width: articleDisplay.width; + height: articleView.height; + + //property string url: (articleView.visible && Math.abs(articleView.currentIndex-index)<2) ? path: ""; + property string html: controller.getArticle(articlePage.feedid, articleid) + ArticleDisplay { + id: articleDisplay + zoomEnabled: articlePage.zoomEnabled; + property bool vertPanningEnabled: articlePage.vertPanningEnabled; + + states: [ State { + name: 'articleIsRead'; + when: articleView.currentIndex == index; + StateChangeScript { + name: "myScript" + script: { + //flipItem.url=path; + controller.setEntryRead(articlePage.feedid, articleid) +// if (articlesModel.count==1) { +// timer.start() +// } + } + } + } + ] } } + } + + Component.onCompleted: { + articlesModel.append({articleid: mainArticleId}) + //articlesModel.append({articleid: controller.getPreviousId(feedid, mainArticleId)}) + //articleView.currentIndex = 1 } +// Timer { +// id: timer +// interval: 500; running: false; repeat: false +// onTriggered: { +// articlesModel.insert(0,{articleid: controller.getNextId(feedid, mainArticleId)}) +// articlesModel.append({articleid: controller.getPreviousId(feedid, mainArticleId)}) +// } +// } + } diff --git a/psa_harmattan/feedingit/qml/main.qml b/psa_harmattan/feedingit/qml/main.qml index 6e34573..cb77f64 100644 --- a/psa_harmattan/feedingit/qml/main.qml +++ b/psa_harmattan/feedingit/qml/main.qml @@ -12,6 +12,7 @@ PageStackWindow { signal articlesReloadRequest() signal addFileSignal(string fullname, string filename) + property string articleid property string feedid property string catid @@ -197,7 +198,7 @@ PageStackWindow { id: feedsItem onFeedClicked: { window.feedid = feedid - pageStack.push(articlesPage) + pageStack.push(articlesListPage) } } @@ -225,54 +226,37 @@ PageStackWindow { } Component { - id: articlesPage + id: articlesListPage Page { - tools: articleTools + tools: articleListTools property string feedid: window.feedid + ArticleViewer { id: flipper + + onOpenArticle: { + window.articleid = articleid + pageStack.push(articleViewPage) + } } ToolBarLayout { - id: articleTools + id: articleListTools visible: false ToolIcon { iconId: "toolbar-back"; onClicked: { myArticlesMenu.close(); - if (flipper.articleShown) { - flipper.reload() - flipper.articleShown = false; - } else { +// if (flipper.articleShown) { +// flipper.reload() +// flipper.articleShown = false; +// } else { window.feedReloadRequest(); pageStack.pop(); - } +// } } } ToolIcon { - platformIconId: "toolbar-previous" - visible: flipper.articleShown - //anchors.right: (parent === undefined) ? undefined : parent.right - onClicked: flipper.prev(); - } - - ToolIcon { - platformIconId: "toolbar-share" - visible: flipper.articleShown - //anchors.right: (parent === undefined) ? undefined : parent.right - onClicked: { - controller.share(window.feedid, flipper.getCurrentArticleId()); - } - } - - ToolIcon { - platformIconId: "toolbar-next" - visible: flipper.articleShown - //anchors.right: (parent === undefined) ? undefined : parent.right - onClicked: flipper.next() - } - - ToolIcon { platformIconId: "toolbar-view-menu" anchors.right: (parent === undefined) ? undefined : parent.right onClicked: (myArticlesMenu.status == DialogStatus.Closed) ? myArticlesMenu.open() : myArticlesMenu.close() @@ -286,6 +270,63 @@ PageStackWindow { } Component { + id: articleViewPage + Page { + tools: articleTools + property string feedid: window.feedid + property string mainArticleId: window.articleid + + Articles { + } + + ToolBarLayout { + id: articleTools + visible: false + ToolIcon { iconId: "toolbar-back"; + onClicked: { + myArticlesMenu.close(); + window.articlesReloadRequest(); + pageStack.pop(); + } + } + +// ToolIcon { +// platformIconId: "toolbar-previous" +// visible: flipper.articleShown +// //anchors.right: (parent === undefined) ? undefined : parent.right +// onClicked: flipper.prev(); +// } + +// ToolIcon { +// platformIconId: "toolbar-share" +// visible: flipper.articleShown +// //anchors.right: (parent === undefined) ? undefined : parent.right +// onClicked: { +// controller.share(window.feedid, mainArticleId); +// } +// } + +// ToolIcon { +// platformIconId: "toolbar-next" +// visible: article.articleShown +// //anchors.right: (parent === undefined) ? undefined : parent.right +// onClicked: flipper.next() +// } + +// ToolIcon { +// platformIconId: "toolbar-view-menu" +// anchors.right: (parent === undefined) ? undefined : parent.right +// onClicked: (myArticlesMenu.status == DialogStatus.Closed) ? myArticlesMenu.open() : myArticlesMenu.close() +// } + } +// Connections { +// target: window +// onArticlesReloadRequest: flipper.reload() +// } + } + } + + Component { id: addFeedPage AddFeed { id: addFeedItem -- 1.7.9.5