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