Mantid
Loading...
Searching...
No Matches
WorkspaceMultiSelector.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 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 <QStringList>
12#include <QTableWidget>
13#include <mutex>
14#include <optional>
15
16#include <Poco/AutoPtr.h>
17#include <Poco/NObserver.h>
18
19typedef std::vector<std::pair<std::string, std::string>> StringPairVec;
20namespace MantidQt {
21namespace MantidWidgets {
37class EXPORT_OPT_MANTIDQT_COMMON WorkspaceMultiSelector final : public QTableWidget {
38 Q_OBJECT
39
40 Q_PROPERTY(QStringList Suffix READ getWSSuffixes WRITE setWSSuffixes)
41
42public:
44 explicit WorkspaceMultiSelector(QWidget *parent = nullptr);
45
47 ~WorkspaceMultiSelector() override;
48
49 void setupTable();
50
51 void refresh();
52 void resetIndexRangeToDefault();
53 void unifyRange();
54
55 StringPairVec retrieveSelectedNameIndexPairs();
56
57 const QStringList &getWSSuffixes() const;
58 void setWSSuffixes(const QStringList &suffix);
59
60 bool isValid() const;
61
62 void connectObservers() const;
63 void disconnectObservers() const;
64
65signals:
66 void emptied();
67 void focussed();
68
69private:
70 void handleAddEvent(Mantid::API::WorkspaceAddNotification_ptr pNf);
72 void handleClearEvent(Mantid::API::ClearADSNotification_ptr pNf);
73 void handleRenameEvent(Mantid::API::WorkspaceRenameNotification_ptr pNf);
74 void handleReplaceEvent(Mantid::API::WorkspaceAfterReplaceNotification_ptr pNf);
75
76 bool checkEligibility(const std::string &name) const;
77 bool hasValidSuffix(const std::string &name) const;
78
79 void addItem(const std::string &name);
80 void addItems(const std::vector<std::string> &names);
81 void renameItem(const std::string &newName, int row);
82
83protected:
84 // Method for handling focus in events
85 void focusInEvent(QFocusEvent * /*unused*/) override;
86
87private:
94
95 QStringList m_suffix;
96 // Mutex for synchronized event handling
97 std::mutex m_adsMutex;
98};
99} // namespace MantidWidgets
100} // namespace MantidQt
std::string name
Definition Run.cpp:60
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
void addItem(WorkspaceGroup &self, const std::string &name)
std::vector< std::pair< std::string, std::string > > StringPairVec
This class defines a widget for selecting multiple workspace present in the AnalysisDataService and a...
Poco::NObserver< WorkspaceMultiSelector, Mantid::API::ClearADSNotification > m_clearObserver
Poco::NObserver< WorkspaceMultiSelector, Mantid::API::WorkspacePostDeleteNotification > m_remObserver
Poco::NObserver< WorkspaceMultiSelector, Mantid::API::WorkspaceAddNotification > m_addObserver
Poco Observers for ADS Notifications.
Poco::NObserver< WorkspaceMultiSelector, Mantid::API::WorkspaceAfterReplaceNotification > m_replaceObserver
Poco::NObserver< WorkspaceMultiSelector, Mantid::API::WorkspaceRenameNotification > m_renameObserver
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::AfterReplaceNotification > & WorkspaceAfterReplaceNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::ClearNotification > & ClearADSNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::RenameNotification > & WorkspaceRenameNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::AddNotification > & WorkspaceAddNotification_ptr
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::PostDeleteNotification > & WorkspacePostDeleteNotification_ptr