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

traintastic / traintastic / 23391602376

21 Mar 2026 11:53PM UTC coverage: 26.259% (-0.2%) from 26.481%
23391602376

push

github

reinder
[cbus] added node list

0 of 264 new or added lines in 7 files covered. (0.0%)

15 existing lines in 2 files now uncovered.

8246 of 31402 relevant lines covered (26.26%)

183.04 hits per line

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

0.0
/server/src/hardware/interface/cbus/cbusnodelisttablemodel.cpp
1
/**
2
 * This file is part of Traintastic,
3
 * see <https://github.com/traintastic/traintastic>.
4
 *
5
 * Copyright (C) 2026 Reinder Feenstra
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 */
21

22
#include "cbusnodelisttablemodel.hpp"
23
#include "cbusnodelist.hpp"
24
#include "../../protocol/cbus/cbusmanufacturermodule.hpp"
25

26
constexpr uint32_t columnCANID = 0;
27
constexpr uint32_t columnNodeNumber = 1;
28
constexpr uint32_t columnManufacturer = 2;
29
constexpr uint32_t columnModule = 3;
30

NEW
31
CBUSNodeListTableModel::CBUSNodeListTableModel(CBUSNodeList& list)
×
NEW
32
  : m_list{list.shared_ptr<CBUSNodeList>()}
×
33
{
NEW
34
  assert(m_list);
×
NEW
35
  m_list->m_models.push_back(this);
×
36

NEW
37
  setColumnHeaders({
×
38
    std::string_view{"cbus_node_list:can_id"},
39
    std::string_view{"cbus_node_list:node_number"},
40
    std::string_view{"cbus_node_list:manufacturer"},
41
    std::string_view{"cbus_node_list:module"}
42
  });
43

NEW
44
  setRowCount(m_list->m_nodes.size());
×
NEW
45
}
×
46

NEW
47
CBUSNodeListTableModel::~CBUSNodeListTableModel()
×
48
{
NEW
49
  auto it = std::find(m_list->m_models.begin(), m_list->m_models.end(), this);
×
NEW
50
  assert(it != m_list->m_models.end());
×
NEW
51
  m_list->m_models.erase(it);
×
NEW
52
}
×
53

NEW
54
std::string CBUSNodeListTableModel::getText(uint32_t column, uint32_t row) const
×
55
{
NEW
56
  if(row < m_list->m_nodes.size())
×
57
  {
NEW
58
    const auto& node = m_list->m_nodes[row];
×
59

NEW
60
    switch(column)
×
61
    {
NEW
62
      case columnCANID:
×
NEW
63
        return std::to_string(node.canId);
×
64

NEW
65
      case columnNodeNumber:
×
NEW
66
        return std::to_string(node.nodeNumber);
×
67

NEW
68
      case columnManufacturer:
×
NEW
69
        if(auto sv = CBUS::manufacturerName(node.manufacturerId); !sv.empty())
×
70
        {
NEW
71
          return std::string(sv);
×
72
        }
NEW
73
        return std::to_string(node.manufacturerId);
×
74

NEW
75
      case columnModule:
×
NEW
76
        if(auto sv = CBUS::moduleName(node.manufacturerId, node.moduleId); !sv.empty())
×
77
        {
NEW
78
          return std::string(sv);
×
79
        }
NEW
80
        return std::to_string(node.moduleId);
×
81
    }
82
  }
NEW
83
  return {};
×
84
}
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