Set currently selected printer to QCUPSSupport in PageSetupWidget

Also adds new method to allows setting a printer in QCUPSSupport by
printer name.

Change-Id: Iff7a88d95eab9de2c96872c45b12e708207bda16
Reviewed-by: John Layt <jlayt@kde.org>
This commit is contained in:
Martin Klapetek 2013-10-18 17:31:46 +02:00 committed by The Qt Project
parent 229d92dc1e
commit fcedf4073a
3 changed files with 13 additions and 0 deletions

View File

@ -408,6 +408,7 @@ void QPageSetupWidget::selectPrinter()
if (QCUPSSupport::isAvailable()) {
m_cups = true;
QCUPSSupport cups;
cups.setCurrentPrinter(m_printer->printerName());
const ppd_option_t* pageSizes = cups.pageSizes();
const int numChoices = pageSizes ? pageSizes->num_choices : 0;

View File

@ -215,6 +215,17 @@ const ppd_file_t* QCUPSSupport::setCurrentPrinter(int index)
return currPPD;
}
const ppd_file_t* QCUPSSupport::setCurrentPrinter(const QString &printerName)
{
Q_FOREACH (const QCUPSSupport::Printer &printer, QCUPSSupport::availableUnixPrinters()) {
if (printer.name == printerName) {
return setCurrentPrinter(printer.cupsPrinterIndex);
}
}
return 0;
}
int QCUPSSupport::currentPrinterIndex() const
{
return currPrinterIndex;

View File

@ -149,6 +149,7 @@ public:
const cups_dest_t* availablePrinters() const;
int currentPrinterIndex() const;
const ppd_file_t* setCurrentPrinter(int index);
const ppd_file_t* setCurrentPrinter(const QString &printerName);
const ppd_file_t* currentPPD() const;
const ppd_option_t* ppdOption(const char *key) const;