diff options
Diffstat (limited to 'src/printsupport/dialogs/qprintdialog_unix.cpp')
-rw-r--r-- | src/printsupport/dialogs/qprintdialog_unix.cpp | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index b96d8dfd22..9b08ffe4df 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -653,18 +659,16 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter * widget.setupUi(parent); int currentPrinterIndex = 0; - QStringList printers; - QString defaultPrinter; QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); if (ps) { - printers = ps->availablePrintDeviceIds(); - defaultPrinter = ps->defaultPrintDeviceId(); - } + const QStringList printers = ps->availablePrintDeviceIds(); + const QString defaultPrinter = ps->defaultPrintDeviceId(); + + widget.printers->addItems(printers); - for (int i = 0; i < printers.size(); ++i) { - widget.printers->addItem(printers.at(i)); - if (printers.at(i) == defaultPrinter) - currentPrinterIndex = i; + const int idx = printers.indexOf(defaultPrinter); + if (idx >= 0) + currentPrinterIndex = idx; } widget.properties->setEnabled(true); @@ -819,12 +823,9 @@ void QUnixPrintWidgetPrivate::applyPrinterProperties() widget.filename->setText( printer->outputFileName() ); QString printerName = printer->printerName(); if (!printerName.isEmpty()) { - for (int i = 0; i < widget.printers->count(); ++i) { - if (widget.printers->itemText(i) == printerName) { - widget.printers->setCurrentIndex(i); - break; - } - } + const int i = widget.printers->findText(printerName); + if (i >= 0) + widget.printers->setCurrentIndex(i); } // PDF printer not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget |