14 : QAbstractTableModel(parent)
61 if(index.parent().isValid())
64 int column = index.column();
70 int row = index.row();
71 if(row < 0 || row >= (
int)
m_status->topics.size())
74 const auto& topic =
m_status->topics[row];
80 case Qt::ForegroundRole:
84 return QColor(Qt::white);
93 case Qt::BackgroundRole:
97 return QColor(Qt::green);
99 return QColor(Qt::red);
104 return QColor(Qt::gray);
108 case Qt::DisplayRole:
114 return QString::fromStdString(topic.name);
116 return QString::number(topic.publishers);
118 return QString::number(topic.messages_in_current_bag);
130 case Qt::TextAlignmentRole:
134 return int(Qt::AlignLeft | Qt::AlignVCenter);
137 return int(Qt::AlignRight | Qt::AlignVCenter);
147 if(role != Qt::DisplayRole || orientation != Qt::Horizontal)
183 for(
auto& t : state->topics)
193 for(
unsigned int i=0;i<
m_status->topics.size();i++)
210 s = fmt::format(
"{:.1f} Hz", rate);
212 s = fmt::format(
"{:.1f} kHz", rate / 1e3);
214 s = fmt::format(
"{:.1f} MHz", rate / 1e6);
216 return QString::fromStdString(
s);
222 if(memory <
static_cast<uint64_t
>(1<<10))
223 s = fmt::format(
"{}.0 B", memory);
224 else if(memory <
static_cast<uint64_t
>(1<<20))
225 s = fmt::format(
"{:.1f} KiB",
static_cast<double>(memory) /
static_cast<uint64_t
>(1<<10));
226 else if(memory <
static_cast<uint64_t
>(1<<30))
227 s = fmt::format(
"{:.1f} MiB",
static_cast<double>(memory) /
static_cast<uint64_t
>(1<<20));
228 else if(memory <
static_cast<uint64_t
>(1ull<<40))
229 s = fmt::format(
"{:.1f} GiB",
static_cast<double>(memory) /
static_cast<uint64_t
>(1ull<<30));
231 s = fmt::format(
"{:.1f} TiB",
static_cast<double>(memory) /
static_cast<uint64_t
>(1ull<<40));
233 return QString::fromStdString(
s);