• 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

0.0
/ui/src/showmanager/efxitem.cpp
1
/*
2
  Q Light Controller Plus
3
  efxitem.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 <QApplication>
21
#include <QPainter>
22
#include <qmath.h>
23
#include <QDebug>
24
#include <QMenu>
25
#include <qmath.h>
26

27
#include "efxitem.h"
28
#include "trackitem.h"
29

30
EFXItem::EFXItem(EFX *efx, ShowFunction *func)
×
31
    : ShowItem(func)
32
    , m_efx(efx)
×
33
{
34
    Q_ASSERT(efx != NULL);
×
35

36
    if (func->color().isValid())
×
37
        setColor(func->color());
×
38
    else
39
        setColor(ShowFunction::defaultColor(Function::EFXType));
×
40

41
    calculateWidth();
×
42
    connect(m_efx, SIGNAL(changed(quint32)), this, SLOT(slotEFXChanged(quint32)));
×
43
}
×
44

45
void EFXItem::calculateWidth()
×
46
{
47
    int newWidth = 0;
×
48
    qint64 efxDuration = getDuration();
×
49
    float timeUnit = 50.0 / float(getTimeScale());
×
50

51
    if (efxDuration == 0)
×
52
    {
53
        newWidth = 100;
×
54
    }
55
    else if (efxDuration == Function::infiniteSpeed())
×
56
    {
57
        newWidth = timeUnit * 10000;
×
58
    }
59
    else
60
    {
61
        newWidth = (timeUnit * float(efxDuration)) / 1000.0;
×
62
    }
63

64
    if (newWidth < timeUnit)
×
65
        newWidth = timeUnit;
×
66

67
    setWidth(newWidth);
×
68
}
×
69

70
void EFXItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
×
71
{
72
    Q_UNUSED(option);
73
    Q_UNUSED(widget);
74

75
    float xpos = 0;
×
76
    float timeUnit = 50.0 / float(getTimeScale());
×
77

78
    ShowItem::paint(painter, option, widget);
×
79

80
    int loopCount = 0;
×
81
    if (getDuration() == Function::infiniteSpeed())
×
82
        loopCount = 10000 / m_efx->duration();
×
83
    else if (getDuration() > 0)
×
84
        loopCount = qFloor(getDuration() / m_efx->duration());
×
85

86
    for (int i = 0; i < loopCount; i++)
×
87
    {
88
        xpos += ((timeUnit * float(m_efx->duration())) / 1000);
×
89
        // draw loop vertical delimiter
90
        painter->setPen(QPen(Qt::white, 1));
×
91
        painter->drawLine(int(xpos), 1, int(xpos), TRACK_HEIGHT - 5);
×
92
    }
93

94
    ShowItem::postPaint(painter);
×
95
}
×
96

97
void EFXItem::setTimeScale(int val)
×
98
{
99
    ShowItem::setTimeScale(val);
×
100
    calculateWidth();
×
101
}
×
102

103
void EFXItem::setDuration(quint32 msec, bool stretch)
×
104
{
105
    if (stretch == true)
×
106
    {
107
        m_efx->setDuration(msec);
×
108
    }
109
    else
110
    {
111
        if (m_function)
×
112
            m_function->setDuration(msec);
×
113
        prepareGeometryChange();
×
114
        calculateWidth();
×
115
        updateTooltip();
×
116
    }
117
}
×
118

119
quint32 EFXItem::getDuration()
×
120
{
121
    return m_function->duration() ? m_function->duration() : m_efx->duration();
×
122
}
123

124
QString EFXItem::functionName()
×
125
{
126
    if (m_efx)
×
127
        return m_efx->name();
×
128
    return QString();
×
129
}
130

131
EFX *EFXItem::getEFX()
×
132
{
133
    return m_efx;
×
134
}
135

136
void EFXItem::slotEFXChanged(quint32)
×
137
{
138
    prepareGeometryChange();
×
139
    calculateWidth();
×
140
    updateTooltip();
×
141
}
×
142

143
void EFXItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *)
×
144
{
145
    QMenu menu;
×
146
    QFont menuFont = qApp->font();
×
147
    menuFont.setPixelSize(14);
×
148
    menu.setFont(menuFont);
×
149

150
    foreach (QAction *action, getDefaultActions())
×
151
        menu.addAction(action);
×
152

153
    menu.exec(QCursor::pos());
×
154
}
×
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