From 4db757839ca023a0c5f52c0626b6afcecb8c933e Mon Sep 17 00:00:00 2001 From: Gabriele Date: Wed, 4 Mar 2015 20:00:00 +0100 Subject: [PATCH 1/3] WebUI: Return full path to files It's otherwise impossible to know the structure of a torrent. --- src/webui/btjson.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index 978e01e72..34bd0f986 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -479,7 +479,7 @@ QByteArray btjson::getFilesForTorrent(const QString& hash) h.file_progress(fp); for (int i = 0; i < h.num_files(); ++i) { QVariantMap file_dict; - QString fileName = h.filename_at(i); + QString fileName = h.filepath_at(i); if (fileName.endsWith(".!qB", Qt::CaseInsensitive)) fileName.chop(4); file_dict[KEY_FILE_NAME] = fsutils::toNativePath(fileName); From dd112c1e1be33a9dde0cea3bee9546a7f347cae9 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Wed, 4 Mar 2015 20:00:00 +0100 Subject: [PATCH 2/3] WebUI: Simplify the code for the update of the content table --- src/webui/www/public/scripts/prop-files.js | 73 ++++++++++------------ 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/src/webui/www/public/scripts/prop-files.js b/src/webui/www/public/scripts/prop-files.js index 7ad473220..d53b7ae51 100644 --- a/src/webui/www/public/scripts/prop-files.js +++ b/src/webui/www/public/scripts/prop-files.js @@ -202,31 +202,28 @@ var filesDynTable = new Class({ updateRow: function(tr, row, id) { var tds = tr.getElements('td'); for (var i = 0; i < row.length; i++) { - if (i == 3) { + switch (i) { + case 0: + if (row[i] > 0) + tds[i].getChildren('input')[0].set('checked', 'checked'); + else + tds[i].getChildren('input')[0].removeProperty('checked'); + break; + case 3: $('pbf_' + id).setValue(row[i].toFloat()); - } - else { - if (i == 0) { - if (row[i] > 0) - tds[i].getChildren('input')[0].set('checked', 'checked'); - else - tds[i].getChildren('input')[0].removeProperty('checked') + break; + case 4: + if (!is_seed && row[i] > 0) { + tds[i].getChildren('select').set('value', row[i]); + $('comboPrio' + id).removeClass("invisible"); } else { - if (i == 4) { - if (!is_seed && row[i] > 0) { - tds[i].getChildren('select').set('value', row[i]); - $('comboPrio' + id).removeClass("invisible"); - } - else { - if (!$('comboPrio' + id).hasClass("invisible")) - $('comboPrio' + id).addClass("invisible"); - } - } - else { - tds[i].set('html', row[i]); - } + if (!$('comboPrio' + id).hasClass("invisible")) + $('comboPrio' + id).addClass("invisible"); } + break; + default: + tds[i].set('html', row[i]); } } return true; @@ -243,28 +240,26 @@ var filesDynTable = new Class({ this.rows.set(id, tr); for (var i = 0; i < row.length; i++) { var td = new Element('td'); - if (i == 3) { + switch (i) { + case 0: + var tree_img = new Element('img', { + src: 'images/L.gif', + style: 'margin-bottom: -2px' + }); + td.adopt(tree_img, createDownloadedCB(id, row[i])); + break; + case 3: td.adopt(new ProgressBar(row[i].toFloat(), { 'id': 'pbf_' + id, 'width': 80 })); - } - else { - if (i == 0) { - var tree_img = new Element('img', { - src: 'images/L.gif', - style: 'margin-bottom: -2px' - }); - td.adopt(tree_img, createDownloadedCB(id, row[i])); - } - else { - if (i == 4) { - td.adopt(createPriorityCombo(id, row[i])); - } - else { - td.set('html', row[i]); - } - } + break; + case 4: + td.adopt(createPriorityCombo(id, row[i])); + break; + default: + td.set('html', row[i]); + break; } td.injectInside(tr); } From 1e4d11801e86d9177f1f3e9b1035303b5aeb3c67 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Wed, 4 Mar 2015 20:00:00 +0100 Subject: [PATCH 3/3] WebUI: Add title attribute to filename cells in content tab This will show the entire file path in a tooltip. This is useful especially since bb1649a797 ("WebUI: return full paths to files). --- src/webui/www/public/scripts/prop-files.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webui/www/public/scripts/prop-files.js b/src/webui/www/public/scripts/prop-files.js index d53b7ae51..8a37b7dc9 100644 --- a/src/webui/www/public/scripts/prop-files.js +++ b/src/webui/www/public/scripts/prop-files.js @@ -248,6 +248,10 @@ var filesDynTable = new Class({ }); td.adopt(tree_img, createDownloadedCB(id, row[i])); break; + case 1: + td.set('html', row[i]); + td.set('title', row[i]); + break; case 3: td.adopt(new ProgressBar(row[i].toFloat(), { 'id': 'pbf_' + id,