00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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 ) {
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"