Major changes
[quicknewsreader] / qml / QuickNewsReader / main.qml
index 0c5cf69..b5c3eaf 100644 (file)
@@ -5,60 +5,29 @@ import "content/modelitf"
 
 Rectangle {
     id: window
+    //anchors.fill: parent // use this little trick to always adapt itself to the screen
     width: 800; height: 480
 
-    property int currentJournalIndex: 0
-    property int currentCategoryIndex: -1
-    property int currentNewsIndex: -1
+    property int currentSourceIndex: 0
 
-    property list<JournalModel> listJournalModel: [
-        LeMondeJournalModel{},
-        FavoriteFeedsJournalModel{},
-        YahooJournalModel{}
+    property list<SourceModel> listSourceModel: [
+        LeMondeSourceModel{},
+        GoogleReaderSourceModel{},
+        FavoriteFeedsSourceModel{},
+        YahooSourceModel{}
     ]
 
+    property variant currentSource: listSourceModel[currentSourceIndex]
+    property bool loading: currentSource.loading
+    property ListModel windowViewsModel: viewsModel
+    property ListView windowViewsList: viewsList
+
     ListModel {
-        id: journalList
+        id: viewsModel
 
-        ListElement {
-            journalName: 'Le Monde'
-            journalHierarchy: [
-                // list of journals
-                ListElement { component: "content/view/Journals.qml"; componentId: "journalsRect" },
-                // list of categories for a given journal
-                ListElement { component: "content/view/Categories.qml"; componentId: "categoriesRect" },
-                // list of news for a given category
-                ListElement { component: "content/view/News.qml"; componentId: "newsRect" },
-                // Details for a given news
-                ListElement { component: "content/view/NewsDetail.qml"; componentId: "newsDetailRect" }
-            ]
-        }
-        ListElement {
-            journalName: 'Favorite RSS'
-            journalHierarchy: [
-                // list of journals
-                ListElement { component: "content/view/Journals.qml"; componentId: "journalsRect" },
-                // list of categories for a given journal
-                ListElement { component: "content/view/Categories.qml"; componentId: "categoriesRect" },
-                // list of news for a given category
-                ListElement { component: "content/view/News.qml"; componentId: "newsRect" }
-            ]
-        }
-        ListElement {
-            journalName: 'Yahoo! News'
-            journalHierarchy: [
-                // list of journals
-                ListElement { component: "content/view/Journals.qml"; componentId: "journalsRect" },
-                // list of categories for a given journal
-                ListElement { component: "content/view/Categories.qml"; componentId: "categoriesRect" },
-                // list of news for a given category
-                ListElement { component: "content/view/News.qml"; componentId: "newsRect" }
-            ]
-        }
+        ListElement { component: "content/view/Sources.qml"; componentDepth: 0 }
     }
 
-    property variant currentJournal: listJournalModel[currentJournalIndex]
-    property bool loading: currentJournal.loading
 
     ListView {
         id: viewsList
@@ -67,14 +36,35 @@ Rectangle {
         orientation: ListView.Horizontal
         snapMode: ListView.SnapOneItem
         flickDeceleration: 500
+        cacheBuffer: 1600 // so that the next delegate gets actually loaded...
+        preferredHighlightBegin: window.x
+        preferredHighlightEnd: window.width
+        highlightRangeMode: ListView.StrictlyEnforceRange
+        boundsBehavior: Flickable.StopAtBounds
 
-        model: journalList.get(currentJournalIndex).journalHierarchy
+        model: viewsModel
         delegate: Loader {
-            id: componentId
+            id: modelLoader
             source: component
+
+            ListView.onAdd: {
+                viewsList.currentIndex = componentDepth
+            }
         }
     }
 
+    function showConfigDialog(index) {
+        configDialog.configModel = listSourceModel[index]
+        configDialog.state = "showSourceConfig"
+    }
+
+    SourceConfigDialog {
+        id:configDialog
+    }
+
+/*
+*/
+
     Component {
         id: quitButtonDelegate
         Item {