8324f4fdf85716b28295a237ec05611ccf8e502d
[quicknewsreader] / qml / QuickNewsReader / content / modelimpl / YahooSourceModel.qml
1 /***
2 ** Copyright (C) 2012 Christophe CHAPUIS <chris.chapuis _at_ gmail _dot_ com>
3 **
4 ** This package is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
8 **
9 ** This package is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ** GNU General Public License for more details.
13 **
14 ** You should have received a copy of the GNU General Public License
15 ** along with this package; if not, write to the Free Software
16 ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17 **
18 ***/
19 import QtQuick 1.0
20 import "../modelitf"
21
22 SourceModel {
23     name: "Yahoo! News"
24
25     listViews: [
26         { viewComponent: 'content/view/Categories.qml' } ,
27         { viewComponent: 'content/view/News.qml' },
28         { viewComponent: 'content/view/NewsDetailFromURL.qml' }
29     ]
30     listModels: [
31         categoriesModel,
32         newsModel,
33         newsModelDetail
34     ]
35
36     function getNewsModelItem(prop)
37     {
38         var newsIndex = currentPath[2]
39
40         if( typeof newsModel.get(newsIndex) != "undefined" )
41             if( typeof newsModel.get(newsIndex)[prop] != "undefined" )
42                 return newsModel.get(newsIndex)[prop]
43
44         return ""
45     }
46
47     property variant categoriesModel: YahooRssFeeds { }
48     property variant newsModel: RssFeedModel {
49         currentFeed: categoriesModel.get(currentPath[1]).feed
50     }
51     property variant newsModelDetail: QtObject {
52         property variant parentModel: newsModel
53         property int sourceDepth: 3
54
55         property string urllink: getNewsModelItem('link')
56         property string title: getNewsModelItem('title')
57         property string image: getNewsModelItem('image')
58     }
59
60     loading: newsModel.loading
61 }