1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
3 import "UIConstants.js" as Const
4 import "ISOdate.js" as ISOdate
5 import "bytesconv.js" as Conv
12 property variant secrets
13 property variant properties
16 [qsTr("Download"),false],
17 [qsTr("Rename"),false],
18 [qsTr("Delete"),false]
21 function menuFun(id) {
22 if(id==qsTr("Download")) {
23 fileSelector.state = "visible";
25 if(id==qsTr("Rename")) {
28 if(id==qsTr("Delete")) {
37 tip.show(qsTr("File deleted!"));
39 pageStack.currentPage.init();
44 tip.show(qsTr("Authorization failed!"));
46 tip.show(qsTr("Error: ")+status);
55 secret: Utils.tokenSecret(),
56 consumer_key : Utils.customerKey(),
57 consumer_secret: Utils.customerSecret()
61 var name = U1.fixFilename(prop.path);
64 var crd = new Date(); crd.setISO8601(prop.when_created);
65 var chd = new Date(); chd.setISO8601(prop.when_changed);
66 created.text = Qt.formatDateTime(crd, "d/M/yyyy h:mm");
67 changed.text = Qt.formatDateTime(chd, "d/M/yyyy h:mm");
68 size.text = Conv.bytesToSize(prop.size);
70 tip.show(qsTr("Internal error!"));
72 root.properties = prop;
75 function setContentType(type)
78 //ctype.font.italic = false;
81 function onRespRename(prop)
83 //console.log("onRespRename");
85 init(prop); pageStack.prevPage().init();
86 tip.show(qsTr("File renamed!"));
89 function onErrRename(status)
91 //console.log("onErrRename");
94 tip.show(qsTr("Authorization failed!"));
95 } else if(status==0) {
96 tip.show(qsTr("Unable to connect!"));
98 tip.show(qsTr("Error: ")+status);
105 contentHeight: content.height+Const.SYSTEM_BAR_HEIGHT+Const.TEXT_MARGIN
106 y: Const.SYSTEM_BAR_HEIGHT+Const.TEXT_MARGIN
110 spacing: Const.DEFAULT_MARGIN
116 text: qsTr("File name:")
123 width: root.width - 6*Const.DEFAULT_MARGIN
126 width: root.width-2*Const.TEXT_MARGIN
140 width: root.width-2*Const.TEXT_MARGIN
145 text: qsTr("Created:")
153 width: root.width-2*Const.TEXT_MARGIN
158 text: qsTr("Changed:")
168 text: qsTr("Preview:")
171 color: Const.TRANSPARENT
172 height: 200; width: 200
173 border.color: Const.DEFAULT_FOREGROUND_COLOR
187 folder: Utils.lastFolder()=="" ? Const.DEFAULT_FOLDER : Utils.lastFolder()
189 fileSelector.state = "invisible";
190 U1.getFileContent(secrets,root,properties.content_path,folder,properties.size,Utils);
191 Utils.setLastFolder(folder);
198 text: qsTr("Delete file?")
199 onOpened: mask.state = "dialog"
204 U1.deleteFile(secrets,properties.resource_path,root,Utils);
207 onCanceled: mask.state = "idle"
211 function getParentPath(path) {
214 var ind = path.lastIndexOf("/");
216 ppath = path.substr(0,ind);
218 if(path=="") ppath = "/";
220 //console.log(ppath);
225 var l=0; var r=s.length -1;
226 while(l < s.length && s[l] == ' ')
228 while(r > l && s[r] == ' ')
230 return s.substring(l, r+1);
236 textWidth: root.width - 4*Const.DEFAULT_MARGIN
237 label: qsTr("Enter new file name:")
238 placeholderText: filename.text
241 Utils.setOrientation("auto");
242 mask.state = "dialog";
246 Utils.setOrientation(root.orientation);
250 var currentPath = root.properties.resource_path;
251 var targetPath = getParentPath(root.properties.path)+"/"+resp;
252 //console.log("targetPath: "+targetPath);
253 U1.renameFile(secrets,currentPath,targetPath,root);;
255 tip.show(qsTr("Invalid file name!"))
259 Utils.setOrientation(root.orientation);