GCC Code Coverage Report


Directory: ./
File: lib/screen.cpp
Date: 2023-04-20 22:59:23
Exec Total Coverage
Lines: 58 59 98.3%
Branches: 9 16 56.2%

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 "screen.h"
20
21 using namespace Disman;
22
23 class Q_DECL_HIDDEN Screen::Private
24 {
25 public:
26 429 Private()
27 429 : id(0)
28 429 , max_outputs_count(0)
29 {
30 429 }
31
32 120 Private(const Private& other)
33 120 : id(other.id)
34 120 , max_outputs_count(other.max_outputs_count)
35 120 , current_size(other.current_size)
36 120 , min_size(other.min_size)
37 120 , max_size(other.max_size)
38 {
39 120 }
40
41 int id;
42 int max_outputs_count;
43 QSize current_size;
44 QSize min_size;
45 QSize max_size;
46 };
47
48 429 Screen::Screen()
49 : QObject(nullptr)
50 429 , d(new Private())
51 {
52 429 }
53
54 120 Screen::Screen(Screen::Private* dd)
55 : QObject()
56 120 , d(dd)
57 {
58 120 }
59
60 2152 Screen::~Screen()
61 {
62
1/2
✓ Branch 0 taken 538 times.
✗ Branch 1 not taken.
1076 delete d;
63 2152 }
64
65 120 ScreenPtr Screen::clone() const
66 {
67 120 return ScreenPtr(new Screen(new Private(*d)));
68 }
69
70 18 bool Screen::compare(ScreenPtr screen) const
71 {
72
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
18 if (!screen) {
73 return false;
74 }
75
76
1/2
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
36 return d->id == screen->d->id && d->max_outputs_count == screen->d->max_outputs_count
77
2/4
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
18 && d->current_size == screen->d->current_size && d->min_size == screen->d->min_size
78
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
36 && d->max_size == screen->d->max_size;
79 }
80
81 2 int Screen::id() const
82 {
83 2 return d->id;
84 }
85
86 145 void Screen::set_id(int id)
87 {
88 145 d->id = id;
89 145 }
90
91 13 QSize Screen::current_size() const
92 {
93 13 return d->current_size;
94 }
95
96 763 void Screen::set_current_size(const QSize& current_size)
97 {
98
2/2
✓ Branch 1 taken 338 times.
✓ Branch 2 taken 425 times.
763 if (d->current_size == current_size) {
99 338 return;
100 }
101
102 425 d->current_size = current_size;
103
104 425 Q_EMIT current_size_changed();
105 }
106
107 19 QSize Screen::max_size() const
108 {
109 19 return d->max_size;
110 }
111
112 705 void Screen::set_max_size(const QSize& max_size)
113 {
114 705 d->max_size = max_size;
115 705 }
116
117 13 QSize Screen::min_size() const
118 {
119 13 return d->min_size;
120 }
121
122 705 void Screen::set_min_size(const QSize& min_size)
123 {
124 705 d->min_size = min_size;
125 705 }
126
127 9 int Screen::max_outputs_count() const
128 {
129 9 return d->max_outputs_count;
130 }
131
132 747 void Screen::set_max_outputs_count(int max_outputs_count)
133 {
134 747 d->max_outputs_count = max_outputs_count;
135 747 }
136
137 42 void Screen::apply(const ScreenPtr& other)
138 {
139 // Only set values that can change
140 42 set_max_outputs_count(other->d->max_outputs_count);
141 42 set_current_size(other->d->current_size);
142 42 }
143