Alkimia API

alkutils.cpp
1/*
2 SPDX-FileCopyrightText: 2024 Ralf Habacker ralf.habacker @freenet.de
3
4 This file is part of libalkimia.
5
6 SPDX-License-Identifier: LGPL-2.1-or-later
7*/
8
9#include "alkutils.h"
10
11#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
12#include <QDir>
13#include <QStandardPaths>
14
15QStringList AlkUtils::getDataFiles(const QString &path, const QStringList &extensions)
16{
17 QStringList resources;
19 Q_FOREACH (const QString& dir, dirs) {
20 const QStringList fileNames = QDir(dir).entryList(extensions);
21 Q_FOREACH (const QString& file, fileNames) {
22 resources.append(dir + '/' + file);
23 }
24 }
25 return resources;
26}
27
28QString AlkUtils::locateDataFile(const QString &filePath)
29{
30 return QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("alkimia%1/%2").arg(TARGET_SUFFIX, filePath));
31}
32
33#else
34#include <KGlobal>
35#include <KStandardDirs>
36
37QStringList AlkUtils::getDataFiles(const QString &path, const QStringList &extensions)
38{
39 const QString filename = QString("%1/%2").arg(path, extensions.at(0));
40 const QStringList resources = KStandardDirs().findAllResources("data", filename);
41 return resources;
42}
43
44QString AlkUtils::locateDataFile(const QString &filePath)
45{
46 return KGlobal::dirs()->findResource("appdata", filePath);
47}
48#endif
KEDUVOCDOCUMENT_EXPORT QStringList fileNames(const QString &language=QString())
QStringList entryList(Filters filters, SortFlags sort) const const
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
QString locate(StandardLocation type, const QString &fileName, LocateOptions options)
QStringList locateAll(StandardLocation type, const QString &fileName, LocateOptions options)
QString arg(Args &&... args) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.