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
9#include "DllOption.h"
11#include "MantidKernel/System.h"
12
13#include <QComboBox>
14#include <QPoint>
15#include <QString>
16#include <QTreeWidget>
17
18#include <Poco/NObserver.h>
19#include <vector>
20
21//------------------------------------------------------------------------------
22// Forward declaration
23//------------------------------------------------------------------------------
24class QPushButton;
25
26namespace Mantid {
27namespace API {
28struct Algorithm_descriptor;
29}
30} // namespace Mantid
31namespace MantidQt {
32namespace MantidWidgets {
33
34class AlgorithmTreeWidget;
35class FindAlgComboBox;
36
42 QString name;
45 operator QString() { return name; }
47 SelectedAlgorithm(const QString &nameIn, const int versionIn) : name(nameIn), version(versionIn) {};
48};
49
50//============================================================================
58 Q_OBJECT
59 Q_PROPERTY(bool showExecuteButton READ showExecuteButton WRITE showExecuteButton)
60
61public:
62 AlgorithmSelectorWidget(QWidget *parent);
63 ~AlgorithmSelectorWidget() override;
64
65 // delete copy operations - Poco::NObserver contains std::atomic which is not copyable
68
69 SelectedAlgorithm getSelectedAlgorithm();
70 void setSelectedAlgorithm(QString &algName);
71 bool showExecuteButton() const;
72 void showExecuteButton(const bool /*val*/);
73
74public slots:
75 void update();
76 void executeSelected();
77 void findAlgTextChanged(const QString &text);
78 void treeSelectionChanged();
79
80signals:
82 void executeAlgorithm(const QString & /*_t1*/, int /*_t2*/);
83 void algorithmSelectionChanged(const QString & /*_t1*/, int /*_t2*/);
84
85protected:
88 QPushButton *m_execButton;
89
90private:
92 void handleAlgorithmFactoryUpdate(Mantid::API::AlgorithmFactoryUpdateNotification_ptr /*unused*/);
95 // Flag to indicate that we are updating
97};
98
99//============================================================================
103class AlgorithmTreeWidget : public QTreeWidget {
104 Q_OBJECT
105public:
106 AlgorithmTreeWidget(QWidget *w) : QTreeWidget(w) {}
107 ~AlgorithmTreeWidget() override = default;
108 void mousePressEvent(QMouseEvent *e) override;
109 void mouseMoveEvent(QMouseEvent *e) override;
110 void mouseDoubleClickEvent(QMouseEvent *e) override;
112
113public slots:
114 void update();
115
116signals:
118 void executeAlgorithm(const QString & /*_t1*/, int /*_t2*/);
119
120private:
122};
123
124//============================================================================
128class FindAlgComboBox : public QComboBox {
129 Q_OBJECT
130public:
131 ~FindAlgComboBox() override = default;
133
134signals:
136
137public slots:
138 void update();
139
140protected:
141 void keyPressEvent(QKeyEvent *e) override;
142
143private:
144 using AlgNamesType = std::vector<Mantid::API::AlgorithmDescriptor>;
145 void addAliases(AlgNamesType &algNamesList);
146 QString stripAlias(const QString &text) const;
147};
148
149} // namespace MantidWidgets
150} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
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