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

Method data

plugins/fontbrowser/fontmodel.cpp:95–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95QVariant FontModel::data(const QModelIndex &index, int role) const
96{
97 if (index.column() == 0) {
98 if (role == Qt::DisplayRole)
99 return m_fonts.at(index.row()).family();
100 } else if (index.column() == 1) {
101 if (role == Qt::DisplayRole)
102 return m_fonts.at(index.row()).styleName();
103 } else if (index.column() == 2) {
104 if (role == Qt::DecorationRole || role == Qt::SizeHintRole) {
105 const QFont &font = m_fonts.at(index.row());
106 QFontMetrics metrics(font);
107 const QString text = m_text.isEmpty() ? tr("<no text>") : m_text;
108 const QRect rect = metrics.boundingRect(text.left(100));
109 if (role == Qt::SizeHintRole)
110 return rect.size();
111 QPixmap pixmap(rect.size());
112 pixmap.fill(m_background);
113 QPainter painter(&pixmap);
114 painter.setPen(m_foreground);
115 painter.setFont(font);
116 painter.drawText(0, -rect.y(), text);
117 return pixmap;
118 }
119 }
120
121 return QVariant();
122}
123
124void FontModel::setPointSize(int size)
125{

Callers 1

updateFontsMethod · 0.45

Calls 8

columnMethod · 0.80
rowMethod · 0.80
boundingRectMethod · 0.80
leftMethod · 0.80
fillMethod · 0.80
QVariantClass · 0.50
isEmptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected