Mantid
Loading...
Searching...
No Matches
FitScriptGeneratorDataTable.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2020 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
12#include <string>
13#include <vector>
14
15#include <QEvent>
16#include <QModelIndex>
17#include <QObject>
18#include <QPainter>
19#include <QPersistentModelIndex>
20#include <QString>
21#include <QStyleOptionViewItem>
22#include <QStyledItemDelegate>
23#include <QTableWidget>
24#include <QTableWidgetItem>
25
26namespace MantidQt {
27namespace MantidWidgets {
28
38 Q_OBJECT
39
40public:
41 enum ColumnIndex { WorkspaceName = 0, WorkspaceIndex = 1, StartX = 2, EndX = 3 };
42
43 FitScriptGeneratorDataTable(QWidget *parent = nullptr);
45
46 [[nodiscard]] std::string workspaceName(FitDomainIndex row) const;
47 [[nodiscard]] MantidWidgets::WorkspaceIndex workspaceIndex(FitDomainIndex row) const;
48 [[nodiscard]] double startX(FitDomainIndex row) const;
49 [[nodiscard]] double endX(FitDomainIndex row) const;
50
51 [[nodiscard]] std::vector<FitDomainIndex> allRows() const;
52 [[nodiscard]] std::vector<FitDomainIndex> selectedRows() const;
53 [[nodiscard]] FitDomainIndex currentRow() const;
54
55 [[nodiscard]] bool hasLoadedData() const;
56
57 [[nodiscard]] QString selectedDomainFunctionPrefix() const;
58
59 void renameWorkspace(QString const &workspaceName, QString const &newName);
60
61 void removeDomain(MantidWidgets::FitDomainIndex domainIndex);
62 void addDomain(QString const &workspaceName, MantidWidgets::WorkspaceIndex workspaceIndex, double startX,
63 double endX);
64
65 void formatSelection();
66 void resetSelection();
67
68 void setFunctionPrefixVisible(bool visible);
69
70signals:
71 void itemExited(int newRowIndex);
72
73private slots:
74 void handleItemClicked(QTableWidgetItem *item);
75 void handleItemSelectionChanged();
76
77private:
78 bool eventFilter(QObject *widget, QEvent *event) override;
79 QPersistentModelIndex hoveredRowIndex(QEvent *event);
80
81 void updateVerticalHeaders();
82
83 QString getText(FitDomainIndex row, int column) const;
84
85 void setSelectedXValue(double xValue);
86
87 std::vector<FitDomainIndex> m_selectedRows;
90 QPersistentModelIndex m_lastHoveredIndex;
91};
92
94
100class CustomItemDelegate : public QStyledItemDelegate {
101 Q_OBJECT
102
103public:
105
106private slots:
107 void handleItemEntered(QTableWidgetItem *item);
108 void handleItemExited(int newRowIndex);
109
110private:
111 QWidget *createEditor(QWidget *parent, QStyleOptionViewItem const &option, QModelIndex const &index) const override;
112 void paint(QPainter *painter, QStyleOptionViewItem const &option, QModelIndex const &index) const override;
113
117};
118
119} // namespace MantidWidgets
120} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
This class is used for formating the type of data allowed in each of the tables columns.
QWidget * createEditor(QWidget *parent, QStyleOptionViewItem const &option, QModelIndex const &index) const override
void paint(QPainter *painter, QStyleOptionViewItem const &option, QModelIndex const &index) const override
This class represents the table widget which holds domain data for the FitScriptGenerator interface.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
void renameWorkspace(const IAlgorithm_sptr &renamer, const Workspace_sptr &workspace, const std::string &newName)