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

mcallegari / qlcplus / 14445404527

14 Apr 2025 12:17PM UTC coverage: 31.854% (-0.05%) from 31.907%
14445404527

push

github

web-flow
Merge pull request #1714 from shaforostoff/webaccess_optimize_loadxml

engine: speedup loadXML methods by using QStringLiteral

1 of 1 new or added line in 1 file covered. (100.0%)

220 existing lines in 5 files now uncovered.

14674 of 46067 relevant lines covered (31.85%)

26455.49 hits per line

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

13.89
/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
QLCModifiersCache::~QLCModifiersCache()
177✔
32
{
33
    qDeleteAll(m_modifiers);
177✔
34
}
177✔
35

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

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

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

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

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

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

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

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

74
    ChannelModifier::Type type;
UNCOV
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 */
UNCOV
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
        {
UNCOV
88
            ChannelModifier* chMod = new ChannelModifier();
×
89
            Q_ASSERT(chMod != NULL);
90

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

© 2025 Coveralls, Inc