• 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/rgbmatrixitem.cpp
1
/*
2
  Q Light Controller Plus
3
  rgbmatrixitem.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

26
#include "rgbmatrixitem.h"
27
#include "trackitem.h"
28

29
RGBMatrixItem::RGBMatrixItem(RGBMatrix *rgbm, ShowFunction *func)
×
30
    : ShowItem(func)
31
    , m_matrix(rgbm)
×
32
{
33
    Q_ASSERT(rgbm != NULL);
×
34

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

40
    calculateWidth();
×
41
    connect(m_matrix, SIGNAL(changed(quint32)), this, SLOT(slotRGBMatrixChanged(quint32)));
×
42
}
×
43

44
void RGBMatrixItem::calculateWidth()
×
45
{
46
    int newWidth = 0;
×
47
    qint64 matrixDuration = getDuration();
×
48

49
    if (matrixDuration != 0)
×
50
        newWidth = ((50 / float(getTimeScale())) * float(matrixDuration)) / 1000;
×
51
    else
52
        newWidth = 100;
×
53

54
    if (newWidth < (50 / m_timeScale))
×
55
        newWidth = 50 / m_timeScale;
×
56
    setWidth(newWidth);
×
57
}
×
58

59
void RGBMatrixItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
×
60
{
61
    Q_UNUSED(option);
62
    Q_UNUSED(widget);
63

64
    float timeScale = 50 / float(m_timeScale);
×
65

66
    ShowItem::paint(painter, option, widget);
×
67

68
    quint32 matrixDuration = getDuration();
×
69

70
    if (matrixDuration)
×
71
    {
72
        float xpos = 0;
×
73
        int loopCount = m_function->duration() ? qFloor(m_function->duration() / m_matrix->totalDuration()) : 0;
×
74

75
        for (int i = 0; i < loopCount; i++)
×
76
        {
77
            xpos += ((timeScale * float(m_matrix->totalDuration())) / 1000);
×
78
            // draw loop vertical delimiter
79
            painter->setPen(QPen(Qt::white, 1));
×
80
            painter->drawLine(int(xpos), 1, int(xpos), TRACK_HEIGHT - 5);
×
81
        }
82
    }
83

84
    ShowItem::postPaint(painter);
×
85
}
×
86

87
void RGBMatrixItem::setTimeScale(int val)
×
88
{
89
    ShowItem::setTimeScale(val);
×
90
    calculateWidth();
×
91
}
×
92

93
void RGBMatrixItem::setDuration(quint32 msec, bool stretch)
×
94
{
95
    if (stretch == true)
×
96
    {
97
        m_matrix->setTotalDuration(msec);
×
98
    }
99
    else
100
    {
101
        if (m_function)
×
102
            m_function->setDuration(msec);
×
103
        prepareGeometryChange();
×
104
        calculateWidth();
×
105
        updateTooltip();
×
106
    }
107
}
×
108

109
quint32 RGBMatrixItem::getDuration()
×
110
{
111
    return m_function->duration() ? m_function->duration() : m_matrix->totalDuration();
×
112
}
113

114
QString RGBMatrixItem::functionName()
×
115
{
116
    if (m_matrix)
×
117
        return m_matrix->name();
×
118
    return QString();
×
119
}
120

121
RGBMatrix *RGBMatrixItem::getRGBMatrix()
×
122
{
123
    return m_matrix;
×
124
}
125

126
void RGBMatrixItem::slotRGBMatrixChanged(quint32)
×
127
{
128
    prepareGeometryChange();
×
129
    calculateWidth();
×
130
    updateTooltip();
×
131
}
×
132

133
void RGBMatrixItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *)
×
134
{
135
    QMenu menu;
×
136
    QFont menuFont = qApp->font();
×
137
    menuFont.setPixelSize(14);
×
138
    menu.setFont(menuFont);
×
139

140
    foreach (QAction *action, getDefaultActions())
×
141
        menu.addAction(action);
×
142

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