Browse Source

- Fix little problem in evenmanager causing this output: "no status, should not happen!!!"

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
ff2fef0dc1
  1. 89
      src/eventmanager.cpp

89
src/eventmanager.cpp

@ -34,72 +34,73 @@
#include <QDebug> #include <QDebug>
EventManager::EventManager(QObject *parent, bittorrent *BTSession) EventManager::EventManager(QObject *parent, bittorrent *BTSession)
: QObject(parent), BTSession(BTSession) : QObject(parent), BTSession(BTSession)
{ {
} }
QList<QVariantMap> EventManager::getEventList() const { QList<QVariantMap> EventManager::getEventList() const {
return event_list.values(); return event_list.values();
} }
void EventManager::addedTorrent(QTorrentHandle& h) void EventManager::addedTorrent(QTorrentHandle& h)
{ {
modifiedTorrent(h); modifiedTorrent(h);
} }
void EventManager::deletedTorrent(QString hash) void EventManager::deletedTorrent(QString hash)
{ {
event_list.remove(hash); event_list.remove(hash);
} }
void EventManager::modifiedTorrent(QTorrentHandle h) void EventManager::modifiedTorrent(QTorrentHandle h)
{ {
QString hash = h.hash(); QString hash = h.hash();
QVariantMap event; QVariantMap event;
if(h.is_paused()) { if(h.is_paused()) {
event["state"] = QVariant("paused"); event["state"] = QVariant("paused");
} else {
if(BTSession->isQueueingEnabled() && h.is_queued()) {
event["state"] = QVariant("queued");
} else { } else {
if(BTSession->isQueueingEnabled() && h.is_queued()) { switch(h.state())
event["state"] = QVariant("queued"); {
} else {
switch(h.state())
{
case torrent_status::finished: case torrent_status::finished:
case torrent_status::seeding: case torrent_status::seeding:
event["state"] = QVariant("seeding"); event["state"] = QVariant("seeding");
break; break;
case torrent_status::checking_files: case torrent_status::allocating:
case torrent_status::queued_for_checking: case torrent_status::checking_files:
event["state"] = QVariant("checking"); case torrent_status::queued_for_checking:
break; case torrent_status::checking_resume_data:
case torrent_status::allocating: event["state"] = QVariant("checking");
break;
case torrent_status::downloading: case torrent_status::downloading:
case torrent_status::downloading_metadata: case torrent_status::downloading_metadata:
if(h.download_payload_rate() > 0) if(h.download_payload_rate() > 0)
event["state"] = QVariant("downloading"); event["state"] = QVariant("downloading");
else else
event["state"] = QVariant("stalled"); event["state"] = QVariant("stalled");
break; break;
default: default:
qDebug("No status, should not happen!!! status is %d", h.state()); qDebug("No status, should not happen!!! status is %d", h.state());
event["state"] = QVariant(); event["state"] = QVariant();
} }
}
} }
event["name"] = QVariant(h.name()); }
event["size"] = QVariant((qlonglong)h.actual_size()); event["name"] = QVariant(h.name());
if(!h.is_seed()) { event["size"] = QVariant((qlonglong)h.actual_size());
event["progress"] = QVariant(h.progress()); if(!h.is_seed()) {
event["dlspeed"] = QVariant(h.download_payload_rate()); event["progress"] = QVariant(h.progress());
if(BTSession->isQueueingEnabled()) { event["dlspeed"] = QVariant(h.download_payload_rate());
event["priority"] = QVariant(h.queue_position()); if(BTSession->isQueueingEnabled()) {
} else { event["priority"] = QVariant(h.queue_position());
event["priority"] = -1; } else {
} event["priority"] = -1;
} }
event["upspeed"] = QVariant(h.upload_payload_rate()); }
event["seed"] = QVariant(h.is_seed()); event["upspeed"] = QVariant(h.upload_payload_rate());
event["hash"] = QVariant(hash); event["seed"] = QVariant(h.is_seed());
event_list[hash] = event; event["hash"] = QVariant(hash);
event_list[hash] = event;
} }

Loading…
Cancel
Save