move all listAppletInfo in PluginLoader
This commit is contained in:
parent
edf1250dce
commit
42bc0a2208
@ -931,40 +931,6 @@ bool Applet::hasValidAssociatedApplication() const
|
||||
return AssociatedApplicationManager::self()->appletHasValidAssociatedApplication(this);
|
||||
}
|
||||
|
||||
KPluginInfo::List Applet::listAppletInfoForMimeType(const QString &mimeType)
|
||||
{
|
||||
QString constraint = AppletPrivate::parentAppConstraint();
|
||||
constraint.append(QString(" and '%1' in [X-Plasma-DropMimeTypes]").arg(mimeType));
|
||||
//kDebug() << "listAppletInfoForMimetype with" << mimeType << constraint;
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
||||
return KPluginInfo::fromServices(offers);
|
||||
}
|
||||
|
||||
KPluginInfo::List Applet::listAppletInfoForUrl(const QUrl &url)
|
||||
{
|
||||
QString constraint = AppletPrivate::parentAppConstraint();
|
||||
constraint.append(" and exist [X-Plasma-DropUrlPatterns]");
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
||||
|
||||
KPluginInfo::List allApplets = KPluginInfo::fromServices(offers);
|
||||
KPluginInfo::List filtered;
|
||||
foreach (const KPluginInfo &info, allApplets) {
|
||||
QStringList urlPatterns = info.property("X-Plasma-DropUrlPatterns").toStringList();
|
||||
foreach (const QString &glob, urlPatterns) {
|
||||
QRegExp rx(glob);
|
||||
rx.setPatternSyntax(QRegExp::Wildcard);
|
||||
if (rx.exactMatch(url.toString())) {
|
||||
#ifndef NDEBUG
|
||||
kDebug() << info.name() << "matches" << glob << url;
|
||||
#endif
|
||||
filtered << info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly)
|
||||
{
|
||||
QString constraint = AppletPrivate::parentAppConstraint(parentApp);
|
||||
|
@ -267,21 +267,6 @@ class PLASMA_EXPORT Applet : public QObject
|
||||
*/
|
||||
void setTitle(const QString &title) const;
|
||||
|
||||
/**
|
||||
* Returns a list of all known applets associated with a certain mimetype.
|
||||
*
|
||||
* @return list of applets
|
||||
**/
|
||||
static KPluginInfo::List listAppletInfoForMimeType(const QString &mimetype);
|
||||
|
||||
/**
|
||||
* Returns a list of all known applets associated with a certain URL.
|
||||
*
|
||||
* @since 4.4
|
||||
* @return list of applets
|
||||
**/
|
||||
static KPluginInfo::List listAppletInfoForUrl(const QUrl &url);
|
||||
|
||||
/**
|
||||
* Returns a list of all the categories used by installed applets.
|
||||
*
|
||||
|
@ -421,6 +421,41 @@ KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QS
|
||||
return KPluginInfo::fromServices(offers);
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::listAppletInfoForMimeType(const QString &mimeType)
|
||||
{
|
||||
QString constraint = AppletPrivate::parentAppConstraint();
|
||||
constraint.append(QString(" and '%1' in [X-Plasma-DropMimeTypes]").arg(mimeType));
|
||||
//kDebug() << "listAppletInfoForMimetype with" << mimeType << constraint;
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
||||
return KPluginInfo::fromServices(offers);
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url)
|
||||
{
|
||||
QString constraint = AppletPrivate::parentAppConstraint();
|
||||
constraint.append(" and exist [X-Plasma-DropUrlPatterns]");
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
||||
|
||||
KPluginInfo::List allApplets = KPluginInfo::fromServices(offers);
|
||||
KPluginInfo::List filtered;
|
||||
foreach (const KPluginInfo &info, allApplets) {
|
||||
QStringList urlPatterns = info.property("X-Plasma-DropUrlPatterns").toStringList();
|
||||
foreach (const QString &glob, urlPatterns) {
|
||||
QRegExp rx(glob);
|
||||
rx.setPatternSyntax(QRegExp::Wildcard);
|
||||
if (rx.exactMatch(url.toString())) {
|
||||
#ifndef NDEBUG
|
||||
kDebug() << info.name() << "matches" << glob << url;
|
||||
#endif
|
||||
filtered << info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
|
||||
KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp)
|
||||
{
|
||||
KPluginInfo::List list;
|
||||
|
@ -136,6 +136,20 @@ public:
|
||||
**/
|
||||
KPluginInfo::List listAppletInfo(const QString &category, const QString &parentApp = QString());
|
||||
|
||||
/**
|
||||
* Returns a list of all known applets associated with a certain mimetype.
|
||||
*
|
||||
* @return list of applets
|
||||
**/
|
||||
static KPluginInfo::List listAppletInfoForMimeType(const QString &mimetype);
|
||||
|
||||
/**
|
||||
* Returns a list of all known applets associated with a certain URL.
|
||||
*
|
||||
* @return list of applets
|
||||
**/
|
||||
static KPluginInfo::List listAppletInfoForUrl(const QUrl &url);
|
||||
|
||||
/**
|
||||
* Returns a list of all known DataEngines.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user