- Timestamp:
- Feb 17, 2010, 8:53:20 PM (15 years ago)
- Location:
- trunk/src/gui
- Files:
-
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/dialogs/dialogs.pri
r561 r573 35 35 dialogs/qprintdialog_mac.mm 36 36 37 # Compile qcolordialog_mac.mm with exception support, disregarding the -no-exceptions 37 # Compile qcolordialog_mac.mm with exception support, disregarding the -no-exceptions 38 38 # configure option. (qcolordialog_mac needs to catch exceptions thrown by cocoa) 39 39 EXCEPTION_SOURCES = dialogs/qcolordialog_mac.mm … … 61 61 } 62 62 63 !mac:!embedded:!symbian:unix {63 !mac:!embedded:!symbian:unix|os2 { 64 64 HEADERS += dialogs/qpagesetupdialog_unix_p.h 65 65 SOURCES += dialogs/qprintdialog_unix.cpp \ -
trunk/src/gui/dialogs/qpagesetupdialog_unix.cpp
r561 r573 54 54 #include <private/qprinter_p.h> 55 55 56 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)56 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 57 57 # include <private/qcups_p.h> 58 58 # include <cups/cups.h> … … 225 225 226 226 QPageSetupWidget *widget; 227 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)227 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 228 228 QCUPSSupport *cups; 229 229 #endif … … 232 232 QPageSetupDialogPrivate::~QPageSetupDialogPrivate() 233 233 { 234 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)234 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 235 235 delete cups; 236 236 #endif … … 243 243 widget = new QPageSetupWidget(q); 244 244 widget->setPrinter(printer); 245 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)245 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 246 246 if (printer->outputFormat() == QPrinter::NativeFormat && QCUPSSupport::isAvailable()) { 247 247 cups = new QCUPSSupport; … … 355 355 ps = val.toInt(); 356 356 } 357 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)357 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 358 358 else if (m_cups && QCUPSSupport::isAvailable() && m_cups->currentPPD()) { 359 359 QByteArray cupsPageSize = val.toByteArray(); … … 391 391 m_cups = cups; 392 392 widget.paperSize->clear(); 393 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)393 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 394 394 if (m_cups && QCUPSSupport::isAvailable()) { 395 395 const ppd_option_t* pageSizes = m_cups->pageSizes(); … … 472 472 bool custom = size == QPrinter::Custom; 473 473 474 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)474 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 475 475 custom = custom ? !m_cups : custom; 476 476 #endif … … 486 486 } else { 487 487 Q_ASSERT(m_printer); 488 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)488 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 489 489 if (m_cups) { // combobox is filled with cups based data 490 490 QByteArray cupsPageSize = widget.paperSize->itemData(widget.paperSize->currentIndex()).toByteArray(); -
trunk/src/gui/dialogs/qprintdialog.h
r561 r573 57 57 class QPrinter; 58 58 59 #if defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC)59 #if (defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC)) || defined (Q_WS_PM) 60 60 class QUnixPrintWidgetPrivate; 61 61 … … 92 92 93 93 int exec(); 94 #if defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC)94 #if (defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC)) || defined (Q_WS_PM) 95 95 virtual void accept(); 96 96 #endif … … 108 108 PrintDialogOptions options() const; 109 109 110 #if defined(Q_OS_UNIX) || defined(Q_WS_MAC) || defined(Q_OS_WIN) 110 #if defined(Q_OS_UNIX) || defined(Q_WS_MAC) || defined(Q_OS_WIN) || defined (Q_WS_PM) 111 111 void setVisible(bool visible); 112 112 #endif … … 144 144 #ifndef QTOPIA_PRINTDIALOG 145 145 Q_PRIVATE_SLOT(d_func(), void _q_chbPrintLastFirstToggled(bool)) 146 #if defined (Q_OS_UNIX) && !defined (Q_OS_MAC)146 #if (defined (Q_OS_UNIX) && !defined (Q_OS_MAC)) || defined (Q_WS_PM) 147 147 Q_PRIVATE_SLOT(d_func(), void _q_collapseOrExpandDialog()) 148 148 #endif 149 # if defined(Q_OS_UNIX) && !defined (Q_OS_MAC) && !defined(QT_NO_MESSAGEBOX)149 # if ((defined(Q_OS_UNIX) && !defined (Q_OS_MAC)) || defined (Q_WS_PM)) && !defined(QT_NO_MESSAGEBOX) 150 150 Q_PRIVATE_SLOT(d_func(), void _q_checkFields()) 151 151 # endif -
trunk/src/gui/dialogs/qprintdialog_unix.cpp
r561 r573 61 61 #include "ui_qprintwidget.h" 62 62 63 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)63 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 64 64 # include <private/qcups_p.h> 65 65 # include <cups/cups.h> … … 85 85 ~QPrintPropertiesDialog(); 86 86 87 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)87 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 88 88 void setCups(QCUPSSupport *cups) { m_cups = cups; } 89 89 void addItemToOptions(QOptionTreeItem *parent, QList<const ppd_option_t*>& options, QList<const char*>& markedOptions) const; … … 103 103 Ui::QPrintPropertiesWidget widget; 104 104 QDialogButtonBox *m_buttons; 105 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)105 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 106 106 QCUPSSupport *m_cups; 107 107 QPPDOptionsModel *m_cupsOptionsModel; … … 121 121 void applyPrinterProperties(QPrinter *p); 122 122 123 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)123 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 124 124 void selectPrinter(QCUPSSupport *cups); 125 125 #endif … … 143 143 }; 144 144 145 #if defined (Q_OS_UNIX) 145 #if defined (Q_OS_UNIX) || defined (Q_WS_PM) 146 146 class QUnixPrintWidgetPrivate 147 147 { … … 172 172 QPrintDialogPrivate *optionsPane; 173 173 bool filePrintersAdded; 174 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)174 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 175 175 QCUPSSupport* cups; 176 176 int cupsPrinterCount; … … 181 181 #endif 182 182 183 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)183 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 184 184 class QOptionTreeItem 185 185 { … … 257 257 QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent) 258 258 : QDialog(parent) 259 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)259 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 260 260 , m_cups(0), m_cupsOptionsModel(0) 261 261 #endif … … 275 275 QPrintPropertiesDialog::~QPrintPropertiesDialog() 276 276 { 277 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)277 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 278 278 delete m_cupsOptionsModel; 279 279 #else … … 291 291 widget.pageSetup->setupPrinter(); 292 292 293 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)293 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 294 294 QPPDOptionsModel* model = static_cast<QPPDOptionsModel*>(widget.treeView->model()); 295 295 if (model) { … … 306 306 void QPrintPropertiesDialog::selectPrinter() 307 307 { 308 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)308 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 309 309 widget.pageSetup->selectPrinter(m_cups); 310 310 widget.treeView->setModel(0); … … 352 352 } 353 353 354 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)354 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 355 355 void QPrintPropertiesDialog::addItemToOptions(QOptionTreeItem *parent, QList<const ppd_option_t*>& options, QList<const char*>& markedOptions) const 356 356 { … … 566 566 } 567 567 568 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)568 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 569 569 void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups) 570 570 { … … 644 644 #endif // QT3_SUPPORT 645 645 646 #if defined (Q_OS_UNIX) 646 #if defined (Q_OS_UNIX) || defined (Q_WS_PM) 647 647 648 648 /*! \internal … … 650 650 QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p) 651 651 : parent(p), propertiesDialog(0), printer(0), optionsPane(0), filePrintersAdded(false) 652 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)652 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 653 653 , cups(0), cupsPrinterCount(0), cupsPrinters(0), cupsPPD(0) 654 654 #endif … … 661 661 662 662 int currentPrinterIndex = 0; 663 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)663 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 664 664 cups = new QCUPSSupport; 665 665 if (QCUPSSupport::isAvailable()) { … … 685 685 } else { 686 686 #endif 687 #ifndef Q_WS_PM 687 688 currentPrinterIndex = qt_getLprPrinters(lprPrinters); 688 689 // populating printer combo … … 690 691 for(; i != lprPrinters.constEnd(); ++i) 691 692 widget.printers->addItem((*i).name); 692 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 693 #endif 694 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 693 695 } 694 696 #endif … … 749 751 QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate() 750 752 { 751 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)753 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 752 754 delete cups; 753 755 #endif … … 781 783 if (propertiesDialog) 782 784 propertiesDialog->selectPdfPsPrinter(printer); 783 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)785 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 784 786 if (optionsPane) 785 787 optionsPane->selectPrinter(0); … … 790 792 791 793 widget.location->setText(QString()); 792 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)794 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 793 795 if (QCUPSSupport::isAvailable()) { 794 796 cups->setCurrentPrinter(index); … … 822 824 propertiesDialog->selectPrinter(); 823 825 } 824 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)826 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 825 827 } 826 828 #endif … … 949 951 950 952 if (propertiesDialog->result() == QDialog::Rejected) { 951 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)953 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 952 954 propertiesDialog->setCups(cups); 953 955 #endif … … 1017 1019 1018 1020 //////////////////////////////////////////////////////////////////////////////// 1019 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 1021 1022 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined (Q_WS_PM)) 1020 1023 1021 1024 QPPDOptionsModel::QPPDOptionsModel(QCUPSSupport *c, QObject *parent) -
trunk/src/gui/painting/painting.pri
r569 r573 110 110 SOURCES += \ 111 111 painting/qcolormap_pm.cpp \ 112 painting/qpaintdevice_pm.cpp 112 painting/qpaintdevice_pm.cpp \ 113 painting/qprinterinfo_pm.cpp 113 114 } 114 115 … … 194 195 } 195 196 196 x11|embedded {197 x11|embedded|os2 { 197 198 contains(QT_CONFIG,qtopia) { 198 199 DEFINES += QT_NO_CUPS QT_NO_LPR … … 200 201 SOURCES += painting/qcups.cpp 201 202 HEADERS += painting/qcups_p.h 203 } 204 os2 { 205 INCLUDEPATH += $$CUPS_INCLUDEPATH 206 LIBS += $$CUPS_LIBS 202 207 } 203 208 } else { -
trunk/src/gui/painting/qcups.cpp
r561 r573 50 50 51 51 QT_BEGIN_NAMESPACE 52 53 #ifndef Q_WS_PM 52 54 53 55 typedef int (*CupsGetDests)(cups_dest_t **dests); … … 86 88 static CupsPrintFile _cupsPrintFile = 0; 87 89 90 #else // ifndef Q_WS_PM 91 92 // On OS/2, we link to libcups statically 93 94 static bool cupsLoaded = false; 95 static int qt_cups_num_printers = 0; 96 97 #define _cupsGetDests cupsGetDests 98 #define _cupsFreeDests cupsFreeDests 99 #define _cupsGetPPD cupsGetPPD 100 #define _cupsLangGet cupsLangGet 101 #define _cupsLangEncoding cupsLangEncoding 102 #define _ppdOpenFile ppdOpenFile 103 #define _ppdMarkDefaults ppdMarkDefaults 104 #define _ppdClose ppdClose 105 #define _cupsMarkOptions cupsMarkOptions 106 #define _ppdMarkOption ppdMarkOption 107 #define _cupsFreeOptions cupsFreeOptions 108 #define _cupsSetDests cupsSetDests 109 #define _cupsAddOption cupsAddOption 110 #define _cupsTempFd cupsTempFd 111 #define _cupsPrintFile cupsPrintFile 112 113 #endif // ifndef Q_WS_PM 114 88 115 static void resolveCups() 89 116 { 117 #ifndef Q_WS_PM 90 118 QLibrary cupsLib(QLatin1String("cups"), 2); 91 119 if(cupsLib.load()) { … … 107 135 108 136 if (_cupsGetDests && _cupsFreeDests) { 137 #endif 109 138 cups_dest_t *printers; 110 139 int num_printers = _cupsGetDests(&printers); … … 112 141 _cupsFreeDests(num_printers, printers); 113 142 qt_cups_num_printers = num_printers; 114 } 115 } 143 #ifndef Q_WS_PM 144 } 145 } 146 #endif 116 147 cupsLoaded = true; 117 148 } … … 218 249 resolveCups(); 219 250 220 return _cupsGetDests && 251 return 252 #ifndef Q_WS_PM 253 _cupsGetDests && 221 254 _cupsFreeDests && 222 255 _cupsGetPPD && … … 231 264 _cupsLangEncoding && 232 265 _cupsAddOption && 266 #endif 233 267 (qt_cups_num_printers > 0); 234 268 } -
trunk/src/gui/painting/qcups_p.h
r561 r573 55 55 #include "QtCore/qstring.h" 56 56 #include "QtCore/qstringlist.h" 57 #include "QtCore/qpair.h" 57 58 #include "QtGui/qprinter.h" 58 59 59 60 #ifndef QT_NO_CUPS 61 62 #ifndef Q_WS_PM 60 63 #include <QtCore/qlibrary.h> 64 #endif 61 65 #include <cups/cups.h> 62 66 -
trunk/src/gui/painting/qpdf.cpp
r561 r573 941 941 { 942 942 Q_D(QPdfBaseEngine); 943 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)943 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 944 944 if (QCUPSSupport::isAvailable()) { 945 945 QCUPSSupport cups; … … 1506 1506 break; 1507 1507 case PPK_NumberOfCopies: 1508 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)1508 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 1509 1509 if (QCUPSSupport::isAvailable()) 1510 1510 ret = 1; … … 1673 1673 } 1674 1674 outDevice = file; 1675 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)1675 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 1676 1676 } else if (QCUPSSupport::isAvailable()) { 1677 1677 QCUPSSupport cups; … … 1691 1691 pr = printerName; 1692 1692 int fds[2]; 1693 #ifdef Q_WS_PM 1694 if (::pipe(fds) != 0) { 1695 #else 1693 1696 if (qt_safe_pipe(fds) != 0) { 1697 #endif 1694 1698 qWarning("QPdfPrinter: Could not open pipe to print"); 1695 1699 return false; … … 1712 1716 ::_exit(0); 1713 1717 } 1718 #ifdef Q_WS_PM 1719 ::dup2(fds[0], 0); 1720 #else 1714 1721 qt_safe_dup2(fds[0], 0, 0); 1722 #endif 1715 1723 1716 1724 closeAllOpenFds(); … … 1789 1797 QT_CLOSE(fds[0]); 1790 1798 fd = fds[1]; 1799 #ifdef Q_WS_PM 1800 (void)::waitpid(pid, 0, 0); 1801 #else 1791 1802 (void)qt_safe_waitpid(pid, 0, 0); 1792 1803 #endif 1793 1804 if (fd < 0) 1794 1805 return false; … … 1817 1828 outDevice = 0; 1818 1829 1819 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)1830 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 1820 1831 if (!cupsTempFile.isEmpty()) { 1821 1832 QString tempFile = cupsTempFile; … … 2030 2041 h = qRound(customPaperSize.height()*resolution/72.); 2031 2042 } else { 2032 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)2043 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 2033 2044 if (QCUPSSupport::isAvailable() && !cupsPaperRect.isNull()) { 2034 2045 QRect r = cupsPaperRect; … … 2058 2069 QRect r; 2059 2070 2060 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)2071 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 2061 2072 if (!hasCustomPageMargins && QCUPSSupport::isAvailable() && !cupsPageRect.isNull()) { 2062 2073 r = cupsPageRect; -
trunk/src/gui/painting/qpdf_p.h
r561 r573 291 291 qreal leftMargin, topMargin, rightMargin, bottomMargin; 292 292 293 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)293 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 294 294 QString cupsTempFile; 295 295 #endif -
trunk/src/gui/painting/qprinter.cpp
r561 r573 48 48 #include <qapplication.h> 49 49 #include <qfileinfo.h> 50 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)50 #if !defined(QT_NO_CUPS) && (!defined(QT_NO_LIBRARY) || defined(Q_WS_PM)) 51 51 #include "private/qcups_p.h" 52 52 #endif … … 184 184 QPrinter::OutputFormat realOutputFormat = outputFormat; 185 185 #if !defined (QTOPIA_PRINTENGINE) 186 #if defined (Q_OS_UNIX) && ! defined (Q_WS_MAC)186 #if (defined (Q_OS_UNIX) && ! defined (Q_WS_MAC)) || defined (Q_WS_PM) 187 187 if(outputFormat == QPrinter::NativeFormat) { 188 188 realOutputFormat = QPrinter::PostScriptFormat; … … 205 205 paintEngine = qwsEngine; 206 206 printEngine = qwsEngine; 207 #elif defined (Q_OS_UNIX) 207 #elif defined (Q_OS_UNIX) || defined (Q_WS_PM) 208 208 Q_ASSERT(false); 209 209 #endif … … 665 665 d->realPaintEngine = 0; 666 666 667 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 667 // Note: On OS/2, sending PDF data doesn't yet work with the current eCUPS 668 // (which is version 1.3.11 of CUPS), so don't force the PDF format there 669 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) && !defined(Q_WS_PM) 668 670 if (QCUPSSupport::cupsVersion() >= 10200 && QCUPSSupport().currentPPD()) { 669 671 setOutputFormat(QPrinter::PdfFormat); … … 825 827 if(d->use_default_engine 826 828 && d->outputFormat == QPrinter::NativeFormat) { 829 // Note: On OS/2, sending PDF data doesn't yet work with the current eCUPS 830 // (which is version 1.3.11 of CUPS), so don't force the PDF format there 831 #ifndef Q_WS_PM 827 832 if (QCUPSSupport::cupsVersion() >= 10200 828 833 && QCUPSSupport::printerHasPPD(name.toLocal8Bit().constData())) 829 834 setOutputFormat(QPrinter::PdfFormat); 830 835 else 836 #endif 831 837 setOutputFormat(QPrinter::PostScriptFormat); 832 838 d->outputFormat = QPrinter::NativeFormat; -
trunk/src/gui/painting/qprinterinfo_pm.cpp
r563 r573 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 6 ** 7 ** Copyright (C) 2009 netlabs.org. OS/2 parts. 6 8 ** 7 9 ** This file is part of the QtGui module of the Qt Toolkit. … … 42 44 #include "qprinterinfo.h" 43 45 44 #include <qfile.h> 45 #include <qfileinfo.h> 46 #include <qdir.h> 47 #include <qprintdialog.h> 48 #include <qlibrary.h> 49 #include <qtextstream.h> 50 51 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 46 #if !defined(QT_NO_CUPS) 52 47 # include <private/qcups_p.h> 53 48 # include <cups/cups.h> 54 49 # include <private/qpdf_p.h> 55 50 #endif 56 57 #include <private/qprinterinfo_unix_p.h>58 51 59 52 QT_BEGIN_NAMESPACE … … 98 91 ///////////////////////////////////////////////////////////////////////////// 99 92 100 void qt_perhapsAddPrinter(QList<QPrinterDescription> *printers, const QString &name,101 QString host, QString comment,102 QStringList aliases)103 {104 for (int i = 0; i < printers->size(); ++i)105 if (printers->at(i).samePrinter(name))106 return;107 108 #ifndef QT_NO_PRINTDIALOG109 if (host.isEmpty())110 host = QPrintDialog::tr("locally connected");111 #endif112 printers->append(QPrinterDescription(name.simplified(), host.simplified(), comment.simplified(), aliases));113 }114 115 void qt_parsePrinterDesc(QString printerDesc, QList<QPrinterDescription> *printers)116 {117 if (printerDesc.length() < 1)118 return;119 120 printerDesc = printerDesc.simplified();121 int i = printerDesc.indexOf(QLatin1Char(':'));122 QString printerName, printerComment, printerHost;123 QStringList aliases;124 125 if (i >= 0) {126 // have ':' want '|'127 int j = printerDesc.indexOf(QLatin1Char('|'));128 if (j > 0 && j < i) {129 printerName = printerDesc.left(j);130 aliases = printerDesc.mid(j + 1, i - j - 1).split(QLatin1Char('|'));131 #ifndef QT_NO_PRINTDIALOG132 // try extracting a comment from the aliases133 printerComment = QPrintDialog::tr("Aliases: %1")134 .arg(aliases.join(QLatin1String(", ")));135 #endif136 } else {137 printerName = printerDesc.left(i);138 }139 // look for lprng pseudo all printers entry140 i = printerDesc.indexOf(QRegExp(QLatin1String(": *all *=")));141 if (i >= 0)142 printerName = QString();143 // look for signs of this being a remote printer144 i = printerDesc.indexOf(QRegExp(QLatin1String(": *rm *=")));145 if (i >= 0) {146 // point k at the end of remote host name147 while (printerDesc[i] != QLatin1Char('='))148 i++;149 while (printerDesc[i] == QLatin1Char('=') || printerDesc[i].isSpace())150 i++;151 j = i;152 while (j < (int)printerDesc.length() && printerDesc[j] != QLatin1Char(':'))153 j++;154 155 // and stuff that into the string156 printerHost = printerDesc.mid(i, j - i);157 }158 }159 if (printerName.length())160 qt_perhapsAddPrinter(printers, printerName, printerHost, printerComment,161 aliases);162 }163 164 int qt_parsePrintcap(QList<QPrinterDescription> *printers, const QString& fileName)165 {166 QFile printcap(fileName);167 if (!printcap.open(QIODevice::ReadOnly))168 return NotFound;169 170 char *line_ascii = new char[1025];171 line_ascii[1024] = '\0';172 173 QString printerDesc;174 bool atEnd = false;175 176 while (!atEnd) {177 if (printcap.atEnd() || printcap.readLine(line_ascii, 1024) <= 0)178 atEnd = true;179 QString line = QString::fromLocal8Bit(line_ascii);180 line = line.trimmed();181 if (line.length() >= 1 && line[int(line.length()) - 1] == QLatin1Char('\\'))182 line.chop(1);183 if (line[0] == QLatin1Char('#')) {184 if (!atEnd)185 continue;186 } else if (line[0] == QLatin1Char('|') || line[0] == QLatin1Char(':')187 || line.isEmpty()) {188 printerDesc += line;189 if (!atEnd)190 continue;191 }192 193 qt_parsePrinterDesc(printerDesc, printers);194 195 // add the first line of the new printer definition196 printerDesc = line;197 }198 delete[] line_ascii;199 return Success;200 }201 202 /*!203 \internal204 205 Checks $HOME/.printers for a line matching '_default <name>' (where206 <name> does not contain any white space). The first such match207 results in <name> being returned.208 If no lines match then an empty string is returned.209 */210 QString qt_getDefaultFromHomePrinters()211 {212 QFile file(QDir::homePath() + QLatin1String("/.printers"));213 if (!file.open(QIODevice::ReadOnly))214 return QString();215 QString all(QLatin1String(file.readAll()));216 QStringList words = all.split(QRegExp(QLatin1String("\\W+")), QString::SkipEmptyParts);217 const int i = words.indexOf(QLatin1String("_default"));218 if (i != -1 && i < words.size() - 1)219 return words.at(i + 1);220 return QString();221 }222 223 // solaris, not 2.6224 void qt_parseEtcLpPrinters(QList<QPrinterDescription> *printers)225 {226 QDir lp(QLatin1String("/etc/lp/printers"));227 QFileInfoList dirs = lp.entryInfoList();228 if (dirs.isEmpty())229 return;230 231 QString tmp;232 for (int i = 0; i < dirs.size(); ++i) {233 QFileInfo printer = dirs.at(i);234 if (printer.isDir()) {235 tmp.sprintf("/etc/lp/printers/%s/configuration",236 printer.fileName().toAscii().data());237 QFile configuration(tmp);238 char *line = new char[1025];239 QString remote(QLatin1String("Remote:"));240 QString contentType(QLatin1String("Content types:"));241 QString printerHost;242 bool canPrintPostscript = false;243 if (configuration.open(QIODevice::ReadOnly)) {244 while (!configuration.atEnd() &&245 configuration.readLine(line, 1024) > 0) {246 if (QString::fromLatin1(line).startsWith(remote)) {247 const char *p = line;248 while (*p != ':')249 p++;250 p++;251 while (isspace((uchar) *p))252 p++;253 printerHost = QString::fromLocal8Bit(p);254 printerHost = printerHost.simplified();255 } else if (QString::fromLatin1(line).startsWith(contentType)) {256 char *p = line;257 while (*p != ':')258 p++;259 p++;260 char *e;261 while (*p) {262 while (isspace((uchar) *p))263 p++;264 if (*p) {265 char s;266 e = p;267 while (isalnum((uchar) *e))268 e++;269 s = *e;270 *e = '\0';271 if (!qstrcmp(p, "postscript") ||272 !qstrcmp(p, "any"))273 canPrintPostscript = true;274 *e = s;275 if (s == ',')276 e++;277 p = e;278 }279 }280 }281 }282 if (canPrintPostscript)283 qt_perhapsAddPrinter(printers, printer.fileName(),284 printerHost, QLatin1String(""));285 }286 delete[] line;287 }288 }289 }290 291 // solaris 2.6292 char *qt_parsePrintersConf(QList<QPrinterDescription> *printers, bool *found)293 {294 QFile pc(QLatin1String("/etc/printers.conf"));295 if (!pc.open(QIODevice::ReadOnly)) {296 if (found)297 *found = false;298 return 0;299 }300 if (found)301 *found = true;302 303 char *line = new char[1025];304 line[1024] = '\0';305 306 QString printerDesc;307 int lineLength = 0;308 309 char *defaultPrinter = 0;310 311 while (!pc.atEnd() &&312 (lineLength=pc.readLine(line, 1024)) > 0) {313 if (*line == '#') {314 *line = '\0';315 lineLength = 0;316 }317 if (lineLength >= 2 && line[lineLength-2] == '\\') {318 line[lineLength-2] = '\0';319 printerDesc += QString::fromLocal8Bit(line);320 } else {321 printerDesc += QString::fromLocal8Bit(line);322 printerDesc = printerDesc.simplified();323 int i = printerDesc.indexOf(QLatin1Char(':'));324 QString printerName, printerHost, printerComment;325 QStringList aliases;326 if (i >= 0) {327 // have : want |328 int j = printerDesc.indexOf(QLatin1Char('|'));329 if (j >= i)330 j = -1;331 printerName = printerDesc.mid(0, j < 0 ? i : j);332 if (printerName == QLatin1String("_default")) {333 i = printerDesc.indexOf(334 QRegExp(QLatin1String(": *use *=")));335 while (printerDesc[i] != QLatin1Char('='))336 i++;337 while (printerDesc[i] == QLatin1Char('=') || printerDesc[i].isSpace())338 i++;339 j = i;340 while (j < (int)printerDesc.length() &&341 printerDesc[j] != QLatin1Char(':') && printerDesc[j] != QLatin1Char(','))342 j++;343 // that's our default printer344 defaultPrinter =345 qstrdup(printerDesc.mid(i, j-i).toAscii().data());346 printerName = QString();347 printerDesc = QString();348 } else if (printerName == QLatin1String("_all")) {349 // skip it.. any other cases we want to skip?350 printerName = QString();351 printerDesc = QString();352 }353 354 if (j > 0) {355 // try extracting a comment from the aliases356 aliases = printerDesc.mid(j + 1, i - j - 1).split(QLatin1Char('|'));357 #ifndef QT_NO_PRINTDIALOG358 printerComment = QPrintDialog::tr("Aliases: %1")359 .arg(aliases.join(QLatin1String(", ")));360 #endif361 }362 // look for signs of this being a remote printer363 i = printerDesc.indexOf(364 QRegExp(QLatin1String(": *bsdaddr *=")));365 if (i >= 0) {366 // point k at the end of remote host name367 while (printerDesc[i] != QLatin1Char('='))368 i++;369 while (printerDesc[i] == QLatin1Char('=') || printerDesc[i].isSpace())370 i++;371 j = i;372 while (j < (int)printerDesc.length() &&373 printerDesc[j] != QLatin1Char(':') && printerDesc[j] != QLatin1Char(','))374 j++;375 // and stuff that into the string376 printerHost = printerDesc.mid(i, j-i);377 // maybe stick the remote printer name into the comment378 if (printerDesc[j] == QLatin1Char(',')) {379 i = ++j;380 while (printerDesc[i].isSpace())381 i++;382 j = i;383 while (j < (int)printerDesc.length() &&384 printerDesc[j] != QLatin1Char(':') && printerDesc[j] != QLatin1Char(','))385 j++;386 if (printerName != printerDesc.mid(i, j-i)) {387 printerComment =388 QLatin1String("Remote name: ");389 printerComment += printerDesc.mid(i, j-i);390 }391 }392 }393 }394 if (printerComment == QLatin1String(":"))395 printerComment = QString(); // for cups396 if (printerName.length())397 qt_perhapsAddPrinter(printers, printerName, printerHost,398 printerComment, aliases);399 // chop away the line, for processing the next one400 printerDesc = QString();401 }402 }403 delete[] line;404 return defaultPrinter;405 }406 407 #ifndef QT_NO_NIS408 409 #if defined(Q_C_CALLBACKS)410 extern "C" {411 #endif412 413 int qt_pd_foreach(int /*status */, char * /*key */, int /*keyLen */,414 char *val, int valLen, char *data)415 {416 qt_parsePrinterDesc(QString::fromLatin1(val, valLen), (QList<QPrinterDescription> *)data);417 return 0;418 }419 420 #if defined(Q_C_CALLBACKS)421 }422 #endif423 424 int qt_retrieveNisPrinters(QList<QPrinterDescription> *printers)425 {426 #ifndef QT_NO_LIBRARY427 typedef int (*WildCast)(int, char *, int, char *, int, char *);428 char printersConfByname[] = "printers.conf.byname";429 char *domain;430 int err;431 432 QLibrary lib(QLatin1String("nsl"));433 typedef int (*ypGetDefaultDomain)(char **);434 ypGetDefaultDomain _ypGetDefaultDomain = (ypGetDefaultDomain)lib.resolve("yp_get_default_domain");435 typedef int (*ypAll)(const char *, const char *, const struct ypall_callback *);436 ypAll _ypAll = (ypAll)lib.resolve("yp_all");437 438 if (_ypGetDefaultDomain && _ypAll) {439 err = _ypGetDefaultDomain(&domain);440 if (err == 0) {441 ypall_callback cb;442 // wild cast to support K&R-style system headers443 (WildCast &) cb.foreach = (WildCast) qt_pd_foreach;444 cb.data = (char *) printers;445 err = _ypAll(domain, printersConfByname, &cb);446 }447 if (!err)448 return Success;449 }450 #endif //QT_NO_LIBRARY451 return Unavail;452 }453 454 #endif // QT_NO_NIS455 456 char *qt_parseNsswitchPrintersEntry(QList<QPrinterDescription> *printers, char *line)457 {458 #define skipSpaces() \459 while (line[k] != '\0' && isspace((uchar) line[k])) \460 k++461 462 char *defaultPrinter = 0;463 bool stop = false;464 int lastStatus = NotFound;465 466 int k = 8;467 skipSpaces();468 if (line[k] != ':')469 return 0;470 k++;471 472 char *cp = strchr(line, '#');473 if (cp != 0)474 *cp = '\0';475 476 while (line[k] != '\0') {477 if (isspace((uchar) line[k])) {478 k++;479 } else if (line[k] == '[') {480 k++;481 skipSpaces();482 while (line[k] != '\0') {483 char status = tolower(line[k]);484 char action = '?';485 486 while (line[k] != '=' && line[k] != ']' && line[k] != '\0')487 k++;488 if (line[k] == '=') {489 k++;490 skipSpaces();491 action = tolower(line[k]);492 while (line[k] != '\0' && !isspace((uchar) line[k]) && line[k] != ']')493 k++;494 } else if (line[k] == ']') {495 k++;496 break;497 }498 skipSpaces();499 500 if (lastStatus == status)501 stop = (action == (char) Return);502 }503 } else {504 if (stop)505 break;506 507 QByteArray source;508 while (line[k] != '\0' && !isspace((uchar) line[k]) && line[k] != '[') {509 source += line[k];510 k++;511 }512 513 if (source == "user") {514 lastStatus = qt_parsePrintcap(printers,515 QDir::homePath() + QLatin1String("/.printers"));516 } else if (source == "files") {517 bool found;518 defaultPrinter = qt_parsePrintersConf(printers, &found);519 if (found)520 lastStatus = Success;521 #ifndef QT_NO_NIS522 } else if (source == "nis") {523 lastStatus = qt_retrieveNisPrinters(printers);524 #endif525 } else {526 // nisplus, dns, etc., are not implemented yet527 lastStatus = NotFound;528 }529 stop = (lastStatus == Success);530 }531 }532 return defaultPrinter;533 }534 535 char *qt_parseNsswitchConf(QList<QPrinterDescription> *printers)536 {537 QFile nc(QLatin1String("/etc/nsswitch.conf"));538 if (!nc.open(QIODevice::ReadOnly))539 return 0;540 541 char *defaultPrinter = 0;542 543 char *line = new char[1025];544 line[1024] = '\0';545 546 while (!nc.atEnd() &&547 nc.readLine(line, 1024) > 0) {548 if (qstrncmp(line, "printers", 8) == 0) {549 defaultPrinter = qt_parseNsswitchPrintersEntry(printers, line);550 delete[] line;551 return defaultPrinter;552 }553 }554 555 strcpy(line, "printers: user files nis nisplus xfn");556 defaultPrinter = qt_parseNsswitchPrintersEntry(printers, line);557 delete[] line;558 return defaultPrinter;559 }560 561 // HP-UX562 void qt_parseEtcLpMember(QList<QPrinterDescription> *printers)563 {564 QDir lp(QLatin1String("/etc/lp/member"));565 if (!lp.exists())566 return;567 QFileInfoList dirs = lp.entryInfoList();568 if (dirs.isEmpty())569 return;570 571 #ifdef QT_NO_PRINTDIALOG572 Q_UNUSED(printers);573 #else574 QString tmp;575 for (int i = 0; i < dirs.size(); ++i) {576 QFileInfo printer = dirs.at(i);577 // I haven't found any real documentation, so I'm guessing that578 // since lpstat uses /etc/lp/member rather than one of the579 // other directories, it's the one to use. I did not find a580 // decent way to locate aliases and remote printers.581 if (printer.isFile())582 qt_perhapsAddPrinter(printers, printer.fileName(),583 QPrintDialog::tr("unknown"),584 QLatin1String(""));585 }586 #endif587 }588 589 // IRIX 6.x590 void qt_parseSpoolInterface(QList<QPrinterDescription> *printers)591 {592 QDir lp(QLatin1String("/usr/spool/lp/interface"));593 if (!lp.exists())594 return;595 QFileInfoList files = lp.entryInfoList();596 if(files.isEmpty())597 return;598 599 for (int i = 0; i < files.size(); ++i) {600 QFileInfo printer = files.at(i);601 602 if (!printer.isFile())603 continue;604 605 // parse out some information606 QFile configFile(printer.filePath());607 if (!configFile.open(QIODevice::ReadOnly))608 continue;609 610 QByteArray line;611 line.resize(1025);612 QString namePrinter;613 QString hostName;614 QString hostPrinter;615 QString printerType;616 617 QString nameKey(QLatin1String("NAME="));618 QString typeKey(QLatin1String("TYPE="));619 QString hostKey(QLatin1String("HOSTNAME="));620 QString hostPrinterKey(QLatin1String("HOSTPRINTER="));621 622 while (!configFile.atEnd() &&623 (configFile.readLine(line.data(), 1024)) > 0) {624 QString uline = QString::fromLocal8Bit(line);625 if (uline.startsWith(typeKey) ) {626 printerType = uline.mid(nameKey.length());627 printerType = printerType.simplified();628 } else if (uline.startsWith(hostKey)) {629 hostName = uline.mid(hostKey.length());630 hostName = hostName.simplified();631 } else if (uline.startsWith(hostPrinterKey)) {632 hostPrinter = uline.mid(hostPrinterKey.length());633 hostPrinter = hostPrinter.simplified();634 } else if (uline.startsWith(nameKey)) {635 namePrinter = uline.mid(nameKey.length());636 namePrinter = namePrinter.simplified();637 }638 }639 configFile.close();640 641 printerType = printerType.trimmed();642 if (printerType.indexOf(QLatin1String("postscript"), 0, Qt::CaseInsensitive) < 0)643 continue;644 645 int ii = 0;646 while ((ii = namePrinter.indexOf(QLatin1Char('"'), ii)) >= 0)647 namePrinter.remove(ii, 1);648 649 if (hostName.isEmpty() || hostPrinter.isEmpty()) {650 qt_perhapsAddPrinter(printers, printer.fileName(),651 QLatin1String(""), namePrinter);652 } else {653 QString comment;654 comment = namePrinter;655 comment += QLatin1String(" (");656 comment += hostPrinter;657 comment += QLatin1Char(')');658 qt_perhapsAddPrinter(printers, printer.fileName(),659 hostName, comment);660 }661 }662 }663 664 665 // Every unix must have its own. It's a standard. Here is AIX.666 void qt_parseQconfig(QList<QPrinterDescription> *printers)667 {668 QFile qconfig(QLatin1String("/etc/qconfig"));669 if (!qconfig.open(QIODevice::ReadOnly))670 return;671 672 QTextStream ts(&qconfig);673 QString line;674 675 QString stanzaName; // either a queue or a device name676 bool up = true; // queue up? default true, can be false677 QString remoteHost; // null if local678 QString deviceName; // null if remote679 680 QRegExp newStanza(QLatin1String("^[0-z\\-]*:$"));681 682 // our basic strategy here is to process each line, detecting new683 // stanzas. each time we see a new stanza, we check if the684 // previous stanza was a valid queue for a) a remote printer or b)685 // a local printer. if it wasn't, we assume that what we see is686 // the start of the first stanza, or that the previous stanza was687 // a device stanza, or that there is some syntax error (we don't688 // report those).689 690 do {691 line = ts.readLine();692 bool indented = line[0].isSpace();693 line = line.simplified();694 695 int i = line.indexOf(QLatin1Char('='));696 if (indented && i != -1) { // line in stanza697 QString variable = line.left(i).simplified();698 QString value=line.mid(i+1, line.length()).simplified();699 if (variable == QLatin1String("device"))700 deviceName = value;701 else if (variable == QLatin1String("host"))702 remoteHost = value;703 else if (variable == QLatin1String("up"))704 up = !(value.toLower() == QLatin1String("false"));705 } else if (line[0] == QLatin1Char('*')) { // comment706 // nothing to do707 } else if (ts.atEnd() || // end of file, or beginning of new stanza708 (!indented && line.contains(newStanza))) {709 if (up && stanzaName.length() > 0 && stanzaName.length() < 21) {710 if (remoteHost.length()) // remote printer711 qt_perhapsAddPrinter(printers, stanzaName, remoteHost,712 QString());713 else if (deviceName.length()) // local printer714 qt_perhapsAddPrinter(printers, stanzaName, QString(),715 QString());716 }717 line.chop(1);718 if (line.length() >= 1 && line.length() <= 20)719 stanzaName = line;720 up = true;721 remoteHost.clear();722 deviceName.clear();723 } else {724 // syntax error? ignore.725 }726 } while (!ts.atEnd());727 }728 729 int qt_getLprPrinters(QList<QPrinterDescription>& printers)730 {731 QByteArray etcLpDefault;732 qt_parsePrintcap(&printers, QLatin1String("/etc/printcap"));733 qt_parseEtcLpMember(&printers);734 qt_parseSpoolInterface(&printers);735 qt_parseQconfig(&printers);736 737 QFileInfo f;738 f.setFile(QLatin1String("/etc/lp/printers"));739 if (f.isDir()) {740 qt_parseEtcLpPrinters(&printers);741 QFile def(QLatin1String("/etc/lp/default"));742 if (def.open(QIODevice::ReadOnly)) {743 etcLpDefault.resize(1025);744 if (def.readLine(etcLpDefault.data(), 1024) > 0) {745 QRegExp rx(QLatin1String("^(\\S+)"));746 if (rx.indexIn(QString::fromLatin1(etcLpDefault)) != -1)747 etcLpDefault = rx.cap(1).toAscii();748 }749 }750 }751 752 char *def = 0;753 f.setFile(QLatin1String("/etc/nsswitch.conf"));754 if (f.isFile()) {755 def = qt_parseNsswitchConf(&printers);756 } else {757 f.setFile(QLatin1String("/etc/printers.conf"));758 if (f.isFile())759 def = qt_parsePrintersConf(&printers);760 }761 762 if (def) {763 etcLpDefault = def;764 delete [] def;765 }766 767 QString homePrintersDefault = qt_getDefaultFromHomePrinters();768 769 // all printers hopefully known. try to find a good default770 QString dollarPrinter;771 {772 dollarPrinter = QString::fromLocal8Bit(qgetenv("PRINTER"));773 if (dollarPrinter.isEmpty())774 dollarPrinter = QString::fromLocal8Bit(qgetenv("LPDEST"));775 if (dollarPrinter.isEmpty())776 dollarPrinter = QString::fromLocal8Bit(qgetenv("NPRINTER"));777 if (dollarPrinter.isEmpty())778 dollarPrinter = QString::fromLocal8Bit(qgetenv("NGPRINTER"));779 #ifndef QT_NO_PRINTDIALOG780 if (!dollarPrinter.isEmpty())781 qt_perhapsAddPrinter(&printers, dollarPrinter,782 QPrintDialog::tr("unknown"),783 QLatin1String(""));784 #endif785 }786 787 int quality = 0;788 int best = 0;789 for (int i = 0; i < printers.size(); ++i) {790 QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)"));791 QRegExp lp(QLatin1String("[^a-z]lp(?:[^a-z]|$)"));792 793 QString name = printers.at(i).name;794 QString comment = printers.at(i).comment;795 if (quality < 5 && name == dollarPrinter) {796 best = i;797 quality = 5;798 } else if (quality < 4 && !homePrintersDefault.isEmpty() &&799 name == homePrintersDefault) {800 best = i;801 quality = 4;802 } else if (quality < 3 && !etcLpDefault.isEmpty() &&803 name == QLatin1String(etcLpDefault)) {804 best = i;805 quality = 3;806 } else if (quality < 2 &&807 (name == QLatin1String("ps") ||808 ps.indexIn(comment) != -1)) {809 best = i;810 quality = 2;811 } else if (quality < 1 &&812 (name == QLatin1String("lp") ||813 lp.indexIn(comment) > -1)) {814 best = i;815 quality = 1;816 }817 }818 819 return best;820 }821 822 /////////////////////////////////////////////////////////////////////////////823 /////////////////////////////////////////////////////////////////////////////824 825 93 QList<QPrinterInfo> QPrinterInfo::availablePrinters() 826 94 { 827 95 QList<QPrinterInfo> list; 828 96 829 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)97 #if !defined(QT_NO_CUPS) 830 98 QCUPSSupport cups; 831 99 if (QCUPSSupport::isAvailable()) { … … 843 111 list[i].d_ptr->m_cupsPrinterIndex = i; 844 112 } 845 } else {846 #endif847 QList<QPrinterDescription> lprPrinters;848 int defprn = qt_getLprPrinters(lprPrinters);849 // populating printer combo850 QList<QPrinterDescription>::const_iterator i = lprPrinters.constBegin();851 for(; i != lprPrinters.constEnd(); ++i) {852 list.append(QPrinterInfo((*i).name));853 }854 if (defprn >= 0 && defprn < lprPrinters.size()) {855 list[defprn].d_ptr->m_default = true;856 }857 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)858 113 } 859 114 #endif … … 890 145 d->q_ptr = this; 891 146 892 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)147 #if !defined(QT_NO_CUPS) 893 148 QCUPSSupport cups; 894 149 if (QCUPSSupport::isAvailable()) { … … 907 162 } 908 163 } 909 } else {910 #endif911 QList<QPrinterDescription> lprPrinters;912 int defprn = qt_getLprPrinters(lprPrinters);913 // populating printer combo914 QList<QPrinterDescription>::const_iterator i = lprPrinters.constBegin();915 int c;916 for(c = 0; i != lprPrinters.constEnd(); ++i, ++c) {917 if (i->name == printer.printerName()) {918 if (defprn == c)919 d->m_default = true;920 return;921 }922 }923 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)924 164 } 925 165 #endif … … 971 211 d->m_mustGetPaperSizes = false; 972 212 973 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)213 #if !defined(QT_NO_CUPS) 974 214 QCUPSSupport cups; 975 215 if (QCUPSSupport::isAvailable()) {
Note:
See TracChangeset
for help on using the changeset viewer.