MCPcopy Create free account
hub / github.com/KDE/labplot / QJsonModel

Method QJsonModel

src/backend/datasources/filters/QJsonModel.cpp:127–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125//=========================================================================
126
127QJsonModel::QJsonModel(QObject* parent)
128 : QAbstractItemModel(parent)
129 , mHeadItem(new QJsonTreeItem)
130 , mRootItem(new QJsonTreeItem(mHeadItem)) {
131 mHeadItem->appendChild(mRootItem);
132 mHeaders.append(i18n("Key"));
133 mHeaders.append(i18n("Value"));
134 mHeaders.append(i18n("Size in Bytes"));
135
136 // icons
137 QPainter painter;
138 QPixmap pix(64, 64);
139
140 QFont font;
141 font.setPixelSize(60);
142
143 const auto color = qApp->palette().color(QPalette::Text);
144 painter.setPen(QPen(color));
145
146 // draw the icon for JSON array
147 pix.fill(QColor(Qt::transparent));
148 painter.begin(&pix);
149 painter.setFont(font);
150 painter.drawText(pix.rect(), Qt::AlignCenter, QLatin1String("[ ]"));
151 painter.end();
152 mArrayIcon = QIcon(pix);
153
154 // draw the icon for JSON object
155 pix.fill(QColor(Qt::transparent));
156 painter.begin(&pix);
157 painter.setFont(font);
158 painter.drawText(pix.rect(), Qt::AlignCenter, QLatin1String("{ }"));
159 painter.end();
160 mObjectIcon = QIcon(pix);
161}
162
163QJsonModel::~QJsonModel() {
164 // delete mRootItem;

Callers

nothing calls this directly

Calls 11

QIconClass · 0.85
appendChildMethod · 0.80
appendMethod · 0.80
setPenMethod · 0.80
rectMethod · 0.80
QPenClass · 0.50
QColorClass · 0.50
colorMethod · 0.45
beginMethod · 0.45
setFontMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected