Documents > BPS V2 C++ API
BpsPrinterSettings Class Reference

The BpsPrinterSettings class allows to save and restore printer settings. More...

#include <bpsprintersettings.h>

List of all members.

Public Member Functions

 BpsPrinterSettings (QPrinter *aPrinter, BpsSettings *aSettings=0, QObject *aParent=0)
QMap< QString, QString > config () const
bool restore ()
 Restore the settings from human readable keys/values.
bool restore (const QString &aKey)
 Restore the settings from an encoded value.
void save ()
 Save the settings as human readable keys/values.
void save (const QString &aKey)
 Save the settings encoded in one single value.
bool setConfig (const QMap< QString, QString > &aConfig)
 Load the settings from a config map instead from the settings.

Static Public Member Functions

static QMap
< QPrinter::ColorMode, QString > 
colorModes ()
static QMap
< QPrinter::DuplexMode,
QString > 
duplexModes ()
static QMap
< QPrinter::Orientation,
QString > 
orientations ()
static QMap
< QPrinter::PageOrder, QString > 
pageOrders ()
static QMap
< QPrinter::PaperSize, QString > 
paperNames ()
 A map with the paper names.
static QMap
< QPrinter::PaperSize, QSizeF > 
paperSizes ()
 A map with paper size informations.
static QMap
< QPrinter::PaperSource,
QString > 
paperSources ()

Detailed Description

The BpsPrinterSettings class allows to save and restore printer settings.

This is useful when you do not want to show a print dialog every time, but reuse the last setting. The status can be saved and restored in 2 different ways: Either binary where all settings are encoded into one single value, or human readable where every setting is in a distinct value.

 QPrinter p;
 BpsSettings s;
 s.open("Settings/Printers/MyPrinter");
 BpsPrinterSettings ps(&p, &s);
 bool ok = ps.load(); 
 if (!ok) {
     // no settings yet saved, show dialog as fallback
     ok = QPrintDialog(&p, this).exec() == QDialog::Accepted;

     // save the new settings
     if (ok) ps.save();
 } // if
 if (ok) {
     // do the printing
     ....
 } // if

Constructor & Destructor Documentation

BpsPrinterSettings::BpsPrinterSettings ( QPrinter *  aPrinter,
BpsSettings aSettings = 0,
QObject *  aParent = 0 
)
Parameters:
[in]aPrinterThe printer object to save/load settings for.
[in]aSettingsThe settings object, opened to the desire path. If aSettings is = 0, the save and restore methods will do nothing.
[in]aParentThe parent object.

Member Function Documentation

static QMap<QPrinter::ColorMode, QString> BpsPrinterSettings::colorModes ( ) [static]
Returns:
A map of all Qt printer color modes to strings.
QMap<QString,QString> BpsPrinterSettings::config ( ) const
Returns:
The config map of the current settings.
static QMap<QPrinter::DuplexMode, QString> BpsPrinterSettings::duplexModes ( ) [static]
Returns:
A map of all Qt printer duplex modes to strings.
static QMap<QPrinter::Orientation, QString> BpsPrinterSettings::orientations ( ) [static]
Returns:
A map of all Qt printer orientations to strings.
static QMap<QPrinter::PageOrder, QString> BpsPrinterSettings::pageOrders ( ) [static]
Returns:
A map of all Qt printer page orders to strings.
static QMap<QPrinter::PaperSize, QString> BpsPrinterSettings::paperNames ( ) [static]

A map with the paper names.

Returns:
A map of all Qt printer paper names.
static QMap<QPrinter::PaperSize, QSizeF> BpsPrinterSettings::paperSizes ( ) [static]

A map with paper size informations.

The paper size in in millimeters, and for portrait orientation. Swap width and height for landscape orientation.

Returns:
A map of all Qt printer paper sizes.
static QMap<QPrinter::PaperSource, QString> BpsPrinterSettings::paperSources ( ) [static]
Returns:
A map of all Qt printer paper sources to strings.
bool BpsPrinterSettings::restore ( )

Restore the settings from human readable keys/values.

Returns:
True is settings are valid for a local printer and got loaded. Otherwise aPrinter settings are unchanged.
bool BpsPrinterSettings::restore ( const QString &  aKey)

Restore the settings from an encoded value.

Parameters:
[in]aKeyThe key to restore the settings from.
Returns:
True is settings are valid for a local printer and got loaded. Otherwise aPrinter settings are unchanged.
void BpsPrinterSettings::save ( const QString &  aKey)

Save the settings encoded in one single value.

Parameters:
[in]aKeyThe key to save the settings.
bool BpsPrinterSettings::setConfig ( const QMap< QString, QString > &  aConfig)

Load the settings from a config map instead from the settings.

Parameters:
[in]aConfigThe config map to use.
Returns:
True is settings are valid for a local printer and got loaded. Otherwise aPrinter settings are unchanged.

The documentation for this class was generated from the following file: