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
46class Q_PRINTSUPPORT_EXPORT QCUPSSupport
47{
48public:
49 // Enum for values of job-hold-until option
50 enum JobHoldUntil {
51 NoHold = 0, //CUPS Default
52 Indefinite,
53 DayTime,
54 Night,
55 SecondShift,
56 ThirdShift,
57 Weekend,
58 SpecificTime
59 };
60
61 // Enum for valid banner pages
62 enum BannerPage {
63 NoBanner = 0, //CUPS Default 'none'
64 Standard,
65 Unclassified,
66 Confidential,
67 Classified,
68 Secret,
69 TopSecret
70 };
71
72 // Enum for valid page set
73 enum PageSet {
74 AllPages = 0, //CUPS Default
75 OddPages,
76 EvenPages
77 };
78
79 // Enum for valid number of pages per sheet
80 enum PagesPerSheet {
81 OnePagePerSheet = 0,
82 TwoPagesPerSheet,
83 FourPagesPerSheet,
84 SixPagesPerSheet,
85 NinePagesPerSheet,
86 SixteenPagesPerSheet
87 };
88
89 // Enum for valid layouts of pages per sheet
90 enum PagesPerSheetLayout {
91 LeftToRightTopToBottom = 0,
92 LeftToRightBottomToTop,
93 RightToLeftTopToBottom,
94 RightToLeftBottomToTop,
95 BottomToTopLeftToRight,
96 BottomToTopRightToLeft,
97 TopToBottomLeftToRight,
98 TopToBottomRightToLeft
99 };
100
101 static void setCupsOption(QPrinter *printer, const QString &option, const QString &value);
102 static void clearCupsOption(QPrinter *printer, const QString &option);
103 static void clearCupsOptions(QPrinter *printer);
104
105 static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, QTime holdUntilTime = QTime());
106 static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString());
107 static void setJobPriority(QPrinter *printer, int priority = 50);
108 static void setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage);
109 static void setPageSet(QPrinter *printer, const PageSet pageSet);
110 static void setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet,
111 const PagesPerSheetLayout pagesPerSheetLayout);
112 static void setPageRange(QPrinter *printer, int pageFrom, int pageTo);
113 static void setPageRange(QPrinter *printer, const QString &pageRange);
114
115 struct JobSheets
116 {
117 JobSheets(BannerPage s = NoBanner, BannerPage e = NoBanner)
118 : startBannerPage(s), endBannerPage(e) {}
119
120 BannerPage startBannerPage;
121 BannerPage endBannerPage;
122 };
123 static JobSheets parseJobSheets(const QString &jobSheets);
124
125 struct JobHoldUntilWithTime
126 {
127 JobHoldUntilWithTime(JobHoldUntil jh = NoHold, QTime t = QTime())
128 : jobHold(jh), time(t) {}
129
130 JobHoldUntil jobHold;
131 QTime time;
132 };
133 static JobHoldUntilWithTime parseJobHoldUntil(const QString &jobHoldUntil);
134
135 static ppd_option_t *findPpdOption(const char *optionName, QPrintDevice *printDevice);
136};
137Q_DECLARE_TYPEINFO(QCUPSSupport::JobHoldUntil, Q_PRIMITIVE_TYPE);
138Q_DECLARE_TYPEINFO(QCUPSSupport::BannerPage, Q_PRIMITIVE_TYPE);
139Q_DECLARE_TYPEINFO(QCUPSSupport::PageSet, Q_PRIMITIVE_TYPE);
140Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheetLayout, Q_PRIMITIVE_TYPE);
141Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheet, Q_PRIMITIVE_TYPE);
142
143QT_END_NAMESPACE
144
145QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::JobHoldUntil,
146 QCUPSSupport__JobHoldUntil, Q_PRINTSUPPORT_EXPORT)
147QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::BannerPage,
148 QCUPSSupport__BannerPage, Q_PRINTSUPPORT_EXPORT)
149QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PageSet, QCUPSSupport__PageSet, Q_PRINTSUPPORT_EXPORT)
150QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheetLayout,
151 QCUPSSupport__PagesPerSheetLayout, Q_PRINTSUPPORT_EXPORT)
152QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheet,
153 QCUPSSupport__PagesPerSheet, Q_PRINTSUPPORT_EXPORT)
154
155#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