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

ossia / score / 33834678478

04 Sep 2026 03:50AM UTC coverage: 24.333% (+0.3%) from 23.997%
33834678478

push

github

jcelerier
tests: the editor-look cases assumed a Windows desktop

Three of them failed under the coverage job's Xvfb display.

Redo is Ctrl+Y only on Windows -- qplatformtheme.cpp binds that one under
KB_Win, and X11 and macOS use Ctrl+Shift+Z -- so the redo half of the hex
undo case tested nothing there. Ask QKeySequence instead.

The other two turn on an editor committing when the focus leaves it, and
QWidget::setFocus only routes through setFocusWidget in an active window.
There is no window manager on that display, so the view was shown but never
activated and no focus event was ever sent: the value simply stayed put.
The fixture now activates the window and waits for it, and the cases that
depend on it say so -- one of them was passing on an empty check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014L61CWsHUpxm7opHyZbsKu

55424 of 227776 relevant lines covered (24.33%)

63160.69 hits per line

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

39.69
/src/plugins/score-lib-device/Device/ItemModels/NodeDisplayMethods.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 "NodeDisplayMethods.hpp"
4

5
#include <State/Domain.hpp>
6
#include <State/Value.hpp>
7
#include <State/ValueConversion.hpp>
8

9
#include <Device/Address/AddressSettings.hpp>
10
#include <Device/Address/IOType.hpp>
11
#include <Device/Node/DeviceNode.hpp>
12
#include <Device/Protocol/DeviceInterface.hpp>
13
#include <Device/Protocol/DeviceSettings.hpp>
14

15
#include <ossia/network/domain/domain.hpp>
16
#include <ossia/network/value/value_conversion.hpp>
17

18
#include <QBrush>
19
#include <QFont>
20
#include <qnamespace.h>
21

22
namespace ossia
23
{
24

25
// TODO MOVEME
26
template <>
27
QVariant convert(const ossia::value& val)
×
28
{
29
  struct vis
30
  {
31
  public:
32
    using return_type = QVariant;
33
    return_type operator()(const ossia::impulse& v) const
×
34
    {
35
      return QVariant::fromValue(v);
×
36
    }
37
    return_type operator()(int i) const { return QVariant::fromValue(i); }
×
38
    return_type operator()(float f) const { return QVariant::fromValue(f); }
×
39
    return_type operator()(bool b) const { return QVariant::fromValue(b); }
×
40
    return_type operator()(const std::string& s) const
×
41
    {
42
      return QString::fromStdString(s);
×
43
    }
×
44
    return_type operator()(char c) const { return QVariant::fromValue(QChar(c)); }
45

46
    return_type operator()(ossia::vec2f t) const { return QVector2D{t[0], t[1]}; }
×
47
    return_type operator()(ossia::vec3f t) const { return QVector3D{t[0], t[1], t[2]}; }
×
48
    return_type operator()(ossia::vec4f t) const
×
49
    {
50
      return QVector4D{t[0], t[1], t[2], t[3]};
×
51
    }
52
    return_type operator()(const std::vector<ossia::value>& t) const
×
53
    {
54
      QVariantList arr;
×
55
      arr.reserve(t.size());
×
56

57
      for(const auto& elt : t)
×
58
      {
59
        arr.push_back(ossia::apply_nonnull(*this, elt.v));
×
60
      }
61

62
      return arr;
×
63
    }
×
64
    return_type operator()(const ossia::value_map_type& t) const
×
65
    {
66
      QVariantMap arr;
×
67

68
      for(const auto& [k, v] : t)
×
69
      {
70
        arr.insert(QString::fromStdString(k), ossia::apply_nonnull(*this, v));
×
71
      }
72

73
      return arr;
×
74
    }
×
75
    return_type operator()() const { return {}; }
×
76
  };
77

78
  return val.apply(vis{});
×
79
}
80
}
81
namespace Device
82
{
83
QVariant nameColumnData(const Device::Node& node, int role)
22,181✔
84
{
85
  static const QFont& italicFont{[]() {
22,184✔
86
    static QFont f;
3✔
87
    f.setItalic(true);
3✔
88
    return f;
3✔
89
  }()};
×
90

91
  using namespace score;
92

93
  const auto ioType = node.get<Device::AddressSettings>().ioType;
22,181✔
94
  switch(role)
22,181✔
95
  {
96
    case Qt::DisplayRole:
97
    case Qt::EditRole:
98
      return node.displayName();
3,287✔
99
    case Qt::FontRole: {
100
      if(ioType == ossia::access_mode::GET || ioType == ossia::access_mode::SET)
3,149✔
101
      {
102
        return italicFont;
×
103
      }
104
      return {};
3,149✔
105
    }
106
    case Qt::ForegroundRole: {
107
      if(ioType == ossia::access_mode::GET || ioType == ossia::access_mode::SET)
3,149✔
108
      {
109
        return QBrush(Qt::lightGray);
×
110
      }
111
      return {};
3,149✔
112
    }
113
    default:
114
      return {};
12,596✔
115
  }
116
}
22,181✔
117

118
QVariant deviceNameColumnData(const Device::Node& node, bool connected, int role)
2,410✔
119
{
120
  static const QFont& italicFont{[]() {
2,413✔
121
    static QFont f;
3✔
122
    f.setItalic(true);
3✔
123
    return f;
3✔
124
  }()};
×
125

126
  using namespace score;
127

128
  switch(role)
2,410✔
129
  {
130
    case Qt::DisplayRole: {
131
      const auto& name = node.get<DeviceSettings>().name;
381✔
132
      return connected ? name : name + " (disconnected)";
381✔
133
    }
134
    case Qt::EditRole:
135
      return node.get<DeviceSettings>().name;
×
136
    case Qt::FontRole: {
137
      if(!connected)
335✔
138
        return italicFont;
335✔
139
      return {};
×
140
    }
141
    default:
142
      return {};
1,694✔
143
  }
144
}
2,410✔
145

146
QVariant valueColumnData(const Device::Node& node, int role)
21,708✔
147
{
148
  using namespace score;
149
  if(node.is<DeviceSettings>())
21,708✔
150
    return {};
2,364✔
151

152
  if(role == Qt::DisplayRole || role == Qt::EditRole)
19,344✔
153
  {
154
    const ossia::value& val = node.get<AddressSettings>().value;
2,764✔
155
    if(ossia::is_array(val))
2,764✔
156
    {
157
      return State::convert::toPrettyString(val);
958✔
158
    }
159
    else if(role == Qt::DisplayRole && val.get_type() == ossia::val_type::FLOAT)
1,806✔
160
    {
161
      // Done here explicitely to avoid Qt's default scientific notation QLocale conversion
162
      return State::convert::toPrettyString(*val.target<float>());
319✔
163
    }
164
    else if(role == Qt::DisplayRole && val.get_type() == ossia::val_type::STRING)
1,487✔
165
    {
166
      return State::convert::stringCellText(
675✔
167
          QByteArray::fromStdString(*val.target<std::string>()));
675✔
168
    }
169
    else if(role == Qt::DisplayRole && val.get_type() == ossia::val_type::BOOL)
812✔
170
    {
171
      // The check box below is the value; a "true" beside it says it twice.
172
      return {};
319✔
173
    }
174
    else
175
    {
176
      return State::convert::value<QVariant>(val);
493✔
177
    }
178
  }
179
  else if(role == Qt::CheckStateRole)
16,580✔
180
  {
181
    // A boolean is one click, not a double-click into a combo box.
182
    if(const auto* b = node.get<AddressSettings>().value.target<bool>())
2,765✔
183
      return *b ? Qt::Checked : Qt::Unchecked;
320✔
184
  }
2,445✔
185
  else if(role == Qt::ForegroundRole)
13,815✔
186
  {
187
    const auto ioType = node.get<AddressSettings>().ioType;
2,763✔
188

189
    if(ioType)
2,763✔
190
    {
191
      switch(*ioType)
2,763✔
192
      {
193
        case ossia::access_mode::GET:
194
          return QBrush(Qt::darkGray);
×
195
        case ossia::access_mode::SET:
196
          return QBrush(Qt::lightGray);
×
197
        default:
198
          return {};
2,763✔
199
      }
200
    }
201
  }
×
202

203
  return {};
13,497✔
204
}
21,708✔
205

206
QVariant GetColumnData(const Device::Node& node, int role)
×
207
{
208
  using namespace score;
209
  if(node.is<DeviceSettings>())
×
210
    return {};
×
211

212
  /*
213
  if(role == Qt::DisplayRole || role == Qt::EditRole)
214
  {
215
      switch(node.get<AddressSettings>().ioType)
216
      {
217
          case ossia::access_mode::GET:    return true;
218
          case ossia::access_mode::SET:   return false;
219
          case ossia::access_mode::BI: return true;
220
          case IOType::Invalid: return QVariant{};
221
          default:            return QVariant{};
222
      }
223
  }
224
  */
225

226
  if(role == Qt::CheckStateRole)
×
227
  {
228
    const auto ioType = node.get<AddressSettings>().ioType;
×
229
    if(ioType)
×
230
    {
231
      switch(*ioType)
×
232
      {
233
        case ossia::access_mode::GET:
234
          return Qt::Checked;
×
235
        case ossia::access_mode::SET:
236
          return Qt::Unchecked;
×
237
        case ossia::access_mode::BI:
238
          return Qt::Checked;
×
239
      }
240
    }
×
241
    return Qt::Unchecked;
×
242
  }
243

244
  return {};
×
245
}
×
246
QVariant SetColumnData(const Device::Node& node, int role)
×
247
{
248
  using namespace score;
249
  if(node.is<DeviceSettings>())
×
250
    return {};
×
251

252
  /*
253
  if(role == Qt::DisplayRole || role == Qt::EditRole)
254
  {
255
      switch(node.get<AddressSettings>().ioType)
256
      {
257
          case ossia::access_mode::GET:    return false;
258
          case ossia::access_mode::SET:   return true;
259
          case ossia::access_mode::BI: return true;
260
          case IOType::Invalid: return true;
261
          default:            return QVariant{};
262
      }
263
  }
264
  */
265

266
  if(role == Qt::CheckStateRole)
×
267
  {
268
    const auto ioType = node.get<AddressSettings>().ioType;
×
269
    if(ioType)
×
270
    {
271
      switch(*ioType)
×
272
      {
273
        case ossia::access_mode::GET:
274
          return Qt::Unchecked;
×
275
        case ossia::access_mode::SET:
276
          return Qt::Checked;
×
277
        case ossia::access_mode::BI:
278
          return Qt::Checked;
×
279
      }
280
    }
×
281
    return Qt::Unchecked;
×
282
  }
283
  return {};
×
284
}
×
285

286
QVariant minColumnData(const Device::Node& node, int role)
×
287
{
288
  using namespace score;
289
  if(node.is<DeviceSettings>())
×
290
    return {};
×
291

292
  if(role == Qt::DisplayRole || role == Qt::EditRole)
×
293
  {
294
    return node.get<AddressSettings>().domain.get().convert_min<QVariant>();
×
295
  }
296

297
  return {};
×
298
}
×
299

300
QVariant maxColumnData(const Device::Node& node, int role)
×
301
{
302
  using namespace score;
303
  if(node.is<DeviceSettings>())
×
304
    return {};
×
305

306
  if(role == Qt::DisplayRole || role == Qt::EditRole)
×
307
  {
308
    return node.get<AddressSettings>().domain.get().convert_max<QVariant>();
×
309
  }
310

311
  return {};
×
312
}
×
313
}
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