Mantid
Loading...
Searching...
No Matches
QtStandardItemTreeAdapter.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
15
16#include <QSortFilterProxyModel>
17#include <QStandardItemModel>
18
19namespace MantidQt {
20namespace MantidWidgets {
21namespace Batch {
22
24public:
25 QtStandardItemTreeModelAdapter(QStandardItemModel &model, Cell emptyCellStyle);
26
27 QModelIndexForMainModel rootIndex() const;
28 std::vector<Cell> emptyRow(int columnCount) const;
29
30 std::vector<Cell> cellsAtRow(QModelIndexForMainModel const &firstCellIndex) const;
31 void setCellsAtRow(QModelIndexForMainModel const &rowIndex, std::vector<Cell> const &cells);
32
33 Cell cellFromCellIndex(QModelIndexForMainModel const &index) const;
34 void setCellAtCellIndex(QModelIndexForMainModel const &index, Cell const &newCellProperties);
35
36 QModelIndexForMainModel appendSiblingRow(QModelIndexForMainModel const &index, std::vector<Cell> const &cells);
37 QModelIndexForMainModel appendEmptySiblingRow(QModelIndexForMainModel const &index);
38
39 QModelIndexForMainModel appendChildRow(QModelIndexForMainModel const &parent, std::vector<Cell> const &cells);
40 QModelIndexForMainModel appendEmptyChildRow(QModelIndexForMainModel const &parent);
41
42 QModelIndexForMainModel insertChildRow(QModelIndexForMainModel const &parent, int row,
43 std::vector<Cell> const &cells);
44 QModelIndexForMainModel insertEmptyChildRow(QModelIndexForMainModel const &parent, int column);
45
46 void removeRowFrom(QModelIndexForMainModel const &index);
47
48 template <typename Action>
49 void enumerateCellsInRow(QModelIndexForMainModel const &startIndex, int columns, Action const &action) const;
50
51private:
52 QList<QStandardItem *> rowItemsFromCells(std::vector<Cell> const &cells);
53
54 QStandardItemModel &m_model;
56};
57
62template <typename Action>
64 Action const &action) const {
65 for (auto i = 0; i < columnCount; i++) {
66 auto cellIndex = startAtCell.sibling(startAtCell.row(), i);
67 action(cellIndex, i);
68 }
69}
70
71EXPORT_OPT_MANTIDQT_COMMON QStandardItem *modelItemFromIndex(QStandardItemModel &model,
73
74EXPORT_OPT_MANTIDQT_COMMON QStandardItem const *modelItemFromIndex(QStandardItemModel const &model,
76} // namespace Batch
77} // namespace MantidWidgets
78} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
void enumerateCellsInRow(QModelIndexForMainModel const &startIndex, int columns, Action const &action) const
Enumerates the first columnCount number of cells to the right of startAtCell, moving left to right.
EXPORT_OPT_MANTIDQT_COMMON QStandardItem * modelItemFromIndex(QStandardItemModel &model, QModelIndexForMainModel const &index)
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...