akonadi/clients
connectionpage.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "connectionpage.h"
00023
00024 #include <QtGui/QTextEdit>
00025 #include <QtGui/QVBoxLayout>
00026
00027 #include "tracernotificationinterface.h"
00028
00029 ConnectionPage::ConnectionPage( const QString &identifier, QWidget *parent )
00030 : QWidget( parent ), mIdentifier( identifier ), mShowAllConnections( false )
00031 {
00032 QVBoxLayout *layout = new QVBoxLayout( this );
00033
00034 mDataView = new QTextEdit( this );
00035 mDataView->setReadOnly( true );
00036
00037 layout->addWidget( mDataView );
00038
00039 org::freedesktop::Akonadi::TracerNotification *iface = new org::freedesktop::Akonadi::TracerNotification( QString(), "/tracing/notifications", QDBusConnection::sessionBus(), this );
00040
00041 connect( iface, SIGNAL( connectionDataInput( const QString&, const QString& ) ),
00042 this, SLOT( connectionDataInput( const QString&, const QString& ) ) );
00043 connect( iface, SIGNAL( connectionDataOutput( const QString&, const QString& ) ),
00044 this, SLOT( connectionDataOutput( const QString&, const QString& ) ) );
00045 }
00046
00047 void ConnectionPage::connectionDataInput( const QString &identifier, const QString &msg )
00048 {
00049 QString str;
00050 if ( mShowAllConnections ) {
00051 str += identifier + ' ';
00052 }
00053 if ( mShowAllConnections || identifier == mIdentifier ) {
00054 str += QString( "<font color=\"red\">%1</font>" ).arg( Qt::escape( msg ) );
00055 mDataView->append( str );
00056 }
00057 }
00058
00059 void ConnectionPage::connectionDataOutput( const QString &identifier, const QString &msg )
00060 {
00061 QString str;
00062 if ( mShowAllConnections ) {
00063 str += identifier + ' ';
00064 }
00065 if ( mShowAllConnections || identifier == mIdentifier ) {
00066 str += QString( "<font color=\"blue\">%1</font>" ).arg( Qt::escape( msg ) );
00067 mDataView->append( str );
00068 }
00069 }
00070
00071 void ConnectionPage::showAllConnections( bool show )
00072 {
00073 mShowAllConnections = show;
00074 }
00075
00076 void ConnectionPage::clear()
00077 {
00078 mDataView->clear();
00079 }
00080
00081 #include "connectionpage.moc"