• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mcallegari / qlcplus / 19144422256

06 Nov 2025 05:33PM UTC coverage: 34.256% (-0.1%) from 34.358%
19144422256

push

github

mcallegari
Back to 5.1.0 debug

17718 of 51723 relevant lines covered (34.26%)

19528.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.08
/engine/src/cue.cpp
1
/*
2
  Q Light Controller Plus
3
  cue.cpp
4

5
  Copyright (c) Heikki Junnila
6
                Massimo Callegari
7

8
  Licensed under the Apache License, Version 2.0 (the "License");
9
  you may not use this file except in compliance with the License.
10
  You may obtain a copy of the License at
11

12
      http://www.apache.org/licenses/LICENSE-2.0.txt
13

14
  Unless required by applicable law or agreed to in writing, software
15
  distributed under the License is distributed on an "AS IS" BASIS,
16
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
  See the License for the specific language governing permissions and
18
  limitations under the License.
19
*/
20

21
#include <QXmlStreamReader>
22
#include <QXmlStreamWriter>
23
#include <QDebug>
24

25
#include "cue.h"
26

27
Cue::Cue(const QString& name)
75✔
28
    : m_name(name)
75✔
29
    , m_fadeInSpeed(0)
75✔
30
    , m_fadeOutSpeed(0)
75✔
31
    , m_duration(0)
75✔
32
{
33
}
75✔
34

35
Cue::Cue(const QMap <uint,uchar> values)
1✔
36
    : m_name(QString())
1✔
37
    , m_values(values)
1✔
38
    , m_fadeInSpeed(0)
1✔
39
    , m_fadeOutSpeed(0)
1✔
40
    , m_duration(0)
1✔
41
{
42
}
1✔
43

44
Cue::Cue(const Cue& cue)
357✔
45
    : m_name(cue.name())
357✔
46
    , m_values(cue.values())
357✔
47
    , m_fadeInSpeed(cue.fadeInSpeed())
357✔
48
    , m_fadeOutSpeed(cue.fadeOutSpeed())
357✔
49
    , m_duration(cue.duration())
357✔
50
{
51
}
357✔
52

53
Cue::~Cue()
433✔
54
{
55
}
433✔
56

57
Cue &Cue::operator=(const Cue &cue)
21✔
58
{
59
    if (this != &cue)
21✔
60
    {
61
        m_name = cue.name();
21✔
62
        m_values = cue.values();
21✔
63
        m_fadeInSpeed = cue.fadeInSpeed();
21✔
64
        m_fadeOutSpeed = cue.fadeOutSpeed();
21✔
65
        m_duration = cue.duration();
21✔
66
    }
67

68
    return *this;
21✔
69
}
70

71
/****************************************************************************
72
 * Name
73
 ****************************************************************************/
74

75
void Cue::setName(const QString& str)
10✔
76
{
77
    m_name = str;
10✔
78
}
10✔
79

80
QString Cue::name() const
467✔
81
{
82
    return m_name;
467✔
83
}
84

85
/****************************************************************************
86
 * Values
87
 ****************************************************************************/
88

89
void Cue::setValue(uint channel, uchar value)
36✔
90
{
91
    m_values[channel] = value;
36✔
92
}
36✔
93

94
void Cue::unsetValue(uint channel)
2✔
95
{
96
    m_values.remove(channel);
2✔
97
}
2✔
98

99
uchar Cue::value(uint channel) const
16✔
100
{
101
    return m_values.value(channel, 0);
16✔
102
}
103

104
QMap <uint,uchar> Cue::values() const
413✔
105
{
106
    return m_values;
413✔
107
}
108

109
/****************************************************************************
110
 * Speed
111
 ****************************************************************************/
112

113
void Cue::setFadeInSpeed(uint ms)
6✔
114
{
115
    m_fadeInSpeed = ms;
6✔
116
}
6✔
117

118
uint Cue::fadeInSpeed() const
402✔
119
{
120
    return m_fadeInSpeed;
402✔
121
}
122

123
void Cue::setFadeOutSpeed(uint ms)
6✔
124
{
125
    m_fadeOutSpeed = ms;
6✔
126
}
6✔
127

