MCPcopy Create free account
hub / github.com/KDE/kdevelop / templateIndexes

Method templateIndexes

kdevplatform/language/codegen/templatesmodel.cpp:288–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288QModelIndexList TemplatesModel::templateIndexes(const QString& fileName) const
289{
290 Q_D(const TemplatesModel);
291
292 QFileInfo info(fileName);
293 QString description =
294 QStandardPaths::locate(QStandardPaths::GenericDataLocation,
295 d->resourceFilter(TemplatesModelPrivate::Description,
296 info.baseName() + QLatin1String(".kdevtemplate")));
297 if (description.isEmpty()) {
298 description =
299 QStandardPaths::locate(QStandardPaths::GenericDataLocation,
300 d->resourceFilter(TemplatesModelPrivate::Description,
301 info.baseName() + QLatin1String(".desktop")));
302 }
303
304 QModelIndexList indexes;
305
306 if (!description.isEmpty()) {
307 KConfig templateConfig(description);
308 KConfigGroup general(&templateConfig, QStringLiteral("General"));
309 const QStringList categories = general.readEntry("Category").split(QLatin1Char('/'));
310
311 QStringList levels;
312 levels.reserve(categories.size());
313 for (const QString& category : categories) {
314 levels << category;
315 indexes << d->templateItems[levels.join(QLatin1Char('/'))]->index();
316 }
317
318 if (!indexes.isEmpty()) {
319 QString name = general.readEntry("Name");
320 QStandardItem* categoryItem = d->templateItems[levels.join(QLatin1Char('/'))];
321 for (int i = 0; i < categoryItem->rowCount(); ++i) {
322 QStandardItem* templateItem = categoryItem->child(i);
323 if (templateItem->text() == name) {
324 indexes << templateItem->index();
325 break;
326 }
327 }
328 }
329 }
330
331 return indexes;
332}
333
334QString TemplatesModel::typePrefix() const
335{

Callers 3

loadFileClickedMethod · 0.45
loadFileClickedMethod · 0.45
setCurrentTemplateMethod · 0.45

Calls 12

resourceFilterMethod · 0.80
baseNameMethod · 0.80
readEntryMethod · 0.80
joinMethod · 0.80
isEmptyMethod · 0.45
splitMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
indexMethod · 0.45
rowCountMethod · 0.45
childMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected