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

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 hits per line

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

0.0
/ui/src/showmanager/headeritems.cpp
1
/*
2
  Q Light Controller Plus
3
  headeritems.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 <QPainter>
21

22
#include "headeritems.h"
23

24
/****************************************************************************
25
 *
26
 * Header item
27
 *
28
 ****************************************************************************/
29
ShowHeaderItem::ShowHeaderItem(int width)
×
30
    : m_width(width)
×
31
    , m_height(HEADER_HEIGHT)
×
32
    , m_timeStep(HALF_SECOND_WIDTH)
×
33
    , m_timeHit(2)
×
34
    , m_timeScale(3)
×
35
    , m_BPMValue(120)
×
36
    , m_type(Show::Time)
×
37
{
38
}
×
39

40
void ShowHeaderItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
×
41
{
42
    QGraphicsItem::mousePressEvent(event);
×
43
    emit itemClicked(event);
×
44
}
×
45

46
QRectF ShowHeaderItem::boundingRect() const
×
47
{
48
    return QRectF(0, 0, m_width, m_height);
×
49
}
50

51
void ShowHeaderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
×
52
{
53
    Q_UNUSED(option);
54
    Q_UNUSED(widget);
55

56
    // draw base background
57
    painter->setPen(QPen(QColor(100, 100, 100, 255), 1));
×
58
    painter->setBrush(QBrush(QColor(150, 150, 150, 255)));
×
59
    painter->drawRect(0, 0, m_width, 35);
×
60

61
    if (m_type > Show::Time)
×
62
        m_timeStep = ((float)(120 * HALF_SECOND_WIDTH) / (float)m_BPMValue) / (float)m_timeScale;
×
63

64
    // draw vertical timing lines and time labels
65
    int tmpSec = 0;
66
    for (int i = 0; i < m_width / m_timeStep; i++)
×
67
    {
68
        float xpos = ((float)i * m_timeStep) + 1;
×
69
        painter->setPen(QPen(QColor(250, 250, 250, 255), 1));
×
70
        if (i%m_timeHit == 0)
×
71
        {
72
            painter->drawLine(xpos, 20, xpos, 34);
×
73
            if (m_height > HEADER_HEIGHT)
×
74
            {
75
                painter->setPen(QPen(QColor(105, 105, 105, 255), 1));
×
76
                painter->drawLine(xpos, HEADER_HEIGHT, xpos, m_height);
×
77
            }
78
            painter->setPen(QPen(Qt::black, 1));
×
79
            if (m_type == Show::Time)
×
80
            {
81
                tmpSec = (i/2) * m_timeScale;
×
82
                if (tmpSec < 60)
×
83
                    painter->drawText(xpos - 4, 15, QString("%1s").arg(tmpSec));
×
84
                else
85
                {
86
                    int tmpMin = tmpSec / 60;
×
87
                    tmpSec = tmpSec - (tmpMin * 60);
×
88
                    painter->drawText(xpos - 4, 15, QString("%1m%2s").arg(tmpMin).arg(tmpSec));
×
89
                }
90
            }
91
            else
92
            {
93
                tmpSec++;
×
94
                painter->drawText(xpos - 4, 15, QString("%1").arg(tmpSec));
×
95
            }
96
        }
97
        else
98
        {
99
            if (m_timeStep > 5)
×
100
            {
101
                painter->drawLine(xpos, 25, xpos, 34);
×
102
                if (m_height > HEADER_HEIGHT)
×
103
                {
104
                    painter->setPen(QPen(QColor(105, 105, 105, 255), 1));
×
105
                    painter->drawLine(xpos, HEADER_HEIGHT, xpos, m_height);
×
106
                }
107
            }
108
        }
109
    }
110

111
}
×
112

113
void ShowHeaderItem::setTimeScale(int val)
×
114
{
115
    m_timeScale = val;
×
116
    update();
×
117
}
×
118

119
int ShowHeaderItem::getTimeScale()
×
120
{
121
    return m_timeScale;
×
122
}
123

124
void ShowHeaderItem::setTimeDivisionType(Show::TimeDivision type)
×
125
{
126
    if (type >= Show::Invalid)
×
127
        return;
128

129
    m_type = type;
×
130
    if (m_type == Show::Time)
×
131
    {
132
        m_timeStep = HALF_SECOND_WIDTH;
×
133
        m_timeHit = 2;
×
134
    }
135
    else
136
    {
137
        if (m_type == Show::BPM_4_4)
×
138
            m_timeHit = 4;
×
139
        else if (m_type == Show::BPM_3_4)
×
140
            m_timeHit = 3;
×
141
        else if (m_type == Show::BPM_2_4)
×
142
            m_timeHit = 2;
×
143
    }
144
    update();
×
145
}
146

147
Show::TimeDivision ShowHeaderItem::getTimeDivisionType()
×
148
{
149
    return m_type;
×
150
}
151

152
void ShowHeaderItem::setBPMValue(int value)
×
153
{
154
    if (value > 1)
×
155
    {
156
        m_BPMValue = value;
×
157
    }
158
    update();
×
159
}
×
160

161
int ShowHeaderItem::getHalfSecondWidth()
×
162
{
163
    return HALF_SECOND_WIDTH;
×
164
}
165

166
float ShowHeaderItem::getTimeDivisionStep()
×
167
{
168
    if (m_type > Show::Time && m_timeStep <= 5)
×
169
        return m_timeStep * m_timeHit;
×
170
    return m_timeStep;
×
171
}
172

173
void ShowHeaderItem::setWidth(int w)
×
174
{
175
    prepareGeometryChange();
×
176
    m_width = w;
×
177
}
×
178

179
void ShowHeaderItem::setHeight(int h)
×
180
{
181
    prepareGeometryChange();
×
182
    m_height = h;
×
183
}
×
184

185

186
/****************************************************************************
187
 *
188
 * Cursor item
189
 *
190
 ****************************************************************************/
191
ShowCursorItem::ShowCursorItem(int h)
×
192
    : m_height(h)
×
193
    , m_time(0)
×
194
{
195
}
×
196

197
void ShowCursorItem::setHeight(int height)
×
198
{
199
    prepareGeometryChange();
×
200
    m_height = height;
×
201
}
×
202

203
void ShowCursorItem::setTime(quint32 t)
×
204
{
205
    m_time = t;
×
206
}
×
207

208
quint32 ShowCursorItem::getTime()
×
209
{
210
    return m_time;
×
211
}
212

213
QRectF ShowCursorItem::boundingRect() const
×
214
{
215
    return QRectF(-5, 0, 10, m_height);
×
216
}
217

218
void ShowCursorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
×
219
{
220
    Q_UNUSED(option);
221
    Q_UNUSED(widget);
222

223
    painter->setBrush(QBrush(Qt::yellow, Qt::SolidPattern));
×
224
    painter->setPen(QPen(Qt::yellow, 1));
×
225
    QPolygonF CursorHead;
226
    CursorHead.append(QPointF(-5.0, 22.0));
×
227
    CursorHead.append(QPointF(5.0, 22.0));
×
228
    CursorHead.append(QPointF(5.0, 25.0));
×
229
    CursorHead.append(QPointF(0.0, 35.0));
×
230
    CursorHead.append(QPointF(-5.0, 25.0));
×
231
    CursorHead.append(QPointF(-5.0, 22.0));
×
232
    painter->drawPolygon(CursorHead);
×
233
    painter->setPen(Qt::NoPen);
×
234
    painter->drawRect(0, 35, 1, m_height - 35);
×
235
}
×
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