1 #ifndef JOBLISTWIDGET_H
2 #define JOBLISTWIDGET_H
3 
4 #include "joblistwidgetitem.h"
5 #include "persistentmodel/job.h"
6 
7 #include <QListWidget>
8 
9 /*!
10  * \ingroup widgets-specialized
11  * \brief The JobListWidget is a QListWidget which displays
12  * information about all jobs.
13  */
14 class JobListWidget : public QListWidget
15 {
16     Q_OBJECT
17 
18 public:
19     //! Constructor.
20     explicit JobListWidget(QWidget *parent = nullptr);
21     ~JobListWidget();
22 
23 public slots:
24     //! Clears the job list, then sets it to the specified jobs.
25     void setJobs(QMap<QString, JobPtr> jobs);
26     //! Create new archives for the selected jobs.
27     void backupSelectedItems();
28     //! Sets the current selection in the list view.
29     void selectJob(JobPtr job);
30     //! Display detailed information about a specific job.
31     //! \param jobRef: the name of the job to inspect.
32     void inspectJobByRef(QString jobRef);
33     //! Create new archives for all jobs.
34     void backupAllJobs();
35     //! Add a new job to the list.
36     void addJob(JobPtr job);
37     //! Display detailed information about the first of the selected items.
38     void inspectSelectedItem();
39     //! Restore the first of the selected jobs.
40     void restoreSelectedItem();
41     //! Delete the selected job.
42     void deleteSelectedItem();
43     //! Filter the list of jobs.
44     void setFilter(QString regex);
45 
46 signals:
47     //! Notify that the job details should be displayed.
48     void displayJobDetails(JobPtr job);
49     //! Notify that a new archive should be created for a specific job.
50     void backupJob(JobPtr job);
51     //! Notify that the specified archive should be restored,
52     //! using the user-selected options from the \ref RestoreDialog.
53     void restoreArchive(ArchivePtr archive, ArchiveRestoreOptions options);
54     //! Notify that the specified job (and possibly archives)
55     //! should be deleted.
56     //! \param job: the job to delete.
57     //! \param purgeArchives: if true, delete all archives belonging
58     //!        to this job.
59     void deleteJob(JobPtr job, bool purgeArchives);
60     //! Notify the total and visible (not hidden) items count on list change
61     //! (item added, removed or hidden).
62     void countChanged(int countTotal, int countVisible);
63 
64 protected:
65     //! Handles the delete and escape keys; passes other events on.
66     void keyPressEvent(QKeyEvent *event);
67 
68 private slots:
69     void backupItem();
70     void inspectItem();
71     void restoreItem();
72     void deleteItem();
73 
74 private:
75     void execDeleteJob(JobListWidgetItem *jobItem);
76     int  visibleItemsCount();
77 
78     QRegExp _filter;
79 };
80 
81 #endif // JOBLISTWIDGET_H
82