Back to index

texmacs  1.0.7.15
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Slots | Protected Member Functions | Protected Attributes
QTMPrinterSettings Class Reference

This class holds the printing options that we are able to manage or heed, as well as list of available ones relevant to those. More...

#include <QTMPrinterSettings.hpp>

List of all members.

Public Types

enum  PagePrintingOrder {
  LR_TB, RL_TB, TB_LR, TB_RL,
  LR_BT, RL_BT, BT_LR, BT_RL
}
 Left-Right_Top-Bottom, Right-Left_Top-Bottom, etc. More...
enum  PageOrientation { Portrait = 3, Landscape = 4, ReversePortrait = 5, ReverseLandscape = 6 }
 Arguments to the "-o orientation-requested=" CUPS option. More...
enum  DriverChoices {
  PageSize, Resolution, Duplex, ColorModel,
  Collate
}
 The different settings, for which we can read available choices from the driver. More...
enum  ColorMode { Monochrome, Gray8Bit, Color }
 TODO: Use this. More...

Public Slots

void startReadingSystemConfig (const QString &pname)

Signals

void doneReading ()

Public Member Functions

 QTMPrinterSettings ()
void getFromQPrinter (const QPrinter &)
 Reads the configuration parameters from a QPrinter object.
void setToQPrinter (QPrinter &) const
 Sets the configuration parameters to a QPrinter object.
QStringList getChoices (DriverChoices _which, int &_default)
 Returns a QStringList with all the available choices reported by the printer driver for the setting specified.
virtual QString toSystemCommand () const =0
 Implemented by one of CupsQTMPrinterSettings, WinQTMPrinterSettings.
virtual QList< QPair< QString,
QString > > 
availablePrinters ()=0
 Implemented by one of CupsQTMPrinterSettings, WinQTMPrinterSettings Must return a list of pairs of strings.

Static Public Member Functions

static QString qtPaperSizeToQString (const QPrinter::PaperSize)
 Just for internal use, converts QPrinter::PaperSize to a string representation.
static QPrinter::PaperSize qStringToQtPaperSize (const QString &)
 Just for internal use, converts a string to QPrinter::PaperSize.

Public Attributes

bool collateCopies
bool blackWhite
QString printerName
 Force black & white printing even on color printers.
QString fileName
QString paperSize
QString printProgram
int dpi
int firstPage
int lastPage
 If firstPage == lastPage == 0, print everything.
bool printOddPages
bool printEvenPages
bool fitToPage
int copyCount
bool duplex
int pagesPerSide
 Print on both sides of the paper.
PagePrintingOrder pagesOrder
 Can be one of 1,2,4,6,9,16.
PageOrientation orientation

Protected Slots

virtual void systemCommandFinished (int exitCode, QProcess::ExitStatus exitStatus)=0

Protected Member Functions

virtual bool fromSystemConfig (const QString &printer)=0
 Implemented by one of CupsQTMPrinterSettings, WinQTMPrinterSettings.

Protected Attributes

QProcess * configProgram
QHash< QString, QString > printerOptions

Detailed Description

This class holds the printing options that we are able to manage or heed, as well as list of available ones relevant to those.

For instance, it can query the printing system as to the available paper sizes for a given printer.

This class provides one signal, doneReading(), which will be emmitted after the system command used to read the configuration variables finishes. Why bother? Because lpoptions uses cupsGetDests() from the CUPS API, which in turn opens a connection to the server (using cupsGetDests2(), see cups/dest.c in CUPS source code, v1.4.5). If it takes too long to reply, we are going to freeze the interface.

Definition at line 48 of file QTMPrinterSettings.hpp.


Member Enumeration Documentation

TODO: Use this.

Enumerator:
Monochrome 
Gray8Bit 
Color 

Definition at line 65 of file QTMPrinterSettings.hpp.

The different settings, for which we can read available choices from the driver.

See getChoices().

Enumerator:
PageSize 
Resolution 
Duplex 
ColorModel 
Collate 

Definition at line 62 of file QTMPrinterSettings.hpp.

Arguments to the "-o orientation-requested=" CUPS option.

Enumerator:
Portrait 
Landscape 
ReversePortrait 
ReverseLandscape 

Definition at line 57 of file QTMPrinterSettings.hpp.

Left-Right_Top-Bottom, Right-Left_Top-Bottom, etc.

Enumerator:
LR_TB 
RL_TB 
TB_LR 
TB_RL 
LR_BT 
RL_BT 
BT_LR 
BT_RL 

