Major changes
[quicknewsreader] / qml / QuickNewsReader / main.qml
index 0c41d95..b5c3eaf 100644 (file)
@@ -5,26 +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 currentSourceIndex: 0
 
     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: viewsModel
 
-        ListElement { component: "content/view/Sources.qml"; componentId: "sourcesRect"; componentDepth: 0 }
+        ListElement { component: "content/view/Sources.qml"; componentDepth: 0 }
     }
 
-    property variant currentSource: listSourceModel[currentSourceIndex]
-    property bool loading: currentSource.loading
-    property ListModel windowViewsModel: viewsModel
-    property ListView windowViewsList: viewsList
 
     ListView {
         id: viewsList
@@ -33,16 +36,25 @@ 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: viewsModel
         delegate: Loader {
-            id: componentId
+            id: modelLoader
             source: component
+
+            ListView.onAdd: {
+                viewsList.currentIndex = componentDepth
+            }
         }
     }
 
-    function showConfigDialog(settingsComponent) {
-        configDialog.configViewComponent = settingsComponent
+    function showConfigDialog(index) {
+        configDialog.configModel = listSourceModel[index]
         configDialog.state = "showSourceConfig"
     }