BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ItemViewOverlayButtons.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Common/ItemViewOverlayButtons.h
6 //! @brief Defines class ItemViewOverlayButtons
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_VIEW_COMMON_ITEMVIEWOVERLAYBUTTONS_H
16 #define BORNAGAIN_GUI_VIEW_COMMON_ITEMVIEWOVERLAYBUTTONS_H
17 
18 #include <QObject>
19 #include <functional>
20 
21 class QAction;
22 class QAbstractItemView;
23 
24 class ItemViewOverlayButtons : public QObject {
25  Q_OBJECT
26 public:
27  using FnGetActions = std::function<QList<QAction*>(const QModelIndex&, bool)>;
28 
29  static void install(QAbstractItemView* view, FnGetActions fnGetActions);
30 
31 protected:
32  bool eventFilter(QObject* obj, QEvent* event) override;
33 
34 private:
35  ItemViewOverlayButtons(QObject* parent);
36  void updateRecursive(const QModelIndex& index);
37  void update();
38  void installOverlay(const QModelIndex& index);
39 
41  QAbstractItemView* m_view;
42 };
43 
44 
45 #endif // BORNAGAIN_GUI_VIEW_COMMON_ITEMVIEWOVERLAYBUTTONS_H
void updateRecursive(const QModelIndex &index)
bool eventFilter(QObject *obj, QEvent *event) override
static void install(QAbstractItemView *view, FnGetActions fnGetActions)
std::function< QList< QAction * >(const QModelIndex &, bool)> FnGetActions
ItemViewOverlayButtons(QObject *parent)
QAbstractItemView * m_view
void installOverlay(const QModelIndex &index)