From 80f7a388906f94f58bf765a32b9abbb16f967db2 Mon Sep 17 00:00:00 2001 From: John Layt Date: Sun, 29 Apr 2012 14:13:10 +0100 Subject: QtPrintSupport: Remove remaining LPR specific code CUPS is the only supported print system on UNIX, LPR/PS support has already been dropped but some LPR specific code still remains. * Move qt_getCupsPrinterPaperSizes from qprinterinfo_unix to QCUPSSupport * Remove qprinterinfo_unix as no longer used * Remove LPR related code from QPdfPrintEngine * Remove all QT_NO_LPR uses * Remove most QT_NO_CUPS uses, use QT_NO_PRINTER where necessary Some QT_NO_CUPS uses remain in QPdfPrintEngine, these will be removed in a following change implementing a CUPS plugin. Change-Id: I439b6fad9cf88c3d24aa48e49475f49ad310dbad Reviewed-by: Lars Knoll --- src/printsupport/dialogs/qprintdialog_unix.cpp | 88 ++------------------------ 1 file changed, 6 insertions(+), 82 deletions(-) (limited to 'src/printsupport/dialogs/qprintdialog_unix.cpp') diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index f7689c1620..4ba04be9ec 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -60,15 +60,8 @@ #include "ui_qprintsettingsoutput.h" #include "ui_qprintwidget.h" -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) -# include -# include -# include -#else -# include -#endif - -#include +#include +#include QT_BEGIN_NAMESPACE @@ -82,10 +75,8 @@ public: QPrintPropertiesDialog(QAbstractPrintDialog *parent = 0); ~QPrintPropertiesDialog(); -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) void setCups(QCUPSSupport *cups) { m_cups = cups; } void addItemToOptions(QOptionTreeItem *parent, QList& options, QList& markedOptions) const; -#endif void selectPrinter(); void selectPdfPsPrinter(const QPrinter *p); @@ -100,10 +91,8 @@ protected: private: Ui::QPrintPropertiesWidget widget; QDialogButtonBox *m_buttons; -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) QCUPSSupport *m_cups; QPPDOptionsModel *m_cupsOptionsModel; -#endif }; class QPrintDialogPrivate : public QAbstractPrintDialogPrivate @@ -118,9 +107,7 @@ public: /// copy printer properties to the widget void applyPrinterProperties(QPrinter *p); -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) void selectPrinter(QCUPSSupport *cups); -#endif void _q_chbPrintLastFirstToggled(bool); #ifndef QT_NO_MESSAGEBOX @@ -151,9 +138,7 @@ public: bool checkFields(); void setupPrinter(); void setOptionsPane(QPrintDialogPrivate *pane); -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) void setCupsProperties(); -#endif // slots void _q_printerChanged(int index); @@ -165,21 +150,17 @@ public: Ui::QPrintWidget widget; QAbstractPrintDialog * q; QPrinter *printer; - QList lprPrinters; void updateWidget(); private: QPrintDialogPrivate *optionsPane; bool filePrintersAdded; -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) QCUPSSupport* cups; int cupsPrinterCount; const cups_dest_t* cupsPrinters; const ppd_file_t* cupsPPD; -#endif }; -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) class QOptionTreeItem { public: @@ -249,15 +230,10 @@ private slots: }; -#endif - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent) - : QDialog(parent) -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) - , m_cups(0), m_cupsOptionsModel(0) -#endif + : QDialog(parent), m_cups(0), m_cupsOptionsModel(0) { QVBoxLayout *lay = new QVBoxLayout(this); this->setLayout(lay); @@ -273,11 +249,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent) QPrintPropertiesDialog::~QPrintPropertiesDialog() { -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) delete m_cupsOptionsModel; -#else - delete widget.cupsPropertiesPage; -#endif } void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p) @@ -289,7 +261,6 @@ void QPrintPropertiesDialog::setupPrinter() const { widget.pageSetup->setupPrinter(); -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) QPPDOptionsModel* model = static_cast(widget.treeView->model()); if (model) { QOptionTreeItem* rootItem = model->rootItem; @@ -299,12 +270,10 @@ void QPrintPropertiesDialog::setupPrinter() const addItemToOptions(rootItem, options, markedOptions); model->cups->saveOptions(options, markedOptions); } -#endif } void QPrintPropertiesDialog::selectPrinter() { -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) widget.pageSetup->selectPrinter(m_cups); widget.treeView->setModel(0); if (m_cups && QCUPSSupport::isAvailable()) { @@ -329,9 +298,7 @@ void QPrintPropertiesDialog::selectPrinter() widget.tabs->setTabEnabled(1, false); } - } else -#endif - { + } else { widget.cupsPropertiesPage->setEnabled(false); widget.pageSetup->selectPrinter(0); } @@ -350,7 +317,6 @@ void QPrintPropertiesDialog::showEvent(QShowEvent* event) event->accept(); } -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) void QPrintPropertiesDialog::addItemToOptions(QOptionTreeItem *parent, QList& options, QList& markedOptions) const { for (int i = 0; i < parent->childItems.count(); ++i) { @@ -366,7 +332,6 @@ void QPrintPropertiesDialog::addItemToOptions(QOptionTreeItem *parent, QList &tabWidgets) } } -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups) { options.duplex->setEnabled(cups && cups->ppdOption("Duplex")); } -#endif //////////////////////////////////////////////////////////////////////////////// @@ -630,10 +593,8 @@ void QPrintDialog::accept() /*! \internal */ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p) - : parent(p), propertiesDialog(0), printer(0), optionsPane(0), filePrintersAdded(false) -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) - , cups(0), cupsPrinterCount(0), cupsPrinters(0), cupsPPD(0) -#endif + : parent(p), propertiesDialog(0), printer(0), optionsPane(0), filePrintersAdded(false), + cups(0), cupsPrinterCount(0), cupsPrinters(0), cupsPPD(0) { q = 0; if (parent) @@ -642,7 +603,6 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p) widget.setupUi(parent); int currentPrinterIndex = 0; -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) cups = new QCUPSSupport; if (QCUPSSupport::isAvailable()) { cupsPPD = cups->currentPPD(); @@ -664,16 +624,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p) widget.properties->setEnabled(true); } currentPrinterIndex = cups->currentPrinterIndex(); - } else { -#endif - currentPrinterIndex = qt_getLprPrinters(lprPrinters); - // populating printer combo - QList::const_iterator i = lprPrinters.constBegin(); - for(; i != lprPrinters.constEnd(); ++i) - widget.printers->addItem((*i).name); -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) } -#endif #if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER) QFileSystemModel *fsm = new QFileSystemModel(widget.filename); @@ -725,9 +676,7 @@ void QUnixPrintWidgetPrivate::updateWidget() QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate() { -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) delete cups; -#endif } void QUnixPrintWidgetPrivate::_q_printerChanged(int index) @@ -751,16 +700,13 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index) widget.lOutput->setEnabled(true); if (propertiesDialog) propertiesDialog->selectPdfPsPrinter(printer); -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) if (optionsPane) optionsPane->selectPrinter(0); -#endif return; } } widget.location->setText(QString()); -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) if (QCUPSSupport::isAvailable()) { cups->setCurrentPrinter(index); @@ -780,21 +726,7 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index) propertiesDialog->selectPrinter(); if (optionsPane) optionsPane->selectPrinter(cups); - } else { - if (optionsPane) - optionsPane->selectPrinter(0); -#endif - if (lprPrinters.count() > 0) { - QString type = lprPrinters.at(index).name + QLatin1Char('@') + lprPrinters.at(index).host; - if (!lprPrinters.at(index).comment.isEmpty()) - type += QLatin1String(", ") + lprPrinters.at(index).comment; - widget.type->setText(type); - if (propertiesDialog) - propertiesDialog->selectPrinter(); - } -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) } -#endif } void QUnixPrintWidgetPrivate::setOptionsPane(QPrintDialogPrivate *pane) @@ -908,9 +840,7 @@ void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() } if (propertiesDialog->result() == QDialog::Rejected) { -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) propertiesDialog->setCups(cups); -#endif propertiesDialog->applyPrinterProperties(q->printer()); if (q->isOptionEnabled(QPrintDialog::PrintToFile) @@ -922,7 +852,6 @@ void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() propertiesDialog->exec(); } -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) void QUnixPrintWidgetPrivate::setCupsProperties() { if (cups && QCUPSSupport::isAvailable() && cups->pageSizes()) { @@ -949,7 +878,6 @@ void QUnixPrintWidgetPrivate::setCupsProperties() } } } -#endif void QUnixPrintWidgetPrivate::setupPrinter() { @@ -972,10 +900,8 @@ void QUnixPrintWidgetPrivate::setupPrinter() if (propertiesDialog && propertiesDialog->result() == QDialog::Accepted) propertiesDialog->setupPrinter(); -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) if (!propertiesDialog) setCupsProperties(); -#endif } @@ -1004,7 +930,6 @@ void QUnixPrintWidget::updatePrinter() } //////////////////////////////////////////////////////////////////////////////// -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) QPPDOptionsModel::QPPDOptionsModel(QCUPSSupport *c, QObject *parent) : QAbstractItemModel(parent), rootItem(0), cups(c), ppd(c->currentPPD()) @@ -1244,7 +1169,6 @@ void QPPDOptionsEditor::cbChanged(int) */ } -#endif // !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) #endif // defined (Q_OS_UNIX) QT_END_NAMESPACE -- cgit v1.2.3