diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index 99e9c231f..31041b401 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -116,6 +116,44 @@ void EventManager::torrentSwitchedtoUnfinished(QString hash) { event["type"] = QVariant("unfinish"); event["hash"] = QVariant(h.hash()); event["name"] = QVariant(h.name()); + if(h.is_paused()) { + if(BTSession->isQueueingEnabled() && (BTSession->isDownloadQueued(hash) || BTSession->isUploadQueued(hash))) + event["state"] = QVariant("queued"); + else + event["state"] = QVariant("paused"); + } else { + switch(h.state()) + { + case torrent_status::finished: + case torrent_status::seeding: + event["state"] = QVariant("seeding"); + break; + case torrent_status::checking_files: + case torrent_status::queued_for_checking: + event["state"] = QVariant("checking"); + break; + case torrent_status::connecting_to_tracker: + if(h.download_payload_rate() > 0) + event["state"] = QVariant("downloading"); + else + event["state"] = QVariant("connecting"); + break; + case torrent_status::downloading: + case torrent_status::downloading_metadata: + if(h.download_payload_rate() > 0) + event["state"] = QVariant("downloading"); + else + event["state"] = QVariant("stalled"); + break; + default: + qDebug("No status, should not happen!!! status is %d", h.state()); + event["state"] = QVariant(); + } + } + event["size"] = QVariant((qlonglong)h.actual_size()); + event["progress"] = QVariant(h.progress()); + event["dlspeed"] = QVariant(h.download_payload_rate()); + event["upspeed"] = QVariant(h.upload_payload_rate()); update(event); } @@ -125,6 +163,42 @@ void EventManager::torrentSwitchedtoFinished(QString hash) { event["type"] = QVariant("finish"); event["hash"] = QVariant(h.hash()); event["name"] = QVariant(h.name()); + if(h.is_paused()) { + if(BTSession->isQueueingEnabled() && (BTSession->isDownloadQueued(hash) || BTSession->isUploadQueued(hash))) + event["state"] = QVariant("queued"); + else + event["state"] = QVariant("paused"); + } else { + switch(h.state()) + { + case torrent_status::finished: + case torrent_status::seeding: + event["state"] = QVariant("seeding"); + break; + case torrent_status::checking_files: + case torrent_status::queued_for_checking: + event["state"] = QVariant("checking"); + break; + case torrent_status::connecting_to_tracker: + if(h.download_payload_rate() > 0) + event["state"] = QVariant("downloading"); + else + event["state"] = QVariant("connecting"); + break; + case torrent_status::downloading: + case torrent_status::downloading_metadata: + if(h.download_payload_rate() > 0) + event["state"] = QVariant("downloading"); + else + event["state"] = QVariant("stalled"); + break; + default: + qDebug("No status, should not happen!!! status is %d", h.state()); + event["state"] = QVariant(); + } + } + event["size"] = QVariant((qlonglong)h.actual_size()); + event["upspeed"] = QVariant(h.upload_payload_rate()); update(event); } @@ -196,15 +270,15 @@ void EventManager::modifiedTorrent(QTorrentHandle h) v = QVariant((qlonglong)h.actual_size()); if(modify(hash, "size", v)) event["size"] = v; - - v = QVariant(h.progress()); - if(modify(hash, "progress", v)) - event["progress"] = v; - - v = QVariant(h.download_payload_rate()); - if(modify(hash, "dlspeed", v)) - event["dlspeed"] = v; - + if(!h.is_seed()) { + v = QVariant(h.progress()); + if(modify(hash, "progress", v)) + event["progress"] = v; + + v = QVariant(h.download_payload_rate()); + if(modify(hash, "dlspeed", v)) + event["dlspeed"] = v; + } v = QVariant(h.upload_payload_rate()); if(modify(hash, "upspeed", v)) { event["upspeed"] = v; diff --git a/src/webui/index.html b/src/webui/index.html index d8923da8f..72bd04abf 100644 --- a/src/webui/index.html +++ b/src/webui/index.html @@ -22,7 +22,7 @@
-

qBittorrent Web User Interface version 1.1

+

qBittorrent Web User Interface version 1.2

    @@ -96,8 +96,6 @@ Name Size - Progress - DL Speed UP Speed diff --git a/src/webui/scripts/client.js b/src/webui/scripts/client.js index 1638ecc7b..0b1ef1ff7 100644 --- a/src/webui/scripts/client.js +++ b/src/webui/scripts/client.js @@ -28,8 +28,8 @@ window.addEvent('domready', function(){ height: '100%' }); // Download list - myTable = new dynamicTable('myTable', {overCls: 'over', selectCls: 'selected', altCls: 'alt'}); - myTableUP = new dynamicTable('myTableUP', {overCls: 'over', selectCls: 'selected', altCls: 'alt'}); + myTable = new dynamicTable('myTable', {overCls: 'over', selectCls: 'selected', altCls: 'alt', type: 'DL'}); + myTableUP = new dynamicTable('myTableUP', {overCls: 'over', selectCls: 'selected', altCls: 'alt', type: 'UP'}); var r=0; var waiting=false; var round1 = function(val){return Math.round(val*10)/10}; @@ -59,7 +59,10 @@ window.addEvent('domready', function(){ switch(event.type){ case 'add': var row = new Array(); - row.length = 6; + if(event.seed) + row.length = 4; + else + row.length = 6; switch (event.state) { case 'paused': @@ -122,14 +125,19 @@ window.addEvent('domready', function(){ if($defined(event.size)){ row[2] = fsize(event.size); } - if($defined(event.progress)) - { - row[3] = round1(event.progress*100) + ' %'; - } - if($defined(event.dlspeed)) - row[4] = fspeed(event.dlspeed); - if($defined(event.upspeed)) - row[5] = fspeed(event.upspeed); + if(!event.seed) { + if($defined(event.progress)) + { + row[3] = round1(event.progress*100) + ' %'; + } + if($defined(event.dlspeed)) + row[4] = fspeed(event.dlspeed); + if($defined(event.upspeed)) + row[5] = fspeed(event.upspeed); + } else { + if($defined(event.upspeed)) + row[3] = fspeed(event.upspeed); + } if(event.seed) myTableUP.updateRow(event.hash, row); else @@ -144,15 +152,69 @@ window.addEvent('domready', function(){ case 'finish': myTable.removeRow(event.hash); var row = new Array(); - row.length = 6; + row.length = 4; + switch (event.state) + { + case 'paused': + row[0] = ''; + break; + case 'seeding': + row[0] = ''; + break; + case 'checking': + row[0] = ''; + break; + case 'downloading': + row[0] = ''; + break; + case 'connecting': + row[0] = ''; + break; + case 'stalled': + row[0] = ''; + break; + case 'queued': + row[0] = ''; + break; + } row[1] = event.name; + row[2] = fsize(event.size); + row[3] = fspeed(event.upspeed); myTableUP.insertRow(event.hash, row); break; case 'unfinish': myTableUP.removeRow(event.hash); var row = new Array(); row.length = 6; + switch (event.state) + { + case 'paused': + row[0] = ''; + break; + case 'seeding': + row[0] = ''; + break; + case 'checking': + row[0] = ''; + break; + case 'downloading': + row[0] = ''; + break; + case 'connecting': + row[0] = ''; + break; + case 'stalled': + row[0] = ''; + break; + case 'queued': + row[0] = ''; + break; + } row[1] = event.name; + row[2] = fsize(event.size); + row[3] = round1(event.progress*100) + ' %'; + row[4] = fspeed(event.dlspeed); + row[5] = fspeed(event.upspeed); myTable.insertRow(event.hash, row); break; } diff --git a/src/webui/scripts/dynamicTable.js b/src/webui/scripts/dynamicTable.js index 16e863102..e2f59ce5f 100644 --- a/src/webui/scripts/dynamicTable.js +++ b/src/webui/scripts/dynamicTable.js @@ -37,7 +37,8 @@ var dynamicTable = new Class ({ this.setOptions({ overCls: false, selectCls: false, - altCls: false + altCls: false, + type: 'DL' }, options); this.table = $(table); this.rows = new Object(); diff --git a/src/webui/scripts/mocha-events.js b/src/webui/scripts/mocha-events.js index ad92ba7f9..f3eb60f3b 100644 --- a/src/webui/scripts/mocha-events.js +++ b/src/webui/scripts/mocha-events.js @@ -96,7 +96,7 @@ function attachMochaLinkEvents(){ loadMethod: 'iframe', contentURL: 'http://bugs.qbittorrent.org/', width: 650, - height: 400, + height: 400 }); }); @@ -108,7 +108,7 @@ function attachMochaLinkEvents(){ loadMethod: 'iframe', contentURL: 'http://www.qbittorrent.org/', width: 650, - height: 400, + height: 400 }); }); @@ -120,7 +120,7 @@ function attachMochaLinkEvents(){ loadMethod: 'iframe', contentURL: 'http://wiki.qbittorrent.org/', width: 650, - height: 400, + height: 400 }); }); @@ -132,7 +132,7 @@ function attachMochaLinkEvents(){ loadMethod: 'iframe', contentURL: 'about.html', width: 650, - height: 400, + height: 400 }); });