f033a6957fc9ae66b2174e9327da9573c6563471
[quicknewsreader] / qml / QuickNewsReader / content / modelimpl / LeMondeSourceModel.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: "Le Monde"
24
25     listViews: [
26         { viewComponent: 'content/view/Categories.qml' } ,
27         { viewComponent: 'content/view/News.qml' },
28         { viewComponent: 'content/view/NewsDetail.qml' },
29         { viewComponent: 'content/view/NewsDetailFromURL.qml' }
30     ]
31     listModels: [
32         categoriesModel,
33         newsModel,
34         newsModelDetail,
35         newsModelDetailComments
36     ]
37
38     function getSeqId(categoryIndex)
39     {
40         if( typeof categoriesModel.get(categoryIndex) != "undefined" )
41             if( typeof categoriesModel.get(categoryIndex).seqid != "undefined" )
42                 return categoriesModel.get(categoryIndex).seqid
43
44         return ""
45     }
46
47     function getNewsModelItem(prop)
48     {
49         var newsIndex = currentPath[2]
50
51         if( typeof newsModel.get(newsIndex) != "undefined" )
52             if( typeof newsModel.get(newsIndex)[prop] != "undefined" )
53                 return newsModel.get(newsIndex)[prop]
54
55         return ""
56     }
57
58     property variant categoriesModel: LeMondeSequencesList { }
59     property variant newsModel: LeMondeSequenceNews {
60         seqid: getSeqId(currentPath[1])
61     }
62     property variant newsModelDetail: QtObject {
63         property variant parentModel: newsModel
64         property int sourceDepth: 3
65
66         property string urllink: getNewsModelItem('link')
67         property string htmlcontent: getNewsModelItem('detailedContent')
68         property string title: getNewsModelItem('title')
69         property string image: getNewsModelItem('image')
70     }
71     property variant newsModelDetailComments: QtObject {
72         property variant parentModel: newsModel
73         property int sourceDepth: 4
74
75         property string urllink: "http://www.lemonde.fr" + getNewsModelItem('commentURL')
76         property string title: getNewsModelItem('title')
77         property string image: getNewsModelItem('image')
78     }
79
80     loading: categoriesModel.loading || newsModel.loading
81 }