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

ossia / score / 41358673654

01 Nov 2026 10:44PM UTC coverage: 51.93% (-0.3%) from 52.268%
41358673654

Pull #2373

github

web-flow
Merge 8cdd0145c into 07f27012e
Pull Request #2373: Monitoring: scopes, meters and viewers for every data type

2061 of 6884 new or added lines in 87 files covered. (29.94%)

35 existing lines in 12 files now uncovered.

188138 of 362292 relevant lines covered (51.93%)

306420.4 hits per line

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

46.48
/src/plugins/score-lib-process/Process/LayerView.cpp
1
// This is an open source non-commercial project. Dear PVS-Studio, please check
2
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3
#include "LayerView.hpp"
4

5
#include <Process/Dataflow/CableItem.hpp>
6
#include <Process/HeaderDelegate.hpp>
7
#include <Process/ProcessMimeSerialization.hpp>
8
#include <Process/Style/ScenarioStyle.hpp>
9

10
#include <QGraphicsSceneDragDropEvent>
11
#include <QPainter>
12
#include <QStyleOption>
13

14
#include <wobjectimpl.h>
15
W_OBJECT_IMPL(Process::LayerView)
25,778 ✔
16
namespace Process
17
{
18
HeaderDelegate::~HeaderDelegate() { }
1,853 ✔
19

20
LayerView::~LayerView()
1,762 ✔
21
{
1,762 ✔
22
  const auto& items = childItems();
1,762 ✔
23
  for(auto item : items)
1,363,891 ✔
24
  {
25
    if(item->type() == Dataflow::CableItem::Type)
1,362,129 ✔
26
    {
27
      item->setParentItem(nullptr);
×
28
    }
×
29
  }
30
}
1,762 ✔
31
void LayerView::heightChanged(qreal) { }
1,672 ✔
32
void LayerView::widthChanged(qreal) { }
3,650 ✔
33

34
MiniLayer::~MiniLayer() = default;
909 ✔
35

36
LayerView::LayerView(QGraphicsItem* parent)
1,762 ✔
37
    : QGraphicsItem{parent}
1,762 ✔
38
{
1,762 ✔
39
  this->setCacheMode(QGraphicsItem::NoCache);
1,762 ✔
40
  this->setFlag(ItemClipsChildrenToShape, false);
1,762 ✔
41
  this->setAcceptHoverEvents(true);
1,762 ✔
42
  this->setAcceptDrops(true);
1,762 ✔
43
}
×
44

45
void LayerView::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
14 ✔
46
{
47
  if(auto p = parentItem())
14 ✔
48
    p->unsetCursor();
14 ✔
49
  // Views may show more while the cursor is over them
50
  update();
14 ✔
51
}
14 ✔
52
void LayerView::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
×
53
{
54
  if(auto p = parentItem())
×
55
    p->unsetCursor();
×
NEW
56
  update();
×
UNCOV
57
}
×
58

59
QRectF LayerView::boundingRect() const
314,713 ✔
60
{
61
  return {0, 0, m_width, m_height};
314,713 ✔
62
}
63

64
void LayerView::paint(
259 ✔
65
    QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
66
{
67
  paint_impl(painter);
259 ✔
68
#if defined(SCORE_SCENARIO_DEBUG_RECTS)
69
  painter->setPen(Qt::green);
70
  painter->setBrush(Qt::NoBrush);
71
  painter->drawRect(boundingRect());
72
#endif
73
}
259 ✔
74

75
void LayerView::setHeight(qreal height) noexcept
22,433 ✔
76
{
77
  if(height != m_height)
22,433 ✔
78
  {
79
    prepareGeometryChange();
1,762 ✔
80
    m_height = height;
1,762 ✔
81
    heightChanged(height);
1,762 ✔
82
  }
1,762 ✔
83
}
22,433 ✔
84

85
void LayerView::setWidth(qreal width) noexcept
26,123 ✔
86
{
87
  if(width != m_width)
26,123 ✔
88
  {
89
    prepareGeometryChange();
3,740 ✔
90
    m_width = width;
3,740 ✔
91
    widthChanged(width);
3,740 ✔
92
  }
3,740 ✔
93
}
26,123 ✔
94

95
QPixmap LayerView::pixmap() noexcept
×
96
{
97
  // Retrieve the bounding rect
98
  QRect rect = boundingRect().toRect();
×
99
  if(rect.isNull() || !rect.isValid())
×
100
  {
101
    return QPixmap();
×
102
  }
103

104
  // Create the pixmap
105
  QPixmap pixmap(rect.size());
×
106
  pixmap.fill(Qt::transparent);
×
107

108
  // Render
109
  QPainter painter(&pixmap);
×
110
  QStyleOptionGraphicsItem item;
×
111
  painter.setRenderHint(QPainter::Antialiasing, true);
×
112
  painter.setRenderHint(QPainter::TextAntialiasing, true);
×
113
  painter.translate(-rect.topLeft());
×
114
  paint(&painter, &item, nullptr);
×
115
  const auto& items = childItems();
×
116
  for(QGraphicsItem* child : items)
×
117
  {
118
    painter.save();
×
119
    painter.translate(child->mapToParent(pos()));
×
120
    child->paint(&painter, &item, nullptr);
×
121
    painter.restore();
×
122
  }
123

124
  painter.end();
×
125

126
  return pixmap;
×
127
}
×
128

129
void LayerView::dragEnterEvent(QGraphicsSceneDragDropEvent* event)
×
130
{
131
  const auto& formats = event->mimeData()->formats();
×
132
  if(formats.contains(score::mime::layerdata()))
×
133
  {
134
    event->accept();
×
135
  }
×
136
  else if(formats.contains(score::mime::processpreset()))
×
137
  {
138
    // TODO check if this is the right process
139
    event->accept();
×
140
    m_dropPresetOverlay = true;
×
141
    update();
×
142
  }
×
143
}
×
144

145
void LayerView::dragLeaveEvent(QGraphicsSceneDragDropEvent* event)
×
146
{
147
  m_dropPresetOverlay = false;
×
148
  update();
×
149
}
×
150

151
void LayerView::dropEvent(QGraphicsSceneDragDropEvent* event)
×
152
{
153
  const auto& formats = event->mimeData()->formats();
×
154
  if(formats.contains(score::mime::processpreset()))
×
155
  {
156
    event->accept();
×
157
    presetDropReceived(event->pos(), *event->mimeData());
×
158
    m_dropPresetOverlay = false;
×
159
    update();
×
160
  }
×
161
}
×
162

163
MiniLayer::MiniLayer(QGraphicsItem* parent)
909 ✔
164
    : QGraphicsItem{parent}
909 ✔
165
{
909 ✔
166
  this->setCacheMode(QGraphicsItem::NoCache);
909 ✔
167
  this->setFlag(ItemClipsChildrenToShape, true);
909 ✔
168
}
×
169

170
QRectF MiniLayer::boundingRect() const
956 ✔
171
{
172
  return {0, 0, m_width, m_height};
956 ✔
173
}
174

175
void MiniLayer::paint(
16 ✔
176
    QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
177
{
178
  paint_impl(painter);
16 ✔
179
}
16 ✔
180

181
void MiniLayer::setHeight(qreal height)
909 ✔
182
{
183
  prepareGeometryChange();
909 ✔
184
  m_height = height;
909 ✔
185
  update();
909 ✔
186
}
909 ✔
187

188
qreal MiniLayer::height() const
×
189
{
190
  return m_height;
×
191
}
192

193
void MiniLayer::setWidth(qreal width)
2,057 ✔
194
{
195
  prepareGeometryChange();
2,057 ✔
196
  m_width = width;
2,057 ✔
197
  update();
2,057 ✔
198
}
2,057 ✔
199

200
qreal MiniLayer::width() const
×
201
{
202
  return m_width;
×
203
}
204

205
void MiniLayer::setZoomRatio(qreal z)
1,148 ✔
206
{
207
  m_zoom = z;
1,148 ✔
208
  update();
1,148 ✔
209
}
1,148 ✔
210

211
qreal MiniLayer::zoom() const
×
212
{
213
  return m_zoom;
×
214
}
215
}
216

217
void Process::LayerView::mousePressEvent(QGraphicsSceneMouseEvent* event)
×
218
{
219
  pressed(event->pos());
×
220
  event->accept();
×
221
}
×
222

223
void Process::LayerView::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
×
224
{
225
  moved(event->pos());
×
226
  event->accept();
×
227
}
×
228

229
void Process::LayerView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
×
230
{
231
  released(event->pos());
×
232
  event->accept();
×
233
}
×
234

235
void Process::LayerView::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
×
236
{
237
  askContextMenu(event->screenPos(), event->scenePos());
×
238
  event->accept();
×
239
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc