| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/printsupport/widgets/qcupsjobwidget.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtPrintSupport module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | - | |||||||||||||
| 35 | #include "qcupsjobwidget_p.h" | - | ||||||||||||
| 36 | - | |||||||||||||
| 37 | #include <QCheckBox> | - | ||||||||||||
| 38 | #include <QDateTime> | - | ||||||||||||
| 39 | #include <QFontDatabase> | - | ||||||||||||
| 40 | #include <QLabel> | - | ||||||||||||
| 41 | #include <QLayout> | - | ||||||||||||
| 42 | #include <QTime> | - | ||||||||||||
| 43 | #include <QTableWidget> | - | ||||||||||||
| 44 | #include <QTableWidgetItem> | - | ||||||||||||
| 45 | #include <QHeaderView> | - | ||||||||||||
| 46 | #include <QPrinter> | - | ||||||||||||
| 47 | #include <QPrintEngine> | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | #if !defined(QT_NO_PRINTER) && !defined(QT_NO_CUPS) | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | /*! | - | ||||||||||||
| 54 | \internal | - | ||||||||||||
| 55 | \class QCupsJobWidget | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | A widget to add to QPrintDialog to enable extra CUPS options | - | ||||||||||||
| 58 | such as Job Scheduling, Job Priority or Job Billing | - | ||||||||||||
| 59 | \ingroup printing | - | ||||||||||||
| 60 | \inmodule QtPrintSupport | - | ||||||||||||
| 61 | */ | - | ||||||||||||
| 62 | - | |||||||||||||
| 63 | QCupsJobWidget::QCupsJobWidget(QWidget *parent) | - | ||||||||||||
| 64 | : QWidget(parent) | - | ||||||||||||
| 65 | { | - | ||||||||||||
| 66 | m_ui.setupUi(this); | - | ||||||||||||
| 67 | //set all the default values | - | ||||||||||||
| 68 | //TODO restore last used values | - | ||||||||||||
| 69 | initJobHold(); | - | ||||||||||||
| 70 | initJobBilling(); | - | ||||||||||||
| 71 | initJobPriority(); | - | ||||||||||||
| 72 | initBannerPages(); | - | ||||||||||||
| 73 | } never executed: end of block | 0 | ||||||||||||
| 74 | - | |||||||||||||
| 75 | QCupsJobWidget::~QCupsJobWidget() | - | ||||||||||||
| 76 | { | - | ||||||||||||
| 77 | } | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | void QCupsJobWidget::setPrinter(QPrinter *printer) | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | m_printer = printer; | - | ||||||||||||
| 82 | } never executed: end of block | 0 | ||||||||||||
| 83 | - | |||||||||||||
| 84 | void QCupsJobWidget::setupPrinter() | - | ||||||||||||
| 85 | { | - | ||||||||||||
| 86 | QCUPSSupport::setJobHold(m_printer, jobHold(), jobHoldTime()); | - | ||||||||||||
| 87 | QCUPSSupport::setJobBilling(m_printer, jobBilling()); | - | ||||||||||||
| 88 | QCUPSSupport::setJobPriority(m_printer, jobPriority()); | - | ||||||||||||
| 89 | QCUPSSupport::setBannerPages(m_printer, startBannerPage(), endBannerPage()); | - | ||||||||||||
| 90 | } never executed: end of block | 0 | ||||||||||||
| 91 | - | |||||||||||||
| 92 | void QCupsJobWidget::initJobHold() | - | ||||||||||||
| 93 | { | - | ||||||||||||
| 94 | m_ui.jobHoldComboBox->addItem(tr("Print Immediately"), QVariant::fromValue(QCUPSSupport::NoHold)); | - | ||||||||||||
| 95 | m_ui.jobHoldComboBox->addItem(tr("Hold Indefinitely"), QVariant::fromValue(QCUPSSupport::Indefinite)); | - | ||||||||||||
| 96 | m_ui.jobHoldComboBox->addItem(tr("Day (06:00 to 17:59)"), QVariant::fromValue(QCUPSSupport::DayTime)); | - | ||||||||||||
| 97 | m_ui.jobHoldComboBox->addItem(tr("Night (18:00 to 05:59)"), QVariant::fromValue(QCUPSSupport::Night)); | - | ||||||||||||
| 98 | m_ui.jobHoldComboBox->addItem(tr("Second Shift (16:00 to 23:59)"), QVariant::fromValue(QCUPSSupport::SecondShift)); | - | ||||||||||||
| 99 | m_ui.jobHoldComboBox->addItem(tr("Third Shift (00:00 to 07:59)"), QVariant::fromValue(QCUPSSupport::ThirdShift)); | - | ||||||||||||
| 100 | m_ui.jobHoldComboBox->addItem(tr("Weekend (Saturday to Sunday)"), QVariant::fromValue(QCUPSSupport::Weekend)); | - | ||||||||||||
| 101 | m_ui.jobHoldComboBox->addItem(tr("Specific Time"), QVariant::fromValue(QCUPSSupport::SpecificTime)); | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | connect(m_ui.jobHoldComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleJobHoldTime())); | - | ||||||||||||
| 104 | - | |||||||||||||
| 105 | setJobHold(QCUPSSupport::NoHold, QTime()); | - | ||||||||||||
| 106 | toggleJobHoldTime(); | - | ||||||||||||
| 107 | } never executed: end of block | 0 | ||||||||||||
| 108 | - | |||||||||||||
| 109 | void QCupsJobWidget::setJobHold(QCUPSSupport::JobHoldUntil jobHold, const QTime &holdUntilTime) | - | ||||||||||||
| 110 | { | - | ||||||||||||
| 111 | if (jobHold == QCUPSSupport::SpecificTime && holdUntilTime.isNull()) {
| 0 | ||||||||||||
| 112 | jobHold = QCUPSSupport::NoHold; | - | ||||||||||||
| 113 | toggleJobHoldTime(); | - | ||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||
| 115 | m_ui.jobHoldComboBox->setCurrentIndex(m_ui.jobHoldComboBox->findData(QVariant::fromValue(jobHold))); | - | ||||||||||||
| 116 | m_ui.jobHoldTimeEdit->setTime(holdUntilTime); | - | ||||||||||||
| 117 | } never executed: end of block | 0 | ||||||||||||
| 118 | - | |||||||||||||
| 119 | QCUPSSupport::JobHoldUntil QCupsJobWidget::jobHold() const | - | ||||||||||||
| 120 | { | - | ||||||||||||
| 121 | return m_ui.jobHoldComboBox->itemData(m_ui.jobHoldComboBox->currentIndex()).value<QCUPSSupport::JobHoldUntil>(); never executed: return m_ui.jobHoldComboBox->itemData(m_ui.jobHoldComboBox->currentIndex()).value<QCUPSSupport::JobHoldUntil>(); | 0 | ||||||||||||
| 122 | } | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | void QCupsJobWidget::toggleJobHoldTime() | - | ||||||||||||
| 125 | { | - | ||||||||||||
| 126 | if (jobHold() == QCUPSSupport::SpecificTime)
| 0 | ||||||||||||
| 127 | m_ui.jobHoldTimeEdit->setEnabled(true); never executed: m_ui.jobHoldTimeEdit->setEnabled(true); | 0 | ||||||||||||
| 128 | else | - | ||||||||||||
| 129 | m_ui.jobHoldTimeEdit->setEnabled(false); never executed: m_ui.jobHoldTimeEdit->setEnabled(false); | 0 | ||||||||||||
| 130 | } | - | ||||||||||||
| 131 | - | |||||||||||||
| 132 | QTime QCupsJobWidget::jobHoldTime() const | - | ||||||||||||
| 133 | { | - | ||||||||||||
| 134 | return m_ui.jobHoldTimeEdit->time(); never executed: return m_ui.jobHoldTimeEdit->time(); | 0 | ||||||||||||
| 135 | } | - | ||||||||||||
| 136 | - | |||||||||||||
| 137 | void QCupsJobWidget::initJobBilling() | - | ||||||||||||
| 138 | { | - | ||||||||||||
| 139 | setJobBilling(QString()); | - | ||||||||||||
| 140 | } never executed: end of block | 0 | ||||||||||||
| 141 | - | |||||||||||||
| 142 | void QCupsJobWidget::setJobBilling(const QString &jobBilling) | - | ||||||||||||
| 143 | { | - | ||||||||||||
| 144 | m_ui.jobBillingLineEdit->insert(jobBilling); | - | ||||||||||||
| 145 | } never executed: end of block | 0 | ||||||||||||
| 146 | - | |||||||||||||
| 147 | QString QCupsJobWidget::jobBilling() const | - | ||||||||||||
| 148 | { | - | ||||||||||||
| 149 | return m_ui.jobBillingLineEdit->text(); never executed: return m_ui.jobBillingLineEdit->text(); | 0 | ||||||||||||
| 150 | } | - | ||||||||||||
| 151 | - | |||||||||||||
| 152 | void QCupsJobWidget::initJobPriority() | - | ||||||||||||
| 153 | { | - | ||||||||||||
| 154 | setJobPriority(50); | - | ||||||||||||
| 155 | } never executed: end of block | 0 | ||||||||||||
| 156 | - | |||||||||||||
| 157 | void QCupsJobWidget::setJobPriority(int jobPriority) | - | ||||||||||||
| 158 | { | - | ||||||||||||
| 159 | m_ui.jobPrioritySpinBox->setValue(jobPriority); | - | ||||||||||||
| 160 | } never executed: end of block | 0 | ||||||||||||
| 161 | - | |||||||||||||
| 162 | int QCupsJobWidget::jobPriority() const | - | ||||||||||||
| 163 | { | - | ||||||||||||
| 164 | return m_ui.jobPrioritySpinBox->value(); never executed: return m_ui.jobPrioritySpinBox->value(); | 0 | ||||||||||||
| 165 | } | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | void QCupsJobWidget::initBannerPages() | - | ||||||||||||
| 168 | { | - | ||||||||||||
| 169 | m_ui.startBannerPageCombo->addItem(tr("None", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::NoBanner)); | - | ||||||||||||
| 170 | m_ui.startBannerPageCombo->addItem(tr("Standard", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Standard)); | - | ||||||||||||
| 171 | m_ui.startBannerPageCombo->addItem(tr("Unclassified", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Unclassified)); | - | ||||||||||||
| 172 | m_ui.startBannerPageCombo->addItem(tr("Confidential", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Confidential)); | - | ||||||||||||
| 173 | m_ui.startBannerPageCombo->addItem(tr("Classified", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Classified)); | - | ||||||||||||
| 174 | m_ui.startBannerPageCombo->addItem(tr("Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Secret)); | - | ||||||||||||
| 175 | m_ui.startBannerPageCombo->addItem(tr("Top Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::TopSecret)); | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | m_ui.endBannerPageCombo->addItem(tr("None", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::NoBanner)); | - | ||||||||||||
| 178 | m_ui.endBannerPageCombo->addItem(tr("Standard", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Standard)); | - | ||||||||||||
| 179 | m_ui.endBannerPageCombo->addItem(tr("Unclassified", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Unclassified)); | - | ||||||||||||
| 180 | m_ui.endBannerPageCombo->addItem(tr("Confidential", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Confidential)); | - | ||||||||||||
| 181 | m_ui.endBannerPageCombo->addItem(tr("Classified", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Classified)); | - | ||||||||||||
| 182 | m_ui.endBannerPageCombo->addItem(tr("Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Secret)); | - | ||||||||||||
| 183 | m_ui.endBannerPageCombo->addItem(tr("Top Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::TopSecret)); | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | setStartBannerPage(QCUPSSupport::NoBanner); | - | ||||||||||||
| 186 | setEndBannerPage(QCUPSSupport::NoBanner); | - | ||||||||||||
| 187 | } never executed: end of block | 0 | ||||||||||||
| 188 | - | |||||||||||||
| 189 | void QCupsJobWidget::setStartBannerPage(const QCUPSSupport::BannerPage bannerPage) | - | ||||||||||||
| 190 | { | - | ||||||||||||
| 191 | m_ui.startBannerPageCombo->setCurrentIndex(m_ui.startBannerPageCombo->findData(QVariant::fromValue(bannerPage))); | - | ||||||||||||
| 192 | } never executed: end of block | 0 | ||||||||||||
| 193 | - | |||||||||||||
| 194 | QCUPSSupport::BannerPage QCupsJobWidget::startBannerPage() const | - | ||||||||||||
| 195 | { | - | ||||||||||||
| 196 | return m_ui.startBannerPageCombo->itemData(m_ui.startBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>(); never executed: return m_ui.startBannerPageCombo->itemData(m_ui.startBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>(); | 0 | ||||||||||||
| 197 | } | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | void QCupsJobWidget::setEndBannerPage(const QCUPSSupport::BannerPage bannerPage) | - | ||||||||||||
| 200 | { | - | ||||||||||||
| 201 | m_ui.endBannerPageCombo->setCurrentIndex(m_ui.endBannerPageCombo->findData(QVariant::fromValue(bannerPage))); | - | ||||||||||||
| 202 | } never executed: end of block | 0 | ||||||||||||
| 203 | - | |||||||||||||
| 204 | QCUPSSupport::BannerPage QCupsJobWidget::endBannerPage() const | - | ||||||||||||
| 205 | { | - | ||||||||||||
| 206 | return m_ui.endBannerPageCombo->itemData(m_ui.endBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>(); never executed: return m_ui.endBannerPageCombo->itemData(m_ui.endBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>(); | 0 | ||||||||||||
| 207 | } | - | ||||||||||||
| 208 | - | |||||||||||||
| 209 | #endif // QT_NO_PRINTER / QT_NO_CUPS | - | ||||||||||||
| 210 | - | |||||||||||||
| 211 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |