1 /*************************************************************************************
2 * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
3 * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
4 * *
5 * This library is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU Lesser General Public *
7 * License as published by the Free Software Foundation; either *
8 * version 2.1 of the License, or (at your option) any later version. *
9 * *
10 * This library is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * Lesser General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Lesser General Public *
16 * License along with this library; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18 *************************************************************************************/
19 #include "mode.h"
20
21 namespace Disman
22 {
23
24 class Q_DECL_HIDDEN Mode::Private
25 {
26 public:
Private()27 Private()
28 : rate(0)
29 {
30 }
31
Private(const Private & other)32 Private(const Private& other)
33 : id(other.id)
34 , name(other.name)
35 , size(other.size)
36 , rate(other.rate)
37 {
38 }
39
40 std::string id;
41 std::string name;
42 QSize size;
43 int rate;
44 };
45
Mode()46 Mode::Mode()
47 : d(new Private())
48 {
49 }
50
Mode(Mode::Private * dd)51 Mode::Mode(Mode::Private* dd)
52 : d(dd)
53 {
54 }
55
~Mode()56 Mode::~Mode()
57 {
58 delete d;
59 }
60
clone() const61 ModePtr Mode::clone() const
62 {
63 return ModePtr(new Mode(new Private(*d)));
64 }
65
id() const66 std::string Mode::id() const
67 {
68 return d->id;
69 }
70
set_id(std::string const & id)71 void Mode::set_id(std::string const& id)
72 {
73 if (d->id == id) {
74 return;
75 }
76
77 d->id = id;
78 }
79
name() const80 std::string Mode::name() const
81 {
82 return d->name;
83 }
84
set_name(std::string const & name)85 void Mode::set_name(std::string const& name)
86 {
87 if (d->name == name) {
88 return;
89 }
90
91 d->name = name;
92 }
93
size() const94 QSize Mode::size() const
95 {
96 return d->size;
97 }
98
set_size(const QSize & size)99 void Mode::set_size(const QSize& size)
100 {
101 if (d->size == size) {
102 return;
103 }
104
105 d->size = size;
106 }
107
refresh() const108 int Mode::refresh() const
109 {
110 return d->rate;
111 }
112
set_refresh(int refresh)113 void Mode::set_refresh(int refresh)
114 {
115 if (d->rate == refresh) {
116 return;
117 }
118
119 d->rate = refresh;
120 }
121
122 }
123
operator <<(QDebug dbg,const Disman::ModePtr & mode)124 QDebug operator<<(QDebug dbg, const Disman::ModePtr& mode)
125 {
126 if (mode) {
127 dbg << "Disman::Mode(Id:" << mode->id().c_str() << ", Size:" << mode->size() << "@"
128 << mode->refresh() << ")";
129 } else {
130 dbg << "Disman::Mode(NULL)";
131 }
132 return dbg;
133 }
134