diff options
author | John Layt <jlayt@kde.org> | 2013-12-18 21:51:12 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-17 13:45:44 +0100 |
commit | b0428926cece7bc362bc24c2eb1621b9fef737c7 (patch) | |
tree | e5497f1b5c2f7bdacb5e7e0ba9898f9423884e26 /src/plugins/platforms/cocoa/qcocoaprintersupport.mm | |
parent | cf8b8340f3d283830a6aca2f708e839bb70d6d57 (diff) |
QPrinterInfo - Switch to QPlatformPrintDevice
Change the QPrinterInfo implementation to use QPlatformPrintDevice as
the backend. Remove all the old QPrinterInfo related code from the
QPA plugin. Add public api to QPrinterInfo to support some features
from QPlatformPrintDevice.
[ChangeLog][QtPrintSupport][QPrinterInfo] Added new public api for
isRemote(), state(), defaultPageSize(), supportedPageSizes(),
supportsCustomPageSizes(), minimumPhysicalPageSize(),
maximumPhysicalPageSize(), supportedResolutions(),
availablePrinterNames(), and defaultPrinterName(). The use of
availablePrinters() is discouraged due to performance concerns.
Task-number: QTBUG-35248
Change-Id: Ic38323a930549ad67bf04a1a6bb43d623dfe6a33
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaprintersupport.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaprintersupport.mm | 107 |
1 files changed, 1 insertions, 106 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm index 70c83498e1..5853135dfb 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm @@ -42,13 +42,11 @@ #include "qcocoaprintersupport.h" #ifndef QT_NO_PRINTER + #include "qcocoaprintdevice.h" #include "qprintengine_mac_p.h" -#include <QtPrintSupport/QPrinter> -#include <QtPrintSupport/QPrinterInfo> #include <private/qprinterinfo_p.h> -#include <private/qprintdevice_p.h> QCocoaPrinterSupport::QCocoaPrinterSupport() { } @@ -104,107 +102,4 @@ QString QCocoaPrinterSupport::defaultPrintDeviceId() const return QString(); } -QList<QPrinter::PaperSize> QCocoaPrinterSupport::supportedPaperSizes(const QPrinterInfo &printerInfo) const -{ - QList<QPrinter::PaperSize> returnValue; - if (printerInfo.isNull()) - return returnValue; - - PMPrinter printer = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(printerInfo.printerName())); - if (!printer) - return returnValue; - - CFArrayRef array; - if (PMPrinterGetPaperList(printer, &array) != noErr) { - PMRelease(printer); - return returnValue; - } - - CFIndex count = CFArrayGetCount(array); - for (CFIndex i = 0; i < count; ++i) { - PMPaper paper = static_cast<PMPaper>(const_cast<void *>(CFArrayGetValueAtIndex(array, i))); - double width, height; - if (PMPaperGetWidth(paper, &width) == noErr - && PMPaperGetHeight(paper, &height) == noErr) { - // width and height are in points, convertQSizeFToPaperSize() expects millimeters - static const double OnePointInMillimeters = 1.0 / 72.0 * 25.4; - QSizeF size(width * OnePointInMillimeters, height * OnePointInMillimeters); - returnValue += QPlatformPrinterSupport::convertQSizeFToPaperSize(size); - } - } - - PMRelease(printer); - - return returnValue; -} - -QList<QPrinterInfo> QCocoaPrinterSupport::availablePrinters() -{ - QList<QPrinterInfo> returnValue; - QCFType<CFArrayRef> printerList; - if (PMServerCreatePrinterList(kPMServerLocal, &printerList) == noErr) { - CFIndex count = CFArrayGetCount(printerList); - for (CFIndex i = 0; i < count; ++i) { - PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(printerList, i))); - returnValue += printerInfoFromPMPrinter(printer); - } - } - return returnValue; -} - -QPrinterInfo QCocoaPrinterSupport::printerInfo(const QString &printerName) -{ - PMPrinter printer = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(printerName)); - QPrinterInfo pi = printerInfoFromPMPrinter(printer); - PMRelease(printer); - return pi; -} - -QPrinterInfo QCocoaPrinterSupport::printerInfoFromPMPrinter(const PMPrinter &printer) -{ - if (!printer) - return QPrinterInfo(); - - QString name = QCFString::toQString(PMPrinterGetID(printer)); - QString description = QCFString::toQString(PMPrinterGetName(printer)); - QString location = QCFString::toQString(PMPrinterGetLocation(printer)); - CFStringRef cfMakeAndModel; - PMPrinterGetMakeAndModelName(printer, &cfMakeAndModel); - QString makeAndModel = QCFString::toQString(cfMakeAndModel); - bool isDefault = PMPrinterIsDefault(printer); - - return createPrinterInfo(name, description, location, makeAndModel, isDefault, 0); -} - -QList<QPair<QString, QSizeF> > QCocoaPrinterSupport::supportedSizesWithNames(const QPrinterInfo &printerInfo) const -{ - QList<QPair<QString, QSizeF> > returnValue; - if (printerInfo.isNull()) - return returnValue; - - PMPrinter printer = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(printerInfo.printerName())); - if (!printer) - return returnValue; - - CFArrayRef array; - if (PMPrinterGetPaperList(printer, &array) != noErr) { - PMRelease(printer); - return returnValue; - } - - int count = CFArrayGetCount(array); - for (int i = 0; i < count; ++i) { - PMPaper paper = static_cast<PMPaper>(const_cast<void *>(CFArrayGetValueAtIndex(array, i))); - double width, height; - if (PMPaperGetWidth(paper, &width) == noErr && PMPaperGetHeight(paper, &height) == noErr) { - static const double OnePointInMillimeters = 1.0 / 72.0 * 25.4; - QCFString paperName; - if (PMPaperCreateLocalizedName(paper, printer, &paperName) == noErr) - returnValue.append(qMakePair(QString(paperName), QSizeF(width * OnePointInMillimeters, height * OnePointInMillimeters))); - } - } - PMRelease(printer); - return returnValue; -} - #endif //QT_NO_PRINTER |