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

mcallegari / qlcplus / 10668847825

02 Sep 2024 02:18PM UTC coverage: 31.426% (-0.07%) from 31.498%
10668847825

push

github

web-flow
Merge pull request #1610 from Ledjlale/fix/qt6_rebase2

qmltoqt6 rebasing

25 of 290 new or added lines in 19 files covered. (8.62%)

25 existing lines in 11 files now uncovered.

15012 of 47769 relevant lines covered (31.43%)

19745.74 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

UNCOV
27
VCSpeedDialFunction::VCSpeedDialFunction(quint32 aFid, SpeedMultiplier aFadeIn,
×
UNCOV
28
                                         SpeedMultiplier aFadeOut, SpeedMultiplier aDuration)
×
29
    : functionId(aFid)
30
    , fadeInMultiplier(aFadeIn)
31
    , fadeOutMultiplier(aFadeOut)
32
    , durationMultiplier(aDuration)
×
33
{
34
}
×
35

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

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

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

68
    return true;
×
69
}
70

71
bool VCSpeedDialFunction::saveXML(QXmlStreamWriter *doc) const
×
72
{
73
    Q_ASSERT(doc != NULL);
×
74

75
    /* Function tag */
76
    doc->writeStartElement(KXMLQLCFunction);
×
77

78
    /* Multipliers */
79
    doc->writeAttribute(KXMLQLCFunctionSpeedFadeIn, QString::number(fadeInMultiplier));
×
80
    doc->writeAttribute(KXMLQLCFunctionSpeedFadeOut, QString::number(fadeOutMultiplier));
×
81
    doc->writeAttribute(KXMLQLCFunctionSpeedDuration, QString::number(durationMultiplier));
×
82

83
    /* Function ID */
84
    doc->writeCharacters(QString::number(functionId));
×
85

86
    /* Close the <Function> tag */
87
    doc->writeEndElement();
×
88

89
    return true;
×
90
}
91

92
const QStringList &VCSpeedDialFunction::speedMultiplierNames()
×
93
{
94
    static QStringList *names = 0;
95

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

112
    return *names;
×
113
}
114

115
const QVector <quint32> &VCSpeedDialFunction::speedMultiplierValuesTimes1000()
×
116
{
117
    static QVector <quint32> *values = 0;
118

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

135
    return *values;
×
136
}
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