• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

akonadi/clients

debugwidget.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of Akonadi.
00003 
00004     Copyright (c) 2006 Tobias Koenig <tokoe@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019     USA.
00020 */
00021 
00022 #include "debugwidget.h"
00023 
00024 #include <QtGui/QPushButton>
00025 #include <QtGui/QSplitter>
00026 #include <QtGui/QTabWidget>
00027 #include <QtGui/QTextEdit>
00028 #include <QtGui/QVBoxLayout>
00029 
00030 #include "tracernotificationinterface.h"
00031 #include "connectionpage.h"
00032 
00033 DebugWidget::DebugWidget( QWidget *parent )
00034   : QWidget( parent )
00035 {
00036   QVBoxLayout *layout = new QVBoxLayout( this );
00037 
00038   QSplitter *splitter = new QSplitter( Qt::Vertical, this );
00039   splitter->setObjectName( "debugSplitter" );
00040   layout->addWidget( splitter );
00041 
00042   mConnectionPages = new QTabWidget( splitter );
00043 
00044   mGeneralView = new QTextEdit( splitter );
00045   mGeneralView->setReadOnly( true );
00046 
00047   ConnectionPage *page = new ConnectionPage( "All" );
00048   page->showAllConnections( true );
00049   mConnectionPages->addTab( page, "All" );
00050 
00051   org::freedesktop::Akonadi::TracerNotification *iface = new org::freedesktop::Akonadi::TracerNotification( QString(), "/tracing/notifications", QDBusConnection::sessionBus(), this );
00052 
00053   connect( iface, SIGNAL( connectionStarted( const QString&, const QString& ) ),
00054            this, SLOT( connectionStarted( const QString&, const QString& ) ) );
00055   connect( iface, SIGNAL( connectionEnded( const QString&, const QString& ) ),
00056            this, SLOT( connectionEnded( const QString&, const QString& ) ) );
00057   connect( iface, SIGNAL( signalEmitted( const QString&, const QString& ) ),
00058            this, SLOT( signalEmitted( const QString&, const QString& ) ) );
00059   connect( iface, SIGNAL( warningEmitted( const QString&, const QString& ) ),
00060            this, SLOT( warningEmitted( const QString&, const QString& ) ) );
00061   connect( iface, SIGNAL( errorEmitted( const QString&, const QString& ) ),
00062            this, SLOT( errorEmitted( const QString&, const QString& ) ) );
00063 
00064   // in case we started listening when the connection is already ongoing
00065   connect( iface, SIGNAL( connectionDataInput( const QString&, const QString& ) ),
00066            this, SLOT( connectionStarted( const QString&, const QString& ) ) );
00067   connect( iface, SIGNAL( connectionDataOutput( const QString&, const QString& ) ),
00068            this, SLOT( connectionStarted( const QString&, const QString& ) ) );
00069 
00070   QHBoxLayout *buttonLayout = new QHBoxLayout;
00071   layout->addLayout( buttonLayout );
00072 
00073   QPushButton *clearAllButton = new QPushButton( "Clear All", this );
00074   QPushButton *clearGeneralButton = new QPushButton( "Clear General", this );
00075 
00076   buttonLayout->addWidget( clearAllButton );
00077   buttonLayout->addWidget( clearGeneralButton );
00078 
00079   connect( clearAllButton, SIGNAL( clicked() ), page, SLOT( clear() ) );
00080   connect( clearGeneralButton, SIGNAL( clicked() ), mGeneralView, SLOT( clear() ) );
00081 }
00082 
00083 void DebugWidget::connectionStarted( const QString &identifier, const QString &msg )
00084 {
00085   Q_UNUSED( msg );
00086   if ( mPageHash.contains( identifier ) )
00087     return;
00088 
00089   ConnectionPage *page = new ConnectionPage( identifier );
00090   mConnectionPages->addTab( page, identifier );
00091 
00092   mPageHash.insert( identifier, page );
00093 }
00094 
00095 void DebugWidget::connectionEnded( const QString &identifier, const QString& )
00096 {
00097   if ( !mPageHash.contains( identifier ) )
00098     return;
00099 
00100   QWidget *widget = mPageHash[ identifier ];
00101 
00102   mConnectionPages->removeTab( mConnectionPages->indexOf( widget ) );
00103 
00104   mPageHash.remove( identifier );
00105   delete widget;
00106 }
00107 
00108 void DebugWidget::signalEmitted( const QString &signalName, const QString &msg )
00109 {
00110   mGeneralView->append( QString( "<font color=\"green\">%1 ( %2 )</font>" ).arg( signalName, msg ) );
00111 }
00112 
00113 void DebugWidget::warningEmitted( const QString &componentName, const QString &msg )
00114 {
00115   mGeneralView->append( QString( "<font color=\"blue\">%1: %2</font>" ).arg( componentName, msg ) );
00116 }
00117 
00118 void DebugWidget::errorEmitted( const QString &componentName, const QString &msg )
00119 {
00120   mGeneralView->append( QString( "<font color=\"red\">%1: %2</font>" ).arg( componentName, msg ) );
00121 }
00122 
00123 #include "debugwidget.moc"

akonadi/clients

Skip menu "akonadi/clients"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal