From eea85b9b5add642d9c3ecec043bd4c4f0dc8208a Mon Sep 17 00:00:00 2001 From: Starccy <452276725@qq.com> Date: Sun, 17 Oct 2021 21:27:10 +0800 Subject: [PATCH] send & receive multiple files --- src/ui/file_transfer.css | 10 ++++++++++ src/ui/file_transfer.tis | 32 ++++++++++++++++++++++++++++---- src/ui/grid.tis | 5 +++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/ui/file_transfer.css b/src/ui/file_transfer.css index 8acde0623..d1e1a4072 100644 --- a/src/ui/file_transfer.css +++ b/src/ui/file_transfer.css @@ -30,6 +30,7 @@ table > thead { } table > tbody { + behavior: select-multiple; overflow-y: scroll-indicator; size: *; background: white; @@ -85,6 +86,15 @@ table.has_current tr:current /* current row */ background-color: color(accent); } +table.has_current tbody tr:checked +{ + background-color: color(accent); +} + +table.has_current tbody tr:checked td { + color: highlighttext; +} + table td { padding: 4px; diff --git a/src/ui/file_transfer.tis b/src/ui/file_transfer.tis index da980d3cd..700efbdd2 100644 --- a/src/ui/file_transfer.tis +++ b/src/ui/file_transfer.tis @@ -25,6 +25,12 @@ var svg_computer = ; +const TYPE_DIR = 1; +const TYPE_DIR_LINK = 2; +const TYPE_DIR_DRIVE = 3; +const TYPE_FILE = 4; +const TYPE_FILE_LINK = 5; + function getSize(type, size) { if (!size) { if (type <= 3) return ""; @@ -374,7 +380,7 @@ class FolderView : Reactor.Component { path = this.joinPath(entry.name); } var tm = entry.time ? new Date(entry.time.toFloat() * 1000.).toLocaleString() : 0; - return + return {entry.name} {tm || ""} @@ -463,10 +469,28 @@ class FolderView : Reactor.Component { return [this.joinPath(name), type]; } + function getCurrentRows() { + var rows = this.table.getCurrentRows(); + if (!rows || rows.length== 0) return; + + var records = new Array(); + + for (var i = 0; i < rows.length; ++i) { + var name = rows[i][1].text; + if (!name || name == "..") continue; + + var type = rows[i][0].attributes["type"]; + records.push([this.joinPath(name), type]); + } + return records; + } + event click $(.send) () { - var cur = this.getCurrentRow(); - if (!cur) return; - file_transfer.job_table.send(cur[0], this.is_remote); + var rows = this.getCurrentRows(); + if (!rows || rows.length == 0) return; + for (var i = 0; i < rows.length; ++i) { + file_transfer.job_table.send(rows[i][0], this.is_remote); + } } event change $(.select-dir) (_, el) { diff --git a/src/ui/grid.tis b/src/ui/grid.tis index cb5932678..f33b4ef35 100644 --- a/src/ui/grid.tis +++ b/src/ui/grid.tis @@ -24,6 +24,11 @@ class Grid: Behavior { { return this.$(tbody>tr:current); } + + function getCurrentRows() + { + return this.$$(tbody>tr:checked); + } function getCurrentColumn() {