Mantid
Loading...
Searching...
No Matches
AlgorithmSelectorWidget.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10#include "MantidQtWidgets/Common/DllOption.h"
11
12#include <QComboBox>
13#include <QPoint>
14#include <QString>
15#include <QTreeWidget>
16
17#include <Poco/NObserver.h>
18#include <vector>
19
20//------------------------------------------------------------------------------
21// Forward declaration
22//------------------------------------------------------------------------------
23class QPushButton;
24
25namespace Mantid {
26namespace API {
27struct Algorithm_descriptor;
28}
29} // namespace Mantid
30namespace MantidQt {
31namespace MantidWidgets {
32
33class AlgorithmTreeWidget;
34class FindAlgComboBox;
35
41 QString name;
44 operator QString() { return name; }
46 SelectedAlgorithm(const QString &nameIn, const int versionIn) : name(nameIn), version(versionIn) {};
47};
48
49//============================================================================
56class EXPORT_OPT_MANTIDQT_COMMON AlgorithmSelectorWidget : public QWidget {
57 Q_OBJECT
58 Q_PROPERTY(bool showExecuteButton READ showExecuteButton WRITE showExecuteButton)
59
60public:
61 AlgorithmSelectorWidget(QWidget *parent);
62 ~AlgorithmSelectorWidget() override;
63
64 // delete copy operations - Poco::NObserver contains std::atomic which is not copyable
67
68 SelectedAlgorithm getSelectedAlgorithm();
69 void setSelectedAlgorithm(QString &algName);
70 bool showExecuteButton() const;
71 void showExecuteButton(const bool /*val*/);
72
73public slots:
74 void update();
75 void executeSelected();
76 void findAlgTextChanged(const QString &text);
77 void treeSelectionChanged();
78
79signals:
81 void executeAlgorithm(const QString & /*_t1*/, int /*_t2*/);
82 void algorithmSelectionChanged(const QString & /*_t1*/, int /*_t2*/);
83
84protected:
87 QPushButton *m_execButton;
88
89private:
91 void handleAlgorithmFactoryUpdate(Mantid::API::AlgorithmFactoryUpdateNotification_ptr /*unused*/);
94 // Flag to indicate that we are updating
96};
97
98//============================================================================
102class AlgorithmTreeWidget : public QTreeWidget {
103 Q_OBJECT
104public:
105 AlgorithmTreeWidget(QWidget *w) : QTreeWidget(w) {}
106 ~AlgorithmTreeWidget() override = default;
107 void mousePressEvent(QMouseEvent *e) override;
108 void mouseMoveEvent(QMouseEvent *e) override;
109 void mouseDoubleClickEvent(QMouseEvent *e) override;
111
112public slots:
113 void update();
114
115signals:
117 void executeAlgorithm(const QString & /*_t1*/, int /*_t2*/);
118
119private:
121};
122
123//============================================================================
127class FindAlgComboBox : public QComboBox {
128 Q_OBJECT
129public:
130 ~FindAlgComboBox() override = default;
132
133signals:
135
136public slots:
137 void update();
138
139protected:
140 void keyPressEvent(QKeyEvent *e) override;
141
142private:
143 using AlgNamesType = std::vector<Mantid::API::AlgorithmDescriptor>;
144 void addAliases(AlgNamesType &algNamesList);
145 QString stripAlias(const QString &text) const;
146};
147
148} // namespace MantidWidgets
149} // namespace MantidQt
A widget consisting of a ComboBox and a TreeWidget to allow a user to select an algorithm either by c...
Poco::NObserver< AlgorithmSelectorWidget, Mantid::API::AlgorithmFactoryUpdateNotification > m_updateObserver
Observes algorithm factory update notifications.
AlgorithmSelectorWidget(const AlgorithmSelectorWidget &)=delete
AlgorithmSelectorWidget & operator=(const AlgorithmSelectorWidget &)=delete
void algorithmSelectionChanged(const QString &, int)
Tree widget with the categories and algorithms listed.
void executeAlgorithm(const QString &, int)
Signal emitted when the widget requests that we execute that algorithm.
void mousePressEvent(QMouseEvent *e) override
SLOT called when clicking the mouse around the tree.
void mouseDoubleClickEvent(QMouseEvent *e) override
SLOT called when double-clicking on an entry in the tree.
void mouseMoveEvent(QMouseEvent *e) override
SLOT called when dragging the mouse around the tree.
SelectedAlgorithm getSelectedAlgorithm()
Return the selected algorithm in the tree.
void update()
Update the list of algos in the tree.
void update()
Update the list of algos in the combo box.
void keyPressEvent(QKeyEvent *e) override
Called when the combo box for finding algorithms has a key press event
void addAliases(AlgNamesType &algNamesList)
Adds alias entries to the list of algorithms.
std::vector< Mantid::API::AlgorithmDescriptor > AlgNamesType
QString stripAlias(const QString &text) const
if a string is for an alias convert it to the algorithm name
SelectedAlgorithm getSelectedAlgorithm()
Return the selected algorithm.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
const Poco::AutoPtr< Mantid::Kernel::DynamicFactory< Algorithm >::UpdateNotification > & AlgorithmFactoryUpdateNotification_ptr
Helper class which provides the Collimation Length for SANS instruments.
Represents the algorithm selected by the user Contains name and version.
SelectedAlgorithm(const QString &nameIn, const int versionIn)
constructor