25 #include <tqcombobox.h>
29 #include <tqlistview.h>
31 #include <tqpushbutton.h>
32 #include <tqradiobutton.h>
34 #include <tdeabc/addresseelist.h>
35 #include <tdeapplication.h>
38 #include <kdialogbase.h>
39 #include <tdelocale.h>
43 #include "detailledstyle.h"
44 #include "mikesstyle.h"
47 #include "printprogress.h"
48 #include "printstyle.h"
49 #include "printsortmode.h"
51 #include "printingwizard.h"
53 using namespace KABPrinting;
56 const TQStringList& selection, TQWidget *parent,
58 : KWizard( parent, name ), mPrinter( printer ), mAddressBook( ab ),
59 mSelection( selection ), mStyle( 0 )
61 mSelectionPage =
new SelectionPage(
this );
62 mSelectionPage->setUseSelection( !selection.isEmpty() );
63 insertPage( mSelectionPage, i18n(
"Choose Contacts to Print"), -1 );
67 for ( Filter::List::ConstIterator it = mFilters.begin(); it != mFilters.end(); ++it )
68 filters.append( (*it).name() );
70 mSelectionPage->setFilters( filters );
72 mSelectionPage->setCategories( KABPrefs::instance()->customCategories() );
74 setAppropriate( mSelectionPage,
true );
77 mStylePage =
new StylePage( mAddressBook,
this );
78 connect( mStylePage, TQ_SIGNAL( styleChanged(
int) ), TQ_SLOT(
slotStyleSelected(
int) ) );
79 insertPage( mStylePage, i18n(
"Choose Printing Style"), -1 );
83 if ( mStyleFactories.count() > 0 )
87 PrintingWizard::~PrintingWizard()
99 mStyleFactories.append(
new DetailledPrintStyleFactory(
this ) );
100 mStyleFactories.append(
new MikesStyleFactory(
this ) );
102 mStylePage->clearStyleNames();
103 for ( uint i = 0; i < mStyleFactories.count(); ++i )
104 mStylePage->addStyleName( mStyleFactories.at( i )->description() );
109 if ( index < 0 || (uint)index >= mStyleFactories.count() )
112 setFinishEnabled( mStylePage,
false );
117 if ( mStyleList.at( index ) != 0 )
118 mStyle = mStyleList.at( index );
121 kdDebug(5720) <<
"PrintingWizardImpl::slotStyleSelected: "
122 <<
"creating print style "
124 mStyle = factory->create();
125 mStyleList.insert( index, mStyle );
130 mStylePage->setPreview( mStyle->
preview() );
132 setFinishEnabled( page( pageCount() - 1 ),
true );
154 insertPage( progress, i18n(
"Print Progress" ), -1 );
155 showPage( progress );
156 kapp->processEvents();
160 TDEABC::AddresseeList list;
162 if ( mSelectionPage->useSelection() ) {
163 TQStringList::ConstIterator it;
164 for ( it = mSelection.begin(); it != mSelection.end(); ++it ) {
165 TDEABC::Addressee addr =
addressBook()->findByUid( *it );
166 if ( !addr.isEmpty() )
169 }
else if ( mSelectionPage->useFilters() ) {
171 Filter::List::ConstIterator filterIt;
172 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
173 if ( (*filterIt).name() == mSelectionPage->filter() )
176 TDEABC::AddressBook::ConstIterator it;
178 if ( (*filterIt).filterAddressee( *it ) )
182 }
else if ( mSelectionPage->useCategories() ) {
183 TQStringList categories = mSelectionPage->categories();
184 TDEABC::AddressBook::ConstIterator it;
186 const TQStringList tmp( (*it).categories() );
187 TQStringList::ConstIterator tmpIt;
188 for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt )
189 if ( categories.contains( *tmpIt ) ) {
196 TDEABC::AddressBook::ConstIterator it;
201 list.setReverseSorting( !mStylePage->sortAscending() );
203 #if KDE_IS_VERSION(3,3,91)
204 PrintSortMode sortMode( mStylePage->sortField() );
205 list.sortByMode( &sortMode );
207 list.sortByField( mStylePage->sortField() );
211 kdDebug(5720) <<
"PrintingWizardImpl::print: printing "
212 << list.count() <<
" contacts." << endl;
215 setBackEnabled( progress,
false );
216 cancelButton()->setEnabled(
false );
217 mStyle->
print( list, progress );
220 #include "printingwizard.moc"
void restore(TDEConfig *config)
Loads the filter from the config file.
This defines a simple widget to display print progress information.
The factories are used to have all object of the respective print style created in one place.
virtual TQString description() const =0
Overload this method to provide a one-liner description for your print style.
bool preferredSortType()
Returns the preferred sort type.
TDEABC::Field * preferredSortField()
Returns the preferred sort criterion field.
const TQPixmap & preview()
Reimplement this method to provide a preview of what will be printed.
void showPages()
Show all style specific pages in the wizard.
void hidePages()
Hide all style specific pages in the wizard.
virtual void print(const TDEABC::Addressee::List &contacts, PrintProgress *)=0
Reimplement this method to actually print.
TDEABC::AddressBook * addressBook()
Retrieve the document object.
void print()
Perform the actual printing.
void accept()
Overloaded accept slot.
void registerStyles()
Modify this method to add a new PrintStyle.
KPrinter * printer()
Retrieve the printer to be used.
PrintingWizard(KPrinter *printer, TDEABC::AddressBook *ab, const TQStringList &selection, TQWidget *parent=0, const char *name=0)
Construct a printing wizard.
void slotStyleSelected(int)
A print style has been selected.