kaddressbook Library API Documentation

printstyle.cpp

00001 /* -*- C++ -*-
00002    This file implements the abstract print style base class.
00003 
00004    the KDE addressbook
00005 
00006    $ Author: Mirko Boehm $
00007    $ Copyright: (C) 1996-2002, Mirko Boehm $
00008    $ Contact: mirko@kde.org
00009          http://www.kde.org $
00010    $ License: LGPL with the following explicit clarification:
00011          This code may be linked against any version of the Qt toolkit
00012          from Troll Tech, Norway. $
00013 
00014    $Revision: 1.5 $
00015 */
00016 
00017 #include <kstandarddirs.h>
00018 #include <kdebug.h>
00019 
00020 #include <qwidget.h>
00021 
00022 #include "printstyle.h"
00023 #include "printingwizard.h"
00024 
00025 using namespace KABPrinting;
00026 
00027 
00028 PrintStyle::PrintStyle( PrintingWizard* parent, const char* name )
00029   : QObject( parent, name ), mWizard( parent )
00030 {
00031 }
00032 
00033 PrintStyle::~PrintStyle()
00034 {
00035 }
00036 
00037 const QPixmap& PrintStyle::preview()
00038 {
00039   return mPreview;
00040 }
00041 
00042 void PrintStyle::setPreview( const QPixmap& image )
00043 {
00044   mPreview = image;
00045 }
00046 
00047 bool PrintStyle::setPreview( const QString& fileName )
00048 {
00049   QPixmap preview;
00050   QString path = locate( "appdata", "printing/" + fileName );
00051   if ( path.isEmpty() ) {
00052     kdDebug() << "PrintStyle::setPreview: preview not locatable." << endl;
00053     return false;
00054   } else {
00055     if ( preview.load( path ) ) {
00056       setPreview( preview );
00057       return true;
00058     } else {
00059       kdDebug() << "PrintStyle::setPreview: preview at '" << path << "' cannot be loaded." << endl;
00060       return false;
00061     }
00062   }
00063 }
00064 
00065 PrintingWizard *PrintStyle::wizard()
00066 {
00067   return mWizard;
00068 }
00069 
00070 void PrintStyle::addPage( QWidget *page, const QString &title )
00071 {
00072   if ( mPageList.find( page ) == -1 ) { // not yet in the list
00073     mPageList.append( page );
00074     mPageTitles.append( title );
00075   }
00076 }
00077 
00078 void PrintStyle::showPages()
00079 {
00080   QWidget *wdg = 0;
00081   int i = 0;
00082   for ( wdg = mPageList.first(); wdg; wdg = mPageList.next(), ++i ) {
00083     mWizard->addPage( wdg, mPageTitles[ i ] );
00084     if ( i == 0 )
00085       mWizard->setAppropriate( wdg, true );
00086   }
00087 
00088   if ( wdg )
00089     mWizard->setFinishEnabled( wdg, true );
00090 }
00091 
00092 void PrintStyle::hidePages()
00093 {
00094   for ( QWidget *wdg = mPageList.first(); wdg; wdg = mPageList.next() )
00095     mWizard->removePage( wdg );
00096 }
00097 
00098 PrintStyleFactory::PrintStyleFactory( PrintingWizard* parent, const char* name )
00099         : mParent( parent ), mName( name )
00100 {
00101 }
00102 
00103 PrintStyleFactory::~PrintStyleFactory()
00104 {
00105 }
00106 
00107 #include "printstyle.moc"
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:10 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001