BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MultiComboPropertyEditor.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/PropertyEditor/MultiComboPropertyEditor.h
6 //! @brief Defines MultiComboPropertyEditor 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 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_PROPERTYEDITOR_MULTICOMBOPROPERTYEDITOR_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_PROPERTYEDITOR_MULTICOMBOPROPERTYEDITOR_H
17 
19 #include <QStyledItemDelegate>
20 #include <memory>
21 
22 class QStandardItemModel;
23 class QModelIndex;
24 class QStyleOptionViewItem;
25 
26 //! Provides custom editor for ComboProperty with multi-select option.
27 
29  Q_OBJECT
30 public:
31  explicit MultiComboPropertyEditor(QWidget* parent = nullptr);
32 
33  QSize sizeHint() const;
34  QSize minimumSizeHint() const;
35 
36 protected slots:
37  void onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&);
38 
39  void onClickedList(const QModelIndex& index);
40 
41 protected:
42  void initEditor();
43 
44 private:
45  bool eventFilter(QObject* obj, QEvent* event);
46  void setConnected(bool isConnected);
47  void updateBoxLabel();
48 
49  bool isClickToSelect(QObject* obj, QEvent* event) const;
50  bool isClickToExpand(QObject* obj, QEvent* event) const;
51 
52  QComboBox* m_box;
54  QStandardItemModel* m_model;
55 };
56 
57 //! Provides custom style delegate for QComboBox to allow checkboxes.
58 
59 class QCheckListStyledItemDelegate : public QStyledItemDelegate {
60 public:
61  QCheckListStyledItemDelegate(QObject* parent = nullptr);
62 
63  void paint(QPainter* painter, const QStyleOptionViewItem& option,
64  const QModelIndex& index) const;
65 };
66 
67 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_PROPERTYEDITOR_MULTICOMBOPROPERTYEDITOR_H
Defines CustomEditors classes.
Base class for all custom variants editors.
Definition: CustomEditors.h:28
Provides custom editor for ComboProperty with multi-select option.
MultiComboPropertyEditor(QWidget *parent=nullptr)
void onModelDataChanged(const QModelIndex &, const QModelIndex &, const QVector< int > &)
Propagate check state from the model to ComboProperty.
bool isClickToExpand(QObject *obj, QEvent *event) const
void updateBoxLabel()
Update text on QComboBox with the label provided by combo property.
void onClickedList(const QModelIndex &index)
Processes press event in QComboBox's underlying list view.
bool isClickToSelect(QObject *obj, QEvent *event) const
bool eventFilter(QObject *obj, QEvent *event)
Handles mouse clicks on QComboBox elements.
class WheelEventEater * m_wheel_event_filter
void initEditor()
Inits editor widgets from m_data.
void setConnected(bool isConnected)
Provides custom style delegate for QComboBox to allow checkboxes.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
QCheckListStyledItemDelegate(QObject *parent=nullptr)
Event filter to install on combo boxes and spin boxes to not to react on wheel events during scrollin...