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

mcallegari / qlcplus / 26064181639

18 May 2026 10:29PM UTC coverage: 35.004% (-0.03%) from 35.037%
26064181639

Pull #2025

github

web-flow
Merge 108f14ffe into 2aa9da5af
Pull Request #2025: Fix Show Manager edge cases around timing and previews

0 of 70 new or added lines in 6 files covered. (0.0%)

6 existing lines in 1 file now uncovered.

18293 of 52259 relevant lines covered (35.0%)

41120.83 hits per line

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

0.0
/ui/src/showmanager/sequenceitem.cpp
1
/*
2
  Q Light Controller Plus
3
  sequenceitem.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 <QMenu>
23

24
#include "sequenceitem.h"
25
#include "chaserstep.h"
26
#include "trackitem.h"
27

28
SequenceItem::SequenceItem(Chaser *seq, ShowFunction *func)
×
29
    : ShowItem(func)
30
    , m_chaser(seq)
×
31
    , m_selectedStep(-1)
×
32
{
33
    Q_ASSERT(seq != NULL);
×
34

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

40
    if (func->duration() == 0)
×
41
        func->setDuration(seq->totalDuration());
×
42

43
    calculateWidth();
×
44

45
    connect(m_chaser, SIGNAL(changed(quint32)),
×
46
            this, SLOT(slotSequenceChanged(quint32)));
47
}
×
48

49
void SequenceItem::calculateWidth()
×
50
{
51
    int newWidth = 0;
×
52
    quint32 seq_duration = m_chaser->totalDuration();
×
53
    float timeUnit = 50.0 / float(getTimeScale());
×
54

55
    if (seq_duration == Function::infiniteSpeed())
×
56
    {
57
        newWidth = timeUnit * 10000;
×
58
    }
59
    else
60
    {
61
        if (seq_duration != 0)
×
62
            newWidth = (timeUnit * float(seq_duration)) / 1000.0;
×
63

64
        if (newWidth < timeUnit)
×
65
            newWidth = timeUnit;
×
66
    }
67
    setWidth(newWidth);
×
68
}
×
69

70
void SequenceItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
×
71
{
72
    float xpos = 0;
×
73
    float timeUnit = 50.0 / float(m_timeScale);
×
74
    int stepIdx = 0;
×
75

76
    ShowItem::paint(painter, option, widget);
×
77

78
    if (this->isSelected() == false)
×
79
        m_selectedStep = -1;
×
80

81
    foreach (ChaserStep step, m_chaser->steps())
×
82
    {
83
        uint stepFadeIn = step.fadeIn;
×
84
        uint stepFadeOut = step.fadeOut;
×
85
        uint stepDuration = step.duration;
×
86

87
        if (m_chaser->fadeInMode() == Chaser::Common)
×
88
            stepFadeIn = m_chaser->fadeInSpeed();
×
89
        if (m_chaser->fadeOutMode() == Chaser::Common)
×
90
            stepFadeOut = m_chaser->fadeOutSpeed();
×
91
        if (m_chaser->durationMode() == Chaser::Common)
×
92
            stepDuration = m_chaser->duration();
×
93

94
        // avoid hanging on infinite duration
95
        if (stepDuration == Function::infiniteSpeed())
×
96
            stepDuration = 10 * 1000 * 1000;
×
97

98
        // draw fade in line
99
        if (stepFadeIn > 0)
×
100
        {
101
            int fadeXpos = xpos + ((timeUnit * (float)stepFadeIn) / 1000);
×
NEW
102
            fadeXpos = qMin(fadeXpos, getWidth());
×
103
            // doesn't even draw it if too small
104
            if (fadeXpos - xpos > 5)
×
105
            {
106
                painter->setPen(QPen(Qt::gray, 1));
×
107
                painter->drawLine(xpos, TRACK_HEIGHT - 4, fadeXpos, 1);
×
108
            }
109
        }
110
        float stepWidth = ((timeUnit * (float)stepDuration) / 1000);
×
111
        // draw selected step
112
        if (stepIdx == m_selectedStep)
×
113
        {
114
            painter->setPen(QPen(Qt::yellow, 2));
×
115
            painter->setBrush(QBrush(Qt::NoBrush));
×
116
            painter->drawRect(xpos, 0, stepWidth, TRACK_HEIGHT - 3);
×
117
        }
118

119
        QRect textRect = QRect(xpos + 1, 0, stepWidth - 1, TRACK_HEIGHT - 3);
×
120
        painter->drawText(textRect, Qt::AlignBottom, step.note);
×
121

122
        xpos += stepWidth;
×
123

124
        // draw step vertical delimiter
125
        painter->setPen(QPen(Qt::white, 1));
×
126
        painter->drawLine(xpos, 1, xpos, TRACK_HEIGHT - 5);
×
127

128
        // draw fade out line
129
        if (stepFadeOut > 0)
×
130
        {
131
            int fadeXpos = xpos + ((timeUnit * (float)stepFadeOut) / 1000);
×
NEW
132
            fadeXpos = qMin(fadeXpos, getWidth());
×
133
            // doesn't even draw it if too small
134
            if (fadeXpos - xpos > 5)
×
135
            {
136
                painter->setPen(QPen(Qt::gray, 1));
×
137
                painter->drawLine(xpos, 1, fadeXpos, TRACK_HEIGHT - 4);
×
138
            }
139
        }
140
        stepIdx++;
×
141
    }
×
142

143
    ShowItem::postPaint(painter);
×
144
}
×
145

146
void SequenceItem::setTimeScale(int val)
×
147
{
148
    ShowItem::setTimeScale(val);
×
149
    calculateWidth();
×
150
}
×
151

152
void SequenceItem::setDuration(quint32 msec, bool stretch)
×
153
{
154
    Q_UNUSED(stretch)
155
    m_chaser->setTotalDuration(msec);
×
156
}
×
157

158
QString SequenceItem::functionName() const
×
159
{
160
    if (m_chaser)
×
161
        return m_chaser->name();
×
162
    return QString();
×
163
}
164

165
void SequenceItem::setSelectedStep(int idx)
×
166
{
167
    m_selectedStep = idx;
×
168
    update();
×
169
}
×
170

171
Chaser *SequenceItem::getChaser() const
×
172
{
173
    return m_chaser;
×
174
}
175

176
void SequenceItem::slotSequenceChanged(quint32)
×
177
{
178
    prepareGeometryChange();
×
179
    calculateWidth();
×
180
    if (m_function)
×
181
        m_function->setDuration(m_chaser->totalDuration());
×
182
    updateTooltip();
×
183
}
×
184

185
void SequenceItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *)
×
186
{
187
    QMenu menu;
×
188
    QFont menuFont = qApp->font();
×
189
    menuFont.setPixelSize(14);
×
190
    menu.setFont(menuFont);
×
191

192
    foreach (QAction *action, getDefaultActions())
×
193
        menu.addAction(action);
×
194

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