BornAgain  1.19.79
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/View/Job/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_VIEW_JOB_JOBLISTVIEWDELEGATE_H
16 #define BORNAGAIN_GUI_VIEW_JOB_JOBLISTVIEWDELEGATE_H
17 
18 #include <QItemDelegate>
19 #include <QMap>
20 #include <QRect>
21 
22 class JobItem;
23 enum class JobStatus;
24 
25 //! ViewDelegate to show progress bar JobQueuListView
26 class JobListViewDelegate : public QItemDelegate {
27  Q_OBJECT
28 public:
29  JobListViewDelegate(QWidget* parent);
30 
31  void paint(QPainter* painter, const QStyleOptionViewItem& option,
32  const QModelIndex& index) const override;
33 
34  bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
35  const QModelIndex& index) override;
36 
37 signals:
38  void cancelButtonClicked(const QModelIndex& index);
39 
40 private:
41  QStyle::State m_buttonState;
42  void drawCustomProjectBar(const JobItem* item, QPainter* painter,
43  const QStyleOptionViewItem& option) const;
44 
45  QRect getTextRect(QRect optionRect) const;
46  QRect getProgressBarRect(QRect optionRect) const;
47  QRect getButtonRect(QRect optionRect) const;
48 
49  QMap<JobStatus, QColor> m_status_to_color;
50 };
51 
52 #endif // BORNAGAIN_GUI_VIEW_JOB_JOBLISTVIEWDELEGATE_H
JobStatus
The JobStatus enum lists the possible states of a job.
Definition: JobStatus.h:22
ViewDelegate to show progress bar JobQueuListView.
JobListViewDelegate(QWidget *parent)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
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< JobStatus, QColor > m_status_to_color
void drawCustomProjectBar(const JobItem *item, QPainter *painter, const QStyleOptionViewItem &option) const