diff options
Diffstat (limited to 'src/plugincontainer.cpp')
| -rw-r--r-- | src/plugincontainer.cpp | 89 |
1 files changed, 54 insertions, 35 deletions
diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp index 90a7e95f..60acc63c 100644 --- a/src/plugincontainer.cpp +++ b/src/plugincontainer.cpp @@ -34,6 +34,55 @@ template <> struct PluginTypeName<MOBase::IPluginTool> { static QString value() template <> struct PluginTypeName<MOBase::IPluginProxy> { static QString value() { return QT_TR_NOOP("Proxy"); } };
template <> struct PluginTypeName<MOBase::IPluginFileMapper> { static QString value() { return QT_TR_NOOP("File Mapper"); } };
+
+QStringList PluginContainer::pluginInterfaces()
+{
+ // Find all the names:
+ QStringList names;
+ boost::mp11::mp_for_each<PluginTypeOrder>([&names](const auto* p) {
+ using plugin_type = std::decay_t<decltype(*p)>;
+ auto name = PluginTypeName<plugin_type>::value();
+ if (!name.isEmpty()) {
+ names.append(name);
+ }
+ });
+
+ return names;
+}
+
+
+PluginContainer::PluginContainer(OrganizerCore *organizer)
+ : m_Organizer(organizer)
+ , m_UserInterface(nullptr)
+{
+}
+
+PluginContainer::~PluginContainer() {
+ m_Organizer = nullptr;
+ unloadPlugins();
+}
+
+
+void PluginContainer::setUserInterface(IUserInterface *userInterface, QWidget *widget)
+{
+ for (IPluginProxy *proxy : bf::at_key<IPluginProxy>(m_Plugins)) {
+ proxy->setParentWidget(widget);
+ }
+
+ if (userInterface != nullptr) {
+ for (IPluginModPage *modPage : bf::at_key<IPluginModPage>(m_Plugins)) {
+ userInterface->registerModPage(modPage);
+ }
+
+ for (IPluginTool *tool : bf::at_key<IPluginTool>(m_Plugins)) {
+ userInterface->registerPluginTool(tool);
+ }
+ }
+
+ m_UserInterface = userInterface;
+}
+
+
QStringList PluginContainer::implementedInterfaces(IPlugin* plugin) const
{
// We need a QObject to be able to qobject_cast<> to the plugin types:
@@ -45,7 +94,7 @@ QStringList PluginContainer::implementedInterfaces(IPlugin* plugin) const // Find all the names:
QStringList names;
- boost::mp11::mp_for_each<PluginTypeOrder>([oPlugin, &names](const auto *p) {
+ boost::mp11::mp_for_each<PluginTypeOrder>([oPlugin, &names](const auto* p) {
using plugin_type = std::decay_t<decltype(*p)>;
if (qobject_cast<plugin_type*>(oPlugin)) {
auto name = PluginTypeName<plugin_type>::value();
@@ -53,7 +102,7 @@ QStringList PluginContainer::implementedInterfaces(IPlugin* plugin) const names.append(name);
}
}
- });
+ });
// If the plugin implements at least one interface other than IPlugin, remove IPlugin:
if (names.size() > 1) {
@@ -63,6 +112,7 @@ QStringList PluginContainer::implementedInterfaces(IPlugin* plugin) const return names;
}
+
QString PluginContainer::topImplementedInterface(IPlugin* plugin) const
{
// We need a QObject to be able to qobject_cast<> to the plugin types:
@@ -74,7 +124,7 @@ QString PluginContainer::topImplementedInterface(IPlugin* plugin) const // Find all the names:
QString name;
- boost::mp11::mp_for_each<PluginTypeOrder>([oPlugin, &name](auto *p) {
+ boost::mp11::mp_for_each<PluginTypeOrder>([oPlugin, &name](auto* p) {
using plugin_type = std::decay_t<decltype(*p)>;
if (name.isEmpty() && qobject_cast<plugin_type*>(oPlugin)) {
auto tname = PluginTypeName<plugin_type>::value();
@@ -82,42 +132,11 @@ QString PluginContainer::topImplementedInterface(IPlugin* plugin) const name = tname;
}
}
- });
+ });
return name;
}
-PluginContainer::PluginContainer(OrganizerCore *organizer)
- : m_Organizer(organizer)
- , m_UserInterface(nullptr)
-{
-}
-
-PluginContainer::~PluginContainer() {
- m_Organizer = nullptr;
- unloadPlugins();
-}
-
-
-void PluginContainer::setUserInterface(IUserInterface *userInterface, QWidget *widget)
-{
- for (IPluginProxy *proxy : bf::at_key<IPluginProxy>(m_Plugins)) {
- proxy->setParentWidget(widget);
- }
-
- if (userInterface != nullptr) {
- for (IPluginModPage *modPage : bf::at_key<IPluginModPage>(m_Plugins)) {
- userInterface->registerModPage(modPage);
- }
-
- for (IPluginTool *tool : bf::at_key<IPluginTool>(m_Plugins)) {
- userInterface->registerPluginTool(tool);
- }
- }
-
- m_UserInterface = userInterface;
-}
-
QStringList PluginContainer::pluginFileNames() const
{
|
