- Fixed torrent exchange from one list to another in Web Ui

This commit is contained in:
Christophe Dumez 2008-09-27 20:31:50 +00:00
parent 04e993c674
commit 78e643039c
5 changed files with 164 additions and 29 deletions

View file

@ -116,6 +116,44 @@ void EventManager::torrentSwitchedtoUnfinished(QString hash) {
event["type"] = QVariant("unfinish"); event["type"] = QVariant("unfinish");
event["hash"] = QVariant(h.hash()); event["hash"] = QVariant(h.hash());
event["name"] = QVariant(h.name()); 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); update(event);
} }
@ -125,6 +163,42 @@ void EventManager::torrentSwitchedtoFinished(QString hash) {
event["type"] = QVariant("finish"); event["type"] = QVariant("finish");
event["hash"] = QVariant(h.hash()); event["hash"] = QVariant(h.hash());
event["name"] = QVariant(h.name()); 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); update(event);
} }
@ -196,7 +270,7 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
v = QVariant((qlonglong)h.actual_size()); v = QVariant((qlonglong)h.actual_size());
if(modify(hash, "size", v)) if(modify(hash, "size", v))
event["size"] = v; event["size"] = v;
if(!h.is_seed()) {
v = QVariant(h.progress()); v = QVariant(h.progress());
if(modify(hash, "progress", v)) if(modify(hash, "progress", v))
event["progress"] = v; event["progress"] = v;
@ -204,7 +278,7 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
v = QVariant(h.download_payload_rate()); v = QVariant(h.download_payload_rate());
if(modify(hash, "dlspeed", v)) if(modify(hash, "dlspeed", v))
event["dlspeed"] = v; event["dlspeed"] = v;
}
v = QVariant(h.upload_payload_rate()); v = QVariant(h.upload_payload_rate());
if(modify(hash, "upspeed", v)) { if(modify(hash, "upspeed", v)) {
event["upspeed"] = v; event["upspeed"] = v;

View file

@ -22,7 +22,7 @@
<div id="mochaDesktop"> <div id="mochaDesktop">
<div id="mochaDesktopHeader"> <div id="mochaDesktopHeader">
<div id="mochaDesktopTitlebar"> <div id="mochaDesktopTitlebar">
<h1>qBittorrent Web User Interface <span class="version">version 1.1</span></h1> <h1>qBittorrent Web User Interface <span class="version">version 1.2</span></h1>
</div> </div>
<div id="mochaDesktopNavbar"> <div id="mochaDesktopNavbar">
<ul> <ul>
@ -96,8 +96,6 @@
<th></th> <th></th>
<th>Name</th> <th>Name</th>
<th>Size</th> <th>Size</th>
<th>Progress</th>
<th>DL Speed</th>
<th>UP Speed</th> <th>UP Speed</th>
</tr> </tr>
</thead> </thead>

View file

@ -28,8 +28,8 @@ window.addEvent('domready', function(){
height: '100%' height: '100%'
}); });
// Download list // Download list
myTable = new dynamicTable('myTable', {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'}); myTableUP = new dynamicTable('myTableUP', {overCls: 'over', selectCls: 'selected', altCls: 'alt', type: 'UP'});
var r=0; var r=0;
var waiting=false; var waiting=false;
var round1 = function(val){return Math.round(val*10)/10}; var round1 = function(val){return Math.round(val*10)/10};
@ -59,6 +59,9 @@ window.addEvent('domready', function(){
switch(event.type){ switch(event.type){
case 'add': case 'add':
var row = new Array(); var row = new Array();
if(event.seed)
row.length = 4;
else
row.length = 6; row.length = 6;
switch (event.state) switch (event.state)
{ {
@ -122,6 +125,7 @@ window.addEvent('domready', function(){
if($defined(event.size)){ if($defined(event.size)){
row[2] = fsize(event.size); row[2] = fsize(event.size);
} }
if(!event.seed) {
if($defined(event.progress)) if($defined(event.progress))
{ {
row[3] = round1(event.progress*100) + ' %'; row[3] = round1(event.progress*100) + ' %';
@ -130,6 +134,10 @@ window.addEvent('domready', function(){
row[4] = fspeed(event.dlspeed); row[4] = fspeed(event.dlspeed);
if($defined(event.upspeed)) if($defined(event.upspeed))
row[5] = fspeed(event.upspeed); row[5] = fspeed(event.upspeed);
} else {
if($defined(event.upspeed))
row[3] = fspeed(event.upspeed);
}
if(event.seed) if(event.seed)
myTableUP.updateRow(event.hash, row); myTableUP.updateRow(event.hash, row);
else else
@ -144,15 +152,69 @@ window.addEvent('domready', function(){
case 'finish': case 'finish':
myTable.removeRow(event.hash); myTable.removeRow(event.hash);
var row = new Array(); var row = new Array();
row.length = 6; row.length = 4;
switch (event.state)
{
case 'paused':
row[0] = '<img src="images/skin/paused.png"/>';
break;
case 'seeding':
row[0] = '<img src="images/skin/seeding.png"/>';
break;
case 'checking':
row[0] = '<img src="images/time.png"/>';
break;
case 'downloading':
row[0] = '<img src="images/skin/downloading.png"/>';
break;
case 'connecting':
row[0] = '<img src="images/skin/connecting.png"/>';
break;
case 'stalled':
row[0] = '<img src="images/skin/stalled.png"/>';
break;
case 'queued':
row[0] = '<img src="images/skin/queued.png"/>';
break;
}
row[1] = event.name; row[1] = event.name;
row[2] = fsize(event.size);
row[3] = fspeed(event.upspeed);
myTableUP.insertRow(event.hash, row); myTableUP.insertRow(event.hash, row);
break; break;
case 'unfinish': case 'unfinish':
myTableUP.removeRow(event.hash); myTableUP.removeRow(event.hash);
var row = new Array(); var row = new Array();
row.length = 6; row.length = 6;
switch (event.state)
{
case 'paused':
row[0] = '<img src="images/skin/paused.png"/>';
break;
case 'seeding':
row[0] = '<img src="images/skin/seeding.png"/>';
break;
case 'checking':
row[0] = '<img src="images/time.png"/>';
break;
case 'downloading':
row[0] = '<img src="images/skin/downloading.png"/>';
break;
case 'connecting':
row[0] = '<img src="images/skin/connecting.png"/>';
break;
case 'stalled':
row[0] = '<img src="images/skin/stalled.png"/>';
break;
case 'queued':
row[0] = '<img src="images/skin/queued.png"/>';
break;
}
row[1] = event.name; 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); myTable.insertRow(event.hash, row);
break; break;
} }

View file

@ -37,7 +37,8 @@ var dynamicTable = new Class ({
this.setOptions({ this.setOptions({
overCls: false, overCls: false,
selectCls: false, selectCls: false,
altCls: false altCls: false,
type: 'DL'
}, options); }, options);
this.table = $(table); this.table = $(table);
this.rows = new Object(); this.rows = new Object();

View file

@ -96,7 +96,7 @@ function attachMochaLinkEvents(){
loadMethod: 'iframe', loadMethod: 'iframe',
contentURL: 'http://bugs.qbittorrent.org/', contentURL: 'http://bugs.qbittorrent.org/',
width: 650, width: 650,
height: 400, height: 400
}); });
}); });
@ -108,7 +108,7 @@ function attachMochaLinkEvents(){
loadMethod: 'iframe', loadMethod: 'iframe',
contentURL: 'http://www.qbittorrent.org/', contentURL: 'http://www.qbittorrent.org/',
width: 650, width: 650,
height: 400, height: 400
}); });
}); });
@ -120,7 +120,7 @@ function attachMochaLinkEvents(){
loadMethod: 'iframe', loadMethod: 'iframe',
contentURL: 'http://wiki.qbittorrent.org/', contentURL: 'http://wiki.qbittorrent.org/',
width: 650, width: 650,
height: 400, height: 400
}); });
}); });
@ -132,7 +132,7 @@ function attachMochaLinkEvents(){
loadMethod: 'iframe', loadMethod: 'iframe',
contentURL: 'about.html', contentURL: 'about.html',
width: 650, width: 650,
height: 400, height: 400
}); });
}); });