diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2012-05-08 12:56:45 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-08 06:58:27 +0200 |
commit | de11b9f5a7aaab79e816983a72b8e92ac84ce5d6 (patch) | |
tree | aafbf1b22400bbaf90046b415490667164a2d93a /src/printsupport/kernel/qcups.cpp | |
parent | 80f7a388906f94f58bf765a32b9abbb16f967db2 (diff) |
Revert "QtPrintSupport: Remove remaining LPR specific code"
This doesn't compile with a typical cross-compilation setup, which
generally won't include cups headers. The commit should have been
rejected, but wasn't, due to a bug in the Qt Project CI.
Since it now causes all other modules depending on qtbase to fail their
CI, it must be reverted to minimize disruption while the commit can be
amended and/or the test toolchain updated to include cups headers.
This reverts commit 80f7a388906f94f58bf765a32b9abbb16f967db2.
Change-Id: I315ae275b37de358a74af28ab7bd691c9849acba
Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
Reviewed-by: Toby Tomkins <toby.tomkins@nokia.com>
Diffstat (limited to 'src/printsupport/kernel/qcups.cpp')
-rw-r--r-- | src/printsupport/kernel/qcups.cpp | 87 |
1 files changed, 15 insertions, 72 deletions
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index 98aecd8299..1f8bed57ea 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -40,8 +40,9 @@ ****************************************************************************/ #include <qdebug.h> #include "qcups_p.h" +#include "qprinterinfo_unix_p.h" -#ifndef QT_NO_PRINTER +#ifndef QT_NO_CUPS #ifndef QT_LINUXBASE // LSB merges everything into cups.h # include <cups/language.h> @@ -404,6 +405,7 @@ QList<QCUPSSupport::Printer> QCUPSSupport::availableUnixPrinters() { QList<Printer> printers; +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) if (QCUPSSupport::isAvailable()) { QCUPSSupport cups; int cupsPrinterCount = cups.availablePrintersCount(); @@ -419,85 +421,26 @@ QList<QCUPSSupport::Printer> QCUPSSupport::availableUnixPrinters() p.cupsPrinterIndex = i; printers.append(p); } + } else +#endif + { + QList<QPrinterDescription> lprPrinters; + int defprn = qt_getLprPrinters(lprPrinters); + // populating printer combo + foreach (const QPrinterDescription &description, lprPrinters) + printers.append(Printer(description.name)); + if (defprn >= 0 && defprn < printers.size()) + printers[defprn].isDefault = true; } return printers; } -// preserve names in ascending order for the binary search -static const struct NamedPaperSize { - const char *const name; - QPrinter::PaperSize size; -} named_sizes_map[QPrinter::NPageSize] = { - { "A0", QPrinter::A0 }, - { "A1", QPrinter::A1 }, - { "A2", QPrinter::A2 }, - { "A3", QPrinter::A3 }, - { "A4", QPrinter::A4 }, - { "A5", QPrinter::A5 }, - { "A6", QPrinter::A6 }, - { "A7", QPrinter::A7 }, - { "A8", QPrinter::A8 }, - { "A9", QPrinter::A9 }, - { "B0", QPrinter::B0 }, - { "B1", QPrinter::B1 }, - { "B10", QPrinter::B10 }, - { "B2", QPrinter::B2 }, - { "B4", QPrinter::B4 }, - { "B5", QPrinter::B5 }, - { "B6", QPrinter::B6 }, - { "B7", QPrinter::B7 }, - { "B8", QPrinter::B8 }, - { "B9", QPrinter::B9 }, - { "C5E", QPrinter::C5E }, - { "Comm10E", QPrinter::Comm10E }, - { "Custom", QPrinter::Custom }, - { "DLE", QPrinter::DLE }, - { "Executive", QPrinter::Executive }, - { "Folio", QPrinter::Folio }, - { "Ledger", QPrinter::Ledger }, - { "Legal", QPrinter::Legal }, - { "Letter", QPrinter::Letter }, - { "Tabloid", QPrinter::Tabloid } -}; - -inline bool operator<(const char *name, const NamedPaperSize &data) -{ return qstrcmp(name, data.name) < 0; } -inline bool operator<(const NamedPaperSize &data, const char *name) -{ return qstrcmp(data.name, name) < 0; } - -static inline QPrinter::PaperSize string2PaperSize(const char *name) -{ - const NamedPaperSize *r = qBinaryFind(named_sizes_map, named_sizes_map + QPrinter::NPageSize, name); - if (r - named_sizes_map != QPrinter::NPageSize) - return r->size; - return QPrinter::Custom; -} - -static inline const char *paperSize2String(QPrinter::PaperSize size) -{ - for (int i = 0; i < QPrinter::NPageSize; ++i) { - if (size == named_sizes_map[i].size) - return named_sizes_map[i].name; - } - return 0; -} - QList<QPrinter::PaperSize> QCUPSSupport::getCupsPrinterPaperSizes(int cupsPrinterIndex) { - QList<QPrinter::PaperSize> result; - if (!QCUPSSupport::isAvailable() || cupsPrinterIndex < 0) - return result; - // Find paper sizes from CUPS. - QCUPSSupport cups; - cups.setCurrentPrinter(cupsPrinterIndex); - if (const ppd_option_t* size = cups.pageSizes()) { - for (int j = 0; j < size->num_choices; ++j) - result.append(string2PaperSize(size->choices[j].choice)); - } - return result; + return qt_getCupsPrinterPaperSizes(cupsPrinterIndex); } QT_END_NAMESPACE -#endif // QT_NO_PRINTER +#endif // QT_NO_CUPS |