Definition at line 53 of file QTMPrinterSettings.hpp.


Constructor & Destructor Documentation

Definition at line 24 of file QTMPrinterSettings.cpp.

: collateCopies(true), blackWhite(true), printerName(""), fileName(""), 
  paperSize("A4"), dpi(600), firstPage(0), lastPage(0), printOddPages(true), 
  printEvenPages(true), fitToPage(true), copyCount(1), duplex(false),
  pagesPerSide(1), pagesOrder(LR_TB), orientation(Portrait)
{
  configProgram = new QProcess(this);

  // See the class documentation for an explanation of the connected signal
  QObject::connect(configProgram, SIGNAL(finished(int, QProcess::ExitStatus)),
                   this, SLOT(systemCommandFinished(int, QProcess::ExitStatus)));
}

Here is the call graph for this function:


Member Function Documentation

virtual QList<QPair<QString,QString> > QTMPrinterSettings::availablePrinters ( ) [pure virtual]

Implemented by one of CupsQTMPrinterSettings, WinQTMPrinterSettings Must return a list of pairs of strings.

The first item in each pair being the printer's display name (i.e. the one to be shown to the user), the second the queue name.

Here is the caller graph for this function:

virtual bool QTMPrinterSettings::fromSystemConfig ( const QString &  printer) [protected, pure virtual]

Implemented by one of CupsQTMPrinterSettings, WinQTMPrinterSettings.

Here is the caller graph for this function:

QStringList QTMPrinterSettings::getChoices ( DriverChoices  _which,
int &  _default 
)

Returns a QStringList with all the available choices reported by the printer driver for the setting specified.

Parameters:
_whichSpecifies which driver option to query.
_defaultWill hold the index number (in the returned list) of the currently selected value, as reported by the printer driver.

Definition at line 123 of file QTMPrinterSettings.cpp.

                                                                  {
  QStringList _ret;
  switch (_which) {
    case PageSize:
      _ret = printerOptions["PageSize"].split(" ", QString::SkipEmptyParts);
      break;
    case Resolution:
      _ret = printerOptions["Resolution"].split(" ", QString::SkipEmptyParts);
      break;
    case Duplex:
      _ret = printerOptions["Duplex"].split(" ", QString::SkipEmptyParts);
      break;
    case ColorModel:
      _ret = printerOptions["ColorModel"].split(" ", QString::SkipEmptyParts);
      break;
    case Collate:
      _ret = printerOptions["Collate"].split(" ", QString::SkipEmptyParts);
      break;
  }
  
  // FIXME: this is CUPS specific (marking the default option with an asterisk)
  for (int i=0; i<_ret.size(); ++i)
    if (_ret[i].trimmed().startsWith("*")) {
      _ret[i] = _ret[i].trimmed().remove(0,1);
      _default = i;
    }
  return _ret;
}

Here is the caller graph for this function:

void QTMPrinterSettings::getFromQPrinter ( const QPrinter &  from)

Reads the configuration parameters from a QPrinter object.

Todo:
Check this sets all the available parameters.

Definition at line 42 of file QTMPrinterSettings.cpp.

                                                        {
  printerName   = from.printerName ();
  fileName      = from.outputFileName ();
  orientation   = (from.orientation() == QPrinter::Landscape) 
                  ? Landscape : Portrait;
  paperSize     = qtPaperSizeToQString(from.paperSize());
  dpi           = from.resolution ();
  firstPage     = from.fromPage ();
  lastPage      = from.toPage ();
#if (QT_VERSION >= 0x040700)
  copyCount     = from.copyCount ();
#endif
  collateCopies = from.collateCopies();
  blackWhite    = (from.colorMode () == QPrinter::Color);
  printProgram  = from.printProgram();
}

Here is the call graph for this function:

QPrinter::PaperSize QTMPrinterSettings::qStringToQtPaperSize ( const QString &  _size) [static]

Just for internal use, converts a string to QPrinter::PaperSize.

Definition at line 101 of file QTMPrinterSettings.cpp.

                                                             {
  
#define PAPER(fmt)  if(_size == "fmt") return QPrinter::fmt
  PAPER (A0) ; PAPER (A1) ; PAPER (A2) ; PAPER (A3) ; PAPER (A4) ;
  PAPER (A5) ; PAPER (A6) ; PAPER (A7) ; PAPER (A8) ; PAPER (A9) ;
  PAPER (B0) ; PAPER (B1) ; PAPER (B2) ; PAPER (B3) ; PAPER (B4) ;
  PAPER (B5) ; PAPER (B6) ; PAPER (B7) ; PAPER (B8) ; PAPER (B9) ;
  PAPER (B10) ;  PAPER (Letter) ;
  return QPrinter::A4;  // Default
#undef PAPER
}

