summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Klapetek <[email protected]>2015-05-25 17:37:08 +0200
committerMartin Klapetek <[email protected]>2015-05-25 17:37:08 +0200
commitb1e2e721a2f8b454b5a7b23df9915978a7a4b8aa (patch)
tree9b75b9274c02b85e1aa870d71f57bdc10285c09a
parent3c1d18feb71c445a60a3280dafe0fa94ec776c68 (diff)
Add a way to obtain a plugin by its name from UiPluginsManager
-rw-r--r--src/uipluginsmanager.cpp20
-rw-r--r--src/uipluginsmanager.h1
2 files changed, 16 insertions, 5 deletions
diff --git a/src/uipluginsmanager.cpp b/src/uipluginsmanager.cpp
index 225a422..5b25f52 100644
--- a/src/uipluginsmanager.cpp
+++ b/src/uipluginsmanager.cpp
@@ -37,7 +37,7 @@ public:
void loadPlugins();
- QList<KAccountsUiPlugin*> uiPlugins;
+ QHash<QString, KAccountsUiPlugin*> pluginsForNames;
QHash<QString, KAccountsUiPlugin*> pluginsForServices;
bool pluginsLoaded;
@@ -52,7 +52,7 @@ UiPluginsManagerPrivate::UiPluginsManagerPrivate()
UiPluginsManagerPrivate::~UiPluginsManagerPrivate()
{
- qDeleteAll(uiPlugins);
+ qDeleteAll(pluginsForNames.values());
}
void UiPluginsManagerPrivate::loadPlugins()
@@ -87,9 +87,9 @@ void UiPluginsManagerPrivate::loadPlugins()
continue;
}
- qDebug() << "Adding plugin" << ui;
+ qDebug() << "Adding plugin" << ui << fileName;
- uiPlugins << ui;
+ pluginsForNames.insert(fileName, ui);
Q_FOREACH (const QString &service, ui->supportedServicesForConfig()) {
qDebug() << " Adding service" << service;
pluginsForServices.insert(service, ui);
@@ -104,13 +104,23 @@ void UiPluginsManagerPrivate::loadPlugins()
pluginsLoaded = true;
}
+
QList<KAccountsUiPlugin*> UiPluginsManager::uiPlugins()
{
if (!s_instance->pluginsLoaded) {
s_instance->loadPlugins();
}
- return s_instance->uiPlugins;
+ return s_instance->pluginsForNames.values();
+}
+
+KAccountsUiPlugin* UiPluginsManager::pluginForName(const QString &name)
+{
+ if (!s_instance->pluginsLoaded) {
+ s_instance->loadPlugins();
+ }
+
+ return s_instance->pluginsForNames.value(name + ".so");
}
KAccountsUiPlugin* UiPluginsManager::pluginForService(const QString &service)
diff --git a/src/uipluginsmanager.h b/src/uipluginsmanager.h
index 1d1791f..15b9479 100644
--- a/src/uipluginsmanager.h
+++ b/src/uipluginsmanager.h
@@ -29,6 +29,7 @@ class UiPluginsManager {
public:
static QList<KAccountsUiPlugin*> uiPlugins();
static KAccountsUiPlugin* pluginForService(const QString &service);
+ static KAccountsUiPlugin* pluginForName(const QString &name);
};
}