forked from KDE/okular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpagesize.cpp
112 lines (90 loc) · 2.27 KB
/
pagesize.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/***************************************************************************
* Copyright (C) 2007 by Pino Toscano <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
// local includes
#include "pagesize.h"
using namespace Okular;
class Okular::PageSizePrivate : public QSharedData
{
public:
PageSizePrivate()
: m_width(0)
, m_height(0)
{
}
bool operator==(const PageSizePrivate &rhs) const
{
return m_width == rhs.m_width && m_height == rhs.m_height && m_name == rhs.m_name;
}
double m_width;
double m_height;
QString m_name;
};
PageSize::PageSize()
{
}
PageSize::PageSize(double width, double height, const QString &name)
: d(new PageSizePrivate)
{
d->m_width = width;
d->m_height = height;
d->m_name = name;
}
PageSize::PageSize(const PageSize &pageSize)
: d(pageSize.d)
{
}
PageSize::~PageSize()
{
}
double PageSize::width() const
{
if (!d)
return 0;
return d->m_width;
}
double PageSize::height() const
{
if (!d)
return 0;
return d->m_height;
}
QString PageSize::name() const
{
if (!d)
return QString();
return d->m_name;
}
bool PageSize::isNull() const
{
if (!d)
return true;
return d->m_width == 0 && d->m_height == 0 && d->m_name.isEmpty();
}
bool PageSize::operator==(const PageSize &pageSize) const
{
// 1st: we're null: check if the other is null too
if (!d)
return !pageSize.d;
// 2nd: we're not null, return if the other is null
if (!pageSize.d)
return false;
// 3rd: normal == check
return *d == *pageSize.d;
}
bool PageSize::operator!=(const PageSize &pageSize) const
{
return !operator==(pageSize);
}
PageSize &PageSize::operator=(const PageSize &pageSize)
{
if (this == &pageSize)
return *this;
d = pageSize.d;
return *this;
}