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

mcallegari / qlcplus / 6683238402

29 Oct 2023 12:10PM UTC coverage: 28.07%. Remained the same
6683238402

push

github

mcallegari
engine: fix build

15385 of 54809 relevant lines covered (28.07%)

20267.63 hits per line

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

0.0
/ui/src/virtualconsole/vcspeeddialfunction.cpp
1
/*
2
  Q Light Controller Plus
3
  vcspeeddialfunction.cpp
4

5
  Copyright (C) 2014 David Garyga
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 "vcspeeddialfunction.h"
25
#include "function.h"
26

27
#define KXMLQLCSequenceSceneValues "Values"
28
#define KXMLQLCStepNote "Note"
29

30
VCSpeedDialFunction::VCSpeedDialFunction(quint32 aFid, SpeedMultiplier aFadeIn,
×
31
                                         SpeedMultiplier aFadeOut, SpeedMultiplier aDuration)
×
32
    : functionId(aFid)
33
    , fadeInMultiplier(aFadeIn)
34
    , fadeOutMultiplier(aFadeOut)
35
    , durationMultiplier(aDuration)
×
36
{
37
}
×
38

39
bool VCSpeedDialFunction::loadXML(QXmlStreamReader &root, SpeedMultiplier aFadeIn,
×
40
                                  SpeedMultiplier aFadeOut, SpeedMultiplier aDuration)
41
{
42
    if (root.name() != KXMLQLCFunction)
×
43
    {
44
        qWarning() << Q_FUNC_INFO << "Function node not found";
×
45
        return false;
×
46
    }
47

48
    QXmlStreamAttributes attrs = root.attributes();
×
49
    QString text = root.readElementText();
×
50
    if (text.isEmpty())
×
51
    {
52
        qWarning() << Q_FUNC_INFO << "Function ID not found";
×
53
        return false;
×
54
    }
55
    functionId = text.toUInt();
×
56

57
    // For each multiplier: If not present in XML, use default value.
58
    if (attrs.hasAttribute(KXMLQLCFunctionSpeedFadeIn) == true)
×
59
        fadeInMultiplier = static_cast<SpeedMultiplier>(attrs.value(KXMLQLCFunctionSpeedFadeIn).toString().toUInt());
×
60
    else
61
        fadeInMultiplier = aFadeIn;
×
62
    if (attrs.hasAttribute(KXMLQLCFunctionSpeedFadeOut) == true)
×
63
        fadeOutMultiplier = static_cast<SpeedMultiplier>(attrs.value(KXMLQLCFunctionSpeedFadeOut).toString().toUInt());
×
64
    else
65
        fadeOutMultiplier = aFadeOut;
×
66
    if (attrs.hasAttribute(KXMLQLCFunctionSpeedDuration) == true)
×
67
        durationMultiplier = static_cast<SpeedMultiplier>(attrs.value(KXMLQLCFunctionSpeedDuration).toString().toUInt());
×
68
    else
69
        durationMultiplier = aDuration;
×
70

71
    return true;
×
72
}
73

74
bool VCSpeedDialFunction::saveXML(QXmlStreamWriter *doc) const
×
75
{
76
    Q_ASSERT(doc != NULL);
×
77

78
    /* Function tag */
79
    doc->writeStartElement(KXMLQLCFunction);
×
80

81
    /* Multipliers */
82
    doc->writeAttribute(KXMLQLCFunctionSpeedFadeIn, QString::number(fadeInMultiplier));
×
83
    doc->writeAttribute(KXMLQLCFunctionSpeedFadeOut, QString::number(fadeOutMultiplier));
×
84
    doc->writeAttribute(KXMLQLCFunctionSpeedDuration,QString::number( durationMultiplier));
×
85

86
    /* Function ID */
87
    doc->writeCharacters(QString::number(functionId));
×
88

89
    /* Close the <Function> tag */
90
    doc->writeEndElement();
×
91

92
    return true;
×
93
}
94

95
const QStringList &VCSpeedDialFunction::speedMultiplierNames()
×
96
{
97
    static QStringList *names = 0;
98

99
    if (names == 0)
×
100
    {
101
        names = new QStringList;
×
102
        *names << "(Not Sent)";
×
103
        *names << "0";
×
104
        *names << "1/16";
×
105
        *names << "1/8";
×
106
        *names << "1/4";
×
107
        *names << "1/2";
×
108
        *names << "1";
×
109
        *names << "2";
×
110
        *names << "4";
×
111
        *names << "8";
×
112
        *names << "16";
×
113
    }
114

115
    return *names;
×
116
}
117

118
const QVector <quint32> &VCSpeedDialFunction::speedMultiplierValuesTimes1000()
×
119
{
120
    static QVector <quint32> *values = 0;
121

122
    if (values == 0)
×
123
    {
124
        values = new QVector <quint32>;
×
125
        *values << 0; // None
×
126
        *values << 0; // Zero
×
127
        *values << 1000 / 16;
×
128
        *values << 1000 / 8;
×
129
        *values << 1000 / 4;
×
130
        *values << 1000 / 2;
×
131
        *values << 1000;
×
132
        *values << 1000 * 2;
×
133
        *values << 1000 * 4;
×
134
        *values << 1000 * 8;
×
135
        *values << 1000 * 16;
×
136
    }
137

138
    return *values;
×
139
}
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