Okular

pagesize.cpp
1/*
2 SPDX-FileCopyrightText: 2007 Pino Toscano <pino@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7// local includes
8#include "pagesize.h"
9
10using namespace Okular;
11
12class Okular::PageSizePrivate : public QSharedData
13{
14public:
15 PageSizePrivate()
16 : m_width(0)
17 , m_height(0)
18 {
19 }
20
21 bool operator==(const PageSizePrivate &rhs) const
22 {
23 return m_width == rhs.m_width && m_height == rhs.m_height && m_name == rhs.m_name;
24 }
25
26 double m_width;
27 double m_height;
28 QString m_name;
29};
30
34
35PageSize::PageSize(double width, double height, const QString &name)
36 : d(new PageSizePrivate)
37{
38 d->m_width = width;
39 d->m_height = height;
40 d->m_name = name;
41}
42
44 : d(pageSize.d)
45{
46}
47
48PageSize::~PageSize()
49{
50}
51
52double PageSize::width() const
53{
54 if (!d) {
55 return 0;
56 }
57
58 return d->m_width;
59}
60
61double PageSize::height() const
62{
63 if (!d) {
64 return 0;
65 }
66
67 return d->m_height;
68}
69
71{
72 if (!d) {
73 return QString();
74 }
75
76 return d->m_name;
77}
78
79bool PageSize::isNull() const
80{
81 if (!d) {
82 return true;
83 }
84
85 return d->m_width == 0 && d->m_height == 0 && d->m_name.isEmpty();
86}
87
88bool PageSize::operator==(const PageSize &pageSize) const
89{
90 // 1st: we're null: check if the other is null too
91 if (!d) {
92 return !pageSize.d;
93 }
94 // 2nd: we're not null, return if the other is null
95 if (!pageSize.d) {
96 return false;
97 }
98
99 // 3rd: normal == check
100 return *d == *pageSize.d;
101}
102
103bool PageSize::operator!=(const PageSize &pageSize) const
104{
105 return !operator==(pageSize);
106}
107
108PageSize &PageSize::operator=(const PageSize &pageSize)
109{
110 if (this == &pageSize) {
111 return *this;
112 }
113
114 d = pageSize.d;
115 return *this;
116}
A small class that represents the size of a page.
Definition pagesize.h:24
double width() const
Returns the width of the page size.
Definition pagesize.cpp:52
QString name() const
Returns the ID of the page size.
Definition pagesize.cpp:70
double height() const
Returns the height of the page size.
Definition pagesize.cpp:61
bool isNull() const
Whether the page size is null.
Definition pagesize.cpp:79
PageSize()
Construct a null page size.
Definition pagesize.cpp:31
bool operator==(const PageSize &pageSize) const
Comparison operator.
Definition pagesize.cpp:88
KREPORT_EXPORT QPageSize::PageSizeId pageSize(const QString &key)
global.h
Definition action.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.