128
uint Cue::fadeOutSpeed() const
393✔
129
{
130
    return m_fadeOutSpeed;
393✔
131
}
132

133
void Cue::setDuration(uint ms)
4✔
134
{
135
    m_duration = ms;
4✔
136
}
4✔
137

138
uint Cue::duration() const
386✔
139
{
140
    return m_duration;
386✔
141
}
142

143
/****************************************************************************
144
 * Load & Save
145
 ****************************************************************************/
146

147
bool Cue::loadXML(QXmlStreamReader &root)
6✔
148
{
149
    qDebug() << Q_FUNC_INFO;
6✔
150

151
    if (root.name() != KXMLQLCCue)
6✔
152
    {
153
        qWarning() << Q_FUNC_INFO << "Cue node not found";
1✔
154
        return false;
1✔
155
    }
156

157
    setName(root.attributes().value(KXMLQLCCueName).toString());
10✔
158

159
    while (root.readNextStartElement())
12✔
160
    {
161
        if (root.name() == KXMLQLCCueValue)
7✔
162
        {
163
            QString ch = root.attributes().value(KXMLQLCCueValueChannel).toString();
8✔
164
            QString val = root.readElementText();
4✔
165
            if (ch.isEmpty() == false && val.isEmpty() == false)
4✔
166
                setValue(ch.toUInt(), uchar(val.toUInt()));
4✔
167
        }
4✔
168
        else if (root.name() == KXMLQLCCueSpeed)
3✔
169
        {
170
            loadXMLSpeed(root);
2✔
171
        }
172
        else
173
        {
174
            qWarning() << Q_FUNC_INFO << "Unrecognized Cue tag:" << root.name();
1✔
175
            root.skipCurrentElement();
1✔
176
        }
177
    }
178

179
    return true;
5✔
180
}
181

182
bool Cue::saveXML(QXmlStreamWriter *doc) const
5✔
183
{
184
    qDebug() << Q_FUNC_INFO;
5✔
185
    Q_ASSERT(doc != NULL);
5✔
186

187
    doc->writeStartElement(KXMLQLCCue);
10✔
188
    doc->writeAttribute(KXMLQLCCueName, name());
10✔
189

190
    QMapIterator <uint,uchar> it(values());
5✔
191
    while (it.hasNext() == true)
9✔
192
    {
193
        it.next();
4✔
194
        doc->writeStartElement(KXMLQLCCueValue);
8✔
195
        doc->writeAttribute(KXMLQLCCueValueChannel, QString::number(it.key()));
8✔
196
        doc->writeCharacters(QString::number(it.value()));
4✔
197
        doc->writeEndElement();
4✔
198
    }
199

200
    saveXMLSpeed(doc);
5✔
201

202
    /* End the <Cue> tag */
203
    doc->writeEndElement();
5✔
204

205
    return true;
5✔
206
}
5✔
207

208
bool Cue::loadXMLSpeed(QXmlStreamReader &speedRoot)
2✔
209
{
210
    if (speedRoot.name() != KXMLQLCCueSpeed)
2✔
211
        return false;
×
212

213
    m_fadeInSpeed = speedRoot.attributes().value(KXMLQLCCueSpeedFadeIn).toString().toUInt();
4✔
214
    m_fadeOutSpeed = speedRoot.attributes().value(KXMLQLCCueSpeedFadeOut).toString().toUInt();
4✔
215
    m_duration = speedRoot.attributes().value(KXMLQLCCueSpeedDuration).toString().toUInt();
4✔
216
    speedRoot.skipCurrentElement();
2✔
217

218
    return true;
2✔
219
}
220

221
bool Cue::saveXMLSpeed(QXmlStreamWriter *doc) const
5✔
222
{
223
    doc->writeStartElement(KXMLQLCCueSpeed);
10✔
224
    doc->writeAttribute(KXMLQLCCueSpeedFadeIn, QString::number(fadeInSpeed()));
10✔
225
    doc->writeAttribute(KXMLQLCCueSpeedFadeOut, QString::number(fadeOutSpeed()));
10✔
226
    doc->writeAttribute(KXMLQLCCueSpeedDuration, QString::number(duration()));
10✔
227
    doc->writeEndElement();
5✔
228

229
    return true;
5✔
230
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc