BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
itemstreeview.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/view/mvvm/widgets/itemstreeview.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_MVVM_VIEW_MVVM_WIDGETS_ITEMSTREEVIEW_H
16 #define BORNAGAIN_MVVM_VIEW_MVVM_WIDGETS_ITEMSTREEVIEW_H
17 
18 #include "mvvm/view_export.h"
19 #include <QWidget>
20 #include <memory>
21 
22 class QTreeView;
23 class QItemSelection;
24 class QItemSelectionModel;
25 
26 namespace ModelView {
27 
28 class SessionItem;
29 class ViewModel;
30 class ViewModelDelegate;
31 
32 //! Tree view to show items of SessionModel via ViewModel mechanism.
33 //! Provides notification mechanism for SessionItem selections, use custom delegate.
34 
35 class MVVM_VIEW_EXPORT ItemsTreeView : public QWidget {
36  Q_OBJECT
37 
38 public:
39  explicit ItemsTreeView(QWidget* parent = nullptr);
40  ~ItemsTreeView() override;
41 
42  QTreeView* treeView();
43 
44  void setViewModel(std::unique_ptr<ViewModel> viewModel);
45 
46  void setViewModelDelegate(std::unique_ptr<ViewModelDelegate> delegate);
47 
48  void setSelected(SessionItem* item);
49 
50  void setRootSessionItem(SessionItem* item);
51 
52  ViewModel* viewModel() const;
53 
54 signals:
56 
57 private slots:
58  void onSelectionChanged(const QItemSelection&, const QItemSelection&);
59 
60 private:
61  QItemSelectionModel* selectionModel();
62 
63  void set_connected(bool flag);
64 
65  QTreeView* m_treeView{nullptr};
66  std::unique_ptr<ViewModel> m_viewModel;
67  std::unique_ptr<ViewModelDelegate> m_delegate;
69 };
70 
71 } // namespace ModelView
72 
73 #endif // BORNAGAIN_MVVM_VIEW_MVVM_WIDGETS_ITEMSTREEVIEW_H
Tree view to show items of SessionModel via ViewModel mechanism.
Definition: itemstreeview.h:35
std::unique_ptr< ViewModelDelegate > m_delegate
Definition: itemstreeview.h:67
std::unique_ptr< ViewModel > m_viewModel
Definition: itemstreeview.h:66
void itemSelected(ModelView::SessionItem *)
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
Main class to represent content of SessionModel in Qt's trees and tables.
Definition: viewmodel.h:29
materialitems.h Collection of materials to populate MaterialModel.