diff --git a/MantidPlot/src/ApplicationWindow.cpp b/MantidPlot/src/ApplicationWindow.cpp index 28e05f98eb294afc56cc3c0e5c0736e33154e82f..706d97bae072cd802b59930e49c7b6a28d811b65 100644 --- a/MantidPlot/src/ApplicationWindow.cpp +++ b/MantidPlot/src/ApplicationWindow.cpp @@ -508,8 +508,7 @@ void ApplicationWindow::init(bool factorySettings, const QStringList &args) { qMakePair(userSubWindowName, userSubWindowName)); const QSet<QString> categories = - UserSubWindowFactory::Instance().getInterfaceCategories( - userSubWindowName); + UserSubWindowFactory::Instance().categories(userSubWindowName); m_interfaceCategories[userSubWindowName] = categories; m_allCategories += categories; diff --git a/qt/applications/workbench/workbench/app/mainwindow.py b/qt/applications/workbench/workbench/app/mainwindow.py index 7c7aedc2e3554ec07a3528da9cb657dacc4ea4db..abf4d98d0b6d3056b8ae34d7f249ed3f4a985692 100644 --- a/qt/applications/workbench/workbench/app/mainwindow.py +++ b/qt/applications/workbench/workbench/app/mainwindow.py @@ -52,6 +52,8 @@ from mantidqt.widgets.codeeditor.execution import PythonCodeExecution # noqa from mantidqt.utils.qt import (add_actions, create_action, plugins, widget_updates_disabled) # noqa from mantidqt.project.project import Project # noqa +from mantidqt.interfacemanager import InterfaceManager # noqa +from mantidqt.usersubwindowfactory import UserSubWindowFactory # noqa # Pre-application setup plugins.setup_library_paths() @@ -175,8 +177,9 @@ class MainWindow(QMainWindow): self.project = None self.project_recovery = None - # Interface Runner - self.executioner = None + # Interfaces + self.interface_manager = None + self.interface_executor = None def setup(self): # menus must be done first so they can be filled by the @@ -226,6 +229,9 @@ class MainWindow(QMainWindow): self.project_recovery = ProjectRecovery(globalfiguremanager=GlobalFigureManager, multifileinterpreter=self.editor.editors, main_window=self) + + self.interface_executor = PythonCodeExecution() + self.interface_executor.sig_exec_error.connect(lambda errobj: logger.warning(str(errobj))) self.interface_manager = InterfaceManager() # uses default configuration as necessary @@ -234,13 +240,12 @@ class MainWindow(QMainWindow): self.setup_layout() self.create_actions() - self.populate_menus() def post_mantid_init(self): """Run any setup that requires mantid to have been initialized """ - self.populate_interfaces_menu() + self.populate_menus() self.algorithm_selector.refresh() # turn on algorithm factory notifications @@ -336,18 +341,41 @@ class MainWindow(QMainWindow): add_actions(self.file_menu, self.file_menu_actions) add_actions(self.view_menu, self.view_menu_actions) add_actions(self.help_menu, self.help_menu_actions) + self.populate_interfaces_menu() - def launch_custom_gui(self, filename): - if self.executioner is None: - self.executioner = PythonCodeExecution() - self.executioner.sig_exec_error.connect(lambda errobj: logger.warning(str(errobj))) - + def launch_custom_python_gui(self, filename): self.executioner.execute(open(filename).read(), filename) + def launch_custom_cpp_gui(self, interface_name): + interface = self.interface_manager.createSubWindow(interface_name) + interface.setAttribute(Qt.WA_DeleteOnClose, True) + interface.show() + def populate_interfaces_menu(self): + """Populate then Interfaces menu with all Python and C++ interfaces""" interface_dir = ConfigService['mantidqt.python_interfaces_directory'] - items = ConfigService['mantidqt.python_interfaces'].split() + interfaces = self._discover_python_interfaces(interface_dir) + interfaces.update(self._discover_cpp_interfaces()) + keys = list(interfaces.keys()) + keys.sort() + for key in keys: + submenu = self.interfaces_menu.addMenu(key) + names = interfaces[key] + names.sort() + for name in names: + if '.py' in name: + action = submenu.addAction(name.replace('.py', '').replace('_', ' ')) + script = os.path.join(interface_dir, name) + action.triggered.connect(lambda checked_py, script=script: self.launch_custom_python_gui(script)) + else: + action = submenu.addAction(name) + action.triggered.connect(lambda checked_cpp, name=name: + self.launch_custom_cpp_gui(name)) + + def _discover_python_interfaces(self, interface_dir): + """Return a dictionary mapping a category to a set of named Python interfaces""" + items = ConfigService['mantidqt.python_interfaces'].split() # list of custom interfaces that are not qt4/qt5 compatible GUI_BLACKLIST = ['ISIS_Reflectometry_Old.py', 'Frequency_Domain_Analysis_Old.py', @@ -364,21 +392,23 @@ class MainWindow(QMainWindow): if scriptname in GUI_BLACKLIST: logger.information('Not adding gui "{}"'.format(scriptname)) continue - temp = interfaces.get(key, []) - temp.append(scriptname) - interfaces[key] = temp + interfaces.setdefault(key, []).append(scriptname) - # add the interfaces to the menu - keys = list(interfaces.keys()) - keys.sort() - for key in keys: - submenu = self.interfaces_menu.addMenu(key) - names = interfaces[key] - names.sort() - for name in names: - action = submenu.addAction(name.replace('.py', '').replace('_', ' ')) - script = os.path.join(interface_dir, name) - action.triggered.connect(lambda checked, script=script: self.launch_custom_gui(script)) + return interfaces + + def _discover_cpp_interfaces(self): + """Return a dictionary mapping a category to a set of named C++ interfaces""" + interfaces = {} + cpp_interface_factory = UserSubWindowFactory.Instance() + interface_names = cpp_interface_factory.keys() + for name in interface_names: + categories = cpp_interface_factory.categories(name) + if len(categories) == 0: + categories = ["General"] + for category in categories: + interfaces.setdefault(category, []).append(name) + + return interfaces def add_dockwidget(self, plugin): """Create a dockwidget around a plugin and add the dock to window""" diff --git a/qt/python/mantidqt/_common.sip b/qt/python/mantidqt/_common.sip index 2b63713db74276a872529d1f47aeddd4742fbc53..049b1c0327ce9e79776a0046039f2945bed62fe2 100644 --- a/qt/python/mantidqt/_common.sip +++ b/qt/python/mantidqt/_common.sip @@ -225,6 +225,37 @@ public: GenericDialog(QWidget *parent = nullptr); }; + +class UserSubWindow : QMainWindow { +%TypeHeaderCode +#include "MantidQtWidgets/Common/UserSubWindow.h" +using namespace MantidQt::API; +%End +private: + UserSubWindow(QWidget *parent = nullptr); +}; + +class UserSubWindowFactoryImpl /PyName=UserSubWindowFactory/ { +%TypeHeaderCode +#include "MantidQtWidgets/Common/UserSubWindowFactory.h" +%End +public: + static SIP_PYOBJECT Instance() const; + %MethodCode + auto &cppInstance = MantidQt::API::UserSubWindowFactory::Instance(); + return sipConvertFromType(&cppInstance, sipType_UserSubWindowFactoryImpl, nullptr); + %End + UserSubWindow *createUnwrapped(const std::string &name) const; + QSet<QString> categories(const QString &interfaceName) const; + QStringList keys() const; + +private: + UserSubWindowFactoryImpl(); + UserSubWindowFactoryImpl(const UserSubWindowFactoryImpl &); + ~UserSubWindowFactoryImpl(); +}; + + class InterfaceManager { %TypeHeaderCode #include "MantidQtWidgets/Common/InterfaceManager.h" @@ -240,6 +271,11 @@ public: const QStringList &enabled = QStringList(), const QStringList &disabled = QStringList()); + UserSubWindow *createSubWindow( + const QString &interface_name, + QWidget *parent = nullptr); + QStringList getUserSubWindowKeys() const; + void showHelpPage(const QString &url=QString()); void showWikiPage(const QString &page=QString()); void showAlgorithmHelp(const QString &name, const int version=-1); diff --git a/qt/python/mantidqt/usersubwindowfactory.py b/qt/python/mantidqt/usersubwindowfactory.py new file mode 100644 index 0000000000000000000000000000000000000000..ae6ac54b8fa271573295379933bfc1dc5d843f3c --- /dev/null +++ b/qt/python/mantidqt/usersubwindowfactory.py @@ -0,0 +1,15 @@ +# Mantid Repository : https://github.com/mantidproject/mantid +# +# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, +# NScD Oak Ridge National Laboratory, European Spallation Source +# & Institut Laue - Langevin +# SPDX - License - Identifier: GPL - 3.0 + +# This file is part of the mantidqt package +# +# +from __future__ import (absolute_import) + +from mantidqt.utils.qt import import_qt + + +UserSubWindowFactory = import_qt('._common', 'mantidqt', 'UserSubWindowFactory') diff --git a/qt/widgets/common/CMakeLists.txt b/qt/widgets/common/CMakeLists.txt index 2fce5de193123080feb8a60ff7f6d39366c3f55d..204d7d5bacfea0b45c814055bc4b50a6ff0e2eab 100644 --- a/qt/widgets/common/CMakeLists.txt +++ b/qt/widgets/common/CMakeLists.txt @@ -25,7 +25,6 @@ set(QT5_SRC_FILES # todo: move this to the instrument view library when the slice # viewer library is removed src/InputController.cpp - src/InterfaceFactory.cpp src/InterfaceManager.cpp src/LineEditWithClear.cpp src/ListPropertyWidget.cpp @@ -62,6 +61,7 @@ set(QT5_SRC_FILES src/UserFunctionDialog.cpp src/UserInputValidator.cpp src/UserSubWindow.cpp + src/UserSubWindowFactory.cpp src/VatesViewerInterface.cpp src/WidgetScrollbarDecorator.cpp src/WorkspaceIcons.cpp @@ -194,6 +194,7 @@ set(QT5_INC_FILES ${QT5_MOC_FILES} inc/MantidQtWidgets/Common/AlgorithmInputHistory.h inc/MantidQtWidgets/Common/AlgorithmRunner.h + inc/MantidQtWidgets/Common/AlgorithmDialogFactory.h inc/MantidQtWidgets/Common/AlternateCSPythonLexer.h inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h inc/MantidQtWidgets/Common/DropEventHelper.h @@ -201,7 +202,6 @@ set(QT5_INC_FILES inc/MantidQtWidgets/Common/FlowLayout.h inc/MantidQtWidgets/Common/HelpWindow.h inc/MantidQtWidgets/Common/IFunctionBrowser.h - inc/MantidQtWidgets/Common/InterfaceFactory.h inc/MantidQtWidgets/Common/MantidDesktopServices.h inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h inc/MantidQtWidgets/Common/MultifitSetupDialog.h @@ -262,7 +262,6 @@ set(SRC_FILES src/HelpWindow.cpp src/FlowLayout.cpp src/Hint.cpp - src/InterfaceFactory.cpp src/InterfaceManager.cpp src/ListPropertyWidget.cpp src/ManageUserDirectories.cpp @@ -293,6 +292,7 @@ set(SRC_FILES src/TSVSerialiser.cpp src/UserInputValidator.cpp src/UserSubWindow.cpp + src/UserSubWindowFactory.cpp src/VatesViewerInterface.cpp src/WidgetScrollbarDecorator.cpp src/WindowIcons.cpp @@ -520,6 +520,7 @@ set(INC_FILES inc/MantidQtWidgets/Common/AlgorithmInputHistory.h inc/MantidQtWidgets/Common/AlgorithmRunner.h inc/MantidQtWidgets/Common/AlternateCSPythonLexer.h + inc/MantidQtWidgets/Common/AlgorithmDialogFactory.h inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h inc/MantidQtWidgets/Common/Configurable.h inc/MantidQtWidgets/Common/DllOption.h @@ -530,7 +531,6 @@ set(INC_FILES inc/MantidQtWidgets/Common/DistributionOptions.h inc/MantidQtWidgets/Common/HelpWindow.h inc/MantidQtWidgets/Common/Hint.h - inc/MantidQtWidgets/Common/InterfaceFactory.h inc/MantidQtWidgets/Common/InterfaceManager.h inc/MantidQtWidgets/Common/IProjectSerialisable.h inc/MantidQtWidgets/Common/MantidDesktopServices.h @@ -547,6 +547,7 @@ set(INC_FILES inc/MantidQtWidgets/Common/ScriptRepositoryView.h inc/MantidQtWidgets/Common/SelectionNotificationService.h inc/MantidQtWidgets/Common/SignalBlocker.h + inc/MantidQtWidgets/Common/UserSubWindowFactory.h inc/MantidQtWidgets/Common/TSVSerialiser.h inc/MantidQtWidgets/Common/UserInputValidator.h inc/MantidQtWidgets/Common/WidgetScrollbarDecorator.h diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h index 595dc70f2bda5e8e58bac0798b1b0d8029f7c456..c2f7cdf2f7fa6a6f9d1bb9d8a6d65aff9bf7365c 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h @@ -24,8 +24,8 @@ //---------------------------------- // Includes //---------------------------------- +#include "AlgorithmDialogFactory.h" #include "DllOption.h" -#include "InterfaceFactory.h" // Could have forward declared this but it makes it easier to use from // inheriting classes if it is included here diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialogFactory.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialogFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..4fef8732580cc06dc7213a284d705b604149bc0d --- /dev/null +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialogFactory.h @@ -0,0 +1,71 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + + +#ifndef MANTIDQT_API_ALGORITHMDIALOGFACTORYIMPL_H_ +#define MANTIDQT_API_ALGORITHMDIALOGFACTORYIMPL_H_ + +//------------------------ +// Includes +//------------------------ +#include "DllOption.h" +#include "MantidKernel/DynamicFactory.h" +#include "MantidKernel/SingletonHolder.h" +#include <QHash> +#include <QSetIterator> +#include <QStringList> +#include <set> + +namespace MantidQt { + +namespace API { + +//------------------------------- +// MantidQt forward declarations +//------------------------------- +class AlgorithmDialog; +class UserSubWindow; + +/** + The AlgorithmDialogFactory is responsible for creating concrete instances of + AlgorithmDialog classes. It is implemented as a singleton class. + + @author Martyn Gigg, Tessella plc + @date 24/02/2009 +*/ +class EXPORT_OPT_MANTIDQT_COMMON AlgorithmDialogFactoryImpl + : public Mantid::Kernel::DynamicFactory<AlgorithmDialog> { + +public: + // Unhide the inherited create method + using Mantid::Kernel::DynamicFactory<AlgorithmDialog>::createUnwrapped; + AlgorithmDialogFactoryImpl(const AlgorithmDialogFactoryImpl &) = delete; + AlgorithmDialogFactoryImpl & + operator=(const AlgorithmDialogFactoryImpl &) = delete; + +private: + friend struct Mantid::Kernel::CreateUsingNew<AlgorithmDialogFactoryImpl>; + + /// Private Constructor for singleton class + AlgorithmDialogFactoryImpl() = default; + + /// Private Destructor + ~AlgorithmDialogFactoryImpl() override = default; +}; + +/// The specific instantiation of the templated type +using AlgorithmDialogFactory = + Mantid::Kernel::SingletonHolder<AlgorithmDialogFactoryImpl>; +} // namespace API +} // namespace MantidQt + +namespace Mantid { +namespace Kernel { +EXTERN_MANTIDQT_COMMON template class EXPORT_OPT_MANTIDQT_COMMON + Mantid::Kernel::SingletonHolder<MantidQt::API::AlgorithmDialogFactoryImpl>; +} // namespace Kernel +} // namespace Mantid +#endif \ No newline at end of file diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/UserSubWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/UserSubWindow.h index 8c83a08ba51702e0acb5bd59bda449eb4d5f0abf..0742e3c2dc6f809299065adeb880535461903a91 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/UserSubWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/UserSubWindow.h @@ -24,8 +24,8 @@ // Includes //---------------------------------- #include "DllOption.h" -#include "InterfaceFactory.h" #include "PythonRunner.h" +#include "UserSubWindowFactory.h" #include <QLabel> #include <QMainWindow> diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceFactory.h b/qt/widgets/common/inc/MantidQtWidgets/Common/UserSubWindowFactory.h similarity index 63% rename from qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceFactory.h rename to qt/widgets/common/inc/MantidQtWidgets/Common/UserSubWindowFactory.h index 69033111dd1a2d0242e83b4def9a04feb80a0f9e..ef56205dfa14911a64446a913669745bde641b85 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceFactory.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/UserSubWindowFactory.h @@ -1,11 +1,12 @@ // Mantid Repository : https://github.com/mantidproject/mantid // -// Copyright © 2009 ISIS Rutherford Appleton Laboratory UKRI, +// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, // NScD Oak Ridge National Laboratory, European Spallation Source // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + -#ifndef MANTIDQT_API_INTERFACEFACTORY_H_ -#define MANTIDQT_API_INTERFACEFACTORY_H_ + +#ifndef MANTIDQT_API_USERSUBWINDOWFACTORYIMPL_H_ +#define MANTIDQT_API_USERSUBWINDOWFACTORYIMPL_H_ //------------------------ // Includes @@ -28,37 +29,6 @@ namespace API { class AlgorithmDialog; class UserSubWindow; -/** - The AlgorithmDialogFactory is responsible for creating concrete instances of - AlgorithmDialog classes. It is implemented as a singleton class. - - @author Martyn Gigg, Tessella plc - @date 24/02/2009 -*/ -class EXPORT_OPT_MANTIDQT_COMMON AlgorithmDialogFactoryImpl - : public Mantid::Kernel::DynamicFactory<AlgorithmDialog> { - -public: - // Unhide the inherited create method - using Mantid::Kernel::DynamicFactory<AlgorithmDialog>::createUnwrapped; - AlgorithmDialogFactoryImpl(const AlgorithmDialogFactoryImpl &) = delete; - AlgorithmDialogFactoryImpl & - operator=(const AlgorithmDialogFactoryImpl &) = delete; - -private: - friend struct Mantid::Kernel::CreateUsingNew<AlgorithmDialogFactoryImpl>; - - /// Private Constructor for singleton class - AlgorithmDialogFactoryImpl() = default; - - /// Private Destructor - ~AlgorithmDialogFactoryImpl() override = default; -}; - -/// The specific instantiation of the templated type -using AlgorithmDialogFactory = - Mantid::Kernel::SingletonHolder<AlgorithmDialogFactoryImpl>; - /** The UserSubWindowFactory is responsible for creating concrete instances of user interface classes. It is implemented as a singleton class. @@ -68,22 +38,6 @@ using AlgorithmDialogFactory = */ class EXPORT_OPT_MANTIDQT_COMMON UserSubWindowFactoryImpl : public Mantid::Kernel::DynamicFactory<UserSubWindow> { -public: - template <typename TYPE> void subscribe() { - std::string realName = TYPE::name(); - Mantid::Kernel::DynamicFactory<UserSubWindow>::subscribe<TYPE>(realName); - saveAliasNames<TYPE>(realName); - - // Make a record of each interface's categories. - const QStringList categories = - TYPE::categoryInfo().split(";", QString::SkipEmptyParts); - QSet<QString> result; - foreach (const QString category, categories) { - result.insert(category.trimmed()); - } - m_categoryLookup[QString::fromStdString(realName)] = result; - } - public: UserSubWindowFactoryImpl(const UserSubWindowFactoryImpl &) = delete; UserSubWindowFactoryImpl & @@ -91,7 +45,10 @@ public: // Override createUnwrapped to search through the alias list UserSubWindow *createUnwrapped(const std::string &name) const override; - QSet<QString> getInterfaceCategories(const QString &interfaceName) const; + QSet<QString> categories(const QString &interfaceName) const; + QStringList keys() const; + + template <typename TYPE> void subscribe(); protected: // Unhide the inherited create method @@ -119,6 +76,21 @@ private: QHash<QString, QSet<QString>> m_categoryLookup; }; +template <typename TYPE> void UserSubWindowFactoryImpl::subscribe() { + std::string realName = TYPE::name(); + Mantid::Kernel::DynamicFactory<UserSubWindow>::subscribe<TYPE>(realName); + saveAliasNames<TYPE>(realName); + + // Make a record of each interface's categories. + const QStringList categories = + TYPE::categoryInfo().split(";", QString::SkipEmptyParts); + QSet<QString> result; + foreach (const QString category, categories) { + result.insert(category.trimmed()); + } + m_categoryLookup[QString::fromStdString(realName)] = result; +} + /** * Save the alias names of an interface * @param realName :: The real name of the interface @@ -148,16 +120,15 @@ void UserSubWindowFactoryImpl::saveAliasNames(const std::string &realName) { /// The specific instantiation of the templated type using UserSubWindowFactory = Mantid::Kernel::SingletonHolder<UserSubWindowFactoryImpl>; + } // namespace API } // namespace MantidQt namespace Mantid { namespace Kernel { -EXTERN_MANTIDQT_COMMON template class EXPORT_OPT_MANTIDQT_COMMON - Mantid::Kernel::SingletonHolder<MantidQt::API::AlgorithmDialogFactoryImpl>; EXTERN_MANTIDQT_COMMON template class EXPORT_OPT_MANTIDQT_COMMON Mantid::Kernel::SingletonHolder<MantidQt::API::UserSubWindowFactoryImpl>; } // namespace Kernel } // namespace Mantid -#endif // MANTIDQT_API_INTERFACEFACTORY_H_ +#endif diff --git a/qt/widgets/common/src/InterfaceManager.cpp b/qt/widgets/common/src/InterfaceManager.cpp index eb0b30fab733383bf91d15a3b5ab75d287e1414e..494e3cc53bfb0e75fabbca10f4707b566bcda960 100644 --- a/qt/widgets/common/src/InterfaceManager.cpp +++ b/qt/widgets/common/src/InterfaceManager.cpp @@ -9,12 +9,13 @@ //---------------------------------- #include "MantidQtWidgets/Common/InterfaceManager.h" #include "MantidQtWidgets/Common/AlgorithmDialog.h" +#include "MantidQtWidgets/Common/AlgorithmDialogFactory.h" #include "MantidQtWidgets/Common/GenericDialog.h" -#include "MantidQtWidgets/Common/InterfaceFactory.h" #include "MantidQtWidgets/Common/MantidDesktopServices.h" #include "MantidQtWidgets/Common/MantidHelpWindow.h" #include "MantidQtWidgets/Common/PluginLibraries.h" #include "MantidQtWidgets/Common/UserSubWindow.h" +#include "MantidQtWidgets/Common/UserSubWindowFactory.h" #include "MantidQtWidgets/Common/VatesViewerInterface.h" #include "MantidAPI/AlgorithmManager.h" @@ -175,14 +176,7 @@ UserSubWindow *InterfaceManager::createSubWindow(const QString &interface_name, * refer to UserSubWindow classes */ QStringList InterfaceManager::getUserSubWindowKeys() const { - QStringList key_list; - std::vector<std::string> keys = UserSubWindowFactory::Instance().getKeys(); - std::vector<std::string>::const_iterator iend = keys.end(); - for (std::vector<std::string>::const_iterator itr = keys.begin(); itr != iend; - ++itr) { - key_list.append(QString::fromStdString(*itr)); - } - return key_list; + return UserSubWindowFactory::Instance().keys(); } //---------------------------------- diff --git a/qt/widgets/common/src/InterfaceFactory.cpp b/qt/widgets/common/src/UserSubWindowFactory.cpp similarity index 85% rename from qt/widgets/common/src/InterfaceFactory.cpp rename to qt/widgets/common/src/UserSubWindowFactory.cpp index 1cb8ef9d38eec628e488ca15621d71441a20198a..da47021dcdaf149e2cccbeb4f5b02299dce0e1ff 100644 --- a/qt/widgets/common/src/InterfaceFactory.cpp +++ b/qt/widgets/common/src/UserSubWindowFactory.cpp @@ -1,13 +1,13 @@ // Mantid Repository : https://github.com/mantidproject/mantid // -// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, // NScD Oak Ridge National Laboratory, European Spallation Source // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + //----------------------------------------------- // Includes //----------------------------------------------- -#include "MantidQtWidgets/Common/InterfaceFactory.h" +#include "MantidQtWidgets/Common/UserSubWindowFactory.h" #include "MantidKernel/Logger.h" #include "MantidQtWidgets/Common/UserSubWindow.h" #include <sstream> @@ -68,8 +68,8 @@ UserSubWindowFactoryImpl::createUnwrapped(const std::string &name) const { *been registered, * else an empty set. */ -QSet<QString> UserSubWindowFactoryImpl::getInterfaceCategories( - const QString &interfaceName) const { +QSet<QString> +UserSubWindowFactoryImpl::categories(const QString &interfaceName) const { if (!m_categoryLookup.contains(interfaceName)) return QSet<QString>(); @@ -113,3 +113,17 @@ UserSubWindowFactoryImpl::createFromAlias(const std::string &name) const { return nullptr; } } + +/** + * The keys associated with UserSubWindow classes + * @returns A QStringList containing the keys from the UserSubWindowFactory that + * refer to UserSubWindow classes + */ +QStringList UserSubWindowFactoryImpl::keys() const { + QStringList key_list; + const auto keys = getKeys(); + for (const auto &key : keys) { + key_list.append(QString::fromStdString(key)); + } + return key_list; +}