GCC Code Coverage Report


Directory: ./
File: lib/mode.cpp
Date: 2023-04-20 22:59:23
Exec Total Coverage
Lines: 45 50 90.0%
Branches: 6 12 50.0%

Line Branch Exec Source
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:
27 21719 Private()
28 21719 : rate(0)
29 {
30 21719 }
31
32 3830 Private(const Private& other)
33 3830 : id(other.id)
34 3830 , name(other.name)
35 3830 , size(other.size)
36 3830 , rate(other.rate)
37 {
38 3830 }
39
40 std::string id;
41 std::string name;
42 QSize size;
43 int rate;
44 };
45
46 21719 Mode::Mode()
47 21719 : d(new Private())
48 {
49 21719 }
50
51 3830 Mode::Mode(Mode::Private* dd)
52 3830 : d(dd)
53 {
54 3830 }
55
56 25434 Mode::~Mode()
57 {
58
1/2
✓ Branch 0 taken 25434 times.
✗ Branch 1 not taken.
25434 delete d;
59 25434 }
60
61 3830 ModePtr Mode::clone() const
62 {
63 3830 return ModePtr(new Mode(new Private(*d)));
64 }
65
66 2069 std::string Mode::id() const
67 {
68 2069 return d->id;
69 }
70
71 21721 void Mode::set_id(std::string const& id)
72 {
73
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 21721 times.
21721 if (d->id == id) {
74 return;
75 }
76
77 21721 d->id = id;
78 }
79
80 13 std::string Mode::name() const
81 {
82 13 return d->name;
83 }
84
85 21719 void Mode::set_name(std::string const& name)
86 {
87
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 21719 times.
21719 if (d->name == name) {
88 return;
89 }
90
91 21719 d->name = name;
92 }
93
94 85637 QSize Mode::size() const
95 {
96 85637 return d->size;
97 }
98
99 21722 void Mode::set_size(const QSize& size)
100 {
101
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 21722 times.
21722 if (d->size == size) {
102 return;
103 }
104
105 21722 d->size = size;
106 }
107
108 14806 int Mode::refresh() const
109 {
110 14806 return d->rate;
111 }
112
113 21719 void Mode::set_refresh(int refresh)
114 {
115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21719 times.
21719 if (d->rate == refresh) {
116 return;
117 }
118
119 21719 d->rate = refresh;
120 }
121
122 }
123
124 1 QDebug operator<<(QDebug dbg, const Disman::ModePtr& mode)
125 {
126
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 if (mode) {
127 2 dbg << "Disman::Mode(Id:" << mode->id().c_str() << ", Size:" << mode->size() << "@"
128 1 << mode->refresh() << ")";
129 } else {
130 dbg << "Disman::Mode(NULL)";
131 }
132 1 return dbg;
133 }
134