BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SessionModelView Class Reference

The SessionModelView is a technical view which shows the content all current application models. More...

Inheritance diagram for SessionModelView:
[legend]
Collaboration diagram for SessionModelView:
[legend]

Public Member Functions

 SessionModelView (MainWindow *mainWindow=0)
 
void setViewActive (bool is_active)
 

Private Slots

void onExpandCollapseTree ()
 

Private Member Functions

void init_tabs ()
 Creates content for tab widget. More...
 
void init_test_view ()
 
QList< SessionModel * > modelsForTabs ()
 Returns list of models to show in tabs. More...
 

Private Attributes

QVector< ModelTreeView * > m_content
 
SessionModelDelegatem_delegate
 
QToolButton * m_expandCollapseButton
 
MainWindowm_mainWindow
 
QTabWidget * m_tabs
 
QToolBar * m_toolBar
 

Detailed Description

The SessionModelView is a technical view which shows the content all current application models.

It appears as an additional view in the main navigation bar on the left, right after the jobView (if corresponding setting of MainWindow is On).

Definition at line 32 of file SessionModelView.h.

Constructor & Destructor Documentation

◆ SessionModelView()

SessionModelView::SessionModelView ( MainWindow mainWindow = 0)

Definition at line 33 of file SessionModelView.cpp.

34  : QWidget(mainWindow)
35  , m_mainWindow(mainWindow)
36  , m_toolBar(new QToolBar)
37  , m_tabs(new QTabWidget)
38  , m_expandCollapseButton(new QToolButton)
39  , m_delegate(new SessionModelDelegate(this))
40 {
41  auto layout = new QVBoxLayout;
42  layout->setMargin(0);
43  layout->setSpacing(0);
44 
45  m_expandCollapseButton->setText("Expand / collapse tree");
46  m_expandCollapseButton->setIcon(QIcon(":/images/toolbar_expand_collapse_tree.svg"));
47  m_expandCollapseButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
48  m_expandCollapseButton->setToolTip("Click to switch between expanded/collapsed tree view");
50  connect(m_expandCollapseButton, &QToolButton::clicked, this,
52 
53  layout->addWidget(m_toolBar);
54  layout->addWidget(m_tabs);
55  setLayout(layout);
56 
57  init_tabs();
58 
59  if (show_test_view)
61 }
The SessionModelDelegate class presents the content of SessionModel items in standard QTreeView.
SessionModelDelegate * m_delegate
QToolButton * m_expandCollapseButton
QTabWidget * m_tabs
QToolBar * m_toolBar
void init_tabs()
Creates content for tab widget.
MainWindow * m_mainWindow

References init_tabs(), init_test_view(), m_expandCollapseButton, m_tabs, m_toolBar, and onExpandCollapseTree().

Here is the call graph for this function:

Member Function Documentation

◆ init_tabs()

void SessionModelView::init_tabs ( )
private

Creates content for tab widget.

Definition at line 70 of file SessionModelView.cpp.

71 {
72  ASSERT(m_content.empty());
73 
74  for (auto model : modelsForTabs()) {
75  auto treeView = new ModelTreeView(this, model);
76  treeView->setItemDelegate(m_delegate);
77  m_tabs->addTab(treeView, treeView->objectName());
78  m_content.push_back(treeView);
79  }
80 }
#define ASSERT(condition)
Definition: Assert.h:31
Equivalent of QTreeView for SessionModel allowing to add visual decorations to the tree.
Definition: ModelTreeView.h:28
QList< SessionModel * > modelsForTabs()
Returns list of models to show in tabs.
QVector< ModelTreeView * > m_content

References ASSERT, m_content, m_delegate, m_tabs, and modelsForTabs().

Referenced by SessionModelView().

Here is the call graph for this function:

◆ init_test_view()

void SessionModelView::init_test_view ( )
private

Definition at line 93 of file SessionModelView.cpp.

94 {
95  auto view = new TestView(m_mainWindow);
96  int index = m_tabs->addTab(view, "Test View");
97  m_tabs->setCurrentIndex(index);
98 }

References m_mainWindow, and m_tabs.

Referenced by SessionModelView().

◆ modelsForTabs()

QList< SessionModel * > SessionModelView::modelsForTabs ( )
private

Returns list of models to show in tabs.

Definition at line 84 of file SessionModelView.cpp.

85 {
86  QList<SessionModel*> result = QList<SessionModel*>()
89  << m_mainWindow->jobModel();
90  return result;
91 }
InstrumentModel * instrumentModel()
Definition: mainwindow.cpp:139
SampleModel * sampleModel()
Definition: mainwindow.cpp:144
JobModel * jobModel()
Definition: mainwindow.cpp:154
MaterialModel * materialModel()
Definition: mainwindow.cpp:134
RealDataModel * realDataModel()
Definition: mainwindow.cpp:149

References MainWindow::instrumentModel(), MainWindow::jobModel(), m_mainWindow, MainWindow::materialModel(), MainWindow::realDataModel(), and MainWindow::sampleModel().

Referenced by init_tabs().

Here is the call graph for this function:

◆ onExpandCollapseTree

void SessionModelView::onExpandCollapseTree ( )
privateslot

Definition at line 63 of file SessionModelView.cpp.

64 {
65  m_content.at(m_tabs->currentIndex())->toggleExpanded();
66 }

References m_content, and m_tabs.

Referenced by SessionModelView().

◆ setViewActive()

void SessionModelView::setViewActive ( bool  is_active)

Member Data Documentation

◆ m_content

QVector<ModelTreeView*> SessionModelView::m_content
private

Definition at line 53 of file SessionModelView.h.

Referenced by init_tabs(), and onExpandCollapseTree().

◆ m_delegate

SessionModelDelegate* SessionModelView::m_delegate
private

Definition at line 52 of file SessionModelView.h.

Referenced by init_tabs().

◆ m_expandCollapseButton

QToolButton* SessionModelView::m_expandCollapseButton
private

Definition at line 51 of file SessionModelView.h.

Referenced by SessionModelView().

◆ m_mainWindow

MainWindow* SessionModelView::m_mainWindow
private

Definition at line 48 of file SessionModelView.h.

Referenced by init_test_view(), and modelsForTabs().

◆ m_tabs

QTabWidget* SessionModelView::m_tabs
private

◆ m_toolBar

QToolBar* SessionModelView::m_toolBar
private

Definition at line 49 of file SessionModelView.h.

Referenced by SessionModelView().


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