C++11 tidying.
[dcpomatic.git] / src / wx / batch_job_view.cc
1 /*
2     Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "batch_job_view.h"
23 #include "dcpomatic_button.h"
24 #include "lib/job_manager.h"
25 #include <wx/sizer.h>
26 #include <wx/button.h>
27
28
29 using std::list;
30 using std::shared_ptr;
31
32
33 BatchJobView::BatchJobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table)
34         : JobView (job, parent, container, table)
35 {
36
37 }
38
39
40 int
41 BatchJobView::insert_position () const
42 {
43         return _table->GetEffectiveRowsCount() * _table->GetEffectiveColsCount();
44 }
45
46
47 void
48 BatchJobView::finish_setup (wxWindow* parent, wxSizer* sizer)
49 {
50         _higher_priority = new Button (parent, _("Higher priority"));
51         _higher_priority->Bind (wxEVT_BUTTON, boost::bind(&BatchJobView::higher_priority_clicked, this));
52         sizer->Add (_higher_priority, 1, wxALIGN_CENTER_VERTICAL);
53         _lower_priority = new Button (parent, _("Lower priority"));
54         _lower_priority->Bind (wxEVT_BUTTON, boost::bind(&BatchJobView::lower_priority_clicked, this));
55         sizer->Add (_lower_priority, 1, wxALIGN_CENTER_VERTICAL);
56 }
57
58
59 void
60 BatchJobView::higher_priority_clicked ()
61 {
62         JobManager::instance()->increase_priority (_job);
63 }
64
65
66 void
67 BatchJobView::lower_priority_clicked ()
68 {
69         JobManager::instance()->decrease_priority (_job);
70 }
71
72
73 void
74 BatchJobView::job_list_changed ()
75 {
76         bool high = false;
77         bool low = false;
78         auto jobs = JobManager::instance()->get();
79         if (!jobs.empty()) {
80                 if (_job != jobs.front()) {
81                         high = true;
82                 }
83                 if (_job != jobs.back()) {
84                         low = true;
85                 }
86         }
87
88         _higher_priority->Enable (high);
89         _lower_priority->Enable (low);
90 }