From ed299a04778350c3a43de902aedbcc6c7cc91644 Mon Sep 17 00:00:00 2001 From: Raquel Alvarez <raquel.alvarez-banos@stfc.ac.uk> Date: Fri, 26 Aug 2016 09:12:05 +0100 Subject: [PATCH] Re #16632 Create a tree manager. So far it deals with commands --- MantidQt/MantidWidgets/CMakeLists.txt | 4 + .../DataProcessorAppendGroupCommand.h | 7 + .../DataProcessorAppendRowCommand.h | 8 + .../DataProcessorClearSelectedCommand.h | 5 + .../DataProcessorUI/DataProcessorCommand.h | 3 + .../DataProcessorCommandAdapter.h | 29 +++ .../DataProcessorCopySelectedCommand.h | 7 + .../DataProcessorCutSelectedCommand.h | 7 + .../DataProcessorDeleteGroupCommand.h | 7 + .../DataProcessorDeleteRowCommand.h | 5 + .../DataProcessorExpandCommand.h | 10 + .../DataProcessorExportTableCommand.h | 5 + .../DataProcessorGroupRowsCommand.h | 5 + .../DataProcessorImportTableCommand.h | 5 + .../DataProcessorMockObjects.h | 9 + .../DataProcessorNewTableCommand.h | 5 + .../DataProcessorOpenTableCommand.h | 7 + .../DataProcessorOptionsCommand.h | 5 + .../DataProcessorPasteSelectedCommand.h | 7 + .../DataProcessorPlotGroupCommand.h | 8 + .../DataProcessorPlotRowCommand.h | 8 + .../DataProcessorProcessCommand.h | 10 + .../DataProcessorSaveTableAsCommand.h | 6 + .../DataProcessorSaveTableCommand.h | 5 + .../DataProcessorSeparatorCommand.h | 3 + .../DataProcessorTreeManager.h | 57 +++++ .../DataProcessorTwoLevelTreeManager.h | 55 +++++ .../DataProcessorUI/DataProcessorView.h | 6 + .../DataProcessorUI/DataProcessorWidget.ui | 229 ------------------ .../DataProcessorWorkspaceCommand.h | 3 + .../GenericDataProcessorPresenter.h | 8 +- .../DataProcessorUI/QDataProcessorWidget.h | 23 +- .../DataProcessorTwoLevelTreeManager.cpp | 83 +++++++ .../GenericDataProcessorPresenter.cpp | 87 ++----- .../DataProcessorUI/QDataProcessorWidget.cpp | 175 +++---------- .../DataProcessorCommandsTest.h | 1 - .../DataProcessorTwoLevelTreeManagerTest.h | 89 +++++++ .../GenericDataProcessorPresenterTest.h | 86 +------ 38 files changed, 554 insertions(+), 528 deletions(-) create mode 100644 MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTreeManager.h create mode 100644 MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTwoLevelTreeManager.h create mode 100644 MantidQt/MantidWidgets/src/DataProcessorUI/DataProcessorTwoLevelTreeManager.cpp create mode 100644 MantidQt/MantidWidgets/test/DataProcessorUI/DataProcessorTwoLevelTreeManagerTest.h diff --git a/MantidQt/MantidWidgets/CMakeLists.txt b/MantidQt/MantidWidgets/CMakeLists.txt index c7dbc9137bb..9b389cd5258 100644 --- a/MantidQt/MantidWidgets/CMakeLists.txt +++ b/MantidQt/MantidWidgets/CMakeLists.txt @@ -10,6 +10,7 @@ set ( SRC_FILES src/DataProcessorUI/DataProcessorPreprocessingAlgorithm.cpp src/DataProcessorUI/DataProcessorProcessingAlgorithm.cpp src/DataProcessorUI/DataProcessorProcessingAlgorithmBase.cpp + src/DataProcessorUI/DataProcessorTwoLevelTreeManager.cpp src/DataProcessorUI/DataProcessorWhiteList.cpp src/DataProcessorUI/GenericDataProcessorPresenter.cpp src/DataProcessorUI/ParseKeyValueString.cpp @@ -228,6 +229,8 @@ set ( INC_FILES inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorProcessingAlgorithmBase.h inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableAsCommand.h inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableCommand.h + inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTreeManager.h + inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTwoLevelTreeManager.h inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorVectorString.h inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorWhiteList.h @@ -333,6 +336,7 @@ set ( TEST_FILES DataProcessorUI/DataProcessorProcessingAlgorithmTest.h DataProcessorUI/DataProcessorCommandsTest.h DataProcessorUI/DataProcessorGenerateNotebookTest.h + DataProcessorUI/DataProcessorTwoLevelTreeManagerTest.h DataProcessorUI/DataProcessorWhiteListTest.h DataProcessorUI/GenericDataProcessorPresenterTest.h DataProcessorUI/ParseKeyValueStringTest.h diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendGroupCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendGroupCommand.h index c288990a45b..2a9486bb3a5 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendGroupCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendGroupCommand.h @@ -42,6 +42,13 @@ public: }; std::string name() override { return std::string("Insert Group After"); } std::string icon() override { return std::string("://insert_group.png"); } + std::string tooltip() override { return std::string("Inserts group after"); } + std::string whatsthis() override { + return std::string("Inserts a new group after the first selected group. If " + "no groups are selected then a new group is added at " + "the end of the table"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendRowCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendRowCommand.h index e113d5c9e7e..5fba52f856e 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendRowCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendRowCommand.h @@ -42,6 +42,14 @@ public: }; std::string name() override { return std::string("Insert Row After"); } std::string icon() override { return std::string("://insert_row.png"); } + std::string tooltip() override { return std::string("Inserts row after"); } + std::string whatsthis() override { + return std::string("Inserts a new row after the last selected row. If " + "groups exist and a group is selected, the new row is " + "appended to the selected group. If nothing is selected " + "then a new row is added to the last group"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorClearSelectedCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorClearSelectedCommand.h index 92270dc1234..81e387d829d 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorClearSelectedCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorClearSelectedCommand.h @@ -41,6 +41,11 @@ public: }; std::string name() override { return std::string("Clear Selected"); } std::string icon() override { return std::string("://erase.png"); } + std::string tooltip() override { return std::string("Clear selected"); } + std::string whatsthis() override { + return std::string("Clears the contents of the selected rows"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommand.h index f862282aa29..ee056a78104 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommand.h @@ -41,6 +41,9 @@ public: virtual void execute() = 0; virtual std::string name() = 0; virtual std::string icon() = 0; + virtual std::string tooltip() = 0; + virtual std::string whatsthis() = 0; + virtual std::string shortcut() = 0; virtual bool hasChild() final { return !m_child.empty(); }; virtual void setChild(std::vector<std::unique_ptr<DataProcessorCommand>> child) final { diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommandAdapter.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommandAdapter.h index b1c70b7785c..6fd0dbb71b5 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommandAdapter.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommandAdapter.h @@ -7,6 +7,7 @@ #include <QObject> #include <memory> #include <qmenu.h> +#include <qtoolbar.h> #include <vector> namespace MantidQt { @@ -45,6 +46,10 @@ class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS DataProcessorCommandAdapter : public QObject { Q_OBJECT public: + /** Constructor: Adds actions to a menu + * @param menu :: The menu where the actions will be added + * @param adaptee :: The action to add + */ DataProcessorCommandAdapter(QMenu *menu, DataProcessorCommand_uptr adaptee) : m_adaptee(std::move(adaptee)) { @@ -72,6 +77,30 @@ public: } }; + /** Constructor: Adds actions to a toolbar + * @param toolbar :: The toolbar where actions will be added + * @param adaptee :: The action to add + */ + DataProcessorCommandAdapter(QToolBar *toolbar, + DataProcessorCommand_uptr adaptee) + : m_adaptee(std::move(adaptee)) { + + if (!m_adaptee->hasChild()) { + // Sub-menus cannot be added to a toolbar + + QAction *action = + new QAction(QString::fromStdString(m_adaptee->name()), this); + action->setIcon(QIcon(QString::fromStdString(m_adaptee->icon()))); + action->setSeparator(m_adaptee->isSeparator()); + action->setToolTip(QString::fromStdString(m_adaptee->tooltip())); + action->setWhatsThis(QString::fromStdString(m_adaptee->whatsthis())); + action->setShortcut( + QKeySequence(QString::fromStdString(m_adaptee->shortcut()))); + toolbar->addAction(action); + connect(action, SIGNAL(triggered()), this, SLOT(call())); + } + }; + public slots: void call() { m_adaptee->execute(); } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCopySelectedCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCopySelectedCommand.h index c650005e6e8..10125347e26 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCopySelectedCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCopySelectedCommand.h @@ -41,6 +41,13 @@ public: }; std::string name() override { return std::string("Copy Selected"); } std::string icon() override { return std::string("://copy.png"); } + std::string tooltip() override { return std::string("Copy selected"); } + std::string whatsthis() override { + return std::string("Copies the selected rows to the clipboard. Each row is " + "placed on a new line, and each cell is separated by a " + "tab"); + } + std::string shortcut() override { return std::string("Ctrl+C"); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCutSelectedCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCutSelectedCommand.h index a928ffd6a59..9d40805a573 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCutSelectedCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorCutSelectedCommand.h @@ -41,6 +41,13 @@ public: }; std::string name() override { return std::string("Cut Selected"); } std::string icon() override { return std::string("://cut.png"); } + std::string tooltip() override { return std::string("Cut selected"); } + std::string whatsthis() override { + return std::string("Copies the selected rows to the clipboard, and then " + "deletes them. Each row is placed on a new line, and " + "each cell is separated by a tab"); + } + std::string shortcut() override { return std::string("Ctrl+X"); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteGroupCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteGroupCommand.h index f5439df1ef8..ca2ac858da1 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteGroupCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteGroupCommand.h @@ -42,6 +42,13 @@ public: }; std::string name() override { return std::string("Delete Group"); } std::string icon() override { return std::string("://delete_group.png"); } + std::string tooltip() override { + return std::string("Deletes selected group"); + } + std::string whatsthis() override { + return std::string("Deletes the selected groups"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteRowCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteRowCommand.h index 9563c50d86c..2913afcc68a 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteRowCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteRowCommand.h @@ -42,6 +42,11 @@ public: }; std::string name() override { return std::string("Delete Row"); } std::string icon() override { return std::string("://delete_row.png"); } + std::string tooltip() override { return std::string("Deletes a row"); } + std::string whatsthis() override { + return std::string("Deletes the selected row"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorExpandCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorExpandCommand.h index f0ccee1d39c..ffd81fde66e 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorExpandCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorExpandCommand.h @@ -41,6 +41,16 @@ public: }; std::string name() override { return std::string("Expand Selection"); } std::string icon() override { return std::string("://fit_frame.png"); } + std::string tooltip() override { + return std::string("Selects an entire group"); + } + std::string whatsthis() override { + return std::string("Expands the current selection to include any runs that " + "are in the same group as any selected run. This " + "effectively means selecting the group to which the " + "selected run belongs"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorExportTableCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorExportTableCommand.h index 75302adbcdc..1d79e9a3ee5 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorExportTableCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorExportTableCommand.h @@ -43,6 +43,11 @@ public: }; std::string name() override { return std::string("Export .TBL"); } std::string icon() override { return std::string("://save_template.png"); } + std::string tooltip() override { return std::string("Export .TBL file"); } + std::string whatsthis() override { + return std::string("Opens a dialog to export a table as .TBL file"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorGroupRowsCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorGroupRowsCommand.h index f8a3fb60238..05c67bc6075 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorGroupRowsCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorGroupRowsCommand.h @@ -41,6 +41,11 @@ public: }; std::string name() override { return std::string("Group Selected"); } std::string icon() override { return std::string("://drag_curves.png"); } + std::string tooltip() override { return std::string("Group selected rows"); } + std::string whatsthis() override { + return std::string("Places all selected runs into the same group"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorImportTableCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorImportTableCommand.h index 09c8f260645..f4e34e1801d 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorImportTableCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorImportTableCommand.h @@ -41,6 +41,11 @@ public: }; std::string name() override { return std::string("Import .TBL"); } std::string icon() override { return std::string("://open_template.png"); } + std::string tooltip() override { return std::string("Import .TBL file"); } + std::string whatsthis() override { + return std::string("Opens a dialog to select a .TBL file to import"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMockObjects.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMockObjects.h index 8bbbcf0d938..b35ff72755a 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMockObjects.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMockObjects.h @@ -53,12 +53,21 @@ public: // Settings MOCK_METHOD1(loadSettings, void(std::map<std::string, QVariant> &)); + // Acctions/commands + // Gmock requires parameters and return values of mocked methods to be + // copyable which means we have to mock addActions() via a proxy method + void addActions(std::vector<DataProcessorCommand_uptr>) override { + addActionsProxy(); + } + MOCK_METHOD0(addActionsProxy, void()); + // Calls we don't care about void showTable(QDataProcessorTwoLevelTreeModel_sptr) override{}; void saveSettings(const std::map<std::string, QVariant> &) override{}; std::string getProcessInstrument() const override { return "FAKE"; } DataProcessorPresenter *getPresenter() const override { return nullptr; } + }; class MockMainPresenter : public DataProcessorMainPresenter { diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorNewTableCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorNewTableCommand.h index 91e74b6e596..8677030aaa6 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorNewTableCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorNewTableCommand.h @@ -41,6 +41,11 @@ public: }; std::string name() override { return std::string("New Table"); } std::string icon() override { return std::string("://new.png"); } + std::string tooltip() override { return std::string("New Table"); } + std::string whatsthis() override { + return std::string("Loads a blank table into the interface"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorOpenTableCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorOpenTableCommand.h index cd09308792b..84ab7564096 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorOpenTableCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorOpenTableCommand.h @@ -41,6 +41,13 @@ public: }; std::string name() override { return std::string("Open Table"); } std::string icon() override { return std::string("://multiload.png"); } + std::string tooltip() override { return std::string("Open Table"); } + std::string whatsthis() override { + return std::string("Loads a table into the interface. Table must exist in " + "the ADS and be compatible in terms of the number and " + "type of columns"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorOptionsCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorOptionsCommand.h index be6a3e760c7..2758978de7b 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorOptionsCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorOptionsCommand.h @@ -41,6 +41,11 @@ public: }; std::string name() override { return std::string("Options"); } std::string icon() override { return std::string("://configure.png"); } + std::string tooltip() override { return std::string("Options"); } + std::string whatsthis() override { + return std::string("Opens a dialog with some options for the table"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPasteSelectedCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPasteSelectedCommand.h index bd95252faab..16ccd8f8ecb 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPasteSelectedCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPasteSelectedCommand.h @@ -41,6 +41,13 @@ public: }; std::string name() override { return std::string("Paste Selected"); } std::string icon() override { return std::string("://paste.png"); } + std::string tooltip() override { return std::string("Paste selected"); } + std::string whatsthis() override { + return std::string("Pastes the contents of the clipboard into the selected " + "rows. If no rows are selected, new ones are added at " + "the end"); + } + std::string shortcut() override { return std::string("Ctrl+V"); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotGroupCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotGroupCommand.h index b18566abf28..1842ddec73a 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotGroupCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotGroupCommand.h @@ -41,6 +41,14 @@ public: }; std::string name() override { return std::string("Plot Selected Groups"); } std::string icon() override { return std::string("://trajectory.png"); } + std::string tooltip() override { + return std::string("Plots the selected group"); + } + std::string whatsthis() override { + return std::string("Creates a plot of the post-processed workspaces " + "produced by any groups any selected runs are in"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotRowCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotRowCommand.h index 1a0c6f3c671..eafc5b9e566 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotRowCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotRowCommand.h @@ -41,6 +41,14 @@ public: }; std::string name() override { return std::string("Plot Selected Rows"); } std::string icon() override { return std::string("://graph.png"); } + std::string tooltip() override { + return std::string("Plot the selected runs"); + } + std::string whatsthis() override { + return std::string("Creates a plot of the reduced workspaces produced by " + "the selected runs"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorProcessCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorProcessCommand.h index 03f7ce1c27a..011e3dda63f 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorProcessCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorProcessCommand.h @@ -41,6 +41,16 @@ public: }; std::string name() override { return std::string("Process"); } std::string icon() override { return std::string("://stat_rows.png"); } + std::string tooltip() override { + return std::string("Processes selected runs"); + } + std::string whatsthis() override { + return std::string("Processes the selected runs. Selected runs are reduced " + "sequentially and independently. If nothing is " + "selected, the behaviour is as if all " + "runs were selected."); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableAsCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableAsCommand.h index ccb14070295..5600edcbf4a 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableAsCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableAsCommand.h @@ -41,6 +41,12 @@ public: }; std::string name() override { return std::string("Save Table As"); } std::string icon() override { return std::string("://filesaveas.png"); } + std::string tooltip() override { return std::string("Save Table As"); } + std::string whatsthis() override { + return std::string("Saves current table as a table workspace. Asks for the " + "name of the ouput table"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableCommand.h index e96c7808e67..2281de73a2b 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableCommand.h @@ -41,6 +41,11 @@ public: }; std::string name() override { return std::string("Save Table"); } std::string icon() override { return std::string("://filesave.png"); } + std::string tooltip() override { return std::string("Save Table"); } + std::string whatsthis() override { + return std::string("Saves current table as a table workspace"); + } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSeparatorCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSeparatorCommand.h index 4234d01032e..43c69e495cf 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSeparatorCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorSeparatorCommand.h @@ -41,6 +41,9 @@ public: void execute() override{}; std::string name() override { return std::string(); } std::string icon() override { return std::string(); } + std::string tooltip() override { return std::string(); } + std::string whatsthis() override { return std::string(); } + std::string shortcut() override { return std::string(); } }; } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTreeManager.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTreeManager.h new file mode 100644 index 00000000000..f79df6e497c --- /dev/null +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTreeManager.h @@ -0,0 +1,57 @@ +#ifndef MANTIDQTMANTIDWIDGETS_DATAPROCESSORTREEMANAGER_H +#define MANTIDQTMANTIDWIDGETS_DATAPROCESSORTREEMANAGER_H + +#include <memory> +#include <vector> + +namespace MantidQt { +namespace MantidWidgets { + +class DataProcessorCommand; + +/** @class DataProcessorTreeManager + +// TODO: Description + +Copyright © 2011-16 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid>. +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ + +class DataProcessorTreeManager { +public: + virtual ~DataProcessorTreeManager(){}; + + /// Actions/commands + + /// Publish actions/commands + virtual std::vector<std::unique_ptr<DataProcessorCommand>> + publishCommands() = 0; + +protected: + /// Add a command to the list of available commands + void addCommand(std::vector<std::unique_ptr<DataProcessorCommand>> &commands, + std::unique_ptr<DataProcessorCommand> command) { + commands.push_back(std::move(command)); + } +}; +} +} +#endif /* MANTIDQTMANTIDWIDGETS_DATAPROCESSORTREEMANAGER_H */ diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTwoLevelTreeManager.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTwoLevelTreeManager.h new file mode 100644 index 00000000000..fb114b9ee2d --- /dev/null +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorTwoLevelTreeManager.h @@ -0,0 +1,55 @@ +#ifndef MANTIDQTMANTIDWIDGETS_DATAPROCESSORTWOLEVELTREEMANAGER_H +#define MANTIDQTMANTIDWIDGETS_DATAPROCESSORTWOLEVELTREEMANAGER_H + +#include "MantidAPI/ITableWorkspace_fwd.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorTreeManager.h" +#include "MantidQtMantidWidgets/WidgetDllOption.h" + +namespace MantidQt { +namespace MantidWidgets { + +class DataProcessorPresenter; + +/** @class DataProcessorTwoLevelTreeManager + +// TODO: Description + +Copyright © 2011-16 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid>. +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS DataProcessorTwoLevelTreeManager + : public DataProcessorTreeManager { +public: + /// Constructor + DataProcessorTwoLevelTreeManager(DataProcessorPresenter *presenter); + /// Destructor + ~DataProcessorTwoLevelTreeManager() override; + + /// Publish commands + std::vector<std::unique_ptr<DataProcessorCommand>> publishCommands() override; + +private: + /// The DataProcessor presenter + DataProcessorPresenter *m_presenter; +}; +} +} +#endif /*MANTIDQTMANTIDWIDGETS_DATAPROCESSORTWOLEVELTREEMANAGER_H*/ diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h index cfa41d1b873..f1abfdff553 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h @@ -5,6 +5,7 @@ #include "MantidQtMantidWidgets/DataProcessorUI/QDataProcessorTwoLevelTreeModel.h" #include <map> +#include <memory> #include <set> #include <string> @@ -12,6 +13,7 @@ namespace MantidQt { namespace MantidWidgets { // Forward dec class HintStrategy; +class DataProcessorCommand; class DataProcessorPresenter; /** @class DataProcessorView @@ -47,6 +49,10 @@ public: DataProcessorView(){}; virtual ~DataProcessorView(){}; + // Add actions to the toolbar + virtual void addActions( + std::vector<std::unique_ptr<DataProcessorCommand>> commands) = 0; + // Connect the model virtual void showTable(QDataProcessorTwoLevelTreeModel_sptr model) = 0; diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorWidget.ui b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorWidget.ui index 7d5a0d04d6b..d9deb8bc5ce 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorWidget.ui +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorWidget.ui @@ -27,23 +27,6 @@ <property name="styleSheet"> <string>QToolBar{border: none;}</string> </property> - <addaction name="actionProcess"/> - <addaction name="actionExpandSelection"/> - <addaction name="separator"/> - <addaction name="actionPlotRow"/> - <addaction name="actionPlotGroup"/> - <addaction name="separator"/> - <addaction name="actionAppendRow"/> - <addaction name="actionAppendGroup"/> - <addaction name="actionDeleteRow"/> - <addaction name="actionDeleteGroup"/> - <addaction name="separator"/> - <addaction name="actionGroupRows"/> - <addaction name="actionCopySelected"/> - <addaction name="actionCutSelected"/> - <addaction name="actionPasteSelected"/> - <addaction name="actionClearSelected"/> - <addaction name="actionHelp"/> </widget> </item> <item> @@ -160,218 +143,6 @@ </iconset> </property> </widget> - <action name="actionProcess"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/stat_rows.png</normaloff>:/stat_rows.png</iconset> - </property> - <property name="text"> - <string>Process</string> - </property> - <property name="whatsThis"> - <string>Processes the selected rows/groups. Selected rows are reduced sequentially and independently. When a group is selected, rows are in addition post-processed together. If nothing is selected the behaviour is as if all groups were selected.</string> - </property> - </action> - <action name="actionExpandSelection"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/fit_frame.png</normaloff>:/fit_frame.png</iconset> - </property> - <property name="text"> - <string>Expand Selection</string> - </property> - <property name="toolTip"> - <string>Select an entire group</string> - </property> - <property name="whatsThis"> - <string>Expands the current selection to include any rows that are in the same group as any selected row. This effectively means selecting the group to which the selected row belongs.</string> - </property> - </action> - <action name="actionPlotRow"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/graph.png</normaloff>:/graph.png - </iconset> - </property> - <property name="text"> - <string>Plot Selected Rows</string> - </property> - <property name="toolTip"> - <string>Plot the selected rows</string> - </property> - <property name="whatsThis"> - <string>Creates a plot of the reduced workspaces produced by the selected rows.</string> - </property> - </action> - <action name="actionPlotGroup"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/trajectory.png</normaloff>:/trajectory.png - </iconset> - </property> - <property name="text"> - <string>Plot Selected Groups</string> - </property> - <property name="toolTip"> - <string>Plot the selected groups</string> - </property> - <property name="whatsThis"> - <string>Creates a plot of the post-processed workspaces produced by any groups any selected rows are in.</string> - </property> - </action> - <action name="actionAppendRow"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/insert_row.png</normaloff>:/insert_row.png - </iconset> - </property> - <property name="text"> - <string>Insert Row After</string> - </property> - <property name="toolTip"> - <string>Insert Row After</string> - </property> - <property name="whatsThis"> - <string>Inserts a new row after the last selected row. - If a group is selected, the new row is appended to the selected group. - If nothing is selected then a new row is added to the last group.</string> - </property> - </action> - <action name="actionAppendGroup"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/insert_group.png</normaloff>:/insert_group.png - </iconset> - </property> - <property name="text"> - <string>Insert Group After</string> - </property> - <property name="toolTip"> - <string>Insert Group After</string> - </property> - <property name="whatsThis"> - <string>Inserts a new group after the first selected group. If no groups are selected then a new group is added at the end of the table.</string> - </property> - </action> - <action name="actionDeleteRow"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/delete_row.png</normaloff>:/delete_row.png - </iconset> - </property> - <property name="text"> - <string>Delete Row</string> - </property> - <property name="whatsThis"> - <string>Deletes the selected rows.</string> - </property> - </action> - <action name="actionDeleteGroup"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/delete_group.png</normaloff>:/delete_group.png - </iconset> - </property> - <property name="text"> - <string>Delete Row</string> - </property> - <property name="whatsThis"> - <string>Deletes the selected groups.</string> - </property> - </action> - <action name="actionGroupRows"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/drag_curves.png</normaloff>:/drag_curves.png - </iconset> - </property> - <property name="text"> - <string>Group Selected</string> - </property> - <property name="whatsThis"> - <string>Places all of the selected rows into the same group.</string> - </property> - </action> - <action name="actionCopySelected"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/copy.png</normaloff>:/copy.png - </iconset> - </property> - <property name="text"> - <string>Copy Selected</string> - </property> - <property name="whatsThis"> - <string>Copies the selected rows to the clipboard. Each row is placed on a new line, and each cell is separated by a tab.</string> - </property> - <property name="shortcut"> - <string>Ctrl+C</string> - </property> - </action> - <action name="actionCutSelected"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/cut.png</normaloff>:/cut.png - </iconset> - </property> - <property name="text"> - <string>Cut Selected</string> - </property> - <property name="whatsThis"> - <string>Copies the selected rows to the clipboard, and then deletes them. Each row is placed on a new line, and each cell is separated by a tab.</string> - </property> - <property name="shortcut"> - <string>Ctrl+X</string> - </property> - </action> - <action name="actionPasteSelected"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/paste.png</normaloff>:/paste.png - </iconset> - </property> - <property name="text"> - <string>Paste Selected</string> - </property> - <property name="whatsThis"> - <string>Pastes the contents of the clipboard into the selected rows. If no rows are selected, new ones are added at the end of the group.</string> - </property> - <property name="shortcut"> - <string>Ctrl+V</string> - </property> - </action> - <action name="actionClearSelected"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/erase.png</normaloff>:/erase.png - </iconset> - </property> - <property name="text"> - <string>Clear Selected</string> - </property> - <property name="whatsThis"> - <string>Clears the contents of the selected rows.</string> - </property> - </action> - <action name="actionHelp"> - <property name="icon"> - <iconset resource="../../../../MantidPlot/icons/icons.qrc"> - <normaloff>:/help.png</normaloff>:/help.png - </iconset> - </property> - <property name="text"> - <string>Help</string> - </property> - <property name="toolTip"> - <string>Opens the documentation.</string> - </property> - <property name="whatsThis"> - <string>Opens the interface's documentation in the Qt Help Browser.</string> - </property> - <property name="shortcut"> - <string>F1</string> - </property> - </action> </widget> <tabstops> <tabstop>viewTable</tabstop> diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorWorkspaceCommand.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorWorkspaceCommand.h index 84670355d6c..470fe04197f 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorWorkspaceCommand.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorWorkspaceCommand.h @@ -45,6 +45,9 @@ public: }; std::string name() override { return m_name; } std::string icon() override { return std::string("://worksheet.png"); } + std::string tooltip() override { return std::string("Table Workspace"); } + std::string whatsthis() override { return std::string("Table Workspace"); } + std::string shortcut() override { return std::string(); } private: std::string m_name; diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/GenericDataProcessorPresenter.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/GenericDataProcessorPresenter.h index f2bfdb50805..65ae278a8f9 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/GenericDataProcessorPresenter.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/GenericDataProcessorPresenter.h @@ -17,6 +17,7 @@ namespace MantidWidgets { class ProgressableView; class DataProcessorView; class DataProcessorCommand; +class DataProcessorTreeManager; /** @class GenericDataProcessorPresenter @@ -84,7 +85,9 @@ public: const std::set<int> &rows, const std::string &prefix = ""); -protected: +private: + // the tree manager + std::unique_ptr<DataProcessorTreeManager> m_manager; // the workspace the model is currently representing Mantid::API::ITableWorkspace_sptr m_ws; // the model @@ -175,6 +178,9 @@ protected: void showOptionsDialog(); void initOptions(); + // actions + void addActions(); + // List of workspaces the user can open std::set<std::string> m_workspaceList; diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h index 147a1568f00..42b74607a90 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h @@ -13,6 +13,8 @@ namespace MantidQt { namespace MantidWidgets { +class DataProcessorCommandAdapter; + /** QDataProcessorWidget : Provides an interface for processing table data. @@ -48,6 +50,10 @@ public: QWidget *parent = 0); ~QDataProcessorWidget() override; + // Add actions to the toolbar + void QDataProcessorWidget::addActions( + std::vector<std::unique_ptr<DataProcessorCommand>> commands) override; + // Connect the model void showTable(QDataProcessorTwoLevelTreeModel_sptr model) override; @@ -101,6 +107,8 @@ private: // the workspace the user selected to open std::string m_toOpen; QSignalMapper *m_openMap; + // Command adapters + std::vector<std::unique_ptr<DataProcessorCommandAdapter>> m_commands; signals: void comboProcessInstrument_currentIndexChanged(int index); @@ -109,21 +117,6 @@ public slots: void on_comboProcessInstrument_currentIndexChanged(int index); private slots: - void on_actionAppendRow_triggered(); - void on_actionAppendGroup_triggered(); - void on_actionDeleteRow_triggered(); - void on_actionDeleteGroup_triggered(); - void on_actionProcess_triggered(); - void on_actionGroupRows_triggered(); - void on_actionClearSelected_triggered(); - void on_actionCopySelected_triggered(); - void on_actionCutSelected_triggered(); - void on_actionPasteSelected_triggered(); - void on_actionExpandSelection_triggered(); - void on_actionHelp_triggered(); - void on_actionPlotRow_triggered(); - void on_actionPlotGroup_triggered(); - void setModel(QString name); void tableUpdated(const QModelIndex &topLeft, const QModelIndex &bottomRight); void showContextMenu(const QPoint &pos); diff --git a/MantidQt/MantidWidgets/src/DataProcessorUI/DataProcessorTwoLevelTreeManager.cpp b/MantidQt/MantidWidgets/src/DataProcessorUI/DataProcessorTwoLevelTreeManager.cpp new file mode 100644 index 00000000000..e4b6aa8dfa2 --- /dev/null +++ b/MantidQt/MantidWidgets/src/DataProcessorUI/DataProcessorTwoLevelTreeManager.cpp @@ -0,0 +1,83 @@ +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorTwoLevelTreeManager.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendGroupCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendRowCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorClearSelectedCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCopySelectedCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCutSelectedCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteGroupCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteRowCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorExpandCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorExportTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorGroupRowsCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorImportTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorNewTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOpenTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOptionsCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPasteSelectedCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotGroupCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotRowCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorProcessCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableAsCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSeparatorCommand.h" +#include "MantidKernel/make_unique.h" + +using namespace Mantid::Kernel; +using namespace MantidQt::MantidWidgets; + +namespace MantidQt { +namespace MantidWidgets { + +/** +* Constructor +* @param presenter :: a pointer to the presenter +*/ +DataProcessorTwoLevelTreeManager::DataProcessorTwoLevelTreeManager( + DataProcessorPresenter *presenter) + : m_presenter(presenter) {} + +/** +* Destructor +*/ +DataProcessorTwoLevelTreeManager::~DataProcessorTwoLevelTreeManager() {} + +/** +* Publishes a list of available commands +* @return : The list of available commands +*/ +std::vector<DataProcessorCommand_uptr> +DataProcessorTwoLevelTreeManager::publishCommands() { + + std::vector<DataProcessorCommand_uptr> commands; + + addCommand(commands, make_unique<DataProcessorOpenTableCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorNewTableCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorSaveTableCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorSaveTableAsCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorSeparatorCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorImportTableCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorExportTableCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorSeparatorCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorOptionsCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorSeparatorCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorProcessCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorExpandCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorSeparatorCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorPlotRowCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorPlotGroupCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorSeparatorCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorAppendRowCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorAppendGroupCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorSeparatorCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorGroupRowsCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorCopySelectedCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorCutSelectedCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorPasteSelectedCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorClearSelectedCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorSeparatorCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorDeleteRowCommand>(m_presenter)); + addCommand(commands, make_unique<DataProcessorDeleteGroupCommand>(m_presenter)); + return commands; +} +} +} diff --git a/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp b/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp index 281b87c6c68..30bdae8571b 100644 --- a/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp +++ b/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp @@ -11,29 +11,9 @@ #include "MantidKernel/Utils.h" #include "MantidKernel/make_unique.h" #include "MantidQtMantidWidgets/AlgorithmHintStrategy.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendGroupCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendRowCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorClearSelectedCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCopySelectedCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCutSelectedCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteGroupCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteRowCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorExpandCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorExportTableCommand.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorGenerateNotebook.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorGroupRowsCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorImportTableCommand.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorNewTableCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOpenTableCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOptionsCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPasteSelectedCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotGroupCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotRowCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorProcessCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableAsCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSeparatorCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorTwoLevelTreeManager.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorWorkspaceCommand.h" #include "MantidQtMantidWidgets/DataProcessorUI/ParseKeyValueString.h" @@ -74,6 +54,9 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( m_processor(processor), m_postprocessor(postprocessor), m_mainPresenter(), m_tableDirty(false) { + m_manager = + Mantid::Kernel::make_unique<DataProcessorTwoLevelTreeManager>(this); + // Column Options must be added to the whitelist m_whitelist.addElement("Options", "Options", "<b>Override <samp>" + processor.name() + @@ -124,6 +107,9 @@ void GenericDataProcessorPresenter::acceptViews( m_view = tableView; m_progressView = progressView; + // Add actions to toolbar + addActions(); + // Initialise options // Load saved values from disk initOptions(); @@ -1557,6 +1543,17 @@ void GenericDataProcessorPresenter::initOptions() { m_view->loadSettings(m_options); } +/** Tells the view which of the actions should be added to the toolbar +*/ +void GenericDataProcessorPresenter::addActions() { + + auto commands = m_manager->publishCommands(); + std::vector<std::unique_ptr<DataProcessorCommand>> commandsToShow; + for (size_t comm = 10; comm < commands.size(); comm++) + commandsToShow.push_back(std::move(commands.at(comm))); + m_view->addActions(std::move(commandsToShow)); +} + /** * Tells the view to load a table workspace * @param name : [input] The workspace's name @@ -1565,52 +1562,14 @@ void GenericDataProcessorPresenter::setModel(std::string name) { m_view->setModel(name); } -/** -* Adds a command to a vector of commands -* @param commands : [input] The vector where the new command will be added -* @param command : [input] The command to add -*/ -void addToCommand(std::vector<DataProcessorCommand_uptr> &commands, - DataProcessorCommand_uptr command) { - commands.push_back(std::move(command)); -} - /** * Publishes a list of available commands * @return : The list of available commands */ -std::vector<DataProcessorCommand_uptr> +std::vector<std::unique_ptr<DataProcessorCommand>> GenericDataProcessorPresenter::publishCommands() { - std::vector<DataProcessorCommand_uptr> commands; - - addToCommand(commands, make_unique<DataProcessorOpenTableCommand>(this)); - addToCommand(commands, make_unique<DataProcessorNewTableCommand>(this)); - addToCommand(commands, make_unique<DataProcessorSaveTableCommand>(this)); - addToCommand(commands, make_unique<DataProcessorSaveTableAsCommand>(this)); - addToCommand(commands, make_unique<DataProcessorSeparatorCommand>(this)); - addToCommand(commands, make_unique<DataProcessorImportTableCommand>(this)); - addToCommand(commands, make_unique<DataProcessorExportTableCommand>(this)); - addToCommand(commands, make_unique<DataProcessorSeparatorCommand>(this)); - addToCommand(commands, make_unique<DataProcessorOptionsCommand>(this)); - addToCommand(commands, make_unique<DataProcessorSeparatorCommand>(this)); - addToCommand(commands, make_unique<DataProcessorProcessCommand>(this)); - addToCommand(commands, make_unique<DataProcessorExpandCommand>(this)); - addToCommand(commands, make_unique<DataProcessorSeparatorCommand>(this)); - addToCommand(commands, make_unique<DataProcessorPlotRowCommand>(this)); - addToCommand(commands, make_unique<DataProcessorPlotGroupCommand>(this)); - addToCommand(commands, make_unique<DataProcessorSeparatorCommand>(this)); - addToCommand(commands, make_unique<DataProcessorAppendRowCommand>(this)); - addToCommand(commands, make_unique<DataProcessorAppendGroupCommand>(this)); - addToCommand(commands, make_unique<DataProcessorSeparatorCommand>(this)); - addToCommand(commands, make_unique<DataProcessorGroupRowsCommand>(this)); - addToCommand(commands, make_unique<DataProcessorCopySelectedCommand>(this)); - addToCommand(commands, make_unique<DataProcessorCutSelectedCommand>(this)); - addToCommand(commands, make_unique<DataProcessorPasteSelectedCommand>(this)); - addToCommand(commands, make_unique<DataProcessorClearSelectedCommand>(this)); - addToCommand(commands, make_unique<DataProcessorSeparatorCommand>(this)); - addToCommand(commands, make_unique<DataProcessorDeleteRowCommand>(this)); - addToCommand(commands, make_unique<DataProcessorDeleteGroupCommand>(this)); + auto commands = m_manager->publishCommands(); // "Open Table" needs the list of "child" commands, i.e. the list of // available workspaces in the ADS @@ -1640,11 +1599,11 @@ GenericDataProcessorPresenter::getTableList() { // Create a command for each of the workspaces in the ADS for (auto it = m_workspaceList.begin(); it != m_workspaceList.end(); ++it) { - addToCommand( - workspaces, - Mantid::Kernel::make_unique<DataProcessorWorkspaceCommand>(this, *it)); + workspaces.push_back(std::move( + Mantid::Kernel::make_unique<DataProcessorWorkspaceCommand>(this, *it))); } return workspaces; } + } } diff --git a/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp b/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp index b13c8597cbe..378bf696b9c 100644 --- a/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp +++ b/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp @@ -1,7 +1,7 @@ #include "MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h" #include "MantidQtAPI/FileDialogHandler.h" -#include "MantidQtAPI/HelpWindow.h" #include "MantidQtAPI/MantidWidget.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommandAdapter.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPresenter.h" #include "MantidQtMantidWidgets/DataProcessorUI/QDataProcessorTwoLevelTreeModel.h" #include "MantidQtMantidWidgets/HintingLineEditFactory.h" @@ -42,11 +42,6 @@ Initialise the Interface void QDataProcessorWidget::createTable() { ui.setupUi(this); - ui.buttonProcess->setDefaultAction(ui.actionProcess); - - // Create a whats this button - ui.rowToolBar->addAction(QWhatsThis::createAction(this)); - // Allow rows and columns to be reordered QHeaderView *header = new QHeaderView(Qt::Horizontal); header->setMovable(true); @@ -62,6 +57,23 @@ void QDataProcessorWidget::createTable() { this, SLOT(showContextMenu(const QPoint &))); } +/** Add actions to the toolbar +* @param commands :: A vector of actions (commands) +*/ +void QDataProcessorWidget::addActions( + std::vector<std::unique_ptr<DataProcessorCommand>> commands) { + + // Put the commands in the toolbar + for (auto &command : commands) { + m_commands.push_back( + Mantid::Kernel::make_unique<DataProcessorCommandAdapter>( + ui.rowToolBar, std::move(command))); + } + + // Add a whats this button + ui.rowToolBar->addAction(QWhatsThis::createAction(this)); +} + /** This slot loads a table workspace model and changes to a LoadedMainView presenter @@ -121,114 +133,6 @@ void QDataProcessorWidget::setTableList(const std::set<std::string> &tables) { } } -/** -This slot notifies the presenter that the "append row" button has been pressed -*/ -void QDataProcessorWidget::on_actionAppendRow_triggered() { - m_presenter->notify(DataProcessorPresenter::AppendRowFlag); -} - -/** -This slot notifies the presenter that the "append group" button has been pressed -*/ -void QDataProcessorWidget::on_actionAppendGroup_triggered() { - m_presenter->notify(DataProcessorPresenter::AppendGroupFlag); -} - -/** -This slot notifies the presenter that the "delete row" button has been pressed -*/ -void QDataProcessorWidget::on_actionDeleteRow_triggered() { - m_presenter->notify(DataProcessorPresenter::DeleteRowFlag); -} - -/** -This slot notifies the presenter that the "delete group" button has been pressed -*/ -void QDataProcessorWidget::on_actionDeleteGroup_triggered() { - m_presenter->notify(DataProcessorPresenter::DeleteGroupFlag); -} - -/** -This slot notifies the presenter that the "process" button has been pressed -*/ -void QDataProcessorWidget::on_actionProcess_triggered() { - m_presenter->notify(DataProcessorPresenter::ProcessFlag); -} - -/** -This slot notifies the presenter that the "group rows" button has been pressed -*/ -void QDataProcessorWidget::on_actionGroupRows_triggered() { - m_presenter->notify(DataProcessorPresenter::GroupRowsFlag); -} - -/** -This slot notifies the presenter that the "clear selected" button has been -pressed -*/ -void QDataProcessorWidget::on_actionClearSelected_triggered() { - m_presenter->notify(DataProcessorPresenter::ClearSelectedFlag); -} - -/** -This slot notifies the presenter that the "copy selection" button has been -pressed -*/ -void QDataProcessorWidget::on_actionCopySelected_triggered() { - m_presenter->notify(DataProcessorPresenter::CopySelectedFlag); -} - -/** -This slot notifies the presenter that the "cut selection" button has been -pressed -*/ -void QDataProcessorWidget::on_actionCutSelected_triggered() { - m_presenter->notify(DataProcessorPresenter::CutSelectedFlag); -} - -/** -This slot notifies the presenter that the "paste selection" button has been -pressed -*/ -void QDataProcessorWidget::on_actionPasteSelected_triggered() { - m_presenter->notify(DataProcessorPresenter::PasteSelectedFlag); -} - -/** -This slot notifies the presenter that the "expand selection" button has been -pressed -*/ -void QDataProcessorWidget::on_actionExpandSelection_triggered() { - m_presenter->notify(DataProcessorPresenter::ExpandSelectionFlag); -} - -/** -This slot opens the documentation when the "help" button has been pressed -*/ -void QDataProcessorWidget::on_actionHelp_triggered() { - MantidQt::API::HelpWindow::showPage( - this, - QString( - "qthelp://org.mantidproject/doc/interfaces/ISIS_Reflectometry.html")); -} - -/** -This slot notifies the presenter that the "plot selected rows" button has been -pressed -*/ -void QDataProcessorWidget::on_actionPlotRow_triggered() { - m_presenter->notify(DataProcessorPresenter::PlotRowFlag); -} - -/** -This slot notifies the presenter that the "plot selected groups" button has been -pressed -*/ -void QDataProcessorWidget::on_actionPlotGroup_triggered() { - m_presenter->notify(DataProcessorPresenter::PlotGroupFlag); -} - /** This slot is used to update the instrument*/ void QDataProcessorWidget::on_comboProcessInstrument_currentIndexChanged( int index) { @@ -255,27 +159,28 @@ void QDataProcessorWidget::showContextMenu(const QPoint &pos) { if (!ui.viewTable->indexAt(pos).isValid()) return; - // parent widget takes ownership of QMenu - QMenu *menu = new QMenu(this); - menu->addAction(ui.actionProcess); - menu->addAction(ui.actionExpandSelection); - menu->addSeparator(); - menu->addAction(ui.actionPlotRow); - menu->addAction(ui.actionPlotGroup); - menu->addSeparator(); - menu->addAction(ui.actionAppendRow); - menu->addAction(ui.actionAppendGroup); - menu->addSeparator(); - menu->addAction(ui.actionGroupRows); - menu->addAction(ui.actionCopySelected); - menu->addAction(ui.actionCutSelected); - menu->addAction(ui.actionPasteSelected); - menu->addAction(ui.actionClearSelected); - menu->addSeparator(); - menu->addAction(ui.actionDeleteRow); - menu->addAction(ui.actionDeleteGroup); - - menu->popup(ui.viewTable->viewport()->mapToGlobal(pos)); + // TODO + //// parent widget takes ownership of QMenu + //QMenu *menu = new QMenu(this); + //menu->addAction(ui.actionProcess); + //menu->addAction(ui.actionExpandSelection); + //menu->addSeparator(); + //menu->addAction(ui.actionPlotRow); + //menu->addAction(ui.actionPlotGroup); + //menu->addSeparator(); + //menu->addAction(ui.actionAppendRow); + //menu->addAction(ui.actionAppendGroup); + //menu->addSeparator(); + //menu->addAction(ui.actionGroupRows); + //menu->addAction(ui.actionCopySelected); + //menu->addAction(ui.actionCutSelected); + //menu->addAction(ui.actionPasteSelected); + //menu->addAction(ui.actionClearSelected); + //menu->addSeparator(); + //menu->addAction(ui.actionDeleteRow); + //menu->addAction(ui.actionDeleteGroup); + + //menu->popup(ui.viewTable->viewport()->mapToGlobal(pos)); } /** diff --git a/MantidQt/MantidWidgets/test/DataProcessorUI/DataProcessorCommandsTest.h b/MantidQt/MantidWidgets/test/DataProcessorUI/DataProcessorCommandsTest.h index ff1a323f1c4..02e1add8f8a 100644 --- a/MantidQt/MantidWidgets/test/DataProcessorUI/DataProcessorCommandsTest.h +++ b/MantidQt/MantidWidgets/test/DataProcessorUI/DataProcessorCommandsTest.h @@ -32,7 +32,6 @@ #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorWorkspaceCommand.h" using namespace MantidQt::MantidWidgets; -// using namespace Mantid::API; using namespace testing; //===================================================================================== diff --git a/MantidQt/MantidWidgets/test/DataProcessorUI/DataProcessorTwoLevelTreeManagerTest.h b/MantidQt/MantidWidgets/test/DataProcessorUI/DataProcessorTwoLevelTreeManagerTest.h new file mode 100644 index 00000000000..e509592b717 --- /dev/null +++ b/MantidQt/MantidWidgets/test/DataProcessorUI/DataProcessorTwoLevelTreeManagerTest.h @@ -0,0 +1,89 @@ +#ifndef MANTID_MANTIDWIDGETS_DATAPROCESSORTWOLEVELTREEMANAGERTEST_H +#define MANTID_MANTIDWIDGETS_DATAPROCESSORTWOLEVELTREEMANAGERTEST_H + +#include <cxxtest/TestSuite.h> +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorTwoLevelTreeManager.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendGroupCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendRowCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorClearSelectedCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCopySelectedCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCutSelectedCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteGroupCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteRowCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorExpandCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorExportTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorGroupRowsCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorImportTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorMockObjects.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorNewTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOpenTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOptionsCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPasteSelectedCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotGroupCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotRowCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorProcessCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableAsCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSeparatorCommand.h" + +using namespace MantidQt::MantidWidgets; +using namespace testing; + +//===================================================================================== +// Functional tests +//===================================================================================== +class DataProcessorTwoLevelTreeManagerTest : public CxxTest::TestSuite { + +private: +public: + // This pair of boilerplate methods prevent the suite being created statically + // This means the constructor isn't called when running other tests + static DataProcessorTwoLevelTreeManagerTest *createSuite() { + return new DataProcessorTwoLevelTreeManagerTest(); + } + static void destroySuite(DataProcessorTwoLevelTreeManagerTest *suite) { + delete suite; + } + + void test_publish_commands() { + NiceMock<MockDataProcessorPresenter> presenter; + DataProcessorTwoLevelTreeManager manager(&presenter); + + auto comm = manager.publishCommands(); + + TS_ASSERT_EQUALS(comm.size(), 27); + TS_ASSERT(dynamic_cast<DataProcessorOpenTableCommand *>(comm[0].get())); + TS_ASSERT(dynamic_cast<DataProcessorNewTableCommand *>(comm[1].get())); + TS_ASSERT(dynamic_cast<DataProcessorSaveTableCommand *>(comm[2].get())); + TS_ASSERT(dynamic_cast<DataProcessorSaveTableAsCommand *>(comm[3].get())); + TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(comm[4].get())); + TS_ASSERT(dynamic_cast<DataProcessorImportTableCommand *>(comm[5].get())); + TS_ASSERT(dynamic_cast<DataProcessorExportTableCommand *>(comm[6].get())); + TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(comm[7].get())); + TS_ASSERT(dynamic_cast<DataProcessorOptionsCommand *>(comm[8].get())); + TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(comm[9].get())); + TS_ASSERT(dynamic_cast<DataProcessorProcessCommand *>(comm[10].get())); + TS_ASSERT(dynamic_cast<DataProcessorExpandCommand *>(comm[11].get())); + TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(comm[12].get())); + TS_ASSERT(dynamic_cast<DataProcessorPlotRowCommand *>(comm[13].get())); + TS_ASSERT(dynamic_cast<DataProcessorPlotGroupCommand *>(comm[14].get())); + TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(comm[15].get())); + TS_ASSERT(dynamic_cast<DataProcessorAppendRowCommand *>(comm[16].get())); + TS_ASSERT(dynamic_cast<DataProcessorAppendGroupCommand *>(comm[17].get())); + TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(comm[18].get())); + TS_ASSERT(dynamic_cast<DataProcessorGroupRowsCommand *>(comm[19].get())); + TS_ASSERT(dynamic_cast<DataProcessorCopySelectedCommand *>(comm[20].get())); + TS_ASSERT(dynamic_cast<DataProcessorCutSelectedCommand *>(comm[21].get())); + TS_ASSERT( + dynamic_cast<DataProcessorPasteSelectedCommand *>(comm[22].get())); + TS_ASSERT( + dynamic_cast<DataProcessorClearSelectedCommand *>(comm[23].get())); + TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(comm[24].get())); + TS_ASSERT(dynamic_cast<DataProcessorDeleteRowCommand *>(comm[25].get())); + TS_ASSERT(dynamic_cast<DataProcessorDeleteGroupCommand *>(comm[26].get())); + } +}; +#endif /* MANTID_MANTIDWIDGETS_DATAPROCESSORTWOLEVELTREEMANAGERTEST_H */ diff --git a/MantidQt/MantidWidgets/test/DataProcessorUI/GenericDataProcessorPresenterTest.h b/MantidQt/MantidWidgets/test/DataProcessorUI/GenericDataProcessorPresenterTest.h index 162757d97ab..5bc65a09812 100644 --- a/MantidQt/MantidWidgets/test/DataProcessorUI/GenericDataProcessorPresenterTest.h +++ b/MantidQt/MantidWidgets/test/DataProcessorUI/GenericDataProcessorPresenterTest.h @@ -8,28 +8,7 @@ #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/TableRow.h" #include "MantidGeometry/Instrument.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendGroupCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorAppendRowCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorClearSelectedCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCopySelectedCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCutSelectedCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteGroupCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorDeleteRowCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorExpandCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorExportTableCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorGroupRowsCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorImportTableCommand.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorMockObjects.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorNewTableCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOpenTableCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOptionsCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPasteSelectedCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotGroupCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPlotRowCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorProcessCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableAsCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSaveTableCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSeparatorCommand.h" #include "MantidQtMantidWidgets/DataProcessorUI/GenericDataProcessorPresenter.h" #include "MantidQtMantidWidgets/DataProcessorUI/ProgressableViewMockObject.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" @@ -327,6 +306,7 @@ public: // called EXPECT_CALL(mockDataProcessorView, setTableList(_)).Times(0); EXPECT_CALL(mockDataProcessorView, setOptionsHintStrategy(_, _)).Times(0); + EXPECT_CALL(mockDataProcessorView, addActionsProxy()).Times(0); // Constructor GenericDataProcessorPresenter presenter( createReflectometryWhiteList(), createReflectometryPreprocessMap(), @@ -352,6 +332,8 @@ public: createReflectometryProcessor(), createReflectometryPostprocessor()); // When the presenter accepts the views, expect the following: + // Expect that the list of actions is published + EXPECT_CALL(mockDataProcessorView, addActionsProxy()).Times(Exactly(1)); // Expect that the list of settings is populated EXPECT_CALL(mockDataProcessorView, loadSettings(_)).Times(Exactly(1)); // Expect that the list of tables is populated @@ -2720,68 +2702,6 @@ public: TS_ASSERT(Mock::VerifyAndClearExpectations(&mockMainPresenter)); } - void testPublishCommands() { - // The mock view is not needed for this test - // We just want to test the list of commands returned by the presenter - NiceMock<MockDataProcessorView> mockDataProcessorView; - MockProgressableView mockProgress; - NiceMock<MockMainPresenter> mockMainPresenter; - GenericDataProcessorPresenter presenter( - createReflectometryWhiteList(), createReflectometryPreprocessMap(), - createReflectometryProcessor(), createReflectometryPostprocessor()); - presenter.acceptViews(&mockDataProcessorView, &mockProgress); - presenter.accept(&mockMainPresenter); - - // Actions (commands) - auto commands = presenter.publishCommands(); - TS_ASSERT_EQUALS(commands.size(), 27); - - TS_ASSERT(dynamic_cast<DataProcessorOpenTableCommand *>(commands[0].get())); - TS_ASSERT(dynamic_cast<DataProcessorNewTableCommand *>(commands[1].get())); - TS_ASSERT(dynamic_cast<DataProcessorSaveTableCommand *>(commands[2].get())); - TS_ASSERT( - dynamic_cast<DataProcessorSaveTableAsCommand *>(commands[3].get())); - TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(commands[4].get())); - TS_ASSERT( - dynamic_cast<DataProcessorImportTableCommand *>(commands[5].get())); - TS_ASSERT( - dynamic_cast<DataProcessorExportTableCommand *>(commands[6].get())); - TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(commands[7].get())); - TS_ASSERT(dynamic_cast<DataProcessorOptionsCommand *>(commands[8].get())); - TS_ASSERT(dynamic_cast<DataProcessorSeparatorCommand *>(commands[9].get())); - TS_ASSERT(dynamic_cast<DataProcessorProcessCommand *>(commands[10].get())); - TS_ASSERT(dynamic_cast<DataProcessorExpandCommand *>(commands[11].get())); - TS_ASSERT( - dynamic_cast<DataProcessorSeparatorCommand *>(commands[12].get())); - TS_ASSERT(dynamic_cast<DataProcessorPlotRowCommand *>(commands[13].get())); - TS_ASSERT( - dynamic_cast<DataProcessorPlotGroupCommand *>(commands[14].get())); - TS_ASSERT( - dynamic_cast<DataProcessorSeparatorCommand *>(commands[15].get())); - TS_ASSERT( - dynamic_cast<DataProcessorAppendRowCommand *>(commands[16].get())); - TS_ASSERT( - dynamic_cast<DataProcessorAppendGroupCommand *>(commands[17].get())); - TS_ASSERT( - dynamic_cast<DataProcessorSeparatorCommand *>(commands[18].get())); - TS_ASSERT( - dynamic_cast<DataProcessorGroupRowsCommand *>(commands[19].get())); - TS_ASSERT( - dynamic_cast<DataProcessorCopySelectedCommand *>(commands[20].get())); - TS_ASSERT( - dynamic_cast<DataProcessorCutSelectedCommand *>(commands[21].get())); - TS_ASSERT( - dynamic_cast<DataProcessorPasteSelectedCommand *>(commands[22].get())); - TS_ASSERT( - dynamic_cast<DataProcessorClearSelectedCommand *>(commands[23].get())); - TS_ASSERT( - dynamic_cast<DataProcessorSeparatorCommand *>(commands[24].get())); - TS_ASSERT( - dynamic_cast<DataProcessorDeleteRowCommand *>(commands[25].get())); - TS_ASSERT( - dynamic_cast<DataProcessorDeleteGroupCommand *>(commands[26].get())); - } - void testWorkspaceNamesNoTrans() { NiceMock<MockDataProcessorView> mockDataProcessorView; NiceMock<MockProgressableView> mockProgress; -- GitLab