BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
selectablecomboboxeditor.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/viewmodel/mvvm/editors/selectablecomboboxeditor.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_VIEWMODEL_MVVM_EDITORS_SELECTABLECOMBOBOXEDITOR_H
16 #define BORNAGAIN_MVVM_VIEWMODEL_MVVM_EDITORS_SELECTABLECOMBOBOXEDITOR_H
17 
19 
20 class QComboBox;
21 class QStandardItemModel;
22 
23 namespace ModelView {
24 
25 class WheelEventFilter;
26 
27 //! Adds multi-selection capabilities to QComboBox.
28 
29 class MVVM_VIEWMODEL_EXPORT SelectableComboBoxEditor : public CustomEditor {
30  Q_OBJECT
31 
32 public:
33  explicit SelectableComboBoxEditor(QWidget* parent = nullptr);
34 
35  QSize sizeHint() const override;
36  QSize minimumSizeHint() const override;
37 
38  bool is_persistent() const override;
39 
40 protected slots:
41  void onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&);
42 
43  void onClickedList(const QModelIndex& index);
44 
45 protected:
46  void update_components() override;
47 
48 private:
49  bool eventFilter(QObject* obj, QEvent* event) override;
50  void setConnected(bool isConnected);
51  void updateBoxLabel();
52 
53  bool isClickToSelect(QObject* obj, QEvent* event) const;
54  bool isClickToExpand(QObject* obj, QEvent* event) const;
55 
56  QComboBox* m_box{nullptr};
57  WheelEventFilter* m_wheelEventFilter{nullptr};
58  QStandardItemModel* m_model{nullptr};
59 };
60 
61 } // namespace ModelView
62 
63 #endif // BORNAGAIN_MVVM_VIEWMODEL_MVVM_EDITORS_SELECTABLECOMBOBOXEDITOR_H
Base class for all custom variant editors.
Definition: customeditor.h:26
Adds multi-selection capabilities to QComboBox.
Event filter to install on combo boxes and spin boxes to ignore wheel events during scrolling.
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.