mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
91fc9e69ee
commit
8966bcacea
@ -39,11 +39,11 @@
|
||||
#include "iconprovider.h"
|
||||
#include "loglistwidget.h"
|
||||
|
||||
ExecutionLog::ExecutionLog(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ExecutionLog),
|
||||
m_msgList(new LogListWidget(MAX_LOG_MESSAGES)),
|
||||
m_peerList(new LogListWidget(MAX_LOG_MESSAGES))
|
||||
ExecutionLog::ExecutionLog(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::ExecutionLog)
|
||||
, m_msgList(new LogListWidget(MAX_LOG_MESSAGES))
|
||||
, m_peerList(new LogListWidget(MAX_LOG_MESSAGES))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -54,57 +54,57 @@ ExecutionLog::ExecutionLog(QWidget *parent) :
|
||||
|
||||
const Logger* const logger = Logger::instance();
|
||||
foreach (const Log::Msg& msg, logger->getMessages())
|
||||
addLogMessage(msg);
|
||||
addLogMessage(msg);
|
||||
foreach (const Log::Peer& peer, logger->getPeers())
|
||||
addPeerMessage(peer);
|
||||
connect(logger, SIGNAL(newLogMessage(const Log::Msg &)), SLOT(addLogMessage(const Logg:Msg &)));
|
||||
addPeerMessage(peer);
|
||||
connect(logger, SIGNAL(newLogMessage(const Log::Msg &)), SLOT(addLogMessage(const Log::Msg &)));
|
||||
connect(logger, SIGNAL(newLogPeer(const Log::Peer &)), SLOT(addPeerMessage(const Log::Peer &)));
|
||||
}
|
||||
|
||||
ExecutionLog::~ExecutionLog()
|
||||
{
|
||||
delete m_msgList;
|
||||
delete m_peerList;
|
||||
delete ui;
|
||||
delete m_msgList;
|
||||
delete m_peerList;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ExecutionLog::addLogMessage(const Log::Msg &msg)
|
||||
{
|
||||
QString text;
|
||||
QDateTime time = QDateTime::fromMSecsSinceEpoch(msg.timestamp);
|
||||
QColor color;
|
||||
QString text;
|
||||
QDateTime time = QDateTime::fromMSecsSinceEpoch(msg.timestamp);
|
||||
QColor color;
|
||||
|
||||
switch (msg.type) {
|
||||
case Log::INFO:
|
||||
color.setNamedColor("blue");
|
||||
break;
|
||||
case Log::WARNING:
|
||||
color.setNamedColor("orange");
|
||||
break;
|
||||
case Log::CRITICAL:
|
||||
color.setNamedColor("red");
|
||||
break;
|
||||
default:
|
||||
color = QApplication::palette().color(QPalette::WindowText);
|
||||
}
|
||||
switch (msg.type) {
|
||||
case Log::INFO:
|
||||
color.setNamedColor("blue");
|
||||
break;
|
||||
case Log::WARNING:
|
||||
color.setNamedColor("orange");
|
||||
break;
|
||||
case Log::CRITICAL:
|
||||
color.setNamedColor("red");
|
||||
break;
|
||||
default:
|
||||
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>";
|
||||
m_msgList->appendLine(text);
|
||||
text = "<font color='grey'>" + time.toString("dd/MM/yyyy hh:mm:ss") + "</font> - <font color='" + color.name() + "'>" + msg.message + "</font>";
|
||||
m_msgList->appendLine(text);
|
||||
}
|
||||
|
||||
void ExecutionLog::addPeerMessage(const Log::Peer& peer)
|
||||
{
|
||||
QString text;
|
||||
QDateTime time = QDateTime::fromMSecsSinceEpoch(peer.timestamp);
|
||||
QString text;
|
||||
QDateTime time = QDateTime::fromMSecsSinceEpoch(peer.timestamp);
|
||||
|
||||
if (peer.blocked)
|
||||
if (peer.blocked)
|
||||
#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
|
||||
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
|
||||
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);
|
||||
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);
|
||||
|
||||
m_peerList->appendLine(text);
|
||||
m_peerList->appendLine(text);
|
||||
}
|
||||
|
@ -43,11 +43,11 @@ class LogListWidget;
|
||||
|
||||
namespace Log
|
||||
{
|
||||
struct Msg;
|
||||
struct Peer;
|
||||
struct Msg;
|
||||
struct Peer;
|
||||
}
|
||||
|
||||
class ExecutionLog : public QWidget
|
||||
class ExecutionLog: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -56,14 +56,14 @@ public:
|
||||
~ExecutionLog();
|
||||
|
||||
private slots:
|
||||
void addLogMessage(const Log::Msg &msg);
|
||||
void addPeerMessage(const Log::Peer &peer);
|
||||
void addLogMessage(const Log::Msg &msg);
|
||||
void addPeerMessage(const Log::Peer &peer);
|
||||
|
||||
private:
|
||||
Ui::ExecutionLog *ui;
|
||||
Ui::ExecutionLog *ui;
|
||||
|
||||
LogListWidget *m_msgList;
|
||||
LogListWidget *m_peerList;
|
||||
LogListWidget *m_msgList;
|
||||
LogListWidget *m_peerList;
|
||||
};
|
||||
|
||||
#endif // EXECUTIONLOG_H
|
||||
|
Loading…
Reference in New Issue
Block a user