BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
gui2::ImportDataEditorActions Class Reference

Actions for ImportDataEditor. More...

Inheritance diagram for gui2::ImportDataEditorActions:
[legend]
Collaboration diagram for gui2::ImportDataEditorActions:
[legend]

Public Slots

void onAddCanvas ()
 Create new canvas and append it to the end of canvas container. More...
 
void onDeleteItem ()
 Delete currently selected items. More...
 
void onImportDialogRequest ()
 
void onMergeCanvases ()
 Merge selected canvases. All graphs will appear below canvas selected first. More...
 
void onRedo ()
 
void onUndo ()
 

Signals

void invokeImportDialogRequest ()
 

Public Member Functions

 ImportDataEditorActions (ExperimentalDataModel *model, QObject *parent=nullptr)
 
bool isUndoEnabled () const
 
void setSelectionModel (DataSelectionModel *selection_model)
 

Private Slots

void onSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 Processes changed selection. More...
 

Private Member Functions

ModelView::UndoStackInterfaceundoStack () const
 

Private Attributes

ExperimentalDataModelm_dataModel {nullptr}
 
DataSelectionModelm_selectionModel {nullptr}
 

Detailed Description

Actions for ImportDataEditor.

Definition at line 34 of file importdataeditoractions.h.

Constructor & Destructor Documentation

◆ ImportDataEditorActions()

gui2::ImportDataEditorActions::ImportDataEditorActions ( ExperimentalDataModel model,
QObject *  parent = nullptr 
)

Definition at line 37 of file importdataeditoractions.cpp.

38  : QObject(parent), m_dataModel(model)
39 {
40 }
ExperimentalDataModel * m_dataModel

Member Function Documentation

◆ invokeImportDialogRequest

void gui2::ImportDataEditorActions::invokeImportDialogRequest ( )
signal

◆ isUndoEnabled()

bool gui2::ImportDataEditorActions::isUndoEnabled ( ) const

Definition at line 55 of file importdataeditoractions.cpp.

56 {
57  return m_dataModel->undoStack() != nullptr;
58 }
UndoStackInterface * undoStack() const
Returns command stack to perform undo/redo.

References m_dataModel, and ModelView::SessionModel::undoStack().

Referenced by gui2::ImportDataEditorToolBar::ImportDataEditorToolBar(), onDeleteItem(), onImportDialogRequest(), onMergeCanvases(), onRedo(), and onUndo().

Here is the call graph for this function:

◆ onAddCanvas

void gui2::ImportDataEditorActions::onAddCanvas ( )
slot

Create new canvas and append it to the end of canvas container.

Definition at line 62 of file importdataeditoractions.cpp.

63 {
65 }

References gui2::ExperimentalDataModel::addCanvas(), and m_dataModel.

Referenced by gui2::ImportDataEditorToolBar::ImportDataEditorToolBar().

Here is the call graph for this function:

◆ onDeleteItem

void gui2::ImportDataEditorActions::onDeleteItem ( )
slot

Delete currently selected items.

Definition at line 82 of file importdataeditoractions.cpp.

83 {
84  if (isUndoEnabled())
85  undoStack()->beginMacro("onDeleteItem");
86 
87  for (auto canvas : m_selectionModel->selectedCanvas())
88  m_dataModel->removeCanvas(*canvas);
89 
90  for (auto graph : m_selectionModel->selectedGraphs())
91  m_dataModel->removeGraph(*graph);
92 
93  if (isUndoEnabled())
94  undoStack()->endMacro();
95 }
virtual void beginMacro(const std::string &name)=0
std::vector< CanvasItem * > selectedCanvas() const
Returns vector of currently slected canvas.
std::vector< ModelView::GraphItem * > selectedGraphs() const
void removeCanvas(CanvasItem &canvas)
Remove canvas with all its graphs.
void removeGraph(ModelView::GraphItem &graph)
Remove graph from the model. Underlying DataItem will be removed too.
ModelView::UndoStackInterface * undoStack() const

References ModelView::UndoStackInterface::beginMacro(), ModelView::UndoStackInterface::endMacro(), isUndoEnabled(), m_dataModel, m_selectionModel, gui2::ExperimentalDataModel::removeCanvas(), gui2::ExperimentalDataModel::removeGraph(), gui2::DataSelectionModel::selectedCanvas(), gui2::DataSelectionModel::selectedGraphs(), and undoStack().

Referenced by gui2::ImportDataEditorToolBar::ImportDataEditorToolBar().

Here is the call graph for this function:

◆ onImportDialogRequest

void gui2::ImportDataEditorActions::onImportDialogRequest ( )
slot

Definition at line 113 of file importdataeditoractions.cpp.

