| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/printsupport/kernel/qprintdevice.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2014 John Layt <jlayt@kde.org> | - | ||||||||||||
| 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 | #include "qprintdevice_p.h" | - | ||||||||||||
| 41 | #include "qplatformprintdevice.h" | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | #include <private/qdebug_p.h> | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | #ifndef QT_NO_PRINTER | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | QPrintDevice::QPrintDevice() | - | ||||||||||||
| 50 | : d(new QPlatformPrintDevice()) | - | ||||||||||||
| 51 | { | - | ||||||||||||
| 52 | } executed 144 times by 3 tests: end of blockExecuted by:
| 144 | ||||||||||||
| 53 | - | |||||||||||||
| 54 | QPrintDevice::QPrintDevice(const QString &id) | - | ||||||||||||
| 55 | : d(new QPlatformPrintDevice(id)) | - | ||||||||||||
| 56 | { | - | ||||||||||||
| 57 | } never executed: end of block | 0 | ||||||||||||
| 58 | - | |||||||||||||
| 59 | QPrintDevice::QPrintDevice(QPlatformPrintDevice *dd) | - | ||||||||||||
| 60 | : d(dd) | - | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||
| 63 | - | |||||||||||||
| 64 | QPrintDevice::QPrintDevice(const QPrintDevice &other) | - | ||||||||||||
| 65 | : d(other.d) | - | ||||||||||||
| 66 | { | - | ||||||||||||
| 67 | } executed 136 times by 2 tests: end of blockExecuted by:
| 136 | ||||||||||||
| 68 | - | |||||||||||||
| 69 | QPrintDevice::~QPrintDevice() | - | ||||||||||||
| 70 | { | - | ||||||||||||
| 71 | } | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | QPrintDevice &QPrintDevice::operator=(const QPrintDevice &other) | - | ||||||||||||
| 74 | { | - | ||||||||||||
| 75 | d = other.d; | - | ||||||||||||
| 76 | return *this; never executed: return *this; | 0 | ||||||||||||
| 77 | } | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | bool QPrintDevice::operator==(const QPrintDevice &other) const | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | if (d && other.d)
| 0 | ||||||||||||
| 82 | return d->id() == other.d->id(); never executed: return d->id() == other.d->id(); | 0 | ||||||||||||
| 83 | return d == other.d; never executed: return d == other.d; | 0 | ||||||||||||
| 84 | } | - | ||||||||||||
| 85 | - | |||||||||||||
| 86 | QString QPrintDevice::id() const | - | ||||||||||||
| 87 | { | - | ||||||||||||
| 88 | return isValid() ? d->id() : QString(); executed 6 times by 2 tests: return isValid() ? d->id() : QString();Executed by:
| 6 | ||||||||||||
| 89 | } | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 | QString QPrintDevice::name() const | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | return isValid() ? d->name() : QString(); never executed: return isValid() ? d->name() : QString(); | 0 | ||||||||||||
| 94 | } | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 | QString QPrintDevice::location() const | - | ||||||||||||
| 97 | { | - | ||||||||||||
| 98 | return isValid() ? d->location() : QString(); executed 4 times by 1 test: return isValid() ? d->location() : QString();Executed by:
| 4 | ||||||||||||
| 99 | } | - | ||||||||||||
| 100 | - | |||||||||||||
| 101 | QString QPrintDevice::makeAndModel() const | - | ||||||||||||
| 102 | { | - | ||||||||||||
| 103 | return isValid() ? d->makeAndModel() : QString(); executed 4 times by 1 test: return isValid() ? d->makeAndModel() : QString();Executed by:
| 4 | ||||||||||||
| 104 | } | - | ||||||||||||
| 105 | - | |||||||||||||
| 106 | bool QPrintDevice::isValid() const | - | ||||||||||||
| 107 | { | - | ||||||||||||
| 108 | return d && d->isValid(); executed 285 times by 3 tests: return d && d->isValid();Executed by:
| 285 | ||||||||||||
| 109 | } | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | bool QPrintDevice::isDefault() const | - | ||||||||||||
| 112 | { | - | ||||||||||||
| 113 | return isValid() && d->isDefault(); never executed: return isValid() && d->isDefault(); | 0 | ||||||||||||
| 114 | } | - | ||||||||||||
| 115 | - | |||||||||||||
| 116 | bool QPrintDevice::isRemote() const | - | ||||||||||||
| 117 | { | - | ||||||||||||
| 118 | return isValid() && d->isRemote(); never executed: return isValid() && d->isRemote(); | 0 | ||||||||||||
| 119 | } | - | ||||||||||||
| 120 | - | |||||||||||||
| 121 | QPrint::DeviceState QPrintDevice::state() const | - | ||||||||||||
| 122 | { | - | ||||||||||||
| 123 | return isValid() ? d->state() : QPrint::Error; never executed: return isValid() ? d->state() : QPrint::Error; | 0 | ||||||||||||
| 124 | } | - | ||||||||||||
| 125 | - | |||||||||||||
| 126 | bool QPrintDevice::isValidPageLayout(const QPageLayout &layout, int resolution) const | - | ||||||||||||
| 127 | { | - | ||||||||||||
| 128 | return isValid() && d->isValidPageLayout(layout, resolution); never executed: return isValid() && d->isValidPageLayout(layout, resolution); | 0 | ||||||||||||
| 129 | } | - | ||||||||||||
| 130 | - | |||||||||||||
| 131 | bool QPrintDevice::supportsMultipleCopies() const | - | ||||||||||||
| 132 | { | - | ||||||||||||
| 133 | return isValid() && d->supportsMultipleCopies(); never executed: return isValid() && d->supportsMultipleCopies(); | 0 | ||||||||||||
| 134 | } | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | bool QPrintDevice::supportsCollateCopies() const | - | ||||||||||||
| 137 | { | - | ||||||||||||
| 138 | return isValid() && d->supportsCollateCopies(); never executed: return isValid() && d->supportsCollateCopies(); | 0 | ||||||||||||
| 139 | } | - | ||||||||||||
| 140 | - | |||||||||||||
| 141 | QPageSize QPrintDevice::defaultPageSize() const | - | ||||||||||||
| 142 | { | - | ||||||||||||
| 143 | return isValid() ? d->defaultPageSize() : QPageSize(); never executed: return isValid() ? d->defaultPageSize() : QPageSize(); | 0 | ||||||||||||
| 144 | } | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | QList<QPageSize> QPrintDevice::supportedPageSizes() const | - | ||||||||||||
| 147 | { | - | ||||||||||||
| 148 | return isValid() ? d->supportedPageSizes() : QList<QPageSize>(); executed 2 times by 1 test: return isValid() ? d->supportedPageSizes() : QList<QPageSize>();Executed by:
| 2 | ||||||||||||
| 149 | } | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | QPageSize QPrintDevice::supportedPageSize(const QPageSize &pageSize) const | - | ||||||||||||
| 152 | { | - | ||||||||||||
| 153 | return isValid() ? d->supportedPageSize(pageSize) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(pageSize) : QPageSize(); | 0 | ||||||||||||
| 154 | } | - | ||||||||||||
| 155 | - | |||||||||||||
| 156 | QPageSize QPrintDevice::supportedPageSize(QPageSize::PageSizeId pageSizeId) const | - | ||||||||||||
| 157 | { | - | ||||||||||||
| 158 | return isValid() ? d->supportedPageSize(pageSizeId) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(pageSizeId) : QPageSize(); | 0 | ||||||||||||
| 159 | } | - | ||||||||||||
| 160 | - | |||||||||||||
| 161 | QPageSize QPrintDevice::supportedPageSize(const QString &pageName) const | - | ||||||||||||
| 162 | { | - | ||||||||||||
| 163 | return isValid() ? d->supportedPageSize(pageName) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(pageName) : QPageSize(); | 0 | ||||||||||||
| 164 | } | - | ||||||||||||
| 165 | - | |||||||||||||
| 166 | QPageSize QPrintDevice::supportedPageSize(const QSize &pointSize) const | - | ||||||||||||
| 167 | { | - | ||||||||||||
| 168 | return isValid() ? d->supportedPageSize(pointSize) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(pointSize) : QPageSize(); | 0 | ||||||||||||
| 169 | } | - | ||||||||||||
| 170 | - | |||||||||||||
| 171 | QPageSize QPrintDevice::supportedPageSize(const QSizeF &size, QPageSize::Unit units) const | - | ||||||||||||
| 172 | { | - | ||||||||||||
| 173 | return isValid() ? d->supportedPageSize(size, units) : QPageSize(); never executed: return isValid() ? d->supportedPageSize(size, units) : QPageSize(); | 0 | ||||||||||||
| 174 | } | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | bool QPrintDevice::supportsCustomPageSizes() const | - | ||||||||||||
| 177 | { | - | ||||||||||||
| 178 | return isValid() && d->supportsCustomPageSizes(); never executed: return isValid() && d->supportsCustomPageSizes(); | 0 | ||||||||||||
| 179 | } | - | ||||||||||||
| 180 | - | |||||||||||||
| 181 | QSize QPrintDevice::minimumPhysicalPageSize() const | - | ||||||||||||
| 182 | { | - | ||||||||||||
| 183 | return isValid() ? d->minimumPhysicalPageSize() : QSize(); never executed: return isValid() ? d->minimumPhysicalPageSize() : QSize(); | 0 | ||||||||||||
| 184 | } | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | QSize QPrintDevice::maximumPhysicalPageSize() const | - | ||||||||||||
| 187 | { | - | ||||||||||||
| 188 | return isValid() ? d->maximumPhysicalPageSize() : QSize(); never executed: return isValid() ? d->maximumPhysicalPageSize() : QSize(); | 0 | ||||||||||||
| 189 | } | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | QMarginsF QPrintDevice::printableMargins(const QPageSize &pageSize, | - | ||||||||||||
| 192 | QPageLayout::Orientation orientation, | - | ||||||||||||
| 193 | int resolution) const | - | ||||||||||||
| 194 | { | - | ||||||||||||
| 195 | return isValid() ? d->printableMargins(pageSize, orientation, resolution) : QMarginsF(); never executed: return isValid() ? d->printableMargins(pageSize, orientation, resolution) : QMarginsF(); | 0 | ||||||||||||
| 196 | } | - | ||||||||||||
| 197 | - | |||||||||||||
| 198 | int QPrintDevice::defaultResolution() const | - | ||||||||||||
| 199 | { | - | ||||||||||||
| 200 | return isValid() ? d->defaultResolution() : 0; never executed: return isValid() ? d->defaultResolution() : 0; | 0 | ||||||||||||
| 201 | } | - | ||||||||||||
| 202 | - | |||||||||||||
| 203 | QList<int> QPrintDevice::supportedResolutions() const | - | ||||||||||||
| 204 | { | - | ||||||||||||
| 205 | return isValid() ? d->supportedResolutions() : QList<int>(); never executed: return isValid() ? d->supportedResolutions() : QList<int>(); | 0 | ||||||||||||
| 206 | } | - | ||||||||||||
| 207 | - | |||||||||||||
| 208 | QPrint::InputSlot QPrintDevice::defaultInputSlot() const | - | ||||||||||||
| 209 | { | - | ||||||||||||
| 210 | return isValid() ? d->defaultInputSlot() : QPrint::InputSlot(); never executed: return isValid() ? d->defaultInputSlot() : QPrint::InputSlot(); | 0 | ||||||||||||
| 211 | } | - | ||||||||||||
| 212 | - | |||||||||||||
| 213 | QList<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const | - | ||||||||||||
| 214 | { | - | ||||||||||||
| 215 | return isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>(); never executed: return isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>(); | 0 | ||||||||||||
| 216 | } | - | ||||||||||||
| 217 | - | |||||||||||||
| 218 | QPrint::OutputBin QPrintDevice::defaultOutputBin() const | - | ||||||||||||
| 219 | { | - | ||||||||||||
| 220 | return isValid() ? d->defaultOutputBin() : QPrint::OutputBin(); never executed: return isValid() ? d->defaultOutputBin() : QPrint::OutputBin(); | 0 | ||||||||||||
| 221 | } | - | ||||||||||||
| 222 | - | |||||||||||||
| 223 | QList<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const | - | ||||||||||||
| 224 | { | - | ||||||||||||
| 225 | return isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>(); never executed: return isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>(); | 0 | ||||||||||||
| 226 | } | - | ||||||||||||
| 227 | - | |||||||||||||
| 228 | QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const | - | ||||||||||||
| 229 | { | - | ||||||||||||
| 230 | return isValid() ? d->defaultDuplexMode() : QPrint::DuplexNone; never executed: return isValid() ? d->defaultDuplexMode() : QPrint::DuplexNone; | 0 | ||||||||||||
| 231 | } | - | ||||||||||||
| 232 | - | |||||||||||||
| 233 | QList<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const | - | ||||||||||||
| 234 | { | - | ||||||||||||
| 235 | return isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>(); never executed: return isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>(); | 0 | ||||||||||||
| 236 | } | - | ||||||||||||
| 237 | - | |||||||||||||
| 238 | QPrint::ColorMode QPrintDevice::defaultColorMode() const | - | ||||||||||||
| 239 | { | - | ||||||||||||
| 240 | return isValid() ? d->defaultColorMode() : QPrint::GrayScale; never executed: return isValid() ? d->defaultColorMode() : QPrint::GrayScale; | 0 | ||||||||||||
| 241 | } | - | ||||||||||||
| 242 | - | |||||||||||||
| 243 | QList<QPrint::ColorMode> QPrintDevice::supportedColorModes() const | - | ||||||||||||
| 244 | { | - | ||||||||||||
| 245 | return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>(); never executed: return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>(); | 0 | ||||||||||||
| 246 | } | - | ||||||||||||
| 247 | - | |||||||||||||
| 248 | #ifndef QT_NO_MIMETYPE | - | ||||||||||||
| 249 | QList<QMimeType> QPrintDevice::supportedMimeTypes() const | - | ||||||||||||
| 250 | { | - | ||||||||||||
| 251 | return isValid() ? d->supportedMimeTypes() : QList<QMimeType>(); never executed: return isValid() ? d->supportedMimeTypes() : QList<QMimeType>(); | 0 | ||||||||||||
| 252 | } | - | ||||||||||||
| 253 | #endif // QT_NO_MIMETYPE | - | ||||||||||||
| 254 | - | |||||||||||||
| 255 | # ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||
| 256 | void QPrintDevice::format(QDebug debug) const | - | ||||||||||||
| 257 | { | - | ||||||||||||
| 258 | QDebugStateSaver saver(debug); | - | ||||||||||||
| 259 | debug.noquote(); | - | ||||||||||||
| 260 | debug.nospace(); | - | ||||||||||||
| 261 | if (isValid()) {
| 0 | ||||||||||||
| 262 | const QString deviceId = id(); | - | ||||||||||||
| 263 | const QString deviceName = name(); | - | ||||||||||||
| 264 | debug << "id=\"" << deviceId << "\", state=" << state(); | - | ||||||||||||
| 265 | if (!deviceName.isEmpty() && deviceName != deviceId)
| 0 | ||||||||||||
| 266 | debug << ", name=\"" << deviceName << '"'; never executed: debug << ", name=\"" << deviceName << '"'; | 0 | ||||||||||||
| 267 | if (!location().isEmpty())
| 0 | ||||||||||||
| 268 | debug << ", location=\"" << location() << '"'; never executed: debug << ", location=\"" << location() << '"'; | 0 | ||||||||||||
| 269 | debug << ", makeAndModel=\"" << makeAndModel() << '"'; | - | ||||||||||||
| 270 | if (isDefault())
| 0 | ||||||||||||
| 271 | debug << ", default"; never executed: debug << ", default"; | 0 | ||||||||||||
| 272 | if (isRemote())
| 0 | ||||||||||||
| 273 | debug << ", remote"; never executed: debug << ", remote"; | 0 | ||||||||||||
| 274 | debug << ", defaultPageSize=" << defaultPageSize(); | - | ||||||||||||
| 275 | if (supportsCustomPageSizes())
| 0 | ||||||||||||
| 276 | debug << ", supportsCustomPageSizes"; never executed: debug << ", supportsCustomPageSizes"; | 0 | ||||||||||||
| 277 | debug << ", physicalPageSize=("; | - | ||||||||||||
| 278 | QtDebugUtils::formatQSize(debug, minimumPhysicalPageSize()); | - | ||||||||||||
| 279 | debug << ")..("; | - | ||||||||||||
| 280 | QtDebugUtils::formatQSize(debug, maximumPhysicalPageSize()); | - | ||||||||||||
| 281 | debug << "), defaultResolution=" << defaultResolution() | - | ||||||||||||
| 282 | << ", defaultDuplexMode=" << defaultDuplexMode() | - | ||||||||||||
| 283 | << ", defaultColorMode="<< defaultColorMode(); | - | ||||||||||||
| 284 | # ifndef QT_NO_MIMETYPE | - | ||||||||||||
| 285 | const QList<QMimeType> mimeTypes = supportedMimeTypes(); | - | ||||||||||||
| 286 | if (!mimeTypes.isEmpty()) {
| 0 | ||||||||||||
| 287 | debug << ", supportedMimeTypes=("; | - | ||||||||||||
| 288 | for (const auto &mimeType : mimeTypes) | - | ||||||||||||
| 289 | debug << " \"" << mimeType.name() << '"'; never executed: debug << " \"" << mimeType.name() << '"'; | 0 | ||||||||||||
| 290 | debug << ')'; | - | ||||||||||||
| 291 | } never executed: end of block | 0 | ||||||||||||
| 292 | # endif // !QT_NO_MIMETYPE | - | ||||||||||||
| 293 | } else { never executed: end of block | 0 | ||||||||||||
| 294 | debug << "null"; | - | ||||||||||||
| 295 | } never executed: end of block | 0 | ||||||||||||
| 296 | } | - | ||||||||||||
| 297 | - | |||||||||||||
| 298 | QDebug operator<<(QDebug debug, const QPrintDevice &p) | - | ||||||||||||
| 299 | { | - | ||||||||||||
| 300 | QDebugStateSaver saver(debug); | - | ||||||||||||
| 301 | debug.nospace(); | - | ||||||||||||
| 302 | debug << "QPrintDevice("; | - | ||||||||||||
| 303 | p.format(debug); | - | ||||||||||||
| 304 | debug << ')'; | - | ||||||||||||
| 305 | return debug; never executed: return debug; | 0 | ||||||||||||
| 306 | } | - | ||||||||||||
| 307 | # endif // QT_NO_DEBUG_STREAM | - | ||||||||||||
| 308 | #endif // QT_NO_PRINTER | - | ||||||||||||
| 309 | - | |||||||||||||
| 310 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |