2
import Ubuntu.Components 0.1
3
import Ubuntu.Components.ListItems 0.1 as ListItem
6
// objectName for functional testing purposes (autopilot-qt5)
7
objectName: "docviewer"
9
applicationName: "ubuntu-docviewer-app"
14
Component.onCompleted: {
18
Component.onDestruction: {
27
objectName: "tabViewer"
30
title: getNameOfFile(file);
34
tools: ToolbarActions {
43
height: childrenRect.height;
52
activeFocusOnPress: false;
55
signal loadCompleted()
57
Component.onCompleted: {
58
var xhr = new XMLHttpRequest;
60
xhr.open("GET", file);
61
xhr.onreadystatechange = function() {
62
if (xhr.readyState === XMLHttpRequest.DONE) {
63
textAreaMain.text = xhr.responseText;
64
textAreaMain.loadCompleted();
76
objectName: "TabDetails"
79
title: i18n.tr("Details")
83
ListItem.SingleValue {
84
text: i18n.tr("Location")
87
ListItem.SingleValue {
89
value: printSize(textAreaMain.text.length);
92
ListItem.SingleValue {
93
text: i18n.tr("Created")
97
ListItem.SingleValue {
98
text: i18n.tr("Modified")
106
function printSize(size)
108
if (size >= 1073741824)
110
return parseInt(size/1073741824) + "," + size%1073741824 + " Gio";
115
return parseInt(size/1048576) + "," + size%1048576 + " Mio";
120
return parseInt(size/1024) + "," + size%1024 + " Kio";
126
function getNameOfFile(path)
128
var name = String(path);
130
return name.substring(name.lastIndexOf('/')+1);