Okular

pagesize.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Pino Toscano <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 // local includes
8 #include "pagesize.h"
9 
10 using namespace Okular;
11 
12 class Okular::PageSizePrivate : public QSharedData
13 {
14 public:
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 
32 {
33 }
34 
35 PageSize::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 
43 PageSize::PageSize(const PageSize &pageSize)
44  : d(pageSize.d)
45 {
46 }
47 
48 PageSize::~PageSize()
49 {
50 }
51 
52 double PageSize::width() const
53 {
54  if (!d) {
55  return 0;
56  }
57 
58  return d->m_width;
59 }
60 
61 double 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 
79 bool 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 
88 bool 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 
103 bool PageSize::operator!=(const PageSize &pageSize) const
104 {
105  return !operator==(pageSize);
106 }
107 
108 PageSize &PageSize::operator=(const PageSize &pageSize)
109 {
110  if (this == &pageSize) {
111  return *this;
112  }
113 
114  d = pageSize.d;
115  return *this;
116 }
bool isNull() const
Whether the page size is null.
Definition: pagesize.cpp:79
PageSize()
Construct a null page size.
Definition: pagesize.cpp:31
The documentation to the global Okular namespace.
Definition: action.h:16
bool operator==(const PageSize &pageSize) const
Comparison operator.
Definition: pagesize.cpp:88
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
double width() const
Returns the width of the page size.
Definition: pagesize.cpp:52
double height() const
Returns the height of the page size.
Definition: pagesize.cpp:61
QString name() const
Returns the ID of the page size.
Definition: pagesize.cpp:70
A small class that represents the size of a page.
Definition: pagesize.h:23
KREPORT_EXPORT QPageSize::PageSizeId pageSize(const QString &key)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 23 2023 04:04:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.