MCPcopy Create free account
hub / github.com/KDAB/GammaRay / headerData

Method headerData

client/messagestatisticsmodel.cpp:210–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210QVariant MessageStatisticsModel::headerData(int section, Qt::Orientation orientation, int role) const
211{
212 if (orientation == Qt::Horizontal) {
213 if (role == Qt::DisplayRole)
214 return MetaEnum::enumToString(static_cast<Protocol::MessageType>(section + 1), message_type_table);
215
216 if (role == Qt::BackgroundRole) {
217 const auto countRatio = ( double )countPerType(section) / ( double )m_totalCount;
218 const auto sizeRatio = ( double )sizePerType(section) / ( double )m_totalSize;
219 const auto ratio = std::max(countRatio, sizeRatio);
220 if (ratio > 0.0) {
221 return colorForRatio(ratio);
222 }
223 }
224
225 if (role == Qt::ToolTipRole) {
226 const auto count = countPerType(section);
227 const auto size = sizePerType(section);
228 return tr("Message Count: %1 of %2 (%3%)\nMessage Size: %4 of %5 (%6%)").arg(count).arg(m_totalCount).arg(100.0 * ( double )count / ( double )m_totalCount, 0, 'f', 2).arg(size).arg(m_totalSize).arg(100.0 * ( double )size / ( double )m_totalSize, 0, 'f', 2);
229 }
230 } else if (orientation == Qt::Vertical) {
231 const auto &info = m_data.at(section);
232 if (role == Qt::DisplayRole) {
233 return info.name;
234 }
235 if (role == Qt::BackgroundRole) {
236 const auto countRatio = ( double )info.totalCount() / ( double )m_totalCount;
237 const auto sizeRatio = ( double )info.totalSize() / ( double )m_totalSize;
238 const auto ratio = std::max(countRatio, sizeRatio);
239 if (ratio > 0.0) {
240 return colorForRatio(ratio);
241 }
242 }
243 if (role == Qt::ToolTipRole) {
244 const auto count = info.totalCount();
245 const auto size = info.totalSize();
246 return tr("Message Count: %1 of %2 (%3%)\nMessage Size: %4 of %5 (%6%)\nObject Address: %7").arg(count).arg(m_totalCount).arg(100.0 * ( double )count / ( double )m_totalCount, 0, 'f', 2).arg(size).arg(m_totalSize).arg(100.0 * ( double )size / ( double )m_totalSize, 0, 'f', 2).arg(section + 1);
247 }
248 }
249
250 return QAbstractTableModel::headerData(section, orientation, role);
251}
252
253int MessageStatisticsModel::countPerType(int msgType) const
254{

Callers

nothing calls this directly

Calls 4

enumToStringFunction · 0.85
totalCountMethod · 0.80
totalSizeMethod · 0.80
colorForRatioFunction · 0.70

Tested by

no test coverage detected