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

mcallegari / qlcplus / 18357067171

08 Oct 2025 08:16PM UTC coverage: 34.26% (+2.2%) from 32.066%
18357067171

push

github

mcallegari
Merge branch 'master' into filedialog

1282 of 4424 new or added lines in 152 files covered. (28.98%)

1342 existing lines in 152 files now uncovered.

17704 of 51675 relevant lines covered (34.26%)

19430.31 hits per line

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

75.0
/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)
193✔
41
    : m_doc(doc)
193✔
42
{
43
}
193✔
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✔
NEW
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;
1✔
72
    RGBPlain plain(doc);
1✔
73
    RGBText text(doc);
1✔
74
    RGBImage image(doc);
1✔
75
    RGBAudio audio(doc);
1✔
76
    list << plain.name();
1✔
77
    list << text.name();
1✔
78
    list << image.name();
1✔
79
    list << audio.name();
1✔
80
    list << doc->rgbScriptsCache()->names();
1✔
81
    return list;
2✔
82
}
1✔
83

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

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

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

110
    if (root.name() != KXMLQLCRGBAlgorithm)
5✔
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();
×
UNCOV
122
    }
×
123
    else if (type == KXMLQLCRGBText)
3✔
124
    {
125
        RGBText text(doc);
1✔
126
        if (text.loadXML(root) == true)
1✔
127
            algo = text.clone();
1✔
128
    }
1✔
129
    else if (type == KXMLQLCRGBAudio)
2✔
130
    {
131
        RGBAudio audio(doc);
×
132
        if (audio.loadXML(root) == true)
×
133
            algo = audio.clone();
×
UNCOV
134
    }
×
135
    else if (type == KXMLQLCRGBScript)
2✔
136
    {
137
        RGBScript* scr = doc->rgbScriptsCache()->script(root.readElementText());
2✔
138
        if (scr->apiVersion() > 0 && scr->name().isEmpty() == false)
2✔
139
            algo = scr;
2✔
140
        else
NEW
141
            delete scr;
×
142
    }
143
    else if (type == KXMLQLCRGBPlain)
×
144
    {
145
        RGBPlain plain(doc);
×
146
        if (plain.loadXML(root) == true)
×
147
            algo = plain.clone();
×
UNCOV
148
    }
×
149
    else
150
    {
151
        qWarning() << "Unrecognized RGB algorithm type:" << type;
×
152
    }
153

154
    return algo;
3✔
155
}
3✔
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