Here is the caller graph for this function:

QString QTMPrinterSettings::qtPaperSizeToQString ( const QPrinter::PaperSize  _size) [static]

Just for internal use, converts QPrinter::PaperSize to a string representation.

Massimiliano's code.

Definition at line 83 of file QTMPrinterSettings.cpp.

                                                                      {
  
#define PAPER(fmt)  case QPrinter::fmt : return "fmt"
  switch (_size) {
      PAPER (A0) ; PAPER (A1) ; PAPER (A2) ; PAPER (A3) ; PAPER (A4) ;
      PAPER (A5) ; PAPER (A6) ; PAPER (A7) ; PAPER (A8) ; PAPER (A9) ;
      PAPER (B0) ; PAPER (B1) ; PAPER (B2) ; PAPER (B3) ; PAPER (B4) ;
      PAPER (B5) ; PAPER (B6) ; PAPER (B7) ; PAPER (B8) ; PAPER (B9) ;
      PAPER (B10) ;  PAPER (Letter) ;
    default: return "A4";
  }
#undef PAPER
}

Here is the caller graph for this function:

void QTMPrinterSettings::setToQPrinter ( QPrinter &  to) const

Sets the configuration parameters to a QPrinter object.

Todo:
Check this sets all the available parameters.

Definition at line 64 of file QTMPrinterSettings.cpp.

                                                    {
  to.setResolution(dpi);
  to.setFromTo(firstPage, lastPage);  
  to.setOrientation((orientation == Landscape) ?
                    QPrinter::Landscape : QPrinter::Portrait);
  to.setOutputFileName(fileName);
  to.setPaperSize(qStringToQtPaperSize(paperSize));
#if (QT_VERSION >= 0x040700)
  to.setCopyCount(copyCount);
#endif  
  to.setCollateCopies(collateCopies);
  to.setColorMode(blackWhite ? QPrinter::Color : QPrinter::GrayScale);
}

Here is the call graph for this function:

void QTMPrinterSettings::startReadingSystemConfig ( const QString &  pname) [inline, slot]

Definition at line 111 of file QTMPrinterSettings.hpp.

{ fromSystemConfig(pname); }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void QTMPrinterSettings::systemCommandFinished ( int  exitCode,
QProcess::ExitStatus  exitStatus 
) [protected, pure virtual, slot]

Here is the caller graph for this function:

virtual QString QTMPrinterSettings::toSystemCommand ( ) const [pure virtual]

Implemented by one of CupsQTMPrinterSettings, WinQTMPrinterSettings.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 68 of file QTMPrinterSettings.hpp.

Definition at line 67 of file QTMPrinterSettings.hpp.

QProcess* QTMPrinterSettings::configProgram [protected]

Definition at line 121 of file QTMPrinterSettings.hpp.

Definition at line 79 of file QTMPrinterSettings.hpp.

Definition at line 73 of file QTMPrinterSettings.hpp.

Definition at line 80 of file QTMPrinterSettings.hpp.

Definition at line 70 of file QTMPrinterSettings.hpp.

Definition at line 74 of file QTMPrinterSettings.hpp.

Definition at line 78 of file QTMPrinterSettings.hpp.

If firstPage == lastPage == 0, print everything.

Definition at line 75 of file QTMPrinterSettings.hpp.

Definition at line 83 of file QTMPrinterSettings.hpp.

Can be one of 1,2,4,6,9,16.

Definition at line 82 of file QTMPrinterSettings.hpp.

Print on both sides of the paper.

Definition at line 81 of file QTMPrinterSettings.hpp.

Definition at line 71 of file QTMPrinterSettings.hpp.

Force black & white printing even on color printers.

Definition at line 69 of file QTMPrinterSettings.hpp.

QHash<QString, QString> QTMPrinterSettings::printerOptions [protected]

Definition at line 122 of file QTMPrinterSettings.hpp.

Definition at line 77 of file QTMPrinterSettings.hpp.

Definition at line 76 of file QTMPrinterSettings.hpp.

Definition at line 72 of file QTMPrinterSettings.hpp.


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