BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
JobListViewDelegate.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/JobWidgets/JobListViewDelegate.h
6 //! @brief Defines class JobListViewDelegate
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_JOBWIDGETS_JOBLISTVIEWDELEGATE_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_JOBLISTVIEWDELEGATE_H
17 
18 #include <QItemDelegate>
19 #include <QMap>
20 #include <QRect>
21 
22 class JobItem;
23 
24 //! ViewDelegate to show progress bar JobQueuListView
25 class JobListViewDelegate : public QItemDelegate {
26  Q_OBJECT
27 public:
28  JobListViewDelegate(QWidget* parent);
29 
30  void paint(QPainter* painter, const QStyleOptionViewItem& option,
31  const QModelIndex& index) const;
32 
33  bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
34  const QModelIndex& index);
35 
36 signals:
37  void cancelButtonClicked(const QModelIndex& index);
38 
39 private:
40  QStyle::State m_buttonState;
41  void drawCustomProjectBar(const JobItem* item, QPainter* painter,
42  const QStyleOptionViewItem& option) const;
43 
44  QRect getTextRect(QRect optionRect) const;
45  QRect getProgressBarRect(QRect optionRect) const;
46  QRect getButtonRect(QRect optionRect) const;
47 
48  QMap<QString, QColor> m_status_to_color;
49 };
50 
51 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_JOBLISTVIEWDELEGATE_H
ViewDelegate to show progress bar JobQueuListView.
JobListViewDelegate(QWidget *parent)
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
void cancelButtonClicked(const QModelIndex &index)
QRect getProgressBarRect(QRect optionRect) const
returns rectangle for progress bar
QStyle::State m_buttonState
QRect getTextRect(QRect optionRect) const
returns rectangle for text
QRect getButtonRect(QRect optionRect) const
returns rectangle for button
QMap< QString, QColor > m_status_to_color
void drawCustomProjectBar(const JobItem *item, QPainter *painter, const QStyleOptionViewItem &option) const