• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDEPrint

KPrintDialogPage Class Reference

#include <kprintdialogpage.h>

Inheritance diagram for KPrintDialogPage:

Inheritance graph
[legend]

List of all members.


Detailed Description

This class is intended to be used as base class for customized print dialog page.

One of the feature of the KDE print framework is to allow to customize the print dialog to add some application specific print options. This is done by subclassing KPrintDialogPage and reimplementing the 3 virtual functions getOptions, setOptions and isValid(). The print options will be stored in the KPrinter object, and will be accessible via KPrinter::option(). The option name should follow the form "kde-appname-optionname" for internal reasons.

 #include <kdeprint/kprintdialogpage.h>

 class MyDialogPage : public KPrintDialogPage
 {
 public:
   MyDialogPage( QWidget *parent = 0, const char *name = 0 );

   //reimplement virtual functions
   void getOptions( QMap<QString,QString>& opts, bool incldef = false );
   void setOptions( const QMap<QString,QString>& opts );
   bool isValid( QString& msg );

 private:
   QComboBox *m_fontcombo;
 }

 MyDialogPage::MyDialogPage( QWidget *parent, const char *name )
 : KPrintDialogPage( parent, name )
 {
   setTitle( i18n( "My Page" ) );
 }

 void MyDialogPage::getOptions( QMap<QString,QString>& opts, bool incldef )
 {
   if ( incldef || m_fontcombo->currentText() != mydefaultvalue )
     opts[ "kde-myapp-fontname" ] = m_fontcombo->currentText();
 }

 void MyDialogPage::setOptions( const QMap<QString,QString>& opts )
 {
   QString fntname = opts[ "kde-myapp-fontname" ];
   m_fontcombo->setEditText( fntname );
 }

 bool MyDialogPage::isValid( QString& msg)
 {
   if ( m_fontcombo->currentText().isEmpty() )
   {
     msg = i18n( "Font name cannot be empty." );
     return false;
   }
   return true;
 }

Base class for customized print dialog pages.

See also:
KPrinter

Definition at line 91 of file kprintdialogpage.h.


Public Member Functions

DrMain * driver ()
virtual void getOptions (QMap< QString, QString > &opts, bool incldef=false)
int id () const
virtual bool isValid (QString &msg)
 KPrintDialogPage (KMPrinter *pr, DrMain *dr=0, QWidget *parent=0)
 KPrintDialogPage (QWidget *parent=0)
bool onlyRealPrinters () const
KMPrinter * printer ()
void setId (int ID)
void setOnlyRealPrinters (bool on=true)
virtual void setOptions (const QMap< QString, QString > &opts)
void setTitle (const QString &txt)
QString title () const
virtual ~KPrintDialogPage ()

Protected Attributes

DrMain * m_driver
int m_ID
bool m_onlyreal
KMPrinter * m_printer
QString m_title

Constructor & Destructor Documentation

KPrintDialogPage::KPrintDialogPage ( QWidget *  parent = 0  ) 

Standard constructor.

Definition at line 23 of file kprintdialogpage.cpp.

KPrintDialogPage::KPrintDialogPage ( KMPrinter *  pr,
DrMain *  dr = 0,
QWidget *  parent = 0 
) [explicit]

Modified constructor.

For internal use only.

Definition at line 29 of file kprintdialogpage.cpp.

KPrintDialogPage::~KPrintDialogPage (  )  [virtual]

Destructor.

Definition at line 35 of file kprintdialogpage.cpp.


Member Function Documentation

DrMain * KPrintDialogPage::driver (  ) 

For internal use only.

Definition at line 82 of file kprintdialogpage.cpp.

void KPrintDialogPage::getOptions ( QMap< QString, QString > &  opts,
bool  incldef = false 
) [virtual]

This function is called to fill the structure opts with the selected options from this dialog page.

If incldef is true, include also options with default values, otherwise discard them. Reimplement this function in subclasses.

Parameters:
opts the option set to fill
incldef if true, include also options with default values
See also:
setOptions()

