Add API to convert QSizeF<->PaperSize in QPlatformPrinterSupport

These static public functions give printsupport plugins access to the
non-exported qt_paperSizeToQSizeF() and qSizeFTopaperSize() functions in
qprinter.cpp to aid implementing QPrintEngine and
QPlatformPrinterSupport::supportedPaperSizes().

Change-Id: I3ebcdcd17e863b06ceb135e096e630b37882a293
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
Bradley T. Hughes 2012-03-01 08:22:57 +01:00 committed by Qt by Nokia
parent 0cb58c7c6d
commit e1ec8727ea
2 changed files with 23 additions and 0 deletions

View File

@ -124,6 +124,26 @@ void QPlatformPrinterSupport::setPrinterInfoCupsPrinterIndex(QPrinterInfo *p, in
#endif #endif
} }
/*
Converts QSizeF in millimeters to a predefined PaperSize (returns Custom if
the size isn't a standard size)
*/
QPrinter::PaperSize QPlatformPrinterSupport::convertQSizeFToPaperSize(const QSizeF &sizef)
{
extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF &);
return qSizeFTopaperSize(sizef);
}
/*
Converts a predefined PaperSize to a QSizeF in millimeters (returns
QSizeF(0.0, 0.0) if PaperSize is Custom)
*/
QSizeF QPlatformPrinterSupport::convertPaperSizeToQSizeF(QPrinter::PaperSize paperSize)
{
extern QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size);
return qt_paperSizeToQSizeF(paperSize);
}
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QT_NO_PRINTER #endif // QT_NO_PRINTER

View File

@ -66,6 +66,9 @@ public:
virtual QList<QPrinterInfo> availablePrinters(); virtual QList<QPrinterInfo> availablePrinters();
virtual QPrinterInfo defaultPrinter(); virtual QPrinterInfo defaultPrinter();
static QPrinter::PaperSize convertQSizeFToPaperSize(const QSizeF &sizef);
static QSizeF convertPaperSizeToQSizeF(QPrinter::PaperSize paperSize);
protected: protected:
static QPrinterInfo printerInfo(const QString &printerName, bool isDefault = false); static QPrinterInfo printerInfo(const QString &printerName, bool isDefault = false);
static void setPrinterInfoDefault(QPrinterInfo *p, bool isDefault); static void setPrinterInfoDefault(QPrinterInfo *p, bool isDefault);