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

mcallegari / qlcplus / 8961243534

05 May 2024 09:23PM UTC coverage: 32.068% (+4.0%) from 28.094%
8961243534

push

github

mcallegari
Merge branch 'master' into qmltoqt6

902 of 2557 new or added lines in 140 files covered. (35.28%)

166 existing lines in 76 files now uncovered.

15395 of 48008 relevant lines covered (32.07%)

22949.67 hits per line

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

85.42
/engine/src/showfunction.cpp
1
/*
2
  Q Light Controller Plus
3
  showfunction.cpp
4

5
  Copyright (c) Massimo Callegari
6

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

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

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

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

24
#include "showfunction.h"
25
#include "function.h"
26
#include "doc.h"
27

28
#define KXMLShowFunctionID "ID"
29
#define KXMLShowFunctionStartTime "StartTime"
30
#define KXMLShowFunctionDuration "Duration"
31
#define KXMLShowFunctionColor "Color"
32
#define KXMLShowFunctionLocked "Locked"
33

34
ShowFunction::ShowFunction(quint32 id, QObject *parent)
13✔
35
    : QObject(parent)
36
    , m_id(id)
37
    , m_functionId(Function::invalidId())
26✔
38
    , m_startTime(UINT_MAX)
39
    , m_duration(0)
40
    , m_color(QColor())
41
    , m_locked(false)
42
    , m_intensityOverrideId(-1)
13✔
43
{
44
}
13✔
45

46
quint32 ShowFunction::id() const
12✔
47
{
48
    return m_id;
12✔
49
}
50

51
void ShowFunction::setFunctionID(quint32 id)
13✔
52
{
53
    if (id == m_functionId)
13✔
54
        return;
×
55

56
    m_functionId = id;
13✔
57
    emit functionIDChanged();
13✔
58
}
59

60
quint32 ShowFunction::functionID() const
34✔
61
{
62
    return m_functionId;
34✔
63
}
64

65
void ShowFunction::setStartTime(quint32 time)
6✔
66
{
67
    if (time == m_startTime)
6✔
68
        return;
×
69

70
    m_startTime = time;
6✔
71
    emit startTimeChanged();
6✔
72
}
73

74
quint32 ShowFunction::startTime() const
11✔
75
{
76
    return m_startTime;
11✔
77
}
78

79
void ShowFunction::setDuration(quint32 duration)
7✔
80
{
81
    if (duration == m_duration)
7✔
82
        return;
×
83

84
    m_duration = duration;
7✔
85
    emit durationChanged();
7✔
86
}
87

88
quint32 ShowFunction::duration() const
6✔
89
{
90
    return m_duration;
6✔
91
}
92

93
quint32 ShowFunction::duration(const Doc *doc) const
4✔
94
{
95
    if (m_duration)
4✔
96
        return m_duration;
4✔
97

98
    if (doc == NULL)
×
99
        return 0;
×
100

NEW
101
    Function *f = doc->function(m_functionId);
×
102
    if (f == NULL)
×
103
        return 0;
×
104

105
    return f->totalDuration();
×
106
}
107

108
void ShowFunction::setColor(QColor color)
6✔
109
{
110
    if (color == m_color)
6✔
111
        return;
1✔
112

113
    m_color = color;
5✔
114
    emit colorChanged();
5✔
115
}
116

117
QColor ShowFunction::color() const
11✔
118
{
119
    return m_color;
11✔
120
}
121

122
QColor ShowFunction::defaultColor(Function::Type type)
8✔
123
{
124
    switch (type)
8✔
125
    {
126
        case Function::ChaserType:    return QColor(85, 107, 128);
1✔
127
        case Function::AudioType:     return QColor(96, 128, 83);
1✔
128
        case Function::RGBMatrixType: return QColor(101, 155, 155);
1✔
129
        case Function::EFXType:       return QColor(128, 60, 60);
1✔
130
        case Function::VideoType:     return QColor(147, 140, 20);
1✔
131
        default: return QColor(100, 100, 100);
3✔
132
    }
133
}
134

135
void ShowFunction::setLocked(bool locked)
5✔
136
{
137
    if (locked == m_locked)
5✔
138
        return;
×
139

140
    m_locked = locked;
5✔
141
    emit lockedChanged();
5✔
142
}
143

144
bool ShowFunction::isLocked() const
7✔
145
{
146
    return m_locked;
7✔
147
}
148

149
int ShowFunction::intensityOverrideId() const
2✔
150
{
151
    return m_intensityOverrideId;
2✔
152
}
153

154
void ShowFunction::setIntensityOverrideId(int id)
2✔
155
{
156
    m_intensityOverrideId = id;
2✔
157
}
2✔
158

159
/************************************************************************
160
 * Load & Save
161
 ***********************************************************************/
162

163
bool ShowFunction::loadXML(QXmlStreamReader &root)
2✔
164
{
165
    if (root.name() != KXMLShowFunction)
2✔
166
    {
167
        qWarning() << Q_FUNC_INFO << "ShowFunction node not found";
×
168
        return false;
×
169
    }
170

171
    QXmlStreamAttributes attrs = root.attributes();
2✔
172

173
    if (attrs.hasAttribute(KXMLShowFunctionID))
2✔
174
        setFunctionID(attrs.value(KXMLShowFunctionID).toString().toUInt());
2✔
175
    if (attrs.hasAttribute(KXMLShowFunctionStartTime))
2✔
176
        setStartTime(attrs.value(KXMLShowFunctionStartTime).toString().toUInt());
1✔
177
    if (attrs.hasAttribute(KXMLShowFunctionDuration))
2✔
178
        setDuration(attrs.value(KXMLShowFunctionDuration).toString().toUInt());
2✔
179
    if (attrs.hasAttribute(KXMLShowFunctionColor))
2✔
180
        setColor(QColor(attrs.value(KXMLShowFunctionColor).toString()));
1✔
181
    if (attrs.hasAttribute(KXMLShowFunctionLocked))
2✔
182
        setLocked(true);
1✔
183

184
    root.skipCurrentElement();
2✔
185

186
    return true;
2✔
187
}
188

189
bool ShowFunction::saveXML(QXmlStreamWriter *doc, quint32 trackId) const
2✔
190
{
191
    Q_ASSERT(doc != NULL);
2✔
192

193
    /* Main tag */
194
    doc->writeStartElement(KXMLShowFunction);
2✔
195

196
    /* Attributes */
197
    if (trackId != UINT_MAX)
2✔
198
    {
NEW
199
        doc->writeAttribute(KXMLShowFunctionUid, QString::number(m_id));
×
NEW
200
        doc->writeAttribute(KXMLShowFunctionTrackId, QString::number(trackId));
×
201
    }
202
    doc->writeAttribute(KXMLShowFunctionID, QString::number(functionID()));
2✔
203
    doc->writeAttribute(KXMLShowFunctionStartTime, QString::number(startTime()));
2✔
204
    if (m_duration)
2✔
205
        doc->writeAttribute(KXMLShowFunctionDuration, QString::number(m_duration));
1✔
206
    if (color().isValid())
2✔
207
        doc->writeAttribute(KXMLShowFunctionColor, color().name());
1✔
208
    if (isLocked())
2✔
209
        doc->writeAttribute(KXMLShowFunctionLocked, QString::number(m_locked));
1✔
210

211
    doc->writeEndElement();
2✔
212

213
    return true;
2✔
214
}
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

© 2025 Coveralls, Inc