kaddressbook

printprogress.cpp

00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #include <qlayout.h>
00025 #include <qprogressbar.h>
00026 #include <qtextbrowser.h>
00027 
00028 #include <kapplication.h>
00029 #include <kdebug.h>
00030 #include <kdialog.h>
00031 #include <klocale.h>
00032 
00033 #include "printprogress.h"
00034 
00035 using namespace KABPrinting;
00036 
00037 PrintProgress::PrintProgress( QWidget *parent, const char *name )
00038   : QWidget( parent, name )
00039 {
00040   setCaption( i18n( "Printing: Progress" ) );
00041 
00042   QGridLayout *topLayout = new QGridLayout( this, 1, 1, KDialog::marginHint(),
00043                                             KDialog::spacingHint() );
00044 
00045   mLogBrowser = new QTextBrowser( this );
00046   topLayout->addWidget( mLogBrowser, 0, 0 );
00047 
00048   mProgressBar = new QProgressBar( this );
00049   mProgressBar->setProgress( 0 );
00050   topLayout->addWidget( mProgressBar, 1, 0 );
00051 
00052   resize( QSize( 370, 220 ).expandedTo( minimumSizeHint() ) );
00053 }
00054 
00055 PrintProgress::~PrintProgress()
00056 {
00057 }
00058 
00059 void PrintProgress::addMessage( const QString &msg )
00060 {
00061   mMessages.append( msg );
00062 
00063   QString head = QString( "<qt><b>" ) + i18n( "Progress" ) +
00064                  QString( ":</b><ul>" );
00065 
00066   QString foot = QString( "</ul></qt>" );
00067 
00068   QString body;
00069   QStringList::ConstIterator it;
00070   for ( it = mMessages.begin(); it != mMessages.end(); ++it )
00071     body.append( QString( "<li>" ) + (*it) + QString( "</li>" ) );
00072 
00073   mLogBrowser->setText( head + body + foot );
00074   kapp->processEvents();
00075 }
00076 
00077 void PrintProgress::setProgress( int step )
00078 {
00079   mProgressBar->setProgress( step );
00080   kapp->processEvents();
00081 }
00082 
00083 #include "printprogress.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys