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

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 hits per line

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

5.88
/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()
177✔
28
{
29
}
177✔
30

31
bool QLCModifiersCache::addModifier(ChannelModifier *modifier)
×
32
{
33
    if (m_modifiers.contains(modifier->name()))
×
34
        return false;
35

36
    //qDebug() << "[QLCModifiersCache] added modifier" << modifier->name();
37
    m_modifiers[modifier->name()] = modifier;
×
38
    return true;
×
39
}
40

41
QList<QString> QLCModifiersCache::templateNames()
×
42
{
43
    return m_modifiers.keys();
×
44
}
45

46
ChannelModifier *QLCModifiersCache::modifier(QString name)
×
47
{
48
    if (m_modifiers.contains(name))
×
49
        return m_modifiers[name];
×
50

51
    return NULL;
52
}
53

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

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

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

69
    if (dir.exists() == false || dir.isReadable() == false)
×
70
        return false;
×
71

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

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

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

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

111
    return true;
112
}
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