Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcups_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QCUPS_P_H
6#define QCUPS_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
20#include <QtPrintSupport/private/qprint_p.h>
21#include "QtCore/qstring.h"
22#include "QtCore/qstringlist.h"
23#include "QtPrintSupport/qprinter.h"
24#include "QtCore/qdatetime.h"
25
27
28QT_BEGIN_NAMESPACE
29
30class QPrintDevice;
31
32// HACK! Define these here temporarily so they can be used in the dialogs
33// without a circular reference to QCupsPrintEngine in the plugin.
34// Move back to qcupsprintengine_p.h in the plugin once all usage
35// removed from the dialogs.
36#define PPK_CupsOptions QPrintEngine::PrintEnginePropertyKey(0xfe00)
37
38#define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase)
39#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1)
40#define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2)
41#define PDPK_CupsJobSheets QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 3)
42#define PDPK_CupsJobBilling QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 4)
43#define PDPK_CupsJobHoldUntil QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 5)
44#define PDPK_PpdChoiceIsInstallableConflict QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 6)
45#define PDPK_PpdCustomOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 7)
46#define PDPK_OptionValue QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 8)
47
48class Q_PRINTSUPPORT_EXPORT QCUPSSupport
49{
50public:
51 // Enum for values of job-hold-until option
52 enum JobHoldUntil {
53 NoHold = 0, //CUPS Default
54 Indefinite,
55 DayTime,
56 Night,
57 SecondShift,
58 ThirdShift,
59 Weekend,
60 SpecificTime
61 };
62
63 // Enum for valid banner pages
64 enum BannerPage {
65 NoBanner = 0, //CUPS Default 'none'
66 Standard,
67 Unclassified,
68 Confidential,
69 Classified,
70 Secret,
71 TopSecret
72 };
73
74 // Enum for valid page set
75 enum PageSet {
76 AllPages = 0, //CUPS Default
77 OddPages,
78 EvenPages
79 };
80
81 // Enum for valid number of pages per sheet
82 enum PagesPerSheet {
83 OnePagePerSheet = 0,
84 TwoPagesPerSheet,
85 FourPagesPerSheet,
86 SixPagesPerSheet,
87 NinePagesPerSheet,
88 SixteenPagesPerSheet
89 };
90
91 // Enum for valid layouts of pages per sheet
92 enum PagesPerSheetLayout {
93 LeftToRightTopToBottom = 0,
94 LeftToRightBottomToTop,
95 RightToLeftTopToBottom,
96 RightToLeftBottomToTop,
97 BottomToTopLeftToRight,
98 BottomToTopRightToLeft,
99 TopToBottomLeftToRight,
100 TopToBottomRightToLeft
101 };
102
103 static void setCupsOption(QPrinter *printer, const QString &option, const QString &value);
104 static void clearCupsOption(QPrinter *printer, const QString &option);
105 static void clearCupsOptions(QPrinter *printer);
106
107 static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, QTime holdUntilTime = QTime());
108 static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString());
109 static void setJobPriority(QPrinter *printer, int priority = 50);
110 static void setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage);
111 static void setPageSet(QPrinter *printer, const PageSet pageSet);
112 static void setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet,
113 const PagesPerSheetLayout pagesPerSheetLayout);
114 static void setPageRange(QPrinter *printer, int pageFrom, int pageTo);
115 static void setPageRange(QPrinter *printer, const QString &pageRange);
116
117 struct JobSheets
118 {
119 JobSheets(BannerPage s = NoBanner, BannerPage e = NoBanner)
120 : startBannerPage(s), endBannerPage(e) {}
121
122 BannerPage startBannerPage;
123 BannerPage endBannerPage;
124 };
125 static JobSheets parseJobSheets(const QString &jobSheets);
126
127 struct JobHoldUntilWithTime
128 {
129 JobHoldUntilWithTime(JobHoldUntil jh = NoHold, QTime t = QTime())
130 : jobHold(jh), time(t) {}
131
132 JobHoldUntil jobHold;
133 QTime time;
134 };
135 static JobHoldUntilWithTime parseJobHoldUntil(const QString &jobHoldUntil);
136
137 static ppd_option_t *findPpdOption(const char *optionName, QPrintDevice *printDevice);
138};
139Q_DECLARE_TYPEINFO(QCUPSSupport::JobHoldUntil, Q_PRIMITIVE_TYPE);
140Q_DECLARE_TYPEINFO(QCUPSSupport::BannerPage, Q_PRIMITIVE_TYPE);
141Q_DECLARE_TYPEINFO(QCUPSSupport::PageSet, Q_PRIMITIVE_TYPE);
142Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheetLayout, Q_PRIMITIVE_TYPE);
143Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheet, Q_PRIMITIVE_TYPE);
144
145QT_END_NAMESPACE
146
147QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::JobHoldUntil,
148 QCUPSSupport__JobHoldUntil, Q_PRINTSUPPORT_EXPORT)
149QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::BannerPage,
150 QCUPSSupport__BannerPage, Q_PRINTSUPPORT_EXPORT)
151QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PageSet, QCUPSSupport__PageSet, Q_PRINTSUPPORT_EXPORT)
152QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheetLayout,
153 QCUPSSupport__PagesPerSheetLayout, Q_PRINTSUPPORT_EXPORT)
154QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheet,
155 QCUPSSupport__PagesPerSheet, Q_PRINTSUPPORT_EXPORT)
156
157#endif
Combined button and popup list for selecting options.
static QCUPSSupport::BannerPage stringToBannerPage(const QString &bannerPage)
Definition qcups.cpp:182
static QString bannerPageToString(const QCUPSSupport::BannerPage bannerPage)
Definition qcups.cpp:168
static QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, QTime holdUntilTime)
Definition qcups.cpp:63
#define PDPK_PpdFile
Definition qcups_p.h:38
QT_REQUIRE_CONFIG(cups)
#define PPK_CupsOptions
Definition qcups_p.h:36