You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
1.0 KiB

/*
SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "okularsingleton.h"
#include <KServiceTypeTrader>
#include <QMimeDatabase>
#include <QMimeType>
OkularSingleton::OkularSingleton()
{
}
QStringList OkularSingleton::nameFilters() const
{
QStringList supportedPatterns;
QString constraint(QStringLiteral("(Library == 'okularpart')"));
QLatin1String basePartService("KParts/ReadOnlyPart");
KService::List offers = KServiceTypeTrader::self()->query(basePartService, constraint);
KService::List::ConstIterator it = offers.constBegin(), itEnd = offers.constEnd();
QMimeDatabase md;
for (; it != itEnd; ++it) {
KService::Ptr service = *it;
const QStringList mimeTypes = service->mimeTypes();
for (const auto &mimeName : mimeTypes) {
for (const auto &suffix : md.mimeTypeForName(mimeName).suffixes())
supportedPatterns += QStringLiteral("*.") + suffix;
}
}
return supportedPatterns;
}