[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-pim
Subject: [Kde-pim] [PATCH] Sorting in KAddressBook Printing
From: Tobias Koenig <tokoe () kde ! org>
Date: 2002-09-21 19:27:57
[Download RAW message or body]
Hi,
the attached patch cleans up the printing code of kaddressbook and
adds sorting of the selected/all contacts which should be printed.
For 3.1 it's to late, but maybe you are interested in testing it and
bugfixing the code ;)
Ciao,
Tobias
--
In a world without walls and fences who
needs Windows and Gates???
["printing.diff" (text/plain)]
? printing.diff
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/Makefile.am,v
retrieving revision 1.7
diff -u -b -p -r1.7 Makefile.am
--- Makefile.am 2002/09/17 12:55:37 1.7
+++ Makefile.am 2002/09/21 19:17:35
@@ -5,7 +5,7 @@ INCLUDES = $(all_includes) -I$(top_srcdi
libprinter_la_METASOURCES = AUTO
-libprinter_la_SOURCES = printingwizard_base.ui \
+libprinter_la_SOURCES = basicpage.cpp \
printingwizard.cpp \
printstyle.cpp \
printprogress_base.ui printprogress.cpp \
@@ -13,7 +13,7 @@ libprinter_la_SOURCES = printingwizard_b
ds_appearance.ui \
mikesstyle.cpp
-EXTRA_DIST = printingwizard_base.ui \
+EXTRA_DIST = basicpage.h \
printingwizard.cpp printingwizard.h \
printstyle.cpp printstyle.h \
printprogress.cpp printprogress.h \
Index: basicpage.cpp
===================================================================
RCS file: basicpage.cpp
diff -N basicpage.cpp
--- /dev/null Fri Feb 1 11:53:05 2002
+++ basicpage.cpp Sat Sep 21 21:17:36 2002
@@ -0,0 +1,169 @@
+#include <qbuttongroup.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpixmap.h>
+#include <qradiobutton.h>
+
+#include <kcombobox.h>
+#include <kdialog.h>
+#include <klocale.h>
+
+#include "basicpage.h"
+
+BasicPage::BasicPage( KABC::AddressBook *ab, QWidget* parent, const char* name )
+ : QWidget( parent, name ), mAddressBook( ab )
+{
+ initGUI();
+
+ initFieldCombo();
+
+ mSortTypeCombo->insertItem( i18n( "Ascending" ) );
+ mSortTypeCombo->insertItem( i18n( "Descending" ) );
+
+ connect( mStyleCombo, SIGNAL( activated( int ) ), SIGNAL( styleChanged( int ) ) );
+}
+
+BasicPage::~BasicPage()
+{
+}
+
+void BasicPage::setPreview( const QPixmap &pixmap )
+{
+ if ( pixmap.isNull() )
+ mPreview->setText( i18n( "(No preview available.)" ) );
+ else
+ mPreview->setPixmap( pixmap );
+}
+
+void BasicPage::setPrintSelectionEnabled( bool value )
+{
+ mPrintSelection->setEnabled( value );
+}
+
+void BasicPage::addStyleName( const QString &name )
+{
+ mStyleCombo->insertItem( name );
+}
+
+void BasicPage::clearStyleNames()
+{
+ mStyleCombo->clear();
+}
+
+bool BasicPage::printSelection()
+{
+ return mPrintSelection->isChecked();
+}
+
+void BasicPage::setSortField( KABC::Field *field )
+{
+ mFieldCombo->setCurrentText( field->label() );
+}
+
+void BasicPage::setSortAscending( bool value )
+{
+ if ( value )
+ mSortTypeCombo->setCurrentItem( 0 );
+ else
+ mSortTypeCombo->setCurrentItem( 1 );
+}
+
+KABC::Field* BasicPage::sortField()
+{
+ if ( mFieldCombo->currentItem() == -1 )
+ return mFields[ 0 ];
+
+ return mFields[ mFieldCombo->currentItem() ];
+}
+
+bool BasicPage::sortAscending()
+{
+ return ( mSortTypeCombo->currentItem() == 0 );
+}
+
+void BasicPage::initFieldCombo()
+{
+ if ( !mAddressBook )
+ return;
+
+ mFieldCombo->clear();
+
+ mFields = mAddressBook->fields( KABC::Field::All );
+ KABC::Field::List::Iterator it;
+ for ( it = mFields.begin(); it != mFields.end(); ++it )
+ mFieldCombo->insertItem( (*it)->label() );
+}
+
+void BasicPage::initGUI()
+{
+ setCaption( i18n( "General" ) );
+
+ QVBoxLayout *layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
+
+ QHBoxLayout *styleLayout = new QHBoxLayout( layout );
+
+ QLabel *label = new QLabel( i18n( "Print style:" ), this );
+ styleLayout->addWidget( label );
+
+ mStyleCombo = new KComboBox( false, this );
+ styleLayout->addWidget( mStyleCombo, 1 );
+
+ QGridLayout *miscLayout = new QGridLayout( layout, 2, 2 );
+
+
+ QButtonGroup *group = new QButtonGroup( i18n( "Print Which Contacts" ), this );
+ group->setColumnLayout( 0, Qt::Vertical );
+ group->layout()->setMargin( KDialog::marginHint() );
+ group->layout()->setSpacing( KDialog::spacingHint() );
+ QVBoxLayout *groupLayout = new QVBoxLayout( group->layout() );
+ groupLayout->setAlignment( Qt::AlignTop );
+
+ mPrintSelection = new QRadioButton( i18n( "Selection" ), group );
+ groupLayout->addWidget( mPrintSelection );
+
+ mPrintWholeBook = new QRadioButton( i18n( "All entries" ), group );
+ mPrintWholeBook->setChecked( true );
+ groupLayout->addWidget( mPrintWholeBook );
+
+ miscLayout->addWidget( group, 0, 0 );
+
+
+ group = new QButtonGroup( i18n( "Sorting:" ), this );
+ group->setColumnLayout( 0, Qt::Vertical );
+ QGridLayout *sortLayout = new QGridLayout( group->layout(), 2, 2,
+ KDialog::spacingHint() );
+ sortLayout->setColStretch( 1, 1 );
+
+ label = new QLabel( i18n( "Criterion:" ), group );
+ sortLayout->addWidget( label, 0, 0 );
+
+ mFieldCombo = new KComboBox( false, group );
+ sortLayout->addWidget( mFieldCombo, 0, 1 );
+
+ label = new QLabel( i18n( "Order:" ), group );
+ sortLayout->addWidget( label, 1, 0 );
+
+ mSortTypeCombo = new KComboBox( false, group );
+ sortLayout->addWidget( mSortTypeCombo, 1, 1 );
+
+ miscLayout->addWidget( group, 1, 0 );
+
+
+ group = new QButtonGroup( i18n( "Preview:" ), this );
+ group->setColumnLayout( 0, Qt::Vertical );
+ groupLayout = new QVBoxLayout( group->layout() );
+
+ mPreview = new QLabel( group );
+ QFont font( mPreview->font() );
+ font.setPointSize( 20 );
+ mPreview->setFont( font );
+ mPreview->setScaledContents( true );
+ mPreview->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
+ groupLayout->addWidget( mPreview );
+
+ miscLayout->addMultiCellWidget( group, 0, 1, 1, 1 );
+
+ resize( QSize( 600, 480 ).expandedTo( sizeHint() ) );
+}
+
+#include "basicpage.moc"
Index: basicpage.h
===================================================================
RCS file: basicpage.h
diff -N basicpage.h
--- /dev/null Fri Feb 1 11:53:05 2002
+++ basicpage.h Sat Sep 21 21:17:36 2002
@@ -0,0 +1,90 @@
+#ifndef BASICPAGE_H
+#define BASICPAGE_H
+
+#include <qwidget.h>
+
+#include <kabc/addressbook.h>
+#include <kabc/field.h>
+
+class QLabel;
+class QPixmap;
+class QRadioButton;
+class KComboBox;
+
+class BasicPage : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ BasicPage( KABC::AddressBook *ab, QWidget* parent = 0, const char* name = 0 );
+ ~BasicPage();
+
+ /**
+ * Set a preview image. If @ref pixmap is 'null' a text will
+ * be displayed instead.
+ */
+ void setPreview( const QPixmap &pixmap );
+
+ /**
+ * Set whether it's possible to print only the selected contacts.
+ */
+ void setPrintSelectionEnabled( bool value );
+
+ /**
+ * Add a style name.
+ */
+ void addStyleName( const QString &name );
+
+ /**
+ * Clear the style name list.
+ */
+ void clearStyleNames();
+
+ /**
+ * Set the sort criterion field.
+ */
+ void setSortField( KABC::Field *field );
+
+ /**
+ * Set the sort type.
+ */
+ void setSortAscending( bool value = true );
+
+ /**
+ * Returns whether only the selected or all contacts should be printed.
+ */
+ bool printSelection();
+
+ /**
+ * Returns the sort criterion field.
+ */
+ KABC::Field* sortField();
+
+ /**
+ * Returns whether the sort type is ascending.
+ */
+ bool sortAscending();
+
+ signals:
+ /**
+ * This signal is emmited when the user selects a new style in the
+ * style combo box.
+ */
+ void styleChanged( int index );
+
+ private:
+ void initGUI();
+ void initFieldCombo();
+
+ KComboBox *mFieldCombo;
+ KComboBox *mSortTypeCombo;
+ KComboBox *mStyleCombo;
+ QLabel *mPreview;
+ QRadioButton *mPrintSelection;
+ QRadioButton *mPrintWholeBook;
+
+ KABC::AddressBook *mAddressBook;
+ KABC::Field::List mFields;
+};
+
+#endif // BASICPAGE_H
Index: detailledstyle.cpp
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/detailledstyle.cpp,v
retrieving revision 1.11
diff -u -b -p -r1.11 detailledstyle.cpp
--- detailledstyle.cpp 2002/09/20 15:18:00 1.11
+++ detailledstyle.cpp 2002/09/21 19:17:37
@@ -117,7 +117,7 @@ namespace KABPrinting {
mEPntr = 0;
}
- void DetailledPrintStyle::print(QStringList contacts, PrintProgress *progress)
+ void DetailledPrintStyle::print( KABC::Addressee::List &contacts, PrintProgress *progress)
{
mPrintProgress=progress;
progress->addMessage(i18n("Setting up fonts and colors"));
@@ -233,36 +233,35 @@ namespace KABPrinting {
config->sync();
}
- bool DetailledPrintStyle::printEntries(const QStringList& contacts,
+ bool DetailledPrintStyle::printEntries( KABC::Addressee::List &contacts,
KPrinter *printer,
QPainter *painter,
const QRect& window)
{
- KABC::Addressee addressee;
- QStringList::ConstIterator it;
QRect brect;
int ypos=0, count=0;
+
// -----
- for(it=contacts.begin(); it!=contacts.end(); ++it)
+ KABC::Addressee::List::Iterator it;
+ for( it = contacts.begin(); it != contacts.end(); ++it )
{
- addressee=wizard()->document()->findByUid(*it);
- if(!addressee.isEmpty())
+ if( !(*it).isEmpty())
{ // print it:
kdDebug() << "DetailledPrintStyle::printEntries: printing addressee "
- << addressee.realName() << endl;
+ << (*it).realName() << endl;
// ----- do a faked print to get the bounding rect:
- if(!mEPntr->printEntry(addressee, window, painter, ypos, true, &brect))
+ if(!mEPntr->printEntry((*it), window, painter, ypos, true, &brect))
{ // it does not fit on the page beginning at ypos:
printer->newPage();
// WORK_TO_DO: this assumes the entry fits on the whole page
// (dunno how to fix this without being illogical)
ypos=0;
}
- mEPntr->printEntry(addressee, window, painter, ypos, false, &brect);
+ mEPntr->printEntry((*it), window, painter, ypos, false, &brect);
ypos+=brect.height();
} else {
kdDebug() << "DetailledPrintStyle::printEntries: strange, addressee "
- << "with UID " << *it << " not available." << endl;
+ << "with UID " << (*it).uid() << " not available." << endl;
}
// ----- set progress:
mPrintProgress->setProgress((count++*100)/contacts.count());
Index: detailledstyle.h
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/detailledstyle.h,v
retrieving revision 1.7
diff -u -b -p -r1.7 detailledstyle.h
--- detailledstyle.h 2002/09/16 18:49:18 1.7
+++ detailledstyle.h 2002/09/21 19:17:37
@@ -32,9 +32,9 @@ namespace KABPrinting {
public:
DetailledPrintStyle(PrintingWizard* parent, const char* name=0);
~DetailledPrintStyle();
- void print(QStringList contacts, PrintProgress*);
+ void print( KABC::Addressee::List &contacts, PrintProgress* );
protected:
- bool printEntries(const QStringList& contacts,
+ bool printEntries( KABC::Addressee::List &contacts,
KPrinter *printer,
QPainter *painter,
const QRect& window);
Index: mikesstyle.cpp
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/mikesstyle.cpp,v
retrieving revision 1.10
diff -u -b -p -r1.10 mikesstyle.cpp
--- mikesstyle.cpp 2002/09/07 15:15:46 1.10
+++ mikesstyle.cpp 2002/09/21 19:17:38
@@ -46,7 +46,7 @@ namespace KABPrinting
{
}
- void MikesStyle::print(QStringList printUids, PrintProgress *progress)
+ void MikesStyle::print( KABC::Addressee::List &contacts, PrintProgress *progress)
{
QFont mFont;
QFont mBoldFont;
@@ -62,23 +62,19 @@ namespace KABPrinting
QPaintDeviceMetrics metrics(p.device());
int height = 0;
- KABC::Addressee a;
- QStringList::ConstIterator iter;
+ KABC::Addressee::List::Iterator it;
progress->addMessage(i18n("Preparing"));
progress->addMessage(i18n("Printing"));
- for (iter = printUids.begin(); iter != printUids.end(); ++iter)
+ for ( it = contacts.begin(); it != contacts.end(); ++it )
{
- progress->setProgress((count++*100)/printUids.count());
+ progress->setProgress((count++*100)/contacts.count());
kapp->processEvents();
- // find the addressee
- a = wizard()->document()->findByUid(*iter);
-
// Get the total height so we know if it will fit on the
// current page
- height = calcHeight(a, mFont, mBoldFont);
+ height = calcHeight((*it), mFont, mBoldFont);
if ((yPos + spacingHint + height)
> (metrics.height()-fm.height()-5))
{
@@ -96,7 +92,7 @@ namespace KABPrinting
yPos += spacingHint;
p.save();
p.translate(0, yPos);
- doPaint(p, a, height, mFont, mBoldFont);
+ doPaint(p, (*it), height, mFont, mBoldFont);
p.restore();
yPos += height;
// ----- set progress bar:
Index: mikesstyle.h
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/mikesstyle.h,v
retrieving revision 1.3
diff -u -b -p -r1.3 mikesstyle.h
--- mikesstyle.h 2002/06/14 03:20:34 1.3
+++ mikesstyle.h 2002/09/21 19:17:38
@@ -32,7 +32,7 @@ namespace KABPrinting {
public:
MikesStyle(PrintingWizard* parent, const char* name);
~MikesStyle();
- void print(QStringList, PrintProgress*);
+ void print(KABC::Addressee::List&, PrintProgress*);
protected:
void doPaint(QPainter &painter, const KABC::Addressee &a,
int maxHeight,
Index: printingwizard.cpp
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/printingwizard.cpp,v
retrieving revision 1.9
diff -u -b -p -r1.9 printingwizard.cpp
--- printingwizard.cpp 2002/09/15 02:21:39 1.9
+++ printingwizard.cpp 2002/09/21 19:17:38
@@ -14,144 +14,148 @@
$Revision: 1.9 $
*/
-#include <qradiobutton.h>
-#include <qcombobox.h>
-#include <qlayout.h>
-#include <qpixmap.h>
-#include <qlabel.h>
#include <qpushbutton.h>
+#include <kapplication.h>
#include <kdebug.h>
-#include <kprinter.h>
-#include <klocale.h>
-#include <kdialog.h>
#include <kdialogbase.h>
-#include <kapplication.h>
+#include <klocale.h>
+#include <kprinter.h>
+#include <kabc/addresseelist.h>
+#include <kabc/field.h>
+
#include "printingwizard.h"
-#include "printstyle.h"
#include "printprogress.h"
+#include "printstyle.h"
+
+// styles
#include "detailledstyle.h"
#include "mikesstyle.h"
-namespace KABPrinting {
+using namespace KABPrinting;
- PrintingWizardImpl::PrintingWizardImpl(KPrinter *printer,
+PrintingWizardImpl::PrintingWizardImpl( KPrinter *printer,
KABC::AddressBook* doc,
const QStringList& selection,
QWidget *parent,
- const char* name)
- : PrintingWizard(printer, doc, selection, parent, name),
- style(0)
- {
- mBasicPage=new BasicPage(this);
- mBasicPage->rbSelection->setEnabled(!selection.isEmpty());
- connect(mBasicPage->cbStyle, SIGNAL(activated(int)),
- SLOT(slotStyleSelected(int)));
- insertPage(mBasicPage, i18n("General"), -1);
- setAppropriate(mBasicPage, true);
+ const char* name )
+ : PrintingWizard( printer, doc, selection, parent, name ), mStyle( 0 )
+{
+ mBasicPage = new BasicPage( doc, this );
+ mBasicPage->setPrintSelectionEnabled( !selection.isEmpty() );
+
+ connect( mBasicPage, SIGNAL( styleChanged( int ) ),
+ SLOT( slotStyleSelected( int ) ) );
+
+ insertPage( mBasicPage, i18n("General"), -1 );
+ setAppropriate( mBasicPage, true );
+
registerStyles();
- if(mBasicPage->cbStyle->count()>0)
- {
- slotStyleSelected(0);
- }
- }
- PrintingWizardImpl::~PrintingWizardImpl()
- {
- }
+ if ( mStyleFactories.count() > 0 )
+ slotStyleSelected( 0 );
+}
+
+PrintingWizardImpl::~PrintingWizardImpl()
+{
+}
- void PrintingWizardImpl::accept()
- {
+void PrintingWizardImpl::accept()
+{
print();
close();
- }
-
- void PrintingWizardImpl::registerStyles()
- {
- styleFactories.append(new DetailledPrintStyleFactory(this));
- styleFactories.append(new MikesStyleFactory(this));
-
- mBasicPage->cbStyle->clear();
- for(unsigned int i=0; i<styleFactories.count(); ++i)
- {
- mBasicPage->cbStyle->insertItem(styleFactories.at(i)->description());
- }
- }
+}
- void PrintingWizardImpl::slotStyleSelected( int index )
- {
- if ( index < 0 || (unsigned)index >= styleFactories.count() )
+void PrintingWizardImpl::registerStyles()
+{
+ mStyleFactories.append( new DetailledPrintStyleFactory( this ) );
+ mStyleFactories.append( new MikesStyleFactory( this ) );
+
+ mBasicPage->clearStyleNames();
+ for ( uint i = 0; i < mStyleFactories.count(); ++i )
+ mBasicPage->addStyleName( mStyleFactories.at( i )->description() );
+}
+
+void PrintingWizardImpl::slotStyleSelected( int index )
+{
+ if ( index < 0 || (uint)index >= mStyleFactories.count() )
return;
setFinishEnabled( mBasicPage, false );
- if ( style )
- style->hidePages();
+ if ( mStyle )
+ mStyle->hidePages();
if ( mStyleList.at( index ) != 0 )
- style = mStyleList.at( index );
+ mStyle = mStyleList.at( index );
else {
- PrintStyleFactory *factory = styleFactories.at( index );
+ PrintStyleFactory *factory = mStyleFactories.at( index );
kdDebug() << "PrintingWizardImpl::slotStyleSelected: "
<< "creating print style "
<< factory->description() << endl;
- style = factory->create();
- mStyleList.insert( index, style );
+ mStyle = factory->create();
+ mStyleList.insert( index, mStyle );
}
- style->showPages();
+ mStyle->showPages();
- const QPixmap& preview = style->preview();
- mBasicPage->plPreview->setPixmap( preview );
- if ( preview.isNull() )
- mBasicPage->plPreview->setText( i18n( "(No preview available.)" ) );
+ mBasicPage->setPreview( mStyle->preview() );
setFinishEnabled( page( pageCount() - 1 ), true );
+
+ if ( mStyle->preferredSortField() != 0 ) {
+ mBasicPage->setSortField( mStyle->preferredSortField() );
+ mBasicPage->setSortAscending( mStyle->preferredSortType() );
}
+}
- KABC::AddressBook* PrintingWizardImpl::document()
- {
+KABC::AddressBook* PrintingWizardImpl::document()
+{
return mDocument;
- }
+}
- KPrinter* PrintingWizardImpl::printer()
- {
+KPrinter* PrintingWizardImpl::printer()
+{
return mPrinter;
- }
+}
- void PrintingWizardImpl::print()
- {
+void PrintingWizardImpl::print()
+{
// ----- create and show print progress widget:
- PrintProgress *progress=new PrintProgress(this);
- insertPage(progress, i18n("Print Progress"), -1);
- showPage(progress);
+ PrintProgress *progress = new PrintProgress( this );
+ insertPage( progress, i18n("Print Progress"), -1 );
+ showPage( progress );
kapp->processEvents();
+
// ----- prepare list of contacts to print:
- QStringList contacts;
- if(style!=0)
- {
- if(mBasicPage->rbSelection->isChecked())
- {
- contacts=mSelection;
- } else {
- // create a string list of all entries:
- KABC::AddressBook::Iterator iter;
- for(iter=document()->begin(); iter!=document()->end(); ++iter)
- {
- contacts << (*iter).uid();
- }
+ KABC::AddresseeList list;
+
+ if ( mStyle != 0 ) {
+ if ( mBasicPage->printSelection() ) {
+ QStringList::Iterator it;
+ for ( it = mSelection.begin(); it != mSelection.end(); ++it ) {
+ KABC::Addressee addr = document()->findByUid( *it );
+ if ( !addr.isEmpty() )
+ list.append( addr );
+ }
+ } else { // create a string list of all entries:
+ KABC::AddressBook::Iterator it;
+ for ( it = document()->begin(); it != document()->end(); ++it )
+ list.append( *it );
}
+
+ list.setReverseSorting( !mBasicPage->sortAscending() );
+ list.sortByField( mBasicPage->sortField() );
}
+
kdDebug() << "PrintingWizardImpl::print: printing "
- << contacts.count() << " contacts." << endl;
- // ... print:
- setBackEnabled(progress, false);
- cancelButton()->setEnabled(false);
- style->print(contacts, progress);
- // ----- done - all GUI elements will disappear
- }
+ << list.count() << " contacts." << endl;
+ // ... print:
+ setBackEnabled( progress, false );
+ cancelButton()->setEnabled( false );
+ mStyle->print( list, progress );
}
#include "printingwizard.moc"
Index: printingwizard.h
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/printingwizard.h,v
retrieving revision 1.5
diff -u -b -p -r1.5 printingwizard.h
--- printingwizard.h 2002/09/07 15:15:46 1.5
+++ printingwizard.h 2002/09/21 19:17:38
@@ -24,60 +24,75 @@
#include "../kaddressbookprinter.h"
#include "kabc/addressbook.h"
#include "printstyle.h"
+#include "basicpage.h"
-// ----- the general page:
-#include "printingwizard_base.h"
-
class KPrinter;
-class QVBoxLayout;
namespace KABPrinting {
- /** The PrintingWizard combines pages common for all print styles
+/**
+ The PrintingWizard combines pages common for all print styles
and those provided by the respective style.
- */
- class PrintingWizardImpl : public PrintingWizard
- {
+*/
+
+class PrintingWizardImpl : public PrintingWizard
+{
Q_OBJECT
+
public:
- /** Construct a printing wizard. Give the document
- (addressbook instance) to print.
+ /**
+ Construct a printing wizard. Give the document (addressbook instance)
+ to print.
*/
- PrintingWizardImpl(KPrinter *printer,
- KABC::AddressBook* doc,
- const QStringList& selection,
- QWidget *parent=0, const char *name=0);
+ PrintingWizardImpl( KPrinter *printer, KABC::AddressBook* doc,
+ const QStringList& selection, QWidget *parent = 0,
+ const char *name = 0 );
+
~PrintingWizardImpl();
- /** Modify this method to add a new PrintStyle.
+
+ /**
+ Modify this method to add a new PrintStyle.
*/
void registerStyles();
- /** Perform the actual printing. */
+
+ /**
+ Perform the actual printing.
+ */
void print();
- /** Retrieve the document object. */
+
+ /**
+ Retrieve the document object.
+ */
KABC::AddressBook *document();
- /** Retrieve the printer to be used. */
+
+ /**
+ Retrieve the printer to be used.
+ */
KPrinter* printer();
+
protected slots:
- /** A print style has been selected. The argument is the index
- in the cbStyle combo and in styles.
+ /**
+ A print style has been selected. The argument is the index
+ in the in styles factory list.
*/
void slotStyleSelected(int);
+
protected:
- QPtrList<PrintStyleFactory> styleFactories;
- QPtrList<PrintStyle> mStyleList;
- PrintStyle *style;
- /** The general page. */
- BasicPage *mBasicPage;
- QVBoxLayout* pageLayout;
- /** Overloaded accept slot. This is used to do the actual
- printing without having the wizard disappearing
- before. What happens is actually up to the print style,
- since it does the printing. It could display a progress
- window, for example (hint, hint).
+ /**
+ Overloaded accept slot. This is used to do the actual printing
+ without having the wizard disappearing before.
+ What happens is actually up to the print style, since it does the
+ printing. It could display a progress window, for example (hint, hint).
*/
void accept();
- };
-}
+ private:
+ QPtrList<PrintStyleFactory> mStyleFactories;
+ QPtrList<PrintStyle> mStyleList;
+ PrintStyle *mStyle;
+ BasicPage *mBasicPage;
+};
+
+}
#endif
Index: printstyle.cpp
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/printstyle.cpp,v
retrieving revision 1.5
diff -u -b -p -r1.5 printstyle.cpp
--- printstyle.cpp 2002/09/07 15:15:46 1.5
+++ printstyle.cpp 2002/09/21 19:17:38
@@ -26,7 +26,7 @@ using namespace KABPrinting;
PrintStyle::PrintStyle( PrintingWizard* parent, const char* name )
- : QObject( parent, name ), mWizard( parent )
+ : QObject( parent, name ), mWizard( parent ), mSortField( 0 )
{
}
@@ -93,6 +93,22 @@ void PrintStyle::hidePages()
{
for ( QWidget *wdg = mPageList.first(); wdg; wdg = mPageList.next() )
mWizard->removePage( wdg );
+}
+
+void PrintStyle::setPreferredSortOptions( KABC::Field *field, bool ascending )
+{
+ mSortField = field;
+ mSortType = ascending;
+}
+
+KABC::Field* PrintStyle::preferredSortField()
+{
+ return mSortField;
+}
+
+bool PrintStyle::preferredSortType()
+{
+ return mSortType;
}
PrintStyleFactory::PrintStyleFactory( PrintingWizard* parent, const char* name )
Index: printstyle.h
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/printstyle.h,v
retrieving revision 1.6
diff -u -b -p -r1.6 printstyle.h
--- printstyle.h 2002/09/07 15:15:46 1.6
+++ printstyle.h 2002/09/21 19:17:38
@@ -21,6 +21,8 @@
#include <qstringlist.h>
#include <qpixmap.h>
+#include <kabc/field.h>
+
namespace KABPrinting {
class PrintingWizard;
@@ -59,7 +61,7 @@ class PrintStyle : public QObject
/**
Reimplement this method to actually print.
*/
- virtual void print(QStringList contacts, PrintProgress*)=0;
+ virtual void print( KABC::Addressee::List &contacts, PrintProgress* ) = 0;
/**
Reimplement this method to provide a preview of what will
@@ -78,17 +80,25 @@ class PrintStyle : public QObject
*/
void showPages();
+ /**
+ Returns the preferred sort criterion field.
+ */
+ KABC::Field* preferredSortField();
+
+ /**
+ Returns the preferred sort type.
+
+ true = ascending
+ false = descending
+ */
+ bool preferredSortType();
+
protected:
/**
Load the preview image from the kaddressbook data
directory. The image should be located in the subdirectory
"printing". Give only the file name without any prefix as
the parameter.
- In case the image cannot be loaded, the preview will show
- a text message that there is no preview available. Do not
- change the preview frame manually if you do not have
- to. The return value is true if loading and setting the
- preview image worked out good.
*/
bool setPreview( const QString& fileName );
@@ -97,7 +107,13 @@ class PrintStyle : public QObject
*/
void setPreview( const QPixmap& image );
+
/**
+ Set preferred sort options for this printing style.
+ */
+ void setPreferredSortOptions( KABC::Field *field, bool ascending = true );
+
+ /**
Return the wizard object.
*/
PrintingWizard *wizard();
@@ -113,6 +129,9 @@ class PrintStyle : public QObject
QPixmap mPreview;
QPtrList<QWidget> mPageList;
QStringList mPageTitles;
+
+ KABC::Field *mSortField;
+ bool mSortType;
};
@@ -127,6 +146,7 @@ class PrintStyleFactory
public:
PrintStyleFactory( PrintingWizard* parent, const char* name = 0 );
virtual ~PrintStyleFactory();
+
virtual PrintStyle *create() = 0;
/**
_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic