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

mcallegari / qlcplus / 10668847825

02 Sep 2024 02:18PM UTC coverage: 31.426% (-0.07%) from 31.498%
10668847825

push

github

web-flow
Merge pull request #1610 from Ledjlale/fix/qt6_rebase2

qmltoqt6 rebasing

25 of 290 new or added lines in 19 files covered. (8.62%)

25 existing lines in 11 files now uncovered.

15012 of 47769 relevant lines covered (31.43%)

19745.74 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;
×
NEW
52
    quint32 seq_duration = m_chaser->totalDuration();
×
NEW
53
    float timeUnit = 50.0 / float(getTimeScale());
×
54

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

NEW
64
        if (newWidth < timeUnit)
×
NEW
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;
×
NEW
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
        if (m_chaser->fadeInMode() == Chaser::Common)
×
87
            stepFadeIn = m_chaser->fadeInSpeed();
×
88
        if (m_chaser->fadeOutMode() == Chaser::Common)
×
89
            stepFadeOut = m_chaser->fadeOutSpeed();
×
90
        if (m_chaser->durationMode() == Chaser::Common)
×
91
            stepDuration = m_chaser->duration();
×
92

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

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

118
        // draw step vertical delimiter
119
        painter->setPen(QPen(Qt::white, 1));
×
120
        painter->drawLine(xpos, 1, xpos, TRACK_HEIGHT - 5);
×
121

122
        // draw fade out line
123
        if (stepFadeOut > 0)
×
124
        {
NEW
125
            int fadeXpos = xpos + ((timeUnit * (float)stepFadeOut) / 1000);
×
126
            // doesn't even draw it if too small
127
            if (fadeXpos - xpos > 5)
×
128
            {
129
                painter->setPen(QPen(Qt::gray, 1));
×
130
                painter->drawLine(xpos, 1, fadeXpos, TRACK_HEIGHT - 4);
×
131
            }
132
        }
133
        stepIdx++;
×
134
    }
135

136
    ShowItem::postPaint(painter);
×
137
}
×
138

139
void SequenceItem::setTimeScale(int val)
×
140
{
141
    ShowItem::setTimeScale(val);
×
142
    calculateWidth();
×
143
}
×
144

145
void SequenceItem::setDuration(quint32 msec, bool stretch)
×
146
{
147
    Q_UNUSED(stretch)
148
    m_chaser->setTotalDuration(msec);
×
149
}
×
150

151
QString SequenceItem::functionName()
×
152
{
153
    if (m_chaser)
×
154
        return m_chaser->name();
×
155
    return QString();
×
156
}
157

158
void SequenceItem::setSelectedStep(int idx)
×
159
{
160
    m_selectedStep = idx;
×
161
    update();
×
162
}
×
163

164
Chaser *SequenceItem::getChaser()
×
165
{
166
    return m_chaser;
×
167
}
168

169
void SequenceItem::slotSequenceChanged(quint32)
×
170
{
171
    prepareGeometryChange();
×
172
    calculateWidth();
×
173
    if (m_function)
×
174
        m_function->setDuration(m_chaser->totalDuration());
×
175
    updateTooltip();
×
176
}
×
177

178
void SequenceItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *)
×
179
{
180
    QMenu menu;
×
181
    QFont menuFont = qApp->font();
×
182
    menuFont.setPixelSize(14);
×
183
    menu.setFont(menuFont);
×
184

185
    foreach (QAction *action, getDefaultActions())
×
186
        menu.addAction(action);
×
187

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