28 template <
typename T> std::vector<T*> itemsFromIndexList(
const QModelIndexList& indices)
38 : QObject(parent), m_dataModel(model)
128 const QItemSelection& deselected)
130 auto selected_graphs = itemsFromIndexList<ModelView::GraphItem>(selected.indexes());
131 for (
auto graph : selected_graphs)
132 graph->penItem()->setSelected(
true);
134 auto deselected_graphs = itemsFromIndexList<ModelView::GraphItem>(deselected.indexes());
135 for (
auto graph : deselected_graphs)
136 graph->penItem()->setSelected(
false);
UndoStackInterface * undoStack() const
Returns command stack to perform undo/redo.
Interface class for undo/redo stack.
virtual void beginMacro(const std::string &name)=0
virtual void endMacro()=0
Custom selection model for data view model (AbstractViewModel).
std::vector< CanvasItem * > selectedCanvas() const
Returns vector of currently slected canvas.
std::vector< ModelView::GraphItem * > selectedGraphs() const
The model to store imported reflectometry data.
void removeCanvas(CanvasItem &canvas)
Remove canvas with all its graphs.
void mergeCanvases(const std::vector< CanvasItem * > &canvases)
Merge canvas from the vector.
void removeGraph(ModelView::GraphItem &graph)
Remove graph from the model. Underlying DataItem will be removed too.
DataSelectionModel * m_selectionModel
ModelView::UndoStackInterface * undoStack() const
bool isUndoEnabled() const
void setSelectionModel(DataSelectionModel *selection_model)
ImportDataEditorActions(ExperimentalDataModel *model, QObject *parent=nullptr)
void onAddCanvas()
Create new canvas and append it to the end of canvas container.
void onImportDialogRequest()
ExperimentalDataModel * m_dataModel
void invokeImportDialogRequest()
void onDeleteItem()
Delete currently selected items.
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Processes changed selection.
void onMergeCanvases()
Merge selected canvases. All graphs will appear below canvas selected first.
MVVM_VIEWMODEL_EXPORT std::vector< SessionItem * > UniqueItemsFromIndex(const QModelIndexList &index_list)
Returns vector of underlying SessionItem's for given index list. Removes repetitions.
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.