- 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["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;

View file

@ -22,7 +22,7 @@
<div id="mochaDesktop">
<div id="mochaDesktopHeader">
<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 id="mochaDesktopNavbar">
<ul>
@ -96,8 +96,6 @@
<th></th>
<th>Name</th>
<th>Size</th>
<th>Progress</th>
<th>DL Speed</th>
<th>UP Speed</th>
</tr>
</thead>

View file

@ -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] = '<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[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] = '<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[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;
}

View file

@ -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();

View file

@ -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
});
});