3 import "../js/SettingsStorage.js" as Storage
10 { viewComponent: 'content/view/Categories.qml' },
11 { viewComponent: 'content/view/News.qml' }
18 property variant categoriesModel: GoogleReaderCategories { }
19 property variant categoryContentModel: GoogleReaderNews { sourceDepth: 2 }
20 property variant categorySubContentModel: GoogleReaderNews { sourceDepth: 3 }
21 property variant newsDetailModel: QtObject {
22 property int sourceDepth: 3
24 property string htmlcontent: ""
25 property string title: ""
26 property string image: ""
29 property variant sidToken;
33 settingsComponent: "GoogleReaderConfig.qml"
34 function storeConfiguration(configUI) {
35 // save the values in the database
36 Storage.setSetting("GoogleReader.login", configUI.loginValue)
37 Storage.setSetting("GoogleReader.password", configUI.passwordValue)
41 function loadConfiguration(configUI) {
42 // retrieve the values from the database
43 configUI.loginValue = Storage.getSetting("GoogleReader.login")
44 configUI.passwordValue = Storage.getSetting("GoogleReader.password")
47 property variant googleReaderLoginWorker: WorkerScript {
48 id: googleReaderLoginWorker
49 source: "../js/GoogleReaderAPI.js"
52 sid = messageObject.sid
53 sidToken = messageObject.sidToken
59 property variant googleReaderLoadCategoryWorker: WorkerScript {
60 id: googleReaderLoadCategoryWorker
61 source: "../js/GoogleReaderAPI.js"
64 categoryContentModel.append({ 'title': messageObject.title, 'description': messageObject.published, 'image': '', 'id': messageObject.id })
69 property variant googleReaderLoadSubscriptionOrTagWorker: WorkerScript {
70 id: googleReaderLoadSubscriptionOrTagWorker
71 source: "../js/GoogleReaderAPI.js"
74 categorySubContentModel.append({ 'title': messageObject.title, 'description': messageObject.published, 'image': '', 'content': messageObject.description })
79 property variant googleReaderLoadItemWorker: WorkerScript {
80 id: googleReaderLoadItemWorker
81 source: "../js/GoogleReaderAPI.js"
84 newsDetailModel.htmlcontent = messageObject.newsContent
91 var loginValue = Storage.getSetting("GoogleReader.login")
92 var passwordValue = Storage.getSetting("GoogleReader.password")
96 googleReaderLoginWorker.sendMessage({
99 'password': passwordValue
102 onCurrentPathChanged: {
103 // build the right model. currentPath[1] => category
104 var selectionDepth = 0;
105 while(typeof currentPath[selectionDepth+1] !== "undefined")
108 if( typeof currentPath[1] !== "undefined" ) {
109 if( selectionDepth == 1 ) {
110 // the category has been selected, so fill in the right content
111 categoryContentModel.clear()
113 // reshape the views and the models to fit the chosen path
114 var newsDetailIndex = 2;
115 var tmpListModels = listModels
116 var tmpListViews = listViews
117 if( currentPath[1] === 3 || currentPath[1] === 4 )
119 tmpListModels[2] = categorySubContentModel;
120 tmpListViews[2] = { viewComponent: 'content/view/News.qml' }
123 tmpListModels[newsDetailIndex] = newsDetailModel;
124 tmpListViews[newsDetailIndex] = { viewComponent: 'content/view/NewsDetail.qml' };
125 tmpListModels[newsDetailIndex+1] = null
126 tmpListViews[newsDetailIndex+1] = null
127 listModels = tmpListModels
128 listViews = tmpListViews
130 googleReaderLoadCategoryWorker.sendMessage({
131 'action': 'getCategoryContent',
132 'sid': sid, 'sidToken': sidToken,
133 'category': currentPath[1]
136 else if( selectionDepth == 2 && currentPath[1] === 3 ) {
137 // subscriptions selected
138 categorySubContentModel.clear()
139 googleReaderLoadSubscriptionOrTagWorker.sendMessage({
140 'action': 'getSubscriptionItems',
141 'sid': sid, 'sidToken': sidToken,
142 'subscription': categoryContentModel.get(currentPath[2]).id
145 else if( selectionDepth == 2 && currentPath[1] === 4 ) {
147 categorySubContentModel.clear()
148 googleReaderLoadSubscriptionOrTagWorker.sendMessage({
149 'action': 'getTaggedItems',
150 'sid': sid, 'sidToken': sidToken,
151 'tag': categoryContentModel.get(currentPath[2]).id
154 else if( selectionDepth == 3 ) {
155 // subscription or tagged item selected
156 newsDetailModel.htmlcontent = categorySubContentModel.get(currentPath[3]).content
158 else if( selectionDepth == 2 ) {
159 // simply get the chosen news
160 newsDetailModel.htmlcontent = categoryContentModel.get(currentPath[2]).content
165 Component.onCompleted: {