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

mcallegari / qlcplus / 11388022654

17 Oct 2024 03:21PM UTC coverage: 31.573% (-0.4%) from 31.983%
11388022654

Pull #1422

github

web-flow
Merge 4147c937e into 5f77fc96f
Pull Request #1422: RgbScript make stage colors available to scripts

56 of 908 new or added lines in 11 files covered. (6.17%)

12 existing lines in 8 files now uncovered.

14057 of 44522 relevant lines covered (31.57%)

26666.02 hits per line

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

74.6
/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)
481✔
41
    : m_doc(doc)
481✔
42
{
43
}
481✔
44

45
void RGBAlgorithm::setColors(QVector<QColor> colors)
21✔
46
{
47
    m_colors.clear();
21✔
48
    QVectorIterator<QColor> it(colors);
49
    int count = 0;
50
    while (it.hasNext()) {
126✔
51
        QColor color = it.next();
52
        if (acceptColors() < count)
105✔
53
            m_colors.append(color);
42✔
54
        count ++;
105✔
55
    }
56
}
21✔
57

NEW
58
QColor RGBAlgorithm::getColor(uint i) const
×
59
{
NEW
60
    return m_colors[i];
×
61
}
62

63
/****************************************************************************
64
 * Available algorithms
65
 ****************************************************************************/
66

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

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

100
/****************************************************************************
101
 * Load & Save
102
 ****************************************************************************/
103

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

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

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

150
    return algo;
151
}
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