KReport

KReportPageSize.cpp
1 /* This file is part of the KDE project
2 Copyright (C) 2015 by Adam Pigg <adam@piggz.co.uk>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "KReportPageSize.h"
21#include <QCoreApplication>
22#include <QPrinterInfo>
23
24struct KReportPageSizeInfo {
25 const char *name;
26 QPageSize::PageSizeId pageSize;
27};
28
29static const KReportPageSizeInfo pageSizeInfo[] = {
30 { "A3", QPageSize::A3},
31 { "A4", QPageSize::A4},
32 { "A5", QPageSize::A5},
33 { "Letter", QPageSize::Letter},
34 { "Legal", QPageSize::Legal},
35 { "Custom", QPageSize::Custom},
36 { "B6", QPageSize::B6},
37 { "B5", QPageSize::B5},
38 { "B4", QPageSize::B4},
39 { "Executive", QPageSize::Executive},
40 { "A0", QPageSize::A0},
41 { "A1", QPageSize::A1},
42 { "A2", QPageSize::A2},
43 { "A6", QPageSize::A6},
44 { "A7", QPageSize::A7},
45 { "A8", QPageSize::A8},
46 { "A9", QPageSize::A9},
47 { "B0", QPageSize::B0},
48 { "B1", QPageSize::B1},
49 { "B10", QPageSize::B10},
50 { "B2", QPageSize::B2},
51 { "B3", QPageSize::B3},
52 { "C5E", QPageSize::C5E},
53 { "Comm10", QPageSize::Comm10E},
54 { "DL", QPageSize::DLE},
55 { "Folio", QPageSize::Folio},
56 { "Ledger", QPageSize::Ledger},
57 { "Tabloid", QPageSize::Tabloid},
58 { "EnvelopeDL", QPageSize::EnvelopeDL},
59 { "EnvelopeC6", QPageSize::EnvelopeC6},
60 { "EnvelopeC65", QPageSize::EnvelopeC65},
61 { "EnvelopeC5", QPageSize::EnvelopeC5},
62 { "EnvelopeC4", QPageSize::EnvelopeC4},
63 { "EnvelopeMonarch", QPageSize::EnvelopeMonarch},
64 { "EnvelopePersonal", QPageSize::EnvelopePersonal},
65 { "Envelope9", QPageSize::Envelope9},
66 { "Envelope10", QPageSize::Envelope10},
67 { "Envelope11", QPageSize::Envelope11},
68 { "Envelope12", QPageSize::Envelope12},
69 { "Postcard", QPageSize::Postcard},
70 { "DoublePostcard", QPageSize::DoublePostcard},
71
73
74};
75
77{
78 QStringList lst;
79 for (int i = 0; pageSizeInfo[i].pageSize != QPageSize::LastPageSize ;i++) {
80 lst << QPageSize::name(pageSizeInfo[ i ].pageSize);
81 }
82 return lst;
83}
84
86{
87 QStringList lst;
88 for (int i = 0; pageSizeInfo[i].pageSize != QPageSize::LastPageSize ;i++) {
89 lst << QLatin1String(pageSizeInfo[ i ].name);
90 }
91 return lst;
92}
93
95{
97 QPageSize size = printerInfo.defaultPageSize();
98 if (size.isValid()) {
99 return size.id();
100 }
101 return QPageSize::A4;
102}
103
105{
106 for (int i = 0; pageSizeInfo[i].pageSize != QPageSize::LastPageSize ;i++) {
107 if (pageSizeInfo[i].pageSize == id) {
108 return QLatin1String(pageSizeInfo[i].name);
109 }
110 }
111 return QString();
112}
113
115{
116 for (int i = 0; pageSizeInfo[i].pageSize != QPageSize::LastPageSize ;i++) {
117 if (QLatin1String(pageSizeInfo[i].name) == size) {
118 return pageSizeInfo[i].pageSize;
119 }
120 }
121 return defaultSize();
122}
KREPORT_EXPORT QString pageSizeKey(QPageSize::PageSizeId id)
KREPORT_EXPORT QPageSize::PageSizeId pageSize(const QString &key)
KREPORT_EXPORT QStringList pageFormatKeys()
KREPORT_EXPORT QPageSize::PageSizeId defaultSize()
KREPORT_EXPORT QStringList pageFormatNames()
PageSizeId id(const QSize &pointSize, SizeMatchPolicy matchPolicy)
bool isValid() const const
QString name() const const
QPageSize defaultPageSize() const const
QPrinterInfo defaultPrinter()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:52:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.