mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 01:03:08 -07:00
- Web UI optimization
This commit is contained in:
parent
a189e4403d
commit
918c1507d3
4 changed files with 18 additions and 14 deletions
|
@ -1575,7 +1575,7 @@ bool GUI::initWebUi(QString username, QString password, int port)
|
||||||
httpServer->close();
|
httpServer->close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
httpServer = new HttpServer(BTSession, 500, this);
|
httpServer = new HttpServer(BTSession, 1000, this);
|
||||||
httpServer->setAuthorization(username, password);
|
httpServer->setAuthorization(username, password);
|
||||||
bool success = httpServer->listen(QHostAddress::Any, port);
|
bool success = httpServer->listen(QHostAddress::Any, port);
|
||||||
if (success)
|
if (success)
|
||||||
|
|
|
@ -32,7 +32,7 @@ EventManager::EventManager(QObject *parent, bittorrent *BTSession)
|
||||||
|
|
||||||
void EventManager::update(QVariantMap event)
|
void EventManager::update(QVariantMap event)
|
||||||
{
|
{
|
||||||
revision++;
|
++revision;
|
||||||
events << QPair<ulong, QVariantMap>(revision, event);
|
events << QPair<ulong, QVariantMap>(revision, event);
|
||||||
emit updated();
|
emit updated();
|
||||||
qDebug("Added the following event");
|
qDebug("Added the following event");
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
|
|
||||||
#include "httpresponsegenerator.h"
|
#include "httpresponsegenerator.h"
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
void HttpResponseGenerator::setMessage(const QByteArray message)
|
void HttpResponseGenerator::setMessage(const QByteArray message)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,13 +32,15 @@ HttpServer::HttpServer(bittorrent *BTSession, int msec, QObject* parent) : QTcpS
|
||||||
HttpServer::BTSession = BTSession;
|
HttpServer::BTSession = BTSession;
|
||||||
manager = new EventManager(this, BTSession);
|
manager = new EventManager(this, BTSession);
|
||||||
//add torrents
|
//add torrents
|
||||||
QStringList list = BTSession->getUnfinishedTorrents() + BTSession->getFinishedTorrents();
|
QStringList list = BTSession->getUnfinishedTorrents();
|
||||||
QString hash;
|
foreach(QString hash, list) {
|
||||||
foreach(hash, list)
|
|
||||||
{
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(h.is_valid())
|
if(h.is_valid()) manager->addedTorrent(h);
|
||||||
manager->addedTorrent(h);
|
}
|
||||||
|
list = BTSession->getFinishedTorrents();
|
||||||
|
foreach(QString hash, list) {
|
||||||
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
|
if(h.is_valid()) manager->addedTorrent(h);
|
||||||
}
|
}
|
||||||
//connect BTSession to manager
|
//connect BTSession to manager
|
||||||
connect(BTSession, SIGNAL(addedTorrent(QTorrentHandle&)), manager, SLOT(addedTorrent(QTorrentHandle&)));
|
connect(BTSession, SIGNAL(addedTorrent(QTorrentHandle&)), manager, SLOT(addedTorrent(QTorrentHandle&)));
|
||||||
|
@ -73,12 +75,15 @@ void HttpServer::newHttpConnection()
|
||||||
|
|
||||||
void HttpServer::onTimer()
|
void HttpServer::onTimer()
|
||||||
{
|
{
|
||||||
QStringList list = BTSession->getUnfinishedTorrents() + BTSession->getFinishedTorrents();
|
QStringList list = BTSession->getUnfinishedTorrents();
|
||||||
foreach(QString hash, list)
|
foreach(QString hash, list) {
|
||||||
{
|
|
||||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(h.is_valid())
|
if(h.is_valid()) manager->modifiedTorrent(h);
|
||||||
manager->modifiedTorrent(h);
|
}
|
||||||
|
list = BTSession->getFinishedTorrents();
|
||||||
|
foreach(QString hash, list) {
|
||||||
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
|
if(h.is_valid()) manager->modifiedTorrent(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue