QVariant data(const QModelIndex &index, int role) const { if (!m_descriptions || !m_scheme) return QVariant(); const FormatDescription &description = m_descriptions->at(index.row()); switch (role) { case Qt::DisplayRole: return description.displayName(); case Qt::ForegroundRole: { QColor foreground = m_scheme->formatFor(description.id()).foreground(); if (foreground.isValid()) return foreground; else return m_scheme->formatFor(C_TEXT).foreground(); } case Qt::BackgroundRole: { QColor background = m_scheme->formatFor(description.id()).background(); if (background.isValid()) return background; else break; } case Qt::FontRole: { QFont font = m_baseFont; auto format = m_scheme->formatFor(description.id()); font.setBold(format.bold()); font.setItalic(format.italic()); font.setUnderline(format.underlineStyle() != QTextCharFormat::NoUnderline); return font; } case Qt::ToolTipRole: { return description.tooltipText(); } } return QVariant(); }
static status initialiseStyle(Style s, Image icon, FontObj font, Colour colour, BoolObj highlight, BoolObj underline, BoolObj bold, BoolObj grey, Any background, BoolObj hidden, Int lm, Int rm) { if ( isDefault(icon) ) icon = NIL; if ( isDefault(lm) ) lm = ZERO; if ( isDefault(rm) ) rm = ZERO; assign(s, font, font); assign(s, icon, icon); assign(s, colour, colour); assign(s, background, background); assign(s, left_margin, lm); assign(s, right_margin, rm); s->attributes = 0; if ( notDefault(highlight) ) highlightStyle(s, highlight); if ( notDefault(underline) ) underlineStyle(s, underline); if ( notDefault(bold) ) boldStyle(s, bold); if ( notDefault(grey) ) greyStyle(s, grey); if ( notDefault(hidden) ) hiddenStyle(s, hidden); succeed; }