mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
91fc9e69ee
commit
8966bcacea
2 changed files with 45 additions and 45 deletions
|
@ -39,11 +39,11 @@
|
||||||
#include "iconprovider.h"
|
#include "iconprovider.h"
|
||||||
#include "loglistwidget.h"
|
#include "loglistwidget.h"
|
||||||
|
|
||||||
ExecutionLog::ExecutionLog(QWidget *parent) :
|
ExecutionLog::ExecutionLog(QWidget *parent)
|
||||||
QWidget(parent),
|
: QWidget(parent)
|
||||||
ui(new Ui::ExecutionLog),
|
, ui(new Ui::ExecutionLog)
|
||||||
m_msgList(new LogListWidget(MAX_LOG_MESSAGES)),
|
, m_msgList(new LogListWidget(MAX_LOG_MESSAGES))
|
||||||
m_peerList(new LogListWidget(MAX_LOG_MESSAGES))
|
, m_peerList(new LogListWidget(MAX_LOG_MESSAGES))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -54,57 +54,57 @@ ExecutionLog::ExecutionLog(QWidget *parent) :
|
||||||
|
|
||||||
const Logger* const logger = Logger::instance();
|
const Logger* const logger = Logger::instance();
|
||||||
foreach (const Log::Msg& msg, logger->getMessages())
|
foreach (const Log::Msg& msg, logger->getMessages())
|
||||||
addLogMessage(msg);
|
addLogMessage(msg);
|
||||||
foreach (const Log::Peer& peer, logger->getPeers())
|
foreach (const Log::Peer& peer, logger->getPeers())
|
||||||
addPeerMessage(peer);
|
addPeerMessage(peer);
|
||||||
connect(logger, SIGNAL(newLogMessage(const Log::Msg &)), SLOT(addLogMessage(const Logg:Msg &)));
|
connect(logger, SIGNAL(newLogMessage(const Log::Msg &)), SLOT(addLogMessage(const Log::Msg &)));
|
||||||
connect(logger, SIGNAL(newLogPeer(const Log::Peer &)), SLOT(addPeerMessage(const Log::Peer &)));
|
connect(logger, SIGNAL(newLogPeer(const Log::Peer &)), SLOT(addPeerMessage(const Log::Peer &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutionLog::~ExecutionLog()
|
ExecutionLog::~ExecutionLog()
|
||||||
{
|
{
|
||||||
delete m_msgList;
|
delete m_msgList;
|
||||||
delete m_peerList;
|
delete m_peerList;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecutionLog::addLogMessage(const Log::Msg &msg)
|
void ExecutionLog::addLogMessage(const Log::Msg &msg)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
QDateTime time = QDateTime::fromMSecsSinceEpoch(msg.timestamp);
|
QDateTime time = QDateTime::fromMSecsSinceEpoch(msg.timestamp);
|
||||||
QColor color;
|
QColor color;
|
||||||
|
|
||||||
switch (msg.type) {
|
switch (msg.type) {
|
||||||
case Log::INFO:
|
case Log::INFO:
|
||||||
color.setNamedColor("blue");
|
color.setNamedColor("blue");
|
||||||
break;
|
break;
|
||||||
case Log::WARNING:
|
case Log::WARNING:
|
||||||
color.setNamedColor("orange");
|
color.setNamedColor("orange");
|
||||||
break;
|
break;
|
||||||
case Log::CRITICAL:
|
case Log::CRITICAL:
|
||||||
color.setNamedColor("red");
|
color.setNamedColor("red");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
color = QApplication::palette().color(QPalette::WindowText);
|
color = QApplication::palette().color(QPalette::WindowText);
|
||||||
}
|
}
|
||||||
|
|
||||||
text = "<font color='grey'>" + time.toString("dd/MM/yyyy hh:mm:ss") + "</font> - <font color='" + color.name() + "'>" + msg.message + "</font>";
|
text = "<font color='grey'>" + time.toString("dd/MM/yyyy hh:mm:ss") + "</font> - <font color='" + color.name() + "'>" + msg.message + "</font>";
|
||||||
m_msgList->appendLine(text);
|
m_msgList->appendLine(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecutionLog::addPeerMessage(const Log::Peer& peer)
|
void ExecutionLog::addPeerMessage(const Log::Peer& peer)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
QDateTime time = QDateTime::fromMSecsSinceEpoch(peer.timestamp);
|
QDateTime time = QDateTime::fromMSecsSinceEpoch(peer.timestamp);
|
||||||
|
|
||||||
if (peer.blocked)
|
if (peer.blocked)
|
||||||
#if LIBTORRENT_VERSION_NUM < 10000
|
#if LIBTORRENT_VERSION_NUM < 10000
|
||||||
text = "<font color='grey'>" + time.toString("dd/MM/yyyy hh:mm:ss") + "</font> - " + tr("<font color='red'>%1</font> was blocked", "x.y.z.w was blocked").arg(peer.ip);
|
text = "<font color='grey'>" + time.toString("dd/MM/yyyy hh:mm:ss") + "</font> - " + tr("<font color='red'>%1</font> was blocked", "x.y.z.w was blocked").arg(peer.ip);
|
||||||
#else
|
#else
|
||||||
text = "<font color='grey'>" + time.toString("dd/MM/yyyy hh:mm:ss") + "</font> - " + tr("<font color='red'>%1</font> was blocked %2", "x.y.z.w was blocked").arg(peer.ip).arg(peer.reason);
|
text = "<font color='grey'>" + time.toString("dd/MM/yyyy hh:mm:ss") + "</font> - " + tr("<font color='red'>%1</font> was blocked %2", "x.y.z.w was blocked").arg(peer.ip).arg(peer.reason);
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
text = "<font color='grey'>" + time.toString("dd/MM/yyyy hh:mm:ss") + "</font> - " + tr("<font color='red'>%1</font> was banned", "x.y.z.w was banned").arg(peer.ip);
|
text = "<font color='grey'>" + time.toString("dd/MM/yyyy hh:mm:ss") + "</font> - " + tr("<font color='red'>%1</font> was banned", "x.y.z.w was banned").arg(peer.ip);
|
||||||
|
|
||||||
m_peerList->appendLine(text);
|
m_peerList->appendLine(text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,11 @@ class LogListWidget;
|
||||||
|
|
||||||
namespace Log
|
namespace Log
|
||||||
{
|
{
|
||||||
struct Msg;
|
struct Msg;
|
||||||
struct Peer;
|
struct Peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExecutionLog : public QWidget
|
class ExecutionLog: public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -56,14 +56,14 @@ public:
|
||||||
~ExecutionLog();
|
~ExecutionLog();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addLogMessage(const Log::Msg &msg);
|
void addLogMessage(const Log::Msg &msg);
|
||||||
void addPeerMessage(const Log::Peer &peer);
|
void addPeerMessage(const Log::Peer &peer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ExecutionLog *ui;
|
Ui::ExecutionLog *ui;
|
||||||
|
|
||||||
LogListWidget *m_msgList;
|
LogListWidget *m_msgList;
|
||||||
LogListWidget *m_peerList;
|
LogListWidget *m_peerList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXECUTIONLOG_H
|
#endif // EXECUTIONLOG_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue