QVariant LogTableModel::data (QModelIndex const & index, int role) const { if (!index.isValid()) return QVariant(); int const col = index.column(); int const row = index.row(); proto::Record const * rec = nullptr; proto::Attrs const * attrs = nullptr; if (checkExistence(index)) { rec = m_data.getRecord(row); attrs = m_data.getAttrs(row); } if (rec == nullptr) { if (role == Qt::BackgroundRole) return QVariant::fromValue<QColor>(Qt::gray); return QVariant(); } if (role == Qt::DisplayRole) { QVariant const ret = m_data.getRecordData(rec->m_values, col); return ret; } else if (role == Qt::ToolTipRole) { QVariant const ret = m_data.getRecordData(rec->m_values, col); QString ttip("<pre>"); ttip.append(ret.toString()); ttip.append(QString("</pre>")); return ttip; } else if (role == Qt::BackgroundRole) { // QVariant const col_flags_qv = m_data.getRecordData(attrs->m_flags, col); // proto::Flags col_flags = col_flags_qv.value<proto::Flags>(); // // if (col_flags.m_scope_type == LogScopeType_scopeEntry) // return QVariant::fromValue<QColor>(QColor(0xEFEDFC)); // if (col_flags.m_scope_type == LogScopeType_scopeExit) // return QVariant::fromValue<QColor>(QColor(0xEAF1FB)); QVariant const col_rgba = m_data.getRecordData(attrs->m_bgcols, col); if (col_rgba.isValid()) if (unsigned const rgba = col_rgba.toUInt()) return QVariant::fromValue<QColor>(QColor(rgba)); } else if (role == Qt::ForegroundRole) { QVariant const col_rgba = m_data.getRecordData(attrs->m_fgcols, col); if (col_rgba.isValid()) if (unsigned const rgba = col_rgba.toUInt()) return QVariant::fromValue<QColor>(QColor(rgba)); } return QVariant(); }
std::vector<ttip> load(const config& cfg) { std::vector<ttip> result; for(const auto & tip : cfg.child_range("tip")) { result.push_back( ttip(tip["text"], tip["source"], tip["encountered_units"])); } return result; }