From 69d9f32deb8b1fa2cb13cfb438d375d45a655aa6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 25 Mar 2009 01:13:49 -0400 Subject: Add plugin loading code for Arena (though something isn't being exported right) --- sigtools/PluginModel.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'sigtools/PluginModel.cpp') diff --git a/sigtools/PluginModel.cpp b/sigtools/PluginModel.cpp index a6e49526..86ed16b0 100644 --- a/sigtools/PluginModel.cpp +++ b/sigtools/PluginModel.cpp @@ -22,10 +22,14 @@ #include "ClassModel.h" #include "PluginTypeModel.h" +// Sigencore includes +#include + // KDE includes #include #include #include +#include #include // Qt includes @@ -33,12 +37,39 @@ #include #include +using namespace Sigencore::Interfaces; using namespace Sigtools; PluginModel::PluginModel(KService::Ptr service, PluginTypeModel* parent) : BaseModel(parent), - m_service(service) + m_service(service), + m_info(new KPluginInfo(m_service)) { + KPluginLoader loader(m_service->library()); + KPluginFactory *factory = loader.factory(); + + if (!factory) + { + KMessageBox::error(NULL, QString("The plugin of type \"%1\" with name \"%2\" is not a valid Sigen plugin. The error was:\n%3").arg(m_service->serviceTypes()[0]).arg(m_service->name()).arg(loader.errorString()), "Plugin loading error"); + return; + } + + const QStringList types = m_service->serviceTypes(); + foreach (const QString& type, types) + { + if (type == "Sigen/Arena") + { + ArenaPlugin* plugin = factory->create(this); + if (plugin) + { + QStringList arenas = plugin->arenas(); + foreach (const QString& arena, arenas) + m_classes.append(new ClassModel(plugin->icon(arena), arena, plugin->description(arena), this)); + } + } + else + KMessageBox::information(NULL, QString("The plugin type \"%1\" is not supported.").arg(m_service->type()), "Unsupported plugin type"); + } } int PluginModel::rowCount() const -- cgit