class KPrintDialogPage

Base class for customized print dialog pages. More...

Definition#include <kprintdialogpage.h>
InheritsQWidget (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected 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 

 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;
 }

See also: KPrinter

 KPrintDialogPage (QWidget *parent = 0, const char *name = 0)

KPrintDialogPage

Standard constructor.

 KPrintDialogPage (KMPrinter *pr, DrMain *dr = 0, QWidget *parent = 0, const char *name = 0)

KPrintDialogPage

Modified constructor. For internal use only.

 ~KPrintDialogPage ()

~KPrintDialogPage

[virtual]

Destructor

void  getOptions (QMap<QString,QString>& opts, bool incldef = false)

getOptions

[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:
optsthe option set to fill
incldefif true, include also options with default values

See also: setOptions()

void  setOptions (const QMap<QString,QString>& opts)

setOptions

[virtual]

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

Parameters:
optsthe structure containing the options to update the page

bool  isValid (QString&)

isValid

[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:
msgshould contain an error message when returning false

Returns: valid status

int  id ()

id

[const]

Get the ID of the page. Not used yet.

Returns: the page ID

See also: setId()

void  setId (int ID)

setId

Set the ID of the page. Not used yet.

Parameters:
IDthe ID number

See also: id()

QString  title ()

title

[const]

Get the page title.

Returns: the page title

See also: setTitle()

void  setTitle (const QString& txt)

setTitle

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

Parameters:
txtthe page title

See also: title()

bool  onlyRealPrinters ()

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()

void  setOnlyRealPrinters (bool on = true)

setOnlyRealPrinters

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 explicitely.

Parameters:
onif true, then the page will be disabled if a non real printer is selected

See also: onlyRealPrinters()

DrMain*  driver ()

driver

For internal use only.

KMPrinter*  printer ()

printer

For internal use only

KMPrinter * m_printer

m_printer

[protected]

DrMain * m_driver

m_driver

[protected]

int m_ID

m_ID

[protected]

QString m_title

m_title

[protected]

bool m_onlyreal

m_onlyreal

[protected]


Generated by: caleb on tcdevel on Tue Jan 28 12:54:25 2003, using kdoc $.