1 // Copyright (C) 2009-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "BL_Summary.hxx"
21 #include "BL_Traces.hxx"
23 #include <QFormLayout>
25 #include <QStandardItemModel>
27 BL::Summary::Summary(QWidget *parent, BL::JobsManager_QT * jobs_manager) : QWidget(parent)
29 DEBTRACE("Creating BL::Summary");
31 BL_ASSERT(jobs_manager);
33 _jobs_manager = jobs_manager;
37 QLabel * summary_jobs = new QLabel("Jobs Summary:");
38 QLabel * total_label = new QLabel("Number of jobs:");
39 _total_line = new QLabel;
40 _total_line->setText("0");
42 QLabel * created_label = new QLabel("Number of created jobs:");
43 _created_line = new QLabel;
44 _created_line->setText("0");
46 QLabel * queued_label = new QLabel("Number of queued jobs:");
47 _queued_line = new QLabel;
48 _queued_line->setText("0");
50 QLabel * running_label = new QLabel("Number of running jobs:");
51 _running_line = new QLabel;
52 _running_line->setText("0");
54 QLabel * finished_label = new QLabel("Number of finished jobs:");
55 _finished_line = new QLabel;
56 _finished_line->setText("0");
58 QFormLayout *mainLayout = new QFormLayout;
59 mainLayout->insertRow(0, summary_jobs);
60 mainLayout->insertRow(1, total_label, _total_line);
61 mainLayout->insertRow(2, created_label, _created_line);
62 mainLayout->insertRow(3, queued_label, _queued_line);
63 mainLayout->insertRow(4, running_label, _running_line);
64 mainLayout->insertRow(5, finished_label, _finished_line);
65 setLayout(mainLayout);
68 BL::Summary::~Summary()
70 DEBTRACE("Destroying BL::Summary");
74 BL::Summary::setModel(QStandardItemModel * model)
76 DEBTRACE("Call setModel BL::Summary");
83 BL::Summary::rowsInserted(const QModelIndex & parent, int start, int end)
85 DEBTRACE("BL::Summary::rowsInserted slot");
90 BL::Summary::rowsRemoved(const QModelIndex & parent, int start, int end)
92 DEBTRACE("BL::Summary::rowsRemoved slot");
97 BL::Summary::itemChanged(QStandardItem * item)
103 BL::Summary::updateJobs()
106 QVariant row_number = _model->rowCount();
107 _total_line->setText(row_number.toString());
110 _created_line->setText("0");
111 _queued_line->setText("0");
112 _running_line->setText("0");
113 _finished_line->setText("0");
115 int created_jobs = 0;
117 int running_jobs = 0;
118 int finished_jobs = 0;
119 std::map<std::string, BL::Job *> jobs = _jobs_manager->getJobs();
120 std::map<std::string, BL::Job *>::iterator jobs_it;
121 jobs_it = jobs.begin();
122 for(; jobs_it != jobs.end(); jobs_it++)
124 BL::Job * job = jobs_it->second;
125 BL::Job::State job_state = job->getState();
126 if (job_state == BL::Job::CREATED)
128 if (job_state == BL::Job::QUEUED)
130 if (job_state == BL::Job::RUNNING)
132 if (job_state == BL::Job::FINISHED)
137 _created_line->setText(QVariant(created_jobs).toString());
138 _queued_line->setText(QVariant(queued_jobs).toString());
139 _running_line->setText(QVariant(running_jobs).toString());
140 _finished_line->setText(QVariant(finished_jobs).toString());