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 SelectedAlgorithm getSelectedAlgorithm();
65 void setSelectedAlgorithm(QString &algName);
66 bool showExecuteButton() const;
67 void showExecuteButton(const bool /*val*/);
68
69public slots:
70 void update();
71 void executeSelected();
72 void findAlgTextChanged(const QString &text);
73 void treeSelectionChanged();
74
75signals:
77 void executeAlgorithm(const QString & /*_t1*/, int /*_t2*/);
78 void algorithmSelectionChanged(const QString & /*_t1*/, int /*_t2*/);
79
80protected:
83 QPushButton *m_execButton;
84
85private:
87 void handleAlgorithmFactoryUpdate(Mantid::API::AlgorithmFactoryUpdateNotification_ptr /*unused*/);
90 // Flag to indicate that we are updating
92};
93
94//============================================================================
98class AlgorithmTreeWidget : public QTreeWidget {
99 Q_OBJECT
100public:
101 AlgorithmTreeWidget(QWidget *w) : QTreeWidget(w) {}
102 ~AlgorithmTreeWidget() override = default;
103 void mousePressEvent(QMouseEvent *e) override;
104 void mouseMoveEvent(QMouseEvent *e) override;
105 void mouseDoubleClickEvent(QMouseEvent *e) override;
107
108public slots:
109 void update();
110
111signals:
113 void executeAlgorithm(const QString & /*_t1*/, int /*_t2*/);
114
115private:
117};
118
119//============================================================================
123class FindAlgComboBox : public QComboBox {
124 Q_OBJECT
125public:
126 ~FindAlgComboBox() override = default;
128
129signals:
131
132public slots:
133 void update();
134
135protected:
136 void keyPressEvent(QKeyEvent *e) override;
137
138private:
139 using AlgNamesType = std::vector<Mantid::API::AlgorithmDescriptor>;
140 void addAliases(AlgNamesType &algNamesList);
141 QString stripAlias(const QString &text) const;
142};
143
144} // namespace MantidWidgets
145} // 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.
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