+/***
+** Copyright (C) 2012 Christophe CHAPUIS <chris.chapuis _at_ gmail _dot_ com>
+**
+** This package is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this package; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+***/
+import QtQuick 1.0
+import QtWebKit 1.0
+
+Item {
+ id: newsDetailFromURLRect
+ width: window.width; height: window.height
+
+ function getNewsModelItem(prop)
+ {
+ if( typeof currentSource.listModels[componentDepth-1] != "undefined" )
+ if( typeof currentSource.listModels[componentDepth-1][prop] != "undefined" )
+ return currentSource.listModels[componentDepth-1][prop]
+
+ return ""
+ }
+
+ property string detailURL: getNewsModelItem('urllink')
+ property string title: getNewsModelItem('title')
+ property string image: getNewsModelItem('image')
+
+ VisualItemModel {
+ id: itemModel
+
+ Column {
+ id: column
+ x: 10; y: 10
+ width: newsDetailFromURLRect.width - 20
+// height: newsDetailFromURLRect.height
+
+ Row {
+ id: titleRow
+ spacing: 5
+
+ Image {
+ id: detailImage
+ source: image
+ }
+
+ Text {
+ anchors.verticalCenter: titleRow.verticalCenter
+ text: title; width: column.width - detailImage.width - 10; wrapMode: Text.WordWrap
+ font { bold: true; family: "Helvetica"; pointSize: 16 }
+ }
+ }
+
+ WebView {
+ width: column.width
+ id: newsDetailWebView
+ url: detailURL
+ preferredWidth: column.width
+ settings.javascriptEnabled: true
+ settings.autoLoadImages: false
+
+ property bool firstLoad: true;
+
+ javaScriptWindowObjects: QtObject {
+ WebView.windowObjectName: "console"
+
+ function log(message) {
+ console.log(message);
+ }
+ }
+
+ // on the maemo platform, the background is dark gray by default, so change it to white
+ onLoadFinished: {
+ newsDetailWebView.evaluateJavaScript("document.bgColor = '#FFFFFF';")
+
+ if( firstLoad )
+ {
+ newsDetailWebView.evaluateJavaScript("readConvertLinksToFootnotes=false;readStyle='style-newspaper';readSize='size-medium';readMargin='margin-wide';_readability_script=document.createElement('script');_readability_script.type='text/javascript';_readability_script.src='file:///home/chris/dev/projects/QuickNewsReader/qml/QuickNewsReader/content/js/Readability.js?x='+(Math.random());document.documentElement.appendChild(_readability_script);_readability_css=document.createElement('link');_readability_css.rel='stylesheet';_readability_css.href='file:///home/chris/dev/projects/QuickNewsReader/qml/QuickNewsReader/content/css/readability.css';_readability_css.type='text/css';_readability_css.media='all';document.getElementsByTagName('head')[0].appendChild(_readability_css);_readability_print_css=document.createElement('link');_readability_print_css.rel='stylesheet';_readability_print_css.href='file:///home/chris/dev/projects/QuickNewsReader/qml/QuickNewsReader/content/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_print_css);")
+
+ var currentHtml = newsDetailWebView.html;
+ newsDetailWebView.html = currentHtml;
+
+ firstLoad = false;
+ }
+ }
+
+ onAlert: console.log(message);
+ }
+ }
+ }
+ ListView {
+ id: itemListView
+ anchors.fill: newsDetailFromURLRect
+ model: itemModel
+ }
+ ScrollBar { scrollArea: itemListView; height: itemListView.height; width: 8; anchors.right: itemListView.right }
+}