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

mcallegari / qlcplus / 19144422256

06 Nov 2025 05:33PM UTC coverage: 34.256% (-0.1%) from 34.358%
19144422256

push

github

mcallegari
Back to 5.1.0 debug

17718 of 51723 relevant lines covered (34.26%)

19528.23 hits per line

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

31.11
/engine/src/qlcmodifierscache.cpp
1
/*
2
  Q Light Controller Plus
3
  qlcmodifierscache.cpp
4

5
  Copyright (c) Massimo Callegari
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 <QDebug>
21

22
#include "qlcmodifierscache.h"
23
#include "channelmodifier.h"
24
#include "qlcconfig.h"
25
#include "qlcfile.h"
26

27
QLCModifiersCache::QLCModifiersCache()
197✔
28
{
29
}
197✔
30

31
QLCModifiersCache::~QLCModifiersCache()
197✔
32
{
33
    qDeleteAll(m_modifiers);
197✔
34
}
197✔
35

36
bool QLCModifiersCache::addModifier(ChannelModifier *modifier)
3✔
37
{
38
    if (m_modifiers.contains(modifier->name()))
3✔
39
        return false;
1✔
40

41
    //qDebug() << "[QLCModifiersCache] added modifier" << modifier->name();
42
    m_modifiers[modifier->name()] = modifier;
2✔
43
    return true;
2✔
44
}
45

46
QList<QString> QLCModifiersCache::templateNames()
1✔
47
{
48
    return m_modifiers.keys();
1✔
49
}
50

51
ChannelModifier *QLCModifiersCache::modifier(QString name)
2✔
52
{
53
    return m_modifiers.value(name, NULL);
2✔
54
}
55

56
QDir QLCModifiersCache::systemTemplateDirectory()
×
57
{
58
    return QLCFile::systemDirectory(QString(MODIFIERSTEMPLATEDIR), QString(KExtModifierTemplate));
×
59
}
60

61
QDir QLCModifiersCache::userTemplateDirectory()
×
62
{
63
    return QLCFile::userDirectory(QString(USERMODIFIERSTEMPLATEDIR), QString(MODIFIERSTEMPLATEDIR),
×
64
                                  QStringList() << QString("*%1").arg(KExtModifierTemplate));
×
65
}
66

67
bool QLCModifiersCache::load(const QDir& dir, bool systemTemplates)
×
68
{
69
    qDebug() << Q_FUNC_INFO << dir.path();
×
70

71
    if (dir.exists() == false || dir.isReadable() == false)
×
72
        return false;
×
73

74
    ChannelModifier::Type type;
75
    if (systemTemplates ==true)
×
76
        type = ChannelModifier::SystemTemplate;
×
77
    else
78
        type = ChannelModifier::UserTemplate;
×
79

80
    /* Attempt to read all specified files from the given directory */
81
    QStringListIterator it(dir.entryList());
×
82
    while (it.hasNext() == true)
×
83
    {
84
        QString path(dir.absoluteFilePath(it.next()));
×
85

86
        if (path.toLower().endsWith(KExtModifierTemplate) == true)
×
87
        {
88
            ChannelModifier* chMod = new ChannelModifier();
×
89
            Q_ASSERT(chMod != NULL);
×
90

91
            QFile::FileError error = chMod->loadXML(path, type);
×
92
            if (error == QFile::NoError)
×
93
            {
94
                /* Delete the modifier if it's a duplicate. */
95
                if (addModifier(chMod) == false)
×
96
                {
97
                    delete chMod;
×
98
                    chMod = NULL;
×
99
                }
100
            }
101
            else
102
            {
103
                qWarning() << Q_FUNC_INFO << "Channel modifier template loading from"
×
104
                           << path << "failed:" << QLCFile::errorString(error);
×
105
                delete chMod;
×
106
                chMod = NULL;
×
107
            }
108
        }
109
        else
110
            qWarning() << Q_FUNC_INFO << "Unrecognized template extension:" << path;
×
111
    }
×
112

113
    return true;
×
114
}
×
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