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