Okular

pagesize.cpp
1 /***************************************************************************
2  * Copyright (C) 2007 by Pino Toscano <[email protected]> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  ***************************************************************************/
9 
10 // local includes
11 #include "pagesize.h"
12 
13 using namespace Okular;
14 
15 class Okular::PageSizePrivate : public QSharedData
16 {
17 public:
18  PageSizePrivate()
19  : m_width(0)
20  , m_height(0)
21  {
22  }
23 
24  bool operator==(const PageSizePrivate &rhs) const
25  {
26  return m_width == rhs.m_width && m_height == rhs.m_height && m_name == rhs.m_name;
27  }
28 
29  double m_width;
30  double m_height;
31  QString m_name;
32 };
33 
35 {
36 }
37 
38 PageSize::PageSize(double width, double height, const QString &name)
39  : d(new PageSizePrivate)
40 {
41  d->m_width = width;
42  d->m_height = height;
43  d->m_name = name;
44 }
45 
46 PageSize::PageSize(const PageSize &pageSize)
47  : d(pageSize.d)
48 {
49 }
50 
51 PageSize::~PageSize()
52 {
53 }
54 
55 double PageSize::width() const
56 {
57  if (!d)
58  return 0;
59 
60  return d->m_width;
61 }
62 
63 double PageSize::height() const
64 {
65  if (!d)
66  return 0;
67 
68  return d->m_height;
69 }
70 
72 {
73  if (!d)
74  return QString();
75 
76  return d->m_name;
77 }
78 
79 bool PageSize::isNull() const
80 {
81  if (!d)
82  return true;
83 
84  return d->m_width == 0 && d->m_height == 0 && d->m_name.isEmpty();
85 }
86 
87 bool PageSize::operator==(const PageSize &pageSize) const
88 {
89  // 1st: we're null: check if the other is null too
90  if (!d)
91  return !pageSize.d;
92  // 2nd: we're not null, return if the other is null
93  if (!pageSize.d)
94  return false;
95 
96  // 3rd: normal == check
97  return *d == *pageSize.d;
98 }
99 
100 bool PageSize::operator!=(const PageSize &pageSize) const
101 {
102  return !operator==(pageSize);
103 }
104 
105 PageSize &PageSize::operator=(const PageSize &pageSize)
106 {
107  if (this == &pageSize)
108  return *this;
109 
110  d = pageSize.d;
111  return *this;
112 }
global.h
Definition: action.h:19
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
double height() const
Returns the height of the page size.
Definition: pagesize.cpp:63
QString name() const
Returns the ID of the page size.
Definition: pagesize.cpp:71
double width() const
Returns the width of the page size.
Definition: pagesize.cpp:55
bool isNull() const
Whether the page size is null.
Definition: pagesize.cpp:79
PageSize()
Construct a null page size.
Definition: pagesize.cpp:34
A small class that represents the size of a page.
Definition: pagesize.h:26
bool operator==(const PageSize &pageSize) const
Comparison operator.
Definition: pagesize.cpp:87
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Sep 23 2020 22:36:13 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.