From 0b4c141bc4508cdf07b8d3ae77dc70d981368d70 Mon Sep 17 00:00:00 2001 From: Hans-Christian Ebke Date: Fri, 27 Jul 2012 08:22:07 +0000 Subject: [PATCH] Core: Added getToolbox method to scripting interface. git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15117 383ad7c9-94d9-4d36-a494-682f7c89f535 --- Core/Core.hh | 9 +++++++++ Core/scripting.cc | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Core/Core.hh b/Core/Core.hh index 401b4cf0..18d38fb2 100644 --- a/Core/Core.hh +++ b/Core/Core.hh @@ -948,6 +948,15 @@ private slots: /// Add a Toolbox from a plugin or from scripting (with icon) void addToolbox(QString _name ,QWidget* _widget, QIcon* _icon); + /** + * Get a toolbox. + * + * @param _pluginName The plugin which the requested toolbox belongs tp. + * @param _toolboxName The name of the requested toolbox. + * @return A pointer to the requested widget if it was found, nullptr, otherwise. + */ + QWidget *getToolbox(QString _pluginName, QString _toolboxName); + private : //=========================================================================== diff --git a/Core/scripting.cc b/Core/scripting.cc index 7aab1ce8..16d31ab7 100644 --- a/Core/scripting.cc +++ b/Core/scripting.cc @@ -217,6 +217,25 @@ void Core::setToolBoxSide(QString _side) { //----------------------------------------------------------------------------- +QWidget *Core::getToolbox(QString _pluginName, QString _toolboxName) { + std::vector::const_iterator pluginIt = plugins_.end(); + for (std::vector::const_iterator it = plugins_.begin(), it_end = plugins_.end(); it != it_end; ++it) { + if (it->name == _pluginName) { + pluginIt = it; + } + } + if (pluginIt == plugins_.end()) return 0; + + std::vector >::const_iterator widgetIt; + for (std::vector >::const_iterator it = pluginIt->toolboxWidgets.begin(), it_end = pluginIt->toolboxWidgets.end(); + it != it_end; ++it) { + if (it->first == _toolboxName) + return it->second; + } + + return 0; +} + void Core::addToolbox(QString _name ,QWidget* _widget) { int id = -1; -- GitLab