114 {
115  if (isUndoEnabled())
116  undoStack()->beginMacro("onImportDialogRequest");
117 
119 
120  if (isUndoEnabled())
121  undoStack()->endMacro();
122 }

References ModelView::UndoStackInterface::beginMacro(), ModelView::UndoStackInterface::endMacro(), invokeImportDialogRequest(), isUndoEnabled(), and undoStack().

Referenced by gui2::ImportDataEditorToolBar::ImportDataEditorToolBar().

Here is the call graph for this function:

◆ onMergeCanvases

void gui2::ImportDataEditorActions::onMergeCanvases ( )
slot

Merge selected canvases. All graphs will appear below canvas selected first.

Definition at line 69 of file importdataeditoractions.cpp.

70 {
71  if (isUndoEnabled())
72  undoStack()->beginMacro("onMergeCanvases");
73 
75 
76  if (isUndoEnabled())
77  undoStack()->endMacro();
78 }
void mergeCanvases(const std::vector< CanvasItem * > &canvases)
Merge canvas from the vector.

References ModelView::UndoStackInterface::beginMacro(), ModelView::UndoStackInterface::endMacro(), isUndoEnabled(), m_dataModel, m_selectionModel, gui2::ExperimentalDataModel::mergeCanvases(), gui2::DataSelectionModel::selectedCanvas(), and undoStack().

Referenced by gui2::ImportDataEditorToolBar::ImportDataEditorToolBar().

Here is the call graph for this function:

◆ onRedo

void gui2::ImportDataEditorActions::onRedo ( )
slot

Definition at line 105 of file importdataeditoractions.cpp.

106 {
107  if (!isUndoEnabled())
108  return;
109 
110  m_dataModel->undoStack()->redo();
111 }

References isUndoEnabled(), m_dataModel, ModelView::UndoStackInterface::redo(), and ModelView::SessionModel::undoStack().

Referenced by gui2::ImportDataEditorToolBar::ImportDataEditorToolBar().

Here is the call graph for this function:

◆ onSelectionChanged

void gui2::ImportDataEditorActions::onSelectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
privateslot

Processes changed selection.

Will change line style of selected graph from solid to dashed line.

Definition at line 127 of file importdataeditoractions.cpp.

129 {
130  auto selected_graphs = itemsFromIndexList<ModelView::GraphItem>(selected.indexes());
131  for (auto graph : selected_graphs)
132  graph->penItem()->setSelected(true);
133 
134  auto deselected_graphs = itemsFromIndexList<ModelView::GraphItem>(deselected.indexes());
135  for (auto graph : deselected_graphs)
136  graph->penItem()->setSelected(false);
137 }

Referenced by setSelectionModel().

◆ onUndo

void gui2::ImportDataEditorActions::onUndo ( )
slot

Definition at line 97 of file importdataeditoractions.cpp.

98 {
99  if (!isUndoEnabled())
100  return;
101 
102  m_dataModel->undoStack()->undo();
103 }

References isUndoEnabled(), m_dataModel, ModelView::UndoStackInterface::undo(), and ModelView::SessionModel::undoStack().

Referenced by gui2::ImportDataEditorToolBar::ImportDataEditorToolBar().

Here is the call graph for this function:

◆ setSelectionModel()

void gui2::ImportDataEditorActions::setSelectionModel ( DataSelectionModel selection_model)

Definition at line 42 of file importdataeditoractions.cpp.

43 {
44  if (m_selectionModel)
45  disconnect(m_selectionModel, &DataSelectionModel::selectionChanged, this,
47 
48  m_selectionModel = selection_model;
49 
50  if (m_selectionModel)
51  connect(m_selectionModel, &DataSelectionModel::selectionChanged, this,
53 }
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Processes changed selection.

References m_selectionModel, and onSelectionChanged().

Referenced by gui2::ImportDataEditor::ImportDataEditor().

Here is the call graph for this function:

◆ undoStack()

ModelView::UndoStackInterface * gui2::ImportDataEditorActions::undoStack ( ) const
private

Definition at line 139 of file importdataeditoractions.cpp.

140 {
141  return m_dataModel->undoStack();
142 }

References m_dataModel, and ModelView::SessionModel::undoStack().

Referenced by onDeleteItem(), onImportDialogRequest(), and onMergeCanvases().

Here is the call graph for this function:

Member Data Documentation

◆ m_dataModel

ExperimentalDataModel* gui2::ImportDataEditorActions::m_dataModel {nullptr}
private

◆ m_selectionModel

DataSelectionModel* gui2::ImportDataEditorActions::m_selectionModel {nullptr}
private

Definition at line 62 of file importdataeditoractions.h.

Referenced by onDeleteItem(), onMergeCanvases(), and setSelectionModel().


The documentation for this class was generated from the following files: