kitchensync

logdialog.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library 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 GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <klocale.h>
00023 #include <libkdepim/progressmanager.h>
00024 
00025 #include <qdatetime.h>
00026 #include <qlayout.h>
00027 #include <qtextedit.h>
00028 
00029 #include "logdialog.h"
00030 
00031 LogDialog::LogDialog( QWidget *parent )
00032   : KDialogBase( Plain, i18n( "Log Dialog" ), Ok | User1, Ok,
00033                  parent, "", false, true )
00034 {
00035   initGUI();
00036 
00037   KPIM::ProgressManager *pm = KPIM::ProgressManager::instance();
00038   connect ( pm, SIGNAL( progressItemAdded( KPIM::ProgressItem* ) ),
00039             this, SLOT( progressItemAdded( KPIM::ProgressItem* ) ) );
00040   connect ( pm, SIGNAL( progressItemStatus( KPIM::ProgressItem*, const QString& ) ),
00041             this, SLOT( progressItemStatus( KPIM::ProgressItem*, const QString& ) ) );
00042 
00043   setButtonText( User1, i18n( "Clear Log" ) );
00044 
00045   connect( this, SIGNAL( user1Clicked() ),
00046            mView, SLOT( clear() ) );
00047 
00048   setInitialSize( QSize( 550, 260 ) );
00049 }
00050 
00051 void LogDialog::progressItemAdded( KPIM::ProgressItem *item )
00052 {
00053   log( item->status() );
00054 }
00055 
00056 void LogDialog::progressItemStatus( KPIM::ProgressItem*, const QString &statusMsg )
00057 {
00058   log( statusMsg );
00059 }
00060 
00061 void LogDialog::log( const QString &msg )
00062 {
00063   mView->append( QDateTime::currentDateTime().toString( Qt::ISODate ) + ": " + msg + "\n" );
00064 }
00065 
00066 void LogDialog::initGUI()
00067 {
00068   QWidget *page = plainPage();
00069 
00070   QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() );
00071   mView = new QTextEdit( page );
00072   mView->setReadOnly( true );
00073 
00074   layout->addWidget( mView );
00075 }
00076 
00077 #include "logdialog.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys