Mantid
Loading...
Searching...
No Matches
JobTreeView.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
11#pragma once
21#include <boost/optional.hpp>
22
23#include <QTreeView>
24
25namespace MantidQt {
26namespace MantidWidgets {
27namespace Batch {
28
29class EXPORT_OPT_MANTIDQT_COMMON JobTreeView : public QTreeView, public IJobTreeView {
30 Q_OBJECT
31public:
32 JobTreeView(QStringList const &columnHeadings, Cell const &defaultCellStyle, QWidget *parent = nullptr);
33
34 void filterRowsBy(std::unique_ptr<RowPredicate> predicate) override;
35 void filterRowsBy(RowPredicate *predicate) override;
36 void resetFilter() override;
37 bool hasFilter() const override;
38
39 void setHintsForColumn(int column, std::unique_ptr<HintStrategy> hintStrategy) override;
40 void setHintsForColumn(int column, HintStrategy *hintStrategy) override;
41
42 void subscribe(JobTreeViewSubscriber *subscriber) override;
43
44 RowLocation insertChildRowOf(RowLocation const &parent, int beforeRow, std::vector<Cell> const &rowText) override;
45 RowLocation insertChildRowOf(RowLocation const &parent, int beforeRow) override;
46 RowLocation appendChildRowOf(RowLocation const &parent) override;
47 RowLocation appendChildRowOf(RowLocation const &parentLocation, std::vector<Cell> const &rowText) override;
48 void appendAndEditAtChildRow() override;
49 void appendAndEditAtRowBelow() override;
50 void editAtRowAbove() override;
51
52 void removeRowAt(RowLocation const &location) override;
53 void removeAllRows() override;
54 void removeRows(std::vector<RowLocation> rowsToRemove) override;
55 bool isOnlyChildOfRoot(RowLocation const &location) const override;
56
57 void replaceRows(std::vector<RowLocation> replacementPoints, std::vector<Subtree> replacements) override;
58
59 void appendSubtreesAt(RowLocation const &parent, std::vector<Subtree> subtrees) override;
60 void appendSubtreeAt(RowLocation const &parent, Subtree const &subtree) override;
61
62 void replaceSubtreeAt(RowLocation const &rootToRemove, Subtree const &toInsert) override;
63 void insertSubtreeAt(RowLocation const &parent, int index, Subtree const &subtree) override;
64
65 std::vector<Cell> cellsAt(RowLocation const &location) const override;
66 void setCellsAt(RowLocation const &location, std::vector<Cell> const &rowText) override;
67
68 Cell cellAt(RowLocation location, int column) const override;
69 void setCellAt(RowLocation location, int column, Cell const &cellText) override;
70
71 void clearSelection() override;
72 void expandAll() override;
73 void collapseAll() override;
74
75 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
76 std::vector<RowLocation> selectedRowLocations() const override;
77 boost::optional<std::vector<Subtree>> selectedSubtrees() const override;
78 boost::optional<std::vector<RowLocation>> selectedSubtreeRoots() const override;
79
80 bool hasNoSelectedDescendants(QModelIndex const &index) const;
81 void appendAllUnselectedDescendants(QModelIndexList &selectedRows, QModelIndex const &index) const;
82 QModelIndexList findImplicitlySelected(QModelIndexList const &selectedRows) const;
83
84 int currentColumn() const override;
85
86 Cell deadCell() const override;
87 using QTreeView::edit;
88
89protected:
90 void keyPressEvent(QKeyEvent *event) override;
91 bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event) override;
92 void setHeaderLabels(QStringList const &columnHeadings);
93 void appendAndEditAtChildRowRequested();
94 void appendAndEditAtRowBelowRequested();
95 void editAtRowAboveRequested();
96 void removeSelectedRequested();
97 void copySelectedRequested();
98 void cutSelectedRequested();
99 void pasteSelectedRequested();
100 void enableFiltering();
101
102protected slots:
103 void commitData(QWidget * /*editor*/) override;
104 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
105
106private:
107 // The view property values for an uneditable, unselectable cell.
108 static Cell const g_deadCell;
109
110 bool indexesAreOnSameRow(QModelIndex const &a, QModelIndex const &b) const;
111
112 QModelIndexForMainModel mapToMainModel(QModelIndexForFilteredModel const &filteredModelIndex) const;
113 QModelIndexForFilteredModel mapToFilteredModel(QModelIndexForMainModel const &mainModelIndex) const;
114
115 QModelIndexForMainModel fromMainModel(QModelIndex const &mainModelIndex) const;
116 QModelIndexForFilteredModel fromFilteredModel(QModelIndex const &filteredModelIndex) const;
117
118 bool isOnlyChild(QModelIndexForMainModel const &index) const;
119 bool isOnlyChildOfRoot(QModelIndexForMainModel const &index) const;
120 QModelIndex siblingIfExistsElseParent(QModelIndex const &index) const;
121 bool rowRemovalWouldBeIneffective(QModelIndexForMainModel const &indexToRemove) const;
122
123 bool isBeingEdited(QModelIndexForFilteredModel const &cellIndex) const;
124 bool isEditable(const QModelIndex &index) const;
125 void closeEditorIfOpenAtCell(QModelIndexForFilteredModel const &cellIndex);
126 void closeAnyOpenEditorsOnUneditableCells(QModelIndexForMainModel const &firstCellOnRow,
127 std::vector<Cell> const &cells);
128 void closeEditorIfCellIsUneditable(QModelIndexForMainModel const &cellIndex, Cell const &cell);
129
131 void editAt(QModelIndexForFilteredModel const &index);
132
133 QtTreeCursorNavigationResult moveNextUntilEditable(QModelIndex const &startingPoint);
134 QModelIndex movePreviousUntilEditable(QModelIndex const &startingPoint);
135 QModelIndex applyNavigationResult(QtTreeCursorNavigationResult const &result);
136 std::pair<QModelIndexForFilteredModel, bool> findOrMakeCellBelow(QModelIndexForFilteredModel const &index);
137 bool hasEditorOpen() const;
138
139 QtTreeCursorNavigation navigation() const;
140 RowLocationAdapter rowLocation() const;
141
143 QStandardItemModel m_mainModel;
145
149};
150} // namespace Batch
151} // namespace MantidWidgets
152} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
bool indexesAreOnSameRow(QModelIndex const &a, QModelIndex const &b) const
QtStandardItemTreeModelAdapter m_adaptedMainModel
Definition: JobTreeView.h:144
HintStrategy : Provides an interface for generating hints to be used by a HintingLineEdit.
Definition: HintStrategy.h:19
std::pair< bool, QModelIndex > QtTreeCursorNavigationResult
std::vector< Row > Subtree
Definition: Subtree.h:18
QModelIndexForMainModel fromMainModel(QModelIndex const &mainModelIndex, QAbstractItemModel const &model)
QModelIndexForFilteredModel fromFilteredModel(QModelIndex const &filteredModelIndex, QAbstractItemModel const &model)
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...