Reimplemented in KPHpgl2Page, KPImagePage, KPSchedulePage, KPTagsPage, KPTextPage, KPCopiesPage, KPDriverPage, KPFileSelectPage, KPFilterPage, KPGeneralPage, KPMarginPage, KPPosterPage, and KPQtPage.

Definition at line 43 of file kprintdialogpage.cpp.

int KPrintDialogPage::id (  )  const

Get the ID of the page.

Not used yet.

Returns:
the page ID
See also:
setId()

Definition at line 52 of file kprintdialogpage.cpp.

bool KPrintDialogPage::isValid ( QString &  msg  )  [virtual]

Returns true if options selected in the page are valid (no conflict), false otherwise.

When returning false, msg should contain an error message explaining what is wrong in the selected options.

Parameters:
msg should contain an error message when returning false
Returns:
valid status

Reimplemented in KPSchedulePage, KPTagsPage, KPDriverPage, and KPFilterPage.

Definition at line 47 of file kprintdialogpage.cpp.

bool KPrintDialogPage::onlyRealPrinters (  )  const

Tell wether or not the page should be disable if a non real printer (special printer) is selected in the print dialog.

Returns false by default. Application specific pages usually corresponds to printer-independent options, so the page should be kept enabled whatever the selected printer. The default value is then correct and your application doesn't to change anything.

Returns:
true if the page should be disabled for non real printers
See also:
setOnlyRealPrinters()

Definition at line 72 of file kprintdialogpage.cpp.

KMPrinter * KPrintDialogPage::printer (  ) 

For internal use only.

Definition at line 87 of file kprintdialogpage.cpp.

void KPrintDialogPage::setId ( int  ID  ) 

Set the ID of the page.

Not used yet.

Parameters:
ID the ID number
See also:
id()

Definition at line 57 of file kprintdialogpage.cpp.

void KPrintDialogPage::setOnlyRealPrinters ( bool  on = true  ) 

Change the page state when a non real printer is selected in the print dialog.

Usually, the default value (false) is OK in most cases and you don't need to call this function explicitly.

Parameters:
on if true, then the page will be disabled if a non real printer is selected
See also:
onlyRealPrinters()

Definition at line 77 of file kprintdialogpage.cpp.

void KPrintDialogPage::setOptions ( const QMap< QString, QString > &  opts  )  [virtual]

This function is called to update the current page with the options contained in opts.

Reimplement it in subclasses.

Parameters:
opts the structure containing the options to update the page

Reimplemented in KPHpgl2Page, KPImagePage, KPSchedulePage, KPTagsPage, KPTextPage, KPCopiesPage, KPDriverPage, KPFileSelectPage, KPFilterPage, KPGeneralPage, KPMarginPage, KPPosterPage, and KPQtPage.

Definition at line 39 of file kprintdialogpage.cpp.

void KPrintDialogPage::setTitle ( const QString &  txt  ) 

Set the page title.

This title will be used as tab name for this page in the print dialog.

Parameters:
txt the page title
See also:
title()

Definition at line 67 of file kprintdialogpage.cpp.

QString KPrintDialogPage::title (  )  const

Get the page title.

Returns:
the page title
See also:
setTitle()

Definition at line 62 of file kprintdialogpage.cpp.


Member Data Documentation

DrMain* KPrintDialogPage::m_driver [protected]

Definition at line 185 of file kprintdialogpage.h.

int KPrintDialogPage::m_ID [protected]

Definition at line 186 of file kprintdialogpage.h.

bool KPrintDialogPage::m_onlyreal [protected]

Definition at line 188 of file kprintdialogpage.h.

KMPrinter* KPrintDialogPage::m_printer [protected]

Reimplemented in KPCopiesPage.

Definition at line 184 of file kprintdialogpage.h.

QString KPrintDialogPage::m_title [protected]

Definition at line 187 of file kprintdialogpage.h.


The documentation for this class was generated from the following files:
  • kprintdialogpage.h
  • kprintdialogpage.cpp

KDEPrint

Skip menu "KDEPrint"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  •   KDEPrint
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal