psa: new icon, increased listing font size
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / debian / feedingit / usr / share / feedingit / qml / ArticleViewer.qml
index a077969..7e58501 100644 (file)
@@ -1,9 +1,11 @@
 import Qt 4.7
+import com.nokia.meego 1.0
 
 Item {
     id: articleViewer
     //width: 480; height: 360;
     width: parent.width; height: parent.height;
+    property string feedid: parent.feedid
     //property string feedid: "61ac1458d761423344998dc76770e36e" //articlesItem.feedid;
     //property string hideReadArticles: "";
     property alias articleShown: articleView.visible;
@@ -41,47 +43,78 @@ Item {
         }
     }
 
-    function viewArticle(articleid) {
-        var index = 0;
-        for (var i=0; i<articleList.count; ++i) {
-            if (articles.get(0).articleid==articleid) {
-                index = i;
-            }
-        }
-        articleView.positionViewAtIndex(index, ListView.Contain); articleView.visible = true;
+    function getCurrentArticleId() {
+        var object = articleView.model.get(articleView.currentIndex)
+        return object.articleid
     }
 
     ListView {
-        id: articleList; model: visualModel.parts.list; z: 6
-        width: parent.width; height: parent.height; /*x: 0;*/
+        id: articleList; /*model: visualModel.parts.list;*/ z: 6
+        model: articles
+        delegate: listing
+        width: parent.width;
+        height: updateBarArticles.visible? parent.height-updateBarArticles.height : parent.height;
+        /*x: 0;*/
         cacheBuffer: 100;
         flickDeceleration: 1500
+        visible: articles.status==XmlListModel.Ready
+        clip: true
     }
 
     ListView {
-        id: articleView; model: visualModel.parts.flip; orientation: ListView.Horizontal
-        width: parent.width; height: parent.height; visible: false; z:8
+        id: articleView;
+        model: articles;
+        delegate: viewer
+        orientation: ListView.Horizontal
+        width: parent.width;
+        height: updateBarArticles.visible? parent.height-updateBarArticles.height : parent.height;
+        visible: false; z:8
         //onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain)
         highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem
         //cacheBuffer: 5;
         onMovementStarted: articleViewer.vertPanningEnabled=false;
         onMovementEnded: articleViewer.vertPanningEnabled=true;
         highlightMoveDuration: 300;
+        clip: true
+    }
+
+    ProgressBar {
+        id: updateBarArticles
+        minimumValue: 0
+        maximumValue: 100
+        value: window.updateProgressValue
+        visible: window.isUpdateInProgress
+        width: parent.width
+        anchors.bottom: parent.bottom
     }
 
     Rectangle {
         id: noArticle
         //width: parent.width; height: parent.height;
-        //color: "#000000"
-        anchors.centerIn: parent;
+        color: "black"
+        opacity: 0.8
+
+        //anchors.centerIn: parent;
+        anchors.fill: parent
         visible: false;
         z:8;
-        Text { id: noText; color: "#ffffff"; anchors.centerIn: parent; text: qsTr("No articles available"); }
-        Image { id: loadingImage; anchors.centerIn: parent; source: "common/images/loading.png";
-            height: 96; width: 96;
-            NumberAnimation on rotation {
-                from: 0; to: 360; running: (loadingImage.visible == true); loops: Animation.Infinite; duration: 900
-            }
+        Text {
+            id: noText; color: "#ffffff"; anchors.centerIn: parent; text: qsTr("No articles available");
+            font.pixelSize: settings.mainTextSize
+        }
+
+        BusyIndicator {
+                     id: loadingIndicator
+                     anchors.centerIn: parent;
+                     running: visible
+                     visible: false
+                     platformStyle: BusyIndicatorStyle { size: "large" }
+        }
+
+        MouseArea {
+            // Disable clicks when this item is visible
+            anchors.fill: parent
+            enabled: parent.visible
         }
 
         states: [ State {
@@ -90,71 +123,87 @@ Item {
             PropertyChanges { target: loadingImage; visible: false; }
             PropertyChanges { target: noText; visible: true; }
             }, State {
-            name: "loading"; when: articles.count==0 && articles.status != XmlListModel.Ready
+            name: "loading"; when: articles.status != XmlListModel.Ready
             PropertyChanges { target: noArticle; visible: true; }
             PropertyChanges { target: noText; visible: false; }
-            PropertyChanges { target: loadingImage; visible: true; }
+            PropertyChanges { target: loadingIndicator; visible: true; }
             }
         ]
     }
 
-    VisualDataModel {
-        id: visualModel;
-        delegate: Package {
-                        id: packageItem
-                        Item { id: flipItem; Package.name: 'flip';  width: articleViewer.width; height: articleViewer.height;
-
-                            property string url: (articleView.visible && Math.abs(articleView.currentIndex-index)<2) ? path: ""; //http://localhost:8000/html/" + articleViewer.feedid + "/" + articleid : "";
-                            property string html: controller.getArticle(articleViewer.feedid, articleid)
-                            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; //"http://localhost:8000/html/" + articleViewer.feedid + "/" + articleid;
-                                            controller.setEntryRead(articleViewer.feedid, articleid)
-                                        }
-                                    }
-                                    }, State {
-                                        name: 'articleIsClose'; when: articleView.visible && Math.abs(articleView.currentIndex-index)<2;
-                                        StateChangeScript {
-                                            script: { flipItem.url=path; } //"http://localhost:8000/html/" + articleViewer.feedid + "/" + articleid;}
-                                        }
-                                    }
-                                ]
-                            }
-                        }
+    Rectangle {
+        id: reloading
+        visible: articles.status != XmlListModel.Ready
 
-                        Item { Package.name: 'list';
-                                id: wrapper; width: articleViewer.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: (unread=="True") ? "white" : "#7b97fd";
-                                        width: wrapper.width; wrapMode: Text.WordWrap; font.bold: false;
-                                    }
-                                }
-                                MouseArea { anchors.fill: wrapper;
-                                    onClicked: { articleView.positionViewAtIndex(index, ListView.Contain); articleView.visible = true; }
-                                }
+
+    }
+
+    Component {
+            id: listing;
+
+            Item {
+                width: articleViewer.width; height: backRect.height + 3
+                id: listItem
+
+                Rectangle {
+                    id: backRect; color: settings.backColour; opacity: index % 2 ? 0.2 : 0.4;
+                    height: articleText.height + 22; width: listItem.width;
+                    y: 1
+                }
+                Text {
+                    id: articleText
+                    anchors.verticalCenter: backRect.verticalCenter
+                    x: 3
+                    width: listItem.width - 6;
+
+                    anchors.margins: 5
+                    verticalAlignment: Text.AlignVCenter;
+                    text: title;
+                    color: (unread=="True") ? settings.mainTextColour : settings.secondaryTextColour;
+
+                     wrapMode: Text.WordWrap; font.bold: false;
+                    font.pointSize: settings.articleListingTextSize
+                }
+                MouseArea { anchors.fill: listItem;
+                    onClicked: { articleView.positionViewAtIndex(index, ListView.Contain); articleView.visible = true; }
+                }
+            }
+
+    }
+
+    Component {
+        id: viewer
+        Item {
+            id: flipItem;
+            width: articleViewer.width; height: articleViewer.height;
+
+            //property string url: (articleView.visible && Math.abs(articleView.currentIndex-index)<2) ? path: "";
+            property string html: controller.getArticle(articleViewer.feedid, articleid)
+            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)
                         }
                     }
-        model: articles
+                    }
+                ]
+            }
+        }
     }
 
     XmlListModel {
         id: articles
 
         //source: articleViewer.feedid == "" ? "" : "http://localhost:8000/articles/" + feedid + "?onlyUnread=" + hideReadArticles
-        //xml: articleViewer.feedid == "" ? "" : controller.getArticlesXml(articleViewer.feedid)
+        xml: articleViewer.feedid == "" ? "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml></xml>" : controller.getArticlesXml(articleViewer.feedid)
         query: "/xml/article"
 
         XmlRole { name: "title"; query: "title/string()" }
@@ -163,5 +212,4 @@ Item {
         XmlRole { name: "unread"; query: "unread/string()"; isKey: true}
     }
 
-
 }