kaddressbook Library API Documentation

printstyle.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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 <kstandarddirs.h>
00025 #include <kdebug.h>
00026 
00027 #include <qwidget.h>
00028 
00029 #include "printstyle.h"
00030 #include "printingwizard.h"
00031 
00032 using namespace KABPrinting;
00033 
00034 
00035 PrintStyle::PrintStyle( PrintingWizard* parent, const char* name )
00036   : QObject( parent, name ), mWizard( parent ), mSortField( 0 )
00037 {
00038 }
00039 
00040 PrintStyle::~PrintStyle()
00041 {
00042 }
00043 
00044 const QPixmap& PrintStyle::preview()
00045 {
00046   return mPreview;
00047 }
00048 
00049 void PrintStyle::setPreview( const QPixmap& image )
00050 {
00051   mPreview = image;
00052 }
00053 
00054 bool PrintStyle::setPreview( const QString& fileName )
00055 {
00056   QPixmap preview;
00057   QString path = locate( "appdata", "printing/" + fileName );
00058   if ( path.isEmpty() ) {
00059     kdDebug(5720) << "PrintStyle::setPreview: preview not locatable." << endl;
00060     return false;
00061   } else {
00062     if ( preview.load( path ) ) {
00063       setPreview( preview );
00064       return true;
00065     } else {
00066       kdDebug(5720) << "PrintStyle::setPreview: preview at '" << path << "' cannot be loaded." << endl;
00067       return false;
00068     }
00069   }
00070 }
00071 
00072 PrintingWizard *PrintStyle::wizard()
00073 {
00074   return mWizard;
00075 }
00076 
00077 void PrintStyle::addPage( QWidget *page, const QString &title )
00078 {
00079   if ( mPageList.find( page ) == -1 ) { // not yet in the list
00080     mPageList.append( page );
00081     mPageTitles.append( title );
00082   }
00083 }
00084 
00085 void PrintStyle::showPages()
00086 {
00087   QWidget *wdg = 0;
00088   int i = 0;
00089   for ( wdg = mPageList.first(); wdg; wdg = mPageList.next(), ++i ) {
00090     mWizard->addPage( wdg, mPageTitles[ i ] );
00091     if ( i == 0 )
00092       mWizard->setAppropriate( wdg, true );
00093   }
00094 
00095   if ( wdg )
00096     mWizard->setFinishEnabled( wdg, true );
00097 }
00098 
00099 void PrintStyle::hidePages()
00100 {
00101   for ( QWidget *wdg = mPageList.first(); wdg; wdg = mPageList.next() )
00102     mWizard->removePage( wdg );
00103 }
00104 
00105 void PrintStyle::setPreferredSortOptions( KABC::Field *field, bool ascending )
00106 {
00107   mSortField = field;
00108   mSortType = ascending;
00109 }
00110 
00111 KABC::Field* PrintStyle::preferredSortField()
00112 {
00113   return mSortField;
00114 }
00115 
00116 bool PrintStyle::preferredSortType()
00117 {
00118   return mSortType;
00119 }
00120 
00121 PrintStyleFactory::PrintStyleFactory( PrintingWizard* parent, const char* name )
00122         : mParent( parent ), mName( name )
00123 {
00124 }
00125 
00126 PrintStyleFactory::~PrintStyleFactory()
00127 {
00128 }
00129 
00130 #include "printstyle.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:38:53 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003