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

mcallegari / qlcplus / 12611954629

04 Jan 2025 04:17PM UTC coverage: 31.468% (-0.5%) from 31.963%
12611954629

Pull #1649

github

web-flow
Merge d17d3ec9b into 3ed321c32
Pull Request #1649: Function Wizard: create Effects

2 of 53 new or added lines in 2 files covered. (3.77%)

2597 existing lines in 15 files now uncovered.

14093 of 44785 relevant lines covered (31.47%)

26791.82 hits per line

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

78.13
/engine/src/rgbalgorithm.cpp
1
/*
2
  Q Light Controller Plus
3
  rgbalgorithm.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 <QStringList>
24
#include <QDebug>
25

26
#include "rgbscriptscache.h"
27
#include "rgbalgorithm.h"
28
#include "rgbaudio.h"
29
#include "rgbimage.h"
30
#include "rgbplain.h"
31
#include "rgbtext.h"
32
#include "doc.h"
33

34
#ifdef QT_QML_LIB
35
  #include "rgbscriptv4.h"
36
#else
37
  #include "rgbscript.h"
38
#endif
39

40
RGBAlgorithm::RGBAlgorithm(Doc * doc)
457✔
41
    : m_doc(doc)
457✔
42
{
43
}
457✔
44

45
void RGBAlgorithm::setColors(QVector<QColor> colors)
17✔
46
{
47
    int nCols = acceptColors();
17✔
48
    m_colors.clear();
17✔
49

50
    for (int i = 0; i < nCols; i++)
54✔
51
    {
52
        if (i < colors.count())
37✔
53
            m_colors.append(colors.at(i));
35✔
54
    }
55
}
17✔
56

57
QColor RGBAlgorithm::getColor(uint i) const
3✔
58
{
59
    if (i >= (uint)m_colors.count())
3✔
60
        return QColor();
61

62
    return m_colors[i];
3✔
63
}
64

65
/****************************************************************************
66
 * Available algorithms
67
 ****************************************************************************/
68

69
QStringList RGBAlgorithm::algorithms(Doc * doc)
1✔
70
{
71
    QStringList list;
72
    RGBPlain plain(doc);
2✔
73
    RGBText text(doc);
2✔
74
    RGBImage image(doc);
2✔
75
    RGBAudio audio(doc);
1✔
76
    list << plain.name();
2✔
77
    list << text.name();
2✔
78
    list << image.name();
2✔
79
    list << audio.name();
2✔
80
    list << doc->rgbScriptsCache()->names();
2✔
81
    return list;
1✔
82
}
83

84
RGBAlgorithm* RGBAlgorithm::algorithm(Doc * doc, const QString& name)
7✔
85
{
86
    RGBText text(doc);
14✔
87
    RGBImage image(doc);
14✔
88
    RGBAudio audio(doc);
14✔
89
    RGBPlain plain(doc);
14✔
90
    if (name == text.name())
7✔
91
        return text.clone();
1✔
92
    else if (name == image.name())
6✔
UNCOV
93
        return image.clone();
×
94
    else if (name == audio.name())
6✔
UNCOV
95
        return audio.clone();
×
96
    else if (name == plain.name())
6✔
UNCOV
97
        return plain.clone();
×
98
    else
99
        return doc->rgbScriptsCache()->script(name).clone();
12✔
100
}
101

102
/****************************************************************************
103
 * Load & Save
104
 ****************************************************************************/
105

106
RGBAlgorithm* RGBAlgorithm::loader(Doc * doc, QXmlStreamReader &root)
5✔
107
{
108
    RGBAlgorithm* algo = NULL;
109

110
    if (root.name() != KXMLQLCRGBAlgorithm)
10✔
111
    {
112
        qWarning() << Q_FUNC_INFO << "RGB Algorithm node not found";
2✔
113
        return NULL;
2✔
114
    }
115

116
    QString type = root.attributes().value(KXMLQLCRGBAlgorithmType).toString();
6✔
117
    if (type == KXMLQLCRGBImage)
3✔
118
    {
119
        RGBImage image(doc);
×
120
        if (image.loadXML(root) == true)
×
121
            algo = image.clone();
×
122
    }
123
    else if (type == KXMLQLCRGBText)
3✔
124
    {
125
        RGBText text(doc);
2✔
126
        if (text.loadXML(root) == true)
1✔
127
            algo = text.clone();
1✔
128
    }
129
    else if (type == KXMLQLCRGBAudio)
2✔
130
    {
131
        RGBAudio audio(doc);
×
132
        if (audio.loadXML(root) == true)
×
133
            algo = audio.clone();
×
134
    }
135
    else if (type == KXMLQLCRGBScript)
2✔
136
    {
137
        RGBScript const& scr = doc->rgbScriptsCache()->script(root.readElementText());
2✔
138
        if (scr.apiVersion() > 0 && scr.name().isEmpty() == false)
2✔
139
            algo = scr.clone();
2✔
140
    }
UNCOV
141
    else if (type == KXMLQLCRGBPlain)
×
142
    {
UNCOV
143
        RGBPlain plain(doc);
×
UNCOV
144
        if (plain.loadXML(root) == true)
×
UNCOV
145
            algo = plain.clone();
×
146
    }
147
    else
148
    {
UNCOV
149
        qWarning() << "Unrecognized RGB algorithm type:" << type;
×
150
    }
151

152
    return algo;
153
}
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